diff --git a/UPGRADE b/UPGRADE index bb0a1daa..09371460 100644 --- a/UPGRADE +++ b/UPGRADE @@ -114,6 +114,12 @@ OTHER CHANGES: systemwide even in lists belonging to campaigns that the user's User Group settings don't allow them to view +21. Added Local Call Time option for Lists to further restrict call times + already set in the campaign. + +22. Added Manual Dial Lead Search Filter option to limit the search of manual + dials to within one campaign's lists. + diff --git a/bin/AST_VDhopper.pl b/bin/AST_VDhopper.pl index b9548e31..c6445a22 100644 --- a/bin/AST_VDhopper.pl +++ b/bin/AST_VDhopper.pl @@ -1,14 +1,16 @@ #!/usr/bin/perl # -# AST_VDhopper.pl version 2.8 +# AST_VDhopper.pl version 2.10 # # DESCRIPTION: -# Updates the VICIDIAL leads hopper for the streamlined -# approach of allocating leads to dialers. +# Updates the VICIDIAL leads hopper for the streamlined approach of allocating +# leads to dialers. Also allows for larger lists and faster dialing. # # SUMMARY: # For VICIDIAL outbound dialing, this program must be in the crontab on only one -# server, running every minute during operating hours +# server, running every minute during operating hours. For manual dialing +# campaigns, there is a campaign option for no-hopper-dialing that can operate +# without this script running, but the list size will be limited under that. # # hopper sources: # - A = Auto-alt-dial @@ -19,7 +21,7 @@ # - R = Recycled leads # - S = Standard hopper load # -# Copyright (C) 2013 Matt Florell LICENSE: AGPLv2 +# Copyright (C) 2015 Matt Florell LICENSE: AGPLv2 # # CHANGELOG # 50810-1613 - Added database server variable definitions lookup @@ -78,10 +80,11 @@ # Changed and added several CLI flags, including -t to --test, added --version, --count-only # Added code to restrict all functions if campaign flag is used # 140612-2124 - Fixed date issue with wrong variable #772 +# 150111-1546 - Added lists option: local call time and enabled whole-campaign outbound call time holidays, Issue #812 # # constants -$build = '140612-2124'; +$build = '150111-1546'; $DB=0; # Debug flag, set to 0 for no debug messages. Can be overriden with CLI --debug flag $US='__'; $MT[0]=''; @@ -325,7 +328,6 @@ if ($sthArows > 0) $sthA->finish(); - $secX = time(); ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($secX); $LOCAL_GMT_OFF = $SERVER_GMT; @@ -668,7 +670,7 @@ if ($hopper_dnc_count > 0) } if ($VD_alt_dnc_count < 1) { - $stmtA = "UPDATE vicidial_hopper SET status='READY',list_id='$VD_list_id',gmt_offset_now='$VD_gmt_offset_now',state='$VD_state',alt_dial='ALT',user='',priority='25' where hopper_id='$AAD_hopper_id[$aad]';"; + $stmtA = "UPDATE $vicidial_hopper SET status='READY',list_id='$VD_list_id',gmt_offset_now='$VD_gmt_offset_now',state='$VD_state',alt_dial='ALT',user='',priority='25' where hopper_id='$AAD_hopper_id[$aad]';"; $affected_rows = $dbhA->do($stmtA); if ($DB) {$event_string = "-- VDH record updated: |$affected_rows| |$stmtA|"; &event_logger;} } @@ -748,7 +750,7 @@ if ($hopper_dnc_count > 0) } if ($VD_alt_dnc_count < 1) { - $stmtA = "UPDATE vicidial_hopper SET status='READY',list_id='$VD_list_id',gmt_offset_now='$VD_gmt_offset_now',state='$VD_state',alt_dial='ADDR3',user='',priority='25' where hopper_id='$AAD_hopper_id[$aad]';"; + $stmtA = "UPDATE $vicidial_hopper SET status='READY',list_id='$VD_list_id',gmt_offset_now='$VD_gmt_offset_now',state='$VD_state',alt_dial='ADDR3',user='',priority='25' where hopper_id='$AAD_hopper_id[$aad]';"; $affected_rows = $dbhA->do($stmtA); if ($DB) {$event_string = "-- VDH record updated: |$affected_rows| |$stmtA|"; &event_logger;} } @@ -797,7 +799,7 @@ if ($hopper_dnc_count > 0) if ($alt_dial_phones_count <= $Xlast) { - $stmtA = "DELETE FROM vicidial_hopper where hopper_id='$AAD_hopper_id[$aad]';"; + $stmtA = "DELETE FROM $vicidial_hopper where hopper_id='$AAD_hopper_id[$aad]';"; $affected_rows = $dbhA->do($stmtA); if ($DB) {$event_string = "-- VDH record DNC deleted: |$affected_rows| |$stmtA|X$Xlast|$VD_altdial_id|"; &event_logger;} } @@ -872,7 +874,7 @@ if ($hopper_dnc_count > 0) { if ($alt_dial_phones_count eq '$Xlast') {$Xlast = 'LAST';} - $stmtA = "UPDATE vicidial_hopper SET status='READY',list_id='$VD_list_id',gmt_offset_now='$VD_gmt_offset_now',state='$VD_state',alt_dial='X$Xlast',user='',priority='25' where hopper_id='$AAD_hopper_id[$aad]';"; + $stmtA = "UPDATE $vicidial_hopper SET status='READY',list_id='$VD_list_id',gmt_offset_now='$VD_gmt_offset_now',state='$VD_state',alt_dial='X$Xlast',user='',priority='25' where hopper_id='$AAD_hopper_id[$aad]';"; $affected_rows = $dbhA->do($stmtA); if ($DB) {$event_string = "-- VDH record updated: |$affected_rows| |$stmtA|X$Xlast|$VD_altdial_id|"; &event_logger;} $Xlast=9999999999; @@ -881,7 +883,7 @@ if ($hopper_dnc_count > 0) { if ($alt_dial_phones_count eq '$Xlast') {$Xlast = 'LAST';} - $stmtA = "UPDATE vicidial_hopper SET status='DNC',list_id='$VD_list_id',gmt_offset_now='$VD_gmt_offset_now',state='$VD_state',alt_dial='X$Xlast',user='',priority='15' where hopper_id='$AAD_hopper_id[$aad]';"; + $stmtA = "UPDATE $vicidial_hopper SET status='DNC',list_id='$VD_list_id',gmt_offset_now='$VD_gmt_offset_now',state='$VD_state',alt_dial='X$Xlast',user='',priority='15' where hopper_id='$AAD_hopper_id[$aad]';"; $affected_rows = $dbhA->do($stmtA); if ($DB) {$event_string = "-- VDH record DNC updated: |$affected_rows| |$stmtA|X$Xlast|$VD_altdial_id|"; &event_logger;} $Xlast=9999999999; @@ -892,7 +894,7 @@ if ($hopper_dnc_count > 0) } if ($VD_alt_dial =~ /XLAST/) { - $stmtA = "DELETE FROM vicidial_hopper where hopper_id='$AAD_hopper_id[$aad]';"; + $stmtA = "DELETE FROM $vicidial_hopper where hopper_id='$AAD_hopper_id[$aad]';"; $affected_rows = $dbhA->do($stmtA); if ($DB) {$event_string = "-- VDH record DNC deleted: |$affected_rows| |$stmtA|X$Xlast|$VD_altdial_id|"; &event_logger;} } @@ -1017,7 +1019,7 @@ while ($sthArows > $rec_count) { if ($DB) { print "---------------Auto Trim Hopper Enabled For $campaign_id[$rec_count]---------------------\n"; } - $stmtB = "SELECT COUNT(*) FROM vicidial_hopper WHERE campaign_id='$campaign_id[$rec_count]' and status IN ('READY') and source IN('S','N');"; + $stmtB = "SELECT COUNT(*) FROM $vicidial_hopper WHERE campaign_id='$campaign_id[$rec_count]' and status IN ('READY') and source IN('S','N');"; $sthB = $dbhA->prepare($stmtB) or die "preparing: ",$dbhA->errstr; $sthB->execute or die "executing: $stmtB ", $dbhA->errstr; @aryLead = $sthB->fetchrow_array; @@ -1033,7 +1035,7 @@ while ($sthArows > $rec_count) if ( $camp_leads > ( 2 * $hopper_level[$rec_count] ) ) { $num_to_delete = $camp_leads - 2 * $hopper_level[$rec_count]; - $stmtB = "DELETE FROM vicidial_hopper WHERE campaign_id='$campaign_id[$rec_count]' AND source='S' AND status IN ('READY') LIMIT $num_to_delete"; + $stmtB = "DELETE FROM $vicidial_hopper WHERE campaign_id='$campaign_id[$rec_count]' AND source='S' AND status IN ('READY') LIMIT $num_to_delete"; $affected_rows = $dbhA->do($stmtB); if ($DB) @@ -1169,6 +1171,8 @@ foreach(@campaign_id) $sthA->finish(); ### END - GATHER STATS FROM THE vicidial_campaign_stats TABLE ### + if ($DB) {print "\nStarting hopper run for $campaign_id[$i] campaign- GMT: $local_call_time[$i] HOPPER: $hopper_level[$i] ORDER: $lead_order[$i]|$lead_order_randomize[$i]|$lead_order_secondary[$i]\n";} + ##### BEGIN calculate what gmt_offset_now values are within the allowed local_call_time setting ### $g=0; $p='13'; @@ -1190,8 +1194,8 @@ foreach(@campaign_id) $g++; } if ($DBX) {print "\n";} - - $stmtA = "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[$i]';"; + + $stmtA = "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,ct_holidays FROM vicidial_call_times where call_time_id='$local_call_time[$i]';"; if ($DBX) {print " |$stmtA|\n";} $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; @@ -1217,10 +1221,51 @@ foreach(@campaign_id) $Gct_saturday_start = $aryA[17]; $Gct_saturday_stop = $aryA[18]; $Gct_state_call_times = $aryA[19]; + $Gct_holidays = $aryA[20]; $rec_count++; } $sthA->finish(); + ### BEGIN Check for outbound call time holiday ### + $holiday_id = ''; + if (length($Gct_holidays)>2) + { + $Gct_holidaysSQL = $Gct_holidays; + $Gct_holidaysSQL =~ s/^\||\|$//gi; + $Gct_holidaysSQL =~ s/\|/','/gi; + $Gct_holidaysSQL = "'$Gct_holidaysSQL'"; + $stmtC = "SELECT holiday_id,holiday_date,holiday_name,ct_default_start,ct_default_stop from vicidial_call_time_holidays where holiday_id IN($Gct_holidaysSQL) and holiday_status='ACTIVE' and holiday_date='$YMD' order by holiday_id;"; + if ($DBX) {print " |$stmtC|\n";} + $sthC = $dbhA->prepare($stmtC) or die "preparing: ",$dbhA->errstr; + $sthC->execute or die "executing: $stmtC ", $dbhA->errstr; + $sthCrows=$sthC->rows; + if ($sthCrows > 0) + { + @aryC = $sthC->fetchrow_array; + $holiday_id = $aryC[0]; + $holiday_date = $aryC[1]; + $holiday_name = $aryC[2]; + if ( ($Gct_default_start < $aryC[3]) && ($Gct_default_stop > 0) ) {$Gct_default_start = $aryC[3];} + if ( ($Gct_default_stop > $aryC[4]) && ($Gct_default_stop > 0) ) {$Gct_default_stop = $aryC[4];} + if ( ($Gct_sunday_start < $aryC[3]) && ($Gct_sunday_stop > 0) ) {$Gct_sunday_start = $aryC[3];} + if ( ($Gct_sunday_stop > $aryC[4]) && ($Gct_sunday_stop > 0) ) {$Gct_sunday_stop = $aryC[4];} + if ( ($Gct_monday_start < $aryC[3]) && ($Gct_monday_stop > 0) ) {$Gct_monday_start = $aryC[3];} + if ( ($Gct_monday_stop > $aryC[4]) && ($Gct_monday_stop > 0) ) {$Gct_monday_stop = $aryC[4];} + if ( ($Gct_tuesday_start < $aryC[3]) && ($Gct_tuesday_stop > 0) ) {$Gct_tuesday_start = $aryC[3];} + if ( ($Gct_tuesday_stop > $aryC[4]) && ($Gct_tuesday_stop > 0) ) {$Gct_tuesday_stop = $aryC[4];} + if ( ($Gct_wednesday_start < $aryC[3]) && ($Gct_wednesday_stop > 0) ) {$Gct_wednesday_start = $aryC[3];} + if ( ($Gct_wednesday_stop > $aryC[4]) && ($Gct_wednesday_stop > 0) ) {$Gct_wednesday_stop = $aryC[4];} + if ( ($Gct_thursday_start < $aryC[3]) && ($Gct_thursday_stop > 0) ) {$Gct_thursday_start = $aryC[3];} + if ( ($Gct_thursday_stop > $aryC[4]) && ($Gct_thursday_stop > 0) ) {$Gct_thursday_stop = $aryC[4];} + if ( ($Gct_friday_start < $aryC[3]) && ($Gct_friday_stop > 0) ) {$Gct_friday_start = $aryC[3];} + if ( ($Gct_friday_stop > $aryC[4]) && ($Gct_friday_stop > 0) ) {$Gct_friday_stop = $aryC[4];} + if ( ($Gct_saturday_start < $aryC[3]) && ($Gct_saturday_stop > 0) ) {$Gct_saturday_start = $aryC[3];} + if ( ($Gct_saturday_stop > $aryC[4]) && ($Gct_saturday_stop > 0) ) {$Gct_saturday_stop = $aryC[4];} + if ($DB) {print " CALL TIME HOLIDAY FOUND! $local_call_time[$i]|$holiday_id|$holiday_date|$holiday_name|$Gct_default_start|$Gct_default_stop|\n";} + } + $sthC->finish(); + } + ### END Check for outbound call time holiday ### ### BEGIN For lead recycling find out the no-call gap time and begin dial time for today $lct_gap=0; # number of seconds from stopping of calling to starting of calling based on local call time @@ -1365,6 +1410,7 @@ foreach(@campaign_id) { if (length($state_rules[$b])>1) { + if ($DBX) {print " Processing state rule $state_rules[$b]|";} $stmtA = "SELECT state_call_time_id,state_call_time_state,state_call_time_name,state_call_time_comments,sct_default_start,sct_default_stop,sct_sunday_start,sct_sunday_stop,sct_monday_start,sct_monday_stop,sct_tuesday_start,sct_tuesday_stop,sct_wednesday_start,sct_wednesday_stop,sct_thursday_start,sct_thursday_stop,sct_friday_start,sct_friday_stop,sct_saturday_start,sct_saturday_stop,ct_holidays from vicidial_state_call_times where state_call_time_id='$state_rules[$b]';"; if ($DBX) {print " |$stmtA|\n";} $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; @@ -1391,21 +1437,31 @@ foreach(@campaign_id) $Gsct_friday_stop = $aryA[17]; $Gsct_saturday_start = $aryA[18]; $Gsct_saturday_stop = $aryA[19]; - $Sct_holidays = $aryA[20]; + $Sct_holidays = $aryA[20]; $ct_states .="'$Gstate_call_time_state',"; } $sthA->finish(); ### BEGIN Check for outbound state holiday ### - - if (length($Sct_holidays)>2) + $Sholiday_id = ''; + if ( (length($Sct_holidays)>2) || ( (length($holiday_id)>2) && (length($Sholiday_id)<2) ) ) { - $Sct_holidaysSQL = $Sct_holidays; - $Sct_holidaysSQL =~ s/^\||\|$//gi; - $Sct_holidaysSQL =~ s/\|/','/gi; - $Sct_holidaysSQL = "'$Sct_holidaysSQL'"; - - $stmtA = "SELECT holiday_id,holiday_date,holiday_name,ct_default_start,ct_default_stop from vicidial_call_time_holidays where holiday_id IN($Sct_holidaysSQL) and holiday_status='ACTIVE' and holiday_date='$YMD' order by holiday_id;"; + #Apply state holiday + if (length($Sct_holidays)>2) + { + $Sct_holidaysSQL = $Sct_holidays; + $Sct_holidaysSQL =~ s/^\||\|$//gi; + $Sct_holidaysSQL =~ s/\|/','/gi; + $Sct_holidaysSQL = "'$Sct_holidaysSQL'"; + $stmtA = "SELECT holiday_id,holiday_date,holiday_name,ct_default_start,ct_default_stop from vicidial_call_time_holidays where holiday_id IN($Sct_holidaysSQL) and holiday_status='ACTIVE' and holiday_date='$YMD' order by holiday_id;"; + $holidaytype = " STATE CALL TIME HOLIDAY FOUND! "; + } + #Apply call time wide holiday + elsif ( (length($holiday_id)>2) && (length($Sholiday_id)<2) ) + { + $stmtA = "SELECT holiday_id,holiday_date,holiday_name,ct_default_start,ct_default_stop from vicidial_call_time_holidays where holiday_id='$holiday_id' and holiday_status='ACTIVE' and holiday_date='$YMD' order by holiday_id;"; + $holidaytype = " NO STATE HOLIDAY APPLYING CALL TIME HOLIDAY! "; + } if ($DBX) {print " |$stmtA|\n";} $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; @@ -1413,26 +1469,26 @@ foreach(@campaign_id) if ($sthArows > 0) { @aryA = $sthA->fetchrow_array; - $holiday_id = $aryA[0]; - $holiday_date = $aryA[1]; - $holiday_name = $aryA[2]; - $Gsct_default_start = $aryA[3]; - $Gsct_default_stop = $aryA[4]; - $Gsct_sunday_start = $aryA[3]; - $Gsct_sunday_stop = $aryA[4]; - $Gsct_monday_start = $aryA[3]; - $Gsct_monday_stop = $aryA[4]; - $Gsct_tuesday_start = $aryA[3]; - $Gsct_tuesday_stop = $aryA[4]; - $Gsct_wednesday_start = $aryA[3]; - $Gsct_wednesday_stop = $aryA[4]; - $Gsct_thursday_start = $aryA[3]; - $Gsct_thursday_stop = $aryA[4]; - $Gsct_friday_start = $aryA[3]; - $Gsct_friday_stop = $aryA[4]; - $Gsct_saturday_start = $aryA[3]; - $Gsct_saturday_stop = $aryA[4]; - if ($DBX) {print "STATE CALL TIME HOLIDAY FOUND! |$Gstate_call_time_id|$Gstate_call_time_state|$holiday_id|$holiday_date|$holiday_name|$Gsct_default_start|$Gsct_default_stop|\n";} + $Sholiday_id = $aryA[0]; + $Sholiday_date = $aryA[1]; + $Sholiday_name = $aryA[2]; + if ( ($Gsct_default_start < $aryA[3]) && ($Gsct_default_stop > 0) ) {$Gsct_default_start = $aryA[3];} + if ( ($Gsct_default_stop > $aryA[4]) && ($Gsct_default_stop > 0) ) {$Gsct_default_stop = $aryA[4];} + if ( ($Gsct_sunday_start < $aryA[3]) && ($Gsct_sunday_stop > 0) ) {$Gsct_sunday_start = $aryA[3];} + if ( ($Gsct_sunday_stop > $aryA[4]) && ($Gsct_sunday_stop > 0) ) {$Gsct_sunday_stop = $aryA[4];} + if ( ($Gsct_monday_start < $aryA[3]) && ($Gsct_monday_stop > 0) ) {$Gsct_monday_start = $aryA[3];} + if ( ($Gsct_monday_stop > $aryA[4]) && ($Gsct_monday_stop > 0) ) {$Gsct_monday_stop = $aryA[4];} + if ( ($Gsct_tuesday_start < $aryA[3]) && ($Gsct_tuesday_stop > 0) ) {$Gsct_tuesday_start = $aryA[3];} + if ( ($Gsct_tuesday_stop > $aryA[4]) && ($Gsct_tuesday_stop > 0) ) {$Gsct_tuesday_stop = $aryA[4];} + if ( ($Gsct_wednesday_start < $aryA[3]) && ($Gsct_wednesday_stop > 0) ) {$Gsct_wednesday_start = $aryA[3];} + if ( ($Gsct_wednesday_stop > $aryA[4]) && ($Gsct_wednesday_stop > 0) ) {$Gsct_wednesday_stop = $aryA[4];} + if ( ($Gsct_thursday_start < $aryA[3]) && ($Gsct_thursday_stop > 0) ) {$Gsct_thursday_start = $aryA[3];} + if ( ($Gsct_thursday_stop > $aryA[4]) && ($Gsct_thursday_stop > 0) ) {$Gsct_thursday_stop = $aryA[4];} + if ( ($Gsct_friday_start < $aryA[3]) && ($Gsct_friday_stop > 0) ) {$Gsct_friday_start = $aryA[3];} + if ( ($Gsct_friday_stop > $aryA[4]) && ($Gsct_friday_stop > 0) ) {$Gsct_friday_stop = $aryA[4];} + if ( ($Gsct_saturday_start < $aryA[3]) && ($Gsct_saturday_stop > 0) ) {$Gsct_saturday_start = $aryA[3];} + if ( ($Gsct_saturday_stop > $aryA[4]) && ($Gsct_saturday_stop > 0) ) {$Gsct_saturday_stop = $aryA[4];} + if ($DB) {print "$holidaytype|$Gstate_call_time_id|$Gstate_call_time_state|$Sholiday_id|$Sholiday_date|$Sholiday_name|$Gsct_default_start|$Gsct_default_stop|\n";} } $sthA->finish(); } @@ -1809,21 +1865,8 @@ foreach(@campaign_id) } ##### END lead recycling parsing and prep ### - if ($DB) {print "Starting hopper run for $campaign_id[$i] campaign- GMT: $local_call_time[$i] HOPPER: $hopper_level[$i] ORDER: $lead_order[$i]|$lead_order_randomize[$i]|$lead_order_secondary[$i]\n";} - ### Delete the DONE leads if there are any - $stmtA = "DELETE from $vicidial_hopper where campaign_id='$campaign_id[$i]' and status IN('DONE');"; - $affected_rows = $dbhA->do($stmtA); - if ($DB) {print " hopper DONE cleared: $affected_rows\n";} - if ($DBX) {print " |$stmtA|\n";} - - ### Delete the leads that are out of GMT time range if there are any - $stmtA = "DELETE from $vicidial_hopper where campaign_id='$campaign_id[$i]' and ($del_gmtSQL[$i]);"; - $affected_rows = $dbhA->do($stmtA); - if ($DB) {print " hopper GMT BAD cleared: $affected_rows\n";} - if ($DBX) {print " |$stmtA|\n";} - - ### Find out how many leads are in the hopper from a specific campaign + ### Find out how many leads are READY in the hopper from a specific campaign $hopper_ready_count=0; $stmtA = "SELECT count(*) from $vicidial_hopper where campaign_id='$campaign_id[$i]' and status='READY';"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; @@ -1839,31 +1882,550 @@ foreach(@campaign_id) $sthA->finish(); $event_string = "|$campaign_id[$i]|$hopper_level[$i]|$hopper_ready_count|$local_call_time[$i]||"; &event_logger; - - $active_listSQL = "and active='Y'"; - if ( ($list_order_mix[$i] !~ /DISABLED/) && ($allow_inactive_list_leads > 0) ) - {$active_listSQL = '';} + ### Get list of the lists in the campaign ### - $stmtA = "SELECT list_id FROM vicidial_lists where campaign_id='$campaign_id[$i]' and expiration_date >= \"$file_date\" $active_listSQL;"; - $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; - $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; - $sthArows=$sthA->rows; + $stmtY = "SELECT list_id,active FROM vicidial_lists where campaign_id='$campaign_id[$i]' and expiration_date >= \"$file_date\";"; + $sthY = $dbhA->prepare($stmtY) or die "preparing: ",$dbhA->errstr; + $sthY->execute or die "executing: $stmtY", $dbhA->errstr; + $sthYrows=$sthY->rows; + # Total list for campaign active & inactive $rec_countLISTS=0; - $camp_lists[$i] = ''; - while ($sthArows > $rec_countLISTS) + # Total Active campaigns for the list + $act_rec_countLISTS=0; + # list active status + $list_id_act=''; + # set hash for individual list sql + my %indv_list_gmt_sql = (); + while ($sthYrows > $rec_countLISTS) { - @aryA = $sthA->fetchrow_array; - $camp_lists[$i] .= "'$aryA[0]',"; + # Start getting list GMT and putting together statements for filtering GMT + @aryY = $sthY->fetchrow_array; + # Set List ID Variable + $cur_list_id = $aryY[0]; + if ($DB) {print " Processing GMT for list $cur_list_id\n";} + # Set active list variable + $list_id_act = $aryY[1]; + # Allow for inactive leads + if ( ($list_order_mix[$i] !~ /DISABLED/) && ($allow_inactive_list_leads > 0) ) + {$allow_inactive = "Y";} + # Pull the call times for the lists + $stmtB = "SELECT local_call_time FROM vicidial_lists where list_id = \"$cur_list_id\""; + $sthB = $dbhA->prepare($stmtB) or die "preparing: ",$dbhA->errstr; + $sthB->execute or die "executing: $stmtB", $dbhA->errstr; + @aryB = $sthB->fetchrow_array; + + # set Cur call_time + $cur_call_time = $aryB[0]; + + $sthB->finish(); + # Handle Passing through and skip GMT code for speed if we don't need it + if ($cur_call_time eq "campaign") + { + # only create sql for pulling leads if the list is active + if ( ($list_id_act eq "Y") || ($allow_inactive eq "Y") ) + { + if ( ( ($act_rec_countLISTS == 0) && ($allow_inactive ne "Y") ) || ( ($rec_countLISTS == 0) && ($allow_inactive eq "Y") ) ) + { + $list_id_sql[$i] = "(list_id=\"$cur_list_id\")"; + } + else + { + $list_id_sql[$i] .= " or (list_id=\"$cur_list_id\")"; + } + $act_rec_countLISTS++; + } + # set variable for List Mix + $indv_list_gmt_sql{ "$cur_list_id" } = "(list_id=\"$cur_list_id\")"; + } + else + { + ##### BEGIN calculate what gmt_offset_now values are within the allowed list local_call_time setting ### + $stmtC = "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,ct_holidays FROM vicidial_call_times where call_time_id='$cur_call_time';"; + if ($DBX) {print " |$stmtC|\n";} + $sthC = $dbhA->prepare($stmtC) or die "preparing: ",$dbhA->errstr; + $sthC->execute or die "executing: $stmtC ", $dbhA->errstr; + $sthCrows=$sthC->rows; + $rec_count=0; + if ($sthCrows > 0) + { + @aryC = $sthC->fetchrow_array; + $Gct_default_start = $aryC[3]; + $Gct_default_stop = $aryC[4]; + $Gct_sunday_start = $aryC[5]; + $Gct_sunday_stop = $aryC[6]; + $Gct_monday_start = $aryC[7]; + $Gct_monday_stop = $aryC[8]; + $Gct_tuesday_start = $aryC[9]; + $Gct_tuesday_stop = $aryC[10]; + $Gct_wednesday_start = $aryC[11]; + $Gct_wednesday_stop = $aryC[12]; + $Gct_thursday_start = $aryC[13]; + $Gct_thursday_stop = $aryC[14]; + $Gct_friday_start = $aryC[15]; + $Gct_friday_stop = $aryC[16]; + $Gct_saturday_start = $aryC[17]; + $Gct_saturday_stop = $aryC[18]; + $Gct_state_call_times = $aryC[19]; + $Gct_holidays = $aryC[20]; + $rec_count++; + } + $sthC->finish(); + + ### BEGIN Check for outbound call time holiday ### + $holiday_id = ''; + if (length($Gct_holidays)>2) + { + $Gct_holidaysSQL = $Gct_holidays; + $Gct_holidaysSQL =~ s/^\||\|$//gi; + $Gct_holidaysSQL =~ s/\|/','/gi; + $Gct_holidaysSQL = "'$Gct_holidaysSQL'"; + + $stmtC = "SELECT holiday_id,holiday_date,holiday_name,ct_default_start,ct_default_stop from vicidial_call_time_holidays where holiday_id IN($Gct_holidaysSQL) and holiday_status='ACTIVE' and holiday_date='$YMD' order by holiday_id;"; + if ($DBX) {print " |$stmtC|\n";} + $sthC = $dbhA->prepare($stmtC) or die "preparing: ",$dbhA->errstr; + $sthC->execute or die "executing: $stmtC ", $dbhA->errstr; + $sthCrows=$sthC->rows; + if ($sthCrows > 0) + { + @aryC = $sthC->fetchrow_array; + $holiday_id = $aryC[0]; + $holiday_date = $aryC[1]; + $holiday_name = $aryC[2]; + if ( ($Gct_default_start < $aryC[3]) && ($Gct_default_stop > 0) ) {$Gct_default_start = $aryC[3];} + if ( ($Gct_default_stop > $aryC[4]) && ($Gct_default_stop > 0) ) {$Gct_default_stop = $aryC[4];} + if ( ($Gct_sunday_start < $aryC[3]) && ($Gct_sunday_stop > 0) ) {$Gct_sunday_start = $aryC[3];} + if ( ($Gct_sunday_stop > $aryC[4]) && ($Gct_sunday_stop > 0) ) {$Gct_sunday_stop = $aryC[4];} + if ( ($Gct_monday_start < $aryC[3]) && ($Gct_monday_stop > 0) ) {$Gct_monday_start = $aryC[3];} + if ( ($Gct_monday_stop > $aryC[4]) && ($Gct_monday_stop > 0) ) {$Gct_monday_stop = $aryC[4];} + if ( ($Gct_tuesday_start < $aryC[3]) && ($Gct_tuesday_stop > 0) ) {$Gct_tuesday_start = $aryC[3];} + if ( ($Gct_tuesday_stop > $aryC[4]) && ($Gct_tuesday_stop > 0) ) {$Gct_tuesday_stop = $aryC[4];} + if ( ($Gct_wednesday_start < $aryC[3]) && ($Gct_wednesday_stop > 0) ) {$Gct_wednesday_start = $aryC[3];} + if ( ($Gct_wednesday_stop > $aryC[4]) && ($Gct_wednesday_stop > 0) ) {$Gct_wednesday_stop = $aryC[4];} + if ( ($Gct_thursday_start < $aryC[3]) && ($Gct_thursday_stop > 0) ) {$Gct_thursday_start = $aryC[3];} + if ( ($Gct_thursday_stop > $aryC[4]) && ($Gct_thursday_stop > 0) ) {$Gct_thursday_stop = $aryC[4];} + if ( ($Gct_friday_start < $aryC[3]) && ($Gct_friday_stop > 0) ) {$Gct_friday_start = $aryC[3];} + if ( ($Gct_friday_stop > $aryC[4]) && ($Gct_friday_stop > 0) ) {$Gct_friday_stop = $aryC[4];} + if ( ($Gct_saturday_start < $aryC[3]) && ($Gct_saturday_stop > 0) ) {$Gct_saturday_start = $aryC[3];} + if ( ($Gct_saturday_stop > $aryC[4]) && ($Gct_saturday_stop > 0) ) {$Gct_saturday_stop = $aryC[4];} + if ($DB) {print " LIST CALL TIME HOLIDAY FOUND! $cur_call_time|$holiday_id|$holiday_date|$holiday_name|$Gct_default_start|$Gct_default_stop|\n";} + } + $sthC->finish(); + } + ### END Check for outbound call time holiday ### + $ct_states = ''; + $ct_state_gmt_SQL = ''; + $list_state_gmt_SQL = ''; + $ct_srs=0; + $b=0; + if (length($Gct_state_call_times)>2) + { + @state_rules = split(/\|/,$Gct_state_call_times); + $ct_srs = ($#state_rules - 0); + } + while($ct_srs >= $b) + { + if (length($state_rules[$b])>1) + { + if ($DBX) {print " Processing state rule $state_rules[$b] | ";} + $stmtC = "SELECT state_call_time_id,state_call_time_state,state_call_time_name,state_call_time_comments,sct_default_start,sct_default_stop,sct_sunday_start,sct_sunday_stop,sct_monday_start,sct_monday_stop,sct_tuesday_start,sct_tuesday_stop,sct_wednesday_start,sct_wednesday_stop,sct_thursday_start,sct_thursday_stop,sct_friday_start,sct_friday_stop,sct_saturday_start,sct_saturday_stop,ct_holidays from vicidial_state_call_times where state_call_time_id='$state_rules[$b]';"; + if ($DBX) {print " |$stmtC|\n";} + $sthC = $dbhA->prepare($stmtC) or die "preparing: ",$dbhA->errstr; + $sthC->execute or die "executing: $stmtC ", $dbhA->errstr; + $sthCrows=$sthC->rows; + if ($sthCrows > 0) + { + @aryC = $sthC->fetchrow_array; + $Gstate_call_time_id = $aryC[0]; + $Gstate_call_time_state = $aryC[1]; + $Gsct_default_start = $aryC[4]; + $Gsct_default_stop = $aryC[5]; + $Gsct_sunday_start = $aryC[6]; + $Gsct_sunday_stop = $aryC[7]; + $Gsct_monday_start = $aryC[8]; + $Gsct_monday_stop = $aryC[9]; + $Gsct_tuesday_start = $aryC[10]; + $Gsct_tuesday_stop = $aryC[11]; + $Gsct_wednesday_start = $aryC[12]; + $Gsct_wednesday_stop = $aryC[13]; + $Gsct_thursday_start = $aryC[14]; + $Gsct_thursday_stop = $aryC[15]; + $Gsct_friday_start = $aryC[16]; + $Gsct_friday_stop = $aryC[17]; + $Gsct_saturday_start = $aryC[18]; + $Gsct_saturday_stop = $aryC[19]; + $Sct_holidays = $aryC[20]; + $ct_states .="'$Gstate_call_time_state',"; + } + + $sthC->finish(); + + ### BEGIN Check for outbound state holiday ### + $Sholiday_id = ''; + if ( (length($Sct_holidays)>2) || ((length($holiday_id)>2) && (length($Sholiday_id)<2))) + { + # Apply state holiday + if (length($Sct_holidays)>2) + { + $Sct_holidaysSQL = $Sct_holidays; + $Sct_holidaysSQL =~ s/^\||\|$//gi; + $Sct_holidaysSQL =~ s/\|/','/gi; + $Sct_holidaysSQL = "'$Sct_holidaysSQL'"; + $stmtA = "SELECT holiday_id,holiday_date,holiday_name,ct_default_start,ct_default_stop from vicidial_call_time_holidays where holiday_id IN($Sct_holidaysSQL) and holiday_status='ACTIVE' and holiday_date='$YMD' order by holiday_id;"; + $holidaytype = " STATE CALL TIME HOLIDAY FOUND! "; + } + # Apply call time wide holiday + elsif ( (length($holiday_id)>2) && (length($Sholiday_id)<2) ) + { + $stmtA = "SELECT holiday_id,holiday_date,holiday_name,ct_default_start,ct_default_stop from vicidial_call_time_holidays where holiday_id='$holiday_id' and holiday_status='ACTIVE' and holiday_date='$YMD' order by holiday_id;"; + $holidaytype = " NO STATE HOLIDAY APPLYING CALL TIME HOLIDAY! "; + } + if ($DBX) {print " |$stmtA|\n";} + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + if ($sthArows > 0) + { + @aryA = $sthA->fetchrow_array; + $Sholiday_id = $aryA[0]; + $Sholiday_date = $aryA[1]; + $Sholiday_name = $aryA[2]; + if ( ($Gsct_default_start < $aryC[3]) && ($Gsct_default_stop > 0) ) {$Gsct_default_start = $aryC[3];} + if ( ($Gsct_default_stop > $aryC[4]) && ($Gsct_default_stop > 0) ) {$Gsct_default_stop = $aryC[4];} + if ( ($Gsct_sunday_start < $aryC[3]) && ($Gsct_sunday_stop > 0) ) {$Gsct_sunday_start = $aryC[3];} + if ( ($Gsct_sunday_stop > $aryC[4]) && ($Gsct_sunday_stop > 0) ) {$Gsct_sunday_stop = $aryC[4];} + if ( ($Gsct_monday_start < $aryC[3]) && ($Gsct_monday_stop > 0) ) {$Gsct_monday_start = $aryC[3];} + if ( ($Gsct_monday_stop > $aryC[4]) && ($Gsct_monday_stop > 0) ) {$Gsct_monday_stop = $aryC[4];} + if ( ($Gsct_tuesday_start < $aryC[3]) && ($Gsct_tuesday_stop > 0) ) {$Gsct_tuesday_start = $aryC[3];} + if ( ($Gsct_tuesday_stop > $aryC[4]) && ($Gsct_tuesday_stop > 0) ) {$Gsct_tuesday_stop = $aryC[4];} + if ( ($Gsct_wednesday_start < $aryC[3]) && ($Gsct_wednesday_stop > 0) ) {$Gsct_wednesday_start = $aryC[3];} + if ( ($Gsct_wednesday_stop > $aryC[4]) && ($Gsct_wednesday_stop > 0) ) {$Gsct_wednesday_stop = $aryC[4];} + if ( ($Gsct_thursday_start < $aryC[3]) && ($Gsct_thursday_stop > 0) ) {$Gsct_thursday_start = $aryC[3];} + if ( ($Gsct_thursday_stop > $aryC[4]) && ($Gsct_thursday_stop > 0) ) {$Gsct_thursday_stop = $aryC[4];} + if ( ($Gsct_friday_start < $aryC[3]) && ($Gsct_friday_stop > 0) ) {$Gsct_friday_start = $aryC[3];} + if ( ($Gsct_friday_stop > $aryC[4]) && ($Gsct_friday_stop > 0) ) {$Gsct_friday_stop = $aryC[4];} + if ( ($Gsct_saturday_start < $aryC[3]) && ($Gsct_saturday_stop > 0) ) {$Gsct_saturday_start = $aryC[3];} + if ( ($Gsct_saturday_stop > $aryC[4]) && ($Gsct_saturday_stop > 0) ) {$Gsct_saturday_stop = $aryC[4];} + if ($DB) {print "$holidaytype|$Gstate_call_time_id|$Gstate_call_time_state|$Sholiday_id|$Sholiday_date|$Sholiday_name|$Gsct_default_start|$Gsct_default_stop|\n";} + } + $sthA->finish(); + } + ### END Check for outbound state holiday ### + $r=0; + $state_gmt=''; + $del_state_gmt=''; + while($r < $g) + { + if ($GMT_day[$r]==0) #### Sunday local time + { + if (($Gsct_sunday_start==0) && ($Gsct_sunday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) && ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_sunday_start) && ($GMT_hour[$r]<$Gsct_sunday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==1) #### Monday local time + { + if (($Gsct_monday_start==0) && ($Gsct_monday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) && ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_monday_start) && ($GMT_hour[$r]<$Gsct_monday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==2) #### Tuesday local time + { + if (($Gsct_tuesday_start==0) && ($Gsct_tuesday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) && ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_tuesday_start) && ($GMT_hour[$r]<$Gsct_tuesday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==3) #### Wednesday local time + { + if (($Gsct_wednesday_start==0) && ($Gsct_wednesday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) && ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_wednesday_start) && ($GMT_hour[$r]<$Gsct_wednesday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==4) #### Thursday local time + { + if (($Gsct_thursday_start==0) && ($Gsct_thursday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) && ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_thursday_start) && ($GMT_hour[$r]<$Gsct_thursday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==5) #### Friday local time + { + if (($Gsct_friday_start==0) && ($Gsct_friday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) && ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_friday_start) && ($GMT_hour[$r]<$Gsct_friday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==6) #### Saturday local time + { + if (($Gsct_saturday_start==0) && ($Gsct_saturday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) && ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_saturday_start) && ($GMT_hour[$r]<$Gsct_saturday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + $r++; + } + $state_gmt = "$state_gmt'99'"; + + $del_list_state_gmt_SQL .= "or (list_id='$cur_list_id' and state='$Gstate_call_time_state' && gmt_offset_now NOT IN($state_gmt)) "; + $list_state_gmt_SQL .= "or (list_id='$cur_list_id' and state='$Gstate_call_time_state' && gmt_offset_now IN($state_gmt)) "; + } + + $b++; + } + if (length($ct_states)>2) + { + $ct_states =~ s/,$//gi; + $ct_statesSQL = "and state NOT IN($ct_states)"; + } + else + { + $ct_statesSQL = ""; + } + + $r=0; + @default_gmt_ARY=@MT; + $dgA=0; + $list_default_gmt=''; + while($r < $g) + { + if ($GMT_day[$r]==0) #### Sunday local time + { + if (($Gct_sunday_start==0) && ($Gct_sunday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) && ($GMT_hour[$r]<$Gct_default_stop) ) + {} + else + {$list_default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_sunday_start) && ($GMT_hour[$r]<$Gct_sunday_stop) ) + {} + else + {$list_default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==1) #### Monday local time + { + if (($Gct_monday_start==0) && ($Gct_monday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) && ($GMT_hour[$r]<$Gct_default_stop) ) + {} + else + {$list_default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_monday_start) && ($GMT_hour[$r]<$Gct_monday_stop) ) + {} + else + {$list_default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==2) #### Tuesday local time + { + if (($Gct_tuesday_start==0) && ($Gct_tuesday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) && ($GMT_hour[$r]<$Gct_default_stop) ) + {$del_list_default_gmt.="'$GMT_gmt[$r]',"; $del_list_default_gmt_ARY[$dgA] = "$GMT_gmt[$r]"; $dgA++;} + else + {$list_default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_tuesday_start) && ($GMT_hour[$r]<$Gct_tuesday_stop) ) + {$del_list_default_gmt.="'$GMT_gmt[$r]',"; $del_list_default_gmt_ARY[$dgA] = "$GMT_gmt[$r]"; $dgA++;} + else + {$list_default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==3) #### Wednesday local time + { + if (($Gct_wednesday_start==0) && ($Gct_wednesday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) && ($GMT_hour[$r]<$Gct_default_stop) ) + {$del_list_default_gmt.="'$GMT_gmt[$r]',"; $del_list_default_gmt_ARY[$dgA] = "$GMT_gmt[$r]"; $dgA++;} + else + {$list_default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_wednesday_start) && ($GMT_hour[$r]<$Gct_wednesday_stop) ) + {} + else + {$list_default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==4) #### Thursday local time + { + if (($Gct_thursday_start==0) && ($Gct_thursday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) && ($GMT_hour[$r]<$Gct_default_stop) ) + {} + else + {$list_default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_thursday_start) && ($GMT_hour[$r]<$Gct_thursday_stop) ) + {} + else + {$list_default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==5) #### Friday local time + { + if (($Gct_friday_start==0) && ($Gct_friday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) && ($GMT_hour[$r]<$Gct_default_stop) ) + {} + else + {$list_default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_friday_start) && ($GMT_hour[$r]<$Gct_friday_stop) ) + {} + else + {$list_default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==6) #### Saturday local time + { + if (($Gct_saturday_start==0) && ($Gct_saturday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) && ($GMT_hour[$r]<$Gct_default_stop) ) + {} + else + {$list_default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_saturday_start) && ($GMT_hour[$r]<$Gct_saturday_stop) ) + {} + else + {$list_default_gmt.="'$GMT_gmt[$r]',";} + } + } + $r++; + } + + $list_default_gmt = "$list_default_gmt'99'"; + + #set variable for List Mix + $indv_list_gmt_sql{ "$cur_list_id" } = "((list_id=\"$cur_list_id\" and gmt_offset_now NOT IN($list_default_gmt) $ct_statesSQL) $list_state_gmt_SQL)"; + + #only add for use if the list is active + if ( ($list_id_act eq "Y") || ($allow_inactive eq "Y") ) + { + if ( ( ($act_rec_countLISTS == 0) && ($allow_inactive ne "Y") ) || ( ($rec_countLISTS == 0) && ($allow_inactive eq "Y") ) ) + { + $list_id_sql[$i] = "((list_id=\"$cur_list_id\" and gmt_offset_now NOT IN($list_default_gmt) $ct_statesSQL) $list_state_gmt_SQL)"; + } + else + { + $list_id_sql[$i] .= " or ((list_id=\"$cur_list_id\" and gmt_offset_now NOT IN($list_default_gmt) $ct_statesSQL) $list_state_gmt_SQL)"; + } + $del_list_id_sql[$i] .= "((list_id=\"$cur_list_id\" and gmt_offset_now IN($list_default_gmt) $ct_statesSQL) $del_list_state_gmt_SQL) or"; + $act_rec_countLISTS++; + } + } + ##### END calculate what gmt_offset_now values are within the allowed local_call_time setting ### + + # Add 1 to row count $rec_countLISTS++; } - $sthA->finish(); - if (length($camp_lists[$i])<3) {$camp_lists[$i]="'999876543210'";} - else {chop($camp_lists[$i]);} - - if ($DB) {print " campaign lists count: $rec_countLISTS | $camp_lists[$i]\n";} + $sthY->finish(); + # Protect against campaigns with no list by making it an impossible list + if (length($list_id_sql[$i]) < 1) {$list_id_sql[$i]="list_id='999876543210'";} + if (length($del_list_id_sql[$i]) < 1) {$del_list_id_sql[$i]="list_id='999876543211'";} + + if ($DB) {print " campaign lists count ACTIVE:$act_rec_countLISTS | TOTAL:$rec_countLISTS \n";} + if ($DBX) {print " LIST ID SQL $list_id_sql[$i]";} if ($DBX) {print " |$stmtA|\n";} + + ### Delete the DONE leads if there are any + $stmtA = "DELETE from $vicidial_hopper where campaign_id='$campaign_id[$i]' and status IN('DONE');"; + $affected_rows = $dbhA->do($stmtA); + if ($DB) {print " hopper DONE cleared: $affected_rows\n";} + if ($DBX) {print " |$stmtA|\n";} + # Update the hopper ready count + if ($affected_rows ne "0E0") + { + $hopper_ready_pre_count = $hopper_ready_count; + $hopper_ready_count = $hopper_ready_count - $affected_rows; + if ($DB) + { + if($hopper_ready_pre_count == $hopper_ready_count) + {print " hopper READY count minus deleted DONE leads: $hopper_ready_count\n";} + } + } + + ### Delete the leads that are out of GMT time range if there are any + $stmtA = "DELETE from $vicidial_hopper where $del_list_id_sql[$i] (campaign_id='$campaign_id[$i]' and ($del_gmtSQL[$i]));"; + $affected_rows = $dbhA->do($stmtA); + if ($DB) {print " hopper GMT BAD cleared: $affected_rows\n";} + if ($DBX) {print " |$stmtA|\n";} + + # Update the hopper ready count + if ($affected_rows ne "0E0") + { + $hopper_ready_pre_count = $hopper_ready_count; + $hopper_ready_count = $hopper_ready_count - $affected_rows; + if ($DB) + { + if($hopper_ready_pre_count == $hopper_ready_count) + {print " hopper READY count minus deleted GMT leads: $hopper_ready_count\n";} + } + } + + # Get Campaign List Mix Settings if ($list_order_mix[$i] !~ /DISABLED/) { $stmtA = "SELECT vcl_id,vcl_name,list_mix_container,mix_method FROM vicidial_campaigns_list_mix where campaign_id='$campaign_id[$i]' and status='ACTIVE';"; @@ -1895,11 +2457,9 @@ foreach(@campaign_id) if ($list_mix_stepARY[3] !~ /\'$/) {$list_mix_stepARY[3] = "$list_mix_stepARY[3]'";} if ($DBX) {print " LM $x ++$list_mixARY[$x]++ |$list_mix_stepARY[0]|$list_mix_stepARY[2]|$list_mix_stepARY[3]|\n";} - $list_mix_dialableSQL .= "(list_id='$list_mix_stepARY[0]' and status IN($list_mix_stepARY[3]))"; - + $list_mix_dialableSQL .= "(($indv_list_gmt_sql{ \"$list_mix_stepARY[0]\" }) and status IN($list_mix_stepARY[3]))"; $x++; } - if ($DB) {print " campaign mix: $list_order_mix[$i] |$vcl_id[$i] - $vcl_name[$i]|$list_mix_container[$i]|$x|$mix_method[$i]|\n";} } @@ -1959,7 +2519,7 @@ foreach(@campaign_id) ##### Get count of leads that are dialable ##### if ($list_order_mix[$i] =~ /DISABLED/) { - $stmtA = "SELECT count(*) FROM vicidial_list where called_since_last_reset='N' and status IN($STATUSsql[$i]) and list_id IN($camp_lists[$i]) and ($all_gmtSQL[$i]) $lead_filter_sql[$i] $DLTsql[$i] $CCLsql[$i];"; + $stmtA = "SELECT count(*) FROM vicidial_list where called_since_last_reset='N' and status IN($STATUSsql[$i]) and ($list_id_sql[$i]) and ($all_gmtSQL[$i]) $lead_filter_sql[$i] $DLTsql[$i] $CCLsql[$i];"; } else { @@ -1981,7 +2541,7 @@ foreach(@campaign_id) if ( ($lead_order[$i] =~ / 2nd NEW$| 3rd NEW$| 4th NEW$| 5th NEW$| 6th NEW$/) && ($list_order_mix[$i] =~ /DISABLED/) ) { - $stmtA = "SELECT count(*) FROM vicidial_list where called_since_last_reset='N' and status IN('NEW') and list_id IN($camp_lists[$i]) and ($all_gmtSQL[$i]) $lead_filter_sql[$i] $DLTsql[$i];"; + $stmtA = "SELECT count(*) FROM vicidial_list where called_since_last_reset='N' and status IN('NEW') and ($list_id_sql[$i]) and ($all_gmtSQL[$i]) $lead_filter_sql[$i] $DLTsql[$i];"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthArows=$sthA->rows; @@ -2122,7 +2682,7 @@ foreach(@campaign_id) if ($hopper_vlc_dup_check[$i] =~ /Y/) {$vlc_dup_check_SQL = "and vendor_lead_code NOT IN($live_vlc$vlc_lists)";} - $stmtA = "SELECT lead_id,list_id,gmt_offset_now,phone_number,state,status,modify_date,user,vendor_lead_code FROM vicidial_list where $recycle_SQL[$i] and list_id IN($camp_lists[$i]) and lead_id NOT IN($lead_id_lists) $vlc_dup_check_SQL and ($all_gmtSQL[$i]) $lead_filter_sql[$i] $CCLsql[$i] $DLTsql[$i] $order_stmt limit $hopper_level[$i];"; + $stmtA = "SELECT lead_id,list_id,gmt_offset_now,phone_number,state,status,modify_date,user,vendor_lead_code FROM vicidial_list where $recycle_SQL[$i] and ($list_id_sql[$i]) and lead_id NOT IN($lead_id_lists) $vlc_dup_check_SQL and ($all_gmtSQL[$i]) $lead_filter_sql[$i] $CCLsql[$i] $DLTsql[$i] $order_stmt limit $hopper_level[$i];"; if ($DBX) {print " |$stmtA|\n";} $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; @@ -2178,7 +2738,7 @@ foreach(@campaign_id) if ($hopper_vlc_dup_check[$i] =~ /Y/) {$vlc_dup_check_SQL = "and vendor_lead_code NOT IN($live_vlc$vlc_lists)";} - $stmtA = "SELECT lead_id,list_id,gmt_offset_now,phone_number,state,status,modify_date,user,vendor_lead_code FROM vicidial_list where called_since_last_reset='N' and status IN('NEW') and list_id IN($camp_lists[$i]) and lead_id NOT IN($lead_id_lists) $vlc_dup_check_SQL and ($all_gmtSQL[$i]) $lead_filter_sql[$i] $CCLsql[$i] $DLTsql[$i] $order_stmt limit $NEW_level;"; + $stmtA = "SELECT lead_id,list_id,gmt_offset_now,phone_number,state,status,modify_date,user,vendor_lead_code FROM vicidial_list where called_since_last_reset='N' and status IN('NEW') and ($list_id_sql[$i]) and lead_id NOT IN($lead_id_lists) $vlc_dup_check_SQL and ($all_gmtSQL[$i]) $lead_filter_sql[$i] $CCLsql[$i] $DLTsql[$i] $order_stmt limit $NEW_level;"; if ($DBX) {print " |$stmtA|\n";} $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; @@ -2231,7 +2791,7 @@ foreach(@campaign_id) if ($list_order_mix[$i] =~ /DISABLED/) { - $stmtA = "SELECT lead_id,list_id,gmt_offset_now,phone_number,state,status,modify_date,user,vendor_lead_code FROM vicidial_list where called_since_last_reset='N' and status IN($STATUSsql[$i]) and list_id IN($camp_lists[$i]) and lead_id NOT IN($lead_id_lists) $vlc_dup_check_SQL and ($all_gmtSQL[$i]) $lead_filter_sql[$i] $CCLsql[$i] $DLTsql[$i] $order_stmt limit $OTHER_level;"; + $stmtA = "SELECT lead_id,list_id,gmt_offset_now,phone_number,state,status,modify_date,user,vendor_lead_code FROM vicidial_list where called_since_last_reset='N' and status IN($STATUSsql[$i]) and ($list_id_sql[$i]) and lead_id NOT IN($lead_id_lists) $vlc_dup_check_SQL and ($all_gmtSQL[$i]) $lead_filter_sql[$i] $CCLsql[$i] $DLTsql[$i] $order_stmt limit $OTHER_level;"; if ($DBX) {print " |$stmtA|\n";} $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; @@ -2329,12 +2889,12 @@ foreach(@campaign_id) if ($list_mix_stepARY[3] !~ /\'$/) {$list_mix_stepARY[3] = "$list_mix_stepARY[3]'";} if ($DBX) {print " LM $x |$list_mix_stepARY[0]|$list_mix_stepARY[2]|$LM_step_goal[$x]|$list_mix_stepARY[3]|\n";} - $list_mix_dialableSQL = "(list_id='$list_mix_stepARY[0]' and status IN($list_mix_stepARY[3]))"; + $list_mix_dialableSQL = "(($indv_list_gmt_sql{ \"$list_mix_stepARY[0]\" }) and status IN($list_mix_stepARY[3]))"; $vlc_dup_check_SQL=''; if ($hopper_vlc_dup_check[$i] =~ /Y/) {$vlc_dup_check_SQL = "and vendor_lead_code NOT IN($live_vlc$vlc_lists)";} - $stmtA = "SELECT lead_id,list_id,gmt_offset_now,phone_number,state,status,modify_date,user,vendor_lead_code FROM vicidial_list where called_since_last_reset='N' and $list_mix_dialableSQL and lead_id NOT IN($lead_id_lists) $vlc_dup_check_SQL and ($all_gmtSQL[$i]) $lead_filter_sql[$i] $CCLsql[$i] $DLTsql[$i] $order_stmt limit $LM_step_goal[$x];"; + $stmtA = "SELECT lead_id,list_id,gmt_offset_now,phone_number,state,status,modify_date,user,vendor_lead_code FROM vicidial_list where called_since_last_reset='N' and ($list_mix_dialableSQL) and lead_id NOT IN($lead_id_lists) $vlc_dup_check_SQL and ($all_gmtSQL[$i]) $lead_filter_sql[$i] $CCLsql[$i] $DLTsql[$i] $order_stmt limit $LM_step_goal[$x];"; if ($DBX) {print " |$stmtA|\n";} $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; @@ -2498,44 +3058,44 @@ foreach(@campaign_id) } } - $VAC_exist=0; - $stmtA="SELECT count(*) FROM vicidial_auto_calls where lead_id='$leads_to_hopper[$h]';"; + $VAC_exist=0; + $stmtA="SELECT count(*) FROM vicidial_auto_calls where lead_id='$leads_to_hopper[$h]';"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + if ($sthArows > 0) + { + @aryA = $sthA->fetchrow_array; + $VAC_exist = $aryA[0]; + } + $sthA->finish(); + + $VLA_exist=0; + $stmtA="SELECT count(*) FROM vicidial_live_agents where lead_id='$leads_to_hopper[$h]';"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + if ($sthArows > 0) + { + @aryA = $sthA->fetchrow_array; + $VLA_exist = $aryA[0]; + } + $sthA->finish(); + + $VLC_exist=0; + if ( ($hopper_vlc_dup_check[$i] =~ /Y/) && (length($vlc_to_hopper[$h]) > 0) ) + { + $stmtA="SELECT count(*) FROM $vicidial_hopper where vendor_lead_code='$vlc_to_hopper[$h]';"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthArows=$sthA->rows; if ($sthArows > 0) { @aryA = $sthA->fetchrow_array; - $VAC_exist = $aryA[0]; + $VLC_exist = $aryA[0]; } $sthA->finish(); - - $VLA_exist=0; - $stmtA="SELECT count(*) FROM vicidial_live_agents where lead_id='$leads_to_hopper[$h]';"; - $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; - $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; - $sthArows=$sthA->rows; - if ($sthArows > 0) - { - @aryA = $sthA->fetchrow_array; - $VLA_exist = $aryA[0]; - } - $sthA->finish(); - - $VLC_exist=0; - if ( ($hopper_vlc_dup_check[$i] =~ /Y/) && (length($vlc_to_hopper[$h]) > 0) ) - { - $stmtA="SELECT count(*) FROM $vicidial_hopper where vendor_lead_code='$vlc_to_hopper[$h]';"; - $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; - $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; - $sthArows=$sthA->rows; - if ($sthArows > 0) - { - @aryA = $sthA->fetchrow_array; - $VLC_exist = $aryA[0]; - } - $sthA->finish(); - } + } if ( ($VAC_exist > 0) || ($VLA_exist > 0) ) { diff --git a/extras/MySQL_AST_CREATE_tables.sql b/extras/MySQL_AST_CREATE_tables.sql index 6c29d387..d6380bee 100644 --- a/extras/MySQL_AST_CREATE_tables.sql +++ b/extras/MySQL_AST_CREATE_tables.sql @@ -920,7 +920,8 @@ comments_callback_screen ENUM('DISABLED','ENABLED','REPLACE_CB_NOTES') default ' qc_comment_history ENUM('CLICK','AUTO_OPEN','CLICK_ALLOW_MINIMIZE','AUTO_OPEN_ALLOW_MINIMIZE') default 'CLICK', show_previous_callback ENUM('DISABLED','ENABLED') default 'ENABLED', clear_script ENUM('DISABLED','ENABLED') default 'DISABLED', -cpd_unknown_action ENUM('DISABLED','DISPO','MESSAGE','CALLMENU','INGROUP') default 'DISABLED' +cpd_unknown_action ENUM('DISABLED','DISPO','MESSAGE','CALLMENU','INGROUP') default 'DISABLED', +manual_dial_search_filter VARCHAR(50) default 'NONE' ) ENGINE=MyISAM; CREATE TABLE vicidial_lists ( @@ -946,7 +947,8 @@ web_form_address_two TEXT, time_zone_setting ENUM('COUNTRY_AND_AREA_CODE','POSTAL_CODE','NANPA_PREFIX','OWNER_TIME_ZONE_CODE') default 'COUNTRY_AND_AREA_CODE', inventory_report ENUM('Y','N') default 'Y', expiration_date DATE default '2099-12-31', -na_call_url TEXT +na_call_url TEXT, +local_call_time VARCHAR(10) NOT NULL DEFAULT 'campaign' ) ENGINE=MyISAM; CREATE TABLE vicidial_statuses ( @@ -3363,4 +3365,4 @@ UPDATE vicidial_configuration set value='1766' where name='qc_database_version'; UPDATE system_settings set vdc_agent_api_active='1'; -UPDATE system_settings SET db_schema_version='1399',db_schema_update_date=NOW(),reload_timestamp=NOW(); +UPDATE system_settings SET db_schema_version='1400',db_schema_update_date=NOW(),reload_timestamp=NOW(); diff --git a/extras/upgrade_2.10.sql b/extras/upgrade_2.10.sql index 1cbb3766..4c538857 100644 --- a/extras/upgrade_2.10.sql +++ b/extras/upgrade_2.10.sql @@ -164,3 +164,9 @@ UPDATE system_settings SET db_schema_version='1398',db_schema_update_date=NOW() ALTER TABLE vicidial_live_agents MODIFY external_transferconf VARCHAR(120) default ''; UPDATE system_settings SET db_schema_version='1399',db_schema_update_date=NOW() where db_schema_version < 1399; + +ALTER TABLE vicidial_lists ADD local_call_time VARCHAR(10) NOT NULL DEFAULT 'campaign'; + +ALTER TABLE vicidial_campaigns ADD manual_dial_search_filter VARCHAR(50) default 'NONE'; + +UPDATE system_settings SET db_schema_version='1400',db_schema_update_date=NOW() where db_schema_version < 1400; diff --git a/www/agc/functions.php b/www/agc/functions.php index eb2cce98..9546b1e3 100644 --- a/www/agc/functions.php +++ b/www/agc/functions.php @@ -25,6 +25,7 @@ # 141128-0846 - Code cleanup for QXZ functions # 141216-1902 - Added MYSQL language method # 150108-1647 - removed phones count as part of validation, can cause problems when there are many phones +# 150111-1541 - Added lists option: local call time(Issue #812) # # $mysql_queries = 20 @@ -1659,9 +1660,8 @@ function lookup_gmt($phone_code,$USarea,$state,$LOCAL_GMT_OFF_STD,$Shour,$Smin,$ ##### DETERMINE IF LEAD IS DIALABLE ##### function dialable_gmt($DB,$link,$local_call_time,$gmt_offset,$state) - { + { require("dbconnect_mysqli.php"); - $dialable=0; $pzone=3600 * $gmt_offset; @@ -1672,8 +1672,9 @@ function dialable_gmt($DB,$link,$local_call_time,$gmt_offset,$state) $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';"; + $YMD = date("Y-m-d"); + + $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,ct_holidays FROM vicidial_call_times where call_time_id='$local_call_time';"; if ($DB) {echo "$stmt\n";} $rslt=mysql_to_mysqli($stmt, $link); $rowx=mysqli_fetch_row($rslt); @@ -1694,99 +1695,330 @@ function dialable_gmt($DB,$link,$local_call_time,$gmt_offset,$state) $Gct_saturday_start = $rowx[17]; $Gct_saturday_stop = $rowx[18]; $Gct_state_call_times = $rowx[19]; + $Gct_holidays = $rowx[20]; - if ($GMT_day==0) #### Sunday local time + ### BEGIN Check for outbound holiday ### + $holiday_id = ''; + if (strlen($Gct_holidays)>2) { - if (($Gct_sunday_start==0) and ($Gct_sunday_stop==0)) + $Gct_holidaysSQL = preg_replace("/\|/", "','", "$Gct_holidays"); + $Gct_holidaysSQL = "'".$Gct_holidaysSQL."'"; + + $stmt = "SELECT holiday_id,holiday_date,holiday_name,ct_default_start,ct_default_stop from vicidial_call_time_holidays where holiday_id IN($Gct_holidaysSQL) and holiday_status='ACTIVE' and holiday_date='$YMD' order by holiday_id;"; + $rslt=mysql_to_mysqli($stmt, $link); + if ($DB) {echo "$stmt\n";} + $sthCrows=mysqli_num_rows($rslt); + if ($sthCrows > 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;} + $aryC=mysqli_fetch_row($rslt); + $holiday_id = $aryC[0]; + $holiday_date = $aryC[1]; + $holiday_name = $aryC[2]; + if ( ($Gct_default_start < $aryC[3]) && ($Gct_default_stop > 0) ) {$Gct_default_start = $aryC[3];} + if ( ($Gct_default_stop > $aryC[4]) && ($Gct_default_stop > 0) ) {$Gct_default_stop = $aryC[4];} + if ( ($Gct_sunday_start < $aryC[3]) && ($Gct_sunday_stop > 0) ) {$Gct_sunday_start = $aryC[3];} + if ( ($Gct_sunday_stop > $aryC[4]) && ($Gct_sunday_stop > 0) ) {$Gct_sunday_stop = $aryC[4];} + if ( ($Gct_monday_start < $aryC[3]) && ($Gct_monday_stop > 0) ) {$Gct_monday_start = $aryC[3];} + if ( ($Gct_monday_stop > $aryC[4]) && ($Gct_monday_stop > 0) ) {$Gct_monday_stop = $aryC[4];} + if ( ($Gct_tuesday_start < $aryC[3]) && ($Gct_tuesday_stop > 0) ) {$Gct_tuesday_start = $aryC[3];} + if ( ($Gct_tuesday_stop > $aryC[4]) && ($Gct_tuesday_stop > 0) ) {$Gct_tuesday_stop = $aryC[4];} + if ( ($Gct_wednesday_start < $aryC[3]) && ($Gct_wednesday_stop > 0) ) {$Gct_wednesday_start = $aryC[3];} + if ( ($Gct_wednesday_stop > $aryC[4]) && ($Gct_wednesday_stop > 0) ) {$Gct_wednesday_stop = $aryC[4];} + if ( ($Gct_thursday_start < $aryC[3]) && ($Gct_thursday_stop > 0) ) {$Gct_thursday_start = $aryC[3];} + if ( ($Gct_thursday_stop > $aryC[4]) && ($Gct_thursday_stop > 0) ) {$Gct_thursday_stop = $aryC[4];} + if ( ($Gct_friday_start < $aryC[3]) && ($Gct_friday_stop > 0) ) {$Gct_friday_start = $aryC[3];} + if ( ($Gct_friday_stop > $aryC[4]) && ($Gct_friday_stop > 0) ) {$Gct_friday_stop = $aryC[4];} + if ( ($Gct_saturday_start < $aryC[3]) && ($Gct_saturday_stop > 0) ) {$Gct_saturday_start = $aryC[3];} + if ( ($Gct_saturday_stop > $aryC[4]) && ($Gct_saturday_stop > 0) ) {$Gct_saturday_stop = $aryC[4];} + if ($DB) {echo "CALL TIME HOLIDAY FOUND! $local_call_time|$holiday_id|$holiday_date|$holiday_name|$Gct_default_start|$Gct_default_stop|\n";} } } - if ($GMT_day==1) #### Monday local time - { - if (($Gct_monday_start==0) and ($Gct_monday_stop==0)) + ### END Check for outbound holiday ### + if( $state != '') { - if ( ($GMT_hour>=$Gct_default_start) and ($GMT_hour<$Gct_default_stop) ) - {$dialable=1;} + $ct_states = ''; + $ct_state_gmt_SQL = ''; + $ct_srs=0; + $b=0; + if (strlen($Gct_state_call_times)>2) + { + $state_rules = explode('|',$Gct_state_call_times); + $ct_srs = ((count($state_rules)) - 2); + } + while($ct_srs >= $b) + { + if (strlen($state_rules[$b])>1) + { + $stmt = "SELECT state_call_time_id,state_call_time_state,state_call_time_name,state_call_time_comments,sct_default_start,sct_default_stop,sct_sunday_start,sct_sunday_stop,sct_monday_start,sct_monday_stop,sct_tuesday_start,sct_tuesday_stop,sct_wednesday_start,sct_wednesday_stop,sct_thursday_start,sct_thursday_stop,sct_friday_start,sct_friday_stop,sct_saturday_start,sct_saturday_stop,ct_holidays from vicidial_state_call_times where state_call_time_id='$state_rules[$b]';"; + $rslt=mysql_to_mysqli($stmt, $link); + if ($DB) {echo "$stmt\n";} + $sthCrows=mysqli_num_rows($rslt); + if ($sthCrows > 0) + { + $aryC=mysqli_fetch_row($rslt); + $Gstate_call_time_state = $aryC[1]; + if ($Gstate_call_time_state == $state) + { + $Gstate_call_time_id = $aryC[0]; + $Gsct_default_start = $aryC[4]; + $Gsct_default_stop = $aryC[5]; + $Gsct_sunday_start = $aryC[6]; + $Gsct_sunday_stop = $aryC[7]; + $Gsct_monday_start = $aryC[8]; + $Gsct_monday_stop = $aryC[9]; + $Gsct_tuesday_start = $aryC[10]; + $Gsct_tuesday_stop = $aryC[11]; + $Gsct_wednesday_start = $aryC[12]; + $Gsct_wednesday_stop = $aryC[13]; + $Gsct_thursday_start = $aryC[14]; + $Gsct_thursday_stop = $aryC[15]; + $Gsct_friday_start = $aryC[16]; + $Gsct_friday_stop = $aryC[17]; + $Gsct_saturday_start = $aryC[18]; + $Gsct_saturday_stop = $aryC[19]; + $Sct_holidays = $aryC[20]; + $ct_states .="'$Gstate_call_time_state',"; + + ### BEGIN Check for outbound state holiday ### + $Sholiday_id = ''; + if ((strlen($Sct_holidays)>2) or ((strlen($holiday_id)>2) and (strlen($Sholiday_id)<2))) + { + # Apply state holiday + if (strlen($Sct_holidays)>2) + { + $Sct_holidaysSQL = preg_replace("/\|/", "','", "$Sct_holidays"); + $Sct_holidaysSQL = "'".$Sct_holidaysSQL."'"; + $stmt = "SELECT holiday_id,holiday_date,holiday_name,ct_default_start,ct_default_stop from vicidial_call_time_holidays where holiday_id IN($Sct_holidaysSQL) and holiday_status='ACTIVE' and holiday_date='$YMD' order by holiday_id;"; + $holidaytype = "STATE CALL TIME HOLIDAY FOUND! "; + } + # Apply call time wide holiday + elseif ((strlen($holiday_id)>2) and (strlen($Sholiday_id)<2)) + { + $stmt = "SELECT holiday_id,holiday_date,holiday_name,ct_default_start,ct_default_stop from vicidial_call_time_holidays where holiday_id='$holiday_id' and holiday_status='ACTIVE' and holiday_date='$YMD' order by holiday_id;"; + $holidaytype = "NO STATE HOLIDAY APPLYING CALL TIME HOLIDAY! "; + } + $rslt=mysql_to_mysqli($stmt, $link); + if ($DB) {echo "$stmt\n";} + $sthCrows=mysqli_num_rows($rslt); + if ($sthCrows > 0) + { + $aryC=mysqli_fetch_row($rslt); + $Sholiday_id = $aryC[0]; + $Sholiday_date = $aryC[1]; + $Sholiday_name = $aryC[2]; + if ( ($Gsct_default_start < $aryC[3]) && ($Gsct_default_stop > 0) ) {$Gsct_default_start = $aryC[3];} + if ( ($Gsct_default_stop > $aryC[4]) && ($Gsct_default_stop > 0) ) {$Gsct_default_stop = $aryC[4];} + if ( ($Gsct_sunday_start < $aryC[3]) && ($Gsct_sunday_stop > 0) ) {$Gsct_sunday_start = $aryC[3];} + if ( ($Gsct_sunday_stop > $aryC[4]) && ($Gsct_sunday_stop > 0) ) {$Gsct_sunday_stop = $aryC[4];} + if ( ($Gsct_monday_start < $aryC[3]) && ($Gsct_monday_stop > 0) ) {$Gsct_monday_start = $aryC[3];} + if ( ($Gsct_monday_stop > $aryC[4]) && ($Gsct_monday_stop > 0) ) {$Gsct_monday_stop = $aryC[4];} + if ( ($Gsct_tuesday_start < $aryC[3]) && ($Gsct_tuesday_stop > 0) ) {$Gsct_tuesday_start = $aryC[3];} + if ( ($Gsct_tuesday_stop > $aryC[4]) && ($Gsct_tuesday_stop > 0) ) {$Gsct_tuesday_stop = $aryC[4];} + if ( ($Gsct_wednesday_start < $aryC[3]) && ($Gsct_wednesday_stop > 0) ) {$Gsct_wednesday_start = $aryC[3];} + if ( ($Gsct_wednesday_stop > $aryC[4]) && ($Gsct_wednesday_stop > 0) ) {$Gsct_wednesday_stop = $aryC[4];} + if ( ($Gsct_thursday_start < $aryC[3]) && ($Gsct_thursday_stop > 0) ) {$Gsct_thursday_start = $aryC[3];} + if ( ($Gsct_thursday_stop > $aryC[4]) && ($Gsct_thursday_stop > 0) ) {$Gsct_thursday_stop = $aryC[4];} + if ( ($Gsct_friday_start < $aryC[3]) && ($Gsct_friday_stop > 0) ) {$Gsct_friday_start = $aryC[3];} + if ( ($Gsct_friday_stop > $aryC[4]) && ($Gsct_friday_stop > 0) ) {$Gsct_friday_stop = $aryC[4];} + if ( ($Gsct_saturday_start < $aryC[3]) && ($Gsct_saturday_stop > 0) ) {$Gsct_saturday_start = $aryC[3];} + if ( ($Gsct_saturday_stop > $aryC[4]) && ($Gsct_saturday_stop > 0) ) {$Gsct_saturday_stop = $aryC[4];} + if ($DB) {echo "$holidaytype |$Gstate_call_time_id|$Gstate_call_time_state|$Sholiday_id|$Sholiday_date|$Sholiday_name|$Gsct_default_start|$Gsct_default_stop|\n";} + } + } + } + } + } + $b++; + } + } + ### END Check for outbound state holiday ### + if(strlen($Gstate_call_time_id)>2){ + # STATE RULES + if ($GMT_day==0) #### Sunday local time + { + if (($Gsct_sunday_start==0) && ($Gsct_sunday_stop==0)) + { + if ( ($GMT_hour>=$Gsct_default_start) && ($GMT_hour<$Gsct_default_stop) ) + {$dialable=1;} + } + else + { + if ( ($GMT_hour>=$Gsct_sunday_start) && ($GMT_hour<$Gsct_sunday_stop) ) + {$dialable=1;} + } + } + if ($GMT_day==1) #### Monday local time + { + if (($Gsct_monday_start==0) && ($Gsct_monday_stop==0)) + { + if ( ($GMT_hour>=$Gsct_default_start) && ($GMT_hour<$Gsct_default_stop) ) + {$dialable=1;} + } + else + { + if ( ($GMT_hour>=$Gsct_monday_start) && ($GMT_hour<$Gsct_monday_stop) ) + {$dialable=1;} + } + } + if ($GMT_day==2) #### Tuesday local time + { + if (($Gsct_tuesday_start==0) && ($Gsct_tuesday_stop==0)) + { + if ( ($GMT_hour>=$Gsct_default_start) && ($GMT_hour<$Gsct_default_stop) ) + {$dialable=1;} + } + else + { + if ( ($GMT_hour>=$Gsct_tuesday_start) && ($GMT_hour<$Gsct_tuesday_stop) ) + {$dialable=1;} + } + } + if ($GMT_day==3) #### Wednesday local time + { + if (($Gsct_wednesday_start==0) && ($Gsct_wednesday_stop==0)) + { + if ( ($GMT_hour>=$Gsct_default_start) && ($GMT_hour<$Gsct_default_stop) ) + {$dialable=1;} + } + else + { + if ( ($GMT_hour>=$Gsct_wednesday_start) && ($GMT_hour<$Gsct_wednesday_stop) ) + {$dialable=1;} + } + } + if ($GMT_day==4) #### Thursday local time + { + if (($Gsct_thursday_start==0) && ($Gsct_thursday_stop==0)) + { + if ( ($GMT_hour>=$Gsct_default_start) && ($GMT_hour<$Gsct_default_stop) ) + {$dialable=1;} + } + else + { + if ( ($GMT_hour>=$Gsct_thursday_start) && ($GMT_hour<$Gsct_thursday_stop) ) + {$dialable=1;} + } + } + if ($GMT_day==5) #### Friday local time + { + if (($Gsct_friday_start==0) && ($Gsct_friday_stop==0)) + { + if ( ($GMT_hour>=$Gsct_default_start) && ($GMT_hour<$Gsct_default_stop) ) + {$dialable=1;} + } + else + { + if ( ($GMT_hour>=$Gsct_friday_start) && ($GMT_hour<$Gsct_friday_stop) ) + {$dialable=1;} + } + } + if ($GMT_day==6) #### Saturday local time + { + if (($Gsct_saturday_start==0) && ($Gsct_saturday_stop==0)) + { + if ( ($GMT_hour>=$Gsct_default_start) && ($GMT_hour<$Gsct_default_stop) ) + {$dialable=1;} + } + else + { + if ( ($GMT_hour>=$Gsct_saturday_start) && ($GMT_hour<$Gsct_saturday_stop) ) + {$dialable=1;} + } + } + } else { + #NO STATE RULES + 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;} + } + } } - 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; } diff --git a/www/agc/vdc_db_query.php b/www/agc/vdc_db_query.php index ad06c611..29ebeab4 100644 --- a/www/agc/vdc_db_query.php +++ b/www/agc/vdc_db_query.php @@ -1,7 +1,7 @@ LICENSE: AGPLv2 +# Copyright (C) 2015 Matt Florell LICENSE: AGPLv2 # # This script is designed to exchange information between vicidial.php and the database server for various actions # @@ -371,10 +371,11 @@ # 141207-1056 - Added pause_trigger to logout to force pause before running logout process # 141216-1900 - Added agent choose language option # 141229-1428 - Changed single-quote QXZ arguments to double-quotes +# 150111-1544 - Added lists option: local call time(Issue #812) and added manual_dial_search_filter feature # -$version = '2.10-266'; -$build = '141229-1428'; +$version = '2.10-267'; +$build = '150111-1544'; $mel=1; # Mysql Error Log enabled = 1 $mysql_log_count=599; $one_mysql_log=0; @@ -626,6 +627,9 @@ if (isset($_GET["in_script"])) {$in_script=$_GET["in_script"];} elseif (isset($_POST["in_script"])) {$in_script=$_POST["in_script"];} if (isset($_GET["camp_script"])) {$camp_script=$_GET["camp_script"];} elseif (isset($_POST["camp_script"])) {$camp_script=$_POST["camp_script"];} +if (isset($_GET["manual_dial_search_filter"])) {$manual_dial_search_filter=$_GET["manual_dial_search_filter"];} + elseif (isset($_POST["manual_dial_search_filter"])) {$manual_dial_search_filter=$_POST["manual_dial_search_filter"];} + header ("Content-type: text/html; charset=utf-8"); header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 @@ -1767,9 +1771,84 @@ if ($ACTION == 'manDiaLnextCaLL') $lead_id_defined++; } - ### BEGIN check for manual dial filtering ### + ### BEGIN lookup of lead or flag for insert ### + $lookup_empty_insert_lead=0; + if ($lead_id_defined < 1) + { + if (strlen($phone_number)>3) + { + if ($stage=='lookup') + { + $manual_dial_search_filterSQL=''; + if (preg_match("/CAMPLISTS/",$manual_dial_search_filter)) + { + $stmt="SELECT list_id,active from vicidial_lists where campaign_id='$campaign'"; + $rslt=mysql_to_mysqli($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00019',$user,$server_ip,$session_name,$one_mysql_log);} + $lists_to_parse = mysqli_num_rows($rslt); + $Scamp_lists=''; + $o=0; + while ($lists_to_parse > $o) + { + $rowx=mysqli_fetch_row($rslt); + if (preg_match("/Y/", $rowx[1])) {$active_lists++; $Scamp_lists .= "'$rowx[0]',";} + if (preg_match("/ALL/",$manual_dial_search_filter)) + { + if (preg_match("/N/", $rowx[1])) + {$inactive_lists++; $Scamp_lists .= "'$rowx[0]',";} + } + else + { + if (preg_match("/N/", $rowx[1])) + {$inactive_lists++;} + } + $o++; + } + $Scamp_lists = preg_replace("/.$/i","",$Scamp_lists); + if (strlen($Scamp_lists)<2) {$Scamp_lists="''";} + $manual_dial_search_filterSQL = "and list_id IN($Scamp_lists)"; + } + if (strlen($vendor_lead_code)>0) + { + $stmt="SELECT lead_id FROM vicidial_list where vendor_lead_code='$vendor_lead_code' $manual_dial_search_filterSQL order by modify_date desc LIMIT 1;"; + $rslt=mysql_to_mysqli($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00021',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $man_leadID_ct = mysqli_num_rows($rslt); + if ( ($man_leadID_ct > 0) and (strlen($phone_number) > 5) ) + {$override_phone++;} + } + else + { + $stmt="SELECT lead_id FROM vicidial_list where phone_number='$phone_number' $manual_dial_search_filterSQL order by modify_date desc LIMIT 1;"; + $rslt=mysql_to_mysqli($stmt, $link); + 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 = mysqli_num_rows($rslt); + } + if ($man_leadID_ct > 0) + { + $row=mysqli_fetch_row($rslt); + $affected_rows=1; + $lead_id =$row[0]; + $CBleadIDset=1; + } + else + { + $lookup_empty_insert_lead++; + } + } + else + { + $lookup_empty_insert_lead++; + } + } + } + ### END lookup of lead or flag for insert ### + if (strlen($phone_number)>3) { + ### BEGIN check for manual dial filtering ### if (preg_match("/ENABLED/",$manual_dial_call_time_check)) { $secX = date("U"); @@ -1813,8 +1892,43 @@ if ($ACTION == 'manDiaLnextCaLL') $USarea = substr($phone_number, 0, 3); $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); + ################################# + ### Get list_id for lead + if ($lookup_empty_insert_lead > 0) + { + $lead_list_id = $list_id; + } + else + { + $stmt="SELECT list_id,state FROM vicidial_list where lead_id='$lead_id';"; + $rslt=mysql_to_mysqli($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00XXX',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $row=mysqli_fetch_row($rslt); + $lead_list_id = $row[0]; + $state = $row[1]; + } + ### Get local_call_time for list + $stmt="SELECT local_call_time FROM vicidial_lists where list_id='$lead_list_id';"; + $rslt=mysql_to_mysqli($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00XXX',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $row=mysqli_fetch_row($rslt); + $list_local_call_time = $row[0]; + + #Check if we are with the gmt for campaign + if( (dialable_gmt($DB,$link,$local_call_time,$gmt_offset,$state) == 1) and ($list_local_call_time != "campaign") ) + { + #Now check if we are with the GMT for the list + $dialable = dialable_gmt($DB,$link,$list_local_call_time,$gmt_offset,$state); + } + else + { + $dialable = dialable_gmt($DB,$link,$local_call_time,$gmt_offset,$state); + } + $affected_rows = $dialable; + ################################# if ($dialable < 1) { ### purge from the dial queue and api @@ -1834,7 +1948,6 @@ if ($ACTION == 'manDiaLnextCaLL') exit; } } - if (preg_match("/DNC/",$manual_dial_filter)) { if (preg_match("/AREACODE/",$use_internal_dnc)) @@ -1961,72 +2074,28 @@ if ($ACTION == 'manDiaLnextCaLL') exit; } } - } + ### END check for manual dial filtering ### - ### END check for manual dial filtering ### - - - if ($lead_id_defined < 1) - { - if (strlen($phone_number)>3) + if ($lookup_empty_insert_lead > 0) { - if ($stage=='lookup') - { - if (strlen($vendor_lead_code)>0) - { - $stmt="SELECT lead_id FROM vicidial_list where vendor_lead_code='$vendor_lead_code' order by modify_date desc LIMIT 1;"; - $rslt=mysql_to_mysqli($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00021',$user,$server_ip,$session_name,$one_mysql_log);} - if ($DB) {echo "$stmt\n";} - $man_leadID_ct = mysqli_num_rows($rslt); - if ( ($man_leadID_ct > 0) and (strlen($phone_number) > 5) ) - {$override_phone++;} - } - else - { - $stmt="SELECT lead_id FROM vicidial_list where phone_number='$phone_number' order by modify_date desc LIMIT 1;"; - $rslt=mysql_to_mysqli($stmt, $link); - 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 = mysqli_num_rows($rslt); - } - if ($man_leadID_ct > 0) - { - $row=mysqli_fetch_row($rslt); - $affected_rows=1; - $lead_id =$row[0]; - $CBleadIDset=1; - } - else - { - ### insert a new lead in the system with this phone number - $stmt = "INSERT INTO vicidial_list SET phone_code='$phone_code',phone_number='$phone_number',list_id='$list_id',status='QUEUE',user='$user',called_since_last_reset='Y',entry_date='$ENTRYdate',last_local_call_time='$NOW_TIME',vendor_lead_code='$vendor_lead_code';"; - if ($DB) {echo "$stmt\n";} - $rslt=mysql_to_mysqli($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00022',$user,$server_ip,$session_name,$one_mysql_log);} - $affected_rows = mysqli_affected_rows($link); - $lead_id = mysqli_insert_id($link); - $CBleadIDset=1; - } - } - else - { - ### insert a new lead in the system with this phone number - $stmt = "INSERT INTO vicidial_list SET phone_code='$phone_code',phone_number='$phone_number',list_id='$list_id',status='QUEUE',user='$user',called_since_last_reset='Y',entry_date='$ENTRYdate',last_local_call_time='$NOW_TIME',vendor_lead_code='$vendor_lead_code';"; - if ($DB) {echo "$stmt\n";} - $rslt=mysql_to_mysqli($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00023',$user,$server_ip,$session_name,$one_mysql_log);} - $affected_rows = mysqli_affected_rows($link); - $lead_id = mysqli_insert_id($link); - $CBleadIDset=1; - } + ### insert a new lead in the system with this phone number + $stmt = "INSERT INTO vicidial_list SET phone_code='$phone_code',phone_number='$phone_number',list_id='$list_id',status='QUEUE',user='$user',called_since_last_reset='Y',entry_date='$ENTRYdate',last_local_call_time='$NOW_TIME',vendor_lead_code='$vendor_lead_code';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_to_mysqli($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00022',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysqli_affected_rows($link); + $lead_id = mysqli_insert_id($link); + $CBleadIDset=1; } - else + } + else + { + if ($lead_id_defined < 1) { ##### 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,lead_order_randomize,lead_order_secondary,call_count_limit FROM vicidial_campaigns where campaign_id='$campaign';"; $rslt=mysql_to_mysqli($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00236',$user,$server_ip,$session_name,$one_mysql_log);} + 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";} $camp_nohopper_ct = mysqli_num_rows($rslt); if ($camp_nohopper_ct > 0) @@ -2049,7 +2118,7 @@ if ($ACTION == 'manDiaLnextCaLL') $stmt = "UPDATE vicidial_hopper set status='QUEUE', user='$user' where campaign_id='$campaign' and status='READY' order by priority desc,hopper_id LIMIT 1"; if ($DB) {echo "$stmt\n";} $rslt=mysql_to_mysqli($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00024',$user,$server_ip,$session_name,$one_mysql_log);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00024',$user,$server_ip,$session_name,$one_mysql_log);} $affected_rows = mysqli_affected_rows($link); } else @@ -2067,6 +2136,7 @@ if ($ACTION == 'manDiaLnextCaLL') $GMT_gmt[0] = ''; $GMT_hour[0] = ''; $GMT_day[0] = ''; + $YMD = date("Y-m-d"); while ($p > -13) { $pzone=3600 * $p; @@ -2080,11 +2150,11 @@ if ($ACTION == 'manDiaLnextCaLL') $p = ($p - 0.25); $g++; } - - $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';"; + + $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,ct_holidays FROM vicidial_call_times where call_time_id='$local_call_time';"; if ($DB) {echo "$stmt\n";} $rslt=mysql_to_mysqli($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00237',$user,$server_ip,$session_name,$one_mysql_log);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00237',$user,$server_ip,$session_name,$one_mysql_log);} $rowx=mysqli_fetch_row($rslt); $Gct_default_start = $rowx[3]; $Gct_default_stop = $rowx[4]; @@ -2103,6 +2173,44 @@ if ($ACTION == 'manDiaLnextCaLL') $Gct_saturday_start = $rowx[17]; $Gct_saturday_stop = $rowx[18]; $Gct_state_call_times = $rowx[19]; + $Gct_holidays = $rowx[20]; + + ### BEGIN Check for outbound holiday ### + $holiday_id = ''; + if (strlen($Gct_holidays)>2) + { + $Gct_holidaysSQL = preg_replace("/\|/", "','", "$Gct_holidays"); + $Gct_holidaysSQL = "'".$Gct_holidaysSQL."'"; + $stmt = "SELECT holiday_id,holiday_date,holiday_name,ct_default_start,ct_default_stop from vicidial_call_time_holidays where holiday_id IN($Gct_holidaysSQL) and holiday_status='ACTIVE' and holiday_date='$YMD' order by holiday_id;"; + $rslt=mysql_to_mysqli($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00240',$user,$server_ip,$session_name,$one_mysql_log);} + $sthCrows=mysqli_num_rows($rslt); + if ($sthCrows > 0) + { + $aryC=mysqli_fetch_row($rslt); + $Sholiday_id = $aryC[0]; + $Sholiday_date = $aryC[1]; + $Sholiday_name = $aryC[2]; + if ( ($Gct_default_start < $aryC[3]) && ($Gct_default_stop > 0) ) {$Gct_default_start = $aryC[3];} + if ( ($Gct_default_stop > $aryC[4]) && ($Gct_default_stop > 0) ) {$Gct_default_stop = $aryC[4];} + if ( ($Gct_sunday_start < $aryC[3]) && ($Gct_sunday_stop > 0) ) {$Gct_sunday_start = $aryC[3];} + if ( ($Gct_sunday_stop > $aryC[4]) && ($Gct_sunday_stop > 0) ) {$Gct_sunday_stop = $aryC[4];} + if ( ($Gct_monday_start < $aryC[3]) && ($Gct_monday_stop > 0) ) {$Gct_monday_start = $aryC[3];} + if ( ($Gct_monday_stop > $aryC[4]) && ($Gct_monday_stop > 0) ) {$Gct_monday_stop = $aryC[4];} + if ( ($Gct_tuesday_start < $aryC[3]) && ($Gct_tuesday_stop > 0) ) {$Gct_tuesday_start = $aryC[3];} + if ( ($Gct_tuesday_stop > $aryC[4]) && ($Gct_tuesday_stop > 0) ) {$Gct_tuesday_stop = $aryC[4];} + if ( ($Gct_wednesday_start < $aryC[3]) && ($Gct_wednesday_stop > 0) ) {$Gct_wednesday_start = $aryC[3];} + if ( ($Gct_wednesday_stop > $aryC[4]) && ($Gct_wednesday_stop > 0) ) {$Gct_wednesday_stop = $aryC[4];} + if ( ($Gct_thursday_start < $aryC[3]) && ($Gct_thursday_stop > 0) ) {$Gct_thursday_start = $aryC[3];} + if ( ($Gct_thursday_stop > $aryC[4]) && ($Gct_thursday_stop > 0) ) {$Gct_thursday_stop = $aryC[4];} + if ( ($Gct_friday_start < $aryC[3]) && ($Gct_friday_stop > 0) ) {$Gct_friday_start = $aryC[3];} + if ( ($Gct_friday_stop > $aryC[4]) && ($Gct_friday_stop > 0) ) {$Gct_friday_stop = $aryC[4];} + if ( ($Gct_saturday_start < $aryC[3]) && ($Gct_saturday_stop > 0) ) {$Gct_saturday_start = $aryC[3];} + if ( ($Gct_saturday_stop > $aryC[4]) && ($Gct_saturday_stop > 0) ) {$Gct_saturday_stop = $aryC[4];} + if ($DB) {echo "CAMPAIGN CALL TIME HOLIDAY FOUND! $local_call_time|$holiday_id|$holiday_date|$holiday_name|$Gct_default_start|$Gct_default_stop|\n";} + } + } + ### END Check for outbound holiday ### $ct_states = ''; $ct_state_gmt_SQL = ''; @@ -2117,9 +2225,9 @@ if ($ACTION == 'manDiaLnextCaLL') { if (strlen($state_rules[$b])>1) { - $stmt="SELECT state_call_time_id,state_call_time_state,state_call_time_name,state_call_time_comments,sct_default_start,sct_default_stop,sct_sunday_start,sct_sunday_stop,sct_monday_start,sct_monday_stop,sct_tuesday_start,sct_tuesday_stop,sct_wednesday_start,sct_wednesday_stop,sct_thursday_start,sct_thursday_stop,sct_friday_start,sct_friday_stop,sct_saturday_start,sct_saturday_stop from vicidial_state_call_times where state_call_time_id='$state_rules[$b]';"; + $stmt="SELECT state_call_time_id,state_call_time_state,state_call_time_name,state_call_time_comments,sct_default_start,sct_default_stop,sct_sunday_start,sct_sunday_stop,sct_monday_start,sct_monday_stop,sct_tuesday_start,sct_tuesday_stop,sct_wednesday_start,sct_wednesday_stop,sct_thursday_start,sct_thursday_stop,sct_friday_start,sct_friday_stop,sct_saturday_start,sct_saturday_stop,ct_holidays from vicidial_state_call_times where state_call_time_id='$state_rules[$b]';"; $rslt=mysql_to_mysqli($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00238',$user,$server_ip,$session_name,$one_mysql_log);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00238',$user,$server_ip,$session_name,$one_mysql_log);} $row=mysqli_fetch_row($rslt); $Gstate_call_time_id = $row[0]; $Gstate_call_time_state = $row[1]; @@ -2139,13 +2247,66 @@ if ($ACTION == 'manDiaLnextCaLL') $Gsct_friday_stop = $row[17]; $Gsct_saturday_start = $row[18]; $Gsct_saturday_stop = $row[19]; - + $Sct_holidays = $row[20]; $ct_states .="'$Gstate_call_time_state',"; + ### BEGIN Check for outbound state holiday ### + $Sholiday_id = ''; + if ((strlen($Sct_holidays)>2) or ((strlen($holiday_id)>2) and (strlen($Sholiday_id)<2))) + { + #Apply state holiday + if (strlen($Sct_holidays)>2) + { + $Sct_holidaysSQL = preg_replace("/\|/", "','", "$Sct_holidays"); + $Sct_holidaysSQL = "'".$Sct_holidaysSQL."'"; + $stmt = "SELECT holiday_id,holiday_date,holiday_name,ct_default_start,ct_default_stop from vicidial_call_time_holidays where holiday_id IN($Sct_holidaysSQL) and holiday_status='ACTIVE' and holiday_date='$YMD' order by holiday_id;"; + $holidaytype = "CAMPAIGN STATE CALL TIME HOLIDAY FOUND! "; + } + #Apply call time wide holiday + elseif ((strlen($holiday_id)>2) and (strlen($Sholiday_id)<2)) + { + $stmt = "SELECT holiday_id,holiday_date,holiday_name,ct_default_start,ct_default_stop from vicidial_call_time_holidays where holiday_id='$holiday_id' and holiday_status='ACTIVE' and holiday_date='$YMD' order by holiday_id;"; + $holidaytype = "CAMPAIGN NO STATE HOLIDAY APPLYING CALL TIME HOLIDAY! "; + } + $rslt=mysql_to_mysqli($stmt, $link); + if ($DB) {echo "$stmt\n";} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00XXX',$user,$server_ip,$session_name,$one_mysql_log);} + $sthCrows=mysqli_num_rows($rslt); + if ($sthCrows > 0) + { + $aryC=mysqli_fetch_row($rslt); + $Sholiday_id = $aryC[0]; + $Sholiday_date = $aryC[1]; + $Sholiday_name = $aryC[2]; + if ( ($Gsct_default_start < $aryC[3]) && ($Gsct_default_stop > 0) ) {$Gsct_default_start = $aryC[3];} + if ( ($Gsct_default_stop > $aryC[4]) && ($Gsct_default_stop > 0) ) {$Gsct_default_stop = $aryC[4];} + if ( ($Gsct_sunday_start < $aryC[3]) && ($Gsct_sunday_stop > 0) ) {$Gsct_sunday_start = $aryC[3];} + if ( ($Gsct_sunday_stop > $aryC[4]) && ($Gsct_sunday_stop > 0) ) {$Gsct_sunday_stop = $aryC[4];} + if ( ($Gsct_monday_start < $aryC[3]) && ($Gsct_monday_stop > 0) ) {$Gsct_monday_start = $aryC[3];} + if ( ($Gsct_monday_stop > $aryC[4]) && ($Gsct_monday_stop > 0) ) {$Gsct_monday_stop = $aryC[4];} + if ( ($Gsct_tuesday_start < $aryC[3]) && ($Gsct_tuesday_stop > 0) ) {$Gsct_tuesday_start = $aryC[3];} + if ( ($Gsct_tuesday_stop > $aryC[4]) && ($Gsct_tuesday_stop > 0) ) {$Gsct_tuesday_stop = $aryC[4];} + if ( ($Gsct_wednesday_start < $aryC[3]) && ($Gsct_wednesday_stop > 0) ) {$Gsct_wednesday_start = $aryC[3];} + if ( ($Gsct_wednesday_stop > $aryC[4]) && ($Gsct_wednesday_stop > 0) ) {$Gsct_wednesday_stop = $aryC[4];} + if ( ($Gsct_thursday_start < $aryC[3]) && ($Gsct_thursday_stop > 0) ) {$Gsct_thursday_start = $aryC[3];} + if ( ($Gsct_thursday_stop > $aryC[4]) && ($Gsct_thursday_stop > 0) ) {$Gsct_thursday_stop = $aryC[4];} + if ( ($Gsct_friday_start < $aryC[3]) && ($Gsct_friday_stop > 0) ) {$Gsct_friday_start = $aryC[3];} + if ( ($Gsct_friday_stop > $aryC[4]) && ($Gsct_friday_stop > 0) ) {$Gsct_friday_stop = $aryC[4];} + if ( ($Gsct_saturday_start < $aryC[3]) && ($Gsct_saturday_stop > 0) ) {$Gsct_saturday_start = $aryC[3];} + if ( ($Gsct_saturday_stop > $aryC[4]) && ($Gsct_saturday_stop > 0) ) {$Gsct_saturday_stop = $aryC[4];} + if ($DB) {echo "$holidaytype |$Gstate_call_time_id|$Gstate_call_time_state|$Sholiday_id|$Sholiday_date|$Sholiday_name|$Gsct_default_start|$Gsct_default_stop|\n";} + } + } + + ### END Check for outbound state holiday ### + + $r=0; $state_gmt=''; while($r < $g) { + if ($DB > 0) + {echo "CSCT_gmt: $r|$GMT_day[$r]|$GMT_gmt[$r]|$Gsct_sunday_start|$Gsct_sunday_stop|$GMT_hour[$r]|$Gsct_default_start|$Gsct_default_stop\n";} if ($GMT_day[$r]==0) #### Sunday local time { if (($Gsct_sunday_start==0) and ($Gsct_sunday_stop==0)) @@ -2259,6 +2420,8 @@ if ($ACTION == 'manDiaLnextCaLL') $default_gmt=''; while($r < $g) { + if ($DB > 0) + {echo "CSCT_gmt: $r|$GMT_day[$r]|$GMT_gmt[$r]|$Gct_sunday_start|$Gct_sunday_stop|$GMT_hour[$r]|$Gct_default_start|$Gct_default_stop\n";} if ($GMT_day[$r]==0) #### Sunday local time { if (($Gct_sunday_start==0) and ($Gct_sunday_stop==0)) @@ -2386,7 +2549,7 @@ if ($ACTION == 'manDiaLnextCaLL') $stmt="SELECT lead_filter_sql FROM vicidial_lead_filters where lead_filter_id='$lead_filter_id';"; $rslt=mysql_to_mysqli($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00239',$user,$server_ip,$session_name,$one_mysql_log);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00239',$user,$server_ip,$session_name,$one_mysql_log);} $filtersql_ct = mysqli_num_rows($rslt); if ($DB) {echo "$filtersql_ct|$stmt\n";} if ($filtersql_ct > 0) @@ -2396,21 +2559,490 @@ if ($ACTION == 'manDiaLnextCaLL') $fSQL = preg_replace('/\\\\/','',$fSQL); } + ################################# + # Camp List $stmt="SELECT list_id FROM vicidial_lists where campaign_id='$campaign' and active='Y';"; - $rslt=mysql_to_mysqli($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00240',$user,$server_ip,$session_name,$one_mysql_log);} - $camplists_ct = mysqli_num_rows($rslt); + $rslt_list=mysql_to_mysqli($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00XXX',$user,$server_ip,$session_name,$one_mysql_log);} + $camplists_ct = mysqli_num_rows($rslt_list); if ($DB) {echo "$camplists_ct|$stmt\n";} $k=0; $camp_lists=''; while ($camplists_ct > $k) { - $row=mysqli_fetch_row($rslt); - $camp_lists .= "'$row[0]',"; + $rowA = mysqli_fetch_row($rslt_list); + $camp_lists .= "'$rowA[0]',"; + + ##### Get Call List call time settings + ##### BEGIN calculate what gmt_offset_now values are within the allowed local_call_time setting ### + $g=0; + $p='13'; + $GMT_gmt[0] = ''; + $GMT_hour[0] = ''; + $GMT_day[0] = ''; + $YMD = date("Y-m-d"); + while ($p > -13) + { + $pzone=3600 * $p; + $pmin=(gmdate("i", time() + $pzone)); + $phour=( (gmdate("G", time() + $pzone)) * 100); + $pday=gmdate("w", time() + $pzone); + $tz = sprintf("%.2f", $p); + $GMT_gmt[$g] = "$tz"; + $GMT_day[$g] = "$pday"; + $GMT_hour[$g] = ($phour + $pmin); + $p = ($p - 0.25); + $g++; + } + + # Set List ID Variable + $cur_list_id = $rowA[0]; + $list_local_call_time = ""; + + # Pull the call times for the lists + $stmt="SELECT local_call_time FROM vicidial_lists where list_id='$cur_list_id';"; + $rslt=mysql_to_mysqli($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00XXX',$user,$server_ip,$session_name,$one_mysql_log);} + $rslt_ct = mysqli_num_rows($rslt); + if ($rslt_ct > 0) + { + #set Cur call_time + $row=mysqli_fetch_row($rslt); + $cur_call_time = $row[0]; + } + + ##### BEGIN local call time for list set different than campaign ##### + if ($cur_call_time != "campaign") + { + ##### BEGIN calculate what gmt_offset_now values are within the allowed local_call_time setting ### + $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,ct_holidays FROM vicidial_call_times where call_time_id='$cur_call_time';"; + if ($DB) {echo "$stmt\n";} + $rsltD=mysql_to_mysqli($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00237',$user,$server_ip,$session_name,$one_mysql_log);} + $aryD=mysqli_fetch_row($rsltD); + $Gct_default_start = $aryD[3]; + $Gct_default_stop = $aryD[4]; + $Gct_sunday_start = $aryD[5]; + $Gct_sunday_stop = $aryD[6]; + $Gct_monday_start = $aryD[7]; + $Gct_monday_stop = $aryD[8]; + $Gct_tuesday_start = $aryD[9]; + $Gct_tuesday_stop = $aryD[10]; + $Gct_wednesday_start = $aryD[11]; + $Gct_wednesday_stop = $aryD[12]; + $Gct_thursday_start = $aryD[13]; + $Gct_thursday_stop = $aryD[14]; + $Gct_friday_start = $aryD[15]; + $Gct_friday_stop = $aryD[16]; + $Gct_saturday_start = $aryD[17]; + $Gct_saturday_stop = $aryD[18]; + $Gct_state_call_times = $aryD[19]; + $Gct_holidays = $aryD[20]; + + ### BEGIN Check for outbound holiday ### + $holiday_id = ''; + if (strlen($Gct_holidays)>2) + { + $Gct_holidaysSQL = preg_replace("/\|/", "','", "$Gct_holidays"); + $Gct_holidaysSQL = "'".$Gct_holidaysSQL."'"; + + $stmt = "SELECT holiday_id,holiday_date,holiday_name,ct_default_start,ct_default_stop from vicidial_call_time_holidays where holiday_id IN($Gct_holidaysSQL) and holiday_status='ACTIVE' and holiday_date='$YMD' order by holiday_id;"; + $rslt=mysql_to_mysqli($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00XXX',$user,$server_ip,$session_name,$one_mysql_log);} + $sthCrows=mysqli_num_rows($rslt); + if ($sthCrows > 0) + { + $aryC=mysqli_fetch_row($rslt); + $holiday_id = $aryC[0]; + $holiday_date = $aryC[1]; + $holiday_name = $aryC[2]; + if ( ($Gct_default_start < $aryC[3]) && ($Gct_default_stop > 0) ) {$Gct_default_start = $aryC[3];} + if ( ($Gct_default_stop > $aryC[4]) && ($Gct_default_stop > 0) ) {$Gct_default_stop = $aryC[4];} + if ( ($Gct_sunday_start < $aryC[3]) && ($Gct_sunday_stop > 0) ) {$Gct_sunday_start = $aryC[3];} + if ( ($Gct_sunday_stop > $aryC[4]) && ($Gct_sunday_stop > 0) ) {$Gct_sunday_stop = $aryC[4];} + if ( ($Gct_monday_start < $aryC[3]) && ($Gct_monday_stop > 0) ) {$Gct_monday_start = $aryC[3];} + if ( ($Gct_monday_stop > $aryC[4]) && ($Gct_monday_stop > 0) ) {$Gct_monday_stop = $aryC[4];} + if ( ($Gct_tuesday_start < $aryC[3]) && ($Gct_tuesday_stop > 0) ) {$Gct_tuesday_start = $aryC[3];} + if ( ($Gct_tuesday_stop > $aryC[4]) && ($Gct_tuesday_stop > 0) ) {$Gct_tuesday_stop = $aryC[4];} + if ( ($Gct_wednesday_start < $aryC[3]) && ($Gct_wednesday_stop > 0) ) {$Gct_wednesday_start = $aryC[3];} + if ( ($Gct_wednesday_stop > $aryC[4]) && ($Gct_wednesday_stop > 0) ) {$Gct_wednesday_stop = $aryC[4];} + if ( ($Gct_thursday_start < $aryC[3]) && ($Gct_thursday_stop > 0) ) {$Gct_thursday_start = $aryC[3];} + if ( ($Gct_thursday_stop > $aryC[4]) && ($Gct_thursday_stop > 0) ) {$Gct_thursday_stop = $aryC[4];} + if ( ($Gct_friday_start < $aryC[3]) && ($Gct_friday_stop > 0) ) {$Gct_friday_start = $aryC[3];} + if ( ($Gct_friday_stop > $aryC[4]) && ($Gct_friday_stop > 0) ) {$Gct_friday_stop = $aryC[4];} + if ( ($Gct_saturday_start < $aryC[3]) && ($Gct_saturday_stop > 0) ) {$Gct_saturday_start = $aryC[3];} + if ( ($Gct_saturday_stop > $aryC[4]) && ($Gct_saturday_stop > 0) ) {$Gct_saturday_stop = $aryC[4];} + if ($DB) {echo "LIST CALL TIME HOLIDAY FOUND! $local_call_time|$holiday_id|$holiday_date|$holiday_name|$Gct_default_start|$Gct_default_stop|\n";} + } + } + ### END Check for outbound holiday ### + + $ct_states = ''; + $ct_state_gmt_SQL = ''; + $ct_srs=0; + $b=0; + if (strlen($Gct_state_call_times)>2) + { + $state_rules = explode('|',$Gct_state_call_times); + $ct_srs = ((count($state_rules)) - 2); + } + while($ct_srs >= $b) + { + if (strlen($state_rules[$b])>1) + { + $stmt = "SELECT state_call_time_id,state_call_time_state,state_call_time_name,state_call_time_comments,sct_default_start,sct_default_stop,sct_sunday_start,sct_sunday_stop,sct_monday_start,sct_monday_stop,sct_tuesday_start,sct_tuesday_stop,sct_wednesday_start,sct_wednesday_stop,sct_thursday_start,sct_thursday_stop,sct_friday_start,sct_friday_stop,sct_saturday_start,sct_saturday_stop,ct_holidays from vicidial_state_call_times where state_call_time_id='$state_rules[$b]';"; + $rslt=mysql_to_mysqli($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00XXX',$user,$server_ip,$session_name,$one_mysql_log);} + $sthCrows=mysqli_num_rows($rslt); + if ($sthCrows > 0) + { + $aryC=mysqli_fetch_row($rslt); + $Gstate_call_time_id = $aryC[0]; + $Gstate_call_time_state = $aryC[1]; + $Gsct_default_start = $aryC[4]; + $Gsct_default_stop = $aryC[5]; + $Gsct_sunday_start = $aryC[6]; + $Gsct_sunday_stop = $aryC[7]; + $Gsct_monday_start = $aryC[8]; + $Gsct_monday_stop = $aryC[9]; + $Gsct_tuesday_start = $aryC[10]; + $Gsct_tuesday_stop = $aryC[11]; + $Gsct_wednesday_start = $aryC[12]; + $Gsct_wednesday_stop = $aryC[13]; + $Gsct_thursday_start = $aryC[14]; + $Gsct_thursday_stop = $aryC[15]; + $Gsct_friday_start = $aryC[16]; + $Gsct_friday_stop = $aryC[17]; + $Gsct_saturday_start = $aryC[18]; + $Gsct_saturday_stop = $aryC[19]; + $Sct_holidays = $aryC[20]; + $ct_states .="'$Gstate_call_time_state',"; + } + + ### BEGIN Check for outbound state holiday ### + $Sholiday_id = ''; + if ((strlen($Sct_holidays)>2) or ((strlen($holiday_id)>2) and (strlen($Sholiday_id)<2))) + { + #Apply state holiday + if (strlen($Sct_holidays)>2) + { + $Sct_holidaysSQL = preg_replace("/\|/", "','", "$Sct_holidays"); + $Sct_holidaysSQL = "'".$Sct_holidaysSQL."'"; + $stmt = "SELECT holiday_id,holiday_date,holiday_name,ct_default_start,ct_default_stop from vicidial_call_time_holidays where holiday_id IN($Sct_holidaysSQL) and holiday_status='ACTIVE' and holiday_date='$YMD' order by holiday_id;"; + $holidaytype = "LIST STATE CALL TIME HOLIDAY FOUND! "; + } + #Apply call time wide holiday + elseif ((strlen($holiday_id)>2) and (strlen($Sholiday_id)<2)) + { + $stmt = "SELECT holiday_id,holiday_date,holiday_name,ct_default_start,ct_default_stop from vicidial_call_time_holidays where holiday_id='$holiday_id' and holiday_status='ACTIVE' and holiday_date='$YMD' order by holiday_id;"; + $holidaytype = "LIST NO STATE HOLIDAY APPLYING CALL TIME HOLIDAY! "; + } + $rslt=mysql_to_mysqli($stmt, $link); + if ($DB) {echo "$stmt\n";} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00XXX',$user,$server_ip,$session_name,$one_mysql_log);} + $sthCrows=mysqli_num_rows($rslt); + if ($sthCrows > 0) + { + $aryC=mysqli_fetch_row($rslt); + $Sholiday_id = $aryC[0]; + $Sholiday_date = $aryC[1]; + $Sholiday_name = $aryC[2]; + if ( ($Gsct_default_start < $aryC[3]) && ($Gsct_default_stop > 0) ) {$Gsct_default_start = $aryC[3];} + if ( ($Gsct_default_stop > $aryC[4]) && ($Gsct_default_stop > 0) ) {$Gsct_default_stop = $aryC[4];} + if ( ($Gsct_sunday_start < $aryC[3]) && ($Gsct_sunday_stop > 0) ) {$Gsct_sunday_start = $aryC[3];} + if ( ($Gsct_sunday_stop > $aryC[4]) && ($Gsct_sunday_stop > 0) ) {$Gsct_sunday_stop = $aryC[4];} + if ( ($Gsct_monday_start < $aryC[3]) && ($Gsct_monday_stop > 0) ) {$Gsct_monday_start = $aryC[3];} + if ( ($Gsct_monday_stop > $aryC[4]) && ($Gsct_monday_stop > 0) ) {$Gsct_monday_stop = $aryC[4];} + if ( ($Gsct_tuesday_start < $aryC[3]) && ($Gsct_tuesday_stop > 0) ) {$Gsct_tuesday_start = $aryC[3];} + if ( ($Gsct_tuesday_stop > $aryC[4]) && ($Gsct_tuesday_stop > 0) ) {$Gsct_tuesday_stop = $aryC[4];} + if ( ($Gsct_wednesday_start < $aryC[3]) && ($Gsct_wednesday_stop > 0) ) {$Gsct_wednesday_start = $aryC[3];} + if ( ($Gsct_wednesday_stop > $aryC[4]) && ($Gsct_wednesday_stop > 0) ) {$Gsct_wednesday_stop = $aryC[4];} + if ( ($Gsct_thursday_start < $aryC[3]) && ($Gsct_thursday_stop > 0) ) {$Gsct_thursday_start = $aryC[3];} + if ( ($Gsct_thursday_stop > $aryC[4]) && ($Gsct_thursday_stop > 0) ) {$Gsct_thursday_stop = $aryC[4];} + if ( ($Gsct_friday_start < $aryC[3]) && ($Gsct_friday_stop > 0) ) {$Gsct_friday_start = $aryC[3];} + if ( ($Gsct_friday_stop > $aryC[4]) && ($Gsct_friday_stop > 0) ) {$Gsct_friday_stop = $aryC[4];} + if ( ($Gsct_saturday_start < $aryC[3]) && ($Gsct_saturday_stop > 0) ) {$Gsct_saturday_start = $aryC[3];} + if ( ($Gsct_saturday_stop > $aryC[4]) && ($Gsct_saturday_stop > 0) ) {$Gsct_saturday_stop = $aryC[4];} + if ($DB) {echo "$holidaytype |$Gstate_call_time_id|$Gstate_call_time_state|$Sholiday_id|$Sholiday_date|$Sholiday_name|$Gsct_default_start|$Gsct_default_stop|\n";} + } + } + ### END Check for outbound state holiday ### + + $r=0; + $state_gmt=''; + $del_state_gmt=''; + while($r < $g) + { + if ($GMT_day[$r]==0) #### Sunday local time + { + if (($Gsct_sunday_start==0) && ($Gsct_sunday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) && ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_sunday_start) && ($GMT_hour[$r]<$Gsct_sunday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==1) #### Monday local time + { + if (($Gsct_monday_start==0) && ($Gsct_monday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) && ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_monday_start) && ($GMT_hour[$r]<$Gsct_monday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==2) #### Tuesday local time + { + if (($Gsct_tuesday_start==0) && ($Gsct_tuesday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) && ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_tuesday_start) && ($GMT_hour[$r]<$Gsct_tuesday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==3) #### Wednesday local time + { + if (($Gsct_wednesday_start==0) && ($Gsct_wednesday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) && ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_wednesday_start) && ($GMT_hour[$r]<$Gsct_wednesday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==4) #### Thursday local time + { + if (($Gsct_thursday_start==0) && ($Gsct_thursday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) && ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_thursday_start) && ($GMT_hour[$r]<$Gsct_thursday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==5) #### Friday local time + { + if (($Gsct_friday_start==0) && ($Gsct_friday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) && ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_friday_start) && ($GMT_hour[$r]<$Gsct_friday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==6) #### Saturday local time + { + if (($Gsct_saturday_start==0) && ($Gsct_saturday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) && ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_saturday_start) && ($GMT_hour[$r]<$Gsct_saturday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + $r++; + } + $state_gmt = "$state_gmt'99'"; + + $del_list_state_gmt_SQL .= "or (list_id=\"$cur_list_id\" and state='$Gstate_call_time_state' and gmt_offset_now NOT IN($state_gmt)) "; + $list_state_gmt_SQL .= "or (list_id=\"$cur_list_id\" and state='$Gstate_call_time_state' and gmt_offset_now IN($state_gmt)) "; + } + + $b++; + } + if (strlen($ct_states)>2) + { + $ct_states = preg_replace("/,$/i",'',$ct_states); + $ct_statesSQL = "and state NOT IN($ct_states)"; + } + else + { + $ct_statesSQL = ""; + } + + $r=0; + $dgA=0; + $list_default_gmt=''; + while($r < $g) + { + if ($DB > 0) + {echo "LCT_gmt: $r|$GMT_day[$r]|$GMT_gmt[$r]|$Gct_sunday_start|$Gct_sunday_stop|$GMT_hour[$r]|$Gct_default_start|$Gct_default_stop\n";} + + if ($GMT_day[$r]==0) #### Sunday local time + { + if (($Gct_sunday_start==0) && ($Gct_sunday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) && ($GMT_hour[$r]<$Gct_default_stop) ) + {} + else + {$list_default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_sunday_start) && ($GMT_hour[$r]<$Gct_sunday_stop) ) + {} + else + {$list_default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==1) #### Monday local time + { + if (($Gct_monday_start==0) && ($Gct_monday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) && ($GMT_hour[$r]<$Gct_default_stop) ) + {} + else + {$list_default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_monday_start) && ($GMT_hour[$r]<$Gct_monday_stop) ) + {} + else + {$list_default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==2) #### Tuesday local time + { + if (($Gct_tuesday_start==0) && ($Gct_tuesday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) && ($GMT_hour[$r]<$Gct_default_stop) ) + {} + else + {$list_default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_tuesday_start) && ($GMT_hour[$r]<$Gct_tuesday_stop) ) + {} + else + {$list_default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==3) #### Wednesday local time + { + if (($Gct_wednesday_start==0) && ($Gct_wednesday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) && ($GMT_hour[$r]<$Gct_default_stop) ) + {} + else + {$list_default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_wednesday_start) && ($GMT_hour[$r]<$Gct_wednesday_stop) ) + {} + else + {$list_default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==4) #### Thursday local time + { + if (($Gct_thursday_start==0) && ($Gct_thursday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) && ($GMT_hour[$r]<$Gct_default_stop) ) + {} + else + {$list_default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_thursday_start) && ($GMT_hour[$r]<$Gct_thursday_stop) ) + {} + else + {$list_default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==5) #### Friday local time + { + if (($Gct_friday_start==0) && ($Gct_friday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) && ($GMT_hour[$r]<$Gct_default_stop) ) + {} + else + {$list_default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_friday_start) && ($GMT_hour[$r]<$Gct_friday_stop) ) + {} + else + {$list_default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==6) #### Saturday local time + { + if (($Gct_saturday_start==0) && ($Gct_saturday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) && ($GMT_hour[$r]<$Gct_default_stop) ) + {} + else + {$list_default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_saturday_start) && ($GMT_hour[$r]<$Gct_saturday_stop) ) + {} + else + {$list_default_gmt.="'$GMT_gmt[$r]',";} + } + } + $r++; + } + + $list_default_gmt = "$list_default_gmt'99'"; + if ($k == 0) + { + $list_id_sql = "((list_id=\"$cur_list_id\" and gmt_offset_now NOT IN($list_default_gmt) $ct_statesSQL) $list_state_gmt_SQL)"; + } + else + { + $list_id_sql .= " or ((list_id=\"$cur_list_id\" and gmt_offset_now NOT IN($list_default_gmt) $ct_statesSQL) $list_state_gmt_SQL)"; + } + } + ##### END local call time for list set different than campaign ##### + + else + { + if ($k == 0) + { + $list_id_sql = "(list_id=\"$cur_list_id\")"; + } + else + { + $list_id_sql .= " or (list_id=\"$cur_list_id\")"; + } + } + $k++; } $camp_lists = preg_replace("/.$/i","",$camp_lists); if (strlen($camp_lists) < 4) {$camp_lists="''";} + if (strlen($list_id_sql) < 4) {$list_id_sql="list_id=''";} $stmt="SELECT user_group,territory FROM vicidial_users where user='$user';"; $rslt=mysql_to_mysqli($stmt, $link); @@ -2513,7 +3145,7 @@ if ($ACTION == 'manDiaLnextCaLL') if (preg_match("/UP TIMEZONE/i",$lead_order)){$order_stmt = "order by gmt_offset_now desc, $last_order";} if (preg_match("/DOWN TIMEZONE/i",$lead_order)){$order_stmt = "order by gmt_offset_now, $last_order";} - $stmt="UPDATE vicidial_list SET user='QUEUE$user' where called_since_last_reset='N' and ( (user NOT LIKE \"QUEUE%\") or (user is NULL) ) and status IN($Dsql) and list_id IN($camp_lists) and ($all_gmtSQL) $CCLsql $DLTsql $fSQL $adooSQL $order_stmt LIMIT 1;"; + $stmt="UPDATE vicidial_list SET user='QUEUE$user' where called_since_last_reset='N' and ( (user NOT LIKE \"QUEUE%\") or (user is NULL) ) and status IN($Dsql) and ($list_id_sql) and ($all_gmtSQL) $CCLsql $DLTsql $fSQL $adooSQL $order_stmt LIMIT 1;"; if ($DB) {echo "$stmt\n";} $rslt=mysql_to_mysqli($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00242',$user,$server_ip,$session_name,$one_mysql_log);} @@ -2554,7 +3186,6 @@ if ($ACTION == 'manDiaLnextCaLL') } } } - if ($affected_rows > 0) { if (!$CBleadIDset) @@ -2587,6 +3218,7 @@ if ($ACTION == 'manDiaLnextCaLL') $vendor_id = trim("$row[5]"); $source_id = trim("$row[6]"); $list_id = trim("$row[7]"); + $lead_list_id = trim("$row[7]"); $gmt_offset_now = trim("$row[8]"); $called_since_last_reset = trim("$row[9]"); $phone_code = trim("$row[10]"); @@ -2671,11 +3303,38 @@ if ($ACTION == 'manDiaLnextCaLL') $postalgmtNOW = ''; $USarea = substr($agent_dialed_number, 0, 3); $PHONEgmt_offset = lookup_gmt($phone_code,$USarea,$state,$LOCAL_GMT_OFF_STD,$Shour,$Smin,$Ssec,$Smon,$Smday,$Syear,$postalgmtNOW,$postal_code); - $PHONEdialable = dialable_gmt($DB,$link,$local_call_time,$PHONEgmt_offset,$state); $postalgmtNOW = 'POSTAL'; $POSTgmt_offset = lookup_gmt($phone_code,$USarea,$state,$LOCAL_GMT_OFF_STD,$Shour,$Smin,$Ssec,$Smon,$Smday,$Syear,$postalgmtNOW,$postal_code); - $POSTdialable = dialable_gmt($DB,$link,$local_call_time,$POSTgmt_offset,$state); + + ### Get local_call_time for list + $stmt="SELECT local_call_time FROM vicidial_lists where list_id='$lead_list_id';"; + $rslt=mysql_to_mysqli($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00XXX',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $row=mysqli_fetch_row($rslt); + $list_local_call_time = $row[0]; + + #Check if we are within the gmt for campaign for $PHONEdialable + if ( (dialable_gmt($DB,$link,$local_call_time,$PHONEgmt_offset,$state) == 1) and ($list_local_call_time != "campaign") ) + { + #Now check if we are with the GMT for the list local call time + $PHONEdialable = dialable_gmt($DB,$link,$list_local_call_time,$PHONEgmt_offset,$state); + } + else + { + $PHONEdialable = dialable_gmt($DB,$link,$local_call_time,$PHONEgmt_offset,$state); + } + #Check if we are with the gmt for campaign for $POSTdialable + if ( (dialable_gmt($DB,$link,$local_call_time,$POSTgmt_offset,$state) == 1) and ($list_local_call_time != "campaign") ) + { + #Now check if we are with the GMT for the list local call time + $POSTdialable = dialable_gmt($DB,$link,$list_local_call_time,$POSTgmt_offset,$state); + } + else + { + $POSTdialable = dialable_gmt($DB,$link,$local_call_time,$POSTgmt_offset,$state); + } # $post_phone_time_diff_alert_message = "$POSTgmt_offset|$POSTdialable --- $PHONEgmt_offset|$PHONEdialable|$USarea"; $post_phone_time_diff_alert_message = ''; @@ -12236,20 +12895,49 @@ if ($ACTION == 'LEADINFOview') } if ( ($post_phone_time_diff_alert == 'ENABLED') or (preg_match("/OUTSIDE_CALLTIME/",$post_phone_time_diff_alert)) ) { - $postal_code = $row[17]; - $phone_code = $row[5]; + $lead_list_id = $row[2]; + $phone_code = $row[5]; $phone_number = $row[6]; - $state = $row[15]; + $state = $row[15]; + $postal_code = $row[17]; + ### get current gmt_offset of the phone_number $postalgmtNOW = ''; $USarea = substr($phone_number, 0, 3); $PHONEgmt_offset = lookup_gmt($phone_code,$USarea,$state,$LOCAL_GMT_OFF_STD,$Shour,$Smin,$Ssec,$Smon,$Smday,$Syear,$postalgmtNOW,$postal_code); - $PHONEdialable = dialable_gmt($DB,$link,$local_call_time,$PHONEgmt_offset,$state); $postalgmtNOW = 'POSTAL'; $POSTgmt_offset = lookup_gmt($phone_code,$USarea,$state,$LOCAL_GMT_OFF_STD,$Shour,$Smin,$Ssec,$Smon,$Smday,$Syear,$postalgmtNOW,$postal_code); - $POSTdialable = dialable_gmt($DB,$link,$local_call_time,$POSTgmt_offset,$state); + ### Get local_call_time for list + $stmt="SELECT local_call_time FROM vicidial_lists where list_id='$lead_list_id';"; + $rslt=mysql_to_mysqli($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00XXX',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $rowy=mysqli_fetch_row($rslt); + $list_local_call_time = $rowy[0]; + + #Check if we are within the gmt for campaign for $PHONEdialable + if ( (dialable_gmt($DB,$link,$local_call_time,$PHONEgmt_offset,$state) == 1) and ($list_local_call_time != "campaign") ) + { + #Now check if we are with the GMT for the list local call time + $PHONEdialable = dialable_gmt($DB,$link,$list_local_call_time,$PHONEgmt_offset,$state); + } + else + { + $PHONEdialable = dialable_gmt($DB,$link,$local_call_time,$PHONEgmt_offset,$state); + } + + #Check if we are with the gmt for campaign for $POSTdialable + if ( (dialable_gmt($DB,$link,$local_call_time,$POSTgmt_offset,$state) == 1) and ($list_local_call_time != "campaign") ) + { + #Now check if we are with the GMT for the list local call time + $POSTdialable = dialable_gmt($DB,$link,$list_local_call_time,$POSTgmt_offset,$state); + } + else + { + $POSTdialable = dialable_gmt($DB,$link,$local_call_time,$POSTgmt_offset,$state); + } # $post_phone_time_diff_alert_message = "$POSTgmt_offset|$POSTdialable|$postal_code --- $PHONEgmt_offset|$PHONEdialable|$USarea"; $post_phone_time_diff_alert_message = ''; @@ -12787,7 +13475,7 @@ if ($ACTION == 'CalLBacKLisT') $loop_count=0; while ($callbacks_count>$loop_count) { - $stmt = "SELECT first_name,last_name,phone_number,gmt_offset_now,state from vicidial_list where lead_id='$lead_id[$loop_count]';"; + $stmt = "SELECT first_name,last_name,phone_number,gmt_offset_now,state,list_id from vicidial_list where lead_id='$lead_id[$loop_count]';"; if ($DB) {echo "$stmt\n";} $rslt=mysql_to_mysqli($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00179',$user,$server_ip,$session_name,$one_mysql_log);} @@ -12796,7 +13484,30 @@ if ($ACTION == 'CalLBacKLisT') $PHONEdialable=1; if ($callback_list_calltime == 'ENABLED') { - $PHONEdialable = dialable_gmt($DB,$link,$local_call_time,$row[3],$row[4]); + $state = $row[4]; + $lead_list_id = $row[5]; + + ### Get local_call_time for list + $stmt="SELECT local_call_time FROM vicidial_lists where list_id='$lead_list_id';"; + $rslt=mysql_to_mysqli($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00XXX',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $rslt_ct = mysqli_num_rows($rslt); + if ($rslt_ct > 0) + { + $rowy=mysqli_fetch_row($rslt); + $list_local_call_time = $rowy[0]; + } + #Check if we are with the gmt for campaign for $POSTdialable + if ( (dialable_gmt($DB,$link,$local_call_time,$row[3],$row[4]) == 1) and ($list_local_call_time != "campaign") ) + { + #Now check if we are with the GMT for the list local call time + $PHONEdialable = dialable_gmt($DB,$link,$list_local_call_time,$row[3],$row[4]); + } + else + { + $PHONEdialable = dialable_gmt($DB,$link,$local_call_time,$row[3],$row[4]); + } } echo "$row[0] ~$row[1] ~$row[2] ~$callback_id[$loop_count] ~$lead_id[$loop_count] ~$campaign_id[$loop_count] ~$status[$loop_count] ~$entry_time[$loop_count] ~$callback_time[$loop_count] ~$comments[$loop_count] ~$PHONEdialable\n"; $loop_count++; diff --git a/www/agc/vicidial.php b/www/agc/vicidial.php index 2bbc6a2c..59d79fdc 100644 --- a/www/agc/vicidial.php +++ b/www/agc/vicidial.php @@ -466,10 +466,11 @@ # 141229-1429 - Changed single-quote QXZ arguments to double-quotes # 150101-1516 - Updated for 2015 # 150108-1725 - Added more validation for API transfer commands +# 150111-1545 - Added manual_dial_search_filter campaign option(Issue #812) # -$version = '2.10-437c'; -$build = '150108-1725'; +$version = '2.10-438c'; +$build = '150111-1545'; $mel=1; # Mysql Error Log enabled = 1 $mysql_log_count=85; $one_mysql_log=0; @@ -1560,7 +1561,7 @@ else $HKstatusnames = substr("$HKstatusnames", 0, -1); ##### grab the campaign settings - $stmt="SELECT park_ext,park_file_name,web_form_address,allow_closers,auto_dial_level,dial_timeout,dial_prefix,campaign_cid,campaign_vdad_exten,campaign_rec_exten,campaign_recording,campaign_rec_filename,campaign_script,get_call_launch,am_message_exten,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number,alt_number_dialing,scheduled_callbacks,wrapup_seconds,wrapup_message,closer_campaigns,use_internal_dnc,allcalls_delay,omit_phone_code,agent_pause_codes_active,no_hopper_leads_logins,campaign_allow_inbound,manual_dial_list_id,default_xfer_group,xfer_groups,disable_alter_custphone,display_queue_count,manual_dial_filter,agent_clipboard_copy,use_campaign_dnc,three_way_call_cid,dial_method,three_way_dial_prefix,web_form_target,vtiger_screen_login,agent_allow_group_alias,default_group_alias,quick_transfer_button,prepopulate_transfer_preset,view_calls_in_queue,view_calls_in_queue_launch,call_requeue_button,pause_after_each_call,no_hopper_dialing,agent_dial_owner_only,agent_display_dialable_leads,web_form_address_two,agent_select_territories,crm_popup_login,crm_login_address,timer_action,timer_action_message,timer_action_seconds,start_call_url,dispo_call_url,xferconf_c_number,xferconf_d_number,xferconf_e_number,use_custom_cid,scheduled_callbacks_alert,scheduled_callbacks_count,manual_dial_override,blind_monitor_warning,blind_monitor_message,blind_monitor_filename,timer_action_destination,enable_xfer_presets,hide_xfer_number_to_dial,manual_dial_prefix,customer_3way_hangup_logging,customer_3way_hangup_seconds,customer_3way_hangup_action,ivr_park_call,manual_preview_dial,api_manual_dial,manual_dial_call_time_check,my_callback_option,per_call_notes,agent_lead_search,agent_lead_search_method,queuemetrics_phone_environment,auto_pause_precall,auto_pause_precall_code,auto_resume_precall,manual_dial_cid,custom_3way_button_transfer,callback_days_limit,disable_dispo_screen,disable_dispo_status,screen_labels,status_display_fields,pllb_grouping,pllb_grouping_limit,in_group_dial,in_group_dial_select,pause_after_next_call,owner_populate,manual_dial_lead_id,dead_max,dispo_max,pause_max,dead_max_dispo,dispo_max_dispo,max_inbound_calls,manual_dial_search_checkbox,hide_call_log_info,timer_alt_seconds,wrapup_bypass,wrapup_after_hotkey,callback_active_limit,callback_active_limit_override,comments_all_tabs,comments_dispo_screen,comments_callback_screen,qc_comment_history,show_previous_callback,clear_script FROM vicidial_campaigns where campaign_id = '$VD_campaign';"; + $stmt="SELECT park_ext,park_file_name,web_form_address,allow_closers,auto_dial_level,dial_timeout,dial_prefix,campaign_cid,campaign_vdad_exten,campaign_rec_exten,campaign_recording,campaign_rec_filename,campaign_script,get_call_launch,am_message_exten,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number,alt_number_dialing,scheduled_callbacks,wrapup_seconds,wrapup_message,closer_campaigns,use_internal_dnc,allcalls_delay,omit_phone_code,agent_pause_codes_active,no_hopper_leads_logins,campaign_allow_inbound,manual_dial_list_id,default_xfer_group,xfer_groups,disable_alter_custphone,display_queue_count,manual_dial_filter,agent_clipboard_copy,use_campaign_dnc,three_way_call_cid,dial_method,three_way_dial_prefix,web_form_target,vtiger_screen_login,agent_allow_group_alias,default_group_alias,quick_transfer_button,prepopulate_transfer_preset,view_calls_in_queue,view_calls_in_queue_launch,call_requeue_button,pause_after_each_call,no_hopper_dialing,agent_dial_owner_only,agent_display_dialable_leads,web_form_address_two,agent_select_territories,crm_popup_login,crm_login_address,timer_action,timer_action_message,timer_action_seconds,start_call_url,dispo_call_url,xferconf_c_number,xferconf_d_number,xferconf_e_number,use_custom_cid,scheduled_callbacks_alert,scheduled_callbacks_count,manual_dial_override,blind_monitor_warning,blind_monitor_message,blind_monitor_filename,timer_action_destination,enable_xfer_presets,hide_xfer_number_to_dial,manual_dial_prefix,customer_3way_hangup_logging,customer_3way_hangup_seconds,customer_3way_hangup_action,ivr_park_call,manual_preview_dial,api_manual_dial,manual_dial_call_time_check,my_callback_option,per_call_notes,agent_lead_search,agent_lead_search_method,queuemetrics_phone_environment,auto_pause_precall,auto_pause_precall_code,auto_resume_precall,manual_dial_cid,custom_3way_button_transfer,callback_days_limit,disable_dispo_screen,disable_dispo_status,screen_labels,status_display_fields,pllb_grouping,pllb_grouping_limit,in_group_dial,in_group_dial_select,pause_after_next_call,owner_populate,manual_dial_lead_id,dead_max,dispo_max,pause_max,dead_max_dispo,dispo_max_dispo,max_inbound_calls,manual_dial_search_checkbox,hide_call_log_info,timer_alt_seconds,wrapup_bypass,wrapup_after_hotkey,callback_active_limit,callback_active_limit_override,comments_all_tabs,comments_dispo_screen,comments_callback_screen,qc_comment_history,show_previous_callback,clear_script,manual_dial_search_filter FROM vicidial_campaigns where campaign_id = '$VD_campaign';"; $rslt=mysql_to_mysqli($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01013',$VD_login,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} @@ -1690,6 +1691,7 @@ else $qc_comment_history = $row[122]; $show_previous_callback = $row[123]; $clear_script = $row[124]; + $manual_dial_search_filter =$row[125]; if ( ($callback_active_limit_override == 'Y') and ($callback_active_limit > 0) ) { @@ -3825,6 +3827,7 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";} var vdc_header_phone_format = ''; var disable_alter_custphone = ''; var manual_dial_filter = ''; + var manual_dial_search_filter = ''; var CopY_tO_ClipboarD = ''; var inOUT = 'OUT'; var useIE = ''; @@ -7763,7 +7766,7 @@ function set_length(SLnumber,SLlength_goal,SLdirection) else {var call_prefix = manual_dial_prefix;} - manDiaLnext_query = "server_ip=" + server_ip + "&session_name=" + session_name + "&ACTION=manDiaLnextCaLL&conf_exten=" + session_id + "&user=" + user + "&pass=" + pass + "&campaign=" + campaign + "&ext_context=" + ext_context + "&dial_timeout=" + dial_timeout + "&dial_prefix=" + call_prefix + "&campaign_cid=" + call_cid + "&preview=" + man_preview + "&agent_log_id=" + agent_log_id + "&callback_id=" + mdnCBid + "&lead_id=" + mdnBDleadid + "&phone_code=" + mdnDiaLCodE + "&phone_number=" + mdnPhonENumbeR + "&list_id=" + mdnLisT_id + "&stage=" + mdnStagE + "&use_internal_dnc=" + use_internal_dnc + "&use_campaign_dnc=" + use_campaign_dnc + "&omit_phone_code=" + omit_phone_code + "&manual_dial_filter=" + manual_dial_filter + "&vendor_lead_code=" + mdVendorid + "&usegroupalias=" + mdgroupalias + "&account=" + active_group_alias + "&agent_dialed_number=" + agent_dialed_number + "&agent_dialed_type=" + agent_dialed_type + "&vtiger_callback_id=" + vtiger_callback_id + "&dial_method=" + dial_method + "&manual_dial_call_time_check=" + manual_dial_call_time_check + "&qm_extension=" + qm_extension + "&dial_ingroup=" + active_ingroup_dial + "&nocall_dial_flag=" + nocall_dial_flag + "&cid_lock=" + cid_lock; + manDiaLnext_query = "server_ip=" + server_ip + "&session_name=" + session_name + "&ACTION=manDiaLnextCaLL&conf_exten=" + session_id + "&user=" + user + "&pass=" + pass + "&campaign=" + campaign + "&ext_context=" + ext_context + "&dial_timeout=" + dial_timeout + "&dial_prefix=" + call_prefix + "&campaign_cid=" + call_cid + "&preview=" + man_preview + "&agent_log_id=" + agent_log_id + "&callback_id=" + mdnCBid + "&lead_id=" + mdnBDleadid + "&phone_code=" + mdnDiaLCodE + "&phone_number=" + mdnPhonENumbeR + "&list_id=" + mdnLisT_id + "&stage=" + mdnStagE + "&use_internal_dnc=" + use_internal_dnc + "&use_campaign_dnc=" + use_campaign_dnc + "&omit_phone_code=" + omit_phone_code + "&manual_dial_filter=" + manual_dial_filter + "&manual_dial_search_filter=" + manual_dial_search_filter + "&vendor_lead_code=" + mdVendorid + "&usegroupalias=" + mdgroupalias + "&account=" + active_group_alias + "&agent_dialed_number=" + agent_dialed_number + "&agent_dialed_type=" + agent_dialed_type + "&vtiger_callback_id=" + vtiger_callback_id + "&dial_method=" + dial_method + "&manual_dial_call_time_check=" + manual_dial_call_time_check + "&qm_extension=" + qm_extension + "&dial_ingroup=" + active_ingroup_dial + "&nocall_dial_flag=" + nocall_dial_flag + "&cid_lock=" + cid_lock; // alert(manual_dial_filter + "\n" +manDiaLnext_query); xmlhttp.open('POST', 'vdc_db_query.php'); xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8'); @@ -7773,8 +7776,8 @@ function set_length(SLnumber,SLlength_goal,SLdirection) if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { var MDnextResponse = null; - // alert(manDiaLnext_query); - // alert(xmlhttp.responseText); + // alert(manDiaLnext_query + "\n" + xmlhttp.responseText); + // document.getElementById("debugbottomspan").innerHTML = manDiaLnext_query + "\n" + xmlhttp.responseText; MDnextResponse = xmlhttp.responseText; if (active_ingroup_dial.length > 0) diff --git a/www/vicidial/admin.php b/www/vicidial/admin.php index 3349a7c9..c20ae520 100644 --- a/www/vicidial/admin.php +++ b/www/vicidial/admin.php @@ -1892,6 +1892,8 @@ if (isset($_GET["language_method"])) {$language_method=$_GET["language_method" elseif (isset($_POST["language_method"])) {$language_method=$_POST["language_method"];} if (isset($_GET["ignore_group_on_search"])) {$ignore_group_on_search=$_GET["ignore_group_on_search"];} elseif (isset($_POST["ignore_group_on_search"])) {$ignore_group_on_search=$_POST["ignore_group_on_search"];} +if (isset($_GET["manual_dial_search_filter"])) {$manual_dial_search_filter=$_GET["manual_dial_search_filter"];} + elseif (isset($_POST["manual_dial_search_filter"])) {$manual_dial_search_filter=$_POST["manual_dial_search_filter"];} if (isset($script_id)) {$script_id= strtoupper($script_id);} @@ -2520,6 +2522,7 @@ if ($non_latin < 1) $survey_method = preg_replace('/[^-_0-9a-zA-Z]/','',$survey_method); $alter_custphone_override = preg_replace('/[^-_0-9a-zA-Z]/','',$alter_custphone_override); $manual_dial_filter = preg_replace('/[^-_0-9a-zA-Z]/','',$manual_dial_filter); + $manual_dial_search_filter = preg_replace('/[^-_0-9a-zA-Z]/','',$manual_dial_search_filter); $agent_clipboard_copy = preg_replace('/[^-_0-9a-zA-Z]/','',$agent_clipboard_copy); $hold_time_option = preg_replace('/[^-_0-9a-zA-Z]/','',$hold_time_option); $hold_time_option_xfer_group = preg_replace('/[^-_0-9a-zA-Z]/','',$hold_time_option_xfer_group); @@ -3419,12 +3422,13 @@ else # 141229-1543 - Added code for on-the-fly language translations display # 150101-1511 - Updated for 2015 # 150107-1938 - Added ignore_group_on_search user option +# 150111-1543 - Added Lists local call time option(Issue #812) and a campaign option for manual_dial_search_filter # # make sure you have added a user to the vicidial_users MySQL table with at least user_level 9 to access this page the first time -$admin_version = '2.10-465a'; -$build = '150107-1938'; +$admin_version = '2.10-467a'; +$build = '150111-1543'; $STARTtime = date("U"); $SQLdate = date("Y-m-d H:i:s"); @@ -8290,7 +8294,7 @@ if ($ADD==20) $rslt=mysql_to_mysqli($stmt, $link); } - $stmt="INSERT INTO vicidial_campaigns (campaign_name,campaign_id,active,dial_status_a,dial_status_b,dial_status_c,dial_status_d,dial_status_e,lead_order,park_ext,park_file_name,web_form_address,allow_closers,hopper_level,auto_dial_level,next_agent_call,local_call_time,voicemail_ext,dial_timeout,dial_prefix,campaign_cid,campaign_vdad_exten,campaign_rec_exten,campaign_recording,campaign_rec_filename,campaign_script,get_call_launch,am_message_exten,amd_send_to_vmx,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number,alt_number_dialing,scheduled_callbacks,lead_filter_id,drop_call_seconds,drop_action,safe_harbor_exten,display_dialable_count,wrapup_seconds,wrapup_message,closer_campaigns,use_internal_dnc,allcalls_delay,omit_phone_code,dial_method,available_only_ratio_tally,adaptive_dropped_percentage,adaptive_maximum_level,adaptive_latest_server_time,adaptive_intensity,adaptive_dl_diff_target,concurrent_transfers,auto_alt_dial,auto_alt_dial_statuses,agent_pause_codes_active,campaign_description,campaign_changedate,campaign_stats_refresh,campaign_logindate,dial_statuses,disable_alter_custdata,no_hopper_leads_logins,list_order_mix,campaign_allow_inbound,manual_dial_list_id,default_xfer_group,queue_priority,drop_inbound_group,qc_enabled,qc_statuses,qc_lists,qc_web_form_address,qc_script,survey_first_audio_file,survey_dtmf_digits,survey_ni_digit,survey_opt_in_audio_file,survey_ni_audio_file,survey_method,survey_no_response_action,survey_ni_status,survey_response_digit_map,survey_xfer_exten,survey_camp_record_dir,disable_alter_custphone,display_queue_count,qc_get_record_launch,qc_show_recording,qc_shift_id,manual_dial_filter,agent_clipboard_copy,agent_extended_alt_dial,use_campaign_dnc,three_way_call_cid,three_way_dial_prefix,web_form_target,vtiger_search_category,vtiger_create_call_record,vtiger_create_lead_record,vtiger_screen_login,cpd_amd_action,agent_allow_group_alias,default_group_alias,vtiger_search_dead,vtiger_status_call,survey_third_digit,survey_fourth_digit,survey_third_audio_file,survey_fourth_audio_file,survey_third_status,survey_fourth_status,survey_third_exten,survey_fourth_exten,drop_lockout_time,quick_transfer_button,prepopulate_transfer_preset,drop_rate_group,view_calls_in_queue,view_calls_in_queue_launch,grab_calls_in_queue,call_requeue_button,pause_after_each_call,no_hopper_dialing,agent_dial_owner_only,agent_display_dialable_leads,web_form_address_two,waitforsilence_options,agent_select_territories,crm_popup_login,crm_login_address,timer_action,timer_action_message,timer_action_seconds,start_call_url,dispo_call_url,xferconf_c_number,xferconf_d_number,xferconf_e_number,use_custom_cid,scheduled_callbacks_alert,queuemetrics_callstatus_override,extension_appended_cidname,scheduled_callbacks_count,manual_dial_override,blind_monitor_warning,blind_monitor_message,blind_monitor_filename,inbound_queue_no_dial,timer_action_destination,enable_xfer_presets,hide_xfer_number_to_dial,manual_dial_prefix,customer_3way_hangup_logging,customer_3way_hangup_seconds,customer_3way_hangup_action,ivr_park_call,ivr_park_call_agi,manual_preview_dial,realtime_agent_time_stats,use_auto_hopper,auto_hopper_multi,auto_trim_hopper,api_manual_dial,manual_dial_call_time_check,display_leads_count,lead_order_randomize,lead_order_secondary,per_call_notes,my_callback_option,agent_lead_search,agent_lead_search_method,queuemetrics_phone_environment,auto_pause_precall,auto_resume_precall,auto_pause_precall_code,manual_dial_cid,post_phone_time_diff_alert,custom_3way_button_transfer,available_only_tally_threshold,available_only_tally_threshold_agents,dial_level_threshold,dial_level_threshold_agents,safe_harbor_audio,safe_harbor_menu_id,survey_menu_id,callback_days_limit,dl_diff_target_method,disable_dispo_screen,disable_dispo_status,screen_labels,status_display_fields,na_call_url,survey_recording,pllb_grouping,pllb_grouping_limit,call_count_limit,call_count_target,callback_hours_block,callback_list_calltime,user_group,hopper_vlc_dup_check,safe_harbor_audio_field,pause_after_next_call,owner_populate,use_other_campaign_dnc,allow_emails,amd_inbound_group,amd_callmenu,survey_wait_sec,manual_dial_lead_id,dead_max,dispo_max,pause_max,dead_max_dispo,dispo_max_dispo,max_inbound_calls,manual_dial_search_checkbox,hide_call_log_info,timer_alt_seconds,wrapup_bypass,wrapup_after_hotkey,callback_active_limit,callback_active_limit_override,comments_all_tabs,comments_dispo_screen,comments_callback_screen,qc_comment_history,show_previous_callback,clear_script,cpd_unknown_action) SELECT \"$campaign_name\",\"$campaign_id\",\"N\",dial_status_a,dial_status_b,dial_status_c,dial_status_d,dial_status_e,lead_order,park_ext,park_file_name,web_form_address,allow_closers,hopper_level,auto_dial_level,next_agent_call,local_call_time,voicemail_ext,dial_timeout,dial_prefix,campaign_cid,campaign_vdad_exten,campaign_rec_exten,campaign_recording,campaign_rec_filename,campaign_script,get_call_launch,am_message_exten,amd_send_to_vmx,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number,alt_number_dialing,scheduled_callbacks,lead_filter_id,drop_call_seconds,drop_action,safe_harbor_exten,display_dialable_count,wrapup_seconds,wrapup_message,closer_campaigns,use_internal_dnc,allcalls_delay,omit_phone_code,dial_method,available_only_ratio_tally,adaptive_dropped_percentage,adaptive_maximum_level,adaptive_latest_server_time,adaptive_intensity,adaptive_dl_diff_target,concurrent_transfers,auto_alt_dial,auto_alt_dial_statuses,agent_pause_codes_active,campaign_description,campaign_changedate,campaign_stats_refresh,campaign_logindate,dial_statuses,disable_alter_custdata,no_hopper_leads_logins,\"DISABLED\",campaign_allow_inbound,manual_dial_list_id,default_xfer_group,queue_priority,drop_inbound_group,qc_enabled,qc_statuses,qc_lists,qc_web_form_address,qc_script,survey_first_audio_file,survey_dtmf_digits,survey_ni_digit,survey_opt_in_audio_file,survey_ni_audio_file,survey_method,survey_no_response_action,survey_ni_status,survey_response_digit_map,survey_xfer_exten,survey_camp_record_dir,disable_alter_custphone,display_queue_count,qc_get_record_launch,qc_show_recording,qc_shift_id,manual_dial_filter,agent_clipboard_copy,agent_extended_alt_dial,use_campaign_dnc,three_way_call_cid,three_way_dial_prefix,web_form_target,vtiger_search_category,vtiger_create_call_record,vtiger_create_lead_record,vtiger_screen_login,cpd_amd_action,agent_allow_group_alias,default_group_alias,vtiger_search_dead,vtiger_status_call,survey_third_digit,survey_fourth_digit,survey_third_audio_file,survey_fourth_audio_file,survey_third_status,survey_fourth_status,survey_third_exten,survey_fourth_exten,drop_lockout_time,quick_transfer_button,prepopulate_transfer_preset,drop_rate_group,view_calls_in_queue,view_calls_in_queue_launch,grab_calls_in_queue,call_requeue_button,pause_after_each_call,no_hopper_dialing,agent_dial_owner_only,agent_display_dialable_leads,web_form_address_two,waitforsilence_options,agent_select_territories,crm_popup_login,crm_login_address,timer_action,timer_action_message,timer_action_seconds,start_call_url,dispo_call_url,xferconf_c_number,xferconf_d_number,xferconf_e_number,use_custom_cid,scheduled_callbacks_alert,queuemetrics_callstatus_override,extension_appended_cidname,scheduled_callbacks_count,manual_dial_override,blind_monitor_warning,blind_monitor_message,blind_monitor_filename,inbound_queue_no_dial,timer_action_destination,enable_xfer_presets,hide_xfer_number_to_dial,manual_dial_prefix,customer_3way_hangup_logging,customer_3way_hangup_seconds,customer_3way_hangup_action,ivr_park_call,ivr_park_call_agi,manual_preview_dial,realtime_agent_time_stats,use_auto_hopper,auto_hopper_multi,auto_trim_hopper,api_manual_dial,manual_dial_call_time_check,display_leads_count,lead_order_randomize,lead_order_secondary,per_call_notes,my_callback_option,agent_lead_search,agent_lead_search_method,queuemetrics_phone_environment,auto_pause_precall,auto_resume_precall,auto_pause_precall_code,manual_dial_cid,post_phone_time_diff_alert,custom_3way_button_transfer,available_only_tally_threshold,available_only_tally_threshold_agents,dial_level_threshold,dial_level_threshold_agents,safe_harbor_audio,safe_harbor_menu_id,survey_menu_id,callback_days_limit,dl_diff_target_method,disable_dispo_screen,disable_dispo_status,screen_labels,status_display_fields,na_call_url,survey_recording,pllb_grouping,pllb_grouping_limit,call_count_limit,call_count_target,callback_hours_block,callback_list_calltime,user_group,hopper_vlc_dup_check,safe_harbor_audio_field,pause_after_next_call,owner_populate,use_other_campaign_dnc,allow_emails,amd_inbound_group,amd_callmenu,survey_wait_sec,manual_dial_lead_id,dead_max,dispo_max,pause_max,dead_max_dispo,dispo_max_dispo,max_inbound_calls,manual_dial_search_checkbox,hide_call_log_info,timer_alt_seconds,wrapup_bypass,wrapup_after_hotkey,callback_active_limit,callback_active_limit_override,comments_all_tabs,comments_dispo_screen,comments_callback_screen,qc_comment_history,show_previous_callback,clear_script,cpd_unknown_action from vicidial_campaigns where campaign_id='$source_campaign_id';"; + $stmt="INSERT INTO vicidial_campaigns (campaign_name,campaign_id,active,dial_status_a,dial_status_b,dial_status_c,dial_status_d,dial_status_e,lead_order,park_ext,park_file_name,web_form_address,allow_closers,hopper_level,auto_dial_level,next_agent_call,local_call_time,voicemail_ext,dial_timeout,dial_prefix,campaign_cid,campaign_vdad_exten,campaign_rec_exten,campaign_recording,campaign_rec_filename,campaign_script,get_call_launch,am_message_exten,amd_send_to_vmx,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number,alt_number_dialing,scheduled_callbacks,lead_filter_id,drop_call_seconds,drop_action,safe_harbor_exten,display_dialable_count,wrapup_seconds,wrapup_message,closer_campaigns,use_internal_dnc,allcalls_delay,omit_phone_code,dial_method,available_only_ratio_tally,adaptive_dropped_percentage,adaptive_maximum_level,adaptive_latest_server_time,adaptive_intensity,adaptive_dl_diff_target,concurrent_transfers,auto_alt_dial,auto_alt_dial_statuses,agent_pause_codes_active,campaign_description,campaign_changedate,campaign_stats_refresh,campaign_logindate,dial_statuses,disable_alter_custdata,no_hopper_leads_logins,list_order_mix,campaign_allow_inbound,manual_dial_list_id,default_xfer_group,queue_priority,drop_inbound_group,qc_enabled,qc_statuses,qc_lists,qc_web_form_address,qc_script,survey_first_audio_file,survey_dtmf_digits,survey_ni_digit,survey_opt_in_audio_file,survey_ni_audio_file,survey_method,survey_no_response_action,survey_ni_status,survey_response_digit_map,survey_xfer_exten,survey_camp_record_dir,disable_alter_custphone,display_queue_count,qc_get_record_launch,qc_show_recording,qc_shift_id,manual_dial_filter,agent_clipboard_copy,agent_extended_alt_dial,use_campaign_dnc,three_way_call_cid,three_way_dial_prefix,web_form_target,vtiger_search_category,vtiger_create_call_record,vtiger_create_lead_record,vtiger_screen_login,cpd_amd_action,agent_allow_group_alias,default_group_alias,vtiger_search_dead,vtiger_status_call,survey_third_digit,survey_fourth_digit,survey_third_audio_file,survey_fourth_audio_file,survey_third_status,survey_fourth_status,survey_third_exten,survey_fourth_exten,drop_lockout_time,quick_transfer_button,prepopulate_transfer_preset,drop_rate_group,view_calls_in_queue,view_calls_in_queue_launch,grab_calls_in_queue,call_requeue_button,pause_after_each_call,no_hopper_dialing,agent_dial_owner_only,agent_display_dialable_leads,web_form_address_two,waitforsilence_options,agent_select_territories,crm_popup_login,crm_login_address,timer_action,timer_action_message,timer_action_seconds,start_call_url,dispo_call_url,xferconf_c_number,xferconf_d_number,xferconf_e_number,use_custom_cid,scheduled_callbacks_alert,queuemetrics_callstatus_override,extension_appended_cidname,scheduled_callbacks_count,manual_dial_override,blind_monitor_warning,blind_monitor_message,blind_monitor_filename,inbound_queue_no_dial,timer_action_destination,enable_xfer_presets,hide_xfer_number_to_dial,manual_dial_prefix,customer_3way_hangup_logging,customer_3way_hangup_seconds,customer_3way_hangup_action,ivr_park_call,ivr_park_call_agi,manual_preview_dial,realtime_agent_time_stats,use_auto_hopper,auto_hopper_multi,auto_trim_hopper,api_manual_dial,manual_dial_call_time_check,display_leads_count,lead_order_randomize,lead_order_secondary,per_call_notes,my_callback_option,agent_lead_search,agent_lead_search_method,queuemetrics_phone_environment,auto_pause_precall,auto_resume_precall,auto_pause_precall_code,manual_dial_cid,post_phone_time_diff_alert,custom_3way_button_transfer,available_only_tally_threshold,available_only_tally_threshold_agents,dial_level_threshold,dial_level_threshold_agents,safe_harbor_audio,safe_harbor_menu_id,survey_menu_id,callback_days_limit,dl_diff_target_method,disable_dispo_screen,disable_dispo_status,screen_labels,status_display_fields,na_call_url,survey_recording,pllb_grouping,pllb_grouping_limit,call_count_limit,call_count_target,callback_hours_block,callback_list_calltime,user_group,hopper_vlc_dup_check,safe_harbor_audio_field,pause_after_next_call,owner_populate,use_other_campaign_dnc,allow_emails,amd_inbound_group,amd_callmenu,survey_wait_sec,manual_dial_lead_id,dead_max,dispo_max,pause_max,dead_max_dispo,dispo_max_dispo,max_inbound_calls,manual_dial_search_checkbox,hide_call_log_info,timer_alt_seconds,wrapup_bypass,wrapup_after_hotkey,callback_active_limit,callback_active_limit_override,comments_all_tabs,comments_dispo_screen,comments_callback_screen,qc_comment_history,show_previous_callback,clear_script,cpd_unknown_action,manual_dial_search_filter) SELECT \"$campaign_name\",\"$campaign_id\",\"N\",dial_status_a,dial_status_b,dial_status_c,dial_status_d,dial_status_e,lead_order,park_ext,park_file_name,web_form_address,allow_closers,hopper_level,auto_dial_level,next_agent_call,local_call_time,voicemail_ext,dial_timeout,dial_prefix,campaign_cid,campaign_vdad_exten,campaign_rec_exten,campaign_recording,campaign_rec_filename,campaign_script,get_call_launch,am_message_exten,amd_send_to_vmx,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number,alt_number_dialing,scheduled_callbacks,lead_filter_id,drop_call_seconds,drop_action,safe_harbor_exten,display_dialable_count,wrapup_seconds,wrapup_message,closer_campaigns,use_internal_dnc,allcalls_delay,omit_phone_code,dial_method,available_only_ratio_tally,adaptive_dropped_percentage,adaptive_maximum_level,adaptive_latest_server_time,adaptive_intensity,adaptive_dl_diff_target,concurrent_transfers,auto_alt_dial,auto_alt_dial_statuses,agent_pause_codes_active,campaign_description,campaign_changedate,campaign_stats_refresh,campaign_logindate,dial_statuses,disable_alter_custdata,no_hopper_leads_logins,\"DISABLED\",campaign_allow_inbound,manual_dial_list_id,default_xfer_group,queue_priority,drop_inbound_group,qc_enabled,qc_statuses,qc_lists,qc_web_form_address,qc_script,survey_first_audio_file,survey_dtmf_digits,survey_ni_digit,survey_opt_in_audio_file,survey_ni_audio_file,survey_method,survey_no_response_action,survey_ni_status,survey_response_digit_map,survey_xfer_exten,survey_camp_record_dir,disable_alter_custphone,display_queue_count,qc_get_record_launch,qc_show_recording,qc_shift_id,manual_dial_filter,agent_clipboard_copy,agent_extended_alt_dial,use_campaign_dnc,three_way_call_cid,three_way_dial_prefix,web_form_target,vtiger_search_category,vtiger_create_call_record,vtiger_create_lead_record,vtiger_screen_login,cpd_amd_action,agent_allow_group_alias,default_group_alias,vtiger_search_dead,vtiger_status_call,survey_third_digit,survey_fourth_digit,survey_third_audio_file,survey_fourth_audio_file,survey_third_status,survey_fourth_status,survey_third_exten,survey_fourth_exten,drop_lockout_time,quick_transfer_button,prepopulate_transfer_preset,drop_rate_group,view_calls_in_queue,view_calls_in_queue_launch,grab_calls_in_queue,call_requeue_button,pause_after_each_call,no_hopper_dialing,agent_dial_owner_only,agent_display_dialable_leads,web_form_address_two,waitforsilence_options,agent_select_territories,crm_popup_login,crm_login_address,timer_action,timer_action_message,timer_action_seconds,start_call_url,dispo_call_url,xferconf_c_number,xferconf_d_number,xferconf_e_number,use_custom_cid,scheduled_callbacks_alert,queuemetrics_callstatus_override,extension_appended_cidname,scheduled_callbacks_count,manual_dial_override,blind_monitor_warning,blind_monitor_message,blind_monitor_filename,inbound_queue_no_dial,timer_action_destination,enable_xfer_presets,hide_xfer_number_to_dial,manual_dial_prefix,customer_3way_hangup_logging,customer_3way_hangup_seconds,customer_3way_hangup_action,ivr_park_call,ivr_park_call_agi,manual_preview_dial,realtime_agent_time_stats,use_auto_hopper,auto_hopper_multi,auto_trim_hopper,api_manual_dial,manual_dial_call_time_check,display_leads_count,lead_order_randomize,lead_order_secondary,per_call_notes,my_callback_option,agent_lead_search,agent_lead_search_method,queuemetrics_phone_environment,auto_pause_precall,auto_resume_precall,auto_pause_precall_code,manual_dial_cid,post_phone_time_diff_alert,custom_3way_button_transfer,available_only_tally_threshold,available_only_tally_threshold_agents,dial_level_threshold,dial_level_threshold_agents,safe_harbor_audio,safe_harbor_menu_id,survey_menu_id,callback_days_limit,dl_diff_target_method,disable_dispo_screen,disable_dispo_status,screen_labels,status_display_fields,na_call_url,survey_recording,pllb_grouping,pllb_grouping_limit,call_count_limit,call_count_target,callback_hours_block,callback_list_calltime,user_group,hopper_vlc_dup_check,safe_harbor_audio_field,pause_after_next_call,owner_populate,use_other_campaign_dnc,allow_emails,amd_inbound_group,amd_callmenu,survey_wait_sec,manual_dial_lead_id,dead_max,dispo_max,pause_max,dead_max_dispo,dispo_max_dispo,max_inbound_calls,manual_dial_search_checkbox,hide_call_log_info,timer_alt_seconds,wrapup_bypass,wrapup_after_hotkey,callback_active_limit,callback_active_limit_override,comments_all_tabs,comments_dispo_screen,comments_callback_screen,qc_comment_history,show_previous_callback,clear_script,cpd_unknown_action,manual_dial_search_filter from vicidial_campaigns where campaign_id='$source_campaign_id';"; $rslt=mysql_to_mysqli($stmt, $link); $stmtA="INSERT INTO vicidial_campaign_stats (campaign_id) values('$campaign_id');"; @@ -10077,7 +10081,7 @@ if ($ADD==211111111) {echo "
"._QXZ("CALL TIME DEFINITION NOT ADDED - there is already a call time entry with this ID")."\n";} else { - if ( (strlen($call_time_id) < 2) or (strlen($call_time_name) < 2) ) + if ( (strlen($call_time_id) < 2) or (strlen($call_time_name) < 2) or ($call_time_id == 'campaign') ) { echo "
"._QXZ("CALL TIME DEFINITION NOT ADDED - Please go back and look at the data you entered")."\n"; echo "
"._QXZ("Call Time ID and name must be at least 2 characters in length")."\n"; @@ -12208,7 +12212,7 @@ if ($ADD==41) if ( ($pause_max > 9) and ($pause_max <= $dial_timeout) ) {$pause_max = ($dial_timeout + 10);} - $stmtA="UPDATE vicidial_campaigns set campaign_name='$campaign_name',active='$active',dial_status_a='$dial_status_a',dial_status_b='$dial_status_b',dial_status_c='$dial_status_c',dial_status_d='$dial_status_d',dial_status_e='$dial_status_e',lead_order='$lead_order',allow_closers='$allow_closers',hopper_level='$hopper_level', auto_trim_hopper='$auto_trim_hopper', use_auto_hopper='$use_auto_hopper', auto_hopper_multi='$auto_hopper_multi', $adlSQL next_agent_call='$next_agent_call', local_call_time='$local_call_time', voicemail_ext='$voicemail_ext', dial_timeout='$dial_timeout', dial_prefix='$dial_prefix', campaign_cid='$campaign_cid', campaign_vdad_exten='$campaign_vdad_exten', web_form_address='" . mysqli_real_escape_string($link, $web_form_address) . "', park_ext='$park_ext', park_file_name='$park_file_name', campaign_rec_exten='$campaign_rec_exten', campaign_recording='$campaign_recording', campaign_rec_filename='$campaign_rec_filename', campaign_script='$script_id', get_call_launch='$get_call_launch', am_message_exten='$am_message_exten', amd_send_to_vmx='$amd_send_to_vmx', xferconf_a_dtmf='$xferconf_a_dtmf',xferconf_a_number='$xferconf_a_number',xferconf_b_dtmf='$xferconf_b_dtmf',xferconf_b_number='$xferconf_b_number',lead_filter_id='$lead_filter_id',alt_number_dialing='$alt_number_dialing',scheduled_callbacks='$scheduled_callbacks',drop_action='$drop_action',drop_call_seconds='$drop_call_seconds',safe_harbor_exten='$safe_harbor_exten',wrapup_seconds='$wrapup_seconds',wrapup_message='$wrapup_message',closer_campaigns=$closer_campaignsSQL,use_internal_dnc='$use_internal_dnc',allcalls_delay='$allcalls_delay',omit_phone_code='$omit_phone_code',dial_method='$dial_method',available_only_ratio_tally='$available_only_ratio_tally',adaptive_dropped_percentage='$adaptive_dropped_percentage',adaptive_maximum_level='$adaptive_maximum_level',adaptive_latest_server_time='$adaptive_latest_server_time',adaptive_intensity='$adaptive_intensity',adaptive_dl_diff_target='$adaptive_dl_diff_target',concurrent_transfers='$concurrent_transfers',auto_alt_dial='$auto_alt_dial',agent_pause_codes_active='$agent_pause_codes_active',campaign_description='$campaign_description',campaign_changedate='$SQLdate',campaign_stats_refresh='$campaign_stats_refresh',disable_alter_custdata='$disable_alter_custdata',no_hopper_leads_logins='$no_hopper_leads_logins',list_order_mix='$list_order_mix',campaign_allow_inbound='$campaign_allow_inbound',manual_dial_list_id='$manual_dial_list_id',default_xfer_group='$default_xfer_group',xfer_groups='$XFERgroups_value',queue_priority='$queue_priority',drop_inbound_group='$drop_inbound_group',disable_alter_custphone='$disable_alter_custphone',display_queue_count='$display_queue_count',manual_dial_filter='$manual_dial_filter',agent_clipboard_copy='$agent_clipboard_copy',agent_extended_alt_dial='$agent_extended_alt_dial',use_campaign_dnc='$use_campaign_dnc',three_way_call_cid='$three_way_call_cid',three_way_dial_prefix='$three_way_dial_prefix',web_form_target='$web_form_target',vtiger_search_category='$vtiger_search_category',vtiger_create_call_record='$vtiger_create_call_record',vtiger_create_lead_record='$vtiger_create_lead_record',vtiger_screen_login='$vtiger_screen_login',cpd_amd_action='$cpd_amd_action',agent_allow_group_alias='$agent_allow_group_alias',default_group_alias='$default_group_alias',vtiger_search_dead='$vtiger_search_dead',vtiger_status_call='$vtiger_status_call',drop_lockout_time='$drop_lockout_time',quick_transfer_button='$quick_transfer_button',prepopulate_transfer_preset='$prepopulate_transfer_preset',drop_rate_group='$drop_rate_group',view_calls_in_queue='$view_calls_in_queue',view_calls_in_queue_launch='$view_calls_in_queue_launch',grab_calls_in_queue='$grab_calls_in_queue',call_requeue_button='$call_requeue_button',pause_after_each_call='$pause_after_each_call',no_hopper_dialing='$no_hopper_dialing',agent_dial_owner_only='$agent_dial_owner_only',agent_display_dialable_leads='$agent_display_dialable_leads',web_form_address_two='" . mysqli_real_escape_string($link, $web_form_address_two) . "',waitforsilence_options='$waitforsilence_options',agent_select_territories='$agent_select_territories',crm_popup_login='$crm_popup_login',crm_login_address='" . mysqli_real_escape_string($link, $crm_login_address) . "',timer_action='$timer_action',timer_action_message='$timer_action_message',timer_action_seconds='$timer_action_seconds',start_call_url='" . mysqli_real_escape_string($link, $start_call_url) . "',dispo_call_url='" . mysqli_real_escape_string($link, $dispo_call_url) . "',xferconf_c_number='$xferconf_c_number',xferconf_d_number='$xferconf_d_number',xferconf_e_number='$xferconf_e_number',use_custom_cid='$use_custom_cid',scheduled_callbacks_alert='$scheduled_callbacks_alert',queuemetrics_callstatus_override='$queuemetrics_callstatus',extension_appended_cidname='$extension_appended_cidname',scheduled_callbacks_count='$scheduled_callbacks_count',manual_dial_override='$manual_dial_override',blind_monitor_warning='$blind_monitor_warning',blind_monitor_message='" . mysqli_real_escape_string($link, $blind_monitor_message) . "',blind_monitor_filename='$blind_monitor_filename',inbound_queue_no_dial='$inbound_queue_no_dial',timer_action_destination='$timer_action_destination',enable_xfer_presets='$enable_xfer_presets',hide_xfer_number_to_dial='$hide_xfer_number_to_dial',manual_dial_prefix='$manual_dial_prefix',customer_3way_hangup_logging='$customer_3way_hangup_logging',customer_3way_hangup_seconds='$customer_3way_hangup_seconds',customer_3way_hangup_action='$customer_3way_hangup_action',ivr_park_call='$ivr_park_call',ivr_park_call_agi='$ivr_park_call_agi',manual_preview_dial='$manual_preview_dial',realtime_agent_time_stats='$realtime_agent_time_stats',api_manual_dial='$api_manual_dial',manual_dial_call_time_check='$manual_dial_call_time_check',lead_order_randomize='$lead_order_randomize',lead_order_secondary='$lead_order_secondary',per_call_notes='$per_call_notes',my_callback_option='$my_callback_option',agent_lead_search='$agent_lead_search',agent_lead_search_method='$agent_lead_search_method',queuemetrics_phone_environment='$queuemetrics_phone_environment',auto_pause_precall='$auto_pause_precall',auto_resume_precall='$auto_resume_precall',auto_pause_precall_code='$auto_pause_precall_code',manual_dial_cid='$manual_dial_cid',post_phone_time_diff_alert='$post_phone_time_diff_alert',custom_3way_button_transfer='$custom_3way_button_transfer',available_only_tally_threshold='$available_only_tally_threshold',available_only_tally_threshold_agents='$available_only_tally_threshold_agents',dial_level_threshold='$dial_level_threshold',dial_level_threshold_agents='$dial_level_threshold_agents',safe_harbor_audio='$safe_harbor_audio',safe_harbor_menu_id='$safe_harbor_menu_id',callback_days_limit='$callback_days_limit',dl_diff_target_method='$dl_diff_target_method',disable_dispo_screen='$disable_dispo_screen',disable_dispo_status='$disable_dispo_status',screen_labels='$screen_labels',status_display_fields='$status_display_fields',na_call_url='" . mysqli_real_escape_string($link, $na_call_url) . "',pllb_grouping='$pllb_grouping',pllb_grouping_limit='$pllb_grouping_limit',call_count_limit='$call_count_limit',call_count_target='$call_count_target',callback_hours_block='$callback_hours_block',callback_list_calltime='$callback_list_calltime',user_group='$user_group',hopper_vlc_dup_check='$hopper_vlc_dup_check',in_group_dial='$in_group_dial',in_group_dial_select='$in_group_dial_select',safe_harbor_audio_field='$safe_harbor_audio_field',pause_after_next_call='$pause_after_next_call',owner_populate='$owner_populate',use_other_campaign_dnc='$use_other_campaign_dnc',allow_emails='$allow_emails',amd_inbound_group='$amd_inbound_group',amd_callmenu='$amd_callmenu',manual_dial_lead_id='$manual_dial_lead_id',dead_max='$dead_max',dispo_max='$dispo_max',pause_max='$pause_max',dead_max_dispo='$dead_max_dispo',dispo_max_dispo='$dispo_max_dispo',max_inbound_calls='$max_inbound_calls',manual_dial_search_checkbox='$manual_dial_search_checkbox',hide_call_log_info='$hide_call_log_info',timer_alt_seconds='$timer_alt_seconds',wrapup_bypass='$wrapup_bypass',wrapup_after_hotkey='$wrapup_after_hotkey',callback_active_limit='$callback_active_limit',callback_active_limit_override='$callback_active_limit_override',comments_all_tabs='$comments_all_tabs',comments_dispo_screen='$comments_dispo_screen',comments_callback_screen='$comments_callback_screen',qc_comment_history='$qc_comment_history',show_previous_callback='$show_previous_callback',clear_script='$clear_script',cpd_unknown_action='$cpd_unknown_action' where campaign_id='$campaign_id';"; + $stmtA="UPDATE vicidial_campaigns set campaign_name='$campaign_name',active='$active',dial_status_a='$dial_status_a',dial_status_b='$dial_status_b',dial_status_c='$dial_status_c',dial_status_d='$dial_status_d',dial_status_e='$dial_status_e',lead_order='$lead_order',allow_closers='$allow_closers',hopper_level='$hopper_level', auto_trim_hopper='$auto_trim_hopper', use_auto_hopper='$use_auto_hopper', auto_hopper_multi='$auto_hopper_multi', $adlSQL next_agent_call='$next_agent_call', local_call_time='$local_call_time', voicemail_ext='$voicemail_ext', dial_timeout='$dial_timeout', dial_prefix='$dial_prefix', campaign_cid='$campaign_cid', campaign_vdad_exten='$campaign_vdad_exten', web_form_address='" . mysqli_real_escape_string($link, $web_form_address) . "', park_ext='$park_ext', park_file_name='$park_file_name', campaign_rec_exten='$campaign_rec_exten', campaign_recording='$campaign_recording', campaign_rec_filename='$campaign_rec_filename', campaign_script='$script_id', get_call_launch='$get_call_launch', am_message_exten='$am_message_exten', amd_send_to_vmx='$amd_send_to_vmx', xferconf_a_dtmf='$xferconf_a_dtmf',xferconf_a_number='$xferconf_a_number',xferconf_b_dtmf='$xferconf_b_dtmf',xferconf_b_number='$xferconf_b_number',lead_filter_id='$lead_filter_id',alt_number_dialing='$alt_number_dialing',scheduled_callbacks='$scheduled_callbacks',drop_action='$drop_action',drop_call_seconds='$drop_call_seconds',safe_harbor_exten='$safe_harbor_exten',wrapup_seconds='$wrapup_seconds',wrapup_message='$wrapup_message',closer_campaigns=$closer_campaignsSQL,use_internal_dnc='$use_internal_dnc',allcalls_delay='$allcalls_delay',omit_phone_code='$omit_phone_code',dial_method='$dial_method',available_only_ratio_tally='$available_only_ratio_tally',adaptive_dropped_percentage='$adaptive_dropped_percentage',adaptive_maximum_level='$adaptive_maximum_level',adaptive_latest_server_time='$adaptive_latest_server_time',adaptive_intensity='$adaptive_intensity',adaptive_dl_diff_target='$adaptive_dl_diff_target',concurrent_transfers='$concurrent_transfers',auto_alt_dial='$auto_alt_dial',agent_pause_codes_active='$agent_pause_codes_active',campaign_description='$campaign_description',campaign_changedate='$SQLdate',campaign_stats_refresh='$campaign_stats_refresh',disable_alter_custdata='$disable_alter_custdata',no_hopper_leads_logins='$no_hopper_leads_logins',list_order_mix='$list_order_mix',campaign_allow_inbound='$campaign_allow_inbound',manual_dial_list_id='$manual_dial_list_id',default_xfer_group='$default_xfer_group',xfer_groups='$XFERgroups_value',queue_priority='$queue_priority',drop_inbound_group='$drop_inbound_group',disable_alter_custphone='$disable_alter_custphone',display_queue_count='$display_queue_count',manual_dial_filter='$manual_dial_filter',agent_clipboard_copy='$agent_clipboard_copy',agent_extended_alt_dial='$agent_extended_alt_dial',use_campaign_dnc='$use_campaign_dnc',three_way_call_cid='$three_way_call_cid',three_way_dial_prefix='$three_way_dial_prefix',web_form_target='$web_form_target',vtiger_search_category='$vtiger_search_category',vtiger_create_call_record='$vtiger_create_call_record',vtiger_create_lead_record='$vtiger_create_lead_record',vtiger_screen_login='$vtiger_screen_login',cpd_amd_action='$cpd_amd_action',agent_allow_group_alias='$agent_allow_group_alias',default_group_alias='$default_group_alias',vtiger_search_dead='$vtiger_search_dead',vtiger_status_call='$vtiger_status_call',drop_lockout_time='$drop_lockout_time',quick_transfer_button='$quick_transfer_button',prepopulate_transfer_preset='$prepopulate_transfer_preset',drop_rate_group='$drop_rate_group',view_calls_in_queue='$view_calls_in_queue',view_calls_in_queue_launch='$view_calls_in_queue_launch',grab_calls_in_queue='$grab_calls_in_queue',call_requeue_button='$call_requeue_button',pause_after_each_call='$pause_after_each_call',no_hopper_dialing='$no_hopper_dialing',agent_dial_owner_only='$agent_dial_owner_only',agent_display_dialable_leads='$agent_display_dialable_leads',web_form_address_two='" . mysqli_real_escape_string($link, $web_form_address_two) . "',waitforsilence_options='$waitforsilence_options',agent_select_territories='$agent_select_territories',crm_popup_login='$crm_popup_login',crm_login_address='" . mysqli_real_escape_string($link, $crm_login_address) . "',timer_action='$timer_action',timer_action_message='$timer_action_message',timer_action_seconds='$timer_action_seconds',start_call_url='" . mysqli_real_escape_string($link, $start_call_url) . "',dispo_call_url='" . mysqli_real_escape_string($link, $dispo_call_url) . "',xferconf_c_number='$xferconf_c_number',xferconf_d_number='$xferconf_d_number',xferconf_e_number='$xferconf_e_number',use_custom_cid='$use_custom_cid',scheduled_callbacks_alert='$scheduled_callbacks_alert',queuemetrics_callstatus_override='$queuemetrics_callstatus',extension_appended_cidname='$extension_appended_cidname',scheduled_callbacks_count='$scheduled_callbacks_count',manual_dial_override='$manual_dial_override',blind_monitor_warning='$blind_monitor_warning',blind_monitor_message='" . mysqli_real_escape_string($link, $blind_monitor_message) . "',blind_monitor_filename='$blind_monitor_filename',inbound_queue_no_dial='$inbound_queue_no_dial',timer_action_destination='$timer_action_destination',enable_xfer_presets='$enable_xfer_presets',hide_xfer_number_to_dial='$hide_xfer_number_to_dial',manual_dial_prefix='$manual_dial_prefix',customer_3way_hangup_logging='$customer_3way_hangup_logging',customer_3way_hangup_seconds='$customer_3way_hangup_seconds',customer_3way_hangup_action='$customer_3way_hangup_action',ivr_park_call='$ivr_park_call',ivr_park_call_agi='$ivr_park_call_agi',manual_preview_dial='$manual_preview_dial',realtime_agent_time_stats='$realtime_agent_time_stats',api_manual_dial='$api_manual_dial',manual_dial_call_time_check='$manual_dial_call_time_check',lead_order_randomize='$lead_order_randomize',lead_order_secondary='$lead_order_secondary',per_call_notes='$per_call_notes',my_callback_option='$my_callback_option',agent_lead_search='$agent_lead_search',agent_lead_search_method='$agent_lead_search_method',queuemetrics_phone_environment='$queuemetrics_phone_environment',auto_pause_precall='$auto_pause_precall',auto_resume_precall='$auto_resume_precall',auto_pause_precall_code='$auto_pause_precall_code',manual_dial_cid='$manual_dial_cid',post_phone_time_diff_alert='$post_phone_time_diff_alert',custom_3way_button_transfer='$custom_3way_button_transfer',available_only_tally_threshold='$available_only_tally_threshold',available_only_tally_threshold_agents='$available_only_tally_threshold_agents',dial_level_threshold='$dial_level_threshold',dial_level_threshold_agents='$dial_level_threshold_agents',safe_harbor_audio='$safe_harbor_audio',safe_harbor_menu_id='$safe_harbor_menu_id',callback_days_limit='$callback_days_limit',dl_diff_target_method='$dl_diff_target_method',disable_dispo_screen='$disable_dispo_screen',disable_dispo_status='$disable_dispo_status',screen_labels='$screen_labels',status_display_fields='$status_display_fields',na_call_url='" . mysqli_real_escape_string($link, $na_call_url) . "',pllb_grouping='$pllb_grouping',pllb_grouping_limit='$pllb_grouping_limit',call_count_limit='$call_count_limit',call_count_target='$call_count_target',callback_hours_block='$callback_hours_block',callback_list_calltime='$callback_list_calltime',user_group='$user_group',hopper_vlc_dup_check='$hopper_vlc_dup_check',in_group_dial='$in_group_dial',in_group_dial_select='$in_group_dial_select',safe_harbor_audio_field='$safe_harbor_audio_field',pause_after_next_call='$pause_after_next_call',owner_populate='$owner_populate',use_other_campaign_dnc='$use_other_campaign_dnc',allow_emails='$allow_emails',amd_inbound_group='$amd_inbound_group',amd_callmenu='$amd_callmenu',manual_dial_lead_id='$manual_dial_lead_id',dead_max='$dead_max',dispo_max='$dispo_max',pause_max='$pause_max',dead_max_dispo='$dead_max_dispo',dispo_max_dispo='$dispo_max_dispo',max_inbound_calls='$max_inbound_calls',manual_dial_search_checkbox='$manual_dial_search_checkbox',hide_call_log_info='$hide_call_log_info',timer_alt_seconds='$timer_alt_seconds',wrapup_bypass='$wrapup_bypass',wrapup_after_hotkey='$wrapup_after_hotkey',callback_active_limit='$callback_active_limit',callback_active_limit_override='$callback_active_limit_override',comments_all_tabs='$comments_all_tabs',comments_dispo_screen='$comments_dispo_screen',comments_callback_screen='$comments_callback_screen',qc_comment_history='$qc_comment_history',show_previous_callback='$show_previous_callback',clear_script='$clear_script',cpd_unknown_action='$cpd_unknown_action',manual_dial_search_filter='$manual_dial_search_filter' where campaign_id='$campaign_id';"; $rslt=mysql_to_mysqli($stmtA, $link); if ($reset_hopper == 'Y') @@ -13049,7 +13053,7 @@ if ($ADD==411) echo "
"._QXZ("LIST MODIFIED").": $list_id\n"; - $stmt="UPDATE vicidial_lists set list_name='$list_name',campaign_id='$campaign_id',active='$active',list_description='$list_description',list_changedate='$SQLdate',reset_time='$reset_time',agent_script_override='$agent_script_override',campaign_cid_override='$campaign_cid_override',am_message_exten_override='$am_message_exten_override',drop_inbound_group_override='$drop_inbound_group_override',xferconf_a_number='$xferconf_a_number',xferconf_b_number='$xferconf_b_number',xferconf_c_number='$xferconf_c_number',xferconf_d_number='$xferconf_d_number',xferconf_e_number='$xferconf_e_number',web_form_address='" . mysqli_real_escape_string($link, $web_form_address) . "',web_form_address_two='" . mysqli_real_escape_string($link, $web_form_address_two) . "',time_zone_setting='$time_zone_setting',inventory_report='$inventory_report',expiration_date='$expiration_date',na_call_url='" . mysqli_real_escape_string($link, $na_call_url) . "' where list_id='$list_id';"; + $stmt="UPDATE vicidial_lists set list_name='$list_name',campaign_id='$campaign_id',active='$active',list_description='$list_description',list_changedate='$SQLdate',reset_time='$reset_time',agent_script_override='$agent_script_override',campaign_cid_override='$campaign_cid_override',am_message_exten_override='$am_message_exten_override',drop_inbound_group_override='$drop_inbound_group_override',xferconf_a_number='$xferconf_a_number',xferconf_b_number='$xferconf_b_number',xferconf_c_number='$xferconf_c_number',xferconf_d_number='$xferconf_d_number',xferconf_e_number='$xferconf_e_number',web_form_address='" . mysqli_real_escape_string($link, $web_form_address) . "',web_form_address_two='" . mysqli_real_escape_string($link, $web_form_address_two) . "',time_zone_setting='$time_zone_setting',inventory_report='$inventory_report',expiration_date='$expiration_date',na_call_url='" . mysqli_real_escape_string($link, $na_call_url) . "',local_call_time='$local_call_time' where list_id='$list_id';"; $rslt=mysql_to_mysqli($stmt, $link); ## BEGIN QC Addition for Audited Comments @@ -18154,7 +18158,7 @@ if ($ADD==31) $enable_vtiger_integration_LU = $row[0]; $vtiger_url_LU = $row[1]; - $stmt="SELECT campaign_id,campaign_name,active,dial_status_a,dial_status_b,dial_status_c,dial_status_d,dial_status_e,lead_order,park_ext,park_file_name,web_form_address,allow_closers,hopper_level,auto_dial_level,next_agent_call,local_call_time,voicemail_ext,dial_timeout,dial_prefix,campaign_cid,campaign_vdad_exten,campaign_rec_exten,campaign_recording,campaign_rec_filename,campaign_script,get_call_launch,am_message_exten,amd_send_to_vmx,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number,alt_number_dialing,scheduled_callbacks,lead_filter_id,drop_call_seconds,drop_action,safe_harbor_exten,display_dialable_count,wrapup_seconds,wrapup_message,closer_campaigns,use_internal_dnc,allcalls_delay,omit_phone_code,dial_method,available_only_ratio_tally,adaptive_dropped_percentage,adaptive_maximum_level,adaptive_latest_server_time,adaptive_intensity,adaptive_dl_diff_target,concurrent_transfers,auto_alt_dial,auto_alt_dial_statuses,agent_pause_codes_active,campaign_description,campaign_changedate,campaign_stats_refresh,campaign_logindate,dial_statuses,disable_alter_custdata,no_hopper_leads_logins,list_order_mix,campaign_allow_inbound,manual_dial_list_id,default_xfer_group,xfer_groups,queue_priority,drop_inbound_group,qc_enabled,qc_statuses,qc_lists,qc_shift_id,qc_get_record_launch,qc_show_recording,qc_web_form_address,qc_script,survey_first_audio_file,survey_dtmf_digits,survey_ni_digit,survey_opt_in_audio_file,survey_ni_audio_file,survey_method,survey_no_response_action,survey_ni_status,survey_response_digit_map,survey_xfer_exten,survey_camp_record_dir,disable_alter_custphone,display_queue_count,manual_dial_filter,agent_clipboard_copy,agent_extended_alt_dial,use_campaign_dnc,three_way_call_cid,three_way_dial_prefix,web_form_target,vtiger_search_category,vtiger_create_call_record,vtiger_create_lead_record,vtiger_screen_login,cpd_amd_action,agent_allow_group_alias,default_group_alias,vtiger_search_dead,vtiger_status_call,survey_third_digit,survey_third_audio_file,survey_third_status,survey_third_exten,survey_fourth_digit,survey_fourth_audio_file,survey_fourth_status,survey_fourth_exten,drop_lockout_time,quick_transfer_button,prepopulate_transfer_preset,drop_rate_group,view_calls_in_queue,view_calls_in_queue_launch,grab_calls_in_queue,call_requeue_button,pause_after_each_call,no_hopper_dialing,agent_dial_owner_only,agent_display_dialable_leads,web_form_address_two,waitforsilence_options,agent_select_territories,campaign_calldate,crm_popup_login,crm_login_address,timer_action,timer_action_message,timer_action_seconds,start_call_url,dispo_call_url,xferconf_c_number,xferconf_d_number,xferconf_e_number,use_custom_cid,scheduled_callbacks_alert,queuemetrics_callstatus_override,extension_appended_cidname,scheduled_callbacks_count,manual_dial_override,blind_monitor_warning,blind_monitor_message,blind_monitor_filename,inbound_queue_no_dial,timer_action_destination,enable_xfer_presets,hide_xfer_number_to_dial,manual_dial_prefix,customer_3way_hangup_logging,customer_3way_hangup_seconds,customer_3way_hangup_action,ivr_park_call,ivr_park_call_agi,manual_preview_dial,realtime_agent_time_stats,use_auto_hopper,auto_hopper_multi,auto_trim_hopper,api_manual_dial,manual_dial_call_time_check,display_leads_count,lead_order_randomize,lead_order_secondary,per_call_notes,my_callback_option,agent_lead_search,agent_lead_search_method,queuemetrics_phone_environment,auto_pause_precall,auto_resume_precall,auto_pause_precall_code,manual_dial_cid,post_phone_time_diff_alert,custom_3way_button_transfer,available_only_tally_threshold,available_only_tally_threshold_agents,dial_level_threshold,dial_level_threshold_agents,safe_harbor_audio,safe_harbor_menu_id,survey_menu_id,callback_days_limit,dl_diff_target_method,disable_dispo_screen,disable_dispo_status,screen_labels,status_display_fields,na_call_url,survey_recording,pllb_grouping,pllb_grouping_limit,call_count_limit,call_count_target,callback_hours_block,callback_list_calltime,user_group,hopper_vlc_dup_check,in_group_dial,in_group_dial_select,safe_harbor_audio_field,pause_after_next_call,owner_populate,use_other_campaign_dnc,allow_emails,amd_inbound_group,amd_callmenu,survey_wait_sec,manual_dial_lead_id,dead_max,dispo_max,pause_max,dead_max_dispo,dispo_max_dispo,max_inbound_calls,manual_dial_search_checkbox,hide_call_log_info,timer_alt_seconds,wrapup_bypass,wrapup_after_hotkey,callback_active_limit,callback_active_limit_override,comments_all_tabs,comments_dispo_screen,comments_callback_screen,qc_comment_history,show_previous_callback,clear_script,cpd_unknown_action from vicidial_campaigns where campaign_id='$campaign_id' $LOGallowed_campaignsSQL;"; + $stmt="SELECT campaign_id,campaign_name,active,dial_status_a,dial_status_b,dial_status_c,dial_status_d,dial_status_e,lead_order,park_ext,park_file_name,web_form_address,allow_closers,hopper_level,auto_dial_level,next_agent_call,local_call_time,voicemail_ext,dial_timeout,dial_prefix,campaign_cid,campaign_vdad_exten,campaign_rec_exten,campaign_recording,campaign_rec_filename,campaign_script,get_call_launch,am_message_exten,amd_send_to_vmx,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number,alt_number_dialing,scheduled_callbacks,lead_filter_id,drop_call_seconds,drop_action,safe_harbor_exten,display_dialable_count,wrapup_seconds,wrapup_message,closer_campaigns,use_internal_dnc,allcalls_delay,omit_phone_code,dial_method,available_only_ratio_tally,adaptive_dropped_percentage,adaptive_maximum_level,adaptive_latest_server_time,adaptive_intensity,adaptive_dl_diff_target,concurrent_transfers,auto_alt_dial,auto_alt_dial_statuses,agent_pause_codes_active,campaign_description,campaign_changedate,campaign_stats_refresh,campaign_logindate,dial_statuses,disable_alter_custdata,no_hopper_leads_logins,list_order_mix,campaign_allow_inbound,manual_dial_list_id,default_xfer_group,xfer_groups,queue_priority,drop_inbound_group,qc_enabled,qc_statuses,qc_lists,qc_shift_id,qc_get_record_launch,qc_show_recording,qc_web_form_address,qc_script,survey_first_audio_file,survey_dtmf_digits,survey_ni_digit,survey_opt_in_audio_file,survey_ni_audio_file,survey_method,survey_no_response_action,survey_ni_status,survey_response_digit_map,survey_xfer_exten,survey_camp_record_dir,disable_alter_custphone,display_queue_count,manual_dial_filter,agent_clipboard_copy,agent_extended_alt_dial,use_campaign_dnc,three_way_call_cid,three_way_dial_prefix,web_form_target,vtiger_search_category,vtiger_create_call_record,vtiger_create_lead_record,vtiger_screen_login,cpd_amd_action,agent_allow_group_alias,default_group_alias,vtiger_search_dead,vtiger_status_call,survey_third_digit,survey_third_audio_file,survey_third_status,survey_third_exten,survey_fourth_digit,survey_fourth_audio_file,survey_fourth_status,survey_fourth_exten,drop_lockout_time,quick_transfer_button,prepopulate_transfer_preset,drop_rate_group,view_calls_in_queue,view_calls_in_queue_launch,grab_calls_in_queue,call_requeue_button,pause_after_each_call,no_hopper_dialing,agent_dial_owner_only,agent_display_dialable_leads,web_form_address_two,waitforsilence_options,agent_select_territories,campaign_calldate,crm_popup_login,crm_login_address,timer_action,timer_action_message,timer_action_seconds,start_call_url,dispo_call_url,xferconf_c_number,xferconf_d_number,xferconf_e_number,use_custom_cid,scheduled_callbacks_alert,queuemetrics_callstatus_override,extension_appended_cidname,scheduled_callbacks_count,manual_dial_override,blind_monitor_warning,blind_monitor_message,blind_monitor_filename,inbound_queue_no_dial,timer_action_destination,enable_xfer_presets,hide_xfer_number_to_dial,manual_dial_prefix,customer_3way_hangup_logging,customer_3way_hangup_seconds,customer_3way_hangup_action,ivr_park_call,ivr_park_call_agi,manual_preview_dial,realtime_agent_time_stats,use_auto_hopper,auto_hopper_multi,auto_trim_hopper,api_manual_dial,manual_dial_call_time_check,display_leads_count,lead_order_randomize,lead_order_secondary,per_call_notes,my_callback_option,agent_lead_search,agent_lead_search_method,queuemetrics_phone_environment,auto_pause_precall,auto_resume_precall,auto_pause_precall_code,manual_dial_cid,post_phone_time_diff_alert,custom_3way_button_transfer,available_only_tally_threshold,available_only_tally_threshold_agents,dial_level_threshold,dial_level_threshold_agents,safe_harbor_audio,safe_harbor_menu_id,survey_menu_id,callback_days_limit,dl_diff_target_method,disable_dispo_screen,disable_dispo_status,screen_labels,status_display_fields,na_call_url,survey_recording,pllb_grouping,pllb_grouping_limit,call_count_limit,call_count_target,callback_hours_block,callback_list_calltime,user_group,hopper_vlc_dup_check,in_group_dial,in_group_dial_select,safe_harbor_audio_field,pause_after_next_call,owner_populate,use_other_campaign_dnc,allow_emails,amd_inbound_group,amd_callmenu,survey_wait_sec,manual_dial_lead_id,dead_max,dispo_max,pause_max,dead_max_dispo,dispo_max_dispo,max_inbound_calls,manual_dial_search_checkbox,hide_call_log_info,timer_alt_seconds,wrapup_bypass,wrapup_after_hotkey,callback_active_limit,callback_active_limit_override,comments_all_tabs,comments_dispo_screen,comments_callback_screen,qc_comment_history,show_previous_callback,clear_script,cpd_unknown_action,manual_dial_search_filter from vicidial_campaigns where campaign_id='$campaign_id' $LOGallowed_campaignsSQL;"; $rslt=mysql_to_mysqli($stmt, $link); $row=mysqli_fetch_row($rslt); $campaign_name = $row[1]; @@ -18392,6 +18396,7 @@ if ($ADD==31) $show_previous_callback = $row[233]; $clear_script = $row[234]; $cpd_unknown_action = $row[235]; + $manual_dial_search_filter=$row[236]; if (preg_match('/DISABLED/', $list_order_mix)) {$DEFlistDISABLE = ''; $DEFstatusDISABLED=0;} @@ -19453,6 +19458,8 @@ if ($ADD==31) echo ""._QXZ("Manual Dial Search Checkbox").": $NWB#campaigns-manual_dial_search_checkbox$NWE\n"; + echo ""._QXZ("Manual Dial Search Filter").": $NWB#campaigns-manual_dial_search_filter$NWE\n"; + echo ""._QXZ("Manual Dial by Lead ID").": $NWB#campaigns-manual_dial_lead_id$NWE\n"; echo ""._QXZ("Manual Call Time Check").": $NWB#campaigns-manual_dial_call_time_check$NWE\n"; @@ -19626,26 +19633,29 @@ if ($ADD==31) $LISTlink='stage=LISTIDDOWN'; $NAMElink='stage=LISTNAMEDOWN'; + $CALLTIMElink='stage=CALLTIMEDOWN'; $TALLYlink='stage=TALLYDOWN'; $ACTIVElink='stage=ACTIVEDOWN'; $CAMPAIGNlink='stage=CAMPAIGNDOWN'; $CALLDATElink='stage=CALLDATEDOWN'; $SQLorder='order by list_id'; - if (preg_match('/LISTIDUP/i', $stage)) {$SQLorder='order by list_id asc'; $LISTlink='stage=LISTIDDOWN';} + if (preg_match('/LISTIDUP/i', $stage)) {$SQLorder='order by list_id asc'; $LISTlink='stage=LISTIDDOWN';} if (preg_match('/LISTIDDOWN/i', $stage)) {$SQLorder='order by list_id desc'; $LISTlink='stage=LISTIDUP';} if (preg_match('/LISTNAMEUP/i', $stage)) {$SQLorder='order by list_name asc'; $NAMElink='stage=LISTNAMEDOWN';} - if (preg_match('/LISTNAMEDOWN/i', $stage)) {$SQLorder='order by list_name desc'; $NAMElink='stage=LISTNAMEUP';} - if (preg_match('/TALLYUP/i', $stage)) {$SQLorder='order by tally asc'; $TALLYlink='stage=TALLYDOWN';} - if (preg_match('/TALLYDOWN/i', $stage)) {$SQLorder='order by tally desc'; $TALLYlink='stage=TALLYUP';} - if (preg_match('/ACTIVEUP/i', $stage)) {$SQLorder='order by active asc'; $ACTIVElink='stage=ACTIVEDOWN';} + if (preg_match('/LISTNAMEDOWN/i', $stage)) {$SQLorder='order by list_name desc'; $NAMElink='stage=LISTNAMEUP';} + if (preg_match('/CALLTIMEUP/i', $stage)) {$SQLorder='order by local_call_time asc'; $CALLTIMElink='stage=CALLTIMEDOWN';} + if (preg_match('/CALLTIMEDOWN/i', $stage)) {$SQLorder='order by local_call_time desc'; $CALLTIMElink='stage=CALLTIMEUP';} + if (preg_match('/TALLYUP/i', $stage)) {$SQLorder='order by tally asc'; $TALLYlink='stage=TALLYDOWN';} + if (preg_match('/TALLYDOWN/i', $stage)) {$SQLorder='order by tally desc'; $TALLYlink='stage=TALLYUP';} + if (preg_match('/ACTIVEUP/i', $stage)) {$SQLorder='order by active asc'; $ACTIVElink='stage=ACTIVEDOWN';} if (preg_match('/ACTIVEDOWN/i', $stage)) {$SQLorder='order by active desc'; $ACTIVElink='stage=ACTIVEUP';} - if (preg_match('/CAMPAIGNUP/i',$stage)) {$SQLorder='order by campaign_id asc'; $CAMPAIGNlink='stage=CAMPAIGNDOWN';} - if (preg_match('/CAMPAIGNUP/i', $stage)) {$SQLorder='order by campaign_id desc'; $CAMPAIGNlink='stage=CAMPAIGNUP';} + if (preg_match('/CAMPAIGNUP/i',$stage)) {$SQLorder='order by campaign_id asc'; $CAMPAIGNlink='stage=CAMPAIGNDOWN';} + if (preg_match('/CAMPAIGNUP/i', $stage)) {$SQLorder='order by campaign_id desc'; $CAMPAIGNlink='stage=CAMPAIGNUP';} if (preg_match('/CALLDATEUP/i', $stage)) {$SQLorder='order by list_lastcalldate asc'; $CALLDATElink='stage=CALLDATEDOWN';} - if (preg_match('/CALLDATEDOWN/i', $stage)) {$SQLorder='order by list_lastcalldate desc'; $CALLDATElink='stage=CALLDATEUP';} - $stmt="SELECT vls.list_id,list_name,list_description,count(*) as tally,active,list_lastcalldate,campaign_id,DATE_FORMAT(expiration_date,'%Y%m%d') from vicidial_lists vls,vicidial_list vl where vls.list_id=vl.list_id and campaign_id='$campaign_id' $LOGallowed_campaignsSQL group by list_id $SQLorder"; + if (preg_match('/CALLDATEDOWN/i', $stage)) {$SQLorder='order by list_lastcalldate desc'; $CALLDATElink='stage=CALLDATEUP';} + $stmt="SELECT vls.list_id,list_name,list_description,count(*) as tally,active,list_lastcalldate,campaign_id,DATE_FORMAT(expiration_date,'%Y%m%d'),local_call_time from vicidial_lists vls,vicidial_list vl where vls.list_id=vl.list_id and campaign_id='$campaign_id' $LOGallowed_campaignsSQL group by list_id $SQLorder"; if ($SSadmin_list_counts < 1) - {$stmt="SELECT list_id,list_name,list_description,'X' as tally,active,list_lastcalldate,campaign_id,DATE_FORMAT(expiration_date,'%Y%m%d') from vicidial_lists where campaign_id='$campaign_id' $LOGallowed_campaignsSQL $SQLorder";} + {$stmt="SELECT list_id,list_name,list_description,'X' as tally,active,list_lastcalldate,campaign_id,DATE_FORMAT(expiration_date,'%Y%m%d'),local_call_time from vicidial_lists where campaign_id='$campaign_id' $LOGallowed_campaignsSQL $SQLorder";} $rslt=mysql_to_mysqli($stmt, $link); $lists_to_print = mysqli_num_rows($rslt); @@ -19655,6 +19665,7 @@ if ($ADD==31) echo ""._QXZ("LIST NAME").""; echo ""._QXZ("DESCRIPTION")."\n"; echo ""._QXZ("LEADS COUNT")."\n"; + echo ""._QXZ("Call Time").""; echo ""._QXZ("ACTIVE").""; echo ""._QXZ("LAST CALL DATE").""; echo "MODIFY\n"; @@ -19672,6 +19683,10 @@ if ($ADD==31) echo " $row[1]"; echo " $row[2]"; echo " $row[3]"; + if ($row[8] == 'campaign') + {echo " $row[8]";} + else + {echo " $row[8]";} echo " $row[4]"; echo ""; @@ -19686,7 +19701,7 @@ if ($ADD==31) $inactive_lists++; echo ""; if ($row[7] < $EXPtestdate) {echo ""._QXZ("EXP")."";} @@ -21106,26 +21121,29 @@ if ($ADD==34) $LISTlink='stage=LISTIDDOWN'; $NAMElink='stage=LISTNAMEDOWN'; + $CALLTIMElink='stage=CALLTIMEDOWN'; $TALLYlink='stage=TALLYDOWN'; $ACTIVElink='stage=ACTIVEDOWN'; $CAMPAIGNlink='stage=CAMPAIGNDOWN'; $CALLDATElink='stage=CALLDATEDOWN'; $SQLorder='order by list_id'; if (preg_match('/LISTIDUP/i', $stage)) {$SQLorder='order by list_id asc'; $LISTlink='stage=LISTIDDOWN';} - if (preg_match('/LISTIDDOWN/i', $stage)) {$SQLorder='order by list_id desc'; $LISTlink='stage=LISTIDUP';} - if (preg_match('/LISTNAMEUP/i', $stage)) {$SQLorder='order by list_name asc'; $NAMElink='stage=LISTNAMEDOWN';} + if (preg_match('/LISTIDDOWN/i', $stage)) {$SQLorder='order by list_id desc'; $LISTlink='stage=LISTIDUP';} + if (preg_match('/LISTNAMEUP/i', $stage)) {$SQLorder='order by list_name asc'; $NAMElink='stage=LISTNAMEDOWN';} if (preg_match('/LISTNAMEDOWN/i', $stage)) {$SQLorder='order by list_name desc'; $NAMElink='stage=LISTNAMEUP';} + if (preg_match('/CALLTIMEUP/i', $stage)) {$SQLorder='order by local_call_time asc'; $CALLTIMElink='stage=CALLTIMEDOWN';} + if (preg_match('/CALLTIMEDOWN/i', $stage)) {$SQLorder='order by local_call_time desc'; $CALLTIMElink='stage=CALLTIMEUP';} if (preg_match('/TALLYUP/i', $stage)) {$SQLorder='order by tally asc'; $TALLYlink='stage=TALLYDOWN';} if (preg_match('/TALLYDOWN/i', $stage)) {$SQLorder='order by tally desc'; $TALLYlink='stage=TALLYUP';} if (preg_match('/ACTIVEUP/i', $stage)) {$SQLorder='order by active asc'; $ACTIVElink='stage=ACTIVEDOWN';} - if (preg_match('/ACTIVEDOWN/i', $stage)) {$SQLorder='order by active desc'; $ACTIVElink='stage=ACTIVEUP';} + if (preg_match('/ACTIVEDOWN/i', $stage)) {$SQLorder='order by active desc'; $ACTIVElink='stage=ACTIVEUP';} if (preg_match('/CAMPAIGNUP/i',$stage)) {$SQLorder='order by campaign_id asc'; $CAMPAIGNlink='stage=CAMPAIGNDOWN';} if (preg_match('/CAMPAIGNUP/i', $stage)) {$SQLorder='order by campaign_id desc'; $CAMPAIGNlink='stage=CAMPAIGNUP';} - if (preg_match('/CALLDATEUP/i', $stage)) {$SQLorder='order by list_lastcalldate asc'; $CALLDATElink='stage=CALLDATEDOWN';} + if (preg_match('/CALLDATEUP/i', $stage)) {$SQLorder='order by list_lastcalldate asc'; $CALLDATElink='stage=CALLDATEDOWN';} if (preg_match('/CALLDATEDOWN/i', $stage)) {$SQLorder='order by list_lastcalldate desc'; $CALLDATElink='stage=CALLDATEUP';} - $stmt="SELECT vls.list_id,list_name,list_description,count(*) as tally,active,list_lastcalldate,campaign_id,DATE_FORMAT(expiration_date,'%Y%m%d') from vicidial_lists vls,vicidial_list vl where vls.list_id=vl.list_id and campaign_id='$campaign_id' $LOGallowed_campaignsSQL group by list_id $SQLorder"; + $stmt="SELECT vls.list_id,list_name,list_description,count(*) as tally,active,list_lastcalldate,campaign_id,DATE_FORMAT(expiration_date,'%Y%m%d'),local_call_time from vicidial_lists vls,vicidial_list vl where vls.list_id=vl.list_id and campaign_id='$campaign_id' $LOGallowed_campaignsSQL group by list_id $SQLorder"; if ($SSadmin_list_counts < 1) - {$stmt="SELECT list_id,list_name,list_description,'X' as tally,active,list_lastcalldate,campaign_id,DATE_FORMAT(expiration_date,'%Y%m%d') from vicidial_lists where campaign_id='$campaign_id' $LOGallowed_campaignsSQL $SQLorder";} + {$stmt="SELECT list_id,list_name,list_description,'X' as tally,active,list_lastcalldate,campaign_id,DATE_FORMAT(expiration_date,'%Y%m%d'),local_call_time from vicidial_lists where campaign_id='$campaign_id' $LOGallowed_campaignsSQL $SQLorder";} $rslt=mysql_to_mysqli($stmt, $link); $lists_to_print = mysqli_num_rows($rslt); @@ -21135,6 +21153,7 @@ if ($ADD==34) echo ""._QXZ("LIST NAME").""; echo ""._QXZ("DESCRIPTION")."\n"; echo ""._QXZ("LEADS COUNT")."\n"; + echo ""._QXZ("Call Time").""; echo ""._QXZ("ACTIVE").""; echo ""._QXZ("LAST CALL DATE").""; echo ""._QXZ("MODIFY")."\n"; @@ -21152,6 +21171,10 @@ if ($ADD==34) echo " $row[1]"; echo " $row[2]"; echo " $row[3]"; + if ($row[8] == 'campaign') + {echo " $row[8]";} + else + {echo " $row[8]";} echo " $row[4]"; echo ""; @@ -22155,7 +22178,8 @@ if ($ADD==311) echo "\n"; - - if($audit_comments=='1') { + + echo "\n"; + + if($audit_comments=='1') + { echo "\n"; - } else { + } + else + { echo "\n"; - } + } echo "\n"; echo "\n"; @@ -27655,7 +27696,7 @@ if ($ADD==311111111) $holiday_rules = explode('|',$ct_holidays); $ct_hrs = ((count($holiday_rules)) - 1); } - echo "\n"; + echo "\n"; echo "\n"; while($ct_hrs >= $b) { @@ -27694,7 +27735,7 @@ if ($ADD==311111111) echo "\n"; echo "\n"; echo "\n"; - echo _QXZ("Add inbound holiday rule").": \n"; echo "\n"; @@ -27730,6 +27771,21 @@ if ($ADD==311111111) $o++; } + echo "
\n"; echo ""; - $stmt="SELECT vicidial_lists.list_id,list_name,campaign_id,active,list_description,list_changedate,list_lastcalldate,reset_time,agent_script_override,campaign_cid_override,am_message_exten_override,drop_inbound_group_override,xferconf_a_number,xferconf_b_number,xferconf_c_number,xferconf_d_number,xferconf_e_number,web_form_address,web_form_address_two,time_zone_setting,inventory_report,IFNULL(audit_comments,0),expiration_date,DATE_FORMAT(expiration_date,'%Y%m%d'),na_call_url from vicidial_lists left outer join vicidial_lists_custom on vicidial_lists.list_id=vicidial_lists_custom.list_id where vicidial_lists.list_id='$list_id' $LOGallowed_campaignsSQL;"; + $stmt="SELECT vicidial_lists.list_id,list_name,campaign_id,active,list_description,list_changedate,list_lastcalldate,reset_time,agent_script_override,campaign_cid_override,am_message_exten_override,drop_inbound_group_override,xferconf_a_number,xferconf_b_number,xferconf_c_number,xferconf_d_number,xferconf_e_number,web_form_address,web_form_address_two,time_zone_setting,inventory_report,IFNULL(audit_comments,0),expiration_date,DATE_FORMAT(expiration_date,'%Y%m%d'),na_call_url,local_call_time from vicidial_lists left outer join vicidial_lists_custom on vicidial_lists.list_id=vicidial_lists_custom.list_id where vicidial_lists.list_id='$list_id' $LOGallowed_campaignsSQL;"; + $rslt=mysql_to_mysqli($stmt, $link); if ($DB) {echo "$stmt\n";} $row=mysqli_fetch_row($rslt); @@ -22183,6 +22207,7 @@ if ($ADD==311) $expiration_date = $row[22]; $expiration_dateINT = $row[23]; $na_call_url = $row[24]; + $list_local_call_time = $row[25]; # grab names of global statuses and statuses in the selected campaign $stmt="SELECT status,status_name,selectable,human_answered,category,sale,dnc,customer_contact,not_interested,unworkable,scheduled_callback,completed from vicidial_statuses order by status;"; @@ -22301,12 +22326,28 @@ if ($ADD==311) {echo "     "._QXZ("LIST EXPIRED")."";} } echo "
"._QXZ("Local Call Time").": $NWB#lists-local_call_time$NWE
"._QXZ("Audit Comments").": $NWB#lists-audit_comments$NWE
"._QXZ("Audit Comments").": $NWB#lists-audit_comments$NWE
"._QXZ("List Change Date").": $list_changedate   $NWB#lists-list_changedate$NWE
"._QXZ("List Last Call Date").": $list_lastcalldate   $NWB#lists-list_lastcalldate$NWE
"._QXZ("Active Inbound Holiday Definitions for this Record").":
"._QXZ("Active Holiday Definitions for this Record").":  
\n"; + echo ""._QXZ("LISTS SET TO THIS CALL TIME").":
\n"; + echo "\n"; + + $stmt="SELECT list_id,list_name from vicidial_lists where local_call_time='$call_time_id' $LOGallowed_campaignsSQL;"; + $rslt=mysql_to_mysqli($stmt, $link); + $lists_to_print = mysqli_num_rows($rslt); + $o=0; + while ($lists_to_print > $o) + { + $row=mysqli_fetch_row($rslt); + echo "\n"; + $o++; + } + echo "
$row[0] $row[1]
\n"; echo "

\n"; @@ -30969,6 +31025,7 @@ if ($ADD==100) $LISTlink='stage=LISTIDDOWN'; $NAMElink='stage=LISTNAMEDOWN'; + $CALLTIMElink='stage=CALLTIMEDOWN'; $TALLYlink='stage=TALLYDOWN'; $ACTIVElink='stage=ACTIVEDOWN'; $CAMPAIGNlink='stage=CAMPAIGNDOWN'; @@ -30978,6 +31035,8 @@ if ($ADD==100) if (preg_match('/LISTIDDOWN/i', $stage)) {$SQLorder='order by list_id desc'; $LISTlink='stage=LISTIDUP';} if (preg_match('/LISTNAMEUP/i', $stage)) {$SQLorder='order by list_name asc'; $NAMElink='stage=LISTNAMEDOWN';} if (preg_match('/LISTNAMEDOWN/i', $stage)) {$SQLorder='order by list_name desc'; $NAMElink='stage=LISTNAMEUP';} + if (preg_match('/CALLTIMEUP/i', $stage)) {$SQLorder='order by local_call_time asc'; $CALLTIMElink='stage=CALLTIMEDOWN';} + if (preg_match('/CALLTIMEDOWN/i', $stage)) {$SQLorder='order by local_call_time desc'; $CALLTIMElink='stage=CALLTIMEUP';} if (preg_match('/TALLYUP/i', $stage)) {$SQLorder='order by tally asc'; $TALLYlink='stage=TALLYDOWN';} if (preg_match('/TALLYDOWN/i', $stage)) {$SQLorder='order by tally desc'; $TALLYlink='stage=TALLYUP';} if (preg_match('/ACTIVEUP/i', $stage)) {$SQLorder='order by active asc'; $ACTIVElink='stage=ACTIVEDOWN';} @@ -30986,9 +31045,9 @@ if ($ADD==100) if (preg_match('/CAMPAIGNUP/i', $stage)) {$SQLorder='order by campaign_id desc'; $CAMPAIGNlink='stage=CAMPAIGNUP';} if (preg_match('/CALLDATEUP/i', $stage)) {$SQLorder='order by list_lastcalldate asc'; $CALLDATElink='stage=CALLDATEDOWN';} if (preg_match('/CALLDATEDOWN/i', $stage)) {$SQLorder='order by list_lastcalldate desc'; $CALLDATElink='stage=CALLDATEUP';} - $stmt="SELECT vls.list_id,list_name,list_description,count(*) as tally,active,list_lastcalldate,campaign_id,reset_time,DATE_FORMAT(expiration_date,'%Y%m%d') from vicidial_lists vls,vicidial_list vl where vls.list_id=vl.list_id $LOGallowed_campaignsSQL group by list_id $SQLorder"; + $stmt="SELECT vls.list_id,list_name,list_description,count(*) as tally,active,list_lastcalldate,campaign_id,reset_time,DATE_FORMAT(expiration_date,'%Y%m%d'),local_call_time from vicidial_lists vls,vicidial_list vl where vls.list_id=vl.list_id $LOGallowed_campaignsSQL group by list_id $SQLorder"; if ($SSadmin_list_counts < 1) - {$stmt="SELECT list_id,list_name,list_description,'X' as tally,active,list_lastcalldate,campaign_id,reset_time,DATE_FORMAT(expiration_date,'%Y%m%d') from vicidial_lists $whereLOGallowed_campaignsSQL $SQLorder";} + {$stmt="SELECT list_id,list_name,list_description,'X' as tally,active,list_lastcalldate,campaign_id,reset_time,DATE_FORMAT(expiration_date,'%Y%m%d'),local_call_time from vicidial_lists $whereLOGallowed_campaignsSQL $SQLorder";} $rslt=mysql_to_mysqli($stmt, $link); $lists_to_print = mysqli_num_rows($rslt); @@ -31000,6 +31059,7 @@ if ($ADD==100) echo ""._QXZ("DESCRIPTION")."\n"; echo ""._QXZ("RTIME")."\n"; echo ""._QXZ("LEADS COUNT")."\n"; + echo ""._QXZ("CALL TIME").""; echo ""._QXZ("ACTIVE").""; echo ""._QXZ("LAST CALL DATE").""; echo ""._QXZ("CAMPAIGN")."\n"; @@ -31020,6 +31080,10 @@ if ($ADD==100) echo " $row[2]"; echo " $row[7]"; echo " $row[3]"; + if ($row[9] == 'campaign') + {echo " $row[9]";} + else + {echo " $row[9]";} echo " $row[4]"; if ($row[8] < $EXPtestdate) {echo " "._QXZ("EXP")."";} @@ -31031,11 +31095,11 @@ if ($ADD==100) $o++; } - $stmt="SELECT list_id,list_name,list_description,0,active,list_lastcalldate,campaign_id,reset_time,DATE_FORMAT(expiration_date,'%Y%m%d') from vicidial_lists where list_id NOT IN($lists_printed'') $LOGallowed_campaignsSQL;"; + $stmt="SELECT list_id,list_name,list_description,0,active,list_lastcalldate,campaign_id,reset_time,DATE_FORMAT(expiration_date,'%Y%m%d'),local_call_time from vicidial_lists where list_id NOT IN($lists_printed'') $LOGallowed_campaignsSQL;"; $rslt=mysql_to_mysqli($stmt, $link); $lists_to_print = mysqli_num_rows($rslt); - $o=0; - while ($lists_to_print > $o) + $p=0; + while ($lists_to_print > $p) { $row=mysqli_fetch_row($rslt); if (preg_match('/1$|3$|5$|7$|9$/i', $o)) @@ -31047,6 +31111,10 @@ if ($ADD==100) echo " $row[2]"; echo " $row[7]"; echo " $row[3]"; + if ($row[9] == 'campaign') + {echo " $row[9]";} + else + {echo " $row[9]";} echo " $row[4]"; if ($row[8] < $EXPtestdate) {echo " "._QXZ("EXP")."";} @@ -31054,6 +31122,7 @@ if ($ADD==100) echo " $row[5]"; echo " $row[6]"; echo ""._QXZ("MODIFY")."\n"; + $p++; $o++; } @@ -34615,6 +34684,7 @@ if (isset($camp_lists)) $GMT_gmt[0] = ''; $GMT_hour[0] = ''; $GMT_day[0] = ''; + $YMD = date("Y-m-d"); while ($p > -13) { $pzone=3600 * $p; @@ -34633,23 +34703,62 @@ if (isset($camp_lists)) if ($DB) {echo "$stmt\n";} $rslt=mysql_to_mysqli($stmt, $link); $rowx=mysqli_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]"; + $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]; + $Gct_holidays = $rowx[20]; + + ### BEGIN Check for outbound holiday ### + $holiday_id = ''; + if (strlen($Gct_holidays)>2) + { + $Gct_holidaysSQL = preg_replace("/\|/", "','", "$Gct_holidays"); + $Gct_holidaysSQL = "'".$Gct_holidaysSQL."'"; + + $stmt = "SELECT holiday_id,holiday_date,holiday_name,ct_default_start,ct_default_stop from vicidial_call_time_holidays where holiday_id IN($Gct_holidaysSQL) and holiday_status='ACTIVE' and holiday_date='$YMD' order by holiday_id;"; + $rslt=mysql_to_mysqli($stmt, $link); + if ($DB) {echo "$stmt\n";} + $sthCrows=mysqli_num_rows($rslt); + if ($sthCrows > 0) + { + $aryC=mysqli_fetch_row($rslt); + $holiday_id = $aryC[0]; + $holiday_date = $aryC[1]; + $holiday_name = $aryC[2]; + if($Gct_default_start < $aryC[3]) {$Gct_default_start = $aryC[3];} + if($Gct_default_stop > $aryC[4]) {$Gct_default_stop = $aryC[4];} + if($Gct_sunday_start < $aryC[3]) {$Gct_sunday_start = $aryC[3];} + if($Gct_sunday_stop > $aryC[4]) {$Gct_sunday_stop = $aryC[4];} + if($Gct_monday_start < $aryC[3]) {$Gct_monday_start = $aryC[3];} + if($Gct_monday_stop > $aryC[4]) {$Gct_monday_stop = $aryC[4];} + if($Gct_tuesday_start < $aryC[3]) {$Gct_tuesday_start = $aryC[3];} + if($Gct_tuesday_stop > $aryC[4]) {$Gct_tuesday_stop = $aryC[4];} + if($Gct_wednesday_start < $aryC[3]) {$Gct_wednesday_start = $aryC[3];} + if($Gct_wednesday_stop > $aryC[4]) {$Gct_wednesday_stop = $aryC[4];} + if($Gct_thursday_start < $aryC[3]) {$Gct_thursday_start = $aryC[3];} + if($Gct_thursday_stop > $aryC[4]) {$Gct_thursday_stop = $aryC[4];} + if($Gct_friday_start < $aryC[3]) {$Gct_friday_start = $aryC[3];} + if($Gct_friday_stop > $aryC[4]) {$Gct_friday_stop = $aryC[4];} + if($Gct_saturday_start < $aryC[3]) {$Gct_saturday_start = $aryC[3];} + if($Gct_saturday_stop > $aryC[4]) {$Gct_saturday_stop = $aryC[4];} + if ($DB) {echo "CALL TIME HOLIDAY FOUND! $local_call_time|$holiday_id|$holiday_date|$holiday_name|$Gct_default_start|$Gct_default_stop|\n";} + } + } + ### END Check for outbound holiday ### $ct_states = ''; $ct_state_gmt_SQL = ''; @@ -34667,27 +34776,73 @@ if (isset($camp_lists)) $stmt="SELECT state_call_time_id,state_call_time_state,state_call_time_name,state_call_time_comments,sct_default_start,sct_default_stop,sct_sunday_start,sct_sunday_stop,sct_monday_start,sct_monday_stop,sct_tuesday_start,sct_tuesday_stop,sct_wednesday_start,sct_wednesday_stop,sct_thursday_start,sct_thursday_stop,sct_friday_start,sct_friday_stop,sct_saturday_start,sct_saturday_stop from vicidial_state_call_times where state_call_time_id='$state_rules[$b]';"; $rslt=mysql_to_mysqli($stmt, $link); $row=mysqli_fetch_row($rslt); - $Gstate_call_time_id = "$row[0]"; - $Gstate_call_time_state = "$row[1]"; - $Gsct_default_start = "$row[4]"; - $Gsct_default_stop = "$row[5]"; - $Gsct_sunday_start = "$row[6]"; - $Gsct_sunday_stop = "$row[7]"; - $Gsct_monday_start = "$row[8]"; - $Gsct_monday_stop = "$row[9]"; - $Gsct_tuesday_start = "$row[10]"; - $Gsct_tuesday_stop = "$row[11]"; - $Gsct_wednesday_start = "$row[12]"; - $Gsct_wednesday_stop = "$row[13]"; - $Gsct_thursday_start = "$row[14]"; - $Gsct_thursday_stop = "$row[15]"; - $Gsct_friday_start = "$row[16]"; - $Gsct_friday_stop = "$row[17]"; - $Gsct_saturday_start = "$row[18]"; - $Gsct_saturday_stop = "$row[19]"; - + $Gstate_call_time_id = $row[0]; + $Gstate_call_time_state = $row[1]; + $Gsct_default_start = $row[4]; + $Gsct_default_stop = $row[5]; + $Gsct_sunday_start = $row[6]; + $Gsct_sunday_stop = $row[7]; + $Gsct_monday_start = $row[8]; + $Gsct_monday_stop = $row[9]; + $Gsct_tuesday_start = $row[10]; + $Gsct_tuesday_stop = $row[11]; + $Gsct_wednesday_start = $row[12]; + $Gsct_wednesday_stop = $row[13]; + $Gsct_thursday_start = $row[14]; + $Gsct_thursday_stop = $row[15]; + $Gsct_friday_start = $row[16]; + $Gsct_friday_stop = $row[17]; + $Gsct_saturday_start = $row[18]; + $Gsct_saturday_stop = $row[19]; + $Sct_holidays = $row[20]; $ct_states .="'$Gstate_call_time_state',"; + ### BEGIN Check for outbound state holiday ### + $Sholiday_id = ''; + if ((strlen($Sct_holidays)>2) or ((strlen($holiday_id)>2) and (strlen($Sholiday_id)<2))) + { + # Apply state holiday + if (strlen($Sct_holidays)>2) + { + $Sct_holidaysSQL = preg_replace("/\|/", "','", "$Sct_holidays"); + $Sct_holidaysSQL = "'".$Sct_holidaysSQL."'"; + $stmt = "SELECT holiday_id,holiday_date,holiday_name,ct_default_start,ct_default_stop from vicidial_call_time_holidays where holiday_id IN($Sct_holidaysSQL) and holiday_status='ACTIVE' and holiday_date='$YMD' order by holiday_id;"; + $holidaytype = "STATE CALL TIME HOLIDAY FOUND! "; + } + # Apply call time wide holiday + elseif ((strlen($holiday_id)>2) and (strlen($Sholiday_id)<2)) + { + $stmt = "SELECT holiday_id,holiday_date,holiday_name,ct_default_start,ct_default_stop from vicidial_call_time_holidays where holiday_id='$holiday_id' and holiday_status='ACTIVE' and holiday_date='$YMD' order by holiday_id;"; + $holidaytype = "NO STATE HOLIDAY APPLYING CALL TIME HOLIDAY! "; + } + $rslt=mysql_to_mysqli($stmt, $link); + if ($DB) {echo "$stmt\n";} + $sthCrows=mysqli_num_rows($rslt); + if ($sthCrows > 0) + { + $aryC=mysqli_fetch_row($rslt); + $Sholiday_id = $aryC[0]; + $Sholiday_date = $aryC[1]; + $Sholiday_name = $aryC[2]; + if ( ($Gsct_default_start < $aryC[3]) && ($Gsct_default_stop > 0) ) {$Gsct_default_start = $aryC[3];} + if ( ($Gsct_default_stop > $aryC[4]) && ($Gsct_default_stop > 0) ) {$Gsct_default_stop = $aryC[4];} + if ( ($Gsct_sunday_start < $aryC[3]) && ($Gsct_sunday_stop > 0) ) {$Gsct_sunday_start = $aryC[3];} + if ( ($Gsct_sunday_stop > $aryC[4]) && ($Gsct_sunday_stop > 0) ) {$Gsct_sunday_stop = $aryC[4];} + if ( ($Gsct_monday_start < $aryC[3]) && ($Gsct_monday_stop > 0) ) {$Gsct_monday_start = $aryC[3];} + if ( ($Gsct_monday_stop > $aryC[4]) && ($Gsct_monday_stop > 0) ) {$Gsct_monday_stop = $aryC[4];} + if ( ($Gsct_tuesday_start < $aryC[3]) && ($Gsct_tuesday_stop > 0) ) {$Gsct_tuesday_start = $aryC[3];} + if ( ($Gsct_tuesday_stop > $aryC[4]) && ($Gsct_tuesday_stop > 0) ) {$Gsct_tuesday_stop = $aryC[4];} + if ( ($Gsct_wednesday_start < $aryC[3]) && ($Gsct_wednesday_stop > 0) ) {$Gsct_wednesday_start = $aryC[3];} + if ( ($Gsct_wednesday_stop > $aryC[4]) && ($Gsct_wednesday_stop > 0) ) {$Gsct_wednesday_stop = $aryC[4];} + if ( ($Gsct_thursday_start < $aryC[3]) && ($Gsct_thursday_stop > 0) ) {$Gsct_thursday_start = $aryC[3];} + if ( ($Gsct_thursday_stop > $aryC[4]) && ($Gsct_thursday_stop > 0) ) {$Gsct_thursday_stop = $aryC[4];} + if ( ($Gsct_friday_start < $aryC[3]) && ($Gsct_friday_stop > 0) ) {$Gsct_friday_start = $aryC[3];} + if ( ($Gsct_friday_stop > $aryC[4]) && ($Gsct_friday_stop > 0) ) {$Gsct_friday_stop = $aryC[4];} + if ( ($Gsct_saturday_start < $aryC[3]) && ($Gsct_saturday_stop > 0) ) {$Gsct_saturday_start = $aryC[3];} + if ( ($Gsct_saturday_stop > $aryC[4]) && ($Gsct_saturday_stop > 0) ) {$Gsct_saturday_stop = $aryC[4];} + if ($DB) {echo "$holidaytype |$Gstate_call_time_id|$Gstate_call_time_state|$Sholiday_id|$Sholiday_date|$Sholiday_name|$Gsct_default_start|$Gsct_default_stop|\n";} + } + } $r=0; $state_gmt=''; while($r < $g) @@ -34950,7 +35105,487 @@ if (isset($camp_lists)) $EXPsql = "and list_id NOT IN($expired_lists)"; - $stmt="SELECT count(*) FROM vicidial_list where called_since_last_reset='N' and status IN($Dsql) and list_id IN($camp_lists) and ($all_gmtSQL) $CCLsql $DLTsql $fSQL $EXPsql"; + ################################# + # Camp List + $stmt="SELECT list_id FROM vicidial_lists where list_id IN($camp_lists) and active='Y';"; + $rslt_list=mysql_to_mysqli($stmt, $link); + $camplists_ct = mysqli_num_rows($rslt_list); + if ($DB) {echo "$camplists_ct|$stmt\n";} + $k=0; + $camp_lists=''; + while ($camplists_ct > $k) + { + $rowA = mysqli_fetch_row($rslt_list); + $camp_lists .= "'$rowA[0]',"; + + ##### Get Call List call time settings + ##### BEGIN calculate what gmt_offset_now values are within the allowed local_call_time setting ### + $g=0; + $p='13'; + $GMT_gmt[0] = ''; + $GMT_hour[0] = ''; + $GMT_day[0] = ''; + $YMD = date("Y-m-d"); + while ($p > -13) + { + $pzone=3600 * $p; + $pmin=(gmdate("i", time() + $pzone)); + $phour=( (gmdate("G", time() + $pzone)) * 100); + $pday=gmdate("w", time() + $pzone); + $tz = sprintf("%.2f", $p); + $GMT_gmt[$g] = "$tz"; + $GMT_day[$g] = "$pday"; + $GMT_hour[$g] = ($phour + $pmin); + $p = ($p - 0.25); + $g++; + } + + # Set List ID Variable + $cur_list_id = $rowA[0]; + $list_local_call_time = ""; + + # Pull the call times for the lists + $stmt="SELECT local_call_time FROM vicidial_lists where list_id='$cur_list_id';"; + $rslt=mysql_to_mysqli($stmt, $link); + $rslt_ct = mysqli_num_rows($rslt); + if ($rslt_ct > 0) + { + #set Cur call_time + $row=mysqli_fetch_row($rslt); + $cur_call_time = $row[0]; + } + + ##### BEGIN local call time for list set different than campaign ##### + if ($cur_call_time != "campaign") + { + ##### BEGIN calculate what gmt_offset_now values are within the allowed local_call_time setting ### + $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,ct_holidays FROM vicidial_call_times where call_time_id='$cur_call_time';"; + if ($DB) {echo "$stmt\n";} + $rsltD=mysql_to_mysqli($stmt, $link); + $aryD=mysqli_fetch_row($rsltD); + $Gct_default_start = $aryD[3]; + $Gct_default_stop = $aryD[4]; + $Gct_sunday_start = $aryD[5]; + $Gct_sunday_stop = $aryD[6]; + $Gct_monday_start = $aryD[7]; + $Gct_monday_stop = $aryD[8]; + $Gct_tuesday_start = $aryD[9]; + $Gct_tuesday_stop = $aryD[10]; + $Gct_wednesday_start = $aryD[11]; + $Gct_wednesday_stop = $aryD[12]; + $Gct_thursday_start = $aryD[13]; + $Gct_thursday_stop = $aryD[14]; + $Gct_friday_start = $aryD[15]; + $Gct_friday_stop = $aryD[16]; + $Gct_saturday_start = $aryD[17]; + $Gct_saturday_stop = $aryD[18]; + $Gct_state_call_times = $aryD[19]; + $Gct_holidays = $aryD[20]; + + ### BEGIN Check for outbound holiday ### + $holiday_id = ''; + if (strlen($Gct_holidays)>2) + { + $Gct_holidaysSQL = preg_replace("/\|/", "','", "$Gct_holidays"); + $Gct_holidaysSQL = "'".$Gct_holidaysSQL."'"; + + $stmt = "SELECT holiday_id,holiday_date,holiday_name,ct_default_start,ct_default_stop from vicidial_call_time_holidays where holiday_id IN($Gct_holidaysSQL) and holiday_status='ACTIVE' and holiday_date='$YMD' order by holiday_id;"; + $rslt=mysql_to_mysqli($stmt, $link); + $sthCrows=mysqli_num_rows($rslt); + if ($sthCrows > 0) + { + $aryC=mysqli_fetch_row($rslt); + $holiday_id = $aryC[0]; + $holiday_date = $aryC[1]; + $holiday_name = $aryC[2]; + if ( ($Gct_default_start < $aryC[3]) && ($Gct_default_stop > 0) ) {$Gct_default_start = $aryC[3];} + if ( ($Gct_default_stop > $aryC[4]) && ($Gct_default_stop > 0) ) {$Gct_default_stop = $aryC[4];} + if ( ($Gct_sunday_start < $aryC[3]) && ($Gct_sunday_stop > 0) ) {$Gct_sunday_start = $aryC[3];} + if ( ($Gct_sunday_stop > $aryC[4]) && ($Gct_sunday_stop > 0) ) {$Gct_sunday_stop = $aryC[4];} + if ( ($Gct_monday_start < $aryC[3]) && ($Gct_monday_stop > 0) ) {$Gct_monday_start = $aryC[3];} + if ( ($Gct_monday_stop > $aryC[4]) && ($Gct_monday_stop > 0) ) {$Gct_monday_stop = $aryC[4];} + if ( ($Gct_tuesday_start < $aryC[3]) && ($Gct_tuesday_stop > 0) ) {$Gct_tuesday_start = $aryC[3];} + if ( ($Gct_tuesday_stop > $aryC[4]) && ($Gct_tuesday_stop > 0) ) {$Gct_tuesday_stop = $aryC[4];} + if ( ($Gct_wednesday_start < $aryC[3]) && ($Gct_wednesday_stop > 0) ) {$Gct_wednesday_start = $aryC[3];} + if ( ($Gct_wednesday_stop > $aryC[4]) && ($Gct_wednesday_stop > 0) ) {$Gct_wednesday_stop = $aryC[4];} + if ( ($Gct_thursday_start < $aryC[3]) && ($Gct_thursday_stop > 0) ) {$Gct_thursday_start = $aryC[3];} + if ( ($Gct_thursday_stop > $aryC[4]) && ($Gct_thursday_stop > 0) ) {$Gct_thursday_stop = $aryC[4];} + if ( ($Gct_friday_start < $aryC[3]) && ($Gct_friday_stop > 0) ) {$Gct_friday_start = $aryC[3];} + if ( ($Gct_friday_stop > $aryC[4]) && ($Gct_friday_stop > 0) ) {$Gct_friday_stop = $aryC[4];} + if ( ($Gct_saturday_start < $aryC[3]) && ($Gct_saturday_stop > 0) ) {$Gct_saturday_start = $aryC[3];} + if ( ($Gct_saturday_stop > $aryC[4]) && ($Gct_saturday_stop > 0) ) {$Gct_saturday_stop = $aryC[4];} + if ($DB) {echo "LIST CALL TIME HOLIDAY FOUND! $local_call_time|$holiday_id|$holiday_date|$holiday_name|$Gct_default_start|$Gct_default_stop|\n";} + } + } + ### END Check for outbound holiday ### + + $ct_states = ''; + $ct_state_gmt_SQL = ''; + $ct_srs=0; + $b=0; + if (strlen($Gct_state_call_times)>2) + { + $state_rules = explode('|',$Gct_state_call_times); + $ct_srs = ((count($state_rules)) - 2); + } + while($ct_srs >= $b) + { + if (strlen($state_rules[$b])>1) + { + $stmt = "SELECT state_call_time_id,state_call_time_state,state_call_time_name,state_call_time_comments,sct_default_start,sct_default_stop,sct_sunday_start,sct_sunday_stop,sct_monday_start,sct_monday_stop,sct_tuesday_start,sct_tuesday_stop,sct_wednesday_start,sct_wednesday_stop,sct_thursday_start,sct_thursday_stop,sct_friday_start,sct_friday_stop,sct_saturday_start,sct_saturday_stop,ct_holidays from vicidial_state_call_times where state_call_time_id='$state_rules[$b]';"; + $rslt=mysql_to_mysqli($stmt, $link); + $sthCrows=mysqli_num_rows($rslt); + if ($sthCrows > 0) + { + $aryC=mysqli_fetch_row($rslt); + $Gstate_call_time_id = $aryC[0]; + $Gstate_call_time_state = $aryC[1]; + $Gsct_default_start = $aryC[4]; + $Gsct_default_stop = $aryC[5]; + $Gsct_sunday_start = $aryC[6]; + $Gsct_sunday_stop = $aryC[7]; + $Gsct_monday_start = $aryC[8]; + $Gsct_monday_stop = $aryC[9]; + $Gsct_tuesday_start = $aryC[10]; + $Gsct_tuesday_stop = $aryC[11]; + $Gsct_wednesday_start = $aryC[12]; + $Gsct_wednesday_stop = $aryC[13]; + $Gsct_thursday_start = $aryC[14]; + $Gsct_thursday_stop = $aryC[15]; + $Gsct_friday_start = $aryC[16]; + $Gsct_friday_stop = $aryC[17]; + $Gsct_saturday_start = $aryC[18]; + $Gsct_saturday_stop = $aryC[19]; + $Sct_holidays = $aryC[20]; + $ct_states .="'$Gstate_call_time_state',"; + } + + ### BEGIN Check for outbound state holiday ### + $Sholiday_id = ''; + if ((strlen($Sct_holidays)>2) or ((strlen($holiday_id)>2) and (strlen($Sholiday_id)<2))) + { + #Apply state holiday + if (strlen($Sct_holidays)>2) + { + $Sct_holidaysSQL = preg_replace("/\|/", "','", "$Sct_holidays"); + $Sct_holidaysSQL = "'".$Sct_holidaysSQL."'"; + $stmt = "SELECT holiday_id,holiday_date,holiday_name,ct_default_start,ct_default_stop from vicidial_call_time_holidays where holiday_id IN($Sct_holidaysSQL) and holiday_status='ACTIVE' and holiday_date='$YMD' order by holiday_id;"; + $holidaytype = "LIST STATE CALL TIME HOLIDAY FOUND! "; + } + #Apply call time wide holiday + elseif ((strlen($holiday_id)>2) and (strlen($Sholiday_id)<2)) + { + $stmt = "SELECT holiday_id,holiday_date,holiday_name,ct_default_start,ct_default_stop from vicidial_call_time_holidays where holiday_id='$holiday_id' and holiday_status='ACTIVE' and holiday_date='$YMD' order by holiday_id;"; + $holidaytype = "LIST NO STATE HOLIDAY APPLYING CALL TIME HOLIDAY! "; + } + $rslt=mysql_to_mysqli($stmt, $link); + if ($DB) {echo "$stmt\n";} + $sthCrows=mysqli_num_rows($rslt); + if ($sthCrows > 0) + { + $aryC=mysqli_fetch_row($rslt); + $Sholiday_id = $aryC[0]; + $Sholiday_date = $aryC[1]; + $Sholiday_name = $aryC[2]; + if ( ($Gsct_default_start < $aryC[3]) && ($Gsct_default_stop > 0) ) {$Gsct_default_start = $aryC[3];} + if ( ($Gsct_default_stop > $aryC[4]) && ($Gsct_default_stop > 0) ) {$Gsct_default_stop = $aryC[4];} + if ( ($Gsct_sunday_start < $aryC[3]) && ($Gsct_sunday_stop > 0) ) {$Gsct_sunday_start = $aryC[3];} + if ( ($Gsct_sunday_stop > $aryC[4]) && ($Gsct_sunday_stop > 0) ) {$Gsct_sunday_stop = $aryC[4];} + if ( ($Gsct_monday_start < $aryC[3]) && ($Gsct_monday_stop > 0) ) {$Gsct_monday_start = $aryC[3];} + if ( ($Gsct_monday_stop > $aryC[4]) && ($Gsct_monday_stop > 0) ) {$Gsct_monday_stop = $aryC[4];} + if ( ($Gsct_tuesday_start < $aryC[3]) && ($Gsct_tuesday_stop > 0) ) {$Gsct_tuesday_start = $aryC[3];} + if ( ($Gsct_tuesday_stop > $aryC[4]) && ($Gsct_tuesday_stop > 0) ) {$Gsct_tuesday_stop = $aryC[4];} + if ( ($Gsct_wednesday_start < $aryC[3]) && ($Gsct_wednesday_stop > 0) ) {$Gsct_wednesday_start = $aryC[3];} + if ( ($Gsct_wednesday_stop > $aryC[4]) && ($Gsct_wednesday_stop > 0) ) {$Gsct_wednesday_stop = $aryC[4];} + if ( ($Gsct_thursday_start < $aryC[3]) && ($Gsct_thursday_stop > 0) ) {$Gsct_thursday_start = $aryC[3];} + if ( ($Gsct_thursday_stop > $aryC[4]) && ($Gsct_thursday_stop > 0) ) {$Gsct_thursday_stop = $aryC[4];} + if ( ($Gsct_friday_start < $aryC[3]) && ($Gsct_friday_stop > 0) ) {$Gsct_friday_start = $aryC[3];} + if ( ($Gsct_friday_stop > $aryC[4]) && ($Gsct_friday_stop > 0) ) {$Gsct_friday_stop = $aryC[4];} + if ( ($Gsct_saturday_start < $aryC[3]) && ($Gsct_saturday_stop > 0) ) {$Gsct_saturday_start = $aryC[3];} + if ( ($Gsct_saturday_stop > $aryC[4]) && ($Gsct_saturday_stop > 0) ) {$Gsct_saturday_stop = $aryC[4];} + if ($DB) {echo "$holidaytype |$Gstate_call_time_id|$Gstate_call_time_state|$Sholiday_id|$Sholiday_date|$Sholiday_name|$Gsct_default_start|$Gsct_default_stop|\n";} + } + } + ### END Check for outbound state holiday ### + + $r=0; + $state_gmt=''; + $del_state_gmt=''; + while($r < $g) + { + if ($GMT_day[$r]==0) #### Sunday local time + { + if (($Gsct_sunday_start==0) && ($Gsct_sunday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) && ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_sunday_start) && ($GMT_hour[$r]<$Gsct_sunday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==1) #### Monday local time + { + if (($Gsct_monday_start==0) && ($Gsct_monday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) && ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_monday_start) && ($GMT_hour[$r]<$Gsct_monday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==2) #### Tuesday local time + { + if (($Gsct_tuesday_start==0) && ($Gsct_tuesday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) && ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_tuesday_start) && ($GMT_hour[$r]<$Gsct_tuesday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==3) #### Wednesday local time + { + if (($Gsct_wednesday_start==0) && ($Gsct_wednesday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) && ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_wednesday_start) && ($GMT_hour[$r]<$Gsct_wednesday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==4) #### Thursday local time + { + if (($Gsct_thursday_start==0) && ($Gsct_thursday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) && ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_thursday_start) && ($GMT_hour[$r]<$Gsct_thursday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==5) #### Friday local time + { + if (($Gsct_friday_start==0) && ($Gsct_friday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) && ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_friday_start) && ($GMT_hour[$r]<$Gsct_friday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==6) #### Saturday local time + { + if (($Gsct_saturday_start==0) && ($Gsct_saturday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) && ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_saturday_start) && ($GMT_hour[$r]<$Gsct_saturday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + $r++; + } + $state_gmt = "$state_gmt'99'"; + + $del_list_state_gmt_SQL .= "or (List_id=\"$cur_list_id\" and state='$Gstate_call_time_state' and gmt_offset_now NOT IN($state_gmt)) "; + $list_state_gmt_SQL .= "or (List_id=\"$cur_list_id\" and state='$Gstate_call_time_state' and gmt_offset_now IN($state_gmt)) "; + } + + $b++; + } + if (strlen($ct_states)>2) + { + $ct_states = preg_replace("/,$/i",'',$ct_states); + $ct_statesSQL = "and state NOT IN($ct_states)"; + } + else + { + $ct_statesSQL = ""; + } + + $r=0; + $dgA=0; + $list_default_gmt=''; + while($r < $g) + { + if ($DB > 0) + {echo "LCT_gmt: $r|$GMT_day[$r]|$GMT_gmt[$r]|$Gct_sunday_start|$Gct_sunday_stop|$GMT_hour[$r]|$Gct_default_start|$Gct_default_stop\n";} + + if ($GMT_day[$r]==0) #### Sunday local time + { + if (($Gct_sunday_start==0) && ($Gct_sunday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) && ($GMT_hour[$r]<$Gct_default_stop) ) + {} + else + {$list_default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_sunday_start) && ($GMT_hour[$r]<$Gct_sunday_stop) ) + {} + else + {$list_default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==1) #### Monday local time + { + if (($Gct_monday_start==0) && ($Gct_monday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) && ($GMT_hour[$r]<$Gct_default_stop) ) + {} + else + {$list_default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_monday_start) && ($GMT_hour[$r]<$Gct_monday_stop) ) + {} + else + {$list_default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==2) #### Tuesday local time + { + if (($Gct_tuesday_start==0) && ($Gct_tuesday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) && ($GMT_hour[$r]<$Gct_default_stop) ) + {} + else + {$list_default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_tuesday_start) && ($GMT_hour[$r]<$Gct_tuesday_stop) ) + {} + else + {$list_default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==3) #### Wednesday local time + { + if (($Gct_wednesday_start==0) && ($Gct_wednesday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) && ($GMT_hour[$r]<$Gct_default_stop) ) + {} + else + {$list_default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_wednesday_start) && ($GMT_hour[$r]<$Gct_wednesday_stop) ) + {} + else + {$list_default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==4) #### Thursday local time + { + if (($Gct_thursday_start==0) && ($Gct_thursday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) && ($GMT_hour[$r]<$Gct_default_stop) ) + {} + else + {$list_default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_thursday_start) && ($GMT_hour[$r]<$Gct_thursday_stop) ) + {} + else + {$list_default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==5) #### Friday local time + { + if (($Gct_friday_start==0) && ($Gct_friday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) && ($GMT_hour[$r]<$Gct_default_stop) ) + {} + else + {$list_default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_friday_start) && ($GMT_hour[$r]<$Gct_friday_stop) ) + {} + else + {$list_default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==6) #### Saturday local time + { + if (($Gct_saturday_start==0) && ($Gct_saturday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) && ($GMT_hour[$r]<$Gct_default_stop) ) + {} + else + {$list_default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_saturday_start) && ($GMT_hour[$r]<$Gct_saturday_stop) ) + {} + else + {$list_default_gmt.="'$GMT_gmt[$r]',";} + } + } + $r++; + } + + $list_default_gmt = "$list_default_gmt'99'"; + if ($k == 0) + { + $list_id_sql = "((list_id=\"$cur_list_id\" and gmt_offset_now NOT IN($list_default_gmt) $ct_statesSQL) $list_state_gmt_SQL)"; + } + else + { + $list_id_sql .= " or ((list_id=\"$cur_list_id\" and gmt_offset_now NOT IN($list_default_gmt) $ct_statesSQL) $list_state_gmt_SQL)"; + } + } + ##### END local call time for list set different than campaign ##### + + else + { + if ($k == 0) + { + $list_id_sql = "(list_id=\"$cur_list_id\")"; + } + else + { + $list_id_sql .= " or (list_id=\"$cur_list_id\")"; + } + } + + $k++; + } + $camp_lists = preg_replace("/.$/i","",$camp_lists); + if (strlen($camp_lists) < 4) {$camp_lists="''";} + if (strlen($list_id_sql) < 4) {$list_id_sql="list_id=''";} + + + $stmt="SELECT count(*) FROM vicidial_list where called_since_last_reset='N' and status IN($Dsql) and list_id IN($camp_lists) and ($list_id_sql) and ($all_gmtSQL) $CCLsql $DLTsql $fSQL $EXPsql"; #$DB=1; if ($DB) {echo "$stmt\n";} $rslt=mysql_to_mysqli($stmt, $link); diff --git a/www/vicidial/help.php b/www/vicidial/help.php index c056da17..0748f7e9 100644 --- a/www/vicidial/help.php +++ b/www/vicidial/help.php @@ -33,6 +33,7 @@ # 141212-0945 - Added user_choose_language, selected_language and language_method # 141230-1503 - Added code for on-the-fly language translations display # 150107-1954 - Added users-ignore_group_on_search +# 150111-1542 - Added lists-local_call_time and manual_dial_search_filter # require("dbconnect_mysqli.php"); @@ -1195,7 +1196,7 @@ if ($SSoutbound_autodial_active > 0)

- - + -
@@ -1552,6 +1553,11 @@ if ($SSoutbound_autodial_active > 0)
- +
+
+
+ - +

@@ -1858,6 +1864,11 @@ if ($SSqc_features_active > 0)
- +
+
+
+ - +