/** * 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; }
$chatenabled = false; } else { $chatenabled = true; } if ($chatenabled && operator_chat_enabled($operator_id)) { $case_id = get_case_id($operator_id); //get BOSH service URL $bosh_service = get_setting("bosh_service"); if (empty($bosh_service)) { $bosh_service = "/xmpp-httpbind"; } //could set this on a shift by shift basis if required $supervisor_xmpp = get_setting("supervisor_xmpp"); //javascript to activate connection for this user print "<script type='text/javascript'>"; print "var SUPERVISOR_NAME = '" . TQ_("Supervisor") . "';"; print "var MY_NAME = '" . TQ_("Me") . "';"; print "var SUPERVISOR_XMPP = '{$supervisor_xmpp}';"; print "var PRESENCE_MESSAGE = '" . TQ_("Case id") . ": {$case_id}';"; print "var conn = new Strophe.Connection('{$bosh_service}');"; print "conn.connect('" . get_operator_variable("chat_user", $operator_id) . "', '" . get_operator_variable("chat_password", $operator_id) . "', OnConnectionStatus);"; print "</script>"; print "<div style='display:none' id='statusavailable'>" . T_("Supervisor is available") . "</div>"; print "<div id='statusunavailable'>" . T_("Supervisor not available") . "</div>"; print "<div id='chatbox'><label for='chattext'>" . T_("Message") . ":</label><input type='text' id='chattext'/> <input type='submit' id='chatclick' value=\"" . T_("Send") . "\"/></div>"; //table for chat messages print "<table class='tclass' id='chattable'><tbody><tr><th>" . T_("From") . "</th><th>" . T_("Message") . "</th></tr></tbody></table>"; } else { print "<p>" . T_("Supervisor chat is not enabled") . "</p>"; } xhtml_foot();
/** * 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 template_replace($string, $operator_id, $case_id) { $respondent_id = get_respondent_id(get_call_attempt($operator_id, false)); 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, "{PeriodOfDay") !== false) { $answreplace = substr($string, stripos($string, "{PeriodOfDay"), stripos($string, "}", stripos($string, "{PeriodOfDay")) - stripos($string, "{PeriodOfDay") + 1); $answreplace3 = get_period_of_day($respondent_id); $string = str_replace($answreplace, $answreplace3, $string); } return $string; }