diff --git a/admin/callrestrict.php b/admin/callrestrict.php new file mode 100644 index 00000000..ffc51048 --- /dev/null +++ b/admin/callrestrict.php @@ -0,0 +1,138 @@ + + * @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"); + +global $db; + +$year="2008"; +$woy="1"; + + +if (isset($_POST['day'])) +{ + $db->StartTrans(); + + $sql = "DELETE FROM call_restrict + WHERE 1"; + + $db->Execute($sql); + + foreach($_POST['day'] as $key => $val) + { + if (!empty($val)) + { + $val = intval($val); + $key = intval($key); + + $start = $db->qstr($_POST['start'][$key],get_magic_quotes_gpc()); + $end = $db->qstr($_POST['end'][$key],get_magic_quotes_gpc()); + + $sql = "INSERT INTO call_restrict (day_of_week,start,end) + VALUES ('$val',$start,$end)"; + + $db->Execute($sql); + } + } + + $db->CompleteTrans(); +} + +xhtml_head(T_("Modify call restriction times"),true,array("../css/shifts.css"),array("../js/addrow-v2.js")); + +/** + * Display warning if timezone data not installed + * + */ + +$sql = "SELECT CONVERT_TZ(NOW(),'Australia/Victoria','UTC') as t"; +$rs = $db->GetRow($sql); + +if (empty($rs) || !$rs || empty($rs['t'])) + print "
" . T_("Your database does not have timezones installed, please see here for details") . "
"; + + +print "

" . T_("Enter the start and end times for each day of the week to restrict calls within") . "

"; + +/** + * Begin displaying currently loaded restriction times + */ + +$sql = "SELECT DATE_FORMAT( STR_TO_DATE( CONCAT( '$year', ' ', '$woy', ' ', day_of_week -1 ) , '%x %v %w' ) , '%W' ) AS dt,day_of_week,start,end + FROM call_restrict"; + +$shifts = $db->GetAll($sql); + + +$sql = "SELECT DATE_FORMAT(STR_TO_DATE(CONCAT($year, ' ',$woy,' ',day_of_week - 1),'%x %v %w'), '%W') as dt, day_of_week as dow + FROM day_of_week"; + +$daysofweek = $db->Execute($sql); + + +?> +
+ +"; + $count = 0; + foreach($shifts as $shift) + { + print ""; + $daysofweek->MoveFirst(); + $count++; + } + print ""; + + +?> +
" . T_("Day") . "" . T_("Start") . "" . T_("End") . "
" . $daysofweek->GetMenu("day[$count]",$shift['dt']) . "
" . $daysofweek->GetMenu("day[$count]") . "
+
+

"/>

+
+ diff --git a/admin/shifttemplate.php b/admin/shifttemplate.php new file mode 100644 index 00000000..71ed1eec --- /dev/null +++ b/admin/shifttemplate.php @@ -0,0 +1,138 @@ + + * @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"); + +global $db; + +$year="2008"; +$woy="1"; + + +if (isset($_POST['day'])) +{ + $db->StartTrans(); + + $sql = "DELETE FROM shift_template + WHERE 1"; + + $db->Execute($sql); + + foreach($_POST['day'] as $key => $val) + { + if (!empty($val)) + { + $val = intval($val); + $key = intval($key); + + $start = $db->qstr($_POST['start'][$key],get_magic_quotes_gpc()); + $end = $db->qstr($_POST['end'][$key],get_magic_quotes_gpc()); + + $sql = "INSERT INTO shift_template (day_of_week,start,end) + VALUES ('$val',$start,$end)"; + + $db->Execute($sql); + } + } + + $db->CompleteTrans(); +} + +xhtml_head(T_("Modify shift template"),true,array("../css/shifts.css"),array("../js/addrow-v2.js")); + +/** + * Display warning if timezone data not installed + * + */ + +$sql = "SELECT CONVERT_TZ(NOW(),'Australia/Victoria','UTC') as t"; +$rs = $db->GetRow($sql); + +if (empty($rs) || !$rs || empty($rs['t'])) + print "
" . T_("Your database does not have timezones installed, please see here for details") . "
"; + + +print "

" . T_("Enter standard shift start and end times for each day of the week in local time") . "

"; + +/** + * Begin displaying currently loaded shifts + */ + +$sql = "SELECT DATE_FORMAT( STR_TO_DATE( CONCAT( '$year', ' ', '$woy', ' ', day_of_week -1 ) , '%x %v %w' ) , '%W' ) AS dt,day_of_week,start,end + FROM shift_template"; + +$shifts = $db->GetAll($sql); + + +$sql = "SELECT DATE_FORMAT(STR_TO_DATE(CONCAT($year, ' ',$woy,' ',day_of_week - 1),'%x %v %w'), '%W') as dt, day_of_week as dow + FROM day_of_week"; + +$daysofweek = $db->Execute($sql); + + +?> +
+ +"; + $count = 0; + foreach($shifts as $shift) + { + print ""; + $daysofweek->MoveFirst(); + $count++; + } + print ""; + + +?> +
" . T_("Day") . "" . T_("Start") . "" . T_("End") . "
" . $daysofweek->GetMenu("day[$count]",$shift['dt']) . "
" . $daysofweek->GetMenu("day[$count]") . "
+
+

"/>

+
+ diff --git a/admin/timezonetemplate.php b/admin/timezonetemplate.php new file mode 100644 index 00000000..91d5d0aa --- /dev/null +++ b/admin/timezonetemplate.php @@ -0,0 +1,110 @@ + + * @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"); + +/** + * Input functions + */ +include("../functions/functions.input.php"); + +global $db; + + +if (isset($_GET['time_zone'])) +{ + //need to add sample to questionnaire + + $tz = $db->qstr($_GET['time_zone'],get_magic_quotes_gpc()); + + $sql = "INSERT INTO timezone_template(Time_zone_name) + VALUES($tz)"; + + $db->Execute($sql); + +} + +if (isset($_GET['tz'])) +{ + //need to remove rsid from questionnaire + + $tz = $db->qstr($_GET['tz'],get_magic_quotes_gpc()); + + $sql = "DELETE FROM timezone_template + WHERE Time_zone_name = $tz"; + + $db->Execute($sql); +} + + +xhtml_head(T_("Add/Remove Timezones"),true,false,array("../js/window.js")); +print "

" . T_("Click to remove a Timezone from the default list") . "

"; + +$sql = "SELECT Time_zone_name + FROM timezone_template"; + + $qs = $db->GetAll($sql); + + foreach($qs as $q) + { + print "

{$q['Time_zone_name']}

"; + } + + print "

" . T_("Add a Timezone:") . "

"; + ?> +

+ +

+
+ diff --git a/js/addrow-v2.js b/js/addrow-v2.js new file mode 100644 index 00000000..5c0c9eb9 --- /dev/null +++ b/js/addrow-v2.js @@ -0,0 +1,117 @@ +/* + * addrow.js - an example JavaScript program for adding a row of input fields + * to an HTML form + * + * This program is placed into the public domain. + * + * The orginal author is Dwayne C. Litzenberger. + * + * THIS SOFTWARE IS PROVIDED AS-IS WITHOUT WARRANTY + * OF ANY KIND, NOT EVEN THE IMPLIED WARRANTY OF + * MERCHANTABILITY. THE AUTHOR OF THIS SOFTWARE, + * ASSUMES _NO_ RESPONSIBILITY FOR ANY CONSEQUENCE + * RESULTING FROM THE USE, MODIFICATION, OR + * REDISTRIBUTION OF THIS SOFTWARE. + * + * Home page: http://www.dlitz.net/software/addrow/ + * + * History: + * Version 2 - 2006-01-14 dlitz@dlitz.net + * - Add support for MSIE 6 + * - Separate HTML and JavaScript into separate files + * - Tested on: + * + Konqueror 3.4.2 + * + Microsoft Internet Explorer 5.00 + * + Microsoft Internet Explorer 6.0 + * + Mozilla Firefox 1.0.4 (via browsershots.org) + * + Mozilla Firefox 1.5 + * + Opera 8.51 + * + Safari 2.0 (via browsershots.org) + * Version 1 + * - Initial release + * + */ + +function addRow() { + /* Declare variables */ + var elements, templateRow, rowCount, row, className, newRow, element; + var i, s, t; + + /* Get and count all "tr" elements with class="row". The last one will + * be serve as a template. */ + if (!document.getElementsByTagName) + return false; /* DOM not supported */ + elements = document.getElementsByTagName("tr"); + templateRow = null; + rowCount = 0; + for (i = 0; i < elements.length; i++) { + row = elements.item(i); + + /* Get the "class" attribute of the row. */ + className = null; + if (row.getAttribute) + className = row.getAttribute('class') + if (className == null && row.attributes) { // MSIE 5 + /* getAttribute('class') always returns null on MSIE 5, and + * row.attributes doesn't work on Firefox 1.0. Go figure. */ + className = row.attributes['class']; + if (className && typeof(className) == 'object' && className.value) { + // MSIE 6 + className = className.value; + } + } + + /* This is not one of the rows we're looking for. Move along. */ + if (className != "row_to_clone") + continue; + + /* This *is* a row we're looking for. */ + templateRow = row; + rowCount++; + } + if (templateRow == null) + return false; /* Couldn't find a template row. */ + + /* Make a copy of the template row */ + newRow = templateRow.cloneNode(true); + + newRow.id = 'row-' + rowCount.toString(); + + /* Change the form variables e.g. price[x] -> price[rowCount] */ + elements = newRow.getElementsByTagName("input"); + for (i = 0; i < elements.length; i++) { + element = elements.item(i); + s = null; + s = element.getAttribute("name"); + if (s == null) + continue; + t = s.split("["); + if (t.length < 2) + continue; + s = t[0] + "[" + rowCount.toString() + "]"; + element.setAttribute("name", s); + element.value = ""; + } + + elements = newRow.getElementsByTagName("select"); + for (i = 0; i < elements.length; i++) { + element = elements.item(i); + s = null; + s = element.getAttribute("name"); + if (s == null) + continue; + t = s.split("["); + if (t.length < 2) + continue; + s = t[0] + "[" + rowCount.toString() + "]"; + element.setAttribute("name", s); + element.value = ""; + } + + + /* Add the newly-created row to the table */ + templateRow.parentNode.appendChild(newRow); + return true; +} + +/* set ts=8 sw=4 sts=4 expandtab: */