} else { $js[] = "js/window_interface2.js"; } if (AUTO_LOGOUT_MINUTES !== false) { $js[] = "include/jquery/jquery-1.4.2.min.js"; $js[] = "js/childnap.js"; } xhtml_head(T_("Status"), false, array("include/bootstrap/css/bootstrap.min.css", "css/status_interface2.css"), $js); $ca = get_call_attempt($operator_id, false); if ($ca) { $respondent_id = get_respondent_id($ca); $case_id = get_case_id($operator_id); $fname = get_respondent_variable("firstName", $respondent_id); $lname = get_respondent_variable("lastName", $respondent_id); print "<h4>" . T_("Name") . ": {$fname} {$lname}</h4>"; $appointment = is_on_appointment($ca); $call_id = get_call($operator_id); $sql = "SELECT o.tryanother, o.require_note\r\n\t\tFROM `call` as c, `outcome` as o\r\n\t\tWHERE c.call_attempt_id = '{$ca}'\r\n\t\tAND c.outcome_id = o.outcome_id\r\n\t\tORDER BY call_id DESC\r\n\t\tLIMIT 1"; $rst = $db->GetRow($sql); if (empty($rst) || $rst['tryanother'] == 1) { if (isset($_POST['contactphone'])) { $pcontact_phone_id = intval($_POST['contactphone']); //If an outcome already assigned, end the current call and start the enxt one to pcontact_phone_id //Otherwise bring up the assign outcome window if (!$call_id) { $call_id = get_call($operator_id, $respondent_id, $pcontact_phone_id, true); echo "<script type='text/javascript'>openParentObject(\"main-content\",\"" . get_respondentselection_url($operator_id, false) . "\");</script>"; } else { //bring up assign outcome window print "<script type='text/javascript'>parent.poptastic('call_interface2.php');</script>"; }
{ print "<p><a href='javascript:" . $trigger . "(\"endcase=endcase\")' class='btn btn-primary'>" . T_("End case") . "</a></p>"; } function print_endwork($trigger = "") { print "<p><a href='javascript:" . $trigger . "(\"endwork=endwork\")' class='btn btn-info'>" . T_("End work") . "</a></p>"; } switch ($state) { case false: //no call made //no call made case 0: //not called -- shouldn't come here as we should create requesting call immediately print "<div class='status'>" . T_("Not on a call") . "</div>"; //if we are on an appointment, we will just call the specified number for the appointment $appointment_id = is_on_appointment($call_attempt_id); if ($appointment_id) { if (isset($_GET['end'])) { //end the case if (!isset($_GET['end'])) { print "<div>" . T_("End work") . "</div>"; } print_endcase("openParent"); print_endwork("openParent"); } else { //determine whether to begin calling based on extension status $es = 1; if (is_voip_enabled($operator_id)) { if (get_extension_status($operator_id)) { $es = 1; } else {
print "<div class='offline statusbutton'>" . T_("No call") . "</div>"; } else { if ($state == 4) { print "<div class='tobecoded statusbutton'>" . T_("To be coded") . "</div>"; } else { if ($state == 1) { print "<div class='online statusbutton'>" . T_("Requesting") . "</div>"; } else { if ($state == 2) { print "<div class='online statusbutton'>" . T_("Ringing") . "</div>"; } else { if ($state == 3) { print "<div class='online statusbutton'>" . T_("Answered") . "</div>"; } } } } } $ca = get_call_attempt($operator_id, false); if ($ca) { print "<div class='text'>" . get_respondent_time(get_respondent_id($ca), TIME_FORMAT) . "</div>"; if (is_on_appointment($ca)) { print "<div class='online statusbutton'>" . T_("APPT") . "</div>"; } if (missed_appointment($ca)) { print "<div class='tobecoded statusbutton'>" . T_("MISSED") . "</div>"; } } else { print "<div class='text'>" . T_("No case") . "</div>"; } xhtml_foot();
/** * Retrieves the token attribute value from the related token table * * @param mixed $surveyid The survey ID * @param mixed $attrName The token-attribute field name * @param mixed $token The token code * @return string The token attribute value (or null on error) */ function GetAttributeValue($surveyid, $attrName, $token) { global $dbprefix, $connect; $attrName = strtolower($attrName); if ($attrName == 'callattempts' || $attrName == 'onappointment' || $attrName == 'perccomplete' || $attrName == 'messagesleft') { include_once "quexs.php"; $quexs_operator_id = get_operator_id(); $quexs_case_id = get_case_id($quexs_operator_id); if ($quexs_case_id) { if ($attrName == 'callattempts') { return get_call_attempts($quexs_case_id); } else { if ($attrName == 'onappointment') { return is_on_appointment($quexs_case_id, $quexs_operator_id); } else { if ($attrName == 'perccomplete') { return get_percent_complete($quexs_case_id); } else { if ($attrName == 'messagesleft') { return get_messages_left($quexs_case_id); } } } } } else { return 0; } } else { if (!tableExists('tokens_' . $surveyid) || !in_array($attrName, GetTokenConditionsFieldNames($surveyid))) { return null; } } $sanitized_token = $connect->qstr($token, get_magic_quotes_gpc()); $surveyid = sanitize_int($surveyid); $query = "SELECT {$attrName} FROM {$dbprefix}tokens_{$surveyid} WHERE token={$sanitized_token}"; $result = db_execute_num($query); $count = $result->RecordCount(); if ($count != 1) { return null; } else { $row = $result->FetchRow(); return $row[0]; } }
/** * Replace placeholders in a string with data for this case/operator * * @param string $string The string * @param int $operator_id The operator id * @param int $case_id The case id * @return string The string with replaced text * */ function quexs_template_replace($string) { $operator_id = get_operator_id(); $case_id = get_case_id($operator_id); $respondent_id = get_respondent_id($case_id, $operator_id); while (stripos($string, "{Respondent:") !== false) { $answreplace = substr($string, stripos($string, "{Respondent:"), stripos($string, "}", stripos($string, "{Respondent:")) - stripos($string, "{Respondent:") + 1); $answreplace2 = substr($answreplace, 12, stripos($answreplace, "}", stripos($answreplace, "{Respondent:")) - 12); $answreplace3 = get_respondent_variable($answreplace2, $respondent_id); $string = str_replace($answreplace, $answreplace3, $string); } while (stripos($string, "{Operator:") !== false) { $answreplace = substr($string, stripos($string, "{Operator:"), stripos($string, "}", stripos($string, "{Operator:")) - stripos($string, "{Operator:") + 1); $answreplace2 = substr($answreplace, 10, stripos($answreplace, "}", stripos($answreplace, "{Operator:")) - 10); $answreplace3 = get_operator_variable($answreplace2, $operator_id); $string = str_replace($answreplace, $answreplace3, $string); } while (stripos($string, "{Sample:") !== false) { $answreplace = substr($string, stripos($string, "{Sample:"), stripos($string, "}", stripos($string, "{Sample:")) - stripos($string, "{Sample:") + 1); $answreplace2 = substr($answreplace, 8, stripos($answreplace, "}", stripos($answreplace, "{Sample:")) - 8); $answreplace3 = get_sample_variable($answreplace2, $case_id); $string = str_replace($answreplace, $answreplace3, $string); } while (stripos($string, "{Outcome:") !== false) { $answreplace = substr($string, stripos($string, "{Outcome:"), stripos($string, "}", stripos($string, "{Outcome:")) - stripos($string, "{Outcome:") + 1); $answreplace2 = substr($answreplace, 9, stripos($answreplace, "}", stripos($answreplace, "{Outcome:")) - 9); $answreplace3 = get_outcome_variable($answreplace2); $string = str_replace($answreplace, $answreplace3, $string); } while (stripos($string, "{CALLATTEMPTS}") !== false) { $call_attempts = get_call_attempts($case_id); $string = str_ireplace("{CALLATTEMPTS}", $call_attempts, $string); } while (stripos($string, "{RESPONDENTSELECTIONURL}") !== false) { $url = get_respondent_selection_url(); $string = str_ireplace("{RESPONDENTSELECTIONURL}", $url, $string); } while (stripos($string, "{ONAPPOINTMENT}") !== false) { $on_appointment = is_on_appointment($case_id, $operator_id); $str = T_("Not on an appointment"); if ($on_appointment) { $str = T_("On an appointment"); } $string = str_ireplace("{ONAPPOINTMENT}", $str, $string); } if (stripos($string, "{PERIODOFDAY}") !== false) { $string = str_ireplace("{PERIODOFDAY}", get_period_of_day($respondent_id), $string); } if (stripos($string, "{APPOINTMENTDATE}") !== false) { $string = str_ireplace("{APPOINTMENTDATE}", get_appointment_date($respondent_id), $string); } if (stripos($string, "{APPOINTMENTTIME}") !== false) { $string = str_ireplace("{APPOINTMENTTIME}", get_appointment_time($respondent_id), $string); } if (stripos($string, "{APPOINTMENTNUMBER}") !== false) { $string = str_ireplace("{APPOINTMENTNUMBER}", get_appointment_number($respondent_id), $string); } if (stripos($string, "{PERCCOMPLETE}") !== false) { $string = str_ireplace("{PERCCOMPLETE}", round(get_percent_complete($case_id), 0), $string); } return $string; }
/** * End the current call * Store the time and outcome in the database * * @param int $operator_id The operator * @param int $outcome_id The outcome to the call * @param int $state The end state of the call 5 default * @return bool True if database execution succeeded * * @todo Implement session destruction here * */ function end_call($operator_id, $outcome_id, $state = 5) { global $db; $db->StartTrans(); $o = false; $ca = get_call($operator_id); if ($ca) { $c = get_call_attempt($operator_id, false); if ($c) { $a = is_on_appointment($c); //if we were on an appointment, complete it with this call if ($a) { $sql = "UPDATE appointment\r\n\t\t\t\t\tSET completed_call_id = '{$ca}'\r\n\t\t\t\t\tWHERE appointment_id = '{$a}'"; $db->Execute($sql); } } $sql = "UPDATE `call`\r\n\t\t\tSET end = CONVERT_TZ(NOW(),'System','UTC'), outcome_id = '{$outcome_id}', state = '{$state}'\r\n\t\t\tWHERE call_id = '{$ca}'"; $db->Execute($sql); } //if ($db->HasFailedTrans()) { print "FAILED in end_call"; exit; } if ($db->CompleteTrans()) { return $o; } return false; }