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

Merged Separate extensions from operators and allow reassigning and selection of extensions feature

This commit is contained in:
Adam Zammit
2014-01-08 14:55:13 +11:00
12 changed files with 475 additions and 104 deletions

View File

@@ -43,26 +43,177 @@ include ("../db.inc.php");
*/
include ("../functions/functions.xhtml.php");
xhtml_head(T_("Display extension status"),true,array("../css/table.css"));
$sql= "SELECT o.firstName, o.extension, CASE o.voip_status WHEN 0 THEN '" . TQ_("VoIP Offline") . "' ELSE '" . TQ_("VoIP Online") . "' END as voip_status, CASE ca.state WHEN 0 THEN '" . TQ_("Not called") . "' WHEN 1 THEN '" . TQ_("Requesting call") . "' WHEN 2 THEN '" . TQ_("Ringing") . "' WHEN 3 THEN '" . TQ_("Answered") . "' WHEN 4 THEN '" . TQ_("Requires coding") . "' ELSE '" . TQ_("Done") . "' END as state, CONCAT('<a href=\'supervisor.php?case_id=', c.case_id , '\'>' , c.case_id, '</a>') as case_id, SEC_TO_TIME(TIMESTAMPDIFF(SECOND,cal.start,CONVERT_TZ(NOW(),'SYSTEM','UTC'))) as calltime, voip_status as vs
FROM operator as o
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)
WHERE o.voip = 1
ORDER BY o.operator_id ASC";
$msg = "";
$rs = $db->GetAll($sql);
if (!empty($rs))
if (isset($_GET))
{
xhtml_table($rs,array("extension","firstName","voip_status","case_id","state","calltime"),array(T_("Extension"),T_("Operator"),T_("VoIP Status"),T_("Case ID"),T_("Call state"),T_("Time on call")),"tclass",array("vs" => "1"));
foreach($_GET as $key=>$val)
{
if (substr($key,0,12) == "operator_id_")
{
if (isset($_GET['extension_id']))
{
$ex = intval($_GET['extension_id']);
$op = intval($val);
$sql = "UPDATE `extension`
SET current_operator_id = $op
WHERE extension_id = $ex
AND current_operator_id IS NULL";
$db->Execute($sql);
}
}
}
}
if (isset($_POST['extension']))
{
$extension = $db->qstr($_POST['extension']);
$password = $db->qstr($_POST['password']);
$extension_id = "NULL";
if (isset($_POST['extensionid']))
$extension_id = intval($_POST['extensionid']);
if (isset($_POST['delete']))
{
$sql = "DELETE FROM `extension`
WHERE current_operator_id IS NULL
AND extension_id = $extension_id";
$rs = $db->Execute($sql);
if (!$rs)
$msg = ("Failed to delete extension. There may be an operator currently assigned to it");
}
else
{
if (!empty($_POST['extension']))
{
$sql = "INSERT INTO `extension` (extension_id,extension,password)
VALUES ($extension_id,$extension,$password)
ON DUPLICATE KEY UPDATE extension=$extension,password=$password";
$rs = $db->Execute($sql);
if (!$rs)
$msg = T_("Failed to add extension. There already may be an extension of this name");
}
}
}
if (isset($_GET['unassign']))
{
$e = intval($_GET['unassign']);
$db->StartTrans();
$sql = "SELECT e.current_operator_id
FROM `extension` as e
LEFT JOIN `case` as c ON (c.current_operator_id = e.current_operator_id)
WHERE e.extension_id = $e
AND c.case_id IS NULL";
$cid = $db->GetOne($sql);
if (!empty($cid))
{
$sql = "UPDATE `extension` as e
SET current_operator_id = NULL
WHERE extension_id = $e
AND current_operator_id = $cid";
$db->Execute($sql);
}
$db->CompleteTrans();
}
xhtml_head(T_("Display extension status"),true,array("../css/table.css"),array("../js/window.js"));
if (isset($_GET['edit']))
{
$sql = "SELECT extension,password,current_operator_id
FROM extension
WHERE extension_id = " . intval($_GET['edit']);
$rs = $db->GetRow($sql);
print "<p><a href='?'>" . T_("Go back") . "</a></p>";
?>
<form enctype="multipart/form-data" action="?" method="post">
<p><?php echo T_("Extension name (such as SIP/1000):"); ?> <input name="extension" type="text" value="<?php echo $rs['extension'];?>"/></p>
<p><?php echo T_("Extension password:"); ?> <input name="password" type="text" value="<?php echo $rs['password'];?>"/></p>
<input name="extensionid" type="hidden" value="<?php echo intval($_GET['edit']);?>"/></p>
<p><input type="submit" value="<?php echo T_("Edit extension"); ?>" /></p>
<?php
if (empty($rs['current_operator_id']))
{
?>
<br/>
<p><input type="submit" name="delete" value="<?php echo T_("Delete extension"); ?>" /></p>
</form>
<?php
}
else
print "<p>" . T_("Unassign the operator from this extension to be able to delete it") . "</p>";
}
else
print "<p>" . T_("No operators") . "</p>";
{
$sql= "SELECT CONCAT('<a href=\'operatorlist.php?edit=',o.operator_id,'\'>',o.firstName,'</a>') as firstName,
CONCAT('<a href=\'?edit=',e.extension_id,'\'>',e.extension,'</a>') as extension,
IF(c.case_id IS NULL,IF(e.current_operator_id IS NULL,'list'
,CONCAT('<a href=\'?unassign=',e.extension_id,'\'>". TQ_("Unassign") ."</a>')),'". TQ_("End case to change assignment")."') as assignment,
CASE e.status WHEN 0 THEN '" . TQ_("VoIP Offline") . "' ELSE '" . TQ_("VoIP Online") . "' END as status,
CASE ca.state WHEN 0 THEN '" . TQ_("Not called") . "' WHEN 1 THEN '" . TQ_("Requesting call") . "' WHEN 2 THEN '" . TQ_("Ringing") . "' WHEN 3 THEN '" . TQ_("Answered") . "' WHEN 4 THEN '" . TQ_("Requires coding") . "' ELSE '" . TQ_("Done") . "' END as state,
CONCAT('<a href=\'supervisor.php?case_id=', c.case_id , '\'>' , c.case_id, '</a>') 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 "<p>$msg</p>";
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 "<p>" . T_("No extensions") . "</p>";
print "<h2>" . T_("Add an extension") . "</h2>";
?>
<form enctype="multipart/form-data" action="" method="post">
<p><?php echo T_("Extension name (such as SIP/1000):"); ?> <input name="extension" type="text"/></p>
<p><?php echo T_("Extension password:"); ?> <input name="password" type="text"/></p>
<p><input type="submit" value="<?php echo T_("Add extension"); ?>" /></p>
</form>
<?php
}
xhtml_foot();
?>

View File

@@ -67,8 +67,6 @@ if (isset($_POST['submit']))
firstName = " . $db->qstr($_POST['firstName']) . ",
chat_user = " . $db->qstr($_POST['chat_user']) . ",
chat_password = " . $db->qstr($_POST['chat_password']) . ",
extension = " . $db->qstr($_POST['extension']) . ",
extension_password = " . $db->qstr($_POST['extension_password']) . ",
Time_zone_name = " . $db->qstr($_POST['timezone']) . ",
voip = $voip, enabled = $enabled, chat_enable = $chat_enable
WHERE operator_id = $operator_id";
@@ -76,7 +74,32 @@ if (isset($_POST['submit']))
$rs = $db->Execute($sql);
if (!empty($rs))
{
{
//only update extension if we aren't on a case
$sql = "SELECT case_id
FROM `case`
WHERE current_operator_id = $operator_id";
$cc= $db->GetOne($sql);
if (empty($cc))
{
$sql = "UPDATE extension
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']))
{
//update password in htaccess
@@ -91,7 +114,7 @@ if (isset($_POST['submit']))
}
else
{
$msg = T_("Failed to update user. Please make sure the username and extension are unique");
$msg = T_("Failed to update user. Please make sure the username is unique");
}
}
$_GET['edit'] = $operator_id;
@@ -119,6 +142,14 @@ if (isset($_GET['edit']))
echo "<p><a href='?'>" . T_("Go back") . "</a></p>";
if (!empty($msg)) print "<h3>$msg</h3>";
$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);
?>
<form action="?" method="post">
<div><label for="username"><?php echo T_("Username") . ": "; ?></label><input type='text' name='username' value="<?php echo $rs['username'];?>"/></div>
@@ -130,9 +161,8 @@ if (isset($_GET['edit']))
?>
<div><label for="firstName"><?php echo T_("First name") . ": "; ?></label><input type='text' name='firstName' value="<?php echo $rs['firstName'];?>"/></div>
<div><label for="lastName"><?php echo T_("Last name") . ": "; ?></label><input type='text' name='lastName' value="<?php echo $rs['lastName'];?>"/></div>
<div><label for="extension"><?php echo T_("Extension") . ": "; ?></label><input type='text' name='extension' value="<?php echo $rs['extension'];?>"/></div>
<div><label for="extension_password"><?php echo T_("Extension Password") . ": "; ?></label><input type='text' name='extension_password' value="<?php echo $rs['extension_password'];?>"/></div>
<div><label for="chat_user"><?php echo T_("Jabber/XMPP chat user") . ": "; ?></label><input type='text' name='chat_user' value="<?php echo $rs['chat_user'];?>"/></div>
<div><label for="extension_id"><?php echo T_("Extension"); echo "</label>"; display_chooser($ers,"extension_id","extension_id",true,false,false,false); ?> </div>
<div><label for="chat_user"><?php echo T_("Jabber/XMPP chat user") . ": "; ?></label><input type='text' name='chat_user' value="<?php echo $rs['chat_user'];?>"/></div>
<div><label for="chat_password"><?php echo T_("Jabber/XMPP chat password") . ": "; ?></label><input type='text' name='chat_password' value="<?php echo $rs['chat_password'];?>"/></div>
<div><label for="chat_enable"><?php echo T_("Uses chat") . "? ";?></label><input type="checkbox" name="chat_enable" <?php if ($rs['chat_enable'] == 1) echo "checked=\"checked\"";?> value="1" /></div>
<div><label for="timezone"><?php echo T_("Timezone") . ": ";?></label><?php display_chooser($tz,"timezone","timezone",false,false,false,false,array("value",$rs['Time_zone_name'])); ?></div>
@@ -200,9 +230,9 @@ if (isset($_GET['operator_id']))
{
$operator_id = intval($_GET['operator_id']);
$sql = "SELECT *,SUBSTRING_INDEX(extension, '/', -1) as ext
FROM operator
WHERE operator_id = $operator_id";
$sql = "SELECT *,SUBSTRING_INDEX(e.extension, '/', -1) as ext
FROM extension as e
WHERE e.current_operator_id = $operator_id";
$rs = $db->GetRow($sql);
@@ -232,7 +262,8 @@ if (isset($_GET['operator_id']))
if ($display)
{
$sql = "SELECT
CONCAT(firstName, ' ', lastName) as name,
CONCAT(firstName, ' ', lastName) as name,
e.extension,
CONCAT('<a href=\'?winbat=winbat&amp;operator_id=',operator_id,'\'>" . TQ_("Windows bat file") . "</a>') as winbat,
CONCAT('<a href=\'?sh=sh&amp;operator_id=',operator_id,'\'>" . TQ_("*nix script file") . "</a>') as sh,
CASE WHEN enabled = 0 THEN
@@ -248,14 +279,15 @@ if ($display)
END as voipenabledisable,
CONCAT('<a href=\'?edit=',operator_id,'\'>" . TQ_("Edit") . "</a>') as edit,
username
FROM operator";
FROM operator
LEFT JOIN `extension` as e ON (e.current_operator_id = operator_id)";
$rs = $db->GetAll($sql);
xhtml_head(T_("Operator list"),true,array("../css/table.css"));
$columns = array("name","username","enabledisable","edit");
$titles = array(T_("Operator"),T_("Username"),T_("Enable/Disable"),T_("Edit"));
$columns = array("name","username","extension","enabledisable","edit");
$titles = array(T_("Operator"),T_("Username"),T_("Extension"),T_("Enable/Disable"),T_("Edit"));
if (VOIP_ENABLED)
{

View File

@@ -57,19 +57,12 @@ if (isset($_POST['operator']))
$chat_user = $db->qstr($_POST['chat_user'],get_magic_quotes_gpc());
$chat_password = $db->qstr($_POST['chat_password'],get_magic_quotes_gpc());
$time_zone_name = $db->qstr($_POST['Time_zone_name'],get_magic_quotes_gpc());
$extension = 1000;
$extensionp = "";
if (FREEPBX_PATH == false)
{
//Manually add extension information
$extension = $db->qstr($_POST['extension'],get_magic_quotes_gpc());
$extensionp = $db->qstr($_POST['extensionp'],get_magic_quotes_gpc());
}
else
$extension = "";
if (FREEPBX_PATH != false)
{
//Generate new extension from last one in database and random password
$sql = "SELECT SUBSTRING_INDEX(extension, '/', -1) as ext
FROM operator
FROM extension
ORDER BY ext DESC
LIMIT 1";
@@ -110,17 +103,32 @@ if (isset($_POST['operator']))
if (!empty($_POST['operator']))
{
$sql = "INSERT INTO operator
(`operator_id` ,`username` ,`firstName` ,`lastName`, `extension`,`extension_password`, `Time_zone_name`,`voip`,`chat_enable`,`chat_user`,`chat_password`)
VALUES (NULL , $operator, $firstname , $lastname, $extension, $extensionp, $time_zone_name, $voip, $chat, $chat_user, $chat_password);";
(`operator_id` ,`username` ,`firstName` ,`lastName`, `Time_zone_name`,`voip`,`chat_enable`,`chat_user`,`chat_password`)
VALUES (NULL , $operator, $firstname , $lastname, $time_zone_name, $voip, $chat, $chat_user, $chat_password);";
if ($db->Execute($sql))
{
{
$oid = $db->Insert_ID();
if (FREEPBX_PATH !== false)
{
{
//add extension
$sql = "INSERT INTO extension (`extension`,`extension_password`,`current_operator_id`)
VALUES ($extension, $extensionp, $oid)";
$db->Execute($sql);
//Generate new extension in freepbx
include_once("../functions/functions.freepbx.php");
freepbx_add_extension($extensionn, $_POST["firstname"] . " " . $_POST["lastname"], $extensionnp);
}
}
else if (!empty($_POST['extension_id']))
{
$sql = "UPDATE extension
SET current_operator_id = $oid
WHERE extension_id = " . intval($_POST['extension_id']);
$db->Execute($sql);
}
if (HTPASSWD_PATH !== false && HTGROUP_PATH !== false)
{
@@ -141,7 +149,6 @@ if (isset($_POST['operator']))
if (FREEPBX_PATH !== false)
$a .= "<br/>" . T_("FreePBX has been reloaded for the new VoIP extension to take effect");
$oid = $db->Insert_ID();
if ($temporary)
{
@@ -164,7 +171,7 @@ if (isset($_POST['operator']))
}
else
{
$a = T_("Could not add operator. There may already be an operator of this name:") . " $operator " . T_("Or there may already be an telephone extension number") . ":$extension" ;
$a = T_("Could not add operator. There may already be an operator of this name:") . " $operator ";
}
@@ -186,6 +193,12 @@ $sql = "SELECT Time_zone_name as value, Time_zone_name as description
$rs = $db->GetAll($sql);
$sql = "SELECT extension_id as value, extension as description
FROM extension
WHERE current_operator_id IS NULL";
$ers = $db->GetAll($sql);
?>
<h1><?php echo T_("Add an operator"); ?></h1>
<p><?php echo T_("Adding an operator here will give the user the ability to call cases"); ?> <a href="operatorquestionnaire.php"><?php echo T_("Assign Operator to Questionnaire"); ?></a> <?php echo T_("tool"); ?>.</p>
@@ -200,8 +213,7 @@ $rs = $db->GetAll($sql);
<p><?php echo T_("Enter the surname of an operator to add:"); ?> <input name="lastname" type="text"/></p>
<p><a href='timezonetemplate.php'><?php echo T_("Enter the Time Zone of an operator to add:"); echo "</a>"; display_chooser($rs,"Time_zone_name","Time_zone_name",false,false,false,false,array("value",DEFAULT_TIME_ZONE)); ?> </p>
<?php if (FREEPBX_PATH == false) { ?>
<p><?php echo T_("Enter the telephone extension number:"); ?> <input name="extension" type="text"/></p>
<p><?php echo T_("Enter the telephone extension password:"); ?> <input name="extensionp" type="text"/></p>
<p><a href='extensionstatus.php'><?php echo T_("Select an extension for this operator:"); echo "</a>"; display_chooser($ers,"extension_id","extension_id",true,false,false,false); ?> </p>
<?php } ?>
<p><?php echo T_("Will this operator be using VoIP?"); ?> <input name="voip" type="checkbox" checked="checked"/></p>
<p><?php echo T_("Jabber/XMPP chat user"); ?>: <input name="chat_user" type="text"/></p>

View File

@@ -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
*/

View File

@@ -391,6 +391,23 @@ INSERT INTO `day_of_week` (`day_of_week`) VALUES(7);
-- --------------------------------------------------------
--
-- Table structure for table `extension`
--
CREATE TABLE IF NOT EXISTS `extension` (
`extension_id` int(11) NOT NULL AUTO_INCREMENT,
`extension` char(10) COLLATE utf8_unicode_ci NOT NULL,
`password` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`status` tinyint(1) NOT NULL DEFAULT '0',
`current_operator_id` bigint(20) DEFAULT NULL,
PRIMARY KEY (`extension_id`),
UNIQUE KEY `extension` (`extension`),
UNIQUE KEY `current_operator_id` (`current_operator_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- Table structure for table `lime_answers`
--
@@ -1170,19 +1187,15 @@ CREATE TABLE `operator` (
`username` varchar(255) collate utf8_unicode_ci NOT NULL,
`firstName` varchar(255) collate utf8_unicode_ci NOT NULL,
`lastName` varchar(255) collate utf8_unicode_ci NOT NULL,
`extension` varchar(10) collate utf8_unicode_ci NOT NULL,
`extension_password` varchar(255) collate utf8_unicode_ci default NULL,
`Time_zone_name` char(64) collate utf8_unicode_ci NOT NULL,
`enabled` tinyint(1) NOT NULL default '1',
`voip` tinyint(1) NOT NULL default '1',
`voip_status` tinyint(1) NOT NULL default '0',
`next_case_id` bigint(20) default NULL,
`chat_enable` tinyint(1) default '0',
`chat_user` varchar(255) collate utf8_unicode_ci default NULL,
`chat_password` varchar(255) collate utf8_unicode_ci default NULL,
PRIMARY KEY (`operator_id`),
UNIQUE KEY `username` (`username`),
UNIQUE KEY `extension` (`extension`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
--

View File

@@ -51,6 +51,27 @@ if (isset($_GET['auto']))
print "<h1>" . T_("Work has ended. That is it") . "</h1>";
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 "<p>" . T_("You have been unassigned from your extension") ."</p>";
}
}
}
print "<p><a href='index.php'>" . T_("Go back to work") . "</a></p>";
xhtml_foot();

View File

@@ -130,13 +130,14 @@ function is_voip_enabled($operator_id)
global $db;
$sql = "SELECT voip
FROM operator
WHERE operator_id = '$operator_id'";
$sql = "SELECT o.voip
FROM `operator` as o, `extension` as e
WHERE o.operator_id = '$operator_id'
AND e.current_operator_id = o.operator_id";
$rs = $db->GetRow($sql);
if ($rs['voip'] == '1')
if (isset($rs['voip']) && $rs['voip'] == '1')
return true;
return false;
@@ -617,9 +618,10 @@ function get_case_id($operator_id, $create = false)
$db->Execute("SET @row := 0");
$sql = "INSERT INTO contact_phone (case_id,priority,phone,description)
SELECT $case_id as case_id,@row := @row + 1 AS priority,SUBSTRING_INDEX(extension,'/',-1) as phone, CONCAT(firstName, ' ', lastName)
FROM operator
WHERE enabled = 1";
SELECT $case_id as case_id,@row := @row + 1 AS priority,SUBSTRING_INDEX(o.extension,'/',-1) as phone, CONCAT(o.firstName, ' ', o.lastName)
FROM operator as o, `extension` as e
WHERE o.enabled = 1
AND e.current_operator_id = o.operator_id";
$db->Execute($sql);
}
@@ -796,9 +798,9 @@ function set_extension_status($operator_id,$online = true)
if ($online) $s = 1;
$sql = "UPDATE `operator`
SET voip_status = '$s'
WHERE operator_id = '$operator_id'";
$sql = "UPDATE `extension`
SET status = '$s'
WHERE current_operator_id = '$operator_id'";
$db->Execute($sql);
}
@@ -814,12 +816,12 @@ function get_extension_status($operator_id)
{
global $db;
$sql = "SELECT o.voip_status
FROM `operator` as o
WHERE o.operator_id = '$operator_id'";
$sql = "SELECT e.status
FROM `extension` as e
WHERE e.current_operator_id = '$operator_id'";
$rs = $db->GetRow($sql);
if (!empty($rs) && $rs['voip_status'] == 1 ) return true;
if (!empty($rs) && $rs['status'] == 1 ) return true;
return false;
}
@@ -834,9 +836,9 @@ function get_extension_password($operator_id)
{
global $db;
$sql = "SELECT o.extension_password
FROM `operator` as o
WHERE o.operator_id = '$operator_id'";
$sql = "SELECT e.extension_password
FROM `extension` as e
WHERE e.current_operator_id = '$operator_id'";
$rs = $db->GetRow($sql);
if (!empty($rs) && isset($rs['extension_password'])) return $rs['extension_password'];
@@ -854,9 +856,9 @@ function get_extension($operator_id)
{
global $db;
$sql = "SELECT o.extension
FROM `operator` as o
WHERE o.operator_id = '$operator_id'";
$sql = "SELECT e.extension
FROM `extension` as e
WHERE e.current_operator_id = '$operator_id'";
$rs = $db->GetRow($sql);
if (!empty($rs) && isset($rs['extension'])) return $rs['extension'];

View File

@@ -417,15 +417,15 @@ class voipWatch extends voip {
global $db;
$sql = "SELECT l.call_id, c.case_id
FROM operator AS o
FROM `extension` AS e
JOIN (`case` AS c, `call_attempt` AS ca, `call` AS l) ON
( c.current_operator_id = o.operator_id
( c.current_operator_id = e.current_operator_id
AND c.case_id = ca.case_id
AND ca.operator_id = o.operator_id
AND ca.operator_id = e.current_operator_id
AND ca.end IS NULL
AND l.call_attempt_id = ca.call_attempt_id
AND l.outcome_id =0 )
WHERE o.extension = '$ext'";
WHERE e.extension = '$ext'";
$rs = $db->GetRow($sql);
$call_id =0;
@@ -448,8 +448,8 @@ class voipWatch extends voip {
if ($msg) print(T_("Extension") . " $ext " . ($online ? T_("online") : T_("offline")) . "\n");
$sql = "UPDATE operator
SET voip_status = '$s'
$sql = "UPDATE `extension`
SET status = '$s'
WHERE extension = '$ext'";
$db->Execute($sql);
@@ -470,21 +470,19 @@ class voipWatch extends voip {
}
/**
* Update the extension status for all extensions
* Update the extension status for all extensions
*/
function updateAllExtensionStatus()
{
global $db;
$sql = "SELECT extension,operator_id
FROM operator
WHERE voip = 1 AND enabled = 1";
$sql = "SELECT e.extension
FROM `extension` as e";
$rs = $db->GetAll($sql);
foreach($rs as $r)
{
$o = $r['operator_id'];
$e = $r['extension'];
$s = $this->getExtensionStatus($e);

View File

@@ -161,48 +161,54 @@ function xhtml_table($content,$fields,$head = false,$class = "tclass",$highlight
* @param bool $js Whether to use JS or not
* @param bool $indiv Whether to display in a div or not
* @param array|bool $select The element to select manually (element,string) (not using selected=\'selected\' in array)
* @param bool $print Default is true, print the chooser otherwise return as a string
*
*/
function display_chooser($elements, $selectid, $var, $useblank = true, $pass = false, $js = true, $indiv = true, $selected = false)
function display_chooser($elements, $selectid, $var, $useblank = true, $pass = false, $js = true, $indiv = true, $selected = false, $print = true)
{
if ($indiv) print "<div>";
print "<select id='$selectid' name='$selectid' ";
if ($js) print "onchange=\"LinkUp('$selectid')\"";
print ">";
$out = "";
if ($indiv) $out .= "<div>";
$out .= "<select id='$selectid' name='$selectid' ";
if ($js) $out .= "onchange=\"LinkUp('$selectid')\"";
$out .= ">";
if ($useblank)
{
print "<option value='";
if ($js) print "?";
$out .= "<option value='";
if ($js) $out .= "?";
if ($pass != false)
print $pass;
print "'></option>";
$out .= $pass;
$out .= "'></option>";
}
foreach($elements as $e)
{
if ($js)
{
print "<option value='?$var={$e['value']}";
$out .= "<option value='?$var={$e['value']}";
if ($pass != false)
print "&amp;$pass";
print "' ";
$out .= "&amp;$pass";
$out .= "' ";
}
else
{
print "<option value='{$e['value']}' ";
$out .= "<option value='{$e['value']}' ";
}
if ($selected == false)
{
if (isset($e['selected']))
print $e['selected'];
$out .= $e['selected'];
}
else
if (strcmp($selected[1],$e[$selected[0]]) == 0) print "selected='selected'";
if (strcmp($selected[1],$e[$selected[0]]) == 0) $out .= "selected='selected'";
print ">".strip_tags($e['description'])."</option>";
$out .= ">".strip_tags($e['description'])."</option>";
}
print "</select>";
if ($indiv) print "</div>";
$out .= "</select>";
if ($indiv) $out .= "</div>";
if ($print)
print $out;
else
return $out;
}
function xhtml_object($data, $id, $class="embeddedobject")

View File

@@ -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();

114
selectextension.php Normal file
View File

@@ -0,0 +1,114 @@
<?php
/**
* Select an extension before continuing
*
*
* This file is part of queXS
*
* queXS is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* queXS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with queXS; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*
* @author Adam Zammit <adam.zammit@deakin.edu.au>
* @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 "<p>" . T_("There are no extensions available, please contact the supervisor or click below to try again for an available extension") . "</p>";
print "<p><a href='?'>" . T_("Try again") . "</a></p>";
}
else
{
print "<h2>" . T_("Select extension") . "</h2>";
print "<p>" . T_("Please select your extension from the list below then click on 'Choose extension'") . "</p>";
print "<form action='?' method='post'>";
print "<label for='extension_id'>" . T_("Extension") . ":</label>";
display_chooser($ers,"extension_id","extension_id",false,false,false,false);
print "<p><input type='submit' value='" .T_ ("Choose extension") . "'/></p></form>";
}
xhtml_foot();
?>

View File

@@ -84,7 +84,7 @@ print "<div class='text'>" . 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 "<div class='online statusbutton'>" . T_("VoIP On") . "</div>";
else
print "<div class='offline statusbutton'><a href='voip/downloadvoipclient.php'>" . T_("VoIP Off") . "</a></div>";
print "<div class='offline statusbutton'><a href='voip/downloadvoipclient.php'>" . T_("VoIP Off") . "</a></div>";
print "<div class='statusbutton'>" . T_("Extension") . ": $ext</div>";
}
else
print "<div class='online statusbutton'>" . T_("No VoIP") . "</div>";