diff --git a/admin/availability.php b/admin/availability.php new file mode 100644 index 00000000..d1f0b81b --- /dev/null +++ b/admin/availability.php @@ -0,0 +1,160 @@ + + * @copyright Australian Consortium for Social and Political Research Inc (ACSPRI) 2011 + * @package queXS + * @subpackage admin + * @link http://www.acspri.org.au/ queXS was writen for ACSPRI + * @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($_GET['availability_group'])) + $availability_group = intval($_GET['availability_group']); +else if (isset($_POST['availability_group'])) + $availability_group = intval($_POST['availability_group']); +else + die(T_("No availability group set")); + + +if (isset($_POST['day'])) +{ + $db->StartTrans(); + + $sql = "DELETE FROM availability + WHERE availability_group_id = $availability_group"; + + $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 availability (day_of_week,start,end,availability_group_id) + VALUES ('$val',$start,$end,$availability_group)"; + + $db->Execute($sql); + } + } + + $db->CompleteTrans(); +} + +xhtml_head(T_("Modify availability"),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_("Go back") . "
"; + + +$sql = "SELECT description + FROM availability_group + WHERE availability_group_id = $availability_group"; + +$rs = $db->GetRow($sql); + +print "

" . $rs['description'] . "

"; + +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 availability + WHERE availability_group_id = $availability_group"; + +$availabilitys = $db->GetAll($sql); +translate_array($availabilitys,array("dt")); + +$sql = "SELECT DATE_FORMAT(STR_TO_DATE(CONCAT($year, ' ',$woy,' ',day_of_week - 1),'%x %v %w'), '%W') as description, day_of_week as value, '' as selected + FROM day_of_week"; + +$daysofweek = $db->GetAll($sql); +translate_array($daysofweek,array("description")); + +?> +
+ +"; + $count = 0; + foreach($availabilitys as $availability) + { + print ""; + $count++; + } + print ""; + + +?> +
" . T_("Day") . "" . T_("Start") . "" . T_("End") . "
"; + display_chooser($daysofweek, "day[$count]", false, true, false, false, false, array("description",$availability['dt'])); + print "
"; + display_chooser($daysofweek, "day[$count]", false, true, false, false, false, false); + print "
+
+

"/>

+ +
+ diff --git a/admin/availabilitygroup.php b/admin/availabilitygroup.php new file mode 100644 index 00000000..991f2213 --- /dev/null +++ b/admin/availabilitygroup.php @@ -0,0 +1,108 @@ + + * @copyright Australian Consortium for Social and Political Research Inc (2011) + * @package queXS + * @subpackage admin + * @link http://www.acspri.org.au/ queXS was writen for ACSPRI + * @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"); + +/** + * Limesurvey functions + */ +include("../functions/functions.limesurvey.php"); + +/** + * Operator functions + */ +include("../functions/functions.operator.php"); + +/** + * Input functions + */ +include("../functions/functions.input.php"); + +global $db; + +xhtml_head(T_("Availability groups"),true,array("../css/table.css"),array("../js/window.js")); + +if (isset($_GET['availability_group'])) +{ + $availability_group = $db->qstr($_GET['availability_group']); + + $sql = "INSERT INTO `availability_group` (availability_group_id,description) + VALUES (NULL,$availability_group)"; + + $db->Execute($sql); +} + +//view groups +$sql = "SELECT description, + CONCAT('". T_("Modify") . "') as link + FROM availability_group"; + + $rs = $db->GetAll($sql); + +print "

" . T_("Availability groups")."

"; + +if (empty($rs)) + print "

" . T_("No availability groups") . "

"; +else + xhtml_table($rs,array("description","link"),array(T_("Availablity group"),T_("Modify"))); + + +//add a note +?> +
+

"/> +

+
+ diff --git a/admin/index.php b/admin/index.php index ec257857..00e99156 100644 --- a/admin/index.php +++ b/admin/index.php @@ -51,24 +51,34 @@ print "
@@ -141,6 +142,7 @@ print $script; $case_id = get_case_id($operator_id,true); $ca = get_call_attempt($operator_id,true); $appointment = false; +$availability = is_using_availability($case_id); if ($ca) { if (is_on_appointment($ca)) @@ -181,6 +183,16 @@ xhtml_object($data,"main-content");
+ +
"> +

+
+
+ + + +
">