/** * Generate the case status report * * @param mixed $questionnaire_id The quesitonnaire, if specified * @param string $sample_id The sample, if speified * @param mixed $outcome_id THe outcome id, if specified * * @return false if empty otherwise true if table drawn * @author Adam Zammit <*****@*****.**> * @since 2012-10-02 */ function case_status_report($questionnaire_id = false, $sample_id = false, $outcome_id = false) { global $db; $q = ""; if ($questionnaire_id !== false) { $q = "AND c.questionnaire_id = {$questionnaire_id}"; } $s = ""; if ($sample_id !== false) { $s = "AND s.import_id = '{$sample_id}'"; } $o = ""; if ($outcome_id !== false) { $o = "AND c.current_outcome_id = {$outcome_id}"; } $sql = "SELECT \tCONCAT('<a href=\\'supervisor.php?case_id=', c.case_id, '\\'>', c.case_id, '</a>') as case_id,\r\n\t\t\to.description as outcomes,\r\n\t\t\tsi.description as samples, s.Time_zone_name as timezone, TIME_FORMAT(CONVERT_TZ(NOW(),@@session.time_zone,s.Time_zone_name),'" . TIME_FORMAT . "') as time, (SELECT COUNT(*) FROM `call` WHERE `call`.case_id = c.case_id) as nrcalls, (SELECT COUNT(*) FROM call_attempt WHERE call_attempt.case_id = c.case_id) as nrattempts, \t\r\n\t\t\tCASE WHEN ca.end IS NULL THEN '" . TQ_("Available") . "'\r\n\t\t\t\tWHEN TIME_TO_SEC(TIMEDIFF(ca.end,CONVERT_TZ(DATE_SUB(NOW(), INTERVAL co.default_delay_minutes MINUTE),'System','UTC'))) < 0 THEN '" . TQ_("Available") . "'\r\n\t\t\t\tELSE CONCAT(ROUND(TIME_TO_SEC(TIMEDIFF(ca.end,CONVERT_TZ(DATE_SUB(NOW(), INTERVAL co.default_delay_minutes MINUTE),'System','UTC'))) / 60),' " . TQ_("minutes") . "')\r\n\t\t\tEND AS availableinmin,\r\n\t\t\tCASE WHEN oq.operator_id IS NULL THEN \r\n\t\t\t\tCONCAT('')\r\n\t\t\tELSE CONCAT('<span class=\\'text-info\\'>', oq.firstName,' ',oq.lastName,'</span>')\r\n\t\t\tEND AS assignedoperator,\r\n\t\t\tCASE WHEN oq.operator_id IS NULL THEN \r\n\t\t\t\tCONCAT('')\r\n\t\t\tELSE CONCAT('   ', cq.sortorder ,' ')\r\n\t\t\tEND AS ordr,\r\n\t\t\tCASE WHEN oq.operator_id IS NULL THEN \r\n\t\t\t\tCONCAT('<span data-toggle=\\'tooltip\\' title=\\'" . TQ_("Not assigned, select to assign") . "\\'><input type=\\'checkbox\\' name=\\'c', c.case_id, '\\' value=\\'', c.case_id, '\\' /></span>')\r\n\t\t\tELSE CONCAT('<a href=\"?questionnaire_id={$questionnaire_id}&sample_import_id={$sample_id}&unassign=', cq.case_queue_id, '\" data-toggle=\\'tooltip\\' title=\\'" . TQ_("Click to unassign") . "\\'><i class=\\'fa fa-trash-o fa-lg text-danger\\'></i></a>')\r\n\t\t\tEND AS flag\t\r\n\t\tFROM `case` as c\r\n\t\tJOIN questionnaire as q ON (q.questionnaire_id = c.questionnaire_id and q.enabled = 1)\r\n\t\tJOIN outcome as o ON (o.outcome_id = c.current_outcome_id AND o.outcome_type_id = 1)\r\n\t\tJOIN sample as s ON (s.sample_id = c.sample_id {$s})\r\n\t\tJOIN sample_import as si ON (s.import_id = si.sample_import_id AND si.enabled = 1)\r\n\t\tJOIN questionnaire_sample as qs ON (qs.questionnaire_id = {$questionnaire_id} AND qs.sample_import_id = s.import_id)\r\n\t\tLEFT JOIN `call` as ca ON (ca.call_id = c.last_call_id)\r\n\t\tLEFT JOIN outcome as co ON (co.outcome_id = ca.outcome_id)\r\n\t\tLEFT JOIN case_queue as cq ON (cq.case_id = c.case_id)\r\n\t\tLEFT JOIN operator as oq ON (cq.operator_id = oq.operator_id)\r\n\t\tLEFT JOIN (questionnaire_sample_quota as qsq) on (s.import_id = qsq.sample_import_id and c.questionnaire_id = qsq.questionnaire_id)\r\n\t\tLEFT JOIN (questionnaire_sample_quota_row as qsqr) on (s.import_id = qsqr.sample_import_id and c.questionnaire_id = qsqr.questionnaire_id)\r\n\t\tWHERE c.current_operator_id IS NULL {$q} {$o}\r\n\t\tAND (qsq.quota_reached IS NULL OR qsq.quota_reached != 1 )\r\n\t\tAND (qsqr.quota_reached IS NULL OR qsqr.quota_reached != 1)\r\n\t\tGROUP BY c.case_id ORDER BY c.case_id ASC"; print "<form method=\"post\" action=\"?questionnaire_id={$questionnaire_id}&sample_import_id={$sample_id}\">"; $rs2 = $db->GetAll($sql); translate_array($rs2, array("outcomes")); $datacol = array('case_id', 'samples', 'timezone', 'time', 'nrattempts', 'nrcalls', 'outcomes', 'availableinmin', 'assignedoperator', 'ordr', 'flag'); $headers = array(T_("Case id"), T_("Sample"), T_("Timezone"), T_("Time NOW"), T_("Call attempts"), T_("Calls"), T_("Outcome"), T_("Available in"), T_("Assigned to"), T_("Order"), "<i class='fa fa-check-square-o fa-lg'></i>"); if (isset($_GET['sample_import_id'])) { unset($datacol[1]); unset($headers[1]); } xhtml_table($rs2, $datacol, $headers, "tclass", false, false, "bs-table"); $sql = "SELECT operator_id as value,CONCAT(firstName,' ', lastName) as description, '' selected\r\n\t\tFROM operator\r\n\t\tWHERE enabled = 1"; $rs3 = $db->GetAll($sql); print "<h4 class='col-sm-offset-5 pull-left text-right control-label'>" . T_("Assign selected cases to") . " " . T_("operator") . " : </h4> "; display_chooser($rs3, "operator_id", "operator_id", true, false, false, true, false, true, "pull-left"); print " <button class='btn btn-default' type='submit' data-toggle='tooltip' title='" . T_("Assign cases to operator queue") . "'><i class='fa fa-link fa-lg text-primary'></i> " . T_("Assign") . "</button>"; print "</form></br>"; return true; }
} else { if (isset($_GET['delete'])) { $questionnaire_id = intval($_GET['delete']); $sql = "SELECT *\r\n\t\tFROM questionnaire\r\n\t\tWHERE questionnaire_id = {$questionnaire_id}"; $rs = $db->GetRow($sql); xhtml_head(T_("Delete Questionnaire"), true, $css, $js_head, false, false, false, " <span class='text-uppercase'>" . "{$rs['description']}" . "</span>"); print "<div class='alert alert-danger'><p>" . T_("Any collected data and the limesurvey instrument will NOT be deleted") . "</p>"; print "<p>" . T_("The questionnaire will be deleted from queXS including call history, cases, case notes, respondent details, appointments and the links between operators, clients and the questionnaire") . "</p>"; print "<p>" . T_("Please confirm you wish to delete the questionnaire") . "</p></div>"; print "<form method='post' action='?'>"; print "<p>  <a href='questionnairelist.php' class='btn btn-default' ><i class='fa fa-chevron-left fa-lg' style='color:blue;'></i> " . T_("Go back") . "</a><input type='submit' name='submit' class='btn btn-danger col-sm-offset-4' value=\"" . T_("Delete this questionnaire") . "\"/>"; print "<input type='hidden' name='questionnaire_id' value='{$questionnaire_id}'/></p>"; print "</form>"; } else { xhtml_head(T_("Questionnaire management"), true, $css, $js_head, false, false, false, T_("Questionnaire list")); echo "<div class='form-group'>\r\n\t\t<a href='' onclick='history.back();return false;' class='btn btn-default'><i class='fa fa-chevron-left fa-lg text-primary'></i> " . T_("Go back") . "</a>\r\n\t\t<a href='new.php' class='btn btn-default col-sm-offset-6' ><i class='fa fa-file-text-o fa-lg'></i> " . T_("Create a new questionnaire") . "</a>\r\n\t</div>"; print "<div>"; // add timeslots, callattempts, quotas? $sql = "SELECT \r\n\t\tCONCAT(' <b class=\\'badge\\'>',questionnaire_id,'</b> ') as qid,\r\n\t\tCONCAT('<h4>',description,'</h4>') as description,\r\n\t\tCASE WHEN enabled = 0 THEN\r\n\t\t\tCONCAT(' <span class=\\'btn label label-default\\'>" . TQ_("Disabled") . "</span> ')\r\n\t\tELSE\r\n\t\t\tCONCAT(' <span class=\\'btn label label-primary\\'>" . TQ_("Enabled") . "</span> ')\r\n\t\tEND as status,\r\n\t\tCASE WHEN enabled = 0 THEN\r\n\t\t\tCONCAT(' <a href=\\'?enable=',questionnaire_id,'\\'><i data-toggle=\\'tooltip\\' title=\\'" . TQ_("Enable") . "\\' class=\\'fa fa-toggle-off fa-3x\\' style=\\'color:grey;\\'></i></a> ')\r\n\t\tELSE\r\n\t\t\tCONCAT(' <a href=\\'\\' data-toggle=\\'confirmation\\' data-href=\\'?disable=',questionnaire_id,'\\'><i data-toggle=\\'tooltip\\' title=\\'" . TQ_("Disable") . "\\' class=\\'fa fa-toggle-on fa-3x\\'></i></a> ')\r\n\t\tEND as enabledisable,\r\n\t\tCONCAT('<a href=\\'?modify=',questionnaire_id,'\\' class=\\'btn\\' title=\\'" . TQ_("Edit Questionnaire") . " ',questionnaire_id,'\\' data-toggle=\\'tooltip\\'><i class=\\'fa fa-edit fa-2x \\'></i></a>') as modify,\r\n\t\tCONCAT('<a href=\\'" . LIME_URL . "admin/admin.php?sid=',lime_sid,'\\' class=\\'btn\\' title=\\'" . T_("Edit Lime survey") . " ',lime_sid,'\\' data-toggle=\\'tooltip\\'><i class=\\'btn-lime fa fa-lemon-o fa-2x\\'></i></a>') as inlime,\r\n\t\tCASE WHEN enabled = 0 THEN \r\n\t\t\tCONCAT('<i class=\\'btn fa fa-calendar fa-2x\\' style=\\'color:lightgrey;\\'></i>')\r\n\t\tELSE\r\n\t\t\tCONCAT('<a href=\\'addshift.php?questionnaire_id=',questionnaire_id,'\\' class=\\'btn\\' title=\\'" . TQ_("Shifts") . " " . TQ_("questionnaire") . " ',questionnaire_id,'\\' data-toggle=\\'tooltip\\'><i class=\\'fa fa-calendar fa-2x\\'></i></a>')\r\n\t\tEND as shifts,\r\n\t\tCASE WHEN enabled = 0 THEN \r\n\t\t\tCONCAT('<i class=\\'btn fa fa-square-o fa-2x\\' style=\\'color:lightgrey;\\'></i>')\r\n\t\tELSE\r\n\t\t\tCONCAT('<a href=\\'questionnaireprefill.php?questionnaire_id=',questionnaire_id,'\\' class=\\'btn\\' title=\\'" . TQ_("Pre-fill questionnaire") . " ',questionnaire_id,'\\' data-toggle=\\'tooltip\\'><i class=\\'fa fa-check-square-o fa-2x\\'></i></a>')\r\n\t\tEND as prefill,\r\n\t\tCASE WHEN enabled = 1 THEN\r\n\t\t\tCONCAT('<i class=\\'btn fa fa-trash-o fa-2x\\' style=\\'color:lightgrey;\\'></i>')\r\n\t\tELSE\r\n\t\t\tCONCAT('<a href=\\'?delete=',questionnaire_id,'\\' class=\\'btn\\' title=\\'" . TQ_("Delete questionnaire") . " ',questionnaire_id,'\\' data-toggle=\\'tooltip\\'><i class=\\'fa fa-trash-o fa-2x\\' style=\\'color:red;\\'></i></a>')\r\n\t\tEND as deletee,\r\n\t\tCASE WHEN enabled = 0 THEN\r\n\t\t\tCONCAT('<i class=\\'btn fa fa-bar-chart fa-2x\\' style=\\'color:lightgrey;\\'></i>')\r\n\t\tELSE\r\n\t\t\tCONCAT('<a href=\\'outcomes.php?questionnaire_id=',questionnaire_id,'\\' class=\\'btn\\' title=\\'" . TQ_("Outcomes for questionnaire") . " ',questionnaire_id,'\\' data-toggle=\\'tooltip\\'><i class=\\'fa fa-bar-chart fa-2x\\'></i></a>')\r\n\t\tEND as outcomes,\r\n\t\tCONCAT('<a href=\\'callhistory.php?questionnaire_id=',questionnaire_id,'\\' class=\\'btn\\' title=\\'" . TQ_("Call history") . " " . TQ_("questionnaire") . " ',questionnaire_id,'\\' data-toggle=\\'tooltip\\'><i class=\\'fa fa-phone fa-2x\\'></i></a>') as calls,\r\n\t\tCONCAT('<a href=\\'set_outcomes.php?qid=',questionnaire_id,'\\' class=\\'btn\\' title=\\'" . TQ_("Set outcomes") . " \n" . TQ_("questionnaire") . " ',questionnaire_id,'\\' data-toggle=\\'tooltip\\'><i class=\\'fa fa-list-ol fa-2x\\'></i></a>') as setoutcomes,\r\n\t\tCASE WHEN enabled = 0 THEN\r\n\t\t\tCONCAT('<i class=\\'btn fa fa-download fa-2x\\' style=\\'color:lightgrey;\\'></i>')\r\n\t\tELSE\r\n\t\t\tCONCAT('<a href=\\'dataoutput.php?questionnaire_id=',questionnaire_id,'\\' class=\\'btn\\' title=\\'" . TQ_("Data output") . " " . TQ_("questionnaire") . " ',questionnaire_id,'\\' data-toggle=\\'tooltip\\'><i class=\\'fa fa-download fa-2x\\'></i></a>')\r\n\t\tEND as dataout,\r\n\t\tCASE WHEN enabled = 0 THEN \r\n\t\t\tCONCAT('<i class=\\'btn fa fa-book fa-2x\\' style=\\'color:lightgrey;\\'></i>')\r\n\t\tELSE\r\n\t\t\tCONCAT('<a href=\\'assignsample.php?questionnaire_id=',questionnaire_id,'\\' class=\\'btn\\' title=\\'" . TQ_("Assigned samples") . "\\' data-toggle=\\'tooltip\\'><i class=\\'fa fa-book fa-2x\\'></i></a>')\r\n\t\tEND as assample,\r\n\t\tCASE WHEN enabled = 0 THEN \r\n\t\t\tCONCAT('<i class=\\'btn fa fa-filter fa-2x\\' style=\\'color:lightgrey;\\'></i>')\r\n\t\tELSE\r\n\t\t\tCONCAT('<a href=\\'quotareport.php?questionnaire_id=',questionnaire_id,'\\' class=\\'btn\\' title=\\'" . T_("Quota report") . " " . TQ_("questionnaire") . " ',questionnaire_id,'\\' data-toggle=\\'tooltip\\'><i class=\\'fa fa-filter fa-2x\\'></i></a>')\r\n\t\tEND as quotareport,\r\n\t\tCASE WHEN enabled = 0 THEN \r\n\t\t\tCONCAT('<i class=\\'btn fa fa-question-circle fa-2x\\' style=\\'color:lightgrey;\\'></i>')\r\n\t\tELSE\r\n\t\t\tCONCAT('<a href=\\'casestatus.php?questionnaire_id=',questionnaire_id,'\\' class=\\'btn\\' title=\\'" . TQ_("Case status and assignment") . "\\' data-toggle=\\'tooltip\\'><i class=\\'fa fa-question-circle fa-2x\\'></i></a>')\r\n\t\tEND as casestatus\r\n\t\tFROM questionnaire"; $rs = $db->GetAll($sql); $columns = array("qid", "description", "status", "enabledisable", "outcomes", "calls", "casestatus", "shifts", "assample", "quotareport", "dataout", "modify", "setoutcomes", "inlime", "prefill", "deletee"); xhtml_table($rs, $columns, false, "table-hover table-condensed "); print "</div>"; } } xhtml_foot($js_foot); ?> <script type="text/javascript"> $('[data-toggle="confirmation"]').confirmation(); </script>
$sql = "INSERT INTO case_note (case_id,operator_id,note,`datetime`)\r\n VALUES ('{$r['case_id']}',1,'" . TQ_("System automatically closed case as not closed for more than 24 hours") . "', CONVERT_TZ(NOW(),'System','UTC'))"; $db->Execute($sql); //finish the call attempt $sql = "UPDATE `call_attempt` \r\n SET end = start\r\n WHERE call_attempt_id = '{$r['call_attempt_id']}'"; $db->Execute($sql); print T_("System automatically closed case as not closed for more than 24 hours") . " - " . T_("Case id") . ": {$r['case_id']}"; } //find all calls without an end that started more than 24 hours ago $sql = "SELECT case_id, call_id\r\n FROM `call` \r\n WHERE TIMESTAMPDIFF(HOUR, start, CONVERT_TZ(NOW(),'System','UTC')) > 24\r\n AND end IS NULL"; $rs = $db->GetAll($sql); foreach ($rs as $r) { //refer to supervisor if case still assigned $sql = "UPDATE `case`\r\n SET current_operator_id = NULL, current_outcome_id = 5, current_call_id = NULL\r\n WHERE case_id = '{$r['case_id']}'\r\n AND current_operator_id IS NOT NULL"; $db->Execute($sql); //add note $sql = "INSERT INTO case_note (case_id,operator_id,note,`datetime`)\r\n VALUES ('{$r['case_id']}',1,'" . TQ_("System automatically closed case as not closed for more than 24 hours") . "', CONVERT_TZ(NOW(),'System','UTC'))"; $db->Execute($sql); //finish the call $sql = "UPDATE `call` \r\n SET end = start, outcome_id = 5, state = 5\r\n WHERE call_id = '{$r['call_id']}'"; $db->Execute($sql); print T_("System automatically closed case as not closed for more than 24 hours") . " - " . T_("Case id") . ": {$r['case_id']}"; } $result = $db->CompleteTrans(); $time_end = microtime(true); $timer = $time_end - $time_start; if ($result) { print T_("Completed case closing") . ". " . T_("This task took") . ": {$timer} " . T_("seconds"); } else { print T_("Failed to complete case closing") . ". " . T_("This task took") . ": {$timer} " . T_("seconds"); } }
} print "</form>"; } print "</div></div>"; } else { $sql = "SELECT questionnaire_sample_quota_row_id,qsq.description,\r\n CONCAT(' <a href=\\'?edit=edit&qsqri=',questionnaire_sample_quota_row_id,'\\'><i class=\"fa fa-pencil-square-o fa-lg text-danger\"></i></a> ') as qedit,\r\n CONCAT('<div class=\\'text-center\\'><input type=\\'checkbox\\' name=\\'select_',questionnaire_sample_quota_row_id,'\\'/></div>') as qselect,\r\n qsq.completions,qsq.quota_reached,qsq.current_completions,\r\n CASE WHEN qsq.autoprioritise = 1 THEN '" . TQ_("Yes") . "' ELSE '" . TQ_("No") . "' END AS ap, qsq.priority,\r\n CASE WHEN qsq.quota_reached = 1 THEN '" . TQ_("closed") . "' ELSE '" . TQ_("open") . "' END AS status\r\n FROM questionnaire_sample_quota_row as qsq, questionnaire as q\r\n \t\t\tWHERE qsq.questionnaire_id = '{$questionnaire_id}'\r\n \t\t\tAND qsq.sample_import_id = '{$sample_import_id}'\r\n \t\t\tAND q.questionnaire_id = '{$questionnaire_id}'"; $r = $db->GetAll($sql); if (empty($r)) { print "<p class='well text-info col-lg-12'>" . T_("Currently no row quotas") . "</p>"; } else { print "<form method='post' action='?questionnaire_id={$questionnaire_id}&sample_import_id={$sample_import_id}'>"; print "<div class='col-sm-12 panel-body'></br><h2>" . T_("Current row quotas") . "</h2><div class='pull-left'>"; xhtml_table($r, array('description', 'qedit', 'completions', 'current_completions', 'status', 'priority', 'ap', 'qselect'), array(T_("Description"), " <i class='fa fa-pencil-square-o fa-lg' data-toggle='tooltip' title='" . T_("Edit") . "'></i> ", T_("Quota"), T_("Completions"), T_("Status"), T_("Priority"), T_("Auto prioritise"), " <i class='fa fa-check-square-o fa-lg' data-toggle='tooltip' title='" . T_("Select") . "'></i> ")); print "</div><div class='pull-left'></br>"; print "<button class='btn btn-default col-sm-offset-2' type='submit' name='submitexport'><i class=\"fa fa-download fa-lg text-primary\"></i> " . TQ_("Export selected") . "</button></br></br>"; print "<button class='btn btn-default col-sm-offset-2' type='submit' name='submitdelete'><i class=\"fa fa-trash-o fa-lg text-danger\"></i> \r\n" . TQ_("Delete selected") . "</button></div></div>"; print "</form>"; } print "<div class='col-sm-8 panel-body'><h2>" . T_("Add row quota") . "</h2>"; ?> <form action="?<?php echo "questionnaire_id={$questionnaire_id}&sample_import_id={$sample_import_id}"; ?> " method="post" class="form-inline table"> <p><label for="description" class="control-label"><?php echo T_("Describe this quota"); ?> :  </label><input type="text" class="form-control" name="description" id="description" required size="70"/></p> <p><label for="priority" class="control-label"><?php echo T_("Quota priority (50 is default, 100 highest, 0 lowest)"); ?>
} header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Pragma: public"); // HTTP/1.0 if (isset($_GET['winbat'])) { echo "voipclient.exe -i -u {$rs['ext']} -p {$rs['password']} -h " . $_SERVER['SERVER_NAME']; } else { echo "./voipclient -i -u {$rs['ext']} -p {$rs['password']} -h " . $_SERVER['SERVER_NAME']; } } } } if ($display) { $sql = "SELECT operator_id,\r\n CONCAT(firstName, ' ', lastName) as name, \r\n\tCONCAT ('<a href=\\'extensionstatus.php?edit=',e.extension_id,'\\'>', e.extension ,'</a>') as `extension`,\r\n\tCONCAT('<a href=\\'?winbat=winbat&operator_id=',operator_id,'\\'>" . TQ_("Win .bat file") . "</a>') as winbat,\r\n\tCONCAT('<a href=\\'?sh=sh&operator_id=',operator_id,'\\'>" . TQ_("*nix script file") . "</a>') as sh,\r\n\tCASE WHEN enabled = 0 THEN\r\n\t\tCONCAT(' <a href=\\'?enable=',operator_id,'\\'><i data-toggle=\\'tooltip\\' title=\\'" . TQ_("Enable") . "\\' class=\\'fa fa-toggle-off fa-2x\\' style=\\'color:grey;\\'></i></a> ') \r\n\tELSE\r\n\t\tCONCAT(' <a href=\\'?disable=',operator_id,'\\'><i data-toggle=\\'tooltip\\' title=\\'" . TQ_("Disable") . "\\' class=\\'fa fa-toggle-on fa-2x\\'></i></a> ')\r\n\tEND as enabledisable,\r\n\tCASE WHEN voip = 0 THEN\r\n\t\tCONCAT('<a href=\\'?voipenable=',operator_id,'\\'>" . TQ_("Enable VoIP") . "</a>') \r\n\tELSE\r\n\t\tCONCAT('<a href=\\'?voipdisable=',operator_id,'\\'>" . TQ_("Disable VoIP") . "</a>') \r\n\tEND as voipenabledisable,\r\n\tCONCAT(' <a href=\\'?edit=',operator_id,'\\'><i data-toggle=\\'tooltip\\' title=\\'" . TQ_("Edit") . "\\' class=\\'fa fa-pencil-square-o fa-lg\\'></i></a> ') as edit, username\r\n FROM operator\r\n LEFT JOIN `extension` as e ON (e.current_operator_id = operator_id)"; $rs = $db->GetAll($sql); xhtml_head(T_("Operator list"), true, array("../include/bootstrap/css/bootstrap.min.css", "../include/font-awesome/css/font-awesome.css", "../css/custom.css")); $columns = array("operator_id", "name", "username", "extension", "enabledisable", "edit"); $titles = array("ID", T_("Operator"), T_("Username"), T_("Extension"), " <i class='fa fa-lg fa-power-off '></i>", " <i class='fa fa-lg fa-pencil-square-o'></i>"); if (VOIP_ENABLED) { $columns[] = "voipenabledisable"; $columns[] = "winbat"; $columns[] = "sh"; $titles[] = T_("VoIP ON/Off"); $titles[] = T_("Win file"); //Windows VoIP $titles[] = T_("*nix flle"); //*nix VoIP } echo "<div class='col-lg-9'><div class='panel-body'>";
print " <a href='displayappointments.php?case_id={$case_id}&rtz={$rtz}&new=new' class='btn btn-default'><i class='fa fa-clock-o fa-lg'></i> " . T_("Create appointment") . "</a>"; } print "</div>"; //view calls and outcomes $sql = "SELECT DATE_FORMAT(CONVERT_TZ(c.start,'UTC',r.Time_zone_name),'" . DATE_TIME_FORMAT . "') as start,CONVERT_TZ(c.end,'UTC',r.Time_zone_name) as end, CONCAT(op.firstName,' ',op.lastName) as firstName, o.description as des, CONCAT(' <a href=\\'?case_id={$case_id}&call_id=', c.call_id, '\\' data-toggle=\\'tooltip\\' title=\\'" . TQ_("Change outcome") . "\\'><i class=\\'fa fa-edit fa-lg \\'></i></a>') as link, cp.phone as phone\r\n\t\t\tFROM `call` as c\r\n\t\t\tJOIN (operator as op, outcome as o, respondent as r, contact_phone as cp) on (c.operator_id = op.operator_id and c.outcome_id = o.outcome_id and r.respondent_id = c.respondent_id and cp.contact_phone_id = c.contact_phone_id)\r\n\t\t\tWHERE c.case_id = '{$case_id}'\r\n\t\t\tORDER BY c.start DESC"; $rs = $db->GetAll($sql); print "<div class='panel-body col-sm-6'><h4 class=''><i class='fa fa-phone'></i> " . T_("Call list") . "</h4>"; if (empty($rs)) { print "<div class='alert text-info' role='alert'><h4>" . T_("No calls made") . "</h4></div>"; } else { translate_array($rs, array("des")); xhtml_table($rs, array("start", "phone", "firstName", "des", "link"), array(T_("Date/Time"), T_("Phone number"), T_("Operator"), T_("Outcome"), " <i class='fa fa-edit fa-lg'></i> ")); } print "</div>"; //view notes $sql = "SELECT DATE_FORMAT(CONVERT_TZ(c.datetime,'UTC',op.Time_zone_name),'" . DATE_TIME_FORMAT . "') as time, CONCAT(op.firstName,' ',op.lastName) as firstName, c.note as note, CONCAT('<a href=\\'\\' data-toggle=\\'confirmation\\' data-placement=\\'left\\' data-href=\\'?case_id={$case_id}&case_note_id=', c.case_note_id, '\\' class=\\'btn center-block\\' ><i class=\\'fa fa-trash fa-lg text-danger\\' data-toggle=\\'tooltip\\' title=\\'" . TQ_("Delete") . "\\'></i></a>') as link \r\n\t\t\tFROM `case_note` as c\r\n\t\t\tJOIN (operator as op) on (c.operator_id = op.operator_id)\r\n\t\t\tWHERE c.case_id = '{$case_id}'\r\n\t\t\tORDER BY c.datetime DESC"; $rs = $db->GetAll($sql); print "<div class='panel-body col-sm-6'><h4 class=''><i class='fa fa-file-text'></i> " . T_("Case notes") . "</h4>"; if (empty($rs)) { print "<p class='alert text-info'>" . T_("No notes") . "</p>"; } else { xhtml_table($rs, array("time", "firstName", "note", "link"), array(T_("Date/Time"), T_("Operator"), T_("Note"), " <i class='fa fa-trash fa-lg'></i> ")); print "<br/>"; } //add a note ?> <form method="get" action="?" class="form-inline" > <input type="hidden" name="case_id" value="<?php echo $case_id; ?> "/>
print "<thead><tr><th>" . T_("Day") . "</th><th>" . T_("Start") . "</th> <th>" . T_("End") . "</th><th>" . T_("Use shift?") . "</th></tr></thead>"; $count = 1; foreach ($shifts as $shift) { $checked = ""; $shift_id = ""; $prefix = ""; if (!empty($shift['shift_id'])) { $checked = "checked=\"checked\""; $shift_id = $shift['shift_id']; } else { $shift_id = $count; $prefix = "NEW_"; } print "<tr><td>"; display_chooser($daysofweek, $prefix . "dow_{$shift_id}", false, true, false, false, false, array("dt", $shift['dt'])); print "</td><td><div class=\"input-group clockpicker\"><input readonly size=\"8\" name=\"" . $prefix . "start_{$shift_id}\" maxlength=\"8\" type=\"time\" value=\"{$shift['start']}\" class=\"form-control \"/><span class=\"input-group-addon\"><span class=\"glyphicon glyphicon-time fa\"></span></span></div></td><td><div class=\"input-group clockpicker\"><input readonly name=\"" . $prefix . "end_{$shift_id}\" type=\"text\" size=\"8\" maxlength=\"8\" value=\"{$shift['end']}\" class=\"form-control\"/><span class=\"input-group-addon\"><span class=\"glyphicon glyphicon-time fa\"></span></span></div></td><td class=\"text-center\"><input name=\"" . $prefix . "use_{$shift_id}\" type=\"checkbox\" class=\"form-control fa\" data-toggle=\"toggle\" data-size=\"\" data-on=" . TQ_("Yes") . " data-off=" . TQ_("No") . " {$checked}/></td></tr>"; $count++; } ?> <!--<tr><td/><td/><td/><td>Select all</td></tr>--> </table></br> <!--<p><input type="submit" name="addshift" value="Add Shift"/></p>--> <input type="submit" name="submit" value="<?php echo T_("Save changes"); ?> " class="btn btn-primary"/> <input type="hidden" name="year" value="<?php echo $year; ?> "/> <input type="hidden" name="woy" value="<?php
unset($_POST['dtzph']); $db->CompleteTrans(); } xhtml_foot($js_foot); exit; } if (isset($_GET['sampledisable'])) { $id = intval($_GET['sampledisable']); $sql = "UPDATE sample_import\r\n\t\tSET enabled = 0\r\n\t\tWHERE sample_import_id = '{$id}'"; $db->Execute($sql); } if (isset($_GET['sampleenable'])) { $id = intval($_GET['sampleenable']); $sql = "UPDATE sample_import\r\n\t\tSET enabled = 1\r\n\t\tWHERE sample_import_id = '{$id}'"; $db->Execute($sql); } $sql = "SELECT\r\n\tCONCAT(' <b class=\\'badge\\'>',sample_import_id,'</b> ') as id,\r\n\tCASE WHEN enabled = 0 THEN\r\n\t\tCONCAT('  <span class=\\'btn label label-default\\'>" . TQ_("Disabled") . "</span> ') \r\n\tELSE\r\n\t\tCONCAT('  <span class=\\'btn label label-primary\\'>" . TQ_("Enabled") . "</span> ') \r\n\tEND as status,\r\n\tCASE WHEN enabled = 0 THEN\r\n\t\tCONCAT('<a href=\\'?sampleenable=',sample_import_id,'\\' class=\\'btn btn-default col-sm-12\\'>" . TQ_("Enable") . " <i class=\\'fa fa-play fa-lg\\' style=\\'color:blue;\\'></i></a>') \r\n\tELSE\r\n\t\tCONCAT('<a href=\\'\\' class=\\'btn btn-default col-sm-12\\' data-toggle=\\'confirmation\\' data-href=\\'?sampledisable=',sample_import_id,'\\' data-title=\\'" . TQ_("ARE YOU SURE?") . "\\' data-btnOkLabel=\\'" . TQ_("Yes") . "\\' data-btnCancelLabel=\\'" . TQ_("Cancel") . "\\'><i class=\\'fa fa-ban fa-lg\\' style=\\'color:red;\\'></i>  " . TQ_("Disable") . "</a> ') \r\n\tEND\r\n\tas enabledisable,\r\n\tCASE WHEN enabled = 1 THEN\r\n\t\tCONCAT('<a href=\\'?edit=',sample_import_id,'\\' class=\\'btn btn-default btn-block\\' data-toggle=\\'tooltip\\' title=\\'" . TQ_("Edit") . " " . TQ_("Viewing permissions") . "\\'><i class=\\'fa fa-eye fa-lg fa-fw \\'></i></a>')\r\n\tELSE\r\n\t\tCONCAT('<a href=\\'?edit=',sample_import_id,'\\' class=\\'btn btn-default \\' data-toggle=\\'tooltip\\' title=\\'" . TQ_("Edit sample parameters") . "\\'><i class=\\'fa fa-eye fa-lg fa-fw text-primary\\'></i> + <i class=\\'fa fa-edit fa-lg fa-fw text-primary\\'></i> + <i class=\\'fa fa-minus-circle fa-lg fa-fw text-danger \\'></i></a>')\r\n\tEND as did,\r\n\tCASE WHEN enabled = 1 THEN\r\n\t\tCONCAT('<a href=\\'\\' class=\\'btn btn-default disabled\\'><i class=\\'fa fa-trash fa-lg fa-fw\\' style=\\'color:grey;\\'></i></a>')\r\n\tELSE\r\n\t\tCONCAT('<a href=\\'\\' class=\\'btn btn-default \\' data-toggle=\\'confirmation\\' data-href=\\'?delete_sample=',sample_import_id,'\\' data-title=\\'" . TQ_("ARE YOU SURE?") . "\\' data-btnOkLabel=\\'" . TQ_("Yes") . "\\' data-btnCancelLabel=\\'" . TQ_("Cancel") . "\\' ><i class=\\'fa fa-trash fa-lg fa-fw text-danger \\' data-toggle=\\'tooltip\\' title=\\'" . TQ_("DELETE SAMPLE") . "\\'></i></a>')\r\n\tEND as delsample,\r\n\tCONCAT('<a href=\\'samplesearch.php?sample_import_id=',sample_import_id,'\\' class=\\'btn btn-default\\' data-toggle=\\'tooltip\\' title=\\'" . TQ_("Search the sample") . "',sample_import_id,'\\'><i class=\\'fa fa-search fa-lg fa-fw text-primary\\'></i></a>') as ssearch,\r\n\tCONCAT('<a href=\\'callhistory.php?sample_import_id=',sample_import_id,'\\' class=\\'btn btn-default\\' data-toggle=\\'tooltip\\' title=\\'" . TQ_("Call history") . " \n" . TQ_("sample") . " ',sample_import_id,'\\'><i class=\\'fa fa-phone fa-lg text-primary\\'></i></a>') as calls,\r\n\tCONCAT('<h4>',description,' </h4>') as description,\r\n\tCONCAT('<h4 class=\\'fa fa-lg text-primary pull-right\\'>',(SELECT COUNT( DISTINCT`sample_var`.sample_id) FROM `sample_var`, `sample` WHERE `sample`.sample_id = `sample_var`.sample_id AND `sample`.import_id = sample_import_id ),' </h4>') as cnt\r\n\tFROM sample_import ORDER BY sample_import_id DESC"; $rs = $db->GetAll($sql); $subtitle = T_("Sample list"); xhtml_head(T_("Sample management"), true, $css, $js_head, false, false, false, $subtitle); echo "<div class='form-group'>\r\n\t\t<a href='' onclick='history.back();return false;' class='btn btn-default'><i class='fa fa-chevron-left fa-lg text-primary'></i> " . T_("Go back") . "</a>\r\n\t\t<a href='import.php' class='btn btn-default col-sm-offset-4' ><i class='fa fa-upload fa-lg'></i> " . T_("Import a sample file") . "</a>\r\n\t</div>"; $columns = array("id", "description", "cnt", "status", "enabledisable", "calls", "did", "ssearch", "delsample"); //"vp","rname", //$titles = array(T_("ID"),T_("Sample"),T_("Records"), T_("Call History"),T_("Enable/Disable"), T_("Status"), T_("Deidentify"), T_("View"), T_("Rename"), T_("Search"), T_("Delete sample")); xhtml_table($rs, $columns, false, "table-hover table-condensed "); xhtml_foot($js_foot); ?> <script type="text/javascript"> $('[data-toggle="confirmation"]').confirmation(); </script>
display_chooser($ops, "require_operator_id", "require_operator_id", false, false, false, true, false, true, "pull-left"); print "\t<input type='hidden' value='{$appointment_id}' id='appointment_id' name='appointment_id'/>\r\n\t\t\t\t\t<input type='hidden' value='update' id='update' name='update'/>\r\n\t\t\t\t\t<input type='hidden' value='{$case_id}' id='case_id' name='case_id'/>"; if (isset($_GET['new']) && $_GET['new'] == 'new') { print "<input type='hidden' value='create' id='new' name='new'/>"; } print "<div class='clearfix'></div><br/><br/>\r\n\t\t\t\t<div class='col-lg-2'><a href='?' class='btn btn-default pull-left'><i class='fa fa-ban fa-lg'></i> " . T_("Cancel edit") . "</a></div>"; print "<div class='col-lg-2'>\r\n\t\t\t\t\t<button type='submit' class='btn btn-primary btn-block'><i class='fa fa-floppy-o fa-lg'></i> " . T_("Save changes") . "</button>\r\n\t\t\t\t\t</div>"; print "<div class='col-lg-2'><a href='' class='btn btn-default pull-right' toggle='confirmation' data-placement='left' data-href='?delete=delete&appointment_id={$appointment_id}&case_id={$case_id}' ><i class='fa fa-trash fa-lg text-danger'></i> " . T_("Delete this appointment") . "</a></div>"; print "</form>"; } } else { $operator_id = get_operator_id(); $subtitle = T_("Appointments"); xhtml_head(T_("Display Appointments"), true, $css, $js_head, false, 30); print "<h3>" . T_("All appointments (with times displayed in your time zone)") . "</h3>"; $sql = "SELECT q.description, si.description as smpl, CONVERT_TZ(a.start,'UTC',@@session.time_zone) as start, CONVERT_TZ(a.end,'UTC',@@session.time_zone) as end,CONCAT(r.firstName, ' ', r.lastName) as resp, IFNULL(ou.description,'" . TQ_("Not yet called") . "') as outcome, oo.firstName as makerName, ooo.firstName as callerName, \r\n\tCONCAT('<a href=\\'supervisor.php?case_id=', c.case_id, '\\'>', c.case_id, '</a>') as case_id, \r\n\tCONCAT(' <a href=\\'\\'><i class=\\'fa fa-trash-o fa-lg text-danger\\' toggle=\\'confirmation\\' data-placement=\\'left\\' data-href=\\'?case_id=', c.case_id, '&appointment_id=', a.appointment_id, '&delete=delete\\' ></i></a> ') as link, \r\n\tCONCAT(' <a href=\\'?case_id=', c.case_id, '&appointment_id=', a.appointment_id, '\\'><i class=\\'fa fa-pencil-square-o fa-lg\\' ></i></a> ') as edit,IFNULL(ao.firstName,'" . TQ_("Any operator") . "') as witho \r\n\tFROM appointment as a \r\n\tJOIN (`case` as c, respondent as r, questionnaire as q, operator as oo, call_attempt as cc, `sample` as s, sample_import as si) on (c.sample_id = s.sample_id and a.case_id = c.case_id and a.respondent_id = r.respondent_id and q.questionnaire_id = c.questionnaire_id and a.call_attempt_id = cc.call_attempt_id and cc.operator_id = oo.operator_id and si.sample_import_id = s.import_id) \r\n\tLEFT JOIN (`call` as ca, outcome as ou, operator as ooo) ON (ca.call_id = a.completed_call_id and ou.outcome_id = ca.outcome_id and ca.operator_id = ooo.operator_id) \r\n\tLEFT JOIN operator AS ao ON ao.operator_id = a.require_operator_id \r\n\tLEFT JOIN (questionnaire_sample_quota as qsq) on (s.import_id = qsq.sample_import_id and c.questionnaire_id = qsq.questionnaire_id)\r\n\tLEFT JOIN (questionnaire_sample_quota_row as qsqr) on (s.import_id = qsqr.sample_import_id and c.questionnaire_id = qsqr.questionnaire_id)\r\n\tWHERE q.enabled=1 AND si.enabled=1 AND a.end >= CONVERT_TZ(NOW(),'System','UTC') AND c.current_outcome_id IN (19,20,21,22)\r\n\tAND (qsq.quota_reached IS NULL OR qsq.quota_reached != 1)\r\n\tAND (qsqr.quota_reached IS NULL OR qsqr.quota_reached != 1)\r\n\tGROUP BY c.case_id ORDER BY a.start ASC"; $rs = $db->GetAll($sql); if (!empty($rs)) { translate_array($rs, array("outcome")); xhtml_table($rs, array("description", "smpl", "case_id", "start", "end", "edit", "makerName", "witho", "resp", "outcome", "callerName", "link"), array(T_("Questionnaire"), T_("Sample"), T_("Case ID"), T_("Start"), T_("End"), " <i class='fa fa-pencil-square-o fa-lg' data-toggle='tooltip' title='" . T_("Edit") . "'></i> ", T_("Created by"), T_("Appointment with"), T_("Respondent"), T_("Current outcome"), T_("Operator who called"), " <i class='fa fa-trash-o fa-lg' data-toggle='tooltip' title='" . T_("Delete") . "'></i> "), "tclass", false, false, "bs-table"); } else { print "<h4 class='well text-info'>" . T_("No future appointments") . "</h4>"; } print "<h3 style='color:red'>" . T_("Missed appointments (with times displayed in your time zone)") . "</h3>"; $sql = "SELECT q.description, si.description as smpl, CONVERT_TZ(a.start,'UTC',@@session.time_zone) as start, CONVERT_TZ(a.end,'UTC',@@session.time_zone) as end, CONCAT(r.firstName, ' ', r.lastName) as resp, \r\n\tCONCAT('<a href=\\'supervisor.php?case_id=', c.case_id, '\\'>', c.case_id, '</a>') as case_id, \r\n\tCONCAT(' <a href=\\'\\'><i class=\\'fa fa-trash-o fa-lg text-danger\\' toggle=\\'confirmation\\' data-placement=\\'left\\' data-href=\\'?case_id=', c.case_id, '&appointment_id=', a.appointment_id, '&delete=delete\\' ></i></a> ') as link, \r\n\tCONCAT(' <a href=\\'?case_id=', c.case_id, '&appointment_id=', a.appointment_id, '\\'><i class=\\'fa fa-pencil-square-o fa-lg\\' ></i></a> ') as edit \r\n\tFROM appointment as a \r\n\tJOIN (`case` as c, respondent as r, questionnaire as q, `sample` as s, sample_import as si) on (a.case_id = c.case_id and a.respondent_id = r.respondent_id and q.questionnaire_id = c.questionnaire_id and s.sample_id = c.sample_id and s.import_id= si.sample_import_id) \r\n\tLEFT JOIN (`call` as ca) ON (ca.call_id = a.completed_call_id)\r\n\tLEFT JOIN (questionnaire_sample_quota as qsq) on (s.import_id = qsq.sample_import_id and c.questionnaire_id = qsq.questionnaire_id)\r\n\tLEFT JOIN (questionnaire_sample_quota_row as qsqr) on (s.import_id = qsqr.sample_import_id and c.questionnaire_id = qsqr.questionnaire_id)\r\n\tWHERE q.enabled=1 AND si.enabled=1 AND a.end < CONVERT_TZ(NOW(),'System','UTC') AND a.completed_call_id IS NULL AND c.current_outcome_id IN (19,20,21,22)\r\n\tAND (qsq.quota_reached IS NULL OR qsq.quota_reached != 1 )\r\n\tAND (qsqr.quota_reached IS NULL OR qsqr.quota_reached != 1)\r\n\tGROUP BY c.case_id\r\n\tORDER BY a.start ASC"; $rs = $db->GetAll($sql); if (!empty($rs)) { xhtml_table($rs, array("description", "smpl", "case_id", "start", "end", "edit", "resp", "link"), array(T_("Questionnaire"), T_("Sample"), T_("Case ID"), T_("Start"), T_("End"), " <i class='fa fa-pencil-square-o fa-lg' data-toggle='tooltip' title='" . T_("Edit") . "'></i> ", T_("Respondent"), " <i class='fa fa-trash-o fa-lg' data-toggle='tooltip' title='" . T_("Delete") . "'></i> "), "tclass", false, false, "bs-table"); } else { print "<h4 class='well text-info'>" . T_("No missed appointments") . "</h4>"; }
/** * Display an XHTML table of the CSV data header * * @param array $data Header data from a CSV file * * @see get_first_row() * */ function display_table($data) { print "<table class='table-hover table-bordered table-condensed tclass'><thead class='highlight'>"; print "<tr><th>" . T_("Selected file column name") . "</th><th>" . T_("Import ?") . "</th><th class='col-sm-4'>" . T_("New Sample Variable Name") . "</th><th>" . T_("Variable Type") . "</th><th>" . T_("Show to operator?") . "</th></tr></thead><tbody>"; $row = 1; global $db; $sql = "SELECT description,type\r\n\t\tFROM sample_var_type ORDER BY type ASC"; $rs = $db->GetAll($sql); foreach ($data as $key => $value) { $val = str_replace(" ", "_", $value); $checked = "checked"; if (empty($val)) { $val = "samp_{$row}"; } print "<tr><td>{$value}</td>\r\n\t\t\t\t\t<td class='text-center'><input type=\"checkbox\" name=\"i_{$row}\" checked=\"{$checked}\" data-toggle=\"toggle\" data-size=\"small\" data-on=\"" . TQ_("Yes") . "\" data-off=" . TQ_("No") . " /></td>\r\n\t\t\t\t\t<td><input type=\"text\" value=\"{$val}\" name=\"n_{$row}\" class=\"form-control\" /></td>\r\n\t\t\t\t\t<td>"; print "<select name=\"t_{$row}\" class=\"form-control\">"; //print "<option value=\"\" $selected></option>"; $selected = "selected=\"selected\""; foreach ($rs as $r) { print "<option value=\"{$r['type']}\" {$selected}>" . T_($r['description']) . "</option>"; $selected = ""; } print "</select></td>"; print "<td class=\"text-center\"><input type=\"checkbox\" name=\"a_{$row}\" data-toggle=\"toggle\" data-size=\"small\" data-on=\"" . TQ_("Yes") . "\" data-off=" . TQ_("No") . " /></td>"; print "</tr>"; $row++; } print "</tbody></table>"; }
} $jsfunctocall = ""; $texttodisplay = ""; $endtexttodisplay = ""; if ($contact_phone_id !== false) { //got a number to dial so initiate the countdown to begin dialing $texttodisplay = TQ_("Will dial in"); $endtexttodisplay = TQ_("Dialling now"); $jsfunctocall = "document.location.href = 'nocallavailable.php?contact_phone=" . $contact_phone_id . "';"; } else { //no more numbers to dial so initiate the countdown to end the case $texttodisplay = TQ_("Will end case in"); $endtexttodisplay = TQ_("Ending case now"); $jsfunctocall = "openParent('endcase=endcase');"; } print "<div id='timer'></div>"; print " <script type='text/javascript'>\r\n var count=" . AUTO_DIAL_SECONDS . ";\r\n var counter=setInterval(timer, 1000); \r\n \r\n function timer()\r\n {\r\n count=count-1;\r\n if (count <= 0)\r\n {\r\n clearInterval(counter);\r\n document.getElementById('timer').innerHTML='" . $endtexttodisplay . "';\r\n " . $jsfunctocall . " \r\n return;\r\n }\r\n document.getElementById('timer').innerHTML='" . $texttodisplay . " ' + count + ' " . TQ_("seconds") . "';\r\n }\r\n\r\n window.onload = function()\r\n {\r\n timer();\r\n }\r\n </script>"; } else { //voip extension not active print "<div>" . T_("Your VoIP extension is not active. Please activate VoIP by clicking once on the red button that says 'VoIP Off'") . "</div>"; } } else { //voip isn't enabled so can't auto dial print "<div>" . T_("Auto dialling unavailable as VoIP is not enabled") . "</div>"; } } else { //on a call so can't proceed print "<div>" . T_("Auto dialling unavailable as you are already on a call") . "</div>"; } } xhtml_foot();
$sql = "DELETE FROM availability\r\n\t\tWHERE availability_group_id = {$availability_group}"; $db->Execute($sql); $sql = "DELETE FROM questionnaire_availability\r\n\t\tWHERE availability_group_id = {$availability_group}"; $db->Execute($sql); $sql = "DELETE FROM availability_group\r\n\t\tWHERE availability_group_id = {$availability_group}"; $db->Execute($sql); $db->CompleteTrans(); } else { if (isset($_POST['availability_group'])) { $availability_group = $db->qstr($_POST['availability_group']); $sql = "INSERT INTO `availability_group` (availability_group_id,description)\r\n\t\tVALUES (NULL,{$availability_group})"; $db->Execute($sql); } } //view groups $sql = "SELECT availability_group_id,description,\r\n\tCONCAT('<a href=\\'availability.php?availability_group=', availability_group_id, '\\'>" . TQ_("Modify") . "</a>') as link \r\n\tFROM availability_group"; $rs = $db->GetAll($sql); print "<div class='well'>" . T_("Time slots define periods of time during particular days of the week. These are used for the availability function and also the call attempt time slot function.") . "</div>"; if (empty($rs)) { print "<div class='alert alert-danger'>" . T_("No time slots") . "</div>"; } else { print "<div class='panel-body col-sm-6'>"; xhtml_table($rs, array("availability_group_id", "description", "link"), array(T_("ID"), T_("Time slot name"), T_("Modify")), "table table-hover"); print "</div>"; } //add a time slot (ex- availablity group) ?> <div class=" panel-body col-sm-4"><form method="post" action="?"> <h3><?php echo T_("Add new time slot"), " :"; ?>
$abtn = T_("Add custom Outcome"); $sbtn = T_("Save questionnaire outcomes"); $class = "tclass"; } } /* for default outcomes */ if (isset($_GET['default'])) { /* allow delay edit only to superadmins (currenlty admin) */ if ($_SESSION['user'] === "admin") { $delay = "CONCAT('<input type=\\'number\\' name=\"delay[', o.outcome_id ,']\" class=\\'form-control text-right\\' style=\\'width:6em;\\' max=50000 min=0 required value=\\'', o.default_delay_minutes ,'\\' />') "; $delete = "CASE WHEN o.outcome_id >= 100 THEN CONCAT('<input type=\\'checkbox\\' class=\\' \\' data-onstyle=\"danger\" title=\\'" . TQ_("Delete outcome") . " ?\\' name=\"delete[', o.outcome_id ,']\" data-toggle=\"toggle\" data-size=\"small\" data-style=\"center-block\" data-on=" . TQ_("Yes") . " data-off=" . TQ_("No") . " data-width=\"60\" />') ELSE '' END as `delete`,"; } else { $delay = "CONCAT('<span class=\\'pull-right\\' >', o.default_delay_minutes ,' </span>')"; $delete = ""; } $sql = "SELECT o.*, ot.description as type, {$delay} as `delay`, {$delete} \r\n\t\t\tCONCAT('<h4> <span class=\"label label-', CASE WHEN o.tryanother = 1 THEN 'primary\">" . T_("Yes") . "' ELSE 'default\">" . T_("No") . "' END , '</span></h4>') as tryanother,\r\n\t\t\tCONCAT('<h4> <span class=\"label label-', CASE WHEN o.tryagain = 1 THEN 'primary\">" . T_("Yes") . "' ELSE 'default\">" . T_("No") . "' END , '</span></h4>') as tryagain,\r\n\t\t\tCONCAT('<h4> <span class=\"label label-', CASE WHEN o.contacted = 1 THEN 'primary\">" . T_("Yes") . "' ELSE 'default\">" . T_("No") . "' END , '</span></h4>') as contacted,\r\n\t\t\tCONCAT('<h4> <span class=\"label label-', CASE WHEN o.eligible = 1 THEN 'primary\">" . T_("Yes") . "' ELSE 'default\">" . T_("No") . "' END , '</span></h4>') as eligible,\r\n\t\t\tCONCAT('<h4> <span class=\"label label-', CASE WHEN o.require_note = 1 THEN 'primary\">" . T_("Yes") . "' ELSE 'default\">" . T_("No") . "' END , '</span></h4>') as require_note,\t\t\t\r\n\t\t\tCONCAT('<input type=\\'checkbox\\' ', CASE WHEN o.default = 1 THEN 'checked=\"checked\"' ELSE '' END ,' ', CASE WHEN o.permanent = 1 THEN 'disabled=\"disabled\" data-onstyle=\"success\"' ELSE '' END ,' name=\"select[]\" value=\\'',o.outcome_id,'\\' data-toggle=\"toggle\" data-size=\"small\" data-style=\"center-block\" data-on=" . TQ_("Yes") . " data-off=" . TQ_("No") . " data-width=\"70\" />') as `select`\r\n\t\t\tfrom `outcome` as o, `outcome_type` as ot\r\n\t\t\tWHERE o.outcome_type_id = ot.outcome_type_id \r\n\t\t\tORDER BY `o`.`outcome_id` ASC"; $rs = $db->GetAll($sql); $row = array("outcome_id", "description", "select", "type", "delay", "contacted", "tryanother", "tryagain", "eligible", "require_note"); $hdr = array(T_("Outcome ID"), T_("Description"), T_("Set default") . " ?", T_("Outcome type"), T_("Delay, min"), T_("Contacted") . " ?", T_("Try another") . " ?", T_("Try again") . " ?", T_("Eligible") . " ?", T_("Require note") . " ?"); if ($_SESSION['user'] === "admin") { $row[] = "delete"; $hdr[] = T_("Delete") . " ?"; } $hid = "default"; $value = ""; $h = "default"; $v = ""; $abtn = T_("Add custom Outcome"); $sbtn = T_("Update default outcomes"); $class = "tclass"; }
} } $subtitle = T_("List & Add Sample"); xhtml_head(T_("Assign samples to questionnaires"), true, $css, $js_head, false, false, false, $subtitle); //array("../css/table.css"),array("../js/window.js") print "<a href='' onclick='history.back();return false;' class='btn btn-default pull-left'><i class='fa fa-chevron-left fa-lg text-primary'></i> " . T_("Go back") . "</a>"; $questionnaire_id = false; if (isset($_GET['questionnaire_id'])) { $questionnaire_id = bigintval($_GET['questionnaire_id']); } print "<div class='form-group clearfix'><h2 class='col-lg-4 text-right'><i class='fa fa-link text-primary'></i> " . T_("Select a questionnaire") . "</h2>"; display_questionnaire_chooser($questionnaire_id, false, "pull-left btn", "form-control "); print "</div>"; if ($questionnaire_id != false) { print "<div class='panel-body'>\r\n\t\t\t<h3 class=''><i class='fa fa-list-ul text-primary'></i> " . T_("Samples assigned to questionnaire") . " <span class='text-primary'>" . $db->GetOne("SELECT description from questionnaire WHERE questionnaire_id = {$questionnaire_id}") . "</span></h3>"; $sql = "SELECT q.sort_order, si.description as description,si.sample_import_id, \r\n\t\t\tCASE WHEN q.call_max = 0 THEN '" . TQ_("Unlimited") . "' ELSE q.call_max END as call_max,\r\n\t\t\tCASE WHEN q.call_attempt_max = 0 THEN '" . TQ_("Unlimited") . "' ELSE q.call_attempt_max END AS call_attempt_max,\r\n\t\t\tCASE WHEN q.random_select = 0 THEN '" . TQ_("Sequential") . "' ELSE '" . TQ_("Random") . "' END as random_select,\r\n\t\t\tCASE WHEN q.answering_machine_messages = 0 THEN '" . TQ_("Never") . "' ELSE q.answering_machine_messages END as answering_machine_messages,\r\n\t\t\tCASE WHEN q.allow_new = 0 THEN '" . TQ_("No") . "' ELSE '" . TQ_("Yes") . "' END as allow_new,\r\n\t\t\tCONCAT('<a href=\"?edit=edit&questionnaire_id={$questionnaire_id}&rsid=', si.sample_import_id ,'\" data-toggle=\\'tooltip\\' title=\\'" . TQ_("Edit") . "\\' class=\\'btn center-block\\'><i class=\\'fa fa-pencil-square-o fa-lg\\'></i></a>') as edit,\r\n\t\t\tCONCAT('<a href=\\'\\' data-toggle=\\'confirmation\\' data-title=\\'" . TQ_("Are you sure?") . "\\' data-btnOkLabel=\\' " . TQ_("Yes") . "\\' data-btnCancelLabel=\\' " . TQ_("No") . "\\' data-placement=\\'top\\' data-href=\"?questionnaire_id={$questionnaire_id}&rsid=', si.sample_import_id ,'\" class=\\'btn center-block\\'><i class=\\'fa fa-chain-broken fa-lg\\' data-toggle=\\'tooltip\\' title=\\'" . TQ_("Click to unassign") . "\\'></i></a>') as unassign\r\n\t\t\tFROM questionnaire_sample as q, sample_import as si\r\n\t\t\tWHERE q.sample_import_id = si.sample_import_id\r\n\t\t\tAND q.questionnaire_id = '{$questionnaire_id}'\r\n\t\t\tORDER BY q.sort_order ASC"; $qs = $db->GetAll($sql); if (!empty($qs)) { $co = count($qs); if ($co > 1) { for ($i = 0; $i < $co; $i++) { $down = "<a href='?questionnaire_id={$questionnaire_id}&sort=down&rsid={$qs[$i]['sample_import_id']}' data-toggle=\"tooltip\" title=\"" . T_("Pull step Down") . "\"><i class=\"fa fa-arrow-down fa-lg\"></i></a>"; $up = "<a href='?questionnaire_id={$questionnaire_id}&sort=up&rsid={$qs[$i]['sample_import_id']}' data-toggle=\"tooltip\" title=\"" . T_("Push step Up") . "\"><i class=\"fa fa-arrow-up fa-lg\"></i></a>"; if ($i == 0) { $qs[$i]['sort_order'] = "<div>   <span class=\"badge\">" . $qs[$i]['sort_order'] . "</span> " . $down . "</div>"; } else { if ($i == $co - 1) { $qs[$i]['sort_order'] = "<div style=\"min-width:5em;\"> " . $up . " <span class=\"badge\">" . $qs[$i]['sort_order'] . "</span>"; } else { $qs[$i]['sort_order'] = "<div> " . $up . " <span class=\"badge\">" . $qs[$i]['sort_order'] . "</span> " . $down . "</div>"; }
?> <h1><?php echo T_("There is no case currently available"); ?> </h1> <h2><?php echo T_("Reasons:"); ?> </h2> <?php /** * check for reasons why no case is displayed */ //you have not been assigned to a questionnaire $sql = "SELECT oq.questionnaire_id, q.description, CASE WHEN q.enabled = 1 THEN '" . TQ_("Enabled") . "' ELSE '" . TQ_("Disabled") . "' END as enabled\r\n\tFROM operator_questionnaire as oq, questionnaire as q\r\n\tWHERE oq.operator_id = '{$operator_id}'\r\n\tAND q.questionnaire_id = oq.questionnaire_id\r\n\tAND q.enabled = 1"; $rs = $db->GetAll($sql); ?> <p><?php echo T_("Assigned questionnaires:"); ?> </p> <?php if (!empty($rs)) { xhtml_table($rs, array("questionnaire_id", "description", "enabled"), array(T_("ID"), T_("Description"), T_("Enabled"))); } else { ?> <p class='error'><?php echo T_("ERROR: No questionnaires assigned to you"); ?> </p> <?php
//xhtml_table($rs,array("firstName","completions","totalcalls","time","callt","CPH","CALLSPH","effectiveness"),array(T_("Operator"),T_("Completions"),T_("Calls"),T_("Total time"),T_("Call time"),T_("Completions p/h"),T_("Calls p/h"),T_("Effectiveness"))); $questionnaire_id = false; print "<h3 class='form-inline pull-left'>" . T_("Please select a questionnaire") . " </h3>"; if (isset($_GET['questionnaire_id'])) { $questionnaire_id = bigintval($_GET['questionnaire_id']); } display_questionnaire_chooser($questionnaire_id, false, "form-inline clearfix", "form-control"); if ($questionnaire_id) { $rs = get_stats_total(get_stats_by_questionnaire($questionnaire_id)); print "<h2>" . T_("This project") . "</h2>"; xhtml_table($rs, array("firstName", "completions", "totalcalls", "time", "callt", "CPH", "CALLSPH", "effectiveness"), array(T_("Operator"), T_("Completions"), T_("Calls"), T_("Total time"), T_("Call time"), T_("Completions p/h"), T_("Calls p/h"), T_("Effectiveness"))); $operator_id = get_operator_id(); $shift_id = false; if (isset($_GET['shift_id'])) { $shift_id = bigintval($_GET['shift_id']); } $sql = "SELECT s.shift_id as value,CONCAT(DATE_FORMAT(CONVERT_TZ(s.start,'UTC',o.Time_zone_name),'" . DATE_TIME_FORMAT . "'),' " . TQ_("till") . " ',DATE_FORMAT(CONVERT_TZ(s.end,'UTC',o.Time_zone_name),'" . TIME_FORMAT . "')) as description,CASE WHEN s.shift_id = '{$shift_id}' THEN 'selected=\\'selected\\'' ELSE '' END AS selected\r\n\t\tFROM shift as s\r\n\t\tLEFT JOIN (operator as o) on (o.operator_id = '{$operator_id}')\r\n\t\tWHERE s.questionnaire_id = '{$questionnaire_id}'\r\n\t\tORDER BY s.start ASC"; $rs = $db->GetAll($sql); print "</br><h3 class='form-inline pull-left'>" . T_("Please select a shift") . " </h3>"; display_chooser($rs, "shift_id", "shift_id", true, "questionnaire_id={$questionnaire_id}", true, true, false, true, "form-inline form-group"); //,false,true,false,true,"pull-left" if ($shift_id) { $rs = get_stats_total(get_stats_by_shift($questionnaire_id, $shift_id)); print "<h2>" . T_("This shift") . "</h2>"; xhtml_table($rs, array("firstName", "completions", "totalcalls", "time", "callt", "CPH", "CALLSPH", "effectiveness"), array(T_("Operator"), T_("Completions"), T_("Calls"), T_("Total time"), T_("Call time"), T_("Completions p/h"), T_("Calls p/h"), T_("Effectiveness"))); } } xhtml_foot(); ?>
/** * Authentication */ require "auth-interviewer.php"; /** * XHTML functions */ include_once "functions/functions.xhtml.php"; xhtml_head(T_("Standby"), false, array("include/bootstrap/css/bootstrap.min.css", "include/bootstrap/css/bootstrap-theme.min.css", "include/font-awesome/css/font-awesome.css", "css/index_interface2.css"), array(), false, 300); if (isset($_GET['auto'])) { include_once "functions/functions.operator.php"; $operator_id = get_operator_id(); $case_id = get_case_id($operator_id, false); end_case($operator_id); //add case note $sql = "INSERT INTO case_note (case_note_id,case_id,operator_id,note,`datetime`)\r\n VALUES (NULL,'{$case_id}','{$operator_id}','" . TQ_("Operator Automatically logged out after: ") . AUTO_LOGOUT_MINUTES . TQ_(" minutes") . "', CONVERT_TZ(NOW(),'System','UTC'))"; $db->Execute($sql); print "<div class='error well' style='margin:2%; color:red;'><b>" . T_("You have been automatically logged out of work due to inactivity") . "</b></div>"; } /* $sql = "SELECT sample_id FROM `sample` where import_id = 1"; $rs = $db->GetAll($sql); for($i=0;$i<=count($rs)-1;$i++){ $ssseedss[] = $rs[$i]['sample_id'] ;} $ssseedssd = implode(",",$ssseedss); print $ssseedssd; */ /** * check if cases available */ //if assigned to a questionnaire $sql = "SELECT oq.questionnaire_id, q.description\r\n\tFROM operator_questionnaire as oq, questionnaire as q\r\n\tWHERE q.enabled = 1\r\n\tAND oq.operator_id = '{$operator_id}'\r\n\tAND q.questionnaire_id = oq.questionnaire_id"; $rs = $db->GetAll($sql); $cases_count = array();
display_chooser($r, "sample_import_id", "sample_import_id", true, false, true, false); print "</div>"; if (isset($_GET['sample_id'])) { //need to remove this sample record from the sample $sample_id = bigintval($_GET['sample_id']); $db->StartTrans(); $sql = "DELETE FROM sample_var\r\n\t\tWHERE sample_id = '{$sample_id}'"; $db->Execute($sql); $sql = "DELETE FROM sample\r\n\t\tWHERE sample_id = '{$sample_id}'"; $db->Execute($sql); $db->CompleteTrans(); print "<div class='alert alert-danger pull-left form-group col-sm-6' role='alert'><button type='button' class='close' data-dismiss='alert' aria-label='Close'><span aria-hidden='true'>×</span></button><p>" . T_("Sample ID") . " <b>" . $sample_id . "</b> " . T_("Deleted") . ".</p></div>"; } print "<div class='clearfix'></div>"; if ($sample_import_id != false) { $sql = "SELECT sv.sample_id, CASE WHEN c.case_id IS NULL THEN \r\n\t\tCONCAT(' <a href=\\'\\' data-toggle=\\'modal\\' data-target=\\'.delete-confirm\\' data-href=\\'?sample_import_id={$sample_import_id}&sample_id=', sv.sample_id ,'\\' data-sample_id=\\' ', sv.sample_id ,' \\' class=\\'\\'><i data-toggle=\\'tooltip\\' title=\\'" . TQ_("Delete sample record") . " ', sv.sample_id ,'\\' class=\\'fa fa-2x fa-trash-o text-danger\\'></i></a> ')\r\n\t\tELSE CONCAT('<a href=\\'supervisor.php?case_id=', c.case_id , '\\' data-toggle=\\'tooltip\\' title=\\'" . TQ_("Assigned to case ID :") . " ', c.case_id , '\\'><b>', c.case_id ,'</b></a>')\r\n\t\tEND as link\r\n\t\t\tFROM sample_var AS sv\r\n\t\t\tJOIN (sample as s) ON (s.import_id = '{$sample_import_id}' and sv.sample_id = s.sample_id)\r\n\t\t\tLEFT JOIN (`case` AS c, questionnaire AS q) ON ( c.sample_id = sv.sample_id AND q.questionnaire_id = c.questionnaire_id )\r\n\t\t\tGROUP BY s.sample_id, c.case_id"; $r = $db->GetAll($sql); if ($r) { $fnames = array("sample_id"); $fdesc = array(T_("Sample id")); $fnames[] = "link"; $fdesc[] = T_("Case ID"); $sql = "SELECT var,var_id\r\n\t\t\t\tFROM sample_import_var_restrict\r\n\t\t\t\tWHERE sample_import_id = {$sample_import_id}\r\n\t\t\t\tORDER by var ASC"; $rs = $db->GetAll($sql); foreach ($rs as $rsw) { $fnames[] = $rsw['var_id']; $fdesc[] = $rsw['var']; } foreach ($r as &$rw) { $sql = "SELECT var_id,val\r\n\t\t\t\t\tFROM sample_var\r\n\t\t\t\t\tWHERE sample_id = {$rw['sample_id']}"; $rs = $db->GetAll($sql);
$mail->Sender = $from['adminemail']; $mail->AddAddress($_POST['email']); foreach ($customheaders as $key => $val) { $mail->AddCustomHeader($val); } $mail->AddCustomHeader("X-Surveymailer: queXS Emailer (quexs.sourceforge.net)"); $mail->IsHTML(true); $mail->Body = $modmessage; $mail->AltBody = trim(strip_tags(html_entity_decode($modmessage, ENT_QUOTES, 'UTF-8'))); $mail->Subject = $modsubject; if ($mail->Send()) { // Put call attempt id in to sent $sql = "UPDATE " . LIME_PREFIX . "tokens_{$lime_sid}\r\n\t\t\t\tSET sent='{$ca}' \r\n\t\t\t\tWHERE token='{$token}'"; $db->Execute($sql); //Add a note that sent $sql = "INSERT INTO `case_note` (case_id,operator_id,note,datetime)\r\n\t\t\t\tVALUES ({$case_id},{$operator_id},'" . TQ_("Self completion invitation sent via email to") . ": " . $_POST['email'] . "',CONVERT_TZ(NOW(),'System','UTC'))"; $db->Execute($sql); //set to start frm the first page if the format for the respondent is not question by question $sql = "SELECT q.lime_mode\r\n\t\t\t\tFROM questionnaire as q, `case` as c\r\n\t\t\t\tWHERE c.case_id = {$case_id}\r\n\t\t\t\tAND q.questionnaire_id = c.questionnaire_id"; $lmode = $db->GetOne($sql); if ($lmode != "question") { $sql = "UPDATE " . LIME_PREFIX . "survey_{$lime_sid}\r\n\t\t\t\t\tSET lastpage = 0\r\n\t\t\t\t\tWHERE token = '{$token}'"; $db->Execute($sql); } if (isset($_POST['submith'])) { end_call($operator_id, 41); //end with outcome sent if (is_voip_enabled($operator_id)) { include "functions/functions.voip.php"; $v = new voip(); $v->connect(VOIP_SERVER);
$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();
/** * Return an option list of each queXS questionnaire and sample associated with * this Limesurvey instrument * * @param int $lime_sid The limesurvey sid * @param string $seleced The selected response, if any * * @return string A list of options for an XHTML select box * @author Adam Zammit <*****@*****.**> * @since 2011-09-07 */ function get_questionnaire_sample_list($lime_sid, $selected = "") { $db = newADOConnection(DB_TYPE); $db->Connect(DB_HOST, DB_USER, DB_PASS, DB_NAME); $db->SetFetchMode(ADODB_FETCH_ASSOC); $return = ""; $sql = "(SELECT q.questionnaire_id, q.description AS qdes, 0 as sample_import_id, '" . TQ_("All samples") . "' AS sdes\r\n\t\tFROM questionnaire AS q\r\n\t\tWHERE q.lime_sid = '{$lime_sid}')\r\n\t\tUNION\r\n\t\t(SELECT q.questionnaire_id, q.description AS qdes, qs.sample_import_id, s.description AS sdes\r\n\t\tFROM questionnaire AS q, questionnaire_sample AS qs, sample_import AS s\r\n\t\tWHERE q.lime_sid = '{$lime_sid}'\r\n\t\tAND q.questionnaire_id = qs.questionnaire_id\r\n\t\tAND s.sample_import_id = qs.sample_import_id)\r\n\t\tORDER BY questionnaire_id ASC, sample_import_id ASC"; $rs = $db->GetAll($sql); if (empty($rs)) { return false; } foreach ($rs as $r) { $s = ""; if (array($r['questionnaire_id'], $r['sample_import_id']) == $selected) { $s = "selected='selected'"; } $return .= "<option {$s} value='{$r['questionnaire_id']}:{$r['sample_import_id']}'>{$r['qdes']} - {$r['sdes']}</option>"; } return $return; }
$sql = "UPDATE questionnaire_sample \r\n\t\tSET sort_order = IF(sort_order = {$sort_order}, {$so}, {$sort_order})\r\n\t\tWHERE sort_order IN( {$sort_order}, {$so})"; $db->Execute($sql); unset($_GET['sort']); unset($_GET['sort_order']); } /* auto-set continiuos sort_order values for existing questionnaire_samples if not set before or first-time run */ if ($db->GetOne("SELECT COUNT(sort_order) - COUNT(DISTINCT sort_order ) FROM questionnaire_sample") > 0) { $db->Execute("SELECT @i := 0"); $db->Execute("UPDATE `questionnaire_sample` SET sort_order = @i:=@i+1 WHERE 1=1 ORDER BY sort_order ASC"); } $subtitle = T_("List and sort samples"); xhtml_head(T_("Sort questionnaire samples"), true, $css, $js_head, false, false, false, $subtitle); //array("../css/table.css"),array("../js/window.js") print "<a href='' onclick='history.back();return false;' class='btn btn-default pull-left'><i class='fa fa-chevron-left fa-lg text-primary'></i> " . T_("Go back") . "</a>"; print "<h2 class='col-lg-offset-2'><i class='fa fa-sort-numeric-asc text-primary'></i> " . T_("Sort order for questionnaire samples") . "</h2>\r\n\t\t<div class='panel-body'>"; $sql = "SELECT q.sort_order as sort_order, si.description as description,si.sample_import_id, q.questionnaire_id,\r\n\t\tCONCAT('<a href=\"assignsample.php?questionnaire_id=', q.questionnaire_id ,'\" data-toggle=\\'tooltip\\' title=\\'" . TQ_("Samples selected for this questionnaire") . " ', q.questionnaire_id ,'\\' class=\\' \\'><h4>', qu.description ,' </h4></a>') as qdesc, \r\n\t\tCASE WHEN q.call_max = 0 THEN '" . TQ_("Unlimited") . "' ELSE q.call_max END as call_max,\r\n\t\tCASE WHEN q.call_attempt_max = 0 THEN '" . TQ_("Unlimited") . "' ELSE q.call_attempt_max END AS call_attempt_max,\r\n\t\tCASE WHEN q.random_select = 0 THEN '" . TQ_("Sequential") . "' ELSE '" . TQ_("Random") . "' END as random_select,\r\n\t\tCASE WHEN q.answering_machine_messages = 0 THEN '" . TQ_("Never") . "' ELSE q.answering_machine_messages END as answering_machine_messages,\r\n\t\tCONCAT('<a href=\"assignsample.php?edit=edit&questionnaire_id=', q.questionnaire_id ,'&rsid=', si.sample_import_id ,'\" data-toggle=\\'tooltip\\' title=\\'" . TQ_("Edit") . "\\' class=\\'btn center-block\\'><i class=\\'fa fa-pencil-square-o fa-lg\\'></i></a>') as edit\r\n\t\tFROM questionnaire_sample as q, sample_import as si, questionnaire as qu\r\n\t\tWHERE q.sample_import_id = si.sample_import_id\r\n\t\tAND q.questionnaire_id = qu.questionnaire_id\r\n\t\tAND qu.enabled = 1\r\n\t\tORDER BY q.sort_order ASC"; $qs = $db->GetAll($sql); if (!empty($qs)) { $co = count($qs); if ($co > 1) { for ($i = 0; $i < $co; $i++) { $down = "<a href='?sort_order={$qs[$i]['sort_order']}&sort=down' data-toggle=\"tooltip\" title=\"" . T_("Pull step Down") . "\"><i class=\"fa fa-angle-down fa-2x\"></i></a>"; $up = "<a href='?sort_order={$qs[$i]['sort_order']}&sort=up' data-toggle=\"tooltip\" title=\"" . T_("Push step Up") . "\"><i class=\"fa fa-angle-up fa-2x\"></i></a>"; if ($i == 0) { $qs[$i]['sort_order'] = "<div>   <span class=\"badge\">" . $qs[$i]['sort_order'] . "</span> " . $down . "</div>"; } else { if ($i == $co - 1) { $qs[$i]['sort_order'] = "<div style=\"min-width:5em;\"> " . $up . " <span class=\"badge\">" . $qs[$i]['sort_order'] . "</span>"; } else { $qs[$i]['sort_order'] = "<div> " . $up . " <span class=\"badge\">" . $qs[$i]['sort_order'] . "</span> " . $down . "</div>"; }
if ($questionnaire_id) { print "<h3>" . T_("Please select a shift") . "</h3>"; $shift_id = false; if (isset($_GET['shift_id'])) { $shift_id = bigintval($_GET['shift_id']); } //get shifts for this questionnaire in operator time $sql = "SELECT s.shift_id as value, CONCAT(DATE_FORMAT(CONVERT_TZ(s.start,'UTC',o.Time_zone_name),'" . DATE_TIME_FORMAT . "'), ' - ', DATE_FORMAT(CONVERT_TZ(s.end,'UTC',o.Time_zone_name),'" . TIME_FORMAT . "')) as description,\r\n\t\t\tCASE WHEN s.shift_id = '{$shift_id}' THEN 'selected=\\'selected\\'' ELSE '' END AS selected \r\n\t\tFROM `shift` as s, operator as o\r\n\t\tWHERE s.questionnaire_id = '{$questionnaire_id}'\r\n\t\tAND o.operator_id = '{$operator_id}'\r\n\t\tORDER BY s.start ASC"; $r = $db->GetAll($sql); if (!empty($r)) { display_chooser($r, "shift", "shift_id", true, "questionnaire_id={$questionnaire_id}", true, true, false, true, "form-inline form-group"); } if ($shift_id) { print "<h3>" . T_("Reports for this shift") . "</h3>"; //list current reports with a link to edit $sql = "SELECT s.report,o.firstName,DATE_FORMAT(CONVERT_TZ(s.datetime,'UTC',o.Time_zone_name),'" . DATE_TIME_FORMAT . "') as d,\r\n\t\t\tCONCAT('<a href=\\'?questionnaire_id={$questionnaire_id}&shift_id={$shift_id}&shift_report_id=', s.shift_report_id, '\\'>" . TQ_("Edit") . "</a>') as link\r\n\t\t\tFROM shift_report as s, operator as o\r\n\t\t\tWHERE s.operator_id = o.operator_id\r\n\t\t\tAND s.shift_id = '{$shift_id}'"; $r = $db->GetAll($sql); if (!empty($r)) { xhtml_table($r, array("firstName", "d", "report", "link"), array(T_("Operator"), T_("Date"), T_("Report"), T_("Edit")), "tclass"); } //link to create a new report print "<p><a href='?questionnaire_id={$questionnaire_id}&shift_id={$shift_id}&createnewreport=yes'>" . T_("Create new report for this shift") . "</a></p>"; if (isset($_GET['createnewreport'])) { //create a new report print "<h3>" . T_("Enter report for this shift") . "</h3>"; print "<form action='?' method='get'><p><textarea name='report' id='report' rows='15' cols='80'></textarea></p>"; print "<p><input type='hidden' name='questionnaire_id' id='questionnaire_id' value='{$questionnaire_id}'/>"; print "<input type='hidden' name='shift_id' id='shift_id' value='{$shift_id}'/>"; print "<input type='submit' name='submit' id='submit' value=\"" . T_("Add report") . "\"/>"; print "</p></form>"; } else {
print "<h4 class='alert text-danger'>" . T_("There are no call attempt time slots selected for this questionnaire") . "</h4>"; } else { print "<h4>" . T_("Call attempt time slots selected for this questionnaire") . "</h4>"; xhtml_table($qs, array("availability_group_id", "description", "link"), false, "table table-hover"); } print "</div>"; $sql = "SELECT si.availability_group_id,si.description\r\n\t\tFROM availability_group as si\r\n\t\tLEFT JOIN questionnaire_timeslot as q ON (q.questionnaire_id = '{$questionnaire_id}' AND q.availability_group_id = si.availability_group_id)\r\n\t\tWHERE q.questionnaire_id is NULL"; $qs = $db->GetAll($sql); if (!empty($qs)) { print "<div class='panel-body'>"; //print "<h3>" . T_("Add a call attempt time slot to this questionnaire:") . "</h3>"; print "<form action='' method='get'><div class='pull-left'><select class='form-control ' name='ca_availability_group' id='ca_availability_group'>"; foreach ($qs as $q) { print "<option value=\"{$q['availability_group_id']}\">{$q['description']}</option>"; } print "</select></div>\r\n\t\t\t\t<input type='hidden' name='questionnaire_id' value='{$questionnaire_id}'/>\r\n\t\t\t\t <input type='submit' class='btn btn-default' name='add_ca_availability' value='" . TQ_("Add call attempt time slot") . "'/>\r\n\t\t\t\t</form></div>"; } print "</div>"; //page questionnairetimeslosample.php print "<div class=col-sm-4><h2>" . T_("Call attempt time slots for sample") . "</h2>"; print "<div class='well'>" . T_("Assigning call attempt time slots to questionnaires will only allow cases to be attempted in a time slot for the n + 1th time where it has been attempted at least n times in all assigned timeslots. Please note timeslots must cover all possible time periods otherwise no cases will be available during missing timeslots.") . "</div>"; print "<h3 class='pull-left'>" . T_("Sample") . ": </h3>"; $sample_import_id = false; if (isset($_GET['sample_import_id'])) { $sample_import_id = bigintval($_GET['sample_import_id']); } display_sample_chooser($questionnaire_id, $sample_import_id, false, "form-inline", "form-control"); if ($sample_import_id !== false) { $sql = "SELECT q.availability_group_id,a.description as description, CONCAT('<a href=\\'?sample_import_id={$sample_import_id}&questionnaire_id={$questionnaire_id}&qs_ravailability_group=', q.availability_group_id,'\\' >" . T_("Click to unassign") . "</a>') as link\r\n FROM questionnaire_sample_timeslot as q, availability_group as a\r\n WHERE q.availability_group_id = a.availability_group_id\r\n AND q.questionnaire_id = '{$questionnaire_id}'\r\n AND q.sample_import_id = '{$sample_import_id}'"; $qs = $db->GetAll($sql); if (empty($qs)) {
$usquery = "SELECT emailstatus from " . db_table_name("tokens_{$surveyid}") . " where token=" . db_quoteall($token, true); $usresult = $connect->GetOne($usquery); if ($usresult == false) { $html .= $clang->gT('You are not a participant in this survey.'); } elseif ($usresult == 'OK') { $usquery = "Update " . db_table_name("tokens_{$surveyid}") . " set emailstatus='OptOut', usesleft=0 where token=" . db_quoteall($token, true); $usresult = $connect->Execute($usquery); //queXS addition //Set to Hard Refusal, respondent $sql = "UPDATE `case`\n\t\tSET current_outcome_id = 9\n\t\tWHERE token = '{$token}'"; $connect->Execute($sql); $sql = "SELECT case_id\n\t\tFROM `case`\n\t\tWHERE token = '{$token}'"; $case_id = $connect->GetOne($sql); include_once dirname(__FILE__) . '/quexs.php'; //Add a case note to clarify (need to translate this string) $sql = "INSERT INTO `case_note` (case_id,operator_id,note,datetime)\n\t\tVALUES ({$case_id},1,'" . TQ_("Self completion refused via opt out function") . "',CONVERT_TZ(NOW(),'System','UTC'))"; $connect->Execute($sql); $html .= $clang->gT('You have been successfully removed from this survey.'); } else { $html .= $clang->gT('You have been already removed from this survey.'); } } $html .= '</p></div>'; //PRINT COMPLETED PAGE if (!$thissurvey['templatedir']) { $thistpl = sGetTemplatePath($defaulttemplate); } else { $thistpl = sGetTemplatePath($thissurvey['templatedir']); } sendcacheheaders(); doHeader();
if (empty($rs['current_operator_id'])) { ?> <input type="submit" name="delete" class="btn btn-danger col-lg-offset-2 pull-left" data-toggle="confirmation" value="<?php echo T_("Delete extension"); ?> " /> <?php } else { print "</br></br><b class='well text-danger'>" . T_("Unassign the operator from this extension to be able to delete it") . "</b>"; } } print "</div></form></div>"; } else { $sql = "SELECT CONCAT('<a href=\\'operatorlist.php?edit=',o.operator_id,'\\'>',o.firstName,' ', o.lastname,'</a>') as firstName,\r\n CONCAT('<a href=\\'?edit=',e.extension_id,'\\' class=\\'\\'>',e.extension,'</a>') as extension,\r\n IF(c.case_id IS NULL,IF(e.current_operator_id IS NULL,'list'\r\n ,CONCAT('<a href=\\'?unassign=',e.extension_id,'\\'>" . TQ_("Unassign") . "</a>')),'" . TQ_("End case to change assignment") . "') as assignment, \r\n CASE e.status WHEN 0 THEN '" . TQ_("VoIP Offline") . "' ELSE '" . TQ_("VoIP Online") . "' END as status, \r\n CASE ca.state WHEN 0 THEN '" . TQ_("Not called") . "' WHEN 1 THEN '" . TQ_("Requesting call") . "' WHEN 2 THEN '" . TQ_("Ringing") . "' WHEN 3 THEN '" . TQ_("Answered") . "' WHEN 4 THEN '" . TQ_("Requires coding") . "' ELSE '" . TQ_("Done") . "' END as state,\r\n CONCAT('<a href=\\'supervisor.php?case_id=', c.case_id , '\\'>' , c.case_id, '</a>') as case_id, SEC_TO_TIME(TIMESTAMPDIFF(SECOND,cal.start,CONVERT_TZ(NOW(),'SYSTEM','UTC'))) as calltime, \r\n e.status as vs,\r\n e.extension_id\r\n FROM extension as e\r\n LEFT JOIN `operator` as o ON (o.operator_id = e.current_operator_id)\r\n \tLEFT JOIN `case` as c ON (c.current_operator_id = o.operator_id)\r\n \tLEFT JOIN `call_attempt` as cal ON (cal.operator_id = o.operator_id AND cal.end IS NULL and cal.case_id = c.case_id)\r\n \tLEFT JOIN `call` as ca ON (ca.case_id = c.case_id AND ca.operator_id = o.operator_id AND ca.outcome_id= 0 AND ca.call_attempt_id = cal.call_attempt_id)\r\n \tORDER BY e.extension_id ASC"; $rs = $db->GetAll($sql); print "<div class='panel-body'>"; if ($msg != "") { print "<p class='alert alert-warning'>{$msg}</p></br>"; } if (!empty($rs)) { $sql = "SELECT o.operator_id as value, CONCAT(o.firstName,' ',o.lastname) as description\r\n FROM `operator` as o\r\n LEFT JOIN `extension` as e ON (e.current_operator_id = o.operator_id)\r\n WHERE e.extension_id IS NULL"; $ers = $db->GetAll($sql); for ($i = 0; $i < count($rs); $i++) { if ($rs[$i]['assignment'] == "list") { $rs[$i]['assignment'] = display_chooser($ers, "operator_id_" . $rs[$i]["extension_id"], "operator_id_" . $rs[$i]["extension_id"], true, "extension_id=" . $rs[$i]["extension_id"], true, false, false, false); } } xhtml_table($rs, array("extension", "firstName", "assignment", "status", "case_id", "state", "calltime"), array(T_("Extension"), T_("Operator"), T_("Assignment"), T_("VoIP Status"), T_("Case ID"), T_("Call state"), T_("Time on call")), "tclass", array("vs" => "1")); print "</br>";
$remain = 0; foreach ($rs as $r) { if ($r['type'] == 1) { $drawn = $r['count']; } if ($r['type'] == 0) { $remain = $r['count']; } } $sql = "SELECT count(*) as count\r\n\t\t\tFROM `case` as c, sample as s\r\n\t\t\tWHERE c.current_outcome_id IN (10,40)\r\n\t\t\tAND s.import_id = '{$sample_import_id}'\r\n\t\t\tAND s.sample_id = c.sample_id\r\n\t\t\tAND c.questionnaire_id = '{$questionnaire_id}'"; $rs = $db->GetRow($sql); $completions = $rs['count']; $report[] = array("strata" => T_("Total sample"), "quota" => $drawn + $remain, "sample" => $drawn + $remain, "sampleused" => $drawn, "sampleremain" => $remain, "completions" => $completions, "perc" => ROUND($completions / ($drawn + $remain) * 100, 2)); print "<form action='' method='post'>"; xhtml_table($report, array("strata", "status", "quota", "sample", "sampleused", "sampleremain", "completions", "perc", "priority", "autoprioritise"), array(T_("Strata"), T_("Status"), T_("Quota"), T_("Sample"), T_("Sample Used"), T_("Sample Remaining"), T_("Completions"), T_("% Complete"), T_("Set priority"), T_("Auto prioritise")), "tclass", false, false); if (count($report) > 1) { print "<input type='hidden' name='questionnaire_id' id='questionnaire_id' value='{$questionnaire_id}'/></br>\r\n\t\t\t\t\t<button type='submit' id='submit' name='submit' class='btn btn-primary'/><i class=\"fa fa-refresh fa-lg\"></i> " . TQ_("Update priorities") . "</button>"; } print "</form>"; } } xhtml_foot(array("../js/custom.js")); ?> <script type="text/javascript"> $('input').iCheck({ checkboxClass: 'icheckbox_square-blue', increaseArea: '30%' }); </script>
print "<h4 class='col-sm-3 text-danger'>" . T_("No operators assigned") . ". </h4>"; } print ""; if ($operator_id != false) { print "<div class='clearfix form-group'></div><div class='col-sm-6'><div class='panel panel-body'><p>" . T_("Operator call outcomes") . "</p>"; $sql = "SELECT o.description as des, o.outcome_id, count( c.call_id ) as count, ROUND((count(c.call_id) / (SELECT count(call.call_id) FROM `call` JOIN `case` ON (call.case_id = `case`.case_id AND `case`.questionnaire_id = {$questionnaire_id} ) WHERE call.operator_id = '{$operator_id}')) * 100,2) as perc\r\n\t\t\t\tFROM `call` AS c, `case` as ca, `outcome` AS o\r\n\t\t\t\tWHERE ca.questionnaire_id = '{$questionnaire_id}'\r\n\t\t\t\tAND ca.case_id = c.case_id\r\n\t\t\t\tAND c.operator_id = '{$operator_id}'\r\n\t\t\t\tAND c.outcome_id = o.outcome_id\r\n\t\t\t\tGROUP BY o.outcome_id"; $rs = $db->GetAll($sql); if (!empty($rs)) { translate_array($rs, array("des")); xhtml_table($rs, array("des", "count", "perc"), array(T_("Outcome"), T_("Count"), T_("%")), "tclass", array("des" => "Complete"), array("count", "perc")); } print "</div></div>"; } } else { print "<p>" . T_("No outcomes recorded for this questionnaire") . "</p>"; } //display a list of shifts with completions and a link to either add a report or view reports print "<div class='clearfix'></div>"; print "<h3 class='col-sm-4 pull-left text-center'>" . T_("Shifts") . ":</h3>"; $sql = "SELECT s.shift_id, CONCAT(DATE_FORMAT(CONVERT_TZ(s.start,'UTC',o.Time_zone_name),'" . DATE_FORMAT . "')) as sdate,CONCAT(DATE_FORMAT(CONVERT_TZ(s.start,'UTC',o.Time_zone_name),'" . TIME_FORMAT . "'),'-', DATE_FORMAT(CONVERT_TZ(s.end,'UTC',o.Time_zone_name),'" . TIME_FORMAT . "')) as stime,\r\n\t\tCASE WHEN sr.shift_id IS NULL THEN \r\n\t\t\tCONCAT('<a href=\\'shiftreport.php?questionnaire_id={$questionnaire_id}&shift_id=', s.shift_id, '&createnewreport=yes\\' data-toggle=\\'tooltip\\' title=\\'" . TQ_("No shift reports: Add report") . "\\' class=\\'btn center-block\\'><i class=\\'fa fa-plus text-warning\\'></i><i class=\\'fa fa-file-text-o fa-lg\\'></i></a>') \r\n\t\t\tELSE CONCAT('<a href=\\'shiftreport.php?questionnaire_id={$questionnaire_id}&shift_id=', s.shift_id, '\\' data-toggle=\\'tooltip\\' title=\\'" . TQ_("View shift reports") . "\\' class=\\'btn center-block\\'><i class=\\'fa fa-file-text-o fa-lg\\'></i></a>')\r\n\t\t\tEND AS link,\r\n\t\t\tc.completions as completions, \r\n\t\t\tCONCAT('<a href=\\'operatorperformance.php?questionnaire_id={$questionnaire_id}&shift_id=', s.shift_id, '\\' data-toggle=\\'tooltip\\' title=\\'" . TQ_("View operator performance") . "\\' class=\\'btn center-block\\'><i class=\\'fa fa-user fa-lg\\'></i><i class=\\'fa fa-signal \\'></i></a>') as operform\r\n\t\tFROM `shift` as s\r\n\t\tJOIN operator as o on (o.operator_id = '{$admin_operator_id}')\r\n\t\tLEFT JOIN shift_report as sr on (sr.shift_id = s.shift_id)\r\n\t\tLEFT JOIN ( SELECT count(*) as completions,sh.shift_id\r\n\t\t\tFROM `call` as a, `case` as b, shift as sh\r\n\t\t\tWHERE a.outcome_id = '10'\r\n\t\t\tAND a.case_id = b.case_id\r\n\t\t\tAND b.questionnaire_id = '{$questionnaire_id}'\r\n\t\t\tAND sh.start <= a.start\r\n\t\t\tAND sh.end >= a.start\r\n\t\t\tGROUP BY sh.shift_id) as c on (s.shift_id = c.shift_id)\r\n\t\tWHERE s.questionnaire_id = '{$questionnaire_id}'\r\n\t\tGROUP BY shift_id\r\n\t\tORDER BY s.start ASC"; $r = $db->GetAll($sql); if (empty($r)) { print "<h4 class='col-sm-4 text-danger'>" . T_("No shifts defined for this questionnaire") . "</h4>"; } else { print "<div class='clearfix form-group'></div>"; print "<div class='col-sm-6 panel-body' style='max-height:400px; overflow:auto;'>"; xhtml_table($r, array("sdate", "stime", "completions", "link", "operform"), array(T_("Date"), T_("Shift time"), T_("Completions"), T_("Shift report"), T_("Operator performance")), "tclass"); print "</div>"; } } xhtml_foot($js_foot);
* Operator functions */ include "functions/functions.operator.php"; $js = false; if (AUTO_LOGOUT_MINUTES !== false) { $js = array("include/jquery/jquery-1.4.2.min.js", "js/childnap.js"); } xhtml_head(T_("Appointment List"), false, array("css/table.css"), $js, false, 60); //List the case appointment // display in respondent time so that the operator will be able to // quote verbatim to the respondent if necessary $db->StartTrans(); $operator_id = get_operator_id(); $case_id = get_case_id($operator_id); $rs = ""; if ($case_id) { $sql = "SELECT DATE_FORMAT(CONVERT_TZ(c.start,'UTC',r.Time_zone_name),'" . DATE_TIME_FORMAT . "') as start,DATE_FORMAT(CONVERT_TZ(c.end,'UTC',r.Time_zone_name),'" . TIME_FORMAT . "') as end, c.completed_call_id, IFNULL(ou.firstName,'" . TQ_("Not yet called") . "') as firstName, CONCAT(r.firstName, ' ', r.lastName) as respname, IFNULL(o.description,'" . TQ_("Not yet called") . "') as des, IFNULL(ao.firstName,'" . TQ_("Any operator") . "') as witho\r\n\t\tFROM `appointment` as c\r\n\t\tJOIN respondent as r on (r.respondent_id = c.respondent_id)\r\n\t\tLEFT JOIN (`call` as ca, outcome as o, operator as ou) on (ca.call_id = c.completed_call_id and ca.outcome_id = o.outcome_id and ou.operator_id = ca.operator_id)\r\n\t\tLEFT JOIN operator AS ao ON (ao.operator_id = c.require_operator_id)\r\n\t\tWHERE c.case_id = '{$case_id}'\r\n\t\tORDER BY c.start DESC"; $rs = $db->GetAll($sql); } if (empty($rs)) { if ($case_id) { print "<p>" . T_("No appointments made") . "</p>"; } else { print "<p>" . T_("No future appointments scheduled") . "</p>"; } } else { translate_array($rs, array("des")); xhtml_table($rs, array("start", "end", "respname", "witho", "des", "firstName"), array(T_("Start"), T_("End"), T_("Respondent"), T_("Appointment with"), T_("Outcome"), T_("Operator"))); } xhtml_foot(); $db->CompleteTrans();