* @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_once(dirname(__FILE__).'/../config.inc.php'); /** * Database file */ include ("../db.inc.php"); /** * XHTML functions */ include ("../functions/functions.xhtml.php"); /** * Operator functions */ include ("../functions/functions.operator.php"); /** * Input functions */ include ("../functions/functions.input.php"); /** * Calendar functions */ include ("../functions/functions.calendar.php"); //Create a new blank appointment and then edit it if (isset($_GET['new']) && isset($_GET['case_id'])) { $case_id = bigintval($_GET['case_id']); $db->StartTrans(); //First create a call attempt $operator_id = get_operator_id(); if ($operator_id == false) die(); //get the first respondent id for this case $sql = "SELECT respondent_id FROM respondent WHERE case_id = '$case_id'"; $rs = $db->GetRow($sql); $respondent_id = $rs['respondent_id']; //get the first contact_phone_id for this case $sql = "SELECT contact_phone_id FROM contact_phone WHERE case_id = '$case_id'"; $rs = $db->GetRow($sql); $contact_phone_id = $rs['contact_phone_id']; $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(),'System','UTC'),CONVERT_TZ(NOW(),'System','UTC'))"; $db->Execute($sql); $call_attempt_id = $db->Insert_ID(); $sql = "INSERT INTO `appointment` (appointment_id,case_id,contact_phone_id,call_attempt_id,start,end,require_operator_id,respondent_id,completed_call_id) VALUES (NULL,'$case_id','$contact_phone_id','$call_attempt_id',CONVERT_TZ(NOW() + INTERVAL 1 DAY,'System','UTC'),CONVERT_TZ(NOW() + INTERVAL 1 DAY,'System','UTC'),NULL,$respondent_id,NULL)"; $db->Execute($sql); $appointment_id = $db->Insert_ID(); $db->CompleteTrans(); $_GET['appointment_id'] = $appointment_id; } //update appointment if (isset($_GET['start']) && isset($_GET['appointment_id'])) { $appointment_id = bigintval($_GET['appointment_id']); $start = $db->qstr($_GET['start']); $end = $db->qstr($_GET['end']); $contact_phone_id = bigintval($_GET['contact_phone_id']); $respondent_id = bigintval($_GET['respondent_id']); $require_operator_id = "NULL"; if ($_GET['require_operator_id'] > 1) $require_operator_id = bigintval($_GET['require_operator_id']); //Edit this appointment in the database $sql = "UPDATE appointment as a, respondent as r SET a.start = CONVERT_TZ($start,r.Time_zone_name,'UTC'), a.end = CONVERT_TZ($end,r.Time_zone_name,'UTC'), a.contact_phone_id = $contact_phone_id, a.respondent_id = $respondent_id, a.require_operator_id = $require_operator_id WHERE a.appointment_id = $appointment_id AND r.respondent_id = $respondent_id"; $db->Execute($sql); } if (isset($_GET['appointment_id']) && isset($_GET['case_id'])) { $appointment_id = bigintval($_GET['appointment_id']); $case_id = bigintval($_GET['case_id']); if (isset($_GET['delete'])) { $sql = "DELETE FROM appointment WHERE appointment_id = '$appointment_id'"; $db->Execute($sql); xhtml_head(T_("Now modify case outcome")); print "
" . T_("The appointment has been deleted. Now you must modify the case outcome") . "
"; print ""; } else { //Display an edit form $css = array("../css/timepicker.css","../include/jquery-ui/css/smoothness/jquery-ui-1.8.2.custom.css"); $js = array("../include/jquery-ui/js/jquery-1.4.2.min.js","../include/jquery-ui/js/jquery-ui-1.8.2.custom.min.js","../include/timepicker/jquery-ui-timepicker-addon.js"); xhtml_head(T_("Edit appointment"),false,$css,$js); print ""; $sql = "SELECT a.contact_phone_id,a.call_attempt_id,CONVERT_TZ(a.start,'UTC',r.Time_zone_name) as start,CONVERT_TZ(a.end,'UTC',r.Time_zone_name) as end,a.respondent_id,a.require_operator_id FROM appointment as a, respondent as r WHERE a.appointment_id = '$appointment_id' AND a.case_id = '$case_id' AND r.respondent_id = a.respondent_id"; $rs = $db->GetRow($sql); if (!empty($rs)) { $respondent_id = $rs['respondent_id']; $contact_phone_id = $rs['contact_phone_id']; $require_operator_id = $rs['require_operator_id']; $start = $rs['start']; $end = $rs['end']; print "