Added Chat Messaging
git-svn-id: svn://192.168.202.10@2428 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
@@ -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 |
Binary file not shown.
@@ -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+"¤t_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'> <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'> <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>
|
||||
Reference in New Issue
Block a user