diff --git a/admin/supervisor.php b/admin/supervisor.php
index edae5840..8f9844dd 100644
--- a/admin/supervisor.php
+++ b/admin/supervisor.php
@@ -163,6 +163,28 @@ if ($case_id != false)
$db->Execute($sql);
}
+ if (isset($_GET['operator_id']))
+ {
+ $case_operator_id = bigintval($_GET['operator_id']);
+
+ if ($case_operator_id == 0)
+ {
+ //clear the next case if set to no operator
+ $sql = "UPDATE `operator`
+ SET next_case_id = NULL
+ WHERE next_case_id = '$case_id'";
+ }
+ else
+ {
+ $sql = "UPDATE `operator`
+ SET next_case_id = '$case_id'
+ WHERE operator_id = '$case_operator_id'";
+ }
+
+ $db->Execute($sql);
+ }
+
+
$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
@@ -280,6 +302,25 @@ if ($case_id != false)
"/>
+
+ //assign this to an operator for their next case
+ print "
" . T_("Assign this case to operator (will appear as next case for them)") . "
";
+ ?>
+
+
+
+
}
else
{
diff --git a/database/quexs.sql b/database/quexs.sql
index 79270e5a..27f2039b 100644
--- a/database/quexs.sql
+++ b/database/quexs.sql
@@ -821,6 +821,7 @@ CREATE TABLE `operator` (
`enabled` tinyint(1) NOT NULL default '1',
`voip` tinyint(1) NOT NULL default '1',
`voip_status` tinyint(1) NOT NULL default '0',
+ `next_case_id` bigint(20) default NULL,
PRIMARY KEY (`operator_id`),
UNIQUE KEY `username` (`username`),
UNIQUE KEY `extension` (`extension`)
diff --git a/functions/functions.operator.php b/functions/functions.operator.php
index db0218fd..59c9c9d0 100644
--- a/functions/functions.operator.php
+++ b/functions/functions.operator.php
@@ -292,8 +292,43 @@ function get_case_id($operator_id, $create = false)
$case_id = false;
if (empty($r1))
- {
- if ($create)
+ {
+ $sql = "SELECT o.next_case_id
+ FROM `operator` as o, `case` as c
+ WHERE o.operator_id = '$operator_id'
+ AND c.case_id = o.next_case_id
+ AND c.current_operator_id IS NULL";
+
+ $rnc = $db->GetRow($sql);
+
+ if (isset($rnc['next_case_id']) && !empty($rnc['next_case_id']))
+ {
+ $case_id = $rnc['next_case_id'];
+
+ $sql = "UPDATE `case`
+ SET current_operator_id = '$operator_id'
+ WHERE current_operator_id IS NULL
+ AND case_id = '$case_id'";
+
+ $db->Execute($sql);
+
+ //should fail transaction if already assigned to another case
+ if ($db->Affected_Rows() != 1)
+ {
+ $db->FailTrans();
+ }
+ else
+ {
+ //remove next case setting
+ $sql = "UPDATE `operator`
+ SET next_case_id = NULL
+ WHERE operator_id = '$operator_id'";
+
+ $db->Execute($sql);
+ }
+
+ }
+ else if ($create)
{
$systemsort = get_setting('systemsort');