Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
119 changes: 62 additions & 57 deletions functions.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,69 +2,74 @@
if (!defined('FREEPBX_IS_AUTH')) { die('No direct script access allowed'); }

function queuemetrics_hookGet_config($engine) {
global $ext;
global $db;

switch($engine) {
case "asterisk":

$ivr_logging = queuemetrics_get_details('ivr_logging');
if ($ivr_logging['value'] == 'true') {

//get all ivrs
$ivrlist = ivr_get_details();
if(is_array($ivrlist)) {

foreach($ivrlist as $item) {
//splice into ivr to set the ivr selection var and append if already defined
$context = 'ivr-'.$item['id'];

//get ivr selection
$ivrentrieslist = ivr_get_entries($item['id']);
if (is_array($ivrentrieslist)) {

foreach($ivrentrieslist as $selection) {
//splice into ivr selection
$ext->splice($context, $selection['selection'], 'ivrsel-'.$selection['selection'], new ext_setvar("IVRSELECTION", '${EXTEN}|${IVR_CONTEXT}'));
$ext->splice($context, $selection['selection'], 'ivrsel-'.$selection['selection'], new ext_queuelog('NONE','${UNIQUEID}','NONE','INFO', 'IVRAPPEND|${IVRSELECTION}'));
}
}
}
}
}
break;
}
global $ext;
global $db;

switch($engine) {
case "asterisk":

$ivr_logging = queuemetrics_get_details('ivr_logging');
if ($ivr_logging['value'] == 'true') {

//get all ivrs
$ivrlist = ivr_get_details();
if(is_array($ivrlist)) {

foreach($ivrlist as $item) {
//splice into ivr to set the ivr selection var and append if already defined
$context = 'ivr-'.$item['id'];

//get ivr selection
$ivrentrieslist = ivr_get_entries($item['id']);
if (is_array($ivrentrieslist)) {

foreach($ivrentrieslist as $selection) {
//splice into ivr selection
$ext->splice($context, $selection['selection'], 'ivrsel-'.$selection['selection'], new ext_setvar("IVRSELECTION", '${EXTEN}|'.$context.'|'.$item['name']));
$ext->splice($context, $selection['selection'], 'ivrsel-'.$selection['selection'], new ext_queuelog('NONE','${UNIQUEID}','NONE','INFO', 'IVRAPPEND|${IVRSELECTION}'));
}
$ext->splice($context, 'i','final', new ext_setvar("IVRSELECTION", 'i|'.$context.'|'.$item['name']));
$ext->splice($context, 'i','final', new ext_queuelog('NONE','${UNIQUEID}','NONE','INFO', 'IVRAPPEND|${IVRSELECTION}'));
$ext->splice($context, 't','final', new ext_setvar("IVRSELECTION", 't|'.$context.'|'.$item['name']));
$ext->splice($context, 't','final', new ext_queuelog('NONE','${UNIQUEID}','NONE','INFO', 'IVRAPPEND|${IVRSELECTION}'));

}
}
}
}
break;
}
}

function queuemetrics_configpageinit($pagename) {
global $currentcomponent;

$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : '';
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : '';
$id = isset($_REQUEST['id']) ? $_REQUEST['id'] : '';

if($pagename == 'queuemetrics'){
$currentcomponent->addprocessfunc('queuemetrics_configprocess');

return true;
return true;
}
}

//process received arguments
function queuemetrics_configprocess(){
if (isset($_REQUEST['display']) && $_REQUEST['display'] == 'queuemetrics'){
//get variables
$get_var = array('ivr_logging');
foreach($get_var as $var){

//get variables
$get_var = array('ivr_logging');

foreach($get_var as $var){
$vars[$var] = isset($_REQUEST[$var]) ? $_REQUEST[$var] : '';
}

$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : '';

switch ($action) {
case 'save':
queuemetrics_put_details($vars);
queuemetrics_put_details($vars);
needreload();
redirect_standard_continue();
break;
Expand All @@ -73,35 +78,35 @@ function queuemetrics_configprocess(){
}

function queuemetrics_put_details($options) {
global $db;
foreach ($options as $key => $item) {
$data[] = array($key, $item);
}
global $db;

foreach ($options as $key => $item) {
$data[] = array($key, $item);
}

$sql = $db->prepare('REPLACE INTO queuemetrics_options (`keyword`, `value`) VALUES (?, ?)');
$sql = $db->prepare('REPLACE INTO queuemetrics_options (`keyword`, `value`) VALUES (?, ?)');
$ret = $db->executeMultiple($sql, $data);
if($db->IsError($ret)) {
die_freepbx($ret->getDebugInfo()."\n".$ret->getUserInfo()."\n".$db->last_query);

if($db->IsError($ret)) {
die_freepbx($ret->getDebugInfo()."\n".$ret->getUserInfo()."\n".$db->last_query);
}
return TRUE;
return TRUE;
}

function queuemetrics_get_details($keyword = '') {
global $db;
global $db;

$sql = "SELECT * FROM queuemetrics_options";

if (!empty($keyword)) {
$sql .= " WHERE `keyword` = '" . $keyword . "'";
}
if (!empty($keyword)) {
$sql .= " WHERE `keyword` = '" . $keyword . "'";
}

$res = $db->getAll($sql, DB_FETCHMODE_ASSOC);
$res = $db->getAll($sql, DB_FETCHMODE_ASSOC);
if($db->IsError($res)) {
die_freepbx($res->getDebugInfo());
}

return (isset($keyword) && $keyword != '') ? $res[0] : $res;
return (isset($keyword) && $keyword != '') ? $res[0] : $res;
}
?>
30 changes: 15 additions & 15 deletions install.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,24 @@
$sql = "SELECT * FROM `queuemetrics_options` LIMIT 1";
$check = $db->query($sql);
if(!DB::IsError($check)) {
out(_("queuemetrics table already exists, exiting"));
out(_("queuemetrics table already exists, exiting"));
} else {

unset($sql);
$sql[] = "CREATE TABLE IF NOT EXISTS `queuemetrics_options` (
`keyword` VARCHAR(25),
`value` TEXT,
UNIQUE KEY `keyword` (`keyword`)
)";
foreach ($sql as $q) {
$result = $db->query($q);
if($db->IsError($result)){
die_freepbx($result->getDebugInfo());
}
}
unset($sql);
$sql[] = "CREATE TABLE IF NOT EXISTS `queuemetrics_options` (
`keyword` VARCHAR(25),
`value` TEXT,
UNIQUE KEY `keyword` (`keyword`)
)";
foreach ($sql as $q) {
$result = $db->query($q);
if($db->IsError($result)){
die_freepbx($result->getDebugInfo());
}
}

outn(_("creating queuemetrics...ok"));
outn(_("creating queuemetrics...ok"));
}

// sysadmin migration
Expand Down
12 changes: 6 additions & 6 deletions page.queuemetrics.php
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
<?php
<?php
if (!defined('FREEPBX_IS_AUTH')) { die('No direct script access allowed'); }

$settings = queuemetrics_get_details();

foreach ($settings as $key => $val) {
$var[$val['keyword']] = isset($_REQUEST[$val['keyword']]) ? $_REQUEST[$val['keyword']] : $val['value'];
$$val['keyword'] = $var[$val['keyword']];
$var[$val['keyword']] = isset($_REQUEST[$val['keyword']]) ? $_REQUEST[$val['keyword']] : $val['value'];
$$val['keyword'] = $var[$val['keyword']];
}

$checked = (isset($ivr_logging) && $ivr_logging == 'true')?'CHECKED':'';

echo '<h2 id="title">QueueMetrics</h2>';
echo '<form action="' . $_SERVER['REQUEST_URI'] . '" method="post">';
echo '<input type="hidden" name="action" value="save">';
echo '<input type="hidden" name="action" value="save">';
echo '<br /><br />';

$table = new CI_Table();

$table->add_row( _('Settings'));
$table->add_row('<hr class="qmhr">');
$table->add_row('<a href="javascript:void(null)" class="info">Log IVR Selections <span style="left: -18px; display: none; ">' . _('When checked, IVR selections will be reported by QueueMetrics') . '</span></a>', '<input type="checkbox" name="ivr_logging" value="true" ' . $checked . '>');
$table->add_row('<a href="javascript:void(null)" class="info">Log IVR Selections <span style="left: -18px; display: none; ">' . _('When checked, IVR selections will be reported by QueueMetrics') . '</span></a>', '<input type="checkbox" name="ivr_logging" value="true" ' . $checked . '>');
$table->add_row('');
$table->add_row('');
$table->add_row('<input type="submit" name="' . _("Submit Changes"). '">');

echo $table->generate();
echo $table->generate();

echo '</form><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />';
2 changes: 1 addition & 1 deletion uninstall.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php
if (!defined('FREEPBX_IS_AUTH')) { die('No direct script access allowed'); }

global $db;
Expand Down