2
0
mirror of https://github.com/ACSPRI/queXS synced 2024-04-02 12:12:16 +00:00

Added "availability" feature

Administrators specificy "availability groups" which include days of the week and times
Operators then choose if a case will be available within the availability group
This commit is contained in:
azammitdcarf
2011-07-04 06:18:19 +00:00
parent a80f582ec3
commit a097c15443
10 changed files with 791 additions and 8 deletions

160
admin/availability.php Normal file
View File

@@ -0,0 +1,160 @@
<?
/**
* Modify availability within this availability group
*
*
* This file is part of queXS
*
* queXS is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* queXS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with queXS; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*
* @author Adam Zammit <adam.zammit@acspri.org.au>
* @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 "<div class='warning'><a href='http://dev.mysql.com/doc/mysql/en/time-zone-support.html'>" . T_("Your database does not have timezones installed, please see here for details") . "</a></div>";
print "<div><a href='availabilitygroup.php'>" . T_("Go back") . "</a></div>";
$sql = "SELECT description
FROM availability_group
WHERE availability_group_id = $availability_group";
$rs = $db->GetRow($sql);
print "<h2>" . $rs['description'] . "</h2>";
print "<h3>" . T_("Enter the start and end times for each day of the week to restrict calls within") . "</h3>";
/**
* 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"));
?>
<form method="post" action="">
<table>
<?
print "<tr><th>" . T_("Day") . "</th><th>" . T_("Start") . "</th><th>" . T_("End") . "</th></tr>";
$count = 0;
foreach($availabilitys as $availability)
{
print "<tr id='row-$count' class='row_to_clone'><td>";
display_chooser($daysofweek, "day[$count]", false, true, false, false, false, array("description",$availability['dt']));
print "</td><td><input size=\"8\" name=\"start[$count]\" maxlength=\"8\" type=\"text\" value=\"{$availability['start']}\"/></td><td><input name=\"end[$count]\" type=\"text\" size=\"8\" maxlength=\"8\" value=\"{$availability['end']}\"/></td></tr>";
$count++;
}
print "<tr class='row_to_clone' id='row-$count'><td>";
display_chooser($daysofweek, "day[$count]", false, true, false, false, false, false);
print "</td><td><input size=\"8\" name=\"start[$count]\" maxlength=\"8\" type=\"text\" value=\"00:00:00\"/></td><td><input name=\"end[$count]\" type=\"text\" size=\"8\" maxlength=\"8\" value=\"00:00:00\"/></td></tr>";
?>
</table>
<div><a onclick="addRow(); return false;" href="#"><? echo T_("Add row"); ?></a></div>
<p><input type="submit" name="submit" value="<? echo T_("Save changes to availabilities"); ?>"/></p>
<input type="hidden" name="availability_group" value="<? echo $availability_group;?>"/>
</form>
<?
xhtml_foot();
?>

108
admin/availabilitygroup.php Normal file
View File

@@ -0,0 +1,108 @@
<?
/**
* List and create availability groups
*
*
* This file is part of queXS
*
* queXS is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* queXS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with queXS; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*
* @author Adam Zammit <adam.zammit@acspri.org.au>
* @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('<a href=\'availability.php?availability_group=', availability_group_id, '\'>". T_("Modify") . "</a>') as link
FROM availability_group";
$rs = $db->GetAll($sql);
print "<h3>" . T_("Availability groups")."</h3>";
if (empty($rs))
print "<p>" . T_("No availability groups") . "</p>";
else
xhtml_table($rs,array("description","link"),array(T_("Availablity group"),T_("Modify")));
//add a note
?>
<form method="get" action="?">
<p><input type="text" class="textclass" name="availability_group" id="availability_group"/><input class="submitclass" type="submit" name="submit" value="<? echo T_("Add availability group"); ?>"/>
</p>
</form>
<?
xhtml_foot();
?>

View File

@@ -51,24 +51,34 @@ print "<div id='menu'><ul class='navmenu'>";
print "<li><h3>" . T_("Questionnaire creation and management") . "</h3>";
print "<ul><li><a href=\"?page=new.php\">" . T_("Create a new questionnaire") . "</a></li>";
print "<li><a href=\"?page=questionnairelist.php\">" . T_("Questionnaire management") . "</a></li>";
print "<li><a href=\"?page=" . LIME_URL . "admin/admin.php\">" . T_("Administer questionnaires with Limesurvey") . "</a></li>";
print "<li><a href=\"?page=" . LIME_URL . "admin/admin.php\">" . T_("Administer questionnaires with Limesurvey") . "</a></li></ul></li>";
print "<li><h3>" . T_("Sample/List management") . "</h3><ul>";
print "<li><a href=\"?page=import.php\">" . T_("Import a sample file (in CSV form)") . "</a></li>";
print "<li><a href=\"?page=assignsample.php\">" . T_("Assign samples to questionnaires") . "</a></li>";
print "<li><a href=\"?page=questionnaireprefill.php\">" . T_("Set values in questionnaire to pre fill") . "</a></li>";
print "<li><a href=\"?page=questionnaireprefill.php\">" . T_("Set values in questionnaire to pre fill") . "</a></li></ul></li>";
print "<li><h3>" . T_("Quota management") . "</h3><ul>";
print "<li><a href=\"?page=quota.php\">" . T_("Quota management") . "</a></li>";
print "<li><a href=\"?page=quotarow.php\">" . T_("Quota row management") . "</a></li>";
print "<li><a href=\"?page=quotarow.php\">" . T_("Quota row management") . "</a></li></ul></li>";
print "<li><h3>" . T_("Operator management") . "</h3><ul>";
print "<li><a href=\"?page=operators.php\">" . T_("Add operators to the system") . "</a></li>";
print "<li><a href=\"?page=operatorlist.php\">" . T_("Operator management") . "</a></li>";
print "<li><a href=\"?page=operatorquestionnaire.php\">" . T_("Assign operators to questionnaires") . "</a></li>";
print "<li><a href=\"?page=operatorskill.php\">" . T_("Modify operator skills") . "</a></li>";
print "<li><a href=\"?page=addshift.php\">" . T_("Shift management (add/remove)") . "</a></li>";
print "<li><a href=\"?page=dataoutput.php\">" . T_("Data output") . "</a></li></ul></li>";
print "<li><a href=\"?page=operatorskill.php\">" . T_("Modify operator skills") . "</a></li></ul></li>";
print "<li><h3>" . T_("Availability and shift management") . "</h3><ul>";
print "<li><a href=\"?page=availabilitygroup.php\">" . T_("Manage availablity groups") . "</a></li>";
print "<li><a href=\"?page=questionnaireavailability.php\">" . T_("Assign availabilities to questionnaires") . "</a></li>";
print "<li><a href=\"?page=addshift.php\">" . T_("Shift management (add/remove)") . "</a></li></ul></li>";
print "<li><h3>" . T_("Questionnaire progress") . "</h3>";
print "<ul><li><a href=\"?page=displayappointments.php\">" . T_("Display all future appointments") . "</a></li>";
print "<li><a href=\"?page=samplecallattempts.php\">" . T_("Sample call attempts report") . "</a></li>";
print "<li><a href=\"?page=quotareport.php\">" . T_("Quota report") . "</a></li>";
print "<li><a href=\"?page=outcomes.php\">" . T_("Questionnaire outcomes") . "</a></li></ul></li>";
print "<li><a href=\"?page=outcomes.php\">" . T_("Questionnaire outcomes") . "</a></li>";
print "<li><a href=\"?page=dataoutput.php\">" . T_("Data output") . "</a></li></ul></li>";
print "<li><h3>" . T_("Performance") . "</h3>";
print "<ul><li><a href=\"?page=operatorperformance.php\">" . T_("Operator performance") . "</a></li></ul></li>";

View File

@@ -0,0 +1,154 @@
<?
/**
* Assign availability groups to a questionnaire
*
*
* This file is part of queXS
*
* queXS is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* queXS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with queXS; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*
* @author Adam Zammit <adam.zammit@acspri.org.au>
* @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");
/**
* Display functions
*/
include("../functions/functions.display.php");
/**
* Input functions
*/
include("../functions/functions.input.php");
global $db;
if (isset($_GET['questionnaire_id']) && isset($_GET['availability_group']))
{
//need to add availability_group to questionnaire
$questionnaire_id = bigintval($_GET['questionnaire_id']);
$availability_group = bigintval($_GET['availability_group']);
$sql = "INSERT INTO questionnaire_availability(questionnaire_id,availability_group_id)
VALUES('$questionnaire_id','$availability_group')";
$db->Execute($sql);
}
if (isset($_GET['questionnaire_id']) && isset($_GET['ravailability_group']))
{
//need to remove rsid from questionnaire
$questionnaire_id = bigintval($_GET['questionnaire_id']);
$availability_group = bigintval($_GET['ravailability_group']);
$sql = "DELETE FROM questionnaire_availability
WHERE questionnaire_id = '$questionnaire_id'
AND availability_group_id = '$availability_group'";
$db->Execute($sql);
}
$questionnaire_id = false;
if (isset($_GET['questionnaire_id'])) $questionnaire_id = bigintval($_GET['questionnaire_id']);
xhtml_head(T_("Assign availability group to questionnaire"),true,false,array("../js/window.js"));
print "<h1>" . T_("Select a questionnaire from the list below") . "</h1>";
display_questionnaire_chooser($questionnaire_id);
if ($questionnaire_id != false)
{
$sql = "SELECT q.availability_group_id,a.description as description
FROM questionnaire_availability as q, availability_group as a
WHERE q.availability_group_id = a.availability_group_id
AND q.questionnaire_id = '$questionnaire_id'";
$qs = $db->GetAll($sql);
if (empty($qs))
{
print "<h2>" . T_("There are no availability groups selected for this questionnaire") . "</h2>";
}
else
{
print "<h2>" . T_("Availability groups selected for this questionnaire") . "</h2>";
foreach($qs as $q)
{
print "<p><a href=\"?questionnaire_id=$questionnaire_id&amp;ravailability_group={$q['availability_group_id']}\">{$q['availability_group_id']} - {$q['description']} (" . T_("Click to unassign") . ")</a></p>";
}
}
$sql = "SELECT si.availability_group_id,si.description
FROM availability_group as si
LEFT JOIN questionnaire_availability as q ON (q.questionnaire_id = '$questionnaire_id' AND q.availability_group_id = si.availability_group_id)
WHERE q.questionnaire_id is NULL";
$qs = $db->GetAll($sql);
if (!empty($qs))
{
print "<h2>" . T_("Add an availability group to this questionnaire:") . "</h2>";
?>
<form action="" method="get">
<p><label for="availability_group"><? echo T_("Select availability group:"); ?></label><select name="availability_group" id="availability_group">
<?
foreach($qs as $q)
{
print "<option value=\"{$q['availability_group_id']}\">{$q['description']}</option>";
}
?>
</select><br/>
<input type="hidden" name="questionnaire_id" value="<? print($questionnaire_id); ?>"/>
<input type="submit" name="add_availability" value="Add availability group"/></p>
</form>
<?
}
}
xhtml_foot();
?>

View File

@@ -184,8 +184,27 @@ if ($case_id != false)
$db->Execute($sql);
}
if (isset($_GET['submitag']))
{
$db->StartTrans();
$sql = "DELETE FROM case_availability
WHERE case_id = '$case_id'";
$db->Execute($sql);
foreach($_GET as $key => $val)
{
if (substr($key,0,2) == "ag")
{
$sql = "INSERT INTO case_availability (case_id,availability_group_id)
VALUES ($case_id,'$val')";
$db->Execute($sql);
}
}
$db->CompleteTrans();
}
$sql = "SELECT o.description,o.outcome_id, q.description as qd, si.description as sd
FROM `case` as c, `outcome` as o, questionnaire as q, sample as s, sample_import as si
WHERE c.case_id = '$case_id'
@@ -303,6 +322,50 @@ if ($case_id != false)
</form>
<?
//view availability
if (is_using_availability($case_id))
{
//List all availability group items and whether selected or not (all selected by default unless >= 1 availability group is in use for this case
$sql = "SELECT qa.availability_group_id,ag.description,ca.availability_group_id as selected_group_id
FROM `case` as c
JOIN questionnaire_availability AS qa ON (qa.questionnaire_id = c.questionnaire_id)
JOIN availability_group AS ag ON (ag.availability_group_id = qa.availability_group_id)
LEFT JOIN case_availability AS ca ON (ca.availability_group_id = qa.availability_group_id and ca.case_id = c.case_id)
WHERE c.case_id = '$case_id'";
$rs = $db->GetAll($sql);
//Display all availability groups as checkboxes
print "<p>" . T_("Select groups to limit availability (Selecting none means always available)") . "</p>";
print "<form action='?' method='get'>";
foreach ($rs as $r)
{
$checked = "";
//if ($allselected || $r['availability_group_id'] == $r['selected_group_id'])
if ($r['availability_group_id'] == $r['selected_group_id'])
$checked = "checked='checked'";
print " <div><input type='checkbox' name='ag{$r['availability_group_id']}' id='ag{$r['availability_group_id']}'
value='{$r['availability_group_id']}' $checked />
<label for='ag{$r['availability_group_id']}'>{$r['description']}</label></div>";
}
?>
<p><input type="hidden" name="case_id" value="<? echo $case_id;?>"/><input class="submitclass" type="submit" name="submitag" value="<? echo T_("Update case availability"); ?>"/></p>
</form>
<?
}
else
{
print "<p>" . T_("Availability groups not defined for this questionnaire") . "</p>";
}
//assign this to an operator for their next case
print "<h3>" . T_("Assign this case to operator (will appear as next case for them)") . "</h3>";
?>

View File

@@ -119,7 +119,10 @@ while (!is_process_killed($process_id)) //check if process killed every $sleepin
LEFT JOIN appointment as apn on (apn.case_id = c.case_id AND apn.completed_call_id is NULL AND (CONVERT_TZ(NOW(),'System','UTC') >= apn.start) AND (CONVERT_TZ(NOW(),'System','UTC') <= apn.end))
LEFT JOIN call_restrict as cr on (cr.day_of_week = DAYOFWEEK(CONVERT_TZ(NOW(), 'System' , s.Time_zone_name)) and TIME(CONVERT_TZ(NOW(), 'System' , s.Time_zone_name)) >= cr.start and TIME(CONVERT_TZ(NOW(), 'System' , s.Time_zone_name)) <= cr.end)
LEFT JOIN questionnaire_sample_exclude_priority AS qsep ON (qsep.questionnaire_id = c.questionnaire_id AND qsep.sample_id = c.sample_id)
LEFT JOIN case_availability AS casa ON (casa.case_id = c.case_id)
LEFT JOIN availability AS ava ON (ava.availability_group_id = casa.availability_group_id)
WHERE c.current_operator_id IS NULL
AND (casa.case_id IS NULL OR (ava.day_of_week = DAYOFWEEK(CONVERT_TZ(NOW(),'System',s.Time_zone_name)) AND TIME(CONVERT_TZ(NOW(), 'System' , s.Time_zone_name)) >= ava.start AND TIME(CONVERT_TZ(NOW(), 'System' , s.Time_zone_name)) <= ava.end ))
AND (a.call_id is NULL or (a.end < CONVERT_TZ(DATE_SUB(NOW(), INTERVAL ou.default_delay_minutes MINUTE),'System','UTC')))
AND ap.case_id is NULL
AND ((qsep.questionnaire_id is NULL) or qsep.exclude = 0)

151
availability.php Normal file
View File

@@ -0,0 +1,151 @@
<?
/**
* Update case availability
*
*
* This file is part of queXS
*
* queXS is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* queXS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with queXS; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*
* @author Adam Zammit <adam.zammit@acspri.org.au>
* @copyright Australian Consortium for Social and Political Research Incorporated (ACSPRI) 2011
* @package queXS
* @subpackage user
* @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");
/**
* Operator functions
*/
include("functions/functions.operator.php");
$js = false;
if (AUTO_LOGOUT_MINUTES !== false)
$js = array("include/jquery-ui/js/jquery-1.4.2.min.js","js/childnap.js");
xhtml_head(T_("Availability"),true,array("css/table.css"),$js);
$operator_id = get_operator_id();
$case_id = get_case_id($operator_id);
if (is_using_availability($case_id))
{
if (isset($_POST['count']))
{
$db->StartTrans();
$sql = "DELETE FROM case_availability
WHERE case_id = '$case_id'";
$db->Execute($sql);
//if number of selected items != count then add
$count = intval($_POST['count']);
$pcount = 0;
foreach($_POST as $key => $val)
{
if (substr($key,0,2) == "ag")
$pcount++;
}
//if ($pcount != $count)
//{
foreach($_POST as $key => $val)
{
if (substr($key,0,2) == "ag")
{
$sql = "INSERT INTO case_availability (case_id,availability_group_id)
VALUES ($case_id,'$val')";
$db->Execute($sql);
}
}
//}
$db->CompleteTrans();
}
//List all availability group items and whether selected or not (all selected by default unless >= 1 availability group is in use for this case
$sql = "SELECT qa.availability_group_id,ag.description,ca.availability_group_id as selected_group_id
FROM `case` as c
JOIN questionnaire_availability AS qa ON (qa.questionnaire_id = c.questionnaire_id)
JOIN availability_group AS ag ON (ag.availability_group_id = qa.availability_group_id)
LEFT JOIN case_availability AS ca ON (ca.availability_group_id = qa.availability_group_id and ca.case_id = c.case_id)
WHERE c.case_id = '$case_id'";
$rs = $db->GetAll($sql);
//See if all are selecetd or not
$allselected = true;
$count = count($rs);
foreach($rs as $r)
{
if (!empty($r['selected_group_id']))
{
$allselected = false;
break;
}
}
//Display all availability groups as checkboxes
print "<p>" . T_("Select groups to limit availability (Selecting none means always available)") . "</p>";
print "<form action='?' method='post' id='agform'>";
foreach ($rs as $r)
{
$checked = "";
//if ($allselected || $r['availability_group_id'] == $r['selected_group_id'])
if ($r['availability_group_id'] == $r['selected_group_id'])
$checked = "checked='checked'";
print " <div><input type='checkbox' name='ag{$r['availability_group_id']}' id='ag{$r['availability_group_id']}'
value='{$r['availability_group_id']}' $checked onclick='document.forms[\"agform\"].submit();' />
<label for='ag{$r['availability_group_id']}'>{$r['description']}</label></div>";
}
print "<input type='hidden' name='count' id='count' value='$count'/></form>";
}
else
{
print "<p>" . T_("Availability groups not defined for this questionnaire") . "</p>";
}
xhtml_foot();
?>

View File

@@ -1388,3 +1388,95 @@ CREATE TABLE `timezone_template` (
`Time_zone_name` char(64) NOT NULL,
PRIMARY KEY (`Time_zone_name`)
) ENGINE=InnoDB DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
-- --------------------------------------------------------
--
-- Table structure for table `availability`
--
CREATE TABLE IF NOT EXISTS `availability` (
`availability_id` bigint(20) NOT NULL auto_increment,
`availability_group_id` bigint(20) NOT NULL,
`start` time NOT NULL,
`end` time NOT NULL,
`day_of_week` tinyint(1) NOT NULL,
PRIMARY KEY (`availability_id`),
KEY `availability_group_id` (`availability_group_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
--
-- Dumping data for table `availability`
--
INSERT INTO `availability` (`availability_id`, `availability_group_id`, `start`, `end`, `day_of_week`) VALUES
(1, 1, '00:00:00', '11:59:59', 2),
(2, 1, '00:00:00', '11:59:59', 3),
(3, 1, '00:00:00', '11:59:59', 4),
(4, 1, '00:00:00', '11:59:59', 5),
(5, 1, '00:00:00', '11:59:59', 6),
(6, 2, '12:00:00', '17:59:59', 2),
(7, 2, '12:00:00', '17:59:59', 3),
(8, 2, '12:00:00', '17:59:59', 4),
(9, 2, '12:00:00', '17:59:59', 5),
(10, 2, '12:00:00', '17:59:59', 6),
(11, 3, '18:00:00', '23:59:59', 2),
(12, 3, '18:00:00', '23:59:59', 3),
(13, 3, '18:00:00', '23:59:59', 4),
(14, 3, '18:00:00', '23:59:59', 5),
(15, 3, '18:00:00', '23:59:59', 6),
(16, 4, '00:00:00', '23:59:59', 7);
-- --------------------------------------------------------
--
-- Table structure for table `availability_group`
--
CREATE TABLE IF NOT EXISTS `availability_group` (
`availability_group_id` bigint(20) NOT NULL auto_increment,
`description` text collate utf8_unicode_ci NOT NULL,
PRIMARY KEY (`availability_group_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
--
-- Dumping data for table `availability_group`
--
INSERT INTO `availability_group` (`availability_group_id`, `description`) VALUES
(1, 'Weekday mornings (Before 12pm)'),
(2, 'Weekday afternoons (After 12pm but before 6pm)'),
(3, 'Evenings (After 6pm)'),
(4, 'Saturdays');
-- --------------------------------------------------------
--
-- Table structure for table `case_availability`
--
CREATE TABLE IF NOT EXISTS `case_availability` (
`case_id` bigint(20) NOT NULL,
`availability_group_id` bigint(20) NOT NULL,
PRIMARY KEY (`case_id`,`availability_group_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
--
-- Dumping data for table `case_availability`
--
-- --------------------------------------------------------
--
-- Table structure for table `questionnaire_availability`
--
CREATE TABLE IF NOT EXISTS `questionnaire_availability` (
`questionnaire_id` bigint(20) NOT NULL,
`availability_group_id` bigint(20) NOT NULL,
PRIMARY KEY (`questionnaire_id`,`availability_group_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
--
-- Dumping data for table `questionnaire_availability`
--

View File

@@ -44,6 +44,33 @@ include_once(dirname(__FILE__).'/../config.inc.php');
include_once(dirname(__FILE__).'/../db.inc.php');
/**
* Check if the project associated with this case is using
* questionnaire availability
*
* @param int $case_id
*
* @return boolean True if using case availability, false if not
* @author Adam Zammit <adam.zammit@acspri.org.au>
* @since 2011-07-01
*/
function is_using_availability($case_id)
{
global $db;
$sql = "SELECT count(qa.questionnaire_id) as cc
FROM `case` as c, questionnaire_availability as qa
WHERE qa.questionnaire_id = c.questionnaire_id
AND c.case_id = $case_id";
$rs = $db->CacheGetRow($sql);
if ($rs['cc'] > 0)
return true;
return false;
}
/**
* Return if VOIP is enabled on an operator by operator basis
* Will always return false if VOIP is globally disabled
@@ -379,8 +406,11 @@ function get_case_id($operator_id, $create = false)
LEFT JOIN appointment as apn on (apn.case_id = c.case_id AND apn.completed_call_id is NULL AND (CONVERT_TZ(NOW(),'System','UTC') >= apn.start) AND (CONVERT_TZ(NOW(),'System','UTC') <= apn.end))
LEFT JOIN call_restrict as cr on (cr.day_of_week = DAYOFWEEK(CONVERT_TZ(NOW(), 'System' , s.Time_zone_name)) and TIME(CONVERT_TZ(NOW(), 'System' , s.Time_zone_name)) >= cr.start and TIME(CONVERT_TZ(NOW(), 'System' , s.Time_zone_name)) <= cr.end)
LEFT JOIN questionnaire_sample_exclude_priority AS qsep ON (qsep.questionnaire_id = c.questionnaire_id AND qsep.sample_id = c.sample_id)
LEFT JOIN case_availability AS casa ON (casa.case_id = c.case_id)
LEFT JOIN availability AS ava ON (ava.availability_group_id = casa.availability_group_id)
JOIN operator_skill as os on (os.operator_id = op.operator_id and os.outcome_type_id = ou.outcome_type_id)
WHERE c.current_operator_id IS NULL
AND (casa.case_id IS NULL OR (ava.day_of_week = DAYOFWEEK(CONVERT_TZ(NOW(),'System',s.Time_zone_name)) AND TIME(CONVERT_TZ(NOW(), 'System' , s.Time_zone_name)) >= ava.start AND TIME(CONVERT_TZ(NOW(), 'System' , s.Time_zone_name)) <= ava.end ))
AND (a.call_id is NULL or (a.end < CONVERT_TZ(DATE_SUB(NOW(), INTERVAL ou.default_delay_minutes MINUTE),'System','UTC')))
AND ap.case_id is NULL
AND ((qsep.questionnaire_id is NULL) or qsep.exclude = 0)
@@ -1659,7 +1689,7 @@ function end_case($operator_id)
JOIN outcome AS o ON ( c.outcome_id = o.outcome_id)
WHERE c.case_id = '$case_id'
AND o.outcome_id != 18
ORDER BY o.contacted DESC,c.call_id DESC
ORDER BY c.call_id DESC
LIMIT 1";
$t = $db->GetRow($sql);

View File

@@ -133,6 +133,7 @@ print $script;
<div class='box'><a href="javascript:poptastic('supervisor.php');"><? echo T_("Supervisor"); ?></a></div>
<div class='box' id='recbox'><a id='reclink' class='offline' href="javascript:poptastic('record.php?start=start');"><? echo T_("Start REC"); ?></a></div>
<? if (HEADER_EXPANDER_MANUAL){ ?> <div class='headerexpand'><img id='headerexpandimage' src='./images/arrow-up-2.png' alt='<? echo T_('Arrow for expanding or contracting'); ?>'/></div> <? } ?>
<div class='box'><a href='index.php?'><? echo T_("Restart"); ?></a></div>
</div>
<div id="content" class="content">
@@ -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");
</div>
<? }?>
<? if ($availability) { ?>
<div class="tabbertab <? if ((DEFAULT_TAB == 'availability' && !$appointment) || (DEFAULT_TAB_APPOINTMENT == 'availability' && $appointment))
print "tabbertabdefault"; ?>">
<h2><? echo T_("Availability"); ?></h2>
<div id="div-casenotes" class="tabberdiv"><?xhtml_object("availability.php","main-casenotes");?></div>
</div>
<? }?>
<? if (TAB_CONTACTDETAILS) { ?>
<div class="tabbertab <? if ((DEFAULT_TAB == 'contactdetails' && !$appointment) || (DEFAULT_TAB_APPOINTMENT == 'contactdetails' && $appointment))
print "tabbertabdefault"; ?>">