diff --git a/admin/casestatus.php b/admin/casestatus.php index 1df580e5..c4730f6e 100644 --- a/admin/casestatus.php +++ b/admin/casestatus.php @@ -88,17 +88,21 @@ function case_status_report($questionnaire_id = false, $sample_id = false, $outc WHEN TIME_TO_SEC(TIMEDIFF(ca.end,CONVERT_TZ(DATE_SUB(NOW(), INTERVAL o.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 o.default_delay_minutes MINUTE),'System','UTC'))) / 60),' " . TQ_("minutes") . "') END AS availableinmin, - CASE WHEN oq.operator_id IS NULL THEN + CASE WHEN cq.operator_id = 0 THEN + CONCAT('" . TQ_("Any operator") . "') + WHEN oq.operator_id IS NULL THEN CONCAT('') ELSE CONCAT('', oq.firstName,' ',oq.lastName,'') END AS assignedoperator, - CASE WHEN oq.operator_id IS NULL THEN + CASE WHEN (cq.operator_id = 0 OR oq.operator_id IS NOT NULL) THEN + CONCAT(' ', cq.sortorder ,' ') + ELSE CONCAT('') - ELSE CONCAT(' ', cq.sortorder ,' ') END AS ordr, - CASE WHEN oq.operator_id IS NULL THEN + CASE WHEN (cq.operator_id = 0 OR oq.operator_id IS NOT NULL) THEN + CONCAT('') + ELSE CONCAT('') - ELSE CONCAT('') END AS flag FROM `case` as c JOIN questionnaire as q ON (q.questionnaire_id = c.questionnaire_id and q.enabled = 1) @@ -135,16 +139,22 @@ function case_status_report($questionnaire_id = false, $sample_id = false, $outc $rs3 = $db->GetAll($sql); + $any = array('value' => 0, 'description' => TQ_("Any operator"), 'selected' => ''); + + $rs3[] = $any; + print "
" . TQ_("Unassign all cases from the operator queue") . "
"; + return true; } -if (isset($_POST['operator_id']) && !empty($_POST['operator_id'])) +if (isset($_POST['operator_id']) && $_POST['operator_id'] != "") { $operator_id = intval($_POST['operator_id']); @@ -211,6 +221,45 @@ if (isset($_GET['unassign'])) $db->CompleteTrans(); } + +function unassignall($questionnaire_id,$sample_import_id) +{ + global $db; + + $sql = "SELECT cq.case_queue_id + FROM case_queue as cq, `case` as c + WHERE c.questionnaire_id = $questionnaire_id + AND cq.case_id = c.case_id"; + + + if ($sample_import_id) { + $sql = "SELECT cq.case_queue_id + FROM case_queue as cq, `case` as c, `sample` as s + WHERE c.questionnaire_id = $questionnaire_id + AND c.sample_id = s.sample_id + AND cq.case_id = c.case_id + AND s.import_id = $sample_import_id"; + } + + $ctoa = $db->GetAll($sql); + + if (!empty($ctoa)) { + $cq = ""; + + foreach($ctoa as $key => $val) { + $cq .= $val['case_queue_id'] . ","; + } + + $cq = substr($cq,0,-1); + + $sql = "DELETE FROM case_queue + WHERE case_queue_id IN ($cq)"; + + $db->Execute($sql); + } +} + + xhtml_head(T_("Case status and assignment"),true,$css,$js_head); echo " " . T_("Go back") . " "; @@ -241,10 +290,15 @@ $outcome_id = false; print "