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)

"/>

" . T_("Assign this case to operator (will appear as next case for them)") . ""; + ?> +
+ GetAll($sql); + display_chooser($rs3, "operator_id", "operator_id",true,false,false); + + ?> +

"/>

+
+ 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');