From 83bd6e6e8c012522563f45248e65ce9e7590ddbd Mon Sep 17 00:00:00 2001 From: Adam Zammit Date: Thu, 15 Mar 2018 15:08:42 +1100 Subject: [PATCH] Fixed issue: System sorting giving low priority where some quotas exist and not others Note: Default system sort order is: 1. Appointments 2. Defined priority by quotas 3. Sample sort order as defined by administrator 4. Time zone of respondent (later in the day for respondent called first) 5. Time of last call (call further in the past made first) --- admin/systemsortprocess.php | 2 +- functions/functions.operator.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/admin/systemsortprocess.php b/admin/systemsortprocess.php index 2ffa8d63..9eb90d7b 100644 --- a/admin/systemsortprocess.php +++ b/admin/systemsortprocess.php @@ -285,7 +285,7 @@ while (!is_process_killed($process_id)) //check if process killed every $sleepin AND ((apn.appointment_id IS NOT NULL) or qs.call_max = 0 or ((SELECT count(*) FROM `call` WHERE `call`.case_id = c.case_id) < qs.call_max)) 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 GROUP BY c.case_id - ORDER BY IF(ISNULL(apn.end),1,0),apn.end ASC, qsep.priority DESC, CONVERT_TZ(NOW(), 'System' , s.Time_zone_name) DESC , a.start ASC, qs.sort_order ASC"; + ORDER BY IF(ISNULL(apn.end),1,0),apn.end ASC, IFNULL(qsep.priority,50) DESC, qs.sort_order ASC, CONVERT_TZ(NOW(), 'System' , s.Time_zone_name) DESC , a.start ASC"; $rs = $db->GetAll($sql); diff --git a/functions/functions.operator.php b/functions/functions.operator.php index 3d42e5d9..c406deae 100644 --- a/functions/functions.operator.php +++ b/functions/functions.operator.php @@ -673,7 +673,7 @@ function get_case_id($operator_id, $create = false) 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 IF(ISNULL(apn.end),1,0),apn.end ASC, qsep.priority DESC, CONVERT_TZ(NOW(), 'System' , s.Time_zone_name) DESC , a.start ASC, qs.sort_order ASC + ORDER BY IF(ISNULL(apn.end),1,0),apn.end ASC, IFNULL(qsep.priority,50) DESC, qs.sort_order ASC, CONVERT_TZ(NOW(), 'System' , s.Time_zone_name) DESC , a.start ASC LIMIT 1"; //apn.appointment_id contains the id of an appointment if we are calling on an appointment