Added show_email variable for chat_customer

Added missing entry_date field on vicidial_list insert on new emails
Fixed issue where non-phone leads were not updating, and a lead_info issue, in vdc_db_query.php

git-svn-id: svn://192.168.202.10@2472 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
mattf
2016-01-21 03:38:25 +00:00
parent 800d279282
commit dc891d5959
6 changed files with 75 additions and 18 deletions
+4 -3
View File
@@ -10,7 +10,7 @@ use Encode qw(from_to decode encode);
use MIME::Base64;
use MIME::QuotedPrint;
# Copyright (C) 2014 Matt Florell, Joe Johnson <vicidial@gmail.com> LICENSE: AGPLv2
# Copyright (C) 2016 Matt Florell, Joe Johnson <vicidial@gmail.com> LICENSE: AGPLv2
#
# AST_inbound_email_parser.pl - This script is essential for periodically checking any active POP3 or IMAP
# email accounts set up through the Vicidial admin.
@@ -61,6 +61,7 @@ use MIME::QuotedPrint;
# 140422-1912 - Added 'related' content type
# 150513-2310 - Added pop3_auth_mode
# 151030-0557 - Small change to catch more attachments properly
# 160120-2149 - Added missing entry_date field on vicidial_list insert
#
# default path to astguiclient configuration file:
@@ -561,7 +562,7 @@ while (@row=$rslt->fetchrow_array) {
my @lead_id_row=$vicidial_lead_check_rslt->fetchrow_array;
$lead_id=$lead_id_row[0];
} else {
my $vicidial_list_stmt="insert into vicidial_list(list_id, email, comments, status) values('$default_list_id', '$email_from', '".substr($message,0,255)."', '$status')";
my $vicidial_list_stmt="insert into vicidial_list(list_id, email, comments, status, entry_date) values('$default_list_id', '$email_from', '".substr($message,0,255)."', '$status', NOW())";
if ($DBX) {print $vicidial_list_stmt;}
my $vicidial_list_rslt=$dbhA->prepare($vicidial_list_stmt);
if ($vicidial_list_rslt->execute()) {
@@ -899,7 +900,7 @@ while (@row=$rslt->fetchrow_array) {
my @lead_id_row=$vicidial_lead_check_rslt->fetchrow_array;
$lead_id=$lead_id_row[0];
} else {
my $vicidial_list_stmt="insert into vicidial_list(list_id, email, comments, status) values('$default_list_id', '$email_from', '".substr($message,0,255)."', '$status')";
my $vicidial_list_stmt="insert into vicidial_list(list_id, email, comments, status, entry_date) values('$default_list_id', '$email_from', '".substr($message,0,255)."', '$status', NOW())";
if ($DBX) {print $vicidial_list_stmt."\n";}
my $vicidial_list_rslt=$dbhA->prepare($vicidial_list_stmt);
if ($vicidial_list_rslt->execute()) {
+2 -1
View File
@@ -1,4 +1,4 @@
CHAT MESSAGING Started 2014-05-01 Updated 2016-01-08
CHAT MESSAGING Started 2014-05-01 Updated 2016-01-20
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.
@@ -57,6 +57,7 @@ There are several variables you can use to assemble a link to a customer chat wi
language - if different than default English, the language the customer chat screen should use
available_agents - only allow chats to start if there are LOGGED_IN agents or WAITING_ONLY agents available
status_link - set to Y if you want to use as a button only on your website showing if chat agents are available or not(150 x 37 pixels)
show_email - set to ONLY if you want to only show the email field, Y_WITH_PHONE if you want both email and phone fields
If you want to link to chat with a specific in-group, you can use a link like this,
+6 -5
View File
@@ -399,10 +399,11 @@
# 151229-2316 - Added manual_dial_timeout campaign setting
# 160108-2300 - Changed some mysqli_query to mysql_to_mysqli for consistency
# 160109-0747 - Added manual_dial_hopper_check campaign setting
# 160120-2226 - Fixed issue where non-phone leads were not updating, and lead_info issue
#
$version = '2.12-293';
$build = '160109-0747';
$version = '2.12-294';
$build = '160120-2226';
$php_script = 'vdc_db_query.php';
$mel=1; # Mysql Error Log enabled = 1
$mysql_log_count=654;
@@ -11698,7 +11699,7 @@ if ($ACTION == 'updateLEAD')
$row=''; $rowx='';
$DO_NOT_UPDATE=0;
$DO_NOT_UPDATE_text='';
if ( (strlen($phone_number)<1) || (strlen($lead_id)<1) )
if ( ( (strlen($phone_number)<1) and (strlen($email)<1) ) or (strlen($lead_id)<1) )
{
echo _QXZ("phone_number %1s or lead_id %2s is not valid",0,'',$phone_number,$lead_id)."\n";
if ($SSagent_debug_logging > 0) {vicidial_ajax_log($NOW_TIME,$startMS,$link,$ACTION,$php_script,$user,$stage,$lead_id,$session_name,$stmt);}
@@ -13973,8 +13974,8 @@ if ($ACTION == 'LEADINFOview')
$stmt="SELECT count(*) from vicidial_call_times where call_time_id='$list_local_call_time';";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00615',$user,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$call_time_exists = $row[0];
$rowc=mysqli_fetch_row($rslt);
$call_time_exists = $rowc[0];
if ($call_time_exists < 1)
{$list_local_call_time = 'campaign';}
}
+4 -1
View File
@@ -11,6 +11,7 @@
# 151217-1015 - Allow for group_id variable
# 151219-1415 - Added header and language variable
# 160108-1659 - Added available_agents variable
# 160120-1944 - Added show_email variable
#
if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];}
@@ -29,8 +30,10 @@ if (isset($_GET["language"])) {$language=$_GET["language"];}
elseif (isset($_POST["language"])) {$language=$_POST["language"];}
if (isset($_GET["available_agents"])) {$available_agents=$_GET["available_agents"];}
elseif (isset($_POST["available_agents"])) {$available_agents=$_POST["available_agents"];}
if (isset($_GET["show_email"])) {$show_email=$_GET["show_email"];}
elseif (isset($_POST["show_email"])) {$show_email=$_POST["show_email"];}
$URL_vars="?user=".urlencode($unique_userID)."&lead_id=".$lead_id."&group_id=".urlencode($chat_group_id)."&chat_id=".$chat_id."&email=".urlencode($email)."&language=".urlencode($language)."&available_agents=".urlencode($available_agents);
$URL_vars="?user=".urlencode($unique_userID)."&lead_id=".$lead_id."&group_id=".urlencode($chat_group_id)."&chat_id=".$chat_id."&email=".urlencode($email)."&language=".urlencode($language)."&available_agents=".urlencode($available_agents)."&show_email=".urlencode($show_email);
header ("Content-type: text/html; charset=utf-8");
header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header ("Pragma: no-cache"); // HTTP/1.0
@@ -7,6 +7,7 @@
# 151217-1016 - Allow for carrying of group_id through to new chat
# 151219-0850 - Added translation code
# 160108-1710 - Added available_agents variable
# 160120-1943 - Added show_email variable
#
require("dbconnect_mysqli.php");
@@ -43,6 +44,8 @@ if (isset($_GET["language"])) {$language=$_GET["language"];}
elseif (isset($_POST["language"])) {$language=$_POST["language"];}
if (isset($_GET["available_agents"])) {$available_agents=$_GET["available_agents"];}
elseif (isset($_POST["available_agents"])) {$available_agents=$_POST["available_agents"];}
if (isset($_GET["show_email"])) {$show_email=$_GET["show_email"];}
elseif (isset($_POST["show_email"])) {$show_email=$_POST["show_email"];}
$chat_member_name = preg_replace('/[^- \.\,\_0-9a-zA-Z]/',"",$chat_member_name);
if (!$user) {echo "No user, no using."; exit;}
@@ -54,6 +57,7 @@ $group_id = preg_replace('/[^- \_0-9a-zA-Z]/','',$group_id);
$language = preg_replace('/[^-\_0-9a-zA-Z]/','',$language);
$chat_member_name = preg_replace("/\'|\"|\\\\|;/","",$chat_member_name);
$available_agents = preg_replace('/[^-\_0-9a-zA-Z]/','',$available_agents);
$show_email = preg_replace('/[^-\_0-9a-zA-Z]/','',$show_email);
if ($non_latin < 1)
{
@@ -178,7 +182,7 @@ 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'>"._QXZ("Chat does not exist or has been closed").": $chat_id</font><BR/><BR/><font class='chat_title'><a href='".$chat_url."?group_id=$group_id&language=$language&available_agents=$available_agents'>"._QXZ("GO BACK TO CHAT FORM")."</a></font>\n";
echo "<font class='chat_title alert'>"._QXZ("Chat does not exist or has been closed").": $chat_id</font><BR/><BR/><font class='chat_title'><a href='".$chat_url."?group_id=$group_id&language=$language&available_agents=$available_agents&show_email=$show_email'>"._QXZ("GO BACK TO CHAT FORM")."</a></font>\n";
} else {
$status_row=mysqli_fetch_row($status_rslt);
@@ -223,7 +227,7 @@ if ($action=="update_chat_window" && $chat_id) {
echo "<input type='hidden' id='current_message_count' name='current_message_count' value='$current_messages'>\n";
} else {
echo "<font class='chat_title bold'>"._QXZ("You have left chat").": $chat_id.</font><BR/><BR/><font class='chat_title'><a href='".$chat_url."?group_id=$group_id&language=$language&available_agents=$available_agents'>"._QXZ("GO BACK TO CHAT FORM")."</a></font>\n";
echo "<font class='chat_title bold'>"._QXZ("You have left chat").": $chat_id.</font><BR/><BR/><font class='chat_title'><a href='".$chat_url."?group_id=$group_id&language=$language&available_agents=$available_agents&show_email=$show_email'>"._QXZ("GO BACK TO CHAT FORM")."</a></font>\n";
}
} else {
if ($status_row[1]=="NONE") {
@@ -15,6 +15,7 @@
# 151219-0850 - Added translation code
# 151220-0959 - Only search for phone number if greater than 4 digits
# 160108-1700 - Added available_agents, status_link button options and validation of active in-group
# 160120-1925 - Fixed missing list_id on vicidial_list inserts, Issue #915. Added show_email option
#
require("dbconnect_mysqli.php");
@@ -48,6 +49,8 @@ if (isset($_GET["available_agents"])) {$available_agents=$_GET["available_agen
elseif (isset($_POST["available_agents"])) {$available_agents=$_POST["available_agents"];}
if (isset($_GET["status_link"])) {$status_link=$_GET["status_link"];}
elseif (isset($_POST["status_link"])) {$status_link=$_POST["status_link"];}
if (isset($_GET["show_email"])) {$show_email=$_GET["show_email"];}
elseif (isset($_POST["show_email"])) {$show_email=$_POST["show_email"];}
$PHP_SELF=$_SERVER["PHP_SELF"];
$lead_id = preg_replace("/[^0-9]/","",$lead_id);
@@ -56,6 +59,7 @@ $group_id = preg_replace('/[^- \_0-9a-zA-Z]/','',$group_id);
$language = preg_replace('/[^-\_0-9a-zA-Z]/','',$language);
$available_agents = preg_replace('/[^-\_0-9a-zA-Z]/','',$available_agents);
$status_link = preg_replace('/[^-\_0-9a-zA-Z]/','',$status_link);
$show_email = preg_replace('/[^-\_0-9a-zA-Z]/','',$show_email);
if ($non_latin < 1)
{
@@ -197,7 +201,7 @@ if (strlen($group_id) > 1)
if ($status_link == 'Y')
{
echo "<a href=\"".$PHP_SELF."?group_id=$group_id&language=$language&available_agents=$available_agents\"><img src=\"./images/"._QXZ("chat_status_button_ON.gif")."\" width=150 height=37 border=0 alt=\""._QXZ("Agents Available, click to chat now")."\"></a>";
echo "<a href=\"".$PHP_SELF."?group_id=$group_id&language=$language&available_agents=$available_agents&show_email=$show_email\"><img src=\"./images/"._QXZ("chat_status_button_ON.gif")."\" width=150 height=37 border=0 alt=\""._QXZ("Agents Available, click to chat now")."\"></a>";
exit;
}
}
@@ -253,8 +257,17 @@ if ($stage == "join_chat") { # For people invited to an existing chat from an ag
# update email and security_phrase?
$upd_rslt=mysql_to_mysqli($upd_stmt, $link);
} else if (!$error_msg) {
$stmtA = "SELECT hold_time_option_callback_list_id FROM vicidial_inbound_groups where group_id='" . mysqli_real_escape_string($link, $group_id) . "';";
$rsltA=mysql_to_mysqli($stmtA, $link);
if ($DB) {echo "$stmtA\n";}
$list_ct = mysqli_num_rows($rsltA);
if ($list_ct > 0)
{
$row=mysqli_fetch_row($rsltA);
$default_list_id = $row[0];
}
# Create lead in vicidial_list table (make special system status for waiting for chat)
$ins_stmt="INSERT INTO vicidial_list(status, first_name, last_name, email, list_id, phone_number, security_phrase) VALUES('WCHAT', '" . mysqli_real_escape_string($link, $first_name) . "', '" . mysqli_real_escape_string($link, $last_name) . "', '" . mysqli_real_escape_string($link, $email) . "', '" . mysqli_real_escape_string($link, $default_list_id) . "', '" . mysqli_real_escape_string($link, $phone_number) . "', '" . mysqli_real_escape_string($link, $group_id) . "')";
$ins_stmt="INSERT INTO vicidial_list(status, first_name, last_name, email, list_id, phone_number, security_phrase, entry_date) 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) . "',NOW())";
$ins_rslt=mysql_to_mysqli($ins_stmt, $link);
$lead_id=mysqli_insert_id($link);
}
@@ -302,10 +315,15 @@ if ($stage == 'send_request') { # For people requesting a chat with an agent; co
if (strlen($phone_number) > 4) {
$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 (strlen($email)<1)
{$email = $ip_address;}
if (mysqli_num_rows($rslt)>0) {
$row=mysqli_fetch_row($rslt);
@@ -316,8 +334,17 @@ if ($stage == 'send_request') { # For people requesting a chat with an agent; co
# update email and security_phrase?
$upd_rslt=mysql_to_mysqli($upd_stmt, $link);
} else if (!$error_msg) {
$stmtA = "SELECT hold_time_option_callback_list_id FROM vicidial_inbound_groups where group_id='" . mysqli_real_escape_string($link, $group_id) . "';";
$rsltA=mysql_to_mysqli($stmtA, $link);
if ($DB) {echo "$stmtA\n";}
$list_ct = mysqli_num_rows($rsltA);
if ($list_ct > 0)
{
$row=mysqli_fetch_row($rsltA);
$default_list_id = $row[0];
}
# Create lead in vicidial_list table (make special system status for waiting for chat)
$ins_stmt="INSERT INTO vicidial_list(status, first_name, last_name, email, list_id, phone_number, security_phrase) VALUES('WCHAT', '" . mysqli_real_escape_string($link, $first_name) . "', '" . mysqli_real_escape_string($link, $last_name) . "', '" . mysqli_real_escape_string($link, $ip_address) . "', '" . mysqli_real_escape_string($link, $default_list_id) . "', '" . mysqli_real_escape_string($link, $phone_number) . "', '" . mysqli_real_escape_string($link, $group_id) . "')";
$ins_stmt="INSERT INTO vicidial_list(status, first_name, last_name, email, list_id, phone_number, security_phrase, entry_date) 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) . "',NOW())";
$ins_rslt=mysql_to_mysqli($ins_stmt, $link);
$lead_id=mysqli_insert_id($link);
}
@@ -367,6 +394,7 @@ echo '<?xml version="1.0" encoding="UTF-8"?>
var language='<?php echo $language ?>';
var group_id='<?php echo $group_id ?>';
var available_agents='<?php echo $available_agents ?>';
var show_email='<?php echo $show_email ?>';
function PleaseWait() {
document.getElementById('chat_request_span').style.display="none";
@@ -398,7 +426,7 @@ function LeaveChat(chat_id, user, chat_member_name) {
}
if (xmlhttp)
{
chat_query = "&action=leave_chat&chat_id="+chat_id+"&group_id="+group_id+"&user="+user+"&chat_member_name="+chat_member_name+"&language="+language+"&available_agents="+available_agents;
chat_query = "&action=leave_chat&chat_id="+chat_id+"&group_id="+group_id+"&user="+user+"&chat_member_name="+chat_member_name+"&language="+language+"&available_agents="+available_agents+"&show_email="+show_email;
// alert(chat_query);
xmlhttp.open('POST', 'customer_chat_functions.php');
xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8');
@@ -433,7 +461,7 @@ function UpdateChatWindow() {
}
if (xmlhttp)
{
chat_query = "&chat_id="+chat_id+"&group_id="+group_id+"&user="+user+"&current_message_count="+current_message_count+"&language="+language+"&available_agents="+available_agents+"&action=update_chat_window&keepalive=1";
chat_query = "&chat_id="+chat_id+"&group_id="+group_id+"&user="+user+"&current_message_count="+current_message_count+"&language="+language+"&available_agents="+available_agents+"&show_email="+show_email+"&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);
@@ -470,7 +498,7 @@ function CustomerSendMessage(chat_id, user, message, chat_member_name) {
}
if (xmlhttp)
{
chat_query = "&chat_message="+chat_message+"&chat_id="+chat_id+"&group_id="+group_id+"&chat_member_name="+chat_member_name+"&user="+user+"&language="+language+"&available_agents="+available_agents+"&chat_level=0&action=send_message";
chat_query = "&chat_message="+chat_message+"&chat_id="+chat_id+"&group_id="+group_id+"&chat_member_name="+chat_member_name+"&user="+user+"&language="+language+"&available_agents="+available_agents+"&show_email="+show_email+"&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);
@@ -504,6 +532,7 @@ $chat_title= _QXZ("Request chat with agent"); # This can be modified for customi
<input type=hidden name=stage value="send_request">
<input type=hidden name=language value="<?php echo $language; ?>">
<input type=hidden name=available_agents value="<?php echo $available_agents; ?>">
<input type=hidden name=show_email value="<?php echo $show_email ?>">
<span id="chat_request_span">
<table width="500" border=0 cellpadding=1 cellspacing=1 height="300">
<tr>
@@ -539,6 +568,8 @@ $chat_title= _QXZ("Request chat with agent"); # This can be modified for customi
{
echo "<tr><td><input type=hidden name=group_id value=\"$group_id\"></td></tr>\n";
}
if ( ($show_email=='') or ($show_email=='N') or ($show_email=='Y_WITH_PHONE') )
{
?>
<tr>
<td align='right' class='body_small'><?php echo _QXZ("Phone number (optional)"); ?>:</td>
@@ -546,6 +577,20 @@ $chat_title= _QXZ("Request chat with agent"); # This can be modified for customi
<input type='text' class="cust_form" name='phone_number' id='phone_number' size='10' maxlength='20'>
</td>
</tr>
<?php
}
if ( ($show_email=='ONLY') or ($show_email=='Y_WITH_PHONE') )
{
?>
<tr>
<td align='right' class='body_small'><?php echo _QXZ("Email (optional)"); ?>:</td>
<td align='left'>
<input type='text' class="cust_form" name='email' id='email' size='50' maxlength='100'>
</td>
</tr>
<?php
}
?>
<tr>
<th colspan='2'><input type='submit' class='blue_btn' value='<?php echo _QXZ("SEND REQUEST"); ?>' name="send_request"><BR></th>
</tr>
@@ -596,6 +641,7 @@ $chat_title= _QXZ("Request chat with agent"); # This can be modified for customi
<input type="hidden" id="lead_id" name="lead_id" value="<?php echo $lead_id; ?>">
<input type="hidden" id="language" name="language" value="<?php echo $language; ?>">
<input type="hidden" id="available_agents" name="available_agents" value="<?php echo $available_agents; ?>">
<input type="hidden" id="show_email" name="show_email" value="<?php echo $show_email ?>">
</form>
</body>
@@ -649,6 +695,7 @@ $chat_title= _QXZ("Request chat with agent"); # This can be modified for customi
<input type="hidden" id="group_id" name="group_id" value="<?php echo $group_id; ?>">
<input type="hidden" id="language" name="language" value="<?php echo $language; ?>">
<input type="hidden" id="available_agents" name="available_agents" value="<?php echo $available_agents; ?>">
<input type="hidden" id="show_email" name="show_email" value="<?php echo $show_email ?>">
<audio id='CustomerChatAudioAlertFile'><source src="sounds/chat_alert.mp3" type="audio/mpeg"></audio>
</form>
</body>