Added Chat Messaging

git-svn-id: svn://192.168.202.10@2428 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
mattf
2015-12-14 02:12:07 +00:00
parent 134707aac4
commit 8952589d00
43 changed files with 7847 additions and 160 deletions
+3
View File
@@ -206,6 +206,9 @@ OTHER CHANGES:
lead_id of the phone call and send a per-phone URL at the start of the
phone call.
51. Added Chat Messaging to agent screen, with manager chat utlitity. For more
information, read the CHAT_MESSAGING.txt doc.
+11 -3
View File
@@ -103,9 +103,10 @@
# 150804-0919 - Added whisper extensions
# 151031-0931 - Added usacan_phone_dialcode_fix feature at timeclock-end-of-day, added -lstn-buffer option
# 151204-0639 - Added phones-unavail_dialplan_fwd_exten options
# 151211-1509 - Added launching of the AST_chat_timeout_cron.pl process on the voicemail server
#
$build = '151204-0639';
$build = '151211-1509';
$DB=0; # Debug flag
@@ -1360,7 +1361,7 @@ if ($timeclock_end_of_day_NOW > 0)
################################################################################
##### Get the settings from system_settings #####
$stmtA = "SELECT sounds_central_control_active,active_voicemail_server,custom_dialplan_entry,default_codecs,generate_cross_server_exten,voicemail_timezones,default_voicemail_timezone,call_menu_qualify_enabled,allow_voicemail_greeting,reload_timestamp,meetme_enter_login_filename,meetme_enter_leave3way_filename FROM system_settings;";
$stmtA = "SELECT sounds_central_control_active,active_voicemail_server,custom_dialplan_entry,default_codecs,generate_cross_server_exten,voicemail_timezones,default_voicemail_timezone,call_menu_qualify_enabled,allow_voicemail_greeting,reload_timestamp,meetme_enter_login_filename,meetme_enter_leave3way_filename,allow_chats FROM system_settings;";
# print "$stmtA\n";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
@@ -1378,8 +1379,9 @@ if ($sthArows > 0)
$SScall_menu_qualify_enabled = $aryA[7];
$SSallow_voicemail_greeting = $aryA[8];
$SSreload_timestamp = $aryA[9];
$meetme_enter_login_filename = $aryA[10];
$meetme_enter_login_filename = $aryA[10];
$meetme_enter_leave3way_filename = $aryA[11];
$SSallow_chats = $aryA[12];
}
$sthA->finish();
if ($DBXXX > 0) {print "SYSTEM SETTINGS: $sounds_central_control_active|$active_voicemail_server|$SScustom_dialplan_entry|$SSdefault_codecs\n";}
@@ -3643,6 +3645,12 @@ if ( ($active_voicemail_server =~ /$server_ip/) && ((length($active_voicemail_se
$upload_flag = '--upload';
}
}
### start the chat timeout process
if ($SSallow_chats > 0)
{
if ($DB) {print "running chat timeout process...\n";}
`/usr/bin/screen -d -m -S ChatTimeout $PATHhome/AST_chat_timeout_cron.pl 2>/dev/null 1>&2`;
}
}
if ( ($active_asterisk_server =~ /Y/) && ( ($sounds_update =~ /Y/) || ($upload_audio > 0) ) )
+241
View File
@@ -0,0 +1,241 @@
#!/usr/bin/perl
# AST_chat_timeout_cron.pl
#
# This script is triggered by the ADMIN_keepalive_ALL.pl to run on the active voicemail server
#
# Copyright (C) 2015 Joe Johnson <freewermadmin@gmail.com, Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# CHANGES
# 150605-2135 - First build
# 150902-2209 - Slight SQL modifications for abandoned chats/notifying agents
#
# This script is designed to repeatedly check any customer-to-agent chats and close the customer side of the
# chat if it has not shown any activity for a period of time longer that what was set for the chat_timeout
# system setting.
#
# It will also close any manager-to-agent chats that do not show the agent(s) involved are still logged in.
### begin parsing run-time options ###
if (length($ARGV[0])>1)
{
$i=0;
while ($#ARGV >= $i)
{
$args = "$args $ARGV[$i]";
$i++;
}
if ($args =~ /--help/i)
{
print "allowed run time options:\n";
print " [--help] = this screen";
print " [--debug] = verbose debug messages\n";
print "\n";
exit;
}
else
{
if ($args =~ /--version/i)
{
print "version: $build\n";
exit;
}
if ($args =~ /--debug/i)
{
$DB=1; # Debug flag
$debug=1;
}
if ($args =~ /--debugX/i)
{
$DBX=1;
print "\n----- SUPER-DUPER DEBUGGING -----\n\n";
}
}
}
else
{
# print "no command line options set\n";
}
### end parsing run-time options ###
# default path to astguiclient configuration file:
$PATHconf = '/etc/astguiclient.conf';
open(conf, "$PATHconf") || die "can't open $PATHconf: $!\n";
@conf = <conf>;
close(conf);
$i=0;
foreach(@conf)
{
$line = $conf[$i];
$line =~ s/ |>|\n|\r|\t|\#.*|;.*//gi;
if ( ($line =~ /^PATHlogs/) && ($CLIlogs < 1) )
{$PATHlogs = $line; $PATHlogs =~ s/.*=//gi;}
if ( ($line =~ /^PATHsounds/) && ($CLIsounds < 1) )
{$PATHsounds = $line; $PATHsounds =~ s/.*=//gi;}
if ( ($line =~ /^VARserver_ip/) && ($CLIserver_ip < 1) )
{$VARserver_ip = $line; $VARserver_ip =~ s/.*=//gi;}
if ( ($line =~ /^VARDB_server/) && ($CLIDB_server < 1) )
{$VARDB_server = $line; $VARDB_server =~ s/.*=//gi;}
if ( ($line =~ /^VARDB_database/) && ($CLIDB_database < 1) )
{$VARDB_database = $line; $VARDB_database =~ s/.*=//gi;}
if ( ($line =~ /^VARDB_user/) && ($CLIDB_user < 1) )
{$VARDB_user = $line; $VARDB_user =~ s/.*=//gi;}
if ( ($line =~ /^VARDB_pass/) && ($CLIDB_pass < 1) )
{$VARDB_pass = $line; $VARDB_pass =~ s/.*=//gi;}
if ( ($line =~ /^VARDB_custom_user/) && ($CLIDB_custom_user < 1) )
{$VARDB_custom_user = $line; $VARDB_custom_user =~ s/.*=//gi;}
if ( ($line =~ /^VARDB_custom_pass/) && ($CLIDB_custom_pass < 1) )
{$VARDB_custom_pass = $line; $VARDB_custom_pass =~ s/.*=//gi;}
if ( ($line =~ /^VARDB_port/) && ($CLIDB_port < 1) )
{$VARDB_port = $line; $VARDB_port =~ s/.*=//gi;}
$i++;
}
# Customized Variables
$server_ip = $VARserver_ip; # Asterisk server IP
$THISserver_voicemail=0;
$voicemail_server_id='';
if (!$VARDB_port) {$VARDB_port='3306';}
use DBI;
$dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VARDB_user", "$VARDB_pass")
or die "Couldn't connect to database: " . DBI->errstr;
$dbhA2 = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VARDB_user", "$VARDB_pass")
or die "Couldn't connect to database: " . DBI->errstr;
$dbhA3 = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VARDB_user", "$VARDB_pass")
or die "Couldn't connect to database: " . DBI->errstr;
$timeout_stmt="select allow_chats, chat_timeout from system_settings";
$timeout_rslt=$dbhA->prepare($timeout_stmt);
$timeout_rslt->execute();
@trow=$timeout_rslt->fetchrow_array;
$allow_chats=$trow[0];
$chat_timeout=$trow[1];
## Kill agent-customer chats that are dead according to the system's chat timeout setting
if ($allow_chats==1 && $chat_timeout>0) {
$stmt="select distinct chat_id from vicidial_chat_participants where vd_agent='N' and ping_date<=now()-INTERVAL ".$chat_timeout." SECOND";
if ($debug) {print $stmt."\n\n";}
$rslt=$dbhA->prepare($stmt);
$rslt->execute();
if ($rslt->rows>0) {
$chat_id_str="";
while (@row=$rslt->fetchrow_array) {
$chat_id_str.="$row[0],";
}
$chat_id_str=~s/,$//;
$archive_stmt="insert ignore into vicidial_chat_archive select chat_id, chat_start_time, 'DROP' as status, chat_creator, group_id, lead_id from vicidial_live_chats where chat_id in (".$chat_id_str.")";
$dbhA->do($archive_stmt);
$archive_log_stmt="insert ignore into vicidial_chat_log_archive select * from vicidial_chat_log where chat_id in (".$chat_id_str.")";
$dbhA->do($archive_log_stmt);
$del_stmt="delete from vicidial_chat_participants where vd_agent='N' and ping_date<=now()-INTERVAL ".$chat_timeout." SECOND and chat_id in (".$chat_id_str.")";
$del_rslt=$dbhA->do($del_stmt);
if ($debug) {print $del_stmt."\n\n";}
########### CLEAR OUT UN-ASSIGNED CHATS
# GET LEAD IDS TO UPDATE vicidial_list TO SHOW CDROP STATUS
$sel_stmt="select lead_id from vicidial_live_chats where chat_id in (".$chat_id_str.") and status='WAITING' and chat_creator='NONE'";
$sel_rslt=$dbhA->prepare($sel_stmt);
$sel_rslt->execute();
$lead_id_str="";
while (@sel_row->$sel_rslt->fetchrow_array) {
$lead_id_str.="$sel_row[0],";
}
$lead_id_str=~s/,$//;
$upd_stmt="update vicidial_list set status='CDROP' where lead_id in (".$lead_id_str.")";
$upd_rslt=$dbhA->do($upd_stmt);
$del_stmt="delete from vicidial_live_chats where chat_id in (".$chat_id_str.") and status='WAITING' and chat_creator='NONE'";
$del_rslt=$dbhA->do($del_stmt);
if ($debug) {print $del_stmt."\n\n";}
$del_log_stmt="delete from vicidial_chat_log where chat_id in (".$chat_id_str.")";
$del_log_rslt=$dbhA->do($del_log_stmt);
#######################################
########### CLEAN ASSIGNED CHATS, NOTIFY AGENTS
$sel_stmt="select lead_id, chat_creator, chat_id from vicidial_live_chats where chat_id in (".$chat_id_str.") and status='LIVE' and chat_creator!='NONE'";
$sel_rslt=$dbhA->prepare($sel_stmt);
$sel_rslt->execute();
# DON'T UPDATE DISPO ON LEAD TO CDROP - NOTIFY AGENT AND LET THEM DO IT
while (@sel_row->$sel_rslt->fetchrow_array) {
$lead_id_str.="$sel_row[0],";
$lead_id=$sel_row[0];
$chat_creator=$sel_row[1];
$chat_id=$sel_row[2];
$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(), 'Customer seems to have abandoned chat', '$chat_id', '1' from vicidial_users where user='$chat_creator'";
$ins_alert_rslt=$dbhA2->do($ins_alert_stmt);
}
$lead_id_str=~s/,$//;
#######################################
}
}
## Kill manager-agent chats where the agent has logged out/is no longer live in the system
# $debug=1;
if ($allow_chats==1) {
$live_stmt="select user from vicidial_live_agents";
if ($debug) {print "$live_stmt\n";}
$live_rslt=$dbhA->prepare($live_stmt);
$live_rslt->execute();
$agent_str="";
while (@live_row=$live_rslt->fetchrow_array) {
$agent_str.="$live_row[0],";
}
$agent_str=~s/,$//;
if ($live_rslt->rows>0) {
$archive_stmt="insert ignore into vicidial_manager_chat_log_archive select * from vicidial_manager_chat_log where user not in ($agent_str)";
$dbhA2->do($archive_stmt);
if ($debug) {print $archive_stmt."\n\n";}
$del_stmt="delete from vicidial_manager_chat_log where user not in ($agent_str)";
$del_rslt=$dbhA2->do($del_stmt);
if ($debug) {print $del_stmt."\n\n";}
$chat_stmt="select distinct manager_chat_id from vicidial_manager_chat_log";
$chat_rslt=$dbhA2->prepare($chat_stmt);
$chat_rslt->execute();
if ($chat_rslt->rows==0) {
$ins_stmt="insert ignore into vicidial_manager_chats_archive select * from vicidial_manager_chats";
$dbhA3->do($ins_stmt);
$del_stmt="delete from vicidial_manager_chats";
$del_rslt=$dbhA3->do($del_stmt);
if ($debug) {print $del_stmt."\n\n";}
} else {
$chat_str="";
while (@chat_row=$chat_rslt->fetchrow_array) {
$chat_str.="$chat_row[0],";
}
$chat_str=~s/,$//;
$ins_stmt="insert ignore into vicidial_manager_chats_archive select * from vicidial_manager_chats where manager_chat_id not in ($chat_str)";
$dbhA3->do($ins_stmt);
$del_stmt="delete from vicidial_manager_chats where manager_chat_id not in ($chat_str)";
$del_rslt=$dbhA3->do($del_stmt);
}
} else {
# Clear all chats because no one is logged in
$archive_stmt="insert ignore into vicidial_manager_chat_log_archive select * from vicidial_manager_chat_log";
$dbhA2->do($archive_stmt);
if ($debug) {print $archive_stmt."\n\n";}
$del_stmt="delete from vicidial_manager_chat_log";
$del_rslt=$dbhA2->do($del_stmt);
if ($debug) {print $del_stmt."\n\n";}
$ins_stmt="insert ignore into vicidial_manager_chats_archive select * from vicidial_manager_chats";
$dbhA3->do($ins_stmt);
$del_stmt="delete from vicidial_manager_chats";
$del_rslt=$dbhA3->do($del_stmt);
}
}
+54
View File
@@ -0,0 +1,54 @@
CHAT MESSAGING Started 2014-05-01 Updated 2015-12-13
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.
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.
AGENT CHAT INTERFACE INSTRUCTIONS:
If your system administrator has enabled the chat feature, when you log in to the Vicidial agent interface, you will see two tabs at the top of your interface labeled "CHAT INTERNAL" and "CHAT CUSTOMER".
If you have any internal chats open, the words "CHAT INTERNAL" will appear in red. If you are involved in a chat where there are unread messages, the chat tab will be blinking red. To view the agent customer chat interface, simply click on the "CHAT CUSTOMER" tabs. The chat interface window will appear in place of the customer's information. If you have a chat with an unread message, that chat will automatically load in the agent screen by default, along with the name of the person you are chatting with and the date and time the chat started. If you have no unread messages, but have any open chats, the chat where the last message was posted will load by default. Otherwise, the screen will simply inform you that you have no active chats.
In the chat window, messages posted by you are displayed in blue text, while messages posted by the person you are chatting with are displayed in red.
Beneath the chat window is the text box you use to type in messages and send them. You can send them either by clicking the blue "SEND MESSAGE" button or by simply pressing the Enter key on your keyboard while you are typing something into the text box.
On the right side of the "CHAT INTERNAL" screen is a box labeled "Your active chats". For every open chat that you have, this box will display the name of the user you are chatting with. Chats with unread messages will be printed in boldface and highlighted in blue. To toggle between chats, simply click on the name of the person you are chatting with.
As you receive messages via the chat interface, you will occasionally hear an audio cue indicating you have a new message. If you would like to prevent this cue from being played, there is a checkbox beneath the "Your active chats" labeled "Mute alert sound" that you can mark to prevent this cue from being played.
If at any point you would like to initiate a chat with another user, you may click on the green "CHAT WITH LIVE AGENT" button to bring up a simple form to begin chatting with an agent. On the left side of the screen you may select a live agent to chat with. The only agents that will be available for you to talk to will be agents who meet two criteria:
1. They must currently be logged into the Vicidial agent interface.
2. They must belong to a user group that your user group has the ability to transfer to - these are the "Agent Status Viewable Groups" which are defined in the admin User Group page by authorized administrators.
On the right side of the screen is a text box in which you type the initial message you'd like to send to the selected live agent. Once you have filled this out you may click the green "START CHAT" button. You must have selected an agent and also have entered a message.
You can return to the chat screen at any time by clicking the red "BACK TO CHAT SCREEN" button. This will also clear anything you entered into the agent form.
MANAGER CHAT INTERFACE INSTRUCTIONS:
In the Administration web screen, there is a new link at the top of the screen next to the HOME link and the Timeclock link called "Chat". If you click on this link, you will be taken to the new manager chat screen. This screen will allow you to start chats with logged-in agents, as well as give you the ability to send broadcast chats to all agents that are logged in, or just specific agents.
CUSTOMER CHAT INSTRUCTIONS:
There is a new folder in the web directory called "chat_customer". You will find a file in this folder called "customer_chat_code.php" that you can use to write your own web page for a customer to chat from, or you can just use that page as your Chat URL. The Chat URL is a field in the System Settings that you need to populate in order for the customer chat to work. To use the default for this, just add "chat_customer/customer_chat_code.php" to your current Vicidial webserver URL. For example, if your current webserver url is "http://192.168.1.2/" then you can use this as your Chat URL: "http://192.168.1.2/chat_customer/customer_chat_code.php"
Chat settings in System Settings:
Allow Chats -This is where you can set whether this system will be able to receive incoming chats in addition to phone calls, as well as allow agent-to-agent and agent-to-manager chatting.
Chat Timeout -This is where you can set how long a customer chat can stay alive after the customer has navigated away from or closed their chat window. When the timeout is reached the chat is closed.
Chat URL -This is the location where you have placed the chat web pages for customer use.
+7 -76
View File
@@ -40,6 +40,7 @@
# 150312-0942 - Added ExpectedDBSchema value in astguiclient.conf
# 150911-1808 - Added creation of GPG directory for encrypted recordings
# 151029-0650 - Added Asterisk 11 as listed option, added new sample voicemail.conf for 1.8 and higher
# 151212-0840 - Added chat_customer web directory, removed static language build actions
#
############################################
@@ -2557,6 +2558,7 @@ if ($NOWEB < 1)
if (!-e "$PATHweb/vicidial/ploticus/") {`mkdir -p $PATHweb/vicidial/ploticus/`;}
if (!-e "$PATHweb/vicidial/agent_reports/") {`mkdir -p $PATHweb/vicidial/agent_reports/`;}
if (!-e "$PATHweb/vicidial/server_reports/") {`mkdir -p $PATHweb/vicidial/server_reports/`;}
if (!-e "$PATHweb/chat_customer/") {`mkdir -p $PATHweb/chat_customer/`;}
print "Copying web files...\n";
# save custom.css if its not empty
@@ -2568,11 +2570,13 @@ if ($NOWEB < 1)
`cp -f ./www/vicidial/robots.txt $PATHweb/vicidial/agent_reports/`;
`cp -f ./www/vicidial/robots.txt $PATHweb/vicidial/server_reports/`;
if (-e "$PATHweb/agc/css/custom.css.save_user_changes") {`mv $PATHweb/agc/css/custom.css.save_user_changes $PATHweb/agc/css/custom.css`;}
`cp -f ./www/vicidial/robots.txt $PATHweb/chat_customer/`;
print "setting web scripts to executable...\n";
`chmod 0777 $PATHweb/`;
`chmod -R 0755 $PATHweb/agc/`;
`chmod -R 0755 $PATHweb/vicidial/`;
`chmod -R 0755 $PATHweb/chat_customer/`;
`chmod 0777 $PATHweb/agc/`;
`chmod 0777 $PATHweb/vicidial/`;
`chmod 0777 $PATHweb/vicidial/ploticus/`;
@@ -2587,86 +2591,12 @@ if ($NOWEB < 1)
`rm -f $PATHweb/vicidial/new_listloader_superL.php`;
`rm -f $PATHweb/vicidial/listloader_super.pl`;
`rm -f $PATHweb/vicidial/listloader.pl`;
`chmod 0777 $PATHweb/chat_customer/`;
}
if ( ($PROMPTcopy_web_lang =~ /y/i) || ($CLIcopy_web_lang =~ /y/i) )
{
print "Copying web language translation files to $PATHweb...\n";
if (!-e "$PATHweb/agc_br/") {`mkdir -p $PATHweb/agc_br/`;}
if (!-e "$PATHweb/agc_de/") {`mkdir -p $PATHweb/agc_de/`;}
if (!-e "$PATHweb/agc_dk/") {`mkdir -p $PATHweb/agc_dk/`;}
if (!-e "$PATHweb/agc_el/") {`mkdir -p $PATHweb/agc_el/`;}
if (!-e "$PATHweb/agc_en/") {`mkdir -p $PATHweb/agc_en/`;}
if (!-e "$PATHweb/agc_es/") {`mkdir -p $PATHweb/agc_es/`;}
if (!-e "$PATHweb/agc_fr/") {`mkdir -p $PATHweb/agc_fr/`;}
if (!-e "$PATHweb/agc_it/") {`mkdir -p $PATHweb/agc_it/`;}
if (!-e "$PATHweb/agc_jp/") {`mkdir -p $PATHweb/agc_jp/`;}
if (!-e "$PATHweb/agc_nl/") {`mkdir -p $PATHweb/agc_nl/`;}
if (!-e "$PATHweb/agc_pl/") {`mkdir -p $PATHweb/agc_pl/`;}
if (!-e "$PATHweb/agc_pt/") {`mkdir -p $PATHweb/agc_pt/`;}
if (!-e "$PATHweb/agc_ru/") {`mkdir -p $PATHweb/agc_ru/`;}
if (!-e "$PATHweb/agc_se/") {`mkdir -p $PATHweb/agc_se/`;}
if (!-e "$PATHweb/agc_sk/") {`mkdir -p $PATHweb/agc_sk/`;}
if (!-e "$PATHweb/agc_tw/") {`mkdir -p $PATHweb/agc_tw/`;}
if (!-e "$PATHweb/vicidial_br/") {`mkdir -p $PATHweb/vicidial_br/`;}
if (!-e "$PATHweb/vicidial_de/") {`mkdir -p $PATHweb/vicidial_de/`;}
if (!-e "$PATHweb/vicidial_el/") {`mkdir -p $PATHweb/vicidial_el/`;}
if (!-e "$PATHweb/vicidial_en/") {`mkdir -p $PATHweb/vicidial_en/`;}
if (!-e "$PATHweb/vicidial_es/") {`mkdir -p $PATHweb/vicidial_es/`;}
if (!-e "$PATHweb/vicidial_fr/") {`mkdir -p $PATHweb/vicidial_fr/`;}
if (!-e "$PATHweb/vicidial_it/") {`mkdir -p $PATHweb/vicidial_it/`;}
print "Copying web files...\n";
`cp -f -R ./LANG_www/* $PATHweb/`;
print "setting web lang scripts to executable...\n";
`chmod 0777 $PATHweb/`;
`chmod -R 0755 $PATHweb/agc_br/`;
`chmod -R 0755 $PATHweb/agc_de/`;
`chmod -R 0755 $PATHweb/agc_dk/`;
`chmod -R 0755 $PATHweb/agc_el/`;
`chmod -R 0755 $PATHweb/agc_en/`;
`chmod -R 0755 $PATHweb/agc_es/`;
`chmod -R 0755 $PATHweb/agc_fr/`;
`chmod -R 0755 $PATHweb/agc_it/`;
`chmod -R 0755 $PATHweb/agc_jp/`;
`chmod -R 0755 $PATHweb/agc_nl/`;
`chmod -R 0755 $PATHweb/agc_pl/`;
`chmod -R 0755 $PATHweb/agc_pt/`;
`chmod -R 0755 $PATHweb/agc_ru/`;
`chmod -R 0755 $PATHweb/agc_se/`;
`chmod -R 0755 $PATHweb/agc_sk/`;
`chmod -R 0755 $PATHweb/agc_tw/`;
`chmod -R 0755 $PATHweb/vicidial_br/`;
`chmod -R 0755 $PATHweb/vicidial_de/`;
`chmod -R 0755 $PATHweb/vicidial_el/`;
`chmod -R 0755 $PATHweb/vicidial_en/`;
`chmod -R 0755 $PATHweb/vicidial_es/`;
`chmod -R 0755 $PATHweb/vicidial_fr/`;
`chmod -R 0755 $PATHweb/vicidial_it/`;
`chmod 0777 $PATHweb/agc_br/`;
`chmod 0777 $PATHweb/agc_de/`;
`chmod 0777 $PATHweb/agc_dk/`;
`chmod 0777 $PATHweb/agc_el/`;
`chmod 0777 $PATHweb/agc_en/`;
`chmod 0777 $PATHweb/agc_es/`;
`chmod 0777 $PATHweb/agc_fr/`;
`chmod 0777 $PATHweb/agc_it/`;
`chmod 0777 $PATHweb/agc_jp/`;
`chmod 0777 $PATHweb/agc_nl/`;
`chmod 0777 $PATHweb/agc_pl/`;
`chmod 0777 $PATHweb/agc_pt/`;
`chmod 0777 $PATHweb/agc_ru/`;
`chmod 0777 $PATHweb/agc_se/`;
`chmod 0777 $PATHweb/agc_sk/`;
`chmod 0777 $PATHweb/agc_tw/`;
`chmod 0777 $PATHweb/vicidial_br/`;
`chmod 0777 $PATHweb/vicidial_de/`;
`chmod 0777 $PATHweb/vicidial_el/`;
`chmod 0777 $PATHweb/vicidial_en/`;
`chmod 0777 $PATHweb/vicidial_es/`;
`chmod 0777 $PATHweb/vicidial_fr/`;
`chmod 0777 $PATHweb/vicidial_it/`;
print "Static language files no longer available, use dynamic language features.\n";
}
if ($PATHconf !~ /\/etc\/astguiclient.conf/)
@@ -2690,6 +2620,7 @@ if ($PATHconf !~ /\/etc\/astguiclient.conf/)
`sed -i 's/$PATHconfDEFAULT/$PATHconfEREG/g' $PATHweb/vicidial/listloader_super.pl `;
`sed -i 's/$PATHconfDEFAULT/$PATHconfEREG/g' $PATHweb/vicidial/listloader_rowdisplay.pl `;
`sed -i 's/$PATHconfDEFAULT/$PATHconfEREG/g' $PATHweb/vicidial/spreadsheet_sales_viewer.pl `;
`sed -i 's/$PATHconfDEFAULT/$PATHconfEREG/g' $PATHweb/chat_customer/dbconnect_mysqli.php `;
}
if ( ($PROMPTcopy_conf_files =~ /y/i) || ($CLIcopy_conf_files =~ /y/i) )
@@ -0,0 +1,269 @@
<?php
# agc_agent_manager_chat_interface.php
#
# Copyright (C) 2015 Joe Johnson, Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# This page is for agents to chat with managers via the agent interface.
#
# changes:
# 141212-2245 - First Build
# 151213-1108 - Added variable filtering
#
$admin_version = '2.12-2';
$build = '151213-1108';
$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"];}
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["user"])) {$user=$_GET["user"];}
elseif (isset($_POST["user"])) {$user=$_POST["user"];}
if (isset($_GET["pass"])) {$pass=$_GET["pass"];}
elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];}
if (!$user) {echo "Page should only be viewed through the agent interface."; die;}
if ($non_latin < 1)
{
$user = preg_replace('/[^-\_0-9a-zA-Z]/','',$user);
$pass = preg_replace('/[^-\_0-9a-zA-Z]/','',$pass);
$manager_chat_id = preg_replace('/[^- \_\.0-9a-zA-Z]/','',$user);
}
else
{
$user = preg_replace("/\'|\"|\\\\|;/","",$user);
$pass=preg_replace("/\'|\"|\\\\|;| /","",$pass);
$manager_chat_id = preg_replace("/\'|\"|\\\\|;/","",$user);
}
# 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";
$unread_rslt=mysqli_query($link, $unread_stmt);
while ($unread_row=mysqli_fetch_array($unread_rslt)) {
$IDNumber=$unread_row["manager_chat_id"]."-".$unread_row["manager_chat_subid"]."-".$unread_row["unread_count"];
array_push($chat_reload_id_number_array, "$IDNumber");
}
# Pull the most recently posted-to chat that has not been viewed, then the most recent period, and display that as the default window
$stmt="select distinct vicidial_manager_chat_log.manager_chat_id, vicidial_manager_chat_log.manager_chat_subid, vicidial_users.full_name, vicidial_manager_chats.chat_start_date, sum(if(vicidial_manager_chat_log.message_viewed_date is null, 1, 0)),vicidial_manager_chat_log.user from vicidial_manager_chat_log, vicidial_manager_chats, vicidial_users where vicidial_manager_chat_log.user='$user' and vicidial_manager_chat_log.manager_chat_id=vicidial_manager_chats.manager_chat_id and vicidial_manager_chats.manager=vicidial_users.user group by manager_chat_id, manager_chat_subid order by message_viewed_date asc, message_date desc";
$rslt=mysqli_query($link, $stmt);
$active_chats_array=array();
$chat_subid_array=array();
$unread_chats_array=array();
$chat_managers_array=array();
$chat_start_date_array=array();
$agents_managers_array=array(); // for override
$priority_chat="";
$priority_chat_subid="";
while ($row=mysqli_fetch_row($rslt)) {
if ($row[0]!="") {
if (!$priority_chat) {$priority_chat=$row[0];} # The priority_chat is the most recent chat that has not been viewed.
if (!$priority_chat_subid) {$priority_chat_subid=$row[1];} # The priority_chat is the most recent chat that has not been viewed.
if (!$agent_manager_override) {$agent_manager_override="0";} # The priority_chat is the most recent chat that has not been viewed.
array_push($active_chats_array, "$row[0]");
$chat_subid_array[$row[0]]="$row[1]";
$chat_managers_array[$row[0]]="$row[2]";
$chat_start_date_array[$row[0]]="$row[3]";
if ($row[4]>0) {array_push($unread_chats_array, $row[0]);} # Store any chat with unread messages.
$agents_managers_array[$row[0]]="0"; // not a chat where the agent is a manager
}
}
# Get a count on unread messages where the user is the chat manager/initiator in order to create the ChatReloadIDNumber variable
$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.manager='$user' group by manager_chat_id, manager_chat_subid order by manager_chat_id, manager_chat_subid";
$unread_rslt=mysqli_query($link, $unread_stmt);
while ($unread_row=mysqli_fetch_array($unread_rslt)) {
$IDNumber=$unread_row["manager_chat_id"]."-".$unread_row["manager_chat_subid"]."-".$unread_row["unread_count"];
array_push($chat_reload_id_number_array, "$IDNumber");
}
### This was added for agent to agent chats since there needs to be a list of open chats where the agent viewing this is also the manager,
### which will now happen because agents can now start their own chats. Added vicidial_manager_chat_log.user to this query on 2/4/15 for
### manager override
$stmt="select distinct vicidial_manager_chat_log.manager_chat_id, vicidial_manager_chat_log.manager_chat_subid, vicidial_users.full_name, vicidial_manager_chats.chat_start_date, sum(if(vicidial_manager_chat_log.message_viewed_date is null, 1, 0)),vicidial_manager_chat_log.user from vicidial_manager_chat_log, vicidial_manager_chats, vicidial_users where vicidial_manager_chat_log.manager='$user' and vicidial_manager_chat_log.manager_chat_id=vicidial_manager_chats.manager_chat_id and vicidial_manager_chat_log.user=vicidial_users.user group by manager_chat_id, manager_chat_subid order by message_viewed_date asc, message_date desc";
$rslt=mysqli_query($link, $stmt);
while ($row=mysqli_fetch_row($rslt)) {
if ($row[0]!="") {
if (!$priority_chat) {$priority_chat=$row[0];} # The priority_chat is the most recent chat that has not been viewed.
if (!$priority_chat_subid) {$priority_chat_subid=$row[1];} # The priority_chat is the most recent chat that has not been viewed.
if (!$agent_manager_override) {$agent_manager_override=$row[5];} # The priority_chat is the most recent chat that has not been viewed.
array_push($active_chats_array, "$row[0]");
$chat_subid_array[$row[0]]="$row[1]"; // Added back in on 3/3 - why was this removed?
$chat_managers_array[$row[0]]="$row[2]";
$chat_start_date_array[$row[0]]="$row[3]";
if ($row[4]>0) {array_push($unread_chats_array, $row[0]);} # Store any chat with unread messages.
$agents_managers_array[$row[0]]="$row[5]"; // IS a chat where the agent is a manager
}
}
#########
asort($active_chats_array);
asort($chat_managers_array);
asort($chat_reload_id_number_array);
$ChatReloadIDNumber="";
while (list($key, $id_number) = each($chat_reload_id_number_array)) {
$ChatReloadIDNumber.="$id_number.";
}
$ChatReloadIDNumber=substr($ChatReloadIDNumber,0,-1);
?>
<html>
<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
</head>
<link rel="stylesheet" href="vicidial_stylesheet.css">
<link rel="stylesheet" href="css/simpletree.css">
<script language="JavaScript" src="vicidial_chat_agent.js"></script>
<title><?php echo _QXZ("ADMINISTRATION: Agent/Manager Chat Interface"); ?></title>
<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 "</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</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";
} else {
while (list($manager_chat_id, $text) = each($chat_managers_array)) {
$manager_chat_subid=$chat_subid_array[$manager_chat_id];
if (!empty($unread_chats_array) && in_array($manager_chat_id, $unread_chats_array)) {$cclass="unreadchat";} else {$cclass="viewedchat";}
echo "\t<li class='".$cclass."'><a onClick=\"document.getElementById('CurrentActiveChat').value='$manager_chat_id'; document.getElementById('CurrentActiveChatSubID').value='$manager_chat_subid'; document.getElementById('AgentManagerOverride').value='".$agents_managers_array[$manager_chat_id]."'; \">".$chat_managers_array[$manager_chat_id]."</a></li>\n";
$sid++;
}
}
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 "</TD>\n";
echo "</TR>\n";
#echo "<TR BGCOLOR='#E6E6E6'>\n";
#echo "<TD align='center' colspan='2'>&nbsp;\n";
#echo "</TD>\n";
#echo "</TR>\n";
echo "</table>\n";
echo "<input type='hidden' name='CurrentActiveChat' id='CurrentActiveChat' value='$priority_chat'>\n";
echo "<input type='hidden' name='InternalMessageCount' id='InternalMessageCount' value='0'>\n";
echo "<input type='hidden' name='CurrentActiveChatSubID' id='CurrentActiveChatSubID' value='$priority_chat_subid'>\n";
echo "<input type='hidden' name='AgentManagerOverride' id='AgentManagerOverride' value='$agent_manager_override'>\n";
echo "<input type='hidden' name='user' id='user' value='$user'>\n";
echo "<input type='hidden' size='50' name='ChatReloadIDNumber' id='ChatReloadIDNumber' value='$ChatReloadIDNumber'>\n";
echo "</form>";
?>
</span>
<span id='AgentNewChatSpan' name='AgentNewChatSpan' style='display: none;'>
<?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";
$stmt="SELECT user_group from vicidial_users where user='$user';";
if ($non_latin > 0) {$rslt=mysql_to_mysqli("SET NAMES 'UTF8'", $link);}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00573',$user,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$VU_user_group = $row[0];
$agent_status_viewable_groupsSQL='';
### Gather timeclock and shift enforcement restriction settings
$stmt="SELECT agent_status_viewable_groups,agent_status_view_time from vicidial_user_groups where user_group='$VU_user_group';";
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$agent_status_viewable_groups = $row[0];
$agent_status_viewable_groupsSQL = preg_replace('/\s\s/i','',$agent_status_viewable_groups);
$agent_status_viewable_groupsSQL = preg_replace('/\s/i',"','",$agent_status_viewable_groupsSQL);
$agent_status_viewable_groupsSQL = "user_group IN('$agent_status_viewable_groupsSQL')";
$agent_status_view = 0;
if (strlen($agent_status_viewable_groups) > 2)
{$agent_status_view = 1;}
$agent_status_view_time=0;
if ($row[1] == 'Y')
{$agent_status_view_time=1;}
$andSQL='';
if (preg_match("/ALL-GROUPS/",$agent_status_viewable_groups))
{$AGENTviewSQL = "";}
else
{
$AGENTviewSQL = "($agent_status_viewable_groupsSQL)";
if (preg_match("/CAMPAIGN-AGENTS/",$agent_status_viewable_groups))
{$AGENTviewSQL = "($AGENTviewSQL or (campaign_id='$campaign'))";}
$AGENTviewSQL = "and $AGENTviewSQL";
}
$stmt="SELECT vla.user,vu.full_name from vicidial_live_agents vla,vicidial_users vu where vla.user=vu.user and vu.user!='$user' $AGENTviewSQL order by vu.full_name;";
$rslt=mysql_to_mysqli($stmt, $link);
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";
while ($agents_count > $loop_count)
{
$row=mysqli_fetch_row($rslt);
echo "<option value='$row[0]'>$row[1]</option>\n";
$loop_count++;
}
echo "</select>";
echo "</td>\n";
echo "<td width='200'><font class='arial'>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 "</table>";
?>
</span>
</body>
</html>
+807
View File
@@ -0,0 +1,807 @@
<?php
# chat_db_query.php
#
# Copyright (C) 2014 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
# vdc_chat_display.php and vicidial_chat_agent.js. Sample actions include creating and ending
# agent-to-agent chats, refreshing the chat window, and sending messages to the database to be
# displayed.
#
# Builds:
# 150901-2348 - First build
#
require("dbconnect_mysqli.php");
require("functions.php");
$NOW_TIME = date("Y-m-d H:i:s");
$color_array=array("#FF0000", "#0000FF", "#009900", "#990099", "#009999", "#666600", "#999999");
$style_array=array("", "italics", "bold italics");
if (isset($_GET["action"])) {$action=$_GET["action"];}
elseif (isset($_POST["action"])) {$action=$_POST["action"];}
if (isset($_GET["DB"])) {$DB=$_GET["DB"];}
elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];}
if (isset($_GET["chat_id"])) {$chat_id=$_GET["chat_id"];}
elseif (isset($_POST["chat_id"])) {$chat_id=$_POST["chat_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["chat_level"])) {$chat_level=$_GET["chat_level"];}
elseif (isset($_POST["chat_level"])) {$chat_level=$_POST["chat_level"];}
if (isset($_GET["chat_creator"])) {$chat_creator=$_GET["chat_creator"];}
elseif (isset($_POST["chat_creator"])) {$chat_creator=$_POST["chat_creator"];}
if (isset($_GET["chat_member_name"])) {$chat_member_name=$_GET["chat_member_name"];}
elseif (isset($_POST["chat_member_name"])) {$chat_member_name=$_POST["chat_member_name"];}
if (isset($_GET["chat_message"])) {$chat_message=$_GET["chat_message"];}
elseif (isset($_POST["chat_message"])) {$chat_message=$_POST["chat_message"];}
if (isset($_GET["email"])) {$email=$_GET["email"];}
elseif (isset($_POST["email"])) {$email=$_POST["email"];}
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["server_ip"])) {$server_ip=$_GET["server_ip"];}
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
if (isset($_GET["user_level"])) {$user_level=$_GET["user_level"];}
elseif (isset($_POST["user_level"])) {$user_level=$_POST["user_level"];}
if (isset($_GET["pass"])) {$pass=$_GET["pass"];}
elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];}
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"];}
elseif (isset($_POST["last_name"])) {$last_name=$_POST["last_name"];}
if (isset($_GET["group_id"])) {$group_id=$_GET["group_id"];}
elseif (isset($_POST["group_id"])) {$group_id=$_POST["group_id"];}
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["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["manager_chat_subid"])) {$manager_chat_subid=$_GET["manager_chat_subid"];}
elseif (isset($_POST["manager_chat_subid"])) {$manager_chat_subid=$_POST["manager_chat_subid"];}
if (isset($_GET["agent_manager"])) {$agent_manager=$_GET["agent_manager"];}
elseif (isset($_POST["agent_manager"])) {$agent_manager=$_POST["agent_manager"];}
if (isset($_GET["agent_user"])) {$agent_user=$_GET["agent_user"];}
elseif (isset($_POST["agent_user"])) {$agent_user=$_POST["agent_user"];}
if (isset($_GET["agent_override"])) {$agent_override=$_GET["agent_override"];}
elseif (isset($_POST["agent_override"])) {$agent_override=$_POST["agent_override"];}
if (isset($_GET["hangup_override"])) {$hangup_override=$_GET["hangup_override"];}
elseif (isset($_POST["hangup_override"])) {$hangup_override=$_POST["hangup_override"];}
if (isset($_GET["manager_message"])) {$manager_message=$_GET["manager_message"];}
elseif (isset($_POST["manager_message"])) {$manager_message=$_POST["manager_message"];}
if (isset($_GET["ChatReloadIDNumber"])) {$ChatReloadIDNumber=$_GET["ChatReloadIDNumber"];}
elseif (isset($_POST["ChatReloadIDNumber"])) {$ChatReloadIDNumber=$_POST["ChatReloadIDNumber"];}
$chat_member_name = preg_replace('/[^- \.\,\_0-9a-zA-Z]/',"",$chat_member_name);
if (!$user) {echo "No user, no using."; exit;}
###### AGENT/MANAGER CHAT FUNCTIONS #######
if ($action=="CreateAgentToAgentChat" && $agent_manager && $agent_user && $manager_message) {
# Check that you aren't already chatting with the agent - also checks for chats where the other agent is the manager and you are the requested chat recipient
$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";
} 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.
$stmt="select vicidial_live_agents.user, vicidial_users.full_name, vicidial_users.user_group, vicidial_live_agents.campaign_id from vicidial_live_agents, vicidial_users where vicidial_live_agents.user=vicidial_users.user and vicidial_live_agents.user='$agent_user' and vicidial_users.user!='$agent_manager' order by vicidial_users.full_name asc";
$rslt=mysqli_query($link, $stmt);
if (mysqli_num_rows($rslt)>0) {
$row=mysqli_fetch_row($rslt);
$user=$row[0];
$user_group=$row[2];
$campaign_id=$row[3];
$ins_stmt="insert into vicidial_manager_chats(chat_start_date, manager, selected_agents, selected_user_groups, selected_campaigns, allow_replies) VALUES(now(), '$agent_manager', '|$agent_user|', '|$user_group|', '|$campaign_id|', 'Y')";
$ins_rslt=mysqli_query($link, $ins_stmt);
$manager_chat_id=mysqli_insert_id($link);
$subid=1;
# $manager_message = preg_replace('/;/i','',$manager_message);
$manager_message = preg_replace("/\r/i",'',$manager_message);
$manager_message = preg_replace("/\n/i",' ',$manager_message);
# $manager_message=addslashes(trim("$manager_message"));
$ins_chat_stmt="insert into vicidial_manager_chat_log(manager_chat_id, manager_chat_subid, manager, user, message, message_date, message_posted_by) VALUES('$manager_chat_id', '$subid', '$agent_manager', '$agent_user', '".mysqli_real_escape_string($link, $manager_message)."', now(), '$agent_manager')";
$ins_chat_rslt=mysqli_query($link, $ins_chat_stmt);
echo "$manager_chat_id|$subid";
}
}
}
if ($action=="DisplayMgrAgentChat" && $manager_chat_id && $manager_chat_subid && $user) {
$stmt="select vm.message_posted_by, vm.message, vm.message_date, vu.full_name, vm.manager, vm.manager_chat_subid, vmc.chat_start_date 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.manager_chat_subid='$manager_chat_subid' and vm.user=vu.user order by vm.manager_chat_subid asc, message_date desc";
$rslt=mysql_to_mysqli($stmt, $link);
if ($debug==1) {echo "$stmt<BR>\n";}
# Mark messages as viewed by user (not manager, even if manager is agent at the time)
$upd_stmt="update vicidial_manager_chat_log set message_viewed_date=now() where message_viewed_date is null and manager_chat_id='$manager_chat_id' and manager_chat_subid='$manager_chat_subid' and user='$user'";
$upd_rslt=mysql_to_mysqli($upd_stmt, $link);
$new_messages=mysqli_affected_rows($link);
if (mysqli_num_rows($rslt)>0) {
$prev_chat_subid="";
$backlog_limit=20;
$chat_output_text="";
while($row=mysqli_fetch_row($rslt)) {
if (!$chat_start_date) {$chat_start_date=$row[6];}
if (!$manager) {$manager=$row[4];}
if ($backlog_limit>0) {
# Current agent is always the blue text
if ($row[0]!=$user) {$fc="#990000";} else {$fc="#000099";}
$chat_output_text="<font color='$fc' FACE=\"ARIAL,HELVETICA\" size='1'>$row[1]</font><BR>".$chat_output_text;
$backlog_limit--;
}
}
$reply_stmt="select allow_replies from vicidial_manager_chats where manager_chat_id='$manager_chat_id'";
$reply_rslt=mysql_to_mysqli($reply_stmt, $link);
$reply_row=mysqli_fetch_row($reply_rslt);
$allow_replies=$reply_row[0];
if ($manager==$user) {
$mgr_stmt="select distinct full_name from vicidial_users vu, vicidial_manager_chat_log vc where manager_chat_id='$manager_chat_id' and manager_chat_subid='$manager_chat_subid' and vc.user=vu.user";
$mgr_rslt=mysql_to_mysqli($mgr_stmt, $link);
if (mysqli_num_rows($mgr_rslt)!=1) {
$display_name="ERROR - $mgr_stmt";
} else {
$mgr_row=mysqli_fetch_row($mgr_rslt);
$display_name=$mgr_row[0];
}
} else {
$mgr_stmt="select full_name from vicidial_users where user='$manager'";
$mgr_rslt=mysql_to_mysqli($mgr_stmt, $link);
$mgr_row=mysqli_fetch_row($mgr_rslt);
$display_name=$mgr_row[0];
}
echo $allow_replies."\n".$chat_output_text."\n".$chat_start_date."\n".$display_name."\n".$new_messages;
} else {
echo "N\nCHAT ENDED\n\n";
}
}
if ($action=="EndAgentToAgentChat" && $manager_chat_id) {
$archive_stmt="insert ignore into vicidial_manager_chat_log_archive select * from vicidial_manager_chat_log where manager_chat_id='$manager_chat_id'";
$archive_rslt=mysqli_query($link, $archive_stmt);
$archive_stmt="insert ignore into vicidial_manager_chats_archive select * from vicidial_manager_chats where manager_chat_id='$manager_chat_id'";
$archive_rslt=mysqli_query($link, $archive_stmt);
$delete_stmt="delete from vicidial_manager_chat_log where manager_chat_id='$manager_chat_id'";
$delete_rslt=mysqli_query($link, $delete_stmt);
if (mysqli_affected_rows($link)>0) {
$archive_stmt="delete from vicidial_manager_chats where manager_chat_id='$manager_chat_id'";
$archive_rslt=mysqli_query($link, $archive_stmt);
}
echo mysqli_affected_rows($link);
}
if ($action=="RefreshActiveChatView" && $user) {
# 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";
$unread_rslt=mysqli_query($link, $unread_stmt);
while ($unread_row=mysqli_fetch_array($unread_rslt)) {
$IDNumber=$unread_row["manager_chat_id"]."-".$unread_row["manager_chat_subid"]."-".$unread_row["unread_count"];
array_push($chat_reload_id_number_array, "$IDNumber");
}
# Pull the most recently posted-to chat that has not been viewed, then the most recent period, and display that as the default window
$stmt="select distinct vicidial_manager_chat_log.manager_chat_id, vicidial_manager_chat_log.manager_chat_subid, vicidial_users.full_name, vicidial_manager_chats.chat_start_date, sum(if(vicidial_manager_chat_log.message_viewed_date is null, 1, 0)) from vicidial_manager_chat_log, vicidial_manager_chats, vicidial_users where vicidial_manager_chat_log.user='$user' and vicidial_manager_chat_log.manager_chat_id=vicidial_manager_chats.manager_chat_id and vicidial_manager_chats.manager=vicidial_users.user group by manager_chat_id, manager_chat_subid order by message_viewed_date asc, message_date desc";
$rslt=mysqli_query($link, $stmt);
$active_chats_array=array();
$chat_subid_array=array();
$unread_chats_array=array();
$chat_managers_array=array();
$chat_start_date_array=array();
while ($row=mysqli_fetch_row($rslt)) {
if ($row[0]!="") {
array_push($active_chats_array, "$row[0]");
$chat_subid_array[$row[0]]="$row[1]";
$chat_managers_array[$row[0]]="$row[2]";
$chat_start_date_array[$row[0]]="$row[3]";
if ($row[4]>0) {array_push($unread_chats_array, $row[0]);} # Store any chat with unread messages.
$agents_managers_array[$row[0]]="0";
}
}
# Get a count on unread messages where the user is the chat manager/initiator in order to create the ChatReloadIDNumber variable
$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.manager='$user' group by manager_chat_id, manager_chat_subid order by manager_chat_id, manager_chat_subid";
$unread_rslt=mysqli_query($link, $unread_stmt);
while ($unread_row=mysqli_fetch_array($unread_rslt)) {
$IDNumber=$unread_row["manager_chat_id"]."-".$unread_row["manager_chat_subid"]."-".$unread_row["unread_count"];
array_push($chat_reload_id_number_array, "$IDNumber");
}
### This was added for agent to agent chats since there needs to be a list of open chats where the agent viewing this is also the manager,
### which will now happen because agents can now start their own chats. Added vicidial_manager_chat_log.user to this query on 2/4/15 for
### manager override
$stmt="select distinct vicidial_manager_chat_log.manager_chat_id, vicidial_manager_chat_log.manager_chat_subid, vicidial_users.full_name, vicidial_manager_chats.chat_start_date, sum(if(vicidial_manager_chat_log.message_viewed_date is null, 1, 0)),vicidial_manager_chat_log.user from vicidial_manager_chat_log, vicidial_manager_chats, vicidial_users where vicidial_manager_chat_log.manager='$user' and vicidial_manager_chat_log.manager_chat_id=vicidial_manager_chats.manager_chat_id and vicidial_manager_chat_log.user=vicidial_users.user group by manager_chat_id, manager_chat_subid order by message_viewed_date asc, message_date desc";
$rslt=mysqli_query($link, $stmt);
while ($row=mysqli_fetch_row($rslt)) {
if ($row[0]!="") {
array_push($active_chats_array, "$row[0]");
$chat_subid_array[$row[0]]="$row[1]";
$chat_managers_array[$row[0]]="$row[2]";
$chat_start_date_array[$row[0]]="$row[3]";
if ($row[4]>0) {array_push($unread_chats_array, $row[0]);} # Store any chat with unread messages.
$agents_managers_array[$row[0]]="$row[5]"; // IS a chat where the agent is a manager
}
}
#########
asort($chat_reload_id_number_array);
$new_ChatReloadIDNumber="";
while (list($key, $id_number) = each($chat_reload_id_number_array)) {
$new_ChatReloadIDNumber.="$id_number.";
}
$new_ChatReloadIDNumber=substr($new_ChatReloadIDNumber,0,-1);
sort($active_chats_array);
asort($chat_managers_array);
if ($new_ChatReloadIDNumber!=$ChatReloadIDNumber) {
echo "$new_ChatReloadIDNumber|";
echo "<ul class='chatview'>";
if (empty($chat_managers_array)) {
echo "\t<li class='arial_bold'>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];
if (!empty($unread_chats_array) && in_array($manager_chat_id, $unread_chats_array)) {$cclass="unreadchat";} else {$cclass="viewedchat";}
echo "\t<li class='".$cclass."'><a onClick=\"document.getElementById('CurrentActiveChat').value='$manager_chat_id'; document.getElementById('CurrentActiveChatSubID').value='$manager_chat_subid'; document.getElementById('AgentManagerOverride').value='".$agents_managers_array[$manager_chat_id]."'; \">".$chat_managers_array[$manager_chat_id]."</a></li>\n";
}
}
echo "</ul>\n";
}
}
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";
$stmt="SELECT user_group from vicidial_users where user='$user';";
if ($non_latin > 0) {$rslt=mysql_to_mysqli("SET NAMES 'UTF8'", $link);}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00573',$user,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$VU_user_group = $row[0];
$agent_status_viewable_groupsSQL='';
### Gather timeclock and shift enforcement restriction settings
$stmt="SELECT agent_status_viewable_groups,agent_status_view_time from vicidial_user_groups where user_group='$VU_user_group';";
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$agent_status_viewable_groups = $row[0];
$agent_status_viewable_groupsSQL = preg_replace('/\s\s/i','',$agent_status_viewable_groups);
$agent_status_viewable_groupsSQL = preg_replace('/\s/i',"','",$agent_status_viewable_groupsSQL);
$agent_status_viewable_groupsSQL = "user_group IN('$agent_status_viewable_groupsSQL')";
$agent_status_view = 0;
if (strlen($agent_status_viewable_groups) > 2)
{$agent_status_view = 1;}
$agent_status_view_time=0;
if ($row[1] == 'Y')
{$agent_status_view_time=1;}
$andSQL='';
if (preg_match("/ALL-GROUPS/",$agent_status_viewable_groups))
{$AGENTviewSQL = "";}
else
{
$AGENTviewSQL = "($agent_status_viewable_groupsSQL)";
if (preg_match("/CAMPAIGN-AGENTS/",$agent_status_viewable_groups))
{$AGENTviewSQL = "($AGENTviewSQL or (campaign_id='$campaign'))";}
$AGENTviewSQL = "and $AGENTviewSQL";
}
$stmt="SELECT vla.user,vu.full_name from vicidial_live_agents vla,vicidial_users vu where vla.user=vu.user and vu.user!='$user' $AGENTviewSQL order by vu.full_name;";
$rslt=mysql_to_mysqli($stmt, $link);
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";
while ($agents_count > $loop_count)
{
$row=mysqli_fetch_row($rslt);
echo "<option value='$row[0]'>$row[1]</option>\n";
$loop_count++;
}
echo "</select>";
echo "</td>\n";
echo "<td width='200'><font class='arial'>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 "</table>";
}
if ($action=="SendMgrChatMessage" && $manager_chat_id && $manager_chat_subid) {
$chat_message = preg_replace("/\r/i",'',$chat_message);
$chat_message = preg_replace("/\n/i",' ',$chat_message);
$mgr_stmt="select manager from vicidial_manager_chats where manager_chat_id='$manager_chat_id'";
$mgr_rslt=mysqli_query($link, $mgr_stmt);
$mgr_row=mysqli_fetch_row($mgr_rslt);
$manager=$mgr_row[0];
$message_posted_by=$user;
if ($agent_override && $agent_override!="0") {$user=$agent_override;} // Added for agent-to-agent chatting so the manager ID and user ID don't get mixed up
if ($manager) {
$ins_chat_stmt="insert into vicidial_manager_chat_log(manager_chat_id, manager_chat_subid, manager, user, message, message_date, message_posted_by) VALUES('$manager_chat_id', '$manager_chat_subid', '$manager', '$user', '".mysqli_real_escape_string($link, $chat_message)."', now(), '$message_posted_by')";
$ins_chat_rslt=mysqli_query($link, $ins_chat_stmt);
if (mysqli_insert_id($link)>0) {
$reload_chat_span=1;
} else {
echo "Error sending message.";
}
} else {
echo "Error sending message.";
}
}
######################################
/* JOEJ - removed since this is for customer requests only and is now done on a single page
if ($action=="request_chat" && $user && $chat_member_name) { # For people requesting a chat with an agent; consider using a special user variable name for this
$ip_address=$_SERVER['REMOTE_ADDR'];
# SEARCH FOR CUSTOMER IN DATABASE - IF NOT FOUND BY PHONE OR IP ADDRESS MAKE A NEW USER
if ($phone_number) {
$stmt="select lead_id from vicidial_list where phone_number='$phone_number' order by entry_date desc limit 1";
$rslt=mysql_to_mysqli($stmt, $link);
} else {
$stmt="select lead_id from vicidial_list where email like '%".$ip_address."%' order by entry_date desc limit 1";
$rslt=mysql_to_mysqli($stmt, $link);
}
if (mysqli_num_rows($rslt)>0) {
$row=mysqli_fetch_row($rslt);
$lead_id=$row[0];
} else {
# Create lead in vicidial_list table
$ins_stmt="insert into vicidial_list(first_name, last_name, email, list_id, phone_number, security_phrase) VALUES('$first_name', '$last_name', '$ip_address', '$default_list_id', '$phone_number', '$group_id')";
$ins_rslt=mysql_to_mysqli($ins_stmt, $link);
$lead_id=mysqli_insert_id($link);
}
if (!$lead_id || $lead_id==0) {
echo "0|Could not find or create dialer entry - $ins_stmt";
exit;
}
$ins_stmt="insert into vicidial_live_chats(status, chat_creator, group_id, lead_id, chat_start_time, customer_ping_date) VALUES('WAITING', 'NONE', '$group_id', '$lead_id', now(), 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) VALUES('$chat_id', '$user', '$chat_member_name')";
$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_rslt=mysql_to_mysqli($del_stmt, $link);
echo "0|Chat started, failure to join";
} else {
echo "1|$chat_id|$lead_id";
}
} else {
echo "0|Chat not started - $ins_stmt";
}
}
*/
if ($action=="assign_chat" && $chat_id) { # Assign available vicidial_agent to chat
}
###### CUSTOMER-AGENT CHAT FUNCTIONS ######
if ($action=="start_chat" && $user && $server_ip) {
if (!$chat_group_id) {
echo "NO_GROUP";
} else {
$user_stmt="select full_name from vicidial_users where user='$user'";
$user_rslt=mysql_to_mysqli($user_stmt, $link);
if (mysqli_num_rows($user_rslt)>0) {
$live_agent_stmt="select * from vicidial_live_agents where user='$user' and status='PAUSED'";
$live_agent_rslt=mysql_to_mysqli($live_agent_stmt, $link);
if (mysqli_num_rows($live_agent_rslt)>0) {
$user_row=mysqli_fetch_row($user_rslt);
$user_name="$user_row[0]";
$upd_stmt="UPDATE vicidial_live_agents set status='INCALL',comments='CHAT',last_call_time='$NOW_TIME',external_hangup=0,external_status='',external_pause='',external_dial='',last_state_change='$NOW_TIME',pause_code='' where user='$user' and server_ip='$server_ip';";
$upd_rslt=mysql_to_mysqli($upd_stmt, $link);
if (mysqli_affected_rows($link)>0) {
$ins_stmt="insert into vicidial_live_chats(chat_creator, chat_start_time, status, group_id) values('$user', now(), 'WAITING', '$chat_group_id')";
$ins_rslt=mysql_to_mysqli($ins_stmt, $link);
$chat_id=mysqli_insert_id($link);
if ($chat_id) {
$ins_stmt2="insert into vicidial_chat_participants(chat_id, chat_member, chat_member_name, vd_agent) values('$chat_id', '$user', '$user_name', 'Y')";
$ins_rslt2=mysql_to_mysqli($ins_stmt2, $link);
echo $chat_id;
} else {
echo "0";
}
} else {
echo "FAILED_LIVE_STATUS";
}
} else {
echo "NOT_PAUSED";
}
} else {
echo "0";
}
}
}
/* Customers have separate function file - customer_chat_functions.php */
if ($action=="agent_send_message" && $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";
} 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";
}
} else {
echo "<font class='chat_title alert'>SYSTEM ERROR</font><BR/>\n";
}
}
} else if (mysqli_num_rows($rslt)==0) {
echo "Chat $chat_id has been closed";
}
}
if ($action=="agent_leave_chat" && $user && $chat_id) {
$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 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);
$lead_id=$row[0];
# CHECK IF SHOULD USE SPECIAL DROP STATUS 'CDROP' FOR DROPPED CHATS
$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 * 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' and status='WAITING' and chat_creator='NONE'";
$del_rslt=mysql_to_mysqli($del_stmt, $link);
}
}
}
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";
} 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_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_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";
# Create color-coding for chat
$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();
while ($row=mysqli_fetch_row($rslt)) {
if (!in_array("$row[4]", $chat_members)) {
array_push($chat_members, "$row[4]");
}
}
## 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";
$rslt=mysql_to_mysqli($stmt, $link);
while ($row=mysqli_fetch_row($rslt)) {
$chat_color_key=array_search("$row[4]", $chat_members);
$row[2]=preg_replace('/\n/', '<BR/>', $row[2]);
echo "<li><font color='$color_array[$chat_color_key]' class='chat_message bold'>$row[5]</font> <font class='chat_timestamp bold'>($row[3])</font> - <font class='chat_message ".$style_array[$row[6]]."'>$row[2]</font></li>\n";
}
## PLAY AUDIO FILE IF THERE ARE NEW MESSAGES
$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";
}
} else {
if ($status_row[1]=="NONE") {
echo "<font class='chat_title bold'>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";
} else {
echo "<font class='chat_title alert'>SYSTEM ERROR</font><BR/>\n";
}
}
}
}
### CURRENTLY DEFUNCT
/*
if ($action=="customer_leave_chat" && $chat_id) {
$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);
$archive_stmt="insert ignore into vicidial_chat_archive select chat_id, chat_start_time, 'DROP' as status, chat_creator, group_id, lead_id from vicidial_live_chats where chat_id='$chat_id' and status='WAITING' and chat_creator='NONE'";
$archive_rslt=mysql_to_mysqli($archive_stmt, $link);
if (mysqli_affected_rows($link)>0) {
$del_stmt="delete from vicidial_live_chats where chat_id='$chat_id' and status='WAITING' and chat_creator='NONE'";
$del_rslt=mysql_to_mysqli($del_stmt, $link);
}
}
*/
#####################################
if ($action=="send_invite" && $chat_id && $email && $chat_group_id) {
$chat_stmt="select chat_url from system_settings";
$chat_rslt=mysql_to_mysqli($chat_stmt, $link);
$chat_row=mysqli_fetch_row($chat_rslt);
$chat_url=$chat_row[0];
## Check if person being emailed exists as a lead
$email_stmt="select lead_id from vicidial_list where email='$email' order by lead_id desc limit 1";
$email_rslt=mysql_to_mysqli($email_stmt, $link);
if (mysqli_num_rows($email_rslt)>0) {
$email_row=mysqli_fetch_row($email_rslt);
$lead_id=$email_row[0];
} else {
$ins_stmt="insert into vicidial_list(status, email, list_id, security_phrase) VALUES('NEW', '$email', '$default_list_id', '$chat_group_id')";
$ins_rslt=mysql_to_mysqli($ins_stmt, $link);
$lead_id=mysqli_insert_id($link);
}
if ($lead_id) {
$to = "$email";
$from = 'vicidial_chat_bot@vicidial.com';
$subject ="VICIDIAL CHAT INVITE - DO NOT REPLY TO THIS EMAIL";
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "To: $email\r\n";
$headers .= "From: $from\r\n";
$unique_userID=time().".".rand(10000, 99999);
$user_stmt="select full_name from vicidial_users where user='$user'";
$user_rslt=mysql_to_mysqli($user_stmt, $link);
$user_row=mysqli_fetch_row($user_rslt);
$user_name=$user_row[0];
$message = "<html>
<head>
<title>Invitation to ViciDIAL chat</title>
</head>
<body>
<p>$user_name has invited you to participate in a Vicidial Chat<BR>
<p><a href='".$chat_url."?unique_userID=".urlencode($unique_userID)."&lead_id=$lead_id&chat_group_id=".urlencode($chat_group_id)."&chat_id=$chat_id&email=".urlencode($email)."'>JOIN CHAT</A><BR>
<p>Enter your name, which will allow you to start chatting with the Vicidial agent.<BR>
</body>
</html>";
# <table>
# <tr>
# <th>PUT FORM HERE LATER</th>
# </tr>
# </table>
$sendmail = @mail($to, $subject, $message, $headers);
}
if ($sendmail)
{
$upd_stmt="update vicidial_live_chats set lead_id='$lead_id' where chat_id='$chat_id'";
$upd_rslt=mysql_to_mysqli($upd_stmt, $link);
if (mysqli_affected_rows($link)>0)
{
echo "$lead_id";
}
else
{
echo "0";
}
}
else
{
echo "0";
}
}
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.";
exit;
}
$archive_stmt="insert ignore into vicidial_chat_archive select * from vicidial_live_chats where chat_id='$chat_id'";
$archive_rslt=mysql_to_mysqli($archive_stmt, $link);
$archive_log_stmt="insert ignore into vicidial_chat_log_archive select * from vicidial_chat_log where chat_id='$chat_id'";
$archive_log_rslt=mysql_to_mysqli($archive_log_stmt, $link);
$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>";
} else {
echo "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);
$del_stmt2="delete from vicidial_chat_participants where chat_id='$chat_id'";
$del_rslt2=mysql_to_mysqli($del_stmt2, $link);
$deleted_participants=mysqli_affected_rows($link);
echo "$deleted_participants 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 "|";
if (!$lead_id) {
$upd_stmt="UPDATE vicidial_live_agents set status='PAUSED',comments='',external_hangup=0,external_status='',external_pause='',external_dial='',last_state_change='$NOW_TIME',pause_code='' where user='$user' and server_ip='$server_ip' and status='INCALL' and comments='CHAT'";
$upd_rslt=mysql_to_mysqli($upd_stmt, $link);
$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/><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>";
if (mysqli_num_rows($vla_rslt)>0) {
$vla_row=mysqli_fetch_row($vla_rslt);
$closer_campaigns=trim($vla_row[0]);
$closer_campaigns=preg_replace('/\s/', '\',\'', $closer_campaigns);
$closer_campaigns_SQL="'".$closer_campaigns."'";
$group_stmt="select group_id, group_name from vicidial_inbound_groups where group_handling='CHAT' and group_id in ($closer_campaigns_SQL) order by group_name asc";
$group_rslt=mysql_to_mysqli($group_stmt, $link);
while ($group_row=mysqli_fetch_row($group_rslt)) {
echo "<option value='".$group_row[0]."'>".$group_row[1]."</option>";
}
}
echo "</select>";
echo "|TOGGLE_DIAL_CONTROL";
}
}
if ($action=="join_chat" && $user && $chat_id && $chat_member_name) {
# REMOVE AGENT FROM OTHER CHATS, JUST IN CASE
$del_stmt="delete from vicidial_chat_participants where chat_member='$user'";
$del_rslt=mysql_to_mysqli($del_stmt, $link);
$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.";
} else {
$creator_stmt="select chat_creator from vicidial_live_chats where chat_id='$chat_id'";
$creator_rslt=mysql_to_mysqli($creator_stmt, $link);
if (mysqli_num_rows($creator_rslt)>0) {
$crow=mysqli_fetch_row($creator_rslt);
echo "$crow[0]";
} else {
echo "ERROR|You have joined a non-existent chat. Trippy.\n";
}
}
}
if ($action=="show_live_chats" && $user) {
echo "<ul id=\"treemenu1\" class=\"treeview\">\n";
if ($user && $pass) {
$user_stmt="select full_name from vicidial_users where user='$user' and pass='$pass'";
$user_rslt=mysql_to_mysqli($user_stmt, $link);
$vicidial_user=mysqli_num_rows($user_rslt);
$vicidial_user_row=mysqli_fetch_row($user_rslt);
$full_name=$vicidial_user_row[0];
}
$active_chats=array();
$agents_in_chat=array();
$absent_agents=array();
if ($vicidial_user) { # If you aren't a vicidial_user you aren't going to see the chat window.
$stmt="select vlc.chat_id, vcp.chat_member, vcp.chat_member_name, vlc.chat_creator, vcp.vd_agent from vicidial_live_chats vlc, vicidial_chat_participants vcp where vlc.chat_id=vcp.chat_id order by vlc.chat_id asc, vcp.chat_member_name asc";
$rslt=mysql_to_mysqli($stmt, $link);
while($row=mysqli_fetch_row($rslt)) {
$chat_id=$row[0];
$chat_member=$row[1];
$chat_member_name=$row[2];
$chat_creator=$row[3];
$vd_agent=$row[4];
$active_chats[$chat_id][]=array("$chat_member", "$chat_member_name", "in chat");
if ($vd_agent=="Y") {
array_push($agents_in_chat, "$chat_member");
}
}
# If an agent is the owner of a live chat but not a participant, they need their name displayed there.
$empty_live_chat_stmt="select chat_id, '$user' as chat_member, '$full_name' as chat_member, chat_creator from vicidial_live_chats where status='LIVE' and chat_creator='$user'";
$empty_live_chat_rslt=mysql_to_mysqli($empty_live_chat_stmt, $link);
while($row=mysqli_fetch_row($empty_live_chat_rslt)) {
$chat_id=$row[0];
$chat_member=$row[1];
$chat_member_name=$row[2];
if (!$active_chats[$chat_id]) {
$active_chats[$chat_id][]=array("$chat_member", "$chat_member_name", "absent");
}
}
}
if ($active_chats) {
echo "<font class='chat_title bold'>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 "\t<ul id=\"chat_members_$key\">\n";
while (list($subkey, $subval)=each($val)) {
if ($subval[2]=="absent") {
$font_color=" absent_agent";
} else if (in_array($subval[0], $agents_in_chat)) {
$font_color=" vd_agent";
} else {
$font_color="";
}
echo "\t\t<li><font class='chat_timestamp bold$font_color'>$subval[1]</font></li>\n";
}
echo "\t</ul>\n";
echo "</li>\n";
}
echo "</ul>";
}
if ($rslt && mysqli_num_rows($rslt)>0) {
echo "<input type='button' style='width:180px' value='CLICK CHAT TO JOIN' disabled>";
}
}
?>
+75 -5
View File
@@ -68,13 +68,14 @@
# 141216-2111 - Added language settings lookups and user/pass variable standardization
# 141228-0053 - Found missing phrase for QXZ
# 150723-1708 - Added ajax logging and agent screen click logging
# 150904-2138 - Added SQL features for chats started via agent invite, modified output
#
$version = '2.12-43';
$build = '150723-1708';
$version = '2.12-44';
$build = '150904-2138';
$php_script = 'conf_exten_check.php';
$mel=1; # Mysql Error Log enabled = 1
$mysql_log_count=40;
$mysql_log_count=43;
$one_mysql_log=0;
$DB=0;
$SSagent_debug_logging=0;
@@ -353,6 +354,75 @@ if ($ACTION == 'refresh')
}
##### END check on calls in queue, number of active calls in the campaign
### see if chats/emails are enabled, and if so how many of each are waiting
# 03041 and 03042 are the error logs for this
$chat_email_stmt="select allow_chats, allow_emails from system_settings;";
$chat_email_rslt=mysql_to_mysqli($chat_email_stmt, $link);
$chat_email_row=mysqli_fetch_row($chat_email_rslt);
# GET closer logs, in case they weren't grabbed above due to campagentstdisp!=YES
if ($chat_email_row[0]!=0 || $chat_email_row[1]!=0)
{
$stmt="SELECT status,campaign_id,closer_campaigns,comments from vicidial_live_agents where user='$user' and server_ip='$server_ip';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03043',$user,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$Alogin=$row[0];
$Acampaign=$row[1];
$AccampSQL=$row[2];
$live_agents_comments=$row[3];
$AccampSQL = preg_replace('/\s\-/','', $AccampSQL);
$AccampSQL = preg_replace('/\s/',"','", $AccampSQL);
if (preg_match('/AGENTDIRECT/i', $AccampSQL))
{
$AccampSQL = preg_replace('/AGENTDIRECT/i','', $AccampSQL);
$ADsql = "or ( (campaign_id LIKE \"%AGENTDIRECT%\") and (agent_only='$user') )";
}
}
if ($chat_email_row[0]==0)
{
$WaitinGChats="N";
}
else
{
$chat_stmt="select count(*) from vicidial_live_chats where status='WAITING' and (group_id IN('$AccampSQL')) and chat_creator!='$user'";
$chat_rslt=mysql_to_mysqli($chat_stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$chat_stmt,'03041',$user,$server_ip,$session_name,$one_mysql_log);}
$chat_row=mysqli_fetch_row($chat_rslt);
$WaitinGChats=$chat_row[0];
# Chat alert priority: waiting chats = blink, then in-chat = on, then = off
if ($WaitinGChats > 0)
{
$WaitinGChats = "Y"; # Make CHAT button blink
}
else if ($Acomments=="CHAT")
{
$WaitinGChats = "C"; # in-chat, so make CHAT button display "ON";
}
else
{
$WaitinGChats = "N"; # no chats waiting, not in chat, make CHAT display "OFF"
}
}
if ($chat_email_row[1]==0)
{
$WaitinGEmails="N";
}
else
{
$email_stmt="select count(*) from vicidial_email_list, vicidial_xfer_log where vicidial_email_list.status='QUEUE' and vicidial_email_list.user='$user' and vicidial_xfer_log.xfercallid=vicidial_email_list.xfercallid and direction='INBOUND' and vicidial_xfer_log.campaign_id in ('$AccampSQL') and closer='EMAIL_XFER'";
$email_rslt=mysql_to_mysqli($email_stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$email_stmt,'03042',$user,$server_ip,$session_name,$one_mysql_log);}
$email_row=mysqli_fetch_row($email_rslt);
$WaitinGEmails=$email_row[0];
if ($WaitinGEmails > 0) {$WaitinGEmails = "<font class=\"queue_text_red\">"._QXZ("Emails in Queue").": $WaitinGEmails</font>";}
else {$WaitinGEmails = "<font class=\"queue_text\">"._QXZ("Emails in Queue").": $WaitinGEmails</font>";}
}
if ($auto_dial_level > 0)
{
### update the vicidial_live_agents every second with a new random number so it is shown to be alive
@@ -719,8 +789,8 @@ if ($ACTION == 'refresh')
$Alogin='API_LOGOUT';
$external_pause='';
}
echo 'DateTime: ' . $NOW_TIME . '|UnixTime: ' . $StarTtime . '|Logged-in: ' . $Alogin . '|CampCalls: ' . $RingCalls . '|Status: ' . $Astatus . '|DiaLCalls: ' . $DiaLCalls . '|APIHanguP: ' . $external_hangup . '|APIStatuS: ' . $external_status . '|APIPausE: ' . $external_pause . '|APIDiaL: ' . $external_dial . '|DEADcall: ' . $DEADcustomer . '|InGroupChange: ' . $InGroupChangeDetails . '|APIFields: ' . $external_update_fields . '|APIFieldsData: ' . $external_update_fields_data . '|APITimerAction: ' . $timer_action . '|APITimerMessage: ' . $timer_action_message . '|APITimerSeconds: ' . $timer_action_seconds . '|APIdtmf: ' . $external_dtmf . '|APItransferconf: ' . $external_transferconf . '|APIpark: ' . $external_park . '|APITimerDestination: ' . $timer_action_destination . '|APIManualDialQueue: ' . $MDQ_count . '|APIRecording: ' . $external_recording . '|APIPaUseCodE: ' . $external_pause_code . "\n";
echo 'DateTime: ' . $NOW_TIME . '|UnixTime: ' . $StarTtime . '|Logged-in: ' . $Alogin . '|CampCalls: ' . $RingCalls . '|Status: ' . $Astatus . '|DiaLCalls: ' . $DiaLCalls . '|APIHanguP: ' . $external_hangup . '|APIStatuS: ' . $external_status . '|APIPausE: ' . $external_pause . '|APIDiaL: ' . $external_dial . '|DEADcall: ' . $DEADcustomer . '|InGroupChange: ' . $InGroupChangeDetails . '|APIFields: ' . $external_update_fields . '|APIFieldsData: ' . $external_update_fields_data . '|APITimerAction: ' . $timer_action . '|APITimerMessage: ' . $timer_action_message . '|APITimerSeconds: ' . $timer_action_seconds . '|APIdtmf: ' . $external_dtmf . '|APItransferconf: ' . $external_transferconf . '|APIpark: ' . $external_park . '|APITimerDestination: ' . $timer_action_destination . '|APIManualDialQueue: ' . $MDQ_count . '|APIRecording: ' . $external_recording . '|APIPaUseCodE: ' . $external_pause_code . '|WaitinGChats: ' . $WaitinGChats . '|WaitinGEmails: ' . $WaitinGEmails . '|LivEAgentCommentS: ' . $live_agents_comments . "\n";
if (strlen($timer_action) > 3)
{
+57 -1
View File
@@ -1 +1,57 @@
input.red_btn{
font-family: Arial, Sans-Serif;
font-size: 10px;
color:#FFFFFF;
font-weight:bold;
background-color:#990000;
border:2px solid;
border-top-color:#FFCCCC;
border-left-color:#FFCCCC;
border-right-color:#330000;
border-bottom-color:#330000;
}
input.green_btn{
font-family: Arial, Sans-Serif;
font-size: 10px;
color:#FFFFFF;
font-weight:bold;
background-color:#009900;
border:2px solid;
border-top-color:#CCFFCC;
border-left-color:#CCFFCC;
border-right-color:#003300;
border-bottom-color:#003300;
}
input.blue_btn{
font-family: Arial, Sans-Serif;
font-size: 10px;
color:#FFFFFF;
font-weight:bold;
background-color:#000099;
border:2px solid;
border-top-color:#CCCCFF;
border-left-color:#CCCCFF;
border-right-color:#000033;
border-bottom-color:#000033;
}
input.form_field {
font-family: Arial, Sans-Serif;
font-size: 10px;
margin-bottom: 3px;
padding: 2px;
border: solid 1px #000066;
}
textarea.form_field {
font-family: Arial, Sans-Serif;
font-size: 10px;
margin-bottom: 3px;
padding: 2px;
border: solid 1px #000066;
}
select.form_field {
font-family: Arial, Sans-Serif;
font-size: 10px;
margin-bottom: 3px;
padding: 2px;
border: solid 1px #000066;
}
+132
View File
@@ -0,0 +1,132 @@
ul.treeview, ul.treeview ul{ /*CSS for Simple Tree Menu*/
list-style-type: none;
/* background: url(images/vline.png) repeat-y; */
font-weight: bold;
margin: 0;
padding: 0;
}
ul.treeview li{ /*Style for LI elements in general (excludes an LI that contains sub lists)*/
background: white url(../images/messenger-blue-icon.png) no-repeat;
list-style-type: none;
padding-left: 15px;
margin-bottom: 2px;
cursor: hand !important;
}
.treeview li.submenu{ /* Style for LI that contains sub lists (other ULs). */
background: white url(../images/messenger-blue-icon.png) no-repeat;
color: #369;
font-weight: bold;
cursor: hand !important;
margin-bottom: 2px;
padding: 0 15px;
line-height: 15px;
}
ul.chatview, ul.chatview ul{ /*CSS for Simple Tree Menu*/
list-style-type: none;
margin: 0;
padding: 0;
}
.chatview li.viewedchat{ /* Style for LI that contains sub lists (other ULs). */
background: white url(../images/messenger-blue-icon.png) no-repeat;
color: #369;
cursor: hand !important;
margin-bottom: 2px;
padding: 0 15px;
line-height: 15px;
font-family: Arial, Helvetica, sans-serif;
font-size: 10pt;
}
.chatview li.unreadchat{ /* Style for LI that contains sub lists (other ULs). */
background: white url(../images/messenger-blue-icon.png) no-repeat;
background-color: #CCCCFF;
color: #369;
cursor: hand !important;
margin-bottom: 2px;
padding: 0 15px;
line-height: 15px;
font-family: Arial, Helvetica, sans-serif;
font-size: 10pt;
font-weight: bold;
}
/* .treeview li.submenu ul{ /*Style for ULs that are children of LIs (submenu) */
/*display: none; /*Hide them by default. Don't delete. */
/* } */
.treeview .submenu ul li{ /*Style for LIs of ULs that are children of LIs (submenu) */
cursor: hand;
}
ul.treeview li:last-child {
/* background: #fff url(images/lastnode.png) no-repeat; */
margin-bottom: 20px;
}
.chat_title { font-family: Arial, Helvetica, sans-serif; font-size: 11pt}
.chat_message { font-family: Arial, Helvetica, sans-serif; font-size: 10pt}
.chat_timestamp { font-family: Arial, Helvetica, sans-serif; font-size: 8pt}
.vd_agent { color:#009900; }
.absent_agent { color:#FF0000; }
.bold {font-weight: bold;}
.italics {font-style: italic;}
.alert {
font-weight: bold;
color:#FFFFFF;
background-color:#FF0000;
}
input.red_btn{
font-family: Arial, Sans-Serif;
font-size: 10px;
color:#FFFFFF;
font-weight:bold;
background-color:#990000;
border:2px solid;
border-top-color:#FFCCCC;
border-left-color:#FFCCCC;
border-right-color:#330000;
border-bottom-color:#330000;
}
input.green_btn{
font-family: Arial, Sans-Serif;
font-size: 10px;
color:#FFFFFF;
font-weight:bold;
background-color:#009900;
border:2px solid;
border-top-color:#CCFFCC;
border-left-color:#CCFFCC;
border-right-color:#003300;
border-bottom-color:#003300;
}
input.blue_btn{
font-family: Arial, Sans-Serif;
font-size: 10px;
color:#FFFFFF;
font-weight:bold;
background-color:#000099;
border:2px solid;
border-top-color:#CCCCFF;
border-left-color:#CCCCFF;
border-right-color:#000033;
border-bottom-color:#000033;
}
textarea.chat_window {
font-family: Arial, Sans-Serif;
font-size: 11px;
margin-bottom: 3px;
padding: 2px;
border: solid 1px #000066;
}
td.chat_window {
border:2px solid #000000;
padding: 5px;
vertical-align: top;
background: -webkit-linear-gradient(top, rgba(255,255,255,1) 0%, rgba(222,222,222,0) 50%, rgba(222,222,222,0) 50%, rgba(222,222,222,1) 100%);
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 795 B

After

Width:  |  Height:  |  Size: 869 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 909 B

After

Width:  |  Height:  |  Size: 905 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 664 B

After

Width:  |  Height:  |  Size: 1.4 KiB

+719
View File
@@ -0,0 +1,719 @@
<?php
# vdc_chat_display.php
#
# Copyright (C) 2015 Joe Johnson, Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# This is the interface for agents to chat with customers and each other. It's separate from the manager-to-agent
# chat interface out of necessity and calls the chat_db_query.php page to send information and display it. It will
# display any open chat the agent has, and of those open chats the full conversation of the current active chat
# will be displayed. It will also show when an agent has a new unread message in any of his conversations and
# allow the agent to toggle between them. They can also initiate chats with any agent currently logged into a
# campaign through the agent interface.
#
# Builds:
# 150903-2349 - First build
# 151213-1107 - Added variable filtering
#
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"];}
elseif (isset($_POST["email_invite_lead_id"])) {$email_invite_lead_id=$_POST["email_invite_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["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["chat_group_ids"])) {$chat_group_ids=$_GET["chat_group_ids"];}
elseif (isset($_POST["chat_group_ids"])) {$chat_group_ids=$_POST["chat_group_ids"];}
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
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["campaign"])) {$campaign=$_GET["campaign"];}
elseif (isset($_POST["campaign"])) {$campaign=$_POST["campaign"];}
if (isset($_GET["dial_method"])) {$dial_method=$_GET["dial_method"];}
elseif (isset($_POST["dial_method"])) {$dial_method=$_POST["dial_method"];}
if (isset($_GET["pass"])) {$pass=$_GET["pass"];}
elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];}
if (isset($_GET["child_window"])) {$child_window=$_GET["child_window"];}
elseif (isset($_POST["child_window"])) {$child_window=$_POST["child_window"];}
if (isset($_GET["outside_user_name"])) {$outside_user_name=$_GET["outside_user_name"];}
elseif (isset($_POST["outside_user_name"])) {$outside_user_name=$_POST["outside_user_name"];}
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"];}
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 ($clickmute!="1") {$clickmute="0";} // Prevents annoying quirk of playing the audio cue every time you click the tab to view this
$lead_id = preg_replace("/[^0-9]/","",$lead_id);
$chat_id = preg_replace('/[^- \_\.0-9a-zA-Z]/','',$chat_id);
$chat_group_id = preg_replace('/[^- \_\.0-9a-zA-Z]/','',$chat_group_id);
$server_ip = preg_replace('/[^- \_\.0-9a-zA-Z]/','',$server_ip);
$email = preg_replace("/\'|\"|\\\\|;/","",$email);
$chat_group_ids = preg_replace("/\\\\|;/","",$chat_group_ids);
$campaign = preg_replace('/[^-\_0-9a-zA-Z]/','',$campaign);
$dial_method = preg_replace('/[^-\_0-9a-zA-Z]/','',$dial_method);
$clickmute = preg_replace("/\'|\"|\\\\|;/","",$clickmute);
if ($non_latin < 1)
{
$user = preg_replace('/[^-\_0-9a-zA-Z]/','',$user);
$pass = preg_replace('/[^-\_0-9a-zA-Z]/','',$pass);
$outside_user_name = preg_replace('/[^- \_\.0-9a-zA-Z]/','',$user);
$chat_creator = preg_replace('/[^- \_0-9a-zA-Z]/','',$chat_creator);
$phone_number = preg_replace("/[^0-9]/","",$phone_number);
$first_name = preg_replace('/[^- \_\.0-9a-zA-Z]/','',$first_name);
$last_name = preg_replace('/[^- \_\.0-9a-zA-Z]/','',$last_name);
}
else
{
$user = preg_replace("/\'|\"|\\\\|;/","",$user);
$pass=preg_replace("/\'|\"|\\\\|;| /","",$pass);
$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";
$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];
if ($chat_id) {
$chat_stmt="select * from vicidial_live_chats where chat_creator='$user' and chat_id='$chat_id'";
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";
} else {
# echo "Waiting for chat request..."; exit;
}
} else {
unset($pass);
## Since user is not a vicidial user, check to see if they belong to another chat and use that as the default chat variable.
$chat_stmt="select chat_id from vicidial_chat_participants where chat_member='$user'";
$chat_rslt=mysql_to_mysqli($chat_stmt, $link);
if (mysqli_num_rows($chat_rslt)>0) {
$chat_row=mysqli_fetch_row($chat_rslt);
$chat_id=$chat_row[0];
}
}
$stmt="select * from vicidial_list where lead_id='$lead_id'";
$rslt=mysql_to_mysqli($stmt, $link);
if (mysqli_num_rows($rslt)>0) {
$row=mysqli_fetch_array($rslt);
$first_name=$row["first_name"];
$last_name=$row["last_name"];
if (!$full_name) {$full_name=trim("$first_name $last_name");}
if (!$email) {$email=$row["email"];}
}
?>
<html>
<head>
<title>Vicidial Chat Interface</title>
<script type="text/javascript" src="simpletreemenu.js">
/***********************************************
* Simple Tree Menu- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/
</script>
<link rel="stylesheet" type="text/css" href="css/simpletree.css" />
<script language="Javascript">
var clickMute=<?php echo $clickmute; ?>;
// Need campaign ID and dial_method to properly toggle the DialControl span
var campaign="<?php echo $campaign; ?>";
var dial_method="<?php echo $dial_method; ?>";
var email_invite_lead_id="<?php echo $email_invite_lead_id; ?>";
// Borrowed from parent window - need these to toggle controls when agent is starting chats
var DiaLControl_auto_HTML = "<a href=\"#\" onclick=\"AutoDial_ReSume_PauSe('VDADready','','','','','','','YES');\"><img src=\"./images/<?php echo _QXZ("vdc_LB_paused.gif") ?>\" border=\"0\" alt=\"You are paused\" /></a>";
var DiaLControl_auto_HTML_OFF = "<img src=\"./images/<?php echo _QXZ("vdc_LB_blank_OFF.gif") ?>\" border=\"0\" alt=\"pause button disabled\" />";
var DiaLControl_inbound_manual_HTML = "<a href=\"#\" onclick=\"AutoDial_ReSume_PauSe('VDADready','','','','','','','YES');\"><img src=\"./images/<?php echo _QXZ("vdc_LB_paused.gif"); ?>\" border=\"0\" alt=\"You are paused\" /></a><br /><a href=\"#\" onclick=\"ManualDialNext('','','','','','0','','','YES');\"><img src=\"./images/<?php echo _QXZ("vdc_LB_dialnextnumber.gif"); ?>\" border=\"0\" alt=\"Dial Next Number\" /></a>";
var DiaLControl_inbound_manual_HTML_OFF = "<img src=\"./images/<?php echo _QXZ("vdc_LB_blank_OFF.gif"); ?>\" border=\"0\" alt=\"pause button disabled\" /><br /><img src=\"./images/<?php echo _QXZ("vdc_LB_dialnextnumber_OFF.gif"); ?>\" border=\"0\" alt=\"Dial Next Number\" />";
// 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();
}
function UpdateChatWindow() {
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 current_message_field = document.getElementById('current_message_count');
if (current_message_field == null) {var current_message_count=0;} else {var current_message_count=current_message_field.value;}
if (chat_id)
{
var xmlhttp=false;
if (!xmlhttp && typeof XMLHttpRequest!='undefined')
{
xmlhttp = new XMLHttpRequest();
}
if (xmlhttp)
{
chat_query = "&chat_creator="+chat_creator+"&chat_id="+chat_id+"&user="+user+"&pass="+pass+"&user_level="+user_level+"&current_message_count="+current_message_count+"&action=update_agent_chat_window";
xmlhttp.open('POST', 'chat_db_query.php');
xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8');
xmlhttp.send(chat_query);
xmlhttp.onreadystatechange = function()
{
if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
{
var fullchatlog = xmlhttp.responseText;
document.getElementById('ChatDisplay').innerHTML=fullchatlog;
var current_message_field_update = document.getElementById('current_message_count');
if (current_message_field_update != null) {var current_message_count_update=current_message_field_update.value;}
if (clickMute==0 && current_message_count_update>current_message_count && !document.getElementById("MuteCustomerChatAlert").checked)
{document.getElementById("CustomerChatAudioAlertFile").play();}
else if (clickMute>0)
{clickMute=0;}
}
}
delete xmlhttp;
}
}
}
function SendMessage(chat_id, user, message, chat_member_name) {
var chat_id=document.getElementById('chat_id').value;
var user=document.getElementById('user').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; ?>';
if (!document.getElementById('private_message') || !document.getElementById('private_message').checked) {
var chat_level=0;
} else {
var chat_level=1;
}
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.");}
document.getElementById('chat_message').value='';
var xmlhttp=false;
if (!xmlhttp && typeof XMLHttpRequest!='undefined')
{
xmlhttp = new XMLHttpRequest();
}
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";
xmlhttp.open('POST', 'chat_db_query.php');
xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8');
xmlhttp.send(chat_query);
xmlhttp.onreadystatechange = function()
{
if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
{
var posting_response = xmlhttp.responseText;
if (posting_response)
{
chat_alert_box(posting_response);
}
else
{
UpdateChatWindow();
}
}
}
delete xmlhttp;
}
}
function JoinChat(chat_id) {
var user=document.getElementById('user').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.");
return false;
}
var xmlhttp=false;
if (!xmlhttp && typeof XMLHttpRequest!='undefined')
{
xmlhttp = new XMLHttpRequest();
}
if (xmlhttp)
{
chat_query = "&chat_id="+chat_id+"&chat_member_name="+chat_member_name+"&user="+user+"&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);
xmlhttp.onreadystatechange = function()
{
if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
{
var join_attempt_results = xmlhttp.responseText.split("|");
if (join_attempt_results[1])
{
chat_alert_box(join_attempt_results[1]);
}
else
{
chat_creator=xmlhttp.responseText;
document.getElementById('chat_member_name').disabled = true;
}
}
document.getElementById('chat_id').value=chat_id;
document.getElementById('chat_creator').value=chat_creator;
// If user is chat creator, show option to end chat or invite people
if (chat_creator==user)
{
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()\">";
}
else
{
document.getElementById('chat_creator_console').innerHTML="<BR/><BR/><input class='red_btn' type='button' style=\"width:150px\" value=\"END CHAT\" onClick=\"EndChat()\">";
}
}
}
delete xmlhttp;
}
}
function RefreshLiveChatWindow() {
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;
window.user_level='<?php echo $user_level; ?>';
var xmlhttp=false;
if (!xmlhttp && typeof XMLHttpRequest!='undefined')
{
xmlhttp = new XMLHttpRequest();
}
if (xmlhttp)
{
chat_query = "&chat_creator="+chat_creator+"&chat_id="+chat_id+"&user="+user+"&pass="+pass+"&user_level="+user_level+"&action=show_live_chats";
xmlhttp.open('POST', 'chat_db_query.php');
xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8');
xmlhttp.send(chat_query);
xmlhttp.onreadystatechange = function()
{
if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
{
var live_chat_info = xmlhttp.responseText;
document.getElementById('ActiveChats').innerHTML=live_chat_info;
UpdateChatWindow();
}
}
delete xmlhttp;
}
}
function StartChat() {
var user=document.getElementById('user').value;
var chat_group_id=document.getElementById('chat_group_id').value;
var server_ip=document.getElementById('server_ip').value;
var xmlhttp=false;
if (!xmlhttp && typeof XMLHttpRequest!='undefined')
{
xmlhttp = new XMLHttpRequest();
}
if (xmlhttp)
{
chat_query = "&action=start_chat&user="+user+"&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);
xmlhttp.onreadystatechange = function()
{
if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
{
var start_chat_attempt_result = xmlhttp.responseText;
if (!start_chat_attempt_result) {
chat_alert_box("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.");
} else if (start_chat_attempt_result=="NO_GROUP") {
chat_alert_box("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");
} 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
if (dial_method=="INBOUND_MAN")
{
window.parent.document.getElementById("DiaLControl").innerHTML = DiaLControl_inbound_manual_HTML_OFF;
}
else
{
window.parent.document.getElementById("DiaLControl").innerHTML = DiaLControl_auto_HTML_OFF;
}
chat_alert_box("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()\">";
}
UpdateChatWindow();
}
}
delete xmlhttp;
}
}
function SendInvite() {
var user=document.getElementById('user').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;
var email=document.getElementById('email_invite').value;
var xmlhttp=false;
if (!xmlhttp && typeof XMLHttpRequest!='undefined')
{
xmlhttp = new XMLHttpRequest();
}
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;
xmlhttp.open('POST', 'chat_db_query.php');
xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8');
xmlhttp.send(chat_query);
xmlhttp.onreadystatechange = function()
{
if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
{
var email_sent = xmlhttp.responseText;
if (email_sent)
{
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()\">";
}
else
{
chat_alert_box("There was a problem sending the email invite - please re-check your information and try again."+email_sent);
}
}
}
delete xmlhttp;
}
}
function LeaveChat(extra_action) {
var chatIDField = document.getElementById('myElementId');
if (document.getElementById('chat_id'))
{
var chat_id=document.getElementById('chat_id').value;
var chat_creator=document.getElementById('chat_creator').value;
var user=document.getElementById('user').value;
var xmlhttp=false;
if (!xmlhttp && typeof XMLHttpRequest!='undefined')
{
xmlhttp = new XMLHttpRequest();
}
if (xmlhttp)
{
chat_query = "&action=agent_leave_chat&chat_id="+chat_id+"&user="+user;
// chat_alert_box(chat_query);
xmlhttp.open('POST', 'chat_db_query.php');
xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8');
xmlhttp.send(chat_query);
xmlhttp.onreadystatechange = function()
{
if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
{
//if (chat_creator==user) {EndChat();}
if (extra_action=="close_window") {window.close();}
}
}
delete xmlhttp;
}
}
}
function EndChat(hangup_override) { // hangup_override comes from parent Iframe when you click the CALL HANGUP button. Added 2015-04-14 - not used yet.
var chat_id=document.getElementById('chat_id').value;
var chat_creator=document.getElementById('chat_creator').value;
var user=document.getElementById('user').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.
if (!chat_creator || !user || !chat_id) {
return false;
} else if (user!=chat_creator) {
chat_alert_box("Only the chat creator can end the chat");
return false;
}
var xmlhttp=false;
if (!xmlhttp && typeof XMLHttpRequest!='undefined')
{
xmlhttp = new XMLHttpRequest();
}
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;
xmlhttp.open('POST', 'chat_db_query.php');
xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8');
xmlhttp.send(chat_query);
xmlhttp.onreadystatechange = function()
{
if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
{
var finished_chat = xmlhttp.responseText;
finished_chat_text=finished_chat.split("|");
if (!hangup_override) {chat_alert_box(finished_chat_text[0]);} // Don't bother to alert if chat ends as the result of the agent clicking HANGUP CUSTOMER from the parent window
if (finished_chat_text[0].match(/Chat ended/))
{
document.getElementById('chat_creator_console').innerHTML=finished_chat_text[1];
document.getElementById('chat_group_id').value='';
// IF AGENT NEVER INVITED SOMEONE, THERE'S NO LEAD ATTACHED AND IT'S SAFE FOR THEM TO JUST GO BACK TO BEING PAUSED WITHOUT HAVING TO DO ANYTHING ELSE.
// HOWEVER, SINCE WE DEACTIVATED THE PAUSE BUTTON FROM THE StartChat() FUNCTION WE NEED TO REACTIVATE IT IN PAUSED MODE.
if (finished_chat_text[2]=="TOGGLE_DIAL_CONTROL")
{
if (dial_method=="INBOUND_MAN")
{
window.parent.document.getElementById("DiaLControl").innerHTML = DiaLControl_inbound_manual_HTML;
}
else
{
window.parent.document.getElementById("DiaLControl").innerHTML = DiaLControl_auto_HTML;
}
}
}
UpdateChatWindow();
}
}
delete xmlhttp;
}
}
function StartRefresh() {
if (!window.parent.document)
{
alert("This page cannot run outside of the Vicidial agent interface");
}
else
{
rInt=window.setInterval(function() {RefreshLiveChatWindow()}, 1000);
}
}
function ShowHideMembers(menuName, chat_id) {
submenu=document.getElementById(menuName);
if (submenu.getAttribute("rel")=="closed") {
submenu.style.display="block";
submenu.setAttribute("rel", "open");
} else {
submenu.style.display="none";
submenu.setAttribute("rel", "closed");
}
}
window.onbeforeunload = LeaveChat;
</script>
</head>
<?php
if (!$user) {
echo "<body>No user ID - no chat access. Sorry </body>";
exit;
}
$user_stmt="select full_name from vicidial_users where user='$user' limit 1";
$user_rslt=mysql_to_mysqli($user_stmt, $link);
$inchat_html=""; $nochat_html="";
$autojoin_js_fx="StartRefresh();";
if (mysqli_num_rows($user_rslt)==0) {
if($outside_user_name && $chat_id) {
$inchat_html.="<input type='hidden' name='chat_member_name' id='chat_member_name' value='$outside_user_name'>";
$autojoin_js_fx.="JoinChat('$chat_id');";
} else {
$chat_stmt="select chat_member_name from vicidial_chat_log where poster='$user' order by message_time desc limit 1";
$chat_rslt=mysql_to_mysqli($chat_stmt, $link);
if (mysqli_num_rows($chat_rslt)==0) {
$nochat_html.="Please enter your name below before joining a chat:<BR>";
$nochat_html.="<input type='text' name='chat_member_name' id='chat_member_name' value='$full_name'>";
} else {
$chat_row=mysqli_fetch_row($chat_rslt);
$outside_user_name=$chat_row[0];
$inchat_html.="<input type='hidden' name='chat_member_name' id='chat_member_name' value='$outside_user_name'>";
$autojoin_js_fx.="JoinChat('$chat_id');";
}
}
} else {
$user_row=mysqli_fetch_row($user_rslt);
$inchat_html.="<input type='hidden' name='chat_member_name' id='chat_member_name' value='$user_row[0]'>";
$autojoin_js_fx.="JoinChat('$chat_id');";
}
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\")'>";
}
?>
<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"; ?>
<form name='chat_form' action='<?php echo $PHP_SELF; ?>'>
<table width='100%' border='0'>
<tr>
<td class='chat_window' height='300' width='*'>
<span id='ChatDisplay' name='ChatDisplay' style=" overflow-y: auto; overflow-x: none;">
</span>
</td>
<td width='200' valign='top'>
<span id='ActiveChats' name='ActiveChats' style=" overflow-y: auto; overflow-x: none;">
</span>
</td>
</tr>
<tr>
<td align='center'>
<table width='400' align='center' border='0' cellpadding='0' cellspacing='0'>
<tr>
<td colspan='2' align='center'>
<textarea border='1' name='chat_message' id='chat_message' class='chat_window' cols='100' rows='4' onkeypress="if (event.keyCode==13 && !event.shiftKey) {SendMessage(this.form.chat_id.value, this.form.user.value, this.form.chat_message.value); return false;}"></textarea>
</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>
<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>
<?php
if ($user_level) {
echo "<input type='checkbox' name='private_message' id='private_message' value='1'>Privacy ON";
}
?>
</td>
</tr>
<tr>
<td colspan='2' align='center'>
<?php
echo "$nochat_html$inchat_html";
?>
</td>
</tr>
</table>
</td>
<td valign='middle' align='center' width='200' rowspan='2'>
<?php
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/><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";
# CREATE LIST OF GroUP IDS to select
if (count($chat_group_ids)>0) {
$group_stmt="select group_id, group_name from vicidial_inbound_groups where group_handling='CHAT' and group_id in ('".implode("','", $chat_group_ids)."') order by group_name asc";
$group_rslt=mysql_to_mysqli($group_stmt, $link);
while ($group_row=mysqli_fetch_row($group_rslt)) {
echo "<option value='".$group_row[0]."'>".$group_row[1]."</option>\n";
}
} else {
$vla_stmt="select closer_campaigns from vicidial_live_agents where user='$user'";
$vla_rslt=mysql_to_mysqli($vla_stmt, $link);
if (mysqli_num_rows($vla_rslt)>0) {
$vla_row=mysqli_fetch_row($vla_rslt);
$closer_campaigns=trim($vla_row[0]);
echo "!$closer_campaigns!";
$closer_campaigns=preg_replace('/\s/', '\',\'', $closer_campaigns);
echo "*$closer_campaigns*";
$closer_campaigns_SQL="'".$closer_campaigns."'";
$group_stmt="select group_id, group_name from vicidial_inbound_groups where group_handling='CHAT' and group_id in ($closer_campaigns_SQL) order by group_name asc";
$group_rslt=mysql_to_mysqli($group_stmt, $link);
while ($group_row=mysqli_fetch_row($group_rslt)) {
echo "<option value='".$group_row[0]."'>".$group_row[1]."</option>\n";
}
}
}
echo "</select>\n";
}
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='red_btn' type='button' style=\"width:150px\" value=\"END CHAT\" onClick=\"EndChat()\">";
}
echo "</span>";
}
?>
</td>
</tr>
<tr>
<td align='center' height='50'>&nbsp;
<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>
</tr>
</table>
</span>
</td>
</tr>
</table>
<input type='hidden' id='user' name='user' value='<?php echo $user; ?>'>
<input type='hidden' id='chat_id' name='chat_id' value='<?php echo $chat_id; ?>'>
<input type='hidden' id='chat_group_id' name='chat_group_id' value='<?php echo $chat_group_id; ?>'>
<input type='hidden' id='chat_creator' name='chat_creator' value='<?php echo $chat_creator; ?>'>
<input type='hidden' id='pass' name='pass' value='<?php echo $pass; ?>'>
<input type='hidden' id='lead_id' name='lead_id' value='<?php echo $lead_id; ?>'>
<input type='hidden' id='server_ip' name='server_ip' value='<?php echo $server_ip; ?>'>
<audio id='CustomerChatAudioAlertFile'><source src="sounds/chat_alert.mp3" type="audio/mpeg"></audio>
</form>
</body>
</html>
+219 -27
View File
@@ -394,13 +394,14 @@
# 151026-1710 - Added function for Status Groups lookups and delivery to agent screen
# 151119-1931 - Fixed issue with outbound CID in some cases during dial-only function
# 151209-1615 - Fixed issue with possible data loss using callback or dispo comments
# 151212-0916 - Added chat-related functions for the agent interface
#
$version = '2.12-289';
$build = '151209-1615';
$version = '2.12-290';
$build = '151212-0916';
$php_script = 'vdc_db_query.php';
$mel=1; # Mysql Error Log enabled = 1
$mysql_log_count=635;
$mysql_log_count=649;
$one_mysql_log=0;
$DB=0;
$SSagent_debug_logging=0;
@@ -630,6 +631,8 @@ if (isset($_GET["email_row_id"])) {$email_row_id=$_GET["email_row_id"];}
elseif (isset($_POST["email_row_id"])) {$email_row_id=$_POST["email_row_id"];}
if (isset($_GET["inbound_email_groups"])) {$inbound_email_groups=$_GET["inbound_email_groups"];}
elseif (isset($_POST["inbound_email_groups"])) {$inbound_email_groups=$_POST["inbound_email_groups"];}
if (isset($_GET["inbound_chat_groups"])) {$inbound_chat_groups=$_GET["inbound_chat_groups"];}
elseif (isset($_POST["inbound_chat_groups"])) {$inbound_chat_groups=$_POST["inbound_chat_groups"];}
if (isset($_GET["recording_id"])) {$recording_id=$_GET["recording_id"];}
elseif (isset($_POST["recording_id"])) {$recording_id=$_POST["recording_id"];}
if (isset($_GET["recording_filename"])) {$recording_filename=$_GET["recording_filename"];}
@@ -830,7 +833,7 @@ $sip_hangup_cause_dictionary = array(
#############################################
##### START SYSTEM_SETTINGS LOOKUP #####
$stmt = "SELECT use_non_latin,timeclock_end_of_day,agentonly_callback_campaign_lock,alt_log_server_ip,alt_log_dbname,alt_log_login,alt_log_pass,tables_use_alt_log_db,qc_features_active,allow_emails,callback_time_24hour,enable_languages,language_method,agent_debug_logging,default_language,active_modules FROM system_settings;";
$stmt = "SELECT use_non_latin,timeclock_end_of_day,agentonly_callback_campaign_lock,alt_log_server_ip,alt_log_dbname,alt_log_login,alt_log_pass,tables_use_alt_log_db,qc_features_active,allow_emails,callback_time_24hour,enable_languages,language_method,agent_debug_logging,default_language,active_modules,allow_chats FROM system_settings;";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00001',$user,$server_ip,$session_name,$one_mysql_log);}
if ($DB) {echo "$stmt\n";}
@@ -854,6 +857,7 @@ if ($qm_conf_ct > 0)
$SSagent_debug_logging = $row[13];
$SSdefault_language = $row[14];
$active_modules = $row[15];
$allow_chats = $row[16];
}
##### END SETTINGS LOOKUP #####
###########################################
@@ -7855,12 +7859,41 @@ if ($ACTION == 'XFERemail')
}
#######################################################################################
### VDADcheckINCOMINGemail - for auto-dial VICIDiaL dialing this will check for emails
### ManagerChatsCheck - for campaigns/systems where chatting is enabled, this will
### look in the vicidial_manager_chats table for any active chats
### involving the agent ID being passed and will return any current
### chats involving the agent, and will blink for unread messages,
### including chats where the agent is the manager/originator
#######################################################################################
if ($ACTION == 'ManagerChatsCheck')
{
// Get a count on how many chats the agent is involved in, and also any chats where there are unread messages BY THE USER to determine if the user gets a blinking light.
$chat_stmt="select manager_chat_id, manager_chat_subid, sum(if(message_viewed_date is null and user='$user', 1, 0)) from vicidial_manager_chat_log where (user='$user' or manager='$user') group by manager_chat_id, manager_chat_subid order by manager_chat_id, manager_chat_subid";
$chat_rslt=mysql_to_mysqli($chat_stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$chat_stmt,'00636',$user,$server_ip,$session_name,$one_mysql_log);}
$active_chats=mysqli_num_rows($chat_rslt);
while ($chat_row=mysqli_fetch_row($chat_rslt))
{
$unread_messages+=$chat_row[2];
}
#$upd_stmt="update vicidial_manager_chat_log set audio_alerted='Y' where (user='$user' or manager='$user') and audio_alerted='N' and message_posted_by!='$user'";
$upd_stmt="select count(*) From vicidial_manager_chat_log where (user='$user' or manager='$user')";
$upd_rslt=mysql_to_mysqli($upd_stmt, $link);
#$message_alert=mysqli_affected_rows($link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$upd_stmt,'00637',$user,$server_ip,$session_name,$one_mysql_log);}
$upd_row=mysqli_fetch_row($upd_rslt);
$message_alert=$upd_row[0];
echo "$active_chats|$unread_messages|$message_alert";
}
#######################################################################################
### VDADcheckINCOMINGother - for auto-dial VICIDiaL dialing this will check for emails
### in the vicidial_email_list table in NEW status, then
### lookup the lead info and pass it back to vicidial.php
### Also looks up transferred emails in vicidial_xfer_log
######################################################################################
if ($ACTION == 'VDADcheckINCOMINGemail')
#######################################################################################
if ($ACTION == 'VDADcheckINCOMINGother')
{
$VDCL_ingroup_recording_override = '';
$VDCL_ingroup_rec_filename = '';
@@ -7876,6 +7909,7 @@ if ($ACTION == 'VDADcheckINCOMINGemail')
$INclosecallid='';
$INxfercallid='';
$email_group_str='';
$chat_group_str='';
$email_group_ct=count($inbound_email_groups); # This should always be greater than zero for the script to reach this point, but just in case...
for ($i=0; $i<$email_group_ct; $i++)
@@ -7883,6 +7917,13 @@ if ($ACTION == 'VDADcheckINCOMINGemail')
$email_group_str.="'$inbound_email_groups[$i]',";
}
$email_group_str=substr($email_group_str, 0, -1);
$chat_group_ct=count($inbound_chat_groups); # This should always be greater than zero for the script to reach this point, but just in case...
for ($i=0; $i<$chat_group_ct; $i++) {
$chat_group_str.="'$inbound_chat_groups[$i]',";
}
$chat_group_str=substr($chat_group_str, 0, -1);
# $DB=1;
if ( (strlen($campaign)<1) || (strlen($server_ip)<1) )
@@ -7895,8 +7936,11 @@ if ($ACTION == 'VDADcheckINCOMINGemail')
}
else
{
### CHECK FOR EMAILS ###
#if ($email_group_ct>0) {
### Check for transfers
#$upd_stmt="update vicidial_email_list inner join(select email_row_id from vicidial_email_list inner join vicidial_inbound_groups on vicidial_inbound_groups.group_id=vicidial_email_list.group_id order by queue_priority desc, email_date asc limit 1) as selected_row on selected_row.email_row_id=vicidial_email_list.email_row_id set status='QUEUE', user='$user'";
$stmt="SELECT vicidial_email_list.lead_id, vicidial_email_list.email_date, vicidial_email_list.email_to, vicidial_email_list.email_from, vicidial_email_list.subject, vicidial_xfer_log.campaign_id, vicidial_email_list.email_row_id, vicidial_xfer_log.xfercallid from vicidial_email_list, vicidial_xfer_log where vicidial_email_list.status='QUEUE' and vicidial_email_list.user='$user' and vicidial_xfer_log.xfercallid=vicidial_email_list.xfercallid and direction='INBOUND' and vicidial_xfer_log.campaign_id in ($email_group_str) and closer='EMAIL_XFER' order by vicidial_xfer_log.call_date asc limit 1";
if ($non_latin > 0) {$rslt=mysql_to_mysqli("SET NAMES 'UTF8'", $link);}
if ($DB) {echo "$stmt\n";}
@@ -7905,6 +7949,7 @@ if ($ACTION == 'VDADcheckINCOMINGemail')
$email_ct = mysqli_num_rows($rslt);
$xferred_email=$email_ct;
# Check if there are any QUEUE emails
if ($email_ct==0)
{
# Check if there are any QUEUE emails
@@ -7913,23 +7958,29 @@ if ($ACTION == 'VDADcheckINCOMINGemail')
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00488',$user,$server_ip,$session_name,$one_mysql_log);}
$email_ct = mysqli_num_rows($rslt);
# if ($email_ct==0)
# {
# $upd_stmt="update vicidial_email_list inner join(select email_row_id from vicidial_email_list inner join vicidial_inbound_groups on vicidial_inbound_groups.group_id=vicidial_email_list.group_id order by queue_priority desc, email_date asc limit 1) as selected_row on selected_row.email_row_id=vicidial_email_list.email_row_id set status='QUEUE', user='$user'";
# if ($DB) {echo "$upd_stmt\n";}
# $rslt=mysql_to_mysqli($stmt, $link);
# if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00104',$user,$server_ip,$session_name,$one_mysql_log);}
}
# if (mysqli_affected_rows($link)>0)
# {
# $stmt = "select lead_id, email_date, email_to, email_from, subject, group_id, email_row_id from vicidial_email_list where status='QUEUE' and direction='INBOUND' and user='$user' and group_id in ($email_group_str) order by email_date asc limit 1";
# if ($DB) {echo "$stmt\n";}
# $rslt=mysql_to_mysqli($stmt, $link);
# if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00104',$user,$server_ip,$session_name,$one_mysql_log);}
# $email_ct = mysqli_num_rows($rslt);
# }
# }
### Check for chats
if ($email_ct==0)
{
$stmt="select * from vicidial_live_chats where status='WAITING' and group_id in ($chat_group_str) order by chat_id asc limit 1";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00638',$user,$server_ip,$session_name,$one_mysql_log);}
if (mysqli_num_rows($rslt)>0)
{
$chat_row=mysqli_fetch_row($rslt);
$chat_id=$chat_row[0];
$status =$chat_row[2];
$chat_creator=$chat_row[3];
$group_id=$chat_row[4];
$VDADchannel_group=$chat_row[4];
$lead_id=$chat_row[5];
$uniqueid=date("U").".".rand(1, 9999);
$upd_stmt="update vicidial_live_chats set status='LIVE', chat_creator='$user' where chat_id='$chat_id'";
$upd_rslt=mysql_to_mysqli($upd_stmt, $link);
$chat_ct=mysqli_affected_rows($link);
}
}
if ($email_ct > 0)
@@ -7946,9 +7997,9 @@ if ($ACTION == 'VDADcheckINCOMINGemail')
$uniqueid=date("U").".".rand(1, 9999);
if (strlen($call_server_ip)<7) {$call_server_ip = $server_ip;}
# echo "1\n" . $lead_id . '|'.$uniqueid.'|' . $email_date . '|' . $email_from . '|' . $subject . '|' . $email_row_id . "|\n"; # VDIC_data_VDAC
# Change to better suit the output processed by the agent interface
echo "1\n" . $lead_id . '|'.$uniqueid.'|' . $email_from . '|EMAIL|' . $email_row_id . '|' . $email_row_id . "|\n"; # VDIC_data_VDAC
echo "1\n" . $lead_id . '|'.$uniqueid.'|' . $email_from . '|EMAIL|' . $email_row_id . '|' . $email_row_id . "|EMAIL\n"; # VDIC_data_VDAC
##### grab number of calls today in this campaign and increment
$stmt="SELECT calls_today FROM vicidial_live_agents WHERE user='$user' and campaign_id='$campaign';";
@@ -8042,13 +8093,18 @@ if ($ACTION == 'VDADcheckINCOMINGemail')
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00493',$user,$server_ip,$session_name,$one_mysql_log);}
### IF incoming result => answer email, not chat...
### update the email lead status to INCALL
# I moved user='$user' clause here because it is now getting added to the lead when the status becomes QUEUE
# user='$user' clause moved here because it is now getting added to the lead when the status becomes QUEUE
$stmt = "UPDATE vicidial_email_list set status='INCALL', uniqueid='$uniqueid' where lead_id='$lead_id' and email_row_id='$email_row_id' and user='$user';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00494',$user,$server_ip,$session_name,$one_mysql_log);}
### END IF
### if a transfer, update the transfer record with the user
if ($xferred_email==1)
{
@@ -8058,6 +8114,112 @@ if ($ACTION == 'VDADcheckINCOMINGemail')
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00495',$user,$server_ip,$session_name,$one_mysql_log);}
}
}
else if ($chat_ct>0)
{
if (strlen($call_server_ip)<7) {$call_server_ip = $server_ip;}
# Change to better suit the output processed by the agent interface
echo "1\n" . $lead_id . '|'.$uniqueid.'|' . $email_from . '|CHAT|' . $chat_id . '|' . $chat_id . "|CHAT\n"; # VDIC_data_VDAC
##### grab number of calls today in this campaign and increment
$stmt="SELECT calls_today FROM vicidial_live_agents WHERE user='$user' and campaign_id='$campaign';";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00639',$user,$server_ip,$session_name,$one_mysql_log);}
if ($DB) {echo "$stmt\n";}
$vla_cc_ct = mysqli_num_rows($rslt);
if ($vla_cc_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$calls_today =$row[0];
}
else
{$calls_today ='0';}
$calls_today++;
### update the agent status to INCALL in vicidial_live_agents while handling email
$stmt = "UPDATE vicidial_live_agents set status='INCALL',comments='CHAT',last_call_time='$NOW_TIME',lead_id='$lead_id',calls_today='$calls_today',external_hangup=0,external_status='',external_pause='',external_dial='',last_state_change='$NOW_TIME',pause_code='' where user='$user' and server_ip='$server_ip';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {$errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00640',$user,$server_ip,$session_name,$one_mysql_log);}
$retry_count=0;
while ( ($errno > 0) and ($retry_count < 9) )
{
$rslt=mysql_to_mysqli($stmt, $link);
$one_mysql_log=1;
$errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,"9106$retry_count",$user,$server_ip,$session_name,$one_mysql_log);
$one_mysql_log=0;
$retry_count++;
}
$stmt = "UPDATE vicidial_campaign_agents set calls_today='$calls_today' where user='$user' and campaign_id='$campaign';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00641',$user,$server_ip,$session_name,$one_mysql_log);}
$stmtA = "UPDATE vicidial_live_inbound_agents set calls_today='$calls_today',last_call_time=NOW() WHERE user='$user' and group_id='$VDADchannel_group';";
$rsltA=mysql_to_mysqli($stmtA, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmtA,'00642',$user,$server_ip,$session_name,$one_mysql_log);}
$stmtA = "UPDATE vicidial_inbound_group_agents set calls_today='$calls_today',group_type='C' WHERE user='$user' and group_id='$VDADchannel_group';";
$rsltA=mysql_to_mysqli($stmtA, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmtA,'00643',$user,$server_ip,$session_name,$one_mysql_log);}
##### grab the data from vicidial_list for the lead_id
$stmt="SELECT lead_id,entry_date,modify_date,status,user,vendor_lead_code,source_id,list_id,gmt_offset_now,called_since_last_reset,phone_code,phone_number,title,first_name,middle_initial,last_name,address1,address2,address3,city,state,province,postal_code,country_code,gender,date_of_birth,alt_phone,email,security_phrase,comments,called_count,last_local_call_time,rank,owner,entry_list_id FROM vicidial_list where lead_id='$lead_id' LIMIT 1;";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00644',$user,$server_ip,$session_name,$one_mysql_log);}
if ($DB) {echo "$stmt\n";}
$list_lead_ct = mysqli_num_rows($rslt);
if ($list_lead_ct > 0)
{
$row=mysqli_fetch_row($rslt);
# $lead_id = trim("$row[0]");
$dispo = trim("$row[3]");
$tsr = trim("$row[4]");
$vendor_id = trim("$row[5]");
$source_id = trim("$row[6]");
$list_id = trim("$row[7]");
$gmt_offset_now = trim("$row[8]");
$phone_code = trim("$row[10]");
$phone_number = trim("$row[11]");
$title = trim("$row[12]");
$first_name = trim("$row[13]");
$middle_initial = trim("$row[14]");
$last_name = trim("$row[15]");
$address1 = trim("$row[16]");
$address2 = trim("$row[17]");
$address3 = trim("$row[18]");
$city = trim("$row[19]");
$state = trim("$row[20]");
$province = trim("$row[21]");
$postal_code = trim("$row[22]");
$country_code = trim("$row[23]");
$gender = trim("$row[24]");
$date_of_birth = trim("$row[25]");
$alt_phone = trim("$row[26]");
$email = trim("$row[27]");
$security_phrase = trim("$row[28]");
$comments = stripslashes(trim("$row[29]"));
$called_count = trim("$row[30]");
$rank = trim("$row[32]");
$owner = trim("$row[33]");
$entry_list_id = trim("$row[34]");
if ($entry_list_id < 100) {$entry_list_id = $list_id;}
}
### update the lead status to INCALL
$stmt = "UPDATE vicidial_list set status='INCALL', user='$user' where lead_id='$lead_id';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00645',$user,$server_ip,$session_name,$one_mysql_log);}
}
if ($email_ct>0 || $chat_ct>0) {
### ANYTHING AFTER THIS POINT - DOES NOT MATTER WHETHER AN EMAIL OR CHAT IS BEING FIELDED
### gather custom_call_id from vicidial_log_extended table
$custom_call_id='';
/* Can't use this - $unique_id is gotten from querying the vicidial_live_agents from an inbound call. These are not calls.
@@ -8072,6 +8234,7 @@ if ($ACTION == 'VDADcheckINCOMINGemail')
$custom_call_id = $row[0];
}
*/
$custom_call_id='';
### gather user_group and full_name of agent
$user_group='';
@@ -11879,6 +12042,35 @@ if ($ACTION == 'userLOGout')
sleep(1);
##### End any still-active chats initiated by the agent
if ($allow_chats==1) {
$stmt="select manager_chat_id from vicidial_manager_chats where manager='$user'";
$rslt=mysqli_query($link, $stmt);
while ($row=mysqli_fetch_row($rslt)) {
$manager_chat_id=$row[0];
$archive_stmt="insert ignore into vicidial_manager_chat_log_archive select * from vicidial_manager_chat_log where manager_chat_id='$manager_chat_id'";
$archive_rslt=mysqli_query($link, $archive_stmt);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$archive_stmt,'00646',$user,$server_ip,$session_name,$one_mysql_log);}
$archive_stmt="insert ignore into vicidial_manager_chats_archive select * from vicidial_manager_chats where manager_chat_id='$manager_chat_id'";
$archive_rslt=mysqli_query($link, $archive_stmt);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$archive_stmt,'00647',$user,$server_ip,$session_name,$one_mysql_log);}
$delete_stmt="delete from vicidial_manager_chat_log where manager_chat_id='$manager_chat_id'";
$delete_rslt=mysqli_query($link, $delete_stmt);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$delete_stmt,'00648',$user,$server_ip,$session_name,$one_mysql_log);}
if (mysqli_affected_rows($link)>0) {
$archive_stmt="delete from vicidial_manager_chats where manager_chat_id='$manager_chat_id'";
$archive_rslt=mysqli_query($link, $archive_stmt);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$archive_stmt,'00649',$user,$server_ip,$session_name,$one_mysql_log);}
}
}
}
######
##### Delete the vicidial_live_agents record for this session
$stmt="DELETE from vicidial_live_agents where server_ip='$server_ip' and user ='$user';";
if ($DB) {echo "$stmt\n";}
+417 -42
View File
@@ -9,6 +9,9 @@
# - conf_exten_check.php: time sync and status updater, calls in queue
# - vdc_script_display.php: displays script with variables
# - vdc_form_display.php: display custom fields form
# - vdc_email_display.php: display email interface
# - vdc_chat_display.php: display chat interface
# - agc_agent_manager_chat_interface.php: display internal chats
#
# CHANGELOG
# 50607-1426 - First Build of VICIDIAL web client basic login process finished
@@ -505,10 +508,11 @@
# 151028-1458 - Added status groups statuses feature with min/max seconds qualifiers for statuses
# 151119-1925 - Fixed issue with scheduled callbacks and status groups
# 151125-0942 - Fixed manual call only logging bug
# 151212-0922 - Added all chat functionality
#
$version = '2.12-477c';
$build = '151125-0942';
$version = '2.12-478c';
$build = '151212-0922';
$mel=1; # Mysql Error Log enabled = 1
$mysql_log_count=85;
$one_mysql_log=0;
@@ -605,7 +609,7 @@ if ($sl_ct > 0)
#############################################
##### START SYSTEM_SETTINGS LOOKUP #####
$stmt = "SELECT use_non_latin,vdc_header_date_format,vdc_customer_date_format,vdc_header_phone_format,webroot_writable,timeclock_end_of_day,vtiger_url,enable_vtiger_integration,outbound_autodial_active,enable_second_webform,user_territories_active,static_agent_url,custom_fields_enabled,pllb_grouping_limit,qc_features_active,allow_emails,callback_time_24hour,enable_languages,language_method,meetme_enter_login_filename,meetme_enter_leave3way_filename,enable_third_webform,default_language,active_modules FROM system_settings;";
$stmt = "SELECT use_non_latin,vdc_header_date_format,vdc_customer_date_format,vdc_header_phone_format,webroot_writable,timeclock_end_of_day,vtiger_url,enable_vtiger_integration,outbound_autodial_active,enable_second_webform,user_territories_active,static_agent_url,custom_fields_enabled,pllb_grouping_limit,qc_features_active,allow_emails,callback_time_24hour,enable_languages,language_method,meetme_enter_login_filename,meetme_enter_leave3way_filename,enable_third_webform,default_language,active_modules,allow_chats,chat_url FROM system_settings;";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01001',$VD_login,$server_ip,$session_name,$one_mysql_log);}
if ($DB) {echo "$stmt\n";}
@@ -637,6 +641,8 @@ if ($qm_conf_ct > 0)
$enable_third_webform = $row[21];
$default_language = $row[22];
$active_modules = $row[23];
$chat_enabled = $row[24];
$chat_URL = $row[25];
}
else
{
@@ -2066,6 +2072,7 @@ else
$VARingroup_handlers="''";
$VARphonegroups="''";
$VARemailgroups="''";
$VARchatgroups="''";
if ( ($campaign_allow_inbound == 'Y') and ($dial_method != 'MANUAL') )
{
### validate that the agent has not exceeded their max inbound calls for today
@@ -2094,6 +2101,7 @@ else
$VARingroup_handlers='';
$VARphonegroups='';
$VARemailgroups='';
$VARchatgroups='';
$stmt="SELECT group_id,group_handling from vicidial_inbound_groups where active = 'Y' and group_id IN($closer_campaigns) order by group_id limit 800;";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01015',$VD_login,$server_ip,$session_name,$one_mysql_log);}
@@ -2101,22 +2109,31 @@ else
$closer_ct = mysqli_num_rows($rslt);
$INgrpCT=0;
$EMAILgrpCT=0;
$CHATgrpCT=0;
$PHONEgrpCT=0;
while ($INgrpCT < $closer_ct)
{
$row=mysqli_fetch_row($rslt);
$closer_groups[$INgrpCT] =$row[0];
$closer_group_handling[$INgrpCT] =$row[1]; // PHONE OR EMAIL - this is important
$closer_group_handling[$INgrpCT] =$row[1]; // PHONE OR EMAIL OR CHAT - this is important
$VARingroups = "$VARingroups'$closer_groups[$INgrpCT]',";
$VARingroup_handlers = "$VARingroup_handlers'$closer_group_handling[$INgrpCT]',";
if ($row[1]=="EMAIL") // Make a list of ingroups for email handling groups and one for phones, so there is no overlap
if ($row[1]=="EMAIL") // Make a list of ingroups for email handling groups, chat handling groups and one for phones, so there is no overlap
{
$VARemailgroups = "$VARemailgroups'$closer_groups[$INgrpCT]',";
$VARemailgroupsURL = $VARemailgroupsURL."&email_group_ids[]=$closer_groups[$INgrpCT]";
$EMAILgrpCT++;
}
else if ($row[1]=="CHAT")
{
$VARchatgroups = "$VARchatgroups'$closer_groups[$INgrpCT]',";
$VARchatgroupsURL = $VARchatgroupsURL."&chat_group_ids[]=$closer_groups[$INgrpCT]";
$CHATgrpCT++;
}
else
{
$VARphonegroups = "$VARphonegroups'$closer_groups[$INgrpCT]',";
$VARphonegroupsURL = $VARphonegroupsURL."&phone_group_ids[]=$closer_groups[$INgrpCT]";
$PHONEgrpCT++;
}
$INgrpCT++;
@@ -2125,6 +2142,7 @@ else
$VARingroup_handlers = substr("$VARingroup_handlers", 0, -1);
$VARphonegroups = substr("$VARphonegroups", 0, -1);
$VARemailgroups = substr("$VARemailgroups", 0, -1);
$VARchatgroups = substr("$VARchatgroups", 0, -1);
}
else
{$closer_campaigns = "''";}
@@ -3774,6 +3792,10 @@ $CCAL_OUT .= "</table>";
var EMAILgroupCOUNT = 0;
var incomingEMAILgroups= new Array();
VARchatgroups = new Array(<?php echo $VARchatgroups ?>);
var CHATgroupCOUNT = 0;
var incomingCHATgroups= new Array();
VARphonegroups = new Array(<?php echo $VARphonegroups ?>);
// var PHONEgroupCOUNT = '<?php echo $PHONEgrpCT ?>';
var PHONEgroupCOUNT = 0;
@@ -4082,7 +4104,7 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";}
var CheckDEADcall = 0;
var CheckDEADcallON = 0;
var CheckDEADcallCOUNT = 0;
var currently_in_email = 0;
var currently_in_email_or_chat = 0;
var VtigeRLogiNScripT = '<?php echo $vtiger_screen_login ?>';
var VtigeRurl = '<?php echo $vtiger_url ?>';
var VtigeREnableD = '<?php echo $enable_vtiger_integration ?>';
@@ -4186,6 +4208,8 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";}
var custom_fields_enabled='<?php echo $custom_fields_enabled ?>';
var form_contents_loaded=0;
var email_enabled='<?php echo $email_enabled ?>';
var chat_enabled='<?php echo $chat_enabled ?>';
var chat_URL='<?php echo $chat_URL; ?>';
var enable_xfer_presets='<?php echo $enable_xfer_presets ?>';
var hide_xfer_number_to_dial='<?php echo $hide_xfer_number_to_dial ?>';
var Presets_HTML='';
@@ -4366,6 +4390,23 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";}
image_LB_ivrgrabparkedcall.src="./images/<?php echo _QXZ("vdc_LB_grabivrparkcall.gif") ?>";
var image_LB_ivrparkcall = new Image();
image_LB_ivrparkcall.src="./images/<?php echo _QXZ("vdc_LB_ivrparkcall.gif") ?>";
var image_internal_chat_OFF = new Image();
image_internal_chat_OFF.src="./images/<?php echo _QXZ("vdc_tab_chat_internal.gif") ?>";
var image_internal_chat_ON = new Image();
image_internal_chat_ON.src="./images/<?php echo _QXZ("vdc_tab_chat_internal_red.gif") ?>";
var image_internal_chat_ALERT = new Image();
image_internal_chat_ALERT.src="./images/<?php echo _QXZ("vdc_tab_chat_internal_blink.gif") ?>";
var image_customer_chat_OFF = new Image();
image_customer_chat_OFF.src="./images/<?php echo _QXZ("vdc_tab_chat_customer.gif") ?>";
var image_customer_chat_ON = new Image();
image_customer_chat_ON.src="./images/<?php echo _QXZ("vdc_tab_chat_customer_red.gif") ?>";
var image_customer_chat_ALERT = new Image();
image_customer_chat_ALERT.src="./images/<?php echo _QXZ("vdc_tab_chat_customer_blink.gif") ?>";
var image_chat_alert_UNMUTE = new Image();
image_chat_alert_UNMUTE.src="./images/<?php echo _QXZ("vdc_volume_UNMUTE.gif") ?>";
var image_chat_alert_MUTE = new Image();
image_chat_alert_MUTE.src="./images/<?php echo _QXZ("vdc_volume_MUTE.gif") ?>";
<?php
if ($window_validation > 0)
{
@@ -5125,6 +5166,10 @@ function set_length(SLnumber,SLlength_goal,SLdirection)
var CamPCalLs = CamPCalLs_array[1];
var DiaLCalLs_array = check_time_array[5].split("DiaLCalls: ");
var DiaLCalLs = DiaLCalLs_array[1];
var WaitinGChats_array = check_time_array[27].split("WaitinGChats: ");
var WaitinGChats = WaitinGChats_array[1];
var WaitinGEmails_array = check_time_array[28].split("WaitinGEmails: ");
var WaitinGEmails = WaitinGEmails_array[1];
if (AGLogiN != 'N')
{
document.getElementById("AgentStatusStatus").innerHTML = AGLogiN;
@@ -5137,6 +5182,27 @@ function set_length(SLnumber,SLlength_goal,SLdirection)
{
document.getElementById("AgentStatusDiaLs").innerHTML = DiaLCalLs;
}
// Chat alert
if (chat_enabled > 0)
{
if (WaitinGChats == 'Y')
{
document.images['CustomerChatImg'].src=image_customer_chat_ALERT.src;
}
else if (WaitinGChats == 'C')
{
document.images['CustomerChatImg'].src=image_customer_chat_ON.src;
}
else
{
document.images['CustomerChatImg'].src=image_customer_chat_OFF.src;
}
}
// Email alert
if (WaitinGEmails != 'N')
{
document.getElementById("AgentStatusEmails").innerHTML = WaitinGEmails;
}
if ( (AGLogiN == 'DEAD_VLA') && ( (vicidial_agent_disable == 'LIVE_AGENT') || (vicidial_agent_disable == 'ALL') ) )
{
showDiv('AgenTDisablEBoX');
@@ -6738,6 +6804,82 @@ function set_length(SLnumber,SLlength_goal,SLdirection)
}
}
// ################################################################################
// Request list of active manager chats for this agent
function InternalChatsCheck(line_code)
{
var xmlhttp=false;
// var MGR_chat_print=0;
var MGRpre='';
var MGRpost='';
/*@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 InternalChat_query = "server_ip=" + server_ip + "&session_name=" + session_name + "&user=" + user + "&pass=" + pass + "&ACTION=ManagerChatsCheck";
xmlhttp.open('POST', 'vdc_db_query.php');
xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8');
xmlhttp.send(InternalChat_query);
xmlhttp.onreadystatechange = function()
{
if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
{
var active_InternalChat_info = null;
active_InternalChat_info = xmlhttp.responseText;
var Internal_chat_array=active_InternalChat_info.split("|");
var Internal_chat_print=Internal_chat_array[0];
var Internal_chat_unread_msg=Internal_chat_array[1];
var Internal_chat_alert_sounds=Internal_chat_array[2];
if (Internal_chat_print>0)
{
if (Internal_chat_unread_msg>0)
{
document.images['InternalChatImg'].src=image_internal_chat_ALERT.src;
}
else
{
document.images['InternalChatImg'].src=image_internal_chat_ON.src;
}
}
else
{
Internal_chat_print="NO";
document.images['InternalChatImg'].src=image_internal_chat_OFF.src;
}
var ChatIFrame = document.getElementById('InternalChatIFrame');
var innerChatDoc = (ChatIFrame.contentDocument) ? ChatIFrame.contentDocument : ChatIFrame.contentWindow.document;
if (innerChatDoc.getElementById("InternalMessageCount")) // Prevents javascript error when page loads
{
if (Internal_chat_alert_sounds>innerChatDoc.getElementById("InternalMessageCount").value && innerChatDoc.getElementById("InternalMessageCount").value>0 && !innerChatDoc.getElementById("MuteChatAlert").checked)
{
document.getElementById("ChatAudioAlertFile").play();
}
innerChatDoc.getElementById("InternalMessageCount").value=Internal_chat_alert_sounds;
}
}
// alert(line_code+ " -- " + MGR_chat_print + " -- " +MGR_chat_unread_msg);
}
}
}
// ################################################################################
// closes callback list screen
@@ -6838,6 +6980,7 @@ function set_length(SLnumber,SLlength_goal,SLdirection)
auto_dial_level=starting_dial_level;
MainPanelToFront();
CalLBacKsCounTCheck();
InternalChatsCheck();
manual_dial_in_progress=0;
}
@@ -8079,6 +8222,11 @@ function set_length(SLnumber,SLlength_goal,SLdirection)
if (fields_list.match(regUDemailreload))
{EmailContentsLoad();}
// JOEJ 060514 - new for chat feature
var regUDchatreload = new RegExp("chatreload,","ig");
if (fields_list.match(regUDchatreload))
{CustomerChatContentsLoad();}
var regWFAcustom = new RegExp("^VAR","ig");
if (VDIC_web_form_address.match(regWFAcustom))
{
@@ -8311,6 +8459,7 @@ function set_length(SLnumber,SLlength_goal,SLdirection)
auto_dial_level=starting_dial_level;
MainPanelToFront();
CalLBacKsCounTCheck();
InternalChatsCheck();
if (MDnextCID.match(regMNCvar))
{alert_box("<?php echo _QXZ("No more leads in the hopper for campaign:"); ?>\n" + campaign); alert_displayed=1;}
@@ -8696,6 +8845,12 @@ function set_length(SLnumber,SLlength_goal,SLdirection)
{
EmailContentsLoad();
}
// JOEJ 060514 - new for chat feature
// Will populate chat tab in case this is a customer awaiting a chat AND the agent selected a campaign that allows chats
if (chat_enabled > 0 && CHATgroupCOUNT > 0)
{
CustomerChatContentsLoad();
}
if (get_call_launch == 'SCRIPT')
{
if (delayed_script_load == 'YES')
@@ -8715,6 +8870,11 @@ function set_length(SLnumber,SLlength_goal,SLdirection)
EmailPanelToFront();
}
if (get_call_launch == 'CHAT')
{
CustomerChatPanelToFront();
}
if (get_call_launch == 'WEBFORM')
{
window.open(TEMP_VDIC_web_form_address, web_form_target, 'toolbar=1,scrollbars=1,location=1,statusbar=1,menubar=1,resizable=1,width=640,height=450');
@@ -9115,6 +9275,12 @@ function set_length(SLnumber,SLlength_goal,SLdirection)
{
EmailContentsLoad();
}
// JOEJ 060514 - new for email feature
// Will populate chat tab in case this is a customer awaiting a chat with an agent
if (chat_enabled > 0)
{
CustomerChatContentsLoad();
}
if (get_call_launch == 'SCRIPT')
{
if (delayed_script_load == 'YES')
@@ -9131,6 +9297,10 @@ function set_length(SLnumber,SLlength_goal,SLdirection)
{
EmailPanelToFront();
}
if (get_call_launch == 'CHAT')
{
CustomerChatPanelToFront();
}
if (get_call_launch == 'WEBFORM')
{
window.open(TEMP_VDIC_web_form_address, web_form_target, 'toolbar=1,scrollbars=1,location=1,statusbar=1,menubar=1,resizable=1,width=640,height=450');
@@ -10074,6 +10244,11 @@ function set_length(SLnumber,SLlength_goal,SLdirection)
{
EmailContentsLoad();
}
// JOEJ 060514 - new for chat feature
if (chat_enabled > 0)
{
CustomerChatContentsLoad();
}
if (CalL_AutO_LauncH == 'SCRIPT')
{
if (delayed_script_load == 'YES')
@@ -10125,15 +10300,15 @@ function set_length(SLnumber,SLlength_goal,SLdirection)
alert(" <?php echo _QXZ("Incoming:"); ?> " + dial_display_number + "\n <?php echo _QXZ("Group"); ?>- " + VDIC_data_VDIG[1] + " &nbsp; " + VDIC_fronter);
}
}
else if (email_enabled>0 && EMAILgroupCOUNT>0 && AutoDialWaiting==1)
else if ( ((email_enabled>0 && EMAILgroupCOUNT>0) || (chat_enabled>0 && CHATgroupCOUNT>0)) && AutoDialWaiting==1)
{
// JOEJ check for EMAIL
// JOEJ check for EMAIL/CHAT
// QUEUEpadding is needed to allow inbound calls to get through QUEUE status
QUEUEpadding++;
if (QUEUEpadding==5)
{
QUEUEpadding=0;
check_for_incoming_email();
check_for_incoming_other();
}
}
xmlhttprequestcheckauto = undefined;
@@ -10146,45 +10321,53 @@ function set_length(SLnumber,SLlength_goal,SLdirection)
// ################################################################################
// Check to see if there is an email unanswered in queue
// Check to see if there is an email or chat unanswered in queue
// This should not happen if the agent is INCALL
function check_for_incoming_email()
// Pass the manual_chat_override when the agent starts a chat themselves,
// so the dialer will skip checking for emails
function check_for_incoming_other(manual_chat_override)
{
if (typeof(xmlhttprequestcheckemail) == "undefined")
if (typeof(xmlhttprequestcheckother) == "undefined")
{
all_record = 'NO';
all_record_count=0;
var xmlhttprequestcheckemail=false;
if (!xmlhttprequestcheckemail && typeof XMLHttpRequest!='undefined')
var xmlhttprequestcheckother=false;
if (!xmlhttprequestcheckother && typeof XMLHttpRequest!='undefined')
{
xmlhttprequestcheckemail = new XMLHttpRequest();
xmlhttprequestcheckother = new XMLHttpRequest();
}
if (xmlhttprequestcheckemail)
if (xmlhttprequestcheckother)
{
checkVDAI_query = "server_ip=" + server_ip + "&session_name=" + session_name + "&user=" + user + "&pass=" + pass + "&orig_pass=" + orig_pass + "&campaign=" + campaign + "&ACTION=VDADcheckINCOMINGemail" + "&agent_log_id=" + agent_log_id;
checkVDAI_query = "server_ip=" + server_ip + "&session_name=" + session_name + "&user=" + user + "&pass=" + pass + "&orig_pass=" + orig_pass + "&campaign=" + campaign + "&ACTION=VDADcheckINCOMINGother" + "&agent_log_id=" + agent_log_id;
// Add on all the email groups the user selected in order to pass them to the vdc_db_query script
for (var i = 0; i < incomingEMAILgroups.length; i++) {
checkVDAI_query+="&inbound_email_groups[]="+incomingEMAILgroups[i];
}
if (!manual_chat_override)
{
// Add on all the email groups the user selected in order to pass them to the vdc_db_query script
for (var i = 0; i < incomingEMAILgroups.length; i++)
{
checkVDAI_query+="&inbound_email_groups[]="+incomingEMAILgroups[i];
}
}
// Add on all the chat groups the user selected in order to pass them to the vdc_db_query script
for (var i = 0; i < incomingCHATgroups.length; i++)
{
checkVDAI_query+="&inbound_chat_groups[]="+incomingCHATgroups[i];
}
xmlhttprequestcheckemail.open('POST', 'vdc_db_query.php');
xmlhttprequestcheckemail.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8');
xmlhttprequestcheckemail.send(checkVDAI_query);
xmlhttprequestcheckother.open('POST', 'vdc_db_query.php');
xmlhttprequestcheckother.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8');
xmlhttprequestcheckother.send(checkVDAI_query);
xmlhttprequestcheckemail.onreadystatechange = function()
xmlhttprequestcheckother.onreadystatechange = function()
{
if (xmlhttprequestcheckemail.readyState == 4 && xmlhttprequestcheckemail.status == 200)
if (xmlhttprequestcheckother.readyState == 4 && xmlhttprequestcheckother.status == 200)
{
var check_incoming = null;
check_incoming = xmlhttprequestcheckemail.responseText;
// alert(checkVDAI_query);
//alert(xmlhttprequestcheckemail.responseText);
check_incoming = xmlhttprequestcheckother.responseText;
var check_VDIC_array=check_incoming.split("\n");
if (check_VDIC_array[0] == '1')
{
// alert(xmlhttprequestcheckemail.responseText);
AutoDialWaiting = 0;
UpdatESettingSChecK = 1;
@@ -10192,7 +10375,21 @@ function set_length(SLnumber,SLlength_goal,SLdirection)
VDIC_web_form_address = VICIDiaL_web_form_address;
VDIC_web_form_address_two = VICIDiaL_web_form_address_two;
VDIC_web_form_address_three = VICIDiaL_web_form_address_three;
document.getElementById("EmailAudioAlertFile").play();
CalL_AutO_LauncH = VDIC_data_VDAC[3];
if (CalL_AutO_LauncH=='EMAIL')
{
document.vicidial_form.email_row_id.value= VDIC_data_VDAC[4];
document.getElementById("EmailAudioAlertFile").play();
}
else if (CalL_AutO_LauncH=='CHAT')
{
if (chat_enabled > 0)
{
document.images['CustomerChatImg'].src=image_customer_chat_ON.src;
document.getElementById("ChatAudioAlertFile").play();
document.vicidial_form.chat_id.value= VDIC_data_VDAC[4];
}
}
var VDIC_fronter='';
var VDIC_data_VDIG=check_VDIC_array[2].split("|");
@@ -10203,7 +10400,6 @@ function set_length(SLnumber,SLlength_goal,SLdirection)
var VDCL_fronter_display = VDIC_data_VDIG[3];
VDCL_group_id = VDIC_data_VDIG[4];
CalL_ScripT_id = VDIC_data_VDIG[5];
CalL_AutO_LauncH = 'EMAIL'; // FORCE EMAIL tab
CalL_XC_a_Dtmf = VDIC_data_VDIG[7];
CalL_XC_a_NuMber = VDIC_data_VDIG[8];
CalL_XC_b_Dtmf = VDIC_data_VDIG[9];
@@ -10305,8 +10501,7 @@ function set_length(SLnumber,SLlength_goal,SLdirection)
VD_live_customer_call = 1;
VD_live_call_secondS = 0;
customer_sec = 0;
CheckDEADcallON = 1; // Do this to keep the interface from instantly reading an email as a hangup
currently_in_email = 1; // Do this to block channel checks (or anything else) that would indicate a completed call
currently_in_email_or_chat = 1; // Do this to block channel checks (or anything else) that would indicate a completed call
// INSERT VICIDIAL_LOG ENTRY FOR THIS CALL PROCESS
// DialLog("start");
@@ -10774,6 +10969,11 @@ function set_length(SLnumber,SLlength_goal,SLdirection)
{
EmailContentsLoad();
}
// JOEJ 060514 - new for chat feature
if (chat_enabled > 0)
{
CustomerChatContentsLoad('', '', manual_chat_override);
}
if (CalL_AutO_LauncH == 'SCRIPT')
{
if (delayed_script_load == 'YES')
@@ -10790,6 +10990,10 @@ function set_length(SLnumber,SLlength_goal,SLdirection)
{
EmailPanelToFront();
}
if (CalL_AutO_LauncH == 'CHAT')
{
CustomerChatPanelToFront();
}
if (CalL_AutO_LauncH == 'WEBFORM')
{
@@ -10825,8 +11029,8 @@ function set_length(SLnumber,SLlength_goal,SLdirection)
alert(" <?php echo _QXZ("Incoming:"); ?> " + dial_display_number + "\n <?php echo _QXZ("Group"); ?>- " + VDIC_data_VDIG[1] + " &nbsp; " + VDIC_fronter);
}
}
xmlhttprequestcheckemail = undefined;
delete xmlhttprequestcheckemail;
xmlhttprequestcheckother = undefined;
delete xmlhttprequestcheckother;
}
}
}
@@ -11068,6 +11272,13 @@ function set_length(SLnumber,SLlength_goal,SLdirection)
if (customer_sec < 1)
{customer_sec = VD_live_call_secondS;}
var process_post_hangup=0;
// Force chat to end, if exists. Uses hangup_override value in EndChat function to end if chat does not exist.
if (document.getElementById('CustomerChatIFrame') && typeof document.getElementById('CustomerChatIFrame').contentWindow.EndChat=='function')
{
document.getElementById('CustomerChatIFrame').contentWindow.EndChat('Hangup');
}
if ( (RedirecTxFEr < 1) && ( (MD_channel_look==1) || (auto_dial_level == 0) ) )
{
MD_channel_look=0;
@@ -11739,7 +11950,7 @@ function set_length(SLnumber,SLlength_goal,SLdirection)
else
{
move_on=0;
alert_box("<?php echo _QXZ("YOU MUST BE PAUSED TO SEARCH FOR A LEAD"); ?>");
alert_box("<?php echo _QXZ("YOU MUST BE PAUSED TO SEARCH FOR A LEAD"); ?>: " + inOUT + "|" + agent_lead_search);
}
}
}
@@ -11990,7 +12201,7 @@ function set_length(SLnumber,SLlength_goal,SLdirection)
CheckDEADcallON=0;
CheckDEADcallCOUNT=0;
customer_sec=0;
currently_in_email=0;
currently_in_email_or_chat=0;
customer_3way_hangup_counter=0;
customer_3way_hangup_counter_trigger=0;
waiting_on_dispo=1;
@@ -12159,6 +12370,8 @@ function set_length(SLnumber,SLlength_goal,SLdirection)
document.vicidial_form.called_count.value ='';
document.vicidial_form.call_notes.value ='';
document.vicidial_form.call_notes_dispo.value ='';
document.vicidial_form.email_row_id.value ='';
document.vicidial_form.chat_id.value ='';
document.vicidial_form.dispo_comments.value ='';
document.vicidial_form.cbcomment_comments.value ='';
VDCL_group_id = '';
@@ -12307,6 +12520,14 @@ function set_length(SLnumber,SLlength_goal,SLdirection)
{document.getElementById("ScriptContents").innerHTML = '';}
parked_hangup='0';
// Set customer chat tab to OFF, just to be sure
if (chat_enabled > 0)
{
document.images['CustomerChatImg'].src=image_customer_chat_OFF.src;
}
CustomerChatContentsLoad();
EmailContentsLoad();
AgentDispoing = 0;
if ( (alt_number_dialing == 'SELECTED') || (alt_number_dialing == 'SELECTED_TIMER_ALT') || (alt_number_dialing == 'SELECTED_TIMER_ADDR3') )
@@ -12854,8 +13075,10 @@ function set_length(SLnumber,SLlength_goal,SLdirection)
// Added to get email counts so inbound emails will come in - this is normally done in CloserSelectContent_select, which is bypassed if agents aren't allowed to select ingroups
var loop_ct = 0;
EMAILgroupCOUNT = 0;
CHATgroupCOUNT = 0;
PHONEgroupCOUNT = 0;
incomingEMAILS = 0;
incomingCHATS = 0;
while (loop_ct < INgroupCOUNT)
{
if (VARingroup_handlers[loop_ct]=="EMAIL")
@@ -12864,6 +13087,12 @@ function set_length(SLnumber,SLlength_goal,SLdirection)
EMAILgroupCOUNT++;
incomingEMAILS++;
}
else if (VARingroup_handlers[loop_ct]=="CHAT")
{
incomingCHATgroups[incomingCHATS]=VARingroups[loop_ct];
CHATgroupCOUNT++;
incomingCHATS++;
}
else
{
PHONEgroupCOUNT++;
@@ -12911,12 +13140,16 @@ function set_length(SLnumber,SLlength_goal,SLdirection)
{
var loop_ct = 0;
EMAILgroupCOUNT = 0;
CHATgroupCOUNT = 0;
PHONEgroupCOUNT = 0;
var CSCcolumn = '';
var live_CSC_HTML_ADD = '';
var live_CSC_HTML_DELETE = '';
var live_CSC_LIST_value = " ";
incomingEMAILS = 0;
incomingCHATS = 0;
incomingEMAILgroups = new Array();
incomingCHATgroups = new Array();
while (loop_ct < INgroupCOUNT)
{
var regCSL = new RegExp(" " + VARingroups[loop_ct] + " ","ig");
@@ -12936,6 +13169,12 @@ function set_length(SLnumber,SLlength_goal,SLdirection)
EMAILgroupCOUNT++;
incomingEMAILS++;
}
else if (VARingroup_handlers[loop_ct]=="CHAT")
{
incomingCHATgroups[incomingCHATS]=VARingroups[loop_ct];
CHATgroupCOUNT++;
incomingCHATS++;
}
else
{
PHONEgroupCOUNT++;
@@ -15059,6 +15298,7 @@ function phone_number_format(formatphone) {
{
if (EMLrefresh=='YES')
{button_click_log = button_click_log + "" + SQLdate + "-----EmailContentsLoad---|";}
var email_row_id = document.vicidial_form.email_row_id.value;
var form_list_id = document.vicidial_form.list_id.value;
var form_entry_list_id = document.vicidial_form.entry_list_id.value;
if (form_entry_list_id.length > 2)
@@ -15068,6 +15308,41 @@ function phone_number_format(formatphone) {
form_entry_list_id = '';
}
// ################################################################################
// Refresh the agent/customer CHAT content
function CustomerChatContentsLoad(clickMute, CHTrefresh, email_invite_lead_id)
{
if (CHTrefresh=='YES')
{button_click_log = button_click_log + "" + SQLdate + "-----CustomerChatContentsLoad---|";} var form_list_id = document.vicidial_form.list_id.value;
var form_entry_list_id = document.vicidial_form.entry_list_id.value;
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('CustomerChatIFrame').src='./vdc_chat_display.php?lead_id=' + document.vicidial_form.lead_id.value + '&list_id=' + form_list_id + '&user=' + user + '&pass=' + orig_pass + '&campaign=' + campaign + '&chat_id=' + form_chat_id + '&dial_method=' + dial_method + '&clickmute=' + clickMute + '&email_invite_lead_id=' + email_invite_lead_id + '&server_ip=' + server_ip + '&session_id=' + '&uniqueid=' + document.vicidial_form.uniqueid.value + '&stage=DISPLAY' + "&campaign=" + campaign + "&phone_login=" + phone_login + "&original_phone_login=" + original_phone_login +"&phone_pass=" + phone_pass + "&fronter=" + fronter + "&closer=" + user + "&group=" + group + "&channel_group=" + group + "&SQLdate=" + SQLdate + "&epoch=" + UnixTime + "&uniqueid=" + document.vicidial_form.uniqueid.value + "&customer_zap_channel=" + lastcustchannel + "&customer_server_ip=" + lastcustserverip +"&server_ip=" + server_ip + "&SIPexten=" + extension + "&session_id=" + session_id + "&phone=" + document.vicidial_form.phone_number.value + "&parked_by=" + document.vicidial_form.lead_id.value +"&dispo=" + LeaDDispO + '' +"&dialed_number=" + dialed_number + '' +"&dialed_label=" + dialed_label + '' +"&camp_script=" + campaign_script + '' +"&in_script=" + CalL_ScripT_id + '' +"&script_width=" + script_width + '' +"&script_height=" + script_height + '' +"&fullname=" + LOGfullname + '' +"&recording_filename=" + recording_filename + '' +"&recording_id=" + recording_id + '' +"&user_custom_one=" + VU_custom_one + '' +"&user_custom_two=" + VU_custom_two + '' +"&user_custom_three=" + VU_custom_three + '' +"&user_custom_four=" + VU_custom_four + '' +"&user_custom_five=" + VU_custom_five + '' +"&preset_number_a=" + CalL_XC_a_NuMber + '' +"&preset_number_b=" + CalL_XC_b_NuMber + '' +"&preset_number_c=" + CalL_XC_c_NuMber + '' +"&preset_number_d=" + CalL_XC_d_NuMber + '' +"&preset_number_e=" + CalL_XC_e_NuMber + '' +"&preset_dtmf_a=" + CalL_XC_a_Dtmf + '' +"&preset_dtmf_b=" + CalL_XC_b_Dtmf + '' +"&did_id=" + did_id + '' +"&did_extension=" + did_extension + '' +"&did_pattern=" + did_pattern + '' +"&did_description=" + did_description + '' +"&closecallid=" + closecallid + '' + "&xfercallid=" + xfercallid + '' + "&chat_group_id=" + VDCL_group_id + '' + "&agent_log_id=" + agent_log_id + "&call_id=" + LasTCID + "&user_group=" + VU_user_group + '' +"&web_vars=" + LIVE_web_vars + '';
form_list_id = '';
form_chat_id = '';
form_entry_list_id = '';
// CustomerChatPanelToFront();
}
// ################################################################################
// Refresh the agent/manager CHAT content
function InternalChatContentsLoad(ICHrefresh)
{
if (ICHrefresh=='YES')
{button_click_log = button_click_log + "" + SQLdate + "-----InternalChatContentsLoad---|";} var form_list_id = document.vicidial_form.list_id.value;
var form_list_id = document.vicidial_form.list_id.value;
var form_entry_list_id = document.vicidial_form.entry_list_id.value;
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 ;
form_list_id = '';
form_chat_id = '';
form_entry_list_id = '';
InternalChatPanelToFront();
}
// ################################################################################
// Move the Dispo frame out of the way and change the link to maximize
@@ -15501,6 +15776,9 @@ function phone_number_format(formatphone) {
hideDiv('ScriptRefresH');
hideDiv('EmailPanel');
hideDiv('EmailRefresH');
hideDiv('CustomerChatPanel');
hideDiv('CustomerChatRefresH');
hideDiv('InternalChatPanel');
hideDiv('FormPanel');
hideDiv('FormRefresH');
hideDiv('DispoSelectBox');
@@ -15547,6 +15825,10 @@ function phone_number_format(formatphone) {
{hideDiv('callsinqueuedisplay');}
if (agentonly_callbacks != '1')
{hideDiv('CallbacksButtons');}
if (email_enabled < 1)
{hideDiv('AgentStatusEmails');}
if (allow_alerts < 1)
{hideDiv('AgentAlertSpan');}
if (allow_alerts < 1)
{hideDiv('AgentAlertSpan');}
// if ( (agentcall_manual != '1') && (starting_dial_level > 0) )
@@ -15784,7 +16066,7 @@ function phone_number_format(formatphone) {
{TerritorySelect_submit();}
}
if (logout_stop_timeouts==1) {WaitingForNextStep=1;}
if ( (custchannellive < customer_gone_seconds) && (lastcustchannel.length > 3) && (no_empty_session_warnings < 1) && (document.vicidial_form.lead_id.value != '') && (currently_in_email==0) )
if ( (custchannellive < customer_gone_seconds) && (lastcustchannel.length > 3) && (no_empty_session_warnings < 1) && (document.vicidial_form.lead_id.value != '') && (currently_in_email_or_chat==0) )
{CustomerChanneLGone();}
// document.getElementById("debugbottomspan").innerHTML = "custchannellive: " + custchannellive + " lastcustchannel.length: " + lastcustchannel.length + " no_empty_session_warnings: " + no_empty_session_warnings + " lead_id: |" + document.vicidial_form.lead_id.value + "|";
if ( (custchannellive < -10) && (lastcustchannel.length > 3) ) {ReChecKCustoMerChaN();}
@@ -15831,6 +16113,10 @@ function phone_number_format(formatphone) {
CalLBacKsCounTCheck();
CB_count_check=0;
}
if (chat_enabled=='1') // JOEJ - if chat is enabled, check if manager has sent message.
{
InternalChatsCheck();
}
if ( (even > 0) && (agent_display_dialable_leads > 0) )
{
DiaLableLeaDsCounT();
@@ -15858,7 +16144,7 @@ function phone_number_format(formatphone) {
VD_live_call_secondS++;
document.vicidial_form.SecondS.value = VD_live_call_secondS;
document.getElementById("SecondSDISP").innerHTML = VD_live_call_secondS;
if (CheckDEADcallON > 0)
if (CheckDEADcallON > 0 && currently_in_email_or_chat < 1)
{
CheckDEADcallCOUNT++;
// document.getElementById("debugbottomspan").innerHTML = "DEAD CALL SECONDS " + CheckDEADcallCOUNT;
@@ -16301,6 +16587,10 @@ function phone_number_format(formatphone) {
{
divref = document.getElementById(divvar).style;
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;
}
}
}
function clearDiv(divvar)
@@ -16526,6 +16816,9 @@ function phone_number_format(formatphone) {
hideDiv('FormRefresH');
hideDiv('EmailPanel');
hideDiv('EmailRefresH');
hideDiv('CustomerChatPanel');
hideDiv('CustomerChatRefresH');
hideDiv('InternalChatPanel');
showDiv('MainPanel');
ShoWGenDerPulldown();
@@ -16598,6 +16891,9 @@ function phone_number_format(formatphone) {
hideDiv('FormRefresH');
hideDiv('EmailPanel');
hideDiv('EmailRefresH');
hideDiv('CustomerChatPanel');
hideDiv('CustomerChatRefresH');
hideDiv('InternalChatPanel');
document.getElementById("MainTable").style.backgroundColor="<?php echo $SCRIPT_COLOR ?>";
document.getElementById("MaiNfooter").style.backgroundColor="<?php echo $SCRIPT_COLOR ?>";
panel_bgcolor='<?php echo $SCRIPT_COLOR ?>';
@@ -16625,6 +16921,9 @@ function phone_number_format(formatphone) {
}
hideDiv('EmailPanel');
hideDiv('EmailRefresH');
hideDiv('CustomerChatPanel');
hideDiv('CustomerChatRefresH');
hideDiv('InternalChatPanel');
document.getElementById("MainTable").style.backgroundColor="<?php echo $FORM_COLOR ?>";
document.getElementById("MaiNfooter").style.backgroundColor="<?php echo $FORM_COLOR ?>";
panel_bgcolor='<?php echo $FORM_COLOR ?>';
@@ -16639,8 +16938,13 @@ function phone_number_format(formatphone) {
var CBFPheight = '<?php echo $QLheight ?>px';
document.getElementById("CallbacksButtons").style.top = CBFPheight;
document.getElementById("CallbacksButtons").style.left = '340px';
hideDiv('FormPanel');
hideDiv('FormRefresH');
showDiv('EmailPanel');
showDiv('EmailRefresH');
hideDiv('CustomerChatPanel');
hideDiv('CustomerChatRefresH');
hideDiv('InternalChatPanel');
if ( (OtherTab == '0') && (comments_all_tabs == 'ENABLED') )
{
OtherTab='1';
@@ -16656,6 +16960,49 @@ function phone_number_format(formatphone) {
HidEGenDerPulldown();
}
function CustomerChatPanelToFront(CPFclick)
{
if (CPFclick=='YES')
{button_click_log = button_click_log + "" + SQLdate + "-----CustomerChatPanelToFront---|";}
var CBFPheight = '<?php echo $QLheight ?>px';
document.getElementById("CallbacksButtons").style.top = CBFPheight;
document.getElementById("CallbacksButtons").style.left = '360px';
hideDiv('FormPanel');
hideDiv('FormRefresH');
hideDiv('EmailPanel');
hideDiv('EmailRefresH');
showDiv('CustomerChatPanel');
showDiv('CustomerChatRefresH');
hideDiv('InternalChatPanel');
document.getElementById("MainTable").style.backgroundColor="<?php echo $FORM_COLOR ?>";
document.getElementById("MaiNfooter").style.backgroundColor="<?php echo $FORM_COLOR ?>";
panel_bgcolor='<?php echo $FORM_COLOR ?>';
// document.getElementById("MainStatuSSpan").style.background = panel_bgcolor;
HidEGenDerPulldown();
}
function InternalChatPanelToFront(IPFclick)
{
if (IPFclick=='YES')
{button_click_log = button_click_log + "" + SQLdate + "-----InternalChatPanelToFront---|";}
var CBFPheight = '<?php echo $QLheight ?>px';
document.getElementById("CallbacksButtons").style.top = CBFPheight;
document.getElementById("CallbacksButtons").style.left = '360px';
hideDiv('FormPanel');
hideDiv('FormRefresH');
hideDiv('EmailPanel');
hideDiv('EmailRefresH');
hideDiv('CustomerChatPanel');
hideDiv('CustomerChatRefresH');
showDiv('InternalChatPanel');
document.getElementById("MainTable").style.backgroundColor="<?php echo $FORM_COLOR ?>";
document.getElementById("MaiNfooter").style.backgroundColor="<?php echo $FORM_COLOR ?>";
panel_bgcolor='<?php echo $FORM_COLOR ?>';
// document.getElementById("MainStatuSSpan").style.background = panel_bgcolor;
HidEGenDerPulldown();
}
function HidEGenDerPulldown()
{
@@ -16749,14 +17096,23 @@ $zi=2;
<table border="0" bgcolor="#FFFFFF" width="<?php echo $MNwidth ?>px" height="30px">
<tr valign="top" align="left">
<td align="left" width="115px"><a href="#" onclick="MainPanelToFront('NO','YES');"><img src="./images/<?php echo _QXZ("vdc_tab_vicidial.gif"); ?>" alt="MAIN" width="115px" height="30px" border="0" /></a></td>
<td align="left" width="90px"><a href="#" onclick="ScriptPanelToFront('YES');"><img src="./images/<?php echo _QXZ("vdc_tab_script.gif"); ?>" alt="SCRIPT" width="90px" height="30px" border="0" /></a></td>
<td align="left" width="67px"><a href="#" onclick="ScriptPanelToFront('YES');"><img src="./images/<?php echo _QXZ("vdc_tab_script.gif"); ?>" alt="SCRIPT" width="67px" height="30px" border="0" /></a></td>
<?php if ($custom_fields_enabled > 0)
{echo "<td align=\"left\" width=\"67px\"><a href=\"#\" onclick=\"FormPanelToFront('YES');\"><img src=\"./images/"._QXZ("vdc_tab_form.gif")."\" alt=\"FORM\" width=\"67px\" height=\"30px\" border=\"0\" /></a></td>\n";}
?>
<?php if ($email_enabled > 0)
{echo "<td align=\"left\" width=\"67px\"><a href=\"#\" onclick=\"EmailPanelToFront('YES');\"><img src=\"./images/"._QXZ("vdc_tab_email.gif")."\" alt=\"EMAIL\" width=\"67px\" height=\"30px\" border=\"0\" /></a></td>\n";}
?>
<td width="<?php echo $HSwidth ?>px" valign="middle" align="center"><font class="body_text">&nbsp; <span id="status"><?php echo _QXZ("LIVE"); ?></span>&nbsp; &nbsp; <?php echo _QXZ("session ID:"); ?> <span id="sessionIDspan"></span>&nbsp; &nbsp;<span id="AgentStatusCalls"></span></font></td>
<?php if ($chat_enabled > 0)
{
# INTERNAL CHAT
echo "<td align=\"left\" width=\"67px\"><a href=\"#\" onclick=\"InternalChatContentsLoad('YES');\"><img src=\"./images/"._QXZ("vdc_tab_chat_internal.gif")."\" name='InternalChatImg' alt=\"CHAT\" width=\"67px\" height=\"30px\" border=\"0\"/></a></td>\n";
# CUSTOMER CHAT
echo "<td align=\"left\" width=\"67px\"><a href=\"#\" onclick=\"CustomerChatPanelToFront('1', 'YES');\"><img src=\"./images/"._QXZ("vdc_tab_chat_customer.gif")."\" name='CustomerChatImg' alt=\"CHAT\" width=\"67px\" height=\"30px\" border=\"0\"/></a></td>\n";
}
?>
<td width="<?php echo $HSwidth ?>px" valign="middle" align="center"><font class="body_tiny">&nbsp; <span id="status"><?php echo _QXZ("LIVE"); ?></span>&nbsp; &nbsp; <?php echo _QXZ("session ID:"); ?> <span id="sessionIDspan"></span></font><br><font class="body_text">&nbsp; &nbsp;<span id="AgentStatusCalls"></span>&nbsp; &nbsp;<span id="AgentStatusEmails"></span></font></td>
<td width="109px"><img src="./images/<?php echo _QXZ("agc_live_call_OFF.gif"); ?>" name="livecall" alt="Live Call" width="109px" height="30px" border="0" /></td>
</tr>
</table>
@@ -16861,6 +17217,8 @@ $zi=2;
<input type="hidden" name="uniqueid" id="uniqueid" value="" />
<input type="hidden" name="callserverip" id="callserverip" value="" />
<input type="hidden" name="SecondS" id="SecondS" value="" />
<input type="hidden" name="email_row_id" id="email_row_id" value="" />
<input type="hidden" name="chat_id" id="chat_id" value="" />
<span class="text_input" id="MainPanelCustInfo">
<table><tr>
<td align="right"></td>
@@ -17267,6 +17625,23 @@ if ($agent_display_dialable_leads > 0)
<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="EmailContents"><iframe src="./vdc_email_display.php?lead_id=&list_id=&stage=WELCOME" style="background-color:transparent;" scrolling="auto" frameborder="0" allowtransparency="true" id="vcEmailIFrame" name="vcEmailIFrame" width="<?php echo $SDwidth ?>px" height="<?php echo $SSheight ?>px" STYLE="z-index:<?php $zi++; echo $zi ?>"> </iframe></div></font></td></tr></table>
</span>
<span style="position:absolute;left:154px;top:<?php echo $SFheight ?>px;z-index:<?php $zi++; echo $zi ?>;" id="CustomerChatPanel">
<?php
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="ChatContents"><iframe src="./vdc_chat_display.php?lead_id=&list_id=&dial_method=<?php echo $dial_method; ?>&stage=WELCOME&server_ip=<?php echo $server_ip; ?>&user=<?php echo $VD_login.$VARchatgroupsURL ?>" style="background-color:transparent;" scrolling="auto" frameborder="0" allowtransparency="true" id="CustomerChatIFrame" name="CustomerChatIFrame" width="<?php echo $SDwidth ?>px" height="<?php echo $SSheight ?>px" STYLE="z-index:<?php $zi++; echo $zi ?>"> </iframe></div></font></td></tr></table>
</span>
<span style="position:absolute;left:154px;top:<?php echo $SFheight ?>px;z-index:<?php $zi++; echo $zi ?>;" id="InternalChatPanel">
<?php
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>
</span>
<span style="position:absolute;left:<?php $tempAMwidth = ($AMwidth - 15); echo $tempAMwidth ?>px;top:<?php echo $SRheight ?>px;z-index:<?php $zi++; echo $zi ?>;" id="FormRefresH">
<a href="#" onclick="FormContentsLoad('YES')"><font class="body_small"><?php echo _QXZ("reset form"); ?></font></a>
</span>
@@ -0,0 +1,396 @@
// vicidial_chat_agent.js
//
// Copyright (C) 2014 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
// chats, ending chats, and sending messages.
//
// Builds:
// 150121-2229 - First build
//
// ################################################################################
// 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);
}
@@ -0,0 +1,57 @@
input.red_btn{
font-family: Arial, Sans-Serif;
font-size: 10px;
color:#FFFFFF;
font-weight:bold;
background-color:#990000;
border:2px solid;
border-top-color:#FFCCCC;
border-left-color:#FFCCCC;
border-right-color:#330000;
border-bottom-color:#330000;
}
input.green_btn{
font-family: Arial, Sans-Serif;
font-size: 10px;
color:#FFFFFF;
font-weight:bold;
background-color:#009900;
border:2px solid;
border-top-color:#CCFFCC;
border-left-color:#CCFFCC;
border-right-color:#003300;
border-bottom-color:#003300;
}
input.blue_btn{
font-family: Arial, Sans-Serif;
font-size: 10px;
color:#FFFFFF;
font-weight:bold;
background-color:#000099;
border:2px solid;
border-top-color:#CCCCFF;
border-left-color:#CCCCFF;
border-right-color:#000033;
border-bottom-color:#000033;
}
input.form_field {
font-family: Arial, Sans-Serif;
font-size: 10px;
margin-bottom: 3px;
padding: 2px;
border: solid 1px #000066;
}
textarea.form_field {
font-family: Arial, Sans-Serif;
font-size: 10px;
margin-bottom: 3px;
padding: 2px;
border: solid 1px #000066;
}
select.form_field {
font-family: Arial, Sans-Serif;
font-size: 10px;
margin-bottom: 3px;
padding: 2px;
border: solid 1px #000066;
}
@@ -0,0 +1,121 @@
ul.treeview, ul.treeview ul{ /*CSS for Simple Tree Menu*/
list-style-type: none;
/* background: url(images/vline.png) repeat-y; */
font-weight: bold;
margin: 0;
padding: 0;
}
ul.treeview li{ /*Style for LI elements in general (excludes an LI that contains sub lists)*/
background: white url(../images/messenger-blue-icon.png) no-repeat;
list-style-type: none;
padding-left: 15px;
margin-bottom: 2px;
cursor: hand !important;
}
.treeview li.submenu{ /* Style for LI that contains sub lists (other ULs). */
background: white url(../images/messenger-blue-icon.png) no-repeat;
color: #369;
font-weight: bold;
cursor: hand !important;
margin-bottom: 2px;
padding: 0 15px;
line-height: 15px;
}
/* .treeview li.submenu ul{ /*Style for ULs that are children of LIs (submenu) */
/*display: none; /*Hide them by default. Don't delete. */
/* } */
.treeview .submenu ul li{ /*Style for LIs of ULs that are children of LIs (submenu) */
cursor: hand;
}
ul.treeview li:last-child {
/* background: #fff url(images/lastnode.png) no-repeat; */
margin-bottom: 20px;
}
.chat_title { font-family: Arial, Helvetica, sans-serif; font-size: 11pt}
.chat_message { font-family: Arial, Helvetica, sans-serif; font-size: 10pt}
.chat_timestamp { font-family: Arial, Helvetica, sans-serif; font-size: 8pt}
.bold {font-weight: bold;}
.italics {font-style: italic;}
.alert {
font-weight: bold;
color:#FFFFFF;
background-color:#FF0000;
}
input.red_btn{
font-family: Arial, Sans-Serif;
font-size: 10px;
color:#FFFFFF;
font-weight:bold;
background-color:#990000;
border:2px solid;
border-top-color:#FFCCCC;
border-left-color:#FFCCCC;
border-right-color:#330000;
border-bottom-color:#330000;
}
input.green_btn{
font-family: Arial, Sans-Serif;
font-size: 10px;
color:#FFFFFF;
font-weight:bold;
background-color:#009900;
border:2px solid;
border-top-color:#CCFFCC;
border-left-color:#CCFFCC;
border-right-color:#003300;
border-bottom-color:#003300;
}
input.blue_btn{
font-family: Arial, Sans-Serif;
font-size: 10px;
color:#FFFFFF;
font-weight:bold;
background-color:#000099;
border:2px solid;
border-top-color:#CCCCFF;
border-left-color:#CCCCFF;
border-right-color:#000033;
border-bottom-color:#000033;
}
textarea.chat_window {
font-family: Arial, Sans-Serif;
font-size: 11px;
margin-bottom: 3px;
padding: 2px;
border: solid 1px #000066;
}
td.chat_window {
border:2px solid #000000;
padding: 5px;
vertical-align: top;
background: -webkit-linear-gradient(top, rgba(255,255,255,1) 0%, rgba(222,222,222,0) 50%, rgba(222,222,222,0) 50%, rgba(222,222,222,1) 100%);
}
input.form_field {
font-family: Arial, Sans-Serif;
font-size: 10px;
margin-bottom: 3px;
padding: 2px;
border: solid 1px #000066;
}
textarea.form_field {
font-family: Arial, Sans-Serif;
font-size: 10px;
margin-bottom: 3px;
padding: 2px;
border: solid 1px #000066;
}
select.form_field {
font-family: Arial, Sans-Serif;
font-size: 10px;
margin-bottom: 3px;
padding: 2px;
border: solid 1px #000066;
}
@@ -0,0 +1,69 @@
/* /!\ DO NOT EDIT THIS FILE !!! Please edit custom.css to keep your customizations after an upgrade /!\ */
body { padding:0; margin:0; background: #FFF; }
div.scroll_list { height: 400px; width: 140px; overflow: scroll; }
div.text_input { overflow: auto; font-size: 10px; font-family: sans-serif; }
.body_text { font-size: 13px; font-family: sans-serif; }
.queue_text_red { font-size: 12px; font-family: sans-serif; font-weight: bold; color: red; }
.queue_text { font-size: 12px; font-family: sans-serif; color: black; text-decoration:none; }
.preview_text { font-size: 13px; font-family: sans-serif; background: #CCFFCC; }
.preview_text_red { font-size: 13px; font-family: sans-serif; background: #FFCCCC; }
.body_small { font-size: 11px; font-family: sans-serif; }
.body_small_bold { font-size: 11px; font-family: sans-serif; font-weight: bold; }
.body_tiny { font-size: 10px; font-family: sans-serif; }
.log_text { font-size: 11px; font-family: monospace; }
.log_text_red { font-size: 11px; font-family: monospace; font-weight: bold; background: #FF3333; }
.log_title { font-size: 12px; font-family: monospace; font-weight: bold; }
.sd_text { font-size: 16px; font-family: sans-serif; font-weight: bold; }
.sh_text { font-size: 14px; font-family: sans-serif; font-weight: bold; }
.sb_text { font-size: 12px; font-family: sans-serif; }
.sk_text { font-size: 11px; font-family: sans-serif; }
.skb_text { font-size: 13px; font-family: sans-serif; font-weight: bold; }
.ON_conf { font-size: 11px; font-family: monospace; color: black; background: #FFFF99; }
.OFF_conf { font-size: 11px; font-family: monospace; color: black; background: #FFCC77; }
.cust_form { font-family: sans-serif; font-size: 10px; overflow: hidden; }
.cust_form_text { font-family: sans-serif; font-size: 10px; overflow: auto; }
.blink {
-webkit-animation: blink .75s linear infinite;
-moz-animation: blink .75s linear infinite;
-ms-animation: blink .75s linear infinite;
-o-animation: blink .75s linear infinite;
animation: blink .75s linear infinite;
}
@-webkit-keyframes blink {
0% { opacity: 1; }
50% { opacity: 1; }
50.01% { opacity: 0; }
100% { opacity: 0; }
}
@-moz-keyframes blink {
0% { opacity: 1; }
50% { opacity: 1; }
50.01% { opacity: 0; }
100% { opacity: 0; }
}
@-ms-keyframes blink {
0% { opacity: 1; }
50% { opacity: 1; }
50.01% { opacity: 0; }
100% { opacity: 0; }
}
@-o-keyframes blink {
0% { opacity: 1; }
50% { opacity: 1; }
50.01% { opacity: 0; }
100% { opacity: 0; }
}
@keyframes blink {
0% { opacity: 1; }
50% { opacity: 1; }
50.01% { opacity: 0; }
100% { opacity: 0; }
}
@@ -0,0 +1,26 @@
<?php
# customer_chat_code.php
#
# Copyright (C) 2015 Joe Johnson, Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# Example for incorporating the customer side of the Vicidial chat into a web page.
# Can be called as an include file, if desired.
#
# Builds:
# 151212-0829 - First Build for customer chat
#
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["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"];}
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);
?>
<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"/>
@@ -0,0 +1,203 @@
<?php
# customer_chat_functions.php
#
# CHANGES
# 151212-0828 - First Build for customer chat
# 151213-1106 - Added variable filtering
#
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");
if (isset($_GET["action"])) {$action=$_GET["action"];}
elseif (isset($_POST["action"])) {$action=$_POST["action"];}
if (isset($_GET["DB"])) {$DB=$_GET["DB"];}
elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];}
if (isset($_GET["chat_id"])) {$chat_id=$_GET["chat_id"];}
elseif (isset($_POST["chat_id"])) {$chat_id=$_POST["chat_id"];}
if (isset($_GET["chat_level"])) {$chat_level=$_GET["chat_level"];}
elseif (isset($_POST["chat_level"])) {$chat_level=$_POST["chat_level"];}
if (isset($_GET["chat_member_name"])) {$chat_member_name=$_GET["chat_member_name"];}
elseif (isset($_POST["chat_member_name"])) {$chat_member_name=$_POST["chat_member_name"];}
if (isset($_GET["chat_message"])) {$chat_message=$_GET["chat_message"];}
elseif (isset($_POST["chat_message"])) {$chat_message=$_POST["chat_message"];}
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["user_level"])) {$user_level=$_GET["user_level"];}
elseif (isset($_POST["user_level"])) {$user_level=$_POST["user_level"];}
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"];}
$chat_member_name = preg_replace('/[^- \.\,\_0-9a-zA-Z]/',"",$chat_member_name);
if (!$user) {echo "No user, no using."; exit;}
$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);
if ($non_latin < 1)
{
$user = preg_replace('/[^- \'\+\_\.0-9a-zA-Z]/','',$user);
$phone_number = preg_replace("/[^0-9]/","",$phone_number);
}
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];
if ($action=="send_message" && $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";
} 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_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_rslt=mysql_to_mysqli($ins_stmt, $link);
if (mysqli_affected_rows($link)<1) {
echo "<font class='chat_title alert'>SYSTEM ERROR</font><BR/>\n";
}
}
} else {
echo "<font class='chat_title alert'>SYSTEM ERROR</font><BR/>\n";
}
}
} else if (mysqli_num_rows($rslt)==0) {
echo "Chat $chat_id has been closed";
}
}
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_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'
$rslt=mysql_to_mysqli($stmt, $link);
if (mysqli_num_rows($rslt)>0) {
$row=mysqli_fetch_row($rslt);
$lead_id=$row[0];
$chat_status=$row[1];
$chat_creator=$row[2];
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_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_rslt=mysql_to_mysqli($ins_stmt, $link);
$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_rslt=mysql_to_mysqli($ins_alert_stmt, $link);
}
}
}
}
if ($action=="update_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/><BR/><font class='chat_title'><a href='".$chat_url."'>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_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_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";
# Create color-coding for chat
$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();
while ($row=mysqli_fetch_row($rslt)) {
if (!in_array("$row[4]", $chat_members)) {
array_push($chat_members, "$row[4]");
}
}
## 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";
$rslt=mysql_to_mysqli($stmt, $link);
while ($row=mysqli_fetch_row($rslt)) {
$chat_color_key=array_search("$row[4]", $chat_members);
$row[2]=preg_replace('/\n/', '<BR/>', $row[2]);
echo "<li><font color='$color_array[$chat_color_key]' class='chat_message bold'>$row[5]</font> <font class='chat_timestamp bold'>($row[3])</font> - <font class='chat_message ".$style_array[$row[6]]."'>$row[2]</font></li>\n";
}
## PLAY AUDIO FILE IF THERE ARE NEW MESSAGES
$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'>You have left chat $chat_id.</font><BR/><BR/><font class='chat_title'><a href='".$chat_url."'>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";
} else {
echo "<font class='chat_title alert'>SYSTEM ERROR</font><BR/>\n";
}
}
}
}
?>
@@ -0,0 +1,88 @@
<?php
#
# dbconnect_mysqli.php version 2.12
#
# database connection settings and some global web settings
#
# Copyright (C) 2015 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# CHANGES:
# 151212-0827 - First Build for customer chat
#
if ( file_exists("/etc/astguiclient.conf") )
{
$DBCagc = file("/etc/astguiclient.conf");
foreach ($DBCagc as $DBCline)
{
$DBCline = preg_replace("/ |>|\n|\r|\t|\#.*|;.*/","",$DBCline);
if (preg_match("/^PATHlogs/", $DBCline))
{$PATHlogs = $DBCline; $PATHlogs = preg_replace("/.*=/","",$PATHlogs);}
if (preg_match("/^PATHweb/", $DBCline))
{$WeBServeRRooT = $DBCline; $WeBServeRRooT = preg_replace("/.*=/","",$WeBServeRRooT);}
if (preg_match("/^VARserver_ip/", $DBCline))
{$WEBserver_ip = $DBCline; $WEBserver_ip = preg_replace("/.*=/","",$WEBserver_ip);}
if (preg_match("/^VARDB_server/", $DBCline))
{$VARDB_server = $DBCline; $VARDB_server = preg_replace("/.*=/","",$VARDB_server);}
if (preg_match("/^VARDB_database/", $DBCline))
{$VARDB_database = $DBCline; $VARDB_database = preg_replace("/.*=/","",$VARDB_database);}
if (preg_match("/^VARDB_user/", $DBCline))
{$VARDB_user = $DBCline; $VARDB_user = preg_replace("/.*=/","",$VARDB_user);}
if (preg_match("/^VARDB_pass/", $DBCline))
{$VARDB_pass = $DBCline; $VARDB_pass = preg_replace("/.*=/","",$VARDB_pass);}
if (preg_match('/^VARDB_custom_user/', $DBCline))
{$VARDB_custom_user = $DBCline; $VARDB_custom_user = preg_replace("/.*=/","",$VARDB_custom_user);}
if (preg_match('/^VARDB_custom_pass/', $DBCline))
{$VARDB_custom_pass = $DBCline; $VARDB_custom_pass = preg_replace("/.*=/","",$VARDB_custom_pass);}
if (preg_match("/^VARDB_port/", $DBCline))
{$VARDB_port = $DBCline; $VARDB_port = preg_replace("/.*=/","",$VARDB_port);}
if (preg_match("/^ExpectedDBSchema/", $DBCline))
{$ExpectedDBSchema = $DBCline; $ExpectedDBSchema = preg_replace("/.*=/","",$ExpectedDBSchema);}
}
}
else
{
#defaults for DB connection
$VARDB_server = 'localhost';
$VARDB_port = '3306';
$VARDB_user = 'cron';
$VARDB_pass = '1234';
$VARDB_custom_user = 'custom';
$VARDB_custom_pass = 'custom1234';
$VARDB_database = '1234';
$WeBServeRRooT = '/srv/www/htdocs';
}
$server_string = $VARDB_server;
if ( ($use_slave_server > 0) and (strlen($slave_db_server)>1) )
{
if (preg_match("/\:/", $slave_db_server))
{
$temp_slave_db = explode(':',$slave_db_server);
$server_string = $temp_slave_db[0];
$VARDB_port = $temp_slave_db[1];
}
else
{
$server_string = $slave_db_server;
}
}
$link=mysqli_connect($server_string, "$VARDB_user", "$VARDB_pass", "$VARDB_database", $VARDB_port);
if (!$link)
{
die("MySQL connect ERROR: " . mysqli_connect_error());
}
$local_DEF = 'Local/';
$conf_silent_prefix = '7';
$local_AMP = '@';
$ext_context = 'default';
$recording_exten = '8309';
$WeBRooTWritablE = '1';
# $non_latin = '0'; # set to 1 for UTF rules, overridden by system_settings
$flag_channels=0;
$flag_string = 'VICIast20';
?>
File diff suppressed because it is too large Load Diff
Binary file not shown.

After

Width:  |  Height:  |  Size: 594 B

@@ -0,0 +1,499 @@
<?php
# vicidial_chat_customer_side.php
#
# Copyright (C) 2015 Joe Johnson, Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# The main page of the customer chat interface. This will display a form for the customer
# to fill out to attempt to initiate a chat with an available agent in the in-group
# ("department") of their choice.
#
# Builds:
# 150902-2100 - First build
# 151212-0830 - First Build for customer chat
# 151213-1105 - Added variable filtering
#
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"];}
elseif (isset($_POST["last_name"])) {$last_name=$_POST["last_name"];}
if (isset($_GET["group_id"])) {$group_id=$_GET["group_id"];}
elseif (isset($_POST["group_id"])) {$group_id=$_POST["group_id"];}
if (isset($_GET["phone_number"])) {$phone_number=$_GET["phone_number"];}
elseif (isset($_POST["phone_number"])) {$phone_number=$_POST["phone_number"];}
if (isset($_GET["send_request"])) {$send_request=$_GET["send_request"];}
elseif (isset($_POST["send_request"])) {$send_request=$_POST["send_request"];}
if (isset($_GET["email"])) {$email=$_GET["email"];}
elseif (isset($_POST["email"])) {$email=$_POST["email"];}
if (isset($_GET["join_chat"])) {$join_chat=$_GET["join_chat"];}
elseif (isset($_POST["join_chat"])) {$join_chat=$_POST["join_chat"];}
if (isset($_GET["chat_id"])) {$chat_id=$_GET["chat_id"];}
elseif (isset($_POST["chat_id"])) {$chat_id=$_POST["chat_id"];}
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"];}
$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);
if ($non_latin < 1)
{
$user = preg_replace('/[^- \'\+\_\.0-9a-zA-Z]/','',$user);
$first_name = preg_replace('/[^- \'\+\_\.0-9a-zA-Z]/','',$first_name);
$first_name = preg_replace('/\+/',' ',$first_name);
$last_name = preg_replace('/[^- \'\+\_\.0-9a-zA-Z]/','',$last_name);
$last_name = preg_replace('/\+/',' ',$last_name);
$email = preg_replace('/[^- \'\+\.\:\/\@\%\_0-9a-zA-Z]/','',$email);
$email = preg_replace('/\+/',' ',$email);
$phone_number = preg_replace("/[^0-9]/","",$phone_number);
}
else
{
$user = preg_replace("/\'|\"|\\\\|;/","",$user);
}
# 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.
$error_msg="";
if (!$first_name || !$last_name) {
$error_msg="Please enter your first and last name";
} else {
$chat_member_name="$first_name $last_name";
$ip_address=$_SERVER['REMOTE_ADDR'];
$user=time().".".rand(10000,99999);
# 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";
# update email and security_phrase?
$upd_rslt=mysql_to_mysqli($upd_stmt, $link);
# Private message
$alert_stmt="select chat_creator from vicidial_live_chats where chat_id='$chat_id' and lead_id='$lead_id'";
$alert_rslt=mysql_to_mysqli($alert_stmt, $link);
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_rslt=mysql_to_mysqli($ins_alert_stmt, $link);
}
} else {
if ($phone_number) {
$stmt="select lead_id from vicidial_list where phone_number='$phone_number' order by entry_date desc limit 1";
$rslt=mysql_to_mysqli($stmt, $link);
} else if ($email) {
$stmt="select lead_id from vicidial_list where email='$email' order by entry_date desc limit 1";
$rslt=mysql_to_mysqli($stmt, $link);
} else {
$stmt="select lead_id from vicidial_list where email like '%".$ip_address."%' order by entry_date desc limit 1";
$rslt=mysql_to_mysqli($stmt, $link);
}
if (mysqli_num_rows($rslt)>0) {
$row=mysqli_fetch_row($rslt);
$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";
# 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_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";
} else {
$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);
}
}
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_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_rslt=mysql_to_mysqli($del_stmt, $link);
$error_msg="Chat started, failure to join";
unset($chat_id);
} else {
# echo "$chat_id|$lead_id|$ins_stmt";
}
} else {
$error_msg="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
$error_msg="";
if (!$first_name || !$last_name) {$error_msg="Please enter your first and last name";}
$chat_member_name="$first_name $last_name";
$ip_address=$_SERVER['REMOTE_ADDR'];
$user=time().".".rand(10000,99999);
# SEARCH FOR CUSTOMER IN DATABASE - IF NOT FOUND BY PHONE OR IP ADDRESS MAKE A NEW USER
if ($phone_number) {
$stmt="select lead_id from vicidial_list where phone_number='$phone_number' order by entry_date desc limit 1";
$rslt=mysql_to_mysqli($stmt, $link);
} else {
$stmt="select lead_id from vicidial_list where email like '%".$ip_address."%' order by entry_date desc limit 1";
$rslt=mysql_to_mysqli($stmt, $link);
}
if (mysqli_num_rows($rslt)>0) {
$row=mysqli_fetch_row($rslt);
$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";
# 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_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";
}
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_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_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_rslt=mysql_to_mysqli($del_stmt, $link);
$error_msg="Chat started, failure to join";
unset($chat_id);
} else {
# echo "$chat_id|$lead_id|$ins_stmt";
}
} else {
$error_msg="Chat not started - $ins_stmt";
}
}
}
?>
<html>
<title><?php echo $error_msg; ?></title>
<head>
<link rel="stylesheet" type="text/css" href="css/style.css" />
<link rel="stylesheet" type="text/css" href="css/custom.css" />
<link rel="stylesheet" type="text/css" href="css/simpletree.css" />
<script language="Javascript">
function PleaseWait() {
document.getElementById('chat_request_span').style.display="none";
document.getElementById('please_wait_span').style.display="block";
RequestChat();
}
function ResetScreen() {
document.getElementById('chat_request_span').style.display="block";
document.getElementById('please_wait_span').style.display="none";
}
function LeaveChat(chat_id, user, chat_member_name) {
if (!chat_id)
{
var chat_id=document.getElementById('chat_id').value;
}
if (!user)
{
var user=document.getElementById('user').value;
}
if (!chat_member_name)
{
var chat_member_name=document.getElementById('chat_member_name').value;
}
var xmlhttp=false;
if (!xmlhttp && typeof XMLHttpRequest!='undefined')
{
xmlhttp = new XMLHttpRequest();
}
if (xmlhttp)
{
chat_query = "&action=leave_chat&chat_id="+chat_id+"&user="+user+"&chat_member_name="+chat_member_name;
// alert(chat_query);
xmlhttp.open('POST', 'customer_chat_functions.php');
xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8');
xmlhttp.send(chat_query);
xmlhttp.onreadystatechange = function()
{
if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
{
//if (chat_creator==user) {EndChat();}
}
}
delete xmlhttp;
}
}
function StartRefresh() {
rInt=window.setInterval(function() {UpdateChatWindow()}, 1000);
}
function UpdateChatWindow() {
var chat_id=document.getElementById('chat_id').value;
// var chat_creator=document.getElementById('chat_creator').value;
var user=document.getElementById('user').value;
var current_message_field = document.getElementById('current_message_count');
if (current_message_field == null) {var current_message_count=0;} else {var current_message_count=current_message_field.value;}
if (chat_id)
{
var xmlhttp=false;
if (!xmlhttp && typeof XMLHttpRequest!='undefined')
{
xmlhttp = new XMLHttpRequest();
}
if (xmlhttp)
{
chat_query = "&chat_id="+chat_id+"&user="+user+"&current_message_count="+current_message_count+"&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);
xmlhttp.onreadystatechange = function()
{
if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
{
var fullchatlog = xmlhttp.responseText;
document.getElementById('ChatDisplay').innerHTML=fullchatlog;
var current_message_field_update = document.getElementById('current_message_count');
if (current_message_field_update != null) {var current_message_count_update=current_message_field_update.value;}
if (current_message_count_update>current_message_count && !document.getElementById("MuteCustomerChatAlert").checked) {document.getElementById("CustomerChatAudioAlertFile").play();}
}
}
delete xmlhttp;
}
}
}
function CustomerSendMessage(chat_id, user, message, chat_member_name) {
var chat_id=document.getElementById('chat_id').value;
var user=document.getElementById('user').value;
var chat_message=encodeURIComponent(document.getElementById('chat_message').value.trim());
var chat_member_name=encodeURIComponent(document.getElementById('chat_member_name').value.trim());
if (!chat_message || !user) {return false;}
if (!chat_member_name) {alert("Please enter a name to chat as.");}
if (!chat_id) {alert("You have not joined a chat yet.");}
document.getElementById('chat_message').value='';
var xmlhttp=false;
if (!xmlhttp && typeof XMLHttpRequest!='undefined')
{
xmlhttp = new XMLHttpRequest();
}
if (xmlhttp)
{
chat_query = "&chat_message="+chat_message+"&chat_id="+chat_id+"&chat_member_name="+chat_member_name+"&user="+user+"&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);
xmlhttp.onreadystatechange = function()
{
if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
{
var posting_response = xmlhttp.responseText;
if (posting_response)
{
// alert(posting_response);
}
else
{
UpdateChatWindow();
}
}
}
delete xmlhttp;
}
}
</script>
</head>
<?php
if (!$chat_id) {
$chat_title="Request chat with agent"; # This can be modified for customization later
?>
<body>
<form action="<?php echo $PHP_SELF; ?>" method="post">
<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='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'>Select the department you wish to chat with:</td>
<td align='left'>
<select name='group_id' id='group_id' class="cust_form">
<?php
$group_stmt="select group_id, group_name from vicidial_inbound_groups where active='Y' and group_handling='CHAT' order by group_name asc";
$group_rslt=mysql_to_mysqli($group_stmt, $link);
while ($row=mysqli_fetch_row($group_rslt)) {
echo "<option value='$row[0]'>$row[1]</option>\n";
}
?>
</select>
</td>
</tr>
<tr>
<td align='right' class='body_small'>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>
</tr>
<?php
if ($error_msg) {
echo "<tr><th colspan='2' class='queue_text_red'>$error_msg<BR></th></tr>";
}
?>
</table>
</span>
</form>
</body>
<?
} else if ($chat_id && $group_id && (!$first_name || !$last_name)) {
?>
<body>
<form action="<?php echo $PHP_SELF; ?>" method="post">
<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='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='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>
</tr>
<?php
if ($error_msg) {
echo "<tr><th colspan='2' class='queue_text_red'>$error_msg<BR></th></tr>";
}
?>
</table>
</span>
<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; ?>">
</form>
</body>
<?
} else {
?>
<body onLoad="StartRefresh();" onUnload="javascript:clearInterval(rInt); LeaveChat();">
<form name='chat_form' action='<?php echo $PHP_SELF; ?>'>
<table width='100%' border='0'>
<tr>
<td class='chat_window' height='250' width='100%'>
<span id='ChatDisplay' name='ChatDisplay' style=" overflow-y: auto; overflow-x: none;">
</span>
</td>
</tr>
<tr>
<td align='center'>
<table width='400' align='center' border='0' cellpadding='0' cellspacing='0'>
<tr>
<td align='center' colspan='2'>
<textarea border='1' name='chat_message' id='chat_message' class='chat_window' cols='86' rows='4' onkeypress="if (event.keyCode==13 && !event.shiftKey) {CustomerSendMessage(this.form.chat_id.value, this.form.user.value, this.form.chat_message.value); return false;}"></textarea>
</td>
</tr>
<tr>
<td align='left' class='chat_message' valign='top'><input class='blue_btn' type='button' style="width:100px" value="<?php echo _QXZ("SEND MESSAGE"); ?>" onClick="CustomerSendMessage(this.form.chat_id.value, this.form.user.value, this.form.chat_message.value)"></td>
<td align='right' valign='top'><input class='blue_btn' type='button' style="width:100px" value="<?php echo _QXZ("CLEAR"); ?>" onClick="document.getElementById('chat_message').value=''"></td>
</tr>
<tr>
<td class='chat_message' valign='top' align='left'><BR>
<input type='checkbox' id='MuteCustomerChatAlert' name='MuteCustomerChatAlert'>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)"
</td>
</tr>
</table>
</td>
</tr>
<?php
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; ?>">
<input type="hidden" id="chat_member_name" name="chat_member_name" value="<?php echo $chat_member_name; ?>">
<input type="hidden" id="chat_id" name="chat_id" value="<?php echo $chat_id; ?>">
<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; ?>">
<audio id='CustomerChatAudioAlertFile'><source src="sounds/chat_alert.mp3" type="audio/mpeg"></audio>
</form>
</body>
<?
}
?>
</html>
@@ -3,7 +3,7 @@
#
# Copyright (C) 2015 Matt Florell <vicidial@gmail.com>, Joe Johnson <freewermadmin@gmail.com> LICENSE: AGPLv2
#
# This is the report page where you can view report informatio of any of the dialer's chats. The web page will
# This is the report page where you can view report information of any of the dialer's chats. The web page will
# display the information about the chat, including the start time and participants, and will also provide links
# allowing you to download transcripts of any chat you wish, based on your account permissions.
#
@@ -988,5 +988,3 @@ else
exit;
?>
+2 -1
View File
@@ -55,6 +55,7 @@
# 150808-2043 - Added compatibility for custom fields data option
# 151020-0654 - Added Status Groups
# 151203-1922 - Fix for javascript timezone issues in editing of timeclock entries
# 151212-0858 - Added Chat link at top of page
#
@@ -1668,7 +1669,7 @@ $SSenable_languages = $row[7];
</span>
<TABLE BGCOLOR=#D9E6FE cellpadding=2 cellspacing=0 WIDTH=<?php echo $page_width ?> HEIGHT=15>
<TR BGCOLOR=#015B91><TD ALIGN=LEFT BGCOLOR=#015B91><FONT FACE="ARIAL,HELVETICA" COLOR=WHITE SIZE=2><B><a href="<?php echo $admin_home_url_LU ?>"><FONT FACE="ARIAL,HELVETICA" COLOR=WHITE SIZE=1><?php echo _QXZ("HOME"); ?></a> | <A HREF="../agc/timeclock.php?referrer=admin"><FONT FACE="ARIAL,HELVETICA" COLOR=WHITE SIZE=1> <?php echo _QXZ("Timeclock"); ?></A> | <a href="<?php echo $ADMIN ?>?force_logout=1"><FONT FACE="ARIAL,HELVETICA" COLOR=WHITE SIZE=1><?php echo _QXZ("Logout"); ?></a> <FONT FACE="ARIAL,HELVETICA" COLOR=WHITE SIZE=1>(<?php echo $PHP_AUTH_USER ?>)</FONT>
<TR BGCOLOR=#015B91><TD ALIGN=LEFT BGCOLOR=#015B91><FONT FACE="ARIAL,HELVETICA" COLOR=WHITE SIZE=2><B><a href="<?php echo $admin_home_url_LU ?>"><FONT FACE="ARIAL,HELVETICA" COLOR=WHITE SIZE=1><?php echo _QXZ("HOME"); ?></a> | <A HREF="../agc/timeclock.php?referrer=admin"><FONT FACE="ARIAL,HELVETICA" COLOR=WHITE SIZE=1> <?php echo _QXZ("Timeclock"); ?></A> | <a href="manager_chat_interface.php"><FONT FACE="ARIAL,HELVETICA" COLOR=WHITE SIZE=1> <?php echo _QXZ("Chat"); ?></a> | <a href="<?php echo $ADMIN ?>?force_logout=1"><FONT FACE="ARIAL,HELVETICA" COLOR=WHITE SIZE=1><?php echo _QXZ("Logout"); ?></a> <FONT FACE="ARIAL,HELVETICA" COLOR=WHITE SIZE=1>(<?php echo $PHP_AUTH_USER ?>)</FONT>
<?php
if ($SSenable_languages == '1')
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

@@ -0,0 +1,298 @@
<?php
# manager_chat_actions.php
#
# Copyright (C) 2015 Joe Johnson, Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# Contains PHP actions for manager_chat_interface.php - works with vicidial_chat.js
#
# changes:
# 150605-2022 First Build
# 151213-1114 - Added variable filtering
#
$admin_version = '2.12-2';
$build = '151213-1114';
$sh="managerchats";
require("dbconnect_mysqli.php");
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["user"])) {$user=$_GET["user"];}
elseif (isset($_POST["user"])) {$user=$_POST["user"];}
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["chat_sub_id"])) {$chat_sub_id=$_GET["chat_sub_id"];}
elseif (isset($_POST["chat_sub_id"])) {$chat_sub_id=$_POST["chat_sub_id"];}
if (isset($_GET["chat_sub_ids"])) {$chat_sub_ids=$_GET["chat_sub_ids"];}
elseif (isset($_POST["chat_sub_ids"])) {$chat_sub_ids=$_POST["chat_sub_ids"];}
if (isset($_GET["chat_message"])) {$chat_message=$_GET["chat_message"];}
elseif (isset($_POST["chat_message"])) {$chat_message=$_POST["chat_message"];}
if (isset($_GET["reload_chat_span"])) {$reload_chat_span=$_GET["reload_chat_span"];}
elseif (isset($_POST["reload_chat_span"])) {$reload_chat_span=$_POST["reload_chat_span"];}
if (isset($_GET["action"])) {$action=$_GET["action"];}
elseif (isset($_POST["action"])) {$action=$_POST["action"];}
#############################################
##### START SYSTEM_SETTINGS LOOKUP #####
$stmt = "SELECT use_non_latin,allow_chats 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];
}
##### END SETTINGS LOOKUP #####
###########################################
if ($non_latin < 1)
{
$PHP_AUTH_USER = preg_replace("/[^-_0-9a-zA-Z]/", "",$PHP_AUTH_USER);
$PHP_AUTH_PW = preg_replace("/[^-_0-9a-zA-Z]/", "",$PHP_AUTH_PW);
$user = preg_replace("/[^-_0-9a-zA-Z]/", "",$user);
} # end of non_latin
else
{
$PHP_AUTH_USER = preg_replace("/'|\"|\\\\|;/","",$PHP_AUTH_USER);
$PHP_AUTH_PW = preg_replace("/'|\"|\\\\|;/","",$PHP_AUTH_PW);
$user = preg_replace("/'|\"|\\\\|;/","",$user);
}
$auth=0;
$auth_message = user_authorization($PHP_AUTH_USER,$PHP_AUTH_PW,'',1);
if ($auth_message == 'GOOD')
{$auth=1;}
if ($auth < 1)
{
$VDdisplayMESSAGE = _QXZ("Login incorrect, please try again");
if ($auth_message == 'LOCK')
{
$VDdisplayMESSAGE = _QXZ("Too many login attempts, try again in 15 minutes");
Header ("Content-type: text/html; charset=utf-8");
echo "$VDdisplayMESSAGE: |$PHP_AUTH_USER|$auth_message|\n";
exit;
}
Header("WWW-Authenticate: Basic realm=\"CONTACT-CENTER-ADMIN\"");
Header("HTTP/1.0 401 Unauthorized");
echo "$VDdisplayMESSAGE: |$PHP_AUTH_USER|$PHP_AUTH_PW|$auth_message|\n";
exit;
}
$chat_sub_id_ct=count($chat_sub_ids);
$debug=0;
if ($action=="EndAgentChat") {
$archive_stmt="insert ignore into vicidial_manager_chat_log_archive select * from vicidial_manager_chat_log where manager_chat_id='$manager_chat_id' and manager_chat_subid='$chat_sub_id'";
$archive_rslt=mysqli_query($link, $archive_stmt);
if ($debug==1) {echo "$archive_stmt<BR>\n";}
$delete_stmt="delete from vicidial_manager_chat_log where manager_chat_id='$manager_chat_id' and manager_chat_subid='$chat_sub_id'";
$delete_rslt=mysqli_query($link, $delete_stmt);
if ($debug==1) {echo "$delete_stmt<BR>\n";}
$count_stmt="select count(*) from vicidial_manager_chat_log where manager_chat_id='$manager_chat_id'";
if ($debug==1) {echo "$count_stmt<BR>\n";}
$count_rslt=mysqli_query($link, $count_stmt);
$count_row=mysqli_fetch_row($count_rslt);
$active_chats=$count_row[0];
if ($active_chats==0) {
$archive_stmt="insert ignore into vicidial_manager_chats_archive select * from vicidial_manager_chats where manager_chat_id='$manager_chat_id'";
$archive_rslt=mysqli_query($link, $archive_stmt);
$del_stmt="delete from vicidial_manager_chats where manager_chat_id='$manager_chat_id'";
$del_rslt=mysqli_query($link, $del_stmt);
$manager_chat_id="";
echo "ALL CHATS CLOSED";
exit;
}
$reload_chat_span=1;
}
if ($action=="CheckNewMessages") {
$time_stmt="select distinct manager_chat_subid from vicidial_manager_chat_log where manager_chat_id='$manager_chat_id' and message_date>=now()-INTERVAL 6 SECOND";
$time_rslt=mysqli_query($link, $time_stmt);
# echo $time_stmt;
if (mysqli_num_rows($time_rslt)==0) {
echo "0";
} else {
$sub_id_str="";
while ($row=mysqli_fetch_row($time_rslt)) {
$sub_id_str.="$row[0]\n";
}
echo $sub_id_str;
}
}
if ($action=="PrintSubChatText") {
for ($i=0; $i<$chat_sub_id_ct; $i++) {
$chat_sub_id=$chat_sub_ids[$i];
$span_name="manager_chat_".$manager_chat_id."_".$chat_sub_id;
$stmt="select vm.message_posted_by, vm.message, vm.message_date, vu.full_name, vm.manager, vm.manager_chat_subid 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.manager_chat_subid='$chat_sub_id' and vm.user=vu.user order by vm.manager_chat_subid asc, message_date desc";
if ($debug==1) {echo "$stmt<BR>\n";}
$rslt=mysqli_query($link, $stmt);
if (mysqli_num_rows($rslt)>0) {
$prev_chat_subid="";
$backlog_limit=20;
$chat_output_text="";
while($row=mysqli_fetch_row($rslt)) {
if ($backlog_limit>0) {
if ($row[0]==$row[4]) {$fc="#990000";} else {$fc="#000099";}
$chat_output_text="<font color='$fc' FACE=\"ARIAL,HELVETICA\" size='1'>$row[1]</font><BR>".$chat_output_text;
$backlog_limit--;
}
}
echo $span_name."\n".$chat_output_text."\n";
}
}
}
if ($action=="SendChatMessage" && $chat_message) {
$chat_message = preg_replace("/\r/i",'',$chat_message);
$chat_message = preg_replace("/\n/i",' ',$chat_message);
$ins_chat_stmt="insert into vicidial_manager_chat_log(manager_chat_id, manager_chat_subid, manager, user, message, message_date, message_posted_by) VALUES('$manager_chat_id', '$chat_sub_id', '$PHP_AUTH_USER', '$user', '".mysqli_real_escape_string($link, $chat_message)."', now(), '$PHP_AUTH_USER')";
$ins_chat_rslt=mysqli_query($link, $ins_chat_stmt);
if (mysqli_insert_id($link)>0) {
$reload_chat_span=1;
} else {
echo "Error sending message.";
}
}
if ($reload_chat_span) {
if (!$manager_chat_id) {
$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();
$user_group_array=array();
$campaign_id_array=array();
while ($row=mysqli_fetch_row($rslt)) {
if (!in_array("$row[0]", $user_array)) {$user_array[$row[0]]="$row[1]";}
if (!in_array("$row[2]", $user_group_array)) {$user_group_array["$row[2]"]="$row[5]";}
if (!in_array("$row[3]", $campaign_id_array)) {$campaign_id_array["$row[3]"]="$row[4]";}
}
asort($user_array);
asort($user_group_array);
asort($campaign_id_array);
echo "<TABLE width=750 cellspacing=1 cellpadding=1>\n";
echo "<TR><TD align='left' class='arial'>"._QXZ("VICIDIAL Manager Chat Interface").":</TD><TD align='right' class='arial_bold'><a link='#FFFF00' vlink='#FFFF00' href='manager_chat_interface.php'>["._QXZ("RELOAD")."]</a></TD></TR>";
echo "<TR BGCOLOR=BLACK>\n";
echo "<TD><font size=1 color=white width='50%'>"._QXZ("CURRENT LIVE AGENTS")."</TD>\n";
echo "<TD><font size=1 color=white width='50%'>"._QXZ("CURRENT LIVE CAMPAIGNS")."</TD></tr>\n";
echo "<TR BGCOLOR='#E6E6E6'>";
echo "<TD rowspan=3 valign='top'>";
echo "<select name='available_chat_agents[]' multiple size='12' style=\"width:350px\">\n";
if (count($user_array)==0) {echo "<option value=''>---- "._QXZ("NO LIVE AGENTS")." ----</option>";}
while (list($user, $full_name) = each($user_array)) {
echo "<option value='$user'>$user - $full_name</option>\n";
}
echo "</select>\n";
echo "</TD>";
echo "<TD valign='top'>";
echo "<select name='available_chat_campaigns[]' multiple size='5' style=\"width:350px\">\n";
if (count($campaign_id_array)==0) {echo "<option value=''>---- "._QXZ("NO LIVE CAMPAIGNS")." ----</option>";}
while (list($campaign_id, $campaign_name) = each($campaign_id_array)) {
echo "<option value='$campaign_id'>$campaign_id - $campaign_name</option>\n";
}
echo "</select>\n";
echo "</TD>";
echo "<TR BGCOLOR=BLACK>";
echo "<TD><font size=1 color=white>"._QXZ("CURRENT LIVE USER GROUPS")."</TD>\n";
echo "</TR>";
echo "<TR BGCOLOR='#E6E6E6'>";
echo "<TD valign='top'>";
echo "<select name='available_chat_groups[]' multiple size='5' style=\"width:350px\">\n";
if (count($user_group_array)==0) {echo "<option value=''>---- "._QXZ("NO LIVE USER GROUPS")." ----</option>";}
while (list($user_group, $group_name) = each($user_group_array)) {
echo "<option value='$user_group'>$user_group - $group_name</option>\n";
}
echo "</select>\n";
echo "</TD>";
echo "</TR>";
echo "</table>";
} 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 "</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 "</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) {
$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)) {
$full_name=$row[3];
$chat_subid=$row[5];
$chat_subids_array.="'$chat_subid',";
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) {
$agent_id=$row[6];
if ($bgcolor=="#E6E6E6") {$bgcolor="#FFFFFF";} else {$bgcolor="#E6E6E6";}
$chat_output_header[$chat_subid]= "<TR BGCOLOR='$bgcolor'>\n";
$chat_output_header[$chat_subid].="\t<td width='100' align='left'><font FACE=\"ARIAL,HELVETICA\" size='1'>$full_name</font></td>";
$chat_output_header[$chat_subid].="\t<td width='325' align='left' valign='top'><div class='scrolling' id='manager_chat_".$manager_chat_id."_".$chat_subid."'>";
$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].="</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)) {
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 {
$reload_function="setInterval(\"RefreshChatDisplay()\", 30000);\n";
}
echo "</table>";
echo "<script language=\"JavaScript\">\n";
echo "$reload_function";
echo "</script>\n";
}
}
?>
@@ -0,0 +1,487 @@
<?php
# manager_chat_interface.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
# 150909-0118 - Bug fixes, added feature to submit messages when Enter is pressed
#
$admin_version = '2.12-1';
$build = '150909-0118';
$sh="managerchats";
require("dbconnect_mysqli.php");
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["allow_replies"])) {$allow_replies=$_GET["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"];}
if (isset($_GET["submit_chat"])) {$submit_chat=$_GET["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;";
$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];
$SSenable_queuemetrics_logging = $row[1];
$SSenable_vtiger_integration = $row[2];
$SSqc_features_active = $row[3];
$SSoutbound_autodial_active = $row[4];
$SSsounds_central_control_active = $row[5];
$SSenable_second_webform = $row[6];
$SSuser_territories_active = $row[7];
$SScustom_fields_enabled = $row[8];
$SSadmin_web_directory = $row[9];
$SSwebphone_url = $row[10];
$SSfirst_login_trigger = $row[11];
$SShosted_settings = $row[12];
$SSdefault_phone_registration_password =$row[13];
$SSdefault_phone_login_password = $row[14];
$SSdefault_server_password = $row[15];
$SStest_campaign_calls = $row[16];
$SSactive_voicemail_server = $row[17];
$SSvoicemail_timezones = $row[18];
$SSdefault_voicemail_timezone = $row[19];
$SSdefault_local_gmt = $row[20];
$SScampaign_cid_areacodes_enabled = $row[21];
$SSpllb_grouping_limit = $row[22];
$SSdid_ra_extensions_enabled = $row[23];
$SSexpanded_list_stats = $row[24];
$SScontacts_enabled = $row[25];
$SSalt_log_server_ip = $row[26];
$SSalt_log_dbname = $row[27];
$SSalt_log_login = $row[28];
$SSalt_log_pass = $row[29];
$SStables_use_alt_log_db = $row[30];
$SSallow_emails = $row[31];
$SSemail_enabled = $row[32];
$SSlevel_8_disable_add = $row[33];
$SSallow_chats = $row[34];
}
##### END SETTINGS LOOKUP #####
###########################################
if ($non_latin < 1)
{
$PHP_AUTH_USER = preg_replace("/[^-_0-9a-zA-Z]/", "",$PHP_AUTH_USER);
$PHP_AUTH_PW = preg_replace("/[^-_0-9a-zA-Z]/", "",$PHP_AUTH_PW);
} # end of non_latin
else
{
$PHP_AUTH_USER = preg_replace("/'|\"|\\\\|;/","",$PHP_AUTH_USER);
$PHP_AUTH_PW = preg_replace("/'|\"|\\\\|;/","",$PHP_AUTH_PW);
}
$list_id = preg_replace("/[^0-9]/","",$list_id);
$STARTtime = date("U");
$TODAY = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
$date = date("r");
$ip = getenv("REMOTE_ADDR");
$browser = getenv("HTTP_USER_AGENT");
$user = $PHP_AUTH_USER;
$add_copy_disabled=0;
$auth=0;
$auth_message = user_authorization($PHP_AUTH_USER,$PHP_AUTH_PW,'',1);
if ($auth_message == 'GOOD')
{$auth=1;}
if ($auth < 1)
{
$VDdisplayMESSAGE = _QXZ("Login incorrect, please try again");
if ($auth_message == 'LOCK')
{
$VDdisplayMESSAGE = _QXZ("Too many login attempts, try again in 15 minutes");
Header ("Content-type: text/html; charset=utf-8");
echo "$VDdisplayMESSAGE: |$PHP_AUTH_USER|$auth_message|\n";
exit;
}
Header("WWW-Authenticate: Basic realm=\"CONTACT-CENTER-ADMIN\"");
Header("HTTP/1.0 401 Unauthorized");
echo "$VDdisplayMESSAGE: |$PHP_AUTH_USER|$PHP_AUTH_PW|$auth_message|\n";
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);
$archive_stmt="insert ignore into vicidial_manager_chats_archive select * from vicidial_manager_chats where manager_chat_id='$end_all_chats'";
$archive_rslt=mysqli_query($link, $archive_stmt);
$delete_stmt="delete from vicidial_manager_chat_log where manager_chat_id='$end_all_chats'";
$delete_rslt=mysqli_query($link, $delete_stmt);
$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") {
$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) {
$i=0;
$available_chat_agents_string='|';
$available_chat_agents_ct = count($available_chat_agents);
$chat_agents_SQL_OR="vicidial_live_agents.user in ('',";
while($i < $available_chat_agents_ct)
{
$available_chat_agents_string .= "$available_chat_agents[$i]|";
$chat_agents_SQL_OR.="'$available_chat_agents[$i]',";
$i++;
}
$chat_agents_SQL_OR=substr($chat_agents_SQL_OR, 0, -1);
$chat_agents_SQL_OR.=") OR ";
$i=0;
$available_chat_groups_string='|';
$available_chat_groups_ct = count($available_chat_groups);
$chat_groups_SQL_OR="vicidial_users.user_group in ('',";
while($i < $available_chat_groups_ct)
{
$available_chat_groups_string .= "$available_chat_groups[$i]|";
$chat_groups_SQL_OR.="'$available_chat_groups[$i]',";
$i++;
}
$chat_groups_SQL_OR=preg_replace("/,$/", "", $chat_groups_SQL_OR);
$chat_groups_SQL_OR.=") OR ";
$i=0;
$available_chat_campaigns_string='|';
$available_chat_campaigns_ct = count($available_chat_campaigns);
$chat_campaigns_SQL_OR="vicidial_live_agents.campaign_id in ('',";
while($i < $available_chat_campaigns_ct)
{
$available_chat_campaigns_string .= "$available_chat_campaigns[$i]|";
$chat_campaigns_SQL_OR.="'$available_chat_campaigns[$i]',";
$i++;
}
$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) {
$chat_query_SQL=" and (".$chat_agents_SQL_OR.$chat_groups_SQL_OR.$chat_campaigns_SQL_OR.")";
} 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) {
$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))) {
$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) {
$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)) {
$user=$row[0];
#$manager_message = preg_replace('/"/i','',$manager_message);
#$manager_message = preg_replace("/'/i",'',$manager_message);
# $manager_message = preg_replace('/;/i','',$manager_message);
# $manager_message = preg_replace("/\\\\/i",' ',$manager_message);
$manager_message = preg_replace("/\r/i",'',$manager_message);
$manager_message = preg_replace("/\n/i",' ',$manager_message);
# $manager_message=addslashes(trim("$manager_message"));
$ins_chat_stmt="insert into vicidial_manager_chat_log(manager_chat_id, manager_chat_subid, manager, user, message, message_date, message_posted_by) VALUES('$manager_chat_id', '$subid', '".$PHP_AUTH_USER."', '$user', '".mysqli_real_escape_string($link, $manager_message)."', now(), '".$PHP_AUTH_USER."')";
$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++;}
$stmt="SELECT allowed_campaigns,allowed_reports,admin_viewable_groups,admin_viewable_call_times from vicidial_user_groups where user_group='$LOGuser_group';";
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$LOGallowed_campaigns = $row[0];
$LOGallowed_reports = $row[1];
$LOGadmin_viewable_groups = $row[2];
$LOGadmin_viewable_call_times = $row[3];
$admin_viewable_groupsALL=0;
$LOGadmin_viewable_groupsSQL='';
$whereLOGadmin_viewable_groupsSQL='';
$valLOGadmin_viewable_groupsSQL='';
$vmLOGadmin_viewable_groupsSQL='';
if ( (!preg_match("/\-\-ALL\-\-/i",$LOGadmin_viewable_groups)) and (strlen($LOGadmin_viewable_groups) > 3) )
{
$rawLOGadmin_viewable_groupsSQL = preg_replace("/ -/",'',$LOGadmin_viewable_groups);
$rawLOGadmin_viewable_groupsSQL = preg_replace("/ /","','",$rawLOGadmin_viewable_groupsSQL);
$LOGadmin_viewable_groupsSQL = "and user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')";
$whereLOGadmin_viewable_groupsSQL = "where user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')";
$valLOGadmin_viewable_groupsSQL = "and val.user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')";
$vmLOGadmin_viewable_groupsSQL = "and vm.user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')";
}
else
{$admin_viewable_groupsALL=1;}
$regexLOGadmin_viewable_groups = " $LOGadmin_viewable_groups ";
$UUgroups_list='';
if ($admin_viewable_groupsALL > 0)
{$UUgroups_list .= "<option value=\"---ALL---\">"._QXZ("All Admin User Groups")."</option>\n";}
$stmt="SELECT user_group,group_name from vicidial_user_groups $whereLOGadmin_viewable_groupsSQL order by user_group;";
$rslt=mysql_to_mysqli($stmt, $link);
$UUgroups_to_print = mysqli_num_rows($rslt);
$o=0;
while ($UUgroups_to_print > $o)
{
$rowx=mysqli_fetch_row($rslt);
$UUgroups_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
$o++;
}
?>
<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>
<title><?php echo _QXZ("ADMINISTRATION: Manager Chat Interface"); ?></title>
<?php
##### BEGIN Set variables to make header show properly #####
$ADD = '0';
$hh = 'managerchats';
$sh = 'emails';
$LOGast_admin_access = '1';
$ADMIN = 'admin.php';
$page_width='770';
$section_width='750';
$header_font_size='3';
$subheader_font_size='2';
$subcamp_font_size='2';
$header_selected_bold='<b>';
$header_nonselected_bold='';
$admin_color = '#FFFF99';
$admin_font = 'BLACK';
$admin_color = '#E6E6E6';
$emails_color = '#FFFF99';
$emails_font = 'BLACK';
$emails_color = '#C6C6C6';
$subcamp_color = '#C6C6C6';
$managerchats_color = '#E6E6E6';
##### END Set variables to make header show properly #####
require("admin_header.php");
if ($SSallow_chats < 1)
{
echo _QXZ("ERROR: Chats are not enabled on this system")."\n";
exit;
}
$NWB = " &nbsp; <a href=\"javascript:openNewWindow('help.php?ADD=99999";
$NWE = "')\"><IMG SRC=\"help.gif\" WIDTH=20 HEIGHT=20 BORDER=0 ALT=\"HELP\" ALIGN=TOP></A>";
echo "<span id='ManagerChatDisplay'>";
if (!$manager_chat_id) { # DO NOT ALLOW NEW CHATS WHILE AN OLD ONE IS OPEN!!!
$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();
$user_group_array=array();
$campaign_id_array=array();
while ($row=mysqli_fetch_row($rslt)) {
if (!in_array("$row[0]", $user_array)) {$user_array[$row[0]]="$row[1]";}
if (!in_array("$row[2]", $user_group_array)) {$user_group_array["$row[2]"]="$row[5]";}
if (!in_array("$row[3]", $campaign_id_array)) {$campaign_id_array["$row[3]"]="$row[4]";}
}
asort($user_array);
asort($user_group_array);
asort($campaign_id_array);
echo "<form action='/vicidial/manager_chat_interface.php' method='GET'>";
echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2><BR>";
if ($message) {echo "<B>$message</B><BR>";}
echo "<span id='ManagerChatAvailabilityDisplay'><TABLE width=750 cellspacing=1 cellpadding=1>\n";
echo "<TR><TD align='left' class='arial'>"._QXZ("VICIDIAL Manager Chat Interface").":</TD><TD align='right' class='arial_bold'><a link='#FFFF00' vlink='#FFFF00' href='manager_chat_interface.php'>["._QXZ("RELOAD")."]</a></TD></TR>";
echo "<TR BGCOLOR=BLACK>\n";
echo "<TD><font size=1 color=white width='50%'>"._QXZ("CURRENT LIVE AGENTS")."</TD>\n";
echo "<TD><font size=1 color=white width='50%'>"._QXZ("CURRENT LIVE CAMPAIGNS")."</TD></tr>\n";
echo "<TR BGCOLOR='#E6E6E6'>";
echo "<TD rowspan=3 valign='top'>";
echo "<select name='available_chat_agents[]' multiple size='12' style=\"width:350px\">\n";
if (count($user_array)==0) {echo "<option value=''>---- "._QXZ("NO LIVE AGENTS")." ----</option>";}
while (list($user, $full_name) = each($user_array)) {
echo "<option value='$user'>$user - $full_name</option>\n";
}
echo "</select>\n";
echo "</TD>";
echo "<TD valign='top'>";
echo "<select name='available_chat_campaigns[]' multiple size='5' style=\"width:350px\">\n";
if (count($campaign_id_array)==0) {echo "<option value=''>---- "._QXZ("NO LIVE CAMPAIGNS")." ----</option>";}
while (list($campaign_id, $campaign_name) = each($campaign_id_array)) {
echo "<option value='$campaign_id'>$campaign_id - $campaign_name</option>\n";
}
echo "</select>\n";
echo "</TD>";
echo "<TR BGCOLOR=BLACK>";
echo "<TD><font size=1 color=white>"._QXZ("CURRENT LIVE USER GROUPS")."</TD>\n";
echo "</TR>";
echo "<TR BGCOLOR='#E6E6E6'>";
echo "<TD valign='top'>";
echo "<select name='available_chat_groups[]' multiple size='5' style=\"width:350px\">\n";
if (count($user_group_array)==0) {echo "<option value=''>---- "._QXZ("NO LIVE USER GROUPS")." ----</option>";}
while (list($user_group, $group_name) = each($user_group_array)) {
echo "<option value='$user_group'>$user_group - $group_name</option>\n";
}
echo "</select>\n";
echo "</TD>";
echo "</TR>";
echo "</table></span>";
echo "<TABLE width=750 cellspacing=1 cellpadding=1>\n";
echo "<TR BGCOLOR=BLACK>\n";
echo "<TD align='left'><font size=1 color=white>"._QXZ("MESSAGE").":</font></td>";
echo "<TD align='left'><font size=1 color=white>"._QXZ("SEND TO").":</font></td>";
echo "</TR>";
echo "<TR BGCOLOR='#E6E6E6'>\n";
echo "<TD align='left'>";
echo "<textarea rows='5' cols='50' name='manager_message' id='manager_message'></textarea><BR><BR>";
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 "</td>";
echo "</TR>";
echo "</table>";
echo "</form>";
echo "<BR>";
$reload_function="setInterval(\"RefreshChatDisplay()\", 30000);\n";
echo "<script language=\"JavaScript\">\n";
echo "$reload_function";
echo "</script>\n";
} 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 "</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 "</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) {
$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)) {
$full_name=$row[3];
$chat_subid=$row[5];
$chat_subids_array.="'$chat_subid',";
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) {
$agent_id=$row[6];
if ($bgcolor=="#E6E6E6") {$bgcolor="#FFFFFF";} else {$bgcolor="#E6E6E6";}
$chat_output_header[$chat_subid]= "<TR BGCOLOR='$bgcolor'>\n";
$chat_output_header[$chat_subid].="\t<td width='100' align='left'><font FACE=\"ARIAL,HELVETICA\" size='1'>$full_name</font></td>";
$chat_output_header[$chat_subid].="\t<td width='325' align='left' valign='top'><div class='scrolling' id='manager_chat_".$manager_chat_id."_".$chat_subid."'>";
$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].="</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)) {
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 {
$reload_function="setInterval(\"RefreshChatDisplay()\", 30000);\n";
}
echo "</table>";
echo "<script language=\"JavaScript\">\n";
echo "$reload_function";
echo "</script>\n";
}
echo "</span>";
$ENDtime = date("U");
$RUNtime = ($ENDtime - $STARTtime);
echo "\n\n\n<br><br><br>\n<font size=1> "._QXZ("runtime").": $RUNtime "._QXZ("seconds")." $ENDtime &nbsp; &nbsp; &nbsp; &nbsp; "._QXZ("Version").": $admin_version &nbsp; &nbsp; "._QXZ("Build").": $build</font>";
# End chat - select all exchanges between user and manager and move them to the dustbin
?>
</body>
</html>
@@ -0,0 +1,136 @@
<?php
require("dbconnect_mysqli.php");
require("functions.php");
#############################################
##### START SYSTEM_SETTINGS LOOKUP #####
$stmt = "SELECT use_non_latin,allow_chats 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];
}
##### END SETTINGS LOOKUP #####
###########################################
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
$PHP_SELF=$_SERVER['PHP_SELF'];
if ($non_latin < 1)
{
$PHP_AUTH_USER = preg_replace("/[^-_0-9a-zA-Z]/", "",$PHP_AUTH_USER);
$PHP_AUTH_PW = preg_replace("/[^-_0-9a-zA-Z]/", "",$PHP_AUTH_PW);
} # end of non_latin
else
{
$PHP_AUTH_USER = preg_replace("/'|\"|\\\\|;/","",$PHP_AUTH_USER);
$PHP_AUTH_PW = preg_replace("/'|\"|\\\\|;/","",$PHP_AUTH_PW);
}
$auth=0;
$auth_message = user_authorization($PHP_AUTH_USER,$PHP_AUTH_PW,'',1);
if ($auth_message == 'GOOD')
{$auth=1;}
if ($auth < 1)
{
$VDdisplayMESSAGE = _QXZ("Login incorrect, please try again");
if ($auth_message == 'LOCK')
{
$VDdisplayMESSAGE = _QXZ("Too many login attempts, try again in 15 minutes");
Header ("Content-type: text/html; charset=utf-8");
echo "$VDdisplayMESSAGE: |$PHP_AUTH_USER|$auth_message|\n";
exit;
}
Header("WWW-Authenticate: Basic realm=\"CONTACT-CENTER-ADMIN\"");
Header("HTTP/1.0 401 Unauthorized");
echo "$VDdisplayMESSAGE: |$PHP_AUTH_USER|$PHP_AUTH_PW|$auth_message|\n";
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();
$user_group_array=array();
$campaign_id_array=array();
while ($row=mysqli_fetch_row($rslt)) {
if (!in_array("$row[0]", $user_array)) {$user_array[$row[0]]="$row[1]";}
if (!in_array("$row[2]", $user_group_array)) {$user_group_array["$row[2]"]="$row[5]";}
if (!in_array("$row[3]", $campaign_id_array)) {$campaign_id_array["$row[3]"]="$row[4]";}
}
asort($user_array);
asort($user_group_array);
asort($campaign_id_array);
echo "<form action='/vicidial/manager_chat_interface.php' method='GET'>";
echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2><BR>";
if ($message) {echo "<B>$message</B><BR>";}
# echo "<br>"._QXZ("VICIDIAL Manager Chat Interface").":\n";
echo "<span id='ManagerChatAvailabilityDisplay'><TABLE width=750 cellspacing=1 cellpadding=1>\n";
echo "<TR><TD align='left' class='arial'>"._QXZ("VICIDIAL Manager Chat Interface").":</TD><TD align='right' class='arial_bold'><a link='#FFFF00' vlink='#FFFF00' href='manager_chat_interface.php'>["._QXZ("RELOAD")."]</a></TD></TR>";
echo "<TR BGCOLOR=BLACK>\n";
echo "<TD><font size=1 color=white width='50%'>"._QXZ("CURRENT LIVE AGENTS")."</TD>\n";
echo "<TD><font size=1 color=white width='50%'>"._QXZ("CURRENT LIVE CAMPAIGNS")."</TD></tr>\n";
echo "<TR BGCOLOR='#E6E6E6'>";
echo "<TD rowspan=3 valign='top'>";
echo "<select name='available_chat_agents[]' multiple size='12' style=\"width:350px\">\n";
if (count($user_array)==0) {echo "<option value=''>---- "._QXZ("NO LIVE AGENTS")." ----</option>";}
while (list($user, $full_name) = each($user_array)) {
echo "<option value='$user'>$user - $full_name</option>\n";
}
echo "</select>\n";
echo "</TD>";
echo "<TD valign='top'>";
echo "<select name='available_chat_campaigns[]' multiple size='5' style=\"width:350px\">\n";
if (count($campaign_id_array)==0) {echo "<option value=''>---- "._QXZ("NO LIVE CAMPAIGNS")." ----</option>";}
while (list($campaign_id, $campaign_name) = each($campaign_id_array)) {
echo "<option value='$campaign_id'>$campaign_id - $campaign_name</option>\n";
}
echo "</select>\n";
echo "</TD>";
echo "<TR BGCOLOR=BLACK>";
echo "<TD><font size=1 color=white>"._QXZ("CURRENT LIVE USER GROUPS")."</TD>\n";
echo "</TR>";
echo "<TR BGCOLOR='#E6E6E6'>";
echo "<TD valign='top'>";
echo "<select name='available_chat_groups[]' multiple size='5' style=\"width:350px\">\n";
if (count($user_group_array)==0) {echo "<option value=''>---- "._QXZ("NO LIVE USER GROUPS")." ----</option>";}
while (list($user_group, $group_name) = each($user_group_array)) {
echo "<option value='$user_group'>$user_group - $group_name</option>\n";
}
echo "</select>\n";
echo "</TD>";
echo "</TR>";
echo "</table></span>";
# echo "<TR BGCOLOR='#E6E6E6'>";
# echo "<TD align='center' colspan='2'><input type='button' name='submit_chat' style='width: 150px' value='"._QXZ("CLEAR SELECTIONS")."'></TD>";
# echo "</TR>";
echo "<TABLE width=750 cellspacing=1 cellpadding=1>\n";
echo "<TR BGCOLOR=BLACK>\n";
echo "<TD align='left'><font size=1 color=white>"._QXZ("MESSAGE").":</font></td>";
echo "<TD align='left'><font size=1 color=white>"._QXZ("SEND TO").":</font></td>";
echo "</TR>";
echo "<TR BGCOLOR='#E6E6E6'>\n";
echo "<TD align='left'>";
echo "<textarea rows='5' cols='50' name='manager_message' id='manager_message'></textarea><BR><BR>";
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 "</td>";
echo "</TR>";
echo "</table>";
echo "</form>";
echo "<BR>";
$reload_function="setInterval(\"RefreshChatDisplay()\", 30000);\n";
echo "<script language=\"JavaScript\">\n";
echo "$reload_function";
echo "</script>\n";
?>
+34 -2
View File
@@ -34,6 +34,7 @@
# 141114-1702 - Fixed issue #800
# 141229-1829 - Added code for on-the-fly language translations display
# 150701-1250 - Modified mysqli_error() to mysqli_connect_error() where appropriate
# 151211-1458 - Added chat visibility
#
$startMS = microtime();
@@ -69,7 +70,7 @@ if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];}
#############################################
##### START SYSTEM_SETTINGS LOOKUP #####
$stmt = "SELECT use_non_latin,webroot_writable,outbound_autodial_active,user_territories_active,level_8_disable_add,enable_languages,language_method FROM system_settings;";
$stmt = "SELECT use_non_latin,webroot_writable,outbound_autodial_active,user_territories_active,level_8_disable_add,enable_languages,language_method,allow_chats FROM system_settings;";
$rslt=mysql_to_mysqli($stmt, $link);
if ($DB) {echo "$stmt\n";}
$qm_conf_ct = mysqli_num_rows($rslt);
@@ -83,6 +84,7 @@ if ($qm_conf_ct > 0)
$SSlevel_8_disable_add = $row[4];
$SSenable_languages = $row[5];
$SSlanguage_method = $row[6];
$SSallow_chats = $row[7];
}
##### END SETTINGS LOOKUP #####
###########################################
@@ -256,6 +258,28 @@ while ($i < $agents_to_print)
$i++;
}
if ($SSallow_chats > 0)
{
$stmt="SELECT chat_id,chat_start_time,status,chat_creator,group_id,lead_id from vicidial_live_chats where status='LIVE' and chat_creator='$user'";
$rslt=mysql_to_mysqli($stmt, $link);
if ($DB) {echo "$stmt\n";}
$active_chats=mysqli_num_rows($rslt);
if($active_chats>0)
{
$Achats="";
while ($row=mysqli_fetch_row($rslt))
{
$chat_id=$row[0];
$Achats.="$chat_id, ";
}
$Achats=preg_replace('/, $/', "", $Achats);
}
else
{
$Achats=_QXZ("NONE");
}
}
$stmt="SELECT event_date,status,ip_address from vicidial_timeclock_status where user='" . mysqli_real_escape_string($link, $user) . "';";
$rslt=mysql_to_mysqli($stmt, $link);
if ($DB) {echo "$stmt\n";}
@@ -313,7 +337,7 @@ while ($i < $groups_to_print)
<html>
<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
<title>ADMINISTRATION: User Status
<title><?php echo _QXZ("ADMINISTRATION: User Status"); ?>
<?php
@@ -864,6 +888,14 @@ else
echo _QXZ("Agent is not logged in")."\n<BR>";
}
if ($SSallow_chats > 0)
{
echo "<BR>\n";
echo "<TABLE CELLPADDING=0 CELLSPACING=0>";
echo "<TR><TD ALIGN=RIGHT>"._QXZ("Currently active in chats").":</TD><TD ALIGN=LEFT> &nbsp; $Achats</TD></TR>\n";
echo "</TABLE>\n<BR>\n";
}
echo "\n<BR>";
if ( ($Tstatus == "LOGIN") or ($Tstatus == "START") )
+292
View File
@@ -0,0 +1,292 @@
// vicidial_chat.js
//
// Copyright (C) 2015 Joe Johnson, Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
//
// Used by manager_chat_actions, this file contains all Javascript functions that grab
// information off of the web page and utilize AJAX to pass data to manager_chat_actions.php,
// which will respond with data used to update the manager chat interface.
//
// Builds:
// 150612-2334 - First build
//
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;
}
}