* @copyright Deakin University 2007,2008 * @package queXS * @subpackage admin * @link http://www.deakin.edu.au/dcarf/ queXS was writen for DCARF - Deakin Computer Assisted Research Facility * @license http://opensource.org/licenses/gpl-2.0.php The GNU General Public License (GPL) Version 2 * * */ /** * Configuration file */ include("../config.inc.php"); /** * Database file */ include ("../db.inc.php"); /** * XHTML functions */ include("../functions/functions.xhtml.php"); /** * Display functions */ include("../functions/functions.display.php"); /** * Limesurvey functions */ include("../functions/functions.limesurvey.php"); /** * Operator functions */ include("../functions/functions.operator.php"); /** * Input functions */ include("../functions/functions.input.php"); global $db; $operator_id = get_operator_id(); $case_id = false; if (isset($_GET['case_id'])) $case_id = bigintval($_GET['case_id']); xhtml_head(T_("Supervisor functions"),true,array("../css/table.css"),array("../js/window.js")); print "

" . T_("Enter a case id or select a case from the list below:") . "

"; $sql = "SELECT c.case_id as value, c.case_id as description, CASE WHEN c.case_id = '$case_id' THEN 'selected=\'selected\'' ELSE '' END AS selected FROM `case` as c, `outcome` as o WHERE c.current_outcome_id = o.outcome_id AND o.outcome_type_id = 2"; $rs = $db->GetAll($sql); if (!empty($rs)) { print "
"; display_chooser($rs,"case","case_id"); print "
"; } ?>

"/>

Execute($sql); } else { print "

" . T_("Set an outcome for this call") . "

"; ?>
GetAll($sql); translate_array($rs2,array("description")); display_chooser($rs2, "set_outcome_id", "set_outcome_id",true,false,false); ?>

"/>

qstr($_GET['note']); $sql = "INSERT INTO `case_note` (case_note_id,case_id,operator_id,note,datetime) VALUES (NULL,'$case_id','$operator_id',$note,CONVERT_TZ(NOW(),'System','UTC'))"; $db->Execute($sql); } if (isset($_GET['outcome_id'])) { $outcome_id = bigintval($_GET['outcome_id']); $sql = "UPDATE `case` SET current_outcome_id = $outcome_id WHERE case_id = '$case_id'"; $db->Execute($sql); } $sql = "SELECT o.description,o.outcome_id, q.description as qd, si.description as sd FROM `case` as c, `outcome` as o, questionnaire as q, sample as s, sample_import as si WHERE c.case_id = '$case_id' AND q.questionnaire_id = c.questionnaire_id AND s.sample_id = c.sample_id AND si.sample_import_id = s.import_id AND c.current_outcome_id = o.outcome_id"; $rs = $db->GetRow($sql); if (!empty($rs)) { print "

" . T_("Project") . ": {$rs['qd']}

"; print "

" . T_("Sample") . ": {$rs['sd']}

"; print "

". T_("Current outcome:") ." " . T_($rs['description']) . "

"; $current_outcome_id = $rs['outcome_id']; print "

" . T_("Appointments")."

"; //View appointments $sql = "SELECT q.description, CONVERT_TZ(a.start,'UTC',o.Time_zone_name) as start, CONVERT_TZ(a.end,'UTC',o.Time_zone_name) as end, r.firstName, r.lastName, IFNULL(ou.description,'" . T_("Not yet called") . "') as outcome, oo.firstName as makerName, ooo.firstName as callerName, CONCAT('', c.case_id, '') as case_id, CONCAT('". T_("Delete") . "') as link FROM appointment as a JOIN (`case` as c, respondent as r, questionnaire as q, operator as o, operator as oo, call_attempt as cc) on (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) LEFT 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) WHERE c.case_id = '$case_id' GROUP BY a.appointment_id ORDER BY a.start ASC"; $rs = $db->GetAll($sql); if (!empty($rs)) { translate_array($rs,array("outcome")); xhtml_table($rs,array("description","start","end","makerName","firstName","lastName","outcome","callerName","link"),array(T_("Questionnaire"),T_("Start"),T_("End"),T_("Operator Name"),T_("Respondent Name"),T_("Surname"),T_("Current outcome"),T_("Operator who called"),T_("Delete"))); } else print "

" . T_("No appointments for this case") . "

"; //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, op.firstName, op.lastName, o.description as des, CONCAT('". T_("Edit") . "') as link, cp.phone as phone FROM `call` as c JOIN (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) WHERE c.case_id = '$case_id' ORDER BY c.start DESC"; $rs = $db->GetAll($sql); print "

" . T_("Call list")."

"; if (empty($rs)) print "

" . T_("No calls made") . "

"; else { translate_array($rs,array("des")); xhtml_table($rs,array("start","des","phone","link","firstName"),array(T_("Date/Time"),T_("Outcome"),T_("Phone number"),T_("Change outcome"),T_("Operator"))); } //view notes $sql = "SELECT DATE_FORMAT(CONVERT_TZ(c.datetime,'UTC',op.Time_zone_name),'".DATE_TIME_FORMAT."') as time, op.firstName, op.lastName, c.note as note FROM `case_note` as c JOIN (operator as op) on (c.operator_id = op.operator_id) WHERE c.case_id = '$case_id' ORDER BY c.datetime DESC"; $rs = $db->GetAll($sql); print "

" . T_("Case notes")."

"; if (empty($rs)) print "

" . T_("No notes") . "

"; else xhtml_table($rs,array("time","firstName","note"),array(T_("Date/Time"),T_("Operator"),T_("Note"))); //add a note ?>

"/>

" . T_("Modify responses for this case") . ""; else print "

" . T_("Case not yet started in Limesurvey") . "

"; //set an outcome print "

" . T_("Set a case outcome") . "

"; ?>
GetAll($sql); translate_array($rs2,array("description")); display_chooser($rs2, "outcome_id", "outcome_id",true,false,false); ?>

"/>

" . T_("Case does not exist") . ""; } } xhtml_foot(); ?>