/** * Display appropriate outcomes based on current call attempt status * * @param int $contacted 0 for not contacted, 1 for contacted (a person on the phone) * @param int $ca Call attempt id * @param int $case_id The Case id * */ function display_outcomes($contacted, $ca, $case_id) { global $db; $completed = limesurvey_is_completed($case_id); //see if the case is completed if ($completed) { $sql = "SELECT outcome_id,description\r\n\t\t\tFROM outcome\r\n\t\t\tWHERE outcome_id = 10"; } else { if (limesurvey_is_quota_full($case_id)) { $sql = "SELECT outcome_id,description\r\n\t\t\tFROM outcome\r\n\t\t\tWHERE outcome_id = 32"; } else { //see if we have made an appointment on this call attempt $sql = "SELECT appointment_id\r\n\t\t\tFROM appointment\r\n\t\t\tWHERE completed_call_id IS NULL\r\n\t\t\tAND call_attempt_id = '{$ca}'"; $rs = $db->GetAll($sql); $outcomes = $db->GetOne("SELECT q.outcomes FROM `questionnaire` as q JOIN `case` as c ON (c.questionnaire_id =q.questionnaire_id) WHERE c.case_id = {$case_id}"); if (!empty($rs)) { //we have an appointment made ... only select appointment ID's $sql = "SELECT outcome_id,description\r\n\t\t\t\tFROM outcome\r\n\t\t\t\tWHERE outcome_type_id = '5'\r\n\t\t\t\tAND outcome_id IN ({$outcomes})"; } else { if ($contacted === false) { $ctd = ""; } else { $contacted = bigintval($contacted); $ctd = "AND contacted = '{$contacted}'"; } $sql = "SELECT outcome_id,description\r\n\t\t\t\t\tFROM outcome\r\n\t\t\t\t\tWHERE outcome_type_id != '5'\r\n\t\t\t\t\t{$ctd}\r\n\t\t\t\t\tAND outcome_id IN ({$outcomes})\r\n\t\t\t\t\tAND outcome_id NOT IN(10,32,42,43,44,45)"; //don't show completed if not, Lime_Quota_full if not, hide max calls as they supposed to be automatic or admin-privileged } } } $rs = $db->GetAll($sql); print "<div>"; if (!empty($rs)) { $lime_sid = get_limesurvey_id(get_operator_id()); //Check to see if we have sent an email on this call and set the default outcome $sql = "SELECT 41\r\n\t\t\tFROM `case` as c, " . LIME_PREFIX . "tokens_{$lime_sid} as t\r\n\t\t\tWHERE t.sent = '{$ca}'\r\n\t\t\tAND c.case_id = {$case_id}\r\n\t\t\tAND t.token = c.token"; $do = $db->GetOne($sql); if (isset($_GET['defaultoutcome'])) { $do = bigintval($_GET['defaultoutcome']); } foreach ($rs as $r) { if ($do == $r['outcome_id']) { $selected = "checked='checked'"; } else { $selected = ""; } print "<div><label class='label'><input type='radio' class='radio' name='outcome' id='outcome-{$r['outcome_id']}' value='{$r['outcome_id']}' {$selected}/>" . T_($r['description']) . "</label></div>"; } } print "</div>"; }
/** * Display appropriate outcomes based on current call attempt status * * @param int $contacted 0 for not contacted, 1 for contacted (a person on the phone) * @param int $ca Call attempt id * @param int $case_id The Case id * */ function display_outcomes($contacted, $ca, $case_id) { global $db; $completed = limesurvey_is_completed($case_id); //see if the case is completed if ($completed) { $sql = "SELECT outcome_id,description,contacted\r\n\t\t\tFROM outcome\r\n\t\t\tWHERE outcome_id = 10"; } else { if (limesurvey_is_quota_full($case_id)) { $sql = "SELECT outcome_id,description,contacted\r\n\t\t\tFROM outcome\r\n\t\t\tWHERE outcome_id = 32"; } else { //see if we have made an appointment on this call attempt $sql = "SELECT appointment_id\r\n\t\t\tFROM appointment\r\n\t\t\tWHERE completed_call_id IS NULL\r\n\t\t\tAND call_attempt_id = '{$ca}'"; $rs = $db->GetAll($sql); $outcomes = $db->GetOne("SELECT q.outcomes FROM `questionnaire` as q JOIN `case` as c ON (c.questionnaire_id =q.questionnaire_id) WHERE c.case_id = {$case_id}"); if (!empty($rs)) { //we have an appointment made ... only select appointment ID's $sql = "SELECT outcome_id,description,contacted\r\n\t\t\t\tFROM outcome\r\n\t\t\t\tWHERE outcome_type_id = '5'\r\n\t\t\t\tAND outcome_id IN ({$outcomes})"; } else { if ($contacted) { $contacted = bigintval($contacted); } else { print "<div class=\"form-group\" ><a href=\"?contacted=1\" class=\"btn btn-info\" style=\"margin-left: 15px; margin-right: 30px; min-width: 150px;\">" . T_("CONTACTED") . "</a>"; print "<a href=\"?contacted=0\" class=\"btn btn-default\" style=\"margin-left: 30px; margin-right: 15px; min-width: 150px;\">" . T_("NOT CONTACTED") . "</a></div>"; if (isset($_GET['contacted'])) { $contacted = bigintval($_GET['contacted']); } } if ($contacted == 1 || $contacted === 0) { $sql = "SELECT outcome_id,description,contacted\r\n\t\t\t\t\tFROM outcome\r\n\t\t\t\t\tWHERE outcome_type_id != '5'\r\n\t\t\t\t\tAND contacted = '{$contacted}'\r\n\t\t\t\t\tAND outcome_id IN ({$outcomes})\r\n\t\t\t\t\tAND outcome_id NOT IN(10,32,42,43,44,45)"; //don't show completed if not, Lime_Quota_full if not, hide max calls as they supposed to be automatic or admin-privileged } } } } $rs = $db->GetAll($sql); print "<div class=\"panel-body\">"; if (!empty($rs)) { $do = false; $lime_sid = get_limesurvey_id(get_operator_id()); //Check to see if we have sent an email on this call and set the default outcome $sql = "SELECT 41\r\n\t\t\tFROM `case` as c, " . LIME_PREFIX . "tokens_{$lime_sid} as t\r\n\t\t\tWHERE t.sent = '{$ca}'\r\n\t\t\tAND c.case_id = {$case_id}\r\n\t\t\tAND t.token = c.token"; $do = $db->GetOne($sql); if (isset($_GET['defaultoutcome'])) { $do = bigintval($_GET['defaultoutcome']); } foreach ($rs as $r) { if ($do == $r['outcome_id']) { $selected = "checked='checked'"; } else { $selected = ""; } if (isset($r['contacted']) && $r['contacted'] == 1) { $highlight = ""; } else { $highlight = "style='color:black;'"; } print "<div><a><label {$highlight} class='btn-link'><input type='radio' class='radio' name='outcome' id='outcome-{$r['outcome_id']}' value='{$r['outcome_id']}' {$selected} style='float:left'/> " . T_($r['description']) . "</label></a></div>"; } $_POST['confirm'] = true; //check that outcome selected } print "</div>"; }