/** * 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>"; }
/** * Get start interviewer URL * * @return string The URL to start the interview */ function get_start_interview_url() { $db = newADOConnection(DB_TYPE); $db->Connect(DB_HOST, DB_USER, DB_PASS, DB_NAME); $db->SetFetchMode(ADODB_FETCH_ASSOC); $operator_id = get_operator_id(); $url = QUEXS_URL . "nocaseavailable.php"; $case_id = get_case_id($operator_id); if ($case_id) { $sql = "SELECT token\r\n\t\t\tFROM `case`\r\n\t\t\tWHERE case_id = {$case_id}"; $token = $db->GetOne($sql); $sid = get_limesurvey_id($operator_id); $url = LIME_URL . "index.php?interviewer=interviewer&loadall=reload&sid={$sid}&token={$token}&lang=" . DEFAULT_LOCALE; $questionnaire_id = get_questionnaire_id($operator_id); //get prefills $sql = "SELECT lime_sgqa,value\r\n FROM questionnaire_prefill\r\n WHERE questionnaire_id = '{$questionnaire_id}'"; $pf = $db->GetAll($sql); if (!empty($pf)) { foreach ($pf as $p) { $url .= "&" . $p['lime_sgqa'] . "=" . quexs_template_replace($p['value']); } } } return $url; }
/** * 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>"; }
/** * Get the complete URL for the Limesurvey questionnaire * If no case available, return an error screen * * @param int $operator_id The operator id * @return string The URL of the LimeSurvey questionnaire, or the URL of an error screen if none available * */ function get_limesurvey_url($operator_id) { global $db; $db->StartTrans(); $url = "nocaseavailable.php"; $case_id = get_case_id($operator_id, false); if ($case_id) { $sql = "SELECT token\r\n\t\t\tFROM `case`\r\n\t\t\tWHERE case_id = {$case_id}"; $token = $db->GetOne($sql); $sid = get_limesurvey_id($operator_id); $url = LIME_URL . "index.php?interviewer=interviewer&loadall=reload&sid={$sid}&token={$token}&lang=" . DEFAULT_LOCALE; $questionnaire_id = get_questionnaire_id($operator_id); //get prefills $sql = "SELECT lime_sgqa,value\r\n\t\t\tFROM questionnaire_prefill\r\n\t\t\tWHERE questionnaire_id = '{$questionnaire_id}'"; $pf = $db->GetAll($sql); if (!empty($pf)) { foreach ($pf as $p) { $url .= "&" . $p['lime_sgqa'] . "=" . template_replace($p['value'], $operator_id, $case_id); } } } //if ($db->HasFailedTrans()) { print "FAILED in get_limesurvey_url"; exit; } $db->CompleteTrans(); return $url; }