diff --git a/agc_2-X/trunk/UPGRADE b/agc_2-X/trunk/UPGRADE
index 53fd5ab0..89329826 100644
--- a/agc_2-X/trunk/UPGRADE
+++ b/agc_2-X/trunk/UPGRADE
@@ -56,7 +56,15 @@ REQUIRED STEPS!!!
OTHER CHANGES:
-1. Nothing new here yet, just branched!
+1. Added AST_inbound_export.pl script for in-group call data exports
+
+2. Added cm_sc_areacode.agi script that allows you to use a Settings Container
+ with the script in a Call Menu to define different destinations for
+ customers from each state to go to: DID, CALLMENU, EXTEN
+
+3. Added Agent DID Report
+
+4. Added the ability for internal chats to have more than one agent participant
diff --git a/agc_2-X/trunk/bin/AST_flush_DBqueue.pl b/agc_2-X/trunk/bin/AST_flush_DBqueue.pl
index dc4a08a4..b12de415 100644
--- a/agc_2-X/trunk/bin/AST_flush_DBqueue.pl
+++ b/agc_2-X/trunk/bin/AST_flush_DBqueue.pl
@@ -1,6 +1,6 @@
#!/usr/bin/perl
#
-# AST_flush_DBqueue.pl version 2.12
+# AST_flush_DBqueue.pl version 2.14
#
# DESCRIPTION:
# - clears out mysql records for this server for the ACQS vicidial_manager table
@@ -21,6 +21,7 @@
# 120411-1637 - Added --seconds option
# 150710-0907 - Added flush of vicidial_dtmf_log table
# 160101-1124 - Added flush of routing_initiated_recordings table
+# 161214-1039 - Added flush of parked_channels_recent table
#
### begin parsing run-time options ###
@@ -209,6 +210,11 @@ if($DB){print STDERR "\n|$stmtA|\n";}
if (!$T) { $affected_rows = $dbhA->do($stmtA);}
if (!$Q) {print " - routing_initiated_recordings flush: $affected_rows rows\n";}
+$stmtA = "DELETE from parked_channels_recent where park_end_time < '$flush_time';";
+if($DB){print STDERR "\n|$stmtA|\n";}
+if (!$T) { $affected_rows = $dbhA->do($stmtA);}
+if (!$Q) {print " - parked_channels_recent flush: $affected_rows rows\n";}
+
$stmtA = "OPTIMIZE table vicidial_manager;";
if($DB){print STDERR "\n|$stmtA|\n";}
if (!$T)
@@ -251,6 +257,20 @@ if (!$T)
if (!$Q) {print " - OPTIMIZE routing_initiated_recordings \n";}
+$stmtA = "OPTIMIZE table parked_channels_recent;";
+if($DB){print STDERR "\n|$stmtA|\n";}
+if (!$T)
+ {
+ $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
+ $sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
+ $sthArows=$sthA->rows;
+ @aryA = $sthA->fetchrow_array;
+ if (!$Q) {print "|",$aryA[0],"|",$aryA[1],"|",$aryA[2],"|",$aryA[3],"|","\n";}
+ $sthA->finish();
+ }
+if (!$Q) {print " - OPTIMIZE parked_channels_recent \n";}
+
+
$stmtA = "OPTIMIZE table vicidial_live_agents;";
if($DB){print STDERR "\n|$stmtA|\n";}
if (!$T)
diff --git a/agc_2-X/trunk/bin/FastAGI_log.pl b/agc_2-X/trunk/bin/FastAGI_log.pl
index bdf854f6..d70c8db4 100644
--- a/agc_2-X/trunk/bin/FastAGI_log.pl
+++ b/agc_2-X/trunk/bin/FastAGI_log.pl
@@ -1,6 +1,6 @@
#!/usr/bin/perl
#
-# FastAGI_log.pl version 2.12
+# FastAGI_log.pl version 2.14
#
# Experimental Deamon using perl Net::Server that runs as FastAGI to reduce load
# replaces the following AGI scripts:
@@ -72,6 +72,7 @@
# 140215-2118 - Added several variable options for QM socket URL
# 150804-1740 - Added code to support in-group drop_lead_reset feature
# 161102-1034 - Fixed QM partition problem
+# 161214-1717 - Fix for rare multi-server grab from IVR park issue
#
# defaults for PreFork
@@ -1009,7 +1010,7 @@ sub process_request
{
########## FIND AND DELETE vicidial_auto_calls ##########
$VD_alt_dial = 'NONE';
- $stmtA = "SELECT lead_id,callerid,campaign_id,alt_dial,stage,UNIX_TIMESTAMP(call_time),uniqueid,status,call_time,phone_code,phone_number,queue_position FROM vicidial_auto_calls where uniqueid = '$uniqueid' or callerid = '$callerid' limit 1;";
+ $stmtA = "SELECT lead_id,callerid,campaign_id,alt_dial,stage,UNIX_TIMESTAMP(call_time),uniqueid,status,call_time,phone_code,phone_number,queue_position,server_ip FROM vicidial_auto_calls where uniqueid = '$uniqueid' or callerid = '$callerid' limit 1;";
if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
@@ -1030,6 +1031,7 @@ sub process_request
$VD_phone_code = $aryA[9];
$VD_phone_number = $aryA[10];
$VD_queue_position = $aryA[11];
+ $VD_server_ip = $aryA[12];
$rec_countCUSTDATA++;
}
$sthA->finish();
@@ -1040,8 +1042,10 @@ sub process_request
}
else
{
- $PC_count=0;
+ $PC_count_rows=0;
$PLC_count=0;
+ $PCR_count=0;
+ $PC_channel='';
$stmtA = "SELECT channel from parked_channels where channel_group='$callerid';";
if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
@@ -1054,6 +1058,49 @@ sub process_request
}
$sthA->finish();
+ if ($PC_count_rows < 1)
+ {
+ $PC_server_ip='';
+ # check parked_channels_recent table
+ $secX = time();
+ $Ptarget = ($secX - 7200); # look back 2 hours
+ ($Psec,$Pmin,$Phour,$Pmday,$Pmon,$Pyear,$Pwday,$Pyday,$Pisdst) = localtime($Ptarget);
+ $Pyear = ($Pyear + 1900);
+ $Pmon++;
+ if ($Pmon < 10) {$Pmon = "0$Pmon";}
+ if ($Pmday < 10) {$Pmday = "0$Pmday";}
+ if ($Phour < 10) {$Phour = "0$Phour";}
+ if ($Pmin < 10) {$Pmin = "0$Pmin";}
+ if ($Psec < 10) {$Psec = "0$Psec";}
+ $PSQLdate = "$Pyear-$Pmon-$Pmday $Phour:$Pmin:$Psec";
+
+ $stmtA = "SELECT channel,server_ip from parked_channels_recent where channel_group='$callerid' and park_end_time > \"$PSQLdate\" order by park_end_time desc limit 1;";
+ if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
+ $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
+ $sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
+ $PC_count_rows=$sthA->rows;
+ if ($PC_count_rows > 0)
+ {
+ $PCR_count++;
+ @aryA = $sthA->fetchrow_array;
+ $PC_channel = $aryA[0];
+ $PC_server_ip = $aryA[1];
+ }
+ $sthA->finish();
+
+ if ($PC_server_ip ne $VARserver_ip)
+ {
+ $PC_count_rows=0;
+ $PLC_count=1;
+ if ($AGILOG) {$agi_string = "VD hangup: VDAC record found with park record OTHER SERVER: $channel($PC_count_rows|$PCR_count) $PC_channel $uniqueid $calleridname $VARserver_ip|$PC_server_ip"; &agi_output;}
+ }
+ else
+ {
+ $PC_count_rows=0;
+ $PC_channel='';
+ }
+ }
+
if ($PC_count_rows > 0)
{
sleep(1);
@@ -1072,13 +1119,13 @@ sub process_request
}
if ($PLC_count > 0)
{
- if ($AGILOG) {$agi_string = "VD hangup: VDAC record found with park record: $channel $PC_channel $uniqueid $calleridname"; &agi_output;}
+ if ($AGILOG) {$agi_string = "VD hangup: VDAC record found with park record: $channel($PC_count_rows|$PCR_count) $PC_channel $uniqueid $calleridname $VD_server_ip"; &agi_output;}
}
else
{
$stmtA = "DELETE FROM vicidial_auto_calls where ( ( (status!='IVR') and (uniqueid='$uniqueid' or callerid = '$callerid') ) or ( (status='IVR') and (uniqueid='$uniqueid') ) ) order by call_time desc limit 1;";
$VACaffected_rows = $dbhA->do($stmtA);
- if ($AGILOG) {$agi_string = "-- VDAC record deleted: |$VACaffected_rows| |$VD_lead_id|$uniqueid|$VD_uniqueid|$VD_callerid|$VARserver_ip|$VD_status|"; &agi_output;}
+ if ($AGILOG) {$agi_string = "-- VDAC record deleted: |$VACaffected_rows| |$VD_lead_id|$uniqueid|$VD_uniqueid|$VD_callerid|$callerid|$VD_status|$channel($VARserver_ip)|$PC_channel($VD_server_ip)|($PC_count_rows|$PCR_count)|"; &agi_output;}
$stmtA = "UPDATE vicidial_live_agents SET ring_callerid='' where ring_callerid='$callerid';";
$VLACaffected_rows = $dbhA->do($stmtA);
diff --git a/agc_2-X/trunk/docs/CELLPHONE_USA_TCPA_FCC_COMPLIANCE.txt b/agc_2-X/trunk/docs/CELLPHONE_USA_TCPA_FCC_COMPLIANCE.txt
index fad03260..e88a6327 100644
--- a/agc_2-X/trunk/docs/CELLPHONE_USA_TCPA_FCC_COMPLIANCE.txt
+++ b/agc_2-X/trunk/docs/CELLPHONE_USA_TCPA_FCC_COMPLIANCE.txt
@@ -101,3 +101,11 @@ PREFIX_SFTP_server => sftp.dncscrub.com
PREFIX_SFTP_user => DEMOVICIDIAL
PREFIX_SFTP_pass => sampLepass
PREFIX_SFTP_port => 22
+
+
+
+Changing DB schema back to allow auto-dialing:
+
+UPDATE system_settings SET disable_auto_dial='0';
+ALTER TABLE vicidial_campaigns MODIFY dial_method ENUM('MANUAL','RATIO','ADAPT_HARD_LIMIT','ADAPT_TAPERED','ADAPT_AVERAGE','INBOUND_MAN') default 'MANUAL';
+ALTER TABLE vicidial_campaigns MODIFY auto_dial_level VARCHAR(6) default '0';
diff --git a/agc_2-X/trunk/docs/CHAT_MESSAGING.txt b/agc_2-X/trunk/docs/CHAT_MESSAGING.txt
index a5d8cfa4..c7038c7c 100644
--- a/agc_2-X/trunk/docs/CHAT_MESSAGING.txt
+++ b/agc_2-X/trunk/docs/CHAT_MESSAGING.txt
@@ -1,4 +1,4 @@
-CHAT MESSAGING Started 2014-05-01 Updated 2016-03-05
+CHAT MESSAGING Started 2014-05-01 Updated 2016-12-17
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.
@@ -10,6 +10,8 @@ UPDATE 2015-12-19: We added several security enhancements related to the chat fu
UPDATE 2016-03-05: We added the ability to transfer a customer chat to another chat group or agent.
+UPDATE 2016-12-17: We added the ability for agents to add more agents to their internal chat sessions, so multiple agents can be chatting together in the same session at one time.
+
AGENT CHAT INTERFACE INSTRUCTIONS:
diff --git a/agc_2-X/trunk/docs/OUTBOUND_OPTIMIZATIONS.txt b/agc_2-X/trunk/docs/OUTBOUND_OPTIMIZATIONS.txt
index 1d388244..72e9f731 100644
--- a/agc_2-X/trunk/docs/OUTBOUND_OPTIMIZATIONS.txt
+++ b/agc_2-X/trunk/docs/OUTBOUND_OPTIMIZATIONS.txt
@@ -28,12 +28,14 @@ In our first three rounds of live testing, we have seen the following results:
- Calls that never resolved in over 30 seconds made up from 5-10% of total Answered calls
- The Asterisk 11 server had a lower rate of LRERR calls, and faster overall routing compared to 1.4 and 1.8 servers
-Some conclusions based upon these round of live testing:
+Some conclusions based upon more rounds of live testing:
- Allowing more than 1 second for channel resolution increased delayed resolution calls being routed by about 30%, although this is still only 1-2% of total Answered calls
+- Using different carriers at different times can greatly affect the rate of LRERRs, from less than 1% to over 30%
- If a call does not resolve within 3 seconds post-Answer, there is very little chance it will ever resolve, although we did have some calls resolve at 25+ seconds
- Asterisk 11 appears to be more successful at forcing resolutions, and routing calls faster, when compared to earlier branches of Asterisk
- The quality of your telco carrier, and the state of that telco network, is a big factor in the LRERR rate for post-answer calls
- The speed of your database is a much larger factor in the speed of the routing of outbound VDAD calls post-Answer
+- The loadavg of the dialer will be LARGELY affected by use of the BETA AGI script(loadavg over 20.00 on quad-core), although it does not seem to affect functionality
diff --git a/agc_2-X/trunk/extras/MySQL_AST_CREATE_tables.sql b/agc_2-X/trunk/extras/MySQL_AST_CREATE_tables.sql
index 53d7c0f2..bffd39e5 100644
--- a/agc_2-X/trunk/extras/MySQL_AST_CREATE_tables.sql
+++ b/agc_2-X/trunk/extras/MySQL_AST_CREATE_tables.sql
@@ -3311,6 +3311,7 @@ manager_chat_subid TINYINT(3) UNSIGNED DEFAULT NULL,
manager VARCHAR(20) COLLATE utf8_unicode_ci DEFAULT NULL,
user VARCHAR(20) COLLATE utf8_unicode_ci DEFAULT NULL,
message MEDIUMTEXT COLLATE utf8_unicode_ci,
+message_id VARCHAR(20),
message_date DATETIME DEFAULT NULL,
message_viewed_date DATETIME DEFAULT NULL,
message_posted_by VARCHAR(20) COLLATE utf8_unicode_ci DEFAULT NULL,
@@ -3329,6 +3330,7 @@ manager_chat_subid TINYINT(3) UNSIGNED DEFAULT NULL,
manager VARCHAR(20) COLLATE utf8_unicode_ci DEFAULT NULL,
user VARCHAR(20) COLLATE utf8_unicode_ci DEFAULT NULL,
message MEDIUMTEXT COLLATE utf8_unicode_ci,
+message_id VARCHAR(20),
message_date DATETIME DEFAULT NULL,
message_viewed_date DATETIME DEFAULT NULL,
message_posted_by VARCHAR(20) COLLATE utf8_unicode_ci DEFAULT NULL,
@@ -3340,6 +3342,7 @@ KEY manager_chat_subid_archive_key (manager_chat_subid)
CREATE TABLE vicidial_manager_chats (
manager_chat_id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
+internal_chat_type ENUM('AGENT', 'MANAGER') default 'MANAGER',
chat_start_date DATETIME DEFAULT NULL,
manager VARCHAR(20) COLLATE utf8_unicode_ci DEFAULT NULL,
selected_agents MEDIUMTEXT COLLATE utf8_unicode_ci,
@@ -3351,6 +3354,7 @@ PRIMARY KEY (manager_chat_id)
CREATE TABLE vicidial_manager_chats_archive (
manager_chat_id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
+internal_chat_type ENUM('AGENT', 'MANAGER') default 'MANAGER',
chat_start_date DATETIME DEFAULT NULL,
manager VARCHAR(20) COLLATE utf8_unicode_ci DEFAULT NULL,
selected_agents MEDIUMTEXT COLLATE utf8_unicode_ci,
@@ -3574,6 +3578,15 @@ index (caller_code),
KEY vdad_dbtime_key (db_time)
) ENGINE=MyISAM CHARSET=utf8 COLLATE=utf8_unicode_ci;
+CREATE TABLE parked_channels_recent (
+channel VARCHAR(100) NOT NULL,
+server_ip VARCHAR(15) NOT NULL,
+channel_group VARCHAR(30),
+park_end_time DATETIME,
+index (channel_group),
+index (park_end_time)
+) ENGINE=MyISAM;
+
ALTER TABLE vicidial_email_list MODIFY message text character set utf8;
@@ -3831,4 +3844,4 @@ UPDATE vicidial_configuration set value='1766' where name='qc_database_version';
UPDATE system_settings set vdc_agent_api_active='1';
-UPDATE system_settings SET db_schema_version='1481',db_schema_update_date=NOW(),reload_timestamp=NOW();
+UPDATE system_settings SET db_schema_version='1482',db_schema_update_date=NOW(),reload_timestamp=NOW();
diff --git a/agc_2-X/trunk/extras/upgrade_2.14.sql b/agc_2-X/trunk/extras/upgrade_2.14.sql
index 513f638d..dc2b489f 100644
--- a/agc_2-X/trunk/extras/upgrade_2.14.sql
+++ b/agc_2-X/trunk/extras/upgrade_2.14.sql
@@ -5,3 +5,20 @@ UPDATE system_settings SET db_schema_version='1480',version='2.14b0.5',db_schema
ALTER TABLE vicidial_settings_containers MODIFY container_type ENUM('OTHER','PERL_CLI','EMAIL_TEMPLATE','AGI') default 'OTHER';
UPDATE system_settings SET db_schema_version='1481',db_schema_update_date=NOW() where db_schema_version < 1481;
+
+CREATE TABLE parked_channels_recent (
+channel VARCHAR(100) NOT NULL,
+server_ip VARCHAR(15) NOT NULL,
+channel_group VARCHAR(30),
+park_end_time DATETIME,
+index (channel_group),
+index (park_end_time)
+) ENGINE=MyISAM;
+
+ALTER TABLE vicidial_manager_chats ADD column internal_chat_type ENUM('AGENT', 'MANAGER') default 'MANAGER' after manager_chat_id;
+ALTER TABLE vicidial_manager_chats_archive ADD column internal_chat_type ENUM('AGENT', 'MANAGER') default 'MANAGER' after manager_chat_id;
+
+ALTER TABLE vicidial_manager_chat_log ADD column message_id VARCHAR(20) after message;
+ALTER TABLE vicidial_manager_chat_log_archive ADD column message_id VARCHAR(20) after message;
+
+UPDATE system_settings SET db_schema_version='1482',db_schema_update_date=NOW() where db_schema_version < 1482;
diff --git a/agc_2-X/trunk/www/agc/agc_agent_manager_chat_interface.php b/agc_2-X/trunk/www/agc/agc_agent_manager_chat_interface.php
index 2a12e2d6..2154e74f 100644
--- a/agc_2-X/trunk/www/agc/agc_agent_manager_chat_interface.php
+++ b/agc_2-X/trunk/www/agc/agc_agent_manager_chat_interface.php
@@ -12,10 +12,11 @@
# 151231-0842 - Added agent_allowed_chat_groups setting
# 160108-2300 - Changed some mysqli_query to mysql_to_mysqli for consistency
# 160523-0630 - Fixed vicidial_stylesheet issues
+# 161217-0827 - Added code for multi-user internal chat sessions
#
-$admin_version = '2.12-6';
-$build = '160523-0630';
+$admin_version = '2.14-7';
+$build = '161217-0827';
$sh="managerchats";
@@ -101,7 +102,7 @@ if ($SSallow_chats < 1)
# 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_stmt="select manager_chat_id, manager_chat_subid, sum(if(message_viewed_date is not null and vicidial_manager_chat_log.user='$user', 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=mysql_to_mysqli($unread_stmt, $link);
while ($unread_row=mysqli_fetch_array($unread_rslt)) {
$IDNumber=$unread_row["manager_chat_id"]."-".$unread_row["manager_chat_subid"]."-".$unread_row["unread_count"];
@@ -109,7 +110,7 @@ while ($unread_row=mysqli_fetch_array($unread_rslt)) {
}
# 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";
+$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 and vicidial_manager_chat_log.user='$user', 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=mysql_to_mysqli($stmt, $link);
$active_chats_array=array();
@@ -135,7 +136,7 @@ while ($row=mysqli_fetch_row($rslt)) {
}
# 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_stmt="select manager_chat_id, manager_chat_subid, sum(if(message_viewed_date is not null and vicidial_manager_chat_log.user='$user', 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=mysql_to_mysqli($unread_stmt, $link);
while ($unread_row=mysqli_fetch_array($unread_rslt)) {
$IDNumber=$unread_row["manager_chat_id"]."-".$unread_row["manager_chat_subid"]."-".$unread_row["unread_count"];
@@ -146,7 +147,7 @@ while ($row=mysqli_fetch_row($rslt)) {
### 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";
+ $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 and vicidial_manager_chat_log.user='$user', 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=mysql_to_mysqli($stmt, $link);
while ($row=mysqli_fetch_row($rslt)) {
if ($row[0]!="") {
@@ -339,6 +340,7 @@ function DisplayMgrAgentChat(manager_chat_id, manager_chat_subid) {
var allow_agent_replies=ChatText_array[0];
var new_messages=ChatText_array[4];
+ var internal_chat_type=ChatText_array[5];
if (allow_agent_replies=="Y")
{
@@ -349,6 +351,23 @@ function DisplayMgrAgentChat(manager_chat_id, manager_chat_subid) {
document.getElementById("AllowAgentReplies").style.display = 'none';
}
+ if (ChatText_array[1].match(/^CHAT ENDED/))
+ {
+ document.getElementById("AgentAddChatSpan").style.display = 'none';
+ document.getElementById("AllLiveNonChatAgents").style.display = 'none';
+ }
+ else
+ {
+ if (internal_chat_type=="AGENT")
+ {
+ document.getElementById("AgentAddChatSpan").style.display = 'block';
+ }
+ else
+ {
+ document.getElementById("AgentAddChatSpan").style.display = 'none';
+ }
+ }
+
document.getElementById("ActiveManagerChatTranscript").innerHTML=ChatText_array[1];
document.getElementById("ActiveChatStartDate").innerHTML=ChatText_array[2];
document.getElementById("ActiveChatManager").innerHTML=ChatText_array[3];
@@ -471,6 +490,7 @@ function RefreshActiveChatView() {
function ReloadAgentNewChatSpan(user) {
var xmlhttp=false;
+ var pass='';
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
// JScript gives us Conditional compilation, we can cope with old IE versions.
@@ -573,8 +593,117 @@ function SendMgrChatMessage(manager_chat_id, manager_chat_subid) {
}
}
+function LoadAvailableAgentsForChat(destinationId, field_name) {
+ var user=document.getElementById("user").value;
+ var manager_chat_id=document.getElementById("CurrentActiveChat").value;
+ var manager_chat_subid=document.getElementById("CurrentActiveChatSubID").value;
+ var pass='';
+ 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=load_available_agents_for_chat&user="+user+"&pass="+pass+"&manager_chat_id="+manager_chat_id+"&manager_chat_subid="+manager_chat_subid+"&field_name="+field_name;
+ 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(destinationId).innerHTML=ChatText;
+ }
+ }
+ }
+ delete xmlhttp;
+ }
+}
+
+function AddAgentToExistingChat() {
+ var agent_to_add=document.getElementById("agent_to_add").value;
+ var user=document.getElementById("user").value;
+ var manager_chat_id=document.getElementById("CurrentActiveChat").value;
+ var manager_chat_subid=document.getElementById("CurrentActiveChatSubID").value;
+ var pass='';
+ 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=add_agent_to_existing_chat&user="+user+"&pass="+pass+"&manager_chat_id="+manager_chat_id+"&manager_chat_subid="+manager_chat_subid+"&agent_to_add="+agent_to_add;
+ 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(destinationId).innerHTML=ChatText;
+ }
+ LoadAvailableAgentsForChat('AllLiveNonChatAgents', 'agent_to_add');
+ }
+ }
+ delete xmlhttp;
+ }
+}
+
+function ToggleSpan(span_name) {
+ var span_vis = document.getElementById(span_name).style;
+ if (span_vis.display=='none') { span_vis.display = 'block'; } else { span_vis.display = 'none'; }
+}
+
function MgrAgentAutoRefresh() {
- rInt=window.setInterval(function() {DisplayMgrAgentChat()}, 1000);
+ rInt=window.setInterval(function() {DisplayMgrAgentChat()}, 500);
}
@@ -607,7 +736,18 @@ echo "
\n";
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
\n"; # $chat_managers_array[$manager_chat_id]
+
+ $additional_agents_stmt="select concat(manager, selected_agents) as participants from vicidial_manager_chats where manager_chat_id='$manager_chat_id'";
+ $additional_agents_rslt=mysql_to_mysqli($additional_agents_stmt, $link);
+ $aa_row=mysqli_fetch_row($additional_agents_rslt);
+ $additional_agents=preg_replace("/^\||\|$/", "", $aa_row[0]);
+ $additional_agents=preg_replace("/\|/", "','", $additional_agents);
+ $full_name_stmt="select full_name from vicidial_users where user in ('$additional_agents') and user!='$user' order by full_name asc";
+ $full_name_rslt=mysql_to_mysqli($full_name_stmt, $link);
+ while ($fname_row=mysqli_fetch_row($full_name_rslt)) {
+ echo "\t
"._QXZ("Message").": \n";
diff --git a/agc_2-X/trunk/www/agc/chat_db_query.php b/agc_2-X/trunk/www/agc/chat_db_query.php
index bdd7822e..00fce623 100644
--- a/agc_2-X/trunk/www/agc/chat_db_query.php
+++ b/agc_2-X/trunk/www/agc/chat_db_query.php
@@ -19,6 +19,7 @@
# 160719-1043 - Bug fixes for non-owner chats, and other issues
# 160818-1236 - Added chat colors, usre nickname and scrolling
# 160831-2225 - Agent-to-agent interface now color-coded using system settings, if desired
+# 161217-0824 - Added code for multi-user internal chat sessions
#
require("dbconnect_mysqli.php");
@@ -71,8 +72,14 @@ 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["current_active_chat"])) {$current_active_chat=$_GET["current_active_chat"];}
+ elseif (isset($_POST["current_active_chat"])) {$current_active_chat=$_POST["current_active_chat"];}
+if (isset($_GET["field_name"])) {$field_name=$_GET["field_name"];}
+ elseif (isset($_POST["field_name"])) {$field_name=$_POST["field_name"];}
if (isset($_GET["agent_manager"])) {$agent_manager=$_GET["agent_manager"];}
elseif (isset($_POST["agent_manager"])) {$agent_manager=$_POST["agent_manager"];}
+if (isset($_GET["agent_to_add"])) {$agent_to_add=$_GET["agent_to_add"];}
+ elseif (isset($_POST["agent_to_add"])) {$agent_to_add=$_POST["agent_to_add"];}
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"];}
@@ -164,7 +171,7 @@ if ($action=="CreateAgentToAgentChat" && $agent_manager && $agent_user && $manag
$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_stmt="insert into vicidial_manager_chats(chat_start_date, manager, selected_agents, selected_user_groups, selected_campaigns, allow_replies, internal_chat_type) VALUES(now(), '$agent_manager', '|$agent_user|', '|$user_group|', '|$campaign_id|', 'Y', 'AGENT')";
$ins_rslt=mysql_to_mysqli($ins_stmt, $link);
$manager_chat_id=mysqli_insert_id($link);
@@ -174,16 +181,33 @@ if ($action=="CreateAgentToAgentChat" && $agent_manager && $agent_user && $manag
$manager_message = preg_replace("/\r/i",'',$manager_message);
$manager_message = preg_replace("/\n/i",' ',$manager_message);
# $manager_message=addslashes(trim("$manager_message"));
+
+ $message_id=date("U").".".rand(10000000,99999999);
- $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=mysql_to_mysqli($ins_chat_stmt, $link);
+ $mgr_stmt="select concat(manager, selected_agents) as participants from vicidial_manager_chats where manager_chat_id='$manager_chat_id'";
+ $mgr_rslt=mysql_to_mysqli($mgr_stmt, $link);
+ $mgr_row=mysqli_fetch_row($mgr_rslt);
+ $participants=preg_replace("/\|$/", "", $mgr_row[0]);
+ $participants_array=explode("|", $participants);
+
+ $message_id=date("U").".".rand(10000000,99999999);
+ $message_date=date("Y-m-d H:i:s");
+
+ # post message to each user, use $error_msg variable to ensure every insert command worked
+ $error_msg="";
+ while (list($key, $val) = each($participants_array)) {
+ $participant=$val;
+ $ins_chat_stmt="insert into vicidial_manager_chat_log(manager_chat_id, manager_chat_subid, manager, user, message, message_id, message_date, message_posted_by) VALUES('$manager_chat_id', '$subid', '$agent_manager', '$participant', '".mysqli_real_escape_string($link, $manager_message)."', '$message_id', '$message_date', '$agent_manager')";
+ $ins_chat_rslt=mysql_to_mysqli($ins_chat_stmt, $link);
+ }
+
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";
+ $stmt="select vm.message_posted_by, vm.message, vm.message_date, vu.full_name, vm.manager, vm.manager_chat_subid, vmc.chat_start_date, vm.message_posted_by 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 and vm.user='$user' order by vm.manager_chat_subid asc, message_date desc";
$rslt=mysql_to_mysqli($stmt, $link);
if ($debug==1) {echo "$stmt \n";}
@@ -197,6 +221,7 @@ if ($action=="DisplayMgrAgentChat" && $manager_chat_id && $manager_chat_subid &&
$backlog_limit=20;
$chat_output_text="";
+/*
$chat_color_stmt="select std_row1_background, std_row2_background from system_settings s, vicidial_screen_colors v where s.agent_screen_colors=v.colors_id and length(frame_background)=6 and length(menu_background)=6 limit 1;";
$color_rslt=mysql_to_mysqli($chat_color_stmt, $link);
if(mysqli_num_rows($color_rslt)>0 && $use_agent_colors>0) {
@@ -207,6 +232,28 @@ if ($action=="DisplayMgrAgentChat" && $manager_chat_id && $manager_chat_subid &&
$color_array=array("#0000FF", "#FF0000");
$chat_background_array=array("#CCCCFF", "#FFCCCC");
}
+*/
+
+ # Create color-coding for chat
+ $cc_stmt="select * from vicidial_manager_chat_log where manager_chat_id='$manager_chat_id' and manager_chat_subid='$manager_chat_subid' order by message_date asc";
+ $cc_rslt=mysql_to_mysqli($cc_stmt, $link);
+ $chat_members=array();
+ while ($cc_row=mysqli_fetch_row($cc_rslt)) {
+ if (!in_array("$cc_row[9]", $chat_members)) {
+ array_push($chat_members, "$cc_row[9]");
+ }
+ }
+
+ $chat_color_stmt="select menu_background, frame_background, std_row1_background, std_row2_background, std_row3_background, std_row4_background, std_row5_background from system_settings s, vicidial_screen_colors v where s.agent_screen_colors=v.colors_id and length(frame_background)=6 and length(menu_background)=6 limit 1;";
+ $color_rslt=mysql_to_mysqli($chat_color_stmt, $link);
+ if(mysqli_num_rows($color_rslt)>0 && $use_agent_colors>0) {
+ $color_row=mysqli_fetch_array($color_rslt);
+ $color_array=array("#000000", "#000000", "#000000", "#000000", "#000000", "#000000", "#000000");
+ $chat_background_array=array("#$color_row[std_row1_background]", "#$color_row[std_row2_background]", "#$color_row[std_row3_background]", "#$color_row[std_row4_background]", "#$color_row[std_row5_background]", "#$color_row[frame_background]", "#$color_row[menu_background]");
+ } else {
+ $color_array=array("#FF0000", "#0000FF", "#009900", "#990099", "#009999", "#666600", "#999999");
+ $chat_background_array=array("#FFCCCC", "#CCCCFF", "#CCFFCC", "#FFCCFF", "#CCFFFF", "#CCCC99", "#CCCCCC");
+ }
while($row=mysqli_fetch_row($rslt)) {
if (!$chat_start_date) {$chat_start_date=$row[6];}
@@ -215,11 +262,13 @@ if ($action=="DisplayMgrAgentChat" && $manager_chat_id && $manager_chat_subid &&
# Current agent is always the blue text
# if ($row[0]!=$user) {$fc="#990000";} else {$fc="#000099";}
- if ($row[0]!=$user) {
- $chat_color_key=1;
- } else {
- $chat_color_key=0;
- }
+ #if ($row[0]!=$user) {
+ # $chat_color_key=1;
+ #} else {
+ # $chat_color_key=0;
+ #}
+ $chat_color_key=array_search("$row[7]", $chat_members);
+
$chat_output_text="
$row[1]
".$chat_output_text;
@@ -231,28 +280,49 @@ if ($action=="DisplayMgrAgentChat" && $manager_chat_id && $manager_chat_subid &&
$chat_output_text.="";
- $reply_stmt="select allow_replies from vicidial_manager_chats where manager_chat_id='$manager_chat_id'";
+ $reply_stmt="select allow_replies, internal_chat_type 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];
+ $internal_chat_type=$reply_row[1]; # Need this returned to determine if agent side can add agents to this chat (manager chats, they should not be able to)
+ $display_name="";
+
+ $participant_stmt="select concat(manager, selected_agents) as participants from vicidial_manager_chats where manager_chat_id='$manager_chat_id'";
+ $participant_rslt=mysql_to_mysqli($participant_stmt, $link);
+ $prow=mysqli_fetch_row($participant_rslt);
+ $participants=preg_replace("/\|$/", "", $prow[0]);
+ $mgr_stmt="select full_name from vicidial_users where user in ('".preg_replace("/\|/", "','", $participants)."') and user!='$user'";
+ $mgr_rslt=mysql_to_mysqli($mgr_stmt, $link);
+ $display_name="";
+ while ($mgr_row=mysqli_fetch_row($mgr_rslt)) {
+ $display_name.=$mgr_row[0];
+ $display_name.=", ";
+ }
+ $display_name=preg_replace("/, $/", "", $display_name);
+
+/*
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) {
+ if (mysqli_num_rows($mgr_rslt)==0) { # Used to be !=1, but can't use that now because it returns all participants
$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_stmt="select full_name from vicidial_users where user='$manager'";
+ $mgr_stmt="select full_name from vicidial_users where user in ('$participants') and user!='$user'";
$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;
+ $other_participants
+ }
+*/
+
+ echo $allow_replies."\n".$chat_output_text."\n".$chat_start_date."\n".$display_name."\n".$new_messages."\n".$internal_chat_type;
} else {
echo "N\n"._QXZ("CHAT ENDED")."\n\n";
}
@@ -289,7 +359,7 @@ if ($action=="EndAgentToAgentChat" && $manager_chat_id && $user) {
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_stmt="select manager_chat_id, manager_chat_subid, sum(if(message_viewed_date is not null and vicidial_manager_chat_log.user='$user', 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=mysql_to_mysqli($unread_stmt, $link);
while ($unread_row=mysqli_fetch_array($unread_rslt)) {
$IDNumber=$unread_row["manager_chat_id"]."-".$unread_row["manager_chat_subid"]."-".$unread_row["unread_count"];
@@ -297,7 +367,7 @@ if ($action=="RefreshActiveChatView" && $user) {
}
# 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";
+ $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 and vicidial_manager_chat_log.user='$user', 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=mysql_to_mysqli($stmt, $link);
$active_chats_array=array();
@@ -317,7 +387,7 @@ if ($action=="RefreshActiveChatView" && $user) {
}
# 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_stmt="select manager_chat_id, manager_chat_subid, sum(if(message_viewed_date is not null and vicidial_manager_chat_log.user='$user', 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=mysql_to_mysqli($unread_stmt, $link);
while ($unread_row=mysqli_fetch_array($unread_rslt)) {
$IDNumber=$unread_row["manager_chat_id"]."-".$unread_row["manager_chat_subid"]."-".$unread_row["unread_count"];
@@ -327,7 +397,7 @@ if ($action=="RefreshActiveChatView" && $user) {
### 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";
+ $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 and vicidial_manager_chat_log.user='$user', 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=mysql_to_mysqli($stmt, $link);
while ($row=mysqli_fetch_row($rslt)) {
if ($row[0]!="") {
@@ -350,7 +420,8 @@ if ($action=="RefreshActiveChatView" && $user) {
sort($active_chats_array);
asort($chat_managers_array);
- if ($new_ChatReloadIDNumber!=$ChatReloadIDNumber) {
+# Removed this on 2016-12-09, because a) the active chat display should be refreshing when an agent is added to a chat, and the agent already in the chat isn't seeing the change, and b) the below section isn't querying the database anyway, so it won't affect page performance.
+# if ($new_ChatReloadIDNumber!=$ChatReloadIDNumber) {
echo "$new_ChatReloadIDNumber|";
echo "
";
if (empty($chat_managers_array)) {
@@ -359,11 +430,21 @@ if ($action=="RefreshActiveChatView" && $user) {
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
\n"; # $chat_managers_array[$manager_chat_id]
+ $additional_agents_stmt="select concat(manager, selected_agents) as participants from vicidial_manager_chats where manager_chat_id='$manager_chat_id'";
+ $additional_agents_rslt=mysql_to_mysqli($additional_agents_stmt, $link);
+ $aa_row=mysqli_fetch_row($additional_agents_rslt);
+ $additional_agents=preg_replace("/^\||\|$/", "", $aa_row[0]);
+ $additional_agents=preg_replace("/\|/", "','", $additional_agents);
+ $full_name_stmt="select full_name from vicidial_users where user in ('$additional_agents') and user!='$user' order by full_name asc";
+ $full_name_rslt=mysql_to_mysqli($full_name_stmt, $link);
+ while ($fname_row=mysqli_fetch_row($full_name_rslt)) {
+ echo "\t
";
- $sub_stmt="select manager_chat_subid, v.user, vu.full_name, count(*) from vicidial_manager_chat_log_archive v, vicidial_users vu where manager_chat_id='".$row["manager_chat_id"]."' and v.user=vu.user $matching_text_subid_SQL group by manager_chat_subid, user, full_name order by manager_chat_subid asc";
+ $sub_stmt="select manager_chat_subid, v.user, vu.full_name, count(*) from vicidial_manager_chat_log_archive v, vicidial_users vu where manager_chat_id='".$row["manager_chat_id"]."' and v.user!=v.manager and v.user=vu.user $matching_text_subid_SQL group by manager_chat_subid, user, full_name order by manager_chat_subid asc";
if ($DB) {echo "$sub_stmt \n";}
$sub_rslt=mysql_to_mysqli($sub_stmt, $link);
$ASCII_text.="";
- $ASCII_text.="+---------+-------------+------------------------------+\n";
- $ASCII_text.=" | "._QXZ("CHAT SUB-ID",11)." | "._QXZ("AGENT",28)." |\n";
- $ASCII_text.=" +-------------+------------------------------+\n";
+ $ASCII_text.="+---------+-------------+------------------------------------------+\n";
+ $ASCII_text.=" | "._QXZ("CHAT SUB-ID",11)." | "._QXZ("AGENT",40)." |\n";
+ $ASCII_text.=" +-------------+------------------------------------------+\n";
$GRAPH_text.="