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

New feature: Assign the next case to an operator specifically using the administrative functions

This commit is contained in:
azammitdcarf
2011-02-28 05:00:26 +00:00
parent 86e5bfbd09
commit e9997305fc
3 changed files with 79 additions and 2 deletions

View File

@@ -163,6 +163,28 @@ if ($case_id != false)
$db->Execute($sql); $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 $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 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)
<p><input type="hidden" name="case_id" value="<? echo $case_id;?>"/><input class="submitclass" type="submit" name="submit" value="<? echo T_("Set outcome"); ?>"/></p> <p><input type="hidden" name="case_id" value="<? echo $case_id;?>"/><input class="submitclass" type="submit" name="submit" value="<? echo T_("Set outcome"); ?>"/></p>
</form> </form>
<? <?
//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>";
?>
<form method="get" action="?">
<?
$sql = "SELECT operator_id as value,CONCAT(firstName,' ', lastName) as description, CASE WHEN next_case_id = '$case_id' THEN 'selected=\'selected\'' ELSE '' END AS selected
FROM operator
WHERE enabled = 1";
$rs3 = $db->GetAll($sql);
display_chooser($rs3, "operator_id", "operator_id",true,false,false);
?>
<p><input type="hidden" name="case_id" value="<? echo $case_id;?>"/><input class="submitclass" type="submit" name="submit" value="<? echo T_("Assign this case to operator"); ?>"/></p>
</form>
<?
} }
else else
{ {

View File

@@ -821,6 +821,7 @@ CREATE TABLE `operator` (
`enabled` tinyint(1) NOT NULL default '1', `enabled` tinyint(1) NOT NULL default '1',
`voip` tinyint(1) NOT NULL default '1', `voip` tinyint(1) NOT NULL default '1',
`voip_status` tinyint(1) NOT NULL default '0', `voip_status` tinyint(1) NOT NULL default '0',
`next_case_id` bigint(20) default NULL,
PRIMARY KEY (`operator_id`), PRIMARY KEY (`operator_id`),
UNIQUE KEY `username` (`username`), UNIQUE KEY `username` (`username`),
UNIQUE KEY `extension` (`extension`) UNIQUE KEY `extension` (`extension`)

View File

@@ -292,8 +292,43 @@ function get_case_id($operator_id, $create = false)
$case_id = false; $case_id = false;
if (empty($r1)) 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'); $systemsort = get_setting('systemsort');