Call Centers: List view updates.

This commit is contained in:
Nate 2019-10-25 19:43:02 -06:00
parent 281ceccda2
commit 4b16c5943d
4 changed files with 721 additions and 265 deletions

View File

@ -27,6 +27,7 @@
require_once "root.php";
require_once "resources/require.php";
require_once "resources/check_auth.php";
require_once "resources/paging.php";
//check permissions
if (permission_exists('call_center_active_view')) {
@ -41,60 +42,72 @@
$language = new text;
$text = $language->get();
//includes and title
require_once "resources/header.php";
$document['title'] = $text['title-active_call_center'];
require_once "resources/paging.php";
//get the variables
$order_by = $_GET["order_by"];
$order = $_GET["order"];
//show the content
echo "<table width='100%' cellpadding='0' cellspacing='0' border='0'>\n";
echo "<tr>\n";
echo "<td width='50%' align=\"left\" nowrap=\"nowrap\"><b>".$text['header-active_call_center']."</b></td>\n";
echo "<td width='50%' align=\"right\">\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td align=\"left\" colspan='2'>\n";
echo $text['description-active_call_center']."<br /><br />\n";
echo "</td>\n";
echo "</tr>\n";
echo "</tr></table>\n";
//add the search term
$search = strtolower($_GET["search"]);
if (strlen($search) > 0) {
$sql_search = " (";
$sql_search .= "lower(queue_name) like :search ";
$sql_search .= "or lower(queue_description) like :search ";
$sql_search .= ") ";
$parameters['search'] = '%'.$search.'%';
}
//get the call center queue count
$sql = "select count(*) from v_call_center_queues ";
$sql .= "where domain_uuid = :domain_uuid ";
if (isset($sql_search)) {
$sql .= "and ".$sql_search;
}
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$database = new database;
$num_rows = $database->select($sql, $parameters, 'column');
//paging the records
$rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50;
$param = '';
$param = "&search=".$search;
$page = $_GET['page'];
if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; }
list($paging_controls, $rows_per_page, $var_3) = paging($num_rows, $param, $rows_per_page);
list($paging_controls, $rows_per_page) = paging($num_rows, $param, $rows_per_page);
list($paging_controls_mini, $rows_per_page) = paging($num_rows, $param, $rows_per_page, true);
$offset = $rows_per_page * $page;
//get the call center queues
$sql = "select * from v_call_center_queues ";
$sql .= "where domain_uuid = :domain_uuid ";
$sql = str_replace('count(*)', '*', $sql);
$sql .= order_by($order_by, $order);
$sql .= limit_offset($rows_per_page, $offset);
$database = new database;
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$call_center_queues = $database->select($sql, $parameters, 'all');
unset($sql, $parameters);
$c = 0;
$row_style["0"] = "row_style0";
$row_style["1"] = "row_style1";
//include header
$document['title'] = $text['title-active_call_center'];
require_once "resources/header.php";
echo "<table class='tr_hover' width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
//show the content
echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'><b>".$text['header-active_call_center']." (".$num_rows.")</b></div>\n";
echo " <div class='actions'>\n";
echo "<form id='form_search' class='inline' method='get'>\n";
echo "<input type='text' class='txt list-search' name='search' id='search' value=\"".escape($search)."\" placeholder=\"".$text['label-search']."\" onkeydown='list_search_reset();'>";
echo button::create(['label'=>$text['button-search'],'icon'=>$_SESSION['theme']['button_icon_search'],'type'=>'submit','id'=>'btn_search','style'=>($search != '' ? 'display: none;' : null)]);
echo button::create(['label'=>$text['button-reset'],'icon'=>$_SESSION['theme']['button_icon_reset'],'type'=>'button','id'=>'btn_reset','link'=>'call_center_queue.php','style'=>($search == '' ? 'display: none;' : null)]);
if ($paging_controls_mini != '') {
echo " <span style='margin-left: 15px;'>".$paging_controls_mini."</span>";
}
echo " </form>\n";
echo " </div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
echo "<tr>\n";
echo $text['description-active_call_center']."\n";
echo "<br /><br />\n";
echo "<table class='list'>\n";
echo "<tr class='list-header'>\n";
echo th_order_by('queue_name', $text['label-queue_name'], $order_by, $order);
echo th_order_by('queue_extension', $text['label-extension'], $order_by, $order);
echo th_order_by('queue_strategy', $text['label-strategy'], $order_by, $order);
@ -110,58 +123,37 @@
//echo th_order_by('queue_abandoned_resume_allowed', $text['label-abandoned_resume_allowed'], $order_by, $order);
//echo th_order_by('queue_tier_rule_wait_multiply_level', $text['label-tier_rule_wait_multiply_level'], $order_by, $order);
echo th_order_by('queue_description', $text['label-description'], $order_by, $order);
echo "<td class='list_control_icon'>\n";
//echo " <a href='call_center_queue_edit.php' alt='add'>$v_link_label_add</a>\n";
echo "</td>\n";
echo "</tr>\n";
if (is_array($call_center_queues)) {
$x = 0;
foreach($call_center_queues as $row) {
$tr_link = "href='".PROJECT_PATH."/app/call_center_active/call_center_active.php?queue_name=".escape($row['call_center_queue_uuid'])."&name=".urlencode(escape($row['queue_name']))."'";
echo "<tr ".$tr_link.">\n";
echo " <td valign='top' class='".$row_style[$c]."'><a href='".PROJECT_PATH."/app/call_center_active/call_center_active.php?queue_name=".escape($row['call_center_queue_uuid'])."&name=".urlencode(escape($row['queue_name']))."'>".escape($row['queue_name'])."</a></td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".escape($row['queue_extension'])."</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".escape($row['queue_strategy'])."</td>\n";
//echo " <td valign='top' class='".$row_style[$c]."'>".escape($row[queue_moh_sound])."</td>\n";
//echo " <td valign='top' class='".$row_style[$c]."'>".escape($row[queue_record_template])."</td>\n";
//echo " <td valign='top' class='".$row_style[$c]."'>".escape($row[queue_time_base_score])."</td>\n";
//echo " <td valign='top' class='".$row_style[$c]."'>".escape($row[queue_max_wait_time])."</td>\n";
//echo " <td valign='top' class='".$row_style[$c]."'>".escape($row[queue_max_wait_time_with_no_agent])."</td>\n";
//echo " <td valign='top' class='".$row_style[$c]."'>".escape($row[queue_tier_rules_apply])."</td>\n";
//echo " <td valign='top' class='".$row_style[$c]."'>".escape($row[queue_tier_rule_wait_second])."</td>\n";
//echo " <td valign='top' class='".$row_style[$c]."'>".escape($row[queue_tier_rule_no_agent_no_wait])."</td>\n";
//echo " <td valign='top' class='".$row_style[$c]."'>".escape($row[queue_discard_abandoned_after])."</td>\n";
//echo " <td valign='top' class='".$row_style[$c]."'>".escape($row[queue_abandoned_resume_allowed])."</td>\n";
//echo " <td valign='top' class='".$row_style[$c]."'>".escape($row[queue_tier_rule_wait_multiply_level])."</td>\n";
echo " <td valign='top' class='row_stylebg'>".escape($row['queue_description'])."&nbsp;</td>\n";
echo " <td class='list_control_icon'>\n";
echo " <a href='".PROJECT_PATH."/app/call_center_active/call_center_active.php?queue_name=".escape($row['call_center_queue_uuid'])."&name=".urlencode(escape($row['queue_name']))."' alt='".$text['button-view']."'>$v_link_label_view</a>\n";
//echo " <a href='call_center_queue_delete.php?id=".escape($row[call_center_queue_uuid])."' alt='delete' onclick=\"return confirm('Do you really want to delete this?')\">$v_link_label_delete</a>\n";
//echo " <input type='button' class='btn' name='' alt='edit' onclick=\"window.location='call_center_queue_edit.php?id=".escape($row[call_center_queue_uuid])."'\" value='e'>\n";
//echo " <input type='button' class='btn' name='' alt='delete' onclick=\"if (confirm('Are you sure you want to delete this?')) { window.location='call_center_queue_delete.php?id=".escape($row[call_center_queue_uuid])."' }\" value='x'>\n";
echo " </td>\n";
$list_row_url = PROJECT_PATH."/app/call_center_active/call_center_active.php?queue_name=".escape($row['call_center_queue_uuid'])."&name=".urlencode(escape($row['queue_name']));
echo "<tr class='list-row' href='".$list_row_url."'>\n";
echo " <td><a href='".$list_row_url."'>".escape($row['queue_name'])."</a></td>\n";
echo " <td>".escape($row['queue_extension'])."</td>\n";
echo " <td>".escape($row['queue_strategy'])."</td>\n";
//echo " <td>".escape($row[queue_moh_sound])."</td>\n";
//echo " <td>".escape($row[queue_record_template])."</td>\n";
//echo " <td>".escape($row[queue_time_base_score])."</td>\n";
//echo " <td>".escape($row[queue_max_wait_time])."</td>\n";
//echo " <td>".escape($row[queue_max_wait_time_with_no_agent])."</td>\n";
//echo " <td>".escape($row[queue_tier_rules_apply])."</td>\n";
//echo " <td>".escape($row[queue_tier_rule_wait_second])."</td>\n";
//echo " <td>".escape($row[queue_tier_rule_no_agent_no_wait])."</td>\n";
//echo " <td>".escape($row[queue_discard_abandoned_after])."</td>\n";
//echo " <td>".escape($row[queue_abandoned_resume_allowed])."</td>\n";
//echo " <td>".escape($row[queue_tier_rule_wait_multiply_level])."</td>\n";
echo " <td class='description overflow hide-xs'>".escape($row['queue_description'])."</td>\n";
echo "</tr>\n";
if ($c==0) { $c=1; } else { $c=0; }
} //end foreach
unset($sql, $result, $row_count);
} //end if results
$x++;
}
unset($call_center_queues);
}
echo "<tr>\n";
echo "<td colspan='17' align='left'>\n";
echo " <table width='100%' cellpadding='0' cellspacing='0'>\n";
echo " <tr>\n";
echo " <td width='33.3%' nowrap>&nbsp;</td>\n";
echo " <td width='33.3%' align='center' nowrap>$paging_controls</td>\n";
echo " <td width='33.3%' align='right'>\n";
//echo " <a href='call_center_queue_edit.php' alt='add'>$v_link_label_add</a>\n";
echo " </td>\n";
echo " </tr>\n";
echo "</table>\n";
echo "</td>\n";
echo "</tr>\n";
echo "</table>";
echo "<br><br>";
echo "<br />\n";
echo "<div align='center'>".$paging_controls."</div>\n";
//show the footer
require_once "resources/footer.php";

View File

@ -28,6 +28,7 @@
require_once "root.php";
require_once "resources/require.php";
require_once "resources/check_auth.php";
require_once "resources/paging.php";
//check permissions
if (permission_exists('call_center_agent_view')) {
@ -42,60 +43,127 @@
$language = new text;
$text = $language->get();
//includes and title
require_once "resources/header.php";
$document['title'] = $text['title-call_center_agents'];
require_once "resources/paging.php";
//get posted data
if (is_array($_POST['call_center_agents'])) {
$action = $_POST['action'];
$search = $_POST['search'];
$call_center_agents = $_POST['call_center_agents'];
}
//get http values and set them to php variables
$order_by = $_GET["order_by"] != '' ? $_GET["order_by"] : 'agent_name';
//copy the call center agents
if (permission_exists('call_center_agent_add')) {
if ($action == 'copy' && is_array($call_center_agents) && @sizeof($call_center_agents) != 0) {
//copy
$obj = new call_center;
$obj->copy_agents($call_center_agents);
//redirect
header('Location: call_center_agents.php'.($search != '' ? '?search='.urlencode($search) : null));
exit;
}
}
//delete the call center agents
if (permission_exists('call_center_agent_delete')) {
if ($action == 'delete' && is_array($call_center_agents) && @sizeof($call_center_agents) != 0) {
//delete
$obj = new call_center;
$obj->delete_agents($call_center_agents);
//redirect
header('Location: call_center_agents.php'.($search != '' ? '?search='.urlencode($search) : null));
exit;
}
}
//get http variables and set them to php variables
$order_by = $_GET["order_by"];
$order = $_GET["order"];
//show content
echo "<table width='100%' cellpadding='0' cellspacing='0' border='0'>\n";
echo "<tr>\n";
echo "<td width='50%' align='left' nowrap='nowrap'><b>".$text['header-call_center_agents']."</b></td>\n";
echo "<td width='50%' align='right'>\n";
echo " <input type='button' class='btn' name='' alt='".$text['button-back']."' onclick=\"window.location='call_center_queues.php'\" value='".$text['button-back']."'>\n";
echo " <input type='button' class='btn' name='' alt='".$text['button-status']."' onclick=\"window.location='call_center_agent_status.php'\" value='".$text['button-status']."'>\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td align='left' colspan='2'>\n";
echo $text['description-call_center_agents']."<br /><br />\n";
echo "</td>\n";
echo "</tr>\n";
echo "</tr></table>\n";
//add the search term
$search = strtolower($_GET["search"]);
if (strlen($search) > 0) {
$sql_search = " (";
$sql_search .= "lower(agent_name) like :search ";
$sql_search .= "or lower(agent_id) like :search ";
$sql_search .= ") ";
$parameters['search'] = '%'.$search.'%';
}
//get total call center agent count from the database
$sql = "select count(*) from v_call_center_agents ";
$sql .= "where domain_uuid = :domain_uuid ";
if (isset($sql_search)) {
$sql .= "and ".$sql_search;
}
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$database = new database;
$num_rows = $database->select($sql, $parameters, 'column');
unset($sql, $parameters);
//prepare to page the results
$rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50;
$param = "";
$param = "&search=".$search;
$page = $_GET['page'];
if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; }
list($paging_controls, $rows_per_page, $var_3) = paging($num_rows, $param, $rows_per_page);
list($paging_controls, $rows_per_page) = paging($num_rows, $param, $rows_per_page);
list($paging_controls_mini, $rows_per_page) = paging($num_rows, $param, $rows_per_page, true);
$offset = $rows_per_page * $page;
$sql = "select * from v_call_center_agents ";
$sql .= "where domain_uuid = :domain_uuid ";
$sql .= order_by($order_by, $order);
//get the list
$sql = str_replace('count(*)', '*', $sql);
$sql .= order_by($order_by, $order, 'agent_name', 'asc');
$sql .= limit_offset($rows_per_page, $offset);
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$database = new database;
$result = $database->select($sql, $parameters, 'all');
unset($sql, $parameters);
$c = 0;
$row_style["0"] = "row_style0";
$row_style["1"] = "row_style1";
//create token
$object = new token;
$token = $object->create($_SERVER['PHP_SELF']);
echo "<table class='tr_hover' width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n";
//includes and title
$document['title'] = $text['title-call_center_agents'];
require_once "resources/header.php";
//show content
echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'><b>".$text['header-call_center_agents']." (".$num_rows.")</b></div>\n";
echo " <div class='actions'>\n";
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'link'=>'call_center_queues.php','style'=>'margin-right: 15px;']);
if (permission_exists('call_center_agent_add')) {
echo button::create(['type'=>'button','label'=>$text['button-add'],'icon'=>$_SESSION['theme']['button_icon_add'],'link'=>'call_center_agent_edit.php']);
}
if (permission_exists('call_center_agent_add') && $result) {
echo button::create(['type'=>'button','label'=>$text['button-copy'],'icon'=>$_SESSION['theme']['button_icon_copy'],'onclick'=>"if (confirm('".$text['confirm-copy']."')) { list_action_set('copy'); list_form_submit('form_list'); } else { this.blur(); return false; }"]);
}
if (permission_exists('call_center_agent_delete') && $result) {
echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'onclick'=>"if (confirm('".$text['confirm-delete']."')) { list_action_set('delete'); list_form_submit('form_list'); } else { this.blur(); return false; }"]);
}
echo "<form id='form_search' class='inline' method='get'>";
echo "<input type='text' class='txt list-search' name='search' id='search' value=\"".escape($search)."\" placeholder=\"".$text['label-search']."\" onkeydown='list_search_reset();'>";
echo button::create(['label'=>$text['button-search'],'icon'=>$_SESSION['theme']['button_icon_search'],'type'=>'submit','id'=>'btn_search','style'=>($search != '' ? 'display: none;' : null)]);
echo button::create(['label'=>$text['button-reset'],'icon'=>$_SESSION['theme']['button_icon_reset'],'type'=>'button','id'=>'btn_reset','link'=>'call_center_agents.php','style'=>($search == '' ? 'display: none;' : null)]);
if ($paging_controls_mini != '') {
echo " <span style='margin-left: 15px;'>".$paging_controls_mini."</span>";
}
echo button::create(['type'=>'button','label'=>$text['button-status'],'icon'=>'user-clock','style'=>'margin-left: 15px;','link'=>'call_center_agent_status.php']);
echo " </form>\n";
echo " </div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
echo $text['description-call_center_agents']."\n";
echo "<br /><br />\n";
echo "<form id='form_list' method='post'>\n";
echo "<input type='hidden' id='action' name='action' value=''>\n";
echo "<input type='hidden' name='search' value=\"".escape($search)."\">\n";
echo "<table class='list'>\n";
echo "<tr class='list-header'>\n";
if (permission_exists('call_center_agent_add') || permission_exists('call_center_agent_delete')) {
echo " <th class='checkbox'>\n";
echo " <input type='checkbox' id='checkbox_all' name='checkbox_all' onclick='list_all_toggle();' ".($result ?: "style='visibility: hidden;'").">\n";
echo " </th>\n";
}
//echo th_order_by('domain_uuid', 'domain_uuid', $order_by, $order);
echo th_order_by('agent_name', $text['label-agent_name'], $order_by, $order);
echo th_order_by('agent_id', $text['label-agent_id'], $order_by, $order);
@ -107,19 +175,25 @@
//echo th_order_by('agent_wrap_up_time', $text['label-wrap_up_time'], $order_by, $order);
//echo th_order_by('agent_reject_delay_time', $text['label-reject_delay_time'], $order_by, $order);
//echo th_order_by('agent_busy_delay_time', $text['label-busy_delay_time'], $order_by, $order);
echo "<td class='list_control_icons'>";
if (permission_exists('call_center_agent_add')) {
echo "<a href='call_center_agent_edit.php' alt='".$text['button-add']."'>".$v_link_label_add."</a>";
if (permission_exists('call_center_agent_edit') && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') {
echo " <td class='action-button'>&nbsp;</td>\n";
}
echo "</td>\n";
echo "</tr>\n";
if (is_array($result)) {
$x = 0;
foreach($result as $row) {
$tr_link = (permission_exists('call_center_agent_edit')) ? "href='call_center_agent_edit.php?id=".escape($row['call_center_agent_uuid'])."'" : null;
echo "<tr ".$tr_link.">\n";
//echo " <td valign='top' class='".$row_style[$c]."'>".escape($row[domain_uuid])."</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>";
if (permission_exists('call_center_agent_edit')) {
$list_row_url = "call_center_agent_edit.php?id=".urlencode($row['call_center_agent_uuid']);
}
echo "<tr class='list-row' href='".$list_row_url."'>\n";
if (permission_exists('call_center_agent_add') || permission_exists('call_center_agent_delete')) {
echo " <td class='checkbox'>\n";
echo " <input type='checkbox' name='call_center_agents[$x][checked]' id='checkbox_".$x."' value='true' onclick=\"if (!this.checked) { document.getElementById('checkbox_all').checked = false; }\">\n";
echo " <input type='hidden' name='call_center_agents[$x][uuid]' value='".escape($row['call_center_agent_uuid'])."' />\n";
echo " </td>\n";
}
echo " <td>";
if (permission_exists('call_center_agent_edit')) {
echo "<a href='call_center_agent_edit.php?id=".escape($row['call_center_agent_uuid'])."'>".escape($row['agent_name'])."</a>";
}
@ -127,9 +201,9 @@
echo escape($row['agent_name']);
}
echo " </td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".escape($row['agent_id'])."&nbsp;</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".escape($row['agent_type'])."&nbsp;</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".escape($row['agent_call_timeout'])."&nbsp;</td>\n";
echo " <td>".escape($row['agent_id'])."</td>\n";
echo " <td>".escape($row['agent_type'])."</td>\n";
echo " <td>".escape($row['agent_call_timeout'])."</td>\n";
$agent_contact = $row['agent_contact'];
// parse out gateway uuid
$bridge_statement = explode('/', $row['agent_contact']);
@ -146,46 +220,30 @@
}
unset($sql, $parameters, $bridge_statement);
}
echo " <td valign='top' class='".$row_style[$c]."'>".$agent_contact."&nbsp;</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".escape($row['agent_max_no_answer'])."&nbsp;</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".escape($row['agent_status'])."&nbsp;</td>\n";
//echo " <td valign='top' class='".$row_style[$c]."'>".$row[agent_wrap_up_time]."&nbsp;</td>\n";
//echo " <td valign='top' class='".$row_style[$c]."'>".$row[agent_reject_delay_time]."&nbsp;</td>\n";
//echo " <td valign='top' class='".$row_style[$c]."'>".$row[agent_busy_delay_time]."&nbsp;</td>\n";
echo " <td class='list_control_icons'>\n";
if (permission_exists('call_center_agent_edit')) {
echo "<a href='call_center_agent_edit.php?id=".escape($row['call_center_agent_uuid'])."' alt='".$text['button-edit']."'>".$v_link_label_edit."</a>";
}
if (permission_exists('call_center_agent_delete')) {
echo "<a href='call_center_agent_delete.php?id=".escape($row['call_center_agent_uuid'])."' alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."')\">".$v_link_label_delete."</a>";
}
//echo " <input type='button' class='btn' name='' alt='edit' onclick=\"window.location='call_center_agent_edit.php?id=".escape($row[call_center_agent_uuid])."'\" value='e'>\n";
//echo " <input type='button' class='btn' name='' alt='delete' onclick=\"if (confirm('Are you sure you want to delete this?')) { window.location='call_center_agent_delete.php?id=".escape($row[call_center_agent_uuid])."' }\" value='x'>\n";
echo " <td>".escape($agent_contact)."</td>\n";
echo " <td>".escape($row['agent_max_no_answer'])."</td>\n";
echo " <td>".escape($row['agent_status'])."</td>\n";
//echo " <td>".$row[agent_wrap_up_time]."</td>\n";
//echo " <td>".$row[agent_reject_delay_time]."</td>\n";
//echo " <td>".$row[agent_busy_delay_time]."</td>\n";
if (permission_exists('call_center_agent_edit') && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') {
echo " <td class='action-button'>";
echo button::create(['type'=>'button','title'=>$text['button-edit'],'icon'=>$_SESSION['theme']['button_icon_edit'],'link'=>$list_row_url]);
echo " </td>\n";
}
echo "</tr>\n";
if ($c==0) { $c=1; } else { $c=0; }
} //end foreach
$x++;
}
unset($result);
} //end if results
echo "<tr>\n";
echo "<td colspan='11' align='left'>\n";
echo " <table width='100%' cellpadding='0' cellspacing='0'>\n";
echo " <tr>\n";
echo " <td width='33.3%' nowrap>&nbsp;</td>\n";
echo " <td width='33.3%' align='center' nowrap>$paging_controls</td>\n";
echo " <td class='list_control_icons'>";
if (permission_exists('call_center_agent_add')) {
echo "<a href='call_center_agent_edit.php' alt='".$text['button-add']."'>".$v_link_label_add."</a>";
}
echo " </td>\n";
echo " </tr>\n";
echo " </table>\n";
echo "</td>\n";
echo "</tr>\n";
echo "</table>";
echo "<br><br>";
echo "</table>\n";
echo "<br />\n";
echo "<div align='center'>".$paging_controls."</div>\n";
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo "</form>\n";
//show the footer
require_once "resources/footer.php";

View File

@ -28,6 +28,7 @@
require_once "root.php";
require_once "resources/require.php";
require_once "resources/check_auth.php";
require_once "resources/paging.php";
//check permisission
if (permission_exists('call_center_queue_view')) {
@ -42,65 +43,131 @@
$language = new text;
$text = $language->get();
//includes and title
require_once "resources/header.php";
$document['title'] = $text['title-call_center_queues'];
require_once "resources/paging.php";
//get posted data
if (is_array($_POST['call_center_queues'])) {
$action = $_POST['action'];
$search = $_POST['search'];
$call_center_queues = $_POST['call_center_queues'];
}
//copy the call center queues
if (permission_exists('call_center_queue_add')) {
if ($action == 'copy' && is_array($call_center_queues) && @sizeof($call_center_queues) != 0) {
//copy
$obj = new call_center;
$obj->copy_queues($call_center_queues);
//redirect
header('Location: call_center_queues.php'.($search != '' ? '?search='.urlencode($search) : null));
exit;
}
}
//delete the call center queues
if (permission_exists('call_center_queue_delete')) {
if ($action == 'delete' && is_array($call_center_queues) && @sizeof($call_center_queues) != 0) {
//delete
$obj = new call_center;
$obj->delete_queues($call_center_queues);
//redirect
header('Location: call_center_queues.php'.($search != '' ? '?search='.urlencode($search) : null));
exit;
}
}
//get http variables and set as php variables
$order_by = $_GET["order_by"] != '' ? $_GET["order_by"] : 'queue_name';
$order_by = $_GET["order_by"];
$order = $_GET["order"];
//show the content
echo "<table width='100%' cellpadding='0' cellspacing='0' border='0'>\n";
echo "<tr>\n";
echo "<td width='50%' align='left' nowrap='nowrap'><b>".$text['header-call_center_queues']."</b></td>\n";
echo "<td width='50%' align='right'>\n";
if (permission_exists('call_center_wallboard')) {
echo " <input type='button' class='btn' value='".$text['button-wallboard']."' onclick=\"document.location.href='".PROJECT_PATH."/app/call_center_wallboard/call_center_wallboard.php';\" />\n";
//add the search term
$search = strtolower($_GET["search"]);
if (strlen($search) > 0) {
$sql_search = " (";
$sql_search .= "lower(queue_name) like :search ";
$sql_search .= "or lower(queue_description) like :search ";
$sql_search .= ") ";
$parameters['search'] = '%'.$search.'%';
}
echo " <input type='button' class='btn' value='".$text['button-agents']."' alt='".$text['button-agents']."' onclick=\"window.location='call_center_agents.php'\">\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td align='left' colspan='2'>\n";
echo $text['description-call_center_queues']."<br /><br />\n";
echo "</td>\n";
echo "</tr>\n";
echo "</tr></table>\n";
//get total call center queues count from the database
$sql = "select count(*) from v_call_center_queues ";
$sql .= "where domain_uuid = :domain_uuid ";
if (isset($sql_search)) {
$sql .= "and ".$sql_search;
}
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$database = new database;
$total_call_center_queues = $database->select($sql, $parameters, 'column');
unset($sql, $parameters);
$num_rows = $database->select($sql, $parameters, 'column');
//prepare to page the results
$num_rows = $total_call_center_queues;
$rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50;
$param = "";
$param = "&search=".$search;
$page = $_GET['page'];
if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; }
list($paging_controls, $rows_per_page, $var_3) = paging($num_rows, $param, $rows_per_page);
list($paging_controls, $rows_per_page) = paging($num_rows, $param, $rows_per_page);
list($paging_controls_mini, $rows_per_page) = paging($num_rows, $param, $rows_per_page, true);
$offset = $rows_per_page * $page;
$sql = "select * from v_call_center_queues ";
$sql .= "where domain_uuid = :domain_uuid ";
$sql .= order_by($order_by, $order);
//get the list
$sql = str_replace('count(*)', '*', $sql);
$sql .= order_by($order_by, $order, 'queue_name', 'asc');
$sql .= limit_offset($rows_per_page, $offset);
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$database = new database;
$result = $database->select($sql, $parameters, 'all');
unset($sql, $parameters);
$c = 0;
$row_style["0"] = "row_style0";
$row_style["1"] = "row_style1";
//create token
$object = new token;
$token = $object->create($_SERVER['PHP_SELF']);
echo "<table class='tr_hover' width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n";
//includes and title
$document['title'] = $text['title-call_center_queues'];
require_once "resources/header.php";
//show the content
echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'><b>".$text['header-call_center_queues']." (".$num_rows.")</b></div>\n";
echo " <div class='actions'>\n";
if (permission_exists('call_center_queue_add') && (!is_numeric($_SESSION['limit']['call_center_queues']['numeric']) || $num_rows <= $_SESSION['limit']['call_center_queues']['numeric'])) {
echo button::create(['type'=>'button','label'=>$text['button-add'],'icon'=>$_SESSION['theme']['button_icon_add'],'link'=>'call_center_queue_edit.php']);
}
if (permission_exists('call_center_queue_add') && $result && (!is_numeric($_SESSION['limit']['call_center_queues']['numeric']) || $num_rows <= $_SESSION['limit']['call_center_queues']['numeric'])) {
echo button::create(['type'=>'button','label'=>$text['button-copy'],'icon'=>$_SESSION['theme']['button_icon_copy'],'onclick'=>"if (confirm('".$text['confirm-copy']."')) { list_action_set('copy'); list_form_submit('form_list'); } else { this.blur(); return false; }"]);
}
if (permission_exists('call_center_queue_delete') && $result) {
echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'onclick'=>"if (confirm('".$text['confirm-delete']."')) { list_action_set('delete'); list_form_submit('form_list'); } else { this.blur(); return false; }"]);
}
echo "<form id='form_search' class='inline' method='get'>\n";
echo "<input type='text' class='txt list-search' name='search' id='search' value=\"".escape($search)."\" placeholder=\"".$text['label-search']."\" onkeydown='list_search_reset();'>";
echo button::create(['label'=>$text['button-search'],'icon'=>$_SESSION['theme']['button_icon_search'],'type'=>'submit','id'=>'btn_search','style'=>($search != '' ? 'display: none;' : null)]);
echo button::create(['label'=>$text['button-reset'],'icon'=>$_SESSION['theme']['button_icon_reset'],'type'=>'button','id'=>'btn_reset','link'=>'call_center_queues.php','style'=>($search == '' ? 'display: none;' : null)]);
if ($paging_controls_mini != '') {
echo " <span style='margin-left: 15px;'>".$paging_controls_mini."</span>";
}
if (permission_exists('call_center_agent_view')) {
echo button::create(['type'=>'button','label'=>$text['button-agents'],'icon'=>'users','style'=>'margin-left: 15px;','link'=>'call_center_agents.php']);
}
if (permission_exists('call_center_wallboard')) {
echo button::create(['type'=>'button','label'=>$text['button-wallboard'],'icon'=>'th','link'=>PROJECT_PATH.'/app/call_center_wallboard/call_center_wallboard.php']);
}
echo " </form>\n";
echo " </div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
echo $text['description-call_center_queues']."\n";
echo "<br /><br />\n";
echo "<form id='form_list' method='post'>\n";
echo "<input type='hidden' id='action' name='action' value=''>\n";
echo "<input type='hidden' name='search' value=\"".escape($search)."\">\n";
echo "<table class='list'>\n";
echo "<tr class='list-header'>\n";
if (permission_exists('call_center_queue_add') || permission_exists('call_center_queue_delete')) {
echo " <th class='checkbox'>\n";
echo " <input type='checkbox' id='checkbox_all' name='checkbox_all' onclick='list_all_toggle();' ".($result ?: "style='visibility: hidden;'").">\n";
echo " </th>\n";
}
echo th_order_by('queue_name', $text['label-queue_name'], $order_by, $order);
echo th_order_by('queue_extension', $text['label-extension'], $order_by, $order);
echo th_order_by('queue_strategy', $text['label-strategy'], $order_by, $order);
@ -115,76 +182,65 @@
//echo th_order_by('queue_discard_abandoned_after', $text['label-discard_abandoned_after'], $order_by, $order);
//echo th_order_by('queue_abandoned_resume_allowed', $text['label-abandoned_resume_allowed'], $order_by, $order);
//echo th_order_by('queue_tier_rule_wait_multiply_level', $text['label-tier_rule_wait_multiply_level'], $order_by, $order);
echo th_order_by('queue_description', $text['label-description'], $order_by, $order);
echo "<td class='list_control_icons'>";
if (permission_exists('call_center_queue_add')) {
if ($_SESSION['limit']['call_center_queues']['numeric'] == '' || ($_SESSION['limit']['call_center_queues']['numeric'] != '' && $total_call_center_queues < $_SESSION['limit']['call_center_queues']['numeric'])) {
echo "<a href='call_center_queue_edit.php' alt='".$text['button-add']."'>".$v_link_label_add."</a>";
echo th_order_by('queue_description', $text['label-description'], $order_by, $order, null, "class='hide-sm-dn'");
if (permission_exists('call_center_queue_edit') && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') {
echo " <td class='action-button'>&nbsp;</td>\n";
}
}
echo "</td>\n";
echo "</tr>\n";
if (is_array($result)) {
$x = 0;
foreach($result as $row) {
$tr_link = (permission_exists('call_center_queue_edit')) ? "href='call_center_queue_edit.php?id=".escape($row['call_center_queue_uuid'])."'" : null;
echo "<tr ".$tr_link.">\n";
echo " <td valign='top' class='".$row_style[$c]."'>";
if (permission_exists('call_center_queue_edit')) {
echo "<a href='call_center_queue_edit.php?id=".escape($row['call_center_queue_uuid'])."'>".escape($row['queue_name'])."</a>";
$list_row_url = "call_center_queue_edit.php?id=".urlencode($row['call_center_queue_uuid']);
}
echo "<tr class='list-row' href='".$list_row_url."'>\n";
if (permission_exists('call_center_queue_add') || permission_exists('call_center_queue_delete')) {
echo " <td class='checkbox'>\n";
echo " <input type='checkbox' name='call_center_queues[$x][checked]' id='checkbox_".$x."' value='true' onclick=\"if (!this.checked) { document.getElementById('checkbox_all').checked = false; }\">\n";
echo " <input type='hidden' name='call_center_queues[$x][uuid]' value='".escape($row['call_center_queue_uuid'])."' />\n";
echo " </td>\n";
}
echo " <td>";
if (permission_exists('call_center_queue_edit')) {
echo " <a href='".$list_row_url."' title=\"".$text['button-edit']."\">".escape($row['queue_name'])."</a>";
}
else {
echo escape($row[queue_name]);
echo " ".escape($row[queue_name]);
}
echo " </td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".escape($row['queue_extension'])."&nbsp;</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".escape($row['queue_strategy'])."&nbsp;</td>\n";
//echo " <td valign='top' class='".$row_style[$c]."'>".escape($row[queue_moh_sound])."&nbsp;</td>\n";
//echo " <td valign='top' class='".$row_style[$c]."'>".escape($row[queue_record_template])."&nbsp;</td>\n";
//echo " <td valign='top' class='".$row_style[$c]."'>".escape($row[queue_time_base_score])."&nbsp;</td>\n";
//echo " <td valign='top' class='".$row_style[$c]."'>".escape($row[queue_max_wait_time])."&nbsp;</td>\n";
//echo " <td valign='top' class='".$row_style[$c]."'>".escape($row[queue_max_wait_time_with_no_agent])."&nbsp;</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".ucwords(escape($row['queue_tier_rules_apply']))."&nbsp;</td>\n";
//echo " <td valign='top' class='".$row_style[$c]."'>".escape($row[queue_tier_rule_wait_second])."&nbsp;</td>\n";
//echo " <td valign='top' class='".$row_style[$c]."'>".escape($row[queue_tier_rule_no_agent_no_wait])."&nbsp;</td>\n";
//echo " <td valign='top' class='".$row_style[$c]."'>".escape($row[queue_discard_abandoned_after])."&nbsp;</td>\n";
//echo " <td valign='top' class='".$row_style[$c]."'>".escape($row[queue_abandoned_resume_allowed])."&nbsp;</td>\n";
//echo " <td valign='top' class='".$row_style[$c]."'>".escape($row[queue_tier_rule_wait_multiply_level])."&nbsp;</td>\n";
echo " <td valign='top' class='row_stylebg'>".escape($row['queue_description'])."&nbsp;</td>\n";
echo " <td class='list_control_icons'>";
if (permission_exists('call_center_queue_edit')) {
echo "<a href='call_center_queue_edit.php?id=".escape($row['call_center_queue_uuid'])."' alt='".$text['button-edit']."'>$v_link_label_edit</a>";
}
if (permission_exists('call_center_queue_delete')) {
echo "<a href='call_center_queue_delete.php?id=".escape($row['call_center_queue_uuid'])."' alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."')\">$v_link_label_delete</a>";
}
echo " <td>".escape($row['queue_extension'])."</td>\n";
echo " <td>".escape($row['queue_strategy'])."</td>\n";
//echo " <td>".escape($row[queue_moh_sound])."&nbsp;</td>\n";
//echo " <td>".escape($row[queue_record_template])."&nbsp;</td>\n";
//echo " <td>".escape($row[queue_time_base_score])."&nbsp;</td>\n";
//echo " <td>".escape($row[queue_max_wait_time])."&nbsp;</td>\n";
//echo " <td>".escape($row[queue_max_wait_time_with_no_agent])."&nbsp;</td>\n";
echo " <td>".ucwords(escape($row['queue_tier_rules_apply']))."</td>\n";
//echo " <td>".escape($row[queue_tier_rule_wait_second])."&nbsp;</td>\n";
//echo " <td>".escape($row[queue_tier_rule_no_agent_no_wait])."&nbsp;</td>\n";
//echo " <td>".escape($row[queue_discard_abandoned_after])."&nbsp;</td>\n";
//echo " <td>".escape($row[queue_abandoned_resume_allowed])."&nbsp;</td>\n";
//echo " <td>".escape($row[queue_tier_rule_wait_multiply_level])."&nbsp;</td>\n";
echo " <td class='description overflow hide-sm-dn'>".escape($row['queue_description'])."</td>\n";
if (permission_exists('call_center_queue_edit') && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') {
echo " <td class='action-button'>";
echo button::create(['type'=>'button','title'=>$text['button-edit'],'icon'=>$_SESSION['theme']['button_icon_edit'],'link'=>$list_row_url]);
echo " </td>\n";
}
echo "</tr>\n";
if ($c==0) { $c=1; } else { $c=0; }
} //end foreach
unset($sql, $result, $row_count);
} //end if results
$x++;
}
unset($result);
}
echo "<tr>\n";
echo "<td colspan='17' align='left'>\n";
echo " <table width='100%' cellpadding='0' cellspacing='0'>\n";
echo " <tr>\n";
echo " <td width='33.3%' nowrap>&nbsp;</td>\n";
echo " <td width='33.3%' align='center' nowrap>$paging_controls</td>\n";
echo " <td class='list_control_icons'>";
if (permission_exists('call_center_queue_add')) {
if ($_SESSION['limit']['call_center_queues']['numeric'] == '' || ($_SESSION['limit']['call_center_queues']['numeric'] != '' && $total_call_center_queues < $_SESSION['limit']['call_center_queues']['numeric'])) {
echo "<a href='call_center_queue_edit.php' alt='".$text['button-add']."'>".$v_link_label_add."</a>";
}
}
echo " </td>\n";
echo " </tr>\n";
echo "</table>\n";
echo "</td>\n";
echo "</tr>\n";
echo "<br />\n";
echo "<div align='center'>".$paging_controls."</div>\n";
echo "</table>";
echo "<br><br>";
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo "</form>\n";
//show the footer
require_once "resources/footer.php";

View File

@ -43,11 +43,24 @@
public $destination_number;
public $queue_cc_exit_keys;
/**
* declare private variables
*/
private $app_name;
private $app_uuid;
private $permission_prefix;
private $list_page;
private $table;
private $uuid_prefix;
private $enabled_prefix;
/**
* Called when the object is created
*/
public function __construct() {
//place holder
//assign private variables
$this->app_name = 'call_center';
$this->app_uuid = '95788e50-9500-079e-2807-fd530b0ea370';
}
/**
@ -264,6 +277,343 @@
return $dialplan_response;
}
/**
* delete records
*/
public function delete_queues($records) {
//assign private variables
$this->permission_prefix = 'call_center_queue_';
$this->list_page = 'call_center_queues.php';
$this->table = 'call_center_queues';
$this->uuid_prefix = 'call_center_queue_';
if (permission_exists($this->permission_prefix.'delete')) {
//add multi-lingual support
$language = new text;
$text = $language->get();
//validate the token
$token = new token;
if (!$token->validate($_SERVER['PHP_SELF'])) {
message::add($text['message-invalid_token'],'negative');
header('Location: '.$this->list_page);
exit;
}
//delete multiple records
if (is_array($records) && @sizeof($records) != 0) {
//build the delete array
foreach($records as $x => $record) {
if ($record['checked'] == 'true' && is_uuid($record['uuid'])) {
$array[$this->table][$x][$this->uuid_prefix.'uuid'] = $record['uuid'];
$array[$this->table][$x]['domain_uuid'] = $_SESSION['domain_uuid'];
$array['call_center_tiers'][$x][$this->uuid_prefix.'uuid'] = $record['uuid'];
$array['call_center_tiers'][$x]['domain_uuid'] = $_SESSION['domain_uuid'];
}
}
//delete the checked rows
if (is_array($array) && @sizeof($array) != 0) {
//grant temporary permissions
$p = new permissions;
$p->add('call_center_tier_delete', 'temp');
//execute delete
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->delete($array);
unset($array);
//revoke temporary permissions
$p->delete('call_center_tier_delete', 'temp');
//set message
message::add($text['message-delete']);
}
unset($records);
}
}
}
public function delete_agents($records) {
//assign private variables
$this->permission_prefix = 'call_center_agent_';
$this->list_page = 'call_center_agents.php';
$this->table = 'call_center_agents';
$this->uuid_prefix = 'call_center_agent_';
if (permission_exists($this->permission_prefix.'delete')) {
//add multi-lingual support
$language = new text;
$text = $language->get();
//validate the token
$token = new token;
if (!$token->validate($_SERVER['PHP_SELF'])) {
message::add($text['message-invalid_token'],'negative');
header('Location: '.$this->list_page);
exit;
}
//delete multiple records
if (is_array($records) && @sizeof($records) != 0) {
//build the delete array
foreach($records as $x => $record) {
if ($record['checked'] == 'true' && is_uuid($record['uuid'])) {
$array[$this->table][$x][$this->uuid_prefix.'uuid'] = $record['uuid'];
$array[$this->table][$x]['domain_uuid'] = $_SESSION['domain_uuid'];
$array['call_center_tiers'][$x][$this->uuid_prefix.'uuid'] = $record['uuid'];
$array['call_center_tiers'][$x]['domain_uuid'] = $_SESSION['domain_uuid'];
}
}
//delete the checked rows
if (is_array($array) && @sizeof($array) != 0) {
//grant temporary permissions
$p = new permissions;
$p->add('call_center_tier_delete', 'temp');
//execute delete
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->delete($array);
unset($array);
//revoke temporary permissions
$p->delete('call_center_tier_delete', 'temp');
//set message
message::add($text['message-delete']);
}
unset($records);
}
}
}
/**
* copy records
*/
public function copy_queues($records) {
//assign private variables
$this->permission_prefix = 'call_center_queue_';
$this->list_page = 'call_center_queues.php';
$this->table = 'call_center_queues';
$this->uuid_prefix = 'call_center_queue_';
if (permission_exists($this->permission_prefix.'add')) {
//add multi-lingual support
$language = new text;
$text = $language->get();
//validate the token
$token = new token;
if (!$token->validate($_SERVER['PHP_SELF'])) {
message::add($text['message-invalid_token'],'negative');
header('Location: '.$this->list_page);
exit;
}
//copy the checked records
if (is_array($records) && @sizeof($records) != 0) {
//get checked records
foreach($records as $x => $record) {
if ($record['checked'] == 'true' && is_uuid($record['uuid'])) {
$record_uuids[] = $this->uuid_prefix."uuid = '".$record['uuid']."'";
}
}
//create insert array from existing data
if (is_array($record_uuids) && @sizeof($record_uuids) != 0) {
//primary table
$sql = "select * from v_".$this->table." ";
$sql .= "where ".implode(' or ', $record_uuids)." ";
$database = new database;
$rows = $database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
$y = 0;
foreach ($rows as $x => $row) {
$primary_uuid = uuid();
//copy data
$array[$this->table][$x] = $row;
//overwrite
$array[$this->table][$x][$this->uuid_prefix.'uuid'] = $primary_uuid;
$array[$this->table][$x]['queue_description'] = trim($row['queue_description'].' ('.$text['label-copy'].')');
//sub table
$sql_2 = "select * from v_call_center_tiers where call_center_queue_uuid = :call_center_queue_uuid";
$parameters_2['call_center_queue_uuid'] = $row['call_center_queue_uuid'];
$database = new database;
$rows_2 = $database->select($sql_2, $parameters_2, 'all');
if (is_array($rows_2) && @sizeof($rows_2) != 0) {
foreach ($rows_2 as $row_2) {
//copy data
$array['call_center_tiers'][$y] = $row_2;
//overwrite
$array['call_center_tiers'][$y]['call_center_tier_uuid'] = uuid();
$array['call_center_tiers'][$y]['call_center_queue_uuid'] = $primary_uuid;
$y++;
}
}
unset($sql_2, $parameters_2, $rows_2, $row_2);
}
}
unset($sql, $parameters, $rows, $row);
}
//save the changes and set the message
if (is_array($array) && @sizeof($array) != 0) {
//grant temporary permissions
$p = new permissions;
$p->add('call_center_tier_add', 'temp');
//save the array
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->save($array);
unset($array);
//revoke temporary permissions
$p->delete('call_center_tier_add', 'temp');
//set message
message::add($text['message-copy']);
}
unset($records);
}
}
}
public function copy_agents($records) {
//assign private variables
$this->permission_prefix = 'call_center_agent_';
$this->list_page = 'call_center_agents.php';
$this->table = 'call_center_agents';
$this->uuid_prefix = 'call_center_agent_';
if (permission_exists($this->permission_prefix.'add')) {
//add multi-lingual support
$language = new text;
$text = $language->get();
//validate the token
$token = new token;
if (!$token->validate($_SERVER['PHP_SELF'])) {
message::add($text['message-invalid_token'],'negative');
header('Location: '.$this->list_page);
exit;
}
//copy the checked records
if (is_array($records) && @sizeof($records) != 0) {
//get checked records
foreach($records as $x => $record) {
if ($record['checked'] == 'true' && is_uuid($record['uuid'])) {
$record_uuids[] = $this->uuid_prefix."uuid = '".$record['uuid']."'";
}
}
//create insert array from existing data
if (is_array($record_uuids) && @sizeof($record_uuids) != 0) {
//primary table
$sql = "select * from v_".$this->table." ";
$sql .= "where ".implode(' or ', $record_uuids)." ";
$database = new database;
$rows = $database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
$y = 0;
foreach ($rows as $x => $row) {
$primary_uuid = uuid();
//copy data
$array[$this->table][$x] = $row;
//overwrite
$array[$this->table][$x][$this->uuid_prefix.'uuid'] = $primary_uuid;
$array[$this->table][$x]['agent_name'] = trim($row['agent_name'].' ('.$text['label-copy'].')');
$array[$this->table][$x]['agent_id'] = null;
//sub table
$sql_2 = "select * from v_call_center_tiers where call_center_agent_uuid = :call_center_agent_uuid";
$parameters_2['call_center_agent_uuid'] = $row['call_center_agent_uuid'];
$database = new database;
$rows_2 = $database->select($sql_2, $parameters_2, 'all');
if (is_array($rows_2) && @sizeof($rows_2) != 0) {
foreach ($rows_2 as $row_2) {
//copy data
$array['call_center_tiers'][$y] = $row_2;
//overwrite
$array['call_center_tiers'][$y]['call_center_tier_uuid'] = uuid();
$array['call_center_tiers'][$y]['call_center_agent_uuid'] = $primary_uuid;
//increment
$y++;
}
}
unset($sql_2, $parameters_2, $rows_2, $row_2);
}
}
unset($sql, $parameters, $rows, $row);
}
//save the changes and set the message
if (is_array($array) && @sizeof($array) != 0) {
//grant temporary permissions
$p = new permissions;
$p->add('call_center_tier_add', 'temp');
//save the array
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->save($array);
unset($array);
//revoke temporary permissions
$p->delete('call_center_tier_add', 'temp');
//set message
message::add($text['message-copy']);
}
unset($records);
}
}
}
}
}