From 4870bc0c5d6848e9e164a030a795cf0b8a7ad3de Mon Sep 17 00:00:00 2001 From: mattf Date: Mon, 5 Feb 2007 21:54:02 +0000 Subject: [PATCH] database changes for last commit git-svn-id: svn://192.168.202.10@502 3d104415-ff17-0410-8863-d5cf3c621b8a --- bin/AST_VDadapt.pl | 142 +++++--- bin/AST_VDauto_dial.pl | 31 +- bin/AST_VDauto_dial_FILL.pl | 308 ++++++++++-------- extras/MySQL_AST_CREATE_tables.sql | 11 +- extras/upgrade_2.0.3.sql | 10 +- .../TO_BE_TRANSLATED_2.0.3.txt | 11 + www/vicidial/admin.php | 107 +++++- 7 files changed, 421 insertions(+), 199 deletions(-) diff --git a/bin/AST_VDadapt.pl b/bin/AST_VDadapt.pl index 2efe201d..2bf778d5 100644 --- a/bin/AST_VDadapt.pl +++ b/bin/AST_VDadapt.pl @@ -1,21 +1,23 @@ #!/usr/bin/perl # -# AST_VDadapt.pl version 2.0.1 *DBI-version* +# AST_VDadapt.pl version 2.0.3 *DBI-version* # # DESCRIPTION: # adjusts the auto_dial_level for vicidial adaptive-predictive campaigns. # # Copyright (C) 2006 Matt Florell LICENSE: GPLv2 # -# 60823-1302 - first build from AST_VDhopper.pl -# 60825-1734 - functional alpha version, no loop -# 60826-0857 - added loop and CLI flag options -# 60827-0035 - separate Drop calculation and target dial level calculation into different subroutines -# - alter code so that DROP percentages would calculate only about once a minute no matter he loop delay -# 60828-1149 - add field for target dial_level difference, -1 would target one agent waiting, +1 would target 1 customer waiting -# 60919-1243 - changed variables to use arrays for all campaign-specific values -# 61215-1110 - added answered calls stats and use drops as percentage of answered for today -# 70111-1600 - added ability to use BLEND/INBND/*_C/*_B/*_I as closer campaigns +# CHANGELOG +# 60823-1302 - First build from AST_VDhopper.pl +# 60825-1734 - Functional alpha version, no loop +# 60826-0857 - Added loop and CLI flag options +# 60827-0035 - Separate Drop calculation and target dial level calculation into different subroutines +# - Alter code so that DROP percentages would calculate only about once a minute no matter he loop delay +# 60828-1149 - Add field for target dial_level difference, -1 would target one agent waiting, +1 would target 1 customer waiting +# 60919-1243 - Changed variables to use arrays for all campaign-specific values +# 61215-1110 - Added answered calls stats and use drops as percentage of answered for today +# 70111-1600 - Added ability to use BLEND/INBND/*_C/*_B/*_I as closer campaigns +# 70205-1429 - Added code for campaign_changedate and campaign_stats_refresh updates # # constants @@ -295,6 +297,8 @@ while ($master_loop<$CLIloops) @adaptive_latest_server_time=@MT; @adaptive_intensity=@MT; @adaptive_dl_diff_target=@MT; +@campaign_changedate=@MT; +@campaign_stats_refresh=@MT; if ($CLIcampaign) { @@ -302,7 +306,7 @@ if ($CLIcampaign) } else { - $stmtA = "SELECT * from vicidial_campaigns where active='Y'"; + $stmtA = "SELECT campaign_id,dial_status_a,dial_status_b,dial_status_c,dial_status_d,dial_status_e,lead_order,hopper_level,auto_dial_level,local_call_time,lead_filter_id,use_internal_dnc,dial_method,available_only_ratio_tally,adaptive_dropped_percentage,adaptive_maximum_level,adaptive_latest_server_time,adaptive_intensity,adaptive_dl_diff_target,UNIX_TIMESTAMP(campaign_changedate),campaign_stats_refresh from vicidial_campaigns where ( (active='Y') or (campaign_stats_refresh='Y') )"; } $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; @@ -311,28 +315,30 @@ $rec_count=0; while ($sthArows > $rec_count) { @aryA = $sthA->fetchrow_array; - $campaign_id[$rec_count] = "$aryA[0]"; - $dial_status_a[$rec_count] = "$aryA[3]"; - $dial_status_b[$rec_count] = "$aryA[4]"; - $dial_status_c[$rec_count] = "$aryA[5]"; - $dial_status_d[$rec_count] = "$aryA[6]"; - $dial_status_e[$rec_count] = "$aryA[7]"; - $lead_order[$rec_count] = "$aryA[8]"; + $campaign_id[$rec_count] = $aryA[0]; + $dial_status_a[$rec_count] = $aryA[1]; + $dial_status_b[$rec_count] = $aryA[2]; + $dial_status_c[$rec_count] = $aryA[3]; + $dial_status_d[$rec_count] = $aryA[4]; + $dial_status_e[$rec_count] = $aryA[5]; + $lead_order[$rec_count] = $aryA[6]; if (!$CLIlevel) - {$hopper_level[$rec_count] = "$aryA[13]";} + {$hopper_level[$rec_count] = $aryA[7];} else - {$hopper_level[$rec_count] = "$CLIlevel";} - $auto_dial_level[$rec_count] = "$aryA[14]"; - $local_call_time[$rec_count] = "$aryA[16]"; - $lead_filter_id[$rec_count] = "$aryA[35]"; - $use_internal_dnc[$rec_count] = "$aryA[43]"; - $dial_method[$rec_count] = $aryA[46]; - $available_only_ratio_tally[$i][$rec_count] = $aryA[47]; - $adaptive_dropped_percentage[$rec_count] = $aryA[48]; - $adaptive_maximum_level[$rec_count] = $aryA[49]; - $adaptive_latest_server_time[$rec_count] = $aryA[50]; - $adaptive_intensity[$rec_count] = $aryA[51]; - $adaptive_dl_diff_target[$rec_count] = $aryA[52]; + {$hopper_level[$rec_count] = $CLIlevel;} + $auto_dial_level[$rec_count] = $aryA[8]; + $local_call_time[$rec_count] = $aryA[9]; + $lead_filter_id[$rec_count] = $aryA[10]; + $use_internal_dnc[$rec_count] = $aryA[11]; + $dial_method[$rec_count] = $aryA[12]; + $available_only_ratio_tally[$i][$rec_count] = $aryA[13]; + $adaptive_dropped_percentage[$rec_count] = $aryA[14]; + $adaptive_maximum_level[$rec_count] = $aryA[15]; + $adaptive_latest_server_time[$rec_count] = $aryA[16]; + $adaptive_intensity[$rec_count] = $aryA[17]; + $adaptive_dl_diff_target[$rec_count] = $aryA[18]; + $campaign_changedate[$rec_count] = $aryA[19]; + $campaign_stats_refresh[$rec_count] = $aryA[20]; $rec_count++; } @@ -397,6 +403,68 @@ foreach(@campaign_id) &calculate_dial_level; } } + else + { + if ($campaign_stats_refresh[$i] =~ /Y/) + { + if ($drop_count_updater>=60) + { + if ($DB) {print " REFRESH OVERRIDE: $campaign_id[$i]\n";} + + &calculate_drops; + + $RESETdrop_count_updater++; + + $stmtA = "UPDATE vicidial_campaigns SET campaign_stats_refresh='N' where campaign_id='$campaign_id[$i]';"; + $affected_rows = $dbhA->do($stmtA); + } + } + else + { + if ($campaign_changedate[$i] >= $VDL_ninty) + { + if ($drop_count_updater>=60) + { + if ($DB) {print " CHANGEDATE OVERRIDE: $campaign_id[$i]\n";} + + &calculate_drops; + + $RESETdrop_count_updater++; + } + } + } + } + } + else + { + if ($campaign_stats_refresh[$i] =~ /Y/) + { + if ($drop_count_updater>=60) + { + if ($DB) {print " REFRESH OVERRIDE: $campaign_id[$i]\n";} + + &calculate_drops; + + $RESETdrop_count_updater++; + + $stmtA = "UPDATE vicidial_campaigns SET campaign_stats_refresh='N' where campaign_id='$campaign_id[$i]';"; + $affected_rows = $dbhA->do($stmtA); + } + } + else + { + if ($campaign_changedate[$i] >= $VDL_ninty) + { + if ($drop_count_updater>=60) + { + if ($DB) {print " CHANGEDATE OVERRIDE: $campaign_id[$i]\n";} + + &calculate_drops; + + $RESETdrop_count_updater++; + } + } + } } $i++; } @@ -505,6 +573,9 @@ if ($Vmon < 10) {$Vmon = "0$Vmon";} if ($Vmday < 10) {$Vmday = "0$Vmday";} $VDL_five = "$Vyear-$Vmon-$Vmday $Vhour:$Vmin:$Vsec"; +### get epoch of ninty seconds ago ### + $VDL_ninty = ($secX - (1 * 90)); + ### get date-time of one minute ago ### $VDL_one = ($secX - (1 * 60)); ($Vsec,$Vmin,$Vhour,$Vmday,$Vmon,$Vyear,$Vwday,$Vyday,$Visdst) = localtime($VDL_one); @@ -875,6 +946,9 @@ if ($VCScalls_five[$i] > 0) } if ($DBX) {print "$campaign_id[$i]|$VCSdrops_five_pct[$i]|$VCSdrops_today_pct[$i]\n";} +$stmtA = "UPDATE vicidial_campaign_stats SET calls_today='$VCScalls_today[$i]',answers_today='$VCSanswers_today[$i]',drops_today='$VCSdrops_today[$i]',drops_today_pct='$VCSdrops_today_pct[$i]',drops_answers_today_pct='$VCSdrops_answers_today_pct[$i]',calls_hour='$VCScalls_hour[$i]',answers_hour='$VCSanswers_hour[$i]',drops_hour='$VCSdrops_hour[$i]',drops_hour_pct='$VCSdrops_hour_pct[$i]',calls_halfhour='$VCScalls_halfhour[$i]',answers_halfhour='$VCSanswers_halfhour[$i]',drops_halfhour='$VCSdrops_halfhour[$i]',drops_halfhour_pct='$VCSdrops_halfhour_pct[$i]',calls_fivemin='$VCScalls_five[$i]',answers_fivemin='$VCSanswers_five[$i]',drops_fivemin='$VCSdrops_five[$i]',drops_fivemin_pct='$VCSdrops_five_pct[$i]',calls_onemin='$VCScalls_one[$i]',answers_onemin='$VCSanswers_one[$i]',drops_onemin='$VCSdrops_one[$i]',drops_onemin_pct='$VCSdrops_one_pct[$i]' where campaign_id='$campaign_id[$i]';"; +$affected_rows = $dbhA->do($stmtA); +if ($DBX) {print "$campaign_id[$i]|$stmtA|\n";} } @@ -941,12 +1015,6 @@ else $differential_onemin[$i] = $stat_differential[$i]; } -## UPDATE STATS FOR CAMPAIGN -$stmtA = "UPDATE vicidial_campaign_stats SET calls_today='$VCScalls_today[$i]',answers_today='$VCSanswers_today[$i]',drops_today='$VCSdrops_today[$i]',drops_today_pct='$VCSdrops_today_pct[$i]',drops_answers_today_pct='$VCSdrops_answers_today_pct[$i]',calls_hour='$VCScalls_hour[$i]',answers_hour='$VCSanswers_hour[$i]',drops_hour='$VCSdrops_hour[$i]',drops_hour_pct='$VCSdrops_hour_pct[$i]',calls_halfhour='$VCScalls_halfhour[$i]',answers_halfhour='$VCSanswers_halfhour[$i]',drops_halfhour='$VCSdrops_halfhour[$i]',drops_halfhour_pct='$VCSdrops_halfhour_pct[$i]',calls_fivemin='$VCScalls_five[$i]',answers_fivemin='$VCSanswers_five[$i]',drops_fivemin='$VCSdrops_five[$i]',drops_fivemin_pct='$VCSdrops_five_pct[$i]',calls_onemin='$VCScalls_one[$i]',answers_onemin='$VCSanswers_one[$i]',drops_onemin='$VCSdrops_one[$i]',drops_onemin_pct='$VCSdrops_one_pct[$i]' where campaign_id='$campaign_id[$i]';"; -$affected_rows = $dbhA->do($stmtA); -if ($DBX) {print "$campaign_id[$i]|$stmtA|\n";} - - if ( ($dial_method[$i] =~ /ADAPT_HARD_LIMIT|ADAPT_AVERAGE|ADAPT_TAPERED/) || ($force_test>0) ) { # Calculate the optimal dial_level differential for the past minute diff --git a/bin/AST_VDauto_dial.pl b/bin/AST_VDauto_dial.pl index 26bf0599..22586e40 100644 --- a/bin/AST_VDauto_dial.pl +++ b/bin/AST_VDauto_dial.pl @@ -1,6 +1,6 @@ #!/usr/bin/perl # -# AST_VDauto_dial.pl version 0.12 *DBI-version* +# AST_VDauto_dial.pl version 2.0.3 *DBI-version* # # DESCRIPTION: # Places auto_dial calls on the VICIDIAL dialer system @@ -27,7 +27,7 @@ # # Copyright (C) 2006 Matt Florell LICENSE: GPLv2 # -# changes: +# CHANGELOG: # 50125-1201 - Changed dial timeout to 120 seconds from 180 seconds # 50317-0954 - Added duplicate check per cycle to account for DB lockups # 50322-1302 - Added campaign custom callerid feature @@ -58,6 +58,7 @@ # 70116-1619 - Added VDAD Ring-No-Answer Auto Alt Dial code # 70118-1539 - Added user_group logging to vicidial_user_log # 70131-1550 - Fixed Manual dialing trunk shortage bug +# 70205-1414 - Added code for last called date update # @@ -265,6 +266,10 @@ while($one_day_interval > 0) $user_campaignIP = '|'; $user_CIPct = 0; $active_agents = "'READY','QUEUE','INCALL','DONE'"; + $lists_update = ''; + $LUcount=0; + $campaigns_update = ''; + $CPcount=0; ##### Get a listing of the users that are active and ready to take calls ##### Also get a listing of the campaigns and campaigns/serverIP that will be used @@ -284,6 +289,7 @@ while($one_day_interval > 0) if ($user_campaigns !~ /\|$DBlive_campaign[$user_counter]\|/i) { + if ($campaigns_update !~ /'$DBlive_campaign[$user_counter]'/) {$campaigns_update .= "'$DBlive_campaign[$user_counter]',"; $CPcount++;} $user_campaigns .= "$DBlive_campaign[$user_counter]|"; $DBcampaigns[$user_campaigns_counter] = $DBlive_campaign[$user_counter]; $user_campaigns_counter++; @@ -671,6 +677,7 @@ while($one_day_interval > 0) while ($sthArows > $rec_count) { @aryA = $sthA->fetchrow_array; + $list_id = "$aryA[7]"; $gmt_offset_now = "$aryA[8]"; $called_since_last_reset = "$aryA[9]"; $phone_code = "$aryA[10]"; @@ -744,6 +751,8 @@ while($one_day_interval > 0) } $PADlead_id = sprintf("%09s", $lead_id); while (length($PADlead_id) > 9) {chop($PADlead_id);} + if ($lists_update !~ /'$list_id'/) {$lists_update .= "'$list_id',"; $LUcount++;} + $lead_id_call_list .= "$lead_id|"; ### whether to omit phone_code or not @@ -1112,6 +1121,24 @@ while($one_day_interval > 0) } + if ($LUcount > 0) + { + chop($lists_update); + $stmtA = "UPDATE vicidial_lists SET list_lastcalldate='$SQLdate' where list_id IN($lists_update);"; + $affected_rows = $dbhA->do($stmtA); + $event_string = "| lastcalldate UPDATED $affected_rows|$lists_update|"; + &event_logger; + } + + if ($CPcount > 0) + { + chop($campaigns_update); + $stmtA = "UPDATE vicidial_campaigns SET campaign_logindate='$SQLdate' where campaign_id IN($campaigns_update);"; + $affected_rows = $dbhA->do($stmtA); + $event_string = "| logindate UPDATED $affected_rows|$campaigns_update|"; + &event_logger; + } + ############################################################################### ###### last, wait for a little bit and repeat the loop diff --git a/bin/AST_VDauto_dial_FILL.pl b/bin/AST_VDauto_dial_FILL.pl index f95e138c..0d8cd6ab 100644 --- a/bin/AST_VDauto_dial_FILL.pl +++ b/bin/AST_VDauto_dial_FILL.pl @@ -1,6 +1,6 @@ #!/usr/bin/perl # -# AST_VDauto_dial_FILL.pl version 0.1 *DBI-version* +# AST_VDauto_dial_FILL.pl version 2.0.3 *DBI-version* # # DESCRIPTION: # Places auto_dial calls on the VICIDIAL dialer system across all servers only @@ -14,9 +14,10 @@ # # Copyright (C) 2006 Matt Florell LICENSE: GPLv2 # -# changes: +# CHANGELOG: # 61115-1246 - First build, framework setup, non-functional # 61120-2008 - second alpha version, functional and tested in production +# 70205-1425 - Added code for last called date update # @@ -222,6 +223,8 @@ while($one_day_interval > 0) $camp_counter=0; $total_shortage=0; $balance_servers=0; + $lists_update = ''; + $LUcount=0; $stmtA = "SELECT count(*) FROM servers where vicidial_balance_active = 'Y';"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; @@ -512,165 +515,179 @@ while($one_day_interval > 0) &event_logger; - - ################################################################################## - ##### PLACE THE CALLS - ################################################################################## - $event_string="$DBfill_campaign[$camp_CIPct] $DB_camp_server_server_ip[$server_CIPct]: CALLING"; - &event_logger; - $call_CMPIPct=0; - $lead_id_call_list='|'; - my $UDaffected_rows=0; - if ($call_CMPIPct < $DB_camp_server_trunks_to_dial[$server_CIPct]) + $stmtA = "SELECT count(*) FROM vicidial_live_agents where campaign_id='$DBfill_campaign[$camp_CIPct]' and status NOT IN('PAUSED');"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + $rec_count=0; + while ($sthArows > $rec_count) { - $stmtA = "UPDATE vicidial_hopper set status='QUEUE', user='VDAD_$DB_camp_server_server_ip[$server_CIPct]' where campaign_id='$DBfill_campaign[$camp_CIPct]' and status='READY' order by hopper_id LIMIT $DB_camp_server_trunks_to_dial[$server_CIPct]"; - print "|$stmtA|\n"; - $UDaffected_rows = $dbhA->do($stmtA); - print "hopper rows updated to QUEUE: |$UDaffected_rows|\n"; + @aryA = $sthA->fetchrow_array; + $LVA_count = $aryA[0]; + $rec_count++; + } + $sthA->finish(); - if ($UDaffected_rows) + if ($LVA_count > 0) + { + ################################################################################## + ##### PLACE THE CALLS + ################################################################################## + $event_string="$DBfill_campaign[$camp_CIPct] $DB_camp_server_server_ip[$server_CIPct]: CALLING"; + &event_logger; + $call_CMPIPct=0; + $lead_id_call_list='|'; + my $UDaffected_rows=0; + if ($call_CMPIPct < $DB_camp_server_trunks_to_dial[$server_CIPct]) { - $lead_id=''; $phone_code=''; $phone_number=''; $called_count=''; - while ($call_CMPIPct < $UDaffected_rows) + $stmtA = "UPDATE vicidial_hopper set status='QUEUE', user='VDAD_$DB_camp_server_server_ip[$server_CIPct]' where campaign_id='$DBfill_campaign[$camp_CIPct]' and status='READY' order by hopper_id LIMIT $DB_camp_server_trunks_to_dial[$server_CIPct]"; + print "|$stmtA|\n"; + $UDaffected_rows = $dbhA->do($stmtA); + print "hopper rows updated to QUEUE: |$UDaffected_rows|\n"; + + if ($UDaffected_rows) { - $stmtA = "SELECT lead_id FROM vicidial_hopper where campaign_id='$DBfill_campaign[$camp_CIPct]' and status='QUEUE' and user='VDAD_$DB_camp_server_server_ip[$server_CIPct]' LIMIT 1"; - print "|$stmtA|\n"; - $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; - $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; - $sthArows=$sthA->rows; - $rec_count=0; - $rec_countCUSTDATA=0; - while ($sthArows > $rec_count) - { - @aryA = $sthA->fetchrow_array; - $lead_id = "$aryA[0]"; - $rec_count++; - } - $sthA->finish(); - - if ($lead_id_call_list =~ /\|$lead_id\|/) + $lead_id=''; $phone_code=''; $phone_number=''; $called_count=''; + while ($call_CMPIPct < $UDaffected_rows) { - print "!!!!!!!!!!!!!!!!duplicate lead_id for this run: |$lead_id| $lead_id_call_list\n"; - if ($SYSLOG) - { - open(DUPout, ">>$PATHlogs/VDAD_DUPLICATE.$file_date") - || die "Can't open $PATHlogs/VDAD_DUPLICATE.$file_date: $!\n"; - print DUPout "$now_date-----$lead_id_call_list-----$lead_id\n"; - close(DUPout); - } - } - else - { - $stmtA = "UPDATE vicidial_hopper set status='INCALL' where lead_id='$lead_id'"; + $stmtA = "SELECT lead_id FROM vicidial_hopper where campaign_id='$DBfill_campaign[$camp_CIPct]' and status='QUEUE' and user='VDAD_$DB_camp_server_server_ip[$server_CIPct]' LIMIT 1"; print "|$stmtA|\n"; - $UQaffected_rows = $dbhA->do($stmtA); - print "hopper row updated to INCALL: |$UQaffected_rows|$lead_id|\n"; - - $stmtA = "SELECT * FROM vicidial_list where lead_id='$lead_id';"; - $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; - $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; - $sthArows=$sthA->rows; - $rec_count=0; - $rec_countCUSTDATA=0; - while ($sthArows > $rec_count) - { - @aryA = $sthA->fetchrow_array; - $gmt_offset_now = "$aryA[8]"; - $called_since_last_reset = "$aryA[9]"; - $phone_code = "$aryA[10]"; - $phone_number = "$aryA[11]"; - $called_count = "$aryA[30]"; - - $rec_countCUSTDATA++; - $rec_count++; - } - $sthA->finish(); - - if ($rec_countCUSTDATA) - { - ### update called_count - $called_count++; - if ($called_since_last_reset =~ /^Y/) + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + $rec_count=0; + $rec_countCUSTDATA=0; + while ($sthArows > $rec_count) { - if ($called_since_last_reset =~ /^Y$/) {$CSLR = 'Y1';} - else + @aryA = $sthA->fetchrow_array; + $lead_id = "$aryA[0]"; + $rec_count++; + } + $sthA->finish(); + + if ($lead_id_call_list =~ /\|$lead_id\|/) + { + print "!!!!!!!!!!!!!!!!duplicate lead_id for this run: |$lead_id| $lead_id_call_list\n"; + if ($SYSLOG) + { + open(DUPout, ">>$PATHlogs/VDAD_DUPLICATE.$file_date") + || die "Can't open $PATHlogs/VDAD_DUPLICATE.$file_date: $!\n"; + print DUPout "$now_date-----$lead_id_call_list-----$lead_id\n"; + close(DUPout); + } + } + else + { + $stmtA = "UPDATE vicidial_hopper set status='INCALL' where lead_id='$lead_id'"; + print "|$stmtA|\n"; + $UQaffected_rows = $dbhA->do($stmtA); + print "hopper row updated to INCALL: |$UQaffected_rows|$lead_id|\n"; + + $stmtA = "SELECT * FROM vicidial_list where lead_id='$lead_id';"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + $rec_count=0; + $rec_countCUSTDATA=0; + while ($sthArows > $rec_count) + { + @aryA = $sthA->fetchrow_array; + $list_id = "$aryA[7]"; + $gmt_offset_now = "$aryA[8]"; + $called_since_last_reset = "$aryA[9]"; + $phone_code = "$aryA[10]"; + $phone_number = "$aryA[11]"; + $called_count = "$aryA[30]"; + + $rec_countCUSTDATA++; + $rec_count++; + } + $sthA->finish(); + + if ($rec_countCUSTDATA) + { + ### update called_count + $called_count++; + if ($called_since_last_reset =~ /^Y/) { - $called_since_last_reset =~ s/^Y//gi; - $called_since_last_reset++; - $CSLR = "Y$called_since_last_reset"; + if ($called_since_last_reset =~ /^Y$/) {$CSLR = 'Y1';} + else + { + $called_since_last_reset =~ s/^Y//gi; + $called_since_last_reset++; + $CSLR = "Y$called_since_last_reset"; + } } - } - else {$CSLR = 'Y';} + else {$CSLR = 'Y';} - $stmtA = "UPDATE vicidial_list set called_since_last_reset='$CSLR', called_count='$called_count',user='VDAD' where lead_id='$lead_id'"; - $affected_rows = $dbhA->do($stmtA); - - $stmtA = "DELETE FROM vicidial_hopper where lead_id='$lead_id'"; - $affected_rows = $dbhA->do($stmtA); - - $CCID_on=0; $CCID=''; - $local_DEF = 'Local/'; - $local_AMP = '@'; - $Local_out_prefix = '9'; - $Local_dial_timeout = '60'; - if ($DBIPdialtimeout[$camp_CIPct] > 4) {$Local_dial_timeout = $DBIPdialtimeout[$camp_CIPct];} - $Local_dial_timeout = ($Local_dial_timeout * 1000); - if (length($DBIPdialprefix[$camp_CIPct]) > 0) {$Local_out_prefix = "$DBIPdialprefix[$camp_CIPct]";} - if (length($DBIPvdadexten[$camp_CIPct]) > 0) {$VDAD_dial_exten = "$DBIPvdadexten[$camp_CIPct]";} - else {$VDAD_dial_exten = "$answer_transfer_agent";} - - if (length($DBfill_campaigncid[$camp_CIPct]) > 6) {$CCID = "$DBfill_campaigncid[$camp_CIPct]"; $CCID_on++;} - if ($DBIPdialprefix[$camp_CIPct] =~ /x/i) {$Local_out_prefix = '';} - - if ($RECcount) - { - if ( (length($RECprefix)>0) && ($called_count < $RECcount) ) - {$Local_out_prefix .= "$RECprefix";} - } - $PADlead_id = sprintf("%09s", $lead_id); while (length($PADlead_id) > 9) {chop($PADlead_id);} - - $lead_id_call_list .= "$lead_id|"; - - ### whether to omit phone_code or not - if ($DBIPomitcode[$camp_CIPct] > 0) - {$Ndialstring = "$Local_out_prefix$phone_number";} - else - {$Ndialstring = "$Local_out_prefix$phone_code$phone_number";} - - ### use manager middleware-app to connect the next call to the meetme room - # VmmddhhmmssLLLLLLLLL - $VqueryCID = "V$CIDdate$PADlead_id"; - if ($CCID_on) {$CIDstring = "\"$VqueryCID\" <$CCID>";} - else {$CIDstring = "$VqueryCID";} - ### insert a NEW record to the vicidial_manager table to be processed - $stmtA = "INSERT INTO vicidial_manager values('','','$SQLdate','NEW','N','$DB_camp_server_server_ip[$server_CIPct]','','Originate','$VqueryCID','Exten: $VDAD_dial_exten','Context: $ext_context','Channel: $local_DEF$Ndialstring$local_AMP$ext_context','Priority: 1','Callerid: $CIDstring','Timeout: $Local_dial_timeout','','','','')"; + $stmtA = "UPDATE vicidial_list set called_since_last_reset='$CSLR', called_count='$called_count',user='VDAD' where lead_id='$lead_id'"; $affected_rows = $dbhA->do($stmtA); - $event_string = "| number call dialed|$DBfill_campaign[$camp_CIPct]|$VqueryCID|$stmtA|$gmt_offset_now|"; - &event_logger; - - ### insert a SENT record to the vicidial_auto_calls table - $stmtA = "INSERT INTO vicidial_auto_calls (server_ip,campaign_id,status,lead_id,callerid,phone_code,phone_number,call_time,call_type) values('$DB_camp_server_server_ip[$server_CIPct]','$DBfill_campaign[$camp_CIPct]','SENT','$lead_id','$VqueryCID','$phone_code','$phone_number','$SQLdate','OUTBALANCE')"; + $stmtA = "DELETE FROM vicidial_hopper where lead_id='$lead_id'"; $affected_rows = $dbhA->do($stmtA); - ### sleep for a tenth of a second to not flood the server with new calls - usleep(1*25*1000); + $CCID_on=0; $CCID=''; + $local_DEF = 'Local/'; + $local_AMP = '@'; + $Local_out_prefix = '9'; + $Local_dial_timeout = '60'; + if ($DBIPdialtimeout[$camp_CIPct] > 4) {$Local_dial_timeout = $DBIPdialtimeout[$camp_CIPct];} + $Local_dial_timeout = ($Local_dial_timeout * 1000); + if (length($DBIPdialprefix[$camp_CIPct]) > 0) {$Local_out_prefix = "$DBIPdialprefix[$camp_CIPct]";} + if (length($DBIPvdadexten[$camp_CIPct]) > 0) {$VDAD_dial_exten = "$DBIPvdadexten[$camp_CIPct]";} + else {$VDAD_dial_exten = "$answer_transfer_agent";} + + if (length($DBfill_campaigncid[$camp_CIPct]) > 6) {$CCID = "$DBfill_campaigncid[$camp_CIPct]"; $CCID_on++;} + if ($DBIPdialprefix[$camp_CIPct] =~ /x/i) {$Local_out_prefix = '';} + if ($RECcount) + { + if ( (length($RECprefix)>0) && ($called_count < $RECcount) ) + {$Local_out_prefix .= "$RECprefix";} + } + $PADlead_id = sprintf("%09s", $lead_id); while (length($PADlead_id) > 9) {chop($PADlead_id);} + + if ($lists_update !~ /'$list_id'/) {$lists_update .= "'$list_id',"; $LUcount++;} + + $lead_id_call_list .= "$lead_id|"; + + ### whether to omit phone_code or not + if ($DBIPomitcode[$camp_CIPct] > 0) + {$Ndialstring = "$Local_out_prefix$phone_number";} + else + {$Ndialstring = "$Local_out_prefix$phone_code$phone_number";} + + ### use manager middleware-app to connect the next call to the meetme room + # VmmddhhmmssLLLLLLLLL + $VqueryCID = "V$CIDdate$PADlead_id"; + if ($CCID_on) {$CIDstring = "\"$VqueryCID\" <$CCID>";} + else {$CIDstring = "$VqueryCID";} + ### insert a NEW record to the vicidial_manager table to be processed + $stmtA = "INSERT INTO vicidial_manager values('','','$SQLdate','NEW','N','$DB_camp_server_server_ip[$server_CIPct]','','Originate','$VqueryCID','Exten: $VDAD_dial_exten','Context: $ext_context','Channel: $local_DEF$Ndialstring$local_AMP$ext_context','Priority: 1','Callerid: $CIDstring','Timeout: $Local_dial_timeout','','','','')"; + $affected_rows = $dbhA->do($stmtA); + + $event_string = "| number call dialed|$DBfill_campaign[$camp_CIPct]|$VqueryCID|$stmtA|$gmt_offset_now|"; + &event_logger; + + ### insert a SENT record to the vicidial_auto_calls table + $stmtA = "INSERT INTO vicidial_auto_calls (server_ip,campaign_id,status,lead_id,callerid,phone_code,phone_number,call_time,call_type) values('$DB_camp_server_server_ip[$server_CIPct]','$DBfill_campaign[$camp_CIPct]','SENT','$lead_id','$VqueryCID','$phone_code','$phone_number','$SQLdate','OUTBALANCE')"; + $affected_rows = $dbhA->do($stmtA); + + ### sleep for a tenth of a second to not flood the server with new calls + usleep(1*25*1000); + + } } + $call_CMPIPct++; } - $call_CMPIPct++; } } } - - - - - - - - - + else + { + $event_string.="No Agents logged in, not dialing"; + &event_logger; + } @@ -720,6 +737,15 @@ while($one_day_interval > 0) &get_time_now; + if ($LUcount > 0) + { + chop($lists_update); + $stmtA = "UPDATE vicidial_lists SET list_lastcalldate='$SQLdate' where list_id IN($lists_update);"; + $affected_rows = $dbhA->do($stmtA); + $event_string = "| lastcalldate UPDATED $affected_rows|$lists_update|"; + &event_logger; + } + ############################################################################### ###### last, wait for a little bit and repeat the loop ############################################################################### diff --git a/extras/MySQL_AST_CREATE_tables.sql b/extras/MySQL_AST_CREATE_tables.sql index 6e8eedc4..2c4b5456 100644 --- a/extras/MySQL_AST_CREATE_tables.sql +++ b/extras/MySQL_AST_CREATE_tables.sql @@ -514,14 +514,21 @@ adaptive_dl_diff_target SMALLINT(3) default '0', concurrent_transfers ENUM('AUTO','1','2','3','4','5','6','7','8','9','10') default 'AUTO', auto_alt_dial ENUM('NONE','ALT_ONLY','ADDR3_ONLY','ALT_AND_ADDR3') default 'NONE', auto_alt_dial_statuses VARCHAR(255) default ' B N NA DC -', -agent_pause_codes_active ENUM('Y','N') default 'N' +agent_pause_codes_active ENUM('Y','N') default 'N', +campaign_description VARCHAR(255), +campaign_changedate DATETIME, +campaign_stats_refresh ENUM('Y','N') default 'N', +campaign_logindate DATETIME ); CREATE TABLE vicidial_lists ( list_id BIGINT(14) UNSIGNED PRIMARY KEY NOT NULL, list_name VARCHAR(30), campaign_id VARCHAR(8), -active ENUM('Y','N') +active ENUM('Y','N'), +list_description VARCHAR(255), +list_changedate DATETIME, +list_lastcalldate DATETIME ); CREATE TABLE vicidial_statuses ( diff --git a/extras/upgrade_2.0.3.sql b/extras/upgrade_2.0.3.sql index 14b85028..f075276f 100644 --- a/extras/upgrade_2.0.3.sql +++ b/extras/upgrade_2.0.3.sql @@ -51,8 +51,6 @@ campaign_id VARCHAR(8), index (campaign_id) ); - - ALTER TABLE vicidial_list DROP INDEX lead_id; ALTER TABLE recording_log DROP INDEX recording_id; ALTER TABLE call_log DROP INDEX uniqueid; @@ -76,3 +74,11 @@ ALTER TABLE vicidial_agent_log DROP INDEX agent_log_id; ALTER TABLE vicidial_scripts DROP INDEX script_id; ALTER TABLE vicidial_lead_recycle DROP INDEX recycle_id; +ALTER TABLE vicidial_lists ADD list_description VARCHAR(255); +ALTER TABLE vicidial_lists ADD list_changedate DATETIME; +ALTER TABLE vicidial_lists ADD list_lastcalldate DATETIME; +ALTER TABLE vicidial_campaigns ADD campaign_description VARCHAR(255); +ALTER TABLE vicidial_campaigns ADD campaign_changedate DATETIME; +ALTER TABLE vicidial_campaigns ADD campaign_stats_refresh ENUM('Y','N') default 'N'; +ALTER TABLE vicidial_campaigns ADD campaign_logindate DATETIME; + diff --git a/translations/raw_translation_files/TO_BE_TRANSLATED_2.0.3.txt b/translations/raw_translation_files/TO_BE_TRANSLATED_2.0.3.txt index d24eca94..3ad9ee3d 100644 --- a/translations/raw_translation_files/TO_BE_TRANSLATED_2.0.3.txt +++ b/translations/raw_translation_files/TO_BE_TRANSLATED_2.0.3.txt @@ -102,6 +102,17 @@ there is already an entry for this campaign with this pause code|| AGENT PAUSE CODE ADDED|| AGENT PAUSE CODE NOT MODIFIED|| CAMPAIGN PAUSE CODE NOT DELETED|| +Campaign Description -<\/B> This is a memo field for the campaign, it is optional and can be a maximum of 255 characters in length|| +Campaign Change Date -<\/B> This is the last time that the settings for this campaign were modified in any way|| +Campaign Stats Refresh -<\/B> This checkbox will allow you to force a vicidial stats refresh, even if the campaign is not active|| +Last Campaign Login Date -<\/B> This is the last time that an agent was logged into this campaign|| +List Description -<\/B> This is the memo field for the list, it is optional|| +List Change Date -<\/B> This is the last time that the settings for this list were modified in any way|| +List Last Call Date -<\/B> This is the last time that lead was dialed from this list|| +List Description: || +List Change Date: || +Campaign Description: || + ############################################################ CLIENT diff --git a/www/vicidial/admin.php b/www/vicidial/admin.php index 21fef6a5..9d737623 100644 --- a/www/vicidial/admin.php +++ b/www/vicidial/admin.php @@ -531,13 +531,18 @@ if (isset($_GET["view_reports"])) {$view_reports=$_GET["view_reports"];} elseif (isset($_POST["view_reports"])) {$view_reports=$_POST["view_reports"];} if (isset($_GET["agent_pause_codes_active"])) {$agent_pause_codes_active=$_GET["agent_pause_codes_active"];} elseif (isset($_POST["agent_pause_codes_active"])) {$agent_pause_codes_active=$_POST["agent_pause_codes_active"];} -if (isset($_GET["pause_code"])) {$pause_code=$_GET["pause_code"];} - elseif (isset($_POST["pause_code"])) {$pause_code=$_POST["pause_code"];} +if (isset($_GET["pause_code"])) {$pause_code=$_GET["pause_code"];} + elseif (isset($_POST["pause_code"])) {$pause_code=$_POST["pause_code"];} if (isset($_GET["pause_code_name"])) {$pause_code_name=$_GET["pause_code_name"];} elseif (isset($_POST["pause_code_name"])) {$pause_code_name=$_POST["pause_code_name"];} -if (isset($_GET["billable"])) {$billable=$_GET["billable"];} - elseif (isset($_POST["billable"])) {$billable=$_POST["billable"];} - +if (isset($_GET["billable"])) {$billable=$_GET["billable"];} + elseif (isset($_POST["billable"])) {$billable=$_POST["billable"];} +if (isset($_GET["campaign_description"])) {$campaign_description=$_GET["campaign_description"];} + elseif (isset($_POST["campaign_description"])) {$campaign_description=$_POST["campaign_description"];} +if (isset($_GET["campaign_stats_refresh"])) {$campaign_stats_refresh=$_GET["campaign_stats_refresh"];} + elseif (isset($_POST["campaign_stats_refresh"])){$campaign_stats_refresh=$_POST["campaign_stats_refresh"];} +if (isset($_GET["list_description"])) {$list_description=$_GET["list_description"];} + elseif (isset($_POST["list_description"])) {$list_description=$_POST["list_description"];} if (isset($script_id)) {$script_id= strtoupper($script_id);} if (isset($lead_filter_id)) {$lead_filter_id = strtoupper($lead_filter_id);} @@ -675,6 +680,7 @@ $sys_perf_log = ereg_replace("[^NY]","",$sys_perf_log); $vicidial_balance_active = ereg_replace("[^NY]","",$vicidial_balance_active); $vd_server_logs = ereg_replace("[^NY]","",$vd_server_logs); $agent_pause_codes_active = ereg_replace("[^NY]","",$agent_pause_codes_active); +$campaign_stats_refresh = ereg_replace("[^NY]","",$campaign_stats_refresh); ### ALPHA-NUMERIC ONLY ### $PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); @@ -689,6 +695,8 @@ $dial_prefix = ereg_replace("[^0-9a-zA-Z]","",$dial_prefix); $state_call_time_state = ereg_replace("[^0-9a-zA-Z]","",$state_call_time_state); $scheduled_callbacks = ereg_replace("[^0-9a-zA-Z]","",$scheduled_callbacks); $concurrent_transfers = ereg_replace("[^0-9a-zA-Z]","",$concurrent_transfers); +$billable = ereg_replace("[^0-9a-zA-Z]","",$billable); +$pause_code = ereg_replace("[^0-9a-zA-Z]","",$pause_code); ### DIGITS and Dots $server_ip = ereg_replace("[^\.0-9]","",$server_ip); @@ -787,6 +795,9 @@ $server_description = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$server_description $status = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$status); $status_name = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$status_name); $wrapup_message = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$wrapup_message); +$pause_code_name = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$pause_code_name); +$campaign_description = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$campaign_description); +$list_description = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$list_description); ### ALPHA-NUMERIC and underscore and dash and slash and at and dot $call_out_number_group = ereg_replace("[^-\.\:\/\@\_0-9a-zA-Z]","",$call_out_number_group); @@ -904,14 +915,17 @@ $lead_filter_sql = ereg_replace(";","",$lead_filter_sql); # 70123-1519 - Added user permission settings for all sections # 70124-1346 - Fixed spelling errors and formatting consistency # 70202-1120 - Added agent_pause_codes section to campaigns +# 70205-1204 - Added memo, last dialed, timestamp and stats-refresh fields to vicidial_campaigns/lists # # make sure you have added a user to the vicidial_users MySQL table with at least user_level 8 to access this page the first time -$version = '2.0.83'; -$build = '70202-1120'; +$version = '2.0.84'; +$build = '70205-1204'; $STARTtime = date("U"); +$SQLdate = date("Y-m-d H:i:s"); + if ($force_logout) { @@ -1572,6 +1586,26 @@ echo "
Campaign Name - This is the description of the campaign, it must be between 6 and 40 characters in length. +
+ +
+Campaign Description - This is a memo field for the campaign, it is optional and can be a maximum of 255 characters in length. + +
+
+
+Campaign Change Date - This is the last time that the settings for this campaign were modified in any way. + +
+
+
+Last Campaign Login Date - This is the last time that an agent was logged into this campaign. + +
+
+
+Campaign Stats Refresh - This checkbox will allow you to force a vicidial stats refresh, even if the campaign is not active. +

@@ -1836,6 +1870,21 @@ echo "
List Name - This is the description of the list, it must be between 2 and 20 characters in length. +
+ +
+List Description - This is the memo field for the list, it is optional. + +
+
+
+List Change Date - This is the last time that the settings for this list were modified in any way. + +
+
+
+List Last Call Date - This is the last time that lead was dialed from this list. +

@@ -3129,6 +3178,7 @@ if ($ADD==11) echo "
\n"; echo "\n"; echo "\n"; + echo "\n"; echo "\n"; echo "\n"; echo "\n"; @@ -3170,6 +3220,7 @@ if ($ADD==111) echo "
Campaign ID: $NWB#vicidial_campaigns-campaign_id$NWE
Campaign Name: $NWB#vicidial_campaigns-campaign_name$NWE
Campaign Description: $NWB#vicidial_campaigns-campaign_description$NWE
Active: $NWB#vicidial_campaigns-active$NWE
Park Extension: $NWB#vicidial_campaigns-park_ext$NWE
Park Filename: $NWB#vicidial_campaigns-park_file_name$NWE
\n"; echo "\n"; echo "\n"; + echo "\n"; echo "
List ID: (digits only)$NWB#vicidial_lists-list_id$NWE
List Name: $NWB#vicidial_lists-list_name$NWE
List Description: $NWB#vicidial_lists-list_description$NWE
Campaign: \n"; echo "
\n"; echo "\n"; - echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; echo "\n"; echo "\n"; echo "\n"; @@ -7046,6 +7107,8 @@ if ($ADD==31) echo "\n"; + echo "\n"; + if (eregi("(CLOSER|BLEND|INBND|_C$|_B$|_I$)", $campaign_id)) { @@ -7406,6 +7469,10 @@ if ($ADD==34) $display_dialable_count = $row[39]; $dial_method = $row[46]; $adaptive_intensity = $row[51]; + $campaign_description = $row[57]; + $campaign_changedate = $row[58]; + $campaign_stats_refresh = $row[59]; + $campaign_logindate = $row[60]; echo "
MODIFY A CAMPAIGN'S RECORD: $row[0] - Basic View | "; echo "Detail View | "; @@ -7416,6 +7483,10 @@ if ($ADD==34) echo "
Campaign ID: $row[0]$NWB#vicidial_campaigns-campaign_id$NWE
Campaign Name: $NWB#vicidial_campaigns-campaign_name$NWE
Campaign Name: $NWB#vicidial_campaigns-campaign_name$NWE
Campaign Description: $NWB#vicidial_campaigns-campaign_description$NWE
Campaign Change Date: $campaign_changedate   $NWB#vicidial_campaigns-campaign_changedate$NWE
Campaign Login Date: $campaign_logindate   $NWB#vicidial_campaigns-campaign_logindate$NWE
Active: $NWB#vicidial_campaigns-active$NWE
Park Extension: - Filename: $NWB#vicidial_campaigns-park_ext$NWE
Web Form: $NWB#vicidial_campaigns-web_form_address$NWE
Agent Pause Codes Active: $NWB#vicidial_campaigns-agent_pause_codes_active$NWE
Campaign Stats Refresh: $NWB#vicidial_campaigns-campaign_stats_refresh$NWE
\n"; echo "\n"; echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; echo "\n"; echo "\n"; @@ -7625,6 +7696,9 @@ if ($ADD==311) $row=mysql_fetch_row($rslt); $campaign_id = $row[2]; $active = $row[3]; + $list_description = $row[4]; + $list_changedate = $row[5]; + $list_lastcalldate = $row[6]; # grab names of global statuses and statuses in the selected campaign $stmt="SELECT * from vicidial_statuses order by status"; @@ -7658,6 +7732,7 @@ if ($ADD==311) echo "
Campaign ID: $row[0]$NWB#vicidial_campaigns-campaign_id$NWE
Campaign Name: $NWB#vicidial_campaigns-campaign_name$NWE
Campaign Description: $NWB#vicidial_campaigns-campaign_description$NWE
Campaign Change Date: $campaign_changedate   $NWB#vicidial_campaigns-campaign_changedate$NWE
Campaign Login Date: $campaign_logindate   $NWB#vicidial_campaigns-campaign_logindate$NWE
Active: $NWB#vicidial_campaigns-active$NWE
Park Extension: $row[9] - $row[10]$NWB#vicidial_campaigns-park_ext$NWE
Web Form: $row[11]$NWB#vicidial_campaigns-web_form_address$NWE
\n"; echo "\n"; echo "\n"; + echo "\n"; echo "\n"; echo "\n"; echo "\n"; + echo "\n"; + echo "\n"; echo "\n"; echo "
List ID: $row[0]$NWB#vicidial_lists-list_id$NWE
List Name: $NWB#vicidial_lists-list_name$NWE
List Description: $NWB#vicidial_lists-list_description$NWE
Campaign: $NWB#vicidial_lists-campaign_id$NWE
Active: $NWB#vicidial_lists-active$NWE
Reset Lead-Called-Status for this list: $NWB#vicidial_lists-reset_list$NWE
List Change Date: $list_changedate   $NWB#vicidial_lists-list_changedate$NWE
List Last Call Date: $list_lastcalldate   $NWB#vicidial_lists-list_lastcalldate$NWE
\n";