" . 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 "
";
-
- //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('". TQ_("Delete") . "') as link, CONCAT('". TQ_("Edit") . "') as edit
- 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","edit"),array(T_("Questionnaire"),T_("Start"),T_("End"),T_("Operator Name"),T_("Respondent Name"),T_("Surname"),T_("Current outcome"),T_("Operator who called"),T_("Delete"),T_("Edit")));
- }
- else
- print "
";
-
-
- //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('". TQ_("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 timeslots
- $sql = "SELECT count(*)
- FROM questionnaire_timeslot as q, `case` as c
- WHERE c.case_id = $case_id
- AND c.questionnaire_id = q.questionnaire_id";
-
- if ($db->GetOne($sql) >= 1)
- {
- print "
" . T_("Call attempts by timeslot") . "
";
-
- $sql = "SELECT ag.description, (SELECT COUNT(*) FROM availability as a, `call_attempt` as ca WHERE ca.case_id = c.case_id AND a.availability_group_id = ag.availability_group_id
- AND (a.day_of_week = DAYOFWEEK(CONVERT_TZ(ca.start,'UTC',s.Time_zone_name))
- AND TIME(CONVERT_TZ(ca.start, 'UTC' , s.Time_zone_name)) >= a.start
- AND TIME(CONVERT_TZ(ca.start, 'UTC' , s.Time_zone_name)) <= a.end)) as cou
- FROM availability_group as ag, `case` as c, `questionnaire_timeslot` as qt, sample as s
- WHERE c.case_id = '$case_id'
- AND s.sample_id = c.sample_id
- AND qt.questionnaire_id = c.questionnaire_id AND ag.availability_group_id = qt.availability_group_id";
-
- xhtml_table($db->GetAll($sql),array('description','cou'),array(T_("Time slot"),T_("Call attempts")));
-
- }
-
- //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, CONCAT('". TQ_("Delete") . "') as link
- 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","link"),array(T_("Date/Time"),T_("Operator"),T_("Note"),T_("Delete")));
-
-
- //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") . "
";
-
- ?>
-
- = 1 availability group is in use for this case
- $sql = "SELECT qa.availability_group_id,ag.description,ca.availability_group_id as selected_group_id
- FROM `case` as c
- JOIN questionnaire_availability AS qa ON (qa.questionnaire_id = c.questionnaire_id)
- JOIN availability_group AS ag ON (ag.availability_group_id = qa.availability_group_id)
- LEFT JOIN case_availability AS ca ON (ca.availability_group_id = qa.availability_group_id and ca.case_id = c.case_id)
- WHERE c.case_id = '$case_id'";
-
- $rs = $db->GetAll($sql);
-
- //Display all availability groups as checkboxes
-
- print "
" . T_("Select groups to limit availability (Selecting none means always available)") . "
";
- print "
- " . T_("Availability groups not defined for this questionnaire") . "
";
- }
-
-
- //assign this to an operator for their next case
- print "
" . T_("Assign this case to operator (will appear as next case for them)") . "
";
- ?>
-
- " . T_("Deidentify") . "";
- print "
" . T_("Remove all sample details and contact numbers from this case") . "
";
+
+ $sql = "SELECT sv.sample_id, c.case_id , s.Time_zone_name,
+ TIME_FORMAT(CONVERT_TZ(NOW(),@@session.time_zone,s.Time_zone_name),'". TIME_FORMAT ."') as time
+ FROM sample_var AS sv
+ LEFT JOIN (`case` AS c , sample as s) ON ( c.sample_id = sv.sample_id AND s.sample_id = c.sample_id ) WHERE c.case_id = '$case_id'
+ GROUP BY sv.sample_id";
+ $r = $db->GetAll($sql);
+ if ($r){
+ $fnames = array("sample_id", "Time_zone_name", "time");
+ $fdesc = array(T_("Sample id"),T_("Timezone"),T_("Time NOW"));
+
+ $sql = "SELECT var
+ FROM sample_var
+ WHERE sample_id = {$r[0]['sample_id']} AND type IN (2,3,6,7)
+ ORDER by var DESC";
+ $rs = $db->GetAll($sql);
+
+ foreach($rs as $rsw)
+ {
+ $fnames[] = $rsw['var'];
+ $fdesc[] = $rsw['var'];
+ }
+ foreach($r as &$rw)
+ {
+ $sql = "SELECT var,val
+ FROM sample_var
+ WHERE sample_id = {$rw['sample_id']} AND type IN (2,3,6,7)";
+ $rs = $db->GetAll($sql);
+ foreach($rs as $rsw){
+ $rw[$rsw['var']] = $rsw['val'];
+ }
+ }
+
+ xhtml_table($r,$fnames,$fdesc,"tclass");
+ }else{
+ print "
" . T_("No sample data for this case") . "
";
+ }
+ print "
";
+
+ //View appointments
+ print "
" . T_("Appointments")."
";
+
+ $sql = "SELECT
+ 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,'" . T_("Not yet called") . "') as outcome,
+ CONCAT (oo.firstName,' ', oo.lastName) as makerName,
+ CONCAT (ooo.firstName,' ', ooo.lastName) as callerName,
+ CONCAT('', c.case_id, '') as case_id,
+ CONCAT(' ') as link,
+ CONCAT(' ') as edit
+ FROM appointment as a
+ JOIN (`case` as c, respondent as r, questionnaire as q, 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("start","end","edit","makerName","resp","outcome","callerName","link"),array(T_("Start"),T_("End")," ",T_("Operator"),T_("Respondent"),T_("Current outcome"),T_("Operator who called")," "),"table-hover table-bordered table-condensed col-sm-10");
+ }
+ else
+ print "
";
+
+
+ //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(' ') 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 "
";
+
+ //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('') as link
+ 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","link"),array(T_("Date/Time"),T_("Operator"),T_("Note")," "));
+ print " ";
+ }
+ //add a note
+ ?>
+
+ ";
+
+ //view timeslots
+ $sql = "SELECT count(*)
+ FROM questionnaire_timeslot as q, `case` as c
+ WHERE c.case_id = $case_id
+ AND c.questionnaire_id = q.questionnaire_id";
+
+ if ($db->GetOne($sql) >= 1)
+ {
+ $sql = "SELECT ag.description, (SELECT COUNT(*) FROM availability as a, `call_attempt` as ca
+ WHERE ca.case_id = c.case_id
+ AND a.availability_group_id = ag.availability_group_id
+ AND (a.day_of_week = DAYOFWEEK(CONVERT_TZ(ca.start,'UTC',s.Time_zone_name))
+ AND TIME(CONVERT_TZ(ca.start, 'UTC' , s.Time_zone_name)) >= a.start
+ AND TIME(CONVERT_TZ(ca.start, 'UTC' , s.Time_zone_name)) <= a.end)) as cou
+ FROM availability_group as ag, `case` as c, `questionnaire_timeslot` as qt, sample as s
+ WHERE c.case_id = '$case_id'
+ AND s.sample_id = c.sample_id
+ AND qt.questionnaire_id = c.questionnaire_id AND ag.availability_group_id = qt.availability_group_id";
+ if ( array("cou") >=1){
+ print "
";
+
+
+
+ if ($r[0]['sample_id']){ // if sample data exists view availability
+
+ print "
" . T_("Availability groups") . "
";
+ if (is_using_availability($case_id))
+ {
+ //List all availability group items and whether selected or not (all selected by default unless >= 1 availability group is in use for this case
+ $sql = "SELECT qa.availability_group_id,ag.description,ca.availability_group_id as selected_group_id
+ FROM `case` as c
+ JOIN questionnaire_availability AS qa ON (qa.questionnaire_id = c.questionnaire_id)
+ JOIN availability_group AS ag ON (ag.availability_group_id = qa.availability_group_id)
+ LEFT JOIN case_availability AS ca ON (ca.availability_group_id = qa.availability_group_id and ca.case_id = c.case_id)
+ WHERE c.case_id = '$case_id'";
+
+ $rs = $db->GetAll($sql);
+
+ //Display all availability groups as checkboxes
+ print "
+
" . T_("Availability groups not defined for this questionnaire") . "
";
+ ?>
+
+ ";
+
+ if ($r[0]['sample_id']){ // if sample data exists deidentify record
+ print "
" . T_("Deidentify") . "
";
+ print "
" . T_("Remove all sample details and contact numbers from this case") . "
";
+ ?>
+
+ " . T_("Case does not exist") . "";
+ }
+}
+xhtml_foot($js_foot);// deidentify data-toggle="modal" type="submit"submitclass
+?>
+
+
+
+
+
\ No newline at end of file