mirror of
https://github.com/ACSPRI/queXS
synced 2024-04-02 12:12:16 +00:00
New feature: Allow restricting appointment to just yourself
This commit is contained in:
@@ -77,18 +77,22 @@ function add_contact_phone($case_id,$phone)
|
||||
* @param int $y the year (4 digit)
|
||||
* @param string $start The time in the format HH:MM:SS
|
||||
* @param string $end The time in the format HH:MM:SS
|
||||
* @param string|int $require_operator_id False if for any operator otherwise restrict this appointment to a particular operator
|
||||
* @return bool Result false if failed to add else true
|
||||
*/
|
||||
function make_appointment($respondent_id,$case_id,$contact_phone_id,$call_attempt_id,$d,$m,$y,$start,$end)
|
||||
function make_appointment($respondent_id,$case_id,$contact_phone_id,$call_attempt_id,$d,$m,$y,$start,$end,$require_operator_id = false)
|
||||
{
|
||||
global $db;
|
||||
|
||||
$start = "$y-$m-$d $start";
|
||||
$end= "$y-$m-$d $end";
|
||||
|
||||
if ($require_operator_id == false)
|
||||
$require_operator_id = "NULL";
|
||||
|
||||
$sql = "INSERT INTO `appointment`
|
||||
(appointment_id,case_id,contact_phone_id,call_attempt_id,start,end,require_operator_id,respondent_id,completed_call_id)
|
||||
SELECT NULL,'$case_id','$contact_phone_id','$call_attempt_id',CONVERT_TZ('$start',r.Time_zone_name,'UTC'),CONVERT_TZ('$end',r.Time_zone_name,'UTC'),NULL,$respondent_id,NULL
|
||||
SELECT NULL,'$case_id','$contact_phone_id','$call_attempt_id',CONVERT_TZ('$start',r.Time_zone_name,'UTC'),CONVERT_TZ('$end',r.Time_zone_name,'UTC'),$require_operator_id,$respondent_id,NULL
|
||||
FROM respondent as r
|
||||
WHERE r.respondent_id = '$respondent_id'";
|
||||
|
||||
|
||||
@@ -382,13 +382,16 @@ function get_case_id($operator_id, $create = false)
|
||||
if ($systemsort)
|
||||
{
|
||||
//Just make sure that this case should go to this operator (assigned to this project and skill)
|
||||
//Also check if this is an exclusive appointment
|
||||
$sql = "SELECT c.case_id as caseid
|
||||
FROM `case` as c
|
||||
JOIN operator_questionnaire AS oq ON (oq.operator_id = '$operator_id' AND oq.questionnaire_id = c.questionnaire_id)
|
||||
JOIN outcome as ou ON (ou.outcome_id = c.current_outcome_id)
|
||||
JOIN operator_skill as os ON (os.operator_id = '$operator_id' AND os.outcome_type_id = ou.outcome_type_id)
|
||||
LEFT JOIN appointment as apn on (apn.case_id = c.case_id AND apn.completed_call_id is NULL AND (CONVERT_TZ(NOW(),'System','UTC') >= apn.start) AND (CONVERT_TZ(NOW(),'System','UTC') <= apn.end))
|
||||
WHERE c.sortorder IS NOT NULL
|
||||
AND c.current_operator_id IS NULL
|
||||
AND (apn.require_operator_id IS NULL OR apn.require_operator_id = '$operator_id')
|
||||
ORDER BY c.sortorder ASC
|
||||
LIMIT 1";
|
||||
|
||||
@@ -438,6 +441,7 @@ function get_case_id($operator_id, $create = false)
|
||||
AND !(si.call_restrict = 1 AND cr.day_of_week IS NULL AND os.outcome_type_id != 2)
|
||||
AND ((apn.appointment_id IS NOT NULL) or qs.call_attempt_max = 0 or ((SELECT count(*) FROM call_attempt WHERE case_id = c.case_id) < qs.call_attempt_max))
|
||||
AND ((apn.appointment_id IS NOT NULL) or qs.call_max = 0 or ((SELECT count(*) FROM `call` WHERE case_id = c.case_id) < qs.call_max))
|
||||
AND (apn.require_operator_id IS NULL OR apn.require_operator_id = '$operator_id')
|
||||
AND (SELECT count(*) FROM `questionnaire_sample_quota` WHERE questionnaire_id = c.questionnaire_id AND sample_import_id = s.import_id AND quota_reached = 1) = 0
|
||||
ORDER BY apn.start DESC, a.start ASC, qsep.priority DESC
|
||||
LIMIT 1";
|
||||
|
||||
Reference in New Issue
Block a user