diff --git a/admin/exten_tab.php b/admin/exten_tab.php deleted file mode 100644 index 6fddb1b0..00000000 --- a/admin/exten_tab.php +++ /dev/null @@ -1,164 +0,0 @@ -$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); - - -} -else -{ - $sql= "SELECT CONCAT('',o.firstName,' ', o.lastname,'') as firstName, - CONCAT('',e.extension,'') as extension, - IF(c.case_id IS NULL,IF(e.current_operator_id IS NULL,'list' - ,CONCAT('". TQ_("Unassign") ."')),'". 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('' , 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, CONCAT(o.firstName,' ', o.lastname) 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") . "

"; - -} - -xhtml_foot(); - -?> diff --git a/admin/extensionstatus.php b/admin/extensionstatus.php index 94c2b621..be32f8f1 100644 --- a/admin/extensionstatus.php +++ b/admin/extensionstatus.php @@ -1,219 +1,269 @@ - - * @copyright Australian Consortium for Social and Political Research Incorporated (ACSPRI) 2010 - * @package queXS - * @subpackage admin - * @link http://www.acspri.org.au/software/ queXS was writen for ACSPRI - * @license http://opensource.org/licenses/gpl-2.0.php The GNU General Public License (GPL) Version 2 - * - */ - -/** - * Configuration file - */ -include_once(dirname(__FILE__).'/../config.inc.php'); - -/** - * Database file - */ -include ("../db.inc.php"); - -/** - * XHTML functions - */ -include ("../functions/functions.xhtml.php"); - -$msg = ""; - -if (isset($_GET)) -{ - 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 "

" . T_("Go back") . "

"; -?> -
-

-

-

-

" />

- -
-

" />

-
-" . T_("Unassign the operator from this extension to be able to delete it") . "

"; - -} -else -{ - $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('". TQ_("Unassign") ."')),'". 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('' , 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") . "

"; - ?> - -
-

-

-

" />

-
- - + + * @copyright Australian Consortium for Social and Political Research Incorporated (ACSPRI) 2010 + * @package queXS + * @subpackage admin + * @link http://www.acspri.org.au/software/ queXS was writen for ACSPRI + * @license http://opensource.org/licenses/gpl-2.0.php The GNU General Public License (GPL) Version 2 + * + */ + +/** + * Configuration file + */ +include_once(dirname(__FILE__).'/../config.inc.php'); + +/** + * Database file + */ +include ("../db.inc.php"); + +/** + * XHTML functions + */ +include ("../functions/functions.xhtml.php"); + +$msg = ""; + +if (isset($_GET)) +{ + 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_("Extensions & status"),true,array("../include/bootstrap-3.3.2/css/bootstrap.min.css","../css/custom.css"),array("../js/window.js")); +?> + + +GetRow($sql); + } + + print "" . T_("Go back") . ""; +?> +
+

+
+
+ + " maxlength="12" required value="" class="form-control"/> +
+
+ + "/>    + " class="btn btn-default fa" />   + +
+ +
+ " /> +
+ + + + + + + + " /> + +
" . T_("Unassign the operator from this extension to be able to delete it") . ""; + } + + print "
"; +} +else +{ + $sql= "SELECT CONCAT('',o.firstName,' ', o.lastname,'') as firstName, + CONCAT('',e.extension,'') as extension, + IF(c.case_id IS NULL,IF(e.current_operator_id IS NULL,'list' + ,CONCAT('". TQ_("Unassign") ."')),'". 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('' , 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); + } + print "
"; + 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")); + print "
"; + } + else + print "

" . T_("No extensions") . "

"; + + print "
" . T_("Add extension") . "
"; + +} + +xhtml_foot(); + +?> \ No newline at end of file diff --git a/admin/operatorlist.php b/admin/operatorlist.php index e6bb7e40..62b15a62 100644 --- a/admin/operatorlist.php +++ b/admin/operatorlist.php @@ -1,315 +1,406 @@ - - * @copyright Australian Consortium for Social and Political Research Incorporated (ACSPRI) 2007,2008,2009,2010,2011 - * @package queXS - * @subpackage admin - * @link http://www.acspri.org.au/software queXS was writen for ACSPRI - * @license http://opensource.org/licenses/gpl-2.0.php The GNU General Public License (GPL) Version 2 - * - */ - -/** - * Configuration file - */ -include_once(dirname(__FILE__).'/../config.inc.php'); - -/** - * Database - */ -include_once(dirname(__FILE__).'/../db.inc.php'); - -/** - * XHTML functions - */ -include_once(dirname(__FILE__).'/../functions/functions.xhtml.php'); - -$display = true; -$msg = ""; - -if (isset($_POST['submit'])) -{ - $operator_id = intval($_POST['operator_id']); - $chat_enable = $voip = $enabled = 0; - if (isset($_POST['voip'])) $voip = 1; - if (isset($_POST['chat_enable'])) $chat_enable = 1; - if (isset($_POST['enabled'])) $enabled = 1; - - if (HTPASSWD_PATH !== false && $_POST['existing_username'] != $_POST['username'] && empty($_POST['password'])) - { - $msg = T_("If changing usernames, you must specify a new password"); - } - else - { - $sql = "UPDATE operator - SET username = " . $db->qstr($_POST['username']) . ", - lastName = " . $db->qstr($_POST['lastName']) . ", - firstName = " . $db->qstr($_POST['firstName']) . ", - chat_user = " . $db->qstr($_POST['chat_user']) . ", - chat_password = " . $db->qstr($_POST['chat_password']) . ", - Time_zone_name = " . $db->qstr($_POST['timezone']) . ", - voip = $voip, enabled = $enabled, chat_enable = $chat_enable - WHERE operator_id = $operator_id"; - - $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 - include_once(dirname(__FILE__).'/../functions/functions.htpasswd.php'); - $htp = New Htpasswd(HTPASSWD_PATH); - $htp->deleteUser($_POST["existing_username"]); - $htp->deleteUser($_POST["username"]); - $htp->addUser($_POST["username"],$_POST["password"]); - $htg = New Htgroup(HTGROUP_PATH); - $htg->deleteUserFromGroup($_POST["existing_username"],HTGROUP_INTERVIEWER); - $htg->addUserToGroup($_POST["username"],HTGROUP_INTERVIEWER); - } - - $msg = T_("Successfully updated user"); - } - else - { - $msg = T_("Failed to update user. Please make sure the username is unique"); - } - } - $_GET['edit'] = $operator_id; -} - - -if (isset($_GET['edit'])) -{ - xhtml_head(T_("Operator edit"),true,array("../css/table.css")); - - $operator_id = intval($_GET['edit']); - - $sql = "SELECT * - FROM operator - WHERE operator_id = $operator_id"; - - $rs = $db->GetRow($sql); - - $sql = "SELECT Time_zone_name as value, Time_zone_name as description - FROM timezone_template"; - - $tz = $db->GetAll($sql); - - print "

" . T_("Edit") . ": " . $rs['username'] . "

"; - echo "

" . T_("Go back") . "

"; - if (!empty($msg)) print "

$msg

"; - - $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); - - ?> -
-
- -
- -
-
-
-
-
-
value="1" />
-
-
value="1" />
-
value="1" />
-
-
-
"/>
-
- Execute($sql); -} - -if (isset($_GET['voipenable'])) -{ - $operator_id = intval($_GET['voipenable']); - - $sql = "UPDATE operator - SET voip = 1 - WHERE operator_id = '$operator_id'"; - - $db->Execute($sql); -} - - -if (isset($_GET['disable'])) -{ - $operator_id = intval($_GET['disable']); - - $sql = "UPDATE operator - SET enabled = 0 - WHERE operator_id = '$operator_id'"; - - $db->Execute($sql); -} - -if (isset($_GET['enable'])) -{ - $operator_id = intval($_GET['enable']); - - $sql = "UPDATE operator - SET enabled = 1 - WHERE operator_id = '$operator_id'"; - - $db->Execute($sql); -} - -if (isset($_GET['operator_id'])) -{ - $operator_id = intval($_GET['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); - - if (!empty($rs)) - { - $display = false; - - if (isset($_GET['winbat']) || isset($_GET['sh'])) - { - header("Content-Type: text/txt"); - if (isset($_GET['winbat'])) - header("Content-Disposition: attachment; filename=operator_$operator_id.bat"); - else - header("Content-Disposition: attachment; filename=operator_$operator_id.sh"); - header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past - header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); - header("Pragma: public"); // HTTP/1.0 - - if (isset($_GET['winbat'])) - echo "voipclient.exe -i -u {$rs['ext']} -p {$rs['password']} -h " . $_SERVER['SERVER_NAME']; - else - echo "./voipclient -i -u {$rs['ext']} -p {$rs['password']} -h " . $_SERVER['SERVER_NAME']; - } - } -} - -if ($display) -{ - $sql = "SELECT - CONCAT(firstName, ' ', lastName) as name, - e.extension, - CONCAT('" . TQ_("Windows bat file") . "') as winbat, - CONCAT('" . TQ_("*nix script file") . "') as sh, - CASE WHEN enabled = 0 THEN - CONCAT('" . TQ_("Enable") . "') - ELSE - CONCAT('" . TQ_("Disable") . "') - END - as enabledisable, - CASE WHEN voip = 0 THEN - CONCAT('" . TQ_("Enable VoIP") . "') - ELSE - CONCAT('" . TQ_("Disable VoIP") . "') - END as voipenabledisable, - CONCAT('" . TQ_("Edit") . "') as edit, - username - 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","extension","enabledisable","edit"); - $titles = array(T_("Operator"),T_("Username"),T_("Extension"),T_("Enable/Disable"),T_("Edit")); - - if (VOIP_ENABLED) - { - print "

" . T_("Download the file for each user and save in the same folder as the voip.exe executable. When the file is executed, it will run the voip.exe program with the correct connection details to connect the operator to the VoIP server") . "

"; - - print "

" . T_("Download Windows VoIP Executable") . "

"; - print "

" . T_("Download Linux VoIP Executable") . "

"; - - $columns[] = "voipenabledisable"; - $columns[] = "winbat"; - $columns[] = "sh"; - $titles[] = T_("Enable/Disable VoIP"); - $titles[] = T_("Windows VoIP"); - $titles[] = T_("*nix VoIP"); - } - - xhtml_table($rs,$columns,$titles); - - - xhtml_foot(); -} -?> + + * @copyright Australian Consortium for Social and Political Research Incorporated (ACSPRI) 2007,2008,2009,2010,2011 + * @package queXS + * @subpackage admin + * @link http://www.acspri.org.au/software queXS was writen for ACSPRI + * @license http://opensource.org/licenses/gpl-2.0.php The GNU General Public License (GPL) Version 2 + * + */ + +/** + * Configuration file + */ +include_once(dirname(__FILE__).'/../config.inc.php'); + +/** + * Database + */ +include_once(dirname(__FILE__).'/../db.inc.php'); + +/** + * XHTML functions + */ +include_once(dirname(__FILE__).'/../functions/functions.xhtml.php'); + +$display = true; +$msg = ""; + +if (isset($_POST['submit'])) +{ + $operator_id = intval($_POST['operator_id']); + $chat_enable = $voip = $enabled = 0; + if (isset($_POST['voip'])) $voip = 1; + if (isset($_POST['chat_enable'])) $chat_enable = 1; + if (isset($_POST['enabled'])) $enabled = 1; + + if (HTPASSWD_PATH !== false && $_POST['existing_username'] != $_POST['username'] && empty($_POST['password'])) + { + $msg = "

" . T_("If changing usernames, you must specify a new password") . "

"; + } + else + { + $sql = "UPDATE operator + SET username = " . $db->qstr($_POST['username']) . ", + lastName = " . $db->qstr($_POST['lastName']) . ", + firstName = " . $db->qstr($_POST['firstName']) . ", + chat_user = " . $db->qstr($_POST['chat_user']) . ", + chat_password = " . $db->qstr($_POST['chat_password']) . ", + Time_zone_name = " . $db->qstr($_POST['timezone']) . ", + voip = $voip, enabled = $enabled, chat_enable = $chat_enable + WHERE operator_id = $operator_id"; + + $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 + include_once(dirname(__FILE__).'/../functions/functions.htpasswd.php'); + $htp = New Htpasswd(HTPASSWD_PATH); + $htp->deleteUser($_POST["existing_username"]); + $htp->deleteUser($_POST["username"]); + $htp->addUser($_POST["username"],$_POST["password"]); + $htg = New Htgroup(HTGROUP_PATH); + $htg->deleteUserFromGroup($_POST["existing_username"],HTGROUP_INTERVIEWER); + $htg->addUserToGroup($_POST["username"],HTGROUP_INTERVIEWER); + } + + $msg = "

" . T_("Successfully updated user") . ": " . $_POST['username'] . "

"; + } + else + { + $msg = "

" . T_("Failed to update user") . ": " . $_POST['username'] . " " . T_("Please make sure the username is unique") . "

"; + } + } + $_GET['edit'] = $operator_id; +} + + +if (isset($_GET['edit'])) +{ + xhtml_head(T_("Edit Operator settings"),true,array("../include/bootstrap-3.3.2/css/bootstrap.min.css","../include/bootstrap-toggle/css/bootstrap-toggle.min.css", "../css/custom.css"),array("../js/jquery-2.1.3.min.js","../include/bootstrap-3.3.2/js/bootstrap.min.js","../include/bootstrap-toggle/js/bootstrap-toggle.min.js")); + + $operator_id = intval($_GET['edit']); + + $sql = "SELECT * + FROM operator + WHERE operator_id = $operator_id"; + + $rs = $db->GetRow($sql); + + $sql = "SELECT Time_zone_name as value, Time_zone_name as description + FROM timezone_template"; + + $tz = $db->GetAll($sql); +?> + + + +
+" . T_("Operator") . ": " . $rs['username'] . ""; + echo "
"; + + if (!empty($msg)) echo $msg; + + $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); + +?> +
+
+ +
+
+ +
+ +
"/>
+
  + " class="btn btn-default"/>   + +
+
+ +
+ +
+
+
+ +
+
+
+ +
+
+ + +
+
+
+ +
+
+ + +
+
+
+ +
" data-off="" value="1" />
+
+
+ +
+
+
+ +
+
+
+ +
" data-off="" value="1"/>
+
+
+ +
" data-off="" value="1" />
+
+
+
+ +
"/>
+
+ + + Execute($sql); +} + +if (isset($_GET['voipenable'])) +{ + $operator_id = intval($_GET['voipenable']); + + $sql = "UPDATE operator + SET voip = 1 + WHERE operator_id = '$operator_id'"; + + $db->Execute($sql); +} + +if (isset($_GET['disable'])) +{ + $operator_id = intval($_GET['disable']); + + $sql = "UPDATE operator + SET enabled = 0 + WHERE operator_id = '$operator_id'"; + + $db->Execute($sql); +} + +if (isset($_GET['enable'])) +{ + $operator_id = intval($_GET['enable']); + + $sql = "UPDATE operator + SET enabled = 1 + WHERE operator_id = '$operator_id'"; + + $db->Execute($sql); +} + +if (isset($_GET['operator_id'])) +{ + $operator_id = intval($_GET['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); + + if (!empty($rs)) + { + $display = false; + + if (isset($_GET['winbat']) || isset($_GET['sh'])) + { + header("Content-Type: text/txt"); + if (isset($_GET['winbat'])) + header("Content-Disposition: attachment; filename=operator_$operator_id.bat"); + else + header("Content-Disposition: attachment; filename=operator_$operator_id.sh"); + header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past + header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); + header("Pragma: public"); // HTTP/1.0 + + if (isset($_GET['winbat'])) + echo "voipclient.exe -i -u {$rs['ext']} -p {$rs['password']} -h " . $_SERVER['SERVER_NAME']; + else + echo "./voipclient -i -u {$rs['ext']} -p {$rs['password']} -h " . $_SERVER['SERVER_NAME']; + } + } +} + +if ($display) +{ + $sql = "SELECT + CONCAT(firstName, ' ', lastName) as name, + CONCAT ('', e.extension ,'') as `extension`, + CONCAT('" . TQ_("Win .bat file") . "') as winbat, + CONCAT('" . TQ_("*nix script file") . "') as sh, + CASE WHEN enabled = 0 THEN + CONCAT('  ') + ELSE + CONCAT('  ') + END as enabledisable, + CASE WHEN voip = 0 THEN + CONCAT('" . TQ_("Enable VoIP") . "') + ELSE + CONCAT('" . TQ_("Disable VoIP") . "') + END as voipenabledisable, + CONCAT('  ') as edit, username + 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("../include/bootstrap-3.3.2/css/bootstrap.min.css","../include/font-awesome-4.3.0/css/font-awesome.css","../css/custom.css")); + + $columns = array("name","username","extension","enabledisable","edit"); + $titles = array(T_("Operator"),T_("Username"),T_("Extension")," "," "); + + if (VOIP_ENABLED) + { + $columns[] = "voipenabledisable"; + $columns[] = "winbat"; + $columns[] = "sh"; + $titles[] = T_("VoIP ON/Off"); + $titles[] = T_("Win file");//Windows VoIP + $titles[] = T_("*nix flle");//*nix VoIP + } + echo "
"; + xhtml_table($rs,$columns,$titles); + echo "
"; + + echo "
+
 " . T_("Add an operator") . "
+
 " . T_("Extensions") . "
+
" . T_("Assign to questionnaire") . "
+
 " . T_("Operator skills") . "
+
 " . T_("Operator performance") . "
"; + + if (VOIP_ENABLED) + { + print "
" . T_("Download the file for each user and save in the same folder as the voip.exe executable. When the file is executed, it will run the voip.exe program with the correct connection details to connect the operator to the VoIP server"). "

"; + + print " " . T_("Download Win file") . "
"; + print " " . T_("Download Linux file") . "
"; + + } + print "
"; + + xhtml_foot(); +} +?> \ No newline at end of file diff --git a/admin/operatorquestionnaire.php b/admin/operatorquestionnaire.php index 36d99cb1..3b62f12f 100644 --- a/admin/operatorquestionnaire.php +++ b/admin/operatorquestionnaire.php @@ -1,284 +1,279 @@ - - * @copyright Deakin University 2007,2008 - * @package queXS - * @subpackage admin - * @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 ("../config.inc.php"); - -/** - * Database file - */ -include ("../db.inc.php"); - -/** - * XHTML functions - */ -include ("../functions/functions.xhtml.php"); - -/** - * Return if an operator has already been assigned to this questionnaire - * - * @param int $operator_id Operator id - * @param int $questionnaire_id Questionnaire id - * @return int 1 if assigned otherwise 0 - * - */ -function vq($operator_id,$questionnaire_id) -{ - global $db; - - $sql = "SELECT operator_id,questionnaire_id - FROM operator_questionnaire - WHERE operator_id = '$operator_id' and questionnaire_id = '$questionnaire_id'"; - - $vq = $db->Execute($sql); - - if ($vq) - return $vq->RecordCount(); - else - return 0; -} - -/** - * Assign an operator to a questionnaire - * - * @param int $operator_id Operator id - * @param int $questionnaire_id Questionnaire id - * - */ -function vqi($operator_id,$questionnaire_id) -{ - global $db; - - $sql = "INSERT INTO - operator_questionnaire (operator_id,questionnaire_id) - VALUES('$operator_id','$questionnaire_id')"; - - $db->Execute($sql); -} - - -/** - * Unassign an operator from a questionnaire - * - * @param int $operator_id Operator id - * @param int $questionnaire_id Questionnaire id - * - */ -function vqd($operator_id,$questionnaire_id) -{ - global $db; - - $sql = "DELETE FROM - operator_questionnaire - WHERE operator_id = '$operator_id' and questionnaire_id = '$questionnaire_id'"; - - $db->Execute($sql); -} - - - - -if (isset($_POST['submit'])) -{ - $db->StartTrans(); - - $sql = "DELETE - FROM operator_questionnaire - WHERE questionnaire_id IN ( - SELECT questionnaire_id - FROM questionnaire - WHERE enabled = 1) - AND operator_id IN ( - SELECT operator_id - FROM operator - WHERE enabled = 1)"; - - $db->Execute($sql); - - foreach ($_POST as $g => $v) - { - $a = explode("_",$g); - if ($a[0] == "cb") - vqi($a[2],$a[1]); - } - - $db->CompleteTrans(); -} - - - -$sql = "SELECT questionnaire_id,description - FROM questionnaire - WHERE enabled = 1 - ORDER by questionnaire_id DESC"; - -$questionnaires = $db->GetAll($sql); - -$sql = "SELECT operator_id,firstname as description - FROM operator - WHERE enabled = 1 - ORDER by operator_id ASC"; - -$operators = $db->GetAll($sql); - - -xhtml_head(T_("Assign operators to questionnaires"),false,array("../css/table.css")); - -?> - - - - - - -"; - -print ""; -foreach($questionnaires as $q) -{ - print ""; -} -print ""; - -$class = 0; - -foreach($operators as $v) -{ - print ""; - print ""; - foreach($questionnaires as $q) - { - $checked = ""; - if (vq($v['operator_id'],$q['questionnaire_id'])) $checked="checked=\"checked\""; - print ""; - } - - print ""; -} - - -print "
{$q['description']}
{$v['description']}

"; - - -xhtml_foot(); - -?> - - - + + * @copyright Deakin University 2007,2008 + * @package queXS + * @subpackage admin + * @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 ("../config.inc.php"); + +/** + * Database file + */ +include ("../db.inc.php"); + +/** + * XHTML functions + */ +include ("../functions/functions.xhtml.php"); + +/** + * Return if an operator has already been assigned to this questionnaire + * + * @param int $operator_id Operator id + * @param int $questionnaire_id Questionnaire id + * @return int 1 if assigned otherwise 0 + * + */ +function vq($operator_id,$questionnaire_id) +{ + global $db; + + $sql = "SELECT operator_id,questionnaire_id + FROM operator_questionnaire + WHERE operator_id = '$operator_id' and questionnaire_id = '$questionnaire_id'"; + + $vq = $db->Execute($sql); + + if ($vq) + return $vq->RecordCount(); + else + return 0; +} + +/** + * Assign an operator to a questionnaire + * + * @param int $operator_id Operator id + * @param int $questionnaire_id Questionnaire id + * + */ +function vqi($operator_id,$questionnaire_id) +{ + global $db; + + $sql = "INSERT INTO + operator_questionnaire (operator_id,questionnaire_id) + VALUES('$operator_id','$questionnaire_id')"; + + $db->Execute($sql); +} + + +/** + * Unassign an operator from a questionnaire + * + * @param int $operator_id Operator id + * @param int $questionnaire_id Questionnaire id + * + */ +function vqd($operator_id,$questionnaire_id) +{ + global $db; + + $sql = "DELETE FROM + operator_questionnaire + WHERE operator_id = '$operator_id' and questionnaire_id = '$questionnaire_id'"; + + $db->Execute($sql); +} + + +if (isset($_POST['submit'])) +{ + $db->StartTrans(); + + $sql = "DELETE + FROM operator_questionnaire + WHERE questionnaire_id IN ( + SELECT questionnaire_id + FROM questionnaire + WHERE enabled = 1) + AND operator_id IN ( + SELECT operator_id + FROM operator + WHERE enabled = 1)"; + + $db->Execute($sql); + + foreach ($_POST as $g => $v) + { + $a = explode("_",$g); + if ($a[0] == "cb") + vqi($a[2],$a[1]); + } + + $db->CompleteTrans(); +} + + +$sql = "SELECT questionnaire_id,description + FROM questionnaire + WHERE enabled = 1 + ORDER by questionnaire_id DESC"; + +$questionnaires = $db->GetAll($sql); + +$sql = "SELECT operator_id, CONCAT(firstName,' ', lastName ) as opname, username + FROM operator + WHERE enabled = 1 + ORDER by operator_id ASC"; + +$operators = $db->GetAll($sql); + + +xhtml_head(T_("Assign operators to questionnaires"),true,array("../include/bootstrap-3.3.2/css/bootstrap.min.css","../include/iCheck/skins/square/blue.css","../css/custom.css"),array("../js/jquery-2.1.3.min.js","../include/iCheck/icheck.min.js")); + +?> + + + + + + + +"; + +print ""; +foreach($questionnaires as $q) +{ + print ""; +} +print ""; + + +foreach($operators as $v) +{ + + print " + + "; + foreach($questionnaires as $q) + { + $checked = ""; + if (vq($v['operator_id'],$q['questionnaire_id'])) $checked="checked=\"checked\""; + print ""; + } + + print ""; +} + + +print "
 " . T_("Username") . "  " . T_("Operator") . " {$q['description']}
 {$v['username']} {$v['opname']}
"; + + +xhtml_foot(); + +?> + + \ No newline at end of file diff --git a/admin/operators.php b/admin/operators.php index 9e7c1886..e8b8d854 100644 --- a/admin/operators.php +++ b/admin/operators.php @@ -1,232 +1,316 @@ - - * @copyright Deakin University 2007,2008 - * @package queXS - * @subpackage admin - * @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 ("../config.inc.php"); - -/** - * Database file - */ -include ("../db.inc.php"); - -/** - * XHTML functions - */ -include ("../functions/functions.xhtml.php"); - - -global $db; - -$a = false; - -if (isset($_POST['operator'])) -{ - $operator = $db->qstr($_POST['operator'],get_magic_quotes_gpc()); - $firstname = $db->qstr($_POST['firstname'],get_magic_quotes_gpc()); - $lastname = $db->qstr($_POST['lastname'],get_magic_quotes_gpc()); - $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 = ""; - if (FREEPBX_PATH != false) - { - //Generate new extension from last one in database and random password - $sql = "SELECT SUBSTRING_INDEX(extension, '/', -1) as ext - FROM extension - ORDER BY ext DESC - LIMIT 1"; - - $laste = $db->GetRow($sql); - - $extensionn = "1000"; - $extension = "'IAX2/1000'"; - - //increment if exists - if (!empty($laste)) - { - $extensionn = $laste['ext'] + 1; - $extension = "'IAX2/$extensionn'"; - } - - //generate random 8 length password - $extensionnp = ""; - $length = 12; - $chars = "abcdefghijklmnopqrstuvwxyz0123456789"; - for ($i = 0; $i < $length; $i++) - $extensionnp .= $chars[(rand() % strlen($chars))]; - - //quote for SQL - $extensionp = "'$extensionnp'"; - - } - $supervisor = 0; - $temporary = 0; - $refusal = 0; - $voip = 0; - $chat = 0; - if (isset($_POST['supervisor']) && $_POST['supervisor'] == "on") $supervisor = 1; - if (isset($_POST['refusal']) && $_POST['refusal'] == "on") $refusal = 1; - if (isset($_POST['temporary']) && $_POST['temporary'] == "on") $temporary = 1; - if (isset($_POST['voip']) && $_POST['voip'] == "on") $voip = 1; - if (isset($_POST['chat_enable']) && $_POST['chat_enable'] == "on") $chat = 1; - - if (!empty($_POST['operator'])) - { - $sql = "INSERT INTO operator - (`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`,`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) - { - //Get password and add it to the configured htpassword - include_once("../functions/functions.htpasswd.php"); - $htp = New Htpasswd(HTPASSWD_PATH); - $htg = New Htgroup(HTGROUP_PATH); - - $htp->addUser($_POST['operator'],$_POST['password']); - $htg->addUserToGroup($_POST['operator'],HTGROUP_INTERVIEWER); - - if ($supervisor) - $htg->addUserGroup(HTGROUP_ADMIN); - } - - $a = T_("Added:") . " " . $operator; - - if (FREEPBX_PATH !== false) - $a .= "
" . T_("FreePBX has been reloaded for the new VoIP extension to take effect"); - - - if ($temporary) - { - $db->Execute(" INSERT INTO operator_skill (operator_id,outcome_type_id) - VALUES ('$oid','1')"); - $db->Execute(" INSERT INTO operator_skill (operator_id,outcome_type_id) - VALUES ('$oid','5')"); //and appointment - } - - if ($supervisor) - $db->Execute(" INSERT INTO operator_skill (operator_id,outcome_type_id) - VALUES ('$oid','2')"); - - if ($refusal) - $db->Execute(" INSERT INTO operator_skill (operator_id,outcome_type_id) - VALUES ('$oid','3')"); - - - - } - else - { - $a = T_("Could not add operator. There may already be an operator of this name:") . " $operator "; - } - - - } -} - - -xhtml_head(T_("Add an operator")); - -if ($a) -{ -?> -

-GetAll($sql); - -$sql = "SELECT extension_id as value, extension as description - FROM extension - WHERE current_operator_id IS NULL"; - -$ers = $db->GetAll($sql); - -?> -

-

.

-

-

-
-

- -

- -

-

-

"; display_chooser($rs,"Time_zone_name","Time_zone_name",false,false,false,false,array("value",get_setting("DEFAULT_TIME_ZONE"))); ?>

- -

"; display_chooser($ers,"extension_id","extension_id",true,false,false,false); ?>

- -

-

:

-

:

-

-

-

-

-

" />

- - - + + * @copyright Deakin University 2007,2008 + * @package queXS + * @subpackage admin + * @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 ("../config.inc.php"); + +/** + * Database file + */ +include ("../db.inc.php"); + +/** + * XHTML functions + */ +include ("../functions/functions.xhtml.php"); + + +global $db; + +$a = false; + +if (isset($_POST['operator']) && isset($_POST['adduser'])) +{ + $operator = $db->qstr($_POST['operator'],get_magic_quotes_gpc()); + $firstname = $db->qstr($_POST['firstname'],get_magic_quotes_gpc()); + $lastname = $db->qstr($_POST['lastname'],get_magic_quotes_gpc()); + $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 = ""; + if (FREEPBX_PATH != false) + { + //Generate new extension from last one in database and random password + $sql = "SELECT SUBSTRING_INDEX(extension, '/', -1) as ext + FROM extension + ORDER BY ext DESC + LIMIT 1"; + + $laste = $db->GetRow($sql); + + $extensionn = "2000"; + $extension = "'IAX2/2000'"; + + //increment if exists + if (!empty($laste)) + { + $extensionn = $laste['ext'] + 1; + $extension = "'IAX2/$extensionn'"; + } + + //generate random 8 length password + $extensionnp = ""; + $length = 25; + $chars = "abcdefghijklmnopqrstuvwxyz0123456789"; + for ($i = 0; $i < $length; $i++) + $extensionnp .= $chars[(mt_rand() % strlen($chars))]; + + //quote for SQL + $extensionp = "'$extensionnp'"; + + } + $supervisor = 0; + $temporary = 0; + $refusal = 0; + $voip = 0; + $chat = 0; + if (isset($_POST['supervisor']) && $_POST['supervisor'] == "on") $supervisor = 1; + if (isset($_POST['refusal']) && $_POST['refusal'] == "on") $refusal = 1; + if (isset($_POST['temporary']) && $_POST['temporary'] == "on") $temporary = 1; + if (isset($_POST['voip']) && $_POST['voip'] == "on") $voip = 1; + if (isset($_POST['chat_enable']) && $_POST['chat_enable'] == "on") $chat = 1; + + if (!empty($_POST['operator'])) + { + $sql = "INSERT INTO operator + (`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`,`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) + { + //Get password and add it to the configured htpassword + include_once("../functions/functions.htpasswd.php"); + $htp = New Htpasswd(HTPASSWD_PATH); + $htg = New Htgroup(HTGROUP_PATH); + + $htp->addUser($_POST['operator'],$_POST['password']); + $htg->addUserToGroup($_POST['operator'],HTGROUP_INTERVIEWER); + + if ($supervisor) + $htg->addUserGroup(HTGROUP_ADMIN); + } + + $a = "

" . T_("Added operator :") . " " . $operator . "

"; + + if (FREEPBX_PATH !== false) + $a .= "
" . T_("FreePBX has been reloaded for the new VoIP extension to take effect"); + + print "
"; + + if ($temporary) + { + $db->Execute(" INSERT INTO operator_skill (operator_id,outcome_type_id) + VALUES ('$oid','1')"); + $db->Execute(" INSERT INTO operator_skill (operator_id,outcome_type_id) + VALUES ('$oid','5')"); //and appointment + } + + if ($supervisor) + $db->Execute(" INSERT INTO operator_skill (operator_id,outcome_type_id) + VALUES ('$oid','2')"); + + if ($refusal) + $db->Execute(" INSERT INTO operator_skill (operator_id,outcome_type_id) + VALUES ('$oid','3')"); + } + else + { + $a = T_("Could not add operator. There may already be an operator of this name:") . " $operator "; + } + } +} + + +xhtml_head(T_("Add an operator"),true,array("../include/bootstrap-3.3.2/css/bootstrap.min.css","../include/bootstrap-toggle/css/bootstrap-toggle.min.css", "../css/custom.css"), array("../js/jquery-2.1.3.min.js", "../include/bootstrap-3.3.2/js/bootstrap.min.js","../include/bootstrap-toggle/js/bootstrap-toggle.min.js")); + +if ($a) { + echo $a; +} +else { + echo "
"; + //echo "

" . T_("Adding an operator here will give the user the ability to call cases") . "" . T_("Assign Operator to Questionnaire") . "" . T_("tool") . ".

"; + echo "

" . T_("Use this form to enter the username of a user based on your directory security system. For example, if you have secured the base directory of queXS using Apache file based security, enter the usernames of the users here.") . "

"; + echo "

" . T_("The username and extension must be unique for each operator.") . "

"; + echo "
"; +} + +$sql = "SELECT Time_zone_name as value, Time_zone_name as description + FROM timezone_template"; + +$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); +?> + + + +
+
+ +
+
+ +
+ +
+
  + " class="btn btn-default fa" />   + +
+
+ +
+ +
+
+
+ +
+
+
+ +
+
+ + +
+
+ +
+ +
+
+ + +
+
+ + +
+ +
" data-off="" checked="checked"/>
+
+
+ +
+
+
+ +
+
+
+ +
" data-off="" />
+
+
+ +
" data-off="" data-offstyle="danger" checked="checked"/>
+
+
+ +
" data-off="" data-onstyle="danger" data-offstyle="primary"/>
+
+
+ +
" data-off="" data-onstyle="danger" data-offstyle="primary"/>
+
+ +
" />
+
+ + \ No newline at end of file diff --git a/admin/operatorskill.php b/admin/operatorskill.php index 2ce676a2..10dfa6fc 100644 --- a/admin/operatorskill.php +++ b/admin/operatorskill.php @@ -1,280 +1,279 @@ - - * @copyright Deakin University 2007,2008 - * @package queXS - * @subpackage admin - * @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 ("../config.inc.php"); - -/** - * Database file - */ -include ("../db.inc.php"); - -/** - * XHTML functions - */ -include ("../functions/functions.xhtml.php"); - -/** - * Determine if an operator has been assigned to a skill (outcome_type) - * - * @param int $operator_id Operator id - * @param int $outcome_type_id Outcome type id (skill) - * @return int 1 if assigned to that skill otherwise 0 - * - */ -function vq($operator_id,$outcome_type_id) -{ - global $db; - - $sql = "SELECT operator_id,outcome_type_id - FROM operator_skill - WHERE operator_id = '$operator_id' and outcome_type_id = '$outcome_type_id'"; - - $vq = $db->Execute($sql); - - if ($vq) - return $vq->RecordCount(); - else - return 0; -} - -/** - * Assign an operator to a skill (outcome_type) - * - * @param int $operator_id Operator id - * @param int $outcome_type_id Outcome type id (skill) - * - */ -function vqi($operator_id,$outcome_type_id) -{ - global $db; - - $sql = "INSERT INTO - operator_skill (operator_id,outcome_type_id) - VALUES('$operator_id','$outcome_type_id')"; - - $db->Execute($sql); -} - -/** - * Delete a skill (outcome_type) from an operator - * - * @param int $operator_id Operator id - * @param int $outcome_type_id Outcome type id (skill) - * - */ -function vqd($operator_id,$outcome_type_id) -{ - global $db; - - $sql = "DELETE FROM - operator_skill - WHERE operator_id = '$operator_id' and outcome_type_id = '$outcome_type_id'"; - - $db->Execute($sql); -} - - - - -if (isset($_POST['submit'])) -{ - $db->StartTrans(); - - $sql = "DELETE - FROM operator_skill - WHERE operator_id IN ( - SELECT operator_id - FROM operator - WHERE enabled = 1)"; - - $db->Execute($sql); - - foreach ($_POST as $g => $v) - { - $a = explode("_",$g); - if ($a[0] == "cb") - vqi($a[2],$a[1]); - } - - $db->CompleteTrans(); -} - - - -$sql = "SELECT outcome_type_id,description - FROM outcome_type - ORDER by outcome_type_id ASC"; - -$outcome_types = $db->GetAll($sql); - -$sql = "SELECT operator_id,firstname as description - FROM operator - WHERE enabled = 1 - ORDER by operator_id ASC"; - -$operators = $db->GetAll($sql); - - -xhtml_head(T_("Assign operators to Skills"),false,array("../css/table.css")); - -print "

" . T_("Set which types of cases will be made available to each operator. Please note that all operators will be allowed to assign all possible outcomes to a case. This restricts which ones will be assigned to an operator.") . "

"; - -?> - - - - - - -"; - -print ""; -foreach($outcome_types as $q) -{ - print ""; -} -print ""; - -$ct = 1; - -foreach($operators as $v) -{ - print ""; - print ""; - foreach($outcome_types as $q) - { - $checked = ""; - if (vq($v['operator_id'],$q['outcome_type_id'])) $checked="checked=\"checked\""; - print ""; - } - - print ""; -} - - -print "
" . T_($q['description']) . "
{$v['description']}

"; - - -xhtml_foot(); - -?> - - - + + * @copyright Deakin University 2007,2008 + * @package queXS + * @subpackage admin + * @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 ("../config.inc.php"); + +/** + * Database file + */ +include ("../db.inc.php"); + +/** + * XHTML functions + */ +include ("../functions/functions.xhtml.php"); + +/** + * Determine if an operator has been assigned to a skill (outcome_type) + * + * @param int $operator_id Operator id + * @param int $outcome_type_id Outcome type id (skill) + * @return int 1 if assigned to that skill otherwise 0 + * + */ +function vq($operator_id,$outcome_type_id) +{ + global $db; + + $sql = "SELECT operator_id,outcome_type_id + FROM operator_skill + WHERE operator_id = '$operator_id' and outcome_type_id = '$outcome_type_id'"; + + $vq = $db->Execute($sql); + + if ($vq) + return $vq->RecordCount(); + else + return 0; +} + +/** + * Assign an operator to a skill (outcome_type) + * + * @param int $operator_id Operator id + * @param int $outcome_type_id Outcome type id (skill) + * + */ +function vqi($operator_id,$outcome_type_id) +{ + global $db; + + $sql = "INSERT INTO + operator_skill (operator_id,outcome_type_id) + VALUES('$operator_id','$outcome_type_id')"; + + $db->Execute($sql); +} + +/** + * Delete a skill (outcome_type) from an operator + * + * @param int $operator_id Operator id + * @param int $outcome_type_id Outcome type id (skill) + * + */ +function vqd($operator_id,$outcome_type_id) +{ + global $db; + + $sql = "DELETE FROM + operator_skill + WHERE operator_id = '$operator_id' and outcome_type_id = '$outcome_type_id'"; + + $db->Execute($sql); +} + + +if (isset($_POST['submit'])) +{ + $db->StartTrans(); + + $sql = "DELETE + FROM operator_skill + WHERE operator_id IN ( + SELECT operator_id + FROM operator + WHERE enabled = 1)"; + + $db->Execute($sql); + + foreach ($_POST as $g => $v) + { + $a = explode("_",$g); + if ($a[0] == "cb") + vqi($a[2],$a[1]); + } + + $db->CompleteTrans(); +} + + + +$sql = "SELECT outcome_type_id,description + FROM outcome_type + ORDER by outcome_type_id ASC"; + +$outcome_types = $db->GetAll($sql); + +$sql = "SELECT operator_id, CONCAT(firstName,' ', lastName) as description, username + FROM operator + WHERE enabled = 1 + ORDER by operator_id ASC"; + +$operators = $db->GetAll($sql); + + +xhtml_head(T_("Assign operators to Skills"),true,array("../include/bootstrap-3.3.2/css/bootstrap.min.css","../include/iCheck/skins/square/blue.css","../css/custom.css"),array("../js/jquery-2.1.3.min.js","../include/iCheck/icheck.min.js")); + +print "
" . T_("Set which types of cases will be made available to each operator.
Please note that all operators will be allowed to assign all possible outcomes to a case. This restricts which ones will be assigned to an operator.") . "
"; + + +?> + + + + + +"; + +print ""; +foreach($outcome_types as $q) +{ + print ""; +} +print ""; + + +foreach($operators as $v) +{ + print " + + "; + foreach($outcome_types as $q) + { + $checked = ""; + if (vq($v['operator_id'],$q['outcome_type_id'])) $checked="checked=\"checked\""; + print ""; + } + + print ""; +} + + +print "
 " . T_("Username") . "  " . T_("Operator") . " " . T_($q['description']) . "
 {$v['username']} {$v['description']}
"; + +xhtml_foot(); + +?> + + \ No newline at end of file diff --git a/functions/functions.performance.php b/functions/functions.performance.php index 12bb062a..26d2e55d 100644 --- a/functions/functions.performance.php +++ b/functions/functions.performance.php @@ -223,7 +223,7 @@ function get_stats_total($rs) $callsph = round($calls/($totaltime/3600),4); } - $rs[] = array("effectiveness" => $effectiveness, "completions" => $completions,"time" => sec_to_time($totaltime),"totalcalls" => $calls,"callt" => sec_to_time($calltime),"CPH" => $cph,"CALLSPH" => $callsph); + $rs[] = array("effectiveness" => '' . $effectiveness . '', "completions" => '' .$completions. '',"time" => '' . sec_to_time($totaltime). '',"totalcalls" => '' . $calls. '',"callt" => '' . sec_to_time($calltime). '',"CPH" => '' . $cph. '',"CALLSPH" => '' . $callsph. ''); return $rs; }