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:
mattf
2015-12-19 22:16:43 +00:00
parent f917c11448
commit 3266980a56
15 changed files with 1449 additions and 1041 deletions
+101 -39
View File
@@ -1,6 +1,6 @@
#!/usr/bin/perl
# ADMIN_www_languages.pl version 2.10
# ADMIN_www_languages.pl version 2.12
#
# This script is designed to traverse the vicidial and agc web directories and
# generate a list of phrases that are output from the QXZ PHP functions so that
@@ -13,11 +13,12 @@
# and alter them if necessary:
# ALTER TABLE audio_store_details CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;
#
# Copyright (C) 2014 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
# Copyright (C) 2015 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# CHANGES
# 141128-0024 - First build
# 141211-2123 - Added --wipe-www-phrases-table CLI option and insert_date field
# 151219-0756 - Added --chat-only option for chat_customer and --one-file-only option
#
$secX = time();
@@ -69,7 +70,9 @@ if (length($ARGV[0])>1)
print " [--debug] = verbose debug messages\n";
print " [--debugX] = extra verbose debug messages\n";
print " [--agc-only] = only parse the agc directory\n";
print " [--chat-only] = only parse the chat_customer directory\n";
print " [--vicidial-only] = only parse the vicidial directory\n";
print " [--one-file-only=/path/from/root] = process one php file only\n";
print " [--QXZlines] = print full lines that include QXZ functions\n";
print " [--QXZvalues] = print only QXZ function values\n";
print " [--QXZvaronly] = print only QXZ function values with PHP variables in them\n";
@@ -89,6 +92,8 @@ if (length($ARGV[0])>1)
{$DBX=1;}
if ($args =~ /--agc-only/i) # agc flag
{$agc_only=1;}
if ($args =~ /--chat-only/i) # agc flag
{$chat_only=1;}
if ($args =~ /--vicidial-only/i) # vicidial flag
{$vicidial_only=1;}
if ($args =~ /--QXZlines/i) # QXZlines flag
@@ -103,6 +108,17 @@ if (length($ARGV[0])>1)
{$QXZplaceonly=1;}
if ($args =~ /--wipe-www-phrases-table/i) # wipewwwphrasestable flag
{$wipewwwphrasestable=1;}
if ($args =~ /--one-file-only=/i) # CLI defined file path for one file only
{
@CLIonefileARY = split(/--one-file-only=/,$args);
@CLIonefileARX = split(/ /,$CLIonefileARY[1]);
if (length($CLIonefileARX[0])>2)
{
$PATHone = $CLIonefileARX[0];
$PATHone =~ s/\/$| |\r|\n|\t//gi;
print " CLI defined one-file-only path: $PATHone\n";
}
}
if ($args =~ /--conffile=/i) # CLI defined file path
{
@CLIconffileARY = split(/--conffile=/,$args);
@@ -195,51 +211,97 @@ if ($wipewwwphrasestable > 0)
$i=0;
$f=0;
if ($vicidial_only < 1)
if (length($PATHone) > 2)
{
opendir(FILE, "$PATHweb/agc/");
@agcFILES = readdir(FILE);
### Loop through files first to gather list
foreach(@agcFILES)
$FILEparseDIR[$f] = "$PATHweb/temp/";
$FILEparseNAME[$f] = '';
$FILEparse[$f] = '';
if ( (length($PATHone) > 2) && (!-d "$PATHone") )
{
$FILEparseDIR[$f] = "$PATHweb/agc/";
$FILEparseNAME[$f] = '';
$FILEparse[$f] = '';
if ( (length($agcFILES[$i]) > 2) && (!-d "$PATHweb/agc/$agcFILES[$i]") )
{
$FILEparse[$f] = "$PATHweb/agc/$agcFILES[$i]";
$FILEparseNAME[$f] = $agcFILES[$i];
$event_string = "$PATHweb/agc/$agcFILES[$i] $FILEparseNAME[$f]";
if ($DBX > 0) {print "$event_string\n";}
&event_logger;
$f++;
}
$i++;
$FILEparse[$f] = "$PATHone";
@oneARY = split("/", $PATHone);
$FILEparseNAME[$f] = $oneARY[-1];
$event_string = "$PATHone $FILEparseNAME[$f]";
if ($DBX > 0) {print "$event_string\n";}
&event_logger;
$f++;
}
$i++;
}
$i=0;
if ($agc_only < 1)
else
{
opendir(FILE, "$PATHweb/vicidial/");
@vicidialFILES = readdir(FILE);
### Loop through files first to gather list
foreach(@vicidialFILES)
$i=0;
if ( ($vicidial_only < 1) && ($chat_only < 1) )
{
$FILEparseDIR[$f] = "$PATHweb/vicidial/";
$FILEparseNAME[$f] = '';
$FILEparse[$f] = '';
if ( (length($vicidialFILES[$i]) > 2) && (!-d "$PATHweb/vicidial/$vicidialFILES[$i]") )
opendir(FILE, "$PATHweb/agc/");
@agcFILES = readdir(FILE);
### Loop through files first to gather list
foreach(@agcFILES)
{
$FILEparse[$f] = "$PATHweb/vicidial/$vicidialFILES[$i]";
$FILEparseNAME[$f] = $vicidialFILES[$i];
$event_string = "$PATHweb/vicidial/$vicidialFILES[$i] $FILEparseNAME[$f]";
if ($DBX > 0) {print "$event_string\n";}
&event_logger;
$f++;
$FILEparseDIR[$f] = "$PATHweb/agc/";
$FILEparseNAME[$f] = '';
$FILEparse[$f] = '';
if ( (length($agcFILES[$i]) > 2) && (!-d "$PATHweb/agc/$agcFILES[$i]") )
{
$FILEparse[$f] = "$PATHweb/agc/$agcFILES[$i]";
$FILEparseNAME[$f] = $agcFILES[$i];
$event_string = "$PATHweb/agc/$agcFILES[$i] $FILEparseNAME[$f]";
if ($DBX > 0) {print "$event_string\n";}
&event_logger;
$f++;
}
$i++;
}
}
$i=0;
if ( ($agc_only < 1) && ($chat_only < 1) )
{
opendir(FILE, "$PATHweb/vicidial/");
@vicidialFILES = readdir(FILE);
### Loop through files first to gather list
foreach(@vicidialFILES)
{
$FILEparseDIR[$f] = "$PATHweb/vicidial/";
$FILEparseNAME[$f] = '';
$FILEparse[$f] = '';
if ( (length($vicidialFILES[$i]) > 2) && (!-d "$PATHweb/vicidial/$vicidialFILES[$i]") )
{
$FILEparse[$f] = "$PATHweb/vicidial/$vicidialFILES[$i]";
$FILEparseNAME[$f] = $vicidialFILES[$i];
$event_string = "$PATHweb/vicidial/$vicidialFILES[$i] $FILEparseNAME[$f]";
if ($DBX > 0) {print "$event_string\n";}
&event_logger;
$f++;
}
$i++;
}
}
$i=0;
if ( ($vicidial_only < 1) && ($agc_only < 1) )
{
opendir(FILE, "$PATHweb/chat_customer/");
@chat_customerFILES = readdir(FILE);
### Loop through files first to gather list
foreach(@chat_customerFILES)
{
$FILEparseDIR[$f] = "$PATHweb/chat_customer/";
$FILEparseNAME[$f] = '';
$FILEparse[$f] = '';
if ( (length($chat_customerFILES[$i]) > 2) && (!-d "$PATHweb/chat_customer/$chat_customerFILES[$i]") )
{
$FILEparse[$f] = "$PATHweb/chat_customer/$chat_customerFILES[$i]";
$FILEparseNAME[$f] = $chat_customerFILES[$i];
$event_string = "$PATHweb/chat_customer/$chat_customerFILES[$i] $FILEparseNAME[$f]";
if ($DBX > 0) {print "$event_string\n";}
&event_logger;
$f++;
}
$i++;
}
$i++;
}
}
+10 -1
View File
@@ -1,4 +1,4 @@
CHAT MESSAGING Started 2014-05-01 Updated 2015-12-17
CHAT MESSAGING Started 2014-05-01 Updated 2015-12-19
After over 18 months of development, the Chat Messaging system for Vicidial was added to svn/trunk on December 13th, 2015(svn revision 2428). Our Chat messaging allows for customers to chat with agents from websites, as well as allowing managers to chat with agents and agents to chat with other agents all within their existing agent screen.
@@ -6,6 +6,8 @@ After over 18 months of development, the Chat Messaging system for Vicidial was
The Chat Messaging built into Vicidial is entirely web-based and uses it's own protocol. Also, all messages are logged and searchable though the Agent-Manager Chat Log accessible through the Admin Utilities webpage.
UPDATE 2015-12-19: We added several security enhancements related to the chat functionality. We strongly recommend that you update your system to svn/trunk revision 2435 or higher if you are running revision between 2428 and 2434. We also added dynamic language capability throughout the chat screens.
AGENT CHAT INTERFACE INSTRUCTIONS:
@@ -54,6 +56,13 @@ If you want to put a chat page within your own IFRAME and use a specific in-grou
http://192.168.1.2/chat_customer/vicidial_chat_customer_side.php?group_id=TESTCHAT
If you want to link to chat with a specific in-group and language ID in the system, you can use a link like this,
http://192.168.1.2/chat_customer/customer_chat_code.php?group_id=TESTCHAT&language=new_spanish
If you want to put a chat page within your own IFRAME and use a specific in-group and language ID in the system, you can use a URL like this,
http://192.168.1.2/chat_customer/vicidial_chat_customer_side.php?group_id=TESTCHAT&language=new_spanish
Chat settings in System Settings:
@@ -8,36 +8,17 @@
# changes:
# 141212-2245 - First Build
# 151213-1108 - Added variable filtering
# 151218-1141 - Added missing translation code and user auth, merged js code into file
#
$admin_version = '2.12-2';
$build = '151213-1108';
$admin_version = '2.12-3';
$build = '151218-1141';
$sh="managerchats";
require("dbconnect_mysqli.php");
require("functions.php");
#############################################
##### START SYSTEM_SETTINGS LOOKUP #####
$stmt = "SELECT use_non_latin,enable_languages,language_method FROM system_settings;";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00XXX',$user,$server_ip,$session_name,$one_mysql_log);}
if ($DB) {echo "$stmt\n";}
$qm_conf_ct = mysqli_num_rows($rslt);
if ($qm_conf_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$non_latin = $row[0];
$SSenable_languages = $row[1];
$SSlanguage_method = $row[2];
}
##### END SETTINGS LOOKUP #####
###########################################
$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"];}
@@ -65,6 +46,56 @@ else
$manager_chat_id = preg_replace("/\'|\"|\\\\|;/","",$user);
}
#############################################
##### START SYSTEM_SETTINGS LOOKUP #####
$VUselected_language = '';
$stmt = "SELECT use_non_latin,enable_languages,language_method,default_language,allow_chats FROM system_settings;";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00XXX',$user,$server_ip,$session_name,$one_mysql_log);}
if ($DB) {echo "$stmt\n";}
$qm_conf_ct = mysqli_num_rows($rslt);
if ($qm_conf_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$non_latin = $row[0];
$SSenable_languages = $row[1];
$SSlanguage_method = $row[2];
$SSdefault_language = $row[3];
$SSallow_chats = $row[4];
}
$VUselected_language = $SSdefault_language;
##### END SETTINGS LOOKUP #####
###########################################
$auth=0;
$auth_message = user_authorization($user,$pass,'',0,0,0);
if ($auth_message == 'GOOD')
{$auth=1;}
if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0))
{
echo _QXZ("Invalid Username/Password:")." |$user|$pass|$auth_message|$sh|\n";
exit;
}
$user_stmt="select full_name,user_level,selected_language from vicidial_users where user='$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;
}
# Get a count on unread messages where the user is involved but not the chat manager/initiator in order to create the ChatReloadIDNumber variable
$chat_reload_id_number_array=array();
$unread_stmt="select manager_chat_id, manager_chat_subid, sum(if(message_viewed_date is not null, 0, 1)) as unread_count from vicidial_manager_chat_log where vicidial_manager_chat_log.user='$user' group by manager_chat_id, manager_chat_subid order by manager_chat_id, manager_chat_subid";
@@ -137,6 +168,13 @@ while (list($key, $id_number) = each($chat_reload_id_number_array)) {
$ChatReloadIDNumber.="$id_number.";
}
$ChatReloadIDNumber=substr($ChatReloadIDNumber,0,-1);
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>
@@ -144,31 +182,424 @@ $ChatReloadIDNumber=substr($ChatReloadIDNumber,0,-1);
</head>
<link rel="stylesheet" href="vicidial_stylesheet.css">
<link rel="stylesheet" href="css/simpletree.css">
<script language="JavaScript" src="vicidial_chat_agent.js"></script>
<script language="JavaScript">
// ################################################################################
// Show parent alert
function chat_alert_box(temp_message)
{
window.parent.document.getElementById("AlertBoxContent").innerHTML = temp_message;
parent.showDiv('AlertBox');
window.parent.document.alert_form.alert_button.focus();
}
/// Functions for agent/manager chatting
function CreateAgentToAgentChat() {
var agent_message=encodeURIComponent(document.getElementById("agent_message").value);
var user=document.getElementById("user").value;
var pass='<?php echo $pass ?>';
var agent=document.getElementById("agent").value;
if (!agent_message || agent_message=="")
{
chat_alert_box("<?php echo _QXZ("Please enter a chat message"); ?>");
return false;
}
if (!agent || agent=="")
{
chat_alert_box("<?php echo _QXZ("Please select an agent to chat with"); ?>");
return false;
}
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_SQL_query = "action=CreateAgentToAgentChat&agent_manager="+user+"&pass="+pass+"&agent_user="+agent+"&manager_message="+agent_message+"&user="+user;
xmlhttp.open('POST', 'chat_db_query.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;
var ChatText_array=ChatText.split("|");
if (ChatText.match(/^Error/))
{
chat_alert_box(ChatText);
}
else
{
document.getElementById("agent_message").value="";
document.getElementById("AgentNewChatSpan").style.display='none';
document.getElementById("AgentChatSpan").style.display='block';
document.getElementById("AgentEndChatSpan").style.display = 'block';
document.getElementById("AgentManagerOverride").value=agent;
document.getElementById("CurrentActiveChat").value=ChatText_array[0];
document.getElementById("CurrentActiveChatSubID").value=ChatText_array[1];
}
}
}
delete xmlhttp;
}
}
// Displays selected chat, also marks any message on it as read.
function DisplayMgrAgentChat(manager_chat_id, manager_chat_subid) {
if (manager_chat_id)
{
document.getElementById("CurrentActiveChat").value=manager_chat_id;
document.getElementById("CurrentActiveChatSubID").value=manager_chat_subid;
}
else
{
var manager_chat_id=document.getElementById("CurrentActiveChat").value;
var manager_chat_subid=document.getElementById("CurrentActiveChatSubID").value;
}
if (!manager_chat_id || !manager_chat_subid)
{
document.getElementById("AllowAgentReplies").style.display = 'none';
// document.getElementById("ActiveManagerChatTranscript").innerHTML=ChatText_array[1];
// document.getElementById("ActiveChatStartDate").innerHTML=ChatText_array[2];
// document.getElementById("ActiveChatManager").innerHTML=ChatText_array[3];
return false;
}
var user=document.getElementById("user").value;
var pass='<?php echo $pass ?>';
var agent_override=document.getElementById("AgentManagerOverride").value;
// JCJ - commented out 10/19 so any agent in a-2-a chat can end it.
// if (agent_override && agent_override!="0" && agent_override!="")
// {
document.getElementById("AgentEndChatSpan").style.display = 'block';
// }
// else
// {
// document.getElementById("AgentEndChatSpan").style.display = 'none';
// }
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_SQL_query = "action=DisplayMgrAgentChat&user="+user+"&pass="+pass+"&manager_chat_id="+manager_chat_id+"&manager_chat_subid="+manager_chat_subid;
xmlhttp.open('POST', 'chat_db_query.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;
var ChatText_array=ChatText.split("\n");
var allow_agent_replies=ChatText_array[0];
var new_messages=ChatText_array[4];
if (allow_agent_replies=="Y")
{
document.getElementById("AllowAgentReplies").style.display = 'block';
}
else
{
document.getElementById("AllowAgentReplies").style.display = 'none';
}
document.getElementById("ActiveManagerChatTranscript").innerHTML=ChatText_array[1];
document.getElementById("ActiveChatStartDate").innerHTML=ChatText_array[2];
document.getElementById("ActiveChatManager").innerHTML=ChatText_array[3];
document.getElementById("ActiveManagerChatTranscript").scrollTop = document.getElementById("ActiveManagerChatTranscript").scrollHeight;
RefreshActiveChatView();
}
}
delete xmlhttp;
}
}
// Ends selected displayed chat
function EndAgentToAgentChat() {
var manager_chat_id=document.getElementById("CurrentActiveChat").value;
var manager_chat_subid=document.getElementById("CurrentActiveChatSubID").value;
var user=document.getElementById("user").value;
var pass='<?php echo $pass ?>';
if (!manager_chat_id || !manager_chat_subid)
{
document.getElementById("AllowAgentReplies").style.display = 'none';
return false;
}
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_SQL_query = "action=EndAgentToAgentChat&user="+user+"&pass="+pass+"&manager_chat_id="+manager_chat_id+"&manager_chat_subid="+manager_chat_subid;
xmlhttp.open('POST', 'chat_db_query.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; // echoes number of lines affected - should be greater than zero.
if (ChatText>0)
{
document.getElementById("AllowAgentReplies").style.display = 'none';
document.getElementById("AgentEndChatSpan").style.display = 'none';
document.getElementById("ActiveManagerChatTranscript").innerHTML='';
document.getElementById("AgentManagerOverride").value='';
document.getElementById("ActiveChatStartDate").innerHTML='';
document.getElementById("ActiveChatManager").innerHTML='';
}
RefreshActiveChatView();
}
}
delete xmlhttp;
}
}
function RefreshActiveChatView() {
var user=document.getElementById("user").value;
var pass='<?php echo $pass ?>';
var ChatReloadIDNumber=document.getElementById("ChatReloadIDNumber").value;
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_SQL_query = "action=RefreshActiveChatView&user="+user+"&pass="+pass+"&ChatReloadIDNumber="+ChatReloadIDNumber;
xmlhttp.open('POST', 'chat_db_query.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 ActiveChatText = null;
ActiveChatText = xmlhttp.responseText;
if(ActiveChatText!="")
{
var ActiveChatText_array=ActiveChatText.split("|");
document.getElementById("ChatReloadIDNumber").value=ActiveChatText_array[0];
document.getElementById("AllActiveChats").innerHTML=ActiveChatText_array[1];
}
}
}
delete xmlhttp;
}
}
function ReloadAgentNewChatSpan(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_SQL_query = "action=ReloadAgentNewChatSpan&user="+user+"&pass="+pass;
xmlhttp.open('POST', 'chat_db_query.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 Agent2AgentText = xmlhttp.responseText;
document.getElementById("AgentNewChatSpan").innerHTML=Agent2AgentText;
}
}
delete xmlhttp;
}
}
function SendMgrChatMessage(manager_chat_id, manager_chat_subid) {
// if (!manager_chat_id) {return false;}
if (manager_chat_id)
{
document.getElementById("CurrentActiveChat").value=manager_chat_id;
document.getElementById("CurrentActiveChatSubID").value=manager_chat_subid;
}
else
{
var manager_chat_id=document.getElementById("CurrentActiveChat").value;
var manager_chat_subid=document.getElementById("CurrentActiveChatSubID").value;
}
var user=document.getElementById("user").value;
var pass='<?php echo $pass ?>';
var agent_override=document.getElementById("AgentManagerOverride").value;
var chat_message=encodeURIComponent(document.getElementById("manager_message").value);
if (!chat_message || chat_message=="") {return false;}
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_SQL_query = "action=SendMgrChatMessage&user="+user+"&pass="+pass+"&manager_chat_id="+manager_chat_id+"&manager_chat_subid="+manager_chat_subid+"&chat_message="+chat_message+"&agent_override="+agent_override;
xmlhttp.open('POST', 'chat_db_query.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/))
{
chat_alert_box(ChatText);
}
else
{
document.getElementById("manager_message").value="";
}
}
}
delete xmlhttp;
}
}
function MgrAgentAutoRefresh() {
rInt=window.setInterval(function() {DisplayMgrAgentChat()}, 1000);
}
</script>
<title><?php echo _QXZ("ADMINISTRATION: Agent/Manager Chat Interface"); ?></title>
<body onLoad="MgrAgentAutoRefresh();" onUnLoad="clearInterval(rInt);"><!-- DisplayMgrAgentChat(<?php echo $priority_chat; ?>); //-->
<body onLoad="MgrAgentAutoRefresh();" onUnLoad="clearInterval(rInt);"><!-- DisplayMgrAgentChat(<?php echo $priority_chat; ?>); -->
<span id="AgentChatSpan" name="AgentChatSpan" style="display: block;">
<?php
echo "<form name='agent_manager_chat_form' id='agent_manager_chat_form'>";
echo "<table width='620' border='0' cellpadding='5' cellspacing='0'>";
echo "<TR BGCOLOR='#E6E6E6'>\n";
echo "<td align='left' width='190' valign='top'><font class='arial'>Chatting with: </font><BR><span class='arial_bold' id='ActiveChatManager'>".$chat_managers_array[$priority_chat]."</span></td>";
echo "<td align='right' width='190' valign='top'><font class='arial'>Chat started: </font><BR><span class='arial_bold' id='ActiveChatStartDate'>".$chat_start_date_array[$priority_chat]."</span></td>";
echo "<td align='left' width='*' valign='bottom'><font class='arial'>Your active chats:</font></td>";
echo "<td align='left' width='190' valign='top'><font class='arial'>"._QXZ("Chatting with").": </font><BR><span class='arial_bold' id='ActiveChatManager'>".$chat_managers_array[$priority_chat]."</span></td>";
echo "<td align='right' width='190' valign='top'><font class='arial'>"._QXZ("Chat started").": </font><BR><span class='arial_bold' id='ActiveChatStartDate'>".$chat_start_date_array[$priority_chat]."</span></td>";
echo "<td align='left' width='*' valign='bottom'><font class='arial'>"._QXZ("Your active chats").":</font></td>";
echo "</TR>";
echo "<TR BGCOLOR='#E6E6E6'>\n";
echo "<TD align='left' colspan='2' valign='top' width='380'>\n";
echo "\t<div class='scrolling_transcript' id='ActiveManagerChatTranscript'></div><BR>\n";
echo "\t<div id='AllowAgentReplies' align='center' style='display:none;'>\n";
echo "\t<textarea class='small_arial' rows='2' cols='65' name='manager_message' id='manager_message' onkeypress='if (event.keyCode == 13) {SendMgrChatMessage();}'></textarea><BR><input class='blue_btn' type='button' style='width:200px' value='SEND MESSAGE' onClick=\"SendMgrChatMessage()\">\n";
echo "\t<textarea class='small_arial' rows='2' cols='65' name='manager_message' id='manager_message' onkeypress='if (event.keyCode == 13) {SendMgrChatMessage();}'></textarea><BR><input class='blue_btn' type='button' style='width:200px' value='"._QXZ("SEND MESSAGE")."' onClick=\"SendMgrChatMessage()\">\n";
echo "\t</div>\n";
echo "</TD>\n";
echo "<TD align='left' rowspan='2' valign='top' width='210'>\n";
echo "<div class='scrolling_chat_display' id='AllActiveChats'>\n";
echo "<ul class='chatview'>";
if (empty($chat_managers_array)) {
echo "\t<li class='arial_bold'>NO OPEN CHATS</li>\n";
echo "\t<li class='arial_bold'>"._QXZ("NO OPEN CHATS")."</li>\n";
} else {
while (list($manager_chat_id, $text) = each($chat_managers_array)) {
$manager_chat_subid=$chat_subid_array[$manager_chat_id];
@@ -180,9 +611,9 @@ echo "<div class='scrolling_chat_display' id='AllActiveChats'>\n";
}
echo "</ul>\n";
echo "\t</div>\n";
echo "<font class='small_arial_bold'>(bolded chats = unread messages)<BR><input type='checkbox' id='MuteChatAlert' name='MuteChatAlert'>Mute alert sound</font>\n";
echo "\t<BR><BR><input class='green_btn' type='button' style='width:200px' value='CHAT WITH LIVE AGENT' onClick=\"document.getElementById('AgentChatSpan').style.display='none'; document.getElementById('AgentNewChatSpan').style.display='block'; ReloadAgentNewChatSpan('$user');\">\n";
echo "\t<BR><BR><span id='AgentEndChatSpan' style='display: none;'><div align='left'><input class='red_btn' type='button' style='width:200px' value='END CHAT' onClick='EndAgentToAgentChat()'></div></span>";
echo "<font class='small_arial_bold'>(bolded chats = unread messages)<BR><input type='checkbox' id='MuteChatAlert' name='MuteChatAlert'>"._QXZ("Mute alert sound")."</font>\n";
echo "\t<BR><BR><input class='green_btn' type='button' style='width:200px' value='"._QXZ("CHAT WITH LIVE AGENT")."' onClick=\"document.getElementById('AgentChatSpan').style.display='none'; document.getElementById('AgentNewChatSpan').style.display='block'; ReloadAgentNewChatSpan('$user');\">\n";
echo "\t<BR><BR><span id='AgentEndChatSpan' style='display: none;'><div align='left'><input class='red_btn' type='button' style='width:200px' value='"._QXZ("END CHAT")."' onClick='EndAgentToAgentChat()'></div></span>";
echo "</TD>\n";
echo "</TR>\n";
@@ -204,7 +635,7 @@ echo "</form>";
<?php
echo "<table width='600' border='0' cellpadding='5' cellspacing='0'>\n";
echo "<TR BGCOLOR='#E6E6E6' valign='top'>\n";
echo "<td width='*'><font class='arial'>Select a live agent:</font><BR>\n";
echo "<td width='*'><font class='arial'>"._QXZ("Select a live agent").":</font><BR>\n";
$stmt="SELECT user_group from vicidial_users where user='$user';";
if ($non_latin > 0) {$rslt=mysql_to_mysqli("SET NAMES 'UTF8'", $link);}
@@ -255,13 +686,13 @@ echo "<td width='*'><font class='arial'>Select a live agent:</font><BR>\n";
echo "</select>";
echo "</td>\n";
echo "<td width='200'><font class='arial'>Message:</font><BR>\n";
echo "<td width='200'><font class='arial'>"._QXZ("Message").":</font><BR>\n";
echo "<textarea class='small_arial' rows='5' style='width:200px; name='agent_message' id='agent_message'></textarea>";
echo "</td></TR>\n";
echo "<TR BGCOLOR='#E6E6E6'>\n";
echo "<td><BR><input class='red_btn' type='button' style='width:200px' value='BACK TO CHAT SCREEN' onClick=\"document.getElementById('AgentChatSpan').style.display='block'; document.getElementById('AgentNewChatSpan').style.display='none';\"></td>\n";
echo "<td align='center'><BR><input class='green_btn' type='button' style='width:200px' value='START CHAT' onClick=\"CreateAgentToAgentChat()\">\n</td></TR>\n";
echo "<td><BR><input class='red_btn' type='button' style='width:200px' value='"._QXZ("BACK TO CHAT SCREEN")."' onClick=\"document.getElementById('AgentChatSpan').style.display='block'; document.getElementById('AgentNewChatSpan').style.display='none';\"></td>\n";
echo "<td align='center'><BR><input class='green_btn' type='button' style='width:200px' value='"._QXZ("START CHAT")."' onClick=\"CreateAgentToAgentChat()\">\n</td></TR>\n";
echo "</table>";
?>
</span>
+83 -32
View File
@@ -1,7 +1,7 @@
<?php
# chat_db_query.php
#
# Copyright (C) 2014 Joe Johnson, Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
# Copyright (C) 2015 Joe Johnson, Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# Called by vdc_chat_display.php and vicidial_chat_agent.js. This contains all actions taken by the
# agent's interface when chatting with customers, other agents, and managers, through
@@ -11,6 +11,7 @@
#
# Builds:
# 150901-2348 - First build
# 151218-1052 - Added missing translation code and user auth
#
require("dbconnect_mysqli.php");
@@ -79,6 +80,56 @@ if (isset($_GET["ChatReloadIDNumber"])) {$ChatReloadIDNumber=$_GET["ChatRelo
$chat_member_name = preg_replace('/[^- \.\,\_0-9a-zA-Z]/',"",$chat_member_name);
if (!$user) {echo "No user, no using."; exit;}
#############################################
##### START SYSTEM_SETTINGS LOOKUP #####
$VUselected_language = '';
$stmt = "SELECT use_non_latin,enable_languages,language_method,default_language,allow_chats FROM system_settings;";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00XXX',$user,$server_ip,$session_name,$one_mysql_log);}
if ($DB) {echo "$stmt\n";}
$qm_conf_ct = mysqli_num_rows($rslt);
if ($qm_conf_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$non_latin = $row[0];
$SSenable_languages = $row[1];
$SSlanguage_method = $row[2];
$SSdefault_language = $row[3];
$SSallow_chats = $row[4];
}
$VUselected_language = $SSdefault_language;
##### END SETTINGS LOOKUP #####
###########################################
$auth=0;
$auth_message = user_authorization($user,$pass,'',0,0,0);
if ($auth_message == 'GOOD')
{$auth=1;}
if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0))
{
echo _QXZ("Invalid Username/Password:")." |$user|$pass|$auth_message|chat_db_query|\n";
exit;
}
$user_stmt="select full_name,user_level,selected_language from vicidial_users where user='$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;
}
###### AGENT/MANAGER CHAT FUNCTIONS #######
if ($action=="CreateAgentToAgentChat" && $agent_manager && $agent_user && $manager_message) {
@@ -86,7 +137,7 @@ if ($action=="CreateAgentToAgentChat" && $agent_manager && $agent_user && $manag
$dupe_chat_stmt="select * from vicidial_manager_chats where (manager='$agent_manager' and selected_agents like '%|$agent_user|%') or (manager='$agent_user' and selected_agents like '%|$agent_manager|%')";
$dupe_chat_rslt=mysqli_query($link, $dupe_chat_stmt);
if (mysqli_num_rows($dupe_chat_rslt)>0) {
echo "Error: You already have an open chat with this agent";
echo _QXZ("Error: You already have an open chat with this agent");
} else {
# This is slightly different from the manager-to-agent chat because it's only one agent you're chatting to so for reporting all that agent's specific information is grabbed and used to make the vicidial_manager_chats entry. Since the query should only return one result there's no while loop to insert subid chat info.
@@ -166,7 +217,7 @@ if ($action=="DisplayMgrAgentChat" && $manager_chat_id && $manager_chat_subid &&
echo $allow_replies."\n".$chat_output_text."\n".$chat_start_date."\n".$display_name."\n".$new_messages;
} else {
echo "N\nCHAT ENDED\n\n";
echo "N\n"._QXZ("CHAT ENDED")."\n\n";
}
}
@@ -255,7 +306,7 @@ if ($action=="RefreshActiveChatView" && $user) {
echo "$new_ChatReloadIDNumber|";
echo "<ul class='chatview'>";
if (empty($chat_managers_array)) {
echo "\t<li class='arial_bold'>NO OPEN CHATS</li>\n";
echo "\t<li class='arial_bold'>"._QXZ("NO OPEN CHATS")."</li>\n";
} else {
while (list($manager_chat_id, $text) = each($chat_managers_array)) {
$manager_chat_subid=$chat_subid_array[$manager_chat_id];
@@ -270,7 +321,7 @@ if ($action=="RefreshActiveChatView" && $user) {
if ($action=="ReloadAgentNewChatSpan" && $user) {
echo "<table width='600' border='0' cellpadding='5' cellspacing='0'>\n";
echo "<TR BGCOLOR='#E6E6E6' valign='top'>\n";
echo "<td width='*'><font class='arial'>Select a live agent:</font><BR>\n";
echo "<td width='*'><font class='arial'>"._QXZ("Select a live agent").":</font><BR>\n";
$stmt="SELECT user_group from vicidial_users where user='$user';";
if ($non_latin > 0) {$rslt=mysql_to_mysqli("SET NAMES 'UTF8'", $link);}
@@ -311,7 +362,7 @@ if ($action=="ReloadAgentNewChatSpan" && $user) {
if ($rslt) {$agents_count = mysqli_num_rows($rslt);}
$loop_count=0;
echo "<select name='agent' id='agent'>\n";
echo "<option value=''>Available agents</option>\n";
echo "<option value=''>"._QXZ("Available agents")."</option>\n";
while ($agents_count > $loop_count)
{
$row=mysqli_fetch_row($rslt);
@@ -321,13 +372,13 @@ if ($action=="ReloadAgentNewChatSpan" && $user) {
echo "</select>";
echo "</td>\n";
echo "<td width='200'><font class='arial'>Message:</font><BR>\n";
echo "<td width='200'><font class='arial'>"._QXZ("Message").":</font><BR>\n";
echo "<textarea class='small_arial' rows='5' cols='36' name='agent_message' id='agent_message'></textarea>";
echo "</td></TR>\n";
echo "<TR BGCOLOR='#E6E6E6'>\n";
echo "<td><BR><input class='red_btn' type='button' style='width:200px' value='BACK TO CHAT SCREEN' onClick=\"document.getElementById('AgentChatSpan').style.display='block'; document.getElementById('AgentNewChatSpan').style.display='none';\"></td>\n";
echo "<td align='center'><BR><input class='green_btn' type='button' style='width:200px' value='START CHAT' onClick=\"CreateAgentToAgentChat()\">\n</td></TR>\n";
echo "<td><BR><input class='red_btn' type='button' style='width:200px' value='"._QXZ("BACK TO CHAT SCREEN")."' onClick=\"document.getElementById('AgentChatSpan').style.display='block'; document.getElementById('AgentNewChatSpan').style.display='none';\"></td>\n";
echo "<td align='center'><BR><input class='green_btn' type='button' style='width:200px' value='"._QXZ("START CHAT")."' onClick=\"CreateAgentToAgentChat()\">\n</td></TR>\n";
echo "</table>";
}
@@ -351,10 +402,10 @@ if ($action=="SendMgrChatMessage" && $manager_chat_id && $manager_chat_subid) {
if (mysqli_insert_id($link)>0) {
$reload_chat_span=1;
} else {
echo "Error sending message.";
echo _QXZ("Error sending message.");
}
} else {
echo "Error sending message.";
echo _QXZ("Error sending message.");
}
}
######################################
@@ -461,20 +512,20 @@ if ($action=="agent_send_message" && $chat_id) {
$live_row=mysqli_fetch_row($live_rslt);
$status=$live_row[0];
if ($status=="WAITING") {
echo "Chat $chat_id is waiting for an agent";
echo _QXZ("Chat is waiting for an agent").": $chat_id";
} else {
if ($status=="LIVE") {
$ins_stmt="insert ignore into vicidial_chat_log(chat_id, message, poster, chat_member_name, chat_level) VALUES('$chat_id', '".mysqli_real_escape_string($link, $chat_message)."', '$user', '".mysqli_real_escape_string($link, $chat_member_name)."', '$chat_level')";
$ins_rslt=mysql_to_mysqli($ins_stmt, $link);
if (mysqli_affected_rows($link)<1) {
echo "<font class='chat_title alert'>SYSTEM ERROR</font><BR/>\n";
echo "<font class='chat_title alert'>"._QXZ("SYSTEM ERROR")."</font><BR/>\n";
}
} else {
echo "<font class='chat_title alert'>SYSTEM ERROR</font><BR/>\n";
echo "<font class='chat_title alert'>"._QXZ("SYSTEM ERROR")."</font><BR/>\n";
}
}
} else if (mysqli_num_rows($rslt)==0) {
echo "Chat $chat_id has been closed";
echo _QXZ("Chat has been closed").": $chat_id";
}
}
@@ -506,7 +557,7 @@ if ($action=="update_agent_chat_window" && $chat_id) {
$status_stmt="select status, chat_creator from vicidial_live_chats where chat_id='$chat_id'";
$status_rslt=mysql_to_mysqli($status_stmt, $link);
if (mysqli_num_rows($status_rslt)==0) {
echo "<font class='chat_title alert'>Chat $chat_id does not exist or has been closed</font><BR/>\n";
echo "<font class='chat_title alert'>"._QXZ("Chat does not exist or has been closed").": $chat_id</font><BR/>\n";
} else {
$status_row=mysqli_fetch_row($status_rslt);
@@ -521,7 +572,7 @@ if ($action=="update_agent_chat_window" && $chat_id) {
$live_stmt="select * from vicidial_live_chats vlc, vicidial_chat_participants vcp where vlc.chat_id='$chat_id' and status='LIVE' and vlc.chat_id=vcp.chat_id and vcp.chat_member='$user'";
$live_rslt=mysql_to_mysqli($live_stmt, $link);
if (mysqli_num_rows($live_rslt)>0) {
echo "<font class='chat_title bold'>Current chat: $chat_id</font><BR/>\n";
echo "<font class='chat_title bold'>"._QXZ("Current chat").": $chat_id</font><BR/>\n";
# Create color-coding for chat
$stmt="select * from vicidial_chat_log where chat_id='$chat_id' order by message_time asc";
@@ -550,16 +601,16 @@ if ($action=="update_agent_chat_window" && $chat_id) {
$current_messages=mysqli_num_rows($rslt);
echo "<input type='hidden' id='current_message_count' name='current_message_count' value='$current_messages'>\n";
} else {
echo "<font class='chat_title bold'>Click on a live chat at right to join it.</font><BR/>\n";
echo "<font class='chat_title bold'>"._QXZ("Click on a live chat at right to join it.")."</font><BR/>\n";
}
} else {
if ($status_row[1]=="NONE") {
echo "<font class='chat_title bold'>Waiting for next available agent....</font><BR/>\n";
echo "<font class='chat_title bold'>"._QXZ("Waiting for next available agent...")."</font><BR/>\n";
# 8/28 - Added in case agent starts chat but hasn't invited someone or they haven't shown up yet
} else if ($status_row[1]==$user || $status_row[0]=="WAITING") {
echo "<font class='chat_title bold'>Please send an invite to the customer to begin...</font><BR/>\n";
echo "<font class='chat_title bold'>"._QXZ("Please send an invite to the customer to begin...")."</font><BR/>\n";
} else {
echo "<font class='chat_title alert'>SYSTEM ERROR</font><BR/>\n";
echo "<font class='chat_title alert'>"._QXZ("SYSTEM ERROR")."</font><BR/>\n";
}
}
}
@@ -661,7 +712,7 @@ if ($action=="send_invite" && $chat_id && $email && $chat_group_id) {
if ($action=="end_chat" && $chat_id && $chat_creator && $user && $server_ip) {
if ($user!=$chat_creator) {
echo "You cannot end this chat unless you are the one who started it.";
echo _QXZ("You cannot end this chat unless you are the one who started it.");
exit;
}
@@ -674,9 +725,9 @@ if ($action=="end_chat" && $chat_id && $chat_creator && $user && $server_ip) {
$del_stmt="delete from vicidial_live_chats where chat_id='$chat_id' and chat_creator='$chat_creator'";
$del_rslt=mysql_to_mysqli($del_stmt, $link);
if (mysqli_affected_rows($link)==0) {
echo "Warning: chat ID not found. Deleting any remaining participants...<BR><BR>";
echo _QXZ("Warning: chat ID not found. Deleting any remaining participants...")."<BR><BR>";
} else {
echo "Chat ended<BR><BR>";
echo _QXZ("Chat ended")."<BR><BR>";
}
$del_log_stmt="delete from vicidial_chat_log where chat_id='$chat_id'";
$del_log_rslt=mysql_to_mysqli($del_log_stmt, $link);
@@ -685,7 +736,7 @@ if ($action=="end_chat" && $chat_id && $chat_creator && $user && $server_ip) {
$del_rslt2=mysql_to_mysqli($del_stmt2, $link);
$deleted_participants=mysqli_affected_rows($link);
echo "$deleted_participants removed from chat.";
echo "$deleted_participants "._QXZ("removed from chat.");
# HTML to display after ending chat - will only display again if no lead_id, i.e. no customer involved and no dispositioning needed.
echo "|";
@@ -695,9 +746,9 @@ if ($action=="end_chat" && $chat_id && $chat_creator && $user && $server_ip) {
$vla_stmt="select closer_campaigns from vicidial_live_agents where user='$user'";
$vla_rslt=mysql_to_mysqli($vla_stmt, $link);
echo "<BR/><BR/><input class='green_btn' type='button' style=\"width:150px\" value=\"START CHAT\" onClick=\"StartChat()\">";
echo "<BR/><BR/><input class='green_btn' type='button' style=\"width:150px\" value=\""._QXZ("START CHAT")."\" onClick=\"StartChat()\">";
echo "<BR/><BR/><select name='startchat_group_id' id='startchat_group_id' class='chat_window' onChange=\"document.getElementById('chat_group_id').value=this.value\">";
echo "<option value='' selected>--SELECT A CHAT GROUP--</option>";
echo "<option value='' selected>--"._QXZ("SELECT A CHAT GROUP")."--</option>";
if (mysqli_num_rows($vla_rslt)>0) {
$vla_row=mysqli_fetch_row($vla_rslt);
$closer_campaigns=trim($vla_row[0]);
@@ -723,7 +774,7 @@ if ($action=="join_chat" && $user && $chat_id && $chat_member_name) {
$ins_stmt="insert into vicidial_chat_participants(chat_id, chat_member, chat_member_name, vd_agent) values('$chat_id', '$user', '".mysqli_real_escape_string($link, $chat_member_name)."', 'Y')";
$ins_rslt=mysql_to_mysqli($ins_stmt, $link);
if (mysqli_affected_rows($link)==0) {
echo "ERROR|Chat was not joined.";
echo "ERROR|"._QXZ("Chat was not joined.");
} else {
$creator_stmt="select chat_creator from vicidial_live_chats where chat_id='$chat_id'";
$creator_rslt=mysql_to_mysqli($creator_stmt, $link);
@@ -731,7 +782,7 @@ if ($action=="join_chat" && $user && $chat_id && $chat_member_name) {
$crow=mysqli_fetch_row($creator_rslt);
echo "$crow[0]";
} else {
echo "ERROR|You have joined a non-existent chat. Trippy.\n";
echo "ERROR|"._QXZ("You have joined a non-existent chat. Trippy.")."\n";
}
}
}
@@ -779,9 +830,9 @@ if ($action=="show_live_chats" && $user) {
}
if ($active_chats) {
echo "<font class='chat_title bold'>Available Chats:</font><BR><BR>";
echo "<font class='chat_title bold'>"._QXZ("Available Chats").":</font><BR><BR>";
while (list($key, $val)=each($active_chats)) {
echo "<li class='submenu' onClick=\"JoinChat('$key', '$chat_creator');\"><font class='chat_message bold'>Chat ID #$key</font>\n";
echo "<li class='submenu' onClick=\"JoinChat('$key', '$chat_creator');\"><font class='chat_message bold'>"._QXZ("Chat ID")." #$key</font>\n";
echo "\t<ul id=\"chat_members_$key\">\n";
while (list($subkey, $subval)=each($val)) {
if ($subval[2]=="absent") {
@@ -800,7 +851,7 @@ if ($action=="show_live_chats" && $user) {
}
if ($rslt && mysqli_num_rows($rslt)>0) {
echo "<input type='button' style='width:180px' value='CLICK CHAT TO JOIN' disabled>";
echo "<input type='button' style='width:180px' value='"._QXZ("CLICK CHAT TO JOIN")."' disabled>";
}
}
+100 -57
View File
@@ -13,28 +13,12 @@
# Builds:
# 150903-2349 - First build
# 151213-1107 - Added variable filtering
# 151218-0913 - Added missing translation code and user auth
#
require("dbconnect_mysqli.php");
require("functions.php");
#############################################
##### START SYSTEM_SETTINGS LOOKUP #####
$stmt = "SELECT use_non_latin,enable_languages,language_method FROM system_settings;";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00XXX',$user,$server_ip,$session_name,$one_mysql_log);}
if ($DB) {echo "$stmt\n";}
$qm_conf_ct = mysqli_num_rows($rslt);
if ($qm_conf_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$non_latin = $row[0];
$SSenable_languages = $row[1];
$SSlanguage_method = $row[2];
}
##### END SETTINGS LOOKUP #####
###########################################
if (isset($_GET["email"])) {$email=$_GET["email"];}
elseif (isset($_POST["email"])) {$email=$_POST["email"];}
if (isset($_GET["email_invite_lead_id"])) {$email_invite_lead_id=$_GET["email_invite_lead_id"];}
@@ -67,6 +51,29 @@ if (isset($_GET["last_name"])) {$last_name=$_GET["last_name"];}
elseif (isset($_POST["last_name"])) {$last_name=$_POST["last_name"];}
if (isset($_GET["clickmute"])) {$clickmute=$_GET["clickmute"];}
elseif (isset($_POST["clickmute"])) {$clickmute=$_POST["clickmute"];}
if (isset($_GET["stage"])) {$stage=$_GET["stage"];}
elseif (isset($_POST["stage"])) {$stage=$_POST["stage"];}
#############################################
##### START SYSTEM_SETTINGS LOOKUP #####
$VUselected_language = '';
$stmt = "SELECT use_non_latin,enable_languages,language_method,default_language,allow_chats FROM system_settings;";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00XXX',$user,$server_ip,$session_name,$one_mysql_log);}
if ($DB) {echo "$stmt\n";}
$qm_conf_ct = mysqli_num_rows($rslt);
if ($qm_conf_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$non_latin = $row[0];
$SSenable_languages = $row[1];
$SSlanguage_method = $row[2];
$SSdefault_language = $row[3];
$SSallow_chats = $row[4];
}
$VUselected_language = $SSdefault_language;
##### END SETTINGS LOOKUP #####
###########################################
header ("Content-type: text/html; charset=utf-8");
header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
@@ -82,6 +89,7 @@ $email = preg_replace("/\'|\"|\\\\|;/","",$email);
$campaign = preg_replace('/[^-\_0-9a-zA-Z]/','',$campaign);
$dial_method = preg_replace('/[^-\_0-9a-zA-Z]/','',$dial_method);
$clickmute = preg_replace("/\'|\"|\\\\|;/","",$clickmute);
$stage = preg_replace('/[^-\_0-9a-zA-Z]/','',$stage);
if ($non_latin < 1)
{
@@ -100,24 +108,47 @@ else
$outside_user_name = preg_replace("/\'|\"|\\\\|;/","",$user);
}
$user_stmt="select full_name, user_level from vicidial_users where user='$user'";
echo "<!-- \n$user_stmt\n\\-->\n";
if( (strlen($stage) > 0) and ($stage == 'WELCOME') )
{
echo _QXZ("Customer Chat Frame");
exit;
}
if ($SSallow_chats < 1)
{
header ("Content-type: text/html; charset=utf-8");
echo _QXZ("Error, chat disabled on this system");
exit;
}
$auth=0;
$auth_message = user_authorization($user,$pass,'',0,0,0);
if ($auth_message == 'GOOD')
{$auth=1;}
if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0))
{
echo _QXZ("Invalid Username/Password:")." |$user|$pass|$auth_message|vdc_chat_display|\n";
exit;
}
$user_stmt="select full_name,user_level,selected_language from vicidial_users where user='$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];
$full_name = $user_row[0];
$user_level = $user_row[1];
$VUselected_language = $user_row[2];
if ($chat_id) {
$chat_stmt="select * from vicidial_live_chats where chat_creator='$user' and chat_id='$chat_id'";
echo "<!-- \n$chat_stmt\n";
# echo "<!-- \n$chat_stmt\n";
$chat_rslt=mysql_to_mysqli($chat_stmt, $link);
if (mysqli_num_rows($chat_rslt)>0) {
$chat_creator=$user;
echo "$chat_creator\n";
}
echo "\\-->\n";
# echo "\\-->\n";
} else {
# echo "Waiting for chat request..."; exit;
}
@@ -141,10 +172,16 @@ if (mysqli_num_rows($rslt)>0) {
if (!$full_name) {$full_name=trim("$first_name $last_name");}
if (!$email) {$email=$row["email"];}
}
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>
<title>Vicidial Chat Interface</title>
<title><?php echo _QXZ("Agent Chat Interface"); ?></title>
<script type="text/javascript" src="simpletreemenu.js">
/***********************************************
@@ -223,6 +260,7 @@ function UpdateChatWindow() {
function SendMessage(chat_id, user, message, chat_member_name) {
var chat_id=document.getElementById('chat_id').value;
var user=document.getElementById('user').value;
var pass=document.getElementById('pass').value;
var chat_message=encodeURIComponent(document.getElementById('chat_message').value.trim());
var chat_member_name=encodeURIComponent(document.getElementById('chat_member_name').value.trim());
window.user_level='<?php echo $user_level; ?>';
@@ -234,8 +272,8 @@ function SendMessage(chat_id, user, message, chat_member_name) {
}
if (!chat_message || !user) {return false;}
if (!chat_member_name) {chat_alert_box("Please enter a name to chat as.");}
if (!chat_id) {chat_alert_box("You have not joined a chat yet.");}
if (!chat_member_name) {chat_alert_box("<?php echo _QXZ("Please enter a name to chat as."); ?>");}
if (!chat_id) {chat_alert_box("<?php echo _QXZ("You have not joined a chat yet."); ?>");}
document.getElementById('chat_message').value='';
var xmlhttp=false;
@@ -245,7 +283,7 @@ function SendMessage(chat_id, user, message, chat_member_name) {
}
if (xmlhttp)
{
chat_query = "&chat_message="+chat_message+"&chat_level="+chat_level+"&user_level="+user_level+"&chat_id="+chat_id+"&chat_member_name="+chat_member_name+"&user="+user+"&action=agent_send_message";
chat_query = "&chat_message="+chat_message+"&chat_level="+chat_level+"&user_level="+user_level+"&chat_id="+chat_id+"&chat_member_name="+chat_member_name+"&user="+user+"&pass="+pass+"&action=agent_send_message";
xmlhttp.open('POST', 'chat_db_query.php');
xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8');
xmlhttp.send(chat_query);
@@ -270,12 +308,13 @@ function SendMessage(chat_id, user, message, chat_member_name) {
function JoinChat(chat_id) {
var user=document.getElementById('user').value;
var pass=document.getElementById('pass').value;
var chat_member_name=encodeURIComponent(document.getElementById('chat_member_name').value.trim());
var chat_creator="";
if (!chat_member_name)
{
chat_alert_box("Please enter your name before joining a chat.");
chat_alert_box("<?php echo _QXZ("Please enter your name before joining a chat."); ?>");
return false;
}
@@ -286,7 +325,7 @@ function JoinChat(chat_id) {
}
if (xmlhttp)
{
chat_query = "&chat_id="+chat_id+"&chat_member_name="+chat_member_name+"&user="+user+"&action=join_chat";
chat_query = "&chat_id="+chat_id+"&chat_member_name="+chat_member_name+"&user="+user+"&pass="+pass+"&action=join_chat";
xmlhttp.open('POST', 'chat_db_query.php');
xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8');
xmlhttp.send(chat_query);
@@ -312,11 +351,11 @@ function JoinChat(chat_id) {
{
if (!email_invite_lead_id)
{
document.getElementById('chat_creator_console').innerHTML="<BR/><BR/><input class='blue_btn' type='button' style=\"width:150px\" value=\"INVITE\" onClick=\"javascript:document.getElementById('email_window').style.display='block'\">\n<BR/><BR/><input class='red_btn' type='button' style=\"width:150px\" value=\"END CHAT\" onClick=\"EndChat()\">";
document.getElementById('chat_creator_console').innerHTML="<BR/><BR/><input class='blue_btn' type='button' style=\"width:150px\" value=\"<?php echo _QXZ("INVITE"); ?>\" onClick=\"javascript:document.getElementById('email_window').style.display='block'\">\n<BR/><BR/><input class='red_btn' type='button' style=\"width:150px\" value=\"<?php echo _QXZ("END CHAT"); ?>\" onClick=\"EndChat()\">";
}
else
{
document.getElementById('chat_creator_console').innerHTML="<BR/><BR/><input class='red_btn' type='button' style=\"width:150px\" value=\"END CHAT\" onClick=\"EndChat()\">";
document.getElementById('chat_creator_console').innerHTML="<BR/><BR/><input class='red_btn' type='button' style=\"width:150px\" value=\"<?php echo _QXZ("END CHAT"); ?>\" onClick=\"EndChat()\">";
}
}
}
@@ -358,6 +397,7 @@ function RefreshLiveChatWindow() {
function StartChat() {
var user=document.getElementById('user').value;
var pass=document.getElementById('pass').value;
var chat_group_id=document.getElementById('chat_group_id').value;
var server_ip=document.getElementById('server_ip').value;
@@ -368,7 +408,7 @@ function StartChat() {
}
if (xmlhttp)
{
chat_query = "&action=start_chat&user="+user+"&chat_group_id="+chat_group_id+"&server_ip="+server_ip;
chat_query = "&action=start_chat&user="+user+"&pass="+pass+"&chat_group_id="+chat_group_id+"&server_ip="+server_ip;
xmlhttp.open('POST', 'chat_db_query.php');
xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8');
xmlhttp.send(chat_query);
@@ -378,13 +418,13 @@ function StartChat() {
{
var start_chat_attempt_result = xmlhttp.responseText;
if (!start_chat_attempt_result) {
chat_alert_box("ATTEMPT TO CREATE CHAT SESSION FAILED.");
chat_alert_box("<?php echo _QXZ("ATTEMPT TO CREATE CHAT SESSION FAILED."); ?>");
} else if (start_chat_attempt_result=="NOT_PAUSED") {
chat_alert_box("YOU MUST BE PAUSED TO INITIATE A CUSTOMER CHAT.");
chat_alert_box("<?php echo _QXZ("YOU MUST BE PAUSED TO INITIATE A CUSTOMER CHAT."); ?>");
} else if (start_chat_attempt_result=="NO_GROUP") {
chat_alert_box("PLEASE SELECT A CHAT GROUP BEFORE STARTING A CHAT.");
chat_alert_box("<?php echo _QXZ("PLEASE SELECT A CHAT GROUP BEFORE STARTING A CHAT."); ?>");
} else if (start_chat_attempt_result=="FAILED_LIVE_STATUS") {
chat_alert_box("UNABLE TO CHANGE LIVE AGENT STATUS");
chat_alert_box("<?php echo _QXZ("UNABLE TO CHANGE LIVE AGENT STATUS"); ?>");
} else {
// parent.check_for_incoming_other('skip_email');
// DEACTIVATE PAUSE BUTTON - AGENTS SHOULD NOT BE ALLOWED TO TOGGLE THIS - THEY ARE ESSENTIALLY INCALL ONCE THEY START A CHAT EVEN IF THE CUSTOMER HASN'T JOINED YET
@@ -396,11 +436,11 @@ function StartChat() {
{
window.parent.document.getElementById("DiaLControl").innerHTML = DiaLControl_auto_HTML_OFF;
}
chat_alert_box("CHAT SESSION CREATED. INVITE CUSTOMER VIA EMAIL TO BEGIN.");
chat_alert_box("<?php echo _QXZ("CHAT SESSION CREATED. INVITE CUSTOMER VIA EMAIL TO BEGIN."); ?>");
document.getElementById('chat_id').value=start_chat_attempt_result;
window.parent.document.vicidial_form.chat_id.value=start_chat_attempt_result;
document.getElementById('chat_creator').value=user;
document.getElementById('chat_creator_console').innerHTML="<BR/><BR/><input class='blue_btn' type='button' style=\"width:150px\" value=\"INVITE\" onClick=\"javascript:document.getElementById('email_window').style.display='block'\">\n<BR/><BR/><input class='red_btn' type='button' style=\"width:150px\" value=\"END CHAT\" onClick=\"EndChat()\">";
document.getElementById('chat_creator_console').innerHTML="<BR/><BR/><input class='blue_btn' type='button' style=\"width:150px\" value=\"<?php echo _QXZ("INVITE"); ?>\" onClick=\"javascript:document.getElementById('email_window').style.display='block'\">\n<BR/><BR/><input class='red_btn' type='button' style=\"width:150px\" value=\"<?php echo _QXZ("END CHAT"); ?>\" onClick=\"EndChat()\">";
}
UpdateChatWindow();
@@ -412,6 +452,7 @@ function StartChat() {
function SendInvite() {
var user=document.getElementById('user').value;
var pass=document.getElementById('pass').value;
var lead_id=document.getElementById('lead_id').value;
var chat_id=document.getElementById('chat_id').value;
var chat_group_id=document.getElementById('chat_group_id').value;
@@ -424,7 +465,7 @@ function SendInvite() {
}
if (xmlhttp)
{
chat_query = "&action=send_invite&chat_id="+chat_id+"&chat_group_id="+chat_group_id+"&lead_id="+lead_id+"&user="+user+"&email="+email;
chat_query = "&action=send_invite&chat_id="+chat_id+"&chat_group_id="+chat_group_id+"&lead_id="+lead_id+"&user="+user+"&pass="+pass+"&email="+email;
xmlhttp.open('POST', 'chat_db_query.php');
xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8');
xmlhttp.send(chat_query);
@@ -437,11 +478,11 @@ function SendInvite() {
{
parent.check_for_incoming_other(email_sent); // Force the agent interface to do it's thing for a live chat coming across, even though in this case the customer isn't in it yet. Sends lead ID to parent function as a flag, so as not to show the INVITE button when this page reloads
document.getElementById('email_window').style.display='none';
document.getElementById('chat_creator_console').innerHTML="<BR/><BR/><input class='red_btn' type='button' style=\"width:150px\" value=\"END CHAT\" onClick=\"EndChat()\">";
document.getElementById('chat_creator_console').innerHTML="<BR/><BR/><input class='red_btn' type='button' style=\"width:150px\" value=\"<?php echo _QXZ("END CHAT"); ?>\" onClick=\"EndChat()\">";
}
else
{
chat_alert_box("There was a problem sending the email invite - please re-check your information and try again."+email_sent);
chat_alert_box("<?php echo _QXZ("There was a problem sending the email invite - please re-check your information and try again."); ?>"+email_sent);
}
}
}
@@ -456,6 +497,7 @@ function LeaveChat(extra_action) {
var chat_id=document.getElementById('chat_id').value;
var chat_creator=document.getElementById('chat_creator').value;
var user=document.getElementById('user').value;
var pass=document.getElementById('pass').value;
var xmlhttp=false;
if (!xmlhttp && typeof XMLHttpRequest!='undefined')
@@ -464,7 +506,7 @@ function LeaveChat(extra_action) {
}
if (xmlhttp)
{
chat_query = "&action=agent_leave_chat&chat_id="+chat_id+"&user="+user;
chat_query = "&action=agent_leave_chat&chat_id="+chat_id+"&user="+user+"&pass="+pass;
// chat_alert_box(chat_query);
xmlhttp.open('POST', 'chat_db_query.php');
xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8');
@@ -486,6 +528,7 @@ function EndChat(hangup_override) { // hangup_override comes from parent Iframe
var chat_id=document.getElementById('chat_id').value;
var chat_creator=document.getElementById('chat_creator').value;
var user=document.getElementById('user').value;
var pass=document.getElementById('pass').value;
var server_ip=document.getElementById('server_ip').value;
var lead_id=document.getElementById('lead_id').value; // used to determine if chat involved a customer. If so, don't allow START CHAT option until chat is fully terminated.
@@ -493,7 +536,7 @@ function EndChat(hangup_override) { // hangup_override comes from parent Iframe
if (!chat_creator || !user || !chat_id) {
return false;
} else if (user!=chat_creator) {
chat_alert_box("Only the chat creator can end the chat");
chat_alert_box("<?php echo _QXZ("Only the chat creator can end the chat"); ?>");
return false;
}
@@ -504,7 +547,7 @@ function EndChat(hangup_override) { // hangup_override comes from parent Iframe
}
if (xmlhttp)
{
chat_query = "&action=end_chat&chat_id="+chat_id+"&chat_creator="+chat_creator+"&user="+user+"&lead_id="+lead_id+"&server_ip="+server_ip;
chat_query = "&action=end_chat&chat_id="+chat_id+"&chat_creator="+chat_creator+"&user="+user+"&pass="+pass+"&lead_id="+lead_id+"&server_ip="+server_ip;
xmlhttp.open('POST', 'chat_db_query.php');
xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8');
xmlhttp.send(chat_query);
@@ -568,7 +611,7 @@ window.onbeforeunload = LeaveChat;
<?php
if (!$user) {
echo "<body>No user ID - no chat access. Sorry </body>";
echo "<body>"._QXZ("No user ID - no chat access. Sorry")."</body>";
exit;
}
@@ -601,11 +644,11 @@ if (mysqli_num_rows($user_rslt)==0) {
}
if($child_window) {
$inchat_html.="<BR><BR><input type='button' class='red_btn' name='close_window_btn' id='close_window_btn' value='CLOSE WINDOW' onClick='LeaveChat(\"close_window\")'>";
$inchat_html.="<BR><BR><input type='button' class='red_btn' name='close_window_btn' id='close_window_btn' value=\""._QXZ("CLOSE WINDOW")."\" onClick='LeaveChat(\"close_window\")'>";
}
?>
<body onLoad="<?php echo $autojoin_js_fx; ?>" onUnload="javascript:clearInterval(rInt); LeaveChat();">
<?php echo "<!-- $user_stmt\n vdc_chat_display.php?user=$user&pass=$pass&lead_id=$lead_id&list_id=$list_id&email=$email&chat_id=$chat_id //-->\n"; ?>
<?php echo "<!-- $user_stmt\n vdc_chat_display.php?user=$user&pass=$pass&lead_id=$lead_id&list_id=$list_id&email=$email&chat_id=$chat_id -->\n"; ?>
<form name='chat_form' action='<?php echo $PHP_SELF; ?>'>
<table width='100%' border='0'>
<tr>
@@ -627,12 +670,12 @@ if($child_window) {
</td>
</tr>
<tr>
<td align='left' class='chat_message' valign='top'><input class='blue_btn' type='button' style="width:100px" value="SEND MESSAGE" onClick="SendMessage(this.form.chat_id.value, this.form.user.value, this.form.chat_message.value)"><BR><BR><input type='checkbox' id='MuteCustomerChatAlert' name='MuteCustomerChatAlert'>Mute alert sound
<td align='left' class='chat_message' valign='top'><input class='blue_btn' type='button' style="width:100px" value="<?php echo _QXZ("SEND MESSAGE"); ?>" onClick="SendMessage(this.form.chat_id.value, this.form.user.value, this.form.chat_message.value)"><BR><BR><input type='checkbox' id='MuteCustomerChatAlert' name='MuteCustomerChatAlert'><?php echo _QXZ("Mute alert sound"); ?>
</td>
<td align='right' class='chat_message' valign='top'><input class='blue_btn' type='button' style="width:100px" value="CLEAR" onClick="document.getElementById('chat_message').value=''"><BR><BR>
<td align='right' class='chat_message' valign='top'><input class='blue_btn' type='button' style="width:100px" value="<?php echo _QXZ("CLEAR"); ?>" onClick="document.getElementById('chat_message').value=''"><BR><BR>
<?php
if ($user_level) {
echo "<input type='checkbox' name='private_message' id='private_message' value='1'>Privacy ON";
echo "<input type='checkbox' name='private_message' id='private_message' value='1'>"._QXZ("Privacy ON");
}
?>
</td>
@@ -652,10 +695,10 @@ if($child_window) {
if ($full_name) {
echo "<span id='chat_creator_console' name='chat_creator_console'>";
if (!$chat_id) {
echo "<BR/><BR/><input class='green_btn' type='button' style=\"width:150px\" value=\"START CHAT\" onClick=\"StartChat()\">";
echo "<BR/><BR/><input class='green_btn' type='button' style=\"width:150px\" value=\""._QXZ("START CHAT")."\" onClick=\"StartChat()\">";
echo "<BR/><BR/><select name='startchat_group_id' id='startchat_group_id' class='chat_window' onChange=\"document.getElementById('chat_group_id').value=this.value\">\n";
echo "<option value='' selected>--SELECT A CHAT GROUP--</option>\n";
echo "<option value='' selected>--"._QXZ("SELECT A CHAT GROUP")."--</option>\n";
# CREATE LIST OF GroUP IDS to select
if (count($chat_group_ids)>0) {
$chat_group_idsSQL = implode("','", $chat_group_ids);
@@ -687,9 +730,9 @@ if($child_window) {
}
if ($chat_creator && $chat_creator==$user) {
if (!$email_invite_lead_id) { # Flag from sending an invite - this page reloads as a result and this below INVITE button must be prevented from being loaded
echo "<BR/><BR/><input class='blue_btn' type='button' style=\"width:150px\" value=\"INVITE\" onClick=\"javascript:document.getElementById('email_window').style.display='block'\">";
echo "<BR/><BR/><input class='blue_btn' type='button' style=\"width:150px\" value=\""._QXZ("INVITE")."\" onClick=\"javascript:document.getElementById('email_window').style.display='block'\">";
}
echo "<BR/><BR/><input class='red_btn' type='button' style=\"width:150px\" value=\"END CHAT\" onClick=\"EndChat()\">";
echo "<BR/><BR/><input class='red_btn' type='button' style=\"width:150px\" value=\""._QXZ("END CHAT")."\" onClick=\"EndChat()\">";
}
echo "</span>";
}
@@ -702,9 +745,9 @@ if($child_window) {
<span id="email_window" style="display: none">
<table width='90%'>
<tr>
<td align='left' class='chat_message'>Enter email address of guest: <input type='text' name='email_invite' id='email_invite' onkeypress="if (event.keyCode==13 &amp;&amp; !event.shiftKey) {SendInvite(); return false;}"></td>
<td align='left'><input class='green_btn' type='button' style="width:150px" value="SEND" onClick="SendInvite()"></td>
<td align='center'><input class='red_btn' type='button' style="width:150px" value="HIDE" onClick="javascript:document.getElementById('email_window').style.display='none'"></td>
<td align='left' class='chat_message'><?php echo _QXZ("Enter email address of guest"); ?>: <input type='text' name='email_invite' id='email_invite' onkeypress="if (event.keyCode==13 &amp;&amp; !event.shiftKey) {SendInvite(); return false;}"></td>
<td align='left'><input class='green_btn' type='button' style="width:150px" value="<?php echo _QXZ("SEND"); ?>" onClick="SendInvite()"></td>
<td align='center'><input class='red_btn' type='button' style="width:150px" value="<?php echo _QXZ("HIDE"); ?>" onClick="javascript:document.getElementById('email_window').style.display='none'"></td>
</tr>
</table>
</span>
+6 -5
View File
@@ -509,10 +509,11 @@
# 151119-1925 - Fixed issue with scheduled callbacks and status groups
# 151125-0942 - Fixed manual call only logging bug
# 151212-0922 - Added all chat functionality
# 151218-1200 - Fixes for chat security and language translation
#
$version = '2.12-478c';
$build = '151212-0922';
$version = '2.12-479c';
$build = '151218-1200';
$mel=1; # Mysql Error Log enabled = 1
$mysql_log_count=85;
$one_mysql_log=0;
@@ -15336,7 +15337,7 @@ function phone_number_format(formatphone) {
var form_chat_id = document.vicidial_form.chat_id.value;
if (form_entry_list_id.length > 2)
{form_list_id = form_entry_list_id}
document.getElementById('InternalChatIFrame').src='./agc_agent_manager_chat_interface.php?lead_id=' + document.vicidial_form.lead_id.value + '&list_id=' + form_list_id + '&user=' + user ;
document.getElementById('InternalChatIFrame').src='./agc_agent_manager_chat_interface.php?lead_id=' + document.vicidial_form.lead_id.value + '&list_id=' + form_list_id + '&user=' + user + '&pass=' + orig_pass;
form_list_id = '';
form_chat_id = '';
form_entry_list_id = '';
@@ -16589,7 +16590,7 @@ function phone_number_format(formatphone) {
divref.visibility = 'hidden';
if (divvar == 'InternalChatPanel') // Clear the manager chat panel to prevent incoming messages from immediately being marked as read
{
document.getElementById('InternalChatIFrame').src='./agc_agent_manager_chat_interface.php?user='+user;
document.getElementById('InternalChatIFrame').src='./agc_agent_manager_chat_interface.php?user='+user+'&pass='+orig_pass;
}
}
}
@@ -17638,7 +17639,7 @@ if ($agent_display_dialable_leads > 0)
if ($webphone_location == 'bar')
{echo "<img src=\"./images/"._QXZ("pixel.gif")."\" width=\"1px\" height=\"".$webphone_height."px\" /><br />\n";}
?>
<table border="0" bgcolor="<?php echo $SCRIPT_COLOR ?>" width="<?php echo $SSwidth ?>px" height="<?php echo $SSheight ?>px"><tr><td align="left" valign="top"><font class="sb_text"><div class="noscroll_script" id="InternalChatContents"><iframe src="./agc_agent_manager_chat_interface.php?user=<?php echo $VD_login; ?>" style="background-color:transparent;" scrolling="auto" frameborder="0" allowtransparency="true" id="InternalChatIFrame" name="InternalChatIFrame" width="<?php echo $SDwidth ?>px" height="<?php echo $SSheight ?>px" STYLE="z-index:<?php $zi++; echo $zi ?>"> </iframe></div></font></td></tr></table>
<table border="0" bgcolor="<?php echo $SCRIPT_COLOR ?>" width="<?php echo $SSwidth ?>px" height="<?php echo $SSheight ?>px"><tr><td align="left" valign="top"><font class="sb_text"><div class="noscroll_script" id="InternalChatContents"><iframe src="./agc_agent_manager_chat_interface.php?user=<?php echo $VD_login; ?>&pass=<?php echo $VD_pass; ?>" style="background-color:transparent;" scrolling="auto" frameborder="0" allowtransparency="true" id="InternalChatIFrame" name="InternalChatIFrame" width="<?php echo $SDwidth ?>px" height="<?php echo $SSheight ?>px" STYLE="z-index:<?php $zi++; echo $zi ?>"> </iframe></div></font></td></tr></table>
</span>
+2 -386
View File
@@ -1,6 +1,6 @@
// vicidial_chat_agent.js
//
// Copyright (C) 2014 Joe Johnson, Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
// Copyright (C) 2015 Joe Johnson, Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
//
// Used by agc_agent_manager_chat_interface.php - this contains all the Javascript functions that
// execute the various actions that run in chat_db_query.php, such as creating chats, displaying
@@ -8,389 +8,5 @@
//
// Builds:
// 150121-2229 - First build
// 151218-1047 - moved into agc_agent_manager_chat_interface.php
//
// ################################################################################
// Show parent alert
function chat_alert_box(temp_message)
{
window.parent.document.getElementById("AlertBoxContent").innerHTML = temp_message;
parent.showDiv('AlertBox');
window.parent.document.alert_form.alert_button.focus();
}
/// Functions for agent/manager chatting
function CreateAgentToAgentChat() {
var agent_message=encodeURIComponent(document.getElementById("agent_message").value);
var user=document.getElementById("user").value;
var agent=document.getElementById("agent").value;
if (!agent_message || agent_message=="")
{
chat_alert_box("Please enter a chat message");
return false;
}
if (!agent || agent=="")
{
chat_alert_box("Please select an agent to chat with");
return false;
}
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_SQL_query = "action=CreateAgentToAgentChat&agent_manager="+user+"&agent_user="+agent+"&manager_message="+agent_message+"&user="+user;
xmlhttp.open('POST', 'chat_db_query.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;
var ChatText_array=ChatText.split("|");
if (ChatText.match(/^Error/))
{
chat_alert_box(ChatText);
}
else
{
document.getElementById("agent_message").value="";
document.getElementById("AgentNewChatSpan").style.display='none';
document.getElementById("AgentChatSpan").style.display='block';
document.getElementById("AgentEndChatSpan").style.display = 'block';
document.getElementById("AgentManagerOverride").value=agent;
document.getElementById("CurrentActiveChat").value=ChatText_array[0];
document.getElementById("CurrentActiveChatSubID").value=ChatText_array[1];
}
}
}
delete xmlhttp;
}
}
// Displays selected chat, also marks any message on it as read.
function DisplayMgrAgentChat(manager_chat_id, manager_chat_subid) {
if (manager_chat_id)
{
document.getElementById("CurrentActiveChat").value=manager_chat_id;
document.getElementById("CurrentActiveChatSubID").value=manager_chat_subid;
}
else
{
var manager_chat_id=document.getElementById("CurrentActiveChat").value;
var manager_chat_subid=document.getElementById("CurrentActiveChatSubID").value;
}
if (!manager_chat_id || !manager_chat_subid)
{
document.getElementById("AllowAgentReplies").style.display = 'none';
// document.getElementById("ActiveManagerChatTranscript").innerHTML=ChatText_array[1];
// document.getElementById("ActiveChatStartDate").innerHTML=ChatText_array[2];
// document.getElementById("ActiveChatManager").innerHTML=ChatText_array[3];
return false;
}
var user=document.getElementById("user").value;
var agent_override=document.getElementById("AgentManagerOverride").value;
// JCJ - commented out 10/19 so any agent in a-2-a chat can end it.
// if (agent_override && agent_override!="0" && agent_override!="")
// {
document.getElementById("AgentEndChatSpan").style.display = 'block';
// }
// else
// {
// document.getElementById("AgentEndChatSpan").style.display = 'none';
// }
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_SQL_query = "action=DisplayMgrAgentChat&user="+user+"&manager_chat_id="+manager_chat_id+"&manager_chat_subid="+manager_chat_subid;
xmlhttp.open('POST', 'chat_db_query.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;
var ChatText_array=ChatText.split("\n");
var allow_agent_replies=ChatText_array[0];
var new_messages=ChatText_array[4];
if (allow_agent_replies=="Y")
{
document.getElementById("AllowAgentReplies").style.display = 'block';
}
else
{
document.getElementById("AllowAgentReplies").style.display = 'none';
}
document.getElementById("ActiveManagerChatTranscript").innerHTML=ChatText_array[1];
document.getElementById("ActiveChatStartDate").innerHTML=ChatText_array[2];
document.getElementById("ActiveChatManager").innerHTML=ChatText_array[3];
document.getElementById("ActiveManagerChatTranscript").scrollTop = document.getElementById("ActiveManagerChatTranscript").scrollHeight;
RefreshActiveChatView();
}
}
delete xmlhttp;
}
}
// Ends selected displayed chat
function EndAgentToAgentChat() {
var manager_chat_id=document.getElementById("CurrentActiveChat").value;
var manager_chat_subid=document.getElementById("CurrentActiveChatSubID").value;
var user=document.getElementById("user").value;
if (!manager_chat_id || !manager_chat_subid)
{
document.getElementById("AllowAgentReplies").style.display = 'none';
return false;
}
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_SQL_query = "action=EndAgentToAgentChat&user="+user+"&manager_chat_id="+manager_chat_id+"&manager_chat_subid="+manager_chat_subid;
xmlhttp.open('POST', 'chat_db_query.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; // echoes number of lines affected - should be greater than zero.
if (ChatText>0)
{
document.getElementById("AllowAgentReplies").style.display = 'none';
document.getElementById("AgentEndChatSpan").style.display = 'none';
document.getElementById("ActiveManagerChatTranscript").innerHTML='';
document.getElementById("AgentManagerOverride").value='';
document.getElementById("ActiveChatStartDate").innerHTML='';
document.getElementById("ActiveChatManager").innerHTML='';
}
RefreshActiveChatView();
}
}
delete xmlhttp;
}
}
function RefreshActiveChatView() {
var user=document.getElementById("user").value;
var ChatReloadIDNumber=document.getElementById("ChatReloadIDNumber").value;
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_SQL_query = "action=RefreshActiveChatView&user="+user+"&ChatReloadIDNumber="+ChatReloadIDNumber;
xmlhttp.open('POST', 'chat_db_query.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 ActiveChatText = null;
ActiveChatText = xmlhttp.responseText;
if(ActiveChatText!="")
{
var ActiveChatText_array=ActiveChatText.split("|");
document.getElementById("ChatReloadIDNumber").value=ActiveChatText_array[0];
document.getElementById("AllActiveChats").innerHTML=ActiveChatText_array[1];
}
}
}
delete xmlhttp;
}
}
function ReloadAgentNewChatSpan(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_SQL_query = "action=ReloadAgentNewChatSpan&user="+user;
xmlhttp.open('POST', 'chat_db_query.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 Agent2AgentText = xmlhttp.responseText;
document.getElementById("AgentNewChatSpan").innerHTML=Agent2AgentText;
}
}
delete xmlhttp;
}
}
function SendMgrChatMessage(manager_chat_id, manager_chat_subid) {
// if (!manager_chat_id) {return false;}
if (manager_chat_id)
{
document.getElementById("CurrentActiveChat").value=manager_chat_id;
document.getElementById("CurrentActiveChatSubID").value=manager_chat_subid;
}
else
{
var manager_chat_id=document.getElementById("CurrentActiveChat").value;
var manager_chat_subid=document.getElementById("CurrentActiveChatSubID").value;
}
var user=document.getElementById("user").value;
var agent_override=document.getElementById("AgentManagerOverride").value;
var chat_message=encodeURIComponent(document.getElementById("manager_message").value);
if (!chat_message || chat_message=="") {return false;}
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_SQL_query = "action=SendMgrChatMessage&user="+user+"&manager_chat_id="+manager_chat_id+"&manager_chat_subid="+manager_chat_subid+"&chat_message="+chat_message+"&agent_override="+agent_override;
xmlhttp.open('POST', 'chat_db_query.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/))
{
chat_alert_box(ChatText);
}
else
{
document.getElementById("manager_message").value="";
}
}
}
delete xmlhttp;
}
}
function MgrAgentAutoRefresh() {
rInt=window.setInterval(function() {DisplayMgrAgentChat()}, 1000);
}
@@ -9,21 +9,30 @@
# Builds:
# 151212-0829 - First Build for customer chat
# 151217-1015 - Allow for group_id variable
# 151219-1415 - Added header and language variable
#
if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];}
elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];}
if (isset($_GET["chat_id"])) {$chat_id=$_GET["chat_id"];}
elseif (isset($_POST["chat_id"])) {$chat_id=$_POST["chat_id"];}
if (isset($_GET["group_id"])) {$chat_group_id=$_GET["group_id"];}
elseif (isset($_POST["group_id"])) {$chat_group_id=$_POST["group_id"];}
if (isset($_GET["chat_group_id"])) {$chat_group_id=$_GET["chat_group_id"];}
if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];}
elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];}
if (isset($_GET["chat_id"])) {$chat_id=$_GET["chat_id"];}
elseif (isset($_POST["chat_id"])) {$chat_id=$_POST["chat_id"];}
if (isset($_GET["group_id"])) {$chat_group_id=$_GET["group_id"];}
elseif (isset($_POST["group_id"])) {$chat_group_id=$_POST["group_id"];}
if (isset($_GET["chat_group_id"])) {$chat_group_id=$_GET["chat_group_id"];}
elseif (isset($_POST["chat_group_id"])) {$chat_group_id=$_POST["chat_group_id"];}
if (isset($_GET["email"])) {$email=$_GET["email"];}
elseif (isset($_POST["email"])) {$email=$_POST["email"];}
if (isset($_GET["unique_userID"])) {$unique_userID=$_GET["unique_userID"];}
if (isset($_GET["email"])) {$email=$_GET["email"];}
elseif (isset($_POST["email"])) {$email=$_POST["email"];}
if (isset($_GET["unique_userID"])) {$unique_userID=$_GET["unique_userID"];}
elseif (isset($_POST["unique_userID"])) {$unique_userID=$_POST["unique_userID"];}
$URL_vars="?user=".urlencode($unique_userID)."&lead_id=".$lead_id."&group_id=".urlencode($chat_group_id)."&chat_id=".$chat_id."&email=".urlencode($email);
if (isset($_GET["language"])) {$language=$_GET["language"];}
elseif (isset($_POST["language"])) {$language=$_POST["language"];}
$URL_vars="?user=".urlencode($unique_userID)."&lead_id=".$lead_id."&group_id=".urlencode($chat_group_id)."&chat_id=".$chat_id."&email=".urlencode($email)."&language=".urlencode($language);
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"?><html><head><title>Chat</title></head>';
?>
<iframe src="/chat_customer/vicidial_chat_customer_side.php<?php echo $URL_vars; ?>" style="width:600;height:400;background-color:transparent;" scrolling="auto" frameborder="0" allowtransparency="true" id="ViCiDiAlChAtIfRaMe" name="ViCiDiAlChAtIfRaMe"/>
<iframe src="/chat_customer/vicidial_chat_customer_side.php<?php echo $URL_vars; ?>" style="width:640;height:480;background-color:transparent;" scrolling="auto" frameborder="0" allowtransparency="true" id="ViCiDiAlChAtIfRaMe" name="ViCiDiAlChAtIfRaMe"/>
</html>
@@ -5,28 +5,12 @@
# 151212-0828 - First Build for customer chat
# 151213-1106 - Added variable filtering
# 151217-1016 - Allow for carrying of group_id through to new chat
# 151219-0850 - Added translation code
#
require("dbconnect_mysqli.php");
require("functions.php");
#############################################
##### START SYSTEM_SETTINGS LOOKUP #####
$stmt = "SELECT use_non_latin,enable_languages,language_method FROM system_settings;";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00XXX',$user,$server_ip,$session_name,$one_mysql_log);}
if ($DB) {echo "$stmt\n";}
$qm_conf_ct = mysqli_num_rows($rslt);
if ($qm_conf_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$non_latin = $row[0];
$SSenable_languages = $row[1];
$SSlanguage_method = $row[2];
}
##### END SETTINGS LOOKUP #####
###########################################
$color_array=array("#FF0000", "#0000FF", "#009900", "#990099", "#009999", "#666600", "#999999");
$style_array=array("", "italics", "bold italics");
@@ -54,6 +38,8 @@ if (isset($_GET["keepalive"])) {$keepalive=$_GET["keepalive"];}
elseif (isset($_POST["keepalive"])) {$keepalive=$_POST["keepalive"];}
if (isset($_GET["current_message_count"])) {$current_message_count=$_GET["current_message_count"];}
elseif (isset($_POST["current_message_count"])) {$current_message_count=$_POST["current_message_count"];}
if (isset($_GET["language"])) {$language=$_GET["language"];}
elseif (isset($_POST["language"])) {$language=$_POST["language"];}
$chat_member_name = preg_replace('/[^- \.\,\_0-9a-zA-Z]/',"",$chat_member_name);
if (!$user) {echo "No user, no using."; exit;}
@@ -62,6 +48,8 @@ $lead_id = preg_replace("/[^0-9]/","",$lead_id);
$chat_id = preg_replace('/[^- \_\.0-9a-zA-Z]/','',$chat_id);
$chat_level = preg_replace('/[^- \_\.0-9a-zA-Z]/','',$chat_level);
$group_id = preg_replace('/[^- \_0-9a-zA-Z]/','',$group_id);
$language = preg_replace('/[^-\_0-9a-zA-Z]/','',$language);
$chat_member_name = preg_replace("/\'|\"|\\\\|;/","",$chat_member_name);
if ($non_latin < 1)
{
@@ -73,49 +61,89 @@ else
$user = preg_replace("/\'|\"|\\\\|;/","",$user);
}
$settings_stmt="select chat_url from system_settings";
$settings_rslt=mysqli_query($link, $settings_stmt);
$settings_row=mysqli_fetch_row($settings_rslt);
$chat_url=$settings_row[0];
#############################################
##### START SYSTEM_SETTINGS LOOKUP #####
$VUselected_language='';
$stmt = "SELECT use_non_latin,enable_languages,language_method,default_language,chat_url,allow_chats FROM system_settings;";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00XXX',$user,$server_ip,$session_name,$one_mysql_log);}
if ($DB) {echo "$stmt\n";}
$qm_conf_ct = mysqli_num_rows($rslt);
if ($qm_conf_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$non_latin = $row[0];
$SSenable_languages = $row[1];
$SSlanguage_method = $row[2];
$SSdefault_language = $row[3];
$chat_url = $row[4];
$SSallow_chats = $row[5];
}
$VUselected_language = $SSdefault_language;
##### END SETTINGS LOOKUP #####
###########################################
if (strlen($language) > 1)
{
$stmt = "SELECT language_code,language_description FROM vicidial_languages where language_id='$language' and active='Y';";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00XXX',$user,$server_ip,$session_name,$one_mysql_log);}
if ($DB) {echo "$stmt\n";}
$lang_good_ct = mysqli_num_rows($rslt);
if ($lang_good_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$language_code = $row[0];
$language_description = $row[1];
$VUselected_language = $language;
}
}
if ($SSallow_chats < 1)
{
header ("Content-type: text/html; charset=utf-8");
echo _QXZ("Error, chat disabled on this system");
exit;
}
if ($action=="send_message" && $chat_id) {
$live_stmt="select status from vicidial_live_chats where chat_id='$chat_id'";
$live_stmt="SELECT status from vicidial_live_chats where chat_id='$chat_id'";
$live_rslt=mysql_to_mysqli($live_stmt, $link);
if ($user && $chat_message && $chat_id && mysqli_num_rows($live_rslt)>0) {
$live_row=mysqli_fetch_row($live_rslt);
$status=$live_row[0];
if ($status=="WAITING") {
echo "Chat $chat_id is waiting for an agent";
echo _QXZ("Chat is waiting for an agent").": $chat_id";
} else {
if ($status=="LIVE") {
# Check that the customer is still in the chat.
$active_stmt="select * from vicidial_chat_participants where chat_id='$chat_id' and chat_member='$user'";
$active_stmt="SELECT * from vicidial_chat_participants where chat_id='$chat_id' and chat_member='$user'";
$active_rslt=mysql_to_mysqli($active_stmt, $link);
if (mysqli_num_rows($active_rslt)>0) {
$ins_stmt="insert ignore into vicidial_chat_log(chat_id, message, poster, chat_member_name, chat_level) VALUES('$chat_id', '".mysqli_real_escape_string($link, $chat_message)."', '$user', '".mysqli_real_escape_string($link, $chat_member_name)."', '$chat_level')";
$ins_stmt="INSERT IGNORE INTO vicidial_chat_log(chat_id, message, poster, chat_member_name, chat_level) VALUES('$chat_id', '".mysqli_real_escape_string($link, $chat_message)."', '$user', '".mysqli_real_escape_string($link, $chat_member_name)."', '$chat_level')";
$ins_rslt=mysql_to_mysqli($ins_stmt, $link);
if (mysqli_affected_rows($link)<1) {
echo "<font class='chat_title alert'>SYSTEM ERROR</font><BR/>\n";
echo "<font class='chat_title alert'>"._QXZ("SYSTEM ERROR")."</font><BR/>\n";
}
}
} else {
echo "<font class='chat_title alert'>SYSTEM ERROR</font><BR/>\n";
echo "<font class='chat_title alert'>"._QXZ("SYSTEM ERROR")."</font><BR/>\n";
}
}
} else if (mysqli_num_rows($rslt)==0) {
echo "Chat $chat_id has been closed";
echo _QXZ("Chat has been closed").": $chat_id";
}
}
if ($action=="leave_chat" && $user && $chat_id) {
if (!$chat_member_name) {$chat_member_name="Customer";}
$del_stmt2="delete from vicidial_chat_participants where chat_id='$chat_id' and chat_member='$user'";
$del_stmt2="DELETE from vicidial_chat_participants where chat_id='$chat_id' and chat_member='$user'";
$del_rslt2=mysql_to_mysqli($del_stmt2, $link);
$deleted_participants=mysqli_affected_rows($link);
if ($deleted_participants>0) {
# ERASE THE CHAT IF THE PERSON NEVER GOT PICKED UP - I DON'T REMEMBER WHY I MOVED customer_leave_chat TO leave_chat
$stmt="select lead_id, status, chat_creator from vicidial_live_chats where chat_id='$chat_id'"; # and status='WAITING' and chat_creator='NONE'
$stmt="SELECT lead_id, status, chat_creator from vicidial_live_chats where chat_id='$chat_id'"; # and status='WAITING' and chat_creator='NONE'
$rslt=mysql_to_mysqli($stmt, $link);
if (mysqli_num_rows($rslt)>0) {
$row=mysqli_fetch_row($rslt);
@@ -125,17 +153,17 @@ if ($action=="leave_chat" && $user && $chat_id) {
if ($chat_status=="WAITING" && $chat_creator=="NONE") {
# USE SPECIAL DROP STATUS 'CDROP' FOR DROPPED CHATS WHERE NO AGENT RESPONDED TO CHAT
$upd_stmt="update vicidial_list set status='CDROP' where lead_id='$lead_id'";
$upd_stmt="UPDATE vicidial_list set status='CDROP' where lead_id='$lead_id'";
$upd_rslt=mysql_to_mysqli($upd_stmt, $link);
$ins_stmt="insert ignore into vicidial_chat_archive select chat_id, chat_start_time, 'DROP', chat_creator, group_id, lead_id From vicidial_live_chats where chat_id='$chat_id'";
$ins_stmt="INSERT IGNORE INTO vicidial_chat_archive SELECT chat_id, chat_start_time, 'DROP', chat_creator, group_id, lead_id From vicidial_live_chats where chat_id='$chat_id'";
$ins_rslt=mysql_to_mysqli($ins_stmt, $link);
$del_stmt="delete from vicidial_live_chats where chat_id='$chat_id'";
$del_stmt="DELETE from vicidial_live_chats where chat_id='$chat_id'";
$del_rslt=mysql_to_mysqli($del_stmt, $link);
} else {
# CHAT IS LIVE/AGENT NEEDS NOTIFICATION
$ins_alert_stmt="insert into vicidial_chat_log(poster, chat_member_name, message_time, message, chat_id, chat_level) select '$chat_creator', full_name, now(), '$chat_member_name has left chat', '$chat_id', '1' from vicidial_users where user='$chat_creator'";
$ins_alert_stmt="INSERT INTO vicidial_chat_log(poster, chat_member_name, message_time, message, chat_id, chat_level) SELECT '$chat_creator', full_name, now(), '$chat_member_name has left chat', '$chat_id', '1' from vicidial_users where user='$chat_creator'";
$ins_alert_rslt=mysql_to_mysqli($ins_alert_stmt, $link);
}
}
@@ -143,28 +171,28 @@ if ($action=="leave_chat" && $user && $chat_id) {
}
if ($action=="update_chat_window" && $chat_id) {
$status_stmt="select status, chat_creator from vicidial_live_chats where chat_id='$chat_id'";
$status_stmt="SELECT status, chat_creator from vicidial_live_chats where chat_id='$chat_id'";
$status_rslt=mysql_to_mysqli($status_stmt, $link);
if (mysqli_num_rows($status_rslt)==0) {
echo "<font class='chat_title alert'>Chat $chat_id does not exist or has been closed</font><BR/><BR/><font class='chat_title'><a href='".$chat_url."?group_id=$group_id'>GO BACK TO CHAT FORM</a></font>\n";
echo "<font class='chat_title alert'>"._QXZ("Chat does not exist or has been closed").": $chat_id</font><BR/><BR/><font class='chat_title'><a href='".$chat_url."?group_id=$group_id&language=$language'>"._QXZ("GO BACK TO CHAT FORM")."</a></font>\n";
} else {
$status_row=mysqli_fetch_row($status_rslt);
## Modify user's ping date to verify they are still participating
if ($user && $keepalive) {
$upd_stmt="update vicidial_chat_participants set ping_date=now() where chat_member='$user' and chat_id='$chat_id'";
$upd_stmt="UPDATE vicidial_chat_participants set ping_date=now() where chat_member='$user' and chat_id='$chat_id'";
$upd_rslt=mysql_to_mysqli($upd_stmt, $link);
}
## CHECK IF CHAT IS ACTIVE, IF SO GRAB DISTINCT USERS IN ORDER OF POST TO ASSIGN COLORS
if ($status_row[0]=="LIVE") {
$live_stmt="select * from vicidial_live_chats vlc, vicidial_chat_participants vcp where vlc.chat_id='$chat_id' and status='LIVE' and vlc.chat_id=vcp.chat_id and vcp.chat_member='$user'";
$live_stmt="SELECT * from vicidial_live_chats vlc, vicidial_chat_participants vcp where vlc.chat_id='$chat_id' and status='LIVE' and vlc.chat_id=vcp.chat_id and vcp.chat_member='$user'";
$live_rslt=mysql_to_mysqli($live_stmt, $link);
if (mysqli_num_rows($live_rslt)>0) {
echo "<font class='chat_title bold'>Current chat: $chat_id</font><BR/>\n";
echo "<font class='chat_title bold'>"._QXZ("Current chat").": $chat_id</font><BR/>\n";
# Create color-coding for chat
$stmt="select * from vicidial_chat_log where chat_id='$chat_id' order by message_time asc";
$stmt="SELECT * from vicidial_chat_log where chat_id='$chat_id' order by message_time asc";
$rslt=mysql_to_mysqli($stmt, $link);
$chat_members=array();
@@ -177,7 +205,7 @@ if ($action=="update_chat_window" && $chat_id) {
## GRAB CHAT MESSAGES AND DISPLAY THEM
if (!$user_level || $user_level==0) {$user_level_clause=" and chat_level='0' ";} else {$user_level_clause="";}
$stmt="select * from vicidial_chat_log where chat_id='$chat_id' $user_level_clause order by message_time asc";
$stmt="SELECT * from vicidial_chat_log where chat_id='$chat_id' $user_level_clause order by message_time asc";
$rslt=mysql_to_mysqli($stmt, $link);
while ($row=mysqli_fetch_row($rslt)) {
@@ -191,13 +219,13 @@ if ($action=="update_chat_window" && $chat_id) {
echo "<input type='hidden' id='current_message_count' name='current_message_count' value='$current_messages'>\n";
} else {
echo "<font class='chat_title bold'>You have left chat $chat_id.</font><BR/><BR/><font class='chat_title'><a href='".$chat_url."?group_id=$group_id'>GO BACK TO CHAT FORM</a></font>\n";
echo "<font class='chat_title bold'>"._QXZ("You have left chat").": $chat_id.</font><BR/><BR/><font class='chat_title'><a href='".$chat_url."?group_id=$group_id&language=$language'>"._QXZ("GO BACK TO CHAT FORM")."</a></font>\n";
}
} else {
if ($status_row[1]=="NONE") {
echo "<font class='chat_title bold'>Waiting for next available agent....</font><BR/>\n";
echo "<font class='chat_title bold'>"._QXZ("Waiting for next available agent...")."</font><BR/>\n";
} else {
echo "<font class='chat_title alert'>SYSTEM ERROR</font><BR/>\n";
echo "<font class='chat_title alert'>"._QXZ("SYSTEM ERROR")."</font><BR/>\n";
}
}
}
@@ -12,29 +12,12 @@
# 151212-0830 - First Build for customer chat
# 151213-1105 - Added variable filtering
# 151217-1017 - Allow for pre-populating of group_id
# 151219-0850 - Added translation code
#
require("dbconnect_mysqli.php");
require("functions.php");
#############################################
##### START SYSTEM_SETTINGS LOOKUP #####
$stmt = "SELECT use_non_latin,enable_languages,language_method FROM system_settings;";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00XXX',$user,$server_ip,$session_name,$one_mysql_log);}
if ($DB) {echo "$stmt\n";}
$qm_conf_ct = mysqli_num_rows($rslt);
if ($qm_conf_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$non_latin = $row[0];
$SSenable_languages = $row[1];
$SSlanguage_method = $row[2];
}
##### END SETTINGS LOOKUP #####
###########################################
if (isset($_GET["first_name"])) {$first_name=$_GET["first_name"];}
elseif (isset($_POST["first_name"])) {$first_name=$_POST["first_name"];}
if (isset($_GET["last_name"])) {$last_name=$_GET["last_name"];}
@@ -55,11 +38,16 @@ if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];}
elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];}
if (isset($_GET["user"])) {$user=$_GET["user"];}
elseif (isset($_POST["user"])) {$user=$_POST["user"];}
if (isset($_GET["language"])) {$language=$_GET["language"];}
elseif (isset($_POST["language"])) {$language=$_POST["language"];}
if (isset($_GET["stage"])) {$stage=$_GET["stage"];}
elseif (isset($_POST["stage"])) {$stage=$_POST["stage"];}
$PHP_SELF=$_SERVER["PHP_SELF"];
$lead_id = preg_replace("/[^0-9]/","",$lead_id);
$chat_id = preg_replace('/[^- \_\.0-9a-zA-Z]/','',$chat_id);
$group_id = preg_replace('/[^- \_0-9a-zA-Z]/','',$group_id);
$language = preg_replace('/[^-\_0-9a-zA-Z]/','',$language);
if ($non_latin < 1)
{
@@ -75,16 +63,64 @@ if ($non_latin < 1)
else
{
$user = preg_replace("/\'|\"|\\\\|;/","",$user);
$first_name = preg_replace("/\"|\\\\|;/","",$first_name);
$last_name = preg_replace("/\"|\\\\|;/","",$last_name);
$email = preg_replace("/\'|\"|\\\\|;/","",$email);
$phone_number = preg_replace('/[^- \'\+\.\:\/\@\%\_0-9a-zA-Z]/','',$email);
}
#############################################
##### START SYSTEM_SETTINGS LOOKUP #####
$VUselected_language='';
$stmt = "SELECT use_non_latin,enable_languages,language_method,default_language,allow_chats FROM system_settings;";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00XXX',$user,$server_ip,$session_name,$one_mysql_log);}
if ($DB) {echo "$stmt\n";}
$qm_conf_ct = mysqli_num_rows($rslt);
if ($qm_conf_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$non_latin = $row[0];
$SSenable_languages = $row[1];
$SSlanguage_method = $row[2];
$SSdefault_language = $row[3];
$SSallow_chats = $row[4];
}
$VUselected_language = $SSdefault_language;
##### END SETTINGS LOOKUP #####
###########################################
if (strlen($language) > 1)
{
$stmt = "SELECT language_code,language_description FROM vicidial_languages where language_id='$language' and active='Y';";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00XXX',$user,$server_ip,$session_name,$one_mysql_log);}
if ($DB) {echo "$stmt\n";}
$lang_good_ct = mysqli_num_rows($rslt);
if ($lang_good_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$language_code = $row[0];
$language_description = $row[1];
$VUselected_language = $language;
}
}
if ($SSallow_chats < 1)
{
header ("Content-type: text/html; charset=utf-8");
echo _QXZ("Error, chat disabled on this system");
exit;
}
# http://192.168.1.2/chat_customer/vicidial_chat_customer_side.php?user=1440723435.60926&lead_id=1079350&group_id=CHAT_TEST_GROUP&chat_id=254&email=joej%40test.com
$phone_number=preg_replace('/[^0-9]/', '', $phone_number);
if ($join_chat=="JOIN CHAT") { # For people invited to an existing chat from an agent.
if ($stage == "join_chat") { # For people invited to an existing chat from an agent.
$error_msg="";
if (!$first_name || !$last_name) {
$error_msg="Please enter your first and last name";
$error_msg=_QXZ("Please enter your first and last name");
} else {
$chat_member_name="$first_name $last_name";
$ip_address=$_SERVER['REMOTE_ADDR'];
@@ -92,7 +128,7 @@ if ($join_chat=="JOIN CHAT") { # For people invited to an existing chat from an
# SEARCH FOR CUSTOMER IN DATABASE - IF NOT FOUND BY PHONE OR IP ADDRESS MAKE A NEW USER
if ($lead_id) { # CAN OCCUR VIA INVITE
$upd_stmt="update vicidial_list set first_name='$first_name', last_name='$last_name', status='WCHAT' where lead_id='$lead_id' limit 1";
$upd_stmt="UPDATE vicidial_list set first_name=\"$first_name\", last_name=\"$last_name\", status='WCHAT' where lead_id='$lead_id' limit 1";
# update email and security_phrase?
$upd_rslt=mysql_to_mysqli($upd_stmt, $link);
@@ -102,7 +138,7 @@ if ($join_chat=="JOIN CHAT") { # For people invited to an existing chat from an
if (mysqli_num_rows($alert_rslt)>0) {
$alert_row=mysqli_fetch_row($alert_rslt);
$chat_creator=$alert_row[0];
$ins_alert_stmt="insert into vicidial_chat_log(poster, chat_member_name, message_time, message, chat_id, chat_level) select '" . mysqli_real_escape_string($link, $chat_creator) . "', full_name, now(), '" . mysqli_real_escape_string($link, $chat_member_name) . " has joined chat', '" . mysqli_real_escape_string($link, $chat_id) . "', '1' from vicidial_users where user='" . mysqli_real_escape_string($link, $chat_creator) . "'";
$ins_alert_stmt="INSERT INTO vicidial_chat_log(poster, chat_member_name, message_time, message, chat_id, chat_level) select '" . mysqli_real_escape_string($link, $chat_creator) . "', full_name, now(), '" . mysqli_real_escape_string($link, $chat_member_name) . " has joined chat', '" . mysqli_real_escape_string($link, $chat_id) . "', '1' from vicidial_users where user='" . mysqli_real_escape_string($link, $chat_creator) . "'";
$ins_alert_rslt=mysql_to_mysqli($ins_alert_stmt, $link);
}
} else {
@@ -122,21 +158,21 @@ if ($join_chat=="JOIN CHAT") { # For people invited to an existing chat from an
$lead_id=$row[0];
# Update to reflect chat request - should I do this? And use WCHAT status for "waiting for chat"?
$upd_stmt="update vicidial_list set first_name='$first_name', last_name='$last_name', status='WCHAT' where lead_id='$lead_id' limit 1";
$upd_stmt="UPDATE vicidial_list set first_name=\"$first_name\", last_name=\"$last_name\", status='WCHAT' where lead_id='$lead_id' limit 1";
# update email and security_phrase?
$upd_rslt=mysql_to_mysqli($upd_stmt, $link);
} else if (!$error_msg) {
# Create lead in vicidial_list table (make special system status for waiting for chat)
$ins_stmt="insert into vicidial_list(status, first_name, last_name, email, list_id, phone_number, security_phrase) VALUES('WCHAT', '" . mysqli_real_escape_string($link, $first_name) . "', '" . mysqli_real_escape_string($link, $last_name) . "', '" . mysqli_real_escape_string($link, $email) . "', '" . mysqli_real_escape_string($link, $default_list_id) . "', '" . mysqli_real_escape_string($link, $phone_number) . "', '" . mysqli_real_escape_string($link, $group_id) . "')";
$ins_stmt="INSERT INTO vicidial_list(status, first_name, last_name, email, list_id, phone_number, security_phrase) VALUES('WCHAT', '" . mysqli_real_escape_string($link, $first_name) . "', '" . mysqli_real_escape_string($link, $last_name) . "', '" . mysqli_real_escape_string($link, $email) . "', '" . mysqli_real_escape_string($link, $default_list_id) . "', '" . mysqli_real_escape_string($link, $phone_number) . "', '" . mysqli_real_escape_string($link, $group_id) . "')";
$ins_rslt=mysql_to_mysqli($ins_stmt, $link);
$lead_id=mysqli_insert_id($link);
}
}
if (!$lead_id || $lead_id==0) {
$error_msg.="<BR>\nCould not find or create dialer entry";
$error_msg.="<BR>\n"._QXZ("Could not find or create dialer entry");
} else {
$chat_upd_stmt="update vicidial_live_chats set lead_id='$lead_id' where chat_id='$chat_id'";
$chat_upd_stmt="UPDATE vicidial_live_chats set lead_id='$lead_id' where chat_id='$chat_id'";
$chat_upd_rslt=mysql_to_mysqli($chat_upd_stmt, $link);
}
@@ -145,27 +181,27 @@ if ($join_chat=="JOIN CHAT") { # For people invited to an existing chat from an
if (!$error_msg) {
if ($chat_id>0) {
$ins_stmt="insert into vicidial_chat_participants(chat_id, chat_member, chat_member_name, ping_date, vd_agent) VALUES('" . mysqli_real_escape_string($link, $chat_id) . "', '" . mysqli_real_escape_string($link, $user) . "', '" . mysqli_real_escape_string($link, $chat_member_name) . "', now(), 'N')";
$ins_stmt="INSERT INTO vicidial_chat_participants(chat_id, chat_member, chat_member_name, ping_date, vd_agent) VALUES('" . mysqli_real_escape_string($link, $chat_id) . "', '" . mysqli_real_escape_string($link, $user) . "', '" . mysqli_real_escape_string($link, $chat_member_name) . "', now(), 'N')";
$ins_rslt=mysql_to_mysqli($ins_stmt, $link);
if (mysqli_affected_rows($link)==0) {
$del_stmt="delete from vicidial_live_chats where chat_id='$chat_id'";
$del_stmt="DELETE from vicidial_live_chats where chat_id='$chat_id'";
$del_rslt=mysql_to_mysqli($del_stmt, $link);
$error_msg="Chat started, failure to join";
$error_msg=_QXZ("Chat started, failure to join");
unset($chat_id);
} else {
# echo "$chat_id|$lead_id|$ins_stmt";
}
} else {
$error_msg="Chat not started - $ins_stmt";
$error_msg=_QXZ("Chat not started")." - $ins_stmt";
}
}
}
if ($send_request=="SEND REQUEST") { # For people requesting a chat with an agent; consider using a special user variable name for this
if ($stage == 'send_request') { # For people requesting a chat with an agent; consider using a special user variable name for this
$error_msg="";
if (!$first_name || !$last_name) {$error_msg="Please enter your first and last name";}
if (!$first_name || !$last_name) {$error_msg=_QXZ("Please enter your first and last name");}
$chat_member_name="$first_name $last_name";
$ip_address=$_SERVER['REMOTE_ADDR'];
@@ -185,42 +221,49 @@ if ($send_request=="SEND REQUEST") { # For people requesting a chat with an agen
$lead_id=$row[0];
# Update to reflect chat request - should I do this? And use WCHAT status for "waiting for chat"?
$upd_stmt="update vicidial_list set first_name='" . mysqli_real_escape_string($link, $first_name) . "', last_name='" . mysqli_real_escape_string($link, $last_name) . "', status='WCHAT' where lead_id='$lead_id' limit 1";
$upd_stmt="UPDATE vicidial_list set first_name='" . mysqli_real_escape_string($link, $first_name) . "', last_name='" . mysqli_real_escape_string($link, $last_name) . "', status='WCHAT' where lead_id='$lead_id' limit 1";
# update email and security_phrase?
$upd_rslt=mysql_to_mysqli($upd_stmt, $link);
} else if (!$error_msg) {
# Create lead in vicidial_list table (make special system status for waiting for chat)
$ins_stmt="insert into vicidial_list(status, first_name, last_name, email, list_id, phone_number, security_phrase) VALUES('WCHAT', '" . mysqli_real_escape_string($link, $first_name) . "', '" . mysqli_real_escape_string($link, $last_name) . "', '" . mysqli_real_escape_string($link, $ip_address) . "', '" . mysqli_real_escape_string($link, $default_list_id) . "', '" . mysqli_real_escape_string($link, $phone_number) . "', '" . mysqli_real_escape_string($link, $group_id) . "')";
$ins_stmt="INSERT INTO vicidial_list(status, first_name, last_name, email, list_id, phone_number, security_phrase) VALUES('WCHAT', '" . mysqli_real_escape_string($link, $first_name) . "', '" . mysqli_real_escape_string($link, $last_name) . "', '" . mysqli_real_escape_string($link, $ip_address) . "', '" . mysqli_real_escape_string($link, $default_list_id) . "', '" . mysqli_real_escape_string($link, $phone_number) . "', '" . mysqli_real_escape_string($link, $group_id) . "')";
$ins_rslt=mysql_to_mysqli($ins_stmt, $link);
$lead_id=mysqli_insert_id($link);
}
if (!$lead_id || $lead_id==0) {
$error_msg.="<BR>\nCould not find or create dialer entry";
$error_msg.="<BR>\n"._QXZ("Could not find or create dialer entry");
}
if (!$error_msg) {
$ins_stmt="insert into vicidial_live_chats(status, chat_creator, group_id, lead_id, chat_start_time) VALUES('WAITING', 'NONE', '" . mysqli_real_escape_string($link, $group_id) . "', '" . mysqli_real_escape_string($link, $lead_id) . "', now())";
$ins_stmt="INSERT INTO vicidial_live_chats(status, chat_creator, group_id, lead_id, chat_start_time) VALUES('WAITING', 'NONE', '" . mysqli_real_escape_string($link, $group_id) . "', '" . mysqli_real_escape_string($link, $lead_id) . "', now())";
$ins_rslt=mysql_to_mysqli($ins_stmt, $link);
$chat_id=mysqli_insert_id($link);
if ($chat_id>0) {
$ins_stmt="insert into vicidial_chat_participants(chat_id, chat_member, chat_member_name, ping_date, vd_agent) VALUES('$chat_id', '" . mysqli_real_escape_string($link, $user) . "', '" . mysqli_real_escape_string($link, $chat_member_name) . "', now(), 'N')";
$ins_stmt="INSERT INTO vicidial_chat_participants(chat_id, chat_member, chat_member_name, ping_date, vd_agent) VALUES('$chat_id', '" . mysqli_real_escape_string($link, $user) . "', '" . mysqli_real_escape_string($link, $chat_member_name) . "', now(), 'N')";
$ins_rslt=mysql_to_mysqli($ins_stmt, $link);
if (mysqli_affected_rows($link)==0) {
$del_stmt="delete from vicidial_live_chats where chat_id='$chat_id'";
$del_stmt="DELETE from vicidial_live_chats where chat_id='$chat_id'";
$del_rslt=mysql_to_mysqli($del_stmt, $link);
$error_msg="Chat started, failure to join";
$error_msg=_QXZ("Chat started, failure to join");
unset($chat_id);
} else {
# echo "$chat_id|$lead_id|$ins_stmt";
}
} else {
$error_msg="Chat not started - $ins_stmt";
$error_msg=_QXZ("Chat not started")." - $ins_stmt";
}
}
}
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>
<title><?php echo $error_msg; ?></title>
@@ -230,6 +273,7 @@ if ($send_request=="SEND REQUEST") { # For people requesting a chat with an agen
<link rel="stylesheet" type="text/css" href="css/simpletree.css" />
<script language="Javascript">
var language='<?php echo $language ?>';
var group_id='<?php echo $group_id ?>';
function PleaseWait() {
@@ -262,7 +306,7 @@ function LeaveChat(chat_id, user, chat_member_name) {
}
if (xmlhttp)
{
chat_query = "&action=leave_chat&chat_id="+chat_id+"&group_id="+group_id+"&user="+user+"&chat_member_name="+chat_member_name;
chat_query = "&action=leave_chat&chat_id="+chat_id+"&group_id="+group_id+"&user="+user+"&chat_member_name="+chat_member_name+"&language="+language;
// alert(chat_query);
xmlhttp.open('POST', 'customer_chat_functions.php');
xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8');
@@ -297,7 +341,7 @@ function UpdateChatWindow() {
}
if (xmlhttp)
{
chat_query = "&chat_id="+chat_id+"&group_id="+group_id+"&user="+user+"&current_message_count="+current_message_count+"&action=update_chat_window&keepalive=1";
chat_query = "&chat_id="+chat_id+"&group_id="+group_id+"&user="+user+"&current_message_count="+current_message_count+"&language="+language+"&action=update_chat_window&keepalive=1";
xmlhttp.open('POST', 'customer_chat_functions.php');
xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8');
xmlhttp.send(chat_query);
@@ -334,7 +378,7 @@ function CustomerSendMessage(chat_id, user, message, chat_member_name) {
}
if (xmlhttp)
{
chat_query = "&chat_message="+chat_message+"&chat_id="+chat_id+"&group_id="+group_id+"&chat_member_name="+chat_member_name+"&user="+user+"&chat_level=0&action=send_message";
chat_query = "&chat_message="+chat_message+"&chat_id="+chat_id+"&group_id="+group_id+"&chat_member_name="+chat_member_name+"&user="+user+"&language="+language+"&chat_level=0&action=send_message";
xmlhttp.open('POST', 'customer_chat_functions.php');
xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8');
xmlhttp.send(chat_query);
@@ -361,17 +405,19 @@ function CustomerSendMessage(chat_id, user, message, chat_member_name) {
</head>
<?php
if (!$chat_id) {
$chat_title="Request chat with agent"; # This can be modified for customization later
$chat_title= _QXZ("Request chat with agent"); # This can be modified for customization later
?>
<body>
<form action="<?php echo $PHP_SELF; ?>" method="post">
<input type=hidden name=stage value="send_request">
<input type=hidden name=language value="<?php echo $language; ?>">
<span id="chat_request_span">
<table width="500" border=0 cellpadding=1 cellspacing=1 height="300">
<tr>
<th colspan='2' class='body_small_bold'><?php echo $chat_title; ?></th>
</tr>
<tr>
<td align='right' class='body_small'>Please enter your name:</td>
<td align='right' class='body_small'><?php echo _QXZ("Please enter your name"); ?>:</td>
<td align='left'>
<input type='text' class="cust_form" name='first_name' id='first_name' size='10' maxlength='30'>&nbsp;<input class="cust_form" type='text' name='last_name' id='last_name' size='15' maxlength='30'>
</td>
@@ -381,7 +427,7 @@ $chat_title="Request chat with agent"; # This can be modified for customization
{
?>
<tr>
<td align='right' class='body_small'>Select the department you wish to chat with:</td>
<td align='right' class='body_small'><?php echo _QXZ("Select the department you wish to chat with"); ?>:</td>
<td align='left'>
<select name='group_id' id='group_id' class="cust_form">
<?php
@@ -402,13 +448,13 @@ $chat_title="Request chat with agent"; # This can be modified for customization
}
?>
<tr>
<td align='right' class='body_small'>Phone number (optional):</td>
<td align='right' class='body_small'><?php echo _QXZ("Phone number (optional)"); ?>:</td>
<td align='left'>
<input type='text' class="cust_form" name='phone_number' id='phone_number' size='10' maxlength='20'>
</td>
</tr>
<tr>
<th colspan='2'><input type='submit' class='blue_btn' value='SEND REQUEST' name="send_request"><BR></th>
<th colspan='2'><input type='submit' class='blue_btn' value='<?php echo _QXZ("SEND REQUEST"); ?>' name="send_request"><BR></th>
</tr>
<?php
if ($error_msg) {
@@ -424,25 +470,26 @@ $chat_title="Request chat with agent"; # This can be modified for customization
?>
<body>
<form action="<?php echo $PHP_SELF; ?>" method="post" name="chat_form" id="chat_form">
<input type=hidden name=stage value="join_chat">
<span id="chat_request_span">
<table width="500" border=0 cellpadding=3 cellspacing=3 height="300">
<tr>
<th colspan='2' class='body_small_bold'><?php echo $chat_title; ?></th>
</tr>
<tr>
<td align='right' class='body_small'>Please enter your name:</td>
<td align='right' class='body_small'><?php echo _QXZ("Please enter your name"); ?>:</td>
<td align='left'>
<input type='text' class="cust_form" name='first_name' id='first_name' size='10' maxlength='30'>&nbsp;<input class="cust_form" type='text' name='last_name' id='last_name' size='15' maxlength='30'>
</td>
</tr>
<tr>
<td align='right' class='body_small'>Phone number (optional):</td>
<td align='right' class='body_small'><?php echo _QXZ("Phone number (optional)"); ?>:</td>
<td align='left'>
<input type='text' class="cust_form" name='phone_number' id='phone_number' size='10' maxlength='20'>
</td>
</tr>
<tr>
<th colspan='2'><input type='submit' class='blue_btn' value='JOIN CHAT' name="join_chat"><BR></th>
<th colspan='2'><input type='submit' class='blue_btn' value='<?php echo _QXZ("JOIN CHAT"); ?>' name="join_chat"><BR></th>
</tr>
<?php
if ($error_msg) {
@@ -454,6 +501,7 @@ $chat_title="Request chat with agent"; # This can be modified for customization
<input type="hidden" id="chat_id" name="chat_id" value="<?php echo $chat_id; ?>">
<input type="hidden" id="group_id" name="group_id" value="<?php echo $group_id; ?>">
<input type="hidden" id="lead_id" name="lead_id" value="<?php echo $lead_id; ?>">
<input type="hidden" id="language" name="language" value="<?php echo $language; ?>">
</form>
</body>
@@ -483,19 +531,20 @@ $chat_title="Request chat with agent"; # This can be modified for customization
</tr>
<tr>
<td class='chat_message' valign='top' align='left'><BR>
<input type='checkbox' id='MuteCustomerChatAlert' name='MuteCustomerChatAlert'>Mute alert sound
<input type='checkbox' id='MuteCustomerChatAlert' name='MuteCustomerChatAlert'><?php echo _QXZ("Mute alert sound"); ?>
</td>
<td valign='top' align='right'><BR>
<input class='red_btn' type='button' style="width:100px" value="<?php echo _QXZ("LEAVE CHAT"); ?>" onClick="LeaveChat(document.getElementById('chat_id').value, document.getElementById('user').value, document.getElementById('chat_member_name').value)">;
<input class='red_btn' type='button' style="width:100px" value="<?php echo _QXZ("LEAVE CHAT"); ?>" onClick="LeaveChat(document.getElementById('chat_id').value, document.getElementById('user').value, document.getElementById('chat_member_name').value);">
</td>
</tr>
</table>
</td>
</tr>
<?php
if ($error_msg) {
echo "<tr><th class='queue_text_red'>$error_msg<BR></th></tr>";
}
if ($error_msg)
{
echo "<tr><th class='queue_text_red'>$error_msg<BR></th></tr>";
}
?>
</table>
<input type="hidden" id="user" name="user" value="<?php echo $user; ?>">
@@ -504,6 +553,7 @@ $chat_title="Request chat with agent"; # This can be modified for customization
<input type="hidden" id="chat_creator" name="chat_creator" value="<?php echo $chat_creator; ?>">
<input type="hidden" id="lead_id" name="lead_id" value="<?php echo $lead_id; ?>">
<input type="hidden" id="group_id" name="group_id" value="<?php echo $group_id; ?>">
<input type="hidden" id="language" name="language" value="<?php echo $language; ?>">
<audio id='CustomerChatAudioAlertFile'><source src="sounds/chat_alert.mp3" type="audio/mpeg"></audio>
</form>
</body>
@@ -53,6 +53,7 @@
# 151125-1633 - Added search archive option
# 151216-1023 - Forked from original as "v2" for Call Time option changes, added CHAT option
# 151218-0651 - Added User Group Call Times restrictions to select list
# 151219-1702 - Some text changes for more efficient dynamic language function
#
$startMS = microtime();
@@ -1115,11 +1116,11 @@ $average_answer_seconds = sprintf("%10s", $average_answer_seconds);
if ($CHAT=='Y')
{
$MAIN.=_QXZ("Total Chats taken in to this In-Group:",47)."$TOTALcalls\n";
$MAIN.=_QXZ("Average Chat Length for all Chats:",47)."$average_call_seconds "._QXZ("seconds")."\n";
$MAIN.=_QXZ("Answered Chats:",47)."$ANSWEREDcalls $ANSWEREDpercent%\n";
$MAIN.=_QXZ("Average queue time for Answered Chats:",47)."$average_answer_seconds "._QXZ("seconds")."\n";
$MAIN.=_QXZ("Chats taken into the IVR for this In-Group:",47)."$IVRcalls\n";
$MAIN.=_QXZ("Total Chats taken in to this In-Group",47).": $TOTALcalls\n";
$MAIN.=_QXZ("Average Chat Length for all Chats",47).": $average_call_seconds "._QXZ("seconds")."\n";
$MAIN.=_QXZ("Answered Chats",47).": $ANSWEREDcalls $ANSWEREDpercent%\n";
$MAIN.=_QXZ("Average queue time for Answered Chats",47).": $average_answer_seconds "._QXZ("seconds")."\n";
$MAIN.=_QXZ("Chats taken into the IVR for this In-Group",47).": $IVRcalls\n";
$CSV_text1.="\""._QXZ("Total Chats taken in to this In-Group").":\",\"$TOTALcalls\"\n";
$CSV_text1.="\""._QXZ("Average Chat Length for all Chats").":\",\"$average_call_seconds "._QXZ("seconds")."\"\n";
@@ -1129,11 +1130,11 @@ if ($CHAT=='Y')
}
elseif ($EMAIL=='Y')
{
$MAIN.=_QXZ("Total Emails taken in to this In-Group:",47)."$TOTALcalls\n";
$MAIN.=_QXZ("Average Email Length for all Emails:",47)."$average_call_seconds "._QXZ("seconds")."\n";
$MAIN.=_QXZ("Answered Emails:",47)."$ANSWEREDcalls $ANSWEREDpercent%\n";
$MAIN.=_QXZ("Average queue time for Answered Emails:",47)."$average_answer_seconds "._QXZ("seconds")."\n";
$MAIN.=_QXZ("Emails taken into the IVR for this In-Group:",47)."$IVRcalls\n";
$MAIN.=_QXZ("Total Emails taken in to this In-Group",47).": $TOTALcalls\n";
$MAIN.=_QXZ("Average Email Length for all Emails",47).": $average_call_seconds "._QXZ("seconds")."\n";
$MAIN.=_QXZ("Answered Emails",47).": $ANSWEREDcalls $ANSWEREDpercent%\n";
$MAIN.=_QXZ("Average queue time for Answered Emails",47).": $average_answer_seconds "._QXZ("seconds")."\n";
$MAIN.=_QXZ("Emails taken into the IVR for this In-Group",47).": $IVRcalls\n";
$CSV_text1.="\""._QXZ("Total Emails taken in to this In-Group").":\",\"$TOTALcalls\"\n";
$CSV_text1.="\""._QXZ("Average Email Length for all Emails").":\",\"$average_call_seconds "._QXZ("seconds")."\"\n";
@@ -1143,11 +1144,11 @@ elseif ($EMAIL=='Y')
}
else
{
$MAIN.=_QXZ("Total calls taken in to this In-Group:",47)."$TOTALcalls\n";
$MAIN.=_QXZ("Average Call Length for all Calls:",47)."$average_call_seconds "._QXZ("seconds")."\n";
$MAIN.=_QXZ("Answered Calls:",47)."$ANSWEREDcalls $ANSWEREDpercent%\n";
$MAIN.=_QXZ("Average queue time for Answered Calls:",47)."$average_answer_seconds "._QXZ("seconds")."\n";
$MAIN.=_QXZ("Calls taken into the IVR for this In-Group:",47)."$IVRcalls\n";
$MAIN.=_QXZ("Total calls taken in to this In-Group",47).": $TOTALcalls\n";
$MAIN.=_QXZ("Average Call Length for all Calls",47).": $average_call_seconds "._QXZ("seconds")."\n";
$MAIN.=_QXZ("Answered Calls",47).": $ANSWEREDcalls $ANSWEREDpercent%\n";
$MAIN.=_QXZ("Average queue time for Answered Calls",47).": $average_answer_seconds "._QXZ("seconds")."\n";
$MAIN.=_QXZ("Calls taken into the IVR for this In-Group",47).": $IVRcalls\n";
$CSV_text1.="\""._QXZ("Total calls taken in to this In-Group").":\",\"$TOTALcalls\"\n";
$CSV_text1.="\""._QXZ("Average Call Length for all Calls").":\",\"$average_call_seconds "._QXZ("seconds")."\"\n";
@@ -1242,8 +1243,8 @@ if ($CHAT=='Y')
{
$MAIN.="\n";
$MAIN.="---------- "._QXZ("CUSTOM INDICATORS")."\n";
$MAIN.="GDE "._QXZ("(Answered/Total chats taken in to this In-Group):",50)." $ANSWEREDpercent%\n";
$MAIN.="ACR "._QXZ("(Dropped/Answered):",50)." $DROP_ANSWEREDpercent%\n";
$MAIN.="GDE "._QXZ("(Answered/Total chats taken in to this In-Group)",50).": $ANSWEREDpercent%\n";
$MAIN.="ACR "._QXZ("(Dropped/Answered)",50).": $DROP_ANSWEREDpercent%\n";
$CSV_text1.="\n\""._QXZ("CUSTOM INDICATORS")."\"\n";
$CSV_text1.="\"GDE "._QXZ("(Answered/Total chats taken in to this In-Group)").":\",\"$ANSWEREDpercent%\"\n";
@@ -1253,8 +1254,8 @@ elseif ($EMAIL=='Y')
{
$MAIN.="\n";
$MAIN.="---------- "._QXZ("CUSTOM INDICATORS")."\n";
$MAIN.="GDE "._QXZ("(Answered/Total emails taken in to this In-Group):",50)." $ANSWEREDpercent%\n";
$MAIN.="ACR "._QXZ("(Dropped/Answered):",50)." $DROP_ANSWEREDpercent%\n";
$MAIN.="GDE "._QXZ("(Answered/Total emails taken in to this In-Group)",50).": $ANSWEREDpercent%\n";
$MAIN.="ACR "._QXZ("(Dropped/Answered)",50).": $DROP_ANSWEREDpercent%\n";
$CSV_text1.="\n\""._QXZ("CUSTOM INDICATORS")."\"\n";
$CSV_text1.="\"GDE "._QXZ("(Answered/Total emails taken in to this In-Group)").":\",\"$ANSWEREDpercent%\"\n";
@@ -1264,8 +1265,8 @@ else
{
$MAIN.="\n";
$MAIN.="---------- "._QXZ("CUSTOM INDICATORS")."\n";
$MAIN.="GDE "._QXZ("(Answered/Total calls taken in to this In-Group):",50)." $ANSWEREDpercent%\n";
$MAIN.="ACR "._QXZ("(Dropped/Answered):",50)." $DROP_ANSWEREDpercent%\n";
$MAIN.="GDE "._QXZ("(Answered/Total calls taken in to this In-Group)",50).": $ANSWEREDpercent%\n";
$MAIN.="ACR "._QXZ("(Dropped/Answered)",50).": $DROP_ANSWEREDpercent%\n";
$CSV_text1.="\n\""._QXZ("CUSTOM INDICATORS")."\"\n";
$CSV_text1.="\"GDE "._QXZ("(Answered/Total calls taken in to this In-Group)").":\",\"$ANSWEREDpercent%\"\n";
@@ -1274,8 +1275,8 @@ else
if ($DID!='Y')
{
$MAIN.="TMR1 "._QXZ("(Answered within %1s seconds/Answered):",50,'',$Sanswer_sec_pct_rt_stat_one)." $PCTanswer_sec_pct_rt_stat_one%\n";
$MAIN.="TMR2 "._QXZ("(Answered within %1s seconds/Answered):",50,'',$Sanswer_sec_pct_rt_stat_two)." $PCTanswer_sec_pct_rt_stat_two%\n";
$MAIN.="TMR1 "._QXZ("(Answered within %1s seconds/Answered)",50,'',$Sanswer_sec_pct_rt_stat_one).": $PCTanswer_sec_pct_rt_stat_one%\n";
$MAIN.="TMR2 "._QXZ("(Answered within %1s seconds/Answered)",50,'',$Sanswer_sec_pct_rt_stat_two).": $PCTanswer_sec_pct_rt_stat_two%\n";
$CSV_text1.="\"TMR1 "._QXZ("(Answered within %1s seconds/Answered)",0,'',$Sanswer_sec_pct_rt_stat_one).":\",\"$PCTanswer_sec_pct_rt_stat_one%\"\n";
$CSV_text1.="\"TMR2 "._QXZ("(Answered within %1s seconds/Answered)",0,'',$Sanswer_sec_pct_rt_stat_two).":\",\"$PCTanswer_sec_pct_rt_stat_two%\"\n";
}
@@ -8,10 +8,11 @@
# changes:
# 150605-2022 First Build
# 151213-1114 - Added variable filtering
# 151218-0739 - Added translation where missing
#
$admin_version = '2.12-2';
$build = '151213-1114';
$admin_version = '2.12-3';
$build = '151218-0739';
$sh="managerchats";
@@ -40,16 +41,20 @@ if (isset($_GET["action"])) {$action=$_GET["action"];}
#############################################
##### START SYSTEM_SETTINGS LOOKUP #####
$stmt = "SELECT use_non_latin,allow_chats FROM system_settings;";
$stmt = "SELECT use_non_latin,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);
if ($qm_conf_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$non_latin = $row[0];
$SSallow_chats = $row[1];
$non_latin = $row[0];
$SSallow_chats = $row[1];
$SSenable_languages = $row[2];
$SSlanguage_method = $row[3];
$SSdefault_language = $row[4];
}
$VUselected_language = $SSdefault_language;
##### END SETTINGS LOOKUP #####
###########################################
@@ -87,6 +92,23 @@ if ($auth < 1)
exit;
}
$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;
}
$chat_sub_id_ct=count($chat_sub_ids);
@@ -233,13 +255,13 @@ if ($reload_chat_span) {
} 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='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)\">[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' 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);
@@ -270,7 +292,7 @@ if ($reload_chat_span) {
$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'></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;
@@ -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>";
@@ -1,19 +1,34 @@
<?php
# new_manager_chat_form.php
#
# Copyright (C) 2015 Joe Johnson, Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# This page is for managers (level 8 or higher) to chat with live agents
#
# changes:
# 150608-2041 - First Build
# 151219-0718 - Added translation code where missing
#
require("dbconnect_mysqli.php");
require("functions.php");
#############################################
##### START SYSTEM_SETTINGS LOOKUP #####
$stmt = "SELECT use_non_latin,allow_chats FROM system_settings;";
$stmt = "SELECT use_non_latin,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);
if ($qm_conf_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$non_latin = $row[0];
$SSallow_chats = $row[1];
$non_latin = $row[0];
$SSallow_chats = $row[1];
$SSenable_languages = $row[2];
$SSlanguage_method = $row[3];
$SSdefault_language = $row[4];
}
$VUselected_language = $SSdefault_language;
##### END SETTINGS LOOKUP #####
###########################################
@@ -51,6 +66,24 @@ if ($auth < 1)
exit;
}
$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;
}
$stmt="select vla.user, vu.full_name, vu.user_group, vla.campaign_id, vc.campaign_name, vug.group_name from vicidial_users vu, vicidial_live_agents vla, vicidial_campaigns vc, vicidial_user_groups vug where vla.user=vu.user and vla.campaign_id=vc.campaign_id and vu.user_group=vug.user_group";
$rslt=mysql_to_mysqli($stmt, $link);
$user_array=array();
@@ -121,8 +154,8 @@ echo "<textarea rows='5' cols='50' name='manager_message' id='manager_message'><
echo "<input type='checkbox' name='allow_replies' id='allow_replies' value='Y' checked><font size='1'>"._QXZ("Allow agent replies")."</font>";
echo "</TD>";
echo "<td align='center' valign='middle'>";
echo "<input type='submit' name='submit_chat' style='width: 150px' value='"._QXZ("SELECTED AGENTS")."'><BR><BR><BR>";
echo "<input type='submit' name='submit_chat' style='width: 150px' value='"._QXZ("ALL LIVE AGENTS")."'>";
echo "<input type='submit' name='submit_chat' style='width: 150px' value=\""._QXZ("SELECTED AGENTS")."\"><BR><BR><BR>";
echo "<input type='submit' name='submit_chat' style='width: 150px' value=\""._QXZ("ALL LIVE AGENTS")."\">";
echo "</td>";
echo "</TR>";
echo "</table>";
+1 -281
View File
@@ -8,285 +8,5 @@
//
// Builds:
// 150612-2334 - First build
// 151219-0719 - moved into manager_chat_interface.php
//
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;
}
}