From 4dde6be34593c549930b6d85023ed2a603f1816f Mon Sep 17 00:00:00 2001 From: mattf Date: Sat, 9 Jan 2016 02:23:52 +0000 Subject: [PATCH] Added available_agents and status_link button options as well as validation of active in-group to the chat_customer screen. git-svn-id: svn://192.168.202.10@2464 3d104415-ff17-0410-8863-d5cf3c621b8a --- UPGRADE | 3 + docs/CHAT_MESSAGING.txt | 18 ++- www/chat_customer/customer_chat_code.php | 7 +- www/chat_customer/customer_chat_functions.php | 8 +- .../images/chat_status_button_OFF.gif | Bin 0 -> 1598 bytes .../images/chat_status_button_OFF_es.gif | Bin 0 -> 1443 bytes .../images/chat_status_button_ON.gif | Bin 0 -> 2401 bytes .../images/chat_status_button_ON_es.gif | Bin 0 -> 2185 bytes .../vicidial_chat_customer_side.php | 104 +++++++++++++++++- 9 files changed, 129 insertions(+), 11 deletions(-) create mode 100644 www/chat_customer/images/chat_status_button_OFF.gif create mode 100644 www/chat_customer/images/chat_status_button_OFF_es.gif create mode 100644 www/chat_customer/images/chat_status_button_ON.gif create mode 100644 www/chat_customer/images/chat_status_button_ON_es.gif diff --git a/UPGRADE b/UPGRADE index a85937b8..6618a134 100644 --- a/UPGRADE +++ b/UPGRADE @@ -230,6 +230,9 @@ OTHER CHANGES: 58. Added in-group option for On-Hook CID Number. +59. Added available_agents and status_link button options as well as validation + of active in-group to the chat_customer screen. + diff --git a/docs/CHAT_MESSAGING.txt b/docs/CHAT_MESSAGING.txt index 7e237cfe..8b579106 100644 --- a/docs/CHAT_MESSAGING.txt +++ b/docs/CHAT_MESSAGING.txt @@ -1,4 +1,4 @@ -CHAT MESSAGING Started 2014-05-01 Updated 2015-12-19 +CHAT MESSAGING Started 2014-05-01 Updated 2016-01-08 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. @@ -46,7 +46,17 @@ In the Administration web screen, there is a new link at the top of the screen n CUSTOMER CHAT INSTRUCTIONS: -There is a new folder in the web directory called "chat_customer". You will find a file in this folder called "customer_chat_code.php" that you can use to write your own web page for a customer to chat from, or you can just use that page as your Chat URL. The Chat URL is a field in the System Settings that you need to populate in order for the customer chat to work. To use the default for this, just add "chat_customer/customer_chat_code.php" to your current Vicidial webserver URL. For example, if your current webserver url is "http://192.168.1.2/" then you can use this as your Chat URL: "http://192.168.1.2/chat_customer/customer_chat_code.php" +There is a new folder in the web directory called "chat_customer". You will find a file in this folder called "customer_chat_code.php" that you can use to write your own web page for a customer to chat from, or you can just use that page as your Chat URL. The Chat URL is a field in the System Settings that you need to populate in order for the customer chat to work. To use the default for this, just add "chat_customer/customer_chat_code.php" to your current Vicidial webserver URL. For example, if your current webserver url is "http://192.168.1.2/" then you can use this as your Chat URL: + "http://192.168.1.2/chat_customer/customer_chat_code.php" + or + "http://192.168.1.2/chat_customer/vicidial_chat_customer_side.php" + + +There are several variables you can use to assemble a link to a customer chat window on your website: + group_id - the Inbound Chat Group that you want to use + 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) If you want to link to chat with a specific in-group, you can use a link like this, @@ -63,6 +73,10 @@ If you want to put a chat page within your own IFRAME and use a specific in-grou http://192.168.1.2/chat_customer/vicidial_chat_customer_side.php?group_id=TESTCHAT&language=new_spanish +If you want to link to a chat status button with a specific in-group and langauge and only if agents are ready and waiting, you can use a link like this, +http://192.168.1.2/chat_customer/vicidial_chat_customer_side.php?status_link=Y&user=&lead_id=&group_id=MIKECHAT&language=new_spanish&available_agents=WAITING_ONLY + + Chat settings in System Settings: diff --git a/www/chat_customer/customer_chat_code.php b/www/chat_customer/customer_chat_code.php index 8e90d23a..24ea313e 100644 --- a/www/chat_customer/customer_chat_code.php +++ b/www/chat_customer/customer_chat_code.php @@ -1,7 +1,7 @@ LICENSE: AGPLv2 +# Copyright (C) 2016 Joe Johnson, Matt Florell 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. @@ -10,6 +10,7 @@ # 151212-0829 - First Build for customer chat # 151217-1015 - Allow for group_id variable # 151219-1415 - Added header and language variable +# 160108-1659 - Added available_agents variable # if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];} @@ -26,8 +27,10 @@ if (isset($_GET["unique_userID"])) {$unique_userID=$_GET["unique_userID"];} elseif (isset($_POST["unique_userID"])) {$unique_userID=$_POST["unique_userID"];} 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"];} -$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); +$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); 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 diff --git a/www/chat_customer/customer_chat_functions.php b/www/chat_customer/customer_chat_functions.php index 11886954..874669ac 100644 --- a/www/chat_customer/customer_chat_functions.php +++ b/www/chat_customer/customer_chat_functions.php @@ -6,6 +6,7 @@ # 151213-1106 - Added variable filtering # 151217-1016 - Allow for carrying of group_id through to new chat # 151219-0850 - Added translation code +# 160108-1710 - Added available_agents variable # require("dbconnect_mysqli.php"); @@ -40,6 +41,8 @@ if (isset($_GET["current_message_count"])) {$current_message_count=$_GET["curr elseif (isset($_POST["current_message_count"])) {$current_message_count=$_POST["current_message_count"];} if (isset($_GET["language"])) {$language=$_GET["language"];} elseif (isset($_POST["language"])) {$language=$_POST["language"];} +if (isset($_GET["available_agents"])) {$available_agents=$_GET["available_agents"];} + elseif (isset($_POST["available_agents"])) {$available_agents=$_POST["available_agents"];} $chat_member_name = preg_replace('/[^- \.\,\_0-9a-zA-Z]/',"",$chat_member_name); if (!$user) {echo "No user, no using."; exit;} @@ -50,6 +53,7 @@ $chat_level = preg_replace('/[^- \_\.0-9a-zA-Z]/','',$chat_level); $group_id = preg_replace('/[^- \_0-9a-zA-Z]/','',$group_id); $language = preg_replace('/[^-\_0-9a-zA-Z]/','',$language); $chat_member_name = preg_replace("/\'|\"|\\\\|;/","",$chat_member_name); +$available_agents = preg_replace('/[^-\_0-9a-zA-Z]/','',$available_agents); if ($non_latin < 1) { @@ -174,7 +178,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 ""._QXZ("Chat does not exist or has been closed").": $chat_id

"._QXZ("GO BACK TO CHAT FORM")."\n"; + echo ""._QXZ("Chat does not exist or has been closed").": $chat_id

"._QXZ("GO BACK TO CHAT FORM")."\n"; } else { $status_row=mysqli_fetch_row($status_rslt); @@ -219,7 +223,7 @@ if ($action=="update_chat_window" && $chat_id) { echo "\n"; } else { - echo ""._QXZ("You have left chat").": $chat_id.

"._QXZ("GO BACK TO CHAT FORM")."\n"; + echo ""._QXZ("You have left chat").": $chat_id.

"._QXZ("GO BACK TO CHAT FORM")."\n"; } } else { if ($status_row[1]=="NONE") { diff --git a/www/chat_customer/images/chat_status_button_OFF.gif b/www/chat_customer/images/chat_status_button_OFF.gif new file mode 100644 index 0000000000000000000000000000000000000000..499d748eff2051f3d093aa1af0e0d6386d276111 GIT binary patch literal 1598 zcmd7P2V0T}007_*l2XLNd5%oHmf%RwEX@XjmqA)ed576`IdXIj>oCje0TofXOf9r! zLq$cFxHT6jjxdc7etv#IK|x_*VNp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)X*H_N{GqeBGr0 lfvTz77^Av2#X0nRmF)e^56Oi7CDY2imy(a>LoK0z?>{CKI^6&O literal 0 HcmV?d00001 diff --git a/www/chat_customer/images/chat_status_button_ON.gif b/www/chat_customer/images/chat_status_button_ON.gif new file mode 100644 index 0000000000000000000000000000000000000000..f3a215167af0af381a03e301ac35a1f4dbd9d4bc GIT binary patch literal 2401 zcmdVZi9geg1Hkd`zNlfI9Ldr(BsW{pt6$eMM{Gkylp~p|Mresps%@BS6>=8k&KYx! zM?KBa9H}OAOXi$gwAh%Q{29N`>-{f$EU@M${^yngr~}h1z_#1|Quk$Bj=de{iap2S zGRN@>$H{@??AUYFsmH~+=i1dC*Wiz#F1`3`y>70(?)Y90_dZYeJ}-~H>z;i#uJ;qJ z_j?oieF*(Gy$5`Kw)x#0@b}$z%YTsQKY07rU;y!tp*y#S0t2=M-5I(YICM8?I5=oH z*ii&4SN@hw+X3DCk zYD#Cz%4Xk`&6dBJEia#?SIp7rbCvYDs>->ls=1n)`P!O!M(sRr&f?Wfp5&YwL1b+j4uykB*N&Iy--K zep>nbdD|EE3Y)#s^>y{@*VXRsRSsvhr{`yH@3y|apZ)#Y1_twXyNF@$t2ZiM5Hz^{J`#sp<9U>2)4&oj0>SGb5Ot70k{F=H>+R z^Md&W!NP)YaZ$LqBwSh&E-wq0e+Ym4*jQQFSXtdzUETQkbK@s}gU{dm^=tFj+UDBY z=KA{Px?ocv5DA4M;f82qL$tXm+7yXIzyGgN*^)C2@Nx_E@`ia;D9 z1^fndfj@1J0zkKb-y+le>A1#lsDk#@wuG zBX;coZHuqASLT0AMS65(V5Hr$Jd zz||Dn=UyT!^Snw^A;m{`4-60TbuN0aY;zvh*LpeUINlbbZxy)@jMHATwTH%w@ zkwkt@o{8RQZG~5Nt&GGTUCm^OG)XtT@>AV$F^*8NQK<~j3SwLL^qNn*A$^1WTk5L- z%S@Fmy4~mDP!do^IU~D_?$_bPpS)FR?TQZjXSE@C%2{;p*Yma>yKoc*%2t-qGIH6dcMncCHG%PSdFkMUWtV@Ayr|8isCRJ)kK{b@-&AoYd&@m2WRp=RqQWGbqWEV#_WYg`Ozu8K2HK`i*PGnZ!RS> z;LXx$T4a;dD0!>FlooZnoW5H(evb$x&dWz-$wOITiHQnyA|(K+t(5fN#<8(d8ELAiS-YC5F-v@#c3D|@V-3#JMtDQ!s zRtj%T7u;bm@%=>|_P&e*3Iiqwdeis$_xUjZ;!Zw#>tGdZHTH4v&WH9R6ea&UtB6By z*2hA`I@ZUZY8-^;>kB^EI-EEIwCXVNU_@V*YkTsQefJsiP8Jc1%zY)|;Zn+uy& z5MUGa+4lHO?WB^!0(w)sr(mY>O9a3Q6fsru@AcT9bYWHnpdW~Hu&GD7*W9dR!8CNL zBp5Phv7{yUZ;N(KH405@%6zpYJarZss~5Xt=R4qU!b+UR*}9fUR5Fh#26cm3>n`aP zI6Co2H(&-F4QZCBso?Z8L)DbN}Z6QnX&CP`%~o&i@T0fkmkF!HTFZhvLV4ps)|#S zBAt5?rzMv_rjfHIv06YCyg$-bqA7>N%6AY>`!xzh;eRw7`#p*mr0S|`qXMT>z&%3tfZFFLpmGw{%)l|{*vot~=ySka zgVvo0<&gI@kjyR&cvmN7S$VlDp5Hz46)-9^ftNU#irIm{E*BH^wfV?AYE*nada;K3 z%%DR_YDJ-c@Hi1;9ErVpe`v(^oW|*{XbjbIcuYA}^{^b~!jq4~Qzsc}N^%%90G#>{ D5pN~U literal 0 HcmV?d00001 diff --git a/www/chat_customer/images/chat_status_button_ON_es.gif b/www/chat_customer/images/chat_status_button_ON_es.gif new file mode 100644 index 0000000000000000000000000000000000000000..3126bff7abcdfd5131e5e473b884656533d93c0f GIT binary patch literal 2185 zcmd_p`#;l*1IO{tX4r->M2=1qg|SY3lT@dgrHe_YR^(QvxA3^Vt+3^UvK+TZbgJ)VES`G68XtVgDJ^_sVRdG zQU@PC7+RN>Hk6(|M5PWt&QQwC6l7%zo@5EKpC~=e7Cd`8vM%S@NN&zZZtlp7=fZV) zFN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EY^N+ur7wG{=7V0hw{Y5;|8=VBCT97etdI^LCl^SAWK{&#%)p=ss7QrbrE9p) zb_-CWJH+Z})!JnI&{WR3IQ7@YwK{jADe#R{XX{K?3mI z(WbVRApneY-0&frihuYvBSBC!10_QMszz3hx05i+Fcwe5YSK-~W`}mgc|h}@{2Obc z4phP&XGJ%xJp6aZ?R~O4m!h-Tp7sZMAI>-I>^3e@X!+N0Ya5T8U^4a~?c)K{$ z%4*bJwHD-1fz>u}8xz_UB-w*f>mi^MpvNZkPc@5Y)iVik=02wlI0nQU>K^PP7IzF7 z-UZ0R1trHA6#bLgj)lKzF-{Zf^&TV&iY#3iI4dlIyx?2B^8w@JfiPV%1OgoR9|r!_ A*8l(j literal 0 HcmV?d00001 diff --git a/www/chat_customer/vicidial_chat_customer_side.php b/www/chat_customer/vicidial_chat_customer_side.php index 932580fd..c36ed8db 100644 --- a/www/chat_customer/vicidial_chat_customer_side.php +++ b/www/chat_customer/vicidial_chat_customer_side.php @@ -1,7 +1,7 @@ LICENSE: AGPLv2 +# Copyright (C) 2016 Joe Johnson, Matt Florell 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 @@ -14,6 +14,7 @@ # 151217-1017 - Allow for pre-populating of group_id # 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 # require("dbconnect_mysqli.php"); @@ -43,12 +44,18 @@ if (isset($_GET["language"])) {$language=$_GET["language"];} elseif (isset($_POST["language"])) {$language=$_POST["language"];} if (isset($_GET["stage"])) {$stage=$_GET["stage"];} elseif (isset($_POST["stage"])) {$stage=$_POST["stage"];} +if (isset($_GET["available_agents"])) {$available_agents=$_GET["available_agents"];} + 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"];} $PHP_SELF=$_SERVER["PHP_SELF"]; $lead_id = preg_replace("/[^0-9]/","",$lead_id); $chat_id = preg_replace('/[^- \_\.0-9a-zA-Z]/','',$chat_id); $group_id = preg_replace('/[^- \_0-9a-zA-Z]/','',$group_id); $language = preg_replace('/[^-\_0-9a-zA-Z]/','',$language); +$available_agents = preg_replace('/[^-\_0-9a-zA-Z]/','',$available_agents); +$status_link = preg_replace('/[^-\_0-9a-zA-Z]/','',$status_link); if ($non_latin < 1) { @@ -109,9 +116,92 @@ if (strlen($language) > 1) if ($SSallow_chats < 1) { header ("Content-type: text/html; charset=utf-8"); - echo _QXZ("Error, chat disabled on this system"); + if ($status_link == 'Y') + {echo "\""._QXZ("no";} + else + {echo _QXZ("Error, chat disabled on this system");} exit; } +if (strlen($group_id) > 1) + { + $group_active='N'; + $group_name=''; + $stmt = "SELECT active,group_name FROM vicidial_inbound_groups where group_id='$group_id';"; + $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";} + $group_good_ct = mysqli_num_rows($rslt); + if ($group_good_ct > 0) + { + $row=mysqli_fetch_row($rslt); + $group_active = $row[0]; + $group_name = $row[1]; + } + + if ($group_active == 'N') + { + header ("Content-type: text/html; charset=utf-8"); + if ($status_link == 'Y') + {echo "\""._QXZ("no";} + else + {echo _QXZ("Error, group is not active").": $group_id $group_name";} + exit; + } + + if ($available_agents == 'WAITING_ONLY') + { + $waiting_agents=0; + $stmt = "SELECT count(*) FROM vicidial_live_agents where closer_campaigns LIKE \"% $group_id %\" and status IN('READY','CLOSER');"; + $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";} + $group_good_ct = mysqli_num_rows($rslt); + if ($group_good_ct > 0) + { + $row=mysqli_fetch_row($rslt); + $waiting_agents = $row[0]; + } + if ($waiting_agents < 1) + { + header ("Content-type: text/html; charset=utf-8"); + if ($status_link == 'Y') + {echo "\""._QXZ("no";} + else + {echo _QXZ("We are sorry, there are no waiting agents at this time. Please try again later.").": $group_id $group_name";} + exit; + } + } + if ($available_agents == 'LOGGED_IN') + { + $loggedin_agents=0; + $stmt = "SELECT count(*) FROM vicidial_live_agents where closer_campaigns LIKE \"% $group_id %\";"; + $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";} + $group_good_ct = mysqli_num_rows($rslt); + if ($group_good_ct > 0) + { + $row=mysqli_fetch_row($rslt); + $loggedin_agents = $row[0]; + } + if ($loggedin_agents < 1) + { + header ("Content-type: text/html; charset=utf-8"); + if ($status_link == 'Y') + {echo "\""._QXZ("no";} + else + {echo _QXZ("We are sorry, there are no logged in agents at this time. Please try again later.").": $group_id $group_name";} + exit; + } + } + + if ($status_link == 'Y') + { + echo "\""._QXZ("Agents"; + exit; + } + } + # http://192.168.1.2/chat_customer/vicidial_chat_customer_side.php?user=1440723435.60926&lead_id=1079350&group_id=CHAT_TEST_GROUP&chat_id=254&email=joej%40test.com @@ -276,6 +366,7 @@ echo '