mirror of
https://github.com/ACSPRI/queXS
synced 2024-04-02 12:12:16 +00:00
Fix timezone issues with using @@session
This commit is contained in:
@@ -88,7 +88,7 @@ if (isset($_GET['start']) && isset($_GET['end']) && isset($_GET['update']))
|
||||
|
||||
// create a call attempt
|
||||
$sql = "INSERT INTO call_attempt (call_attempt_id,case_id,operator_id,respondent_id,start,end)
|
||||
VALUES (NULL,$case_id,$operator_id,$respondent_id,CONVERT_TZ(NOW(),@@session.time_zone,'UTC'),CONVERT_TZ(NOW(),@@session.time_zone,'UTC'))";
|
||||
VALUES (NULL,$case_id,$operator_id,$respondent_id,CONVERT_TZ(NOW(),'System','UTC'),CONVERT_TZ(NOW(),'System','UTC'))";
|
||||
$db->Execute($sql);
|
||||
|
||||
$call_attempt_id = $db->Insert_ID();
|
||||
@@ -292,19 +292,20 @@ else {
|
||||
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 MIN(q.description) as description, MIN(si.description) as smpl, MIN(CONVERT_TZ(a.start,'UTC',@@session.time_zone)) as start, MIN(CONVERT_TZ(a.end,'UTC',@@session.time_zone)) as end,MIN(CONCAT(r.firstName, ' ', r.lastName)) as resp, MIN( IFNULL(ou.description,'" . TQ_("Not yet called") . "')) as outcome, MIN(oo.firstName) as makerName, MIN(ooo.firstName) as callerName,
|
||||
$sql = "SELECT MIN(q.description) as description, MIN(si.description) as smpl, MIN(CONVERT_TZ(a.start,'UTC',co.Time_zone_name)) as start, MIN(CONVERT_TZ(a.end,'UTC',co.Time_zone_name)) as end,MIN(CONCAT(r.firstName, ' ', r.lastName)) as resp, MIN( IFNULL(ou.description,'" . TQ_("Not yet called") . "')) as outcome, MIN(oo.firstName) as makerName, MIN(ooo.firstName) as callerName,
|
||||
CONCAT('<a href=\'supervisor.php?case_id=', c.case_id, '\'>', c.case_id, '</a>') as case_id,
|
||||
MIN(CONCAT(' <a href=\'\'><i class=\'fa fa-trash-o fa-lg text-danger\' toggle=\'confirmation\' data-title=\'" . TQ_("ARE YOU SURE?") . "\' data-btnOkLabel=\'" . TQ_("Yes") . "\' data-btnCancelLabel=\'" . TQ_("No") . "\' data-placement=\'left\' data-href=\'?case_id=', c.case_id, '&appointment_id=', a.appointment_id, '&delete=delete\' ></i></a> ')) as link,
|
||||
MIN(CONCAT(' <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,MIN(IFNULL(ao.firstName,'" . TQ_("Any operator") . "')) as witho
|
||||
FROM appointment as a
|
||||
JOIN (`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)
|
||||
JOIN (`case` as c, respondent as r, questionnaire as q, operator as oo, call_attempt as cc, operator as co, `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)
|
||||
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)
|
||||
LEFT JOIN operator AS ao ON ao.operator_id = a.require_operator_id
|
||||
LEFT JOIN (questionnaire_sample_quota as qsq) on (s.import_id = qsq.sample_import_id and c.questionnaire_id = qsq.questionnaire_id)
|
||||
LEFT JOIN (questionnaire_sample_quota_row as qsqr) on (s.import_id = qsqr.sample_import_id and c.questionnaire_id = qsqr.questionnaire_id)
|
||||
WHERE 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)
|
||||
WHERE q.enabled=1 AND si.enabled=1 AND a.end >= CONVERT_TZ(NOW(),'System','UTC')
|
||||
AND (qsq.quota_reached IS NULL OR qsq.quota_reached != 1)
|
||||
AND (qsqr.quota_reached IS NULL OR qsqr.quota_reached != 1)
|
||||
AND co.operator_id = '$operator_id'
|
||||
GROUP BY c.case_id ORDER BY a.start ASC";
|
||||
$rs = $db->GetAll($sql);
|
||||
if (!empty($rs)) {
|
||||
@@ -315,18 +316,19 @@ else {
|
||||
|
||||
print "<h3 style='color:red'>" . T_("Missed appointments (with times displayed in your time zone)") . "</h3>";
|
||||
|
||||
$sql = "SELECT MIN(q.description), MIN(si.description) as smpl, MIN(CONVERT_TZ(a.start,'UTC',@@session.time_zone)) as start, MIN(CONVERT_TZ(a.end,'UTC',@@session.time_zone)) as end, MIN(CONCAT(r.firstName, ' ', r.lastName)) as resp,
|
||||
$sql = "SELECT MIN(q.description) as description, MIN(si.description) as smpl, MIN(CONVERT_TZ(a.start,'UTC',co.Time_zone_name)) as start, MIN(CONVERT_TZ(a.end,'UTC',co.Time_zone_name)) as end, MIN(CONCAT(r.firstName, ' ', r.lastName)) as resp,
|
||||
MIN(CONCAT('<a href=\'supervisor.php?case_id=', c.case_id, '\'>', c.case_id, '</a>')) as case_id,
|
||||
MIN(CONCAT(' <a href=\'\'><i class=\'fa fa-trash-o fa-lg text-danger\' toggle=\'confirmation\' data-title=\'" . TQ_("ARE YOU SURE?") . "\' data-btnOkLabel=\'" . TQ_("Yes") . "\' data-btnCancelLabel=\'" . TQ_("No") . "\' data-placement=\'left\' data-href=\'?case_id=', c.case_id, '&appointment_id=', a.appointment_id, '&delete=delete\' ></i></a> ')) as link,
|
||||
MIN(CONCAT(' <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
|
||||
FROM appointment as a
|
||||
JOIN (`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)
|
||||
JOIN (`case` as c, respondent as r, questionnaire as q, `sample` as s, sample_import as si, operator as co) 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)
|
||||
LEFT JOIN (`call` as ca) ON (ca.call_id = a.completed_call_id)
|
||||
LEFT JOIN (questionnaire_sample_quota as qsq) on (s.import_id = qsq.sample_import_id and c.questionnaire_id = qsq.questionnaire_id)
|
||||
LEFT JOIN (questionnaire_sample_quota_row as qsqr) on (s.import_id = qsqr.sample_import_id and c.questionnaire_id = qsqr.questionnaire_id)
|
||||
WHERE 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)
|
||||
WHERE q.enabled=1 AND si.enabled=1 AND a.end < CONVERT_TZ(NOW(),'System','UTC') AND a.completed_call_id IS NULL
|
||||
AND (qsq.quota_reached IS NULL OR qsq.quota_reached != 1 )
|
||||
AND (qsqr.quota_reached IS NULL OR qsqr.quota_reached != 1)
|
||||
AND co.operator_id = '$operator_id'
|
||||
GROUP BY c.case_id
|
||||
ORDER BY a.start ASC";
|
||||
|
||||
|
||||
@@ -320,7 +320,7 @@ if ($case_id != false)
|
||||
print "<div class='panel-body'><h4 class=''><i class='fa fa-book'></i> " . T_("Sample details")."</h4>";
|
||||
|
||||
$sql = "SELECT sv.sample_id, MIN(c.case_id) as case_id , MIN(s.Time_zone_name) as Time_zone_name,
|
||||
MIN(TIME_FORMAT(CONVERT_TZ(NOW(),@@session.time_zone,s.Time_zone_name),'". TIME_FORMAT ."')) as time
|
||||
MIN(TIME_FORMAT(CONVERT_TZ(NOW(),'System',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";
|
||||
@@ -363,8 +363,8 @@ if ($case_id != false)
|
||||
print "<div class='panel-body'><h4 class=''><i class='fa fa-clock-o'></i> " . T_("Appointments")."</h4>";
|
||||
|
||||
$sql = "SELECT
|
||||
MIN(CONVERT_TZ(a.start,'UTC',@@session.time_zone)) as start,
|
||||
MIN(CONVERT_TZ(a.end,'UTC',@@session.time_zone)) as end,
|
||||
MIN(CONVERT_TZ(a.start,'UTC',co.Time_zone_name)) as start,
|
||||
MIN(CONVERT_TZ(a.end,'UTC',co.Time_zone_name)) as end,
|
||||
MIN(CONCAT(r.firstName,' ', r.lastName)) as resp,
|
||||
MIN(IFNULL(ou.description,'" . T_("Not yet called") . "')) as outcome,
|
||||
MIN(CONCAT (oo.firstName,' ', oo.lastName)) as makerName,
|
||||
@@ -373,9 +373,10 @@ if ($case_id != false)
|
||||
MIN(CONCAT(' <a href=\'\' data-toggle=\'confirmation\' data-title=\'" . TQ_("ARE YOU SURE?") . "\' data-btnOkLabel=\'" . TQ_("Yes") . "\' data-btnCancelLabel=\'" . TQ_("No") . "\' data-placement=\'left\' data-href=\'displayappointments.php?case_id=', c.case_id, '&appointment_id=', a.appointment_id,'&delete=delete\'><i class=\'fa fa-trash fa-lg text-danger\' data-toggle=\'tooltip\' title=\'" . TQ_("Delete") . "\'></i></a> ')) as link,
|
||||
MIN(CONCAT(' <a href=\'displayappointments.php?case_id=', c.case_id, '&appointment_id=', a.appointment_id, '\' data-toggle=\'tooltip\' title=\'" . TQ_("Edit") . "\'><i class=\'fa fa-edit fa-lg\'></i></a> ')) 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)
|
||||
JOIN (`case` as c, respondent as r, questionnaire as q, operator as oo, call_attempt as cc, operator as co) 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'
|
||||
AND co.operator_id = '$operator_id'
|
||||
GROUP BY a.appointment_id
|
||||
ORDER BY a.start ASC";
|
||||
|
||||
|
||||
@@ -120,7 +120,7 @@ print "</div>";
|
||||
|
||||
print "<div class='col-sm-5'><h3>" . T_("Timezone list") . "</h3>";
|
||||
|
||||
$sql = "SELECT Time_zone_name, TIME_FORMAT(CONVERT_TZ(NOW(),@@session.time_zone,Time_zone_name),'". TIME_FORMAT ."') as time, CONCAT('<p class=\'text-center\' style=\'margin-bottom: 3px;\'><b class=\'label label-default\' style=\'font-size:85%;\'>', TIME_FORMAT(TIMEDIFF( CONVERT_TZ(NOW(),'$dtz','$dtz'),CONVERT_TZ(NOW(), Time_zone_name,'$dtz')),' %H : %i'), '</b></p>') AS timediff,
|
||||
$sql = "SELECT Time_zone_name, TIME_FORMAT(CONVERT_TZ(NOW(),'System',Time_zone_name),'". TIME_FORMAT ."') as time, CONCAT('<p class=\'text-center\' style=\'margin-bottom: 3px;\'><b class=\'label label-default\' style=\'font-size:85%;\'>', TIME_FORMAT(TIMEDIFF( CONVERT_TZ(NOW(),'$dtz','$dtz'),CONVERT_TZ(NOW(), Time_zone_name,'$dtz')),' %H : %i'), '</b></p>') AS timediff,
|
||||
CONCAT('<a href=\"?tz=', Time_zone_name ,'\" title=\"" . T_("Remove Timezone") . "\"><i class=\"fa fa-trash fa-lg text-danger\">" . T_("Remove") . "</i></a>') as link
|
||||
FROM timezone_template ORDER BY time ASC";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user