From 6d81384378586b31f2001cf486c9105266076392 Mon Sep 17 00:00:00 2001 From: Adam Zammit Date: Tue, 26 Nov 2013 11:49:38 +1100 Subject: [PATCH] Added featue for allowing operators to choose their own extension if not assigned one already --- config.default.php | 5 ++ endwork.php | 21 ++++++++ index.php | 15 ++++++ selectextension.php | 114 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 155 insertions(+) create mode 100644 selectextension.php diff --git a/config.default.php b/config.default.php index 38a9c5a7..c6f0166b 100644 --- a/config.default.php +++ b/config.default.php @@ -69,6 +69,11 @@ if (!defined('TIME_FORMAT')) define('TIME_FORMAT','%I:%i%p'); */ if (!defined('VOIP_ENABLED')) define('VOIP_ENABLED',false); +/** + * Allow operators to choose their extension? + */ +if (!defined('ALLOW_OPERATOR_EXTENSION_SELECT')) define('ALLOW_OPERATOR_EXTENSION_SELECT',false); + /** * The Asterisk server address */ diff --git a/endwork.php b/endwork.php index 59ab7f20..47145bb6 100644 --- a/endwork.php +++ b/endwork.php @@ -51,6 +51,27 @@ if (isset($_GET['auto'])) print "

" . T_("Work has ended. That is it") . "

"; +if (ALLOW_OPERATOR_EXTENSION_SELECT && VOIP_ENABLED) +{ + //unassign extension + include_once("functions/functions.operator.php"); + $operator_id = get_operator_id(); + + if (get_case_id($operator_id) == false && is_voip_enabled($operator_id)) + { + $sql = "UPDATE `extension` + SET current_operator_id = NULL + WHERE current_operator_id = $operator_id"; + + $rs = $db->Execute($sql); + + if ($rs) + { + print "

" . T_("You have been unassigned from your extension") ."

"; + } + } +} + print "

" . T_("Go back to work") . "

"; xhtml_foot(); diff --git a/index.php b/index.php index 2eaf544b..0f488633 100644 --- a/index.php +++ b/index.php @@ -52,6 +52,21 @@ if (ALTERNATE_INTERFACE && !is_voip_enabled($operator_id)) include_once("waitnextcase_interface2.php"); die(); } +else if (ALLOW_OPERATOR_EXTENSION_SELECT && VOIP_ENABLED) +{ + $sql = "SELECT o.voip,e.extension_id + FROM `operator` as o + LEFT JOIN `extension` as e ON (e.current_operator_id = o.operator_id) + WHERE o.operator_id = $operator_id"; + + $ve = $db->GetRow($sql); + + if ($ve['voip'] == 1 && empty($ve['extension_id'])) + { + include_once("selectextension.php"); + die(); + } +} $db->StartTrans(); diff --git a/selectextension.php b/selectextension.php new file mode 100644 index 00000000..42487bbb --- /dev/null +++ b/selectextension.php @@ -0,0 +1,114 @@ + + * @copyright Deakin University 2007,2008 + * @package queXS + * @subpackage user + * @link http://www.deakin.edu.au/dcarf/ queXS was writen for DCARF - Deakin Computer Assisted Research Facility + * @license http://opensource.org/licenses/gpl-2.0.php The GNU General Public License (GPL) Version 2 + * + * + */ + +/** + * Configuration file + */ +include_once("config.inc.php"); + +/** + * XHTML functions + */ +include_once("functions/functions.xhtml.php"); + +/** + * Operator functions + */ +include_once("functions/functions.operator.php"); + +$operator_id = get_operator_id(); + +if (!$operator_id) + die(); + +//if already assigned just get straight to it +$sql = "SELECT extension + FROM `extension` + WHERE current_operator_id = '$operator_id'"; + +$e = $db->GetOne($sql); + +if (!empty($e)) +{ + header('Location: index.php'); + die(); +} + +if (isset($_POST['extension_id']) && !empty($_POST['extension_id'])) +{ + if ($operator_id) + { + $e = intval($_POST['extension_id']); + + $sql = "UPDATE `extension` + SET current_operator_id = $operator_id + WHERE current_operator_id IS NULL + AND extension_id = $e"; + + $r = $db->Execute($sql); + + if ($r) + { + header('Location: index.php'); + die(); + } + } +} + + +xhtml_head(T_("queXS")); + + +$sql = "SELECT e.extension_id as value, e.extension as description + FROM `extension` as e + WHERE e.current_operator_id IS NULL"; + +$ers = $db->GetAll($sql); + +if (empty($ers)) +{ + print "

" . T_("There are no extensions available, please contact the supervisor or click below to try again for an available extension") . "

"; + print "

" . T_("Try again") . "

"; +} +else +{ + print "

" . T_("Select extension") . "

"; + print "

" . T_("Please select your extension from the list below then click on 'Choose extension'") . "

"; + + print "
"; + print ""; + display_chooser($ers,"extension_id","extension_id",false,false,false,false); + print "

"; +} +xhtml_foot(); + +?>