From b6e56cce3031a112c26ea73b4248387f096e6ced Mon Sep 17 00:00:00 2001 From: mattf Date: Fri, 25 Mar 2011 04:48:19 +0000 Subject: [PATCH] update of SPanish and Italian agent builds git-svn-id: svn://192.168.202.10@1630 3d104415-ff17-0410-8863-d5cf3c621b8a --- .../LANG_www/agc_es/conf_exten_check.php | 169 +- agc_2-X/trunk/LANG_www/agc_es/css/custom.css | 1 + agc_2-X/trunk/LANG_www/agc_es/css/style.css | 26 + agc_2-X/trunk/LANG_www/agc_es/functions.php | 897 +++++ .../trunk/LANG_www/agc_es/manager_send.php | 257 +- .../trunk/LANG_www/agc_es/vdc_db_query.php | 1698 ++++++++- agc_2-X/trunk/LANG_www/agc_es/vicidial.php | 3381 +++++++++++------ .../LANG_www/agc_it/conf_exten_check.php | 169 +- agc_2-X/trunk/LANG_www/agc_it/css/custom.css | 1 + agc_2-X/trunk/LANG_www/agc_it/css/style.css | 26 + agc_2-X/trunk/LANG_www/agc_it/functions.php | 897 +++++ .../trunk/LANG_www/agc_it/manager_send.php | 257 +- .../trunk/LANG_www/agc_it/vdc_db_query.php | 1698 ++++++++- agc_2-X/trunk/LANG_www/agc_it/vicidial.php | 3381 +++++++++++------ 14 files changed, 10000 insertions(+), 2858 deletions(-) create mode 100644 agc_2-X/trunk/LANG_www/agc_es/css/custom.css create mode 100644 agc_2-X/trunk/LANG_www/agc_es/css/style.css create mode 100644 agc_2-X/trunk/LANG_www/agc_it/css/custom.css create mode 100644 agc_2-X/trunk/LANG_www/agc_it/css/style.css diff --git a/agc_2-X/trunk/LANG_www/agc_es/conf_exten_check.php b/agc_2-X/trunk/LANG_www/agc_es/conf_exten_check.php index e0bd50ec..c8215eb1 100644 --- a/agc_2-X/trunk/LANG_www/agc_es/conf_exten_check.php +++ b/agc_2-X/trunk/LANG_www/agc_es/conf_exten_check.php @@ -52,17 +52,22 @@ # 100109-1337 - Fixed Manual dial live call detection # 100527-0957 - Added send_dtmf, transfer_conference and park_call API functions # 100727-2209 - Added timer actions for hangup, extension, callmenu and ingroup as well as destination +# 101123-1105 - Added api manual dial queue feature to external_dial function +# 101208-0308 - Moved the Calls in Queue count and other counts outside of the autodial section (issue 406) # -$version = '2.4-27'; -$build = '100727-2209'; +$version = '2.4-29'; +$build = '101208-0308'; $mel=1; # Mysql Error Log enabled = 1 -$mysql_log_count=32; +$mysql_log_count=36; $one_mysql_log=0; +$DB=0; require("dbconnect.php"); ### If you have globals turned off uncomment these lines +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} if (isset($_GET["user"])) {$user=$_GET["user"];} elseif (isset($_POST["user"])) {$user=$_POST["user"];} if (isset($_GET["pass"])) {$pass=$_GET["pass"];} @@ -215,7 +220,7 @@ echo " if ($Acount > 0) { - $stmt="SELECT status,callerid,agent_log_id,campaign_id from vicidial_live_agents where user='$user' and server_ip='$server_ip';"; + $stmt="SELECT status,callerid,agent_log_id,campaign_id,lead_id from vicidial_live_agents where user='$user' and server_ip='$server_ip';"; if ($DB) {echo "|$stmt|\n";} $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03004',$user,$server_ip,$session_name,$one_mysql_log);} @@ -224,6 +229,17 @@ echo " $Acallerid = $row[1]; $Aagent_log_id = $row[2]; $Acampaign_id = $row[3]; + $Alead_id = $row[4]; + + $api_manual_dial='STANDARD'; + $stmt = "SELECT api_manual_dial FROM vicidial_campaigns where campaign_id='$Acampaign_id';"; + $rslt=mysql_query($stmt, $link); + $vcc_conf_ct = mysql_num_rows($rslt); + if ($vcc_conf_ct > 0) + { + $row=mysql_fetch_row($rslt); + $api_manual_dial = $row[0]; + } } # ### find out if external table shows agent should be disabled # $stmt="SELECT count(*) from another_table where user='$user' and status='DEAD';"; @@ -232,6 +248,53 @@ echo " # $row=mysql_fetch_row($rslt); # $AexternalDEAD=$row[0]; + ##### BEGIN check en calls in queue, number of active calls in the campaign + if ($campagentstdisp == 'YES') + { + $ADsql=''; + ### grab the status of this agent to display + $stmt="SELECT status,campaign_id,closer_campaigns from vicidial_live_agents where user='$user' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03006',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $Alogin=$row[0]; + $Acampaign=$row[1]; + $AccampSQL=$row[2]; + $AccampSQL = ereg_replace(' -','', $AccampSQL); + $AccampSQL = ereg_replace(' ',"','", $AccampSQL); + if (eregi('AGENTDIRECT', $AccampSQL)) + { + $AccampSQL = ereg_replace('AGENTDIRECT','', $AccampSQL); + $ADsql = "or ( (campaign_id LIKE \"%AGENTDIRECT%\") and (agent_only='$user') )"; + } + + ### grab the number of calls being placed from this server and campaign + $stmt="SELECT count(*) from vicidial_auto_calls where status IN('LIVE') and ( (campaign_id='$Acampaign') or (campaign_id IN('$AccampSQL')) $ADsql);"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03007',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $RingCalls=$row[0]; + if ($RingCalls > 0) {$RingCalls = "Pide, en la cola: $RingCalls";} + else {$RingCalls = "Pide, en la cola: $RingCalls";} + + ### grab the number of calls being placed from this server and campaign + $stmt="SELECT count(*) from vicidial_auto_calls where status NOT IN('XFER') and ( (campaign_id='$Acampaign') or (campaign_id IN('$AccampSQL')) );"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03008',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $DiaLCalls=$row[0]; + } + else + { + $Alogin='N'; + $RingCalls='N'; + $DiaLCalls='N'; + } + ##### END check en calls in queue, number of active calls in the campaign + if ($auto_dial_level > 0) { ### update the vicidial_live_agents every second with a new random number so it is shown to be alive @@ -285,59 +348,9 @@ echo " } } ##### END DEAD logging section ##### - - if ($campagentstdisp == 'YES') - { - $ADsql=''; - ### grab the status of this agent to display - $stmt="SELECT status,campaign_id,closer_campaigns from vicidial_live_agents where user='$user' and server_ip='$server_ip';"; - if ($DB) {echo "|$stmt|\n";} - $rslt=mysql_query($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03006',$user,$server_ip,$session_name,$one_mysql_log);} - $row=mysql_fetch_row($rslt); - $Alogin=$row[0]; - $Acampaign=$row[1]; - $AccampSQL=$row[2]; - $AccampSQL = ereg_replace(' -','', $AccampSQL); - $AccampSQL = ereg_replace(' ',"','", $AccampSQL); - if (eregi('AGENTDIRECT', $AccampSQL)) - { - $AccampSQL = ereg_replace('AGENTDIRECT','', $AccampSQL); - $ADsql = "or ( (campaign_id LIKE \"%AGENTDIRECT%\") and (agent_only='$user') )"; - } - - ### grab the number of calls being placed from this server and campaign - $stmt="SELECT count(*) from vicidial_auto_calls where status IN('LIVE') and ( (campaign_id='$Acampaign') or (campaign_id IN('$AccampSQL')) $ADsql);"; - if ($DB) {echo "|$stmt|\n";} - $rslt=mysql_query($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03007',$user,$server_ip,$session_name,$one_mysql_log);} - $row=mysql_fetch_row($rslt); - $RingCalls=$row[0]; - if ($RingCalls > 0) {$RingCalls = "Pide, en la cola: $RingCalls";} - else {$RingCalls = "Pide, en la cola: $RingCalls";} - - ### grab the number of calls being placed from this server and campaign - $stmt="SELECT count(*) from vicidial_auto_calls where status NOT IN('XFER') and ( (campaign_id='$Acampaign') or (campaign_id IN('$AccampSQL')) );"; - if ($DB) {echo "|$stmt|\n";} - $rslt=mysql_query($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03008',$user,$server_ip,$session_name,$one_mysql_log);} - $row=mysql_fetch_row($rslt); - $DiaLCalls=$row[0]; - - } - else - { - $Alogin='N'; - $RingCalls='N'; - $DiaLCalls='N'; - } } else { - $Alogin='N'; - $RingCalls='N'; - $DiaLCalls='N'; - ### update the vicidial_live_agents every second with a new random number so it is shown to be alive $stmt="UPDATE vicidial_live_agents set random_id='$random' where user='$user' and server_ip='$server_ip';"; if ($format=='debug') {echo "\n";} @@ -410,6 +423,52 @@ echo " $external_park = $row[11]; $timer_action_destination = $row[12]; + $MDQ_count=0; + if ( ($api_manual_dial=='QUEUE') or ($api_manual_dial=='QUEUE_AND_AUTOCALL') ) + { + $stmt="SELECT count(*) FROM vicidial_manual_dial_queue where user='$user' and status='READY';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03033',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $mdq_count_record_ct = mysql_num_rows($rslt); + if ($mdq_count_record_ct > 0) + { + $row=mysql_fetch_row($rslt); + $MDQ_count = $row[0]; + } + + if ( ($MDQ_count > 0) and (strlen($external_dial) < 16) and ($Astatus=='PAUSED') and ($Alead_id < 1) ) + { + $stmt="SELECT mdq_id,external_dial FROM vicidial_manual_dial_queue where user='$user' and status='READY' order by entry_time limit 1;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03034',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $mdq_record_ct = mysql_num_rows($rslt); + if ($mdq_record_ct > 0) + { + $row=mysql_fetch_row($rslt); + $MDQ_mdq_id = $row[0]; + $MDQ_external_dial = $row[1]; + $external_dial = $MDQ_external_dial; + + $stmt="UPDATE vicidial_manual_dial_queue SET status='QUEUE' where mdq_id='$MDQ_mdq_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03035',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $UMDQaffected_rows_update = mysql_affected_rows($link); + + if ($UMDQaffected_rows_update > 0) + { + $stmt="UPDATE vicidial_live_agents SET external_dial='$MDQ_external_dial' where user='$user' and server_ip='$server_ip';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03036',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $VLAMDQaffected_rows_update = mysql_affected_rows($link); + } + } + } + } + if (strlen($external_status)<1) {$external_status = '::::::::::';} $web_epoch = date("U"); @@ -578,7 +637,7 @@ echo " if ($Ashift_logout > 0) {$Alogin='SHIFT_LOGOUT';} - echo 'DateTime: ' . $NOW_TIME . '|UnixTime: ' . $StarTtime . '|Logged-in: ' . $Alogin . '|CampCalls: ' . $RingCalls . '|Estado: ' . $Astatus . '|DiaLCalls: ' . $DiaLCalls . '|APIHanguP: ' . $external_hangup . '|APIStatuS: ' . $external_status . '|APIPausE: ' . $external_pause . '|APIDiaL: ' . $external_dial . '|DEADcall: ' . $DEADcustomer . '|InGroupChange: ' . $InGroupChangeDetails . '|APIFields: ' . $external_update_fields . '|APIFieldsData: ' . $external_update_fields_data . '|APITimerAction: ' . $timer_action . '|APITimerMessage: ' . $timer_action_message . '|APITimerSeconds: ' . $timer_action_seconds . '|APIdtmf: ' . $external_dtmf . '|APItransferconf: ' . $external_transferconf . '|APIpark: ' . $external_park . '|APITimerDestination: ' . $timer_action_destination . "\n"; + echo 'DateTime: ' . $NOW_TIME . '|UnixTime: ' . $StarTtime . '|Logged-in: ' . $Alogin . '|CampCalls: ' . $RingCalls . '|Estado: ' . $Astatus . '|DiaLCalls: ' . $DiaLCalls . '|APIHanguP: ' . $external_hangup . '|APIStatuS: ' . $external_status . '|APIPausE: ' . $external_pause . '|APIDiaL: ' . $external_dial . '|DEADcall: ' . $DEADcustomer . '|InGroupChange: ' . $InGroupChangeDetails . '|APIFields: ' . $external_update_fields . '|APIFieldsData: ' . $external_update_fields_data . '|APITimerAction: ' . $timer_action . '|APITimerMessage: ' . $timer_action_message . '|APITimerSeconds: ' . $timer_action_seconds . '|APIdtmf: ' . $external_dtmf . '|APItransferconf: ' . $external_transferconf . '|APIpark: ' . $external_park . '|APITimerDestination: ' . $timer_action_destination . '|APIManualDialQueue: ' . $MDQ_count . "\n"; if (strlen($timer_action) > 3) { diff --git a/agc_2-X/trunk/LANG_www/agc_es/css/custom.css b/agc_2-X/trunk/LANG_www/agc_es/css/custom.css new file mode 100644 index 00000000..8d1c8b69 --- /dev/null +++ b/agc_2-X/trunk/LANG_www/agc_es/css/custom.css @@ -0,0 +1 @@ + diff --git a/agc_2-X/trunk/LANG_www/agc_es/css/style.css b/agc_2-X/trunk/LANG_www/agc_es/css/style.css new file mode 100644 index 00000000..2e30a009 --- /dev/null +++ b/agc_2-X/trunk/LANG_www/agc_es/css/style.css @@ -0,0 +1,26 @@ +/* /!\ 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; } diff --git a/agc_2-X/trunk/LANG_www/agc_es/functions.php b/agc_2-X/trunk/LANG_www/agc_es/functions.php index 9af6831b..12fd19a6 100644 --- a/agc_2-X/trunk/LANG_www/agc_es/functions.php +++ b/agc_2-X/trunk/LANG_www/agc_es/functions.php @@ -9,6 +9,7 @@ # # CHANGES: # 100629-1201 - First Build +# 101124-0625 - Added lookup_gmt and dialable_gmt functions # @@ -496,6 +497,902 @@ function custom_list_fields_values($lead_id,$list_id,$uniqueid,$user) +##### LOOKUP GMT, FINDS THE CURRENT GMT OFFSET FOR A PHONE NUMBER ##### + +function lookup_gmt($phone_code,$USarea,$state,$LOCAL_GMT_OFF_STD,$Shour,$Smin,$Ssec,$Smon,$Smday,$Syear,$postalgmt,$postal_code) + { + require("dbconnect.php"); + + $postalgmt_found=0; + if ( (eregi("POSTAL",$postalgmt)) && (strlen($postal_code)>4) ) + { + if (preg_match('/^1$/', $phone_code)) + { + $stmt="select postal_code,state,GMT_offset,DST,DST_range,country,country_code from vicidial_postal_codes where country_code='$phone_code' and postal_code LIKE \"$postal_code%\";"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $row=mysql_fetch_row($rslt); + $gmt_offset = $row[2]; $gmt_offset = eregi_replace("\+","",$gmt_offset); + $dst = $row[3]; + $dst_range = $row[4]; + $PC_processed++; + $postalgmt_found++; + $post++; + } + } + } + if ($postalgmt_found < 1) + { + $PC_processed=0; + ### UNITED STATES ### + if ($phone_code =='1') + { + $stmt="select country_code,country,areacode,state,GMT_offset,DST,DST_range,geographic_description from vicidial_phone_codes where country_code='$phone_code' and areacode='$USarea';"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $row=mysql_fetch_row($rslt); + $gmt_offset = $row[4]; $gmt_offset = eregi_replace("\+","",$gmt_offset); + $dst = $row[5]; + $dst_range = $row[6]; + $PC_processed++; + } + } + ### MEXICO ### + if ($phone_code =='52') + { + $stmt="select country_code,country,areacode,state,GMT_offset,DST,DST_range,geographic_description from vicidial_phone_codes where country_code='$phone_code' and areacode='$USarea';"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $row=mysql_fetch_row($rslt); + $gmt_offset = $row[4]; $gmt_offset = eregi_replace("\+","",$gmt_offset); + $dst = $row[5]; + $dst_range = $row[6]; + $PC_processed++; + } + } + ### AUSTRALIA ### + if ($phone_code =='61') + { + $stmt="select country_code,country,areacode,state,GMT_offset,DST,DST_range,geographic_description from vicidial_phone_codes where country_code='$phone_code' and state='$state';"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $row=mysql_fetch_row($rslt); + $gmt_offset = $row[4]; $gmt_offset = eregi_replace("\+","",$gmt_offset); + $dst = $row[5]; + $dst_range = $row[6]; + $PC_processed++; + } + } + ### ALL OTHER COUNTRY CODES ### + if (!$PC_processed) + { + $PC_processed++; + $stmt="select country_code,country,areacode,state,GMT_offset,DST,DST_range,geographic_description from vicidial_phone_codes where country_code='$phone_code';"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $row=mysql_fetch_row($rslt); + $gmt_offset = $row[4]; $gmt_offset = eregi_replace("\+","",$gmt_offset); + $dst = $row[5]; + $dst_range = $row[6]; + $PC_processed++; + } + } + } + + ### Find out if DST to raise the gmt offset ### + $AC_GMT_diff = ($gmt_offset - $LOCAL_GMT_OFF_STD); + $AC_localtime = mktime(($Shour + $AC_GMT_diff), $Smin, $Ssec, $Smon, $Smday, $Syear); + $hour = date("H",$AC_localtime); + $min = date("i",$AC_localtime); + $sec = date("s",$AC_localtime); + $mon = date("m",$AC_localtime); + $mday = date("d",$AC_localtime); + $wday = date("w",$AC_localtime); + $year = date("Y",$AC_localtime); + $dsec = ( ( ($hour * 3600) + ($min * 60) ) + $sec ); + + $AC_processed=0; + if ( (!$AC_processed) and ($dst_range == 'SSM-FSN') ) + { + if ($DBX) {print " Second Sunday March to First Sunday November\n";} + #********************************************************************** + # SSM-FSN + # This is returns 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on Second Sunday March to First Sunday November at 2 am. + # INPUTS: + # mm INTEGER Month. + # dd INTEGER Day of the month. + # ns INTEGER Seconds into the day. + # dow INTEGER Day of week (0=Sunday, to 6=Saturday) + # OPTIONAL INPUT: + # timezone INTEGER hour difference UTC - local standard time + # (DEFAULT is blank) + # make calculations based on UTC time, + # which means shift at 10:00 UTC in April + # and 9:00 UTC in October + # OUTPUT: + # INTEGER 1 = DST, 0 = not DST + # + # S M T W T F S + # 1 2 3 4 5 6 7 + # 8 9 10 11 12 13 14 + #15 16 17 18 19 20 21 + #22 23 24 25 26 27 28 + #29 30 31 + # + # S M T W T F S + # 1 2 3 4 5 6 + # 7 8 9 10 11 12 13 + #14 15 16 17 18 19 20 + #21 22 23 24 25 26 27 + #28 29 30 31 + # + #********************************************************************** + + $USACAN_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 11) { + $USACAN_DST=0; + } elseif ($mm >= 4 and $mm <= 10) { + $USACAN_DST=1; + } elseif ($mm == 3) { + if ($dd > 13) { + $USACAN_DST=1; + } elseif ($dd >= ($dow+8)) { + if ($timezone) { + if ($dow == 0 and $ns < (7200+$timezone*3600)) { + $USACAN_DST=0; + } else { + $USACAN_DST=1; + } + } else { + if ($dow == 0 and $ns < 7200) { + $USACAN_DST=0; + } else { + $USACAN_DST=1; + } + } + } else { + $USACAN_DST=0; + } + } elseif ($mm == 11) { + if ($dd > 7) { + $USACAN_DST=0; + } elseif ($dd < ($dow+1)) { + $USACAN_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (7200+($timezone-1)*3600)) { + $USACAN_DST=1; + } else { + $USACAN_DST=0; + } + } else { # local time calculations + if ($ns < 7200) { + $USACAN_DST=1; + } else { + $USACAN_DST=0; + } + } + } else { + $USACAN_DST=0; + } + } # end of month checks + if ($DBX) {print " DST: $USACAN_DST\n";} + if ($USACAN_DST) {$gmt_offset++;} + $AC_processed++; + } + + if ( (!$AC_processed) and ($dst_range == 'FSA-LSO') ) + { + if ($DBX) {print " First Sunday April to Last Sunday October\n";} + #********************************************************************** + # FSA-LSO + # This is returns 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on first Sunday in April and last Sunday in October at 2 am. + #********************************************************************** + + $USA_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 4 || $mm > 10) { + $USA_DST=0; + } elseif ($mm >= 5 and $mm <= 9) { + $USA_DST=1; + } elseif ($mm == 4) { + if ($dd > 7) { + $USA_DST=1; + } elseif ($dd >= ($dow+1)) { + if ($timezone) { + if ($dow == 0 and $ns < (7200+$timezone*3600)) { + $USA_DST=0; + } else { + $USA_DST=1; + } + } else { + if ($dow == 0 and $ns < 7200) { + $USA_DST=0; + } else { + $USA_DST=1; + } + } + } else { + $USA_DST=0; + } + } elseif ($mm == 10) { + if ($dd < 25) { + $USA_DST=1; + } elseif ($dd < ($dow+25)) { + $USA_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (7200+($timezone-1)*3600)) { + $USA_DST=1; + } else { + $USA_DST=0; + } + } else { # local time calculations + if ($ns < 7200) { + $USA_DST=1; + } else { + $USA_DST=0; + } + } + } else { + $USA_DST=0; + } + } # end of month checks + + if ($DBX) {print " DST: $USA_DST\n";} + if ($USA_DST) {$gmt_offset++;} + $AC_processed++; + } + + if ( (!$AC_processed) and ($dst_range == 'LSM-LSO') ) + { + if ($DBX) {print " Last Sunday March to Last Sunday October\n";} + #********************************************************************** + # This is s 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on last Sunday in March and last Sunday in October at 1 am. + #********************************************************************** + + $GBR_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $GBR_DST=0; + } elseif ($mm >= 4 and $mm <= 9) { + $GBR_DST=1; + } elseif ($mm == 3) { + if ($dd < 25) { + $GBR_DST=0; + } elseif ($dd < ($dow+25)) { + $GBR_DST=0; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $GBR_DST=0; + } else { + $GBR_DST=1; + } + } else { # local time calculations + if ($ns < 3600) { + $GBR_DST=0; + } else { + $GBR_DST=1; + } + } + } else { + $GBR_DST=1; + } + } elseif ($mm == 10) { + if ($dd < 25) { + $GBR_DST=1; + } elseif ($dd < ($dow+25)) { + $GBR_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $GBR_DST=1; + } else { + $GBR_DST=0; + } + } else { # local time calculations + if ($ns < 3600) { + $GBR_DST=1; + } else { + $GBR_DST=0; + } + } + } else { + $GBR_DST=0; + } + } # end of month checks + if ($DBX) {print " DST: $GBR_DST\n";} + if ($GBR_DST) {$gmt_offset++;} + $AC_processed++; + } + if ( (!$AC_processed) and ($dst_range == 'LSO-LSM') ) + { + if ($DBX) {print " Last Sunday October to Last Sunday March\n";} + #********************************************************************** + # This is s 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on last Sunday in October and last Sunday in March at 1 am. + #********************************************************************** + + $AUS_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $AUS_DST=1; + } elseif ($mm >= 4 and $mm <= 9) { + $AUS_DST=0; + } elseif ($mm == 3) { + if ($dd < 25) { + $AUS_DST=1; + } elseif ($dd < ($dow+25)) { + $AUS_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $AUS_DST=1; + } else { + $AUS_DST=0; + } + } else { # local time calculations + if ($ns < 3600) { + $AUS_DST=1; + } else { + $AUS_DST=0; + } + } + } else { + $AUS_DST=0; + } + } elseif ($mm == 10) { + if ($dd < 25) { + $AUS_DST=0; + } elseif ($dd < ($dow+25)) { + $AUS_DST=0; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $AUS_DST=0; + } else { + $AUS_DST=1; + } + } else { # local time calculations + if ($ns < 3600) { + $AUS_DST=0; + } else { + $AUS_DST=1; + } + } + } else { + $AUS_DST=1; + } + } # end of month checks + if ($DBX) {print " DST: $AUS_DST\n";} + if ($AUS_DST) {$gmt_offset++;} + $AC_processed++; + } + + if ( (!$AC_processed) and ($dst_range == 'FSO-LSM') ) + { + if ($DBX) {print " First Sunday October to Last Sunday March\n";} + #********************************************************************** + # TASMANIA ONLY + # This is s 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on first Sunday in October and last Sunday in March at 1 am. + #********************************************************************** + + $AUST_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $AUST_DST=1; + } elseif ($mm >= 4 and $mm <= 9) { + $AUST_DST=0; + } elseif ($mm == 3) { + if ($dd < 25) { + $AUST_DST=1; + } elseif ($dd < ($dow+25)) { + $AUST_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $AUST_DST=1; + } else { + $AUST_DST=0; + } + } else { # local time calculations + if ($ns < 3600) { + $AUST_DST=1; + } else { + $AUST_DST=0; + } + } + } else { + $AUST_DST=0; + } + } elseif ($mm == 10) { + if ($dd > 7) { + $AUST_DST=1; + } elseif ($dd >= ($dow+1)) { + if ($timezone) { + if ($dow == 0 and $ns < (7200+$timezone*3600)) { + $AUST_DST=0; + } else { + $AUST_DST=1; + } + } else { + if ($dow == 0 and $ns < 3600) { + $AUST_DST=0; + } else { + $AUST_DST=1; + } + } + } else { + $AUST_DST=0; + } + } # end of month checks + if ($DBX) {print " DST: $AUST_DST\n";} + if ($AUST_DST) {$gmt_offset++;} + $AC_processed++; + } + + if ( (!$AC_processed) and ($dst_range == 'FSO-FSA') ) + { + if ($DBX) {print " Sunday in October to First Sunday in April\n";} + #********************************************************************** + # FSO-FSA + # 2008+ AUSTRALIA ONLY (country code 61) + # This is returns 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on first Sunday in October and first Sunday in April at 1 am. + #********************************************************************** + + $AUSE_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 4 or $mm > 10) { + $AUSE_DST=1; + } elseif ($mm >= 5 and $mm <= 9) { + $AUSE_DST=0; + } elseif ($mm == 4) { + if ($dd > 7) { + $AUSE_DST=0; + } elseif ($dd >= ($dow+1)) { + if ($timezone) { + if ($dow == 0 and $ns < (3600+$timezone*3600)) { + $AUSE_DST=1; + } else { + $AUSE_DST=0; + } + } else { + if ($dow == 0 and $ns < 7200) { + $AUSE_DST=1; + } else { + $AUSE_DST=0; + } + } + } else { + $AUSE_DST=1; + } + } elseif ($mm == 10) { + if ($dd >= 8) { + $AUSE_DST=1; + } elseif ($dd >= ($dow+1)) { + if ($timezone) { + if ($dow == 0 and $ns < (7200+$timezone*3600)) { + $AUSE_DST=0; + } else { + $AUSE_DST=1; + } + } else { + if ($dow == 0 and $ns < 3600) { + $AUSE_DST=0; + } else { + $AUSE_DST=1; + } + } + } else { + $AUSE_DST=0; + } + } # end of month checks + if ($DBX) {print " DST: $AUSE_DST\n";} + if ($AUSE_DST) {$gmt_offset++;} + $AC_processed++; + } + + if ( (!$AC_processed) and ($dst_range == 'FSO-TSM') ) + { + if ($DBX) {print " First Sunday October to Third Sunday March\n";} + #********************************************************************** + # This is s 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on first Sunday in October and third Sunday in March at 1 am. + #********************************************************************** + + $NZL_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $NZL_DST=1; + } elseif ($mm >= 4 and $mm <= 9) { + $NZL_DST=0; + } elseif ($mm == 3) { + if ($dd < 14) { + $NZL_DST=1; + } elseif ($dd < ($dow+14)) { + $NZL_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $NZL_DST=1; + } else { + $NZL_DST=0; + } + } else { # local time calculations + if ($ns < 3600) { + $NZL_DST=1; + } else { + $NZL_DST=0; + } + } + } else { + $NZL_DST=0; + } + } elseif ($mm == 10) { + if ($dd > 7) { + $NZL_DST=1; + } elseif ($dd >= ($dow+1)) { + if ($timezone) { + if ($dow == 0 and $ns < (7200+$timezone*3600)) { + $NZL_DST=0; + } else { + $NZL_DST=1; + } + } else { + if ($dow == 0 and $ns < 3600) { + $NZL_DST=0; + } else { + $NZL_DST=1; + } + } + } else { + $NZL_DST=0; + } + } # end of month checks + if ($DBX) {print " DST: $NZL_DST\n";} + if ($NZL_DST) {$gmt_offset++;} + $AC_processed++; + } + + if ( (!$AC_processed) and ($dst_range == 'LSS-FSA') ) + { + if ($DBX) {print " Last Sunday in September to First Sunday in April\n";} + #********************************************************************** + # LSS-FSA + # 2007+ NEW ZEALAND (country code 64) + # This is returns 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on last Sunday in September and first Sunday in April at 1 am. + #********************************************************************** + + $NZLN_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 4 || $mm > 9) { + $NZLN_DST=1; + } elseif ($mm >= 5 && $mm <= 9) { + $NZLN_DST=0; + } elseif ($mm == 4) { + if ($dd > 7) { + $NZLN_DST=0; + } elseif ($dd >= ($dow+1)) { + if ($timezone) { + if ($dow == 0 && $ns < (3600+$timezone*3600)) { + $NZLN_DST=1; + } else { + $NZLN_DST=0; + } + } else { + if ($dow == 0 && $ns < 7200) { + $NZLN_DST=1; + } else { + $NZLN_DST=0; + } + } + } else { + $NZLN_DST=1; + } + } elseif ($mm == 9) { + if ($dd < 25) { + $NZLN_DST=0; + } elseif ($dd < ($dow+25)) { + $NZLN_DST=0; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $NZLN_DST=0; + } else { + $NZLN_DST=1; + } + } else { # local time calculations + if ($ns < 3600) { + $NZLN_DST=0; + } else { + $NZLN_DST=1; + } + } + } else { + $NZLN_DST=1; + } + } # end of month checks + if ($DBX) {print " DST: $NZLN_DST\n";} + if ($NZLN_DST) {$gmt_offset++;} + $AC_processed++; + } + + if ( (!$AC_processed) and ($dst_range == 'TSO-LSF') ) + { + if ($DBX) {print " Third Sunday October to Last Sunday February\n";} + #********************************************************************** + # TSO-LSF + # This is returns 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. Brazil + # Based on Third Sunday October to Last Sunday February at 1 am. + #********************************************************************** + + $BZL_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 2 || $mm > 10) { + $BZL_DST=1; + } elseif ($mm >= 3 and $mm <= 9) { + $BZL_DST=0; + } elseif ($mm == 2) { + if ($dd < 22) { + $BZL_DST=1; + } elseif ($dd < ($dow+22)) { + $BZL_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $BZL_DST=1; + } else { + $BZL_DST=0; + } + } else { # local time calculations + if ($ns < 3600) { + $BZL_DST=1; + } else { + $BZL_DST=0; + } + } + } else { + $BZL_DST=0; + } + } elseif ($mm == 10) { + if ($dd < 22) { + $BZL_DST=0; + } elseif ($dd < ($dow+22)) { + $BZL_DST=0; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $BZL_DST=0; + } else { + $BZL_DST=1; + } + } else { # local time calculations + if ($ns < 3600) { + $BZL_DST=0; + } else { + $BZL_DST=1; + } + } + } else { + $BZL_DST=1; + } + } # end of month checks + if ($DBX) {print " DST: $BZL_DST\n";} + if ($BZL_DST) {$gmt_offset++;} + $AC_processed++; + } + + if (!$AC_processed) + { + if ($DBX) {print " No DST Method Found\n";} + if ($DBX) {print " DST: 0\n";} + $AC_processed++; + } + + return $gmt_offset; + } + + + + + +##### DETERMINE IF LEAD IS DIALABLE ##### +function dialable_gmt($DB,$link,$local_call_time,$gmt_offset,$state) + { + require("dbconnect.php"); + + $dialable=0; + + $pzone=3600 * $gmt_offset; + $pmin=(gmdate("i", time() + $pzone)); + $phour=( (gmdate("G", time() + $pzone)) * 100); + $pday=gmdate("w", time() + $pzone); + $tz = sprintf("%.2f", $p); + $GMT_gmt = "$tz"; + $GMT_day = "$pday"; + $GMT_hour = ($phour + $pmin); + + $stmt="SELECT call_time_id,call_time_name,call_time_comments,ct_default_start,ct_default_stop,ct_sunday_start,ct_sunday_stop,ct_monday_start,ct_monday_stop,ct_tuesday_start,ct_tuesday_stop,ct_wednesday_start,ct_wednesday_stop,ct_thursday_start,ct_thursday_stop,ct_friday_start,ct_friday_stop,ct_saturday_start,ct_saturday_stop,ct_state_call_times FROM vicidial_call_times where call_time_id='$local_call_time';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + $Gct_default_start = $rowx[3]; + $Gct_default_stop = $rowx[4]; + $Gct_sunday_start = $rowx[5]; + $Gct_sunday_stop = $rowx[6]; + $Gct_monday_start = $rowx[7]; + $Gct_monday_stop = $rowx[8]; + $Gct_tuesday_start = $rowx[9]; + $Gct_tuesday_stop = $rowx[10]; + $Gct_wednesday_start = $rowx[11]; + $Gct_wednesday_stop = $rowx[12]; + $Gct_thursday_start = $rowx[13]; + $Gct_thursday_stop = $rowx[14]; + $Gct_friday_start = $rowx[15]; + $Gct_friday_stop = $rowx[16]; + $Gct_saturday_start = $rowx[17]; + $Gct_saturday_stop = $rowx[18]; + $Gct_state_call_times = $rowx[19]; + + if ($GMT_day==0) #### Sunday local time + { + if (($Gct_sunday_start==0) and ($Gct_sunday_stop==0)) + { + if ( ($GMT_hour>=$Gct_default_start) and ($GMT_hour<$Gct_default_stop) ) + {$dialable=1;} + } + else + { + if ( ($GMT_hour>=$Gct_sunday_start) and ($GMT_hour<$Gct_sunday_stop) ) + {$dialable=1;} + } + } + if ($GMT_day==1) #### Monday local time + { + if (($Gct_monday_start==0) and ($Gct_monday_stop==0)) + { + if ( ($GMT_hour>=$Gct_default_start) and ($GMT_hour<$Gct_default_stop) ) + {$dialable=1;} + } + else + { + if ( ($GMT_hour>=$Gct_monday_start) and ($GMT_hour<$Gct_monday_stop) ) + {$dialable=1;} + } + } + if ($GMT_day==2) #### Tuesday local time + { + if (($Gct_tuesday_start==0) and ($Gct_tuesday_stop==0)) + { + if ( ($GMT_hour>=$Gct_default_start) and ($GMT_hour<$Gct_default_stop) ) + {$dialable=1;} + } + else + { + if ( ($GMT_hour>=$Gct_tuesday_start) and ($GMT_hour<$Gct_tuesday_stop) ) + {$dialable=1;} + } + } + if ($GMT_day==3) #### Wednesday local time + { + if (($Gct_wednesday_start==0) and ($Gct_wednesday_stop==0)) + { + if ( ($GMT_hour>=$Gct_default_start) and ($GMT_hour<$Gct_default_stop) ) + {$dialable=1;} + } + else + { + if ( ($GMT_hour>=$Gct_wednesday_start) and ($GMT_hour<$Gct_wednesday_stop) ) + {$dialable=1;} + } + } + if ($GMT_day==4) #### Thursday local time + { + if (($Gct_thursday_start==0) and ($Gct_thursday_stop==0)) + { + if ( ($GMT_hour>=$Gct_default_start) and ($GMT_hour<$Gct_default_stop) ) + {$dialable=1;} + } + else + { + if ( ($GMT_hour>=$Gct_thursday_start) and ($GMT_hour<$Gct_thursday_stop) ) + {$dialable=1;} + } + } + if ($GMT_day==5) #### Friday local time + { + if (($Gct_friday_start==0) and ($Gct_friday_stop==0)) + { + if ( ($GMT_hour>=$Gct_default_start) and ($GMT_hour<$Gct_default_stop) ) + {$dialable=1;} + } + else + { + if ( ($GMT_hour>=$Gct_friday_start) and ($GMT_hour<$Gct_friday_stop) ) + {$dialable=1;} + } + } + if ($GMT_day==6) #### Saturday local time + { + if (($Gct_saturday_start==0) and ($Gct_saturday_stop==0)) + { + if ( ($GMT_hour>=$Gct_default_start) and ($GMT_hour<$Gct_default_stop) ) + {$dialable=1;} + } + else + { + if ( ($GMT_hour>=$Gct_saturday_start) and ($GMT_hour<$Gct_saturday_stop) ) + {$dialable=1;} + } + } + + return $dialable; + } + + ##### MySQL Error Logging ##### function mysql_error_logging($NOW_TIME,$link,$mel,$stmt,$query_id,$user,$server_ip,$session_name,$one_mysql_log) diff --git a/agc_2-X/trunk/LANG_www/agc_es/manager_send.php b/agc_2-X/trunk/LANG_www/agc_es/manager_send.php index 952beb0d..70cc3849 100644 --- a/agc_2-X/trunk/LANG_www/agc_es/manager_send.php +++ b/agc_2-X/trunk/LANG_www/agc_es/manager_send.php @@ -1,7 +1,7 @@ LICENSE: AGPLv2 +# Copyright (C) 2011 Matt Florell LICENSE: AGPLv2 # # This script is designed purely to insert records into the vicidial_manager table to signal Actions to an asterisk server # This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table @@ -43,6 +43,8 @@ # - $nodeletevdac - ('0','1') # - $alertCID - ('0','1') # - $preset_name = ('TESTING PRESET',...) +# - $call_variables = ('Variable: vendor_lead_code=1234|campaign=TESTCAMP|...') +# - $log_campaign # # CHANGELOG: # 50401-1002 - First build of script, Hangup function only @@ -102,12 +104,15 @@ # 100813-0833 - Added preset_name variable and logging # 101004-1345 - Added Ivr park functions # 101024-1638 - Added park_log logging for parked calls +# 101107-2331 - Added CALLERONHOLD/CALLEROFFHOLD queue_log entries +# 101125-1018 - Added call_variables Originate variables +# 110224-1710 - Added compatibility with QM phone environment logging # -$version = '2.4-52'; -$build = '101024-1638'; +$version = '2.4-55'; +$build = '110224-1710'; $mel=1; # Mysql Error Log enabled = 1 -$mysql_log_count=97; +$mysql_log_count=116; $one_mysql_log=0; require("dbconnect.php"); @@ -197,6 +202,10 @@ if (isset($_GET["alertCID"])) {$alertCID=$_GET["alertCID"];} elseif (isset($_POST["alertCID"])) {$alertCID=$_POST["alertCID"];} if (isset($_GET["preset_name"])) {$preset_name=$_GET["preset_name"];} elseif (isset($_POST["preset_name"])) {$preset_name=$_POST["preset_name"];} +if (isset($_GET["call_variables"])) {$call_variables=$_GET["call_variables"];} + elseif (isset($_POST["call_variables"])) {$call_variables=$_POST["call_variables"];} +if (isset($_GET["log_campaign"])) {$log_campaign=$_GET["log_campaign"];} + elseif (isset($_POST["log_campaign"])) {$log_campaign=$_POST["log_campaign"];} header ("Content-type: text/html; charset=utf-8"); @@ -437,10 +446,12 @@ if ($ACTION=="Originate") { $RAWaccount = $account; $account = "Account: $account"; - $variable = "Variable: usegroupalias=1"; + $variable = "Variable: _usegroupalias=1"; + if (strlen($call_variables)>9) + {$variable = "Variable: _usegroupalias=1";} # |$call_variables } else - {$account=''; $variable='';} + {$variable=''; $account="Variable: $call_variables";} $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$queryCID','Channel: $channel','Context: $ext_context','Exten: $exten','Priority: $ext_priority','Callerid: $outCID','$account','$variable','','','');"; if ($format=='debug') {echo "\n";} $rslt=mysql_query($stmt, $link); @@ -712,8 +723,20 @@ if ($ACTION=="Hangup") if ($time_id > 100000) {$secondS = ($StarTtime - $time_id);} + $data4SQL=''; + $stmt="SELECT queuemetrics_phone_environment FROM vicidial_campaigns where campaign_id='$log_campaign' and queuemetrics_phone_environment!='';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'02116',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $cqpe_ct = mysql_num_rows($rslt); + if ($cqpe_ct > 0) + { + $row=mysql_fetch_row($rslt); + $data4SQL = ",data4='$row[0]'"; + } + if ($format=='debug') {echo "\n";} - $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='$CalLCID',queue='$CLcampaign_id',agent='Agent/$user',verb='COMPLETEAGENT',data1='$CLstage',data2='$secondS',data3='$CLqueue_position',serverid='$queuemetrics_log_id';"; + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='$CalLCID',queue='$CLcampaign_id',agent='Agent/$user',verb='COMPLETEAGENT',data1='$CLstage',data2='$secondS',data3='$CLqueue_position',serverid='$queuemetrics_log_id' $data4SQL;"; $rslt=mysql_query($stmt, $linkB); if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'02019',$user,$server_ip,$session_name,$one_mysql_log);} $affected_rows = mysql_affected_rows($linkB); @@ -842,7 +865,60 @@ if ($ACTION=="RedirectToPark") $stmt = "INSERT INTO park_log SET uniqueid='$uniqueid',status='PARKINGED',channel='$channel',channel_group='$campaign',server_ip='$server_ip',parked_time='$NOW_TIME',parked_sec=0,extension='$CalLCID',user='$user',lead_id='$lead_id';"; if ($format=='debug') {echo "\n";} $rslt=mysql_query($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02XXX',$user,$server_ip,$session_name,$one_mysql_log);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02098',$user,$server_ip,$session_name,$one_mysql_log);} + + + ############################################# + ##### START QUEUEMETRICS LOGGING LOOKUP ##### + $stmt = "SELECT enable_queuemetrics_logging,queuemetrics_server_ip,queuemetrics_dbname,queuemetrics_login,queuemetrics_pass,queuemetrics_log_id FROM system_settings;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02099',$user,$server_ip,$session_name,$one_mysql_log);} + if ($format=='debug') {echo "\n";} + $qm_conf_ct = mysql_num_rows($rslt); + $i=0; + while ($i < $qm_conf_ct) + { + $row=mysql_fetch_row($rslt); + $enable_queuemetrics_logging = $row[0]; + $queuemetrics_server_ip = $row[1]; + $queuemetrics_dbname = $row[2]; + $queuemetrics_login = $row[3]; + $queuemetrics_pass = $row[4]; + $queuemetrics_log_id = $row[5]; + $i++; + } + ##### END QUEUEMETRICS LOGGING LOOKUP ##### + ########################################### + if ($enable_queuemetrics_logging > 0) + { + $linkB=mysql_connect("$queuemetrics_server_ip", "$queuemetrics_login", "$queuemetrics_pass"); + mysql_select_db("$queuemetrics_dbname", $linkB); + + $time_id=0; + $stmt="SELECT time_id,queue,agent from queue_log where call_id='$CalLCID' and verb='CONNECT' order by time_id desc limit 1;"; + $rslt=mysql_query($stmt, $linkB); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'02100',$user,$server_ip,$session_name,$one_mysql_log);} + $VAC_eq_ct = mysql_num_rows($rslt); + if ($VAC_eq_ct > 0) + { + $row=mysql_fetch_row($rslt); + $time_id = $row[0]; + $queue = $row[1]; + $agent = $row[2]; + } + $StarTtime = date("U"); + if ($time_id > 100000) + {$secondS = ($StarTtime - $time_id);} + + if ($VAC_eq_ct > 0) + { + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='$CalLCID',queue='$queue',agent='Agent/$user',verb='CALLERONHOLD',data1='PARKING',serverid='$queuemetrics_log_id';"; + $rslt=mysql_query($stmt, $linkB); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'02101',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($linkB); + if ($format=='debug') {echo "\n";} + } + } # $fp = fopen ("./vicidial_debug.txt", "a"); # fwrite ($fp, "$NOW_TIME|MS_LOG_0|$queryCID|$stmt|\n"); @@ -880,7 +956,7 @@ if ($ACTION=="RedirectFromPark") $parked_sec=0; $stmt = "SELECT UNIX_TIMESTAMP(parked_time) FROM park_log where uniqueid='$uniqueid' and server_ip='$server_ip' and extension='$CalLCID' and (parked_sec < 1 or grab_time is NULL) order by parked_time desc limit 1;"; $rslt=mysql_query($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02XXX',$user,$server_ip,$session_name,$one_mysql_log);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02102',$user,$server_ip,$session_name,$one_mysql_log);} $VAC_pl_ct = mysql_num_rows($rslt); if ($VAC_pl_ct > 0) { @@ -890,7 +966,59 @@ if ($ACTION=="RedirectFromPark") $stmt = "UPDATE park_log SET status='GRABBED',grab_time='$NOW_TIME',parked_sec='$parked_sec' where uniqueid='$uniqueid' and server_ip='$server_ip' and extension='$CalLCID' order by parked_time desc limit 1;"; if ($format=='debug') {echo "\n";} $rslt=mysql_query($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02XXX',$user,$server_ip,$session_name,$one_mysql_log);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02103',$user,$server_ip,$session_name,$one_mysql_log);} + + ############################################# + ##### START QUEUEMETRICS LOGGING LOOKUP ##### + $stmt = "SELECT enable_queuemetrics_logging,queuemetrics_server_ip,queuemetrics_dbname,queuemetrics_login,queuemetrics_pass,queuemetrics_log_id FROM system_settings;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02104',$user,$server_ip,$session_name,$one_mysql_log);} + if ($format=='debug') {echo "\n";} + $qm_conf_ct = mysql_num_rows($rslt); + $i=0; + while ($i < $qm_conf_ct) + { + $row=mysql_fetch_row($rslt); + $enable_queuemetrics_logging = $row[0]; + $queuemetrics_server_ip = $row[1]; + $queuemetrics_dbname = $row[2]; + $queuemetrics_login = $row[3]; + $queuemetrics_pass = $row[4]; + $queuemetrics_log_id = $row[5]; + $i++; + } + ##### END QUEUEMETRICS LOGGING LOOKUP ##### + ########################################### + if ($enable_queuemetrics_logging > 0) + { + $linkB=mysql_connect("$queuemetrics_server_ip", "$queuemetrics_login", "$queuemetrics_pass"); + mysql_select_db("$queuemetrics_dbname", $linkB); + + $time_id=0; + $stmt="SELECT time_id,queue,agent from queue_log where call_id='$CalLCID' and verb='CONNECT' order by time_id desc limit 1;"; + $rslt=mysql_query($stmt, $linkB); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'02105',$user,$server_ip,$session_name,$one_mysql_log);} + $VAC_eq_ct = mysql_num_rows($rslt); + if ($VAC_eq_ct > 0) + { + $row=mysql_fetch_row($rslt); + $time_id = $row[0]; + $queue = $row[1]; + $agent = $row[2]; + } + $StarTtime = date("U"); + if ($time_id > 100000) + {$secondS = ($StarTtime - $time_id);} + + if ($VAC_eq_ct > 0) + { + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='$CalLCID',queue='$queue',agent='Agent/$user',verb='CALLEROFFHOLD',data1='$parked_sec',data2='PARKING',serverid='$queuemetrics_log_id';"; + $rslt=mysql_query($stmt, $linkB); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'02106',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($linkB); + if ($format=='debug') {echo "\n";} + } + } } } @@ -932,8 +1060,59 @@ if ($ACTION=="RedirectToParkIVR") $stmt = "INSERT INTO park_log SET uniqueid='$uniqueid',status='IVRPARKINGED',channel='$channel',channel_group='$campaign',server_ip='$server_ip',parked_time='$NOW_TIME',parked_sec=0,extension='$CalLCID',user='$user',lead_id='$lead_id';"; if ($format=='debug') {echo "\n";} $rslt=mysql_query($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02XXX',$user,$server_ip,$session_name,$one_mysql_log);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02107',$user,$server_ip,$session_name,$one_mysql_log);} + ############################################# + ##### START QUEUEMETRICS LOGGING LOOKUP ##### + $stmt = "SELECT enable_queuemetrics_logging,queuemetrics_server_ip,queuemetrics_dbname,queuemetrics_login,queuemetrics_pass,queuemetrics_log_id FROM system_settings;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02108',$user,$server_ip,$session_name,$one_mysql_log);} + if ($format=='debug') {echo "\n";} + $qm_conf_ct = mysql_num_rows($rslt); + $i=0; + while ($i < $qm_conf_ct) + { + $row=mysql_fetch_row($rslt); + $enable_queuemetrics_logging = $row[0]; + $queuemetrics_server_ip = $row[1]; + $queuemetrics_dbname = $row[2]; + $queuemetrics_login = $row[3]; + $queuemetrics_pass = $row[4]; + $queuemetrics_log_id = $row[5]; + $i++; + } + ##### END QUEUEMETRICS LOGGING LOOKUP ##### + ########################################### + if ($enable_queuemetrics_logging > 0) + { + $linkB=mysql_connect("$queuemetrics_server_ip", "$queuemetrics_login", "$queuemetrics_pass"); + mysql_select_db("$queuemetrics_dbname", $linkB); + + $time_id=0; + $stmt="SELECT time_id,queue,agent from queue_log where call_id='$CalLCID' and verb='CONNECT' order by time_id desc limit 1;"; + $rslt=mysql_query($stmt, $linkB); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'02109',$user,$server_ip,$session_name,$one_mysql_log);} + $VAC_eq_ct = mysql_num_rows($rslt); + if ($VAC_eq_ct > 0) + { + $row=mysql_fetch_row($rslt); + $time_id = $row[0]; + $queue = $row[1]; + $agent = $row[2]; + } + $StarTtime = date("U"); + if ($time_id > 100000) + {$secondS = ($StarTtime - $time_id);} + + if ($VAC_eq_ct > 0) + { + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='$CalLCID',queue='$queue',agent='Agent/$user',verb='CALLERONHOLD',data1='IVRPARKING',serverid='$queuemetrics_log_id';"; + $rslt=mysql_query($stmt, $linkB); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'02110',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($linkB); + if ($format=='debug') {echo "\n";} + } + } # $fp = fopen ("./vicidial_debug.txt", "a"); # fwrite ($fp, "$NOW_TIME|MS_LOG_0|$queryCID|$stmt|\n"); # fclose($fp); @@ -975,7 +1154,7 @@ if ($ACTION=="RedirectFromParkIVR") $parked_sec=0; $stmt = "SELECT UNIX_TIMESTAMP(parked_time) FROM park_log where uniqueid='$uniqueid' and server_ip='$server_ip' and extension='$CalLCID' and (parked_sec < 1 or grab_time is NULL) order by parked_time desc limit 1;"; $rslt=mysql_query($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02XXX',$user,$server_ip,$session_name,$one_mysql_log);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02111',$user,$server_ip,$session_name,$one_mysql_log);} $VAC_pl_ct = mysql_num_rows($rslt); if ($VAC_pl_ct > 0) { @@ -985,7 +1164,59 @@ if ($ACTION=="RedirectFromParkIVR") $stmt = "UPDATE park_log SET status='GRABBEDIVR',grab_time='$NOW_TIME',parked_sec='$parked_sec' where uniqueid='$uniqueid' and server_ip='$server_ip' and extension='$CalLCID' order by parked_time desc limit 1;"; if ($format=='debug') {echo "\n";} $rslt=mysql_query($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02XXX',$user,$server_ip,$session_name,$one_mysql_log);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02112',$user,$server_ip,$session_name,$one_mysql_log);} + + ############################################# + ##### START QUEUEMETRICS LOGGING LOOKUP ##### + $stmt = "SELECT enable_queuemetrics_logging,queuemetrics_server_ip,queuemetrics_dbname,queuemetrics_login,queuemetrics_pass,queuemetrics_log_id FROM system_settings;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02113',$user,$server_ip,$session_name,$one_mysql_log);} + if ($format=='debug') {echo "\n";} + $qm_conf_ct = mysql_num_rows($rslt); + $i=0; + while ($i < $qm_conf_ct) + { + $row=mysql_fetch_row($rslt); + $enable_queuemetrics_logging = $row[0]; + $queuemetrics_server_ip = $row[1]; + $queuemetrics_dbname = $row[2]; + $queuemetrics_login = $row[3]; + $queuemetrics_pass = $row[4]; + $queuemetrics_log_id = $row[5]; + $i++; + } + ##### END QUEUEMETRICS LOGGING LOOKUP ##### + ########################################### + if ($enable_queuemetrics_logging > 0) + { + $linkB=mysql_connect("$queuemetrics_server_ip", "$queuemetrics_login", "$queuemetrics_pass"); + mysql_select_db("$queuemetrics_dbname", $linkB); + + $time_id=0; + $stmt="SELECT time_id,queue,agent from queue_log where call_id='$CalLCID' and verb='CONNECT' order by time_id desc limit 1;"; + $rslt=mysql_query($stmt, $linkB); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'02114',$user,$server_ip,$session_name,$one_mysql_log);} + $VAC_eq_ct = mysql_num_rows($rslt); + if ($VAC_eq_ct > 0) + { + $row=mysql_fetch_row($rslt); + $time_id = $row[0]; + $queue = $row[1]; + $agent = $row[2]; + } + $StarTtime = date("U"); + if ($time_id > 100000) + {$secondS = ($StarTtime - $time_id);} + + if ($VAC_eq_ct > 0) + { + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='$CalLCID',queue='$queue',agent='Agent/$user',verb='CALLEROFFHOLD',data1='$parked_sec',data2='IVRPARKING',serverid='$queuemetrics_log_id';"; + $rslt=mysql_query($stmt, $linkB); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'02115',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($linkB); + if ($format=='debug') {echo "\n";} + } + } } } diff --git a/agc_2-X/trunk/LANG_www/agc_es/vdc_db_query.php b/agc_2-X/trunk/LANG_www/agc_es/vdc_db_query.php index 50f0c962..2b029c22 100644 --- a/agc_2-X/trunk/LANG_www/agc_es/vdc_db_query.php +++ b/agc_2-X/trunk/LANG_www/agc_es/vdc_db_query.php @@ -1,7 +1,7 @@ LICENSE: AGPLv2 +# Copyright (C) 2011 Matt Florell LICENSE: AGPLv2 # # This script is designed to exchange information between vicidial.php and the database server for various actions # @@ -89,6 +89,7 @@ # - $DiaL_SecondS - ('0','1','2',...) # - $date - ('2010-02-19') # - $custom_field_names - ('|start_date|finish_date|favorite_color|') +# - $call_notes # # CHANGELOG: # 50629-1044 - First build of script @@ -260,15 +261,36 @@ # 100927-1618 - Added ability to use custom fields in web form and dispo_call_url # 101001-1451 - Added full name display to Call Log functionality # 101022-1243 - Fixed missing variables from start and dispo call urls +# 101108-0115 - Added ADDMEMBER option for queue_log +# 101111-1556 - Added source to vicidial_hopper inserts +# 101124-1033 - Added require for functions.php and manual dial call time check campaign option +# 101128-0108 - Added list override for webforms +# 101208-0414 - Fixed Call Log dial bug (issue 393) +# 110103-1343 - Added queuemetrics_loginout NONE option +# 110124-1134 - Small query fix for large queue_log tables +# 110124-1456 - Fixed AREACODE DNC manual dial bug +# 110212-2103 - Added support for custom scheduled callback statuses +# 110214-2320 - Added support for lead_order_secondary option +# 110215-1125 - Added support for call_notes +# 110218-1519 - Added support for agent lead search +# 110222-2228 - Added owner restriction to agent lead search +# 110224-1712 - Added compatibility with QM phone environment logging and QM pause code last call logging +# 110225-1237 - Added scheduled callback lead info display to the lead info view function +# 110303-1616 - Added vicidial_log_extended logging for manual dial calls +# 110304-1207 - Changed lead search with territory restriction to work with agents that cannot select territories +# 110310-0546 - Added ability to set a pause code at the same time of a pause +# 110310-1628 - removed callslogview, extended lead info function to be used instead +# 110317-0222 - Logging bug fixes # -$version = '2.4-166'; -$build = '101022-1243'; +$version = '2.4-186'; +$build = '110317-0222'; $mel=1; # Mysql Error Log enabled = 1 -$mysql_log_count=345; +$mysql_log_count=413; $one_mysql_log=0; require("dbconnect.php"); +require("functions.php"); ### If you have globals turned off uncomment these lines if (isset($_GET["user"])) {$user=$_GET["user"];} @@ -449,6 +471,18 @@ if (isset($_GET["date"])) {$date=$_GET["date"];} elseif (isset($_POST["date"])) {$date=$_POST["date"];} if (isset($_GET["custom_field_names"])) {$FORMcustom_field_names=$_GET["custom_field_names"];} elseif (isset($_POST["custom_field_names"])) {$FORMcustom_field_names=$_POST["custom_field_names"];} +if (isset($_GET["qm_phone"])) {$qm_phone=$_GET["qm_phone"];} + elseif (isset($_POST["qm_phone"])) {$qm_phone=$_POST["qm_phone"];} +if (isset($_GET["manual_dial_call_time_check"])) {$manual_dial_call_time_check=$_GET["manual_dial_call_time_check"];} + elseif (isset($_POST["manual_dial_call_time_check"])) {$manual_dial_call_time_check=$_POST["manual_dial_call_time_check"];} +if (isset($_GET["CallBackLeadEstado"])) {$CallBackLeadEstado=$_GET["CallBackLeadEstado"];} + elseif (isset($_POST["CallBackLeadEstado"])) {$CallBackLeadEstado=$_POST["CallBackLeadEstado"];} +if (isset($_GET["call_notes"])) {$call_notes=$_GET["call_notes"];} + elseif (isset($_POST["call_notes"])) {$call_notes=$_POST["call_notes"];} +if (isset($_GET["search"])) {$search=$_GET["search"];} + elseif (isset($_POST["search"])) {$search=$_POST["search"];} +if (isset($_GET["sub_status"])) {$sub_status=$_GET["sub_status"];} + elseif (isset($_POST["sub_status"])) {$sub_status=$_POST["sub_status"];} header ("Content-type: text/html; charset=utf-8"); @@ -465,6 +499,7 @@ $MT[0]=''; $agents='@agents'; $US='_'; while (strlen($CIDdate) > 9) {$CIDdate = substr("$CIDdate", 1);} +$check_time = ($StarTtime - 86400); ##### Hangup Cause Dictionary ##### $hangup_cause_dictionary = array( @@ -863,6 +898,35 @@ if ($ACTION == 'regCLOSER') $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00012',$user,$server_ip,$session_name,$one_mysql_log);} + ############################################# + ##### START QUEUEMETRICS LOGGING LOOKUP ##### + $stmt = "SELECT enable_queuemetrics_logging,queuemetrics_server_ip,queuemetrics_dbname,queuemetrics_login,queuemetrics_pass,queuemetrics_log_id,queuemetrics_addmember_enabled,queuemetrics_dispo_pause FROM system_settings;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00349',$user,$server_ip,$session_name,$one_mysql_log);} + if ($format=='debug') {echo "\n";} + $qm_conf_ct = mysql_num_rows($rslt); + $i=0; + while ($i < $qm_conf_ct) + { + $row=mysql_fetch_row($rslt); + $enable_queuemetrics_logging = $row[0]; + $queuemetrics_server_ip = $row[1]; + $queuemetrics_dbname = $row[2]; + $queuemetrics_login = $row[3]; + $queuemetrics_pass = $row[4]; + $queuemetrics_log_id = $row[5]; + $queuemetrics_addmember_enabled = $row[6]; + $queuemetrics_dispo_pause = $row[7]; + $i++; + } + ##### END QUEUEMETRICS LOGGING LOOKUP ##### + ########################################### + if ( ($enable_queuemetrics_logging > 0) and ($queuemetrics_addmember_enabled > 0) ) + { + $linkB=mysql_connect("$queuemetrics_server_ip", "$queuemetrics_login", "$queuemetrics_pass"); + mysql_select_db("$queuemetrics_dbname", $linkB); + } + $in_groups_pre = preg_replace('/-$/','',$closer_choice); $in_groups = explode(" ",$in_groups_pre); $in_groups_ct = count($in_groups); @@ -891,6 +955,28 @@ if ($ACTION == 'regCLOSER') if ($format=='debug') {echo "\n";} $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00014',$user,$server_ip,$session_name,$one_mysql_log);} + + if ( ($enable_queuemetrics_logging > 0) and ($queuemetrics_addmember_enabled > 0) ) + { + $data4SQL=''; + $stmt="SELECT queuemetrics_phone_environment FROM vicidial_campaigns where campaign_id='$campaign' and queuemetrics_phone_environment!='';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00388',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $cqpe_ct = mysql_num_rows($rslt); + if ($cqpe_ct > 0) + { + $row=mysql_fetch_row($rslt); + $data4SQL = ",data4='$row[0]'"; + } + + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='NONE',queue='$in_groups[$k]',agent='Agent/$user',verb='ADDMEMBER2',data1='$qm_phone',serverid='$queuemetrics_log_id' $data4SQL;"; + $rslt=mysql_query($stmt, $linkB); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'0350',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($linkB); + if ($format=='debug') {echo "\n";} + } + } $k++; } @@ -1083,7 +1169,9 @@ if ($ACTION == 'manDiaLnextCaLL') { $MT[0]=''; $row=''; $rowx=''; + $override_dial_number=''; $channel_live=1; + $lead_id = ereg_replace("[^0-9]","",$lead_id); if ( (strlen($conf_exten)<1) || (strlen($campaign)<1) || (strlen($ext_context)<1) ) { $channel_live=0; @@ -1134,31 +1222,163 @@ if ($ACTION == 'manDiaLnextCaLL') $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00016',$user,$server_ip,$session_name,$one_mysql_log);} } + ### check if this is a specific lead call, if it is, skip the grabbing of a new lead + elseif (strlen($lead_id)>0) + { + $affected_rows=1; + $CBleadIDset=1; + + if (strlen($phone_number) > 5) + {$override_dial_number = $phone_number;} + } else { if (strlen($phone_number)>3) { + if (ereg("ENABLED",$manual_dial_call_time_check)) + { + $secX = date("U"); + $hour = date("H"); + $min = date("i"); + $sec = date("s"); + $mon = date("m"); + $mday = date("d"); + $year = date("Y"); + $isdst = date("I"); + $Shour = date("H"); + $Smin = date("i"); + $Ssec = date("s"); + $Smon = date("m"); + $Smday = date("d"); + $Syear = date("Y"); + $pulldate0 = "$year-$mon-$mday $hour:$min:$sec"; + $inSD = $pulldate0; + $dsec = ( ( ($hour * 3600) + ($min * 60) ) + $sec ); + + ### Grab Servidor GMT value from the database + $stmt="SELECT local_gmt FROM servers where active='Y' limit 1;"; + $rslt=mysql_query($stmt, $link); + $gmt_recs = mysql_num_rows($rslt); + if ($gmt_recs > 0) + { + $row=mysql_fetch_row($rslt); + $DBSERVER_GMT = $row[0]; + if (strlen($DBSERVER_GMT)>0) {$SERVER_GMT = $DBSERVER_GMT;} + if ($isdst) {$SERVER_GMT++;} + } + else + { + $SERVER_GMT = date("O"); + $SERVER_GMT = eregi_replace("\+","",$SERVER_GMT); + $SERVER_GMT = ($SERVER_GMT + 0); + $SERVER_GMT = ($SERVER_GMT / 100); + } + + $LOCAL_GMT_OFF = $SERVER_GMT; + $LOCAL_GMT_OFF_STD = $SERVER_GMT; + $postalgmt=''; + $postal_code=''; + $state=''; + if (strlen($phone_code)<1) + {$phone_code='1';} + + $local_call_time='24hours'; + ##### gather local call time setting from campaign + $stmt="SELECT local_call_time FROM vicidial_campaigns where campaign_id='$campaign';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00353',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $camp_lct_ct = mysql_num_rows($rslt); + if ($camp_lct_ct > 0) + { + $row=mysql_fetch_row($rslt); + $local_call_time = $row[0]; + } + + ### get current gmt_offset of the phone_number + $gmt_offset = lookup_gmt($phone_code,$USarea,$state,$LOCAL_GMT_OFF_STD,$Shour,$Smin,$Ssec,$Smon,$Smday,$Syear,$postalgmt,$postal_code); + + $dialable = dialable_gmt($DB,$link,$local_call_time,$gmt_offset,$state); + + if ($dialable < 1) + { + ### insert a new lead in the system with this phone number + $stmt = "DELETE from vicidial_manual_dial_queue where phone_number='$phone_number' and user='$user';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00354',$user,$server_ip,$session_name,$one_mysql_log);} + $VMDQaffected_rows = mysql_affected_rows($link); + + $stmt = "UPDATE vicidial_live_agents set external_dial='' where user='$user';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00355',$user,$server_ip,$session_name,$one_mysql_log);} + $VLAEDaffected_rows = mysql_affected_rows($link); + + echo "OUTSIDE OF LOCAL LLAMADA TIME $VMDQaffected_rows|$VLAEDaffected_rows\n"; + exit; + } + } + if (ereg("DNC",$manual_dial_filter)) { - $stmt="SELECT count(*) FROM vicidial_dnc where phone_number='$phone_number';"; + if (ereg("AREACODE",$use_internal_dnc)) + { + $phone_number_areacode = substr($phone_number, 0, 3); + $phone_number_areacode .= "XXXXXXX"; + $stmt="SELECT count(*) from vicidial_dnc where phone_number IN('$phone_number','$phone_number_areacode');"; + } + else + {$stmt="SELECT count(*) FROM vicidial_dnc where phone_number='$phone_number';";} $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00017',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} $row=mysql_fetch_row($rslt); - if ($row[0] > 0) { + ### insert a new lead in the system with this phone number + $stmt = "DELETE from vicidial_manual_dial_queue where phone_number='$phone_number' and user='$user';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00356',$user,$server_ip,$session_name,$one_mysql_log);} + $VMDQaffected_rows = mysql_affected_rows($link); + + $stmt = "UPDATE vicidial_live_agents set external_dial='' where user='$user';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00357',$user,$server_ip,$session_name,$one_mysql_log);} + $VLAEDaffected_rows = mysql_affected_rows($link); + echo "DNC NÚMERO\n"; exit; } - $stmt="SELECT count(*) FROM vicidial_campaign_dnc where phone_number='$phone_number' and campaign_id='$campaign';"; + if (ereg("AREACODE",$use_campaign_dnc)) + { + $phone_number_areacode = substr($phone_number, 0, 3); + $phone_number_areacode .= "XXXXXXX"; + $stmt="SELECT count(*) from vicidial_campaign_dnc where phone_number IN('$phone_number','$phone_number_areacode') and campaign_id='$campaign';"; + } + else + {$stmt="SELECT count(*) FROM vicidial_campaign_dnc where phone_number='$phone_number' and campaign_id='$campaign';";} $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00018',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} $row=mysql_fetch_row($rslt); - if ($row[0] > 0) { + ### insert a new lead in the system with this phone number + $stmt = "DELETE from vicidial_manual_dial_queue where phone_number='$phone_number' and user='$user';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00358',$user,$server_ip,$session_name,$one_mysql_log);} + $VMDQaffected_rows = mysql_affected_rows($link); + + $stmt = "UPDATE vicidial_live_agents set external_dial='' where user='$user';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00359',$user,$server_ip,$session_name,$one_mysql_log);} + $VLAEDaffected_rows = mysql_affected_rows($link); + echo "DNC NÚMERO\n"; exit; } @@ -1197,6 +1417,19 @@ if ($ACTION == 'manDiaLnextCaLL') if ($row[0] < 1) { + ### insert a new lead in the system with this phone number + $stmt = "DELETE from vicidial_manual_dial_queue where phone_number='$phone_number' and user='$user';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00360',$user,$server_ip,$session_name,$one_mysql_log);} + $VMDQaffected_rows = mysql_affected_rows($link); + + $stmt = "UPDATE vicidial_live_agents set external_dial='' where user='$user';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00361',$user,$server_ip,$session_name,$one_mysql_log);} + $VLAEDaffected_rows = mysql_affected_rows($link); + echo "NÚMERO NOT IN CAMPLISTS\n"; exit; } @@ -1217,7 +1450,7 @@ if ($ACTION == 'manDiaLnextCaLL') { $stmt="SELECT lead_id FROM vicidial_list where phone_number='$phone_number' order by modify_date desc LIMIT 1;"; $rslt=mysql_query($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00021',$user,$server_ip,$session_name,$one_mysql_log);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00362',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} $man_leadID_ct = mysql_num_rows($rslt); } @@ -1255,7 +1488,7 @@ if ($ACTION == 'manDiaLnextCaLL') else { ##### gather no hopper dialing settings from campaign - $stmt="SELECT no_hopper_dialing,agent_dial_owner_only,local_call_time,dial_statuses,drop_lockout_time,lead_filter_id,lead_order FROM vicidial_campaigns where campaign_id='$campaign';"; + $stmt="SELECT no_hopper_dialing,agent_dial_owner_only,local_call_time,dial_statuses,drop_lockout_time,lead_filter_id,lead_order,lead_order_randomize,lead_order_secondary FROM vicidial_campaigns where campaign_id='$campaign';"; $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00236',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} @@ -1270,6 +1503,8 @@ if ($ACTION == 'manDiaLnextCaLL') $drop_lockout_time = $row[4]; $lead_filter_id = $row[5]; $lead_order = $row[6]; + $lead_order_randomize = $row[7]; + $lead_order_secondary = $row[8]; } if (eregi("N",$no_hopper_dialing)) { @@ -1614,7 +1849,8 @@ if ($ACTION == 'manDiaLnextCaLL') if ($filtersql_ct > 0) { $row=mysql_fetch_row($rslt); - $fSQL = $row[0]; + $fSQL = "and $row[0]"; + $fSQL = preg_replace('/\\\\/','',$fSQL); } $stmt="SELECT list_id FROM vicidial_lists where campaign_id='$campaign' and active='Y';"; @@ -1645,47 +1881,88 @@ if ($ACTION == 'manDiaLnextCaLL') $territory = $row[1]; } - $agent_territories=''; - $stmt="SELECT agent_territories FROM vicidial_live_agents where user='$user';"; - $rslt=mysql_query($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00258',$user,$server_ip,$session_name,$one_mysql_log);} - $userterrVLA_ct = mysql_num_rows($rslt); - if ($DB) {echo "$userterrVLA_ct|$stmt\n";} - if ($userterrVLA_ct > 0) - { - $row=mysql_fetch_row($rslt); - $agent_territories = $row[0]; - } - if (strlen($agent_territories) > 3) - { - $agent_territoriesSQL = preg_replace('/-$/','',$agent_territories); - $agent_territoriesSQL = preg_replace('/ $|^ /','',$agent_territoriesSQL); - $territory = preg_replace('/ /',"','",$agent_territoriesSQL); - } - $adooSQL = ''; + if (eregi("TERRITORY",$agent_dial_owner_only)) + { + $agent_territories=''; + $agent_choose_territories=0; + $stmt="SELECT agent_choose_territories from vicidial_users where user='$user';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00406',$user,$server_ip,$session_name,$one_mysql_log);} + $Uterrs_to_parse = mysql_num_rows($rslt); + if ($Uterrs_to_parse > 0) + { + $rowx=mysql_fetch_row($rslt); + $agent_choose_territories = $rowx[0]; + } + + if ($agent_choose_territories < 1) + { + $stmt="SELECT territory from vicidial_user_territories where user='$user';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00407',$user,$server_ip,$session_name,$one_mysql_log);} + $vuts_to_parse = mysql_num_rows($rslt); + $o=0; + while ($vuts_to_parse > $o) + { + $rowx=mysql_fetch_row($rslt); + $agent_territories .= "'$rowx[0]',"; + $o++; + } + $agent_territories = preg_replace("/\,$/",'',$agent_territories); + $searchownerSQL=" and owner IN($agent_territories)"; + if ($vuts_to_parse < 1) + {$searchownerSQL=" and lead_id < 0";} + } + else + { + $stmt="SELECT agent_territories from vicidial_live_agents where user='$user';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00408',$user,$server_ip,$session_name,$one_mysql_log);} + $terrs_to_parse = mysql_num_rows($rslt); + if ($terrs_to_parse > 0) + { + $rowx=mysql_fetch_row($rslt); + $agent_territories = $rowx[0]; + $agent_territories = preg_replace("/ -$|^ /",'',$agent_territories); + $agent_territories = preg_replace("/ /","','",$agent_territories); + $searchownerSQL=" and owner IN('$agent_territories')"; + } + } + + $adooSQL = $searchownerSQL; + } if (eregi("USER",$agent_dial_owner_only)) {$adooSQL = "and owner='$user'";} - if (eregi("TERRITORY",$agent_dial_owner_only)) {$adooSQL = "and owner IN('$territory')";} if (eregi("USER_GROUP",$agent_dial_owner_only)) {$adooSQL = "and owner='$user_group'";} + if ($lead_order_randomize == 'Y') {$last_order = "RAND()";} + else + { + $last_order = "lead_id asc"; + if ($lead_order_secondary == 'LEAD_ASCEND') {$last_order = "lead_id asc";} + if ($lead_order_secondary == 'LEAD_DESCEND') {$last_order = "lead_id desc";} + if ($lead_order_secondary == 'CALLTIME_ASCEND') {$last_order = "last_local_call_time asc";} + if ($lead_order_secondary == 'CALLTIME_DESCEND') {$last_order = "last_local_call_time desc";} + } + $order_stmt = ''; if (eregi("DOWN",$lead_order)){$order_stmt = 'order by lead_id asc';} if (eregi("UP",$lead_order)){$order_stmt = 'order by lead_id desc';} - if (eregi("UP LAST NAME",$lead_order)){$order_stmt = 'order by last_name desc, lead_id asc';} - if (eregi("DOWN LAST NAME",$lead_order)){$order_stmt = 'order by last_name, lead_id asc';} - if (eregi("UP PHONE",$lead_order)){$order_stmt = 'order by phone_number desc, lead_id asc';} - if (eregi("DOWN PHONE",$lead_order)){$order_stmt = 'order by phone_number, lead_id asc';} - if (eregi("UP COUNT",$lead_order)){$order_stmt = 'order by called_count desc, lead_id asc';} - if (eregi("DOWN COUNT",$lead_order)){$order_stmt = 'order by called_count, lead_id asc';} - if (eregi("UP LAST LLAMADA TIME",$lead_order)){$order_stmt = 'order by last_local_call_time desc, lead_id asc';} - if (eregi("DOWN LAST LLAMADA TIME",$lead_order)){$order_stmt = 'order by last_local_call_time, lead_id asc';} - if (eregi("RANDOM",$lead_order)){$order_stmt = 'order by RAND()';} - if (eregi("UP RANK",$lead_order)){$order_stmt = 'order by rank desc, lead_id asc';} - if (eregi("DOWN RANK",$lead_order)){$order_stmt = 'order by rank, lead_id asc';} - if (eregi("UP OWNER",$lead_order)){$order_stmt = 'order by owner desc, lead_id asc';} - if (eregi("DOWN OWNER",$lead_order)){$order_stmt = 'order by owner, lead_id asc';} - if (eregi("UP TIMEZONE",$lead_order)){$order_stmt = 'order by gmt_offset_now desc, lead_id asc';} - if (eregi("DOWN TIMEZONE",$lead_order)){$order_stmt = 'order by gmt_offset_now, lead_id asc';} + if (eregi("UP LAST NAME",$lead_order)){$order_stmt = "order by last_name desc, $last_order";} + if (eregi("DOWN LAST NAME",$lead_order)){$order_stmt = "order by last_name, $last_order";} + if (eregi("UP PHONE",$lead_order)){$order_stmt = "order by phone_number desc, $last_order";} + if (eregi("DOWN PHONE",$lead_order)){$order_stmt = "order by phone_number, $last_order";} + if (eregi("UP COUNT",$lead_order)){$order_stmt = "order by called_count desc, $last_order";} + if (eregi("DOWN COUNT",$lead_order)){$order_stmt = "order by called_count, $last_order";} + if (eregi("UP LAST LLAMADA TIME",$lead_order)){$order_stmt = "order by last_local_call_time desc, $last_order";} + if (eregi("DOWN LAST LLAMADA TIME",$lead_order)){$order_stmt = "order by last_local_call_time, $last_order";} + if (eregi("RANDOM",$lead_order)){$order_stmt = "order by RAND()";} + if (eregi("UP RANK",$lead_order)){$order_stmt = "order by rank desc, $last_order";} + if (eregi("DOWN RANK",$lead_order)){$order_stmt = "order by rank, $last_order";} + if (eregi("UP OWNER",$lead_order)){$order_stmt = "order by owner desc, $last_order";} + if (eregi("DOWN OWNER",$lead_order)){$order_stmt = "order by owner, $last_order";} + if (eregi("UP TIMEZONE",$lead_order)){$order_stmt = "order by gmt_offset_now desc, $last_order";} + if (eregi("DOWN TIMEZONE",$lead_order)){$order_stmt = "order by gmt_offset_now, $last_order";} $stmt="UPDATE vicidial_list SET status='QUEUE',user='$user' where called_since_last_reset='N' and status IN($Dsql) and list_id IN($camp_lists) and ($all_gmtSQL) $DLTsql $fSQL $adooSQL $order_stmt LIMIT 1;"; if ($DB) {echo "$stmt\n";} @@ -1693,6 +1970,10 @@ if ($ACTION == 'manDiaLnextCaLL') if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00242',$user,$server_ip,$session_name,$one_mysql_log);} $affected_rows = mysql_affected_rows($link); + # $fp = fopen ("./DNNdebug_log.txt", "a"); + # fwrite ($fp, "$NOW_TIME|$campaign|$lead_id|$agent_dialed_number|$user|M|$MqueryCID||$province|$affected_rows|$stmt|\n"); + # fclose($fp); + if ($affected_rows > 0) { $stmt="SELECT lead_id,list_id,gmt_offset_now,state,entry_list_id FROM vicidial_list where status='QUEUE' and user='$user' order by modify_date desc LIMIT 1;"; @@ -1709,7 +1990,7 @@ if ($ACTION == 'manDiaLnextCaLL') $state = $row[3]; $entry_list_id = $row[4]; - $stmt = "INSERT INTO vicidial_hopper SET lead_id='$lead_id',campaign_id='$campaign',status='QUEUE',list_id='$list_id',gmt_offset_now='$gmt_offset_now',state='$state',alt_dial='MAIN',user='$user',priority='0';"; + $stmt = "INSERT INTO vicidial_hopper SET lead_id='$lead_id',campaign_id='$campaign',status='QUEUE',list_id='$list_id',gmt_offset_now='$gmt_offset_now',state='$state',alt_dial='MAIN',user='$user',priority='0',source='Q';"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00244',$user,$server_ip,$session_name,$one_mysql_log);} @@ -1788,6 +2069,13 @@ if ($ACTION == 'manDiaLnextCaLL') $called_count++; + if ( (strlen($agent_dialed_type) < 3) or (strlen($agent_dialed_number) < 6) ) + { + $agent_dialed_number = $phone_number; + if (strlen($agent_dialed_type) < 3) + {$agent_dialed_type = 'MAIN';} + } + ##### check if system is set to generate logfile for transfers $stmt="SELECT enable_agc_xfer_log FROM system_settings;"; $rslt=mysql_query($stmt, $link); @@ -1811,7 +2099,7 @@ if ($ACTION == 'manDiaLnextCaLL') # DATETIME|campaign|lead_id|phone_number|user|type # 2007-08-22 11:11:11|TESTCAMP|65432|3125551212|1234|M $fp = fopen ("./xfer_log.txt", "a"); - fwrite ($fp, "$NOW_TIME|$campaign|$lead_id|$phone_number|$user|M|$MqueryCID||$province\n"); + fwrite ($fp, "$NOW_TIME|$campaign|$lead_id|$agent_dialed_number|$user|M|$MqueryCID||$province\n"); fclose($fp); } @@ -1820,7 +2108,32 @@ if ($ACTION == 'manDiaLnextCaLL') $CBcallback_time = ''; $CBuser = ''; $CBcomments = ''; - if (ereg("CALLBK",$dispo)) + $CBstatus = 0; + + $stmt="SELECT count(*) FROM vicidial_statuses where status='$dispo' and scheduled_callback='Y';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00366',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $cb_record_ct = mysql_num_rows($rslt); + if ($cb_record_ct > 0) + { + $row=mysql_fetch_row($rslt); + $CBstatus = $row[0]; + } + if ($CBstatus < 1) + { + $stmt="SELECT count(*) FROM vicidial_campaign_statuses where status='$dispo' and scheduled_callback='Y';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00367',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $cb_record_ct = mysql_num_rows($rslt); + if ($cb_record_ct > 0) + { + $row=mysql_fetch_row($rslt); + $CBstatus = $row[0]; + } + } + if ( ($CBstatus > 0) or ($dispo == 'CBHOLD') ) { $stmt="SELECT entry_time,callback_time,user,comments FROM vicidial_callbacks where lead_id='$lead_id' order by callback_id desc LIMIT 1;"; $rslt=mysql_query($stmt, $link); @@ -1846,6 +2159,8 @@ if ($ACTION == 'manDiaLnextCaLL') { $row=mysql_fetch_row($rslt); $local_gmt = $row[0]; + $isdst = date("I"); + if ($isdst) {$local_gmt++;} } $LLCT_DATE_offset = ($local_gmt - $gmt_offset_now); $LLCT_DATE = date("Y-m-d H:i:s", mktime(date("H")-$LLCT_DATE_offset,date("i"),date("s"),date("m"),date("d"),date("Y"))); @@ -1878,6 +2193,26 @@ if ($ACTION == 'manDiaLnextCaLL') $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00032',$user,$server_ip,$session_name,$one_mysql_log);} + $campaign_cid_override=''; + $LISTweb_form_address=''; + $LISTweb_form_address_two=''; + ### check if there is a list_id override + if (strlen($list_id) > 1) + { + $stmt = "SELECT campaign_cid_override,web_form_address,web_form_address_two FROM vicidial_lists where list_id='$list_id';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00245',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $lio_ct = mysql_num_rows($rslt); + if ($lio_ct > 0) + { + $row=mysql_fetch_row($rslt); + $campaign_cid_override = $row[0]; + $LISTweb_form_address = $row[1]; + $LISTweb_form_address_two = $row[2]; + } + } + ### if preview dialing, do not send the call if ( (strlen($preview)<1) || ($preview == 'NO') ) { @@ -1893,21 +2228,6 @@ if ($ACTION == 'manDiaLnextCaLL') $Local_dial_timeout = ($Local_dial_timeout * 1000); if (strlen($dial_prefix) > 0) {$Local_out_prefix = "$dial_prefix";} if (strlen($campaign_cid) > 6) {$CCID = "$campaign_cid"; $CCID_on++;} - $campaign_cid_override=''; - ### check if there is a list_id override - if (strlen($list_id) > 1) - { - $stmt = "SELECT campaign_cid_override FROM vicidial_lists where list_id='$list_id';"; - $rslt=mysql_query($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00245',$user,$server_ip,$session_name,$one_mysql_log);} - if ($DB) {echo "$stmt\n";} - $lio_ct = mysql_num_rows($rslt); - if ($lio_ct > 0) - { - $row=mysql_fetch_row($rslt); - $campaign_cid_override = $row[0]; - } - } if (strlen($campaign_cid_override) > 6) {$CCID = "$campaign_cid_override"; $CCID_on++;} ### check for custom cid use $use_custom_cid=0; @@ -1958,9 +2278,9 @@ if ($ACTION == 'manDiaLnextCaLL') ### whether to omit phone_code or not if (eregi('Y',$omit_phone_code)) - {$Ndialstring = "$Local_out_prefix$phone_number";} + {$Ndialstring = "$Local_out_prefix$agent_dialed_number";} else - {$Ndialstring = "$Local_out_prefix$phone_code$phone_number";} + {$Ndialstring = "$Local_out_prefix$phone_code$agent_dialed_number";} if ( ($usegroupalias > 0) and (strlen($account)>1) ) { @@ -1978,7 +2298,7 @@ if ($ACTION == 'manDiaLnextCaLL') $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00033',$user,$server_ip,$session_name,$one_mysql_log);} - $stmt = "INSERT INTO vicidial_auto_calls (server_ip,campaign_id,status,lead_id,callerid,phone_code,phone_number,call_time,call_type) values('$server_ip','$campaign','XFER','$lead_id','$MqueryCID','$phone_code','$phone_number','$NOW_TIME','OUT')"; + $stmt = "INSERT INTO vicidial_auto_calls (server_ip,campaign_id,status,lead_id,callerid,phone_code,phone_number,call_time,call_type) values('$server_ip','$campaign','XFER','$lead_id','$MqueryCID','$phone_code','$agent_dialed_number','$NOW_TIME','OUT')"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00034',$user,$server_ip,$session_name,$one_mysql_log);} @@ -2040,7 +2360,7 @@ if ($ACTION == 'manDiaLnextCaLL') if ($agent_dialed_number > 0) { - $stmt = "INSERT INTO user_call_log (user,call_date,call_type,server_ip,phone_number,number_dialed,lead_id,callerid,group_alias_id) values('$user','$NOW_TIME','$agent_dialed_type','$server_ip','$phone_number','$Ndialstring','$lead_id','$CCID','$RAWaccount')"; + $stmt = "INSERT INTO user_call_log (user,call_date,call_type,server_ip,phone_number,number_dialed,lead_id,callerid,group_alias_id) values('$user','$NOW_TIME','$agent_dialed_type','$server_ip','$agent_dialed_number','$Ndialstring','$lead_id','$CCID','$RAWaccount')"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00191',$user,$server_ip,$session_name,$one_mysql_log);} @@ -2067,25 +2387,37 @@ if ($ACTION == 'manDiaLnextCaLL') ########################################### if ($enable_queuemetrics_logging > 0) { + $data4SQL=''; + $stmt="SELECT queuemetrics_phone_environment FROM vicidial_campaigns where campaign_id='$campaign' and queuemetrics_phone_environment!='';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00389',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $cqpe_ct = mysql_num_rows($rslt); + if ($cqpe_ct > 0) + { + $row=mysql_fetch_row($rslt); + $data4SQL = ",data4='$row[0]'"; + } + $linkB=mysql_connect("$queuemetrics_server_ip", "$queuemetrics_login", "$queuemetrics_pass"); mysql_select_db("$queuemetrics_dbname", $linkB); # UNPAUSEALL - $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='NONE',queue='NONE',agent='Agent/$user',verb='UNPAUSEALL',serverid='$queuemetrics_log_id';"; + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='NONE',queue='NONE',agent='Agent/$user',verb='UNPAUSEALL',serverid='$queuemetrics_log_id' $data4SQL;"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $linkB); if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00038',$user,$server_ip,$session_name,$one_mysql_log);} $affected_rows = mysql_affected_rows($linkB); # LLAMADAOUTBOUND (formerly ENTERQUEUE) - $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='$MqueryCID',queue='$campaign',agent='NONE',verb='CALLOUTBOUND',data2='$phone_number',serverid='$queuemetrics_log_id';"; + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='$MqueryCID',queue='$campaign',agent='NONE',verb='CALLOUTBOUND',data2='$agent_dialed_number',serverid='$queuemetrics_log_id' $data4SQL;"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $linkB); if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00039',$user,$server_ip,$session_name,$one_mysql_log);} $affected_rows = mysql_affected_rows($linkB); # CONNECT - $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='$MqueryCID',queue='$campaign',agent='Agent/$user',verb='CONNECT',data1='0',serverid='$queuemetrics_log_id';"; + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='$MqueryCID',queue='$campaign',agent='Agent/$user',verb='CONNECT',data1='0',serverid='$queuemetrics_log_id' $data4SQL;"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $linkB); if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00040',$user,$server_ip,$session_name,$one_mysql_log);} @@ -2246,8 +2578,8 @@ if ($ACTION == 'manDiaLnextCaLL') $LeaD_InfO .= $CBcallback_time . "\n"; $LeaD_InfO .= $CBuser . "\n"; $LeaD_InfO .= $CBcomments . "\n"; - $LeaD_InfO .= $phone_number . "\n"; - $LeaD_InfO .= "MAIN\n"; + $LeaD_InfO .= $agent_dialed_number . "\n"; + $LeaD_InfO .= $agent_dialed_type . "\n"; $LeaD_InfO .= $source_id . "\n"; $LeaD_InfO .= $rank . "\n"; $LeaD_InfO .= $owner . "\n"; @@ -2262,6 +2594,8 @@ if ($ACTION == 'manDiaLnextCaLL') $LeaD_InfO .= $custom_field_names . "\n"; $LeaD_InfO .= $custom_field_values . "\n"; $LeaD_InfO .= $custom_field_types . "\n"; + $LeaD_InfO .= $LISTweb_form_address . "\n"; + $LeaD_InfO .= $LISTweb_form_address_two . "\n"; echo $LeaD_InfO; } @@ -2409,6 +2743,8 @@ if ($ACTION == 'manDiaLonly') ### prepare variables to place manual call from VICIDiaL $CCID_on=0; $CCID=''; + $LISTweb_form_address=''; + $LISTweb_form_address_two=''; $local_DEF = 'Local/'; $local_AMP = '@'; $Local_out_prefix = '9'; @@ -2436,7 +2772,7 @@ if ($ACTION == 'manDiaLonly') if (strlen($list_id) > 1) { - $stmt = "SELECT campaign_cid_override FROM vicidial_lists where list_id='$list_id';"; + $stmt = "SELECT campaign_cid_override,web_form_address,web_form_address_two FROM vicidial_lists where list_id='$list_id';"; $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00247',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} @@ -2445,6 +2781,8 @@ if ($ACTION == 'manDiaLonly') { $row=mysql_fetch_row($rslt); $campaign_cid_override = $row[0]; + $LISTweb_form_address = $row[1]; + $LISTweb_form_address_two = $row[2]; } } } @@ -2647,25 +2985,37 @@ if ($ACTION == 'manDiaLonly') ########################################### if ($enable_queuemetrics_logging > 0) { + $data4SQL=''; + $stmt="SELECT queuemetrics_phone_environment FROM vicidial_campaigns where campaign_id='$campaign' and queuemetrics_phone_environment!='';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00390',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $cqpe_ct = mysql_num_rows($rslt); + if ($cqpe_ct > 0) + { + $row=mysql_fetch_row($rslt); + $data4SQL = ",data4='$row[0]'"; + } + $linkB=mysql_connect("$queuemetrics_server_ip", "$queuemetrics_login", "$queuemetrics_pass"); mysql_select_db("$queuemetrics_dbname", $linkB); # UNPAUSEALL - $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='NONE',queue='NONE',agent='Agent/$user',verb='UNPAUSEALL',serverid='$queuemetrics_log_id';"; + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='NONE',queue='NONE',agent='Agent/$user',verb='UNPAUSEALL',serverid='$queuemetrics_log_id' $data4SQL;"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $linkB); if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00049',$user,$server_ip,$session_name,$one_mysql_log);} $affected_rows = mysql_affected_rows($linkB); # LLAMADAOUTBOUND (formerly ENTERQUEUE) - $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='$MqueryCID',queue='$campaign',agent='NONE',verb='CALLOUTBOUND',data2='$phone_number',serverid='$queuemetrics_log_id';"; + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='$MqueryCID',queue='$campaign',agent='NONE',verb='CALLOUTBOUND',data2='$phone_number',serverid='$queuemetrics_log_id' $data4SQL;"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $linkB); if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00050',$user,$server_ip,$session_name,$one_mysql_log);} $affected_rows = mysql_affected_rows($linkB); # CONNECT - $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='$MqueryCID',queue='$campaign',agent='Agent/$user',verb='CONNECT',data1='0',serverid='$queuemetrics_log_id';"; + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='$MqueryCID',queue='$campaign',agent='Agent/$user',verb='CONNECT',data1='0',serverid='$queuemetrics_log_id' $data4SQL;"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $linkB); if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00051',$user,$server_ip,$session_name,$one_mysql_log);} @@ -2749,6 +3099,11 @@ if ($ACTION == 'manDiaLlookCaLL') if ($format=='debug') {echo "\n";} $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00293',$user,$server_ip,$session_name,$one_mysql_log);} + + $stmt="UPDATE vicidial_live_agents set ring_callerid='' where ring_callerid='$MDnextCID';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00399',$user,$server_ip,$session_name,$one_mysql_log);} } } } @@ -2835,6 +3190,13 @@ if ($stage == "start") $user_group = trim("$row[0]"); } + ##### insert log into vicidial_log_extended for manual VICIDiaL call + $stmt="INSERT IGNORE INTO vicidial_log_extended SET uniqueid='$uniqueid',server_ip='$server_ip',call_date='$NOW_TIME',lead_id='$lead_id',caller_code='$MDnextCID',custom_call_id='' ON DUPLICATE KEY UPDATE server_ip='$server_ip',call_date='$NOW_TIME',lead_id='$lead_id',caller_code='$MDnextCID';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00400',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rowsX = mysql_affected_rows($link); + $manualVLexists=0; $beginUNIQUEID = preg_replace("/\..*/","",$uniqueid); $stmt="SELECT count(*) from vicidial_log where lead_id='$lead_id' and user='$user' and phone_number='$phone_number' and uniqueid LIKE \"$beginUNIQUEID%\";"; @@ -2979,7 +3341,7 @@ if ($stage == "end") fclose($fp); ##### start epoch in the vicidial_log table, couldn't find one in vicidial_closer_log - $stmt="SELECT start_epoch,term_reason,campaign_id FROM vicidial_log where uniqueid='$uniqueid' and lead_id='$lead_id' order by call_date desc limit 1;"; + $stmt="SELECT start_epoch,term_reason,campaign_id,status FROM vicidial_log where uniqueid='$uniqueid' and lead_id='$lead_id' order by call_date desc limit 1;"; $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00061',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} @@ -2990,6 +3352,7 @@ if ($stage == "end") $start_epoch = $row[0]; $VDterm_reason = $row[1]; $VDcampaign_id = $row[2]; + $VDstatus = $row[3]; $length_in_sec = ($StarTtime - $start_epoch); } else @@ -3031,7 +3394,7 @@ if ($stage == "end") ############################################# ##### START QUEUEMETRICS LOGGING LOOKUP ##### - $stmt = "SELECT enable_queuemetrics_logging,queuemetrics_server_ip,queuemetrics_dbname,queuemetrics_login,queuemetrics_pass,queuemetrics_log_id FROM system_settings;"; + $stmt = "SELECT enable_queuemetrics_logging,queuemetrics_server_ip,queuemetrics_dbname,queuemetrics_login,queuemetrics_pass,queuemetrics_log_id,queuemetrics_dispo_pause FROM system_settings;"; $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00063',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} @@ -3046,6 +3409,7 @@ if ($stage == "end") $queuemetrics_login = $row[3]; $queuemetrics_pass = $row[4]; $queuemetrics_log_id = $row[5]; + $queuemetrics_dispo_pause = $row[6]; if ($enable_queuemetrics_logging > 0) { @@ -3157,7 +3521,7 @@ if ($stage == "end") if ($VD_alt_dnc_count < 1) { ### insert record into vicidial_hopper for alt_phone call attempt - $stmt = "INSERT INTO vicidial_hopper SET lead_id='$lead_id',campaign_id='$campaign',status='HOLD',list_id='$list_id',gmt_offset_now='$gmt_offset_now',state='$state',alt_dial='ALT',user='',priority='25';"; + $stmt = "INSERT INTO vicidial_hopper SET lead_id='$lead_id',campaign_id='$campaign',status='HOLD',list_id='$list_id',gmt_offset_now='$gmt_offset_now',state='$state',alt_dial='ALT',user='',priority='25',source='A';"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00068',$user,$server_ip,$session_name,$one_mysql_log);} @@ -3234,7 +3598,7 @@ if ($stage == "end") if ($VD_alt_dnc_count < 1) { ### insert record into vicidial_hopper for address3 call attempt - $stmt = "INSERT INTO vicidial_hopper SET lead_id='$lead_id',campaign_id='$campaign',status='HOLD',list_id='$list_id',gmt_offset_now='$gmt_offset_now',state='$state',alt_dial='ADDR3',user='',priority='20';"; + $stmt = "INSERT INTO vicidial_hopper SET lead_id='$lead_id',campaign_id='$campaign',status='HOLD',list_id='$list_id',gmt_offset_now='$gmt_offset_now',state='$state',alt_dial='ADDR3',user='',priority='20',source='A';"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00072',$user,$server_ip,$session_name,$one_mysql_log);} @@ -3350,7 +3714,7 @@ if ($stage == "end") { if ($alt_dial_phones_count == $Xlast) {$Xlast = 'LAST';} - $stmt = "INSERT INTO vicidial_hopper SET lead_id='$lead_id',campaign_id='$campaign',status='HOLD',list_id='$EA_list_id',gmt_offset_now='$EA_gmt_offset_now',state='$EA_state',alt_dial='X$Xlast',user='',priority='15';"; + $stmt = "INSERT INTO vicidial_hopper SET lead_id='$lead_id',campaign_id='$campaign',status='HOLD',list_id='$EA_list_id',gmt_offset_now='$EA_gmt_offset_now',state='$EA_state',alt_dial='X$Xlast',user='',priority='15',source='A';"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00078',$user,$server_ip,$session_name,$one_mysql_log);} @@ -3437,7 +3801,19 @@ if ($stage == "end") { if ($enable_queuemetrics_logging > 0) { - $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='NONE',queue='NONE',agent='Agent/$user',verb='PAUSEALL',serverid='$queuemetrics_log_id';"; + $data4SQL=''; + $stmt="SELECT queuemetrics_phone_environment FROM vicidial_campaigns where campaign_id='$campaign' and queuemetrics_phone_environment!='';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00391',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $cqpe_ct = mysql_num_rows($rslt); + if ($cqpe_ct > 0) + { + $row=mysql_fetch_row($rslt); + $data4SQL = ",data4='$row[0]'"; + } + + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='NONE',queue='NONE',agent='Agent/$user',verb='PAUSEALL',serverid='$queuemetrics_log_id' $data4SQL;"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $linkB); if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00083',$user,$server_ip,$session_name,$one_mysql_log);} @@ -3475,7 +3851,19 @@ if ($stage == "end") $CLstage = preg_replace("/XFER|CLOSER|-/",'',$CLstage); if ($CLstage < 0.25) {$CLstage=0;} - $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='$MDnextCID',queue='$VDcampaign_id',agent='Agent/$user',verb='COMPLETEAGENT',data1='$CLstage',data2='$length_in_sec',data3='$CLqueue_position',serverid='$queuemetrics_log_id';"; + $data4SQL=''; + $stmt="SELECT queuemetrics_phone_environment FROM vicidial_campaigns where campaign_id='$campaign' and queuemetrics_phone_environment!='';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00392',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $cqpe_ct = mysql_num_rows($rslt); + if ($cqpe_ct > 0) + { + $row=mysql_fetch_row($rslt); + $data4SQL = ",data4='$row[0]'"; + } + + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='$MDnextCID',queue='$VDcampaign_id',agent='Agent/$user',verb='COMPLETEAGENT',data1='$CLstage',data2='$length_in_sec',data3='$CLqueue_position',serverid='$queuemetrics_log_id' $data4SQL;"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $linkB); if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00085',$user,$server_ip,$session_name,$one_mysql_log);} @@ -3510,7 +3898,7 @@ if ($stage == "end") { if ($enable_queuemetrics_logging > 0) { - $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='NONE',queue='NONE',agent='Agent/$user',verb='PAUSEALL',serverid='$queuemetrics_log_id';"; + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='NONE',queue='NONE',agent='Agent/$user',verb='PAUSEALL',serverid='$queuemetrics_log_id' $data4SQL;"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $linkB); if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00088',$user,$server_ip,$session_name,$one_mysql_log);} @@ -3526,15 +3914,16 @@ if ($stage == "end") if ( (ereg("NONE",$term_reason)) or (ereg("NONE",$VDterm_reason)) or (strlen($VDterm_reason) < 1) ) { ### check to see if lead should be alt_dialed - $stmt="SELECT term_reason,uniqueid from vicidial_log where uniqueid='$uniqueid' and lead_id='$lead_id' order by call_date desc limit 1;"; + $stmt="SELECT term_reason,uniqueid,status from vicidial_log where uniqueid='$uniqueid' and lead_id='$lead_id' order by call_date desc limit 1;"; $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00089',$user,$server_ip,$session_name,$one_mysql_log);} $VAC_qm_ct = mysql_num_rows($rslt); if ($VAC_qm_ct > 0) { $row=mysql_fetch_row($rslt); - $VDterm_reason = $row[0]; - $VDvicidial_id = $row[1]; + $VDterm_reason = $row[0]; + $VDvicidial_id = $row[1]; + $VDstatus = $row[2]; $VDIDselect = "VDL_UIDLID $uniqueid $lead_id"; } if (ereg("CALLER",$VDterm_reason)) @@ -3547,18 +3936,25 @@ if ($stage == "end") } } + ##### insert log into vicidial_log_extended for manual VICIDiaL call + $stmt="INSERT IGNORE INTO vicidial_log_extended SET uniqueid='$uniqueid',server_ip='$server_ip',call_date='$NOW_TIME',lead_id='$lead_id',caller_code='$MDnextCID',custom_call_id='' ON DUPLICATE KEY UPDATE server_ip='$server_ip',call_date='$NOW_TIME',lead_id='$lead_id',caller_code='$MDnextCID';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00401',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rowsX = mysql_affected_rows($link); + ### check to see if the vicidial_log record exists, if not, insert it $manualVLexists=0; $beginUNIQUEID = preg_replace("/\..*/","",$uniqueid); - $stmt="SELECT count(*) from vicidial_log where lead_id='$lead_id' and user='$user' and phone_number='$phone_number' and uniqueid LIKE \"$beginUNIQUEID%\";"; + $stmt="SELECT status from vicidial_log where lead_id='$lead_id' and user='$user' and phone_number='$phone_number' and uniqueid LIKE \"$beginUNIQUEID%\";"; $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00223',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} - $VL_exists_ct = mysql_num_rows($rslt); - if ($VL_exists_ct > 0) + $manualVLexists = mysql_num_rows($rslt); + if ($manualVLexists > 0) { $row=mysql_fetch_row($rslt); - $manualVLexists = $row[0]; + $VDstatus = $row[0]; } if ($manualVLexists < 1) @@ -3590,7 +3986,8 @@ if ($stage == "end") } ##### update the duration and end time in the vicidial_log table - $stmt="UPDATE vicidial_log set $SQLterm end_epoch='$StarTtime', length_in_sec='$length_in_sec', status='$status_dispo' where uniqueid='$uniqueid' and lead_id='$lead_id' and user='$user' order by call_date desc limit 1;"; + if ($VDstatus == 'INCALL') {$vl_statusSQL = ",status='$status_dispo'";} + $stmt="UPDATE vicidial_log set $SQLterm end_epoch='$StarTtime', length_in_sec='$length_in_sec' $vl_statusSQL where uniqueid='$uniqueid' and lead_id='$lead_id' and user='$user' order by call_date desc limit 1;"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00090',$user,$server_ip,$session_name,$one_mysql_log);} @@ -3678,7 +4075,19 @@ if ($stage == "end") if (strlen($VDqueue_position) < 1) {$VDqueue_position=1;} - $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='$MDnextCID',queue='$VDcampaign_id',agent='Agent/$user',verb='COMPLETEAGENT',data1='$CLstage',data2='$length_in_sec',data3='$VDqueue_position',serverid='$queuemetrics_log_id';"; + $data4SQL=''; + $stmt="SELECT queuemetrics_phone_environment FROM vicidial_campaigns where campaign_id='$campaign' and queuemetrics_phone_environment!='';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00393',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $cqpe_ct = mysql_num_rows($rslt); + if ($cqpe_ct > 0) + { + $row=mysql_fetch_row($rslt); + $data4SQL = ",data4='$row[0]'"; + } + + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='$MDnextCID',queue='$VDcampaign_id',agent='Agent/$user',verb='COMPLETEAGENT',data1='$CLstage',data2='$length_in_sec',data3='$VDqueue_position',serverid='$queuemetrics_log_id' $data4SQL;"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $linkB); if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00094',$user,$server_ip,$session_name,$one_mysql_log);} @@ -3810,7 +4219,7 @@ if ($stage == "end") if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00098',$user,$server_ip,$session_name,$one_mysql_log);} echo "REC_STOP|$rec_channels[$loop_count]|$filename[$loop_count]|"; - if (strlen($filename)>2) + if (strlen($filename[$loop_count])>2) { $stmt="SELECT recording_id,start_epoch,vicidial_id,lead_id FROM recording_log where filename='$filename[$loop_count]'"; if ($format=='debug') {echo "\n";} @@ -3917,6 +4326,16 @@ if ($stage == "end") if ($format=='debug') {echo "\n";} $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00299',$user,$server_ip,$session_name,$one_mysql_log);} + + ### if queuemetrics_dispo_pause dispo tag is enabled, log it here + if (strlen($queuemetrics_dispo_pause) > 0) + { + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='$MDnextCID',queue='NONE',agent='Agent/$user',verb='PAUSEREASON',serverid='$queuemetrics_log_id',data1='$queuemetrics_dispo_pause';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkB); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00364',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($linkB); + } } } @@ -4095,7 +4514,32 @@ if ($ACTION == 'VDADcheckINCOMING') $CBcallback_time = ''; $CBuser = ''; $CBcomments = ''; - if (ereg("CALLBK",$dispo)) + $CBstatus = 0; + + $stmt="SELECT count(*) FROM vicidial_statuses where status='$dispo' and scheduled_callback='Y';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00368',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $cb_record_ct = mysql_num_rows($rslt); + if ($cb_record_ct > 0) + { + $row=mysql_fetch_row($rslt); + $CBstatus = $row[0]; + } + if ($CBstatus < 1) + { + $stmt="SELECT count(*) FROM vicidial_campaign_statuses where status='$dispo' and scheduled_callback='Y';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00369',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $cb_record_ct = mysql_num_rows($rslt); + if ($cb_record_ct > 0) + { + $row=mysql_fetch_row($rslt); + $CBstatus = $row[0]; + } + } + if ( ($CBstatus > 0) or ($dispo == 'CBHOLD') ) { $stmt="SELECT entry_time,callback_time,user,comments FROM vicidial_callbacks where lead_id='$lead_id' order by callback_id desc LIMIT 1;"; $rslt=mysql_query($stmt, $link); @@ -4572,7 +5016,7 @@ if ($ACTION == 'VDADcheckINCOMING') ### Check for List ID override settings if (strlen($list_id)>0) { - $stmt = "select xferconf_a_number,xferconf_b_number,xferconf_c_number,xferconf_d_number,xferconf_e_number from vicidial_lists where list_id='$list_id';"; + $stmt = "select xferconf_a_number,xferconf_b_number,xferconf_c_number,xferconf_d_number,xferconf_e_number,web_form_address,web_form_address_two from vicidial_lists where list_id='$list_id';"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00282',$user,$server_ip,$session_name,$one_mysql_log);} @@ -4590,6 +5034,10 @@ if ($ACTION == 'VDADcheckINCOMING') {$VDCL_xferconf_d_number = $row[3];} if (strlen($row[4]) > 0) {$VDCL_xferconf_e_number = $row[4];} + if (strlen($row[5]) > 5) + {$VDCL_group_web = $row[5];} + if (strlen($row[6]) > 5) + {$VDCL_group_web_two = $row[6];} } } @@ -4783,8 +5231,33 @@ if ($ACTION == 'VDADcheckINCOMING') $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00124',$user,$server_ip,$session_name,$one_mysql_log);} - ### If LLAMADABK, change vicidial_callback record to INACTIVE - if (eregi("CALLBK|CBHOLD", $dispo)) + ### If a scheduled callback, change vicidial_callback record to INACTIVE + $CBstatus = 0; + + $stmt="SELECT count(*) FROM vicidial_statuses where status='$dispo' and scheduled_callback='Y';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00370',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $cb_record_ct = mysql_num_rows($rslt); + if ($cb_record_ct > 0) + { + $row=mysql_fetch_row($rslt); + $CBstatus = $row[0]; + } + if ($CBstatus < 1) + { + $stmt="SELECT count(*) FROM vicidial_campaign_statuses where status='$dispo' and scheduled_callback='Y';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00371',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $cb_record_ct = mysql_num_rows($rslt); + if ($cb_record_ct > 0) + { + $row=mysql_fetch_row($rslt); + $CBstatus = $row[0]; + } + } + if ( ($CBstatus > 0) or (eregi("CALLBK|CBHOLD", $dispo)) ) { $stmt="UPDATE vicidial_callbacks set status='INACTIVE' where lead_id='$lead_id' and status NOT IN('INACTIVE','DEAD','ARCHIVE');"; if ($format=='debug') {echo "\n";} @@ -5156,7 +5629,7 @@ if ($ACTION == 'userLOGout') { ############################################# ##### START QUEUEMETRICS LOGGING LOOKUP ##### - $stmt = "SELECT enable_queuemetrics_logging,queuemetrics_server_ip,queuemetrics_dbname,queuemetrics_login,queuemetrics_pass,queuemetrics_log_id,allow_sipsak_messages,queuemetrics_loginout FROM system_settings;"; + $stmt = "SELECT enable_queuemetrics_logging,queuemetrics_server_ip,queuemetrics_dbname,queuemetrics_login,queuemetrics_pass,queuemetrics_log_id,allow_sipsak_messages,queuemetrics_loginout,queuemetrics_addmember_enabled,queuemetrics_dispo_pause FROM system_settings;"; $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00138',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} @@ -5164,14 +5637,16 @@ if ($ACTION == 'userLOGout') if ($qm_conf_ct > 0) { $row=mysql_fetch_row($rslt); - $enable_queuemetrics_logging = $row[0]; - $queuemetrics_server_ip = $row[1]; - $queuemetrics_dbname = $row[2]; - $queuemetrics_login = $row[3]; - $queuemetrics_pass = $row[4]; - $queuemetrics_log_id = $row[5]; - $allow_sipsak_messages = $row[6]; - $queuemetrics_loginout = $row[7]; + $enable_queuemetrics_logging = $row[0]; + $queuemetrics_server_ip = $row[1]; + $queuemetrics_dbname = $row[2]; + $queuemetrics_login = $row[3]; + $queuemetrics_pass = $row[4]; + $queuemetrics_log_id = $row[5]; + $allow_sipsak_messages = $row[6]; + $queuemetrics_loginout = $row[7]; + $queuemetrics_addmember_enabled = $row[8]; + $queuemetrics_dispo_pause = $row[9]; } ##### END QUEUEMETRICS LOGGING LOOKUP ##### ########################################### @@ -5196,7 +5671,8 @@ if ($ACTION == 'userLOGout') # $rslt=mysql_query($stmt, $linkB); # $affected_rows = mysql_affected_rows($linkB); - $stmt = "SELECT time_id,data1 FROM queue_log where agent='Agent/$user' and verb IN('AGENTLOGIN','AGENTCALLBACKLOGIN') order by time_id desc limit 1;"; + $logintime=0; + $stmt = "SELECT time_id,data1 FROM queue_log where agent='Agent/$user' and verb IN('AGENTLOGIN','AGENTCALLBACKLOGIN') and time_id > $check_time order by time_id desc limit 1;"; $rslt=mysql_query($stmt, $linkB); if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00139',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} @@ -5211,15 +5687,83 @@ if ($ACTION == 'userLOGout') $i++; } + $data4SQL=''; + $stmt="SELECT queuemetrics_phone_environment FROM vicidial_campaigns where campaign_id='$campaign' and queuemetrics_phone_environment!='';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00394',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $cqpe_ct = mysql_num_rows($rslt); + if ($cqpe_ct > 0) + { + $row=mysql_fetch_row($rslt); + $data4SQL = ",data4='$row[0]'"; + } + $time_logged_in = ($StarTtime - $logintime); if ($time_logged_in > 1000000) {$time_logged_in=1;} - $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='NONE',queue='NONE',agent='Agent/$user',verb='$QM_LOGOFF',data1='$loginphone',data2='$time_logged_in',serverid='$queuemetrics_log_id';"; - if ($DB) {echo "$stmt\n";} - $rslt=mysql_query($stmt, $linkB); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00140',$user,$server_ip,$session_name,$one_mysql_log);} - $affected_rows = mysql_affected_rows($linkB); + if ($queuemetrics_loginout != 'NONE') + { + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='NONE',queue='NONE',agent='Agent/$user',verb='$QM_LOGOFF',data1='$loginphone',data2='$time_logged_in',serverid='$queuemetrics_log_id' $data4SQL;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkB); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00140',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($linkB); + } + if ($queuemetrics_addmember_enabled > 0) + { + if ($queuemetrics_loginout == 'NONE') + { + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='NONE',queue='NONE',agent='Agent/$user',verb='PAUSEREASON',serverid='$queuemetrics_log_id',data1='LOGOFF';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkB); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00396',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($linkB); + } + if ( ($logintime < 1) or ($queuemetrics_loginout == 'NONE') ) + { + $stmtB = "SELECT time_id,data3 FROM queue_log where agent='Agent/$user' and verb='PAUSEREASON' and data1='LOGIN' order by time_id desc limit 1;"; + $rsltB=mysql_query($stmtB, $linkB); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00365',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "
$stmtB\n";} + $qml_ct = mysql_num_rows($rsltB); + if ($qml_ct > 0) + { + $row=mysql_fetch_row($rsltB); + $logintime = $row[0]; + $loginphone = $row[1]; + } + } + $stmt = "SELECT distinct queue FROM queue_log where time_id >= $logintime and agent='Agent/$user' and verb IN('ADDMEMBER','ADDMEMBER2') and queue != '$campaign' order by time_id desc;"; + $rslt=mysql_query($stmt, $linkB); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00351',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + echo "$stmt\n"; + $amq_conf_ct = mysql_num_rows($rslt); + $i=0; + while ($i < $amq_conf_ct) + { + $row=mysql_fetch_row($rslt); + $AMqueue[$i] = $row[0]; + $i++; + } + + ### add the logged-in campaign as well + $AMqueue[$i] = $campaign; + $i++; + $amq_conf_ct++; + + $i=0; + while ($i < $amq_conf_ct) + { + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='NONE',queue='$AMqueue[$i]',agent='Agent/$user',verb='REMOVEMEMBER',data1='$loginphone',serverid='$queuemetrics_log_id' $data4SQL;"; + $rslt=mysql_query($stmt, $linkB); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00352',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($linkB); + $i++; + } + } mysql_close($linkB); } } @@ -5288,6 +5832,8 @@ if ($ACTION == 'updateDISPO') # $fp = fopen ("./vicidial_debug.txt", "a"); # fwrite ($fp, "$NOW_TIME|DISPO_CALL |$MDnextCID|$stage|$campaign|$lead_id|$dispo_choice|$user|$uniqueid|$auto_dial_level|$agent_log_id|\n"); # fclose($fp); + $log_dispo_choice = $dispo_choice; + if (strlen($CallBackLeadEstado) > 0) {$log_dispo_choice = $CallBackLeadEstado;} $stmt = "SELECT count(*) from vicidial_inbound_groups where group_id='$stage';"; if ($format=='debug') {echo "\n";} @@ -5297,7 +5843,7 @@ if ($ACTION == 'updateDISPO') if ($row[0] > 0) { $call_type='IN'; - $stmt = "UPDATE vicidial_closer_log set status='$dispo_choice' where lead_id='$lead_id' and user='$user' order by closecallid desc limit 1;"; + $stmt = "UPDATE vicidial_closer_log set status='$log_dispo_choice' where lead_id='$lead_id' and user='$user' order by closecallid desc limit 1;"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00144',$user,$server_ip,$session_name,$one_mysql_log);} @@ -5333,7 +5879,7 @@ if ($ACTION == 'updateDISPO') $row=mysql_fetch_row($rslt); if ($row[0] > 0) { - $stmt="UPDATE vicidial_log set status='$dispo_choice' where lead_id='$lead_id' and user='$user' and call_date > \"$four_hours_ago\" order by uniqueid desc limit 1;"; + $stmt="UPDATE vicidial_log set status='$log_dispo_choice' where lead_id='$lead_id' and user='$user' and call_date > \"$four_hours_ago\" order by uniqueid desc limit 1;"; if ($format=='debug') {echo "\n";} $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00145',$user,$server_ip,$session_name,$one_mysql_log);} @@ -5422,13 +5968,20 @@ if ($ACTION == 'updateDISPO') } $PADlead_id = sprintf("%010s", $lead_id); - while (strlen($PADlead_id) > 10) {$PADlead_id = substr("$PADlead_id", 1);} + while (strlen($PADlead_id) > 9) {$PADlead_id = substr("$PADlead_id", 1);} $FAKEcall_id = "$StarTtime.$PADlead_id"; - $stmt = "INSERT INTO vicidial_log set uniqueid='$FAKEcall_id',lead_id='$lead_id',list_id='$VLlist_id',campaign_id='$campaign',call_date='$NOW_TIME',start_epoch='$StarTtime',end_epoch='$StarTtime',length_in_sec='0',status='$dispo_choice',phone_code='$VLphone_code',phone_number='$VLphone_number',user='$user',comments='MANUAL',processed='N',user_group='$user_group',term_reason='AGENT',alt_dial='$VLalt';"; + $stmt = "INSERT INTO vicidial_log set uniqueid='$FAKEcall_id',lead_id='$lead_id',list_id='$VLlist_id',campaign_id='$campaign',call_date='$NOW_TIME',start_epoch='$StarTtime',end_epoch='$StarTtime',length_in_sec='0',status='$log_dispo_choice',phone_code='$VLphone_code',phone_number='$VLphone_number',user='$user',comments='MANUAL',processed='N',user_group='$user_group',term_reason='AGENT',alt_dial='$VLalt';"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00215',$user,$server_ip,$session_name,$one_mysql_log);} + ##### insert log into vicidial_log_extended for manual VICIDiaL call + $stmt="INSERT IGNORE INTO vicidial_log_extended SET uniqueid='$FAKEcall_id',server_ip='$server_ip',call_date='$NOW_TIME',lead_id='$lead_id',caller_code='$MDnextCID',custom_call_id='' ON DUPLICATE KEY UPDATE server_ip='$server_ip',call_date='$NOW_TIME',lead_id='$lead_id',caller_code='$MDnextCID';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00402',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rowsX = mysql_affected_rows($link); + $MAN_vl_insert++; } @@ -5436,10 +5989,15 @@ if ($ACTION == 'updateDISPO') if ($format=='debug') {echo "\n";} $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00219',$user,$server_ip,$session_name,$one_mysql_log);} + + $stmt="UPDATE vicidial_live_agents set ring_callerid='' where ring_callerid='$MDnextCID';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00403',$user,$server_ip,$session_name,$one_mysql_log);} } else { - $stmt="UPDATE vicidial_log set status='$dispo_choice' where lead_id='$lead_id' and user='$user' and call_date > \"$four_hours_ago\" order by uniqueid desc limit 1;"; + $stmt="UPDATE vicidial_log set status='$log_dispo_choice' where lead_id='$lead_id' and user='$user' and call_date > \"$four_hours_ago\" order by uniqueid desc limit 1;"; if ($format=='debug') {echo "\n";} $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00145',$user,$server_ip,$session_name,$one_mysql_log);} @@ -5480,7 +6038,7 @@ if ($ACTION == 'updateDISPO') } $insert_into_dnc=0; - if ( ($use_internal_dnc=='Y') and (eregi("\|$dispo_choice\|", $DNC_string_check) ) ) + if ( ($use_internal_dnc=='Y') and (eregi("\|$log_dispo_choice\|", $DNC_string_check) ) ) { $stmt = "select phone_number from vicidial_list where lead_id='$lead_id';"; if ($DB) {echo "$stmt\n";} @@ -5493,7 +6051,7 @@ if ($ACTION == 'updateDISPO') if ($DB) {echo "$stmt\n";} $insert_into_dnc++; } - if ( ($use_campaign_dnc=='Y') and (eregi("\|$dispo_choice\|", $DNC_string_check) ) ) + if ( ($use_campaign_dnc=='Y') and (eregi("\|$log_dispo_choice\|", $DNC_string_check) ) ) { $stmt = "select phone_number from vicidial_list where lead_id='$lead_id';"; if ($DB) {echo "$stmt\n";} @@ -5545,7 +6103,7 @@ if ($ACTION == 'updateDISPO') } } } - $stmt="UPDATE vicidial_agent_log set dispo_sec='$dispo_sec',status='$dispo_choice',uniqueid='$uniqueid' $dispo_epochSQL $lead_id_commentsSQL where agent_log_id='$agent_log_id';"; + $stmt="UPDATE vicidial_agent_log set dispo_sec='$dispo_sec',status='$log_dispo_choice',uniqueid='$uniqueid' $dispo_epochSQL $lead_id_commentsSQL where agent_log_id='$agent_log_id';"; if ($format=='debug') {echo "\n";} $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00151',$user,$server_ip,$session_name,$one_mysql_log);} @@ -5594,19 +6152,48 @@ if ($ACTION == 'updateDISPO') $comments = eregi_replace("'",'',$comments); $comments = eregi_replace(';','',$comments); $comments = eregi_replace("\\\\",' ',$comments); - $stmt="INSERT INTO vicidial_callbacks (lead_id,list_id,campaign_id,status,entry_time,callback_time,user,recipient,comments,user_group) values('$lead_id','$list_id','$campaign','ACTIVE','$NOW_TIME','$CallBackDatETimE','$user','$recipient','$comments','$user_group');"; + $stmt="INSERT INTO vicidial_callbacks (lead_id,list_id,campaign_id,status,entry_time,callback_time,user,recipient,comments,user_group,lead_status) values('$lead_id','$list_id','$campaign','ACTIVE','$NOW_TIME','$CallBackDatETimE','$user','$recipient','$comments','$user_group','$CallBackLeadEstado');"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00154',$user,$server_ip,$session_name,$one_mysql_log);} } - $stmt="SELECT auto_alt_dial_statuses,use_internal_dnc,use_campaign_dnc from vicidial_campaigns where campaign_id='$campaign';"; + ### BEGIN Call Notas Logging ### + if (strlen($call_notes) > 1) + { + $VDADchannel_group=$campaign; + $stmt = "SELECT campaign_id,closecallid from vicidial_closer_log where uniqueid='$uniqueid' and user='$user' order by call_date desc limit 1;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00372',$user,$server_ip,$session_name,$one_mysql_log);} + $VDCL_cn_ct = mysql_num_rows($rslt); + if ($VDCL_cn_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VDADchannel_group = $row[0]; + $vicidial_id = $row[1]; + } + else + {$vicidial_id = $uniqueid;} + + # Insert into vicidial_call_notes + $stmt="INSERT INTO vicidial_call_notes set lead_id='$lead_id',vicidial_id='$vicidial_id',call_date='$NOW_TIME',call_notes='" . mysql_real_escape_string($call_notes) . "';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00373',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($link); + $notesid = mysql_insert_id($link); + } + ### END Call Notas Logging ### + + $stmt="SELECT auto_alt_dial_statuses,use_internal_dnc,use_campaign_dnc,api_manual_dial from vicidial_campaigns where campaign_id='$campaign';"; $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00155',$user,$server_ip,$session_name,$one_mysql_log);} $row=mysql_fetch_row($rslt); $VC_auto_alt_dial_statuses = $row[0]; $use_internal_dnc = $row[1]; $use_campaign_dnc = $row[2]; + $api_manual_dial = $row[3]; if ( ($auto_dial_level > 0) and (ereg(" $dispo_choice ",$VC_auto_alt_dial_statuses)) ) { @@ -5701,6 +6288,13 @@ if ($ACTION == 'updateDISPO') $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00158',$user,$server_ip,$session_name,$one_mysql_log);} } + if ( ($api_manual_dial=='QUEUE') or ($api_manual_dial=='QUEUE_AND_AUTOCALL') ) + { + $stmt="DELETE from vicidial_manual_dial_queue where user='$user' and status='QUEUE';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00363',$user,$server_ip,$session_name,$one_mysql_log);} + } ####### START Vtiger Call Logging ####### $stmt = "SELECT enable_vtiger_integration,vtiger_server_ip,vtiger_dbname,vtiger_login,vtiger_pass,vtiger_url FROM system_settings;"; @@ -6092,7 +6686,7 @@ if ($ACTION == 'updateDISPO') ############################################# ##### START QUEUEMETRICS LOGGING LOOKUP ##### - $stmt = "SELECT enable_queuemetrics_logging,queuemetrics_server_ip,queuemetrics_dbname,queuemetrics_login,queuemetrics_pass,queuemetrics_log_id,queuemetrics_callstatus FROM system_settings;"; + $stmt = "SELECT enable_queuemetrics_logging,queuemetrics_server_ip,queuemetrics_dbname,queuemetrics_login,queuemetrics_pass,queuemetrics_log_id,queuemetrics_callstatus,queuemetrics_dispo_pause FROM system_settings;"; $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00159',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} @@ -6107,6 +6701,7 @@ if ($ACTION == 'updateDISPO') $queuemetrics_pass = $row[4]; $queuemetrics_log_id = $row[5]; $queuemetrics_callstatus = $row[6]; + $queuemetrics_dispo_pause = $row[7]; } ##### END QUEUEMETRICS LOGGING LOOKUP ##### ########################################### @@ -6118,12 +6713,89 @@ if ($ACTION == 'updateDISPO') if (strlen($stage) < 2) {$stage = $campaign;} - $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='$MDnextCID',queue='$stage',agent='Agent/$user',verb='CALLSTATUS',data1='$dispo_choice',serverid='$queuemetrics_log_id';"; + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='$MDnextCID',queue='$stage',agent='Agent/$user',verb='CALLSTATUS',data1='$log_dispo_choice',serverid='$queuemetrics_log_id';"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $linkB); if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00160',$user,$server_ip,$session_name,$one_mysql_log);} $affected_rows = mysql_affected_rows($linkB); + ### check to make sure a COMPLETE record is present for this call + $QLcomplete_records=0; + $stmt = "SELECT count(*) FROM queue_log where verb IN('COMPLETEAGENT','COMPLETECALLER') and call_id='$MDnextCID' and agent='Agent/$user' and queue='$stage';"; + $rslt=mysql_query($stmt, $linkB); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00409',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + echo "$stmt\n"; + $comp_ct = mysql_num_rows($rslt); + if ($comp_ct > 0) + { + $row=mysql_fetch_row($rslt); + $QLcomplete_records = $row[0]; + } + + ### if there are no complete records, look up information to insert one for this call + if ($QLcomplete_records < 1) + { + $QLconnect_time=$StarTtime; + $QLcomplete_time=$StarTtime; + $QLconnect_one=''; + $QLconnect_four=''; + $QLcomplete_position=1; + + $stmt = "SELECT time_id,data1,data4 FROM queue_log where verb='CONNECT' and call_id='$MDnextCID' and agent='Agent/$user' and queue='$stage' order by time_id desc limit 1;"; + $rslt=mysql_query($stmt, $linkB); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00410',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + echo "$stmt\n"; + $connect_ct = mysql_num_rows($rslt); + if ($connect_ct > 0) + { + $row=mysql_fetch_row($rslt); + $QLconnect_time = $row[0]; + $QLconnect_one = $row[1]; + $QLconnect_four = $row[2]; + } + + $stmt = "SELECT time_id FROM queue_log where verb='PAUSEREASON' and call_id='$MDnextCID' and agent='Agent/$user' and data1='$queuemetrics_dispo_pause' order by time_id desc limit 1;"; + $rslt=mysql_query($stmt, $linkB); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00411',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + echo "$stmt\n"; + $pausereason_ct = mysql_num_rows($rslt); + if ($pausereason_ct > 0) + { + $row=mysql_fetch_row($rslt); + $QLcomplete_time = $row[0]; + } + + $QLcomplete_length = ($QLcomplete_time - $QLconnect_time); + if ($QLcomplete_length < 0) {$QLcomplete_length=0;} + if ($QLcomplete_length > 86400) {$QLcomplete_length=1;} + + ## if inbound, check for initial queue position + if (preg_match("/^Y/",$MDnextCID)) + { + $four_hours_ago = date("Y-m-d H:i:s", mktime(date("H")-4,date("i"),date("s"),date("m"),date("d"),date("Y"))); + + $stmt = "SELECT queue_position FROM vicidial_closer_log where lead_id='$lead_id' and campaign_id='$stage' and call_date > \"$four_hours_ago\" order by closecallid desc limit 1;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00412',$user,$server_ip,$session_name,$one_mysql_log);} + $vcl_ct = mysql_num_rows($rslt); + if ($vcl_ct > 0) + { + $row=mysql_fetch_row($rslt); + $QLcomplete_position = $row[0]; + } + } + + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$QLcomplete_time',call_id='$MDnextCID',queue='$stage',agent='Agent/$user',verb='COMPLETEAGENT',data1='$QLconnect_one',data2='$QLcomplete_length',data3='$QLcomplete_position',serverid='$queuemetrics_log_id',data4='$QLconnect_four';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkB); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00413',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($linkB); + } + mysql_close($linkB); } @@ -6242,7 +6914,7 @@ if ($ACTION == 'updateDISPO') $stmt = "SELECT did_id,extension from vicidial_did_log where uniqueid='$uniqueid' order by call_date desc limit 1;"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00XXX',$user,$server_ip,$session_name,$one_mysql_log);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00346',$user,$server_ip,$session_name,$one_mysql_log);} $VDIDL_ct = mysql_num_rows($rslt); if ($VDIDL_ct > 0) { @@ -6253,7 +6925,7 @@ if ($ACTION == 'updateDISPO') $stmt = "SELECT did_pattern,did_description from vicidial_inbound_dids where did_id='$DID_id' limit 1;"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00XXX',$user,$server_ip,$session_name,$one_mysql_log);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00347',$user,$server_ip,$session_name,$one_mysql_log);} $VDIDL_ct = mysql_num_rows($rslt); if ($VDIDL_ct > 0) { @@ -6272,7 +6944,7 @@ if ($ACTION == 'updateDISPO') $stmt = "SELECT campaign_id,closecallid,xfercallid from vicidial_closer_log where uniqueid='$uniqueid' and user='$user' order by call_date desc limit 1;"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00XXX',$user,$server_ip,$session_name,$one_mysql_log);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00348',$user,$server_ip,$session_name,$one_mysql_log);} $VDCL_mvac_ct = mysql_num_rows($rslt); if ($VDCL_mvac_ct > 0) { @@ -6678,7 +7350,9 @@ if ( ($ACTION == 'VDADpause') || ($ACTION == 'VDADready') ) $vla_lead_wipeSQL=''; if ($ACTION == 'VDADready') {$vla_lead_wipeSQL = ",lead_id=0";} - $stmt="UPDATE vicidial_live_agents set status='$stage' $vla_lead_wipeSQL where user='$user' and server_ip='$server_ip';"; + if ($ACTION == 'VDADpause') + {$vla_ring_resetSQL = ",ring_callerid=''";} + $stmt="UPDATE vicidial_live_agents set status='$stage' $vla_lead_wipeSQL $vla_ring_resetSQL where user='$user' and server_ip='$server_ip';"; if ($format=='debug') {echo "\n";} $rslt=mysql_query($stmt, $link); if ($mel > 0) {$errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00166',$user,$server_ip,$session_name,$one_mysql_log);} @@ -6735,7 +7409,19 @@ if ( ($ACTION == 'VDADpause') || ($ACTION == 'VDADready') ) $user_group = trim("$row[0]"); } - $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='NONE',queue='NONE',agent='Agent/$user',verb='$QMstatus',serverid='$queuemetrics_log_id';"; + $data4SQL=''; + $stmt="SELECT queuemetrics_phone_environment FROM vicidial_campaigns where campaign_id='$campaign' and queuemetrics_phone_environment!='';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00395',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $cqpe_ct = mysql_num_rows($rslt); + if ($cqpe_ct > 0) + { + $row=mysql_fetch_row($rslt); + $data4SQL = ",data4='$row[0]'"; + } + + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='NONE',queue='NONE',agent='Agent/$user',verb='$QMstatus',serverid='$queuemetrics_log_id' $data4SQL;"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $linkB); if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00168',$user,$server_ip,$session_name,$one_mysql_log);} @@ -6834,7 +7520,17 @@ if ( ($ACTION == 'VDADpause') || ($ACTION == 'VDADready') ) $VLAaffected_rows_update = mysql_affected_rows($link); } } - echo 'Agent ' . $user . ' ahora está en estado ' . $stage . "\nNext agent_log_id:\n$agent_log_id\n"; + if (strlen($sub_status) > 0) + { + ### if a pause code(sub_status) is sent with this pause request, continue en to that action without printing output + $stage = 0; + $status = $sub_status; + $ACTION = 'PauseCodeSubmit'; + } + else + { + echo 'Agent ' . $user . ' ahora está en estado ' . $stage . "\nNext agent_log_id:\n$agent_log_id\n"; + } } @@ -6976,10 +7672,12 @@ if ($ACTION == 'PauseCodeSubmit') } if ($enable_queuemetrics_logging > 0) { + $pause_call_id='NONE'; + if (strlen($campaign_cid) > 12) {$pause_call_id = $campaign_cid;} $linkB=mysql_connect("$queuemetrics_server_ip", "$queuemetrics_login", "$queuemetrics_pass"); mysql_select_db("$queuemetrics_dbname", $linkB); - $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='NONE',queue='NONE',agent='Agent/$user',verb='PAUSEREASON',serverid='$queuemetrics_log_id',data1='$status';"; + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='$pause_call_id',queue='NONE',agent='Agent/$user',verb='PAUSEREASON',serverid='$queuemetrics_log_id',data1='$status';"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $linkB); if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00177',$user,$server_ip,$session_name,$one_mysql_log);} @@ -7529,19 +8227,366 @@ if ($ACTION == 'CALLLOGview') echo " $ALLalt_dial[$i] \n"; echo " $ALLhangup_reason[$i] \n"; echo " INFO \n"; - echo " DIAL \n"; + echo " DIAL \n"; echo "\n"; } echo ""; echo "
"; - echo "Close Call Log"; + echo "Close Call Log"; echo ""; } ################################################################################ -### LEADINFOview - display the information for a lead +### SEARCHRESULTSview - display search results for lead search +################################################################################ +if ($ACTION == 'SEARCHRESULTSview') + { + if (strlen($stage) < 3) + {$stage = '670';} + + $stmt="select agent_lead_search_method,manual_dial_list_id from vicidial_campaigns where campaign_id='$campaign';"; + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00374',$user,$server_ip,$session_name,$one_mysql_log);} + $rslt=mysql_query($stmt, $link); + $camps_to_print = mysql_num_rows($rslt); + if ($camps_to_print > 0) + { + $row=mysql_fetch_row($rslt); + $agent_lead_search_method = $row[0]; + $manual_dial_list_id = $row[1]; + + $searchSQL=''; + $searchmethodSQL=''; + + $lead_id=ereg_replace("[^0-9]","",$lead_id); + $vendor_lead_code = ereg_replace("'|\"|\\\\|;","",$vendor_lead_code); + $last_name = ereg_replace("'|\"|\\\\|;","",$last_name); + $first_name = ereg_replace("'|\"|\\\\|;","",$first_name); + $city = ereg_replace("'|\"|\\\\|;","",$city); + $state = ereg_replace("'|\"|\\\\|;","",$state); + $postal_code = ereg_replace("'|\"|\\\\|;","",$postal_code); + + if (strlen($lead_id) > 0) + { + ### lead ID entered, search by this + $searchSQL = "lead_id='$lead_id'"; + } + elseif (strlen($vendor_lead_code) > 0) + { + ### vendor ID entered, search by this + $searchSQL = "vendor_lead_code='$vendor_lead_code'"; + } + elseif ( (strlen($phone_number) >= 6) and (strlen($search) > 2) ) + { + ### phone number entered, search by this + if (preg_match('/MAIN/',$search)) + {$searchSQL = "phone_number='$phone_number'";} + if (preg_match('/ALT/',$search)) + { + if (strlen($searchSQL) > 10) + {$searchSQL .= " or ";} + $searchSQL .= "alt_phone='$phone_number'"; + } + if (preg_match('/ADDR3/',$search)) + { + if (strlen($searchSQL) > 10) + {$searchSQL .= " or ";} + $searchSQL .= "address3='$phone_number'"; + } + } + elseif (strlen($last_name) > 0) + { + ### last name entered, search by this and other fields + $searchSQL = "last_name='$last_name'"; + if (strlen($first_name) > 0) + { + if (strlen($searchSQL) > 10) + {$searchSQL .= " and ";} + $searchSQL .= "first_name='$first_name'"; + } + if (strlen($city) > 0) + { + if (strlen($searchSQL) > 10) + {$searchSQL .= " and ";} + $searchSQL .= "city='$city'"; + } + if (strlen($state) > 0) + { + if (strlen($searchSQL) > 10) + {$searchSQL .= " and ";} + $searchSQL .= "state='$state'"; + } + if (strlen($postal_code) > 0) + { + if (strlen($searchSQL) > 10) + {$searchSQL .= " and ";} + $searchSQL .= "postal_code='$postal_code'"; + } + } + else + { + echo "ERROR: You must enter in search terms, one of these must be populated: lead ID, vendor ID, phone number, last name\n"; + echo "

"; + echo "Vaya Detrás"; + echo ""; + exit; + } + + $searchownerSQL=''; + ### limit results to specified search method + # USER_, GROUP_, TERRITORY_ + if (preg_match('/USER_/',$agent_lead_search_method)) + {$searchownerSQL=" and owner='$user'";} + if (preg_match('/GROUP_/',$agent_lead_search_method)) + { + $stmt="SELECT user_group from vicidial_users where user='$user';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00386',$user,$server_ip,$session_name,$one_mysql_log);} + $groups_to_parse = mysql_num_rows($rslt); + if ($groups_to_parse > 0) + { + $rowx=mysql_fetch_row($rslt); + $searchownerSQL=" and owner='$rowx[0]'"; + } + } + if (preg_match('/TERRITORY_/',$agent_lead_search_method)) + { + $agent_territories=''; + $agent_choose_territories=0; + $stmt="SELECT agent_choose_territories from vicidial_users where user='$user';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00404',$user,$server_ip,$session_name,$one_mysql_log);} + $Uterrs_to_parse = mysql_num_rows($rslt); + if ($Uterrs_to_parse > 0) + { + $rowx=mysql_fetch_row($rslt); + $agent_choose_territories = $rowx[0]; + } + + if ($agent_choose_territories < 1) + { + $stmt="SELECT territory from vicidial_user_territories where user='$user';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00405',$user,$server_ip,$session_name,$one_mysql_log);} + $vuts_to_parse = mysql_num_rows($rslt); + $o=0; + while ($vuts_to_parse > $o) + { + $rowx=mysql_fetch_row($rslt); + $agent_territories .= "'$rowx[0]',"; + $o++; + } + $agent_territories = preg_replace("/\,$/",'',$agent_territories); + $searchownerSQL=" and owner IN($agent_territories)"; + if ($vuts_to_parse < 1) + {$searchownerSQL=" and lead_id < 0";} + } + else + { + $stmt="SELECT agent_territories from vicidial_live_agents where user='$user';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00387',$user,$server_ip,$session_name,$one_mysql_log);} + $terrs_to_parse = mysql_num_rows($rslt); + if ($terrs_to_parse > 0) + { + $rowx=mysql_fetch_row($rslt); + $agent_territories = $rowx[0]; + $agent_territories = preg_replace("/ -$|^ /",'',$agent_territories); + $agent_territories = preg_replace("/ /","','",$agent_territories); + $searchownerSQL=" and owner IN('$agent_territories')"; + } + } + } + + ### limit results to specified search method + # 'SYSTEM','CAMPAIGNLISTS','CAMPLISTS_ALL','LIST' + if (preg_match('/SYSTEM/',$agent_lead_search_method)) + {$searchmethodSQL='';} + if (preg_match('/LIST/',$agent_lead_search_method)) + {$searchmethodSQL=" and list_id='$manual_dial_list_id'";} + if (preg_match('/CAMPLISTS_ALL/',$agent_lead_search_method)) + { + $stmt="SELECT list_id from vicidial_lists where campaign_id='$campaign';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00375',$user,$server_ip,$session_name,$one_mysql_log);} + $lists_to_parse = mysql_num_rows($rslt); + $camp_lists=''; + $o=0; + while ($lists_to_parse > $o) + { + $rowx=mysql_fetch_row($rslt); + $camp_lists .= "'$rowx[0]',"; + $o++; + } + $camp_lists = eregi_replace(".$","",$camp_lists); + $searchmethodSQL=" and list_id IN($camp_lists)"; + } + if (preg_match('/CAMPAIGNLISTS/',$agent_lead_search_method)) + { + $stmt="SELECT list_id,active from vicidial_lists where campaign_id='$campaign' and active='Y';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00376',$user,$server_ip,$session_name,$one_mysql_log);} + $lists_to_parse = mysql_num_rows($rslt); + $camp_lists=''; + $o=0; + while ($lists_to_parse > $o) + { + $rowx=mysql_fetch_row($rslt); + $camp_lists .= "'$rowx[0]',"; + $o++; + } + $camp_lists = eregi_replace(".$","",$camp_lists); + $searchmethodSQL=" and list_id IN($camp_lists)"; + } + + + ##### BEGIN search queries and output ##### + $stmt="select count(*) from vicidial_list where $searchSQL $searchownerSQL $searchmethodSQL;"; + + ### LOG INSERTION Search Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmtL="INSERT INTO vicidial_lead_search_log set event_date='$NOW_TIME', user='$user', source='agent', results='0', search_query=\"$SQL_log\";"; + if ($DB) {echo "|$stmtL|\n";} + $rslt=mysql_query($stmtL, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00377',$user,$server_ip,$session_name,$one_mysql_log);} + $search_log_id = mysql_insert_id($link); + + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00378',$user,$server_ip,$session_name,$one_mysql_log);} + $counts_to_print = mysql_num_rows($rslt); + if ($counts_to_print > 0) + { + $row=mysql_fetch_row($rslt); + $search_result_count = $row[0]; + + $end_process_time = date("U"); + $search_seconds = ($end_process_time - $StarTtime); + + $stmtL="UPDATE vicidial_lead_search_log set results='$search_result_count',seconds='$search_seconds' where search_log_id='$search_log_id';"; + if ($DB) {echo "|$stmtL|\n";} + $rslt=mysql_query($stmtL, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00379',$user,$server_ip,$session_name,$one_mysql_log);} + + + echo "
\n"; + echo ""; + echo "Results Found: $search_result_count"; + echo "\n"; + echo "
\n"; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + + if ($search_result_count) + { + $stmt="select first_name,last_name,phone_code,phone_number,status,last_local_call_time,lead_id,city,state,postal_code from vicidial_list where $searchSQL $searchownerSQL $searchmethodSQL order by last_local_call_time desc limit 1000;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00380',$user,$server_ip,$session_name,$one_mysql_log);} + $out_logs_to_print = mysql_num_rows($rslt); + if ($format=='debug') {echo "|$out_logs_to_print|$stmt|";} + + $g=0; + $u=0; + while ($out_logs_to_print > $u) + { + $row=mysql_fetch_row($rslt); + $ALLsort[$g] = "$row[0]-----$g"; + $ALLname[$g] = "$row[0] $row[1]"; + $ALLphone_code[$g] = $row[2]; + $ALLphone_number[$g] = $row[3]; + $ALLstatus[$g] = $row[4]; + $ALLcall_date[$g] = $row[5]; + $ALLlead_id[$g] = $row[6]; + $ALLcity[$g] = $row[7]; + $ALLstate[$g] = $row[8]; + $ALLpostal_code[$g] = $row[9]; + + $g++; + $u++; + } + + if ($g < 1) + {echo "";} + + $u=0; + while ($g > $u) + { + $sort_split = explode("-----",$ALLsort[$u]); + $i = $sort_split[1]; + + if (eregi("1$|3$|5$|7$|9$", $u)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + $u++; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } + + $end_process_time = date("U"); + $search_seconds = ($end_process_time - $StarTtime); + + $stmtL="UPDATE vicidial_lead_search_log set segundos='$search_seconds' where search_log_id='$search_log_id';"; + if ($DB) {echo "|$stmtL|\n";} + $rslt=mysql_query($stmtL, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00381',$user,$server_ip,$session_name,$one_mysql_log);} + } + else + {echo "";} + + echo "
  #     NAME     PHONE     ESTADO     LAST LLAMADA     CITY     STATE     ZIP     INFO     DIAL  
No results found
$u$ALLname[$i] $ALLphone_code[$i] $ALLphone_number[$i] $ALLstatus[$i] $ALLcall_date[$i] $ALLcity[$i] $ALLstate[$i] $ALLpostal_code[$i] INFO DIAL
No results found
"; + echo "
"; + echo "Vaya Detrás"; + echo "
"; + } + else + { + echo "ERROR: There was a problem with your search terms\n"; + echo "

"; + echo "Vaya Detrás"; + echo ""; + exit; + } + ##### END search queries and output ##### + } + else + { + echo "ERROR: Campaña not found\n"; + echo "

"; + echo "Vaya Detrás"; + echo ""; + exit; + } + } + + + +################################################################################ +### LEADINFOview - display the information for a lead and logs for that lead ################################################################################ if ($ACTION == 'LEADINFOview') { @@ -7549,7 +8594,41 @@ if ($ACTION == 'LEADINFOview') {echo "ERROR: no Lead ID";} else { + $hide_dial_links=0; + echo "
\n"; + + if ($search == 'logfirst') + {$hide_dial_links++;} + + ### BEGIN Display callback information ### + $callback_id = preg_replace('/\D/','',$callback_id); + if (strlen($callback_id) > 0) + { + $stmt="select status,entry_time,callback_time,modify_date,user,recipient,comments,lead_status from vicidial_callbacks where lead_id='$lead_id' and callback_id='$callback_id' limit 1;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00397',$user,$server_ip,$session_name,$one_mysql_log);} + $cb_to_print = mysql_num_rows($rslt); + if ($format=='debug') {echo "|$cb_to_print|$stmt|";} + if ($cb_to_print > 0) + { + $row=mysql_fetch_row($rslt); + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "
Callback Estado:   $row[0]
Callback Lead Estado:   $row[7]
Callback Entry Time:   $row[1]
Callback Trigger Time:   $row[2]
Callback Comentarios:  $row[6]
"; + echo "
"; + $hide_dial_links++; + } + } + ### END Display callback information ### + + + ### BEGIN Display lead info and custom fields ### ### BEGIN find any custom field labels ### + $INFOout=''; $label_title = 'Título'; $label_first_name = 'Primero'; $label_middle_initial = 'MI'; @@ -7594,56 +8673,290 @@ if ($ACTION == 'LEADINFOview') if (strlen($row[18])>0) {$label_comments = $row[18];} ### END find any custom field labels ### - echo "
\n"; - echo ""; + $INFOout .= "
"; - $stmt="select status,vendor_lead_code,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,alt_phone,email,security_phrase,comments,called_count,last_local_call_time,rank,owner,entry_list_id from vicidial_list where lead_id='$lead_id'limit 1;"; + $stmt="select status,vendor_lead_code,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,alt_phone,email,security_phrase,comments,called_count,last_local_call_time,rank,owner,entry_list_id from vicidial_list where lead_id='$lead_id' limit 1;"; $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00398',$user,$server_ip,$session_name,$one_mysql_log);} $info_to_print = mysql_num_rows($rslt); - if ($format=='debug') {echo "|$out_logs_to_print|$stmt|";} + if ($format=='debug') {$INFOout .= "|$out_logs_to_print|$stmt|";} - if ($info_to_print > 0) + if ($info_to_print > 0) { $row=mysql_fetch_row($rslt); - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - # echo ""; - # echo ""; - # echo ""; + $INFOout .= ""; + $INFOout .= ""; + $INFOout .= ""; + $INFOout .= ""; + $INFOout .= ""; + $INFOout .= ""; + $INFOout .= ""; + $INFOout .= ""; + $INFOout .= ""; + $INFOout .= ""; + $INFOout .= ""; + $INFOout .= ""; + $INFOout .= ""; + $INFOout .= ""; + $INFOout .= ""; + $INFOout .= ""; + $INFOout .= ""; + $INFOout .= ""; + $INFOout .= ""; + $INFOout .= ""; + $INFOout .= ""; + $INFOout .= ""; + $INFOout .= ""; + $INFOout .= ""; + $INFOout .= ""; + $INFOout .= ""; + # $INFOout .= ""; + # $INFOout .= ""; + # $INFOout .= ""; + + $entry_list_id = $row[28]; + $CFoutput=''; + $stmt="SHOW TABLES LIKE \"custom_$entry_list_id\";"; + if ($DB>0) {$INFOout .= "$stmt";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00382',$user,$server_ip,$session_name,$one_mysql_log);} + $tablecount_to_print = mysql_num_rows($rslt); + if ($tablecount_to_print > 0) + { + $stmt="SELECT count(*) from custom_$entry_list_id where lead_id='$lead_id';"; + if ($DB>0) {$INFOout .= "$stmt";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00383',$user,$server_ip,$session_name,$one_mysql_log);} + $fieldscount_to_print = mysql_num_rows($rslt); + if ($fieldscount_to_print > 0) + { + $rowx=mysql_fetch_row($rslt); + $custom_records_count = $rowx[0]; + + $select_SQL=''; + $stmt="SHOW COLUMNS FROM custom_$entry_list_id where Field != 'lead_id';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00384',$user,$server_ip,$session_name,$one_mysql_log);} + $fields_to_print = mysql_num_rows($rslt); + $select_SQL=''; + $o=0; + while ($fields_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $select_SQL .= "$rowx[0],"; + $A_field_name[$o] = $rowx[0]; + $o++; + } + $select_SQL = preg_replace("/.$/",'',$select_SQL); + if (strlen($select_SQL) > 0) + { + $stmt="SELECT $select_SQL FROM custom_$entry_list_id where lead_id='$lead_id' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00385',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {$INFOout .= "$stmt\n";} + $list_lead_ct = mysql_num_rows($rslt); + if ($list_lead_ct > 0) + { + $row=mysql_fetch_row($rslt); + $o=0; + while ($fields_to_print > $o) + { + $A_field_value = trim("$row[$o]"); + + $INFOout .= ""; + + $o++; + } + } + } + } + } } - echo "
Estado:   $row[0]
$label_vendor_lead_code:   $row[1]
List ID:   $row[2]
Timezone:   $row[3]
Llamado Since Último Reset:   $row[4]
$label_phone_code:   $row[5]
$label_phone_number:   $row[6] -         DIAL
$label_title:   $row[7]
$label_first_name:   $row[8]
$label_middle_initial:   $row[9]
$label_last_name:   $row[10]
$label_address1:   $row[11]
$label_address2:   $row[12]
$label_address3:   $row[13]
$label_city:   $row[14]
$label_state:   $row[15]
$label_province:   $row[16]
$label_postal_code:   $row[17]
Country:   $row[18]
$label_gender:   $row[19]
$label_alt_phone:   $row[20] -         DIAL
$label_email:   $row[21]
$label_security_phrase:   $row[22]
$label_comments:   $row[23]
Llamado Count:   $row[24]
Último Local Call Time:   $row[25]
Rank:   $row[26]
Owner:   $row[27]
Entry List ID:   $row[28]
Estado:   $row[0]
$label_vendor_lead_code:   $row[1]
List ID:   $row[2]
Timezone:   $row[3]
Llamado Since Último Reset:   $row[4]
$label_phone_code:   $row[5]
$label_phone_number:   $row[6] -         "; + if ($hide_dial_links < 1) + {$INFOout .= "DIAL";} + $INFOout .= "
$label_title:   $row[7]
$label_first_name:   $row[8]
$label_middle_initial:   $row[9]
$label_last_name:   $row[10]
$label_address1:   $row[11]
$label_address2:   $row[12]
$label_address3:   $row[13]
$label_city:   $row[14]
$label_state:   $row[15]
$label_province:   $row[16]
$label_postal_code:   $row[17]
Country:   $row[18]
$label_gender:   $row[19]
$label_alt_phone:   $row[20] -         "; + if ($hide_dial_links < 1) + {$INFOout .= "DIAL";} + $INFOout .= "
$label_email:   $row[21]
$label_security_phrase:   $row[22]
$label_comments:   $row[23]
Llamado Count:   $row[24]
Último Local Call Time:   $row[25]
Rank:   $row[26]
Owner:   $row[27]
Entry List ID:   $row[28]
$A_field_name[$o]:   $A_field_value
"; - echo "
"; - echo "Close Info Box"; + $INFOout .= ""; + $INFOout .= "
"; + ### END Display lead info and custom fields ### + + + ### BEGIN Gather Call Log and notes ### + $NOTESout=''; + if ($search != 'logfirst') + {$NOTESout .= "
CALL LOG FOR THIS LEAD:
\n";} + $NOTESout .= ""; + $NOTESout .= ""; + $NOTESout .= ""; + $NOTESout .= ""; + $NOTESout .= ""; + $NOTESout .= ""; + $NOTESout .= ""; + $NOTESout .= ""; + $NOTESout .= ""; + $NOTESout .= ""; + $NOTESout .= ""; + $NOTESout .= ""; + # $NOTESout .= ""; + # $NOTESout .= ""; + $NOTESout .= ""; + + + $stmt="select start_epoch,call_date,campaign_id,length_in_sec,status,phone_code,phone_number,lead_id,term_reason,alt_dial,comments,uniqueid,user from vicidial_log where lead_id='$lead_id' order by call_date desc limit 10000;"; + $rslt=mysql_query($stmt, $link); + $out_logs_to_print = mysql_num_rows($rslt); + if ($format=='debug') {$NOTESout .= "|$out_logs_to_print|$stmt|";} + + $g=0; + $u=0; + while ($out_logs_to_print > $u) + { + $row=mysql_fetch_row($rslt); + $ALLsort[$g] = "$row[0]-----$g"; + $ALLstart_epoch[$g] = $row[0]; + $ALLcall_date[$g] = $row[1]; + $ALLcampaign_id[$g] = $row[2]; + $ALLlength_in_sec[$g] = $row[3]; + $ALLstatus[$g] = $row[4]; + $ALLphone_code[$g] = $row[5]; + $ALLphone_number[$g] = $row[6]; + $ALLlead_id[$g] = $row[7]; + $ALLhangup_reason[$g] = $row[8]; + $ALLalt_dial[$g] = $row[9]; + $ALLuniqueid[$g] = $row[11]; + $ALLuser[$g] = $row[12]; + $ALLin_out[$g] = "OUT-AUTO"; + if ($row[10] == 'MANUAL') {$ALLin_out[$g] = "OUT-MANUAL";} + + $stmtA="SELECT call_notes FROM vicidial_call_notes WHERE lead_id='$ALLlead_id[$g]' and vicidial_id='$ALLuniqueid[$g]';"; + $rsltA=mysql_query($stmtA, $link); + $out_notes_to_print = mysql_num_rows($rslt); + if ($out_notes_to_print > 0) + { + $rowA=mysql_fetch_row($rsltA); + $Allcall_notes[$g] = $rowA[0]; + if (strlen($Allcall_notes[$g]) > 0) + {$Allcall_notes[$g] = "NOTES: $Allcall_notes[$g]";} + } + $stmtA="SELECT full_name FROM vicidial_users WHERE user='$ALLuser[$g]';"; + $rsltA=mysql_query($stmtA, $link); + $users_to_print = mysql_num_rows($rslt); + if ($users_to_print > 0) + { + $rowA=mysql_fetch_row($rsltA); + $ALLuser[$g] .= " - $rowA[0]"; + } + + $Allcounter[$g] = $g; + + $g++; + $u++; + } + + $stmt="select start_epoch,call_date,campaign_id,length_in_sec,status,phone_code,phone_number,lead_id,term_reason,queue_seconds,uniqueid,closecallid,user from vicidial_closer_log where lead_id='$lead_id' order by call_date desc limit 10000;"; + $rslt=mysql_query($stmt, $link); + $in_logs_to_print = mysql_num_rows($rslt); + if ($format=='debug') {$NOTESout .= "|$in_logs_to_print|$stmt|";} + + $u=0; + while ($in_logs_to_print > $u) + { + $row=mysql_fetch_row($rslt); + $ALLsort[$g] = "$row[0]-----$g"; + $ALLstart_epoch[$g] = $row[0]; + $ALLcall_date[$g] = $row[1]; + $ALLcampaign_id[$g] = $row[2]; + $ALLlength_in_sec[$g] = ($row[3] - $row[9]); + if ($ALLlength_in_sec[$g] < 0) {$ALLlength_in_sec[$g]=0;} + $ALLstatus[$g] = $row[4]; + $ALLphone_code[$g] = $row[5]; + $ALLphone_number[$g] = $row[6]; + $ALLlead_id[$g] = $row[7]; + $ALLhangup_reason[$g] = $row[8]; + $ALLuniqueid[$g] = $row[10]; + $ALLclosecallid[$g] = $row[11]; + $ALLuser[$g] = $row[12]; + $ALLalt_dial[$g] = "MAIN"; + $ALLin_out[$g] = "IN"; + + $stmtA="SELECT call_notes FROM vicidial_call_notes WHERE lead_id='$ALLlead_id[$g]' and vicidial_id='$ALLclosecallid[$g]';"; + $rsltA=mysql_query($stmtA, $link); + $in_notes_to_print = mysql_num_rows($rslt); + if ($in_notes_to_print > 0) + { + $rowA=mysql_fetch_row($rsltA); + $Allcall_notes[$g] = $rowA[0]; + if (strlen($Allcall_notes[$g]) > 0) + {$Allcall_notes[$g] = "NOTES: $Allcall_notes[$g]";} + } + $stmtA="SELECT full_name FROM vicidial_users WHERE user='$ALLuser[$g]';"; + $rsltA=mysql_query($stmtA, $link); + $users_to_print = mysql_num_rows($rslt); + if ($users_to_print > 0) + { + $rowA=mysql_fetch_row($rsltA); + $ALLuser[$g] .= " - $rowA[0]"; + } + + $Allcounter[$g] = $g; + + $g++; + $u++; + } + + if ($g > 0) + {sort($ALLsort, SORT_NUMERIC);} + else + {$NOTESout .= "";} + + $u=0; + while ($g > $u) + { + $sort_split = explode("-----",$ALLsort[$u]); + $i = $sort_split[1]; + + if (eregi("1$|3$|5$|7$|9$", $u)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + $u++; + $NOTESout .= ""; + $NOTESout .= ""; + $NOTESout .= ""; + $NOTESout .= "\n"; + $NOTESout .= "\n"; + $NOTESout .= "\n"; + $NOTESout .= "\n"; + $NOTESout .= "\n"; + $NOTESout .= "\n"; + $NOTESout .= "\n"; + $NOTESout .= "\n"; + $NOTESout .= ""; + $NOTESout .= ""; + $NOTESout .= ""; + $NOTESout .= "\n"; + } + + $NOTESout .= "
  #     DATE/TIME     AGENT     LENGTH     ESTADO     PHONE     CAMPAIGN     IN/OUT     ALT     HANGUP  
  FULL NAME  
No calls found
$u$ALLcall_date[$i] $ALLuser[$i] $ALLlength_in_sec[$i] $ALLstatus[$i] $ALLphone_code[$i] $ALLphone_number[$i] $ALLcampaign_id[$i] $ALLin_out[$i] $ALLalt_dial[$i] $ALLhangup_reason[$i]
$Allcall_notes[$i]
"; + $NOTESout .= "
"; + ### END Gather Call Log and notes ### + + + if ($search == 'logfirst') + {echo "$NOTESout\n$INFOout\n";} + else + {echo "$INFOout\n$NOTESout\n";} + echo "
"; } } + ################################################################################ ### CALLSINQUEUEgrab - grab a call in queue and reserve it for that agent ################################################################################ @@ -7846,44 +9159,23 @@ if ($ACTION == 'Clear_API_Field') if ($format=='debug') -{ -$ENDtime = date("U"); -$RUNtime = ($ENDtime - $StarTtime); -echo "\n"; -echo "\n\n\n"; -} + { + $ENDtime = date("U"); + $RUNtime = ($ENDtime - $StarTtime); + echo "\n"; + echo "\n\n\n"; + } exit; ##### Hangup Cause Description Map ##### function hangup_cause_description($code) -{ -global $hangup_cause_dictionary; -if ( array_key_exists($code,$hangup_cause_dictionary) ) { return $hangup_cause_dictionary[$code]; } -else { return "Unidentified Hangup Cause Code."; } -} - - -##### MySQL Error Logging ##### -function mysql_error_logging($NOW_TIME,$link,$mel,$stmt,$query_id,$user,$server_ip,$session_name,$one_mysql_log) -{ -$NOW_TIME = date("Y-m-d H:i:s"); -# mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00001',$user,$server_ip,$session_name,$one_mysql_log); -$errno=''; $error=''; -if ( ($mel > 0) or ($one_mysql_log > 0) ) { - $errno = mysql_errno($link); - if ( ($errno > 0) or ($mel > 1) or ($one_mysql_log > 0) ) - { - $error = mysql_error($link); - $efp = fopen ("./vicidial_mysql_errors.txt", "a"); - fwrite ($efp, "$NOW_TIME|vdc_db_query|$query_id|$errno|$error|$stmt|$user|$server_ip|$session_name|\n"); - fclose($efp); - } + global $hangup_cause_dictionary; + if ( array_key_exists($code,$hangup_cause_dictionary) ) { return $hangup_cause_dictionary[$code]; } + else { return "Unidentified Hangup Cause Code."; } } -$one_mysql_log=0; -return $errno; -} + ?> diff --git a/agc_2-X/trunk/LANG_www/agc_es/vicidial.php b/agc_2-X/trunk/LANG_www/agc_es/vicidial.php index 33ca8677..f1039201 100644 --- a/agc_2-X/trunk/LANG_www/agc_es/vicidial.php +++ b/agc_2-X/trunk/LANG_www/agc_es/vicidial.php @@ -1,7 +1,7 @@ LICENSE: AGPLv2 +# Copyright (C) 2011 Matt Florell LICENSE: AGPLv2 # # Other scripts that this application depends on: # - vdc_db_query.php: Updates information in the database @@ -320,12 +320,35 @@ # 101008-0356 - Added manual_preview_dial and two new variables for recording filenames # 101012-1656 - Added scroll command at dispo submission to for scrolling to the top of the screen # 101024-1639 - Added parked call counter +# 101108-0110 - Added ADDMEMBER option for queue_log +# 101124-0436 - Added manual dial queue and manual dial call time check features +# 101125-2151 - Changed CIDname for 3way calls +# 101128-0102 - Added list webform override options +# 101207-1621 - Added scroll to the top after in-group, pause code, etc... selections, and added focus blur to several functions +# 101208-1210 - Fixed focus/blur coding to work after Dispo +# 101216-1758 - Added the ability to hide fields if the label is set to ---HIDE--- in System Settings +# 101227-1645 - Added dialplan off toggle options, and settings and code changes for top bar webphone +# 110109-1205 - Added queuemetrics_loginout NONE option +# 110112-1254 - Added options.php option for focus/blur/enter functions +# 110129-1050 - Changed to XHTML compliant formatting, issue #444 +# 110208-1202 - Made scheduled callbacks notice move when on script/form tabs +# 110212-2206 - Added scheduled callback custom statuses compatibility +# 110215-1412 - Added my_callback_option and per_call_notes options +# 110218-1522 - Added agent_lead_search feature +# 110221-1251 - Changed statuses display to keep track of non-selectable statuses +# 110224-1713 - Added compatibility with QM phone environment logging, QM pause code last call logging and active server twin check +# 110225-1231 - Changed scheduled callbacks list to allow clicking to see lead info without dialing, and separate dial link +# 110303-2321 - Added notice of on-hook phone use, and ability to click 'ring' to call into session, minor queue_log fix +# 110304-1623 - Added callback count notification defer options +# 110310-0331 - Added auto-pause/resume functions in auto-dial mode for pre-call work +# 110310-1627 - Changed most browser alerts to HTML alerts, other bug fixes +# 110322-0923 - Allowed hiding of gender pulldown # -$version = '2.4-297'; -$build = '101024-1639'; +$version = '2.4-320c'; +$build = '110322-0923'; $mel=1; # Mysql Error Log enabled = 1 -$mysql_log_count=68; +$mysql_log_count=72; $one_mysql_log=0; require("dbconnect.php"); @@ -400,6 +423,8 @@ $month_old = mktime(11, 0, 0, date("m"), date("d")-2, date("Y")); $past_month_date = date("Y-m-d H:i:s",$month_old); $minutes_old = mktime(date("H"), date("i")-2, date("s"), date("m"), date("d"), date("Y")); $past_minutes_date = date("Y-m-d H:i:s",$minutes_old); +$webphone_width = 460; +$webphone_height = 500; $random = (rand(1000000, 9999999) + 10000000); @@ -435,52 +460,57 @@ if ($qm_conf_ct > 0) ##### DEFINABLE SETTINGS AND OPTIONS ########################################### +# set defaults for hard-coded variables +$conf_silent_prefix = '5'; # vicidial_conferences prefix to enter silently and muted for recording +$dtmf_silent_prefix = '7'; # vicidial_conferences prefix to enter silently +$HKuser_level = '5'; # minimum vicidial user_level for HotKeys +$campaign_login_list = '1'; # show drop-down list of campaigns at login +$manual_dial_preview = '1'; # allow preview lead option when manual dial +$multi_line_comments = '1'; # set to 1 to allow multi-line comment box +$user_login_first = '0'; # set to 1 to have the vicidial_user login before the phone login +$view_scripts = '1'; # set to 1 to show the SCRIPTS tab +$dispo_check_all_pause = '0'; # set to 1 to allow for persistent pause after dispo +$callholdstatus = '1'; # set to 1 to show calls en hold count +$agentcallsstatus = '0'; # set to 1 to show agent status and call dialed count + $campagentstatctmax = '3'; # Number of segundos for campaign call and agent stats +$show_campname_pulldown = '1'; # set to 1 to show campaign name en login pulldown +$webform_sessionname = '1'; # set to 1 to include the session_name in webform URL +$local_consult_xfers = '1'; # set to 1 to send consultative transfers from original server +$clientDST = '1'; # set to 1 to check for DST en server for agent time +$no_delete_sessions = '1'; # set to 1 to not delete sessions at logout +$volumecontrol_active = '1'; # set to 1 to allow agents to alter volume of channels +$PreseT_DiaL_LinKs = '0'; # set to 1 to show a DIAL link for Dial Presets +$LogiNAJAX = '1'; # set to 1 to do lookups en campaigns for login +$HidEMonitoRSessionS = '1'; # set to 1 to hide remote monitoring channels from "session calls" +$hangup_all_non_reserved= '1'; # set to 1 to force hangup all non-reserved channels upon Colgar al Cliente +$LogouTKicKAlL = '1'; # set to 1 to hangup all calls in session upon agent logout +$PhonESComPIP = '1'; # set to 1 to log computer IP to phone if blank, set to 2 to force log each login +$DefaulTAlTDiaL = '0'; # set to 1 to enable ALT DIAL by default if enabled for the campaign +$AgentAlert_allowed = '1'; # set to 1 to allow Agent alert option +$disable_blended_checkbox='0'; # set to 1 to disable the BLENDED checkbox from the in-group chooser screen +$hide_timeclock_link = '0'; # set to 1 to hide the timeclock link en the agent login screen +$conf_check_attempts = '3'; # number of attempts to try before loosing webserver connection, for bad network setups +$focus_blur_enabled = '0'; # set to 1 to enable the focus/blur enter key blocking(some IE instances have issues) +$TEST_all_statuses = '0'; # TEST variable allows all statuses in dispo screen + +$stretch_dimensions = '1'; # sets the vicidial screen to the size of the browser window +$BROWSER_HEIGHT = 500; # set to the minimum browser height, default=500 +$BROWSER_WIDTH = 770; # set to the minimum browser width, default=770 +$webphone_width = 460; # set the webphone frame width +$webphone_height = 500; # set the webphone frame height +$webphone_pad = 0; # set the table cellpadding for the webphone +$webphone_location = 'right'; # set the location en the agent screen 'right' or 'bar' +$MAIN_COLOR = '#CCCCCC'; # old default is E0C2D6 +$SCRIPT_COLOR = '#E6E6E6'; # old default is FFE7D0 +$FORM_COLOR = '#EFEFEF'; +$SIDEBAR_COLOR = '#F6F6F6'; + +# if options file exists, use the override values for the above variables +# see the options-example.php file for more information if (file_exists('options.php')) { require('options.php'); } -else - { - $conf_silent_prefix = '5'; # vicidial_conferences prefix to enter silently and muted for recording - $dtmf_silent_prefix = '7'; # vicidial_conferences prefix to enter silently - $HKuser_level = '5'; # minimum vicidial user_level for HotKeys - $campaign_login_list = '1'; # show drop-down list of campaigns at login - $manual_dial_preview = '1'; # allow preview lead option when manual dial - $multi_line_comments = '1'; # set to 1 to allow multi-line comment box - $user_login_first = '0'; # set to 1 to have the vicidial_user login before the phone login - $view_scripts = '1'; # set to 1 to show the SCRIPTS tab - $dispo_check_all_pause = '0'; # set to 1 to allow for persistent pause after dispo - $callholdstatus = '1'; # set to 1 to show calls en hold count - $agentcallsstatus = '0'; # set to 1 to show agent status and call dialed count - $campagentstatctmax = '3'; # Number of segundos for campaign call and agent stats - $show_campname_pulldown = '1'; # set to 1 to show campaign name en login pulldown - $webform_sessionname = '1'; # set to 1 to include the session_name in webform URL - $local_consult_xfers = '1'; # set to 1 to send consultative transfers from original server - $clientDST = '1'; # set to 1 to check for DST en server for agent time - $no_delete_sessions = '1'; # set to 1 to not delete sessions at logout - $volumecontrol_active = '1'; # set to 1 to allow agents to alter volume of channels - $PreseT_DiaL_LinKs = '0'; # set to 1 to show a DIAL link for Dial Presets - $LogiNAJAX = '1'; # set to 1 to do lookups en campaigns for login - $HidEMonitoRSessionS = '1'; # set to 1 to hide remote monitoring channels from "session calls" - $hangup_all_non_reserved= '1'; # set to 1 to force hangup all non-reserved channels upon Colgar al Cliente - $LogouTKicKAlL = '1'; # set to 1 to hangup all calls in session upon agent logout - $PhonESComPIP = '1'; # set to 1 to log computer IP to phone if blank, set to 2 to force log each login - $DefaulTAlTDiaL = '0'; # set to 1 to enable ALT DIAL by default if enabled for the campaign - $AgentAlert_allowed = '1'; # set to 1 to allow Agent alert option - $disable_blended_checkbox='0'; # set to 1 to disable the BLENDED checkbox from the in-group chooser screen - $hide_timeclock_link = '0'; # set to 1 to hide the timeclock link en the agent login screen - $conf_check_attempts = '3'; # number of attempts to try before loosing webserver connection, for bad network setups - - $TEST_all_statuses = '0'; # TEST variable allows all statuses in dispo screen - - $stretch_dimensions = '1'; # sets the vicidial screen to the size of the browser window - $BROWSER_HEIGHT = 500; # set to the minimum browser height, default=500 - $BROWSER_WIDTH = 770; # set to the minimum browser width, default=770 - $MAIN_COLOR = '#CCCCCC'; # old default is E0C2D6 - $SCRIPT_COLOR = '#E6E6E6'; # old default is FFE7D0 - $FORM_COLOR = '#EFEFEF'; - $SIDEBAR_COLOR = '#F6F6F6'; - } ### BEGIN find any custom field labels ### $label_title = 'Título'; @@ -527,6 +557,10 @@ if (strlen($row[17])>0) {$label_email = $row[17];} if (strlen($row[18])>0) {$label_comments = $row[18];} ### END find any custom field labels ### +$hide_gender=0; +if ($label_gender == '---HIDE---') + {$hide_gender=1;} + $US='_'; $CL=':'; $AT='@'; @@ -550,14 +584,20 @@ if (strlen($static_agent_url) > 5) 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 -echo "\n"; -echo "\n"; +echo ' + + + + + + +'; echo "\n"; echo "\n"; if ($campaign_login_list > 0) { - $camp_form_code = "\n"; $camp_form_code .= "\n"; $LOGallowed_campaignsSQL=''; @@ -634,7 +674,7 @@ if ($campaign_login_list > 0) if ($VD_campaign) { if ( (eregi("$VD_campaign",$rowx[0])) and (strlen($VD_campaign) == strlen($rowx[0])) ) - {$camp_form_code .= "\n";} + {$camp_form_code .= "\n";} else { if (!ereg('login_allowable_campaigns',$camp_form_code)) @@ -652,7 +692,7 @@ if ($campaign_login_list > 0) } else { - $camp_form_code = "\n"; + $camp_form_code = "\n"; } @@ -660,29 +700,32 @@ if ($LogiNAJAX > 0) { ?> - @@ -11211,327 +11995,423 @@ else \n"; -$zi=1; +$zi=2; ?> - -
+ + + - height=>
-
-
-
-
-
-
-           Loading -
-
-
+
+
+
+
+
+
+
+           Loading +
+
+
- MARGINWIDTH=0 MARGINHEIGHT=0 LEFTMARGIN=0 TOPMARGIN=0 VALIGN=TOP ALIGN=LEFT> - +
- - - + + -
+ + + Usuario - -     - + ring)";} + echo "  a la campaña: $VD_campaign  \n"; + ?> +     + 0) {echo "TERRITORIES     \n";} ?> 0) {echo "GROUPS     \n";} ?> SALIR\n"; ?> -
+
- height=30> - - - +
MAINSCRIPT
+ + + 0) - {echo "\n";} + {echo "\n";} ?> - - - -
MAINSCRIPT \"FORM\"\"FORM\" VALIGN=MIDDLE ALIGN=CENTER>  LIVE   session ID:    Llamada Activa
+   LIVE   session ID:     + Llamada Activa + +
- height=>

Agent Screen
+

Agent Screen
- id="MainTable"> - - - - - - -
ESTADO:
+ + + + - +
+
\n"; + } + ?> + ESTADO:
- Marcar el Siguiente Número
- MOSTRAR LEAD
- TELÉFONO DEL ALT
+ Marcar el Siguiente Número
+ + + MOSTRAR LEAD
+ TELÉFONO DEL ALT
- GRABANDO ARCHIVO:
+ GRABANDO ARCHIVO:
-
- GRABACIÓN ID:
+
+ GRABACIÓN ID:
- Comenzar La Grabación
-
- Formulario Web
+ Comenzar La Grabación
+
+ Formulario Web
0) - {echo "\"Formulario
\n";} + {echo "\"Formulario
\n";} ?> -  
- Aparcar llamada
+  
+ Aparcar llamada
\"IVR
\n";} + {echo "\"IVR
\n";} else - {echo "\n";} + {echo "\n";} ?> - Transferencia - Conferencia
+ Transferencia - Conferencia
0) - {echo "\"Quick
\n";} + {echo "\"Quick
\n";} ?> 0) - {echo "
\n";} + {echo "
\n";} ?> -
- Colgar al Cliente
-
-
Enviar DTMF

+
+ Colgar al Cliente
+
+
Enviar DTMF

align=left valign=top> - - - - - - - - - - - - - + + + + + + + + + + + + + + - - - +
  Customer Time:                         Canal:
+ + - + -
  Customer Time:                         Canal:
Información Del Cliente: Información Del Cliente:         + LEAD SEARCH";} + ?> +
+ + + + -
+ ";} + else + {echo "$label_title: ";} + if ($label_first_name == '---HIDE---') + {echo "  ";} + else + {echo "  $label_first_name: ";} + if ($label_middle_initial == '---HIDE---') + {echo "  ";} + else + {echo "  $label_middle_initial: ";} + if ($label_last_name == '---HIDE---') + {echo "  ";} + else + {echo "  $label_last_name: ";} + + echo "
"; + + if ($label_address1 == '---HIDE---') + {echo " ";} + else + {echo "$label_address1: ";} + + echo "
"; + + if ($label_address2 == '---HIDE---') + {echo " ";} + else + {echo "$label_address2: ";} + + echo ""; + + if ($label_address3 == '---HIDE---') + {echo " ";} + else + {echo "$label_address3: ";} + + echo "
"; + + if ($label_city == '---HIDE---') + {echo " ";} + else + {echo "$label_city: ";} + + echo ""; + + if ($label_state == '---HIDE---') + {echo " ";} + else + {echo "$label_state: ";} + + echo ""; + + if ($label_postal_code == '---HIDE---') + {echo " ";} + else + {echo "$label_postal_code: ";} + + echo "
"; + + if ($label_province == '---HIDE---') + {echo " ";} + else + {echo "$label_province: ";} + + echo ""; + + if ($label_vendor_lead_code == '---HIDE---') + {echo " ";} + else + {echo "$label_vendor_lead_code: ";} + + echo ""; + + if ($label_gender == '---HIDE---') + { + echo ""; + } + else + { + echo "$label_gender: "; + } + + echo "
"; + + echo "$label_phone_number: "; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
:   :   :   :
:
: :
: : :
: : :
: -                     "; - echo ""; + echo "                     "; + echo ""; } else { - echo ""; + echo ""; } - ?> - : :
: :
: - - \n";} + echo ""; + + if ($label_phone_code == '---HIDE---') + {echo " ";} else - {echo "\n";} + {echo "$label_phone_code: ";} + + echo ""; + + if ($label_alt_phone == '---HIDE---') + {echo " ";} + else + {echo "$label_alt_phone: ";} + + echo "
"; + + if ($label_security_phrase == '---HIDE---') + {echo " ";} + else + {echo "$label_security_phrase: ";} + + echo ""; + + if ($label_email == '---HIDE---') + {echo " ";} + else + {echo "$label_email: ";} + + echo "
"; + + if ($label_comments == '---HIDE---') + { + echo " \n"; + } + else + { + echo "$label_comments: "; + if ( ($multi_line_comments) ) + {echo "\n";} + else + {echo "\n";} + } + + echo "
\n"; + + if ($per_call_notes == 'ENABLED') + { + echo "Call Notas:"; + if ($agent_call_log_view == '1') + {echo "
view notes ";} + echo "
"; + echo "\n"; + } + else + { + echo " \n"; + } + + ?>
+
+
> +
 
+
 
+ - +
+ -MARCADO MANUAL       DIAL RÁPIDO
-
- - -X SERVICIOS REPETIDOS ACTIVOS
+MARCADO MANUAL       DIAL RÁPIDO
-
+
-VIEW LLAMADA LOG
+VIEW LLAMADA LOG
- -     - >
Agent web-client version:     CONSTRUCCION:               Servidor:              
+ +     + - - + - +
VERSIÓN:   CONSTRUCCION:     Servidor:              
Mostrar la información del canal Conferencia -

 
+

 
+
0) ) {echo "Alert is ON";} else {echo "Alert is OFF";} ?> -
+
- -
+ +
0) && ( ($user_level>=$HKuser_level) or ($VU_hotkeys_active > 0) ) ) { ?> -TECLAS ACCESO RÁPIDO INACTIVAS +TECLAS ACCESO RÁPIDO INACTIVAS - segundos: -     + segundos: +     -
+
-Su Estado:
Calls Dialing: +Su Estado:
Calls Dialing:
- + D1 - DIAL\n"; - echo "
\n"; + echo "   \n"; echo "D2 - DIAL\n"; } - else {echo "
\n";} + else {echo "
\n";} ?> -

 
+

 
-
 Llamadas en cola:  
 
+
 Llamadas en cola:  
 
- + 0) { @@ -11543,20 +12423,35 @@ if ($view_calls_in_queue > 0) ?> -
  -Otros agentes de Estado:  
 
+ +X SERVICIOS REPETIDOS ACTIVOS
+
-
  -Web Teléfono:  
+
  +Otros agentes de Estado:  
 
-
Agents View +
+$webphone_content
\n"; + } +else + { + echo "
  + Web Teléfono:  
$webphone_content
\n"; + } +?> + + +
Agents View +
-
  WebTeléfono View -
+
  WebTeléfono View -
0) { - echo "Dialable Leads:
 \n"; + echo "Dialable Leads:
 \n"; } ?>
- - height=>
AGENT SCRIPT
+ +
\n";} + ?> +
AGENT SCRIPT
- + refresh - - height=>
+ +
\n";} + ?> +
- + refresh - > - -
+ + + -
- Transferencia - Conferencia            
+ Transferencia - Conferencia            
- - -
- + + + - - + CLOSER LOCAL     + + + - - + - - - + channel + + + + - - + - - - + AGENTES + + + + + + + - - + - + Blind Transfer VMail Message + + -
+ - CLOSER LOCAL     - - Colgar Línea Xfer -
+ Colgar Línea Xfer +
- seconds +
+ seconds   - channel - - CONSULTIVO   - - Colgar Ambas Líneas -
+ CONSULTIVO   + + Colgar Ambas Líneas +
- Número a llamar +
+ Número a llamar   -                     +                     -   +   - AGENTES - - - - - INVALIDACIÓN DEL MARCADO - - ABANDONAR LLAMADA 3-WAY -
+ INVALIDACIÓN DEL MARCADO + + ABANDONAR LLAMADA 3-WAY +
- Marcar Blind Transfer +
+ Marcar Blind Transfer   - Marcar Con El Cliente + Marcar Con El Cliente   - Dial Del Cliente Del Parque + Dial Del Cliente Del Parque   - Presets Button + Presets Button 0) } ?>   - Blind Transfer VMail Message -
+
+
-
-Agentes disponibles de transferencia:
+
+Agentes disponibles de transferencia:
- height=70> - -
Lead Dispositioned Como:

- -
-
+ + +
Lead Dispositioned Como:

+ -
+
- height=70> - +
Teclas de acceso rápido a la Disposición: + + - - + - + -
Teclas de acceso rápido a la Disposición: Cuando esté activo, presione simplemente la tecla para la disposición deseada para esta llamada. La llamada después será colgada y dispositioned automáticamente:
+ - + - + -
+
- height=70> - - - +
Información Anterior Del Servicio repetido: close
+ + + - - + -
Información Anterior Del Servicio repetido: close
-
-
-
-
+ +
+
+
+
-
+
+ - height=70> - - - +
Teléfono de Información ampliado Alt: reduzca al mínimo
+ + + - - + -
Teléfono de Información ampliado Alt: reduzca al mínimo
-
-
-
-
+
+
+
+
+
-
+
+ - - - -
maximice
Alt Teléfono Info
+ + + +
maximice
Alt Teléfono Info
- height=>
Nadie está en su sesión:
+
Nadie está en su sesión:
Vaya Detrás -

+

Agente De la Llamada Otra vez -
+
- height=>
El cliente ha colgado:
+
El cliente ha colgado:
Vaya Detrás -

+

Final y llamada de la disposición -
+
- height=>
Llamada Wrapup: segundos restantes en wrapup

+
Llamada Wrapup: segundos restantes en wrapup

-

+

Final Wrapup y movimiento encendido -
+
-
-


+
+


Cerrar Mensaje -
+
- height=>
Se ha inhabilitado su sesión
SALIR

Vaya Detrás -
+
Se ha inhabilitado su sesión
SALIR

Vaya Detrás +
- height=>
Hay un problema de sincronización de tiempo con su sistema, por favor, dígale a su administrador del sistema


Vaya Detrás -
+
Hay un problema de sincronización de tiempo con su sistema, por favor, dígale a su administrador del sistema


Vaya Detrás +
- height=>

SALIR
+

SALIR
-
+
-
 
+
 
- height=47>
Cualquier cambio realizado al cliente que no será la información abajo en este tiempo comitted, usted debe cambiar la información del cliente antes de usted retraso la llamada.
+
Cualquier cambio realizado al cliente que no será la información abajo en este tiempo comitted, usted debe cambiar la información del cliente antes de usted retraso la llamada.
- height=>
DISPOSITION LLAMADA :       Retraso Otra vez       reduzca al mínimo
+
DISPOSITION LLAMADA :       Retraso Otra vez       reduzca al mínimo
+
\n";} + ?> + + selección de la disposición del End-of-call -
- PARAR LA LLAMADA
+
+ PARAR LA LLAMADA
REINICIAR | ENVIAR -

+

WEB FORM ENVIAR -

  -
+

  +
- height=>
Seleccione una fecha del servicio repetido :
- - +
Seleccione una fecha del servicio repetido :
+
\n";} + ?> + + Seleccione una fecha abajo       Hour: - @@ -11858,7 +12771,7 @@ Agentes disponibles de transferencia: 12   Minutes: - @@ -11873,165 +12786,317 @@ Agentes disponibles de transferencia: 55   - -  
+  
MI SERVICIO REPETIDO SOLAMENTE
";} + {echo " MI SERVICIO REPETIDO SOLAMENTE
";} ?> - Comentarios de los CBES:

+ Comentarios de los CBES:

- ENVIAR

+ ENVIAR

-

  -
+

  +
- height=>
SERVICIOS REPETIDOS PARA EL AGENTE :
Chasque encendido un servicio repetido abajo ahora para llamar la parte posteriora del cliente. Si usted chasca encendido un expediente abajo para llamarlo, será quitado de la lista. -
+
SERVICIOS REPETIDOS PARA EL AGENTE :
To see information en one of the callbacks below, click en the INFO link. To call the customer back now, click en the DIAL link. If you click en a record below to dial it, it will be removed from the list. +
+
\n";} + ?>
-
  +
  Recarga                 - Vaya Detrás -
+ Vaya Detrás +
- height=>
NUEVO PLOMO MANUAL DEL DIAL PARA :

Incorpore la información abajo para el nuevo plomo que usted desea llamar. -
+
NUEVO PLOMO MANUAL DEL DIAL PARA :

Incorpore la información abajo para el nuevo plomo que usted desea llamar. +
\n"; + echo "Nota: un prefijo del dial de $manual_dial_prefix será agregado al principio de este número
\n"; } ?> - Note: all new manual dial leads will go into list

- - - + Note: all new manual dial leads will go into list

+
Dial Código:   (Éste es generalmente un 1 en los U.S.A. y el Canadá)
+ + - - + - - + + - +

Si usted desea marcar un número y hacerlo no agregar como nuevo plomo, entre en dialstring exacto ese usted desean llamar en el campo de la invalidación del dial abajo. Al retraso esta llamada usted tendrá que abrir las LLAMADAS EN ESTE acoplamiento de la SESIÓN en el fondo de la pantalla y colgarlas para arriba chascando en su acoplamiento del canal allí.
  - - + -
Dial Código:   (Éste es generalmente un 1 en los U.S.A. y el Canadá)
Teléfono Number: -   (digits only) + Teléfono Number: +   (digits only) + +
Plomos Existentes De la Búsqueda:   (Esta opción si está comprobada procurará encontrar el número de teléfono en el sistema antes de insertarlo como nuevo plomo) Plomos Existentes De la Búsqueda:   (Esta opción si está comprobada procurará encontrar el número de teléfono en el sistema antes de insertarlo como nuevo plomo)
-

+
+

   
-

Si usted desea marcar un número y hacerlo no agregar como nuevo plomo, entre en dialstring exacto ese usted desean llamar en el campo de la invalidación del dial abajo. Al retraso esta llamada usted tendrá que abrir las LLAMADAS EN ESTE acoplamiento de la SESIÓN en el fondo de la pantalla y colgarlas para arriba chascando en su acoplamiento del canal allí.
 
Inválidoación Del Dial:   (los dígitos satisfacen solamente) + Inválidoación Del Dial:   (los dígitos satisfacen solamente)
-
+
+
Dial Ahora                 Vista previa de llamada                 - Vaya Detrás -
+ Vaya Detrás +
- height=>
SELECCIÓN DEL GRUPO DE ENTRANTES CLOSER
+
SELECCIÓN DEL GRUPO DE ENTRANTES CLOSER
+
\n";} + ?> SELECCIÓN DEL GRUPO DE ENTRANTES CLOSER -
+
0) and ($disable_blended_checkbox < 1) and ($dial_method != 'INBOUND_MAN') and ($VU_agent_choose_blended > 0) ) { ?> - BLENDED LLAMADAING(Salientes activdas)
+ BLENDED LLAMADAING(Salientes activdas)
REINICIAR | ENVIAR -



  -
+



  +
- height=>
TERRITORY SELECTION
+
TERRITORY SELECTION
+
\n";} + ?> Territory Selection -
+
REINICIAR | ENVIAR -



  -
+



  +
- Canal Canal MI SERVICIO REPETIDO SOLAMENTE
";} + {echo " MI SERVICIO REPETIDO SOLAMENTE
";} if ( ($outbound_autodial_active < 1) or ($disable_blended_checkbox > 0) or ($dial_method == 'INBOUND_MAN') or ($VU_agent_choose_blended < 1) ) - {echo " BLENDED LLAMADAING
";} + {echo " BLENDED LLAMADAING
";} ?>
- height=>
AGENT LLAMADA LOG:
+
      AGENT LLAMADA LOG:             close [X]
+
\n";} + ?>
Call log List
-

  -
+

  +
+
+ + +
      SEARCH FOR A LEAD:             close [X]
+
\n";} + ?> +

+ Notas:when doing a search for a lead, the phone number, lead ID or are the best fields to use.
Using the other fields may be slower. Lead searching does not allow for wildcard or partial search terms.
Lead search requests are all logged in the system. +

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Teléfono Number:
Teléfono Number Fields: + Main Teléfono Number + Alternate Teléfono Number + Dirección3 Teléfono Number +
Lead ID:
:
:
:
:
:
:

ENVIAR SEARCH             reset form
+

  +
+
+ + +
      SEARCH RESULTS:             close [X]
+
\n";} + ?> +
Search Results
+

  +
+
+ + +
      LLAMADA NOTES LOG:             close [X]
+
\n";} + ?> +
Call Notas List
+

  + Close Info Box +
- height=>
Información Del Cliente:
+
      Información Del Cliente:             close [X] +
+
\n";} + ?> Lead Info -

  -
+

  + Close Info Box +
- height=>
SELECCIONE Un CÓDIGO De la PAUSA :
+
SELECCIONE Un CÓDIGO De la PAUSA :
+
\n";} + ?> Pausa Code Selection - -

  -
+ +

  +
- >
SELECT A PRESET :
+
SELECT A PRESET :
+
\n";} + ?> Presets Selection - -
+ +
- height=>
SELECCIONAR UN GRUPO DE ALIAS :
+
SELECCIONAR UN GRUPO DE ALIAS :
+
\n";} + ?> Grupo de Selección de Alias - -

  -
+ +

  +
- height=>
ALERT :
-     -

Vaya Detrás -
+
ALERT :
+     +

Vaya Detrás +
- + - +
+ + +
+ + + + + + +
+ +
+ + + + + +
+   Agent Alert! +
+ + + + + + +
  +

+alert +
  +

+ + Alert Box + +

+
+ +
  + +
+
+
+ +
- @@ -12040,4 +13105,4 @@ Agentes disponibles de transferencia: +?> \ No newline at end of file diff --git a/agc_2-X/trunk/LANG_www/agc_it/conf_exten_check.php b/agc_2-X/trunk/LANG_www/agc_it/conf_exten_check.php index 76fcd5f8..358626fb 100644 --- a/agc_2-X/trunk/LANG_www/agc_it/conf_exten_check.php +++ b/agc_2-X/trunk/LANG_www/agc_it/conf_exten_check.php @@ -52,17 +52,22 @@ # 100109-1337 - Fixed Manual dial live call detection # 100527-0957 - Added send_dtmf, transfer_conference and park_call API functions # 100727-2209 - Added timer actions for hangup, extension, callmenu and ingroup as well as destination +# 101123-1105 - Added api manual dial queue feature to external_dial function +# 101208-0308 - Moved the Calls in Queue count and other counts outside of the autodial section (issue 406) # -$version = '2.4-27'; -$build = '100727-2209'; +$version = '2.4-29'; +$build = '101208-0308'; $mel=1; # Mysql Error Log enabled = 1 -$mysql_log_count=32; +$mysql_log_count=36; $one_mysql_log=0; +$DB=0; require("dbconnect.php"); ### If you have globals turned off uncomment these lines +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} if (isset($_GET["user"])) {$user=$_GET["user"];} elseif (isset($_POST["user"])) {$user=$_POST["user"];} if (isset($_GET["pass"])) {$pass=$_GET["pass"];} @@ -215,7 +220,7 @@ echo " if ($Acount > 0) { - $stmt="SELECT status,callerid,agent_log_id,campaign_id from vicidial_live_agents where user='$user' and server_ip='$server_ip';"; + $stmt="SELECT status,callerid,agent_log_id,campaign_id,lead_id from vicidial_live_agents where user='$user' and server_ip='$server_ip';"; if ($DB) {echo "|$stmt|\n";} $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03004',$user,$server_ip,$session_name,$one_mysql_log);} @@ -224,6 +229,17 @@ echo " $Acallerid = $row[1]; $Aagent_log_id = $row[2]; $Acampaign_id = $row[3]; + $Alead_id = $row[4]; + + $api_manual_dial='STANDARD'; + $stmt = "SELECT api_manual_dial FROM vicidial_campaigns where campaign_id='$Acampaign_id';"; + $rslt=mysql_query($stmt, $link); + $vcc_conf_ct = mysql_num_rows($rslt); + if ($vcc_conf_ct > 0) + { + $row=mysql_fetch_row($rslt); + $api_manual_dial = $row[0]; + } } # ### find out if external table shows agent should be disabled # $stmt="SELECT count(*) from another_table where user='$user' and status='DEAD';"; @@ -232,6 +248,53 @@ echo " # $row=mysql_fetch_row($rslt); # $AexternalDEAD=$row[0]; + ##### BEGIN check su calls in queue, number of active calls in the campaign + if ($campagentstdisp == 'YES') + { + $ADsql=''; + ### grab the status of this agent to display + $stmt="SELECT status,campaign_id,closer_campaigns from vicidial_live_agents where user='$user' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03006',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $Alogin=$row[0]; + $Acampaign=$row[1]; + $AccampSQL=$row[2]; + $AccampSQL = ereg_replace(' -','', $AccampSQL); + $AccampSQL = ereg_replace(' ',"','", $AccampSQL); + if (eregi('AGENTDIRECT', $AccampSQL)) + { + $AccampSQL = ereg_replace('AGENTDIRECT','', $AccampSQL); + $ADsql = "or ( (campaign_id LIKE \"%AGENTDIRECT%\") and (agent_only='$user') )"; + } + + ### grab the number of calls being placed from this server and campaign + $stmt="SELECT count(*) from vicidial_auto_calls where status IN('LIVE') and ( (campaign_id='$Acampaign') or (campaign_id IN('$AccampSQL')) $ADsql);"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03007',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $RingCalls=$row[0]; + if ($RingCalls > 0) {$RingCalls = "Chiamate in coda: $RingCalls";} + else {$RingCalls = "Chiamate in coda: $RingCalls";} + + ### grab the number of calls being placed from this server and campaign + $stmt="SELECT count(*) from vicidial_auto_calls where status NOT IN('XFER') and ( (campaign_id='$Acampaign') or (campaign_id IN('$AccampSQL')) );"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03008',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $DiaLCalls=$row[0]; + } + else + { + $Alogin='N'; + $RingCalls='N'; + $DiaLCalls='N'; + } + ##### END check su calls in queue, number of active calls in the campaign + if ($auto_dial_level > 0) { ### update the vicidial_live_agents every second with a new random number so it is shown to be alive @@ -285,59 +348,9 @@ echo " } } ##### END DEAD logging section ##### - - if ($campagentstdisp == 'YES') - { - $ADsql=''; - ### grab the status of this agent to display - $stmt="SELECT status,campaign_id,closer_campaigns from vicidial_live_agents where user='$user' and server_ip='$server_ip';"; - if ($DB) {echo "|$stmt|\n";} - $rslt=mysql_query($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03006',$user,$server_ip,$session_name,$one_mysql_log);} - $row=mysql_fetch_row($rslt); - $Alogin=$row[0]; - $Acampaign=$row[1]; - $AccampSQL=$row[2]; - $AccampSQL = ereg_replace(' -','', $AccampSQL); - $AccampSQL = ereg_replace(' ',"','", $AccampSQL); - if (eregi('AGENTDIRECT', $AccampSQL)) - { - $AccampSQL = ereg_replace('AGENTDIRECT','', $AccampSQL); - $ADsql = "or ( (campaign_id LIKE \"%AGENTDIRECT%\") and (agent_only='$user') )"; - } - - ### grab the number of calls being placed from this server and campaign - $stmt="SELECT count(*) from vicidial_auto_calls where status IN('LIVE') and ( (campaign_id='$Acampaign') or (campaign_id IN('$AccampSQL')) $ADsql);"; - if ($DB) {echo "|$stmt|\n";} - $rslt=mysql_query($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03007',$user,$server_ip,$session_name,$one_mysql_log);} - $row=mysql_fetch_row($rslt); - $RingCalls=$row[0]; - if ($RingCalls > 0) {$RingCalls = "Chiamate in coda: $RingCalls";} - else {$RingCalls = "Chiamate in coda: $RingCalls";} - - ### grab the number of calls being placed from this server and campaign - $stmt="SELECT count(*) from vicidial_auto_calls where status NOT IN('XFER') and ( (campaign_id='$Acampaign') or (campaign_id IN('$AccampSQL')) );"; - if ($DB) {echo "|$stmt|\n";} - $rslt=mysql_query($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03008',$user,$server_ip,$session_name,$one_mysql_log);} - $row=mysql_fetch_row($rslt); - $DiaLCalls=$row[0]; - - } - else - { - $Alogin='N'; - $RingCalls='N'; - $DiaLCalls='N'; - } } else { - $Alogin='N'; - $RingCalls='N'; - $DiaLCalls='N'; - ### update the vicidial_live_agents every second with a new random number so it is shown to be alive $stmt="UPDATE vicidial_live_agents set random_id='$random' where user='$user' and server_ip='$server_ip';"; if ($format=='debug') {echo "\n";} @@ -410,6 +423,52 @@ echo " $external_park = $row[11]; $timer_action_destination = $row[12]; + $MDQ_count=0; + if ( ($api_manual_dial=='QUEUE') or ($api_manual_dial=='QUEUE_AND_AUTOCALL') ) + { + $stmt="SELECT count(*) FROM vicidial_manual_dial_queue where user='$user' and status='READY';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03033',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $mdq_count_record_ct = mysql_num_rows($rslt); + if ($mdq_count_record_ct > 0) + { + $row=mysql_fetch_row($rslt); + $MDQ_count = $row[0]; + } + + if ( ($MDQ_count > 0) and (strlen($external_dial) < 16) and ($Astatus=='PAUSED') and ($Alead_id < 1) ) + { + $stmt="SELECT mdq_id,external_dial FROM vicidial_manual_dial_queue where user='$user' and status='READY' order by entry_time limit 1;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03034',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $mdq_record_ct = mysql_num_rows($rslt); + if ($mdq_record_ct > 0) + { + $row=mysql_fetch_row($rslt); + $MDQ_mdq_id = $row[0]; + $MDQ_external_dial = $row[1]; + $external_dial = $MDQ_external_dial; + + $stmt="UPDATE vicidial_manual_dial_queue SET status='QUEUE' where mdq_id='$MDQ_mdq_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03035',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $UMDQaffected_rows_update = mysql_affected_rows($link); + + if ($UMDQaffected_rows_update > 0) + { + $stmt="UPDATE vicidial_live_agents SET external_dial='$MDQ_external_dial' where user='$user' and server_ip='$server_ip';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03036',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $VLAMDQaffected_rows_update = mysql_affected_rows($link); + } + } + } + } + if (strlen($external_status)<1) {$external_status = '::::::::::';} $web_epoch = date("U"); @@ -578,7 +637,7 @@ echo " if ($Ashift_logout > 0) {$Alogin='SHIFT_LOGOUT';} - echo 'DateTime: ' . $NOW_TIME . '|UnixTime: ' . $StarTtime . '|Logged-in: ' . $Alogin . '|CampCalls: ' . $RingCalls . '|Stato: ' . $Astatus . '|DiaLCalls: ' . $DiaLCalls . '|APIHanguP: ' . $external_hangup . '|APIStatuS: ' . $external_status . '|APIPausE: ' . $external_pause . '|APIDiaL: ' . $external_dial . '|DEADcall: ' . $DEADcustomer . '|InGroupChange: ' . $InGroupChangeDetails . '|APIFields: ' . $external_update_fields . '|APIFieldsData: ' . $external_update_fields_data . '|APITimerAction: ' . $timer_action . '|APITimerMessage: ' . $timer_action_message . '|APITimerSeconds: ' . $timer_action_seconds . '|APIdtmf: ' . $external_dtmf . '|APItransferconf: ' . $external_transferconf . '|APIpark: ' . $external_park . '|APITimerDestination: ' . $timer_action_destination . "\n"; + echo 'DateTime: ' . $NOW_TIME . '|UnixTime: ' . $StarTtime . '|Logged-in: ' . $Alogin . '|CampCalls: ' . $RingCalls . '|Stato: ' . $Astatus . '|DiaLCalls: ' . $DiaLCalls . '|APIHanguP: ' . $external_hangup . '|APIStatuS: ' . $external_status . '|APIPausE: ' . $external_pause . '|APIDiaL: ' . $external_dial . '|DEADcall: ' . $DEADcustomer . '|InGroupChange: ' . $InGroupChangeDetails . '|APIFields: ' . $external_update_fields . '|APIFieldsData: ' . $external_update_fields_data . '|APITimerAction: ' . $timer_action . '|APITimerMessage: ' . $timer_action_message . '|APITimerSeconds: ' . $timer_action_seconds . '|APIdtmf: ' . $external_dtmf . '|APItransferconf: ' . $external_transferconf . '|APIpark: ' . $external_park . '|APITimerDestination: ' . $timer_action_destination . '|APIManualDialQueue: ' . $MDQ_count . "\n"; if (strlen($timer_action) > 3) { diff --git a/agc_2-X/trunk/LANG_www/agc_it/css/custom.css b/agc_2-X/trunk/LANG_www/agc_it/css/custom.css new file mode 100644 index 00000000..8d1c8b69 --- /dev/null +++ b/agc_2-X/trunk/LANG_www/agc_it/css/custom.css @@ -0,0 +1 @@ + diff --git a/agc_2-X/trunk/LANG_www/agc_it/css/style.css b/agc_2-X/trunk/LANG_www/agc_it/css/style.css new file mode 100644 index 00000000..2e30a009 --- /dev/null +++ b/agc_2-X/trunk/LANG_www/agc_it/css/style.css @@ -0,0 +1,26 @@ +/* /!\ 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; } diff --git a/agc_2-X/trunk/LANG_www/agc_it/functions.php b/agc_2-X/trunk/LANG_www/agc_it/functions.php index 9af6831b..12fd19a6 100644 --- a/agc_2-X/trunk/LANG_www/agc_it/functions.php +++ b/agc_2-X/trunk/LANG_www/agc_it/functions.php @@ -9,6 +9,7 @@ # # CHANGES: # 100629-1201 - First Build +# 101124-0625 - Added lookup_gmt and dialable_gmt functions # @@ -496,6 +497,902 @@ function custom_list_fields_values($lead_id,$list_id,$uniqueid,$user) +##### LOOKUP GMT, FINDS THE CURRENT GMT OFFSET FOR A PHONE NUMBER ##### + +function lookup_gmt($phone_code,$USarea,$state,$LOCAL_GMT_OFF_STD,$Shour,$Smin,$Ssec,$Smon,$Smday,$Syear,$postalgmt,$postal_code) + { + require("dbconnect.php"); + + $postalgmt_found=0; + if ( (eregi("POSTAL",$postalgmt)) && (strlen($postal_code)>4) ) + { + if (preg_match('/^1$/', $phone_code)) + { + $stmt="select postal_code,state,GMT_offset,DST,DST_range,country,country_code from vicidial_postal_codes where country_code='$phone_code' and postal_code LIKE \"$postal_code%\";"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $row=mysql_fetch_row($rslt); + $gmt_offset = $row[2]; $gmt_offset = eregi_replace("\+","",$gmt_offset); + $dst = $row[3]; + $dst_range = $row[4]; + $PC_processed++; + $postalgmt_found++; + $post++; + } + } + } + if ($postalgmt_found < 1) + { + $PC_processed=0; + ### UNITED STATES ### + if ($phone_code =='1') + { + $stmt="select country_code,country,areacode,state,GMT_offset,DST,DST_range,geographic_description from vicidial_phone_codes where country_code='$phone_code' and areacode='$USarea';"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $row=mysql_fetch_row($rslt); + $gmt_offset = $row[4]; $gmt_offset = eregi_replace("\+","",$gmt_offset); + $dst = $row[5]; + $dst_range = $row[6]; + $PC_processed++; + } + } + ### MEXICO ### + if ($phone_code =='52') + { + $stmt="select country_code,country,areacode,state,GMT_offset,DST,DST_range,geographic_description from vicidial_phone_codes where country_code='$phone_code' and areacode='$USarea';"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $row=mysql_fetch_row($rslt); + $gmt_offset = $row[4]; $gmt_offset = eregi_replace("\+","",$gmt_offset); + $dst = $row[5]; + $dst_range = $row[6]; + $PC_processed++; + } + } + ### AUSTRALIA ### + if ($phone_code =='61') + { + $stmt="select country_code,country,areacode,state,GMT_offset,DST,DST_range,geographic_description from vicidial_phone_codes where country_code='$phone_code' and state='$state';"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $row=mysql_fetch_row($rslt); + $gmt_offset = $row[4]; $gmt_offset = eregi_replace("\+","",$gmt_offset); + $dst = $row[5]; + $dst_range = $row[6]; + $PC_processed++; + } + } + ### ALL OTHER COUNTRY CODES ### + if (!$PC_processed) + { + $PC_processed++; + $stmt="select country_code,country,areacode,state,GMT_offset,DST,DST_range,geographic_description from vicidial_phone_codes where country_code='$phone_code';"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $row=mysql_fetch_row($rslt); + $gmt_offset = $row[4]; $gmt_offset = eregi_replace("\+","",$gmt_offset); + $dst = $row[5]; + $dst_range = $row[6]; + $PC_processed++; + } + } + } + + ### Find out if DST to raise the gmt offset ### + $AC_GMT_diff = ($gmt_offset - $LOCAL_GMT_OFF_STD); + $AC_localtime = mktime(($Shour + $AC_GMT_diff), $Smin, $Ssec, $Smon, $Smday, $Syear); + $hour = date("H",$AC_localtime); + $min = date("i",$AC_localtime); + $sec = date("s",$AC_localtime); + $mon = date("m",$AC_localtime); + $mday = date("d",$AC_localtime); + $wday = date("w",$AC_localtime); + $year = date("Y",$AC_localtime); + $dsec = ( ( ($hour * 3600) + ($min * 60) ) + $sec ); + + $AC_processed=0; + if ( (!$AC_processed) and ($dst_range == 'SSM-FSN') ) + { + if ($DBX) {print " Second Sunday March to First Sunday November\n";} + #********************************************************************** + # SSM-FSN + # This is returns 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on Second Sunday March to First Sunday November at 2 am. + # INPUTS: + # mm INTEGER Month. + # dd INTEGER Day of the month. + # ns INTEGER Seconds into the day. + # dow INTEGER Day of week (0=Sunday, to 6=Saturday) + # OPTIONAL INPUT: + # timezone INTEGER hour difference UTC - local standard time + # (DEFAULT is blank) + # make calculations based on UTC time, + # which means shift at 10:00 UTC in April + # and 9:00 UTC in October + # OUTPUT: + # INTEGER 1 = DST, 0 = not DST + # + # S M T W T F S + # 1 2 3 4 5 6 7 + # 8 9 10 11 12 13 14 + #15 16 17 18 19 20 21 + #22 23 24 25 26 27 28 + #29 30 31 + # + # S M T W T F S + # 1 2 3 4 5 6 + # 7 8 9 10 11 12 13 + #14 15 16 17 18 19 20 + #21 22 23 24 25 26 27 + #28 29 30 31 + # + #********************************************************************** + + $USACAN_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 11) { + $USACAN_DST=0; + } elseif ($mm >= 4 and $mm <= 10) { + $USACAN_DST=1; + } elseif ($mm == 3) { + if ($dd > 13) { + $USACAN_DST=1; + } elseif ($dd >= ($dow+8)) { + if ($timezone) { + if ($dow == 0 and $ns < (7200+$timezone*3600)) { + $USACAN_DST=0; + } else { + $USACAN_DST=1; + } + } else { + if ($dow == 0 and $ns < 7200) { + $USACAN_DST=0; + } else { + $USACAN_DST=1; + } + } + } else { + $USACAN_DST=0; + } + } elseif ($mm == 11) { + if ($dd > 7) { + $USACAN_DST=0; + } elseif ($dd < ($dow+1)) { + $USACAN_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (7200+($timezone-1)*3600)) { + $USACAN_DST=1; + } else { + $USACAN_DST=0; + } + } else { # local time calculations + if ($ns < 7200) { + $USACAN_DST=1; + } else { + $USACAN_DST=0; + } + } + } else { + $USACAN_DST=0; + } + } # end of month checks + if ($DBX) {print " DST: $USACAN_DST\n";} + if ($USACAN_DST) {$gmt_offset++;} + $AC_processed++; + } + + if ( (!$AC_processed) and ($dst_range == 'FSA-LSO') ) + { + if ($DBX) {print " First Sunday April to Last Sunday October\n";} + #********************************************************************** + # FSA-LSO + # This is returns 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on first Sunday in April and last Sunday in October at 2 am. + #********************************************************************** + + $USA_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 4 || $mm > 10) { + $USA_DST=0; + } elseif ($mm >= 5 and $mm <= 9) { + $USA_DST=1; + } elseif ($mm == 4) { + if ($dd > 7) { + $USA_DST=1; + } elseif ($dd >= ($dow+1)) { + if ($timezone) { + if ($dow == 0 and $ns < (7200+$timezone*3600)) { + $USA_DST=0; + } else { + $USA_DST=1; + } + } else { + if ($dow == 0 and $ns < 7200) { + $USA_DST=0; + } else { + $USA_DST=1; + } + } + } else { + $USA_DST=0; + } + } elseif ($mm == 10) { + if ($dd < 25) { + $USA_DST=1; + } elseif ($dd < ($dow+25)) { + $USA_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (7200+($timezone-1)*3600)) { + $USA_DST=1; + } else { + $USA_DST=0; + } + } else { # local time calculations + if ($ns < 7200) { + $USA_DST=1; + } else { + $USA_DST=0; + } + } + } else { + $USA_DST=0; + } + } # end of month checks + + if ($DBX) {print " DST: $USA_DST\n";} + if ($USA_DST) {$gmt_offset++;} + $AC_processed++; + } + + if ( (!$AC_processed) and ($dst_range == 'LSM-LSO') ) + { + if ($DBX) {print " Last Sunday March to Last Sunday October\n";} + #********************************************************************** + # This is s 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on last Sunday in March and last Sunday in October at 1 am. + #********************************************************************** + + $GBR_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $GBR_DST=0; + } elseif ($mm >= 4 and $mm <= 9) { + $GBR_DST=1; + } elseif ($mm == 3) { + if ($dd < 25) { + $GBR_DST=0; + } elseif ($dd < ($dow+25)) { + $GBR_DST=0; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $GBR_DST=0; + } else { + $GBR_DST=1; + } + } else { # local time calculations + if ($ns < 3600) { + $GBR_DST=0; + } else { + $GBR_DST=1; + } + } + } else { + $GBR_DST=1; + } + } elseif ($mm == 10) { + if ($dd < 25) { + $GBR_DST=1; + } elseif ($dd < ($dow+25)) { + $GBR_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $GBR_DST=1; + } else { + $GBR_DST=0; + } + } else { # local time calculations + if ($ns < 3600) { + $GBR_DST=1; + } else { + $GBR_DST=0; + } + } + } else { + $GBR_DST=0; + } + } # end of month checks + if ($DBX) {print " DST: $GBR_DST\n";} + if ($GBR_DST) {$gmt_offset++;} + $AC_processed++; + } + if ( (!$AC_processed) and ($dst_range == 'LSO-LSM') ) + { + if ($DBX) {print " Last Sunday October to Last Sunday March\n";} + #********************************************************************** + # This is s 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on last Sunday in October and last Sunday in March at 1 am. + #********************************************************************** + + $AUS_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $AUS_DST=1; + } elseif ($mm >= 4 and $mm <= 9) { + $AUS_DST=0; + } elseif ($mm == 3) { + if ($dd < 25) { + $AUS_DST=1; + } elseif ($dd < ($dow+25)) { + $AUS_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $AUS_DST=1; + } else { + $AUS_DST=0; + } + } else { # local time calculations + if ($ns < 3600) { + $AUS_DST=1; + } else { + $AUS_DST=0; + } + } + } else { + $AUS_DST=0; + } + } elseif ($mm == 10) { + if ($dd < 25) { + $AUS_DST=0; + } elseif ($dd < ($dow+25)) { + $AUS_DST=0; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $AUS_DST=0; + } else { + $AUS_DST=1; + } + } else { # local time calculations + if ($ns < 3600) { + $AUS_DST=0; + } else { + $AUS_DST=1; + } + } + } else { + $AUS_DST=1; + } + } # end of month checks + if ($DBX) {print " DST: $AUS_DST\n";} + if ($AUS_DST) {$gmt_offset++;} + $AC_processed++; + } + + if ( (!$AC_processed) and ($dst_range == 'FSO-LSM') ) + { + if ($DBX) {print " First Sunday October to Last Sunday March\n";} + #********************************************************************** + # TASMANIA ONLY + # This is s 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on first Sunday in October and last Sunday in March at 1 am. + #********************************************************************** + + $AUST_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $AUST_DST=1; + } elseif ($mm >= 4 and $mm <= 9) { + $AUST_DST=0; + } elseif ($mm == 3) { + if ($dd < 25) { + $AUST_DST=1; + } elseif ($dd < ($dow+25)) { + $AUST_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $AUST_DST=1; + } else { + $AUST_DST=0; + } + } else { # local time calculations + if ($ns < 3600) { + $AUST_DST=1; + } else { + $AUST_DST=0; + } + } + } else { + $AUST_DST=0; + } + } elseif ($mm == 10) { + if ($dd > 7) { + $AUST_DST=1; + } elseif ($dd >= ($dow+1)) { + if ($timezone) { + if ($dow == 0 and $ns < (7200+$timezone*3600)) { + $AUST_DST=0; + } else { + $AUST_DST=1; + } + } else { + if ($dow == 0 and $ns < 3600) { + $AUST_DST=0; + } else { + $AUST_DST=1; + } + } + } else { + $AUST_DST=0; + } + } # end of month checks + if ($DBX) {print " DST: $AUST_DST\n";} + if ($AUST_DST) {$gmt_offset++;} + $AC_processed++; + } + + if ( (!$AC_processed) and ($dst_range == 'FSO-FSA') ) + { + if ($DBX) {print " Sunday in October to First Sunday in April\n";} + #********************************************************************** + # FSO-FSA + # 2008+ AUSTRALIA ONLY (country code 61) + # This is returns 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on first Sunday in October and first Sunday in April at 1 am. + #********************************************************************** + + $AUSE_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 4 or $mm > 10) { + $AUSE_DST=1; + } elseif ($mm >= 5 and $mm <= 9) { + $AUSE_DST=0; + } elseif ($mm == 4) { + if ($dd > 7) { + $AUSE_DST=0; + } elseif ($dd >= ($dow+1)) { + if ($timezone) { + if ($dow == 0 and $ns < (3600+$timezone*3600)) { + $AUSE_DST=1; + } else { + $AUSE_DST=0; + } + } else { + if ($dow == 0 and $ns < 7200) { + $AUSE_DST=1; + } else { + $AUSE_DST=0; + } + } + } else { + $AUSE_DST=1; + } + } elseif ($mm == 10) { + if ($dd >= 8) { + $AUSE_DST=1; + } elseif ($dd >= ($dow+1)) { + if ($timezone) { + if ($dow == 0 and $ns < (7200+$timezone*3600)) { + $AUSE_DST=0; + } else { + $AUSE_DST=1; + } + } else { + if ($dow == 0 and $ns < 3600) { + $AUSE_DST=0; + } else { + $AUSE_DST=1; + } + } + } else { + $AUSE_DST=0; + } + } # end of month checks + if ($DBX) {print " DST: $AUSE_DST\n";} + if ($AUSE_DST) {$gmt_offset++;} + $AC_processed++; + } + + if ( (!$AC_processed) and ($dst_range == 'FSO-TSM') ) + { + if ($DBX) {print " First Sunday October to Third Sunday March\n";} + #********************************************************************** + # This is s 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on first Sunday in October and third Sunday in March at 1 am. + #********************************************************************** + + $NZL_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $NZL_DST=1; + } elseif ($mm >= 4 and $mm <= 9) { + $NZL_DST=0; + } elseif ($mm == 3) { + if ($dd < 14) { + $NZL_DST=1; + } elseif ($dd < ($dow+14)) { + $NZL_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $NZL_DST=1; + } else { + $NZL_DST=0; + } + } else { # local time calculations + if ($ns < 3600) { + $NZL_DST=1; + } else { + $NZL_DST=0; + } + } + } else { + $NZL_DST=0; + } + } elseif ($mm == 10) { + if ($dd > 7) { + $NZL_DST=1; + } elseif ($dd >= ($dow+1)) { + if ($timezone) { + if ($dow == 0 and $ns < (7200+$timezone*3600)) { + $NZL_DST=0; + } else { + $NZL_DST=1; + } + } else { + if ($dow == 0 and $ns < 3600) { + $NZL_DST=0; + } else { + $NZL_DST=1; + } + } + } else { + $NZL_DST=0; + } + } # end of month checks + if ($DBX) {print " DST: $NZL_DST\n";} + if ($NZL_DST) {$gmt_offset++;} + $AC_processed++; + } + + if ( (!$AC_processed) and ($dst_range == 'LSS-FSA') ) + { + if ($DBX) {print " Last Sunday in September to First Sunday in April\n";} + #********************************************************************** + # LSS-FSA + # 2007+ NEW ZEALAND (country code 64) + # This is returns 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on last Sunday in September and first Sunday in April at 1 am. + #********************************************************************** + + $NZLN_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 4 || $mm > 9) { + $NZLN_DST=1; + } elseif ($mm >= 5 && $mm <= 9) { + $NZLN_DST=0; + } elseif ($mm == 4) { + if ($dd > 7) { + $NZLN_DST=0; + } elseif ($dd >= ($dow+1)) { + if ($timezone) { + if ($dow == 0 && $ns < (3600+$timezone*3600)) { + $NZLN_DST=1; + } else { + $NZLN_DST=0; + } + } else { + if ($dow == 0 && $ns < 7200) { + $NZLN_DST=1; + } else { + $NZLN_DST=0; + } + } + } else { + $NZLN_DST=1; + } + } elseif ($mm == 9) { + if ($dd < 25) { + $NZLN_DST=0; + } elseif ($dd < ($dow+25)) { + $NZLN_DST=0; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $NZLN_DST=0; + } else { + $NZLN_DST=1; + } + } else { # local time calculations + if ($ns < 3600) { + $NZLN_DST=0; + } else { + $NZLN_DST=1; + } + } + } else { + $NZLN_DST=1; + } + } # end of month checks + if ($DBX) {print " DST: $NZLN_DST\n";} + if ($NZLN_DST) {$gmt_offset++;} + $AC_processed++; + } + + if ( (!$AC_processed) and ($dst_range == 'TSO-LSF') ) + { + if ($DBX) {print " Third Sunday October to Last Sunday February\n";} + #********************************************************************** + # TSO-LSF + # This is returns 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. Brazil + # Based on Third Sunday October to Last Sunday February at 1 am. + #********************************************************************** + + $BZL_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 2 || $mm > 10) { + $BZL_DST=1; + } elseif ($mm >= 3 and $mm <= 9) { + $BZL_DST=0; + } elseif ($mm == 2) { + if ($dd < 22) { + $BZL_DST=1; + } elseif ($dd < ($dow+22)) { + $BZL_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $BZL_DST=1; + } else { + $BZL_DST=0; + } + } else { # local time calculations + if ($ns < 3600) { + $BZL_DST=1; + } else { + $BZL_DST=0; + } + } + } else { + $BZL_DST=0; + } + } elseif ($mm == 10) { + if ($dd < 22) { + $BZL_DST=0; + } elseif ($dd < ($dow+22)) { + $BZL_DST=0; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $BZL_DST=0; + } else { + $BZL_DST=1; + } + } else { # local time calculations + if ($ns < 3600) { + $BZL_DST=0; + } else { + $BZL_DST=1; + } + } + } else { + $BZL_DST=1; + } + } # end of month checks + if ($DBX) {print " DST: $BZL_DST\n";} + if ($BZL_DST) {$gmt_offset++;} + $AC_processed++; + } + + if (!$AC_processed) + { + if ($DBX) {print " No DST Method Found\n";} + if ($DBX) {print " DST: 0\n";} + $AC_processed++; + } + + return $gmt_offset; + } + + + + + +##### DETERMINE IF LEAD IS DIALABLE ##### +function dialable_gmt($DB,$link,$local_call_time,$gmt_offset,$state) + { + require("dbconnect.php"); + + $dialable=0; + + $pzone=3600 * $gmt_offset; + $pmin=(gmdate("i", time() + $pzone)); + $phour=( (gmdate("G", time() + $pzone)) * 100); + $pday=gmdate("w", time() + $pzone); + $tz = sprintf("%.2f", $p); + $GMT_gmt = "$tz"; + $GMT_day = "$pday"; + $GMT_hour = ($phour + $pmin); + + $stmt="SELECT call_time_id,call_time_name,call_time_comments,ct_default_start,ct_default_stop,ct_sunday_start,ct_sunday_stop,ct_monday_start,ct_monday_stop,ct_tuesday_start,ct_tuesday_stop,ct_wednesday_start,ct_wednesday_stop,ct_thursday_start,ct_thursday_stop,ct_friday_start,ct_friday_stop,ct_saturday_start,ct_saturday_stop,ct_state_call_times FROM vicidial_call_times where call_time_id='$local_call_time';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + $Gct_default_start = $rowx[3]; + $Gct_default_stop = $rowx[4]; + $Gct_sunday_start = $rowx[5]; + $Gct_sunday_stop = $rowx[6]; + $Gct_monday_start = $rowx[7]; + $Gct_monday_stop = $rowx[8]; + $Gct_tuesday_start = $rowx[9]; + $Gct_tuesday_stop = $rowx[10]; + $Gct_wednesday_start = $rowx[11]; + $Gct_wednesday_stop = $rowx[12]; + $Gct_thursday_start = $rowx[13]; + $Gct_thursday_stop = $rowx[14]; + $Gct_friday_start = $rowx[15]; + $Gct_friday_stop = $rowx[16]; + $Gct_saturday_start = $rowx[17]; + $Gct_saturday_stop = $rowx[18]; + $Gct_state_call_times = $rowx[19]; + + if ($GMT_day==0) #### Sunday local time + { + if (($Gct_sunday_start==0) and ($Gct_sunday_stop==0)) + { + if ( ($GMT_hour>=$Gct_default_start) and ($GMT_hour<$Gct_default_stop) ) + {$dialable=1;} + } + else + { + if ( ($GMT_hour>=$Gct_sunday_start) and ($GMT_hour<$Gct_sunday_stop) ) + {$dialable=1;} + } + } + if ($GMT_day==1) #### Monday local time + { + if (($Gct_monday_start==0) and ($Gct_monday_stop==0)) + { + if ( ($GMT_hour>=$Gct_default_start) and ($GMT_hour<$Gct_default_stop) ) + {$dialable=1;} + } + else + { + if ( ($GMT_hour>=$Gct_monday_start) and ($GMT_hour<$Gct_monday_stop) ) + {$dialable=1;} + } + } + if ($GMT_day==2) #### Tuesday local time + { + if (($Gct_tuesday_start==0) and ($Gct_tuesday_stop==0)) + { + if ( ($GMT_hour>=$Gct_default_start) and ($GMT_hour<$Gct_default_stop) ) + {$dialable=1;} + } + else + { + if ( ($GMT_hour>=$Gct_tuesday_start) and ($GMT_hour<$Gct_tuesday_stop) ) + {$dialable=1;} + } + } + if ($GMT_day==3) #### Wednesday local time + { + if (($Gct_wednesday_start==0) and ($Gct_wednesday_stop==0)) + { + if ( ($GMT_hour>=$Gct_default_start) and ($GMT_hour<$Gct_default_stop) ) + {$dialable=1;} + } + else + { + if ( ($GMT_hour>=$Gct_wednesday_start) and ($GMT_hour<$Gct_wednesday_stop) ) + {$dialable=1;} + } + } + if ($GMT_day==4) #### Thursday local time + { + if (($Gct_thursday_start==0) and ($Gct_thursday_stop==0)) + { + if ( ($GMT_hour>=$Gct_default_start) and ($GMT_hour<$Gct_default_stop) ) + {$dialable=1;} + } + else + { + if ( ($GMT_hour>=$Gct_thursday_start) and ($GMT_hour<$Gct_thursday_stop) ) + {$dialable=1;} + } + } + if ($GMT_day==5) #### Friday local time + { + if (($Gct_friday_start==0) and ($Gct_friday_stop==0)) + { + if ( ($GMT_hour>=$Gct_default_start) and ($GMT_hour<$Gct_default_stop) ) + {$dialable=1;} + } + else + { + if ( ($GMT_hour>=$Gct_friday_start) and ($GMT_hour<$Gct_friday_stop) ) + {$dialable=1;} + } + } + if ($GMT_day==6) #### Saturday local time + { + if (($Gct_saturday_start==0) and ($Gct_saturday_stop==0)) + { + if ( ($GMT_hour>=$Gct_default_start) and ($GMT_hour<$Gct_default_stop) ) + {$dialable=1;} + } + else + { + if ( ($GMT_hour>=$Gct_saturday_start) and ($GMT_hour<$Gct_saturday_stop) ) + {$dialable=1;} + } + } + + return $dialable; + } + + ##### MySQL Error Logging ##### function mysql_error_logging($NOW_TIME,$link,$mel,$stmt,$query_id,$user,$server_ip,$session_name,$one_mysql_log) diff --git a/agc_2-X/trunk/LANG_www/agc_it/manager_send.php b/agc_2-X/trunk/LANG_www/agc_it/manager_send.php index 0399a4f6..f79eb4f8 100644 --- a/agc_2-X/trunk/LANG_www/agc_it/manager_send.php +++ b/agc_2-X/trunk/LANG_www/agc_it/manager_send.php @@ -1,7 +1,7 @@ LICENSE: AGPLv2 +# Copyright (C) 2011 Matt Florell LICENSE: AGPLv2 # # This script is designed purely to insert records into the vicidial_manager table to signal Actions to an asterisk server # This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table @@ -43,6 +43,8 @@ # - $nodeletevdac - ('0','1') # - $alertCID - ('0','1') # - $preset_name = ('TESTING PRESET',...) +# - $call_variables = ('Variable: vendor_lead_code=1234|campaign=TESTCAMP|...') +# - $log_campaign # # CHANGELOG: # 50401-1002 - First build of script, Hangup function only @@ -102,12 +104,15 @@ # 100813-0833 - Added preset_name variable and logging # 101004-1345 - Added Ivr park functions # 101024-1638 - Added park_log logging for parked calls +# 101107-2331 - Added CALLERONHOLD/CALLEROFFHOLD queue_log entries +# 101125-1018 - Added call_variables Originate variables +# 110224-1710 - Added compatibility with QM phone environment logging # -$version = '2.4-52'; -$build = '101024-1638'; +$version = '2.4-55'; +$build = '110224-1710'; $mel=1; # Mysql Error Log enabled = 1 -$mysql_log_count=97; +$mysql_log_count=116; $one_mysql_log=0; require("dbconnect.php"); @@ -197,6 +202,10 @@ if (isset($_GET["alertCID"])) {$alertCID=$_GET["alertCID"];} elseif (isset($_POST["alertCID"])) {$alertCID=$_POST["alertCID"];} if (isset($_GET["preset_name"])) {$preset_name=$_GET["preset_name"];} elseif (isset($_POST["preset_name"])) {$preset_name=$_POST["preset_name"];} +if (isset($_GET["call_variables"])) {$call_variables=$_GET["call_variables"];} + elseif (isset($_POST["call_variables"])) {$call_variables=$_POST["call_variables"];} +if (isset($_GET["log_campaign"])) {$log_campaign=$_GET["log_campaign"];} + elseif (isset($_POST["log_campaign"])) {$log_campaign=$_POST["log_campaign"];} header ("Content-type: text/html; charset=utf-8"); @@ -437,10 +446,12 @@ if ($ACTION=="Originate") { $RAWaccount = $account; $account = "Account: $account"; - $variable = "Variable: usegroupalias=1"; + $variable = "Variable: _usegroupalias=1"; + if (strlen($call_variables)>9) + {$variable = "Variable: _usegroupalias=1";} # |$call_variables } else - {$account=''; $variable='';} + {$variable=''; $account="Variable: $call_variables";} $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$queryCID','Channel: $channel','Context: $ext_context','Exten: $exten','Priority: $ext_priority','Callerid: $outCID','$account','$variable','','','');"; if ($format=='debug') {echo "\n";} $rslt=mysql_query($stmt, $link); @@ -712,8 +723,20 @@ if ($ACTION=="Hangup") if ($time_id > 100000) {$secondS = ($StarTtime - $time_id);} + $data4SQL=''; + $stmt="SELECT queuemetrics_phone_environment FROM vicidial_campaigns where campaign_id='$log_campaign' and queuemetrics_phone_environment!='';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'02116',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $cqpe_ct = mysql_num_rows($rslt); + if ($cqpe_ct > 0) + { + $row=mysql_fetch_row($rslt); + $data4SQL = ",data4='$row[0]'"; + } + if ($format=='debug') {echo "\n";} - $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='$CalLCID',queue='$CLcampaign_id',agent='Agent/$user',verb='COMPLETEAGENT',data1='$CLstage',data2='$secondS',data3='$CLqueue_position',serverid='$queuemetrics_log_id';"; + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='$CalLCID',queue='$CLcampaign_id',agent='Agent/$user',verb='COMPLETEAGENT',data1='$CLstage',data2='$secondS',data3='$CLqueue_position',serverid='$queuemetrics_log_id' $data4SQL;"; $rslt=mysql_query($stmt, $linkB); if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'02019',$user,$server_ip,$session_name,$one_mysql_log);} $affected_rows = mysql_affected_rows($linkB); @@ -842,7 +865,60 @@ if ($ACTION=="RedirectToPark") $stmt = "INSERT INTO park_log SET uniqueid='$uniqueid',status='ATTESAED',channel='$channel',channel_group='$campaign',server_ip='$server_ip',parked_time='$NOW_TIME',parked_sec=0,extension='$CalLCID',user='$user',lead_id='$lead_id';"; if ($format=='debug') {echo "\n";} $rslt=mysql_query($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02XXX',$user,$server_ip,$session_name,$one_mysql_log);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02098',$user,$server_ip,$session_name,$one_mysql_log);} + + + ############################################# + ##### START QUEUEMETRICS LOGGING LOOKUP ##### + $stmt = "SELECT enable_queuemetrics_logging,queuemetrics_server_ip,queuemetrics_dbname,queuemetrics_login,queuemetrics_pass,queuemetrics_log_id FROM system_settings;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02099',$user,$server_ip,$session_name,$one_mysql_log);} + if ($format=='debug') {echo "\n";} + $qm_conf_ct = mysql_num_rows($rslt); + $i=0; + while ($i < $qm_conf_ct) + { + $row=mysql_fetch_row($rslt); + $enable_queuemetrics_logging = $row[0]; + $queuemetrics_server_ip = $row[1]; + $queuemetrics_dbname = $row[2]; + $queuemetrics_login = $row[3]; + $queuemetrics_pass = $row[4]; + $queuemetrics_log_id = $row[5]; + $i++; + } + ##### END QUEUEMETRICS LOGGING LOOKUP ##### + ########################################### + if ($enable_queuemetrics_logging > 0) + { + $linkB=mysql_connect("$queuemetrics_server_ip", "$queuemetrics_login", "$queuemetrics_pass"); + mysql_select_db("$queuemetrics_dbname", $linkB); + + $time_id=0; + $stmt="SELECT time_id,queue,agent from queue_log where call_id='$CalLCID' and verb='CONNECT' order by time_id desc limit 1;"; + $rslt=mysql_query($stmt, $linkB); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'02100',$user,$server_ip,$session_name,$one_mysql_log);} + $VAC_eq_ct = mysql_num_rows($rslt); + if ($VAC_eq_ct > 0) + { + $row=mysql_fetch_row($rslt); + $time_id = $row[0]; + $queue = $row[1]; + $agent = $row[2]; + } + $StarTtime = date("U"); + if ($time_id > 100000) + {$secondS = ($StarTtime - $time_id);} + + if ($VAC_eq_ct > 0) + { + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='$CalLCID',queue='$queue',agent='Agent/$user',verb='CALLERONHOLD',data1='ATTESA',serverid='$queuemetrics_log_id';"; + $rslt=mysql_query($stmt, $linkB); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'02101',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($linkB); + if ($format=='debug') {echo "\n";} + } + } # $fp = fopen ("./vicidial_debug.txt", "a"); # fwrite ($fp, "$NOW_TIME|MS_LOG_0|$queryCID|$stmt|\n"); @@ -880,7 +956,7 @@ if ($ACTION=="RedirectFromPark") $parked_sec=0; $stmt = "SELECT UNIX_TIMESTAMP(parked_time) FROM park_log where uniqueid='$uniqueid' and server_ip='$server_ip' and extension='$CalLCID' and (parked_sec < 1 or grab_time is NULL) order by parked_time desc limit 1;"; $rslt=mysql_query($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02XXX',$user,$server_ip,$session_name,$one_mysql_log);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02102',$user,$server_ip,$session_name,$one_mysql_log);} $VAC_pl_ct = mysql_num_rows($rslt); if ($VAC_pl_ct > 0) { @@ -890,7 +966,59 @@ if ($ACTION=="RedirectFromPark") $stmt = "UPDATE park_log SET status='GRABBED',grab_time='$NOW_TIME',parked_sec='$parked_sec' where uniqueid='$uniqueid' and server_ip='$server_ip' and extension='$CalLCID' order by parked_time desc limit 1;"; if ($format=='debug') {echo "\n";} $rslt=mysql_query($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02XXX',$user,$server_ip,$session_name,$one_mysql_log);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02103',$user,$server_ip,$session_name,$one_mysql_log);} + + ############################################# + ##### START QUEUEMETRICS LOGGING LOOKUP ##### + $stmt = "SELECT enable_queuemetrics_logging,queuemetrics_server_ip,queuemetrics_dbname,queuemetrics_login,queuemetrics_pass,queuemetrics_log_id FROM system_settings;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02104',$user,$server_ip,$session_name,$one_mysql_log);} + if ($format=='debug') {echo "\n";} + $qm_conf_ct = mysql_num_rows($rslt); + $i=0; + while ($i < $qm_conf_ct) + { + $row=mysql_fetch_row($rslt); + $enable_queuemetrics_logging = $row[0]; + $queuemetrics_server_ip = $row[1]; + $queuemetrics_dbname = $row[2]; + $queuemetrics_login = $row[3]; + $queuemetrics_pass = $row[4]; + $queuemetrics_log_id = $row[5]; + $i++; + } + ##### END QUEUEMETRICS LOGGING LOOKUP ##### + ########################################### + if ($enable_queuemetrics_logging > 0) + { + $linkB=mysql_connect("$queuemetrics_server_ip", "$queuemetrics_login", "$queuemetrics_pass"); + mysql_select_db("$queuemetrics_dbname", $linkB); + + $time_id=0; + $stmt="SELECT time_id,queue,agent from queue_log where call_id='$CalLCID' and verb='CONNECT' order by time_id desc limit 1;"; + $rslt=mysql_query($stmt, $linkB); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'02105',$user,$server_ip,$session_name,$one_mysql_log);} + $VAC_eq_ct = mysql_num_rows($rslt); + if ($VAC_eq_ct > 0) + { + $row=mysql_fetch_row($rslt); + $time_id = $row[0]; + $queue = $row[1]; + $agent = $row[2]; + } + $StarTtime = date("U"); + if ($time_id > 100000) + {$secondS = ($StarTtime - $time_id);} + + if ($VAC_eq_ct > 0) + { + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='$CalLCID',queue='$queue',agent='Agent/$user',verb='CALLEROFFHOLD',data1='$parked_sec',data2='ATTESA',serverid='$queuemetrics_log_id';"; + $rslt=mysql_query($stmt, $linkB); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'02106',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($linkB); + if ($format=='debug') {echo "\n";} + } + } } } @@ -932,8 +1060,59 @@ if ($ACTION=="RedirectToParkIVR") $stmt = "INSERT INTO park_log SET uniqueid='$uniqueid',status='IVRATTESAED',channel='$channel',channel_group='$campaign',server_ip='$server_ip',parked_time='$NOW_TIME',parked_sec=0,extension='$CalLCID',user='$user',lead_id='$lead_id';"; if ($format=='debug') {echo "\n";} $rslt=mysql_query($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02XXX',$user,$server_ip,$session_name,$one_mysql_log);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02107',$user,$server_ip,$session_name,$one_mysql_log);} + ############################################# + ##### START QUEUEMETRICS LOGGING LOOKUP ##### + $stmt = "SELECT enable_queuemetrics_logging,queuemetrics_server_ip,queuemetrics_dbname,queuemetrics_login,queuemetrics_pass,queuemetrics_log_id FROM system_settings;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02108',$user,$server_ip,$session_name,$one_mysql_log);} + if ($format=='debug') {echo "\n";} + $qm_conf_ct = mysql_num_rows($rslt); + $i=0; + while ($i < $qm_conf_ct) + { + $row=mysql_fetch_row($rslt); + $enable_queuemetrics_logging = $row[0]; + $queuemetrics_server_ip = $row[1]; + $queuemetrics_dbname = $row[2]; + $queuemetrics_login = $row[3]; + $queuemetrics_pass = $row[4]; + $queuemetrics_log_id = $row[5]; + $i++; + } + ##### END QUEUEMETRICS LOGGING LOOKUP ##### + ########################################### + if ($enable_queuemetrics_logging > 0) + { + $linkB=mysql_connect("$queuemetrics_server_ip", "$queuemetrics_login", "$queuemetrics_pass"); + mysql_select_db("$queuemetrics_dbname", $linkB); + + $time_id=0; + $stmt="SELECT time_id,queue,agent from queue_log where call_id='$CalLCID' and verb='CONNECT' order by time_id desc limit 1;"; + $rslt=mysql_query($stmt, $linkB); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'02109',$user,$server_ip,$session_name,$one_mysql_log);} + $VAC_eq_ct = mysql_num_rows($rslt); + if ($VAC_eq_ct > 0) + { + $row=mysql_fetch_row($rslt); + $time_id = $row[0]; + $queue = $row[1]; + $agent = $row[2]; + } + $StarTtime = date("U"); + if ($time_id > 100000) + {$secondS = ($StarTtime - $time_id);} + + if ($VAC_eq_ct > 0) + { + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='$CalLCID',queue='$queue',agent='Agent/$user',verb='CALLERONHOLD',data1='IVRATTESA',serverid='$queuemetrics_log_id';"; + $rslt=mysql_query($stmt, $linkB); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'02110',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($linkB); + if ($format=='debug') {echo "\n";} + } + } # $fp = fopen ("./vicidial_debug.txt", "a"); # fwrite ($fp, "$NOW_TIME|MS_LOG_0|$queryCID|$stmt|\n"); # fclose($fp); @@ -975,7 +1154,7 @@ if ($ACTION=="RedirectFromParkIVR") $parked_sec=0; $stmt = "SELECT UNIX_TIMESTAMP(parked_time) FROM park_log where uniqueid='$uniqueid' and server_ip='$server_ip' and extension='$CalLCID' and (parked_sec < 1 or grab_time is NULL) order by parked_time desc limit 1;"; $rslt=mysql_query($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02XXX',$user,$server_ip,$session_name,$one_mysql_log);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02111',$user,$server_ip,$session_name,$one_mysql_log);} $VAC_pl_ct = mysql_num_rows($rslt); if ($VAC_pl_ct > 0) { @@ -985,7 +1164,59 @@ if ($ACTION=="RedirectFromParkIVR") $stmt = "UPDATE park_log SET status='GRABBEDIVR',grab_time='$NOW_TIME',parked_sec='$parked_sec' where uniqueid='$uniqueid' and server_ip='$server_ip' and extension='$CalLCID' order by parked_time desc limit 1;"; if ($format=='debug') {echo "\n";} $rslt=mysql_query($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02XXX',$user,$server_ip,$session_name,$one_mysql_log);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02112',$user,$server_ip,$session_name,$one_mysql_log);} + + ############################################# + ##### START QUEUEMETRICS LOGGING LOOKUP ##### + $stmt = "SELECT enable_queuemetrics_logging,queuemetrics_server_ip,queuemetrics_dbname,queuemetrics_login,queuemetrics_pass,queuemetrics_log_id FROM system_settings;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02113',$user,$server_ip,$session_name,$one_mysql_log);} + if ($format=='debug') {echo "\n";} + $qm_conf_ct = mysql_num_rows($rslt); + $i=0; + while ($i < $qm_conf_ct) + { + $row=mysql_fetch_row($rslt); + $enable_queuemetrics_logging = $row[0]; + $queuemetrics_server_ip = $row[1]; + $queuemetrics_dbname = $row[2]; + $queuemetrics_login = $row[3]; + $queuemetrics_pass = $row[4]; + $queuemetrics_log_id = $row[5]; + $i++; + } + ##### END QUEUEMETRICS LOGGING LOOKUP ##### + ########################################### + if ($enable_queuemetrics_logging > 0) + { + $linkB=mysql_connect("$queuemetrics_server_ip", "$queuemetrics_login", "$queuemetrics_pass"); + mysql_select_db("$queuemetrics_dbname", $linkB); + + $time_id=0; + $stmt="SELECT time_id,queue,agent from queue_log where call_id='$CalLCID' and verb='CONNECT' order by time_id desc limit 1;"; + $rslt=mysql_query($stmt, $linkB); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'02114',$user,$server_ip,$session_name,$one_mysql_log);} + $VAC_eq_ct = mysql_num_rows($rslt); + if ($VAC_eq_ct > 0) + { + $row=mysql_fetch_row($rslt); + $time_id = $row[0]; + $queue = $row[1]; + $agent = $row[2]; + } + $StarTtime = date("U"); + if ($time_id > 100000) + {$secondS = ($StarTtime - $time_id);} + + if ($VAC_eq_ct > 0) + { + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='$CalLCID',queue='$queue',agent='Agent/$user',verb='CALLEROFFHOLD',data1='$parked_sec',data2='IVRATTESA',serverid='$queuemetrics_log_id';"; + $rslt=mysql_query($stmt, $linkB); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'02115',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($linkB); + if ($format=='debug') {echo "\n";} + } + } } } diff --git a/agc_2-X/trunk/LANG_www/agc_it/vdc_db_query.php b/agc_2-X/trunk/LANG_www/agc_it/vdc_db_query.php index 136a10c1..5ec1a2f6 100644 --- a/agc_2-X/trunk/LANG_www/agc_it/vdc_db_query.php +++ b/agc_2-X/trunk/LANG_www/agc_it/vdc_db_query.php @@ -1,7 +1,7 @@ LICENSE: AGPLv2 +# Copyright (C) 2011 Matt Florell LICENSE: AGPLv2 # # This script is designed to exchange information between vicidial.php and the database server for various actions # @@ -89,6 +89,7 @@ # - $DiaL_SecondS - ('0','1','2',...) # - $date - ('2010-02-19') # - $custom_field_names - ('|start_date|finish_date|favorite_color|') +# - $call_notes # # CHANGELOG: # 50629-1044 - First build of script @@ -260,15 +261,36 @@ # 100927-1618 - Added ability to use custom fields in web form and dispo_call_url # 101001-1451 - Added full name display to Call Log functionality # 101022-1243 - Fixed missing variables from start and dispo call urls +# 101108-0115 - Added ADDMEMBER option for queue_log +# 101111-1556 - Added source to vicidial_hopper inserts +# 101124-1033 - Added require for functions.php and manual dial call time check campaign option +# 101128-0108 - Added list override for webforms +# 101208-0414 - Fixed Call Log dial bug (issue 393) +# 110103-1343 - Added queuemetrics_loginout NONE option +# 110124-1134 - Small query fix for large queue_log tables +# 110124-1456 - Fixed AREACODE DNC manual dial bug +# 110212-2103 - Added support for custom scheduled callback statuses +# 110214-2320 - Added support for lead_order_secondary option +# 110215-1125 - Added support for call_notes +# 110218-1519 - Added support for agent lead search +# 110222-2228 - Added owner restriction to agent lead search +# 110224-1712 - Added compatibility with QM phone environment logging and QM pause code last call logging +# 110225-1237 - Added scheduled callback lead info display to the lead info view function +# 110303-1616 - Added vicidial_log_extended logging for manual dial calls +# 110304-1207 - Changed lead search with territory restriction to work with agents that cannot select territories +# 110310-0546 - Added ability to set a pause code at the same time of a pause +# 110310-1628 - removed callslogview, extended lead info function to be used instead +# 110317-0222 - Logging bug fixes # -$version = '2.4-166'; -$build = '101022-1243'; +$version = '2.4-186'; +$build = '110317-0222'; $mel=1; # Mysql Error Log enabled = 1 -$mysql_log_count=345; +$mysql_log_count=413; $one_mysql_log=0; require("dbconnect.php"); +require("functions.php"); ### If you have globals turned off uncomment these lines if (isset($_GET["user"])) {$user=$_GET["user"];} @@ -449,6 +471,18 @@ if (isset($_GET["date"])) {$date=$_GET["date"];} elseif (isset($_POST["date"])) {$date=$_POST["date"];} if (isset($_GET["custom_field_names"])) {$FORMcustom_field_names=$_GET["custom_field_names"];} elseif (isset($_POST["custom_field_names"])) {$FORMcustom_field_names=$_POST["custom_field_names"];} +if (isset($_GET["qm_phone"])) {$qm_phone=$_GET["qm_phone"];} + elseif (isset($_POST["qm_phone"])) {$qm_phone=$_POST["qm_phone"];} +if (isset($_GET["manual_dial_call_time_check"])) {$manual_dial_call_time_check=$_GET["manual_dial_call_time_check"];} + elseif (isset($_POST["manual_dial_call_time_check"])) {$manual_dial_call_time_check=$_POST["manual_dial_call_time_check"];} +if (isset($_GET["CallBackLeadStato"])) {$CallBackLeadStato=$_GET["CallBackLeadStato"];} + elseif (isset($_POST["CallBackLeadStato"])) {$CallBackLeadStato=$_POST["CallBackLeadStato"];} +if (isset($_GET["call_notes"])) {$call_notes=$_GET["call_notes"];} + elseif (isset($_POST["call_notes"])) {$call_notes=$_POST["call_notes"];} +if (isset($_GET["search"])) {$search=$_GET["search"];} + elseif (isset($_POST["search"])) {$search=$_POST["search"];} +if (isset($_GET["sub_status"])) {$sub_status=$_GET["sub_status"];} + elseif (isset($_POST["sub_status"])) {$sub_status=$_POST["sub_status"];} header ("Content-type: text/html; charset=utf-8"); @@ -465,6 +499,7 @@ $MT[0]=''; $agents='@agents'; $US='_'; while (strlen($CIDdate) > 9) {$CIDdate = substr("$CIDdate", 1);} +$check_time = ($StarTtime - 86400); ##### Hangup Cause Dictionary ##### $hangup_cause_dictionary = array( @@ -863,6 +898,35 @@ if ($ACTION == 'regCLOSER') $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00012',$user,$server_ip,$session_name,$one_mysql_log);} + ############################################# + ##### START QUEUEMETRICS LOGGING LOOKUP ##### + $stmt = "SELECT enable_queuemetrics_logging,queuemetrics_server_ip,queuemetrics_dbname,queuemetrics_login,queuemetrics_pass,queuemetrics_log_id,queuemetrics_addmember_enabled,queuemetrics_dispo_pause FROM system_settings;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00349',$user,$server_ip,$session_name,$one_mysql_log);} + if ($format=='debug') {echo "\n";} + $qm_conf_ct = mysql_num_rows($rslt); + $i=0; + while ($i < $qm_conf_ct) + { + $row=mysql_fetch_row($rslt); + $enable_queuemetrics_logging = $row[0]; + $queuemetrics_server_ip = $row[1]; + $queuemetrics_dbname = $row[2]; + $queuemetrics_login = $row[3]; + $queuemetrics_pass = $row[4]; + $queuemetrics_log_id = $row[5]; + $queuemetrics_addmember_enabled = $row[6]; + $queuemetrics_dispo_pause = $row[7]; + $i++; + } + ##### END QUEUEMETRICS LOGGING LOOKUP ##### + ########################################### + if ( ($enable_queuemetrics_logging > 0) and ($queuemetrics_addmember_enabled > 0) ) + { + $linkB=mysql_connect("$queuemetrics_server_ip", "$queuemetrics_login", "$queuemetrics_pass"); + mysql_select_db("$queuemetrics_dbname", $linkB); + } + $in_groups_pre = preg_replace('/-$/','',$closer_choice); $in_groups = explode(" ",$in_groups_pre); $in_groups_ct = count($in_groups); @@ -891,6 +955,28 @@ if ($ACTION == 'regCLOSER') if ($format=='debug') {echo "\n";} $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00014',$user,$server_ip,$session_name,$one_mysql_log);} + + if ( ($enable_queuemetrics_logging > 0) and ($queuemetrics_addmember_enabled > 0) ) + { + $data4SQL=''; + $stmt="SELECT queuemetrics_phone_environment FROM vicidial_campaigns where campaign_id='$campaign' and queuemetrics_phone_environment!='';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00388',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $cqpe_ct = mysql_num_rows($rslt); + if ($cqpe_ct > 0) + { + $row=mysql_fetch_row($rslt); + $data4SQL = ",data4='$row[0]'"; + } + + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='NONE',queue='$in_groups[$k]',agent='Agent/$user',verb='ADDMEMBER2',data1='$qm_phone',serverid='$queuemetrics_log_id' $data4SQL;"; + $rslt=mysql_query($stmt, $linkB); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'0350',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($linkB); + if ($format=='debug') {echo "\n";} + } + } $k++; } @@ -1083,7 +1169,9 @@ if ($ACTION == 'manDiaLnextCaLL') { $MT[0]=''; $row=''; $rowx=''; + $override_dial_number=''; $channel_live=1; + $lead_id = ereg_replace("[^0-9]","",$lead_id); if ( (strlen($conf_exten)<1) || (strlen($campaign)<1) || (strlen($ext_context)<1) ) { $channel_live=0; @@ -1134,31 +1222,163 @@ if ($ACTION == 'manDiaLnextCaLL') $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00016',$user,$server_ip,$session_name,$one_mysql_log);} } + ### check if this is a specific lead call, if it is, skip the grabbing of a new lead + elseif (strlen($lead_id)>0) + { + $affected_rows=1; + $CBleadIDset=1; + + if (strlen($phone_number) > 5) + {$override_dial_number = $phone_number;} + } else { if (strlen($phone_number)>3) { + if (ereg("ENABLED",$manual_dial_call_time_check)) + { + $secX = date("U"); + $hour = date("H"); + $min = date("i"); + $sec = date("s"); + $mon = date("m"); + $mday = date("d"); + $year = date("Y"); + $isdst = date("I"); + $Shour = date("H"); + $Smin = date("i"); + $Ssec = date("s"); + $Smon = date("m"); + $Smday = date("d"); + $Syear = date("Y"); + $pulldate0 = "$year-$mon-$mday $hour:$min:$sec"; + $inSD = $pulldate0; + $dsec = ( ( ($hour * 3600) + ($min * 60) ) + $sec ); + + ### Grab Server GMT value from the database + $stmt="SELECT local_gmt FROM servers where active='Y' limit 1;"; + $rslt=mysql_query($stmt, $link); + $gmt_recs = mysql_num_rows($rslt); + if ($gmt_recs > 0) + { + $row=mysql_fetch_row($rslt); + $DBSERVER_GMT = $row[0]; + if (strlen($DBSERVER_GMT)>0) {$SERVER_GMT = $DBSERVER_GMT;} + if ($isdst) {$SERVER_GMT++;} + } + else + { + $SERVER_GMT = date("O"); + $SERVER_GMT = eregi_replace("\+","",$SERVER_GMT); + $SERVER_GMT = ($SERVER_GMT + 0); + $SERVER_GMT = ($SERVER_GMT / 100); + } + + $LOCAL_GMT_OFF = $SERVER_GMT; + $LOCAL_GMT_OFF_STD = $SERVER_GMT; + $postalgmt=''; + $postal_code=''; + $state=''; + if (strlen($phone_code)<1) + {$phone_code='1';} + + $local_call_time='24hours'; + ##### gather local call time setting from campaign + $stmt="SELECT local_call_time FROM vicidial_campaigns where campaign_id='$campaign';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00353',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $camp_lct_ct = mysql_num_rows($rslt); + if ($camp_lct_ct > 0) + { + $row=mysql_fetch_row($rslt); + $local_call_time = $row[0]; + } + + ### get current gmt_offset of the phone_number + $gmt_offset = lookup_gmt($phone_code,$USarea,$state,$LOCAL_GMT_OFF_STD,$Shour,$Smin,$Ssec,$Smon,$Smday,$Syear,$postalgmt,$postal_code); + + $dialable = dialable_gmt($DB,$link,$local_call_time,$gmt_offset,$state); + + if ($dialable < 1) + { + ### insert a new lead in the system with this phone number + $stmt = "DELETE from vicidial_manual_dial_queue where phone_number='$phone_number' and user='$user';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00354',$user,$server_ip,$session_name,$one_mysql_log);} + $VMDQaffected_rows = mysql_affected_rows($link); + + $stmt = "UPDATE vicidial_live_agents set external_dial='' where user='$user';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00355',$user,$server_ip,$session_name,$one_mysql_log);} + $VLAEDaffected_rows = mysql_affected_rows($link); + + echo "OUTSIDE OF LOCAL CHIAMATA TIME $VMDQaffected_rows|$VLAEDaffected_rows\n"; + exit; + } + } + if (ereg("DNC",$manual_dial_filter)) { - $stmt="SELECT count(*) FROM vicidial_dnc where phone_number='$phone_number';"; + if (ereg("AREACODE",$use_internal_dnc)) + { + $phone_number_areacode = substr($phone_number, 0, 3); + $phone_number_areacode .= "XXXXXXX"; + $stmt="SELECT count(*) from vicidial_dnc where phone_number IN('$phone_number','$phone_number_areacode');"; + } + else + {$stmt="SELECT count(*) FROM vicidial_dnc where phone_number='$phone_number';";} $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00017',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} $row=mysql_fetch_row($rslt); - if ($row[0] > 0) { + ### insert a new lead in the system with this phone number + $stmt = "DELETE from vicidial_manual_dial_queue where phone_number='$phone_number' and user='$user';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00356',$user,$server_ip,$session_name,$one_mysql_log);} + $VMDQaffected_rows = mysql_affected_rows($link); + + $stmt = "UPDATE vicidial_live_agents set external_dial='' where user='$user';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00357',$user,$server_ip,$session_name,$one_mysql_log);} + $VLAEDaffected_rows = mysql_affected_rows($link); + echo "DNC NUMERO\n"; exit; } - $stmt="SELECT count(*) FROM vicidial_campaign_dnc where phone_number='$phone_number' and campaign_id='$campaign';"; + if (ereg("AREACODE",$use_campaign_dnc)) + { + $phone_number_areacode = substr($phone_number, 0, 3); + $phone_number_areacode .= "XXXXXXX"; + $stmt="SELECT count(*) from vicidial_campaign_dnc where phone_number IN('$phone_number','$phone_number_areacode') and campaign_id='$campaign';"; + } + else + {$stmt="SELECT count(*) FROM vicidial_campaign_dnc where phone_number='$phone_number' and campaign_id='$campaign';";} $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00018',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} $row=mysql_fetch_row($rslt); - if ($row[0] > 0) { + ### insert a new lead in the system with this phone number + $stmt = "DELETE from vicidial_manual_dial_queue where phone_number='$phone_number' and user='$user';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00358',$user,$server_ip,$session_name,$one_mysql_log);} + $VMDQaffected_rows = mysql_affected_rows($link); + + $stmt = "UPDATE vicidial_live_agents set external_dial='' where user='$user';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00359',$user,$server_ip,$session_name,$one_mysql_log);} + $VLAEDaffected_rows = mysql_affected_rows($link); + echo "DNC NUMERO\n"; exit; } @@ -1197,6 +1417,19 @@ if ($ACTION == 'manDiaLnextCaLL') if ($row[0] < 1) { + ### insert a new lead in the system with this phone number + $stmt = "DELETE from vicidial_manual_dial_queue where phone_number='$phone_number' and user='$user';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00360',$user,$server_ip,$session_name,$one_mysql_log);} + $VMDQaffected_rows = mysql_affected_rows($link); + + $stmt = "UPDATE vicidial_live_agents set external_dial='' where user='$user';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00361',$user,$server_ip,$session_name,$one_mysql_log);} + $VLAEDaffected_rows = mysql_affected_rows($link); + echo "NUMERO NOT IN CAMPLISTS\n"; exit; } @@ -1217,7 +1450,7 @@ if ($ACTION == 'manDiaLnextCaLL') { $stmt="SELECT lead_id FROM vicidial_list where phone_number='$phone_number' order by modify_date desc LIMIT 1;"; $rslt=mysql_query($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00021',$user,$server_ip,$session_name,$one_mysql_log);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00362',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} $man_leadID_ct = mysql_num_rows($rslt); } @@ -1255,7 +1488,7 @@ if ($ACTION == 'manDiaLnextCaLL') else { ##### gather no hopper dialing settings from campaign - $stmt="SELECT no_hopper_dialing,agent_dial_owner_only,local_call_time,dial_statuses,drop_lockout_time,lead_filter_id,lead_order FROM vicidial_campaigns where campaign_id='$campaign';"; + $stmt="SELECT no_hopper_dialing,agent_dial_owner_only,local_call_time,dial_statuses,drop_lockout_time,lead_filter_id,lead_order,lead_order_randomize,lead_order_secondary FROM vicidial_campaigns where campaign_id='$campaign';"; $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00236',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} @@ -1270,6 +1503,8 @@ if ($ACTION == 'manDiaLnextCaLL') $drop_lockout_time = $row[4]; $lead_filter_id = $row[5]; $lead_order = $row[6]; + $lead_order_randomize = $row[7]; + $lead_order_secondary = $row[8]; } if (eregi("N",$no_hopper_dialing)) { @@ -1614,7 +1849,8 @@ if ($ACTION == 'manDiaLnextCaLL') if ($filtersql_ct > 0) { $row=mysql_fetch_row($rslt); - $fSQL = $row[0]; + $fSQL = "and $row[0]"; + $fSQL = preg_replace('/\\\\/','',$fSQL); } $stmt="SELECT list_id FROM vicidial_lists where campaign_id='$campaign' and active='Y';"; @@ -1645,47 +1881,88 @@ if ($ACTION == 'manDiaLnextCaLL') $territory = $row[1]; } - $agent_territories=''; - $stmt="SELECT agent_territories FROM vicidial_live_agents where user='$user';"; - $rslt=mysql_query($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00258',$user,$server_ip,$session_name,$one_mysql_log);} - $userterrVLA_ct = mysql_num_rows($rslt); - if ($DB) {echo "$userterrVLA_ct|$stmt\n";} - if ($userterrVLA_ct > 0) - { - $row=mysql_fetch_row($rslt); - $agent_territories = $row[0]; - } - if (strlen($agent_territories) > 3) - { - $agent_territoriesSQL = preg_replace('/-$/','',$agent_territories); - $agent_territoriesSQL = preg_replace('/ $|^ /','',$agent_territoriesSQL); - $territory = preg_replace('/ /',"','",$agent_territoriesSQL); - } - $adooSQL = ''; + if (eregi("TERRITORY",$agent_dial_owner_only)) + { + $agent_territories=''; + $agent_choose_territories=0; + $stmt="SELECT agent_choose_territories from vicidial_users where user='$user';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00406',$user,$server_ip,$session_name,$one_mysql_log);} + $Uterrs_to_parse = mysql_num_rows($rslt); + if ($Uterrs_to_parse > 0) + { + $rowx=mysql_fetch_row($rslt); + $agent_choose_territories = $rowx[0]; + } + + if ($agent_choose_territories < 1) + { + $stmt="SELECT territory from vicidial_user_territories where user='$user';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00407',$user,$server_ip,$session_name,$one_mysql_log);} + $vuts_to_parse = mysql_num_rows($rslt); + $o=0; + while ($vuts_to_parse > $o) + { + $rowx=mysql_fetch_row($rslt); + $agent_territories .= "'$rowx[0]',"; + $o++; + } + $agent_territories = preg_replace("/\,$/",'',$agent_territories); + $searchownerSQL=" and owner IN($agent_territories)"; + if ($vuts_to_parse < 1) + {$searchownerSQL=" and lead_id < 0";} + } + else + { + $stmt="SELECT agent_territories from vicidial_live_agents where user='$user';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00408',$user,$server_ip,$session_name,$one_mysql_log);} + $terrs_to_parse = mysql_num_rows($rslt); + if ($terrs_to_parse > 0) + { + $rowx=mysql_fetch_row($rslt); + $agent_territories = $rowx[0]; + $agent_territories = preg_replace("/ -$|^ /",'',$agent_territories); + $agent_territories = preg_replace("/ /","','",$agent_territories); + $searchownerSQL=" and owner IN('$agent_territories')"; + } + } + + $adooSQL = $searchownerSQL; + } if (eregi("USER",$agent_dial_owner_only)) {$adooSQL = "and owner='$user'";} - if (eregi("TERRITORY",$agent_dial_owner_only)) {$adooSQL = "and owner IN('$territory')";} if (eregi("USER_GROUP",$agent_dial_owner_only)) {$adooSQL = "and owner='$user_group'";} + if ($lead_order_randomize == 'Y') {$last_order = "RAND()";} + else + { + $last_order = "lead_id asc"; + if ($lead_order_secondary == 'LEAD_ASCEND') {$last_order = "lead_id asc";} + if ($lead_order_secondary == 'LEAD_DESCEND') {$last_order = "lead_id desc";} + if ($lead_order_secondary == 'CALLTIME_ASCEND') {$last_order = "last_local_call_time asc";} + if ($lead_order_secondary == 'CALLTIME_DESCEND') {$last_order = "last_local_call_time desc";} + } + $order_stmt = ''; if (eregi("DOWN",$lead_order)){$order_stmt = 'order by lead_id asc';} if (eregi("UP",$lead_order)){$order_stmt = 'order by lead_id desc';} - if (eregi("UP LAST NAME",$lead_order)){$order_stmt = 'order by last_name desc, lead_id asc';} - if (eregi("DOWN LAST NAME",$lead_order)){$order_stmt = 'order by last_name, lead_id asc';} - if (eregi("UP PHONE",$lead_order)){$order_stmt = 'order by phone_number desc, lead_id asc';} - if (eregi("DOWN PHONE",$lead_order)){$order_stmt = 'order by phone_number, lead_id asc';} - if (eregi("UP COUNT",$lead_order)){$order_stmt = 'order by called_count desc, lead_id asc';} - if (eregi("DOWN COUNT",$lead_order)){$order_stmt = 'order by called_count, lead_id asc';} - if (eregi("UP LAST CHIAMATA TIME",$lead_order)){$order_stmt = 'order by last_local_call_time desc, lead_id asc';} - if (eregi("DOWN LAST CHIAMATA TIME",$lead_order)){$order_stmt = 'order by last_local_call_time, lead_id asc';} - if (eregi("RANDOM",$lead_order)){$order_stmt = 'order by RAND()';} - if (eregi("UP RANK",$lead_order)){$order_stmt = 'order by rank desc, lead_id asc';} - if (eregi("DOWN RANK",$lead_order)){$order_stmt = 'order by rank, lead_id asc';} - if (eregi("UP OWNER",$lead_order)){$order_stmt = 'order by owner desc, lead_id asc';} - if (eregi("DOWN OWNER",$lead_order)){$order_stmt = 'order by owner, lead_id asc';} - if (eregi("UP TIMEZONE",$lead_order)){$order_stmt = 'order by gmt_offset_now desc, lead_id asc';} - if (eregi("DOWN TIMEZONE",$lead_order)){$order_stmt = 'order by gmt_offset_now, lead_id asc';} + if (eregi("UP LAST NAME",$lead_order)){$order_stmt = "order by last_name desc, $last_order";} + if (eregi("DOWN LAST NAME",$lead_order)){$order_stmt = "order by last_name, $last_order";} + if (eregi("UP PHONE",$lead_order)){$order_stmt = "order by phone_number desc, $last_order";} + if (eregi("DOWN PHONE",$lead_order)){$order_stmt = "order by phone_number, $last_order";} + if (eregi("UP COUNT",$lead_order)){$order_stmt = "order by called_count desc, $last_order";} + if (eregi("DOWN COUNT",$lead_order)){$order_stmt = "order by called_count, $last_order";} + if (eregi("UP LAST CHIAMATA TIME",$lead_order)){$order_stmt = "order by last_local_call_time desc, $last_order";} + if (eregi("DOWN LAST CHIAMATA TIME",$lead_order)){$order_stmt = "order by last_local_call_time, $last_order";} + if (eregi("RANDOM",$lead_order)){$order_stmt = "order by RAND()";} + if (eregi("UP RANK",$lead_order)){$order_stmt = "order by rank desc, $last_order";} + if (eregi("DOWN RANK",$lead_order)){$order_stmt = "order by rank, $last_order";} + if (eregi("UP OWNER",$lead_order)){$order_stmt = "order by owner desc, $last_order";} + if (eregi("DOWN OWNER",$lead_order)){$order_stmt = "order by owner, $last_order";} + if (eregi("UP TIMEZONE",$lead_order)){$order_stmt = "order by gmt_offset_now desc, $last_order";} + if (eregi("DOWN TIMEZONE",$lead_order)){$order_stmt = "order by gmt_offset_now, $last_order";} $stmt="UPDATE vicidial_list SET status='QUEUE',user='$user' where called_since_last_reset='N' and status IN($Dsql) and list_id IN($camp_lists) and ($all_gmtSQL) $DLTsql $fSQL $adooSQL $order_stmt LIMIT 1;"; if ($DB) {echo "$stmt\n";} @@ -1693,6 +1970,10 @@ if ($ACTION == 'manDiaLnextCaLL') if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00242',$user,$server_ip,$session_name,$one_mysql_log);} $affected_rows = mysql_affected_rows($link); + # $fp = fopen ("./DNNdebug_log.txt", "a"); + # fwrite ($fp, "$NOW_TIME|$campaign|$lead_id|$agent_dialed_number|$user|M|$MqueryCID||$province|$affected_rows|$stmt|\n"); + # fclose($fp); + if ($affected_rows > 0) { $stmt="SELECT lead_id,list_id,gmt_offset_now,state,entry_list_id FROM vicidial_list where status='QUEUE' and user='$user' order by modify_date desc LIMIT 1;"; @@ -1709,7 +1990,7 @@ if ($ACTION == 'manDiaLnextCaLL') $state = $row[3]; $entry_list_id = $row[4]; - $stmt = "INSERT INTO vicidial_hopper SET lead_id='$lead_id',campaign_id='$campaign',status='QUEUE',list_id='$list_id',gmt_offset_now='$gmt_offset_now',state='$state',alt_dial='MAIN',user='$user',priority='0';"; + $stmt = "INSERT INTO vicidial_hopper SET lead_id='$lead_id',campaign_id='$campaign',status='QUEUE',list_id='$list_id',gmt_offset_now='$gmt_offset_now',state='$state',alt_dial='MAIN',user='$user',priority='0',source='Q';"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00244',$user,$server_ip,$session_name,$one_mysql_log);} @@ -1788,6 +2069,13 @@ if ($ACTION == 'manDiaLnextCaLL') $called_count++; + if ( (strlen($agent_dialed_type) < 3) or (strlen($agent_dialed_number) < 6) ) + { + $agent_dialed_number = $phone_number; + if (strlen($agent_dialed_type) < 3) + {$agent_dialed_type = 'MAIN';} + } + ##### check if system is set to generate logfile for transfers $stmt="SELECT enable_agc_xfer_log FROM system_settings;"; $rslt=mysql_query($stmt, $link); @@ -1811,7 +2099,7 @@ if ($ACTION == 'manDiaLnextCaLL') # DATETIME|campaign|lead_id|phone_number|user|type # 2007-08-22 11:11:11|TESTCAMP|65432|3125551212|1234|M $fp = fopen ("./xfer_log.txt", "a"); - fwrite ($fp, "$NOW_TIME|$campaign|$lead_id|$phone_number|$user|M|$MqueryCID||$province\n"); + fwrite ($fp, "$NOW_TIME|$campaign|$lead_id|$agent_dialed_number|$user|M|$MqueryCID||$province\n"); fclose($fp); } @@ -1820,7 +2108,32 @@ if ($ACTION == 'manDiaLnextCaLL') $CBcallback_time = ''; $CBuser = ''; $CBcomments = ''; - if (ereg("CALLBK",$dispo)) + $CBstatus = 0; + + $stmt="SELECT count(*) FROM vicidial_statuses where status='$dispo' and scheduled_callback='Y';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00366',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $cb_record_ct = mysql_num_rows($rslt); + if ($cb_record_ct > 0) + { + $row=mysql_fetch_row($rslt); + $CBstatus = $row[0]; + } + if ($CBstatus < 1) + { + $stmt="SELECT count(*) FROM vicidial_campaign_statuses where status='$dispo' and scheduled_callback='Y';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00367',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $cb_record_ct = mysql_num_rows($rslt); + if ($cb_record_ct > 0) + { + $row=mysql_fetch_row($rslt); + $CBstatus = $row[0]; + } + } + if ( ($CBstatus > 0) or ($dispo == 'CBHOLD') ) { $stmt="SELECT entry_time,callback_time,user,comments FROM vicidial_callbacks where lead_id='$lead_id' order by callback_id desc LIMIT 1;"; $rslt=mysql_query($stmt, $link); @@ -1846,6 +2159,8 @@ if ($ACTION == 'manDiaLnextCaLL') { $row=mysql_fetch_row($rslt); $local_gmt = $row[0]; + $isdst = date("I"); + if ($isdst) {$local_gmt++;} } $LLCT_DATE_offset = ($local_gmt - $gmt_offset_now); $LLCT_DATE = date("Y-m-d H:i:s", mktime(date("H")-$LLCT_DATE_offset,date("i"),date("s"),date("m"),date("d"),date("Y"))); @@ -1878,6 +2193,26 @@ if ($ACTION == 'manDiaLnextCaLL') $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00032',$user,$server_ip,$session_name,$one_mysql_log);} + $campaign_cid_override=''; + $LISTweb_form_address=''; + $LISTweb_form_address_two=''; + ### check if there is a list_id override + if (strlen($list_id) > 1) + { + $stmt = "SELECT campaign_cid_override,web_form_address,web_form_address_two FROM vicidial_lists where list_id='$list_id';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00245',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $lio_ct = mysql_num_rows($rslt); + if ($lio_ct > 0) + { + $row=mysql_fetch_row($rslt); + $campaign_cid_override = $row[0]; + $LISTweb_form_address = $row[1]; + $LISTweb_form_address_two = $row[2]; + } + } + ### if preview dialing, do not send the call if ( (strlen($preview)<1) || ($preview == 'NO') ) { @@ -1893,21 +2228,6 @@ if ($ACTION == 'manDiaLnextCaLL') $Local_dial_timeout = ($Local_dial_timeout * 1000); if (strlen($dial_prefix) > 0) {$Local_out_prefix = "$dial_prefix";} if (strlen($campaign_cid) > 6) {$CCID = "$campaign_cid"; $CCID_on++;} - $campaign_cid_override=''; - ### check if there is a list_id override - if (strlen($list_id) > 1) - { - $stmt = "SELECT campaign_cid_override FROM vicidial_lists where list_id='$list_id';"; - $rslt=mysql_query($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00245',$user,$server_ip,$session_name,$one_mysql_log);} - if ($DB) {echo "$stmt\n";} - $lio_ct = mysql_num_rows($rslt); - if ($lio_ct > 0) - { - $row=mysql_fetch_row($rslt); - $campaign_cid_override = $row[0]; - } - } if (strlen($campaign_cid_override) > 6) {$CCID = "$campaign_cid_override"; $CCID_on++;} ### check for custom cid use $use_custom_cid=0; @@ -1958,9 +2278,9 @@ if ($ACTION == 'manDiaLnextCaLL') ### whether to omit phone_code or not if (eregi('Y',$omit_phone_code)) - {$Ndialstring = "$Local_out_prefix$phone_number";} + {$Ndialstring = "$Local_out_prefix$agent_dialed_number";} else - {$Ndialstring = "$Local_out_prefix$phone_code$phone_number";} + {$Ndialstring = "$Local_out_prefix$phone_code$agent_dialed_number";} if ( ($usegroupalias > 0) and (strlen($account)>1) ) { @@ -1978,7 +2298,7 @@ if ($ACTION == 'manDiaLnextCaLL') $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00033',$user,$server_ip,$session_name,$one_mysql_log);} - $stmt = "INSERT INTO vicidial_auto_calls (server_ip,campaign_id,status,lead_id,callerid,phone_code,phone_number,call_time,call_type) values('$server_ip','$campaign','XFER','$lead_id','$MqueryCID','$phone_code','$phone_number','$NOW_TIME','OUT')"; + $stmt = "INSERT INTO vicidial_auto_calls (server_ip,campaign_id,status,lead_id,callerid,phone_code,phone_number,call_time,call_type) values('$server_ip','$campaign','XFER','$lead_id','$MqueryCID','$phone_code','$agent_dialed_number','$NOW_TIME','OUT')"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00034',$user,$server_ip,$session_name,$one_mysql_log);} @@ -2040,7 +2360,7 @@ if ($ACTION == 'manDiaLnextCaLL') if ($agent_dialed_number > 0) { - $stmt = "INSERT INTO user_call_log (user,call_date,call_type,server_ip,phone_number,number_dialed,lead_id,callerid,group_alias_id) values('$user','$NOW_TIME','$agent_dialed_type','$server_ip','$phone_number','$Ndialstring','$lead_id','$CCID','$RAWaccount')"; + $stmt = "INSERT INTO user_call_log (user,call_date,call_type,server_ip,phone_number,number_dialed,lead_id,callerid,group_alias_id) values('$user','$NOW_TIME','$agent_dialed_type','$server_ip','$agent_dialed_number','$Ndialstring','$lead_id','$CCID','$RAWaccount')"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00191',$user,$server_ip,$session_name,$one_mysql_log);} @@ -2067,25 +2387,37 @@ if ($ACTION == 'manDiaLnextCaLL') ########################################### if ($enable_queuemetrics_logging > 0) { + $data4SQL=''; + $stmt="SELECT queuemetrics_phone_environment FROM vicidial_campaigns where campaign_id='$campaign' and queuemetrics_phone_environment!='';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00389',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $cqpe_ct = mysql_num_rows($rslt); + if ($cqpe_ct > 0) + { + $row=mysql_fetch_row($rslt); + $data4SQL = ",data4='$row[0]'"; + } + $linkB=mysql_connect("$queuemetrics_server_ip", "$queuemetrics_login", "$queuemetrics_pass"); mysql_select_db("$queuemetrics_dbname", $linkB); # UNPAUSEALL - $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='NONE',queue='NONE',agent='Agent/$user',verb='UNPAUSEALL',serverid='$queuemetrics_log_id';"; + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='NONE',queue='NONE',agent='Agent/$user',verb='UNPAUSEALL',serverid='$queuemetrics_log_id' $data4SQL;"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $linkB); if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00038',$user,$server_ip,$session_name,$one_mysql_log);} $affected_rows = mysql_affected_rows($linkB); # CHIAMATAOUTBOUND (formerly ENTERQUEUE) - $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='$MqueryCID',queue='$campaign',agent='NONE',verb='CALLOUTBOUND',data2='$phone_number',serverid='$queuemetrics_log_id';"; + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='$MqueryCID',queue='$campaign',agent='NONE',verb='CALLOUTBOUND',data2='$agent_dialed_number',serverid='$queuemetrics_log_id' $data4SQL;"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $linkB); if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00039',$user,$server_ip,$session_name,$one_mysql_log);} $affected_rows = mysql_affected_rows($linkB); # CONNECT - $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='$MqueryCID',queue='$campaign',agent='Agent/$user',verb='CONNECT',data1='0',serverid='$queuemetrics_log_id';"; + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='$MqueryCID',queue='$campaign',agent='Agent/$user',verb='CONNECT',data1='0',serverid='$queuemetrics_log_id' $data4SQL;"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $linkB); if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00040',$user,$server_ip,$session_name,$one_mysql_log);} @@ -2246,8 +2578,8 @@ if ($ACTION == 'manDiaLnextCaLL') $LeaD_InfO .= $CBcallback_time . "\n"; $LeaD_InfO .= $CBuser . "\n"; $LeaD_InfO .= $CBcomments . "\n"; - $LeaD_InfO .= $phone_number . "\n"; - $LeaD_InfO .= "MAIN\n"; + $LeaD_InfO .= $agent_dialed_number . "\n"; + $LeaD_InfO .= $agent_dialed_type . "\n"; $LeaD_InfO .= $source_id . "\n"; $LeaD_InfO .= $rank . "\n"; $LeaD_InfO .= $owner . "\n"; @@ -2262,6 +2594,8 @@ if ($ACTION == 'manDiaLnextCaLL') $LeaD_InfO .= $custom_field_names . "\n"; $LeaD_InfO .= $custom_field_values . "\n"; $LeaD_InfO .= $custom_field_types . "\n"; + $LeaD_InfO .= $LISTweb_form_address . "\n"; + $LeaD_InfO .= $LISTweb_form_address_two . "\n"; echo $LeaD_InfO; } @@ -2409,6 +2743,8 @@ if ($ACTION == 'manDiaLonly') ### prepare variables to place manual call from VICIDiaL $CCID_on=0; $CCID=''; + $LISTweb_form_address=''; + $LISTweb_form_address_two=''; $local_DEF = 'Local/'; $local_AMP = '@'; $Local_out_prefix = '9'; @@ -2436,7 +2772,7 @@ if ($ACTION == 'manDiaLonly') if (strlen($list_id) > 1) { - $stmt = "SELECT campaign_cid_override FROM vicidial_lists where list_id='$list_id';"; + $stmt = "SELECT campaign_cid_override,web_form_address,web_form_address_two FROM vicidial_lists where list_id='$list_id';"; $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00247',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} @@ -2445,6 +2781,8 @@ if ($ACTION == 'manDiaLonly') { $row=mysql_fetch_row($rslt); $campaign_cid_override = $row[0]; + $LISTweb_form_address = $row[1]; + $LISTweb_form_address_two = $row[2]; } } } @@ -2647,25 +2985,37 @@ if ($ACTION == 'manDiaLonly') ########################################### if ($enable_queuemetrics_logging > 0) { + $data4SQL=''; + $stmt="SELECT queuemetrics_phone_environment FROM vicidial_campaigns where campaign_id='$campaign' and queuemetrics_phone_environment!='';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00390',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $cqpe_ct = mysql_num_rows($rslt); + if ($cqpe_ct > 0) + { + $row=mysql_fetch_row($rslt); + $data4SQL = ",data4='$row[0]'"; + } + $linkB=mysql_connect("$queuemetrics_server_ip", "$queuemetrics_login", "$queuemetrics_pass"); mysql_select_db("$queuemetrics_dbname", $linkB); # UNPAUSEALL - $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='NONE',queue='NONE',agent='Agent/$user',verb='UNPAUSEALL',serverid='$queuemetrics_log_id';"; + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='NONE',queue='NONE',agent='Agent/$user',verb='UNPAUSEALL',serverid='$queuemetrics_log_id' $data4SQL;"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $linkB); if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00049',$user,$server_ip,$session_name,$one_mysql_log);} $affected_rows = mysql_affected_rows($linkB); # CHIAMATAOUTBOUND (formerly ENTERQUEUE) - $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='$MqueryCID',queue='$campaign',agent='NONE',verb='CALLOUTBOUND',data2='$phone_number',serverid='$queuemetrics_log_id';"; + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='$MqueryCID',queue='$campaign',agent='NONE',verb='CALLOUTBOUND',data2='$phone_number',serverid='$queuemetrics_log_id' $data4SQL;"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $linkB); if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00050',$user,$server_ip,$session_name,$one_mysql_log);} $affected_rows = mysql_affected_rows($linkB); # CONNECT - $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='$MqueryCID',queue='$campaign',agent='Agent/$user',verb='CONNECT',data1='0',serverid='$queuemetrics_log_id';"; + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='$MqueryCID',queue='$campaign',agent='Agent/$user',verb='CONNECT',data1='0',serverid='$queuemetrics_log_id' $data4SQL;"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $linkB); if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00051',$user,$server_ip,$session_name,$one_mysql_log);} @@ -2749,6 +3099,11 @@ if ($ACTION == 'manDiaLlookCaLL') if ($format=='debug') {echo "\n";} $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00293',$user,$server_ip,$session_name,$one_mysql_log);} + + $stmt="UPDATE vicidial_live_agents set ring_callerid='' where ring_callerid='$MDnextCID';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00399',$user,$server_ip,$session_name,$one_mysql_log);} } } } @@ -2835,6 +3190,13 @@ if ($stage == "start") $user_group = trim("$row[0]"); } + ##### insert log into vicidial_log_extended for manual VICIDiaL call + $stmt="INSERT IGNORE INTO vicidial_log_extended SET uniqueid='$uniqueid',server_ip='$server_ip',call_date='$NOW_TIME',lead_id='$lead_id',caller_code='$MDnextCID',custom_call_id='' ON DUPLICATE KEY UPDATE server_ip='$server_ip',call_date='$NOW_TIME',lead_id='$lead_id',caller_code='$MDnextCID';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00400',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rowsX = mysql_affected_rows($link); + $manualVLexists=0; $beginUNIQUEID = preg_replace("/\..*/","",$uniqueid); $stmt="SELECT count(*) from vicidial_log where lead_id='$lead_id' and user='$user' and phone_number='$phone_number' and uniqueid LIKE \"$beginUNIQUEID%\";"; @@ -2979,7 +3341,7 @@ if ($stage == "end") fclose($fp); ##### start epoch in the vicidial_log table, couldn't find one in vicidial_closer_log - $stmt="SELECT start_epoch,term_reason,campaign_id FROM vicidial_log where uniqueid='$uniqueid' and lead_id='$lead_id' order by call_date desc limit 1;"; + $stmt="SELECT start_epoch,term_reason,campaign_id,status FROM vicidial_log where uniqueid='$uniqueid' and lead_id='$lead_id' order by call_date desc limit 1;"; $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00061',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} @@ -2990,6 +3352,7 @@ if ($stage == "end") $start_epoch = $row[0]; $VDterm_reason = $row[1]; $VDcampaign_id = $row[2]; + $VDstatus = $row[3]; $length_in_sec = ($StarTtime - $start_epoch); } else @@ -3031,7 +3394,7 @@ if ($stage == "end") ############################################# ##### START QUEUEMETRICS LOGGING LOOKUP ##### - $stmt = "SELECT enable_queuemetrics_logging,queuemetrics_server_ip,queuemetrics_dbname,queuemetrics_login,queuemetrics_pass,queuemetrics_log_id FROM system_settings;"; + $stmt = "SELECT enable_queuemetrics_logging,queuemetrics_server_ip,queuemetrics_dbname,queuemetrics_login,queuemetrics_pass,queuemetrics_log_id,queuemetrics_dispo_pause FROM system_settings;"; $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00063',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} @@ -3046,6 +3409,7 @@ if ($stage == "end") $queuemetrics_login = $row[3]; $queuemetrics_pass = $row[4]; $queuemetrics_log_id = $row[5]; + $queuemetrics_dispo_pause = $row[6]; if ($enable_queuemetrics_logging > 0) { @@ -3157,7 +3521,7 @@ if ($stage == "end") if ($VD_alt_dnc_count < 1) { ### insert record into vicidial_hopper for alt_phone call attempt - $stmt = "INSERT INTO vicidial_hopper SET lead_id='$lead_id',campaign_id='$campaign',status='HOLD',list_id='$list_id',gmt_offset_now='$gmt_offset_now',state='$state',alt_dial='ALT',user='',priority='25';"; + $stmt = "INSERT INTO vicidial_hopper SET lead_id='$lead_id',campaign_id='$campaign',status='HOLD',list_id='$list_id',gmt_offset_now='$gmt_offset_now',state='$state',alt_dial='ALT',user='',priority='25',source='A';"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00068',$user,$server_ip,$session_name,$one_mysql_log);} @@ -3234,7 +3598,7 @@ if ($stage == "end") if ($VD_alt_dnc_count < 1) { ### insert record into vicidial_hopper for address3 call attempt - $stmt = "INSERT INTO vicidial_hopper SET lead_id='$lead_id',campaign_id='$campaign',status='HOLD',list_id='$list_id',gmt_offset_now='$gmt_offset_now',state='$state',alt_dial='ADDR3',user='',priority='20';"; + $stmt = "INSERT INTO vicidial_hopper SET lead_id='$lead_id',campaign_id='$campaign',status='HOLD',list_id='$list_id',gmt_offset_now='$gmt_offset_now',state='$state',alt_dial='ADDR3',user='',priority='20',source='A';"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00072',$user,$server_ip,$session_name,$one_mysql_log);} @@ -3350,7 +3714,7 @@ if ($stage == "end") { if ($alt_dial_phones_count == $Xlast) {$Xlast = 'LAST';} - $stmt = "INSERT INTO vicidial_hopper SET lead_id='$lead_id',campaign_id='$campaign',status='HOLD',list_id='$EA_list_id',gmt_offset_now='$EA_gmt_offset_now',state='$EA_state',alt_dial='X$Xlast',user='',priority='15';"; + $stmt = "INSERT INTO vicidial_hopper SET lead_id='$lead_id',campaign_id='$campaign',status='HOLD',list_id='$EA_list_id',gmt_offset_now='$EA_gmt_offset_now',state='$EA_state',alt_dial='X$Xlast',user='',priority='15',source='A';"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00078',$user,$server_ip,$session_name,$one_mysql_log);} @@ -3437,7 +3801,19 @@ if ($stage == "end") { if ($enable_queuemetrics_logging > 0) { - $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='NONE',queue='NONE',agent='Agent/$user',verb='PAUSEALL',serverid='$queuemetrics_log_id';"; + $data4SQL=''; + $stmt="SELECT queuemetrics_phone_environment FROM vicidial_campaigns where campaign_id='$campaign' and queuemetrics_phone_environment!='';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00391',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $cqpe_ct = mysql_num_rows($rslt); + if ($cqpe_ct > 0) + { + $row=mysql_fetch_row($rslt); + $data4SQL = ",data4='$row[0]'"; + } + + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='NONE',queue='NONE',agent='Agent/$user',verb='PAUSEALL',serverid='$queuemetrics_log_id' $data4SQL;"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $linkB); if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00083',$user,$server_ip,$session_name,$one_mysql_log);} @@ -3475,7 +3851,19 @@ if ($stage == "end") $CLstage = preg_replace("/XFER|CLOSER|-/",'',$CLstage); if ($CLstage < 0.25) {$CLstage=0;} - $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='$MDnextCID',queue='$VDcampaign_id',agent='Agent/$user',verb='COMPLETEAGENT',data1='$CLstage',data2='$length_in_sec',data3='$CLqueue_position',serverid='$queuemetrics_log_id';"; + $data4SQL=''; + $stmt="SELECT queuemetrics_phone_environment FROM vicidial_campaigns where campaign_id='$campaign' and queuemetrics_phone_environment!='';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00392',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $cqpe_ct = mysql_num_rows($rslt); + if ($cqpe_ct > 0) + { + $row=mysql_fetch_row($rslt); + $data4SQL = ",data4='$row[0]'"; + } + + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='$MDnextCID',queue='$VDcampaign_id',agent='Agent/$user',verb='COMPLETEAGENT',data1='$CLstage',data2='$length_in_sec',data3='$CLqueue_position',serverid='$queuemetrics_log_id' $data4SQL;"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $linkB); if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00085',$user,$server_ip,$session_name,$one_mysql_log);} @@ -3510,7 +3898,7 @@ if ($stage == "end") { if ($enable_queuemetrics_logging > 0) { - $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='NONE',queue='NONE',agent='Agent/$user',verb='PAUSEALL',serverid='$queuemetrics_log_id';"; + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='NONE',queue='NONE',agent='Agent/$user',verb='PAUSEALL',serverid='$queuemetrics_log_id' $data4SQL;"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $linkB); if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00088',$user,$server_ip,$session_name,$one_mysql_log);} @@ -3526,15 +3914,16 @@ if ($stage == "end") if ( (ereg("NONE",$term_reason)) or (ereg("NONE",$VDterm_reason)) or (strlen($VDterm_reason) < 1) ) { ### check to see if lead should be alt_dialed - $stmt="SELECT term_reason,uniqueid from vicidial_log where uniqueid='$uniqueid' and lead_id='$lead_id' order by call_date desc limit 1;"; + $stmt="SELECT term_reason,uniqueid,status from vicidial_log where uniqueid='$uniqueid' and lead_id='$lead_id' order by call_date desc limit 1;"; $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00089',$user,$server_ip,$session_name,$one_mysql_log);} $VAC_qm_ct = mysql_num_rows($rslt); if ($VAC_qm_ct > 0) { $row=mysql_fetch_row($rslt); - $VDterm_reason = $row[0]; - $VDvicidial_id = $row[1]; + $VDterm_reason = $row[0]; + $VDvicidial_id = $row[1]; + $VDstatus = $row[2]; $VDIDselect = "VDL_UIDLID $uniqueid $lead_id"; } if (ereg("CALLER",$VDterm_reason)) @@ -3547,18 +3936,25 @@ if ($stage == "end") } } + ##### insert log into vicidial_log_extended for manual VICIDiaL call + $stmt="INSERT IGNORE INTO vicidial_log_extended SET uniqueid='$uniqueid',server_ip='$server_ip',call_date='$NOW_TIME',lead_id='$lead_id',caller_code='$MDnextCID',custom_call_id='' ON DUPLICATE KEY UPDATE server_ip='$server_ip',call_date='$NOW_TIME',lead_id='$lead_id',caller_code='$MDnextCID';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00401',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rowsX = mysql_affected_rows($link); + ### check to see if the vicidial_log record exists, if not, insert it $manualVLexists=0; $beginUNIQUEID = preg_replace("/\..*/","",$uniqueid); - $stmt="SELECT count(*) from vicidial_log where lead_id='$lead_id' and user='$user' and phone_number='$phone_number' and uniqueid LIKE \"$beginUNIQUEID%\";"; + $stmt="SELECT status from vicidial_log where lead_id='$lead_id' and user='$user' and phone_number='$phone_number' and uniqueid LIKE \"$beginUNIQUEID%\";"; $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00223',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} - $VL_exists_ct = mysql_num_rows($rslt); - if ($VL_exists_ct > 0) + $manualVLexists = mysql_num_rows($rslt); + if ($manualVLexists > 0) { $row=mysql_fetch_row($rslt); - $manualVLexists = $row[0]; + $VDstatus = $row[0]; } if ($manualVLexists < 1) @@ -3590,7 +3986,8 @@ if ($stage == "end") } ##### update the duration and end time in the vicidial_log table - $stmt="UPDATE vicidial_log set $SQLterm end_epoch='$StarTtime', length_in_sec='$length_in_sec', status='$status_dispo' where uniqueid='$uniqueid' and lead_id='$lead_id' and user='$user' order by call_date desc limit 1;"; + if ($VDstatus == 'INCALL') {$vl_statusSQL = ",status='$status_dispo'";} + $stmt="UPDATE vicidial_log set $SQLterm end_epoch='$StarTtime', length_in_sec='$length_in_sec' $vl_statusSQL where uniqueid='$uniqueid' and lead_id='$lead_id' and user='$user' order by call_date desc limit 1;"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00090',$user,$server_ip,$session_name,$one_mysql_log);} @@ -3678,7 +4075,19 @@ if ($stage == "end") if (strlen($VDqueue_position) < 1) {$VDqueue_position=1;} - $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='$MDnextCID',queue='$VDcampaign_id',agent='Agent/$user',verb='COMPLETEAGENT',data1='$CLstage',data2='$length_in_sec',data3='$VDqueue_position',serverid='$queuemetrics_log_id';"; + $data4SQL=''; + $stmt="SELECT queuemetrics_phone_environment FROM vicidial_campaigns where campaign_id='$campaign' and queuemetrics_phone_environment!='';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00393',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $cqpe_ct = mysql_num_rows($rslt); + if ($cqpe_ct > 0) + { + $row=mysql_fetch_row($rslt); + $data4SQL = ",data4='$row[0]'"; + } + + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='$MDnextCID',queue='$VDcampaign_id',agent='Agent/$user',verb='COMPLETEAGENT',data1='$CLstage',data2='$length_in_sec',data3='$VDqueue_position',serverid='$queuemetrics_log_id' $data4SQL;"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $linkB); if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00094',$user,$server_ip,$session_name,$one_mysql_log);} @@ -3810,7 +4219,7 @@ if ($stage == "end") if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00098',$user,$server_ip,$session_name,$one_mysql_log);} echo "REC_STOP|$rec_channels[$loop_count]|$filename[$loop_count]|"; - if (strlen($filename)>2) + if (strlen($filename[$loop_count])>2) { $stmt="SELECT recording_id,start_epoch,vicidial_id,lead_id FROM recording_log where filename='$filename[$loop_count]'"; if ($format=='debug') {echo "\n";} @@ -3917,6 +4326,16 @@ if ($stage == "end") if ($format=='debug') {echo "\n";} $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00299',$user,$server_ip,$session_name,$one_mysql_log);} + + ### if queuemetrics_dispo_pause dispo tag is enabled, log it here + if (strlen($queuemetrics_dispo_pause) > 0) + { + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='$MDnextCID',queue='NONE',agent='Agent/$user',verb='PAUSEREASON',serverid='$queuemetrics_log_id',data1='$queuemetrics_dispo_pause';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkB); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00364',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($linkB); + } } } @@ -4095,7 +4514,32 @@ if ($ACTION == 'VDADcheckINCOMING') $CBcallback_time = ''; $CBuser = ''; $CBcomments = ''; - if (ereg("CALLBK",$dispo)) + $CBstatus = 0; + + $stmt="SELECT count(*) FROM vicidial_statuses where status='$dispo' and scheduled_callback='Y';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00368',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $cb_record_ct = mysql_num_rows($rslt); + if ($cb_record_ct > 0) + { + $row=mysql_fetch_row($rslt); + $CBstatus = $row[0]; + } + if ($CBstatus < 1) + { + $stmt="SELECT count(*) FROM vicidial_campaign_statuses where status='$dispo' and scheduled_callback='Y';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00369',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $cb_record_ct = mysql_num_rows($rslt); + if ($cb_record_ct > 0) + { + $row=mysql_fetch_row($rslt); + $CBstatus = $row[0]; + } + } + if ( ($CBstatus > 0) or ($dispo == 'CBHOLD') ) { $stmt="SELECT entry_time,callback_time,user,comments FROM vicidial_callbacks where lead_id='$lead_id' order by callback_id desc LIMIT 1;"; $rslt=mysql_query($stmt, $link); @@ -4572,7 +5016,7 @@ if ($ACTION == 'VDADcheckINCOMING') ### Check for List ID override settings if (strlen($list_id)>0) { - $stmt = "select xferconf_a_number,xferconf_b_number,xferconf_c_number,xferconf_d_number,xferconf_e_number from vicidial_lists where list_id='$list_id';"; + $stmt = "select xferconf_a_number,xferconf_b_number,xferconf_c_number,xferconf_d_number,xferconf_e_number,web_form_address,web_form_address_two from vicidial_lists where list_id='$list_id';"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00282',$user,$server_ip,$session_name,$one_mysql_log);} @@ -4590,6 +5034,10 @@ if ($ACTION == 'VDADcheckINCOMING') {$VDCL_xferconf_d_number = $row[3];} if (strlen($row[4]) > 0) {$VDCL_xferconf_e_number = $row[4];} + if (strlen($row[5]) > 5) + {$VDCL_group_web = $row[5];} + if (strlen($row[6]) > 5) + {$VDCL_group_web_two = $row[6];} } } @@ -4783,8 +5231,33 @@ if ($ACTION == 'VDADcheckINCOMING') $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00124',$user,$server_ip,$session_name,$one_mysql_log);} - ### If CHIAMATABK, change vicidial_callback record to INACTIVE - if (eregi("CALLBK|CBHOLD", $dispo)) + ### If a scheduled callback, change vicidial_callback record to INACTIVE + $CBstatus = 0; + + $stmt="SELECT count(*) FROM vicidial_statuses where status='$dispo' and scheduled_callback='Y';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00370',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $cb_record_ct = mysql_num_rows($rslt); + if ($cb_record_ct > 0) + { + $row=mysql_fetch_row($rslt); + $CBstatus = $row[0]; + } + if ($CBstatus < 1) + { + $stmt="SELECT count(*) FROM vicidial_campaign_statuses where status='$dispo' and scheduled_callback='Y';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00371',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $cb_record_ct = mysql_num_rows($rslt); + if ($cb_record_ct > 0) + { + $row=mysql_fetch_row($rslt); + $CBstatus = $row[0]; + } + } + if ( ($CBstatus > 0) or (eregi("CALLBK|CBHOLD", $dispo)) ) { $stmt="UPDATE vicidial_callbacks set status='INACTIVE' where lead_id='$lead_id' and status NOT IN('INACTIVE','DEAD','ARCHIVE');"; if ($format=='debug') {echo "\n";} @@ -5156,7 +5629,7 @@ if ($ACTION == 'userLOGout') { ############################################# ##### START QUEUEMETRICS LOGGING LOOKUP ##### - $stmt = "SELECT enable_queuemetrics_logging,queuemetrics_server_ip,queuemetrics_dbname,queuemetrics_login,queuemetrics_pass,queuemetrics_log_id,allow_sipsak_messages,queuemetrics_loginout FROM system_settings;"; + $stmt = "SELECT enable_queuemetrics_logging,queuemetrics_server_ip,queuemetrics_dbname,queuemetrics_login,queuemetrics_pass,queuemetrics_log_id,allow_sipsak_messages,queuemetrics_loginout,queuemetrics_addmember_enabled,queuemetrics_dispo_pause FROM system_settings;"; $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00138',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} @@ -5164,14 +5637,16 @@ if ($ACTION == 'userLOGout') if ($qm_conf_ct > 0) { $row=mysql_fetch_row($rslt); - $enable_queuemetrics_logging = $row[0]; - $queuemetrics_server_ip = $row[1]; - $queuemetrics_dbname = $row[2]; - $queuemetrics_login = $row[3]; - $queuemetrics_pass = $row[4]; - $queuemetrics_log_id = $row[5]; - $allow_sipsak_messages = $row[6]; - $queuemetrics_loginout = $row[7]; + $enable_queuemetrics_logging = $row[0]; + $queuemetrics_server_ip = $row[1]; + $queuemetrics_dbname = $row[2]; + $queuemetrics_login = $row[3]; + $queuemetrics_pass = $row[4]; + $queuemetrics_log_id = $row[5]; + $allow_sipsak_messages = $row[6]; + $queuemetrics_loginout = $row[7]; + $queuemetrics_addmember_enabled = $row[8]; + $queuemetrics_dispo_pause = $row[9]; } ##### END QUEUEMETRICS LOGGING LOOKUP ##### ########################################### @@ -5196,7 +5671,8 @@ if ($ACTION == 'userLOGout') # $rslt=mysql_query($stmt, $linkB); # $affected_rows = mysql_affected_rows($linkB); - $stmt = "SELECT time_id,data1 FROM queue_log where agent='Agent/$user' and verb IN('AGENTLOGIN','AGENTCALLBACKLOGIN') order by time_id desc limit 1;"; + $logintime=0; + $stmt = "SELECT time_id,data1 FROM queue_log where agent='Agent/$user' and verb IN('AGENTLOGIN','AGENTCALLBACKLOGIN') and time_id > $check_time order by time_id desc limit 1;"; $rslt=mysql_query($stmt, $linkB); if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00139',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} @@ -5211,15 +5687,83 @@ if ($ACTION == 'userLOGout') $i++; } + $data4SQL=''; + $stmt="SELECT queuemetrics_phone_environment FROM vicidial_campaigns where campaign_id='$campaign' and queuemetrics_phone_environment!='';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00394',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $cqpe_ct = mysql_num_rows($rslt); + if ($cqpe_ct > 0) + { + $row=mysql_fetch_row($rslt); + $data4SQL = ",data4='$row[0]'"; + } + $time_logged_in = ($StarTtime - $logintime); if ($time_logged_in > 1000000) {$time_logged_in=1;} - $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='NONE',queue='NONE',agent='Agent/$user',verb='$QM_LOGOFF',data1='$loginphone',data2='$time_logged_in',serverid='$queuemetrics_log_id';"; - if ($DB) {echo "$stmt\n";} - $rslt=mysql_query($stmt, $linkB); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00140',$user,$server_ip,$session_name,$one_mysql_log);} - $affected_rows = mysql_affected_rows($linkB); + if ($queuemetrics_loginout != 'NONE') + { + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='NONE',queue='NONE',agent='Agent/$user',verb='$QM_LOGOFF',data1='$loginphone',data2='$time_logged_in',serverid='$queuemetrics_log_id' $data4SQL;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkB); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00140',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($linkB); + } + if ($queuemetrics_addmember_enabled > 0) + { + if ($queuemetrics_loginout == 'NONE') + { + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='NONE',queue='NONE',agent='Agent/$user',verb='PAUSEREASON',serverid='$queuemetrics_log_id',data1='LOGOFF';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkB); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00396',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($linkB); + } + if ( ($logintime < 1) or ($queuemetrics_loginout == 'NONE') ) + { + $stmtB = "SELECT time_id,data3 FROM queue_log where agent='Agent/$user' and verb='PAUSEREASON' and data1='LOGIN' order by time_id desc limit 1;"; + $rsltB=mysql_query($stmtB, $linkB); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00365',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "
$stmtB\n";} + $qml_ct = mysql_num_rows($rsltB); + if ($qml_ct > 0) + { + $row=mysql_fetch_row($rsltB); + $logintime = $row[0]; + $loginphone = $row[1]; + } + } + $stmt = "SELECT distinct queue FROM queue_log where time_id >= $logintime and agent='Agent/$user' and verb IN('ADDMEMBER','ADDMEMBER2') and queue != '$campaign' order by time_id desc;"; + $rslt=mysql_query($stmt, $linkB); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00351',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + echo "$stmt\n"; + $amq_conf_ct = mysql_num_rows($rslt); + $i=0; + while ($i < $amq_conf_ct) + { + $row=mysql_fetch_row($rslt); + $AMqueue[$i] = $row[0]; + $i++; + } + + ### add the logged-in campaign as well + $AMqueue[$i] = $campaign; + $i++; + $amq_conf_ct++; + + $i=0; + while ($i < $amq_conf_ct) + { + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='NONE',queue='$AMqueue[$i]',agent='Agent/$user',verb='REMOVEMEMBER',data1='$loginphone',serverid='$queuemetrics_log_id' $data4SQL;"; + $rslt=mysql_query($stmt, $linkB); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00352',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($linkB); + $i++; + } + } mysql_close($linkB); } } @@ -5288,6 +5832,8 @@ if ($ACTION == 'updateDISPO') # $fp = fopen ("./vicidial_debug.txt", "a"); # fwrite ($fp, "$NOW_TIME|DISPO_CALL |$MDnextCID|$stage|$campaign|$lead_id|$dispo_choice|$user|$uniqueid|$auto_dial_level|$agent_log_id|\n"); # fclose($fp); + $log_dispo_choice = $dispo_choice; + if (strlen($CallBackLeadStato) > 0) {$log_dispo_choice = $CallBackLeadStato;} $stmt = "SELECT count(*) from vicidial_inbound_groups where group_id='$stage';"; if ($format=='debug') {echo "\n";} @@ -5297,7 +5843,7 @@ if ($ACTION == 'updateDISPO') if ($row[0] > 0) { $call_type='IN'; - $stmt = "UPDATE vicidial_closer_log set status='$dispo_choice' where lead_id='$lead_id' and user='$user' order by closecallid desc limit 1;"; + $stmt = "UPDATE vicidial_closer_log set status='$log_dispo_choice' where lead_id='$lead_id' and user='$user' order by closecallid desc limit 1;"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00144',$user,$server_ip,$session_name,$one_mysql_log);} @@ -5333,7 +5879,7 @@ if ($ACTION == 'updateDISPO') $row=mysql_fetch_row($rslt); if ($row[0] > 0) { - $stmt="UPDATE vicidial_log set status='$dispo_choice' where lead_id='$lead_id' and user='$user' and call_date > \"$four_hours_ago\" order by uniqueid desc limit 1;"; + $stmt="UPDATE vicidial_log set status='$log_dispo_choice' where lead_id='$lead_id' and user='$user' and call_date > \"$four_hours_ago\" order by uniqueid desc limit 1;"; if ($format=='debug') {echo "\n";} $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00145',$user,$server_ip,$session_name,$one_mysql_log);} @@ -5422,13 +5968,20 @@ if ($ACTION == 'updateDISPO') } $PADlead_id = sprintf("%010s", $lead_id); - while (strlen($PADlead_id) > 10) {$PADlead_id = substr("$PADlead_id", 1);} + while (strlen($PADlead_id) > 9) {$PADlead_id = substr("$PADlead_id", 1);} $FAKEcall_id = "$StarTtime.$PADlead_id"; - $stmt = "INSERT INTO vicidial_log set uniqueid='$FAKEcall_id',lead_id='$lead_id',list_id='$VLlist_id',campaign_id='$campaign',call_date='$NOW_TIME',start_epoch='$StarTtime',end_epoch='$StarTtime',length_in_sec='0',status='$dispo_choice',phone_code='$VLphone_code',phone_number='$VLphone_number',user='$user',comments='MANUAL',processed='N',user_group='$user_group',term_reason='AGENT',alt_dial='$VLalt';"; + $stmt = "INSERT INTO vicidial_log set uniqueid='$FAKEcall_id',lead_id='$lead_id',list_id='$VLlist_id',campaign_id='$campaign',call_date='$NOW_TIME',start_epoch='$StarTtime',end_epoch='$StarTtime',length_in_sec='0',status='$log_dispo_choice',phone_code='$VLphone_code',phone_number='$VLphone_number',user='$user',comments='MANUAL',processed='N',user_group='$user_group',term_reason='AGENT',alt_dial='$VLalt';"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00215',$user,$server_ip,$session_name,$one_mysql_log);} + ##### insert log into vicidial_log_extended for manual VICIDiaL call + $stmt="INSERT IGNORE INTO vicidial_log_extended SET uniqueid='$FAKEcall_id',server_ip='$server_ip',call_date='$NOW_TIME',lead_id='$lead_id',caller_code='$MDnextCID',custom_call_id='' ON DUPLICATE KEY UPDATE server_ip='$server_ip',call_date='$NOW_TIME',lead_id='$lead_id',caller_code='$MDnextCID';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00402',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rowsX = mysql_affected_rows($link); + $MAN_vl_insert++; } @@ -5436,10 +5989,15 @@ if ($ACTION == 'updateDISPO') if ($format=='debug') {echo "\n";} $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00219',$user,$server_ip,$session_name,$one_mysql_log);} + + $stmt="UPDATE vicidial_live_agents set ring_callerid='' where ring_callerid='$MDnextCID';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00403',$user,$server_ip,$session_name,$one_mysql_log);} } else { - $stmt="UPDATE vicidial_log set status='$dispo_choice' where lead_id='$lead_id' and user='$user' and call_date > \"$four_hours_ago\" order by uniqueid desc limit 1;"; + $stmt="UPDATE vicidial_log set status='$log_dispo_choice' where lead_id='$lead_id' and user='$user' and call_date > \"$four_hours_ago\" order by uniqueid desc limit 1;"; if ($format=='debug') {echo "\n";} $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00145',$user,$server_ip,$session_name,$one_mysql_log);} @@ -5480,7 +6038,7 @@ if ($ACTION == 'updateDISPO') } $insert_into_dnc=0; - if ( ($use_internal_dnc=='Y') and (eregi("\|$dispo_choice\|", $DNC_string_check) ) ) + if ( ($use_internal_dnc=='Y') and (eregi("\|$log_dispo_choice\|", $DNC_string_check) ) ) { $stmt = "select phone_number from vicidial_list where lead_id='$lead_id';"; if ($DB) {echo "$stmt\n";} @@ -5493,7 +6051,7 @@ if ($ACTION == 'updateDISPO') if ($DB) {echo "$stmt\n";} $insert_into_dnc++; } - if ( ($use_campaign_dnc=='Y') and (eregi("\|$dispo_choice\|", $DNC_string_check) ) ) + if ( ($use_campaign_dnc=='Y') and (eregi("\|$log_dispo_choice\|", $DNC_string_check) ) ) { $stmt = "select phone_number from vicidial_list where lead_id='$lead_id';"; if ($DB) {echo "$stmt\n";} @@ -5545,7 +6103,7 @@ if ($ACTION == 'updateDISPO') } } } - $stmt="UPDATE vicidial_agent_log set dispo_sec='$dispo_sec',status='$dispo_choice',uniqueid='$uniqueid' $dispo_epochSQL $lead_id_commentsSQL where agent_log_id='$agent_log_id';"; + $stmt="UPDATE vicidial_agent_log set dispo_sec='$dispo_sec',status='$log_dispo_choice',uniqueid='$uniqueid' $dispo_epochSQL $lead_id_commentsSQL where agent_log_id='$agent_log_id';"; if ($format=='debug') {echo "\n";} $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00151',$user,$server_ip,$session_name,$one_mysql_log);} @@ -5594,19 +6152,48 @@ if ($ACTION == 'updateDISPO') $comments = eregi_replace("'",'',$comments); $comments = eregi_replace(';','',$comments); $comments = eregi_replace("\\\\",' ',$comments); - $stmt="INSERT INTO vicidial_callbacks (lead_id,list_id,campaign_id,status,entry_time,callback_time,user,recipient,comments,user_group) values('$lead_id','$list_id','$campaign','ACTIVE','$NOW_TIME','$CallBackDatETimE','$user','$recipient','$comments','$user_group');"; + $stmt="INSERT INTO vicidial_callbacks (lead_id,list_id,campaign_id,status,entry_time,callback_time,user,recipient,comments,user_group,lead_status) values('$lead_id','$list_id','$campaign','ACTIVE','$NOW_TIME','$CallBackDatETimE','$user','$recipient','$comments','$user_group','$CallBackLeadStato');"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00154',$user,$server_ip,$session_name,$one_mysql_log);} } - $stmt="SELECT auto_alt_dial_statuses,use_internal_dnc,use_campaign_dnc from vicidial_campaigns where campaign_id='$campaign';"; + ### BEGIN Call Note Logging ### + if (strlen($call_notes) > 1) + { + $VDADchannel_group=$campaign; + $stmt = "SELECT campaign_id,closecallid from vicidial_closer_log where uniqueid='$uniqueid' and user='$user' order by call_date desc limit 1;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00372',$user,$server_ip,$session_name,$one_mysql_log);} + $VDCL_cn_ct = mysql_num_rows($rslt); + if ($VDCL_cn_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VDADchannel_group = $row[0]; + $vicidial_id = $row[1]; + } + else + {$vicidial_id = $uniqueid;} + + # Insert into vicidial_call_notes + $stmt="INSERT INTO vicidial_call_notes set lead_id='$lead_id',vicidial_id='$vicidial_id',call_date='$NOW_TIME',call_notes='" . mysql_real_escape_string($call_notes) . "';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00373',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($link); + $notesid = mysql_insert_id($link); + } + ### END Call Note Logging ### + + $stmt="SELECT auto_alt_dial_statuses,use_internal_dnc,use_campaign_dnc,api_manual_dial from vicidial_campaigns where campaign_id='$campaign';"; $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00155',$user,$server_ip,$session_name,$one_mysql_log);} $row=mysql_fetch_row($rslt); $VC_auto_alt_dial_statuses = $row[0]; $use_internal_dnc = $row[1]; $use_campaign_dnc = $row[2]; + $api_manual_dial = $row[3]; if ( ($auto_dial_level > 0) and (ereg(" $dispo_choice ",$VC_auto_alt_dial_statuses)) ) { @@ -5701,6 +6288,13 @@ if ($ACTION == 'updateDISPO') $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00158',$user,$server_ip,$session_name,$one_mysql_log);} } + if ( ($api_manual_dial=='QUEUE') or ($api_manual_dial=='QUEUE_AND_AUTOCALL') ) + { + $stmt="DELETE from vicidial_manual_dial_queue where user='$user' and status='QUEUE';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00363',$user,$server_ip,$session_name,$one_mysql_log);} + } ####### START Vtiger Call Logging ####### $stmt = "SELECT enable_vtiger_integration,vtiger_server_ip,vtiger_dbname,vtiger_login,vtiger_pass,vtiger_url FROM system_settings;"; @@ -6092,7 +6686,7 @@ if ($ACTION == 'updateDISPO') ############################################# ##### START QUEUEMETRICS LOGGING LOOKUP ##### - $stmt = "SELECT enable_queuemetrics_logging,queuemetrics_server_ip,queuemetrics_dbname,queuemetrics_login,queuemetrics_pass,queuemetrics_log_id,queuemetrics_callstatus FROM system_settings;"; + $stmt = "SELECT enable_queuemetrics_logging,queuemetrics_server_ip,queuemetrics_dbname,queuemetrics_login,queuemetrics_pass,queuemetrics_log_id,queuemetrics_callstatus,queuemetrics_dispo_pause FROM system_settings;"; $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00159',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} @@ -6107,6 +6701,7 @@ if ($ACTION == 'updateDISPO') $queuemetrics_pass = $row[4]; $queuemetrics_log_id = $row[5]; $queuemetrics_callstatus = $row[6]; + $queuemetrics_dispo_pause = $row[7]; } ##### END QUEUEMETRICS LOGGING LOOKUP ##### ########################################### @@ -6118,12 +6713,89 @@ if ($ACTION == 'updateDISPO') if (strlen($stage) < 2) {$stage = $campaign;} - $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='$MDnextCID',queue='$stage',agent='Agent/$user',verb='CALLSTATUS',data1='$dispo_choice',serverid='$queuemetrics_log_id';"; + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='$MDnextCID',queue='$stage',agent='Agent/$user',verb='CALLSTATUS',data1='$log_dispo_choice',serverid='$queuemetrics_log_id';"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $linkB); if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00160',$user,$server_ip,$session_name,$one_mysql_log);} $affected_rows = mysql_affected_rows($linkB); + ### check to make sure a COMPLETE record is present for this call + $QLcomplete_records=0; + $stmt = "SELECT count(*) FROM queue_log where verb IN('COMPLETEAGENT','COMPLETECALLER') and call_id='$MDnextCID' and agent='Agent/$user' and queue='$stage';"; + $rslt=mysql_query($stmt, $linkB); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00409',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + echo "$stmt\n"; + $comp_ct = mysql_num_rows($rslt); + if ($comp_ct > 0) + { + $row=mysql_fetch_row($rslt); + $QLcomplete_records = $row[0]; + } + + ### if there are no complete records, look up information to insert one for this call + if ($QLcomplete_records < 1) + { + $QLconnect_time=$StarTtime; + $QLcomplete_time=$StarTtime; + $QLconnect_one=''; + $QLconnect_four=''; + $QLcomplete_position=1; + + $stmt = "SELECT time_id,data1,data4 FROM queue_log where verb='CONNECT' and call_id='$MDnextCID' and agent='Agent/$user' and queue='$stage' order by time_id desc limit 1;"; + $rslt=mysql_query($stmt, $linkB); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00410',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + echo "$stmt\n"; + $connect_ct = mysql_num_rows($rslt); + if ($connect_ct > 0) + { + $row=mysql_fetch_row($rslt); + $QLconnect_time = $row[0]; + $QLconnect_one = $row[1]; + $QLconnect_four = $row[2]; + } + + $stmt = "SELECT time_id FROM queue_log where verb='PAUSEREASON' and call_id='$MDnextCID' and agent='Agent/$user' and data1='$queuemetrics_dispo_pause' order by time_id desc limit 1;"; + $rslt=mysql_query($stmt, $linkB); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00411',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + echo "$stmt\n"; + $pausereason_ct = mysql_num_rows($rslt); + if ($pausereason_ct > 0) + { + $row=mysql_fetch_row($rslt); + $QLcomplete_time = $row[0]; + } + + $QLcomplete_length = ($QLcomplete_time - $QLconnect_time); + if ($QLcomplete_length < 0) {$QLcomplete_length=0;} + if ($QLcomplete_length > 86400) {$QLcomplete_length=1;} + + ## if inbound, check for initial queue position + if (preg_match("/^Y/",$MDnextCID)) + { + $four_hours_ago = date("Y-m-d H:i:s", mktime(date("H")-4,date("i"),date("s"),date("m"),date("d"),date("Y"))); + + $stmt = "SELECT queue_position FROM vicidial_closer_log where lead_id='$lead_id' and campaign_id='$stage' and call_date > \"$four_hours_ago\" order by closecallid desc limit 1;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00412',$user,$server_ip,$session_name,$one_mysql_log);} + $vcl_ct = mysql_num_rows($rslt); + if ($vcl_ct > 0) + { + $row=mysql_fetch_row($rslt); + $QLcomplete_position = $row[0]; + } + } + + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$QLcomplete_time',call_id='$MDnextCID',queue='$stage',agent='Agent/$user',verb='COMPLETEAGENT',data1='$QLconnect_one',data2='$QLcomplete_length',data3='$QLcomplete_position',serverid='$queuemetrics_log_id',data4='$QLconnect_four';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkB); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00413',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($linkB); + } + mysql_close($linkB); } @@ -6242,7 +6914,7 @@ if ($ACTION == 'updateDISPO') $stmt = "SELECT did_id,extension from vicidial_did_log where uniqueid='$uniqueid' order by call_date desc limit 1;"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00XXX',$user,$server_ip,$session_name,$one_mysql_log);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00346',$user,$server_ip,$session_name,$one_mysql_log);} $VDIDL_ct = mysql_num_rows($rslt); if ($VDIDL_ct > 0) { @@ -6253,7 +6925,7 @@ if ($ACTION == 'updateDISPO') $stmt = "SELECT did_pattern,did_description from vicidial_inbound_dids where did_id='$DID_id' limit 1;"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00XXX',$user,$server_ip,$session_name,$one_mysql_log);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00347',$user,$server_ip,$session_name,$one_mysql_log);} $VDIDL_ct = mysql_num_rows($rslt); if ($VDIDL_ct > 0) { @@ -6272,7 +6944,7 @@ if ($ACTION == 'updateDISPO') $stmt = "SELECT campaign_id,closecallid,xfercallid from vicidial_closer_log where uniqueid='$uniqueid' and user='$user' order by call_date desc limit 1;"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00XXX',$user,$server_ip,$session_name,$one_mysql_log);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00348',$user,$server_ip,$session_name,$one_mysql_log);} $VDCL_mvac_ct = mysql_num_rows($rslt); if ($VDCL_mvac_ct > 0) { @@ -6678,7 +7350,9 @@ if ( ($ACTION == 'VDADpause') || ($ACTION == 'VDADready') ) $vla_lead_wipeSQL=''; if ($ACTION == 'VDADready') {$vla_lead_wipeSQL = ",lead_id=0";} - $stmt="UPDATE vicidial_live_agents set status='$stage' $vla_lead_wipeSQL where user='$user' and server_ip='$server_ip';"; + if ($ACTION == 'VDADpause') + {$vla_ring_resetSQL = ",ring_callerid=''";} + $stmt="UPDATE vicidial_live_agents set status='$stage' $vla_lead_wipeSQL $vla_ring_resetSQL where user='$user' and server_ip='$server_ip';"; if ($format=='debug') {echo "\n";} $rslt=mysql_query($stmt, $link); if ($mel > 0) {$errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00166',$user,$server_ip,$session_name,$one_mysql_log);} @@ -6735,7 +7409,19 @@ if ( ($ACTION == 'VDADpause') || ($ACTION == 'VDADready') ) $user_group = trim("$row[0]"); } - $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='NONE',queue='NONE',agent='Agent/$user',verb='$QMstatus',serverid='$queuemetrics_log_id';"; + $data4SQL=''; + $stmt="SELECT queuemetrics_phone_environment FROM vicidial_campaigns where campaign_id='$campaign' and queuemetrics_phone_environment!='';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00395',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $cqpe_ct = mysql_num_rows($rslt); + if ($cqpe_ct > 0) + { + $row=mysql_fetch_row($rslt); + $data4SQL = ",data4='$row[0]'"; + } + + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='NONE',queue='NONE',agent='Agent/$user',verb='$QMstatus',serverid='$queuemetrics_log_id' $data4SQL;"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $linkB); if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00168',$user,$server_ip,$session_name,$one_mysql_log);} @@ -6834,7 +7520,17 @@ if ( ($ACTION == 'VDADpause') || ($ACTION == 'VDADready') ) $VLAaffected_rows_update = mysql_affected_rows($link); } } - echo 'Agent ' . $user . ' è ora nello stato ' . $stage . "\nNext agent_log_id:\n$agent_log_id\n"; + if (strlen($sub_status) > 0) + { + ### if a pause code(sub_status) is sent with this pause request, continue su to that action without printing output + $stage = 0; + $status = $sub_status; + $ACTION = 'PauseCodeSubmit'; + } + else + { + echo 'Agent ' . $user . ' è ora nello stato ' . $stage . "\nNext agent_log_id:\n$agent_log_id\n"; + } } @@ -6976,10 +7672,12 @@ if ($ACTION == 'PauseCodeSubmit') } if ($enable_queuemetrics_logging > 0) { + $pause_call_id='NONE'; + if (strlen($campaign_cid) > 12) {$pause_call_id = $campaign_cid;} $linkB=mysql_connect("$queuemetrics_server_ip", "$queuemetrics_login", "$queuemetrics_pass"); mysql_select_db("$queuemetrics_dbname", $linkB); - $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='NONE',queue='NONE',agent='Agent/$user',verb='PAUSEREASON',serverid='$queuemetrics_log_id',data1='$status';"; + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='$pause_call_id',queue='NONE',agent='Agent/$user',verb='PAUSEREASON',serverid='$queuemetrics_log_id',data1='$status';"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $linkB); if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00177',$user,$server_ip,$session_name,$one_mysql_log);} @@ -7529,19 +8227,366 @@ if ($ACTION == 'CALLLOGview') echo " $ALLalt_dial[$i] \n"; echo " $ALLhangup_reason[$i] \n"; echo " INFO \n"; - echo " DIAL \n"; + echo " DIAL \n"; echo "\n"; } echo ""; echo "
"; - echo "Close Call Log"; + echo "Close Call Log"; echo "
"; } ################################################################################ -### LEADINFOview - display the information for a lead +### SEARCHRESULTSview - display search results for lead search +################################################################################ +if ($ACTION == 'SEARCHRESULTSview') + { + if (strlen($stage) < 3) + {$stage = '670';} + + $stmt="select agent_lead_search_method,manual_dial_list_id from vicidial_campaigns where campaign_id='$campaign';"; + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00374',$user,$server_ip,$session_name,$one_mysql_log);} + $rslt=mysql_query($stmt, $link); + $camps_to_print = mysql_num_rows($rslt); + if ($camps_to_print > 0) + { + $row=mysql_fetch_row($rslt); + $agent_lead_search_method = $row[0]; + $manual_dial_list_id = $row[1]; + + $searchSQL=''; + $searchmethodSQL=''; + + $lead_id=ereg_replace("[^0-9]","",$lead_id); + $vendor_lead_code = ereg_replace("'|\"|\\\\|;","",$vendor_lead_code); + $last_name = ereg_replace("'|\"|\\\\|;","",$last_name); + $first_name = ereg_replace("'|\"|\\\\|;","",$first_name); + $city = ereg_replace("'|\"|\\\\|;","",$city); + $state = ereg_replace("'|\"|\\\\|;","",$state); + $postal_code = ereg_replace("'|\"|\\\\|;","",$postal_code); + + if (strlen($lead_id) > 0) + { + ### lead ID entered, search by this + $searchSQL = "lead_id='$lead_id'"; + } + elseif (strlen($vendor_lead_code) > 0) + { + ### vendor ID entered, search by this + $searchSQL = "vendor_lead_code='$vendor_lead_code'"; + } + elseif ( (strlen($phone_number) >= 6) and (strlen($search) > 2) ) + { + ### phone number entered, search by this + if (preg_match('/MAIN/',$search)) + {$searchSQL = "phone_number='$phone_number'";} + if (preg_match('/ALT/',$search)) + { + if (strlen($searchSQL) > 10) + {$searchSQL .= " or ";} + $searchSQL .= "alt_phone='$phone_number'"; + } + if (preg_match('/ADDR3/',$search)) + { + if (strlen($searchSQL) > 10) + {$searchSQL .= " or ";} + $searchSQL .= "address3='$phone_number'"; + } + } + elseif (strlen($last_name) > 0) + { + ### last name entered, search by this and other fields + $searchSQL = "last_name='$last_name'"; + if (strlen($first_name) > 0) + { + if (strlen($searchSQL) > 10) + {$searchSQL .= " and ";} + $searchSQL .= "first_name='$first_name'"; + } + if (strlen($city) > 0) + { + if (strlen($searchSQL) > 10) + {$searchSQL .= " and ";} + $searchSQL .= "city='$city'"; + } + if (strlen($state) > 0) + { + if (strlen($searchSQL) > 10) + {$searchSQL .= " and ";} + $searchSQL .= "state='$state'"; + } + if (strlen($postal_code) > 0) + { + if (strlen($searchSQL) > 10) + {$searchSQL .= " and ";} + $searchSQL .= "postal_code='$postal_code'"; + } + } + else + { + echo "ERROR: You must enter in search terms, one of these must be populated: lead ID, vendor ID, phone number, last name\n"; + echo "

"; + echo "Torna Indietro"; + echo "
"; + exit; + } + + $searchownerSQL=''; + ### limit results to specified search method + # USER_, GROUP_, TERRITORY_ + if (preg_match('/USER_/',$agent_lead_search_method)) + {$searchownerSQL=" and owner='$user'";} + if (preg_match('/GROUP_/',$agent_lead_search_method)) + { + $stmt="SELECT user_group from vicidial_users where user='$user';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00386',$user,$server_ip,$session_name,$one_mysql_log);} + $groups_to_parse = mysql_num_rows($rslt); + if ($groups_to_parse > 0) + { + $rowx=mysql_fetch_row($rslt); + $searchownerSQL=" and owner='$rowx[0]'"; + } + } + if (preg_match('/TERRITORY_/',$agent_lead_search_method)) + { + $agent_territories=''; + $agent_choose_territories=0; + $stmt="SELECT agent_choose_territories from vicidial_users where user='$user';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00404',$user,$server_ip,$session_name,$one_mysql_log);} + $Uterrs_to_parse = mysql_num_rows($rslt); + if ($Uterrs_to_parse > 0) + { + $rowx=mysql_fetch_row($rslt); + $agent_choose_territories = $rowx[0]; + } + + if ($agent_choose_territories < 1) + { + $stmt="SELECT territory from vicidial_user_territories where user='$user';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00405',$user,$server_ip,$session_name,$one_mysql_log);} + $vuts_to_parse = mysql_num_rows($rslt); + $o=0; + while ($vuts_to_parse > $o) + { + $rowx=mysql_fetch_row($rslt); + $agent_territories .= "'$rowx[0]',"; + $o++; + } + $agent_territories = preg_replace("/\,$/",'',$agent_territories); + $searchownerSQL=" and owner IN($agent_territories)"; + if ($vuts_to_parse < 1) + {$searchownerSQL=" and lead_id < 0";} + } + else + { + $stmt="SELECT agent_territories from vicidial_live_agents where user='$user';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00387',$user,$server_ip,$session_name,$one_mysql_log);} + $terrs_to_parse = mysql_num_rows($rslt); + if ($terrs_to_parse > 0) + { + $rowx=mysql_fetch_row($rslt); + $agent_territories = $rowx[0]; + $agent_territories = preg_replace("/ -$|^ /",'',$agent_territories); + $agent_territories = preg_replace("/ /","','",$agent_territories); + $searchownerSQL=" and owner IN('$agent_territories')"; + } + } + } + + ### limit results to specified search method + # 'SYSTEM','CAMPAIGNLISTS','CAMPLISTS_ALL','LIST' + if (preg_match('/SYSTEM/',$agent_lead_search_method)) + {$searchmethodSQL='';} + if (preg_match('/LIST/',$agent_lead_search_method)) + {$searchmethodSQL=" and list_id='$manual_dial_list_id'";} + if (preg_match('/CAMPLISTS_ALL/',$agent_lead_search_method)) + { + $stmt="SELECT list_id from vicidial_lists where campaign_id='$campaign';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00375',$user,$server_ip,$session_name,$one_mysql_log);} + $lists_to_parse = mysql_num_rows($rslt); + $camp_lists=''; + $o=0; + while ($lists_to_parse > $o) + { + $rowx=mysql_fetch_row($rslt); + $camp_lists .= "'$rowx[0]',"; + $o++; + } + $camp_lists = eregi_replace(".$","",$camp_lists); + $searchmethodSQL=" and list_id IN($camp_lists)"; + } + if (preg_match('/CAMPAIGNLISTS/',$agent_lead_search_method)) + { + $stmt="SELECT list_id,active from vicidial_lists where campaign_id='$campaign' and active='Y';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00376',$user,$server_ip,$session_name,$one_mysql_log);} + $lists_to_parse = mysql_num_rows($rslt); + $camp_lists=''; + $o=0; + while ($lists_to_parse > $o) + { + $rowx=mysql_fetch_row($rslt); + $camp_lists .= "'$rowx[0]',"; + $o++; + } + $camp_lists = eregi_replace(".$","",$camp_lists); + $searchmethodSQL=" and list_id IN($camp_lists)"; + } + + + ##### BEGIN search queries and output ##### + $stmt="select count(*) from vicidial_list where $searchSQL $searchownerSQL $searchmethodSQL;"; + + ### LOG INSERTION Search Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmtL="INSERT INTO vicidial_lead_search_log set event_date='$NOW_TIME', user='$user', source='agent', results='0', search_query=\"$SQL_log\";"; + if ($DB) {echo "|$stmtL|\n";} + $rslt=mysql_query($stmtL, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00377',$user,$server_ip,$session_name,$one_mysql_log);} + $search_log_id = mysql_insert_id($link); + + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00378',$user,$server_ip,$session_name,$one_mysql_log);} + $counts_to_print = mysql_num_rows($rslt); + if ($counts_to_print > 0) + { + $row=mysql_fetch_row($rslt); + $search_result_count = $row[0]; + + $end_process_time = date("U"); + $search_seconds = ($end_process_time - $StarTtime); + + $stmtL="UPDATE vicidial_lead_search_log set results='$search_result_count',seconds='$search_seconds' where search_log_id='$search_log_id';"; + if ($DB) {echo "|$stmtL|\n";} + $rslt=mysql_query($stmtL, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00379',$user,$server_ip,$session_name,$one_mysql_log);} + + + echo "
\n"; + echo ""; + echo "Results Found: $search_result_count"; + echo "\n"; + echo "
\n"; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + + if ($search_result_count) + { + $stmt="select first_name,last_name,phone_code,phone_number,status,last_local_call_time,lead_id,city,state,postal_code from vicidial_list where $searchSQL $searchownerSQL $searchmethodSQL order by last_local_call_time desc limit 1000;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00380',$user,$server_ip,$session_name,$one_mysql_log);} + $out_logs_to_print = mysql_num_rows($rslt); + if ($format=='debug') {echo "|$out_logs_to_print|$stmt|";} + + $g=0; + $u=0; + while ($out_logs_to_print > $u) + { + $row=mysql_fetch_row($rslt); + $ALLsort[$g] = "$row[0]-----$g"; + $ALLname[$g] = "$row[0] $row[1]"; + $ALLphone_code[$g] = $row[2]; + $ALLphone_number[$g] = $row[3]; + $ALLstatus[$g] = $row[4]; + $ALLcall_date[$g] = $row[5]; + $ALLlead_id[$g] = $row[6]; + $ALLcity[$g] = $row[7]; + $ALLstate[$g] = $row[8]; + $ALLpostal_code[$g] = $row[9]; + + $g++; + $u++; + } + + if ($g < 1) + {echo "";} + + $u=0; + while ($g > $u) + { + $sort_split = explode("-----",$ALLsort[$u]); + $i = $sort_split[1]; + + if (eregi("1$|3$|5$|7$|9$", $u)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + $u++; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } + + $end_process_time = date("U"); + $search_seconds = ($end_process_time - $StarTtime); + + $stmtL="UPDATE vicidial_lead_search_log set secondi='$search_seconds' where search_log_id='$search_log_id';"; + if ($DB) {echo "|$stmtL|\n";} + $rslt=mysql_query($stmtL, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00381',$user,$server_ip,$session_name,$one_mysql_log);} + } + else + {echo "";} + + echo "
  #     NAME     PHONE     STATO     LAST CHIAMATA     CITY     STATE     ZIP     INFO     CHIAMA  
No results found
$u$ALLname[$i] $ALLphone_code[$i] $ALLphone_number[$i] $ALLstatus[$i] $ALLcall_date[$i] $ALLcity[$i] $ALLstate[$i] $ALLpostal_code[$i] INFO DIAL
No results found
"; + echo "
"; + echo "Torna Indietro"; + echo "
"; + } + else + { + echo "ERROR: There was a problem with your search terms\n"; + echo "

"; + echo "Torna Indietro"; + echo ""; + exit; + } + ##### END search queries and output ##### + } + else + { + echo "ERROR: Campagna not found\n"; + echo "

"; + echo "Torna Indietro"; + echo ""; + exit; + } + } + + + +################################################################################ +### LEADINFOview - display the information for a lead and logs for that lead ################################################################################ if ($ACTION == 'LEADINFOview') { @@ -7549,7 +8594,41 @@ if ($ACTION == 'LEADINFOview') {echo "ERROR: no Lead ID";} else { + $hide_dial_links=0; + echo "
\n"; + + if ($search == 'logfirst') + {$hide_dial_links++;} + + ### BEGIN Display callback information ### + $callback_id = preg_replace('/\D/','',$callback_id); + if (strlen($callback_id) > 0) + { + $stmt="select status,entry_time,callback_time,modify_date,user,recipient,comments,lead_status from vicidial_callbacks where lead_id='$lead_id' and callback_id='$callback_id' limit 1;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00397',$user,$server_ip,$session_name,$one_mysql_log);} + $cb_to_print = mysql_num_rows($rslt); + if ($format=='debug') {echo "|$cb_to_print|$stmt|";} + if ($cb_to_print > 0) + { + $row=mysql_fetch_row($rslt); + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "
Callback Stato:   $row[0]
Callback Lead Stato:   $row[7]
Callback Entry Time:   $row[1]
Callback Trigger Time:   $row[2]
Callback Note:  $row[6]
"; + echo "
"; + $hide_dial_links++; + } + } + ### END Display callback information ### + + + ### BEGIN Display lead info and custom fields ### ### BEGIN find any custom field labels ### + $INFOout=''; $label_title = 'Titolo'; $label_first_name = 'Nome'; $label_middle_initial = 'MI'; @@ -7594,56 +8673,290 @@ if ($ACTION == 'LEADINFOview') if (strlen($row[18])>0) {$label_comments = $row[18];} ### END find any custom field labels ### - echo "
\n"; - echo ""; + $INFOout .= "
"; - $stmt="select status,vendor_lead_code,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,alt_phone,email,security_phrase,comments,called_count,last_local_call_time,rank,owner,entry_list_id from vicidial_list where lead_id='$lead_id'limit 1;"; + $stmt="select status,vendor_lead_code,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,alt_phone,email,security_phrase,comments,called_count,last_local_call_time,rank,owner,entry_list_id from vicidial_list where lead_id='$lead_id' limit 1;"; $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00398',$user,$server_ip,$session_name,$one_mysql_log);} $info_to_print = mysql_num_rows($rslt); - if ($format=='debug') {echo "|$out_logs_to_print|$stmt|";} + if ($format=='debug') {$INFOout .= "|$out_logs_to_print|$stmt|";} - if ($info_to_print > 0) + if ($info_to_print > 0) { $row=mysql_fetch_row($rslt); - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - # echo ""; - # echo ""; - # echo ""; + $INFOout .= ""; + $INFOout .= ""; + $INFOout .= ""; + $INFOout .= ""; + $INFOout .= ""; + $INFOout .= ""; + $INFOout .= ""; + $INFOout .= ""; + $INFOout .= ""; + $INFOout .= ""; + $INFOout .= ""; + $INFOout .= ""; + $INFOout .= ""; + $INFOout .= ""; + $INFOout .= ""; + $INFOout .= ""; + $INFOout .= ""; + $INFOout .= ""; + $INFOout .= ""; + $INFOout .= ""; + $INFOout .= ""; + $INFOout .= ""; + $INFOout .= ""; + $INFOout .= ""; + $INFOout .= ""; + $INFOout .= ""; + # $INFOout .= ""; + # $INFOout .= ""; + # $INFOout .= ""; + + $entry_list_id = $row[28]; + $CFoutput=''; + $stmt="SHOW TABLES LIKE \"custom_$entry_list_id\";"; + if ($DB>0) {$INFOout .= "$stmt";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00382',$user,$server_ip,$session_name,$one_mysql_log);} + $tablecount_to_print = mysql_num_rows($rslt); + if ($tablecount_to_print > 0) + { + $stmt="SELECT count(*) from custom_$entry_list_id where lead_id='$lead_id';"; + if ($DB>0) {$INFOout .= "$stmt";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00383',$user,$server_ip,$session_name,$one_mysql_log);} + $fieldscount_to_print = mysql_num_rows($rslt); + if ($fieldscount_to_print > 0) + { + $rowx=mysql_fetch_row($rslt); + $custom_records_count = $rowx[0]; + + $select_SQL=''; + $stmt="SHOW COLUMNS FROM custom_$entry_list_id where Field != 'lead_id';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00384',$user,$server_ip,$session_name,$one_mysql_log);} + $fields_to_print = mysql_num_rows($rslt); + $select_SQL=''; + $o=0; + while ($fields_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $select_SQL .= "$rowx[0],"; + $A_field_name[$o] = $rowx[0]; + $o++; + } + $select_SQL = preg_replace("/.$/",'',$select_SQL); + if (strlen($select_SQL) > 0) + { + $stmt="SELECT $select_SQL FROM custom_$entry_list_id where lead_id='$lead_id' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00385',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {$INFOout .= "$stmt\n";} + $list_lead_ct = mysql_num_rows($rslt); + if ($list_lead_ct > 0) + { + $row=mysql_fetch_row($rslt); + $o=0; + while ($fields_to_print > $o) + { + $A_field_value = trim("$row[$o]"); + + $INFOout .= ""; + + $o++; + } + } + } + } + } } - echo "
Stato:   $row[0]
$label_vendor_lead_code:   $row[1]
List ID:   $row[2]
Timezone:   $row[3]
Chiamato Since Cognome Reset:   $row[4]
$label_phone_code:   $row[5]
$label_phone_number:   $row[6] -         DIAL
$label_title:   $row[7]
$label_first_name:   $row[8]
$label_middle_initial:   $row[9]
$label_last_name:   $row[10]
$label_address1:   $row[11]
$label_address2:   $row[12]
$label_address3:   $row[13]
$label_city:   $row[14]
$label_state:   $row[15]
$label_province:   $row[16]
$label_postal_code:   $row[17]
Country:   $row[18]
$label_gender:   $row[19]
$label_alt_phone:   $row[20] -         DIAL
$label_email:   $row[21]
$label_security_phrase:   $row[22]
$label_comments:   $row[23]
Chiamato Count:   $row[24]
Cognome Local Call Time:   $row[25]
Rank:   $row[26]
Owner:   $row[27]
Entry List ID:   $row[28]
Stato:   $row[0]
$label_vendor_lead_code:   $row[1]
List ID:   $row[2]
Timezone:   $row[3]
Chiamato Since Cognome Reset:   $row[4]
$label_phone_code:   $row[5]
$label_phone_number:   $row[6] -         "; + if ($hide_dial_links < 1) + {$INFOout .= "DIAL";} + $INFOout .= "
$label_title:   $row[7]
$label_first_name:   $row[8]
$label_middle_initial:   $row[9]
$label_last_name:   $row[10]
$label_address1:   $row[11]
$label_address2:   $row[12]
$label_address3:   $row[13]
$label_city:   $row[14]
$label_state:   $row[15]
$label_province:   $row[16]
$label_postal_code:   $row[17]
Country:   $row[18]
$label_gender:   $row[19]
$label_alt_phone:   $row[20] -         "; + if ($hide_dial_links < 1) + {$INFOout .= "DIAL";} + $INFOout .= "
$label_email:   $row[21]
$label_security_phrase:   $row[22]
$label_comments:   $row[23]
Chiamato Count:   $row[24]
Cognome Local Call Time:   $row[25]
Rank:   $row[26]
Owner:   $row[27]
Entry List ID:   $row[28]
$A_field_name[$o]:   $A_field_value
"; - echo "
"; - echo "Close Info Box"; + $INFOout .= ""; + $INFOout .= "
"; + ### END Display lead info and custom fields ### + + + ### BEGIN Gather Call Log and notes ### + $NOTESout=''; + if ($search != 'logfirst') + {$NOTESout .= "
CALL LOG FOR THIS LEAD:
\n";} + $NOTESout .= ""; + $NOTESout .= ""; + $NOTESout .= ""; + $NOTESout .= ""; + $NOTESout .= ""; + $NOTESout .= ""; + $NOTESout .= ""; + $NOTESout .= ""; + $NOTESout .= ""; + $NOTESout .= ""; + $NOTESout .= ""; + $NOTESout .= ""; + # $NOTESout .= ""; + # $NOTESout .= ""; + $NOTESout .= ""; + + + $stmt="select start_epoch,call_date,campaign_id,length_in_sec,status,phone_code,phone_number,lead_id,term_reason,alt_dial,comments,uniqueid,user from vicidial_log where lead_id='$lead_id' order by call_date desc limit 10000;"; + $rslt=mysql_query($stmt, $link); + $out_logs_to_print = mysql_num_rows($rslt); + if ($format=='debug') {$NOTESout .= "|$out_logs_to_print|$stmt|";} + + $g=0; + $u=0; + while ($out_logs_to_print > $u) + { + $row=mysql_fetch_row($rslt); + $ALLsort[$g] = "$row[0]-----$g"; + $ALLstart_epoch[$g] = $row[0]; + $ALLcall_date[$g] = $row[1]; + $ALLcampaign_id[$g] = $row[2]; + $ALLlength_in_sec[$g] = $row[3]; + $ALLstatus[$g] = $row[4]; + $ALLphone_code[$g] = $row[5]; + $ALLphone_number[$g] = $row[6]; + $ALLlead_id[$g] = $row[7]; + $ALLhangup_reason[$g] = $row[8]; + $ALLalt_dial[$g] = $row[9]; + $ALLuniqueid[$g] = $row[11]; + $ALLuser[$g] = $row[12]; + $ALLin_out[$g] = "OUT-AUTO"; + if ($row[10] == 'MANUAL') {$ALLin_out[$g] = "OUT-MANUAL";} + + $stmtA="SELECT call_notes FROM vicidial_call_notes WHERE lead_id='$ALLlead_id[$g]' and vicidial_id='$ALLuniqueid[$g]';"; + $rsltA=mysql_query($stmtA, $link); + $out_notes_to_print = mysql_num_rows($rslt); + if ($out_notes_to_print > 0) + { + $rowA=mysql_fetch_row($rsltA); + $Allcall_notes[$g] = $rowA[0]; + if (strlen($Allcall_notes[$g]) > 0) + {$Allcall_notes[$g] = "NOTES: $Allcall_notes[$g]";} + } + $stmtA="SELECT full_name FROM vicidial_users WHERE user='$ALLuser[$g]';"; + $rsltA=mysql_query($stmtA, $link); + $users_to_print = mysql_num_rows($rslt); + if ($users_to_print > 0) + { + $rowA=mysql_fetch_row($rsltA); + $ALLuser[$g] .= " - $rowA[0]"; + } + + $Allcounter[$g] = $g; + + $g++; + $u++; + } + + $stmt="select start_epoch,call_date,campaign_id,length_in_sec,status,phone_code,phone_number,lead_id,term_reason,queue_seconds,uniqueid,closecallid,user from vicidial_closer_log where lead_id='$lead_id' order by call_date desc limit 10000;"; + $rslt=mysql_query($stmt, $link); + $in_logs_to_print = mysql_num_rows($rslt); + if ($format=='debug') {$NOTESout .= "|$in_logs_to_print|$stmt|";} + + $u=0; + while ($in_logs_to_print > $u) + { + $row=mysql_fetch_row($rslt); + $ALLsort[$g] = "$row[0]-----$g"; + $ALLstart_epoch[$g] = $row[0]; + $ALLcall_date[$g] = $row[1]; + $ALLcampaign_id[$g] = $row[2]; + $ALLlength_in_sec[$g] = ($row[3] - $row[9]); + if ($ALLlength_in_sec[$g] < 0) {$ALLlength_in_sec[$g]=0;} + $ALLstatus[$g] = $row[4]; + $ALLphone_code[$g] = $row[5]; + $ALLphone_number[$g] = $row[6]; + $ALLlead_id[$g] = $row[7]; + $ALLhangup_reason[$g] = $row[8]; + $ALLuniqueid[$g] = $row[10]; + $ALLclosecallid[$g] = $row[11]; + $ALLuser[$g] = $row[12]; + $ALLalt_dial[$g] = "MAIN"; + $ALLin_out[$g] = "IN"; + + $stmtA="SELECT call_notes FROM vicidial_call_notes WHERE lead_id='$ALLlead_id[$g]' and vicidial_id='$ALLclosecallid[$g]';"; + $rsltA=mysql_query($stmtA, $link); + $in_notes_to_print = mysql_num_rows($rslt); + if ($in_notes_to_print > 0) + { + $rowA=mysql_fetch_row($rsltA); + $Allcall_notes[$g] = $rowA[0]; + if (strlen($Allcall_notes[$g]) > 0) + {$Allcall_notes[$g] = "NOTES: $Allcall_notes[$g]";} + } + $stmtA="SELECT full_name FROM vicidial_users WHERE user='$ALLuser[$g]';"; + $rsltA=mysql_query($stmtA, $link); + $users_to_print = mysql_num_rows($rslt); + if ($users_to_print > 0) + { + $rowA=mysql_fetch_row($rsltA); + $ALLuser[$g] .= " - $rowA[0]"; + } + + $Allcounter[$g] = $g; + + $g++; + $u++; + } + + if ($g > 0) + {sort($ALLsort, SORT_NUMERIC);} + else + {$NOTESout .= "";} + + $u=0; + while ($g > $u) + { + $sort_split = explode("-----",$ALLsort[$u]); + $i = $sort_split[1]; + + if (eregi("1$|3$|5$|7$|9$", $u)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + $u++; + $NOTESout .= ""; + $NOTESout .= ""; + $NOTESout .= ""; + $NOTESout .= "\n"; + $NOTESout .= "\n"; + $NOTESout .= "\n"; + $NOTESout .= "\n"; + $NOTESout .= "\n"; + $NOTESout .= "\n"; + $NOTESout .= "\n"; + $NOTESout .= "\n"; + $NOTESout .= ""; + $NOTESout .= ""; + $NOTESout .= ""; + $NOTESout .= "\n"; + } + + $NOTESout .= "
  #     DATE/TIME     AGENT     LENGTH     STATO     PHONE     CAMPAIGN     IN/OUT     ALT     HANGUP  
  FULL NAME  
No calls found
$u$ALLcall_date[$i] $ALLuser[$i] $ALLlength_in_sec[$i] $ALLstatus[$i] $ALLphone_code[$i] $ALLphone_number[$i] $ALLcampaign_id[$i] $ALLin_out[$i] $ALLalt_dial[$i] $ALLhangup_reason[$i]
$Allcall_notes[$i]
"; + $NOTESout .= "
"; + ### END Gather Call Log and notes ### + + + if ($search == 'logfirst') + {echo "$NOTESout\n$INFOout\n";} + else + {echo "$INFOout\n$NOTESout\n";} + echo "
"; } } + ################################################################################ ### CALLSINQUEUEgrab - grab a call in queue and reserve it for that agent ################################################################################ @@ -7846,44 +9159,23 @@ if ($ACTION == 'Clear_API_Field') if ($format=='debug') -{ -$ENDtime = date("U"); -$RUNtime = ($ENDtime - $StarTtime); -echo "\n"; -echo "\n\n\n"; -} + { + $ENDtime = date("U"); + $RUNtime = ($ENDtime - $StarTtime); + echo "\n"; + echo "\n\n\n"; + } exit; ##### Hangup Cause Description Map ##### function hangup_cause_description($code) -{ -global $hangup_cause_dictionary; -if ( array_key_exists($code,$hangup_cause_dictionary) ) { return $hangup_cause_dictionary[$code]; } -else { return "Unidentified Hangup Cause Code."; } -} - - -##### MySQL Error Logging ##### -function mysql_error_logging($NOW_TIME,$link,$mel,$stmt,$query_id,$user,$server_ip,$session_name,$one_mysql_log) -{ -$NOW_TIME = date("Y-m-d H:i:s"); -# mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00001',$user,$server_ip,$session_name,$one_mysql_log); -$errno=''; $error=''; -if ( ($mel > 0) or ($one_mysql_log > 0) ) { - $errno = mysql_errno($link); - if ( ($errno > 0) or ($mel > 1) or ($one_mysql_log > 0) ) - { - $error = mysql_error($link); - $efp = fopen ("./vicidial_mysql_errors.txt", "a"); - fwrite ($efp, "$NOW_TIME|vdc_db_query|$query_id|$errno|$error|$stmt|$user|$server_ip|$session_name|\n"); - fclose($efp); - } + global $hangup_cause_dictionary; + if ( array_key_exists($code,$hangup_cause_dictionary) ) { return $hangup_cause_dictionary[$code]; } + else { return "Unidentified Hangup Cause Code."; } } -$one_mysql_log=0; -return $errno; -} + ?> diff --git a/agc_2-X/trunk/LANG_www/agc_it/vicidial.php b/agc_2-X/trunk/LANG_www/agc_it/vicidial.php index 40498dc8..44e593e3 100644 --- a/agc_2-X/trunk/LANG_www/agc_it/vicidial.php +++ b/agc_2-X/trunk/LANG_www/agc_it/vicidial.php @@ -1,7 +1,7 @@ LICENSE: AGPLv2 +# Copyright (C) 2011 Matt Florell LICENSE: AGPLv2 # # Other scripts that this application depends on: # - vdc_db_query.php: Updates information in the database @@ -320,12 +320,35 @@ # 101008-0356 - Added manual_preview_dial and two new variables for recording filenames # 101012-1656 - Added scroll command at dispo submission to for scrolling to the top of the screen # 101024-1639 - Added parked call counter +# 101108-0110 - Added ADDMEMBER option for queue_log +# 101124-0436 - Added manual dial queue and manual dial call time check features +# 101125-2151 - Changed CIDname for 3way calls +# 101128-0102 - Added list webform override options +# 101207-1621 - Added scroll to the top after in-group, pause code, etc... selections, and added focus blur to several functions +# 101208-1210 - Fixed focus/blur coding to work after Dispo +# 101216-1758 - Added the ability to hide fields if the label is set to ---HIDE--- in System Settings +# 101227-1645 - Added dialplan off toggle options, and settings and code changes for top bar webphone +# 110109-1205 - Added queuemetrics_loginout NONE option +# 110112-1254 - Added options.php option for focus/blur/enter functions +# 110129-1050 - Changed to XHTML compliant formatting, issue #444 +# 110208-1202 - Made scheduled callbacks notice move when on script/form tabs +# 110212-2206 - Added scheduled callback custom statuses compatibility +# 110215-1412 - Added my_callback_option and per_call_notes options +# 110218-1522 - Added agent_lead_search feature +# 110221-1251 - Changed statuses display to keep track of non-selectable statuses +# 110224-1713 - Added compatibility with QM phone environment logging, QM pause code last call logging and active server twin check +# 110225-1231 - Changed scheduled callbacks list to allow clicking to see lead info without dialing, and separate dial link +# 110303-2321 - Added notice of on-hook phone use, and ability to click 'ring' to call into session, minor queue_log fix +# 110304-1623 - Added callback count notification defer options +# 110310-0331 - Added auto-pause/resume functions in auto-dial mode for pre-call work +# 110310-1627 - Changed most browser alerts to HTML alerts, other bug fixes +# 110322-0923 - Allowed hiding of gender pulldown # -$version = '2.4-297'; -$build = '101024-1639'; +$version = '2.4-320c'; +$build = '110322-0923'; $mel=1; # Mysql Error Log enabled = 1 -$mysql_log_count=68; +$mysql_log_count=72; $one_mysql_log=0; require("dbconnect.php"); @@ -400,6 +423,8 @@ $month_old = mktime(11, 0, 0, date("m"), date("d")-2, date("Y")); $past_month_date = date("Y-m-d H:i:s",$month_old); $minutes_old = mktime(date("H"), date("i")-2, date("s"), date("m"), date("d"), date("Y")); $past_minutes_date = date("Y-m-d H:i:s",$minutes_old); +$webphone_width = 460; +$webphone_height = 500; $random = (rand(1000000, 9999999) + 10000000); @@ -435,52 +460,57 @@ if ($qm_conf_ct > 0) ##### DEFINABLE SETTINGS AND OPTIONS ########################################### +# set defaults for hard-coded variables +$conf_silent_prefix = '5'; # vicidial_conferences prefix to enter silently and muted for recording +$dtmf_silent_prefix = '7'; # vicidial_conferences prefix to enter silently +$HKuser_level = '5'; # minimum vicidial user_level for HotKeys +$campaign_login_list = '1'; # show drop-down list of campaigns at login +$manual_dial_preview = '1'; # allow preview lead option when manual dial +$multi_line_comments = '1'; # set to 1 to allow multi-line comment box +$user_login_first = '0'; # set to 1 to have the vicidial_user login before the phone login +$view_scripts = '1'; # set to 1 to show the SCRIPTS tab +$dispo_check_all_pause = '0'; # set to 1 to allow for persistent pause after dispo +$callholdstatus = '1'; # set to 1 to show calls su hold count +$agentcallsstatus = '0'; # set to 1 to show agent status and call dialed count + $campagentstatctmax = '3'; # Number of secondi for campaign call and agent stats +$show_campname_pulldown = '1'; # set to 1 to show campaign name su login pulldown +$webform_sessionname = '1'; # set to 1 to include the session_name in webform URL +$local_consult_xfers = '1'; # set to 1 to send consultative transfers from original server +$clientDST = '1'; # set to 1 to check for DST su server for agent time +$no_delete_sessions = '1'; # set to 1 to not delete sessions at logout +$volumecontrol_active = '1'; # set to 1 to allow agents to alter volume of channels +$PreseT_DiaL_LinKs = '0'; # set to 1 to show a CHIAMA link for Dial Presets +$LogiNAJAX = '1'; # set to 1 to do lookups su campaigns for login +$HidEMonitoRSessionS = '1'; # set to 1 to hide remote monitoring channels from "session calls" +$hangup_all_non_reserved= '1'; # set to 1 to force hangup all non-reserved channels upon Riaggancia il cliente +$LogouTKicKAlL = '1'; # set to 1 to hangup all calls in session upon agent logout +$PhonESComPIP = '1'; # set to 1 to log computer IP to phone if blank, set to 2 to force log each login +$DefaulTAlTDiaL = '0'; # set to 1 to enable ALT CHIAMA by default if enabled for the campaign +$AgentAlert_allowed = '1'; # set to 1 to allow Agent alert option +$disable_blended_checkbox='0'; # set to 1 to disable the BLENDED checkbox from the in-group chooser screen +$hide_timeclock_link = '0'; # set to 1 to hide the timeclock link su the agent login screen +$conf_check_attempts = '3'; # number of attempts to try before loosing webserver connection, for bad network setups +$focus_blur_enabled = '0'; # set to 1 to enable the focus/blur enter key blocking(some IE instances have issues) +$TEST_all_statuses = '0'; # TEST variable allows all statuses in dispo screen + +$stretch_dimensions = '1'; # sets the vicidial screen to the size of the browser window +$BROWSER_HEIGHT = 500; # set to the minimum browser height, default=500 +$BROWSER_WIDTH = 770; # set to the minimum browser width, default=770 +$webphone_width = 460; # set the webphone frame width +$webphone_height = 500; # set the webphone frame height +$webphone_pad = 0; # set the table cellpadding for the webphone +$webphone_location = 'right'; # set the location su the agent screen 'right' or 'bar' +$MAIN_COLOR = '#CCCCCC'; # old default is E0C2D6 +$SCRIPT_COLOR = '#E6E6E6'; # old default is FFE7D0 +$FORM_COLOR = '#EFEFEF'; +$SIDEBAR_COLOR = '#F6F6F6'; + +# if options file exists, use the override values for the above variables +# see the options-example.php file for more information if (file_exists('options.php')) { require('options.php'); } -else - { - $conf_silent_prefix = '5'; # vicidial_conferences prefix to enter silently and muted for recording - $dtmf_silent_prefix = '7'; # vicidial_conferences prefix to enter silently - $HKuser_level = '5'; # minimum vicidial user_level for HotKeys - $campaign_login_list = '1'; # show drop-down list of campaigns at login - $manual_dial_preview = '1'; # allow preview lead option when manual dial - $multi_line_comments = '1'; # set to 1 to allow multi-line comment box - $user_login_first = '0'; # set to 1 to have the vicidial_user login before the phone login - $view_scripts = '1'; # set to 1 to show the SCRIPTS tab - $dispo_check_all_pause = '0'; # set to 1 to allow for persistent pause after dispo - $callholdstatus = '1'; # set to 1 to show calls su hold count - $agentcallsstatus = '0'; # set to 1 to show agent status and call dialed count - $campagentstatctmax = '3'; # Number of secondi for campaign call and agent stats - $show_campname_pulldown = '1'; # set to 1 to show campaign name su login pulldown - $webform_sessionname = '1'; # set to 1 to include the session_name in webform URL - $local_consult_xfers = '1'; # set to 1 to send consultative transfers from original server - $clientDST = '1'; # set to 1 to check for DST su server for agent time - $no_delete_sessions = '1'; # set to 1 to not delete sessions at logout - $volumecontrol_active = '1'; # set to 1 to allow agents to alter volume of channels - $PreseT_DiaL_LinKs = '0'; # set to 1 to show a CHIAMA link for Dial Presets - $LogiNAJAX = '1'; # set to 1 to do lookups su campaigns for login - $HidEMonitoRSessionS = '1'; # set to 1 to hide remote monitoring channels from "session calls" - $hangup_all_non_reserved= '1'; # set to 1 to force hangup all non-reserved channels upon Riaggancia il cliente - $LogouTKicKAlL = '1'; # set to 1 to hangup all calls in session upon agent logout - $PhonESComPIP = '1'; # set to 1 to log computer IP to phone if blank, set to 2 to force log each login - $DefaulTAlTDiaL = '0'; # set to 1 to enable ALT CHIAMA by default if enabled for the campaign - $AgentAlert_allowed = '1'; # set to 1 to allow Agent alert option - $disable_blended_checkbox='0'; # set to 1 to disable the BLENDED checkbox from the in-group chooser screen - $hide_timeclock_link = '0'; # set to 1 to hide the timeclock link su the agent login screen - $conf_check_attempts = '3'; # number of attempts to try before loosing webserver connection, for bad network setups - - $TEST_all_statuses = '0'; # TEST variable allows all statuses in dispo screen - - $stretch_dimensions = '1'; # sets the vicidial screen to the size of the browser window - $BROWSER_HEIGHT = 500; # set to the minimum browser height, default=500 - $BROWSER_WIDTH = 770; # set to the minimum browser width, default=770 - $MAIN_COLOR = '#CCCCCC'; # old default is E0C2D6 - $SCRIPT_COLOR = '#E6E6E6'; # old default is FFE7D0 - $FORM_COLOR = '#EFEFEF'; - $SIDEBAR_COLOR = '#F6F6F6'; - } ### BEGIN find any custom field labels ### $label_title = 'Titolo'; @@ -527,6 +557,10 @@ if (strlen($row[17])>0) {$label_email = $row[17];} if (strlen($row[18])>0) {$label_comments = $row[18];} ### END find any custom field labels ### +$hide_gender=0; +if ($label_gender == '---HIDE---') + {$hide_gender=1;} + $US='_'; $CL=':'; $AT='@'; @@ -550,14 +584,20 @@ if (strlen($static_agent_url) > 5) 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 -echo "\n"; -echo "\n"; +echo ' + + + + + + +'; echo "\n"; echo "\n"; if ($campaign_login_list > 0) { - $camp_form_code = "\n"; $camp_form_code .= "\n"; $LOGallowed_campaignsSQL=''; @@ -634,7 +674,7 @@ if ($campaign_login_list > 0) if ($VD_campaign) { if ( (eregi("$VD_campaign",$rowx[0])) and (strlen($VD_campaign) == strlen($rowx[0])) ) - {$camp_form_code .= "\n";} + {$camp_form_code .= "\n";} else { if (!ereg('login_allowable_campaigns',$camp_form_code)) @@ -652,7 +692,7 @@ if ($campaign_login_list > 0) } else { - $camp_form_code = "\n"; + $camp_form_code = "\n"; } @@ -660,29 +700,32 @@ if ($LogiNAJAX > 0) { ?> - @@ -11211,327 +11995,423 @@ else \n"; -$zi=1; +$zi=2; ?> - -
+ + + - height=>
-
-
-
-
-
-
-           Loading -
-
-
+
+
+
+
+
+
+
+           Loading +
+
+
- MARGINWIDTH=0 MARGINHEIGHT=0 LEFTMARGIN=0 TOPMARGIN=0 VALIGN=TOP ALIGN=LEFT> - +
- - - + + -
+ + + Loggato come Utente - -     - + ring)";} + echo "  nella campagna: $VD_campaign  \n"; + ?> +     + 0) {echo "TERRITORIES     \n";} ?> 0) {echo "GROUPS     \n";} ?> LOGOUT\n"; ?> -
+
- height=30> - - - +
MAINSCRIPT
+ + + 0) - {echo "\n";} + {echo "\n";} ?> - - - -
MAINSCRIPT \"FORM\"\"FORM\" VALIGN=MIDDLE ALIGN=CENTER>  LIVE   session ID:    Chiamata in corso
+   LIVE   session ID:     + Chiamata in corso + +
- height=>

Agent Screen
+

Agent Screen
- id="MainTable"> - - - - - - -
STATO:
+ + + + - +
+
\n"; + } + ?> + STATO:
- Chiama il prossimo numero
- ANTEPRIMA CLIENTE
- CHIAMA ALT NUM
+ Chiama il prossimo numero
+ + + ANTEPRIMA CLIENTE
+ CHIAMA ALT NUM
- FILE REGISTRAZIONE:
+ FILE REGISTRAZIONE:
-
- ID RECORD:
+
+ ID RECORD:
- Inizia Registrazione
-
- Web Form
+ Inizia Registrazione
+
+ Web Form
0) - {echo "\"Web
\n";} + {echo "\"Web
\n";} ?> -  
- Metti in attesa la chiamata
+  
+ Metti in attesa la chiamata
\"IVR
\n";} + {echo "\"IVR
\n";} else - {echo "\n";} + {echo "\n";} ?> - Trasferimento - Conferenza
+ Trasferimento - Conferenza
0) - {echo "\"Quick
\n";} + {echo "\"Quick
\n";} ?> 0) - {echo "
\n";} + {echo "
\n";} ?> -
- Riaggancia il cliente
-
-
Trasmetti Tono Tastiera

+
+ Riaggancia il cliente
+
+
Trasmetti Tono Tastiera

align=left valign=top> - - - - - - - - - - - - - + + + + + + + + + + + + + + - - - +
  Customer Time:                         Canale:
+ + - + -
  Customer Time:                         Canale:
Dati Cliente: Dati Cliente:         + LEAD SEARCH";} + ?> +
+ + + + -
+ ";} + else + {echo "$label_title: ";} + if ($label_first_name == '---HIDE---') + {echo "  ";} + else + {echo "  $label_first_name: ";} + if ($label_middle_initial == '---HIDE---') + {echo "  ";} + else + {echo "  $label_middle_initial: ";} + if ($label_last_name == '---HIDE---') + {echo "  ";} + else + {echo "  $label_last_name: ";} + + echo "
"; + + if ($label_address1 == '---HIDE---') + {echo " ";} + else + {echo "$label_address1: ";} + + echo "
"; + + if ($label_address2 == '---HIDE---') + {echo " ";} + else + {echo "$label_address2: ";} + + echo ""; + + if ($label_address3 == '---HIDE---') + {echo " ";} + else + {echo "$label_address3: ";} + + echo "
"; + + if ($label_city == '---HIDE---') + {echo " ";} + else + {echo "$label_city: ";} + + echo ""; + + if ($label_state == '---HIDE---') + {echo " ";} + else + {echo "$label_state: ";} + + echo ""; + + if ($label_postal_code == '---HIDE---') + {echo " ";} + else + {echo "$label_postal_code: ";} + + echo "
"; + + if ($label_province == '---HIDE---') + {echo " ";} + else + {echo "$label_province: ";} + + echo ""; + + if ($label_vendor_lead_code == '---HIDE---') + {echo " ";} + else + {echo "$label_vendor_lead_code: ";} + + echo ""; + + if ($label_gender == '---HIDE---') + { + echo ""; + } + else + { + echo "$label_gender: "; + } + + echo "
"; + + echo "$label_phone_number: "; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
:   :   :   :
:
: :
: : :
: : :
: -                     "; - echo ""; + echo "                     "; + echo ""; } else { - echo ""; + echo ""; } - ?> - : :
: :
: - - \n";} + echo ""; + + if ($label_phone_code == '---HIDE---') + {echo " ";} else - {echo "\n";} + {echo "$label_phone_code: ";} + + echo ""; + + if ($label_alt_phone == '---HIDE---') + {echo " ";} + else + {echo "$label_alt_phone: ";} + + echo "
"; + + if ($label_security_phrase == '---HIDE---') + {echo " ";} + else + {echo "$label_security_phrase: ";} + + echo ""; + + if ($label_email == '---HIDE---') + {echo " ";} + else + {echo "$label_email: ";} + + echo "
"; + + if ($label_comments == '---HIDE---') + { + echo " \n"; + } + else + { + echo "$label_comments: "; + if ( ($multi_line_comments) ) + {echo "\n";} + else + {echo "\n";} + } + + echo "
\n"; + + if ($per_call_notes == 'ENABLED') + { + echo "Call Note: "; + if ($agent_call_log_view == '1') + {echo "
view notes ";} + echo "
"; + echo "\n"; + } + else + { + echo " \n"; + } + + ?>
+
+
> +
 
+
 
+ - +
+ -CHIAMATA MANUALE       CHIAMATA VELOCE
-
- - -X RICHIAMI ATTIVI
+CHIAMATA MANUALE       CHIAMATA VELOCE
-
+
-VIEW CHIAMATA LOG
+VIEW CHIAMATA LOG
- -     - >
Agent web-client version:     BUILD:               Server:              
+ +     + - - + - +
VERSIONE:   BUILD:     Server:              
Mostra le informazioni relative al canale della conferenza -

 
+

 
+
0) ) {echo "Alert is ON";} else {echo "Alert is OFF";} ?> -
+
- -
+ +
0) && ( ($user_level>=$HKuser_level) or ($VU_hotkeys_active > 0) ) ) { ?> -TASTI FUNZIONE DISATTIVATI +TASTI FUNZIONE DISATTIVATI - secondi: -     + secondi: +     -
+
-Il tuo stato:
Calls Dialing: +Il tuo stato:
Calls Dialing:
- + D1 - CHIAMA\n"; - echo "
\n"; + echo "   \n"; echo "D2 - CHIAMA\n"; } - else {echo "
\n";} + else {echo "
\n";} ?> -

 
+

 
-
 Chiamate in coda:  
 
+
 Chiamate in coda:  
 
- + 0) { @@ -11543,20 +12423,35 @@ if ($view_calls_in_queue > 0) ?> -
  -Stato Altri Operatori:  
 
+ +X RICHIAMI ATTIVI
+
-
  -Web Telefono:  
+
  +Stato Altri Operatori:  
 
-
Agents View +
+$webphone_content
\n"; + } +else + { + echo "
  + Web Telefono:  
$webphone_content
\n"; + } +?> + + +
Agents View +
-
  WebTelefono View -
+
  WebTelefono View -
0) { - echo "Dialable Leads:
 \n"; + echo "Dialable Leads:
 \n"; } ?>
- - height=>
AGENT SCRIPT
+ +
\n";} + ?> +
AGENT SCRIPT
- + refresh - - height=>
+ +
\n";} + ?> +
- + refresh - > - -
+ + + -
- Trasferimento - Conferenza            
+ Trasferimento - Conferenza            
- - -
- + + + - - + LOCAL CLOSER     + + + - - + - - - + channel + + + + - - + - - - + OPERATORI + + + + + + + - - + - + Blind Transfer VMail Message + + -
+ - LOCAL CLOSER     - - Riaggancia la linea trasferita -
+ Riaggancia la linea trasferita +
- seconds +
+ seconds   - channel - - CONSULTIVO   - - Riaggancia entrambe le linee -
+ CONSULTIVO   + + Riaggancia entrambe le linee +
- Numero da chiamare +
+ Numero da chiamare   -                     +                     -   +   - OPERATORI - - - - - CHIAMA OVERRIDE - - LASCIA LA CONFERENZA A 3 -
+ CHIAMA OVERRIDE + + LASCIA LA CONFERENZA A 3 +
- Effettua il Blind Transfer +
+ Effettua il Blind Transfer   - Chiama il Cliente + Chiama il Cliente   - Metti in attesa il cliente + Metti in attesa il cliente   - Presets Button + Presets Button 0) } ?>   - Blind Transfer VMail Message -
+
+
-
-Trasferimento Operatori Disponibili:
+
+Trasferimento Operatori Disponibili:
- height=70> - -
Esito Contatto:

- -
-
+ + +
Esito Contatto:

+ -
+
- height=70> - +
Tasti Funzione per Esiti: + + - - + - + -
Tasti Funzione per Esiti: Se attivo, premi il tasto corrispondente all`esito desiderato e la chiamata sarà riagganciata automaticamente:
+ - + - + -
+
- height=70> - - - +
Informazioni richiamo precedente: close
+ + + - - + -
Informazioni richiamo precedente: close
-
-
-
-
+ +
+
+
+
-
+
+ - height=70> - - - +
Informazioni Estese Numero Alternativo: riduci
+ + + - - + -
Informazioni Estese Numero Alternativo: riduci
-
-
-
-
+
+
+
+
+
-
+
+ - - - -
ingrandisci
Alt Telefono Info
+ + + +
ingrandisci
Alt Telefono Info
- height=>
Non c`è nessuno nella tua sessione:
+
Non c`è nessuno nella tua sessione:
Torna Indietro -

+

Chiama l`operatore di nuovo -
+
- height=>
Il cliente ha riagganciato:
+
Il cliente ha riagganciato:
Torna Indietro -

+

Termina e definisci un Esito per la chiamata -
+
- height=>
Riposo prima della prossima chiamata: secondi di riposo restanti

+
Riposo prima della prossima chiamata: secondi di riposo restanti

-

+

Termina riposo e continua -
+
-
-


+
+


Chiudi Messaggio -
+
- height=>
La tua sessione è stata disabilitata
LOGOUT

Torna Indietro -
+
La tua sessione è stata disabilitata
LOGOUT

Torna Indietro +
- height=>
C`è un problema di sincronizzazione con il sistema, si prega di informare l`amministratore di sistema


Torna Indietro -
+
C`è un problema di sincronizzazione con il sistema, si prega di informare l`amministratore di sistema


Torna Indietro +
- height=>

LOGOUT
+

LOGOUT
-
+
-
 
+
 
- height=47>
Tutti i cambiamenti eseguiti sui dati del cliente non saranno salvati, bisogna effettuare le modifiche prima di riagganciare.
+
Tutti i cambiamenti eseguiti sui dati del cliente non saranno salvati, bisogna effettuare le modifiche prima di riagganciare.
- height=>
ESITO CHIAMATA :       Aggancia di nuovo       riduci
+
ESITO CHIAMATA :       Aggancia di nuovo       riduci
+
\n";} + ?> + + Selezione Esito di fine chiamata -
- PAUSA OPERATORE
+
+ PAUSA OPERATORE
PULISCI IL FORM | INVIA -

+

WEB FORM INVIA -

  -
+

  +
- height=>
Selezionare una data di richiamo! :
- - +
Selezionare una data di richiamo! :
+
\n";} + ?> + + Seleziona una data qui sotto       Ora: - @@ -11858,7 +12771,7 @@ Trasferimento Operatori Disponibili: 12   Minuti: - @@ -11873,165 +12786,317 @@ Trasferimento Operatori Disponibili: 55   - -  
+  
RICHIAMO PERSONALE
";} + {echo " RICHIAMO PERSONALE
";} ?> - Note Richiamo:

+ Note Richiamo:

- INVIA

+ INVIA

-

  -
+

  +
- height=>
RICHIAMI PER L`OPERATORE :
Selezionare un richiamo per chiamare il cliente ora. Una volta fatto click, il record sarà rimosso dalla lista. -
+
RICHIAMI PER L`OPERATORE :
To see information su one of the callbacks below, click su the INFO link. To call the customer back now, click su the CHIAMA link. If you click su a record below to dial it, it will be removed from the list. +
+
\n";} + ?>
-
  +
  Aggiorna                 - Torna Indietro -
+ Torna Indietro +
- height=>
NUOVA CHIAMATA MANUALE PER IL CONTATTO :

Inserisci le informazioni per il nuovo contatto da chiamare. -
+
NUOVA CHIAMATA MANUALE PER IL CONTATTO :

Inserisci le informazioni per il nuovo contatto da chiamare. +
\n"; + echo "Nota: prefisso di chiamata $manual_dial_prefix sarà aggiunto all`inizio di questo numero
\n"; } ?> - Nota: tutti i nuovi contatti chiamati manualmente andranno nella lista

- - - + Nota: tutti i nuovi contatti chiamati manualmente andranno nella lista

+
Codice di Chiamata:   (Vale 1 negli USA ed in Canada)
+ + - - + - - + + - +

If you want to dial a number and have it NOT be added as a new lead, enter in the exact dialstring that you want to call in the Chiamata automatica field below. To hangup this call you will have to open the CHIAMATAS IN THIS SESSION link at the bottom of the screen and hang it up by clicking su its channel link there.
  - - + -
Codice di Chiamata:   (Vale 1 negli USA ed in Canada)
Telefono Number: -   (digits only) + Telefono Number: +   (digits only) + +
Cerca Contatti esistenti:   (Questa opzione tenterà di trovare il numero di telefono nel sistema prima di inserire un nuovo contatto) Cerca Contatti esistenti:   (Questa opzione tenterà di trovare il numero di telefono nel sistema prima di inserire un nuovo contatto)
-

+
+

   
-

If you want to dial a number and have it NOT be added as a new lead, enter in the exact dialstring that you want to call in the Chiamata automatica field below. To hangup this call you will have to open the CHIAMATAS IN THIS SESSION link at the bottom of the screen and hang it up by clicking su its channel link there.
 
Chiamata automatica:   (solo cifre per favore) + Chiamata automatica:   (solo cifre per favore)
-
+
+
Chiama Ora                 Anteprima Chiamata                 - Torna Indietro -
+ Torna Indietro +
- height=>
SELEZIONE del CLOSER INBOUND GROUP
+
SELEZIONE del CLOSER INBOUND GROUP
+
\n";} + ?> Selezione del Closer Inbound Group -
+
0) and ($disable_blended_checkbox < 1) and ($dial_method != 'INBOUND_MAN') and ($VU_agent_choose_blended > 0) ) { ?> - CHIAMATA MISTA(outbound attivato)
+ CHIAMATA MISTA(outbound attivato)
RESET | INVIA -



  -
+



  +
- height=>
TERRITORY SELECTION
+
TERRITORY SELECTION
+
\n";} + ?> Territory Selection -
+
RESET | INVIA -



  -
+



  +
- Canale Canale RICHIAMO PERSONALE
";} + {echo " RICHIAMO PERSONALE
";} if ( ($outbound_autodial_active < 1) or ($disable_blended_checkbox > 0) or ($dial_method == 'INBOUND_MAN') or ($VU_agent_choose_blended < 1) ) - {echo " CHIAMATA MISTA
";} + {echo " CHIAMATA MISTA
";} ?>
- height=>
AGENT CHIAMATA LOG:
+
      AGENT CHIAMATA LOG:             close [X]
+
\n";} + ?>
Call log List
-

  -
+

  +
+
+ + +
      SEARCH FOR A LEAD:             close [X]
+
\n";} + ?> +

+ Note: when doing a search for a lead, the phone number, lead ID or are the best fields to use.
Using the other fields may be slower. Lead searching does not allow for wildcard or partial search terms.
Lead search requests are all logged in the system. +

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Telefono Number:
Telefono Number Fields: + Main Telefono Number + Alternate Telefono Number + Indirizzo3 Telefono Number +
Lead ID:
:
:
:
:
:
:

INVIA SEARCH             reset form
+

  +
+
+ + +
      SEARCH RESULTS:             close [X]
+
\n";} + ?> +
Search Results
+

  +
+
+ + +
      CHIAMATA NOTES LOG:             close [X]
+
\n";} + ?> +
Call Note List
+

  + Close Info Box +
- height=>
Dati Cliente:
+
      Dati Cliente:             close [X] +
+
\n";} + ?> Lead Info -

  -
+

  + Close Info Box +
- height=>
SELEZIONARE UN CODICE PAUSA:
+
SELEZIONARE UN CODICE PAUSA:
+
\n";} + ?> Pausa Code Selection - -

  -
+ +

  +
- >
SELECT A PRESET :
+
SELECT A PRESET :
+
\n";} + ?> Presets Selection - -
+ +
- height=>
SCEGLI UN GRUPPO ALIAS :
+
SCEGLI UN GRUPPO ALIAS :
+
\n";} + ?> Selezione Gruppo Alias - -

  -
+ +

  +
- height=>
ALERT :
-     -

Torna Indietro -
+
ALERT :
+     +

Torna Indietro +
- + - +
+ + +
+ + + + + + +
+ +
+ + + + + +
+   Agent Alert! +
+ + + + + + +
  +

+alert +
  +

+ + Alert Box + +

+
+ +
  + +
+
+
+ +
- @@ -12040,4 +13105,4 @@ Trasferimento Operatori Disponibili: +?> \ No newline at end of file