mirror of
https://github.com/ACSPRI/queXS
synced 2024-04-02 12:12:16 +00:00
Updated to trunk
This commit is contained in:
@@ -69,10 +69,11 @@ if (isset($_GET['questionnaire_id']) && isset($_GET['sample']) && isset($_GET['
|
||||
$am = bigintval($_GET['answering_machine_messages']);
|
||||
$selecttype = 0;
|
||||
if (isset($_GET['selecttype'])) $selecttype = 1;
|
||||
$an = 0;
|
||||
if (isset($_GET['allownew'])) $an = 1;
|
||||
|
||||
|
||||
$sql = "INSERT INTO questionnaire_sample(questionnaire_id,sample_import_id,call_max,call_attempt_max,random_select,answering_machine_messages)
|
||||
VALUES('$questionnaire_id','$sid','$cm','$cam','$selecttype','$am')";
|
||||
$sql = "INSERT INTO questionnaire_sample(questionnaire_id,sample_import_id,call_max,call_attempt_max,random_select,answering_machine_messages,allow_new)
|
||||
VALUES('$questionnaire_id','$sid','$cm','$cam','$selecttype','$am', '$an')";
|
||||
|
||||
$db->Execute($sql);
|
||||
|
||||
@@ -89,13 +90,17 @@ if (isset($_POST['edit']))
|
||||
$am = bigintval($_POST['answering_machine_messages']);
|
||||
$selecttype = 0;
|
||||
if (isset($_POST['selecttype'])) $selecttype = 1;
|
||||
$an = 0;
|
||||
if (isset($_POST['allownew'])) $an = 1;
|
||||
|
||||
|
||||
|
||||
$sql = "UPDATE questionnaire_sample
|
||||
SET call_max = '$cm',
|
||||
call_attempt_max = '$cam',
|
||||
random_select = '$selecttype',
|
||||
answering_machine_messages = '$am'
|
||||
answering_machine_messages = '$am',
|
||||
allow_new = '$an'
|
||||
WHERE questionnaire_id = '$questionnaire_id'
|
||||
AND sample_import_id = '$sid'";
|
||||
|
||||
@@ -119,7 +124,8 @@ if (isset($_GET['questionnaire_id']) && isset($_GET['rsid']))
|
||||
q.call_max,
|
||||
q.call_attempt_max,
|
||||
q.random_select,
|
||||
q.answering_machine_messages
|
||||
q.answering_machine_messages,
|
||||
q.allow_new
|
||||
FROM questionnaire_sample as q, sample_import as si, questionnaire as qr
|
||||
WHERE q.sample_import_id = si.sample_import_id
|
||||
AND q.questionnaire_id = '$questionnaire_id'
|
||||
@@ -134,9 +140,11 @@ if (isset($_GET['questionnaire_id']) && isset($_GET['rsid']))
|
||||
|
||||
print "<p><a href='?questionnaire_id=$questionnaire_id'>" . T_("Go back") . "</a></p>";
|
||||
|
||||
$selected ="";
|
||||
$allownew = $selected ="";
|
||||
if ($qs['random_select'] == 1)
|
||||
$selected = "checked=\"checked\"";
|
||||
if ($qs['allow_new'] == 1)
|
||||
$allownew = "checked=\"checked\"";
|
||||
|
||||
?>
|
||||
<form action="?questionnaire_id=<?php echo $questionnaire_id;?>" method="post">
|
||||
@@ -144,6 +152,7 @@ if (isset($_GET['questionnaire_id']) && isset($_GET['rsid']))
|
||||
<label for="call_attempt_max"><?php echo T_("Max call attempts (0 for unlimited)"); ?></label><input type="text" name="call_attempt_max" id="call_attempt_max" value="<?php echo $qs['call_attempt_max'];?>"/> <br/>
|
||||
<label for="answering_machine_messages"><?php echo T_("Number of answering machine messages to leave per case (0 for never)"); ?></label><input type="text" name="answering_machine_messages" id="answering_machine_messages" value="<?php echo $qs['answering_machine_messages'];?>"/> <br/>
|
||||
<label for="selecttype"><?php echo T_("Select from sample randomly? (otherwise sequentially)"); ?></label><input type="checkbox" id = "selecttype" name="selecttype" <?php echo $selected;?> /> <br/>
|
||||
<label for="allownew"><?php echo T_("Allow new numbers to be drawn?"); ?></label><input type="checkbox" id = "allownew" name="allownew" <?php echo $allownew;?> /> <br/>
|
||||
<input type="hidden" name="questionnaire_id" value="<?php print($questionnaire_id); ?>"/>
|
||||
<input type="hidden" name="sample_import_id" value="<?php print($sid); ?>"/>
|
||||
<input type="submit" name="edit" value="<?php echo T_("Edit"); ?>"/></p>
|
||||
@@ -181,6 +190,7 @@ if ($questionnaire_id != false)
|
||||
CASE WHEN q.call_attempt_max = 0 THEN '" . TQ_("Unlimited") . "' ELSE q.call_attempt_max END AS call_attempt_max,
|
||||
CASE WHEN q.random_select = 0 THEN '" . TQ_("Sequential") . "' ELSE '". TQ_("Random") . "' END as random_select,
|
||||
CASE WHEN q.answering_machine_messages = 0 THEN '" . TQ_("Never") . "' ELSE q.answering_machine_messages END as answering_machine_messages,
|
||||
CASE WHEN q.allow_new = 0 THEN '" . TQ_("No") . "' ELSE '".TQ_("Yes")."' END as allow_new,
|
||||
CONCAT('<a href=\"?edit=edit&questionnaire_id=$questionnaire_id&rsid=', si.sample_import_id ,'\">" . TQ_("Edit") ."</a>') as edit,
|
||||
CONCAT('<a href=\"?questionnaire_id=$questionnaire_id&rsid=', si.sample_import_id ,'\">" . TQ_("Click to unassign") ."</a>') as unassign
|
||||
FROM questionnaire_sample as q, sample_import as si
|
||||
@@ -190,7 +200,7 @@ if ($questionnaire_id != false)
|
||||
$qs = $db->GetAll($sql);
|
||||
|
||||
if (!empty($qs))
|
||||
xhtml_table($qs,array("description","call_max","call_attempt_max","answering_machine_messages","random_select","edit","unassign"),array(T_("Sample"), T_("Max calls"), T_("Max call attempts"), T_("Answering machine messages"), T_("Selection type"), T_("Edit"), T_("Unassign sample") ));
|
||||
xhtml_table($qs,array("description","call_max","call_attempt_max","answering_machine_messages","random_select","allow_new","edit","unassign"),array(T_("Sample"), T_("Max calls"), T_("Max call attempts"), T_("Answering machine messages"), T_("Selection type"), T_("Allow new numbers to be drawn?"), T_("Edit"), T_("Unassign sample") ));
|
||||
else
|
||||
print "<p>" . T_("No samples selected for this questionnaire") . "</p>";
|
||||
|
||||
@@ -223,6 +233,7 @@ if ($questionnaire_id != false)
|
||||
<label for="call_attempt_max"><?php echo T_("Max call attempts (0 for unlimited)"); ?></label><input type="text" name="call_attempt_max" id="call_attempt_max" value="0"/> <br/>
|
||||
<label for="answering_machine_messages"><?php echo T_("Number of answering machine messages to leave per case (0 for never)"); ?></label><input type="text" name="answering_machine_messages" id="answering_machine_messages" value="1"/> <br/>
|
||||
<label for="selecttype"><?php echo T_("Select from sample randomly? (otherwise sequentially)"); ?></label><input type="checkbox" id = "selecttype" name="selecttype" /> <br/>
|
||||
<label for="allownew"><?php echo T_("Allow new numbers to be drawn?"); ?></label><input type="checkbox" id = "allownew" name="allownew" checked="checked" /> <br/>
|
||||
<input type="hidden" name="questionnaire_id" value="<?php print($questionnaire_id); ?>"/>
|
||||
<input type="submit" name="add_sample" value="<?php echo T_("Add sample");?>"/></p>
|
||||
</form>
|
||||
|
||||
@@ -54,7 +54,7 @@ if (isset($_GET['availability_group']))
|
||||
else if (isset($_POST['availability_group']))
|
||||
$availability_group = intval($_POST['availability_group']);
|
||||
else
|
||||
die(T_("No availability group set"));
|
||||
die(T_("No time slot group set"));
|
||||
|
||||
|
||||
if (isset($_POST['day']))
|
||||
@@ -92,7 +92,7 @@ if (isset($_POST['day']))
|
||||
$db->CompleteTrans();
|
||||
}
|
||||
|
||||
xhtml_head(T_("Modify availability"),true,array("../css/shifts.css"),array("../js/addrow-v2.js"));
|
||||
xhtml_head(T_("Modify time slots"),true,array("../css/shifts.css"),array("../js/addrow-v2.js"));
|
||||
|
||||
/**
|
||||
* Display warning if timezone data not installed
|
||||
@@ -158,12 +158,12 @@ translate_array($daysofweek,array("description"));
|
||||
?>
|
||||
</table>
|
||||
<p><a onclick="addRow(); return false;" href="#"><?php echo T_("Add row"); ?></a></p>
|
||||
<p><label for="description"><?php echo T_("Availability group name"); ?>: </label><input type="text" name="description" id="description" value="<?php echo $description;?>"/></p>
|
||||
<p><input type="submit" name="submit" value="<?php echo T_("Save changes to availabilities"); ?>"/></p>
|
||||
<p><label for="description"><?php echo T_("Time slot group name"); ?>: </label><input type="text" name="description" id="description" value="<?php echo $description;?>"/></p>
|
||||
<p><input type="submit" name="submit" value="<?php echo T_("Save changes to time slot group"); ?>"/></p>
|
||||
<input type="hidden" name="availability_group" value="<?php echo $availability_group;?>"/>
|
||||
</form>
|
||||
<form method="post" action="availabilitygroup.php">
|
||||
<p><input type="submit" name="subdel" value="<?php echo T_("Delete this availability group"); ?>"/></p>
|
||||
<p><input type="submit" name="subdel" value="<?php echo T_("Delete this time slot group"); ?>"/></p>
|
||||
<input type="hidden" name="availability_group" value="<?php echo $availability_group;?>"/>
|
||||
</form>
|
||||
<?php
|
||||
|
||||
@@ -67,7 +67,7 @@ include("../functions/functions.input.php");
|
||||
|
||||
global $db;
|
||||
|
||||
xhtml_head(T_("Availability groups"),true,array("../css/table.css"),array("../js/window.js"));
|
||||
xhtml_head(T_("Time slots"),true,array("../css/table.css"),array("../js/window.js"));
|
||||
|
||||
if (isset($_POST['subdel']))
|
||||
{
|
||||
@@ -109,22 +109,22 @@ $sql = "SELECT description,
|
||||
|
||||
$rs = $db->GetAll($sql);
|
||||
|
||||
print "<h3>" . T_("Availability groups")."</h3>";
|
||||
print "<h3>" . T_("Time slots")."</h3>";
|
||||
|
||||
print "<p>" . T_("Availability groups define periods of time of respondent availability.") . "</p>";
|
||||
print "<p>" . T_("Time slots define periods of time during particular days of the week. These are used for the availability function and also the call attempt time slot function.") . "</p>";
|
||||
|
||||
if (empty($rs))
|
||||
print "<p>" . T_("No availability groups") . "</p>";
|
||||
print "<p>" . T_("No time slots") . "</p>";
|
||||
else
|
||||
xhtml_table($rs,array("description","link"),array(T_("Availablity group"),T_("Modify")));
|
||||
xhtml_table($rs,array("description","link"),array(T_("Time slot"),T_("Modify")));
|
||||
|
||||
|
||||
//add an availablity group
|
||||
print "<h3>" . T_("Add availability group") . "</h3>";
|
||||
print "<h3>" . T_("Add time slot") . "</h3>";
|
||||
?>
|
||||
<form method="post" action="?">
|
||||
<p><label for="availability_group"><?php echo T_("Availability group name"); ?>: </label><input type="text" class="textclass" name="availability_group" id="availability_group"/></p>
|
||||
<p><input class="submitclass" type="submit" name="submit" value="<?php echo T_("Add availability group"); ?>"/>
|
||||
<p><label for="availability_group"><?php echo T_("Time slot name"); ?>: </label><input type="text" class="textclass" name="availability_group" id="availability_group"/></p>
|
||||
<p><input class="submitclass" type="submit" name="submit" value="<?php echo T_("Add time slot"); ?>"/>
|
||||
</p>
|
||||
</form>
|
||||
<?php
|
||||
|
||||
@@ -96,7 +96,8 @@ function case_status_report($questionnaire_id = false, $sample_id = false, $outc
|
||||
JOIN questionnaire as q ON (q.questionnaire_id = c.questionnaire_id and q.enabled = 1)
|
||||
JOIN outcome as o ON (o.outcome_id = c.current_outcome_id AND o.outcome_type_id = 1)
|
||||
JOIN sample as s ON (s.sample_id = c.sample_id $s)
|
||||
JOIN sample_import as si ON (s.import_id = si.sample_import_id)
|
||||
JOIN sample_import as si ON (s.import_id = si.sample_import_id AND si.enabled = 1)
|
||||
JOIN questionnaire_sample as qs ON (qs.questionnaire_id = q.questionnaire_id AND qs.sample_import_id = s.import_id)
|
||||
LEFT JOIN `call` as ca ON (ca.call_id = c.last_call_id)
|
||||
LEFT JOIN outcome as co ON (co.outcome_id = ca.outcome_id)
|
||||
LEFT JOIN case_queue as cq ON (cq.case_id = c.case_id)
|
||||
@@ -207,7 +208,7 @@ $outcome_id = false;
|
||||
print "<label for='questionnaire'>" . T_("Questionnaire") . ":</label>";
|
||||
display_questionnaire_chooser($questionnaire_id);
|
||||
print "<label for='sample'>" . T_("Sample") . ":</label>";
|
||||
display_sample_chooser($questionnaire_id,$sample_import_id);
|
||||
display_sample_chooser($questionnaire_id,$sample_import_id,false);
|
||||
|
||||
if ($questionnaire_id)
|
||||
case_status_report($questionnaire_id,$sample_import_id,$outcome_id);
|
||||
|
||||
@@ -53,6 +53,7 @@ include("../include/ckeditor/ckeditor.php");
|
||||
global $db;
|
||||
|
||||
$CKEditor = new CKEditor();
|
||||
$CKEditor->basePath = "../include/ckeditor/";
|
||||
|
||||
if (isset($_POST['information']))
|
||||
{
|
||||
|
||||
@@ -111,7 +111,7 @@ if ($a)
|
||||
<?php } ?>
|
||||
<p><?php echo T_("Enter the first name of a client to add:"); ?> <input name="firstname" type="text"/></p>
|
||||
<p><?php echo T_("Enter the surname of a client to add:"); ?> <input name="lastname" type="text"/></p>
|
||||
<p><a href='timezonetemplate.php'><?php echo T_("Enter the Time Zone of a client to add:"); echo "</a>"; display_chooser($rs,"Time_zone_name","Time_zone_name",false,false,false,false,array("value",DEFAULT_TIME_ZONE)); ?> </p>
|
||||
<p><a href='timezonetemplate.php'><?php echo T_("Enter the Time Zone of a client to add:"); echo "</a>"; display_chooser($rs,"Time_zone_name","Time_zone_name",false,false,false,false,array("value",get_setting("DEFAULT_TIME_ZONE"))); ?> </p>
|
||||
<p><input type="submit" value="<?php echo T_("Add user"); ?>" /></p>
|
||||
</form>
|
||||
|
||||
|
||||
@@ -70,8 +70,10 @@ print "<li><a href=\"?page=operatorquestionnaire.php\">" . T_("Assign operators
|
||||
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=availabilitygroup.php\">" . T_("Manage time slots") . "</a></li>";
|
||||
print "<li><a href=\"?page=questionnaireavailability.php\">" . T_("Assign availabilities to questionnaires") . "</a></li>";
|
||||
print "<li><a href=\"?page=questionnairecatimeslots.php\">" . T_("Assign call attempt time slots to questionnaire") . "</a></li>";
|
||||
print "<li><a href=\"?page=questionnairecatimeslotssample.php\">" . T_("Assign call attempt time slots to questionnaire sample") . "</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>";
|
||||
|
||||
@@ -158,8 +158,7 @@ else
|
||||
<?php
|
||||
$sql = "SELECT s.sid as sid, sl.surveyls_title AS title
|
||||
FROM " . LIME_PREFIX . "surveys AS s
|
||||
LEFT JOIN " . LIME_PREFIX . "surveys_languagesettings AS sl ON ( s.sid = sl.surveyls_survey_id
|
||||
AND sl.surveyls_language = 'en' )
|
||||
LEFT JOIN " . LIME_PREFIX . "surveys_languagesettings AS sl ON ( s.sid = sl.surveyls_survey_id)
|
||||
WHERE s.active = 'Y'";
|
||||
|
||||
$surveys = $db->GetAll($sql);
|
||||
@@ -173,6 +172,7 @@ if (!empty($surveys))
|
||||
}
|
||||
|
||||
$CKEditor = new CKEditor();
|
||||
$CKEditor->basePath = "../include/ckeditor/";
|
||||
|
||||
$ckeditorConfig = array("toolbar" => array(array("tokens","-","Source"),
|
||||
array("Cut","Copy","Paste","PasteText","PasteFromWord","-","Print","SpellChecker"),
|
||||
|
||||
@@ -255,9 +255,9 @@ if (isset($_GET['operator_id']))
|
||||
header("Pragma: public"); // HTTP/1.0
|
||||
|
||||
if (isset($_GET['winbat']))
|
||||
echo "voipclient.exe -i -u {$rs['ext']} -p {$rs['extension_password']} -h " . $_SERVER['SERVER_NAME'];
|
||||
echo "voipclient.exe -i -u {$rs['ext']} -p {$rs['password']} -h " . $_SERVER['SERVER_NAME'];
|
||||
else
|
||||
echo "./voipclient -i -u {$rs['ext']} -p {$rs['extension_password']} -h " . $_SERVER['SERVER_NAME'];
|
||||
echo "./voipclient -i -u {$rs['ext']} -p {$rs['password']} -h " . $_SERVER['SERVER_NAME'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ if (isset($_POST['operator']))
|
||||
if (FREEPBX_PATH !== false)
|
||||
{
|
||||
//add extension
|
||||
$sql = "INSERT INTO extension (`extension`,`extension_password`,`current_operator_id`)
|
||||
$sql = "INSERT INTO extension (`extension`,`password`,`current_operator_id`)
|
||||
VALUES ($extension, $extensionp, $oid)";
|
||||
|
||||
$db->Execute($sql);
|
||||
@@ -211,7 +211,7 @@ $ers = $db->GetAll($sql);
|
||||
<?php } ?>
|
||||
<p><?php echo T_("Enter the first name of an operator to add:"); ?> <input name="firstname" type="text"/></p>
|
||||
<p><?php echo T_("Enter the surname of an operator to add:"); ?> <input name="lastname" type="text"/></p>
|
||||
<p><a href='timezonetemplate.php'><?php echo T_("Enter the Time Zone of an operator to add:"); echo "</a>"; display_chooser($rs,"Time_zone_name","Time_zone_name",false,false,false,false,array("value",DEFAULT_TIME_ZONE)); ?> </p>
|
||||
<p><a href='timezonetemplate.php'><?php echo T_("Enter the Time Zone of an operator to add:"); echo "</a>"; display_chooser($rs,"Time_zone_name","Time_zone_name",false,false,false,false,array("value",get_setting("DEFAULT_TIME_ZONE"))); ?> </p>
|
||||
<?php if (FREEPBX_PATH == false) { ?>
|
||||
<p><a href='extensionstatus.php'><?php echo T_("Select an extension for this operator:"); echo "</a>"; display_chooser($ers,"extension_id","extension_id",true,false,false,false); ?> </p>
|
||||
<?php } ?>
|
||||
|
||||
@@ -91,7 +91,10 @@ $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>";
|
||||
|
||||
print "<p>" . T_("Assigning an availability group to a questionnaire will allow interviewers to select from those groups to restrict calls to a particular case to the times within the group") ."</p>";
|
||||
|
||||
print "<h3>" . T_("Select a questionnaire from the list below") . "</h3>";
|
||||
display_questionnaire_chooser($questionnaire_id);
|
||||
|
||||
|
||||
@@ -143,7 +146,7 @@ if ($questionnaire_id != false)
|
||||
?>
|
||||
</select><br/>
|
||||
<input type="hidden" name="questionnaire_id" value="<?php print($questionnaire_id); ?>"/>
|
||||
<input type="submit" name="add_availability" value="Add availability group"/></p>
|
||||
<input type="submit" name="add_availability" value="<?php echo TQ_("Add availability group") ?>"/></p>
|
||||
</form>
|
||||
<?php
|
||||
}
|
||||
|
||||
157
admin/questionnairecatimeslots.php
Normal file
157
admin/questionnairecatimeslots.php
Normal file
@@ -0,0 +1,157 @@
|
||||
<?php
|
||||
/**
|
||||
* Assign call attempt time slots 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_timeslot(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_timeslot
|
||||
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 call attempt time slots to questionnaire"),true,false,array("../js/window.js"));
|
||||
|
||||
print "<p>" . T_("Assigning call attempt time slots to questionnaires will only allow cases to be attempted in a time slot for the n + 1th time where it has been attempted at least n times in all assigned timeslots. Please note timeslots must cover all possible time periods otherwise no cases will be available during missing timeslots.") ."</p>";
|
||||
|
||||
print "<h3>" . T_("Select a questionnaire from the list below") . "</h3>";
|
||||
display_questionnaire_chooser($questionnaire_id);
|
||||
|
||||
|
||||
if ($questionnaire_id != false)
|
||||
{
|
||||
|
||||
$sql = "SELECT q.availability_group_id,a.description as description
|
||||
FROM questionnaire_timeslot 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 call attempt time slots selected for this questionnaire") . "</h2>";
|
||||
}
|
||||
else
|
||||
{
|
||||
print "<h2>" . T_("Call attempt time slots selected for this questionnaire") . "</h2>";
|
||||
foreach($qs as $q)
|
||||
{
|
||||
print "<p><a href=\"?questionnaire_id=$questionnaire_id&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_timeslot 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 a call attempt time slot to this questionnaire:") . "</h2>";
|
||||
?>
|
||||
<form action="" method="get">
|
||||
<p><label for="availability_group"><?php echo T_("Select call attempt time slot:"); ?></label><select name="availability_group" id="availability_group">
|
||||
<?php
|
||||
|
||||
foreach($qs as $q)
|
||||
{
|
||||
print "<option value=\"{$q['availability_group_id']}\">{$q['description']}</option>";
|
||||
}
|
||||
|
||||
?>
|
||||
</select><br/>
|
||||
<input type="hidden" name="questionnaire_id" value="<?php print($questionnaire_id); ?>"/>
|
||||
<input type="submit" name="add_availability" value="<?php echo TQ_("Add call attempt time slot") ?>"/></p>
|
||||
</form>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
xhtml_foot();
|
||||
|
||||
|
||||
?>
|
||||
172
admin/questionnairecatimeslotssample.php
Normal file
172
admin/questionnairecatimeslotssample.php
Normal file
@@ -0,0 +1,172 @@
|
||||
<?php
|
||||
/**
|
||||
* Assign call attempt time slots to a questionnaire sample
|
||||
*
|
||||
*
|
||||
* 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['sample_import_id']) && isset($_GET['availability_group']))
|
||||
{
|
||||
//need to add availability_group to questionnaire
|
||||
|
||||
$questionnaire_id = bigintval($_GET['questionnaire_id']);
|
||||
$sample_import_id = bigintval($_GET['sample_import_id']);
|
||||
$availability_group = bigintval($_GET['availability_group']);
|
||||
|
||||
$sql = "INSERT INTO questionnaire_sample_timeslot (questionnaire_id,sample_import_id,availability_group_id)
|
||||
VALUES('$questionnaire_id','$sample_import_id','$availability_group')";
|
||||
|
||||
$db->Execute($sql);
|
||||
|
||||
}
|
||||
|
||||
if (isset($_GET['questionnaire_id']) && isset($_GET['sample_import_id']) && isset($_GET['ravailability_group']))
|
||||
{
|
||||
//need to remove rsid from questionnaire
|
||||
|
||||
$questionnaire_id = bigintval($_GET['questionnaire_id']);
|
||||
$sample_import_id = bigintval($_GET['sample_import_id']);
|
||||
$availability_group = bigintval($_GET['ravailability_group']);
|
||||
|
||||
$sql = "DELETE FROM questionnaire_sample_timeslot
|
||||
WHERE questionnaire_id = '$questionnaire_id'
|
||||
AND sample_import_id = '$sample_import_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 call attempt time slots to questionnaire sample"),true,false,array("../js/window.js"));
|
||||
|
||||
print "<p>" . T_("Assigning call attempt time slots to questionnaires will only allow cases to be attempted in a time slot for the n + 1th time where it has been attempted at least n times in all assigned timeslots. Please note timeslots must cover all possible time periods otherwise no cases will be available during missing timeslots.") ."</p>";
|
||||
|
||||
print "<h3>" . T_("Select a questionnaire from the list below") . "</h3>";
|
||||
display_questionnaire_chooser($questionnaire_id);
|
||||
|
||||
|
||||
if ($questionnaire_id != false)
|
||||
{
|
||||
print "<h3>" . T_("Select a sample from the list below") . "</h3>";
|
||||
|
||||
$sample_import_id = false;
|
||||
if (isset($_GET['sample_import_id'])) $sample_import_id = bigintval($_GET['sample_import_id']);
|
||||
display_sample_chooser($questionnaire_id,$sample_import_id);
|
||||
|
||||
if ($sample_import_id !== false)
|
||||
{
|
||||
|
||||
$sql = "SELECT q.availability_group_id,a.description as description
|
||||
FROM questionnaire_sample_timeslot as q, availability_group as a
|
||||
WHERE q.availability_group_id = a.availability_group_id
|
||||
AND q.questionnaire_id = '$questionnaire_id'
|
||||
AND q.sample_import_id = '$sample_import_id'";
|
||||
|
||||
$qs = $db->GetAll($sql);
|
||||
|
||||
if (empty($qs))
|
||||
{
|
||||
print "<h2>" . T_("There are no call attempt time slots selected for this questionnaire sample") . "</h2>";
|
||||
}
|
||||
else
|
||||
{
|
||||
print "<h2>" . T_("Call attempt time slots selected for this questionnaire sample") . "</h2>";
|
||||
foreach($qs as $q)
|
||||
{
|
||||
print "<p><a href=\"?sample_import_id=$sample_import_id&questionnaire_id=$questionnaire_id&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_sample_timeslot as q ON (q.sample_import_id = '$sample_import_id' AND 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 a call attempt time slot to this questionnaire sample:") . "</h2>";
|
||||
?>
|
||||
<form action="" method="get">
|
||||
<p><label for="availability_group"><?php echo T_("Select call attempt time slot:"); ?></label><select name="availability_group" id="availability_group">
|
||||
<?php
|
||||
|
||||
foreach($qs as $q)
|
||||
{
|
||||
print "<option value=\"{$q['availability_group_id']}\">{$q['description']}</option>";
|
||||
}
|
||||
|
||||
?>
|
||||
</select><br/>
|
||||
<input type="hidden" name="questionnaire_id" value="<?php print($questionnaire_id); ?>"/>
|
||||
<input type="hidden" name="sample_import_id" value="<?php print($sample_import_id); ?>"/>
|
||||
<input type="submit" name="add_availability" value="<?php echo TQ_("Add call attempt time slot") ?>"/></p>
|
||||
</form>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
}
|
||||
xhtml_foot();
|
||||
|
||||
|
||||
?>
|
||||
@@ -298,6 +298,7 @@ if (isset($_GET['modify']))
|
||||
$questionnaire_id = intval($_GET['modify']);
|
||||
|
||||
$CKEditor = new CKEditor();
|
||||
$CKEditor->basePath = "../include/ckeditor/";
|
||||
|
||||
$ckeditorConfig = array("toolbar" => array(array("tokens","-","Source"),
|
||||
array("Cut","Copy","Paste","PasteText","PasteFromWord","-","Print","SpellChecker"),
|
||||
|
||||
@@ -319,7 +319,30 @@ if ($case_id != false)
|
||||
translate_array($rs,array("des"));
|
||||
xhtml_table($rs,array("start","des","phone","link","firstName"),array(T_("Date/Time"),T_("Outcome"),T_("Phone number"),T_("Change outcome"),T_("Operator")));
|
||||
}
|
||||
|
||||
|
||||
//view timeslots
|
||||
$sql = "SELECT count(*)
|
||||
FROM questionnaire_timeslot as q, `case` as c
|
||||
WHERE c.case_id = $case_id
|
||||
AND c.questionnaire_id = q.questionnaire_id";
|
||||
|
||||
if ($db->GetOne($sql) >= 1)
|
||||
{
|
||||
print "<h3>" . T_("Call attempts by timeslot") . "</h3>";
|
||||
|
||||
$sql = "SELECT ag.description, (SELECT COUNT(*) FROM availability as a, `call_attempt` as ca WHERE ca.case_id = c.case_id AND a.availability_group_id = ag.availability_group_id
|
||||
AND (a.day_of_week = DAYOFWEEK(CONVERT_TZ(ca.start,'UTC',s.Time_zone_name))
|
||||
AND TIME(CONVERT_TZ(ca.start, 'UTC' , s.Time_zone_name)) >= a.start
|
||||
AND TIME(CONVERT_TZ(ca.start, 'UTC' , s.Time_zone_name)) <= a.end)) as cou
|
||||
FROM availability_group as ag, `case` as c, `questionnaire_timeslot` as qt, sample as s
|
||||
WHERE c.case_id = '$case_id'
|
||||
AND s.sample_id = c.sample_id
|
||||
AND qt.questionnaire_id = c.questionnaire_id AND ag.availability_group_id = qt.availability_group_id";
|
||||
|
||||
xhtml_table($db->GetAll($sql),array('description','cou'),array(T_("Time slot"),T_("Call attempts")));
|
||||
|
||||
}
|
||||
|
||||
//view notes
|
||||
$sql = "SELECT DATE_FORMAT(CONVERT_TZ(c.datetime,'UTC',op.Time_zone_name),'".DATE_TIME_FORMAT."') as time, op.firstName, op.lastName, c.note as note, CONCAT('<a href=\'?case_id=$case_id&case_note_id=', c.case_note_id, '\'>". TQ_("Delete") . "</a>') as link
|
||||
FROM `case_note` as c
|
||||
@@ -418,7 +441,6 @@ if ($case_id != false)
|
||||
}
|
||||
|
||||
|
||||
|
||||
//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>";
|
||||
?>
|
||||
|
||||
@@ -88,8 +88,11 @@ register_shutdown_function('disable_systemsort');
|
||||
//all output send to database instead of stdout
|
||||
ob_start('update_callback',2);
|
||||
|
||||
$closecasescounter = 0;
|
||||
|
||||
print T_("Sorting cases process starting");
|
||||
|
||||
$closecasesinterval = (24 * 60) / SYSTEM_SORT_MINUTES; //check for closed cases once every day
|
||||
$sleepinterval = 10; // in seconds so we can monitor if the process has been killed
|
||||
|
||||
while (!is_process_killed($process_id)) //check if process killed every $sleepinterval
|
||||
@@ -97,202 +100,232 @@ while (!is_process_killed($process_id)) //check if process killed every $sleepin
|
||||
//Make sure that the system knows we are system sorting
|
||||
set_setting('systemsort',true);
|
||||
|
||||
print T_("Sorting cases");
|
||||
if ($closecasescounter == 0 || $closecasescounter > $closecasesinterval)
|
||||
{
|
||||
$time_start = microtime(true);
|
||||
print T_("Checking for cases open for more than 24 hours");
|
||||
|
||||
$time_start = microtime(true);
|
||||
$closecasescounter = 0;
|
||||
$db->StartTrans();
|
||||
|
||||
$db->StartTrans();
|
||||
//find all call attempts without an end that started more than 24 hours ago
|
||||
|
||||
$sql = "SELECT case_id, call_attempt_id
|
||||
FROM `call_attempt`
|
||||
WHERE TIMESTAMPDIFF(HOUR, start, CONVERT_TZ(NOW(),'System','UTC')) > 24
|
||||
AND end IS NULL";
|
||||
|
||||
$rs = $db->GetAll($sql);
|
||||
|
||||
foreach ($rs as $r)
|
||||
{
|
||||
//refer to supervisor if case still assigned
|
||||
|
||||
$sql = "UPDATE `case`
|
||||
SET current_operator_id = NULL, current_outcome_id = 5
|
||||
WHERE case_id = '{$r['case_id']}'
|
||||
AND current_operator_id IS NOT NULL
|
||||
AND current_call_id IS NULL";
|
||||
|
||||
$db->Execute($sql);
|
||||
|
||||
//add note
|
||||
|
||||
//find all call attempts without an end that started more than 24 hours ago
|
||||
$sql = "INSERT INTO case_note (case_id,operator_id,note,`datetime`)
|
||||
VALUES ('{$r['case_id']}',1,'" . TQ_("System automatically closed case as not closed for more than 24 hours") ."', CONVERT_TZ(NOW(),'System','UTC'))";
|
||||
|
||||
$sql = "SELECT case_id, call_attempt_id
|
||||
FROM `call_attempt`
|
||||
WHERE TIMESTAMPDIFF(HOUR, start, CONVERT_TZ(NOW(),'System','UTC')) > 24
|
||||
AND end IS NULL";
|
||||
|
||||
$rs = $db->GetAll($sql);
|
||||
|
||||
foreach ($rs as $r)
|
||||
{
|
||||
//refer to supervisor if case still assigned
|
||||
|
||||
$sql = "UPDATE `case`
|
||||
SET current_operator_id = NULL, current_outcome_id = 5
|
||||
WHERE case_id = '{$r['case_id']}'
|
||||
AND current_operator_id IS NOT NULL
|
||||
AND current_call_id IS NULL";
|
||||
$db->Execute($sql);
|
||||
|
||||
//finish the call attempt
|
||||
|
||||
$sql = "UPDATE `call_attempt`
|
||||
SET end = start
|
||||
WHERE call_attempt_id = '{$r['call_attempt_id']}'";
|
||||
|
||||
$db->Execute($sql);
|
||||
$db->Execute($sql);
|
||||
|
||||
//add note
|
||||
print T_("System automatically closed case as not closed for more than 24 hours") . " - " . T_("Case id") . ": {$r['case_id']}";
|
||||
}
|
||||
|
||||
//find all calls without an end that started more than 24 hours ago
|
||||
|
||||
$sql = "SELECT case_id, call_id
|
||||
FROM `call`
|
||||
WHERE TIMESTAMPDIFF(HOUR, start, CONVERT_TZ(NOW(),'System','UTC')) > 24
|
||||
AND end IS NULL";
|
||||
|
||||
$rs = $db->GetAll($sql);
|
||||
|
||||
foreach ($rs as $r)
|
||||
{
|
||||
//refer to supervisor if case still assigned
|
||||
|
||||
$sql = "UPDATE `case`
|
||||
SET current_operator_id = NULL, current_outcome_id = 5, current_call_id = NULL
|
||||
WHERE case_id = '{$r['case_id']}'
|
||||
AND current_operator_id IS NOT NULL";
|
||||
|
||||
$sql = "INSERT INTO case_note (case_id,operator_id,note,`datetime`)
|
||||
VALUES ('{$r['case_id']}',1,'" . TQ_("System automatically closed case as not closed for more than 24 hours") ."', CONVERT_TZ(NOW(),'System','UTC'))";
|
||||
$db->Execute($sql);
|
||||
|
||||
$db->Execute($sql);
|
||||
|
||||
//finish the call attempt
|
||||
|
||||
$sql = "UPDATE `call_attempt`
|
||||
SET end = start
|
||||
WHERE call_attempt_id = '{$r['call_attempt_id']}'";
|
||||
//add note
|
||||
|
||||
$sql = "INSERT INTO case_note (case_id,operator_id,note,`datetime`)
|
||||
VALUES ('{$r['case_id']}',1,'" . TQ_("System automatically closed case as not closed for more than 24 hours") ."', CONVERT_TZ(NOW(),'System','UTC'))";
|
||||
|
||||
$db->Execute($sql);
|
||||
$db->Execute($sql);
|
||||
|
||||
print T_("System automatically closed case as not closed for more than 24 hours") . " - " . T_("Case id") . ": {$r['case_id']}";
|
||||
}
|
||||
|
||||
//find all calls without an end that started more than 24 hours ago
|
||||
|
||||
$sql = "SELECT case_id, call_id
|
||||
FROM `call`
|
||||
WHERE TIMESTAMPDIFF(HOUR, start, CONVERT_TZ(NOW(),'System','UTC')) > 24
|
||||
AND end IS NULL";
|
||||
|
||||
$rs = $db->GetAll($sql);
|
||||
|
||||
foreach ($rs as $r)
|
||||
{
|
||||
//refer to supervisor if case still assigned
|
||||
|
||||
$sql = "UPDATE `case`
|
||||
SET current_operator_id = NULL, current_outcome_id = 5, current_call_id = NULL
|
||||
WHERE case_id = '{$r['case_id']}'
|
||||
AND current_operator_id IS NOT NULL";
|
||||
//finish the call
|
||||
|
||||
$sql = "UPDATE `call`
|
||||
SET end = start, outcome_id = 5, state = 5
|
||||
WHERE call_id = '{$r['call_id']}'";
|
||||
|
||||
$db->Execute($sql);
|
||||
$db->Execute($sql);
|
||||
|
||||
//add note
|
||||
|
||||
$sql = "INSERT INTO case_note (case_id,operator_id,note,`datetime`)
|
||||
VALUES ('{$r['case_id']}',1,'" . TQ_("System automatically closed case as not closed for more than 24 hours") ."', CONVERT_TZ(NOW(),'System','UTC'))";
|
||||
print T_("System automatically closed case as not closed for more than 24 hours") . " - " . T_("Case id") . ": {$r['case_id']}";
|
||||
}
|
||||
|
||||
$db->Execute($sql);
|
||||
$result = $db->CompleteTrans();
|
||||
|
||||
$time_end = microtime(true);
|
||||
$timer = $time_end - $time_start;
|
||||
|
||||
//finish the call
|
||||
|
||||
$sql = "UPDATE `call`
|
||||
SET end = start, outcome_id = 5, state = 5
|
||||
WHERE call_id = '{$r['call_id']}'";
|
||||
if ($result)
|
||||
print T_("Completed case closing") . ". " . T_("This task took") . ": $timer " . T_("seconds");
|
||||
else
|
||||
print T_("Failed to complete case closing") . ". " . T_("This task took") . ": $timer " . T_("seconds");
|
||||
}
|
||||
|
||||
$db->Execute($sql);
|
||||
|
||||
print T_("System automatically closed case as not closed for more than 24 hours") . " - " . T_("Case id") . ": {$r['case_id']}";
|
||||
}
|
||||
|
||||
|
||||
//Set all cases as unavailable
|
||||
$sql = "UPDATE `case`
|
||||
SET sortorder = NULL
|
||||
WHERE 1";
|
||||
$closecasescounter++;
|
||||
|
||||
$db->Execute($sql);
|
||||
|
||||
|
||||
//Update quotas for all enabled questionnaires
|
||||
$sql = "SELECT questionnaire_id
|
||||
//Sort cases on a questionnaire by questionnaire basis
|
||||
$sql = "SELECT questionnaire_id, description
|
||||
FROM questionnaire
|
||||
WHERE enabled = 1";
|
||||
|
||||
$qs = $db->GetAll($sql);
|
||||
|
||||
foreach($qs as $q)
|
||||
update_quotas($q['questionnaire_id']);
|
||||
{
|
||||
print T_("Sorting cases for ") . $q['description'];
|
||||
|
||||
$questionnaire_id = $q['questionnaire_id'];
|
||||
|
||||
$time_start = microtime(true);
|
||||
|
||||
$db->StartTrans();
|
||||
|
||||
//Set all cases as unavailable
|
||||
$sql = "UPDATE `case`
|
||||
SET sortorder = NULL
|
||||
WHERE sortorder IS NOT NULL
|
||||
AND questionnaire_id = '$questionnaire_id'";
|
||||
|
||||
$db->Execute($sql);
|
||||
|
||||
|
||||
//update quotas
|
||||
update_quotas($questionnaire_id);
|
||||
|
||||
|
||||
//Sort current cases for all enabled questionnaires
|
||||
//Sort current cases for this questionnaire
|
||||
|
||||
|
||||
$sql = "SELECT c.case_id
|
||||
FROM `case` as c
|
||||
LEFT JOIN `call` as a on (a.call_id = c.last_call_id)
|
||||
JOIN (sample as s, sample_import as si) on (s.sample_id = c.sample_id and si.sample_import_id = s.import_id)
|
||||
JOIN (questionnaire_sample as qs, questionnaire as q, outcome as ou) on (c.questionnaire_id = q.questionnaire_id and qs.sample_import_id = s.import_id and ou.outcome_id = c.current_outcome_id and q.enabled = 1 and qs.questionnaire_id = c.questionnaire_id)
|
||||
LEFT JOIN shift as sh on (sh.questionnaire_id = q.questionnaire_id and (CONVERT_TZ(NOW(),'System','UTC') >= sh.start) AND (CONVERT_TZ(NOW(),'System','UTC') <= sh.end))
|
||||
LEFT JOIN appointment as ap on (ap.case_id = c.case_id AND ap.completed_call_id is NULL AND (ap.start > CONVERT_TZ(NOW(),'System','UTC')))
|
||||
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)
|
||||
AND !(q.restrict_work_shifts = 1 AND sh.shift_id IS NULL)
|
||||
AND !(si.call_restrict = 1 AND cr.day_of_week IS NULL)
|
||||
AND ((apn.appointment_id IS NOT NULL) or qs.call_attempt_max = 0 or ((SELECT count(*) FROM call_attempt WHERE case_id = c.case_id) < qs.call_attempt_max))
|
||||
AND ((apn.appointment_id IS NOT NULL) or qs.call_max = 0 or ((SELECT count(*) FROM `call` WHERE case_id = c.case_id) < qs.call_max))
|
||||
AND (SELECT count(*) FROM `questionnaire_sample_quota` WHERE questionnaire_id = c.questionnaire_id AND sample_import_id = s.import_id AND quota_reached = 1) = 0
|
||||
GROUP BY c.case_id
|
||||
ORDER BY IF(ISNULL(apn.end),1,0),apn.end ASC, a.start ASC, qsep.priority DESC";
|
||||
|
||||
$rs = $db->GetAll($sql);
|
||||
$sql = "SELECT c.case_id
|
||||
FROM `case` as c
|
||||
LEFT JOIN `call` as a on (a.call_id = c.last_call_id)
|
||||
JOIN (sample as s, sample_import as si) on (s.sample_id = c.sample_id and si.sample_import_id = s.import_id)
|
||||
JOIN (questionnaire_sample as qs, questionnaire as q, outcome as ou) on (c.questionnaire_id = q.questionnaire_id and qs.sample_import_id = s.import_id and ou.outcome_id = c.current_outcome_id and q.questionnaire_id = '$questionnaire_id' and qs.questionnaire_id = c.questionnaire_id)
|
||||
LEFT JOIN shift as sh on (sh.questionnaire_id = q.questionnaire_id and (CONVERT_TZ(NOW(),'System','UTC') >= sh.start) AND (CONVERT_TZ(NOW(),'System','UTC') <= sh.end))
|
||||
LEFT JOIN appointment as ap on (ap.case_id = c.case_id AND ap.completed_call_id is NULL AND (ap.start > CONVERT_TZ(NOW(),'System','UTC')))
|
||||
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)
|
||||
LEFT JOIN questionnaire_timeslot AS qast ON (qast.questionnaire_id = c.questionnaire_id)
|
||||
LEFT JOIN questionnaire_sample_timeslot AS qasts ON (qasts.questionnaire_id = c.questionnaire_id AND qasts.sample_import_id = si.sample_import_id)
|
||||
WHERE c.current_operator_id IS NULL
|
||||
AND c.questionnaire_id = '$questionnaire_id'
|
||||
AND ((apn.appointment_id IS NOT NULL) OR 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 ((apn.appointment_id IS NOT NULL) OR qast.questionnaire_id IS NULL OR ((SELECT COUNT(*) FROM availability WHERE availability.availability_group_id = qast.availability_group_id AND (availability.day_of_week = DAYOFWEEK(CONVERT_TZ(NOW(),'System',s.Time_zone_name)) AND TIME(CONVERT_TZ(NOW(), 'System' , s.Time_zone_name)) >= availability.start AND TIME(CONVERT_TZ(NOW(), 'System' , s.Time_zone_name)) <= availability.end)) >= 1 AND (SELECT COUNT(call_attempt_id) FROM `call_attempt`, availability WHERE call_attempt.case_id = c.case_id AND (availability.availability_group_id = qast.availability_group_id AND (availability.day_of_week = DAYOFWEEK(CONVERT_TZ(call_attempt.start,'UTC',s.Time_zone_name)) AND TIME(CONVERT_TZ(call_attempt.start, 'UTC' , s.Time_zone_name)) >= availability.start AND TIME(CONVERT_TZ(call_attempt.start, 'UTC' , s.Time_zone_name)) <= availability.end))) = ( SELECT (SELECT COUNT(*) FROM availability, call_attempt WHERE call_attempt.case_id = c.case_id AND availability.availability_group_id = availability_group.availability_group_id AND (availability.day_of_week = DAYOFWEEK(CONVERT_TZ(call_attempt.start,'UTC',s.Time_zone_name)) AND TIME(CONVERT_TZ(call_attempt.start, 'UTC' , s.Time_zone_name)) >= availability.start AND TIME(CONVERT_TZ(call_attempt.start, 'UTC' , s.Time_zone_name)) <= availability.end)) as cou FROM availability_group, questionnaire_timeslot WHERE questionnaire_timeslot.questionnaire_id = c.questionnaire_id AND availability_group.availability_group_id = questionnaire_timeslot.availability_group_id ORDER BY cou ASC LIMIT 1)))
|
||||
AND ((apn.appointment_id IS NOT NULL) OR qasts.questionnaire_id IS NULL OR ((SELECT COUNT(*) FROM availability WHERE availability.availability_group_id = qasts.availability_group_id AND (availability.day_of_week = DAYOFWEEK(CONVERT_TZ(NOW(),'System',s.Time_zone_name)) AND TIME(CONVERT_TZ(NOW(), 'System' , s.Time_zone_name)) >= availability.start AND TIME(CONVERT_TZ(NOW(), 'System' , s.Time_zone_name)) <= availability.end)) >= 1 AND (SELECT COUNT(call_attempt_id) FROM `call_attempt`, availability WHERE call_attempt.case_id = c.case_id AND (availability.availability_group_id = qasts.availability_group_id AND (availability.day_of_week = DAYOFWEEK(CONVERT_TZ(call_attempt.start,'UTC',s.Time_zone_name)) AND TIME(CONVERT_TZ(call_attempt.start, 'UTC' , s.Time_zone_name)) >= availability.start AND TIME(CONVERT_TZ(call_attempt.start, 'UTC' , s.Time_zone_name)) <= availability.end))) = ( SELECT (SELECT COUNT(*) FROM availability, call_attempt WHERE call_attempt.case_id = c.case_id AND availability.availability_group_id = availability_group.availability_group_id AND (availability.day_of_week = DAYOFWEEK(CONVERT_TZ(call_attempt.start,'UTC',s.Time_zone_name)) AND TIME(CONVERT_TZ(call_attempt.start, 'UTC' , s.Time_zone_name)) >= availability.start AND TIME(CONVERT_TZ(call_attempt.start, 'UTC' , s.Time_zone_name)) <= availability.end)) as cou FROM availability_group, questionnaire_sample_timeslot WHERE questionnaire_sample_timeslot.questionnaire_id = c.questionnaire_id AND questionnaire_sample_timeslot.sample_import_id = si.sample_import_id AND availability_group.availability_group_id = questionnaire_sample_timeslot.availability_group_id ORDER BY cou ASC LIMIT 1)))
|
||||
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)
|
||||
AND !(q.restrict_work_shifts = 1 AND sh.shift_id IS NULL)
|
||||
AND !(si.call_restrict = 1 AND cr.day_of_week IS NULL)
|
||||
AND ((apn.appointment_id IS NOT NULL) or qs.call_attempt_max = 0 or ((SELECT count(*) FROM call_attempt WHERE case_id = c.case_id) < qs.call_attempt_max))
|
||||
AND ((apn.appointment_id IS NOT NULL) or qs.call_max = 0 or ((SELECT count(*) FROM `call` WHERE case_id = c.case_id) < qs.call_max))
|
||||
AND (SELECT count(*) FROM `questionnaire_sample_quota` WHERE questionnaire_id = c.questionnaire_id AND sample_import_id = s.import_id AND quota_reached = 1) = 0
|
||||
GROUP BY c.case_id
|
||||
ORDER BY IF(ISNULL(apn.end),1,0),apn.end ASC, qsep.priority DESC, a.start ASC";
|
||||
|
||||
$rs = $db->GetAll($sql);
|
||||
|
||||
$i = 1;
|
||||
foreach ($rs as $r)
|
||||
{
|
||||
$sql = "UPDATE `case`
|
||||
SET sortorder = '$i'
|
||||
WHERE case_id = '{$r['case_id']}'";
|
||||
|
||||
$db->Execute($sql);
|
||||
$i++;
|
||||
}
|
||||
$i = 1;
|
||||
foreach ($rs as $r)
|
||||
{
|
||||
$sql = "UPDATE `case`
|
||||
SET sortorder = '$i'
|
||||
WHERE case_id = '{$r['case_id']}'";
|
||||
|
||||
$db->Execute($sql);
|
||||
$i++;
|
||||
}
|
||||
|
||||
|
||||
//First set all sample records as unavailable
|
||||
$sql = "UPDATE `questionnaire_sample_exclude_priority`
|
||||
SET sortorder = NULL
|
||||
WHERE 1";
|
||||
//First set all sample records as unavailable
|
||||
$sql = "UPDATE `questionnaire_sample_exclude_priority`
|
||||
SET sortorder = NULL
|
||||
WHERE sortorder IS NOT NULL
|
||||
AND questionnaire_id = '$questionnaire_id'";
|
||||
|
||||
$db->Execute($sql);
|
||||
$db->Execute($sql);
|
||||
|
||||
|
||||
//Sort sample list where attached to this questionnaire
|
||||
|
||||
//Sort sample list where attached to an enabled questionnaire
|
||||
$sql = "SELECT s.sample_id as sample_id,qs.questionnaire_id as questionnaire_id
|
||||
FROM sample as s
|
||||
JOIN (questionnaire_sample as qs, questionnaire as q, sample_import as si) on (qs.sample_import_id = s.import_id and si.sample_import_id = s.import_id and q.questionnaire_id = qs.questionnaire_id AND q.questionnaire_id = '$questionnaire_id' AND qs.allow_new = 1)
|
||||
LEFT JOIN `case` as c on (c.sample_id = s.sample_id and c.questionnaire_id = qs.questionnaire_id)
|
||||
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 shift as sh on (sh.questionnaire_id = q.questionnaire_id and (CONVERT_TZ(NOW(),'System','UTC') >= sh.start) AND (CONVERT_TZ(NOW(),'System','UTC') <= sh.end))
|
||||
LEFT JOIN questionnaire_sample_exclude_priority AS qsep ON (qsep.questionnaire_id = qs.questionnaire_id AND qsep.sample_id = s.sample_id)
|
||||
WHERE c.case_id is NULL
|
||||
AND ((qsep.questionnaire_id IS NULL) or qsep.exclude = 0)
|
||||
AND !(q.restrict_work_shifts = 1 AND sh.shift_id IS NULL)
|
||||
AND !(si.call_restrict = 1 AND cr.day_of_week IS NULL)
|
||||
AND (SELECT count(*) FROM `questionnaire_sample_quota` WHERE questionnaire_id = qs.questionnaire_id AND sample_import_id = s.import_id AND quota_reached = 1) = 0
|
||||
GROUP BY s.sample_id,qs.questionnaire_id
|
||||
ORDER BY qsep.priority DESC, rand() * qs.random_select, s.sample_id";
|
||||
|
||||
$rs = $db->GetAll($sql);
|
||||
|
||||
$sql = "SELECT s.sample_id as sample_id,qs.questionnaire_id as questionnaire_id
|
||||
FROM sample as s
|
||||
JOIN (questionnaire_sample as qs, questionnaire as q, sample_import as si) on (qs.sample_import_id = s.import_id and si.sample_import_id = s.import_id and q.questionnaire_id = qs.questionnaire_id AND q.enabled = 1)
|
||||
LEFT JOIN `case` as c on (c.sample_id = s.sample_id and c.questionnaire_id = qs.questionnaire_id)
|
||||
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 shift as sh on (sh.questionnaire_id = q.questionnaire_id and (CONVERT_TZ(NOW(),'System','UTC') >= sh.start) AND (CONVERT_TZ(NOW(),'System','UTC') <= sh.end))
|
||||
LEFT JOIN questionnaire_sample_exclude_priority AS qsep ON (qsep.questionnaire_id = qs.questionnaire_id AND qsep.sample_id = s.sample_id)
|
||||
WHERE c.case_id is NULL
|
||||
AND ((qsep.questionnaire_id IS NULL) or qsep.exclude = 0)
|
||||
AND !(q.restrict_work_shifts = 1 AND sh.shift_id IS NULL)
|
||||
AND !(si.call_restrict = 1 AND cr.day_of_week IS NULL)
|
||||
AND (SELECT count(*) FROM `questionnaire_sample_quota` WHERE questionnaire_id = qs.questionnaire_id AND sample_import_id = s.import_id AND quota_reached = 1) = 0
|
||||
GROUP BY s.sample_id,qs.questionnaire_id
|
||||
ORDER BY qsep.priority DESC, rand() * qs.random_select, s.sample_id";
|
||||
|
||||
$rs = $db->GetAll($sql);
|
||||
$i = 1;
|
||||
foreach ($rs as $r)
|
||||
{
|
||||
$sql = "INSERT INTO questionnaire_sample_exclude_priority (questionnaire_id,sample_id,exclude,priority,sortorder)
|
||||
VALUES ('{$r['questionnaire_id']}', '{$r['sample_id']}', 0, 50,'$i')
|
||||
ON DUPLICATE KEY UPDATE sortorder = '$i'";
|
||||
|
||||
$i = 1;
|
||||
foreach ($rs as $r)
|
||||
{
|
||||
$sql = "INSERT INTO questionnaire_sample_exclude_priority (questionnaire_id,sample_id,exclude,priority,sortorder)
|
||||
VALUES ('{$r['questionnaire_id']}', '{$r['sample_id']}', 0, 50,'$i')
|
||||
ON DUPLICATE KEY UPDATE sortorder = '$i'";
|
||||
$db->Execute($sql);
|
||||
$i++;
|
||||
}
|
||||
|
||||
|
||||
$db->Execute($sql);
|
||||
$i++;
|
||||
}
|
||||
|
||||
|
||||
$result = $db->CompleteTrans();
|
||||
|
||||
$time_end = microtime(true);
|
||||
$timer = $time_end - $time_start;
|
||||
|
||||
|
||||
$result = $db->CompleteTrans();
|
||||
|
||||
$time_end = microtime(true);
|
||||
$timer = $time_end - $time_start;
|
||||
|
||||
if ($result)
|
||||
print T_("Completed sort") . ". " . T_("This task took") . ": $timer " . T_("seconds");
|
||||
else
|
||||
print T_("Failed to complete sort") . ". " . T_("This task took") . ": $timer " . T_("seconds");
|
||||
if ($result)
|
||||
print T_("Completed sort") . ". " . T_("This task took") . ": $timer " . T_("seconds");
|
||||
else
|
||||
print T_("Failed to complete sort") . ". " . T_("This task took") . ": $timer " . T_("seconds");
|
||||
}
|
||||
|
||||
for ($i = 0; $i < (SYSTEM_SORT_MINUTES * 60); $i += $sleepinterval)
|
||||
{
|
||||
|
||||
@@ -58,6 +58,11 @@ include("../functions/functions.input.php");
|
||||
global $db;
|
||||
|
||||
|
||||
if (isset($_POST['dtime_zone']))
|
||||
{
|
||||
set_setting('DEFAULT_TIME_ZONE', $_POST['dtime_zone']);
|
||||
}
|
||||
|
||||
if (isset($_GET['time_zone']))
|
||||
{
|
||||
//need to add sample to questionnaire
|
||||
@@ -86,8 +91,10 @@ if (isset($_GET['tz']))
|
||||
|
||||
xhtml_head(T_("Add/Remove Timezones"),true,array("../css/shifts.css"),array("../js/window.js"));
|
||||
|
||||
$dtz = get_setting("DEFAULT_TIME_ZONE");
|
||||
|
||||
$sql = "SELECT name as value, name as description,
|
||||
CASE WHEN name LIKE '" . DEFAULT_TIME_ZONE . "' THEN 'selected=\'selected\'' ELSE '' END AS selected
|
||||
CASE WHEN name LIKE '$dtz' THEN 'selected=\'selected\'' ELSE '' END AS selected
|
||||
FROM mysql.time_zone_name";
|
||||
|
||||
$tzl = $db->GetAll($sql);
|
||||
@@ -97,6 +104,13 @@ if (empty($tzl) || !$tzl)
|
||||
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 "<h1>" . T_("Set default timezone") . ": </h1>";
|
||||
?>
|
||||
<form action="" method="post"><p>
|
||||
<label for="dtime_zone"><?php echo T_("Default Timezone: "); ?></label><?php display_chooser($tzl, 'dtime_zone', 'dtime_zone', false, false, false, false, false); ?>
|
||||
<input type="submit" name="set_dtimezone" value="<?php echo T_("Set default timezone"); ?>"/></p>
|
||||
</form>
|
||||
<?php
|
||||
|
||||
print "<h1>" . T_("Click to remove a Timezone from the default list") . "</h1>";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user