From 23942b8939d02ab460ebc99a1c5fd3937c37f811 Mon Sep 17 00:00:00 2001 From: Adam Zammit Date: Mon, 10 Aug 2015 16:24:28 +1000 Subject: [PATCH] Fixes lp:1408870 Add "Maximum attempts reached" as an outcome Dev: Updated outcomes to be 4 new outcomes (max calls, max call attempts split by eligible, unknown eligibility) Dev: Set the end_case function to set the outcomes to max call * reached if those variables set Dev: Made sure outcomes are temporary outcomes as otherwise numbers will not be available again if max call limits changed Dev: This means the outcomes are indicators only and could still be assigned to operators - it is merely a temporary case outcome (not a final outcome nor a call outcome) --- CHANGELOG | 7 ++- admin/databasestrings.php | 7 +-- call_interface2.php | 4 +- database/quexs.sql | 7 ++- functions/functions.operator.php | 85 +++++++++++++++++++++++++------- locale/quexs.pot | 14 ++++-- nocaseavailable.php | 2 +- waitnextcase_interface2.php | 2 +- 8 files changed, 95 insertions(+), 33 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 03e09aaf..64bf664c 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -66,8 +66,11 @@ Database updates required: /* New outcomes */ -INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`) VALUES(42, '3.13', 'Max call attempts reached', 0, 1, 0, 1, 0, 1, 0, 'UH'); -INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`) VALUES(43, '3.13', 'Max calls reached', 0, 1, 0, 1, 0, 1, 0, 'UH'); +DELETE FROM `outcome` WHERE outcome_id IN (42,43,44,45); +INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`) VALUES(42, '3.90', 'Max call attempts reached (Unknown eligibility)', 0, 1, 0, 1, 1, 0, 0, 'UH'); +INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`) VALUES(43, '3.90', 'Max calls reached (Unknown eligibility)', 0, 1, 0, 1, 1, 0, 0, 'UH'); +INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`) VALUES(44, '2.30', 'Max call attempts reached (Eligible)', 0, 1, 0, 1, 1, 1, 0, 'O'); +INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`) VALUES(45, '2.30', 'Max calls reached (Eligible)', 0, 1, 0, 1, 1, 1, 0, 'O'); /* Add var_id sample var identifier */ diff --git a/admin/databasestrings.php b/admin/databasestrings.php index 68a34cc2..69152f4a 100755 --- a/admin/databasestrings.php +++ b/admin/databasestrings.php @@ -88,7 +88,8 @@ T_("Respondent last name"); T_("Email address"); T_("Self completion email invitation sent"); T_("Self completed online"); -T_("Max call attempts reached"); -T_("Max calls reached"); - +T_("Max call attempts reached (Eligible)"); +T_("Max calls reached (Eligible)"); +T_("Max call attempts reached (Unknown eligibility)"); +T_("Max calls reached (Unknown eligibility)"); ?> diff --git a/call_interface2.php b/call_interface2.php index 65567369..ae5b3247 100644 --- a/call_interface2.php +++ b/call_interface2.php @@ -123,7 +123,7 @@ function display_outcomes($contacted,$ca,$case_id) $sql = "SELECT outcome_id,description,contacted FROM outcome WHERE contacted = '$contacted' - AND outcome_id NOT IN(5,10,19,21,40,41,42,43)"; + AND outcome_id NOT IN(5,10,19,21,40,41,42,43,44,45)"; } } else @@ -133,7 +133,7 @@ function display_outcomes($contacted,$ca,$case_id) $sql = "SELECT outcome_id,description,contacted FROM outcome WHERE contacted = '$contacted' - AND outcome_id NOT IN(5,10,19,21,40,41,42,43)"; + AND outcome_id NOT IN(5,10,19,21,40,41,42,43,44,45)"; } } } diff --git a/database/quexs.sql b/database/quexs.sql index 4902813b..70968a0d 100644 --- a/database/quexs.sql +++ b/database/quexs.sql @@ -1091,8 +1091,11 @@ INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_m INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`) VALUES(33, '2.36', 'Miscellaneous - Unavailable for a week', 10080, 1, 0, 1, 1, 1, 0, 'O'); INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`) VALUES(40, '1.1', 'Self completed online', 0, 4, 0, 1, 1, 1, 0, 'I'); INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`) VALUES(41, '2.36', 'Self completion email invitation sent', 10080, 1, 0, 1, 1, 1, 0, 'O'); -INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`) VALUES(42, '3.13', 'Max call attempts reached', 0, 1, 0, 1, 0, 1, 0, 'UH'); -INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`) VALUES(43, '3.13', 'Max calls reached', 0, 1, 0, 1, 0, 1, 0, 'UH'); +INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`) VALUES(42, '3.90', 'Max call attempts reached (Unknown eligibility)', 0, 1, 0, 1, 1, 0, 0, 'UH'); +INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`) VALUES(43, '3.90', 'Max calls reached (Unknown eligibility)', 0, 1, 0, 1, 1, 0, 0, 'UH'); +INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`) VALUES(44, '2.30', 'Max call attempts reached (Eligible)', 0, 1, 0, 1, 1, 1, 0, 'O'); +INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`) VALUES(45, '2.30', 'Max calls reached (Eligible)', 0, 1, 0, 1, 1, 1, 0, 'O'); + -- -------------------------------------------------------- -- diff --git a/functions/functions.operator.php b/functions/functions.operator.php index e8367ab6..00ba2f25 100644 --- a/functions/functions.operator.php +++ b/functions/functions.operator.php @@ -2171,9 +2171,9 @@ function end_case($operator_id) $lastcall = 0; if (!empty($l)) $lastcall = $l['call_id']; - - - if ($count == 0) //no numbers to be tried again, get last outcome or 1 + + + if ($count == 0) //no numbers to be tried again, get last outcome or 1 { //last call $sql = "SELECT c.outcome_id as outcome_id @@ -2191,23 +2191,70 @@ function end_case($operator_id) $outcome = $t['outcome_id']; } } - else if ($count >= 1) //one or more numbers to be tried again - first code as eligible if ever eligible... - { - //$r[0]['contact_phone_id']; - //code as eligible if ever eligible, or if referred to the supervisor, code as that if last call - $sql = "SELECT c.outcome_id as outcome_id - FROM `call` as c - JOIN outcome AS o ON ( c.outcome_id = o.outcome_id AND (o.eligible = 1 OR o.outcome_type_id = 2 OR o.outcome_type_id = 1) ) - WHERE c.case_id = '$case_id' - ORDER BY c.call_id DESC"; - - $t = $db->GetRow($sql); + else if ($count >= 1) //one or more numbers to be tried again - see if max calls reached, then code as eligible if ever eligible... + { + $sql = "SELECT call_attempt_max,call_max + FROM questionnaire_sample as qs, `case` as c + WHERE c.case_id = '$case_id' + AND qs.sample_id = c.sample_id + AND qs.questionnaire_id = c.questionnaire_id"; + + $cm = $db->GetRow($sql); + - if (!empty($t)) - $outcome = $t['outcome_id']; - } - } - else + $sql = "SELECT COUNT(*) as c + FROM call_attempt + WHERE case_id = '$case_id'"; + + $callattempts = $db->GetOne($sql); + + $sql = "SELECT COUNT(*) as c + FROM `call` + WHERE case_id = '$case_id'"; + + $calls = $db->GetOne($sql); + + $eligsql = "SELECT count(*) + FROM `call` as c, `outcome` as o + WHERE c.outcome_id = o.outcome_id + AND o.eligible = 1 + AND c.case_id = '$case_id'"; + + if ($cm['call_attempt_max'] > 0 && $callattempts >= $cm['call_attempt_max']) //max call attempts reached + { + //if ever eligible, code as eligible + if ($db->GetOne($eligsql) > 0) + $outcome = 44; + else + $outcome = 42; + } + else if ($cm['call_max'] > 0 && $calls >= $cm['call_max']) //max calls reached + { + //if ever eligible, code as eligible + if ($db->GetOne($eligsql) > 0) + $outcome = 45; + else + $outcome = 43; + } + else + { + + //$r[0]['contact_phone_id']; + //code as eligible if ever eligible, or if referred to the supervisor, code as that if last call + $sql = "SELECT c.outcome_id as outcome_id + FROM `call` as c + JOIN outcome AS o ON ( c.outcome_id = o.outcome_id AND (o.eligible = 1 OR o.outcome_type_id = 2 OR o.outcome_type_id = 1) ) + WHERE c.case_id = '$case_id' + ORDER BY c.call_id DESC"; + + $t = $db->GetRow($sql); + + if (!empty($t)) + $outcome = $t['outcome_id']; + } + } + } + else { //the last call is the call with the final otucome $outcome = $a['outcome_id']; diff --git a/locale/quexs.pot b/locale/quexs.pot index a567574d..a7d083f4 100644 --- a/locale/quexs.pot +++ b/locale/quexs.pot @@ -2,7 +2,7 @@ msgid "" msgstr "" "Project-Id-Version: queXS\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2015-08-07 15:48+1000\n" +"POT-Creation-Date: 2015-08-10 16:24+1000\n" "PO-Revision-Date: \n" "Last-Translator: Adam Zammit \n" "Language-Team: \n" @@ -3589,11 +3589,19 @@ msgid "Self completed online" msgstr "" #: admin/databasestrings.php:91 -msgid "Max call attempts reached" +msgid "Max call attempts reached (Eligible)" msgstr "" #: admin/databasestrings.php:92 -msgid "Max calls reached" +msgid "Max calls reached (Eligible)" +msgstr "" + +#: admin/databasestrings.php:93 +msgid "Max call attempts reached (Unknown eligibility)" +msgstr "" + +#: admin/databasestrings.php:94 +msgid "Max calls reached (Unknown eligibility)" msgstr "" #: call_interface2.php:116 diff --git a/nocaseavailable.php b/nocaseavailable.php index faa9072f..9e8fdbdc 100644 --- a/nocaseavailable.php +++ b/nocaseavailable.php @@ -156,7 +156,7 @@ $sql = "SELECT count(s.sample_id) as count_samples AND si.enabled = 1 AND !(si.call_restrict = 1 AND cr.day_of_week IS NULL) AND ou.outcome_type_id IN( SELECT outcome_type_id FROM operator_skill WHERE operator_id = '$operator_id') - AND ou.outcome_id NOT IN (10,25,28,42,43,40) "; + AND ou.outcome_id NOT IN (10,25,28,42,43,44,45,40) "; $rs = $db->GetRow($sql); diff --git a/waitnextcase_interface2.php b/waitnextcase_interface2.php index 4545022c..baa7ba51 100644 --- a/waitnextcase_interface2.php +++ b/waitnextcase_interface2.php @@ -149,7 +149,7 @@ else AND s.import_id IN ($siid) AND !(si.call_restrict = 1 AND cr.day_of_week IS NULL) AND ou.outcome_type_id IN( SELECT outcome_type_id FROM operator_skill WHERE operator_id = '$operator_id') - AND ou.outcome_id NOT IN (10,25,28,42,43,40)"; + AND ou.outcome_id NOT IN (10,25,28,42,43,44,45,40)"; $cases_count = $db->GetRow($sql); if ($cases_count['count_samples'] == 0){