";
+ $sql = "SELECT extension_id as value, extension as description,
+ CASE WHEN current_operator_id = $operator_id THEN 'selected=\'selected\'' ELSE '' END AS selected
+ FROM extension
+ WHERE current_operator_id IS NULL
+ OR current_operator_id = $operator_id";
+
+ $ers = $db->GetAll($sql);
+
?>
+
" />
+
+
+
" />
+
+" . T_("Unassign the operator from this extension to be able to delete it") . "";
+
}
else
- print "
" . T_("No extensions") . "
";
+{
+ $sql= "SELECT CONCAT('',o.firstName,'') as firstName,
+ CONCAT('',e.extension,'') as extension,
+ IF(c.case_id IS NULL,IF(e.current_operator_id IS NULL,'list'
+ ,CONCAT('". T_("Unassign") ."')),'". T_("End case to change assignment")."') as assignment,
+ CASE e.status WHEN 0 THEN '" . T_("VoIP Offline") . "' ELSE '" . T_("VoIP Online") . "' END as status,
+ CASE ca.state WHEN 0 THEN '" . T_("Not called") . "' WHEN 1 THEN '" . T_("Requesting call") . "' WHEN 2 THEN '" . T_("Ringing") . "' WHEN 3 THEN '" . T_("Answered") . "' WHEN 4 THEN '" . T_("Requires coding") . "' ELSE '" . T_("Done") . "' END as state,
+ CONCAT('' , c.case_id, '') as case_id, SEC_TO_TIME(TIMESTAMPDIFF(SECOND,cal.start,CONVERT_TZ(NOW(),'SYSTEM','UTC'))) as calltime,
+ e.status as vs,
+ e.extension_id
+ FROM extension as e
+ LEFT JOIN `operator` as o ON (o.operator_id = e.current_operator_id)
+ LEFT JOIN `case` as c ON (c.current_operator_id = o.operator_id)
+ LEFT JOIN `call_attempt` as cal ON (cal.operator_id = o.operator_id AND cal.end IS NULL and cal.case_id = c.case_id)
+ LEFT JOIN `call` as ca ON (ca.case_id = c.case_id AND ca.operator_id = o.operator_id AND ca.outcome_id= 0 AND ca.call_attempt_id = cal.call_attempt_id)
+ ORDER BY e.extension_id ASC";
+
+ $rs = $db->GetAll($sql);
+
+ if ($msg != "")
+ print "
$msg
";
+
+ if (!empty($rs))
+ {
+ $sql = "SELECT o.operator_id as value, o.firstName as description
+ FROM `operator` as o
+ LEFT JOIN `extension` as e ON (e.current_operator_id = o.operator_id)
+ WHERE e.extension_id IS NULL";
+
+ $ers = $db->GetAll($sql);
+
+ for ($i = 0; $i < count($rs); $i++)
+ {
+ if ($rs[$i]['assignment'] == "list")
+ $rs[$i]['assignment'] = display_chooser($ers,"operator_id_" . $rs[$i]["extension_id"],"operator_id_" . $rs[$i]["extension_id"],true,"extension_id=".$rs[$i]["extension_id"],true,false,false,false);
+ }
+ xhtml_table($rs,array("extension","firstName","assignment","status","case_id","state","calltime"),array(T_("Extension"),T_("Operator"),T_("Assignment"),T_("VoIP Status"),T_("Case ID"),T_("Call state"),T_("Time on call")),"tclass",array("vs" => "1"));
+ }
+ else
+ print "
" . T_("No extensions") . "
";
+
+ print "
" . T_("Add an extension") . "
";
+ ?>
+
+
+
+
+
" />
+
+
+
Date: Mon, 25 Nov 2013 16:31:08 +1100
Subject: [PATCH 6/9] Only allow extension changes when not on a case
---
admin/operatorlist.php | 25 ++++++++++++++++++-------
1 file changed, 18 insertions(+), 7 deletions(-)
diff --git a/admin/operatorlist.php b/admin/operatorlist.php
index d337dedf..b74ad0c7 100644
--- a/admin/operatorlist.php
+++ b/admin/operatorlist.php
@@ -75,18 +75,29 @@ if (isset($_POST['submit']))
if (!empty($rs))
{
- $sql = "UPDATE extension
- SET current_operator_id = NULL
- WHERE current_operator_id= $operator_id";
- $db->Execute($sql);
+ //only update extension if we aren't on a case
+ $sql = "SELECT case_id
+ FROM `case`
+ WHERE current_operator_id = $operator_id";
- if (!empty($_POST['extension_id']))
+ $cc= $db->GetOne($sql);
+
+ if (empty($cc))
{
$sql = "UPDATE extension
- SET current_operator_id = $operator_id
- WHERE extension_id = " . intval($_POST['extension_id']);
+ SET current_operator_id = NULL
+ WHERE current_operator_id= $operator_id";
$db->Execute($sql);
+
+ if (!empty($_POST['extension_id']))
+ {
+ $sql = "UPDATE extension
+ SET current_operator_id = $operator_id
+ WHERE extension_id = " . intval($_POST['extension_id']);
+
+ $db->Execute($sql);
+ }
}
if (HTPASSWD_PATH !== false && !empty($_POST['password']))
From 5d812fa968ed8ac6518fd20c14075d5e68277087 Mon Sep 17 00:00:00 2001
From: Adam Zammit
Date: Tue, 26 Nov 2013 11:49:06 +1100
Subject: [PATCH 7/9] Added extension to status screen
---
status.php | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/status.php b/status.php
index 08246e19..30781bc7 100644
--- a/status.php
+++ b/status.php
@@ -84,7 +84,7 @@ print "
" . get_operator_time($operator_id,DATE_TIME_FORMAT) ."
if (is_voip_enabled($operator_id))
{
- $ext = get_extension($operator_id);
+ $ext = get_extension($operator_id);
$exta = $ext;
//Get just the start of the extension for auto dial out
$exts = explode('/', $ext, 2);
@@ -94,7 +94,9 @@ if (is_voip_enabled($operator_id))
if (get_extension_status($operator_id))
print "