Call Center Active: Action bar and list view updates.

This commit is contained in:
Nate 2020-01-13 09:45:21 -07:00
parent d10cfc3252
commit 8c54adb5c4
2 changed files with 151 additions and 137 deletions

View File

@ -51,8 +51,8 @@
unset($_SESSION['agents']); unset($_SESSION['agents']);
//get the header //get the header
require_once "resources/header.php";
$document['title'] = $text['title-call_center_queue_activity']; $document['title'] = $text['title-call_center_queue_activity'];
require_once "resources/header.php";
//add the ajax //add the ajax
?><script type="text/javascript"> ?><script type="text/javascript">
@ -88,6 +88,18 @@
if (this.xmlHttp.readyState == 4 && (this.xmlHttp.status == 200 || !/^http/.test(window.location.href))) if (this.xmlHttp.readyState == 4 && (this.xmlHttp.status == 200 || !/^http/.test(window.location.href)))
//this.el.innerHTML = this.xmlHttp.responseText; //this.el.innerHTML = this.xmlHttp.responseText;
document.getElementById('ajax_response').innerHTML = this.xmlHttp.responseText; document.getElementById('ajax_response').innerHTML = this.xmlHttp.responseText;
//link table rows (except the last - the list_control_icons cell) on a table with a class of 'tr_hover', according to the href attribute of the <tr> tag
$('.tr_hover tr,.list tr').each(function(i,e) {
$(e).children('td:not(.list_control_icon,.list_control_icons,.tr_link_void,.list-row > .no-link,.list-row > .checkbox,.list-row > .button,.list-row > .action-button)').on('click', function() {
var href = $(this).closest('tr').attr('href');
var target = $(this).closest('tr').attr('target');
if (href) {
if (target) { window.open(href, target); }
else { window.location = href; }
}
});
});
} }
var requestTime = function() { var requestTime = function() {
@ -123,7 +135,7 @@
<?php <?php
//show the response //show the response
echo " <div id='ajax_response'></div>\n"; echo "<div id='ajax_response'></div>\n";
echo "<br><br>"; echo "<br><br>";
//include the footer //include the footer

View File

@ -17,7 +17,7 @@
The Initial Developer of the Original Code is The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com> Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2008-2018 Portions created by the Initial Developer are Copyright (C) 2008-2019
the Initial Developer. All Rights Reserved. the Initial Developer. All Rights Reserved.
Contributor(s): Contributor(s):
@ -89,11 +89,6 @@
return $result; return $result;
} }
//alternate the color of the row
$c = 0;
$row_style["0"] = "row_style0";
$row_style["1"] = "row_style1";
//create an event socket connection //create an event socket connection
$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
@ -158,124 +153,135 @@
} }
//list the agents //list the agents
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n"; echo "<table class='list'>\n";
echo "<tr>\n"; echo "<tr class='list-header'>\n";
echo "<th>".$text['label-name']."</th>\n"; echo "<th>".$text['label-name']."</th>\n";
echo "<th>".$text['label-extension']."</th>\n"; echo "<th>".$text['label-extension']."</th>\n";
echo "<th>".$text['label-status']."</th>\n"; echo "<th>".$text['label-status']."</th>\n";
echo "<th>".$text['label-state']."</th>\n"; echo "<th>".$text['label-state']."</th>\n";
echo "<th>".$text['label-status_change']."</th>\n"; echo "<th>".$text['label-status_change']."</th>\n";
echo "<th>".$text['label-missed']."</th>\n"; echo "<th class='center'>".$text['label-missed']."</th>\n";
echo "<th>".$text['label-answered']."</th>\n"; echo "<th class='center'>".$text['label-answered']."</th>\n";
echo "<th>".$text['label-tier_state']."</th>\n"; echo "<th>".$text['label-tier_state']."</th>\n";
echo "<th>".$text['label-tier_level']."</th>\n"; echo "<th class='center'>".$text['label-tier_level']."</th>\n";
echo "<th>".$text['label-tier_position']."</th>\n"; echo "<th class='center'>".$text['label-tier_position']."</th>\n";
if (permission_exists('call_center_active_options')) { if (permission_exists('call_center_active_options')) {
echo "<th>".$text['label-options']."</th>\n"; echo "<th class='center'>".$text['label-options']."</th>\n";
} }
echo "</tr>\n"; echo "</tr>\n";
if (isset($tier_result)) foreach ($tier_result as $tier_row) { if (isset($tier_result)) {
//$queue = $tier_row['queue']; foreach ($tier_result as $tier_row) {
//$queue = str_replace('@'.$_SESSION['domain_name'], '', $queue); //$queue = $tier_row['queue'];
$agent = $tier_row['agent']; //$queue = str_replace('@'.$_SESSION['domain_name'], '', $queue);
//$agent = str_replace('@'.$_SESSION['domain_name'], '', $agent); $agent = $tier_row['agent'];
$tier_state = $tier_row['state']; //$agent = str_replace('@'.$_SESSION['domain_name'], '', $agent);
$tier_level = $tier_row['level']; $tier_state = $tier_row['state'];
$tier_position = $tier_row['position']; $tier_level = $tier_row['level'];
$tier_position = $tier_row['position'];
if (isset($agent_result)) foreach ($agent_result as $agent_row) { if (isset($agent_result)) {
if ($tier_row['agent'] == $agent_row['name']) { foreach ($agent_result as $agent_row) {
$agent_uuid = $agent_row['name']; if ($tier_row['agent'] == $agent_row['name']) {
$agent_uuid = $agent_row['name'];
//get the agent name //get the agent name
$agent_name = ''; $agent_name = '';
if (is_array($_SESSION['agents'])) foreach ($_SESSION['agents'] as $agent) { if (is_array($_SESSION['agents'])) {
if ($agent['call_center_agent_uuid'] == $agent_uuid) { foreach ($_SESSION['agents'] as $agent) {
$agent_name = $agent['agent_name']; if ($agent['call_center_agent_uuid'] == $agent_uuid) {
} $agent_name = $agent['agent_name'];
} }
}
}
//$system = $agent_row['system']; //$system = $agent_row['system'];
$agent_uuid = $agent_row['uuid']; if (is_uuid($agent_row['uuid'])) {
//$type = $agent_row['type']; $agent_uuid = $agent_row['uuid'];
$contact = $agent_row['contact']; }
$agent_extension = preg_replace("/user\//", "", $contact); //$type = $agent_row['type'];
$agent_extension = preg_replace("/@.*/", "", $agent_extension); $contact = $agent_row['contact'];
$agent_extension = preg_replace("/{.*}/", "", $agent_extension); $agent_extension = preg_replace("/user\//", "", $contact);
$status = $agent_row['status']; $agent_extension = preg_replace("/@.*/", "", $agent_extension);
$state = $agent_row['state']; $agent_extension = preg_replace("/{.*}/", "", $agent_extension);
$max_no_answer = $agent_row['max_no_answer']; $status = $agent_row['status'];
$wrap_up_time = $agent_row['wrap_up_time']; $state = $agent_row['state'];
$reject_delay_time = $agent_row['reject_delay_time']; $max_no_answer = $agent_row['max_no_answer'];
$busy_delay_time = $agent_row['busy_delay_time']; $wrap_up_time = $agent_row['wrap_up_time'];
$last_bridge_start = $agent_row['last_bridge_start']; $reject_delay_time = $agent_row['reject_delay_time'];
$last_bridge_end = $agent_row['last_bridge_end']; $busy_delay_time = $agent_row['busy_delay_time'];
//$last_offered_call = $agent_row['last_offered_call']; $last_bridge_start = $agent_row['last_bridge_start'];
$last_status_change = $agent_row['last_status_change']; $last_bridge_end = $agent_row['last_bridge_end'];
$no_answer_count = $agent_row['no_answer_count']; //$last_offered_call = $agent_row['last_offered_call'];
$calls_answered = $agent_row['calls_answered']; $last_status_change = $agent_row['last_status_change'];
$talk_time = $agent_row['talk_time']; $no_answer_count = $agent_row['no_answer_count'];
$ready_time = $agent_row['ready_time']; $calls_answered = $agent_row['calls_answered'];
$talk_time = $agent_row['talk_time'];
$ready_time = $agent_row['ready_time'];
$last_offered_call_seconds = time() - $last_offered_call; $last_offered_call_seconds = time() - $last_offered_call;
$last_offered_call_length_hour = floor($last_offered_call_seconds/3600); $last_offered_call_length_hour = floor($last_offered_call_seconds/3600);
$last_offered_call_length_min = floor($last_offered_call_seconds/60 - ($last_offered_call_length_hour * 60)); $last_offered_call_length_min = floor($last_offered_call_seconds/60 - ($last_offered_call_length_hour * 60));
$last_offered_call_length_sec = $last_offered_call_seconds - (($last_offered_call_length_hour * 3600) + ($last_offered_call_length_min * 60)); $last_offered_call_length_sec = $last_offered_call_seconds - (($last_offered_call_length_hour * 3600) + ($last_offered_call_length_min * 60));
$last_offered_call_length_min = sprintf("%02d", $last_offered_call_length_min); $last_offered_call_length_min = sprintf("%02d", $last_offered_call_length_min);
$last_offered_call_length_sec = sprintf("%02d", $last_offered_call_length_sec); $last_offered_call_length_sec = sprintf("%02d", $last_offered_call_length_sec);
$last_offered_call_length = $last_offered_call_length_hour.':'.$last_offered_call_length_min.':'.$last_offered_call_length_sec; $last_offered_call_length = $last_offered_call_length_hour.':'.$last_offered_call_length_min.':'.$last_offered_call_length_sec;
$last_status_change_seconds = time() - $last_status_change; $last_status_change_seconds = time() - $last_status_change;
$last_status_change_length_hour = floor($last_status_change_seconds/3600); $last_status_change_length_hour = floor($last_status_change_seconds/3600);
$last_status_change_length_min = floor($last_status_change_seconds/60 - ($last_status_change_length_hour * 60)); $last_status_change_length_min = floor($last_status_change_seconds/60 - ($last_status_change_length_hour * 60));
$last_status_change_length_sec = $last_status_change_seconds - (($last_status_change_length_hour * 3600) + ($last_status_change_length_min * 60)); $last_status_change_length_sec = $last_status_change_seconds - (($last_status_change_length_hour * 3600) + ($last_status_change_length_min * 60));
$last_status_change_length_min = sprintf("%02d", $last_status_change_length_min); $last_status_change_length_min = sprintf("%02d", $last_status_change_length_min);
$last_status_change_length_sec = sprintf("%02d", $last_status_change_length_sec); $last_status_change_length_sec = sprintf("%02d", $last_status_change_length_sec);
$last_status_change_length = $last_status_change_length_hour.':'.$last_status_change_length_min.':'.$last_status_change_length_sec; $last_status_change_length = $last_status_change_length_hour.':'.$last_status_change_length_min.':'.$last_status_change_length_sec;
echo "<tr>\n"; if (permission_exists('call_center_agent_edit')) {
echo "<td valign='top' class='".$row_style[$c]."'>".escape($agent_name)."</td>\n"; $list_row_url = "../call_centers/call_center_agent_edit.php?id=".$agent_uuid;
echo "<td valign='top' class='".$row_style[$c]."'>".escape($agent_extension)."</td>\n"; }
echo "<td valign='top' class='".$row_style[$c]."'>".escape($status)."</td>\n";
echo "<td valign='top' class='".$row_style[$c]."'>".escape($state)."</td>\n";
echo "<td valign='top' class='".$row_style[$c]."'>".escape($last_status_change_length)."</td>\n";
echo "<td valign='top' class='".$row_style[$c]."'>".escape($no_answer_count)."</td>\n";
echo "<td valign='top' class='".$row_style[$c]."'>".escape($calls_answered)."</td>\n";
echo "<td valign='top' class='".$row_style[$c]."'>".escape($tier_state)."</td>\n";
echo "<td valign='top' class='".$row_style[$c]."'>".escape($tier_level)."</td>\n";
echo "<td valign='top' class='".$row_style[$c]."'>".escape($tier_position)."</td>\n";
if (permission_exists('call_center_active_options')) { echo "<tr class='list-row' href='".$list_row_url."'>\n";
echo "<td>";
if (permission_exists('call_center_agent_edit')) {
echo "<a href='".$list_row_url."'>".escape($agent_name)."</a>";
}
else {
echo escape($agent_name);
}
echo "</td>\n";
echo "<td>".escape($agent_extension)."</td>\n";
echo "<td>".escape($status)."</td>\n";
echo "<td>".escape($state)."</td>\n";
echo "<td>".escape($last_status_change_length)."</td>\n";
echo "<td class='center'>".escape($no_answer_count)."</td>\n";
echo "<td class='center'>".escape($calls_answered)."</td>\n";
echo "<td>".escape($tier_state)."</td>\n";
echo "<td class='center'>".escape($tier_level)."</td>\n";
echo "<td class='center'>".escape($tier_position)."</td>\n";
if (permission_exists('call_center_active_options')) {
echo "<td class='no-link center'>\n";
//need to check state to so only waiting gets call, and trying/answer gets eavesdrop
if ($tier_state == "Offering" || $tier_state == "Active Inbound") {
//$orig_command="{origination_caller_id_name=eavesdrop,origination_caller_id_number=".escape($agent_extension)."}user/".$_SESSION['user']['extension'][0]['user']."@".$_SESSION['domain_name']." %26eavesdrop(".escape($agent_uuid).")";
echo button::create(['type'=>'button','class'=>'link','label'=>$text['label-eavesdrop'],'onclick'=>"if (confirm('".$text['message-confirm']."')) { send_command('call_center_exec.php?command=eavesdrop&uuid=".urlencode($agent_uuid)."&extension=".urlencode($agent_extension)."'); } else { this.blur(); return false; }"]);
echo "<td valign='top' class='".$row_style[$c]."'>"; //$xfer_command = escape($agent_uuid)." -bleg ".escape($_SESSION['user']['extension'][0]['user'])." XML ".escape($_SESSION['domain_name']);
echo button::create(['type'=>'button','class'=>'link','label'=>$text['label-transfer'],'style'=>'margin-left: 15px;','onclick'=>"if (confirm('".$text['message-confirm']."')) { send_command('call_center_exec.php?command=uuid_transfer&uuid=".urlencode($agent_uuid)."'); } else { this.blur(); return false; }"]);
//need to check state to so only waiting gets call, and trying/answer gets eavesdrop }
if ($tier_state == "Offering" || $tier_state == "Active Inbound") { else {
//$orig_command="{origination_caller_id_name=eavesdrop,origination_caller_id_number=".escape($agent_extension)."}user/".$_SESSION['user']['extension'][0]['user']."@".$_SESSION['domain_name']." %26eavesdrop(".escape($agent_uuid).")"; //$orig_call="{origination_caller_id_name=c2c-".urlencode(escape($name)).",origination_caller_id_number=".escape($agent_extension)."}user/".$_SESSION['user']['extension'][0]['user']."@".$_SESSION['domain_name']." %26bridge(user/".escape($agent_extension)."@".$_SESSION['domain_name'].")";
echo " <a href='javascript:void(0);' style='color: #444444;' onclick=\"confirm_response = confirm('".$text['message-confirm']."');if (confirm_response){send_command('call_center_exec.php?command=eavesdrop&uuid=".escape($agent_uuid)."&extension=".escape($agent_extension)."');}\">".$text['label-eavesdrop']."</a>&nbsp;\n"; echo button::create(['type'=>'button','class'=>'link','label'=>$text['label-call'],'onclick'=>"if (confirm('".$text['message-confirm']."')) { send_command('call_center_exec.php?command=bridge&extension=".urlencode($agent_extension)."&caller_id_name=".urlencode($name)."'); } else { this.blur(); return false; }"]);
}
//$xfer_command = escape($agent_uuid)." -bleg ".escape($_SESSION['user']['extension'][0]['user'])." XML ".escape($_SESSION['domain_name']); echo "</td>";
echo " <a href='javascript:void(0);' style='color: #444444;' onclick=\"confirm_response = confirm('".$text['message-confirm']."');if (confirm_response){send_command('call_center_exec.php?command=uuid_transfer&uuid=".escape($agent_uuid)."');}\">".$text['label-transfer']."</a>&nbsp;\n"; }
} echo "</tr>\n";
else { } //if
//$orig_call="{origination_caller_id_name=c2c-".urlencode(escape($name)).",origination_caller_id_number=".escape($agent_extension)."}user/".$_SESSION['user']['extension'][0]['user']."@".$_SESSION['domain_name']." %26bridge(user/".escape($agent_extension)."@".$_SESSION['domain_name'].")"; } //foreach
echo " <a href='javascript:void(0);' style='color: #444444;' onclick=\"confirm_response = confirm('".$text['message-confirm']."');if (confirm_response){send_command('call_center_exec.php?command=bridge&extension=".escape($agent_extension)."&caller_id_name=".urlencode(escape($name))."');}\">".$text['label-call']."</a>&nbsp;\n"; } //if
} } //foreach
echo "</td>"; } //if
}
}
}
echo "</tr>\n";
if ($c==0) { $c=1; } else { $c=0; }
}
echo "</table>\n\n"; echo "</table>\n\n";
//add vertical spacing //add vertical spacing
echo "<br />"; echo "<br /><br /><br />";
echo "<br />";
echo "<br />";
echo "<br />";
//get the queue list //get the queue list
//send the event socket command and get the response //send the event socket command and get the response
@ -292,12 +298,9 @@
$q_trying=0; $q_trying=0;
$q_answered=0; $q_answered=0;
echo "<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n"; echo "<div class='action_bar sub'>\n";
echo " <tr>\n"; echo " <div class='heading'><b>".$text['label-queue'].": ".ucfirst(escape($queue_name))."</b></div>\n";
echo " <td align='left'><b>".$text['label-queue'].": ".ucfirst(escape($queue_name))."</b><br />\n"; echo " <div class='actions'>\n";
echo " ".$text['description-queue']."<br />\n";
echo " </td>\n";
echo " <td align='right' valign='top'>";
if (isset($result)) { if (isset($result)) {
foreach ($result as $row) { foreach ($result as $row) {
$state = $row['state']; $state = $row['state'];
@ -309,13 +312,15 @@
echo " <strong>".$text['label-waiting'].":</strong> <b>".$q_waiting."</b>&nbsp;&nbsp;&nbsp;"; echo " <strong>".$text['label-waiting'].":</strong> <b>".$q_waiting."</b>&nbsp;&nbsp;&nbsp;";
echo " <strong>".$text['label-trying'].":</strong> <b>".$q_trying."</b>&nbsp;&nbsp;&nbsp; "; echo " <strong>".$text['label-trying'].":</strong> <b>".$q_trying."</b>&nbsp;&nbsp;&nbsp; ";
echo " <strong>".$text['label-answered'].":</strong> <b>".$q_answered."</b>"; echo " <strong>".$text['label-answered'].":</strong> <b>".$q_answered."</b>";
echo " </td>"; echo " </div>\n";
echo " </tr>\n"; echo " <div style='clear: both;'></div>\n";
echo "</table>\n"; echo "</div>\n";
echo "<br />\n";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n"; echo $text['description-queue']."\n";
echo "<tr>\n"; echo "<br /><br />\n";
echo "<table class='list'>\n";
echo "<tr class='list-header'>\n";
echo "<th>".$text['label-time']."</th>\n"; echo "<th>".$text['label-time']."</th>\n";
//echo "<th>".$text['label-system']."</th>\n"; //echo "<th>".$text['label-system']."</th>\n";
echo "<th>".$text['label-name']."</th>\n"; echo "<th>".$text['label-name']."</th>\n";
@ -355,40 +360,37 @@
//get the serving agent name //get the serving agent name
$serving_agent_name = ''; $serving_agent_name = '';
if (is_array($_SESSION['agents'])) foreach ($_SESSION['agents'] as $agent) { if (is_array($_SESSION['agents'])) {
if ($agent['call_center_agent_uuid'] == $serving_agent) { foreach ($_SESSION['agents'] as $agent) {
$serving_agent_name = $agent['agent_name']; if ($agent['call_center_agent_uuid'] == $serving_agent) {
$serving_agent_name = $agent['agent_name'];
}
} }
} }
echo "<tr>\n"; echo "<tr class='list-row'>\n";
echo "<td valign='top' class='".$row_style[$c]."'>".escape($joined_length)."</td>\n"; echo "<td>".escape($joined_length)."</td>\n";
//echo "<td valign='top' class='".$row_style[$c]."'>".escape($system_length)."</td>\n"; //echo "<td>".escape($system_length)."</td>\n";
echo "<td valign='top' class='".$row_style[$c]."'>".escape($caller_name)."&nbsp;</td>\n"; echo "<td>".escape($caller_name)."&nbsp;</td>\n";
echo "<td valign='top' class='".$row_style[$c]."'>".escape($caller_number)."&nbsp;</td>\n"; echo "<td>".escape($caller_number)."&nbsp;</td>\n";
echo "<td valign='top' class='".$row_style[$c]."'>".escape($state)."</td>\n"; echo "<td>".escape($state)."</td>\n";
if (if_group("admin") || if_group("superadmin")) { if (if_group("admin") || if_group("superadmin")) {
echo "<td valign='top' class='".$row_style[$c]."'>"; echo "<td>";
if ($state != "Abandoned") { if ($state != "Abandoned") {
$orig_command="{origination_caller_id_name=eavesdrop,origination_caller_id_number=".escape($q_caller_number)."}user/".escape($_SESSION['user']['extension'][0]['user'])."@".escape($_SESSION['domain_name'])." %26eavesdrop(".escape($session_uuid).")"; $orig_command="{origination_caller_id_name=eavesdrop,origination_caller_id_number=".escape($q_caller_number)."}user/".escape($_SESSION['user']['extension'][0]['user'])."@".escape($_SESSION['domain_name'])." %26eavesdrop(".escape($session_uuid).")";
echo " <a href='javascript:void(0);' style='color: #444444;' onclick=\"confirm_response = confirm('".$text['message-confirm']."');if (confirm_response){send_command('call_center_exec.php?command=eavesdrop&caller_id_number=".escape(urlencode($caller_number))."&uuid=".escape($session_uuid)."');}\">".$text['label-eavesdrop']."</a>&nbsp;\n"; echo button::create(['type'=>'button','class'=>'link','label'=>$text['label-eavesdrop'],'onclick'=>"if (confirm('".$text['message-confirm']."')) { send_command('call_center_exec.php?command=eavesdrop&caller_id_number=".urlencode($caller_number)."&uuid=".urlencode($session_uuid)."'); } else { this.blur(); return false; }"]);
} }
else { else {
echo "&nbsp;"; echo "&nbsp;";
} }
echo "</td>"; echo "</td>";
} }
echo "<td valign='top' class='".$row_style[$c]."'>".escape($serving_agent_name)."&nbsp;</td>\n"; echo "<td>".escape($serving_agent_name)."&nbsp;</td>\n";
echo "</tr>\n"; echo "</tr>\n";
if ($c==0) { $c=1; } else { $c=0; }
} }
} }
echo "</table>\n"; echo "</table>\n";
//add vertical spacing
echo "<br />\n";
echo "<br />\n";
echo "<br />\n";
} }
?> ?>