Added dynamic language ability to chat functions
Fixed several security issues with Chat functions Added new options to ADMIN_www_languages.pl script git-svn-id: svn://192.168.202.10@2435 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
@@ -8,10 +8,11 @@
|
||||
# changes:
|
||||
# 150608-2041 - First Build
|
||||
# 150909-0118 - Bug fixes, added feature to submit messages when Enter is pressed
|
||||
# 151219-0718 - Added vicidial_chat.js code, translation code where missing
|
||||
#
|
||||
|
||||
$admin_version = '2.12-1';
|
||||
$build = '150909-0118';
|
||||
$admin_version = '2.12-3';
|
||||
$build = '151219-0718';
|
||||
|
||||
$sh="managerchats";
|
||||
|
||||
@@ -21,33 +22,35 @@ require("functions.php");
|
||||
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
|
||||
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
|
||||
$PHP_SELF=$_SERVER['PHP_SELF'];
|
||||
if (isset($_GET["DB"])) {$DB=$_GET["DB"];}
|
||||
elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];}
|
||||
if (isset($_GET["action"])) {$action=$_GET["action"];}
|
||||
elseif (isset($_POST["action"])) {$action=$_POST["action"];}
|
||||
if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];}
|
||||
elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];}
|
||||
if (isset($_GET["manager_chat_id"])) {$manager_chat_id=$_GET["manager_chat_id"];}
|
||||
elseif (isset($_POST["manager_chat_id"])) {$manager_chat_id=$_POST["manager_chat_id"];}
|
||||
if (isset($_GET["available_chat_agents"])) {$available_chat_agents=$_GET["available_chat_agents"];}
|
||||
elseif (isset($_POST["available_chat_agents"])) {$available_chat_agents=$_POST["available_chat_agents"];}
|
||||
if (isset($_GET["available_chat_groups"])) {$available_chat_groups=$_GET["available_chat_groups"];}
|
||||
elseif (isset($_POST["available_chat_groups"])) {$available_chat_groups=$_POST["available_chat_groups"];}
|
||||
if (isset($_GET["available_chat_campaigns"])) {$available_chat_campaigns=$_GET["available_chat_campaigns"];}
|
||||
elseif (isset($_POST["available_chat_campaigns"])) {$available_chat_campaigns=$_POST["available_chat_campaigns"];}
|
||||
if (isset($_GET["manager_message"])) {$manager_message=$_GET["manager_message"];}
|
||||
elseif (isset($_POST["manager_message"])) {$manager_message=$_POST["manager_message"];}
|
||||
if (isset($_GET["DB"])) {$DB=$_GET["DB"];}
|
||||
elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];}
|
||||
if (isset($_GET["action"])) {$action=$_GET["action"];}
|
||||
elseif (isset($_POST["action"])) {$action=$_POST["action"];}
|
||||
if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];}
|
||||
elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];}
|
||||
if (isset($_GET["manager_chat_id"])) {$manager_chat_id=$_GET["manager_chat_id"];}
|
||||
elseif (isset($_POST["manager_chat_id"])) {$manager_chat_id=$_POST["manager_chat_id"];}
|
||||
if (isset($_GET["available_chat_agents"])) {$available_chat_agents=$_GET["available_chat_agents"];}
|
||||
elseif (isset($_POST["available_chat_agents"])) {$available_chat_agents=$_POST["available_chat_agents"];}
|
||||
if (isset($_GET["available_chat_groups"])) {$available_chat_groups=$_GET["available_chat_groups"];}
|
||||
elseif (isset($_POST["available_chat_groups"])) {$available_chat_groups=$_POST["available_chat_groups"];}
|
||||
if (isset($_GET["available_chat_campaigns"])) {$available_chat_campaigns=$_GET["available_chat_campaigns"];}
|
||||
elseif (isset($_POST["available_chat_campaigns"])) {$available_chat_campaigns=$_POST["available_chat_campaigns"];}
|
||||
if (isset($_GET["manager_message"])) {$manager_message=$_GET["manager_message"];}
|
||||
elseif (isset($_POST["manager_message"])) {$manager_message=$_POST["manager_message"];}
|
||||
if (isset($_GET["allow_replies"])) {$allow_replies=$_GET["allow_replies"];}
|
||||
elseif (isset($_POST["allow_replies"])) {$allow_replies=$_POST["allow_replies"];}
|
||||
elseif (isset($_POST["allow_replies"])) {$allow_replies=$_POST["allow_replies"];}
|
||||
if (isset($_GET["end_all_chats"])) {$end_all_chats=$_GET["end_all_chats"];}
|
||||
elseif (isset($_POST["end_all_chats"])) {$end_all_chats=$_POST["end_all_chats"];}
|
||||
elseif (isset($_POST["end_all_chats"])) {$end_all_chats=$_POST["end_all_chats"];}
|
||||
if (isset($_GET["submit_chat"])) {$submit_chat=$_GET["submit_chat"];}
|
||||
elseif (isset($_POST["submit_chat"])) {$submit_chat=$_POST["submit_chat"];}
|
||||
elseif (isset($_POST["submit_chat"])) {$submit_chat=$_POST["submit_chat"];}
|
||||
if (!$allow_replies) {$allow_replies="N";}
|
||||
|
||||
|
||||
#############################################
|
||||
##### START SYSTEM_SETTINGS LOOKUP #####
|
||||
$stmt = "SELECT use_non_latin,enable_queuemetrics_logging,enable_vtiger_integration,qc_features_active,outbound_autodial_active,sounds_central_control_active,enable_second_webform,user_territories_active,custom_fields_enabled,admin_web_directory,webphone_url,first_login_trigger,hosted_settings,default_phone_registration_password,default_phone_login_password,default_server_password,test_campaign_calls,active_voicemail_server,voicemail_timezones,default_voicemail_timezone,default_local_gmt,campaign_cid_areacodes_enabled,pllb_grouping_limit,did_ra_extensions_enabled,expanded_list_stats,contacts_enabled,alt_log_server_ip,alt_log_dbname,alt_log_login,alt_log_pass,tables_use_alt_log_db,allow_emails,allow_emails,level_8_disable_add,allow_chats FROM system_settings;";
|
||||
$VUselected_language = '';
|
||||
$stmt = "SELECT use_non_latin,enable_queuemetrics_logging,enable_vtiger_integration,qc_features_active,outbound_autodial_active,sounds_central_control_active,enable_second_webform,user_territories_active,custom_fields_enabled,admin_web_directory,webphone_url,first_login_trigger,hosted_settings,default_phone_registration_password,default_phone_login_password,default_server_password,test_campaign_calls,active_voicemail_server,voicemail_timezones,default_voicemail_timezone,default_local_gmt,campaign_cid_areacodes_enabled,pllb_grouping_limit,did_ra_extensions_enabled,expanded_list_stats,contacts_enabled,alt_log_server_ip,alt_log_dbname,alt_log_login,alt_log_pass,tables_use_alt_log_db,allow_emails,allow_emails,level_8_disable_add,allow_chats,enable_languages,language_method,default_language FROM system_settings;";
|
||||
$rslt=mysql_to_mysqli($stmt, $link);
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$qm_conf_ct = mysqli_num_rows($rslt);
|
||||
@@ -89,7 +92,11 @@ if ($qm_conf_ct > 0)
|
||||
$SSemail_enabled = $row[32];
|
||||
$SSlevel_8_disable_add = $row[33];
|
||||
$SSallow_chats = $row[34];
|
||||
$SSenable_languages = $row[35];
|
||||
$SSlanguage_method = $row[36];
|
||||
$SSdefault_language = $row[37];
|
||||
}
|
||||
$VUselected_language = $SSdefault_language;
|
||||
##### END SETTINGS LOOKUP #####
|
||||
###########################################
|
||||
|
||||
@@ -135,7 +142,26 @@ if ($auth < 1)
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($end_all_chats) {
|
||||
$user_stmt="select full_name,user_level,selected_language from vicidial_users where user='$PHP_AUTH_USER'";
|
||||
$user_level=0;
|
||||
$user_rslt=mysql_to_mysqli($user_stmt, $link);
|
||||
if (mysqli_num_rows($user_rslt)>0)
|
||||
{
|
||||
$user_row=mysqli_fetch_row($user_rslt);
|
||||
$full_name = $user_row[0];
|
||||
$user_level = $user_row[1];
|
||||
$VUselected_language = $user_row[2];
|
||||
}
|
||||
if ($SSallow_chats < 1)
|
||||
{
|
||||
header ("Content-type: text/html; charset=utf-8");
|
||||
echo _QXZ("Error, chat disabled on this system");
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
if ($end_all_chats)
|
||||
{
|
||||
$archive_stmt="insert ignore into vicidial_manager_chat_log_archive select * from vicidial_manager_chat_log where manager_chat_id='$end_all_chats'";
|
||||
$archive_rslt=mysqli_query($link, $archive_stmt);
|
||||
|
||||
@@ -147,16 +173,19 @@ if ($end_all_chats) {
|
||||
|
||||
$archive_stmt="delete from vicidial_manager_chats where manager_chat_id='$end_all_chats'";
|
||||
$archive_rslt=mysqli_query($link, $archive_stmt);
|
||||
}
|
||||
}
|
||||
|
||||
if ($submit_chat=="ALL LIVE AGENTS") {
|
||||
if ($submit_chat == _QXZ("ALL LIVE AGENTS"))
|
||||
{
|
||||
$chat_agents_SQL_OR="";
|
||||
$chat_groups_SQL_OR="";
|
||||
$chat_campaigns_SQL_OR="";
|
||||
$available_chat_agents_string='|';
|
||||
$available_chat_groups_string='|';
|
||||
$available_chat_campaigns_string='|';
|
||||
} else if ($submit_chat) {
|
||||
}
|
||||
else if ($submit_chat)
|
||||
{
|
||||
$i=0;
|
||||
$available_chat_agents_string='|';
|
||||
$available_chat_agents_ct = count($available_chat_agents);
|
||||
@@ -195,33 +224,40 @@ if ($submit_chat=="ALL LIVE AGENTS") {
|
||||
}
|
||||
$chat_campaigns_SQL_OR=preg_replace("/,$/", "", $chat_campaigns_SQL_OR);
|
||||
$chat_campaigns_SQL_OR.=") ";
|
||||
}
|
||||
if (strlen($chat_agents_SQL_OR.$chat_groups_SQL_OR.$chat_campaigns_SQL_OR)>0) {
|
||||
}
|
||||
if (strlen($chat_agents_SQL_OR.$chat_groups_SQL_OR.$chat_campaigns_SQL_OR)>0)
|
||||
{
|
||||
$chat_query_SQL=" and (".$chat_agents_SQL_OR.$chat_groups_SQL_OR.$chat_campaigns_SQL_OR.")";
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
$chat_query_SQL="";
|
||||
}
|
||||
}
|
||||
|
||||
$check_stmt="select manager_chat_id from vicidial_manager_chats where manager='$PHP_AUTH_USER' limit 1";
|
||||
$check_rslt=mysqli_query($link, $check_stmt);
|
||||
$active_chats=mysqli_num_rows($check_rslt);
|
||||
if ($active_chats>0) {
|
||||
if ($active_chats>0)
|
||||
{
|
||||
$active_row=mysqli_fetch_row($check_rslt);
|
||||
$manager_chat_id=$active_row[0];
|
||||
}
|
||||
}
|
||||
|
||||
if ($active_chats<1 && $manager_message && ($submit_chat=="ALL LIVE AGENTS" || ($submit_chat=="SELECTED AGENTS" && ($available_chat_agents_ct+$available_chat_groups_ct+$available_chat_campaigns_ct)>0))) {
|
||||
if ($active_chats<1 && $manager_message && ($submit_chat== _QXZ("ALL LIVE AGENTS") || ($submit_chat== _QXZ("SELECTED AGENTS") && ($available_chat_agents_ct+$available_chat_groups_ct+$available_chat_campaigns_ct)>0)))
|
||||
{
|
||||
$stmt="select vicidial_live_agents.user, vicidial_users.full_name from vicidial_live_agents, vicidial_users where vicidial_live_agents.user=vicidial_users.user $chat_query_SQL and vicidial_users.user!='$PHP_AUTH_USER' order by vicidial_users.full_name asc";
|
||||
$rslt=mysqli_query($link, $stmt);
|
||||
echo "<!-- $stmt //-->\n";
|
||||
if (mysqli_num_rows($rslt)>0) {
|
||||
if (mysqli_num_rows($rslt)>0)
|
||||
{
|
||||
$ins_stmt="insert into vicidial_manager_chats(chat_start_date, manager, selected_agents, selected_user_groups, selected_campaigns, allow_replies) VALUES(now(), '$PHP_AUTH_USER', '$available_chat_agents_string', '$available_chat_groups_string', '$available_chat_campaigns_string', '$allow_replies')";
|
||||
echo "<!-- $ins_stmt //-->\n";
|
||||
$ins_rslt=mysqli_query($link, $ins_stmt);
|
||||
$manager_chat_id=mysqli_insert_id($link);
|
||||
|
||||
$subid=1;
|
||||
while($row=mysqli_fetch_row($rslt)) {
|
||||
while($row=mysqli_fetch_row($rslt))
|
||||
{
|
||||
$user=$row[0];
|
||||
|
||||
#$manager_message = preg_replace('/"/i','',$manager_message);
|
||||
@@ -237,9 +273,9 @@ if ($active_chats<1 && $manager_message && ($submit_chat=="ALL LIVE AGENTS" || (
|
||||
$ins_chat_rslt=mysqli_query($link, $ins_chat_stmt);
|
||||
echo "<!-- $ins_chat_stmt //-->\n";
|
||||
$subid++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (($LOGuser_level < 9) and ($SSlevel_8_disable_add > 0))
|
||||
{$add_copy_disabled++;}
|
||||
@@ -283,14 +319,303 @@ while ($UUgroups_to_print > $o)
|
||||
$o++;
|
||||
}
|
||||
|
||||
|
||||
header ("Content-type: text/html; charset=utf-8");
|
||||
header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
|
||||
header ("Pragma: no-cache"); // HTTP/1.0
|
||||
echo '<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
';
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
||||
</head>
|
||||
<link rel="stylesheet" href="vicidial_stylesheet.css">
|
||||
<script language="JavaScript" src="vicidial_chat.js"></script>
|
||||
<script language="JavaScript">
|
||||
|
||||
function RefreshChatDisplay(manager_chat_id) {
|
||||
var xmlhttp=false;
|
||||
/*@cc_on @*/
|
||||
/*@if (@_jscript_version >= 5)
|
||||
// JScript gives us Conditional compilation, we can cope with old IE versions.
|
||||
// and security blocked creation of the objects.
|
||||
try {
|
||||
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
|
||||
} catch (e) {
|
||||
try {
|
||||
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
|
||||
} catch (E) {
|
||||
xmlhttp = false;
|
||||
}
|
||||
}
|
||||
@end @*/
|
||||
if (!xmlhttp && typeof XMLHttpRequest!='undefined')
|
||||
{
|
||||
xmlhttp = new XMLHttpRequest();
|
||||
}
|
||||
if (xmlhttp)
|
||||
{
|
||||
chat_SQL_query = "reload_chat_span=1";
|
||||
xmlhttp.open('POST', 'manager_chat_actions.php');
|
||||
xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8');
|
||||
xmlhttp.send(chat_SQL_query);
|
||||
xmlhttp.onreadystatechange = function()
|
||||
{
|
||||
if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
|
||||
{
|
||||
var ChatText = null;
|
||||
ChatText = xmlhttp.responseText;
|
||||
document.getElementById("ManagerChatAvailabilityDisplay").innerHTML=ChatText;
|
||||
}
|
||||
}
|
||||
delete xmlhttp;
|
||||
}
|
||||
}
|
||||
|
||||
function CheckNewMessages(manager_chat_id) {
|
||||
var xmlhttp=false;
|
||||
/*@cc_on @*/
|
||||
/*@if (@_jscript_version >= 5)
|
||||
// JScript gives us Conditional compilation, we can cope with old IE versions.
|
||||
// and security blocked creation of the objects.
|
||||
try {
|
||||
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
|
||||
} catch (e) {
|
||||
try {
|
||||
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
|
||||
} catch (E) {
|
||||
xmlhttp = false;
|
||||
}
|
||||
}
|
||||
@end @*/
|
||||
if (!xmlhttp && typeof XMLHttpRequest!='undefined')
|
||||
{
|
||||
xmlhttp = new XMLHttpRequest();
|
||||
}
|
||||
if (xmlhttp)
|
||||
{
|
||||
chat_SQL_query = "action=CheckNewMessages&manager_chat_id="+manager_chat_id;
|
||||
// alert(chat_SQL_query);
|
||||
xmlhttp.open('POST', 'manager_chat_actions.php');
|
||||
xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8');
|
||||
xmlhttp.send(chat_SQL_query);
|
||||
xmlhttp.onreadystatechange = function()
|
||||
{
|
||||
if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
|
||||
{
|
||||
var ChatResponseText = null;
|
||||
ChatResponseText = xmlhttp.responseText;
|
||||
if (ChatResponseText==0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
var sub_ids=[];
|
||||
var ChatText_array=ChatResponseText.split("\n");
|
||||
for (var i=0; i<ChatText_array.length; i++)
|
||||
{
|
||||
if (ChatText_array[i].length>0) {sub_ids.push(ChatText_array[i]);}
|
||||
}
|
||||
// console.log(sub_ids);
|
||||
RefreshChatSubIDs(manager_chat_id, sub_ids);
|
||||
}
|
||||
}
|
||||
}
|
||||
delete xmlhttp;
|
||||
}
|
||||
}
|
||||
|
||||
function RefreshChatSubIDs(manager_chat_id, sub_ids) {
|
||||
var xmlhttp=false;
|
||||
/*@cc_on @*/
|
||||
/*@if (@_jscript_version >= 5)
|
||||
// JScript gives us Conditional compilation, we can cope with old IE versions.
|
||||
// and security blocked creation of the objects.
|
||||
try {
|
||||
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
|
||||
} catch (e) {
|
||||
try {
|
||||
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
|
||||
} catch (E) {
|
||||
xmlhttp = false;
|
||||
}
|
||||
}
|
||||
@end @*/
|
||||
if (!xmlhttp && typeof XMLHttpRequest!='undefined')
|
||||
{
|
||||
xmlhttp = new XMLHttpRequest();
|
||||
}
|
||||
if (xmlhttp)
|
||||
{
|
||||
var sub_id_str="";
|
||||
for (var i=0; i<sub_ids.length; i++)
|
||||
{
|
||||
sub_id_str+="&chat_sub_ids[]="+sub_ids[i];
|
||||
}
|
||||
chat_SQL_query = "action=PrintSubChatText&manager_chat_id="+manager_chat_id+sub_id_str;
|
||||
// alert(chat_SQL_query);
|
||||
xmlhttp.open('POST', 'manager_chat_actions.php');
|
||||
xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8');
|
||||
xmlhttp.send(chat_SQL_query);
|
||||
xmlhttp.onreadystatechange = function()
|
||||
{
|
||||
if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
|
||||
{
|
||||
var ChatResponseText = null;
|
||||
ChatResponseText = xmlhttp.responseText;
|
||||
var ChatText_array=ChatResponseText.split("\n");
|
||||
for (var j=1; j<ChatText_array.length; j+=2)
|
||||
{
|
||||
var manager_chat_span_id=ChatText_array[j-1];
|
||||
var ChatText=ChatText_array[j];
|
||||
if (document.getElementById(manager_chat_span_id))
|
||||
{
|
||||
document.getElementById(manager_chat_span_id).innerHTML=ChatText;
|
||||
var objDiv = document.getElementById(manager_chat_span_id);
|
||||
objDiv.scrollTop = objDiv.scrollHeight;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
delete xmlhttp;
|
||||
}
|
||||
}
|
||||
|
||||
function PrintSubChatText(manager_chat_id, chat_sub_id) {
|
||||
var xmlhttp=false;
|
||||
/*@cc_on @*/
|
||||
/*@if (@_jscript_version >= 5)
|
||||
// JScript gives us Conditional compilation, we can cope with old IE versions.
|
||||
// and security blocked creation of the objects.
|
||||
try {
|
||||
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
|
||||
} catch (e) {
|
||||
try {
|
||||
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
|
||||
} catch (E) {
|
||||
xmlhttp = false;
|
||||
}
|
||||
}
|
||||
@end @*/
|
||||
if (!xmlhttp && typeof XMLHttpRequest!='undefined')
|
||||
{
|
||||
xmlhttp = new XMLHttpRequest();
|
||||
}
|
||||
if (xmlhttp)
|
||||
{
|
||||
var manager_chat_span_id="manager_chat_"+manager_chat_id+"_"+chat_sub_id;
|
||||
chat_SQL_query = "action=PrintSubChatText&manager_chat_id="+manager_chat_id+"&chat_sub_id="+chat_sub_id;
|
||||
xmlhttp.open('POST', 'manager_chat_actions.php');
|
||||
xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8');
|
||||
xmlhttp.send(chat_SQL_query);
|
||||
xmlhttp.onreadystatechange = function()
|
||||
{
|
||||
if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
|
||||
{
|
||||
var ChatText = null;
|
||||
ChatText = xmlhttp.responseText;
|
||||
document.getElementById(manager_chat_span_id).innerHTML=ChatText;
|
||||
}
|
||||
}
|
||||
delete xmlhttp;
|
||||
}
|
||||
}
|
||||
|
||||
function SendChatMessage(manager_chat_id, chat_sub_id, user) {
|
||||
var xmlhttp=false;
|
||||
/*@cc_on @*/
|
||||
/*@if (@_jscript_version >= 5)
|
||||
// JScript gives us Conditional compilation, we can cope with old IE versions.
|
||||
// and security blocked creation of the objects.
|
||||
try {
|
||||
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
|
||||
} catch (e) {
|
||||
try {
|
||||
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
|
||||
} catch (E) {
|
||||
xmlhttp = false;
|
||||
}
|
||||
}
|
||||
@end @*/
|
||||
if (!xmlhttp && typeof XMLHttpRequest!='undefined')
|
||||
{
|
||||
xmlhttp = new XMLHttpRequest();
|
||||
}
|
||||
if (xmlhttp)
|
||||
{
|
||||
var chat_message_field_id="manager_chat_message_"+manager_chat_id+"_"+chat_sub_id;
|
||||
var chat_message=encodeURIComponent(document.getElementById(chat_message_field_id).value);
|
||||
|
||||
chat_SQL_query = "action=SendChatMessage&manager_chat_id="+manager_chat_id+"&chat_sub_id="+chat_sub_id+"&chat_message="+chat_message+"&user="+user;
|
||||
xmlhttp.open('POST', 'manager_chat_actions.php');
|
||||
xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8');
|
||||
xmlhttp.send(chat_SQL_query);
|
||||
xmlhttp.onreadystatechange = function()
|
||||
{
|
||||
if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
|
||||
{
|
||||
var ChatText = null;
|
||||
ChatText = xmlhttp.responseText;
|
||||
if (ChatText.length>0 && ChatText.match(/^Error/))
|
||||
{
|
||||
alert(ChatText);
|
||||
}
|
||||
else
|
||||
{
|
||||
document.getElementById(chat_message_field_id).value="";
|
||||
}
|
||||
}
|
||||
}
|
||||
delete xmlhttp;
|
||||
}
|
||||
}
|
||||
|
||||
function EndAgentChat(manager_chat_id, chat_sub_id) {
|
||||
var xmlhttp=false;
|
||||
/*@cc_on @*/
|
||||
/*@if (@_jscript_version >= 5)
|
||||
// JScript gives us Conditional compilation, we can cope with old IE versions.
|
||||
// and security blocked creation of the objects.
|
||||
try {
|
||||
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
|
||||
} catch (e) {
|
||||
try {
|
||||
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
|
||||
} catch (E) {
|
||||
xmlhttp = false;
|
||||
}
|
||||
}
|
||||
@end @*/
|
||||
if (!xmlhttp && typeof XMLHttpRequest!='undefined')
|
||||
{
|
||||
xmlhttp = new XMLHttpRequest();
|
||||
}
|
||||
if (xmlhttp)
|
||||
{
|
||||
chat_SQL_query = "action=EndAgentChat&manager_chat_id="+manager_chat_id+"&chat_sub_id="+chat_sub_id;
|
||||
xmlhttp.open('POST', 'manager_chat_actions.php');
|
||||
xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8');
|
||||
xmlhttp.send(chat_SQL_query);
|
||||
xmlhttp.onreadystatechange = function()
|
||||
{
|
||||
if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
|
||||
{
|
||||
var ChatText = null;
|
||||
ChatText = xmlhttp.responseText;
|
||||
if (ChatText=="ALL CHATS CLOSED")
|
||||
{
|
||||
window.location.assign("manager_chat_interface.php");
|
||||
}
|
||||
document.getElementById("ManagerChatDisplay").innerHTML=ChatText;
|
||||
}
|
||||
}
|
||||
delete xmlhttp;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
<title><?php echo _QXZ("ADMINISTRATION: Manager Chat Interface"); ?></title>
|
||||
<?php
|
||||
|
||||
@@ -412,34 +737,38 @@ $NWE = "')\"><IMG SRC=\"help.gif\" WIDTH=20 HEIGHT=20 BORDER=0 ALT=\"HELP\" ALIG
|
||||
} else {
|
||||
echo "<TABLE width=750 cellspacing=1 cellpadding=1>";
|
||||
echo "<TR BGCOLOR=BLACK>\n";
|
||||
echo "<TD align='left' colspan='3'><font FACE=\"ARIAL,HELVETICA\" size=1 color=white><B>CURRENT CHAT #$manager_chat_id</B></font></TD>\n";
|
||||
echo "<TD align='right'><font FACE=\"ARIAL,HELVETICA\" size=1><B><a href='manager_chat_interface.php?end_all_chats=$manager_chat_id' style=\"color: rgb(255,255,255)\">[END ALL CHATS]</a></font></td>";
|
||||
echo "<TD align='left' colspan='3'><font FACE=\"ARIAL,HELVETICA\" size=1 color=white><B>"._QXZ("CURRENT CHAT")." #$manager_chat_id</B></font></TD>\n";
|
||||
echo "<TD align='right'><font FACE=\"ARIAL,HELVETICA\" size=1><B><a href='manager_chat_interface.php?end_all_chats=$manager_chat_id' style=\"color: rgb(255,255,255)\">["._QXZ("END ALL CHATS")."]</a></font></td>";
|
||||
echo "</TR>";
|
||||
echo "<TR BGCOLOR=BLACK>\n";
|
||||
echo "\t<TD align='left'><font FACE=\"ARIAL,HELVETICA\" size=1 color=white>Agent</font></TD>\n";
|
||||
echo "\t<TD align='left' colspan='1'><font FACE=\"ARIAL,HELVETICA\" size=1 color=white>Transcript</font></TD>\n";
|
||||
echo "\t<TD align='left' colspan='2'><font FACE=\"ARIAL,HELVETICA\" size=1 color=white>Message</font></TD>\n";
|
||||
echo "\t<TD align='left'><font FACE=\"ARIAL,HELVETICA\" size=1 color=white>"._QXZ("Agent")."</font></TD>\n";
|
||||
echo "\t<TD align='left' colspan='1'><font FACE=\"ARIAL,HELVETICA\" size=1 color=white>"._QXZ("Transcript")."</font></TD>\n";
|
||||
echo "\t<TD align='left' colspan='2'><font FACE=\"ARIAL,HELVETICA\" size=1 color=white>"._QXZ("Message")."</font></TD>\n";
|
||||
echo "</TR>";
|
||||
$stmt="select vm.message_posted_by, vm.message, vm.message_date, vu.full_name, vm.manager, vm.manager_chat_subid, vm.user from vicidial_manager_chats vmc, vicidial_manager_chat_log vm, vicidial_users vu where vmc.manager_chat_id='$manager_chat_id' and vmc.manager_chat_id=vm.manager_chat_id and vm.user=vu.user order by vm.manager_chat_subid asc, message_date desc";
|
||||
$rslt=mysqli_query($link, $stmt);
|
||||
if (mysqli_num_rows($rslt)>0) {
|
||||
if (mysqli_num_rows($rslt)>0)
|
||||
{
|
||||
$prev_chat_subid="";
|
||||
$backlog_limit=20;
|
||||
$chat_output_header=array();
|
||||
$chat_output_text=array();
|
||||
$chat_output_footer=array();
|
||||
$chat_subids_array="[";
|
||||
while($row=mysqli_fetch_row($rslt)) {
|
||||
while($row=mysqli_fetch_row($rslt))
|
||||
{
|
||||
$full_name=$row[3];
|
||||
$chat_subid=$row[5];
|
||||
$chat_subids_array.="'$chat_subid',";
|
||||
|
||||
if ($backlog_limit>0) {
|
||||
if ($backlog_limit>0)
|
||||
{
|
||||
if ($row[0]==$row[4]) {$fc="#990000";} else {$fc="#000099";}
|
||||
$chat_output_text[$chat_subid]="<font color='$fc' FACE=\"ARIAL,HELVETICA\" size='1'>$row[1]</font><BR>".$chat_output_text[$chat_subid];
|
||||
$backlog_limit--;
|
||||
}
|
||||
if ($prev_chat_subid!=$chat_subid) {
|
||||
}
|
||||
if ($prev_chat_subid!=$chat_subid)
|
||||
{
|
||||
$agent_id=$row[6];
|
||||
if ($bgcolor=="#E6E6E6") {$bgcolor="#FFFFFF";} else {$bgcolor="#E6E6E6";}
|
||||
$chat_output_header[$chat_subid]= "<TR BGCOLOR='$bgcolor'>\n";
|
||||
@@ -449,30 +778,33 @@ $NWE = "')\"><IMG SRC=\"help.gif\" WIDTH=20 HEIGHT=20 BORDER=0 ALT=\"HELP\" ALIG
|
||||
$chat_output_footer[$chat_subid]= "</span></td>";
|
||||
# $chat_output_footer[$chat_subid].="\t<td width='75' align='center'><input type='button' style='width: 75px' class='tiny_green_btn' value='SHOW ALL' onClick='ShowFullChat($manager_chat_id, $chat_subid)'><BR><BR><input type='button' style='width: 75px' class='tiny_red_btn' value='HIDE' onClick='HideFullChat($manager_chat_id, $chat_subid)'></td>";
|
||||
$chat_output_footer[$chat_subid].="\t<td width='250' align='left' valign='top'><textarea class='chat_box' id='manager_chat_message_".$manager_chat_id."_".$chat_subid."' name='manager_chat_message_".$manager_chat_id."_".$chat_subid."' rows='7' cols='40' onkeypress='if (event.keyCode==13 && !event.shiftKey) {SendChatMessage($manager_chat_id, $chat_subid, \"$agent_id\"); return false;}'></textarea></td>";
|
||||
$chat_output_footer[$chat_subid].="\t<td width='75' align='center'><input type='button' style='width: 75px' class='tiny_green_btn' value='SEND' onClick='SendChatMessage($manager_chat_id, $chat_subid, \"$agent_id\")'><BR><BR><input type='button' style='width: 75px' class='tiny_red_btn' value='END' onClick='EndAgentChat($manager_chat_id, $chat_subid)'></td>";
|
||||
$chat_output_footer[$chat_subid].="\t<td width='75' align='center'><input type='button' style='width: 75px' class='tiny_green_btn' value='"._QXZ("SEND")."' onClick='SendChatMessage($manager_chat_id, $chat_subid, \"$agent_id\")'><BR><BR><input type='button' style='width: 75px' class='tiny_red_btn' value='"._QXZ("END")."' onClick='EndAgentChat($manager_chat_id, $chat_subid)'></td>";
|
||||
$chat_output_footer[$chat_subid].="</TR>";
|
||||
|
||||
$backlog_limit=20;
|
||||
$prev_chat_subid=$chat_subid;
|
||||
}
|
||||
}
|
||||
}
|
||||
$chat_subids_array=preg_replace("/,$/", "", $chat_subids_array);
|
||||
$chat_subids_array.="]";
|
||||
while (list($chat_subid, $text) = each($chat_output_header)) {
|
||||
while (list($chat_subid, $text) = each($chat_output_header))
|
||||
{
|
||||
echo $chat_output_header[$chat_subid];
|
||||
echo $chat_output_text[$chat_subid];
|
||||
echo $chat_output_footer[$chat_subid];
|
||||
}
|
||||
}
|
||||
# $reload_function="setInterval(\"CheckNewMessages($manager_chat_id, $chat_subids_array)\", 3000);\n";
|
||||
$reload_function="setInterval(\"CheckNewMessages($manager_chat_id)\", 2000);\n";
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
$reload_function="setInterval(\"RefreshChatDisplay()\", 30000);\n";
|
||||
}
|
||||
}
|
||||
echo "</table>";
|
||||
echo "<script language=\"JavaScript\">\n";
|
||||
echo "$reload_function";
|
||||
echo "</script>\n";
|
||||
}
|
||||
}
|
||||
echo "</span>";
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user