Added scheduled_callbacks_email_alert campaign option

git-svn-id: svn://192.168.202.10@2842 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
mattf
2017-10-19 02:12:27 +00:00
parent c081886ffe
commit 1ddc0a1efb
6 changed files with 234 additions and 13 deletions
+4
View File
@@ -214,6 +214,10 @@ OTHER CHANGES:
53. Added Webphone Layout option in Phones and override in User Groups 53. Added Webphone Layout option in Phones and override in User Groups
54. Added campaigns-scheduled_callbacks_email_alert option to send email alerts
to agents when scheduled callbacks are triggered while they are logged
in to the agent screen. Read the HELP for instructions to set up.
@@ -988,7 +988,8 @@ agent_xfer_validation ENUM('N','Y') default 'N',
ready_max_logout MEDIUMINT(7) default '0', ready_max_logout MEDIUMINT(7) default '0',
callback_display_days SMALLINT(3) default '0', callback_display_days SMALLINT(3) default '0',
three_way_record_stop ENUM('Y','N') default 'N', three_way_record_stop ENUM('Y','N') default 'N',
hangup_xfer_record_start ENUM('Y','N') default 'N' hangup_xfer_record_start ENUM('Y','N') default 'N',
scheduled_callbacks_email_alert ENUM('Y', 'N') default 'N'
) ENGINE=MyISAM; ) ENGINE=MyISAM;
CREATE TABLE vicidial_lists ( CREATE TABLE vicidial_lists (
@@ -1367,6 +1368,8 @@ recipient ENUM('USERONLY','ANYONE'),
comments VARCHAR(255), comments VARCHAR(255),
user_group VARCHAR(20), user_group VARCHAR(20),
lead_status VARCHAR(6) default 'CALLBK', lead_status VARCHAR(6) default 'CALLBK',
email_alert datetime,
email_result ENUM('SENT','FAILED','NOT AVAILABLE'),
index (lead_id), index (lead_id),
index (status), index (status),
index (callback_time) index (callback_time)
@@ -4089,6 +4092,8 @@ INSERT INTO vicidial_qc_codes (code,code_name,qc_result_type) VALUES ('QCCANCEL'
INSERT INTO vicidial_configuration (id, name, value) VALUES (NULL, 'qc_database_version', '1638'); INSERT INTO vicidial_configuration (id, name, value) VALUES (NULL, 'qc_database_version', '1638');
UPDATE vicidial_configuration set value='1766' where name='qc_database_version'; UPDATE vicidial_configuration set value='1766' where name='qc_database_version';
INSERT INTO vicidial_settings_containers(container_id,container_notes,container_type,user_group,container_entry) VALUES ('AGENT_CALLBACK_EMAIL ','Scheduled callback email alert settings','OTHER','---ALL---','; sending email address\r\nemail_from => vicidial@local.server\r\n\r\n; subject of the email\r\nemail_subject => Scheduled callback alert for --A--agent_name--B--\r\n\r\nemail_body_begin => \r\nThis is a reminder that you have a scheduled callback right now for the following lead:\r\n\r\nName: --A--first_name--B-- --A--last_name--B--\r\nPhone: --A--phone_number--B--\r\nAlt. phone: --A--alt_phone--B--\r\nEmail: --A--email--B--\r\nCB Comments: --A--callback_comments--B--\r\nLead Comments: --A--comments--B--\r\n\r\nPlease don\'t respond to this, fool.\r\n\r\nemail_body_end');
UPDATE system_settings set vdc_agent_api_active='1'; UPDATE system_settings set vdc_agent_api_active='1';
UPDATE system_settings SET db_schema_version='1522',db_schema_update_date=NOW(),reload_timestamp=NOW(); UPDATE system_settings SET db_schema_version='1523',db_schema_update_date=NOW(),reload_timestamp=NOW();
+12
View File
@@ -417,3 +417,15 @@ ALTER TABLE phones ADD webphone_layout VARCHAR(255) default '';
ALTER TABLE vicidial_user_groups ADD webphone_layout VARCHAR(255) default ''; ALTER TABLE vicidial_user_groups ADD webphone_layout VARCHAR(255) default '';
UPDATE system_settings SET db_schema_version='1522',db_schema_update_date=NOW() where db_schema_version < 1522; UPDATE system_settings SET db_schema_version='1522',db_schema_update_date=NOW() where db_schema_version < 1522;
ALTER TABLE vicidial_campaigns ADD scheduled_callbacks_email_alert ENUM('Y', 'N') default 'N';
ALTER TABLE vicidial_callbacks ADD email_alert datetime;
ALTER TABLE vicidial_callbacks ADD email_result ENUM('SENT','FAILED','NOT AVAILABLE');
ALTER TABLE vicidial_callbacks_archive ADD email_alert datetime;
ALTER TABLE vicidial_callbacks_archive ADD email_result ENUM('SENT','FAILED','NOT AVAILABLE');
INSERT INTO vicidial_settings_containers(container_id,container_notes,container_type,user_group,container_entry) VALUES ('AGENT_CALLBACK_EMAIL ','Scheduled callback email alert settings','OTHER','---ALL---','; sending email address\r\nemail_from => vicidial@local.server\r\n\r\n; subject of the email\r\nemail_subject => Scheduled callback alert for --A--agent_name--B--\r\n\r\nemail_body_begin => \r\nThis is a reminder that you have a scheduled callback right now for the following lead:\r\n\r\nName: --A--first_name--B-- --A--last_name--B--\r\nPhone: --A--phone_number--B--\r\nAlt. phone: --A--alt_phone--B--\r\nEmail: --A--email--B--\r\nCB Comments: --A--callback_comments--B--\r\nLead Comments: --A--comments--B--\r\n\r\nPlease don\'t respond to this, fool.\r\n\r\nemail_body_end');
UPDATE system_settings SET db_schema_version='1523',db_schema_update_date=NOW() where db_schema_version < 1523;
+193 -6
View File
@@ -436,13 +436,14 @@
# 170712-1548 - Changed agents view to use last_state_change for time # 170712-1548 - Changed agents view to use last_state_change for time
# 170816-2334 - Added ask post-call survey feature for in-group calls # 170816-2334 - Added ask post-call survey feature for in-group calls
# 170912-1618 - Fix for no-hopper dnc dialing issue # 170912-1618 - Fix for no-hopper dnc dialing issue
# 171018-1310 - Added code for campaign scheduled callback email alerts
# #
$version = '2.14-330'; $version = '2.14-331';
$build = '170912-1618'; $build = '171018-1310';
$php_script = 'vdc_db_query.php'; $php_script = 'vdc_db_query.php';
$mel=1; # Mysql Error Log enabled = 1 $mel=1; # Mysql Error Log enabled = 1
$mysql_log_count=694; $mysql_log_count=700;
$one_mysql_log=0; $one_mysql_log=0;
$DB=0; $DB=0;
$VD_login=0; $VD_login=0;
@@ -15881,15 +15882,16 @@ if ($ACTION == 'CalLBacKCounT')
{ {
$campaignCBhoursSQL = ''; $campaignCBhoursSQL = '';
$campaignCBdisplaydaysSQL = ''; $campaignCBdisplaydaysSQL = '';
$stmt = "SELECT callback_hours_block,callback_display_days from vicidial_campaigns where campaign_id='$campaign';"; $stmt = "SELECT callback_hours_block,callback_display_days,scheduled_callbacks_email_alert from vicidial_campaigns where campaign_id='$campaign';";
$rslt=mysql_to_mysqli($stmt, $link); $rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00438',$user,$server_ip,$session_name,$one_mysql_log);} if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00438',$user,$server_ip,$session_name,$one_mysql_log);}
if ($rslt) {$camp_count = mysqli_num_rows($rslt);} if ($rslt) {$camp_count = mysqli_num_rows($rslt);}
if ($camp_count > 0) if ($camp_count > 0)
{ {
$row=mysqli_fetch_row($rslt); $row=mysqli_fetch_row($rslt);
$callback_hours_block = $row[0]; $callback_hours_block = $row[0];
$callback_display_days = $row[1]; $callback_display_days = $row[1];
$scheduled_callbacks_email_alert = $row[2];
if ($callback_hours_block > 0) if ($callback_hours_block > 0)
{ {
$x_hours_ago = date("Y-m-d H:i:s", mktime(date("H")-$callback_hours_block,date("i"),date("s"),date("m"),date("d"),date("Y"))); $x_hours_ago = date("Y-m-d H:i:s", mktime(date("H")-$callback_hours_block,date("i"),date("s"),date("m"),date("d"),date("Y")));
@@ -15921,6 +15923,191 @@ if ($ACTION == 'CalLBacKCounT')
echo "$cbcount|$cbcount_live"; echo "$cbcount|$cbcount_live";
$stage = "$campaign|$cbcount|$cbcount_live"; $stage = "$campaign|$cbcount|$cbcount_live";
if ($scheduled_callbacks_email_alert=="Y")
{
$user_stmt="SELECT email, full_name from vicidial_users where user='$user'";
$user_rslt=mysql_to_mysqli($user_stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$user_stmt,'00695',$user,$server_ip,$session_name,$one_mysql_log);}
$user_row=mysqli_fetch_row($user_rslt);
$email_to=$user_row[0];
$agent_name=$user_row[1];
$container_id="AGENT_CALLBACK_EMAIL";
$stmt = "SELECT container_entry FROM vicidial_settings_containers where container_id='$container_id';";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00696',$user,$server_ip,$session_name,$one_mysql_log);}
if ($DB) {echo "$stmt\n";}
$sc_ct = mysqli_num_rows($rslt);
if ($sc_ct > 0 && filter_var($email_to, FILTER_VALIDATE_EMAIL))
{
$row=mysqli_fetch_row($rslt);
$container_entry = $row[0];
$container_ARY = explode("\n",$container_entry);
$email_body_gather=0;
$p=0;
$container_ct = count($container_ARY);
while ($p <= $container_ct)
{
$line = $container_ARY[$p];
if ($email_body_gather < 1)
{
$line = preg_replace("/>|\n|\r|\t|\#.*|;.*/",'',$line);
if (preg_match("/^email_to/",$line))
{$email_to = $line; $email_to = trim(preg_replace("/.*=/",'',$email_to));}
if (preg_match("/^email_from/",$line))
{$email_from = $line; $email_from = trim(preg_replace("/.*=/",'',$email_from));}
if (preg_match("/^email_subject/",$line))
{$email_subject = $line; $email_subject = trim(preg_replace("/.*=/",'',$email_subject));}
if (preg_match("/^email_body_begin/",$line))
{$email_body = $line; $email_body = trim(preg_replace("/.*=/",'',$email_body)) . "\n"; $email_body_gather++;}
}
else
{
if (preg_match("/^email_body_end/",$line))
{$email_body_gather=0;}
else
{$email_body .= $line;}
}
$p++;
}
$email_stmt="SELECT callback_id, lead_id, comments from vicidial_callbacks where recipient='USERONLY' and user='$user' $campaignCBsql and email_alert is null and callback_time>=now()-INTERVAL 1 MINUTE and callback_time<=now()";
$email_rslt=mysql_to_mysqli($email_stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$email_stmt,'00697',$user,$server_ip,$session_name,$one_mysql_log);}
while($email_row=mysqli_fetch_array($email_rslt))
{
$CB_id=$email_row["callback_id"];
$CB_lead_id=$email_row["lead_id"];
$callback_comments=$email_row["comments"];
##### grab the data from vicidial_list for the lead_id
$stmt="SELECT lead_id,entry_date,modify_date,status,user,vendor_lead_code,source_id,list_id,gmt_offset_now,called_since_last_reset,phone_code,phone_number,title,first_name,middle_initial,last_name,address1,address2,address3,city,state,province,postal_code,country_code,gender,date_of_birth,alt_phone,email,security_phrase,comments,called_count,last_local_call_time,rank,owner,entry_list_id FROM vicidial_list where lead_id='$CB_lead_id' LIMIT 1;";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00698',$user,$server_ip,$session_name,$one_mysql_log);}
if ($DB) {echo "$stmt\n";}
$list_lead_ct = mysqli_num_rows($rslt);
if ($list_lead_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$entry_date = urlencode(trim($row[1]));
$dispo = urlencode(trim($row[3]));
$tsr = urlencode(trim($row[4]));
$vendor_id = urlencode(trim($row[5]));
$vendor_lead_code = urlencode(trim($row[5]));
$source_id = urlencode(trim($row[6]));
$list_id = urlencode(trim($row[7]));
$gmt_offset_now = urlencode(trim($row[8]));
$phone_code = urlencode(trim($row[10]));
$phone_number = urlencode(trim($row[11]));
$title = urlencode(trim($row[12]));
$first_name = urlencode(trim($row[13]));
$middle_initial = urlencode(trim($row[14]));
$last_name = urlencode(trim($row[15]));
$address1 = urlencode(trim($row[16]));
$address2 = urlencode(trim($row[17]));
$address3 = urlencode(trim($row[18]));
$city = urlencode(trim($row[19]));
$state = urlencode(trim($row[20]));
$province = urlencode(trim($row[21]));
$postal_code = urlencode(trim($row[22]));
$country_code = urlencode(trim($row[23]));
$gender = urlencode(trim($row[24]));
$date_of_birth = urlencode(trim($row[25]));
$alt_phone = urlencode(trim($row[26]));
$email = urlencode(trim($row[27]));
$security_phrase = urlencode(trim($row[28]));
$comments = urlencode(trim($row[29]));
$called_count = urlencode(trim($row[30]));
$rank = urlencode(trim($row[32]));
$owner = urlencode(trim($row[33]));
$entry_list_id = urlencode(trim($row[34]));
}
### populate variables in email_subject
if (preg_match('/--A--/i',$email_subject))
{
$email_subject = preg_replace('/^VAR|--A--CF_uses_custom_fields--B--/','',$email_subject);
$email_subject = preg_replace('/--A--lead_id--B--/i',"$lead_id",$email_subject);
$email_subject = preg_replace('/--A--vendor_id--B--/i',"$vendor_id",$email_subject);
$email_subject = preg_replace('/--A--vendor_lead_code--B--/i',"$vendor_lead_code",$email_subject);
$email_subject = preg_replace('/--A--list_id--B--/i',"$list_id",$email_subject);
$email_subject = preg_replace('/--A--list_name--B--/i',"$list_name",$email_subject);
$email_subject = preg_replace('/--A--list_description--B--/i',"$list_description",$email_subject);
$email_subject = preg_replace('/--A--gmt_offset_now--B--/i',"$gmt_offset_now",$email_subject);
$email_subject = preg_replace('/--A--phone_code--B--/i',"$phone_code",$email_subject);
$email_subject = preg_replace('/--A--phone_number--B--/i',"$phone_number",$email_subject);
$email_subject = preg_replace('/--A--title--B--/i',"$title",$email_subject);
$email_subject = preg_replace('/--A--first_name--B--/i',"$first_name",$email_subject);
$email_subject = preg_replace('/--A--middle_initial--B--/i',"$middle_initial",$email_subject);
$email_subject = preg_replace('/--A--last_name--B--/i',"$last_name",$email_subject);
$email_subject = preg_replace('/--A--address1--B--/i',"$address1",$email_subject);
$email_subject = preg_replace('/--A--address2--B--/i',"$address2",$email_subject);
$email_subject = preg_replace('/--A--address3--B--/i',"$address3",$email_subject);
$email_subject = preg_replace('/--A--city--B--/i',"$city",$email_subject);
$email_subject = preg_replace('/--A--state--B--/i',"$state",$email_subject);
$email_subject = preg_replace('/--A--province--B--/i',"$province",$email_subject);
$email_subject = preg_replace('/--A--postal_code--B--/i',"$postal_code",$email_subject);
$email_subject = preg_replace('/--A--country_code--B--/i',"$country_code",$email_subject);
$email_subject = preg_replace('/--A--gender--B--/i',"$gender",$email_subject);
$email_subject = preg_replace('/--A--date_of_birth--B--/i',"$date_of_birth",$email_subject);
$email_subject = preg_replace('/--A--alt_phone--B--/i',"$alt_phone",$email_subject);
$email_subject = preg_replace('/--A--email--B--/i',"$email",$email_subject);
$email_subject = preg_replace('/--A--security_phrase--B--/i',"$security_phrase",$email_subject);
$email_subject = preg_replace('/--A--comments--B--/i',"$comments",$email_subject);
$email_subject = preg_replace('/--A--agent_name--B--/i',"$agent_name",$email_subject);
$email_subject = preg_replace('/--A--callback_comments--B--/i',"$callback_comments",$email_subject);
}
### check for variables in email_body
if (preg_match('/--A--/i',$email_body))
{
$email_body = preg_replace('/^VAR|--A--CF_uses_custom_fields--B--/','',$email_body);
$email_body = preg_replace('/--A--lead_id--B--/i',"$lead_id",$email_body);
$email_body = preg_replace('/--A--vendor_id--B--/i',"$vendor_id",$email_body);
$email_body = preg_replace('/--A--vendor_lead_code--B--/i',"$vendor_lead_code",$email_body);
$email_body = preg_replace('/--A--list_id--B--/i',"$list_id",$email_body);
$email_body = preg_replace('/--A--list_name--B--/i',"$list_name",$email_body);
$email_body = preg_replace('/--A--list_description--B--/i',"$list_description",$email_body);
$email_body = preg_replace('/--A--gmt_offset_now--B--/i',"$gmt_offset_now",$email_body);
$email_body = preg_replace('/--A--phone_code--B--/i',"$phone_code",$email_body);
$email_body = preg_replace('/--A--phone_number--B--/i',"$phone_number",$email_body);
$email_body = preg_replace('/--A--title--B--/i',"$title",$email_body);
$email_body = preg_replace('/--A--first_name--B--/i',"$first_name",$email_body);
$email_body = preg_replace('/--A--middle_initial--B--/i',"$middle_initial",$email_body);
$email_body = preg_replace('/--A--last_name--B--/i',"$last_name",$email_body);
$email_body = preg_replace('/--A--address1--B--/i',"$address1",$email_body);
$email_body = preg_replace('/--A--address2--B--/i',"$address2",$email_body);
$email_body = preg_replace('/--A--address3--B--/i',"$address3",$email_body);
$email_body = preg_replace('/--A--city--B--/i',"$city",$email_body);
$email_body = preg_replace('/--A--state--B--/i',"$state",$email_body);
$email_body = preg_replace('/--A--province--B--/i',"$province",$email_body);
$email_body = preg_replace('/--A--postal_code--B--/i',"$postal_code",$email_body);
$email_body = preg_replace('/--A--country_code--B--/i',"$country_code",$email_body);
$email_body = preg_replace('/--A--gender--B--/i',"$gender",$email_body);
$email_body = preg_replace('/--A--date_of_birth--B--/i',"$date_of_birth",$email_body);
$email_body = preg_replace('/--A--alt_phone--B--/i',"$alt_phone",$email_body);
$email_body = preg_replace('/--A--email--B--/i',"$email",$email_body);
$email_body = preg_replace('/--A--security_phrase--B--/i',"$security_phrase",$email_body);
$email_body = preg_replace('/--A--comments--B--/i',"$comments",$email_body);
$email_body = preg_replace('/--A--agent_name--B--/i',"$agent_name",$email_body);
$email_body = preg_replace('/--A--callback_comments--B--/i',"$callback_comments",$email_body);
$email_body = urldecode($email_body);
}
##### sending email through PHP #####
$sendmail = @mail("$email_to","$email_subject","$email_body", "From: $email_from");
if ($sendmail) {$email_result="SENT";} else {$email_result="FAILED";}
$upd_stmt="UPDATE vicidial_callbacks set email_alert=now(), email_result='$email_result' where callback_id='$CB_id'";
$upd_rslt=mysql_to_mysqli($upd_stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$upd_stmt,'00699',$user,$server_ip,$session_name,$one_mysql_log);}
}
}
$upd_stmt="UPDATE vicidial_callbacks set email_alert=now(), email_result='NOT AVAILABLE' where recipient='USERONLY' and user='$user' and callback_time<=now() and email_alert is null $campaignCBsql";
$upd_rslt=mysql_to_mysqli($upd_stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$upd_stmt,'00700',$user,$server_ip,$session_name,$one_mysql_log);}
}
} }
File diff suppressed because one or more lines are too long
+6
View File
@@ -138,6 +138,7 @@
# 170930-0906 - Added new extension append cidname options and custom reports help # 170930-0906 - Added new extension append cidname options and custom reports help
# 171006-2058 - Added lists-inbound_list_script_override entry # 171006-2058 - Added lists-inbound_list_script_override entry
# 171011-1505 - Added webphone_layout entries # 171011-1505 - Added webphone_layout entries
# 171018-2203 - Added campaigns-scheduled_callbacks_email_alert entry
# #
@@ -1619,6 +1620,11 @@ if ($SSoutbound_autodial_active > 0)
<BR> <BR>
<B><?php echo _QXZ("Scheduled Callbacks Alert"); ?> -</B><?php echo _QXZ("This option allows the callbacks status line in the agent interface to be red, blink or blink red when there are AGENTONLY scheduled callbacks that have hit their trigger time and date. Default is NONE for standard status line. The DEFER options will stop blinking and-or displaying in red when you check the callbacks, until the number of callbacks changes."); ?> <B><?php echo _QXZ("Scheduled Callbacks Alert"); ?> -</B><?php echo _QXZ("This option allows the callbacks status line in the agent interface to be red, blink or blink red when there are AGENTONLY scheduled callbacks that have hit their trigger time and date. Default is NONE for standard status line. The DEFER options will stop blinking and-or displaying in red when you check the callbacks, until the number of callbacks changes."); ?>
<BR>
<A NAME="campaigns-scheduled_callbacks_email_alert">
<BR>
<B><?php echo _QXZ("Send Callbacks Email"); ?> -</B><?php echo _QXZ("This option will cause the dialer to attempt to send an email notification to the owner of a USERONLY scheduled callback when the callback time arrives. In order for this to work, the owner must have a valid email address on their user profile, and the system must have a settings container named AGENT_CALLBACK_EMAIL in the Settings Container section of the admin portal. That container must also define the following variables for the email to be sent properly: email_from - the email address the notification shows as coming from, email_subject - the subject shown on the email, and email_body_begin which when declared will treat all text between it and the string email_body_end as the body of the email. Values from the lead ,the vicidial_list table, can be included using the same --A-- --B-- declaration style used in the scripts feature. These emails are only sent when the agent is logged into the agent screen."); ?>
<BR> <BR>
<A NAME="campaigns-scheduled_callbacks_count"> <A NAME="campaigns-scheduled_callbacks_count">
<BR> <BR>