* @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"); /** * Authentication file */ include ("auth-admin.php"); /** * XHTML functions */ include ("../functions/functions.xhtml.php"); /** * Display functions */ include("../functions/functions.display.php"); /** * Operator functions */ include("../functions/functions.operator.php"); /** * Input functions */ include("../functions/functions.input.php"); xhtml_head(T_("Shift reports"),true,array("../include/bootstrap/css/bootstrap.min.css","../css/custom.css"),array("../js/window.js")); $operator_id = get_operator_id(); print "

" . T_("Please select a questionnaire") . "

"; $questionnaire_id = false; if (isset($_GET['questionnaire_id'])) $questionnaire_id = bigintval($_GET['questionnaire_id']); display_questionnaire_chooser($questionnaire_id ,false,"form-inline clearfix", "form-control"); if ($questionnaire_id) { print "

" . T_("Please select a shift") . "

"; $shift_id = false; if (isset($_GET['shift_id'])) $shift_id = bigintval($_GET['shift_id']); //get shifts for this questionnaire in operator time $sql = "SELECT s.shift_id as value, CONCAT(DATE_FORMAT(CONVERT_TZ(s.start,'UTC',o.Time_zone_name),'" . DATE_TIME_FORMAT ."'), ' - ', DATE_FORMAT(CONVERT_TZ(s.end,'UTC',o.Time_zone_name),'" . TIME_FORMAT ."')) as description, CASE WHEN s.shift_id = '$shift_id' THEN 'selected=\'selected\'' ELSE '' END AS selected FROM `shift` as s, operator as o WHERE s.questionnaire_id = '$questionnaire_id' AND o.operator_id = '$operator_id' ORDER BY s.start ASC"; $r = $db->GetAll($sql); if (!empty($r)) display_chooser($r,"shift","shift_id",true,"questionnaire_id=$questionnaire_id",true,true,false,true,"form-inline form-group"); if ($shift_id) { print "

" . T_("Reports for this shift") . "

"; //list current reports with a link to edit $sql = "SELECT s.report,o.firstName,DATE_FORMAT(CONVERT_TZ(s.datetime,'UTC',o.Time_zone_name),'" . DATE_TIME_FORMAT ."') as d, CONCAT('". TQ_("Edit") . "') as link FROM shift_report as s, operator as o WHERE s.operator_id = o.operator_id AND s.shift_id = '$shift_id'"; $r = $db->GetAll($sql); if (!empty($r)) xhtml_table($r,array("firstName", "d", "report","link"),array(T_("Operator"),T_("Date"),T_("Report"),T_("Edit")),"tclass"); //link to create a new report print "

" . T_("Create new report for this shift") . "

"; if (isset($_GET['createnewreport'])) { //create a new report print "

" . T_("Enter report for this shift") . "

"; print "

"; print "

"; print ""; print ""; print "

"; } else if (isset($_GET['report'])) { //add report to database $report = $db->qstr($_GET['report']); $sql = "INSERT INTO shift_report (shift_id,operator_id,datetime,report,shift_report_id) VALUES ('$shift_id','$operator_id',CONVERT_TZ(NOW(),'System','UTC'),$report,NULL)"; $db->Execute($sql); } else if (isset($_GET['shift_report_id'])) { $shift_report_id = bigintval($_GET['shift_report_id']); if (isset($_GET['ereport'])) { //edit report $report = $db->qstr($_GET['ereport']); $sql = "UPDATE shift_report SET operator_id = '$operator_id', datetime = CONVERT_TZ(NOW(),'System','UTC'), report = $report WHERE shift_report_id = '$shift_report_id'"; $db->Execute($sql); } $sql = "SELECT report FROM shift_report WHERE shift_report_id = '$shift_report_id'"; $r = $db->GetRow($sql); if (empty($r)) { print "

" . T_("This report does not exist in the database") . "

"; } else { //edit report print "

" . T_("Edit report for this shift") . "

"; print "

"; print "

"; print ""; print ""; print ""; print "

"; } } } } xhtml_foot(); ?>