mirror of
https://github.com/ACSPRI/queXS
synced 2024-04-02 12:12:16 +00:00
new casestatus.php
This commit is contained in:
@@ -1,219 +1,246 @@
|
|||||||
<?php /**
|
<?php /**
|
||||||
* Display a list of cases including status. Allow for assigning to operators in a queue
|
* Display a list of cases including status. Allow for assigning to operators in a queue
|
||||||
*
|
*/
|
||||||
* This file is part of queXS
|
|
||||||
*
|
/**
|
||||||
* queXS is free software; you can redistribute it and/or modify
|
* Configuration file
|
||||||
* it under the terms of the GNU General Public License as published by
|
*/
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
include_once(dirname(__FILE__).'/../config.inc.php');
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
/**
|
||||||
* queXS is distributed in the hope that it will be useful,
|
* Database file
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
*/
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
include ("../db.inc.php");
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
/**
|
||||||
* You should have received a copy of the GNU General Public License
|
* XHTML functions
|
||||||
* along with queXS; if not, write to the Free Software
|
*/
|
||||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
include ("../functions/functions.xhtml.php");
|
||||||
*
|
|
||||||
*
|
/**
|
||||||
* @author Adam Zammit <adam.zammit@acspri.org.au>
|
* Display functions
|
||||||
* @copyright Australian Consortium for Social and Political Research Incorporated (ACSPRI) 2013
|
*/
|
||||||
* @package queXS
|
include("../functions/functions.display.php");
|
||||||
* @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
|
* Input functions
|
||||||
*
|
*/
|
||||||
*/
|
include("../functions/functions.input.php");
|
||||||
|
|
||||||
/**
|
$css = array(
|
||||||
* Configuration file
|
"../include/bootstrap-3.3.2/css/bootstrap.min.css",
|
||||||
*/
|
"../include/bootstrap-3.3.2/css/bootstrap-theme.min.css",
|
||||||
include_once(dirname(__FILE__).'/../config.inc.php');
|
"../include/font-awesome-4.3.0/css/font-awesome.css",
|
||||||
|
"../include/bs-data-table/css/jquery.bdt.css",
|
||||||
/**
|
//"../include/iCheck/skins/square/blue.css",
|
||||||
* Database file
|
"../css/custom.css"
|
||||||
*/
|
);
|
||||||
include ("../db.inc.php");
|
$js_head = array(
|
||||||
|
"../js/jquery-2.1.3.min.js",
|
||||||
/**
|
"../include/bootstrap-3.3.2/js/bootstrap.min.js"
|
||||||
* XHTML functions
|
);
|
||||||
*/
|
$js_foot = array(
|
||||||
include ("../functions/functions.xhtml.php");
|
"../include/bs-data-table/js/vendor/jquery.sortelements.js",
|
||||||
|
"../include/bs-data-table/js/jquery.bdt.js",
|
||||||
/**
|
"../include/iCheck/icheck.min.js",
|
||||||
* Display functions
|
"../js/window.js",
|
||||||
*/
|
"../js/custom.js"
|
||||||
include("../functions/functions.display.php");
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Input functions
|
* Generate the case status report
|
||||||
*/
|
*
|
||||||
include("../functions/functions.input.php");
|
* @param mixed $questionnaire_id The quesitonnaire, if specified
|
||||||
|
* @param string $sample_id The sample, if speified
|
||||||
/**
|
* @param mixed $outcome_id THe outcome id, if specified
|
||||||
* Generate the case status report
|
*
|
||||||
*
|
* @return false if empty otherwise true if table drawn
|
||||||
* @param mixed $questionnaire_id The quesitonnaire, if specified
|
* @author Adam Zammit <adam.zammit@acspri.org.au>
|
||||||
* @param string $sample_id The sample, if speified
|
* @since 2012-10-02
|
||||||
* @param mixed $outcome_id THe outcome id, if specified
|
*/
|
||||||
*
|
|
||||||
* @return false if empty otherwise true if table drawn
|
|
||||||
* @author Adam Zammit <adam.zammit@acspri.org.au>
|
function case_status_report($questionnaire_id = false, $sample_id = false, $outcome_id = false)
|
||||||
* @since 2012-10-02
|
{
|
||||||
*/
|
global $db;
|
||||||
function case_status_report($questionnaire_id = false, $sample_id = false, $outcome_id = false)
|
|
||||||
{
|
$q = "";
|
||||||
global $db;
|
if ($questionnaire_id !== false)
|
||||||
|
$q = "AND c.questionnaire_id = $questionnaire_id";
|
||||||
$q = "";
|
|
||||||
if ($questionnaire_id !== false)
|
$s = "";
|
||||||
$q = "AND c.questionnaire_id = $questionnaire_id";
|
if ($sample_id !== false)
|
||||||
|
$s = "AND s.import_id = '$sample_id'";
|
||||||
$s = "";
|
|
||||||
if ($sample_id !== false)
|
$o = "";
|
||||||
$s = "AND s.import_id = '$sample_id'";
|
if ($outcome_id !== false)
|
||||||
|
$o = "AND c.current_outcome_id = $outcome_id";
|
||||||
$o = "";
|
|
||||||
if ($outcome_id !== false)
|
$sql = "SELECT CONCAT('<a href=\'supervisor.php?case_id=', c.case_id, '\'>', c.case_id, '</a>') as case_id,
|
||||||
$o = "AND c.current_outcome_id = $outcome_id";
|
o.description as outcomes,
|
||||||
|
si.description as samples, s.Time_zone_name as timezone, (SELECT COUNT(*) FROM `call` WHERE `call`.case_id = c.case_id) as nrcalls, (SELECT COUNT(*) FROM call_attempt WHERE call_attempt.case_id = c.case_id) as nrattempts,
|
||||||
|
CASE WHEN ca.end IS NULL THEN '" . TQ_("Available") . "'
|
||||||
|
WHEN TIME_TO_SEC(TIMEDIFF(ca.end,CONVERT_TZ(DATE_SUB(NOW(), INTERVAL co.default_delay_minutes MINUTE),'System','UTC'))) < 0 THEN '" . TQ_("Available") . "'
|
||||||
|
ELSE CONCAT(ROUND(TIME_TO_SEC(TIMEDIFF(ca.end,CONVERT_TZ(DATE_SUB(NOW(), INTERVAL co.default_delay_minutes MINUTE),'System','UTC'))) / 60),' " . TQ_("minutes") . "')
|
||||||
$sql = "SELECT CONCAT('<a href=\'supervisor.php?case_id=', c.case_id, '\'>', c.case_id, '</a>') as case_id,
|
END AS availableinmin,
|
||||||
o.description as outcomes,
|
CASE WHEN oq.operator_id IS NULL THEN
|
||||||
si.description as samples,
|
CONCAT('')
|
||||||
CASE WHEN ca.end IS NULL THEN '" . TQ_("Now") . "'
|
ELSE CONCAT('<span class=\'text-info\'>', oq.firstName,' ',oq.lastname,'</span>')
|
||||||
WHEN TIME_TO_SEC(TIMEDIFF(ca.end,CONVERT_TZ(DATE_SUB(NOW(), INTERVAL co.default_delay_minutes MINUTE),'System','UTC'))) < 0 THEN '" . TQ_("Now") . "'
|
END AS assignedoperator,
|
||||||
ELSE ROUND(TIME_TO_SEC(TIMEDIFF(ca.end,CONVERT_TZ(DATE_SUB(NOW(), INTERVAL co.default_delay_minutes MINUTE),'System','UTC'))) / 60)
|
CASE WHEN oq.operator_id IS NULL THEN
|
||||||
END AS availableinmin,
|
CONCAT('')
|
||||||
CASE WHEN oq.operator_id IS NULL THEN CONCAT('". TQ_("Not assigned, select to assign") ." ','<input type=\"checkbox\" name=\"c', c.case_id, '\" value=\"', c.case_id, '\"/>')
|
ELSE CONCAT('   ', cq.sortorder ,' ')
|
||||||
ELSE CONCAT('<a href=\"?questionnaire_id=$questionnaire_id&sample_import_id=$sample_id&unassign=', cq.case_queue_id, '\"/>". TQ_("Assigned to") . ": ', oq.firstName, ' " . TQ_("Order") . ":', cq.sortorder , ' (". TQ_("Click to unassign") .")</a>')
|
END AS ordr,
|
||||||
END AS assignedoperator
|
CASE WHEN oq.operator_id IS NULL THEN
|
||||||
FROM `case` as c
|
CONCAT('<span data-toggle=\'tooltip\' title=\'" . TQ_("Not assigned, select to assign") . "\'><input type=\'checkbox\' name=\'c', c.case_id, '\' value=\'', c.case_id, '\' /></span>')
|
||||||
JOIN questionnaire as q ON (q.questionnaire_id = c.questionnaire_id and q.enabled = 1)
|
ELSE CONCAT('<a href=\"?questionnaire_id=$questionnaire_id&sample_import_id=$sample_id&unassign=', cq.case_queue_id, '\" data-toggle=\'tooltip\' title=\'" . TQ_("Click to unassign") ."\'><i class=\'fa fa-trash-o fa-lg text-danger\'></i></a>')
|
||||||
JOIN outcome as o ON (o.outcome_id = c.current_outcome_id AND o.outcome_type_id = 1)
|
END AS flag
|
||||||
JOIN sample as s ON (s.sample_id = c.sample_id $s)
|
FROM `case` as c
|
||||||
JOIN sample_import as si ON (s.import_id = si.sample_import_id AND si.enabled = 1)
|
JOIN questionnaire as q ON (q.questionnaire_id = c.questionnaire_id and q.enabled = 1)
|
||||||
JOIN questionnaire_sample as qs ON (qs.questionnaire_id = q.questionnaire_id AND qs.sample_import_id = s.import_id)
|
JOIN outcome as o ON (o.outcome_id = c.current_outcome_id AND o.outcome_type_id = 1)
|
||||||
LEFT JOIN `call` as ca ON (ca.call_id = c.last_call_id)
|
JOIN sample as s ON (s.sample_id = c.sample_id $s)
|
||||||
LEFT JOIN outcome as co ON (co.outcome_id = ca.outcome_id)
|
JOIN sample_import as si ON (s.import_id = si.sample_import_id AND si.enabled = 1)
|
||||||
LEFT JOIN case_queue as cq ON (cq.case_id = c.case_id)
|
JOIN questionnaire_sample as qs ON (qs.questionnaire_id = $questionnaire_id AND qs.sample_import_id = s.import_id)
|
||||||
LEFT JOIN operator as oq ON (cq.operator_id = oq.operator_id)
|
LEFT JOIN `call` as ca ON (ca.call_id = c.last_call_id)
|
||||||
WHERE c.current_operator_id IS NULL $q $o
|
LEFT JOIN outcome as co ON (co.outcome_id = ca.outcome_id)
|
||||||
ORDER BY availableinmin ASC";
|
LEFT JOIN case_queue as cq ON (cq.case_id = c.case_id)
|
||||||
|
LEFT JOIN operator as oq ON (cq.operator_id = oq.operator_id)
|
||||||
// print $sql;
|
WHERE c.current_operator_id IS NULL $q $o
|
||||||
|
ORDER BY availableinmin ASC";
|
||||||
print ("<form method=\"post\" action=\"?questionnaire_id=$questionnaire_id&sample_import_id=$sample_id\">");
|
|
||||||
|
// print $sql;
|
||||||
xhtml_table($db->GetAll($sql),array('case_id','outcomes','samples','availableinmin','assignedoperator'),array(T_("Case id"),T_("Outcome"),T_("Sample"),T_("Case available in x minutes"),T_("Assigned to operator")));
|
|
||||||
|
print ("<form method=\"post\" action=\"?questionnaire_id=$questionnaire_id&sample_import_id=$sample_id\">");
|
||||||
$sql = "SELECT operator_id as value,CONCAT(firstName,' ', lastName) as description, '' selected
|
|
||||||
FROM operator
|
xhtml_table($db->GetAll($sql),array('case_id','samples','timezone','nrattempts','nrcalls','outcomes','availableinmin','assignedoperator','ordr','flag'),array(T_("Case id"),T_("Sample"),T_("Timezone"),T_("Call attempts"),T_("Calls"),T_("Outcome"),T_("Available in"),T_("Assigned to"),T_("Order"),"<i class='fa fa-check-square-o fa-lg'></i>"), "tclass",false,false,"bs-table");
|
||||||
WHERE enabled = 1";
|
|
||||||
|
$sql = "SELECT operator_id as value,CONCAT(firstName,' ', lastName) as description, '' selected
|
||||||
$rs3 = $db->GetAll($sql);
|
FROM operator
|
||||||
|
WHERE enabled = 1";
|
||||||
print "<label for=\"operator_id\">" . T_("Choose operator to assign selected cases to") . ": </label>";
|
|
||||||
display_chooser($rs3, "operator_id", "operator_id",true,false,false);
|
$rs3 = $db->GetAll($sql);
|
||||||
|
|
||||||
print ("<input type=\"submit\" value=\"" . T_("Assign cases to operator queue") . "\"/>");
|
print "<h4 class='col-sm-offset-5 pull-left text-right control-label'>" . T_("Assign selected cases to") . " " . T_("operator") . " : </h4> ";
|
||||||
print ("</form>");
|
display_chooser($rs3, "operator_id", "operator_id",true,false,false,true,false,true,"pull-left");
|
||||||
|
|
||||||
return true;
|
print " <button class='btn btn-default' type='submit' data-toggle='tooltip' title='" . T_("Assign cases to operator queue") . "'><i class='fa fa-link fa-lg text-primary'></i> " . T_("Assign") . "</button>";
|
||||||
}
|
print "</form></br>";
|
||||||
|
|
||||||
if (isset($_POST['operator_id']) && !empty($_POST['operator_id']))
|
return true;
|
||||||
{
|
}
|
||||||
$operator_id = intval($_POST['operator_id']);
|
|
||||||
|
if (isset($_POST['operator_id']) && !empty($_POST['operator_id']))
|
||||||
$db->StartTrans();
|
{
|
||||||
|
$operator_id = intval($_POST['operator_id']);
|
||||||
$sql = "SELECT MAX(sortorder)
|
|
||||||
FROM case_queue
|
$db->StartTrans();
|
||||||
WHERE operator_id = '$operator_id'";
|
|
||||||
|
$sql = "SELECT MAX(sortorder)
|
||||||
$sortorder = $db->GetOne($sql);
|
FROM case_queue
|
||||||
|
WHERE operator_id = '$operator_id'";
|
||||||
foreach($_POST as $key => $val)
|
|
||||||
{
|
$sortorder = $db->GetOne($sql);
|
||||||
$sortorder++;
|
|
||||||
|
foreach($_POST as $key => $val)
|
||||||
if (substr($key,0,1) == "c")
|
{
|
||||||
{
|
$sortorder++;
|
||||||
$sql = "INSERT INTO case_queue (case_id,operator_id,sortorder)
|
|
||||||
VALUES ('" . bigintval($val) . "', '$operator_id', '$sortorder')";
|
if (substr($key,0,1) == "c")
|
||||||
|
{
|
||||||
$db->Execute($sql);
|
$sql = "INSERT INTO case_queue (case_id,operator_id,sortorder)
|
||||||
}
|
VALUES ('" . bigintval($val) . "', '$operator_id', '$sortorder')";
|
||||||
}
|
|
||||||
|
$db->Execute($sql);
|
||||||
$db->CompleteTrans();
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_GET['unassign']))
|
$db->CompleteTrans();
|
||||||
{
|
}
|
||||||
$case_queue_id = bigintval($_GET['unassign']);
|
|
||||||
|
if (isset($_GET['unassign']))
|
||||||
$db->StartTrans();
|
{
|
||||||
|
$case_queue_id = bigintval($_GET['unassign']);
|
||||||
$sql = "SELECT operator_id
|
|
||||||
FROM case_queue
|
$db->StartTrans();
|
||||||
WHERE case_queue_id = '$case_queue_id'";
|
|
||||||
|
$sql = "SELECT operator_id
|
||||||
$operator_id = $db->GetOne($sql);
|
FROM case_queue
|
||||||
|
WHERE case_queue_id = '$case_queue_id'";
|
||||||
$sql = "DELETE FROM case_queue
|
|
||||||
WHERE case_queue_id = '$case_queue_id'";
|
$operator_id = $db->GetOne($sql);
|
||||||
|
|
||||||
$db->Execute($sql);
|
$sql = "DELETE FROM case_queue
|
||||||
|
WHERE case_queue_id = '$case_queue_id'";
|
||||||
$sql = "SELECT case_queue_id
|
|
||||||
FROM case_queue
|
$db->Execute($sql);
|
||||||
WHERE operator_id = '$operator_id'
|
|
||||||
ORDER BY sortorder ASC";
|
$sql = "SELECT case_queue_id
|
||||||
|
FROM case_queue
|
||||||
$rs = $db->GetAll($sql);
|
WHERE operator_id = '$operator_id'
|
||||||
|
ORDER BY sortorder ASC";
|
||||||
$sortorder = 1;
|
|
||||||
foreach($rs as $r)
|
$rs = $db->GetAll($sql);
|
||||||
{
|
|
||||||
$sql = "UPDATE case_queue
|
$sortorder = 1;
|
||||||
SET sortorder = '$sortorder'
|
foreach($rs as $r)
|
||||||
WHERE case_queue_id = '{$r['case_queue_id']}'";
|
{
|
||||||
|
$sql = "UPDATE case_queue
|
||||||
$db->Execute($sql);
|
SET sortorder = '$sortorder'
|
||||||
|
WHERE case_queue_id = '{$r['case_queue_id']}'";
|
||||||
$sortorder++;
|
|
||||||
}
|
$db->Execute($sql);
|
||||||
|
|
||||||
|
$sortorder++;
|
||||||
$db->CompleteTrans();
|
}
|
||||||
|
|
||||||
}
|
$db->CompleteTrans();
|
||||||
|
}
|
||||||
xhtml_head(T_("Case status and assignment"),true,array("../css/table.css"),array("../js/window.js"));
|
|
||||||
|
xhtml_head(T_("Case status and assignment"),true,$css,$js_head);//array("../css/table.css"),array("../js/window.js")
|
||||||
print "<p>" . T_("List cases by questionnaire and sample with the ability to assign them to be called next in a queue by a particular operator. If you assign cases to an operator, it will override the normal scheduling process and call them as soon as the operator is available.") . "</p>";
|
echo "<a href='' onclick='history.back();return false;' class='btn btn-default pull-left' ><i class='fa fa-chevron-left text-primary'></i> " . T_("Go back") . "</a>
|
||||||
|
<i class='fa fa-question-circle fa-3x text-primary pull-right btn' data-toggle='modal' data-target='.inform'></i>";
|
||||||
$questionnaire_id = false;
|
?>
|
||||||
if (isset($_GET['questionnaire_id'])) $questionnaire_id = bigintval($_GET['questionnaire_id']);
|
<div class="modal fade inform" id="inform" tabindex="-1" role="dialog" aria-labelledby="inform" aria-hidden="true">
|
||||||
$sample_import_id = false;
|
<div class="modal-dialog modal-lg">
|
||||||
if (isset($_GET['sample_import_id']) && !empty($_GET['sample_import_id'])) $sample_import_id = bigintval($_GET['sample_import_id']);
|
<div class="modal-content">
|
||||||
$outcome_id = false;
|
<div class="modal-header">
|
||||||
|
<h3 class="modal-title"><small class="text-info"><?php echo T_("INFORMATION");?></small></h4>
|
||||||
print "<label for='questionnaire'>" . T_("Questionnaire") . ":</label>";
|
</div>
|
||||||
display_questionnaire_chooser($questionnaire_id);
|
<div class="modal-body">
|
||||||
print "<label for='sample'>" . T_("Sample") . ":</label>";
|
<p><?php echo T_("List cases by questionnaire and sample with the ability to assign them to be called next in a queue by a particular operator. <br/>If you assign cases to an operator, it will override the normal scheduling process and call them as soon as the operator is available.");?></p>
|
||||||
display_sample_chooser($questionnaire_id,$sample_import_id,false);
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
if ($questionnaire_id)
|
<button type="button" class="btn btn-info" data-dismiss="modal"><?php echo T_("OK");?></button>
|
||||||
case_status_report($questionnaire_id,$sample_import_id,$outcome_id);
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
xhtml_foot();
|
</div>
|
||||||
|
<?php
|
||||||
?>
|
|
||||||
|
$questionnaire_id = false;
|
||||||
|
if (isset($_GET['questionnaire_id'])) $questionnaire_id = bigintval($_GET['questionnaire_id']);
|
||||||
|
$sample_import_id = false;
|
||||||
|
if (isset($_GET['sample_import_id']) && !empty($_GET['sample_import_id'])) $sample_import_id = bigintval($_GET['sample_import_id']);
|
||||||
|
$outcome_id = false;
|
||||||
|
|
||||||
|
print "<div class='form-group '><h3 class=' col-sm-2 text-right'>" . T_("Questionnaire") . ":</h3>";
|
||||||
|
display_questionnaire_chooser($questionnaire_id, false, "pull-left", "form-control");
|
||||||
|
print "<h3 class=' col-sm-2 text-right'>" . T_("Sample") . ":</h3>";
|
||||||
|
display_sample_chooser($questionnaire_id,$sample_import_id,false, "pull-left", "form-control");
|
||||||
|
print "</div>
|
||||||
|
<div class='clearfix'></div>";
|
||||||
|
if ($questionnaire_id)
|
||||||
|
case_status_report($questionnaire_id,$sample_import_id,$outcome_id);
|
||||||
|
|
||||||
|
xhtml_foot($js_foot);
|
||||||
|
?>
|
||||||
|
<script type="text/javascript">
|
||||||
|
$('#bs-table').bdt();
|
||||||
|
$('input').iCheck({
|
||||||
|
//checkboxClass: 'icheckbox_square-blue',
|
||||||
|
//increaseArea: '30%'
|
||||||
|
checkboxClass: 'fa fa-lg ', // text-primary
|
||||||
|
checkedCheckboxClass: 'fa-check-square-o text-primary',
|
||||||
|
uncheckedCheckboxClass: 'fa-square-o'
|
||||||
|
});
|
||||||
|
</script>
|
||||||
Reference in New Issue
Block a user