2
0
mirror of https://github.com/ACSPRI/queXS synced 2024-04-02 12:12:16 +00:00

Added questionnaire to call history and CSV download option

This commit is contained in:
azammitdcarf
2012-10-02 02:05:35 +00:00
parent 1ab70e7b5a
commit 70a8c9cb44

View File

@@ -49,34 +49,65 @@ include ("../functions/functions.xhtml.php");
*/
include("../functions/functions.operator.php");
xhtml_head(T_("Call History List"),true,array("../css/table.css"));
//List the case call history
$operator_id = get_operator_id();
if ($operator_id)
{
$sql = "SELECT DATE_FORMAT(CONVERT_TZ(c.start,'UTC',op.Time_zone_name),'".DATE_TIME_FORMAT."') as start,DATE_FORMAT(CONVERT_TZ(c.end,'UTC',op.Time_zone_name),'".TIME_FORMAT."') as end, o.description as des, (CONCAT(r.firstName,' ',r.lastName)) as firstName, opp.firstName as opname, CONCAT('<a href=\'supervisor.php?case_id=', c.case_id, '\'>', c.case_id, '</a>') as case_id
$sql = "SELECT DATE_FORMAT(CONVERT_TZ(c.start,'UTC',op.Time_zone_name),'".DATE_TIME_FORMAT."') as start,DATE_FORMAT(CONVERT_TZ(c.end,'UTC',op.Time_zone_name),'".TIME_FORMAT."') as end, o.description as des, (CONCAT(r.firstName,' ',r.lastName)) as firstName, opp.firstName as opname, CONCAT('<a href=\'supervisor.php?case_id=', c.case_id, '\'>', c.case_id, '</a>') as case_id, q.description as qd
FROM `call` as c
JOIN (operator as op, respondent as r) on (op.operator_id = '$operator_id' and r.respondent_id = c.respondent_id)
JOIN (`case` as ca, questionnaire as q) ON (ca.case_id = c.case_id AND q.questionnaire_id = ca.questionnaire_id)
LEFT JOIN (outcome as o) on (c.outcome_id = o.outcome_id)
LEFT JOIN (operator as opp) on (opp.operator_id = c.operator_id)
ORDER BY c.start DESC
LIMIT 500";
ORDER BY c.start DESC";
if (!isset($_GET['csv']))
$sql .= " LIMIT 500";
$rs = $db->GetAll($sql);
if (empty($rs))
{
xhtml_head(T_("Call History List"),true,array("../css/table.css"));
print "<p>" . T_("No calls ever made") . "</p>";
}
else
{
translate_array($rs,array("des"));
xhtml_table($rs,array("start","end","case_id","opname","des","firstName"),array(T_("Date/Time call start"),T_("Time end"),T_("Case ID"),T_("Operator"),T_("Outcome"),T_("Respondent")));
if (isset($_GET['csv']))
{
$fn = "callhistory.csv";
header("Content-Type: text/csv");
header("Content-Disposition: attachment; filename=$fn");
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("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Pragma: no-cache"); // HTTP/1.0
echo(T_("Date/Time call start") . "," . T_("Time end") . "," . T_("Case ID") . "," . T_("Questionnaire") . "," . T_("Operator") . "," . T_("Outcome") . "," . T_("Respondent") . "\n");
foreach($rs as $r)
{
echo $r['start'] . "," . $r['end'] . "," . strip_tags($r['case_id']) . "," . $r['qd'] . "," . $r['opname'] . ",\"" . $r['des'] . "\"," . $r['firstName'] . "\n";
}
exit;
}
else
{
xhtml_head(T_("Call History List"),true,array("../css/table.css"));
print "<p><a href='?csv=csv'>" . T_("Download Call History List") . "</a></p>";
xhtml_table($rs,array("start","end","case_id","qd","opname","des","firstName"),array(T_("Date/Time call start"),T_("Time end"),T_("Case ID"),T_("Questionnaire"),T_("Operator"),T_("Outcome"),T_("Respondent")));
}
}
}
else
{
xhtml_head(T_("Call History List"),true,array("../css/table.css"));
print "<p>" . T_("No operator") . "</p>";
}
xhtml_foot();