diff --git a/UPGRADE b/UPGRADE index 019edd53..3e77ae34 100644 --- a/UPGRADE +++ b/UPGRADE @@ -134,6 +134,34 @@ NOTE: Upgrading from 1.1.12-3 to 2.0.1 is at the bottom 35. Added a Re-Queue Call button to send the current call back to an AGENTDIRECT in-group for the agent to take later +36. Added rank and owner to the vicidial_list table. the CLI lead loader has + a new stdrankowner format to add these fields in lead files. Also, added + these fields to the web-based lead loader formats and field chooser. + Related to this, RANK and OWNER are now lead order options in the + campaign screen. + +37. Added automatic list reset option to List Modification screen. You can enter + multiple times, and the leads in the list will be reset at those times. + +38. Added no-hopper dialing option for MANUAL and INBOUND_MAN campaigns. If This + is enabled, the hopper will not run for this campaign. This option is + only available when the dial method is set to MANUAL or INBOUND_MAN. It + is recommended that you do not enable this option if you have a very + large lead database, over 100,000 leads. With No Hopper Dialing, the + following features do not work: lead recycling, auto-alt-dialing, list + mix, list ordering with Xth NEW. If you want to use Owner Only Dialing + you must have No Hopper Dialing enabled. Default is N for disabled. + +39. Added lead owner option to restrict dialing within a list to the owner of a + lead only. If This is enabled, the agent will only receive leads that + they are within the ownership parameters for. If this is set to USER + then the agent must be the user defined in the database as the owner of + this lead. If this is set to TERRITORY then the owner of the lead must + match the territory listed in the User Modification screen for this + agent. If this is set to USER_GROUP then the owner of the lead must + match the user group that the agent is a member of. For this feature to + work the dial method must be set to MANUAL or INBOUND_MAN and No Hopper + Dialing must be enabled. Default is NONE for disabled. diff --git a/agi/agi-VDAD_ALL_inbound.agi b/agi/agi-VDAD_ALL_inbound.agi index 88e0977d..be2565e3 100644 --- a/agi/agi-VDAD_ALL_inbound.agi +++ b/agi/agi-VDAD_ALL_inbound.agi @@ -1334,7 +1334,13 @@ if ( ($agent_search_method =~ /^SO|^LO/) && ($skipLOSO < 1) ) $qp_groupWAIT .= "closer_campaigns NOT LIKE \"% $aryA[0] %\" "; $dbc++; } - chop($qp_groupWAIT_aco); + if (length($qp_groupWAIT_aco)>2) + {chop($qp_groupWAIT_aco);} + else + { + $qp_groupWAIT_aco="''"; + $qp_groupWAIT = "closer_campaigns != ''"; + } $qp_groupWAIT_SQL = "and ($qp_groupWAIT)"; $qp_groupWAIT_aco_SQL = "and vicidial_live_inbound_agents.group_id NOT IN($qp_groupWAIT_aco)"; @@ -1674,7 +1680,13 @@ if ($agent_search_method =~ /^LO|^LB/) $qp_groupWAIT .= "closer_campaigns NOT LIKE \"% $aryA[0] %\" "; $dbc++; } - chop($qp_groupWAIT_aco); + if (length($qp_groupWAIT_aco)>2) + {chop($qp_groupWAIT_aco);} + else + { + $qp_groupWAIT_aco="''"; + $qp_groupWAIT = "closer_campaigns != ''"; + } if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;} diff --git a/agi/agi-VDAD_ALL_outbound.agi b/agi/agi-VDAD_ALL_outbound.agi index 1b9b7dd3..88529c6a 100644 --- a/agi/agi-VDAD_ALL_outbound.agi +++ b/agi/agi-VDAD_ALL_outbound.agi @@ -65,6 +65,7 @@ # 90628-1138 - Added more variable options for Cepstral TTS generation # 90630-2250 - Added more Sangoma CDP statuses # 90702-2240 - Added option to send to remote agent as phone*vendor_id +# 90721-1137 - Added rank and owner as vicidial_list fields # $script = 'agi-VDAD_ALL_outbound.agi'; @@ -462,7 +463,7 @@ if ($affected_rows > 0) ### if there are TTS audio files run this if ($t > 0) { - $stmtA = "SELECT lead_id,entry_date,modify_date,status,user,vendor_lead_code,source_id,list_id,phone_number,title,first_name,middle_initial,last_name,address1,address2,address3,city,state,province,postal_code,country_code,gender,date_of_birth,alt_phone,email,security_phrase,comments,called_count,last_local_call_time FROM vicidial_list where lead_id='$CIDlead_id';"; + $stmtA = "SELECT lead_id,entry_date,modify_date,status,user,vendor_lead_code,source_id,list_id,phone_number,title,first_name,middle_initial,last_name,address1,address2,address3,city,state,province,postal_code,country_code,gender,date_of_birth,alt_phone,email,security_phrase,comments,called_count,last_local_call_time,rank,owner FROM vicidial_list where lead_id='$CIDlead_id';"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthArows=$sthA->rows; @@ -499,6 +500,8 @@ if ($affected_rows > 0) $TTS_comments = $aryA[26]; $TTS_called_count = $aryA[27]; $TTS_last_local_call_time = $aryA[28]; + $TTS_rank = $aryA[29]; + $TTS_owner = $aryA[30]; } $sthA->finish(); @@ -545,6 +548,8 @@ if ($affected_rows > 0) $TTS_text[$s] =~ s/--A--comments--B--/$TTS_comments/gi; $TTS_text[$s] =~ s/--A--called_count--B--/$TTS_called_count/gi; $TTS_text[$s] =~ s/--A--last_local_call_time--B--/$TTS_last_local_call_time/gi; + $TTS_text[$s] =~ s/--A--rank--B--/$TTS_rank/gi; + $TTS_text[$s] =~ s/--A--owner--B--/$TTS_owner/gi; $TTS_text[$s] =~ s/[^,\.\<\>\'\/\=\_ 0-9a-zA-Z]//gi; $TTS_textRAW[$s] = $TTS_text[$s]; $TTS_text[$s] =~ s/ /\\ /gi; diff --git a/bin/ADMIN_keepalive_ALL.pl b/bin/ADMIN_keepalive_ALL.pl index e3829495..bd7fd1f5 100644 --- a/bin/ADMIN_keepalive_ALL.pl +++ b/bin/ADMIN_keepalive_ALL.pl @@ -5,7 +5,13 @@ # Designed to keep the astGUIclient processes alive and check every minute # Replaces all other ADMIN_keepalive scripts # Uses /etc/astguiclient.conf file to know which processes to keepalive -# Also, this script generates Asterisk conf files and reloads Asterisk +# +# Other functions of this program: +# - Launches the timeclock auto-logout process +# - Generates Asterisk conf files and reloads Asterisk +# - Synchronizes the audio store files +# - Runs trigger processes at defined times +# - Auto reset lists at defined times # # Copyright (C) 2009 Matt Florell LICENSE: AGPLv2 # @@ -30,12 +36,26 @@ # 90622-2146 - Added 83047777777777 for dynamic agent alert extension # 90630-2259 - Added vicidial_process_triggers functionality # 90713-0140 - Changed direct dial phone extensions to failover to voicemail forwarder +# 90722-1102 - Added list reset by time option # $DB=0; # Debug flag $MT[0]=''; $MT[1]=''; @psline=@MT; +($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); +$year = ($year + 1900); +$mon++; +$wtoday = $wday; +if ($mon < 10) {$mon = "0$mon";} +if ($mday < 10) {$mday = "0$mday";} +if ($hour < 10) {$Fhour = "0$hour";} +if ($min < 10) {$min = "0$min";} +if ($sec < 10) {$sec = "0$sec";} +$now_date = "$year-$mon-$mday $hour:$min:$sec"; +$reset_test = "$hour$min"; + + ### begin parsing run-time options ### if (length($ARGV[0])>1) { @@ -460,7 +480,6 @@ if ($timeclock_auto_logout > 0) - ################################################################################ ##### START Creation of auto-generated conf files ################################################################################ @@ -1503,6 +1522,52 @@ if ($sthBrows > 0) +################################################################################ +##### BEGIN reset lists +################################################################################ +$stmtA = "SELECT list_id FROM vicidial_lists where active='Y' and reset_time LIKE \"%$reset_test%\";"; +$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; +$sthA->execute or die "executing: $stmtA ", $dbhA->errstr; +$sthBrows=$sthA->rows; +$i=0; +while ($sthBrows > $i) + { + @aryA = $sthA->fetchrow_array; + $list_id[$i] = "$aryA[0]"; + $i++; + } +$sthA->finish(); + +if ($DBX) {print "RESET LIST: $i|$reset_test";} + +$i=0; +while ($sthBrows > $i) + { + $stmtA="UPDATE vicidial_list set called_since_last_reset='N' where list_id='$list_id[$i]';"; + $affected_rows = $dbhA->do($stmtA); + + $SQL_log = "$stmtA|"; + $SQL_log =~ s/;|\\|\'|\"//gi; + + if ($DB) {print "DONE\n";} + if ($DB) {print "$trigger_results\n";} + + $stmtA="INSERT INTO vicidial_admin_log set event_date='$now_date', user='VDAD', ip_address='1.1.1.1', event_section='LISTS', event_type='RESET', record_id='$list_id[$i]', event_code='ADMIN RESET LIST', event_sql=\"$SQL_log\", event_notes='$affected_rows leads reset';"; + $Iaffected_rows = $dbhA->do($stmtA); + if ($DB) {print "FINISHED: $affected_rows|$Iaffected_rows|$stmtA";} + + $i++; + } +################################################################################ +##### END reset lists +################################################################################ + + + + + + + if ($DB) {print "DONE\n";} exit; diff --git a/bin/AST_VDhopper.pl b/bin/AST_VDhopper.pl index e71e37cf..7b9f53b2 100644 --- a/bin/AST_VDhopper.pl +++ b/bin/AST_VDhopper.pl @@ -55,6 +55,7 @@ # 90601-2111 - Added allow_inactive_list_leads to allow for inactive lists while in List Mix mode # 90603-1157 - Fixed rare bug in list mix where statuses field do not end with - # 90608-1201 - Added Drop Lockout Time Campaign setting option +# 90723-0842 - Added no hopper dial option to clear hopper leads # # constants @@ -84,7 +85,7 @@ $now_date = "$year-$mon-$mday $hour:$min:$sec"; $VDL_date = "$year-$mon-$mday 00:00:01"; ### get date-time of one hour ago ### - $VDL_hour = ($secX - (60 * 60)); +$VDL_hour = ($secX - (60 * 60)); ($Vsec,$Vmin,$Vhour,$Vmday,$Vmon,$Vyear,$Vwday,$Vyday,$Visdst) = localtime($VDL_hour); $Vyear = ($Vyear + 1900); $Vmon++; @@ -93,7 +94,7 @@ if ($Vmday < 10) {$Vmday = "0$Vmday";} $VDL_hour = "$Vyear-$Vmon-$Vmday $Vhour:$Vmin:$Vsec"; ### get date-time of half hour ago ### - $VDL_halfhour = ($secX - (30 * 60)); +$VDL_halfhour = ($secX - (30 * 60)); ($Vsec,$Vmin,$Vhour,$Vmday,$Vmon,$Vyear,$Vwday,$Vyday,$Visdst) = localtime($VDL_halfhour); $Vyear = ($Vyear + 1900); $Vmon++; @@ -102,7 +103,7 @@ if ($Vmday < 10) {$Vmday = "0$Vmday";} $VDL_halfhour = "$Vyear-$Vmon-$Vmday $Vhour:$Vmin:$Vsec"; ### get date-time of five minutes ago ### - $VDL_five = ($secX - (5 * 60)); +$VDL_five = ($secX - (5 * 60)); ($Vsec,$Vmin,$Vhour,$Vmday,$Vmon,$Vyear,$Vwday,$Vyday,$Visdst) = localtime($VDL_five); $Vyear = ($Vyear + 1900); $Vmon++; @@ -111,7 +112,7 @@ if ($Vmday < 10) {$Vmday = "0$Vmday";} $VDL_five = "$Vyear-$Vmon-$Vmday $Vhour:$Vmin:$Vsec"; ### get date-time of one minute ago ### - $VDL_one = ($secX - (1 * 60)); +$VDL_one = ($secX - (1 * 60)); ($Vsec,$Vmin,$Vhour,$Vmday,$Vmon,$Vyear,$Vwday,$Vyday,$Visdst) = localtime($VDL_one); $Vyear = ($Vyear + 1900); $Vmon++; @@ -121,90 +122,90 @@ $VDL_one = "$Vyear-$Vmon-$Vmday $Vhour:$Vmin:$Vsec"; ### begin parsing run-time options ### if (length($ARGV[0])>1) -{ + { $i=0; $allow_inactive_list_leads=0; - while ($#ARGV >= $i) - { - $args = "$args $ARGV[$i]"; - $i++; - } + while ($#ARGV >= $i) + { + $args = "$args $ARGV[$i]"; + $i++; + } if ($args =~ /--help/i) - { - print "allowed run time options(must stay in this order):\n"; - print " [--debug] = debug\n"; - print " [--debugX] = super debug\n"; - print " [--dbgmt] = show GMT offset of records as they are inserted into hopper\n"; - print " [--dbdetail] = additional level of logging the leads that are inserted into the hopper\n"; - print " [--allow-inactive-list-leads] = do not delete inactive list leads\n"; - print " [-t] = test\n"; - print " [--level=XXX] = force a hopper_level of XXX\n"; - print " [--campaign=XXX] = run for campaign XXX only\n"; - print "\n"; - exit; - } - else - { - if ($args =~ /--campaign=/i) { - # print "\n|$ARGS|\n\n"; - @data_in = split(/--campaign=/,$args); + print "allowed run time options(must stay in this order):\n"; + print " [--debug] = debug\n"; + print " [--debugX] = super debug\n"; + print " [--dbgmt] = show GMT offset of records as they are inserted into hopper\n"; + print " [--dbdetail] = additional level of logging the leads that are inserted into the hopper\n"; + print " [--allow-inactive-list-leads] = do not delete inactive list leads\n"; + print " [-t] = test\n"; + print " [--level=XXX] = force a hopper_level of XXX\n"; + print " [--campaign=XXX] = run for campaign XXX only\n"; + print "\n"; + exit; + } + else + { + if ($args =~ /--campaign=/i) + { + # print "\n|$ARGS|\n\n"; + @data_in = split(/--campaign=/,$args); $CLIcampaign = $data_in[1]; $CLIcampaign =~ s/ .*$//gi; - } + } else {$CLIcampaign = '';} if ($args =~ /--level=/i) - { - @data_in = split(/--level=/,$args); + { + @data_in = split(/--level=/,$args); $CLIlevel = $data_in[1]; $CLIlevel =~ s/ .*$//gi; $CLIlevel =~ s/\D//gi; - print "\n-----HOPPER LEVEL OVERRIDE: $CLIlevel -----\n\n"; - } + print "\n-----HOPPER LEVEL OVERRIDE: $CLIlevel -----\n\n"; + } else {$CLIlevel = '';} if ($args =~ /--debug/i) - { - $DB=1; - print "\n----- DEBUG -----\n\n"; - } + { + $DB=1; + print "\n----- DEBUG -----\n\n"; + } if ($args =~ /--debugX/i) - { - $DBX=1; - print "\n----- SUPER DEBUG -----\n\n"; - } + { + $DBX=1; + print "\n----- SUPER DEBUG -----\n\n"; + } if ($args =~ /--dbgmt/i) - { - $DB_show_offset=1; - print "\n-----DEBUG GMT -----\n\n"; - } + { + $DB_show_offset=1; + print "\n-----DEBUG GMT -----\n\n"; + } if ($args =~ /--dbdetail/i) - { - $DB_detail=1; -# print "\n-----DEBUG DETAIL -----\n\n"; - } + { + $DB_detail=1; + # print "\n-----DEBUG DETAIL -----\n\n"; + } if ($args =~ /--allow-inactive-list-leads/i) - { - $allow_inactive_list_leads=1; -# print "\n-----DEBUG DETAIL -----\n\n"; - } + { + $allow_inactive_list_leads=1; + # print "\n-----DEBUG DETAIL -----\n\n"; + } if ($args =~ /-t/i) - { - $T=1; $TEST=1; - print "\n-----TESTING -----\n\n"; - } + { + $T=1; $TEST=1; + print "\n-----TESTING -----\n\n"; + } if ($args =~ /--wipe-hopper-clean/i) - { - $wipe_hopper_clean=1; + { + $wipe_hopper_clean=1; + } } } -} else -{ -print "no command line options set\n"; -} + { + print "no command line options set\n"; + } # default path to astguiclient configuration file: $PATHconf = '/etc/astguiclient.conf'; @@ -255,54 +256,54 @@ $dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VA ### Grab Server values from the database - $stmtA = "SELECT vd_server_logs,local_gmt FROM servers where server_ip = '$VARserver_ip';"; - $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; - $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; - $sthArows=$sthA->rows; - if ($sthArows==0) {die "Server IP $VARserver_ip does not have an entry in the servers table\n\n";} - if ($sthArows > 0) - { - @aryA = $sthA->fetchrow_array; - $DBvd_server_logs = "$aryA[0]"; - $DBSERVER_GMT = "$aryA[1]"; - if ($DBvd_server_logs =~ /Y/) {$SYSLOG = '1';} - else {$SYSLOG = '0';} - if (length($DBSERVER_GMT)>0) {$SERVER_GMT = $DBSERVER_GMT;} - } - $sthA->finish(); +$stmtA = "SELECT vd_server_logs,local_gmt FROM servers where server_ip = '$VARserver_ip';"; +$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; +$sthA->execute or die "executing: $stmtA ", $dbhA->errstr; +$sthArows=$sthA->rows; +if ($sthArows==0) {die "Server IP $VARserver_ip does not have an entry in the servers table\n\n";} +if ($sthArows > 0) + { + @aryA = $sthA->fetchrow_array; + $DBvd_server_logs = "$aryA[0]"; + $DBSERVER_GMT = "$aryA[1]"; + if ($DBvd_server_logs =~ /Y/) {$SYSLOG = '1';} + else {$SYSLOG = '0';} + if (length($DBSERVER_GMT)>0) {$SERVER_GMT = $DBSERVER_GMT;} + } +$sthA->finish(); $secX = time(); - ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($secX); - $LOCAL_GMT_OFF = $SERVER_GMT; - $LOCAL_GMT_OFF_STD = $SERVER_GMT; - if ($isdst) {$LOCAL_GMT_OFF++;} +($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($secX); +$LOCAL_GMT_OFF = $SERVER_GMT; +$LOCAL_GMT_OFF_STD = $SERVER_GMT; +if ($isdst) {$LOCAL_GMT_OFF++;} $GMT_now = ($secX - ($LOCAL_GMT_OFF * 3600)); - ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($GMT_now); - $mon++; - $year = ($year + 1900); - if ($mon < 10) {$mon = "0$mon";} - if ($mday < 10) {$mday = "0$mday";} - if ($hour < 10) {$hour = "0$hour";} - if ($min < 10) {$min = "0$min";} - if ($sec < 10) {$sec = "0$sec";} +($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($GMT_now); +$mon++; +$year = ($year + 1900); +if ($mon < 10) {$mon = "0$mon";} +if ($mday < 10) {$mday = "0$mday";} +if ($hour < 10) {$hour = "0$hour";} +if ($min < 10) {$min = "0$min";} +if ($sec < 10) {$sec = "0$sec";} - if ($DB) {print "TIME DEBUG: $LOCAL_GMT_OFF_STD|$LOCAL_GMT_OFF|$isdst| GMT: $hour:$min\n";} +if ($DB) {print "TIME DEBUG: $LOCAL_GMT_OFF_STD|$LOCAL_GMT_OFF|$isdst| GMT: $hour:$min\n";} if ($wipe_hopper_clean) { $stmtA = "DELETE from $vicidial_hopper;"; $affected_rows = $dbhA->do($stmtA); if ($DB) {print "Hopper Wiped Clean: $affected_rows\n";} - $event_string = "|HOPPER WIPE CLEAN|"; - &event_logger; + $event_string = "|HOPPER WIPE CLEAN|"; + &event_logger; exit; } ### Delete leads from inactive lists if there are any -$stmtA = "SELECT * FROM vicidial_lists where active='N';"; +$stmtA = "SELECT list_id FROM vicidial_lists where active='N';"; if ($DB) {print $stmtA;} $inactive_lists=''; $inactive_lists_count=0; @@ -338,7 +339,7 @@ $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; @aryA = $sthA->fetchrow_array; $CBHOLD_count = $aryA[0]; - if ($DB) {print "CALLBACK HOLD: $CBHOLD_count|$stmtA|\n";} +if ($DB) {print "CALLBACK HOLD: $CBHOLD_count|$stmtA|\n";} $sthA->finish(); if ($CBHOLD_count > 0) @@ -375,24 +376,23 @@ if ($CBHOLD_count > 0) $stmtA = "UPDATE vicidial_callbacks set status='LIVE' where lead_id IN($update_leads) and status NOT IN('INACTIVE','DEAD','ARCHIVE');"; $affected_rows = $dbhA->do($stmtA); if ($DB) {print "Scheduled Callbacks Activated: $affected_rows\n";} - $event_string = "|CALLBACKS CB ACT |$affected_rows|"; - &event_logger; - + $event_string = "|CALLBACKS CB ACT |$affected_rows|"; + &event_logger; } ### INSERT ANYONE CALLBACKS INTO HOPPER DIRECTLY ### if ( ($cba > 0) && ($insert_auto_CB_to_hopper) ) { if ($DB) {print "ANYONE Scheduled Callbacks to Insert into hopper: $cba\n";} - $event_string = "|ANYONE CB HOPPER |$cba|"; - &event_logger; + $event_string = "|ANYONE CB HOPPER |$cba|"; + &event_logger; $CAu=0; foreach(@CA_lead_id) { $stmtA = "UPDATE vicidial_list set status='CALLBK', called_since_last_reset='N' where lead_id='$CA_lead_id[$CAu]';"; $affected_rows = $dbhA->do($stmtA); if ($DB) {print "Scheduled Callbacks Activated: $affected_rows\n";} - $event_string = "|CALLBACKS LISTACT|$affected_rows|"; - &event_logger; + $event_string = "|CALLBACKS LISTACT|$affected_rows|"; + &event_logger; $stmtA = "INSERT INTO $vicidial_hopper SET lead_id='$CA_lead_id[$CAu]',campaign_id='$CA_campaign_id[$CAu]',list_id='$CA_list_id[$CAu]',gmt_offset_now='$CA_gmt_offset_now[$CAu]',user='',state='$CA_state[$CAu]',priority='50';"; $affected_rows = $dbhA->do($stmtA); @@ -408,11 +408,11 @@ if ($CBHOLD_count > 0) if ($CLIcampaign) { - $stmtA = "SELECT * from vicidial_campaigns where campaign_id='$CLIcampaign'"; + $stmtA = "SELECT campaign_id,lead_order,hopper_level,auto_dial_level,local_call_time,lead_filter_id,use_internal_dnc,dial_method,available_only_ratio_tally,adaptive_dropped_percentage,adaptive_maximum_level,dial_statuses,list_order_mix,use_campaign_dnc,drop_lockout_time,no_hopper_dialing from vicidial_campaigns where campaign_id='$CLIcampaign';"; } else { - $stmtA = "SELECT * from vicidial_campaigns where active='Y'"; + $stmtA = "SELECT campaign_id,lead_order,hopper_level,auto_dial_level,local_call_time,lead_filter_id,use_internal_dnc,dial_method,available_only_ratio_tally,adaptive_dropped_percentage,adaptive_maximum_level,dial_statuses,list_order_mix,use_campaign_dnc,drop_lockout_time,no_hopper_dialing from vicidial_campaigns where active='Y';"; } $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; @@ -421,24 +421,25 @@ $rec_count=0; while ($sthArows > $rec_count) { @aryA = $sthA->fetchrow_array; - $campaign_id[$rec_count] = "$aryA[0]"; - $lead_order[$rec_count] = "$aryA[8]"; + $campaign_id[$rec_count] = $aryA[0]; + $lead_order[$rec_count] = $aryA[1]; if (!$CLIlevel) - {$hopper_level[$rec_count] = "$aryA[13]";} + {$hopper_level[$rec_count] = $aryA[2];} else {$hopper_level[$rec_count] = "$CLIlevel";} - $auto_dial_level[$rec_count] = "$aryA[14]"; - $local_call_time[$rec_count] = "$aryA[16]"; - $lead_filter_id[$rec_count] = "$aryA[35]"; - $use_internal_dnc[$rec_count] = "$aryA[43]"; - $dial_method[$rec_count] = $aryA[46]; - $available_only_ratio_tally[$rec_count] = $aryA[47]; - $adaptive_dropped_percentage[$rec_count] = $aryA[48]; - $adaptive_maximum_level[$rec_count] = $aryA[49]; - $dial_statuses[$rec_count] = $aryA[61]; - $list_order_mix[$rec_count] = $aryA[64]; - $use_campaign_dnc[$rec_count] = $aryA[95]; - $drop_lockout_time[$rec_count] = $aryA[116]; + $auto_dial_level[$rec_count] = $aryA[3]; + $local_call_time[$rec_count] = $aryA[4]; + $lead_filter_id[$rec_count] = $aryA[5]; + $use_internal_dnc[$rec_count] = $aryA[6]; + $dial_method[$rec_count] = $aryA[7]; + $available_only_ratio_tally[$rec_count] = $aryA[8]; + $adaptive_dropped_percentage[$rec_count] = $aryA[9]; + $adaptive_maximum_level[$rec_count] = $aryA[10]; + $dial_statuses[$rec_count] = $aryA[11]; + $list_order_mix[$rec_count] = $aryA[12]; + $use_campaign_dnc[$rec_count] = $aryA[13]; + $drop_lockout_time[$rec_count] = $aryA[14]; + $no_hopper_dialing[$rec_count] = $aryA[15]; $rec_count++; } @@ -450,787 +451,51 @@ if ($DB) {print "CAMPAIGNS TO PROCESSES HOPPER FOR: $rec_count|$#campaign_id\n" $i=0; foreach(@campaign_id) { - $vicidial_log = 'vicidial_log'; - $VCSdialable_leads[$i]=0; - - if ($list_order_mix[$i] =~ /DISABLED/) + if ($no_hopper_dialing[$i] =~ /Y/) { - ### BEGIN - GATHER STATS FOR THE vicidial_campaign_stats TABLE ### - $dial_statuses[$i] =~ s/ -$//gi; - @Dstatuses = split(/ /,$dial_statuses[$i]); - $Ds_to_print = (($#Dstatuses) + 0); - $STATUSsql[$i]=''; - $o=0; - while ($Ds_to_print > $o) - { - $o++; - $STATUSsql[$i] .= "'$Dstatuses[$o]',"; - } - if (length($STATUSsql[$i])<3) {$STATUSsql[$i]="''";} - else {chop($STATUSsql[$i]);} - } + if ($DB) {print "Campaign $campaign_id[$i] set to no-hopper-dialing: $no_hopper_dialing[$i]\n";} - $stmtA = "SELECT dialable_leads from vicidial_campaign_stats where campaign_id='$campaign_id[$i]';"; - $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; - $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; - $sthArows=$sthA->rows; - $rec_count=0; - while ($sthArows > $rec_count) - { + ### BEGIN Change CBHOLD status leads to CALLBK if their vicidial_callbacks time has passed + $stmtA = "SELECT count(*) FROM $vicidial_hopper where campaign_id='$campaign_id[$i]' and status NOT IN('QUEUE','HOLD');"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; @aryA = $sthA->fetchrow_array; - $VCSdialable_leads[$i] = "$aryA[0]"; - $rec_count++; - } - $sthA->finish(); - ### END - GATHER STATS FOR THE vicidial_campaign_stats TABLE ### + $NOHOPPER_count = $aryA[0]; + if ($DBX) {print "NO HOPPER COUNT: $NOHOPPER_count|$stmtA|\n";} + $sthA->finish(); - ##### 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] = ''; - if ($DBX) {print "\n |GMT-DAY-HOUR| ";} - while ($p > -13) - { - $pzone = ($GMT_now + ($p * 3600)); - ($psec,$pmin,$phour,$pmday,$pmon,$pyear,$pday,$pyday,$pisdst) = localtime($pzone); - $phour=($phour * 100); - $tz = sprintf("%.2f", $p); - $GMT_gmt[$g] = "$tz"; - $GMT_day[$g] = "$pday"; - $GMT_hour[$g] = ($phour + $pmin); - $p = ($p - 0.25); - if ($DBX) {print "|$GMT_gmt[$g]-$GMT_day[$g]-$GMT_hour[$g]|";} - $g++; - } - if ($DBX) {print "\n";} - - $stmtA = "SELECT * 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; - $sthArows=$sthA->rows; - $rec_count=0; - while ($sthArows > $rec_count) - { - @aryA = $sthA->fetchrow_array; - $Gct_default_start = "$aryA[3]"; - $Gct_default_stop = "$aryA[4]"; - $Gct_sunday_start = "$aryA[5]"; - $Gct_sunday_stop = "$aryA[6]"; - $Gct_monday_start = "$aryA[7]"; - $Gct_monday_stop = "$aryA[8]"; - $Gct_tuesday_start = "$aryA[9]"; - $Gct_tuesday_stop = "$aryA[10]"; - $Gct_wednesday_start = "$aryA[11]"; - $Gct_wednesday_stop = "$aryA[12]"; - $Gct_thursday_start = "$aryA[13]"; - $Gct_thursday_stop = "$aryA[14]"; - $Gct_friday_start = "$aryA[15]"; - $Gct_friday_stop = "$aryA[16]"; - $Gct_saturday_start = "$aryA[17]"; - $Gct_saturday_stop = "$aryA[18]"; - $Gct_state_call_times = "$aryA[19]"; - $rec_count++; - } - $sthA->finish(); - - - ### 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 - $lct_begin=0; # hour and minute of the begin time for the local call time - $lct_end=0; # hour and minute of the end time for the local call time - - $secYESTERDAY = ($secX - (24 * 3600)); - ($ksec,$kmin,$khour,$kmday,$kmon,$kyear,$wyesterday,$kyday,$kisdst) = localtime($secYESTERDAY); - - if ($wtoday < 1) #### Sunday local time - { - if (($Gct_sunday_start < 1) && ($Gct_sunday_stop < 1)) {$lct_begin = $Gct_default_start;} - else {$lct_begin = $Gct_sunday_start;} - } - if ($wtoday==1) #### Monday local time - { - if (($Gct_monday_start < 1) && ($Gct_monday_stop < 1)) {$lct_begin = $Gct_default_start;} - else {$lct_begin = $Gct_monday_start;} - } - if ($wtoday==2) #### Tuesday local time - { - if (($Gct_tuesday_start < 1) && ($Gct_tuesday_stop < 1)) {$lct_begin = $Gct_default_start;} - else {$lct_begin = $Gct_tuesday_start;} - } - if ($wtoday==3) #### Wednesday local time - { - if (($Gct_wednesday_start < 1) && ($Gct_wednesday_stop < 1)) {$lct_begin = $Gct_default_start;} - else {$lct_begin = $Gct_wednesday_start;} - } - if ($wtoday==4) #### Thursday local time - { - if (($Gct_thursday_start < 1) && ($Gct_thursday_stop < 1)) {$lct_begin = $Gct_default_start;} - else {$lct_begin = $Gct_thursday_start;} - } - if ($wtoday==5) #### Friday local time - { - if (($Gct_friday_start < 1) && ($Gct_friday_stop < 1)) {$lct_begin = $Gct_default_start;} - else {$lct_begin = $Gct_friday_start;} - } - if ($wtoday==6) #### Saturday local time - { - if (($Gct_saturday_start < 1) && ($Gct_saturday_stop < 1)) {$lct_begin = $Gct_default_start;} - else {$lct_begin = $Gct_saturday_start;} - } - - - $dayBACKsec=0; - $weekBACK=0; - while ( ($lct_end < 1) && ($weekBACK <= 1) ) - { - if ($wyesterday==6) #### Saturday local time + if ($NOHOPPER_count > 0) { - if ($Gct_saturday_start > 2399) {$wyesterday = 0; $dayBACKsec = ($dayBACKsec + 86400); if ($DBX) {print "DayBACK: $wyesterday\n";}} - else - { - if (($Gct_saturday_start < 1) && ($Gct_saturday_stop < 1)) {$lct_end = $Gct_default_stop;} - else {$lct_end = $Gct_saturday_stop;} - } + $stmtA = "DELETE from $vicidial_hopper where campaign_id='$campaign_id[$i]' and status NOT IN('QUEUE','HOLD');"; + $affected_rows = $dbhA->do($stmtA); + if ($DB) {print "No Hopper delete: $affected_rows\n";} + $event_string = "|NO HOPPER DELETE|$affected_rows|"; + &event_logger; } - if ($wyesterday==5) #### Friday local time - { - if ($Gct_friday_start > 2399) {$wyesterday = 1; $dayBACKsec = ($dayBACKsec + 86400); if ($DBX) {print "DayBACK: $wyesterday\n";}} - else - { - if (($Gct_friday_start < 1) && ($Gct_friday_stop < 1)) {$lct_end = $Gct_default_stop;} - else {$lct_end = $Gct_friday_stop;} - } - } - if ($wyesterday==4) #### Thursday local time - { - if ($Gct_thursday_start > 2399) {$wyesterday = 2; $dayBACKsec = ($dayBACKsec + 86400); if ($DBX) {print "DayBACK: $wyesterday\n";}} - else - { - if (($Gct_thursday_start < 1) && ($Gct_thursday_stop < 1)) {$lct_end = $Gct_default_stop;} - else {$lct_end = $Gct_thursday_stop;} - } - } - if ($wyesterday==3) #### Wednesday local time - { - if ($Gct_wednesday_start > 2399) {$wyesterday = 3; $dayBACKsec = ($dayBACKsec + 86400); if ($DBX) {print "DayBACK: $wyesterday\n";}} - else - { - if (($Gct_wednesday_start < 1) && ($Gct_wednesday_stop < 1)) {$lct_end = $Gct_default_stop;} - else {$lct_end = $Gct_wednesday_stop;} - } - } - if ($wyesterday==2) #### Tuesday local time - { - if ($Gct_tuesday_start > 2399) {$wyesterday = 4; $dayBACKsec = ($dayBACKsec + 86400); if ($DBX) {print "DayBACK: $wyesterday\n";}} - else - { - if (($Gct_tuesday_start < 1) && ($Gct_tuesday_stop < 1)) {$lct_end = $Gct_default_stop;} - else {$lct_end = $Gct_tuesday_stop;} - } - } - if ($wyesterday==1) #### Monday local time - { - if ($Gct_monday_start > 2399) {$wyesterday = 5; $dayBACKsec = ($dayBACKsec + 86400); if ($DBX) {print "DayBACK: $wyesterday\n";}} - else - { - if (($Gct_monday_start < 1) && ($Gct_monday_stop < 1)) {$lct_end = $Gct_default_stop;} - else {$lct_end = $Gct_monday_stop;} - } - } - if ($wyesterday==0) #### Sunday local time - { - if ($Gct_sunday_start > 2399) {$wyesterday = 6; $dayBACKsec = ($dayBACKsec + 86400); if ($DBX) {print "DayBACK: $wyesterday\n";}} - else - { - if (($Gct_sunday_start < 1) && ($Gct_sunday_stop < 1)) {$lct_end = $Gct_default_stop;} - else {$lct_end = $Gct_sunday_stop;} - } - } - $weekBACK++; - } - - $lct_end = sprintf("%04d", $lct_end); - $lct_end_hour = substr($lct_end, 0, 2); - $lct_end_min = substr($lct_end, 2, 2); - $lct_begin = sprintf("%04d", $lct_begin); - $lct_begin_hour = substr($lct_begin, 0, 2); - $lct_begin_min = substr($lct_begin, 2, 2); - - $lct_gap = ( ( ( ( ( (24 - $lct_end_hour) + $lct_begin_hour) * 3600) + ($lct_begin_min * 60) ) - ($lct_end_min * 60) ) + $dayBACKsec); - - if ($DBX) {print "LocalCallTime No-Call Gap: |$lct_gap|$lct_end($lct_end_hour $lct_end_min)|$lct_begin($lct_begin_hour $lct_begin_min)|$wtoday|$wyesterday|\n";} - - ### END For lead recycling find out the no-call gap time and begin dial time for today - - - $ct_states = ''; - $ct_state_gmt_SQL = ''; - $del_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 - 2); - } - while($ct_srs >= $b) - { - if (length($state_rules[$b])>1) - { - $stmtA = "SELECT * 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; - $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; - $sthArows=$sthA->rows; - $rec_count=0; - while ($sthArows > $rec_count) - { - @aryA = $sthA->fetchrow_array; - $Gstate_call_time_id = "$aryA[0]"; - $Gstate_call_time_state = "$aryA[1]"; - $Gsct_default_start = "$aryA[4]"; - $Gsct_default_stop = "$aryA[5]"; - $Gsct_sunday_start = "$aryA[6]"; - $Gsct_sunday_stop = "$aryA[7]"; - $Gsct_monday_start = "$aryA[8]"; - $Gsct_monday_stop = "$aryA[9]"; - $Gsct_tuesday_start = "$aryA[10]"; - $Gsct_tuesday_stop = "$aryA[11]"; - $Gsct_wednesday_start = "$aryA[12]"; - $Gsct_wednesday_stop = "$aryA[13]"; - $Gsct_thursday_start = "$aryA[14]"; - $Gsct_thursday_stop = "$aryA[15]"; - $Gsct_friday_start = "$aryA[16]"; - $Gsct_friday_stop = "$aryA[17]"; - $Gsct_saturday_start = "$aryA[18]"; - $Gsct_saturday_stop = "$aryA[19]"; - $ct_states .="'$Gstate_call_time_state',"; - $rec_count++; - } - $sthA->finish(); - - $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 - {$del_state_gmt.="'$GMT_gmt[$r]',";} - } - else - { - if ( ($GMT_hour[$r]>=$Gsct_sunday_start) && ($GMT_hour[$r]<$Gsct_sunday_stop) ) - {$state_gmt.="'$GMT_gmt[$r]',";} - else - {$del_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 - {$del_state_gmt.="'$GMT_gmt[$r]',";} - } - else - { - if ( ($GMT_hour[$r]>=$Gsct_monday_start) && ($GMT_hour[$r]<$Gsct_monday_stop) ) - {$state_gmt.="'$GMT_gmt[$r]',";} - else - {$del_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 - {$del_state_gmt.="'$GMT_gmt[$r]',";} - } - else - { - if ( ($GMT_hour[$r]>=$Gsct_tuesday_start) && ($GMT_hour[$r]<$Gsct_tuesday_stop) ) - {$state_gmt.="'$GMT_gmt[$r]',";} - else - {$del_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 - {$del_state_gmt.="'$GMT_gmt[$r]',";} - } - else - { - if ( ($GMT_hour[$r]>=$Gsct_wednesday_start) && ($GMT_hour[$r]<$Gsct_wednesday_stop) ) - {$state_gmt.="'$GMT_gmt[$r]',";} - else - {$del_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 - {$del_state_gmt.="'$GMT_gmt[$r]',";} - } - else - { - if ( ($GMT_hour[$r]>=$Gsct_thursday_start) && ($GMT_hour[$r]<$Gsct_thursday_stop) ) - {$state_gmt.="'$GMT_gmt[$r]',";} - else - {$del_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 - {$del_state_gmt.="'$GMT_gmt[$r]',";} - } - else - { - if ( ($GMT_hour[$r]>=$Gsct_friday_start) && ($GMT_hour[$r]<$Gsct_friday_stop) ) - {$state_gmt.="'$GMT_gmt[$r]',";} - else - {$del_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 - {$del_state_gmt.="'$GMT_gmt[$r]',";} - } - else - { - if ( ($GMT_hour[$r]>=$Gsct_saturday_start) && ($GMT_hour[$r]<$Gsct_saturday_stop) ) - {$state_gmt.="'$GMT_gmt[$r]',";} - else - {$del_state_gmt.="'$GMT_gmt[$r]',";} - } - } - $r++; - } - $state_gmt = "$state_gmt'99'"; - $del_state_gmt = "$del_state_gmt'99'"; - $ct_state_gmt_SQL .= "or (state='$Gstate_call_time_state' && gmt_offset_now IN($state_gmt)) "; - $del_state_gmt_SQL .= "or (state='$Gstate_call_time_state' && gmt_offset_now IN($del_state_gmt)) "; - } - - $b++; - } - if (length($ct_states)>2) - { - $ct_states =~ s/,$//gi; - $ct_statesSQL = "and state NOT IN($ct_states)"; } else { - $ct_statesSQL = ""; - } + $vicidial_log = 'vicidial_log'; + $VCSdialable_leads[$i]=0; - $r=0; - @default_gmt_ARY=@MT; - $dgA=0; - $default_gmt=''; - $del_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) ) - {$default_gmt.="'$GMT_gmt[$r]',"; $default_gmt_ARY[$dgA] = "$GMT_gmt[$r]"; $dgA++;} - else - {$del_default_gmt.="'$GMT_gmt[$r]',";} - } - else - { - if ( ($GMT_hour[$r]>=$Gct_sunday_start) && ($GMT_hour[$r]<$Gct_sunday_stop) ) - {$default_gmt.="'$GMT_gmt[$r]',"; $default_gmt_ARY[$dgA] = "$GMT_gmt[$r]"; $dgA++;} - else - {$del_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) ) - {$default_gmt.="'$GMT_gmt[$r]',"; $default_gmt_ARY[$dgA] = "$GMT_gmt[$r]"; $dgA++;} - else - {$del_default_gmt.="'$GMT_gmt[$r]',";} - } - else - { - if ( ($GMT_hour[$r]>=$Gct_monday_start) && ($GMT_hour[$r]<$Gct_monday_stop) ) - {$default_gmt.="'$GMT_gmt[$r]',"; $default_gmt_ARY[$dgA] = "$GMT_gmt[$r]"; $dgA++;} - else - {$del_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) ) - {$default_gmt.="'$GMT_gmt[$r]',"; $default_gmt_ARY[$dgA] = "$GMT_gmt[$r]"; $dgA++;} - else - {$del_default_gmt.="'$GMT_gmt[$r]',";} - } - else - { - if ( ($GMT_hour[$r]>=$Gct_tuesday_start) && ($GMT_hour[$r]<$Gct_tuesday_stop) ) - {$default_gmt.="'$GMT_gmt[$r]',"; $default_gmt_ARY[$dgA] = "$GMT_gmt[$r]"; $dgA++;} - else - {$del_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) ) - {$default_gmt.="'$GMT_gmt[$r]',"; $default_gmt_ARY[$dgA] = "$GMT_gmt[$r]"; $dgA++;} - else - {$del_default_gmt.="'$GMT_gmt[$r]',";} - } - else - { - if ( ($GMT_hour[$r]>=$Gct_wednesday_start) && ($GMT_hour[$r]<$Gct_wednesday_stop) ) - {$default_gmt.="'$GMT_gmt[$r]',"; $default_gmt_ARY[$dgA] = "$GMT_gmt[$r]"; $dgA++;} - else - {$del_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) ) - {$default_gmt.="'$GMT_gmt[$r]',"; $default_gmt_ARY[$dgA] = "$GMT_gmt[$r]"; $dgA++;} - else - {$del_default_gmt.="'$GMT_gmt[$r]',";} - } - else - { - if ( ($GMT_hour[$r]>=$Gct_thursday_start) && ($GMT_hour[$r]<$Gct_thursday_stop) ) - {$default_gmt.="'$GMT_gmt[$r]',"; $default_gmt_ARY[$dgA] = "$GMT_gmt[$r]"; $dgA++;} - else - {$del_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) ) - {$default_gmt.="'$GMT_gmt[$r]',"; $default_gmt_ARY[$dgA] = "$GMT_gmt[$r]"; $dgA++;} - else - {$del_default_gmt.="'$GMT_gmt[$r]',";} - } - else - { - if ( ($GMT_hour[$r]>=$Gct_friday_start) && ($GMT_hour[$r]<$Gct_friday_stop) ) - {$default_gmt.="'$GMT_gmt[$r]',"; $default_gmt_ARY[$dgA] = "$GMT_gmt[$r]"; $dgA++;} - else - {$del_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) ) - {$default_gmt.="'$GMT_gmt[$r]',"; $default_gmt_ARY[$dgA] = "$GMT_gmt[$r]"; $dgA++;} - else - {$del_default_gmt.="'$GMT_gmt[$r]',";} - } - else - { - if ( ($GMT_hour[$r]>=$Gct_saturday_start) && ($GMT_hour[$r]<$Gct_saturday_stop) ) - {$default_gmt.="'$GMT_gmt[$r]',"; $default_gmt_ARY[$dgA] = "$GMT_gmt[$r]"; $dgA++;} - else - {$del_default_gmt.="'$GMT_gmt[$r]',";} - } - } - $r++; - } - - $default_gmt = "$default_gmt'99'"; - $del_default_gmt = "$del_default_gmt'99'"; - $all_gmtSQL[$i] = "(gmt_offset_now IN($default_gmt) $ct_statesSQL) $ct_state_gmt_SQL"; - $del_gmtSQL[$i] = "(gmt_offset_now IN($del_default_gmt) $ct_statesSQL) $del_state_gmt_SQL"; - - ##### END calculate what gmt_offset_now values are within the allowed local_call_time setting ### - - ##### BEGIN lead recycling parsing and prep ### - - $stmtA = "SELECT * from vicidial_lead_recycle where campaign_id='$campaign_id[$i]' and active='Y';"; - $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; - $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; - $sthArows=$sthA->rows; - @recycle_status=@MT; - @recycle_delay=@MT; - @recycle_maximum=@MT; - @RSQLdate=@MT; - $r_ct=0; - $rec_ct[$i]=0; - while ($sthArows > $r_ct) - { - @aryA = $sthA->fetchrow_array; - $recycle_status[$r_ct] = "$aryA[2]"; - $recycle_delay[$r_ct] = "$aryA[3]"; - $recycle_maximum[$r_ct] = "$aryA[4]"; - $r_ct++; - $rec_ct[$i]++; - } - $sthA->finish(); - - if ($rec_ct[$i] > 0) - { - $rc=0; - $recycle_SQL[$i] = "( "; - while($rc < $rec_ct[$i]) - { - $Y=1; - $recycle_Y = "'Y'"; - while ($Y < $recycle_maximum[$rc]) - { - $recycle_Y .= ",'Y$Y'"; - $Y++; - } - - if ($rc > 0) {$recycle_SQL[$i] .= " or ";} - - $recycle_SQL[$i] .= "( (called_since_last_reset IN($recycle_Y)) and (status='$recycle_status[$rc]') and ("; - - $dgA=0; - foreach(@default_gmt_ARY) - { - $secX = time(); - $LLCT_DATE_offset = ($LOCAL_GMT_OFF - $default_gmt_ARY[$dgA]); - $LLCT_DATE_offset_epoch = ( $secX - ($LLCT_DATE_offset * 3600) ); - $Rtarget = ($LLCT_DATE_offset_epoch - $recycle_delay[$rc]); - ($Rsec,$Rmin,$Rhour,$Rmday,$Rmon,$Ryear,$Rwday,$Ryday,$Risdst) = localtime($Rtarget); - $Ryear = ($Ryear + 1900); - $Rmon++; - if ($Rmon < 10) {$Rmon = "0$Rmon";} - if ($Rmday < 10) {$Rmday = "0$Rmday";} - if ($Rhour < 10) {$Rhour = "0$Rhour";} - if ($Rmin < 10) {$Rmin = "0$Rmin";} - if ($Rsec < 10) {$Rsec = "0$Rsec";} - $Rhourmin = "$Rhour$Rmin"; - if ( ($Rhourmin < $lct_begin) || ($Rhourmin > $lct_end) ) - { - $RGtarget = ($Rtarget - $lct_gap); - ($Rsec,$Rmin,$Rhour,$Rmday,$Rmon,$Ryear,$Rwday,$Ryday,$Risdst) = localtime($RGtarget); - $Ryear = ($Ryear + 1900); - $Rmon++; - if ($Rmon < 10) {$Rmon = "0$Rmon";} - if ($Rmday < 10) {$Rmday = "0$Rmday";} - if ($Rhour < 10) {$Rhour = "0$Rhour";} - if ($Rmin < 10) {$Rmin = "0$Rmin";} - if ($Rsec < 10) {$Rsec = "0$Rsec";} - if ($DBX) {print "RECYCLE DELAY GAP: |$campaign_id[$i]|$Rhourmin|$RGtarget|Rtarget|($recycle_delay[$rc] $lct_gap)\n";} - } - $RSQLdate[$rc] = "$Ryear-$Rmon-$Rmday $Rhour:$Rmin:$Rsec"; - - if ($dgA > 0) {$recycle_SQL[$i] .= " or ";} - - $recycle_SQL[$i] .= "( (gmt_offset_now='$default_gmt_ARY[$dgA]') and (last_local_call_time < \"$RSQLdate[$rc]\") )"; - - $dgA++; - } - if ($DBX) {print "RECYCLE: |$campaign_id[$i]|$recycle_status[$rc]|$recycle_delay[$rc]|$recycle_maximum[$rc]|$RSQLdate[$rc]|\n";} - - $recycle_SQL[$i] .= " ) )"; - - $rc++; - } - - $recycle_SQL[$i] .= " )"; - - if ($DBX) {print "RECYCLE SQL: |$recycle_SQL[$i]|\n";} - } - ##### 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]\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 - $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; - $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; - $sthArows=$sthA->rows; - $rec_count=0; - while ($sthArows > $rec_count) - { - @aryA = $sthA->fetchrow_array; - $hopper_ready_count = $aryA[0]; - if ($DB) {print " hopper READY count: $hopper_ready_count\n";} - if ($DBX) {print " |$stmtA|\n";} - $rec_count++; - } - $sthA->finish(); - $event_string = "|$campaign_id[$i]|$hopper_level[$i]|$hopper_ready_count|$local_call_time[$i]||"; - &event_logger; - - ##### IF hopper level is below set minimum, then try to add more leads ##### - if ($hopper_ready_count < $hopper_level[$i]) - { - if ($DB) {print " hopper too low ($hopper_ready_count|$hopper_level[$i]) starting hopper dump\n";} - - $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]' $active_listSQL;"; - $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; - $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; - $sthArows=$sthA->rows; - $rec_countLISTS=0; - $camp_lists[$i] = ''; - while ($sthArows > $rec_countLISTS) - { - @aryA = $sthA->fetchrow_array; - $camp_lists[$i] .= "'$aryA[0]',"; - $rec_countLISTS++; - } - $sthA->finish(); - if (length($camp_lists[$i])<3) {$camp_lists[$i]="''";} - else {chop($camp_lists[$i]);} - - if ($DB) {print " campaign lists count: $rec_countLISTS | $camp_lists[$i]\n";} - if ($DBX) {print " |$stmtA|\n";} - - 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';"; - $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; - $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; - $sthArows=$sthA->rows; - $rec_count=0; - while ($sthArows > $rec_count) - { - @aryA = $sthA->fetchrow_array; - $vcl_id[$i] = "$aryA[0]"; - $vcl_name[$i] = "$aryA[1]"; - $list_mix_container[$i] = "$aryA[2]"; - $mix_method[$i] = "$aryA[3]"; - $rec_count++; - } - $sthA->finish(); - - @list_mixARY=@MT; - $list_mix_dialableSQL=''; - @list_mixARY = split(/:/,$list_mix_container[$i]); - $x=0; - foreach(@list_mixARY) - { - if ($x > 0) {$list_mix_dialableSQL .= " or ";} - @list_mix_stepARY = split(/\|/,$list_mixARY[$x]); - $list_mix_stepARY[3] =~ s/ /\',\'/gi; - $list_mix_stepARY[3] =~ s/^\',|,\'-//gi; - 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]))"; - - $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";} - } - - if ( ($lead_filter_id[$i] !~ /NONE/) && (length($lead_filter_id[$i])>0) ) - { - ### Get SQL of lead filter for the campaign ### - $stmtA = "SELECT lead_filter_sql FROM vicidial_lead_filters where lead_filter_id='$lead_filter_id[$i]';"; - $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; - $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; - $sthArows=$sthA->rows; - $rec_count=0; - while ($sthArows > $rec_count) - { - @aryA = $sthA->fetchrow_array; - $lead_filter_sql[$i] = "$aryA[0]"; - $lead_filter_sql[$i] =~ s/\\//gi; - $rec_count++; - } - $sthA->finish(); - $lead_filter_sql[$i] =~ s/^and|and$|^or|or$|^ and|and $|^ or|or $//gi; - $lead_filter_sql[$i] = "and $lead_filter_sql[$i]"; - if ($DB) {print " lead filter $lead_filter_id[$i] defined for $campaign_id[$i]\n";} - if ($DBX) {print " |$lead_filter_sql[$i]|\n";} - } - else - { - $lead_filter_sql[$i] = ''; - if ($DB) {print " no lead filter defined for campaign: $campaign_id[$i]\n";} - if ($DBX) {print " |$lead_filter_id[$i]|\n";} - } - - $DLTsql[$i]=''; - if ($drop_lockout_time[$i] > 0) - { - $DLseconds[$i] = ($drop_lockout_time[$i] * 3600); - $DLTsql[$i] = "and ( ( (status IN('DROP','XDROP')) and (last_local_call_time < CONCAT(DATE_ADD(NOW(), INTERVAL -$DLseconds[$i] SECOND),' ',CURTIME()) ) ) or (status NOT IN('DROP','XDROP')) )"; - if ($DB) {print " drop lockout time $drop_lockout_time[$i]($DLseconds[$i]) defined for $campaign_id[$i]\n";} - if ($DBX) {print " |$DLTsql[$i]|\n";} - } - - ##### 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];"; + ### BEGIN - GATHER STATS FOR THE vicidial_campaign_stats TABLE ### + $dial_statuses[$i] =~ s/ -$//gi; + @Dstatuses = split(/ /,$dial_statuses[$i]); + $Ds_to_print = (($#Dstatuses) + 0); + $STATUSsql[$i]=''; + $o=0; + while ($Ds_to_print > $o) + { + $o++; + $STATUSsql[$i] .= "'$Dstatuses[$o]',"; + } + if (length($STATUSsql[$i])<3) {$STATUSsql[$i]="''";} + else {chop($STATUSsql[$i]);} } - else - { - $stmtA = "SELECT count(*) FROM vicidial_list where called_since_last_reset='N' and ($list_mix_dialableSQL) and ($all_gmtSQL[$i]) $lead_filter_sql[$i] $DLTsql[$i];"; - } - if ($DBX) {print " |$stmtA|\n";} + + $stmtA = "SELECT dialable_leads from vicidial_campaign_stats where campaign_id='$campaign_id[$i]';"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthArows=$sthA->rows; @@ -1238,16 +503,759 @@ foreach(@campaign_id) while ($sthArows > $rec_count) { @aryA = $sthA->fetchrow_array; - $campaign_leads_to_call[$i] = "$aryA[0]"; - if ($DB) {print " leads to call count: $campaign_leads_to_call[$i]\n";} - if ($DBX) {print " |$stmtA|\n";} + $VCSdialable_leads[$i] = "$aryA[0]"; + $rec_count++; + } + $sthA->finish(); + ### END - GATHER STATS FOR THE vicidial_campaign_stats TABLE ### + + ##### 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] = ''; + if ($DBX) {print "\n |GMT-DAY-HOUR| ";} + while ($p > -13) + { + $pzone = ($GMT_now + ($p * 3600)); + ($psec,$pmin,$phour,$pmday,$pmon,$pyear,$pday,$pyday,$pisdst) = localtime($pzone); + $phour=($phour * 100); + $tz = sprintf("%.2f", $p); + $GMT_gmt[$g] = "$tz"; + $GMT_day[$g] = "$pday"; + $GMT_hour[$g] = ($phour + $pmin); + $p = ($p - 0.25); + if ($DBX) {print "|$GMT_gmt[$g]-$GMT_day[$g]-$GMT_hour[$g]|";} + $g++; + } + if ($DBX) {print "\n";} + + $stmtA = "SELECT * 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; + $sthArows=$sthA->rows; + $rec_count=0; + while ($sthArows > $rec_count) + { + @aryA = $sthA->fetchrow_array; + $Gct_default_start = "$aryA[3]"; + $Gct_default_stop = "$aryA[4]"; + $Gct_sunday_start = "$aryA[5]"; + $Gct_sunday_stop = "$aryA[6]"; + $Gct_monday_start = "$aryA[7]"; + $Gct_monday_stop = "$aryA[8]"; + $Gct_tuesday_start = "$aryA[9]"; + $Gct_tuesday_stop = "$aryA[10]"; + $Gct_wednesday_start = "$aryA[11]"; + $Gct_wednesday_stop = "$aryA[12]"; + $Gct_thursday_start = "$aryA[13]"; + $Gct_thursday_stop = "$aryA[14]"; + $Gct_friday_start = "$aryA[15]"; + $Gct_friday_stop = "$aryA[16]"; + $Gct_saturday_start = "$aryA[17]"; + $Gct_saturday_stop = "$aryA[18]"; + $Gct_state_call_times = "$aryA[19]"; $rec_count++; } $sthA->finish(); - if ( ($lead_order[$i] =~ / 2nd NEW$| 3rd NEW$| 4th NEW$| 5th NEW$| 6th NEW$/) && ($list_order_mix[$i] =~ /DISABLED/) ) + + ### 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 + $lct_begin=0; # hour and minute of the begin time for the local call time + $lct_end=0; # hour and minute of the end time for the local call time + + $secYESTERDAY = ($secX - (24 * 3600)); + ($ksec,$kmin,$khour,$kmday,$kmon,$kyear,$wyesterday,$kyday,$kisdst) = localtime($secYESTERDAY); + + if ($wtoday < 1) #### Sunday local time { - $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];"; + if (($Gct_sunday_start < 1) && ($Gct_sunday_stop < 1)) {$lct_begin = $Gct_default_start;} + else {$lct_begin = $Gct_sunday_start;} + } + if ($wtoday==1) #### Monday local time + { + if (($Gct_monday_start < 1) && ($Gct_monday_stop < 1)) {$lct_begin = $Gct_default_start;} + else {$lct_begin = $Gct_monday_start;} + } + if ($wtoday==2) #### Tuesday local time + { + if (($Gct_tuesday_start < 1) && ($Gct_tuesday_stop < 1)) {$lct_begin = $Gct_default_start;} + else {$lct_begin = $Gct_tuesday_start;} + } + if ($wtoday==3) #### Wednesday local time + { + if (($Gct_wednesday_start < 1) && ($Gct_wednesday_stop < 1)) {$lct_begin = $Gct_default_start;} + else {$lct_begin = $Gct_wednesday_start;} + } + if ($wtoday==4) #### Thursday local time + { + if (($Gct_thursday_start < 1) && ($Gct_thursday_stop < 1)) {$lct_begin = $Gct_default_start;} + else {$lct_begin = $Gct_thursday_start;} + } + if ($wtoday==5) #### Friday local time + { + if (($Gct_friday_start < 1) && ($Gct_friday_stop < 1)) {$lct_begin = $Gct_default_start;} + else {$lct_begin = $Gct_friday_start;} + } + if ($wtoday==6) #### Saturday local time + { + if (($Gct_saturday_start < 1) && ($Gct_saturday_stop < 1)) {$lct_begin = $Gct_default_start;} + else {$lct_begin = $Gct_saturday_start;} + } + + + $dayBACKsec=0; + $weekBACK=0; + while ( ($lct_end < 1) && ($weekBACK <= 1) ) + { + if ($wyesterday==6) #### Saturday local time + { + if ($Gct_saturday_start > 2399) {$wyesterday = 0; $dayBACKsec = ($dayBACKsec + 86400); if ($DBX) {print "DayBACK: $wyesterday\n";}} + else + { + if (($Gct_saturday_start < 1) && ($Gct_saturday_stop < 1)) {$lct_end = $Gct_default_stop;} + else {$lct_end = $Gct_saturday_stop;} + } + } + if ($wyesterday==5) #### Friday local time + { + if ($Gct_friday_start > 2399) {$wyesterday = 1; $dayBACKsec = ($dayBACKsec + 86400); if ($DBX) {print "DayBACK: $wyesterday\n";}} + else + { + if (($Gct_friday_start < 1) && ($Gct_friday_stop < 1)) {$lct_end = $Gct_default_stop;} + else {$lct_end = $Gct_friday_stop;} + } + } + if ($wyesterday==4) #### Thursday local time + { + if ($Gct_thursday_start > 2399) {$wyesterday = 2; $dayBACKsec = ($dayBACKsec + 86400); if ($DBX) {print "DayBACK: $wyesterday\n";}} + else + { + if (($Gct_thursday_start < 1) && ($Gct_thursday_stop < 1)) {$lct_end = $Gct_default_stop;} + else {$lct_end = $Gct_thursday_stop;} + } + } + if ($wyesterday==3) #### Wednesday local time + { + if ($Gct_wednesday_start > 2399) {$wyesterday = 3; $dayBACKsec = ($dayBACKsec + 86400); if ($DBX) {print "DayBACK: $wyesterday\n";}} + else + { + if (($Gct_wednesday_start < 1) && ($Gct_wednesday_stop < 1)) {$lct_end = $Gct_default_stop;} + else {$lct_end = $Gct_wednesday_stop;} + } + } + if ($wyesterday==2) #### Tuesday local time + { + if ($Gct_tuesday_start > 2399) {$wyesterday = 4; $dayBACKsec = ($dayBACKsec + 86400); if ($DBX) {print "DayBACK: $wyesterday\n";}} + else + { + if (($Gct_tuesday_start < 1) && ($Gct_tuesday_stop < 1)) {$lct_end = $Gct_default_stop;} + else {$lct_end = $Gct_tuesday_stop;} + } + } + if ($wyesterday==1) #### Monday local time + { + if ($Gct_monday_start > 2399) {$wyesterday = 5; $dayBACKsec = ($dayBACKsec + 86400); if ($DBX) {print "DayBACK: $wyesterday\n";}} + else + { + if (($Gct_monday_start < 1) && ($Gct_monday_stop < 1)) {$lct_end = $Gct_default_stop;} + else {$lct_end = $Gct_monday_stop;} + } + } + if ($wyesterday==0) #### Sunday local time + { + if ($Gct_sunday_start > 2399) {$wyesterday = 6; $dayBACKsec = ($dayBACKsec + 86400); if ($DBX) {print "DayBACK: $wyesterday\n";}} + else + { + if (($Gct_sunday_start < 1) && ($Gct_sunday_stop < 1)) {$lct_end = $Gct_default_stop;} + else {$lct_end = $Gct_sunday_stop;} + } + } + $weekBACK++; + } + + $lct_end = sprintf("%04d", $lct_end); + $lct_end_hour = substr($lct_end, 0, 2); + $lct_end_min = substr($lct_end, 2, 2); + $lct_begin = sprintf("%04d", $lct_begin); + $lct_begin_hour = substr($lct_begin, 0, 2); + $lct_begin_min = substr($lct_begin, 2, 2); + + $lct_gap = ( ( ( ( ( (24 - $lct_end_hour) + $lct_begin_hour) * 3600) + ($lct_begin_min * 60) ) - ($lct_end_min * 60) ) + $dayBACKsec); + + if ($DBX) {print "LocalCallTime No-Call Gap: |$lct_gap|$lct_end($lct_end_hour $lct_end_min)|$lct_begin($lct_begin_hour $lct_begin_min)|$wtoday|$wyesterday|\n";} + + ### END For lead recycling find out the no-call gap time and begin dial time for today + + + $ct_states = ''; + $ct_state_gmt_SQL = ''; + $del_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 - 2); + } + while($ct_srs >= $b) + { + if (length($state_rules[$b])>1) + { + $stmtA = "SELECT * 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; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + $rec_count=0; + while ($sthArows > $rec_count) + { + @aryA = $sthA->fetchrow_array; + $Gstate_call_time_id = "$aryA[0]"; + $Gstate_call_time_state = "$aryA[1]"; + $Gsct_default_start = "$aryA[4]"; + $Gsct_default_stop = "$aryA[5]"; + $Gsct_sunday_start = "$aryA[6]"; + $Gsct_sunday_stop = "$aryA[7]"; + $Gsct_monday_start = "$aryA[8]"; + $Gsct_monday_stop = "$aryA[9]"; + $Gsct_tuesday_start = "$aryA[10]"; + $Gsct_tuesday_stop = "$aryA[11]"; + $Gsct_wednesday_start = "$aryA[12]"; + $Gsct_wednesday_stop = "$aryA[13]"; + $Gsct_thursday_start = "$aryA[14]"; + $Gsct_thursday_stop = "$aryA[15]"; + $Gsct_friday_start = "$aryA[16]"; + $Gsct_friday_stop = "$aryA[17]"; + $Gsct_saturday_start = "$aryA[18]"; + $Gsct_saturday_stop = "$aryA[19]"; + $ct_states .="'$Gstate_call_time_state',"; + $rec_count++; + } + $sthA->finish(); + + $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 + {$del_state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_sunday_start) && ($GMT_hour[$r]<$Gsct_sunday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + else + {$del_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 + {$del_state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_monday_start) && ($GMT_hour[$r]<$Gsct_monday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + else + {$del_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 + {$del_state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_tuesday_start) && ($GMT_hour[$r]<$Gsct_tuesday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + else + {$del_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 + {$del_state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_wednesday_start) && ($GMT_hour[$r]<$Gsct_wednesday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + else + {$del_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 + {$del_state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_thursday_start) && ($GMT_hour[$r]<$Gsct_thursday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + else + {$del_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 + {$del_state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_friday_start) && ($GMT_hour[$r]<$Gsct_friday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + else + {$del_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 + {$del_state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_saturday_start) && ($GMT_hour[$r]<$Gsct_saturday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + else + {$del_state_gmt.="'$GMT_gmt[$r]',";} + } + } + $r++; + } + $state_gmt = "$state_gmt'99'"; + $del_state_gmt = "$del_state_gmt'99'"; + $ct_state_gmt_SQL .= "or (state='$Gstate_call_time_state' && gmt_offset_now IN($state_gmt)) "; + $del_state_gmt_SQL .= "or (state='$Gstate_call_time_state' && gmt_offset_now IN($del_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; + $default_gmt=''; + $del_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) ) + {$default_gmt.="'$GMT_gmt[$r]',"; $default_gmt_ARY[$dgA] = "$GMT_gmt[$r]"; $dgA++;} + else + {$del_default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_sunday_start) && ($GMT_hour[$r]<$Gct_sunday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',"; $default_gmt_ARY[$dgA] = "$GMT_gmt[$r]"; $dgA++;} + else + {$del_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) ) + {$default_gmt.="'$GMT_gmt[$r]',"; $default_gmt_ARY[$dgA] = "$GMT_gmt[$r]"; $dgA++;} + else + {$del_default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_monday_start) && ($GMT_hour[$r]<$Gct_monday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',"; $default_gmt_ARY[$dgA] = "$GMT_gmt[$r]"; $dgA++;} + else + {$del_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) ) + {$default_gmt.="'$GMT_gmt[$r]',"; $default_gmt_ARY[$dgA] = "$GMT_gmt[$r]"; $dgA++;} + else + {$del_default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_tuesday_start) && ($GMT_hour[$r]<$Gct_tuesday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',"; $default_gmt_ARY[$dgA] = "$GMT_gmt[$r]"; $dgA++;} + else + {$del_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) ) + {$default_gmt.="'$GMT_gmt[$r]',"; $default_gmt_ARY[$dgA] = "$GMT_gmt[$r]"; $dgA++;} + else + {$del_default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_wednesday_start) && ($GMT_hour[$r]<$Gct_wednesday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',"; $default_gmt_ARY[$dgA] = "$GMT_gmt[$r]"; $dgA++;} + else + {$del_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) ) + {$default_gmt.="'$GMT_gmt[$r]',"; $default_gmt_ARY[$dgA] = "$GMT_gmt[$r]"; $dgA++;} + else + {$del_default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_thursday_start) && ($GMT_hour[$r]<$Gct_thursday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',"; $default_gmt_ARY[$dgA] = "$GMT_gmt[$r]"; $dgA++;} + else + {$del_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) ) + {$default_gmt.="'$GMT_gmt[$r]',"; $default_gmt_ARY[$dgA] = "$GMT_gmt[$r]"; $dgA++;} + else + {$del_default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_friday_start) && ($GMT_hour[$r]<$Gct_friday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',"; $default_gmt_ARY[$dgA] = "$GMT_gmt[$r]"; $dgA++;} + else + {$del_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) ) + {$default_gmt.="'$GMT_gmt[$r]',"; $default_gmt_ARY[$dgA] = "$GMT_gmt[$r]"; $dgA++;} + else + {$del_default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_saturday_start) && ($GMT_hour[$r]<$Gct_saturday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',"; $default_gmt_ARY[$dgA] = "$GMT_gmt[$r]"; $dgA++;} + else + {$del_default_gmt.="'$GMT_gmt[$r]',";} + } + } + $r++; + } + + $default_gmt = "$default_gmt'99'"; + $del_default_gmt = "$del_default_gmt'99'"; + $all_gmtSQL[$i] = "(gmt_offset_now IN($default_gmt) $ct_statesSQL) $ct_state_gmt_SQL"; + $del_gmtSQL[$i] = "(gmt_offset_now IN($del_default_gmt) $ct_statesSQL) $del_state_gmt_SQL"; + + ##### END calculate what gmt_offset_now values are within the allowed local_call_time setting ### + + ##### BEGIN lead recycling parsing and prep ### + + $stmtA = "SELECT * from vicidial_lead_recycle where campaign_id='$campaign_id[$i]' and active='Y';"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + @recycle_status=@MT; + @recycle_delay=@MT; + @recycle_maximum=@MT; + @RSQLdate=@MT; + $r_ct=0; + $rec_ct[$i]=0; + while ($sthArows > $r_ct) + { + @aryA = $sthA->fetchrow_array; + $recycle_status[$r_ct] = "$aryA[2]"; + $recycle_delay[$r_ct] = "$aryA[3]"; + $recycle_maximum[$r_ct] = "$aryA[4]"; + $r_ct++; + $rec_ct[$i]++; + } + $sthA->finish(); + + if ($rec_ct[$i] > 0) + { + $rc=0; + $recycle_SQL[$i] = "( "; + while($rc < $rec_ct[$i]) + { + $Y=1; + $recycle_Y = "'Y'"; + while ($Y < $recycle_maximum[$rc]) + { + $recycle_Y .= ",'Y$Y'"; + $Y++; + } + + if ($rc > 0) {$recycle_SQL[$i] .= " or ";} + + $recycle_SQL[$i] .= "( (called_since_last_reset IN($recycle_Y)) and (status='$recycle_status[$rc]') and ("; + + $dgA=0; + foreach(@default_gmt_ARY) + { + $secX = time(); + $LLCT_DATE_offset = ($LOCAL_GMT_OFF - $default_gmt_ARY[$dgA]); + $LLCT_DATE_offset_epoch = ( $secX - ($LLCT_DATE_offset * 3600) ); + $Rtarget = ($LLCT_DATE_offset_epoch - $recycle_delay[$rc]); + ($Rsec,$Rmin,$Rhour,$Rmday,$Rmon,$Ryear,$Rwday,$Ryday,$Risdst) = localtime($Rtarget); + $Ryear = ($Ryear + 1900); + $Rmon++; + if ($Rmon < 10) {$Rmon = "0$Rmon";} + if ($Rmday < 10) {$Rmday = "0$Rmday";} + if ($Rhour < 10) {$Rhour = "0$Rhour";} + if ($Rmin < 10) {$Rmin = "0$Rmin";} + if ($Rsec < 10) {$Rsec = "0$Rsec";} + $Rhourmin = "$Rhour$Rmin"; + if ( ($Rhourmin < $lct_begin) || ($Rhourmin > $lct_end) ) + { + $RGtarget = ($Rtarget - $lct_gap); + ($Rsec,$Rmin,$Rhour,$Rmday,$Rmon,$Ryear,$Rwday,$Ryday,$Risdst) = localtime($RGtarget); + $Ryear = ($Ryear + 1900); + $Rmon++; + if ($Rmon < 10) {$Rmon = "0$Rmon";} + if ($Rmday < 10) {$Rmday = "0$Rmday";} + if ($Rhour < 10) {$Rhour = "0$Rhour";} + if ($Rmin < 10) {$Rmin = "0$Rmin";} + if ($Rsec < 10) {$Rsec = "0$Rsec";} + if ($DBX) {print "RECYCLE DELAY GAP: |$campaign_id[$i]|$Rhourmin|$RGtarget|Rtarget|($recycle_delay[$rc] $lct_gap)\n";} + } + $RSQLdate[$rc] = "$Ryear-$Rmon-$Rmday $Rhour:$Rmin:$Rsec"; + + if ($dgA > 0) {$recycle_SQL[$i] .= " or ";} + + $recycle_SQL[$i] .= "( (gmt_offset_now='$default_gmt_ARY[$dgA]') and (last_local_call_time < \"$RSQLdate[$rc]\") )"; + + $dgA++; + } + if ($DBX) {print "RECYCLE: |$campaign_id[$i]|$recycle_status[$rc]|$recycle_delay[$rc]|$recycle_maximum[$rc]|$RSQLdate[$rc]|\n";} + + $recycle_SQL[$i] .= " ) )"; + + $rc++; + } + + $recycle_SQL[$i] .= " )"; + + if ($DBX) {print "RECYCLE SQL: |$recycle_SQL[$i]|\n";} + } + ##### 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]\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 + $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; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + $rec_count=0; + while ($sthArows > $rec_count) + { + @aryA = $sthA->fetchrow_array; + $hopper_ready_count = $aryA[0]; + if ($DB) {print " hopper READY count: $hopper_ready_count\n";} + if ($DBX) {print " |$stmtA|\n";} + $rec_count++; + } + $sthA->finish(); + $event_string = "|$campaign_id[$i]|$hopper_level[$i]|$hopper_ready_count|$local_call_time[$i]||"; + &event_logger; + + ##### IF hopper level is below set minimum, then try to add more leads ##### + if ($hopper_ready_count < $hopper_level[$i]) + { + if ($DB) {print " hopper too low ($hopper_ready_count|$hopper_level[$i]) starting hopper dump\n";} + + $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]' $active_listSQL;"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + $rec_countLISTS=0; + $camp_lists[$i] = ''; + while ($sthArows > $rec_countLISTS) + { + @aryA = $sthA->fetchrow_array; + $camp_lists[$i] .= "'$aryA[0]',"; + $rec_countLISTS++; + } + $sthA->finish(); + if (length($camp_lists[$i])<3) {$camp_lists[$i]="''";} + else {chop($camp_lists[$i]);} + + if ($DB) {print " campaign lists count: $rec_countLISTS | $camp_lists[$i]\n";} + if ($DBX) {print " |$stmtA|\n";} + + 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';"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + $rec_count=0; + while ($sthArows > $rec_count) + { + @aryA = $sthA->fetchrow_array; + $vcl_id[$i] = "$aryA[0]"; + $vcl_name[$i] = "$aryA[1]"; + $list_mix_container[$i] = "$aryA[2]"; + $mix_method[$i] = "$aryA[3]"; + $rec_count++; + } + $sthA->finish(); + + @list_mixARY=@MT; + $list_mix_dialableSQL=''; + @list_mixARY = split(/:/,$list_mix_container[$i]); + $x=0; + foreach(@list_mixARY) + { + if ($x > 0) {$list_mix_dialableSQL .= " or ";} + @list_mix_stepARY = split(/\|/,$list_mixARY[$x]); + $list_mix_stepARY[3] =~ s/ /\',\'/gi; + $list_mix_stepARY[3] =~ s/^\',|,\'-//gi; + 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]))"; + + $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";} + } + + if ( ($lead_filter_id[$i] !~ /NONE/) && (length($lead_filter_id[$i])>0) ) + { + ### Get SQL of lead filter for the campaign ### + $stmtA = "SELECT lead_filter_sql FROM vicidial_lead_filters where lead_filter_id='$lead_filter_id[$i]';"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + $rec_count=0; + while ($sthArows > $rec_count) + { + @aryA = $sthA->fetchrow_array; + $lead_filter_sql[$i] = "$aryA[0]"; + $lead_filter_sql[$i] =~ s/\\//gi; + $rec_count++; + } + $sthA->finish(); + $lead_filter_sql[$i] =~ s/^and|and$|^or|or$|^ and|and $|^ or|or $//gi; + $lead_filter_sql[$i] = "and $lead_filter_sql[$i]"; + if ($DB) {print " lead filter $lead_filter_id[$i] defined for $campaign_id[$i]\n";} + if ($DBX) {print " |$lead_filter_sql[$i]|\n";} + } + else + { + $lead_filter_sql[$i] = ''; + if ($DB) {print " no lead filter defined for campaign: $campaign_id[$i]\n";} + if ($DBX) {print " |$lead_filter_id[$i]|\n";} + } + + $DLTsql[$i]=''; + if ($drop_lockout_time[$i] > 0) + { + $DLseconds[$i] = ($drop_lockout_time[$i] * 3600); + $DLTsql[$i] = "and ( ( (status IN('DROP','XDROP')) and (last_local_call_time < CONCAT(DATE_ADD(NOW(), INTERVAL -$DLseconds[$i] SECOND),' ',CURTIME()) ) ) or (status NOT IN('DROP','XDROP')) )"; + if ($DB) {print " drop lockout time $drop_lockout_time[$i]($DLseconds[$i]) defined for $campaign_id[$i]\n";} + if ($DBX) {print " |$DLTsql[$i]|\n";} + } + + ##### 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];"; + } + else + { + $stmtA = "SELECT count(*) FROM vicidial_list where called_since_last_reset='N' and ($list_mix_dialableSQL) and ($all_gmtSQL[$i]) $lead_filter_sql[$i] $DLTsql[$i];"; + } + 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; @@ -1255,271 +1263,211 @@ foreach(@campaign_id) while ($sthArows > $rec_count) { @aryA = $sthA->fetchrow_array; - $NEW_campaign_leads_to_call[$i] = "$aryA[0]"; - if ($DB) {print " NEW leads to call count: $NEW_campaign_leads_to_call[$i]\n";} + $campaign_leads_to_call[$i] = "$aryA[0]"; + if ($DB) {print " leads to call count: $campaign_leads_to_call[$i]\n";} if ($DBX) {print " |$stmtA|\n";} $rec_count++; } $sthA->finish(); - } - ##### IF no NEW leads to be called, error out of this campaign ##### - if ( ($lead_order[$i] =~ / 2nd NEW$| 3rd NEW$| 4th NEW$| 5th NEW$| 6th NEW$/) && ($NEW_campaign_leads_to_call[$i] > 0) && ($list_order_mix[$i] =~ /DISABLED/) ) {$GOOD=1;} - else - { - if ($lead_order[$i] !~ / 2nd NEW$| 3rd NEW$| 4th NEW$| 5th NEW$| 6th NEW$/) + if ( ($lead_order[$i] =~ / 2nd NEW$| 3rd NEW$| 4th NEW$| 5th NEW$| 6th NEW$/) && ($list_order_mix[$i] =~ /DISABLED/) ) { - if ($DB) {print " NO SHUFFLE-NEW-LEADS INTO HOPPER DEFINED FOR LEAD ORDER\n";} + $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];"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + $rec_count=0; + while ($sthArows > $rec_count) + { + @aryA = $sthA->fetchrow_array; + $NEW_campaign_leads_to_call[$i] = "$aryA[0]"; + if ($DB) {print " NEW leads to call count: $NEW_campaign_leads_to_call[$i]\n";} + if ($DBX) {print " |$stmtA|\n";} + $rec_count++; + } + $sthA->finish(); + } + + ##### IF no NEW leads to be called, error out of this campaign ##### + if ( ($lead_order[$i] =~ / 2nd NEW$| 3rd NEW$| 4th NEW$| 5th NEW$| 6th NEW$/) && ($NEW_campaign_leads_to_call[$i] > 0) && ($list_order_mix[$i] =~ /DISABLED/) ) {$GOOD=1;} + else + { + if ($lead_order[$i] !~ / 2nd NEW$| 3rd NEW$| 4th NEW$| 5th NEW$| 6th NEW$/) + { + if ($DB) {print " NO SHUFFLE-NEW-LEADS INTO HOPPER DEFINED FOR LEAD ORDER\n";} + } + else + { + if ($DB) {print " ERROR CANNOT ADD ANY NEW LEADS TO HOPPER\n";} + } + } + + ##### IF no leads to be called, error out of this campaign ##### + if ( ($campaign_leads_to_call[$i] < 1) && ($rec_ct[$i] < 1) ) + { + if ($DB) {print " ERROR CANNOT ADD ANY LEADS TO HOPPER\n";} + if ($VCSdialable_leads[$i] > 0) + { + $stmtA = "UPDATE vicidial_campaign_stats SET dialable_leads='0' where campaign_id='$campaign_id[$i]';"; + $affected_rows = $dbhA->do($stmtA); + if ($DBX) {print "CAMPAIGN STATS: $affected_rows|$stmtA|\n";} + } } else { - if ($DB) {print " ERROR CANNOT ADD ANY NEW LEADS TO HOPPER\n";} - } - } - - ##### IF no leads to be called, error out of this campaign ##### - if ( ($campaign_leads_to_call[$i] < 1) && ($rec_ct[$i] < 1) ) - { - if ($DB) {print " ERROR CANNOT ADD ANY LEADS TO HOPPER\n";} - if ($VCSdialable_leads[$i] > 0) - { - $stmtA = "UPDATE vicidial_campaign_stats SET dialable_leads='0' where campaign_id='$campaign_id[$i]';"; - $affected_rows = $dbhA->do($stmtA); - if ($DBX) {print "CAMPAIGN STATS: $affected_rows|$stmtA|\n";} - } - } - else - { - if ($VCSdialable_leads[$i] != $campaign_leads_to_call[$i]) - { - $stmtA = "UPDATE vicidial_campaign_stats SET dialable_leads='$campaign_leads_to_call[$i]' where campaign_id='$campaign_id[$i]';"; - $affected_rows = $dbhA->do($stmtA); - if ($DBX) {print "CAMPAIGN STATS: $affected_rows|$stmtA|\n";} - } - if ($DB) {print " Getting Leads to add to hopper\n";} - ### grab leads already in hopper so we don't duplicate - $stmtA = "SELECT lead_id FROM $vicidial_hopper where campaign_id='$campaign_id[$i]';"; - 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; - $lead_id_lists = ''; - $rec_countLISTS=0; - while ($sthArows > $rec_countLISTS) - { - @aryA = $sthA->fetchrow_array; - $lead_id_lists .= "'$aryA[0]',"; - $rec_countLISTS++; - } - $sthA->finish(); - $lead_id_lists .= "'0'"; - $order_stmt=''; - $NEW_count = 0; - $NEW_level = 0; - $OTHER_level = $hopper_level[$i]; - if ($lead_order[$i] =~ /^DOWN/) {$order_stmt = 'order by lead_id asc';} - if ($lead_order[$i] =~ /^UP/) {$order_stmt = 'order by lead_id desc';} - if ($lead_order[$i] =~ /^UP LAST NAME/) {$order_stmt = 'order by last_name desc, lead_id asc';} - if ($lead_order[$i] =~ /^DOWN LAST NAME/) {$order_stmt = 'order by last_name, lead_id asc';} - if ($lead_order[$i] =~ /^UP PHONE/) {$order_stmt = 'order by phone_number desc, lead_id asc';} - if ($lead_order[$i] =~ /^DOWN PHONE/) {$order_stmt = 'order by phone_number, lead_id asc';} - if ($lead_order[$i] =~ /^UP COUNT/) {$order_stmt = 'order by called_count desc, lead_id asc';} - if ($lead_order[$i] =~ /^DOWN COUNT/) {$order_stmt = 'order by called_count, lead_id asc';} - if ($lead_order[$i] =~ /^UP LAST CALL TIME/) {$order_stmt = 'order by last_local_call_time desc, lead_id asc';} - if ($lead_order[$i] =~ /^DOWN LAST CALL TIME/) {$order_stmt = 'order by last_local_call_time, lead_id asc';} - if ($lead_order[$i] =~ /^RANDOM/) {$order_stmt = 'order by RAND()';} - if ($lead_order[$i] =~ / 2nd NEW$/) {$NEW_count = 2;} - if ($lead_order[$i] =~ / 3rd NEW$/) {$NEW_count = 3;} - if ($lead_order[$i] =~ / 4th NEW$/) {$NEW_count = 4;} - if ($lead_order[$i] =~ / 5th NEW$/) {$NEW_count = 5;} - if ($lead_order[$i] =~ / 6th NEW$/) {$NEW_count = 6;} - - ### BEGIN recycle grab leads ### - $REC_rec_countLEADS=0; - @REC_leads_to_hopper=@MT; - @REC_lists_to_hopper=@MT; - @REC_phone_to_hopper=@MT; - @REC_gmt_to_hopper=@MT; - @REC_state_to_hopper=@MT; - @REC_status_to_hopper=@MT; - @REC_modify_to_hopper=@MT; - @REC_user_to_hopper=@MT; - if ($rec_ct[$i] > 0) - { - if ($DB) {print " looking for RECYCLE leads, maximum of $hopper_level[$i]\n";} - - $stmtA = "SELECT lead_id,list_id,gmt_offset_now,phone_number,state,status,modify_date,user FROM vicidial_list where $recycle_SQL[$i] and list_id IN($camp_lists[$i]) and lead_id NOT IN($lead_id_lists) and ($all_gmtSQL[$i]) $lead_filter_sql[$i] $DLTsql[$i] limit $hopper_level[$i];"; + if ($VCSdialable_leads[$i] != $campaign_leads_to_call[$i]) + { + $stmtA = "UPDATE vicidial_campaign_stats SET dialable_leads='$campaign_leads_to_call[$i]' where campaign_id='$campaign_id[$i]';"; + $affected_rows = $dbhA->do($stmtA); + if ($DBX) {print "CAMPAIGN STATS: $affected_rows|$stmtA|\n";} + } + if ($DB) {print " Getting Leads to add to hopper\n";} + ### grab leads already in hopper so we don't duplicate + $stmtA = "SELECT lead_id FROM $vicidial_hopper where campaign_id='$campaign_id[$i]';"; 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 ($DB) {print " RECYCLE leads to call count: $sthArows\n";} - if ($DBX) {print " |$stmtA|\n";} - while ($sthArows > $REC_rec_countLEADS) + $lead_id_lists = ''; + $rec_countLISTS=0; + while ($sthArows > $rec_countLISTS) { @aryA = $sthA->fetchrow_array; - $REC_leads_to_hopper[$REC_rec_countLEADS] = "$aryA[0]"; - $REC_lists_to_hopper[$REC_rec_countLEADS] = "$aryA[1]"; - $REC_gmt_to_hopper[$REC_rec_countLEADS] = "$aryA[2]"; - $REC_phone_to_hopper[$REC_rec_countLEADS] = "$aryA[3]"; - $REC_state_to_hopper[$REC_rec_countLEADS] = "$aryA[4]"; - $REC_status_to_hopper[$REC_rec_countLEADS] = "$aryA[5]"; - $REC_modify_to_hopper[$REC_rec_countLEADS] = "$aryA[6]"; - $REC_user_to_hopper[$REC_rec_countLEADS] = "$aryA[7]"; - if ($DB_show_offset) {print "LEAD_ADD: $aryA[2] $aryA[3] $aryA[4]\n";} - $REC_rec_countLEADS++; + $lead_id_lists .= "'$aryA[0]',"; + $rec_countLISTS++; } $sthA->finish(); - } - else - { - if ($DB) {print " NO RECYCLE-LEADS INTO HOPPER DEFINED\n";} - } - ### END recycle grab leads ### + $lead_id_lists .= "'0'"; + $order_stmt=''; + $NEW_count = 0; + $NEW_level = 0; + $OTHER_level = $hopper_level[$i]; + if ($lead_order[$i] =~ /^DOWN/) {$order_stmt = 'order by lead_id asc';} + if ($lead_order[$i] =~ /^UP/) {$order_stmt = 'order by lead_id desc';} + if ($lead_order[$i] =~ /^UP LAST NAME/) {$order_stmt = 'order by last_name desc, lead_id asc';} + if ($lead_order[$i] =~ /^DOWN LAST NAME/) {$order_stmt = 'order by last_name, lead_id asc';} + if ($lead_order[$i] =~ /^UP PHONE/) {$order_stmt = 'order by phone_number desc, lead_id asc';} + if ($lead_order[$i] =~ /^DOWN PHONE/) {$order_stmt = 'order by phone_number, lead_id asc';} + if ($lead_order[$i] =~ /^UP COUNT/) {$order_stmt = 'order by called_count desc, lead_id asc';} + if ($lead_order[$i] =~ /^DOWN COUNT/) {$order_stmt = 'order by called_count, lead_id asc';} + if ($lead_order[$i] =~ /^UP LAST CALL TIME/) {$order_stmt = 'order by last_local_call_time desc, lead_id asc';} + if ($lead_order[$i] =~ /^DOWN LAST CALL TIME/) {$order_stmt = 'order by last_local_call_time, lead_id asc';} + if ($lead_order[$i] =~ /^RANDOM/) {$order_stmt = 'order by RAND()';} + if ($lead_order[$i] =~ /^UP RANK/) {$order_stmt = 'order by rank desc, lead_id asc';} + if ($lead_order[$i] =~ /^DOWN RANK/) {$order_stmt = 'order by rank, lead_id asc';} + if ($lead_order[$i] =~ /^UP OWNER/) {$order_stmt = 'order by owner desc, lead_id asc';} + if ($lead_order[$i] =~ /^DOWN OWNER/) {$order_stmt = 'order by owner, lead_id asc';} + if ($lead_order[$i] =~ / 2nd NEW$/) {$NEW_count = 2;} + if ($lead_order[$i] =~ / 3rd NEW$/) {$NEW_count = 3;} + if ($lead_order[$i] =~ / 4th NEW$/) {$NEW_count = 4;} + if ($lead_order[$i] =~ / 5th NEW$/) {$NEW_count = 5;} + if ($lead_order[$i] =~ / 6th NEW$/) {$NEW_count = 6;} - - ### BEGIN NEW grab leads ### - $NEW_rec_countLEADS=0; - @NEW_leads_to_hopper=@MT; - @NEW_lists_to_hopper=@MT; - @NEW_phone_to_hopper=@MT; - @NEW_gmt_to_hopper=@MT; - @NEW_state_to_hopper=@MT; - @NEW_status_to_hopper=@MT; - @NEW_modify_to_hopper=@MT; - @NEW_user_to_hopper=@MT; - if ( ($NEW_count > 0) && ($list_order_mix[$i] =~ /DISABLED/) ) - { - $NEW_level = int($hopper_level[$i] / $NEW_count); - $OTHER_level = ($hopper_level[$i] - $NEW_level); - # $order_stmt = 'order by called_count, lead_id asc'; - if ($DB) {print " looking for $NEW_level NEW leads mixed in with $OTHER_level other leads\n";} - - $stmtA = "SELECT lead_id,list_id,gmt_offset_now,phone_number,state,status,modify_date,user 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) and ($all_gmtSQL[$i]) $lead_filter_sql[$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; - $sthArows=$sthA->rows; - while ($sthArows > $NEW_rec_countLEADS) + ### BEGIN recycle grab leads ### + $REC_rec_countLEADS=0; + @REC_leads_to_hopper=@MT; + @REC_lists_to_hopper=@MT; + @REC_phone_to_hopper=@MT; + @REC_gmt_to_hopper=@MT; + @REC_state_to_hopper=@MT; + @REC_status_to_hopper=@MT; + @REC_modify_to_hopper=@MT; + @REC_user_to_hopper=@MT; + if ($rec_ct[$i] > 0) { - @aryA = $sthA->fetchrow_array; - $NEW_leads_to_hopper[$NEW_rec_countLEADS] = "$aryA[0]"; - $NEW_lists_to_hopper[$NEW_rec_countLEADS] = "$aryA[1]"; - $NEW_gmt_to_hopper[$NEW_rec_countLEADS] = "$aryA[2]"; - $NEW_phone_to_hopper[$NEW_rec_countLEADS] = "$aryA[3]"; - $NEW_state_to_hopper[$NEW_rec_countLEADS] = "$aryA[4]"; - $NEW_status_to_hopper[$NEW_rec_countLEADS] = "$aryA[5]"; - $NEW_modify_to_hopper[$NEW_rec_countLEADS] = "$aryA[6]"; - $NEW_user_to_hopper[$NEW_rec_countLEADS] = "$aryA[7]"; - if ($DB_show_offset) {print "LEAD_ADD: $aryA[2] $aryA[3] $aryA[4]\n";} - $NEW_rec_countLEADS++; - } - $OTHER_level = ($hopper_level[$i] - $NEW_rec_countLEADS); - $sthA->finish(); - } + if ($DB) {print " looking for RECYCLE leads, maximum of $hopper_level[$i]\n";} - ### BEGIN standard grab leads ### - $rec_countLEADS=0; - $NEW_dec=99; - $NEW_in=0; - $rec_count=0; - $REC_insert_count=0; - @leads_to_hopper=@MT; - @lists_to_hopper=@MT; - @gmt_to_hopper=@MT; - @state_to_hopper=@MT; - @phone_to_hopper=@MT; - @status_to_hopper=@MT; - @modify_to_hopper=@MT; - @user_to_hopper=@MT; - if ($campaign_leads_to_call[$i] > 0) - { - if ($DB) {print " lead call order: $order_stmt\n";} - - if ($list_order_mix[$i] =~ /DISABLED/) - { - $stmtA = "SELECT lead_id,list_id,gmt_offset_now,phone_number,state,status,modify_date,user 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) and ($all_gmtSQL[$i]) $lead_filter_sql[$i] $DLTsql[$i] $order_stmt limit $OTHER_level;"; + $stmtA = "SELECT lead_id,list_id,gmt_offset_now,phone_number,state,status,modify_date,user FROM vicidial_list where $recycle_SQL[$i] and list_id IN($camp_lists[$i]) and lead_id NOT IN($lead_id_lists) and ($all_gmtSQL[$i]) $lead_filter_sql[$i] $DLTsql[$i] 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; $sthArows=$sthA->rows; - while ($sthArows > $rec_count) + if ($DB) {print " RECYCLE leads to call count: $sthArows\n";} + if ($DBX) {print " |$stmtA|\n";} + while ($sthArows > $REC_rec_countLEADS) { @aryA = $sthA->fetchrow_array; - if ( ($NEW_count > 0) && ($NEW_rec_countLEADS > $NEW_in) ) - { - if ($DB_show_offset) {print "NEW_COUNT: $NEW_count|$NEW_dec|$NEW_in|$NEW_rec_countLEADS\n";} - if ($NEW_count > $NEW_dec) - { - $NEW_dec++; - } - else - { - $leads_to_hopper[$rec_countLEADS] = "$NEW_leads_to_hopper[$NEW_in]"; - $lists_to_hopper[$rec_countLEADS] = "$NEW_lists_to_hopper[$NEW_in]"; - $gmt_to_hopper[$rec_countLEADS] = "$NEW_gmt_to_hopper[$NEW_in]"; - $state_to_hopper[$rec_countLEADS] = "$NEW_state_to_hopper[$NEW_in]"; - $phone_to_hopper[$rec_countLEADS] = "$NEW_phone_to_hopper[$NEW_in]"; - $status_to_hopper[$rec_countLEADS] = "$NEW_status_to_hopper[$NEW_in]"; - $modify_to_hopper[$rec_countLEADS] = "$NEW_modify_to_hopper[$NEW_in]"; - $user_to_hopper[$rec_countLEADS] = "$NEW_user_to_hopper[$NEW_in]"; - if ($DB_show_offset) {print "LEAD_ADD: $NEW_leads_to_hopper[$NEW_in] $NEW_phone_to_hopper[$NEW_in]\n";} - $rec_countLEADS++; - $NEW_in++; - $NEW_dec=2; - } - } - if ($REC_rec_countLEADS > $REC_insert_count) - { - $leads_to_hopper[$rec_countLEADS] = "$REC_leads_to_hopper[$REC_insert_count]"; - $lists_to_hopper[$rec_countLEADS] = "$REC_lists_to_hopper[$REC_insert_count]"; - $gmt_to_hopper[$rec_countLEADS] = "$REC_gmt_to_hopper[$REC_insert_count]"; - $state_to_hopper[$rec_countLEADS] = "$REC_state_to_hopper[$REC_insert_count]"; - $phone_to_hopper[$rec_countLEADS] = "$REC_phone_to_hopper[$REC_insert_count]"; - $status_to_hopper[$rec_countLEADS] = "$REC_status_to_hopper[$REC_insert_count]"; - $modify_to_hopper[$rec_countLEADS] = "$REC_modify_to_hopper[$REC_insert_count]"; - $user_to_hopper[$rec_countLEADS] = "$REC_user_to_hopper[$REC_insert_count]"; - $rec_countLEADS++; - $REC_insert_count++; - } - $leads_to_hopper[$rec_countLEADS] = "$aryA[0]"; - $lists_to_hopper[$rec_countLEADS] = "$aryA[1]"; - $gmt_to_hopper[$rec_countLEADS] = "$aryA[2]"; - $state_to_hopper[$rec_countLEADS] = "$aryA[4]"; - $phone_to_hopper[$rec_countLEADS] = "$aryA[3]"; - $status_to_hopper[$rec_countLEADS] = "$aryA[5]"; - $modify_to_hopper[$rec_countLEADS] = "$aryA[6]"; - $user_to_hopper[$rec_countLEADS] = "$aryA[7]"; + $REC_leads_to_hopper[$REC_rec_countLEADS] = "$aryA[0]"; + $REC_lists_to_hopper[$REC_rec_countLEADS] = "$aryA[1]"; + $REC_gmt_to_hopper[$REC_rec_countLEADS] = "$aryA[2]"; + $REC_phone_to_hopper[$REC_rec_countLEADS] = "$aryA[3]"; + $REC_state_to_hopper[$REC_rec_countLEADS] = "$aryA[4]"; + $REC_status_to_hopper[$REC_rec_countLEADS] = "$aryA[5]"; + $REC_modify_to_hopper[$REC_rec_countLEADS] = "$aryA[6]"; + $REC_user_to_hopper[$REC_rec_countLEADS] = "$aryA[7]"; if ($DB_show_offset) {print "LEAD_ADD: $aryA[2] $aryA[3] $aryA[4]\n";} - $rec_countLEADS++; - $rec_count++; + $REC_rec_countLEADS++; } - $sthA->finish(); + $sthA->finish(); } - - ##### LIST MIX LEADS GRAB ##### else { - $USX='_____'; - $x=0; - $z=0; - @LM_results=@MT; - foreach(@list_mixARY) + if ($DB) {print " NO RECYCLE-LEADS INTO HOPPER DEFINED\n";} + } + ### END recycle grab leads ### + + + ### BEGIN NEW grab leads ### + $NEW_rec_countLEADS=0; + @NEW_leads_to_hopper=@MT; + @NEW_lists_to_hopper=@MT; + @NEW_phone_to_hopper=@MT; + @NEW_gmt_to_hopper=@MT; + @NEW_state_to_hopper=@MT; + @NEW_status_to_hopper=@MT; + @NEW_modify_to_hopper=@MT; + @NEW_user_to_hopper=@MT; + if ( ($NEW_count > 0) && ($list_order_mix[$i] =~ /DISABLED/) ) + { + $NEW_level = int($hopper_level[$i] / $NEW_count); + $OTHER_level = ($hopper_level[$i] - $NEW_level); + # $order_stmt = 'order by called_count, lead_id asc'; + if ($DB) {print " looking for $NEW_level NEW leads mixed in with $OTHER_level other leads\n";} + + $stmtA = "SELECT lead_id,list_id,gmt_offset_now,phone_number,state,status,modify_date,user 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) and ($all_gmtSQL[$i]) $lead_filter_sql[$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; + $sthArows=$sthA->rows; + while ($sthArows > $NEW_rec_countLEADS) { - $rec_count=0; - @list_mix_stepARY=@MT; + @aryA = $sthA->fetchrow_array; + $NEW_leads_to_hopper[$NEW_rec_countLEADS] = "$aryA[0]"; + $NEW_lists_to_hopper[$NEW_rec_countLEADS] = "$aryA[1]"; + $NEW_gmt_to_hopper[$NEW_rec_countLEADS] = "$aryA[2]"; + $NEW_phone_to_hopper[$NEW_rec_countLEADS] = "$aryA[3]"; + $NEW_state_to_hopper[$NEW_rec_countLEADS] = "$aryA[4]"; + $NEW_status_to_hopper[$NEW_rec_countLEADS] = "$aryA[5]"; + $NEW_modify_to_hopper[$NEW_rec_countLEADS] = "$aryA[6]"; + $NEW_user_to_hopper[$NEW_rec_countLEADS] = "$aryA[7]"; + if ($DB_show_offset) {print "LEAD_ADD: $aryA[2] $aryA[3] $aryA[4]\n";} + $NEW_rec_countLEADS++; + } + $OTHER_level = ($hopper_level[$i] - $NEW_rec_countLEADS); + $sthA->finish(); + } - @list_mix_stepARY = split(/\|/,$list_mixARY[$x]); - $LM_step_goal[$x] = ( ($list_mix_stepARY[2] / 100) * $hopper_level[$i]); - $LM_step_even[$x] = ( (100 / $list_mix_stepARY[2]) * 100000); - $list_mix_stepARY[3] =~ s/ /','/gi; - $list_mix_stepARY[3] =~ s/^',|,'-//gi; - 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]))"; + ### BEGIN standard grab leads ### + $rec_countLEADS=0; + $NEW_dec=99; + $NEW_in=0; + $rec_count=0; + $REC_insert_count=0; + @leads_to_hopper=@MT; + @lists_to_hopper=@MT; + @gmt_to_hopper=@MT; + @state_to_hopper=@MT; + @phone_to_hopper=@MT; + @status_to_hopper=@MT; + @modify_to_hopper=@MT; + @user_to_hopper=@MT; + if ($campaign_leads_to_call[$i] > 0) + { + if ($DB) {print " lead call order: $order_stmt\n";} - $stmtA = "SELECT lead_id,list_id,gmt_offset_now,phone_number,state,status,modify_date,user FROM vicidial_list where called_since_last_reset='N' and $list_mix_dialableSQL and lead_id NOT IN($lead_id_lists) and ($all_gmtSQL[$i]) $lead_filter_sql[$i] $DLTsql[$i] $order_stmt limit $LM_step_goal[$x];"; + if ($list_order_mix[$i] =~ /DISABLED/) + { + $stmtA = "SELECT lead_id,list_id,gmt_offset_now,phone_number,state,status,modify_date,user 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) and ($all_gmtSQL[$i]) $lead_filter_sql[$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; @@ -1527,155 +1475,236 @@ foreach(@campaign_id) while ($sthArows > $rec_count) { @aryA = $sthA->fetchrow_array; - if ($mix_method[$i] =~ /RANDOM/) + if ( ($NEW_count > 0) && ($NEW_rec_countLEADS > $NEW_in) ) { - $order = int( rand(9999999)) + 10000000; - } - else - { - if ($mix_method[$i] =~ /EVEN_MIX/) + if ($DB_show_offset) {print "NEW_COUNT: $NEW_count|$NEW_dec|$NEW_in|$NEW_rec_countLEADS\n";} + if ($NEW_count > $NEW_dec) { - $order = ( ($rec_count * $LM_step_even[$x]) + $x); + $NEW_dec++; } else { - $order = ( ($x * 1000000) + $rec_count); + $leads_to_hopper[$rec_countLEADS] = "$NEW_leads_to_hopper[$NEW_in]"; + $lists_to_hopper[$rec_countLEADS] = "$NEW_lists_to_hopper[$NEW_in]"; + $gmt_to_hopper[$rec_countLEADS] = "$NEW_gmt_to_hopper[$NEW_in]"; + $state_to_hopper[$rec_countLEADS] = "$NEW_state_to_hopper[$NEW_in]"; + $phone_to_hopper[$rec_countLEADS] = "$NEW_phone_to_hopper[$NEW_in]"; + $status_to_hopper[$rec_countLEADS] = "$NEW_status_to_hopper[$NEW_in]"; + $modify_to_hopper[$rec_countLEADS] = "$NEW_modify_to_hopper[$NEW_in]"; + $user_to_hopper[$rec_countLEADS] = "$NEW_user_to_hopper[$NEW_in]"; + if ($DB_show_offset) {print "LEAD_ADD: $NEW_leads_to_hopper[$NEW_in] $NEW_phone_to_hopper[$NEW_in]\n";} + $rec_countLEADS++; + $NEW_in++; + $NEW_dec=2; } } - $LM_results[$z] = "$order$USX$aryA[0]$USX$aryA[1]$USX$aryA[2]$USX$aryA[3]$USX$aryA[4]$USX$aryA[5]$USX$aryA[6]$USX$aryA[7]"; - # if ($DBX) {print " $z|$LM_results[$z]\n";} - - $rec_count++; - $z++; - } - $sthA->finish(); - - $x++; - } - - @LM_results_SORT = sort { $a <=> $b } @LM_results; - - $w=0; - while ($z > $w) - { - @aryA = split(/_____/,$LM_results_SORT[$w]); - if ($REC_rec_countLEADS > $REC_insert_count) - { - $leads_to_hopper[$rec_countLEADS] = "$REC_leads_to_hopper[$REC_insert_count]"; - $lists_to_hopper[$rec_countLEADS] = "$REC_lists_to_hopper[$REC_insert_count]"; - $gmt_to_hopper[$rec_countLEADS] = "$REC_gmt_to_hopper[$REC_insert_count]"; - $state_to_hopper[$rec_countLEADS] = "$REC_state_to_hopper[$REC_insert_count]"; - $phone_to_hopper[$rec_countLEADS] = "$REC_phone_to_hopper[$REC_insert_count]"; - $status_to_hopper[$rec_countLEADS] = "$REC_status_to_hopper[$REC_insert_count]"; - $modify_to_hopper[$rec_countLEADS] = "$REC_modify_to_hopper[$REC_insert_count]"; - $user_to_hopper[$rec_countLEADS] = "$REC_user_to_hopper[$REC_insert_count]"; + if ($REC_rec_countLEADS > $REC_insert_count) + { + $leads_to_hopper[$rec_countLEADS] = "$REC_leads_to_hopper[$REC_insert_count]"; + $lists_to_hopper[$rec_countLEADS] = "$REC_lists_to_hopper[$REC_insert_count]"; + $gmt_to_hopper[$rec_countLEADS] = "$REC_gmt_to_hopper[$REC_insert_count]"; + $state_to_hopper[$rec_countLEADS] = "$REC_state_to_hopper[$REC_insert_count]"; + $phone_to_hopper[$rec_countLEADS] = "$REC_phone_to_hopper[$REC_insert_count]"; + $status_to_hopper[$rec_countLEADS] = "$REC_status_to_hopper[$REC_insert_count]"; + $modify_to_hopper[$rec_countLEADS] = "$REC_modify_to_hopper[$REC_insert_count]"; + $user_to_hopper[$rec_countLEADS] = "$REC_user_to_hopper[$REC_insert_count]"; + $rec_countLEADS++; + $REC_insert_count++; + } + $leads_to_hopper[$rec_countLEADS] = "$aryA[0]"; + $lists_to_hopper[$rec_countLEADS] = "$aryA[1]"; + $gmt_to_hopper[$rec_countLEADS] = "$aryA[2]"; + $state_to_hopper[$rec_countLEADS] = "$aryA[4]"; + $phone_to_hopper[$rec_countLEADS] = "$aryA[3]"; + $status_to_hopper[$rec_countLEADS] = "$aryA[5]"; + $modify_to_hopper[$rec_countLEADS] = "$aryA[6]"; + $user_to_hopper[$rec_countLEADS] = "$aryA[7]"; + if ($DB_show_offset) {print "LEAD_ADD: $aryA[2] $aryA[3] $aryA[4]\n";} $rec_countLEADS++; - $REC_insert_count++; + $rec_count++; + } + $sthA->finish(); + } + + ##### LIST MIX LEADS GRAB ##### + else + { + $USX='_____'; + $x=0; + $z=0; + @LM_results=@MT; + foreach(@list_mixARY) + { + $rec_count=0; + @list_mix_stepARY=@MT; + + @list_mix_stepARY = split(/\|/,$list_mixARY[$x]); + $LM_step_goal[$x] = ( ($list_mix_stepARY[2] / 100) * $hopper_level[$i]); + $LM_step_even[$x] = ( (100 / $list_mix_stepARY[2]) * 100000); + $list_mix_stepARY[3] =~ s/ /','/gi; + $list_mix_stepARY[3] =~ s/^',|,'-//gi; + 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]))"; + + $stmtA = "SELECT lead_id,list_id,gmt_offset_now,phone_number,state,status,modify_date,user FROM vicidial_list where called_since_last_reset='N' and $list_mix_dialableSQL and lead_id NOT IN($lead_id_lists) and ($all_gmtSQL[$i]) $lead_filter_sql[$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; + $sthArows=$sthA->rows; + while ($sthArows > $rec_count) + { + @aryA = $sthA->fetchrow_array; + if ($mix_method[$i] =~ /RANDOM/) + { + $order = int( rand(9999999)) + 10000000; + } + else + { + if ($mix_method[$i] =~ /EVEN_MIX/) + { + $order = ( ($rec_count * $LM_step_even[$x]) + $x); + } + else + { + $order = ( ($x * 1000000) + $rec_count); + } + } + $LM_results[$z] = "$order$USX$aryA[0]$USX$aryA[1]$USX$aryA[2]$USX$aryA[3]$USX$aryA[4]$USX$aryA[5]$USX$aryA[6]$USX$aryA[7]"; + # if ($DBX) {print " $z|$LM_results[$z]\n";} + + $rec_count++; + $z++; + } + $sthA->finish(); + + $x++; + } + + @LM_results_SORT = sort { $a <=> $b } @LM_results; + + $w=0; + while ($z > $w) + { + @aryA = split(/_____/,$LM_results_SORT[$w]); + if ($REC_rec_countLEADS > $REC_insert_count) + { + $leads_to_hopper[$rec_countLEADS] = "$REC_leads_to_hopper[$REC_insert_count]"; + $lists_to_hopper[$rec_countLEADS] = "$REC_lists_to_hopper[$REC_insert_count]"; + $gmt_to_hopper[$rec_countLEADS] = "$REC_gmt_to_hopper[$REC_insert_count]"; + $state_to_hopper[$rec_countLEADS] = "$REC_state_to_hopper[$REC_insert_count]"; + $phone_to_hopper[$rec_countLEADS] = "$REC_phone_to_hopper[$REC_insert_count]"; + $status_to_hopper[$rec_countLEADS] = "$REC_status_to_hopper[$REC_insert_count]"; + $modify_to_hopper[$rec_countLEADS] = "$REC_modify_to_hopper[$REC_insert_count]"; + $user_to_hopper[$rec_countLEADS] = "$REC_user_to_hopper[$REC_insert_count]"; + $rec_countLEADS++; + $REC_insert_count++; + } + $leads_to_hopper[$rec_countLEADS] = "$aryA[1]"; + $lists_to_hopper[$rec_countLEADS] = "$aryA[2]"; + $gmt_to_hopper[$rec_countLEADS] = "$aryA[3]"; + $phone_to_hopper[$rec_countLEADS] = "$aryA[4]"; + $state_to_hopper[$rec_countLEADS] = "$aryA[5]"; + $status_to_hopper[$rec_countLEADS] = "$aryA[6]"; + $modify_to_hopper[$rec_countLEADS] = "$aryA[7]"; + $user_to_hopper[$rec_countLEADS] = "$aryA[8]"; + if ($DB_show_offset) {print "LEAD_ADD: $aryA[3] $aryA[4] $aryA[5]\n";} + if ($DBX) {print " $w|$LM_results[$w]\n";} + $rec_countLEADS++; + $w++; } - $leads_to_hopper[$rec_countLEADS] = "$aryA[1]"; - $lists_to_hopper[$rec_countLEADS] = "$aryA[2]"; - $gmt_to_hopper[$rec_countLEADS] = "$aryA[3]"; - $phone_to_hopper[$rec_countLEADS] = "$aryA[4]"; - $state_to_hopper[$rec_countLEADS] = "$aryA[5]"; - $status_to_hopper[$rec_countLEADS] = "$aryA[6]"; - $modify_to_hopper[$rec_countLEADS] = "$aryA[7]"; - $user_to_hopper[$rec_countLEADS] = "$aryA[8]"; - if ($DB_show_offset) {print "LEAD_ADD: $aryA[3] $aryA[4] $aryA[5]\n";} - if ($DBX) {print " $w|$LM_results[$w]\n";} - $rec_countLEADS++; - $w++; } } - } - ### finish inserting any recycled leads if any - while ($REC_rec_countLEADS > $REC_insert_count) - { - $leads_to_hopper[$rec_countLEADS] = "$REC_leads_to_hopper[$REC_insert_count]"; - $lists_to_hopper[$rec_countLEADS] = "$REC_lists_to_hopper[$REC_insert_count]"; - $gmt_to_hopper[$rec_countLEADS] = "$REC_gmt_to_hopper[$REC_insert_count]"; - $state_to_hopper[$rec_countLEADS] = "$REC_state_to_hopper[$REC_insert_count]"; - $phone_to_hopper[$rec_countLEADS] = "$REC_phone_to_hopper[$REC_insert_count]"; - $status_to_hopper[$rec_countLEADS] = "$REC_status_to_hopper[$REC_insert_count]"; - $modify_to_hopper[$rec_countLEADS] = "$REC_modify_to_hopper[$REC_insert_count]"; - $user_to_hopper[$rec_countLEADS] = "$REC_user_to_hopper[$REC_insert_count]"; - $rec_countLEADS++; - $REC_insert_count++; - } - - if ($DB) {print " Adding to hopper: $rec_countLEADS\n";} - $event_string = "|$campaign_id[$i]|Added to hopper $rec_countLEADS|"; - &event_logger; - - $h=0; - foreach(@leads_to_hopper) - { - if ($leads_to_hopper[$h] != '0') + ### finish inserting any recycled leads if any + while ($REC_rec_countLEADS > $REC_insert_count) { - $DNClead=0; - if ($use_internal_dnc[$i] =~ /Y/) - { - if ($DB) {print " Doing DNC Check: $phone_to_hopper[$h] - $use_internal_dnc[$i]\n";} - $stmtA = "SELECT count(*) from vicidial_dnc where phone_number='$phone_to_hopper[$h]';"; - $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; - $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; - $sthArows=$sthA->rows; - $rec_count=0; - while ($sthArows > $rec_count) - { - @aryA = $sthA->fetchrow_array; - $DNClead = "$aryA[0]"; - $rec_count++; - } - $sthA->finish(); - if ($DNClead != '0') - { - $stmtA = "UPDATE vicidial_list SET status='DNCL' where lead_id='$leads_to_hopper[$h]';"; - $affected_rows = $dbhA->do($stmtA); - if ($DBX) {print "Flagging DNC lead: $affected_rows $phone_to_hopper[$h]\n";} - } - } - if ( ($use_campaign_dnc[$i] =~ /Y/) && ($DNClead == '0') ) - { - if ($DB) {print "Doing CAMP DNC Check: $phone_to_hopper[$h] - $use_campaign_dnc[$i]\n";} - $stmtA = "SELECT count(*) from vicidial_campaign_dnc where phone_number='$phone_to_hopper[$h]' and campaign_id='$campaign_id[$i]';"; - $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; - $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; - $sthArows=$sthA->rows; - $rec_count=0; - while ($sthArows > $rec_count) - { - @aryA = $sthA->fetchrow_array; - $DNClead = "$aryA[0]"; - $rec_count++; - } - $sthA->finish(); - if ($DNClead != '0') - { - $stmtA = "UPDATE vicidial_list SET status='DNCC' where lead_id='$leads_to_hopper[$h]';"; - $affected_rows = $dbhA->do($stmtA); - if ($DBX) {print "Flagging DNC lead: $affected_rows $phone_to_hopper[$h] $campaign_id[$i]\n";} - } - } - if ($DNClead == '0') - { - $stmtA = "INSERT INTO $vicidial_hopper (lead_id,campaign_id,status,user,list_id,gmt_offset_now,state,priority) values('$leads_to_hopper[$h]','$campaign_id[$i]','READY','','$lists_to_hopper[$h]','$gmt_to_hopper[$h]','$state_to_hopper[$h]','0');"; - $affected_rows = $dbhA->do($stmtA); - if ($DBX) {print "LEAD INSERTED: $affected_rows|$leads_to_hopper[$h]|\n";} - if ($DB_detail) - { - $detail_string = "|$campaign_id[$i]|$leads_to_hopper[$h]|$phone_to_hopper[$h]|$state_to_hopper[$h]|$gmt_to_hopper[$h]|$status_to_hopper[$h]|$modify_to_hopper[$h]|$user_to_hopper[$h]|"; - &detail_logger; - } - } + $leads_to_hopper[$rec_countLEADS] = "$REC_leads_to_hopper[$REC_insert_count]"; + $lists_to_hopper[$rec_countLEADS] = "$REC_lists_to_hopper[$REC_insert_count]"; + $gmt_to_hopper[$rec_countLEADS] = "$REC_gmt_to_hopper[$REC_insert_count]"; + $state_to_hopper[$rec_countLEADS] = "$REC_state_to_hopper[$REC_insert_count]"; + $phone_to_hopper[$rec_countLEADS] = "$REC_phone_to_hopper[$REC_insert_count]"; + $status_to_hopper[$rec_countLEADS] = "$REC_status_to_hopper[$REC_insert_count]"; + $modify_to_hopper[$rec_countLEADS] = "$REC_modify_to_hopper[$REC_insert_count]"; + $user_to_hopper[$rec_countLEADS] = "$REC_user_to_hopper[$REC_insert_count]"; + $rec_countLEADS++; + $REC_insert_count++; + } + + if ($DB) {print " Adding to hopper: $rec_countLEADS\n";} + $event_string = "|$campaign_id[$i]|Added to hopper $rec_countLEADS|"; + &event_logger; + + $h=0; + foreach(@leads_to_hopper) + { + if ($leads_to_hopper[$h] != '0') + { + $DNClead=0; + if ($use_internal_dnc[$i] =~ /Y/) + { + if ($DB) {print " Doing DNC Check: $phone_to_hopper[$h] - $use_internal_dnc[$i]\n";} + $stmtA = "SELECT count(*) from vicidial_dnc where phone_number='$phone_to_hopper[$h]';"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + $rec_count=0; + while ($sthArows > $rec_count) + { + @aryA = $sthA->fetchrow_array; + $DNClead = "$aryA[0]"; + $rec_count++; + } + $sthA->finish(); + if ($DNClead != '0') + { + $stmtA = "UPDATE vicidial_list SET status='DNCL' where lead_id='$leads_to_hopper[$h]';"; + $affected_rows = $dbhA->do($stmtA); + if ($DBX) {print "Flagging DNC lead: $affected_rows $phone_to_hopper[$h]\n";} + } + } + if ( ($use_campaign_dnc[$i] =~ /Y/) && ($DNClead == '0') ) + { + if ($DB) {print "Doing CAMP DNC Check: $phone_to_hopper[$h] - $use_campaign_dnc[$i]\n";} + $stmtA = "SELECT count(*) from vicidial_campaign_dnc where phone_number='$phone_to_hopper[$h]' and campaign_id='$campaign_id[$i]';"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + $rec_count=0; + while ($sthArows > $rec_count) + { + @aryA = $sthA->fetchrow_array; + $DNClead = "$aryA[0]"; + $rec_count++; + } + $sthA->finish(); + if ($DNClead != '0') + { + $stmtA = "UPDATE vicidial_list SET status='DNCC' where lead_id='$leads_to_hopper[$h]';"; + $affected_rows = $dbhA->do($stmtA); + if ($DBX) {print "Flagging DNC lead: $affected_rows $phone_to_hopper[$h] $campaign_id[$i]\n";} + } + } + if ($DNClead == '0') + { + $stmtA = "INSERT INTO $vicidial_hopper (lead_id,campaign_id,status,user,list_id,gmt_offset_now,state,priority) values('$leads_to_hopper[$h]','$campaign_id[$i]','READY','','$lists_to_hopper[$h]','$gmt_to_hopper[$h]','$state_to_hopper[$h]','0');"; + $affected_rows = $dbhA->do($stmtA); + if ($DBX) {print "LEAD INSERTED: $affected_rows|$leads_to_hopper[$h]|\n";} + if ($DB_detail) + { + $detail_string = "|$campaign_id[$i]|$leads_to_hopper[$h]|$phone_to_hopper[$h]|$state_to_hopper[$h]|$gmt_to_hopper[$h]|$status_to_hopper[$h]|$modify_to_hopper[$h]|$user_to_hopper[$h]|"; + &detail_logger; + } + } + } + $h++; } - $h++; - } if ($DB) {print " DONE with this campaign\n";} + } } + } - - $i++; } @@ -1683,40 +1712,40 @@ foreach(@campaign_id) $dbhA->disconnect(); if($DB) -{ -### calculate time to run script ### -$secY = time(); -$secZ = ($secY - $secT); + { + ### calculate time to run script ### + $secY = time(); + $secZ = ($secY - $secT); -if (!$q) {print "DONE. Script execution time in seconds: $secZ\n";} -} + if (!$q) {print "DONE. Script execution time in seconds: $secZ\n";} + } exit; sub event_logger -{ -if ($SYSLOG) { - ### open the log file for writing ### - open(Lout, ">>$VDHLOGfile") - || die "Can't open $VDHLOGfile: $!\n"; - print Lout "$now_date|$event_string|\n"; - close(Lout); + if ($SYSLOG) + { + ### open the log file for writing ### + open(Lout, ">>$VDHLOGfile") + || die "Can't open $VDHLOGfile: $!\n"; + print Lout "$now_date|$event_string|\n"; + close(Lout); + } + $event_string=''; } -$event_string=''; -} sub detail_logger -{ -if ($SYSLOG) { - ### open the log file for writing ### - open(LDout, ">>$VDHDLOGfile") - || die "Can't open $VDHDLOGfile: $!\n"; - print LDout "$now_date|$detail_string|\n"; - close(LDout); + if ($SYSLOG) + { + ### open the log file for writing ### + open(LDout, ">>$VDHDLOGfile") + || die "Can't open $VDHDLOGfile: $!\n"; + print LDout "$now_date|$detail_string|\n"; + close(LDout); + } + $detail_string=''; } -$detail_string=''; -} diff --git a/bin/AST_VDsales_export.pl b/bin/AST_VDsales_export.pl index 181fde5e..4ffd760a 100644 --- a/bin/AST_VDsales_export.pl +++ b/bin/AST_VDsales_export.pl @@ -20,6 +20,7 @@ # 90620-0900 - Formatting fixes # 90627-0757 - Added time addition when transfer recordings is enabled # 90710-0514 - Fixes for data output formatting changes +# 90721-1314 - Added rank and owner as vicidial_list fields # $txt = '.txt'; @@ -428,7 +429,7 @@ $TOTAL_SALES=0; ########################################################################### ########### CURRENT DAY SALES GATHERING outbound-only: vicidial_log ###### ########################################################################### -$stmtA = "select vicidial_log.user,first_name,last_name,address1,address2,city,state,postal_code,vicidial_list.phone_number,vicidial_list.email,security_phrase,vicidial_list.comments,call_date,vicidial_list.lead_id,vicidial_users.full_name,vicidial_log.status,vicidial_list.vendor_lead_code,vicidial_list.source_id,vicidial_log.list_id,title,address3,last_local_call_time,uniqueid,length_in_sec from vicidial_list,vicidial_log,vicidial_users where campaign_id IN($campaignSQL) $sale_statusesSQL and call_date > '$shipdate 00:00:01' and call_date < '$shipdate 23:59:59' and vicidial_log.lead_id=vicidial_list.lead_id and vicidial_users.user=vicidial_log.user order by call_date;"; +$stmtA = "select vicidial_log.user,first_name,last_name,address1,address2,city,state,postal_code,vicidial_list.phone_number,vicidial_list.email,security_phrase,vicidial_list.comments,call_date,vicidial_list.lead_id,vicidial_users.full_name,vicidial_log.status,vicidial_list.vendor_lead_code,vicidial_list.source_id,vicidial_log.list_id,title,address3,last_local_call_time,uniqueid,length_in_sec,vicidial_list.rank,vicidial_list.owner from vicidial_list,vicidial_log,vicidial_users where campaign_id IN($campaignSQL) $sale_statusesSQL and call_date > '$shipdate 00:00:01' and call_date < '$shipdate 23:59:59' and vicidial_log.lead_id=vicidial_list.lead_id and vicidial_users.user=vicidial_log.user order by call_date;"; #$stmtA = "select vicidial_users.user,first_name,last_name,address1,address2,city,state,postal_code,phone_number,email,security_phrase,comments,last_local_call_time,lead_id,vicidial_users.full_name,status,vendor_lead_code,source_id,list_id,title,address3,last_local_call_time from vicidial_list,vicidial_users where list_id NOT IN('999','998') $sale_statusesSQL and called_count > 0 and vicidial_users.user=vicidial_list.user;"; if ($DB) {print "|$stmtA|\n";} $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; @@ -463,6 +464,8 @@ while ($sthArows > $rec_count) $vicidial_id = $aryA[22]; $uniqueid = $aryA[22]; $length_in_sec = $aryA[23]; + $rank = $aryA[24]; + $owner = $aryA[25]; $queue_seconds = '0'; $closer=''; @@ -478,7 +481,7 @@ if (length($with_inboundSQL)>3) ########################################################################### ########### CURRENT DAY SALES GATHERING inbound-only: vicidial_closer_log ###### ########################################################################### - $stmtA = "select vicidial_closer_log.user,first_name,last_name,address1,address2,city,state,postal_code,vicidial_list.phone_number,vicidial_list.email,security_phrase,vicidial_list.comments,call_date,vicidial_list.lead_id,vicidial_users.full_name,vicidial_closer_log.status,vicidial_list.vendor_lead_code,vicidial_list.source_id,vicidial_closer_log.list_id,campaign_id,title,address3,last_local_call_time,xfercallid,closecallid,uniqueid,length_in_sec,queue_seconds from vicidial_list,vicidial_closer_log,vicidial_users where campaign_id IN($with_inboundSQL) $close_statusesSQL and call_date > '$shipdate 00:00:01' and call_date < '$shipdate 23:59:59' and vicidial_closer_log.lead_id=vicidial_list.lead_id and vicidial_users.user=vicidial_closer_log.user order by call_date;"; + $stmtA = "select vicidial_closer_log.user,first_name,last_name,address1,address2,city,state,postal_code,vicidial_list.phone_number,vicidial_list.email,security_phrase,vicidial_list.comments,call_date,vicidial_list.lead_id,vicidial_users.full_name,vicidial_closer_log.status,vicidial_list.vendor_lead_code,vicidial_list.source_id,vicidial_closer_log.list_id,campaign_id,title,address3,last_local_call_time,xfercallid,closecallid,uniqueid,length_in_sec,queue_seconds,vicidial_list.rank,vicidial_list.owner from vicidial_list,vicidial_closer_log,vicidial_users where campaign_id IN($with_inboundSQL) $close_statusesSQL and call_date > '$shipdate 00:00:01' and call_date < '$shipdate 23:59:59' and vicidial_closer_log.lead_id=vicidial_list.lead_id and vicidial_users.user=vicidial_closer_log.user order by call_date;"; if ($DB) {print "|$stmtA|\n";} $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; @@ -515,6 +518,8 @@ if (length($with_inboundSQL)>3) $uniqueid = $aryA[25]; $length_in_sec = $aryA[26]; $queue_seconds = $aryA[27]; + $rank = $aryA[28]; + $owner = $aryA[29]; $user = ''; $agent_name=''; @@ -858,17 +863,17 @@ sub select_format_loop if ($output_format =~ /^pipe-standard$/) { - $str = "$first_name|$last_name|$address1|$address2|$city|$state|$postal_code|$phone_number|$email|$security|$comments|$call_date|$lead_id|$list_id|$user|$agent_name|$status|$vendor_id|$source_id|$campaign|$campaign_id|$ivr_id|$closer|$closer_name|\n"; + $str = "$first_name|$last_name|$address1|$address2|$city|$state|$postal_code|$phone_number|$email|$security|$comments|$call_date|$lead_id|$list_id|$user|$agent_name|$status|$vendor_id|$source_id|$campaign|$campaign_id|$ivr_id|$closer|$closer_name|$rank|$owner|\n"; } if ($output_format =~ /^csv-standard$/) { - $str = "\"$first_name\",\"$last_name\",\"$address1\",\"$address2\",\"$city\",\"$state\",\"$postal_code\",\"$phone_number\",\"$email\",\"$security\",\"$comments\",\"$call_date\",\"$lead_id\",\"$list_id\",\"$user\",\"$agent_name\",\"$status\",\"$vendor_id\",\"$source_id\",\"$campaign\",\"$campaign_id\",\"$ivr_id\",\"$closer\",\"$closer_name\"\r\n"; + $str = "\"$first_name\",\"$last_name\",\"$address1\",\"$address2\",\"$city\",\"$state\",\"$postal_code\",\"$phone_number\",\"$email\",\"$security\",\"$comments\",\"$call_date\",\"$lead_id\",\"$list_id\",\"$user\",\"$agent_name\",\"$status\",\"$vendor_id\",\"$source_id\",\"$campaign\",\"$campaign_id\",\"$ivr_id\",\"$closer\",\"$closer_name\",\"$rank\",\"$owner\"\r\n"; } if ($output_format =~ /^tab-standard$/) { - $str = "$first_name\t$last_name\t$address1\t$address2\t$city\t$state\t$postal_code\t$phone_number\t$email\t$security\t$comments\t$call_date\t$lead_id\t$list_id\t$user\t$agent_name\t$status\t$vendor_id\t$source_id\t$campaign\t$campaign_id\t$ivr_id\t$closer\t$closer_name\t\n"; + $str = "$first_name\t$last_name\t$address1\t$address2\t$city\t$state\t$postal_code\t$phone_number\t$email\t$security\t$comments\t$call_date\t$lead_id\t$list_id\t$user\t$agent_name\t$status\t$vendor_id\t$source_id\t$campaign\t$campaign_id\t$ivr_id\t$closer\t$closer_name\t$rank\t$owner\t\n"; } if ($output_format =~ /^pipe-triplep$/) diff --git a/bin/VICIDIAL_IN_new_leads_file.pl b/bin/VICIDIAL_IN_new_leads_file.pl index 37d93c34..b482b013 100644 --- a/bin/VICIDIAL_IN_new_leads_file.pl +++ b/bin/VICIDIAL_IN_new_leads_file.pl @@ -33,6 +33,7 @@ # 80829-2301 - Added multi-alt-phone entry insertion capability # 90324-1038 - Added minicsv02 format # 90401-1340 - Fixed quiet flag functionality +# 90721-1315 - Added rank and owner as vicidial_list fields, stdrankowner format # $secX = time(); @@ -140,6 +141,9 @@ if (length($ARGV[0])>1) print "standard:\n"; print "vendor_lead_code|source_code|list_id|phone_code|phone_number|title|first_name|middle|last_name|address1|address2|address3|city|state|province|postal_code|country|gender|date_of_birth|alt_phone|email|security_phrase|COMMENTS|called_count|status|entry_date|multi-alt-entries\n"; print "3857822|31022|105|01144|1625551212|MRS|B||BURTON|249 MUNDON ROAD|MALDON|ESSEX||||CM9 6PW|UK||||||COMMENTS|2|B|2007-08-09 00:00:00|7275551212_1_work!7275551213_61_sister house!7275551214_44_neighbor\n\n"; + print "stdrankowner:\n"; + print "vendor_lead_code|source_code|list_id|phone_code|phone_number|title|first_name|middle|last_name|address1|address2|address3|city|state|province|postal_code|country|gender|date_of_birth|alt_phone|email|security_phrase|COMMENTS|called_count|status|entry_date|rank|owner|multi-alt-entries\n"; + print "3857822|31022|105|01144|1625551212|MRS|B||BURTON|249 MUNDON ROAD|MALDON|ESSEX||||CM9 6PW|UK||||||COMMENTS|2|B|2007-08-09 00:00:00|99|6666|7275551212_1_work!7275551213_61_sister house!7275551214_44_neighbor\n\n"; print "minicsv:\n"; print "address1,city,name,phone_number,state,postal_code\n"; print "\"105 Fifth St\",\"Steinhatchee\",\"Frank Smith\",\"3525556601\",\"FL\",\"32359\"\n\n"; @@ -417,37 +421,39 @@ foreach(@FILES) if ($DB) {print "SEED TIME $secX : $year-$mon-$mday $hour:$min:$sec LOCAL GMT OFFSET NOW: $LOCAL_GMT_OFF\n";} - $a=0; ### each line of input file counter ### - $b=0; ### status of 'APPROVED' counter ### - $c=0; ### status of 'DECLINED' counter ### - $d=0; ### status of 'REFERRED' counter ### - $e=0; ### status of 'ERROR' counter ### - $f=0; ### number of 'DUPLICATE' counter ### - $g=0; ### number of leads with multi-alt-entries + $a=0; ### each line of input file counter ### + $b=0; ### status of 'APPROVED' counter ### + $c=0; ### status of 'DECLINED' counter ### + $d=0; ### status of 'REFERRED' counter ### + $e=0; ### status of 'ERROR' counter ### + $f=0; ### number of 'DUPLICATE' counter ### + $g=0; ### number of leads with multi-alt-entries - $multi_insert_counter=0; - $multistmt=''; + $multi_insert_counter=0; + $multistmt=''; + $rank=''; + $owner=''; #if ($DB) - while () - { - @m=@MT; - # print "$a| $number\n"; - $number = $_; - chomp($number); - # $number =~ s/,/\|/gi; - $number =~ s/\t/\|/gi; - $number =~ s/\'|\t|\r|\n|\l//gi; - $number =~ s/\'|\t|\r|\n|\l//gi; - $number =~ s/\",,,,,,,\"/\|\|\|\|\|\|\|/gi; - $number =~ s/\",,,,,,\"/\|\|\|\|\|\|/gi; - $number =~ s/\",,,,,\"/\|\|\|\|\|/gi; - $number =~ s/\",,,,\"/\|\|\|\|/gi; - $number =~ s/\",,,\"/\|\|\|/gi; - $number =~ s/\",,\"/\|\|/gi; - $number =~ s/\",\"/\|/gi; - $number =~ s/\"//gi; - @m = split(/\|/, $number); + while () + { + @m=@MT; + # print "$a| $number\n"; + $number = $_; + chomp($number); + # $number =~ s/,/\|/gi; + $number =~ s/\t/\|/gi; + $number =~ s/\'|\t|\r|\n|\l//gi; + $number =~ s/\'|\t|\r|\n|\l//gi; + $number =~ s/\",,,,,,,\"/\|\|\|\|\|\|\|/gi; + $number =~ s/\",,,,,,\"/\|\|\|\|\|\|/gi; + $number =~ s/\",,,,,\"/\|\|\|\|\|/gi; + $number =~ s/\",,,,\"/\|\|\|\|/gi; + $number =~ s/\",,,\"/\|\|\|/gi; + $number =~ s/\",,\"/\|\|/gi; + $number =~ s/\",\"/\|/gi; + $number =~ s/\"//gi; + @m = split(/\|/, $number); $format_set=0; @@ -487,6 +493,7 @@ foreach(@FILES) $format_set++; } + # This is the format for the minicsv lead files #"105 Fifth St","Steinhatchee","Frank Smith","3525556601","FL","32359" if ( ($format =~ /minicsv/) && ($format_set < 1) ) @@ -522,6 +529,79 @@ foreach(@FILES) $format_set++; } + + # This is the format for the stdrankowner lead files (standard plus rank and owner ) + #3857822|31022|105|01144|1625551212|MRS|B||BURTON|249 MUNDON ROAD|MALDON|ESSEX||||CM9 6PW|UK||||||COMMENTS|COUNT|STATUS|INS-DATE|RANK|OWNER + if ( ($format =~ /stdrankowner/) && ($format_set < 1) ) + { + $vendor_lead_code = $m[0]; chomp($vendor_lead_code); + $source_code = $m[1]; chomp($source_code); $source_id = $source_code; + $list_id = $m[2]; chomp($list_id); + $phone_code = $m[3]; chomp($phone_code); $phone_code =~ s/\D//gi; + $phone_number = $m[4]; chomp($phone_number); $phone_number =~ s/\D//gi; + $USarea = substr($phone_number, 0, 3); + $title = $m[5]; chomp($title); + $first_name = $m[6]; chomp($first_name); + $middle_initial = $m[7]; chomp($middle_initial); + $last_name = $m[8]; chomp($last_name); + $address1 = $m[9]; chomp($address1); + $address2 = $m[10]; chomp($address2); + $address3 = $m[11]; chomp($address3); + $city = $m[12]; chomp($city); + $state = $m[13]; chomp($state); + $province = $m[14]; chomp($province); + $postal_code = $m[15]; chomp($postal_code); + $country = $m[16]; chomp($country); + $gender = $m[17]; + $date_of_birth = $m[18]; + $alt_phone = $m[19]; chomp($alt_phone); $alt_phone =~ s/\D//gi; + $email = $m[20]; + $security_phrase = $m[21]; + $comments = $m[22]; + $called_count = $m[23]; $called_count =~ s/\D|\r|\n|\t//gi; if (length($called_count)<1) {$called_count=0;} + $status = $m[24]; $status =~ s/ |\r|\n|\t//gi; if (length($status)<1) {$status='NEW';} + $insert_date = $m[25]; $insert_date =~ s/\r|\n|\t|[a-zA-Z]//gi; if (length($insert_date)<6) {$insert_date=$pulldate0;} + if ($insert_date =~ /\//) + { + @iD = split(/\//, $insert_date); + $iD[0] = sprintf("%02d", $iD[0]); + $iD[1] = sprintf("%02d", $iD[1]); + $insert_date = "$iD[2]-$iD[0]-$iD[1]"; + } + $rank = $m[26]; + $owner = $m[27]; + $multi_alt_phones = $m[28]; + + $map_count=0; + if (length($multi_alt_phones)>4) + { + @map=@MT; @ALTm_phone_code=@MT; @ALTm_phone_number=@MT; @ALTm_phone_note=@MT; + @map = split(/\!/, $multi_alt_phones); + $map_count = ($#map +1); + if ($DBX) {print "multi-al-entry: $a|$map_count|$multi_alt_phones\n";} + $g++; + $r=0; + while ($r < $map_count) + { + @ncn=@MT; + @ncn = split(/\_/, $map[$r]); + print "$ncn[0]|$ncn[1]|$ncn[2]"; + + if (length($forcephonecode) > 0) + {$ALTm_phone_code[$r] = $forcephonecode;} + else + {$ALTm_phone_code[$r] = $ncn[1];} + if (length($ALTm_phone_code[$r]) < 1) + {$ALTm_phone_code[$r]='1';} + $ALTm_phone_number[$r] = $ncn[0]; + $ALTm_phone_note[$r] = $ncn[2]; + $r++; + } + } + + $format_set++; + } + # This is the format for the standard lead files #3857822|31022|105|01144|1625551212|MRS|B||BURTON|249 MUNDON ROAD|MALDON|ESSEX||||CM9 6PW|UK||||||COMMENTS if ($format_set < 1) @@ -590,6 +670,8 @@ foreach(@FILES) } } + if (length($rank)<1) {$rank='0';} + if (length($forcelistid) > 0) { $list_id = $forcelistid; # set list_id to override value @@ -911,7 +993,7 @@ foreach(@FILES) if ($map_count > 0) { - $stmtZ = "INSERT INTO vicidial_list values('','$insert_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments','$called_count','2008-01-01 00:00:00');"; + $stmtZ = "INSERT INTO vicidial_list (lead_id,entry_date,modify_date,status,user,vendor_lead_code,source_id,list_id,gmt_offset_now,called_since_last_reset,phone_code,phone_number,title,first_name,middle_initial,last_name,address1,address2,address3,city,state,province,postal_code,country_code,gender,date_of_birth,alt_phone,email,security_phrase,comments,called_count,last_local_call_time,rank,owner) values('','$insert_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments','$called_count','2008-01-01 00:00:00','$rank','$owner');"; if (!$T) {$affected_rows = $dbhA->do($stmtZ); } # or die "Couldn't execute query: |$stmtZ|\n"; $lead_id = $dbhA->{'mysql_insertid'}; if($DB){print STDERR "\n|$affected_rows|$stmtZ|\n";} @@ -933,7 +1015,7 @@ foreach(@FILES) if ($multi_insert_counter > 8) { ### insert good lead into pending_transactions table ### - $stmtZ = "INSERT INTO vicidial_list values$multistmt('','$insert_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments','$called_count','2008-01-01 00:00:00');"; + $stmtZ = "INSERT INTO vicidial_list (lead_id,entry_date,modify_date,status,user,vendor_lead_code,source_id,list_id,gmt_offset_now,called_since_last_reset,phone_code,phone_number,title,first_name,middle_initial,last_name,address1,address2,address3,city,state,province,postal_code,country_code,gender,date_of_birth,alt_phone,email,security_phrase,comments,called_count,last_local_call_time,rank,owner) values$multistmt('','$insert_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments','$called_count','2008-01-01 00:00:00','$rank','$owner');"; if (!$T) {$affected_rows = $dbhA->do($stmtZ); } # or die "Couldn't execute query: |$stmtZ|\n"; if($DB){print STDERR "\n|$affected_rows|$stmtZ|\n";} @@ -943,7 +1025,7 @@ foreach(@FILES) } else { - $multistmt .= "('','$insert_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments','$called_count','2008-01-01 00:00:00'),"; + $multistmt .= "('','$insert_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments','$called_count','2008-01-01 00:00:00','$rank','$owner'),"; $multi_insert_counter++; } } @@ -979,7 +1061,7 @@ foreach(@FILES) { chop($multistmt); ### insert good deal into pending_transactions table ### - $stmtZ = "INSERT INTO vicidial_list values$multistmt;"; + $stmtZ = "INSERT INTO vicidial_list (lead_id,entry_date,modify_date,status,user,vendor_lead_code,source_id,list_id,gmt_offset_now,called_since_last_reset,phone_code,phone_number,title,first_name,middle_initial,last_name,address1,address2,address3,city,state,province,postal_code,country_code,gender,date_of_birth,alt_phone,email,security_phrase,comments,called_count,last_local_call_time,rank,owner) values$multistmt;"; if (!$T) {$affected_rows = $dbhA->do($stmtZ); } # or die "Couldn't execute query: |$stmtZ|\n"; if($DB){print STDERR "\n|$affected_rows|$stmtZ|\n";} diff --git a/docs/NON-AGENT_API.txt b/docs/NON-AGENT_API.txt index 9ff73499..e5ba7edf 100644 --- a/docs/NON-AGENT_API.txt +++ b/docs/NON-AGENT_API.txt @@ -19,6 +19,7 @@ Changes: 80724-1723 - First build 90428-0208 - Added blind_monitor function 90513-1720 - Added sounds_list function +90721-1432 - Added rank and owner @@ -142,6 +143,8 @@ email - 1-70 characters security_phrase - 1-100 characters comments - 1-255 characters multi_alt_phones - 5-1024 characters (see examples for more info) +rank - 1-5 digits +owner - 1-20 characters (user ID, Territory or user group) Multi-ALT-Phones format: diff --git a/docs/conf_examples/extensions.conf.sample b/docs/conf_examples/extensions.conf.sample index 35b655cf..c1426760 100644 --- a/docs/conf_examples/extensions.conf.sample +++ b/docs/conf_examples/extensions.conf.sample @@ -16,11 +16,6 @@ TRUNKblind = IAX2/ASTblind:test@127.0.0.1:41569 ; used for testing #include extensions-vicidial.conf [trunkinbound] -; agent dial-in: -exten => 2345,1,Answer ; Answer the line -exten => 2345,2,AGI(agi-AGENT_dial_in.agi) -exten => 2345,3,Hangup - ; DID call routing process exten => _X.,1,AGI(agi-DID_route.agi) diff --git a/docs/conf_examples/extensions.conf.sample-1.4 b/docs/conf_examples/extensions.conf.sample-1.4 index 89031c32..e93c8fd3 100644 --- a/docs/conf_examples/extensions.conf.sample-1.4 +++ b/docs/conf_examples/extensions.conf.sample-1.4 @@ -16,11 +16,6 @@ TRUNKblind = IAX2/ASTblind:test@127.0.0.1:41569 ; used for testing #include extensions-vicidial.conf [trunkinbound] -; agent dial-in: -exten => 2345,1,Answer ; Answer the line -exten => 2345,2,AGI(agi-AGENT_dial_in.agi) -exten => 2345,3,Hangup - ; DID call routing process exten => _X.,1,AGI(agi-DID_route.agi) diff --git a/extras/MySQL_AST_CREATE_tables.sql b/extras/MySQL_AST_CREATE_tables.sql index 44dcefa8..6a41802b 100644 --- a/extras/MySQL_AST_CREATE_tables.sql +++ b/extras/MySQL_AST_CREATE_tables.sql @@ -269,7 +269,7 @@ status VARCHAR(6), user VARCHAR(20), vendor_lead_code VARCHAR(20), source_id VARCHAR(50), -list_id BIGINT(14) UNSIGNED, +list_id BIGINT(14) UNSIGNED NOT NULL DEFAULT '0', gmt_offset_now DECIMAL(4,2) DEFAULT '0.00', called_since_last_reset ENUM('Y','N','Y1','Y2','Y3','Y4','Y5','Y6','Y7','Y8','Y9','Y10') default 'N', phone_code VARCHAR(10), @@ -294,13 +294,16 @@ security_phrase VARCHAR(100), comments VARCHAR(255), called_count SMALLINT(5) UNSIGNED default '0', last_local_call_time DATETIME, +rank SMALLINT(5) NOT NULL default '0', +owner VARCHAR(20) default '', index (phone_number), index (list_id), index (called_since_last_reset), index (status), index (gmt_offset_now), index (postal_code), -index (last_local_call_time) +index (last_local_call_time), +index (rank) ); CREATE TABLE vicidial_hopper ( @@ -662,7 +665,9 @@ view_calls_in_queue ENUM('NONE','ALL','1','2','3','4','5') default 'NONE', view_calls_in_queue_launch ENUM('AUTO','MANUAL') default 'MANUAL', grab_calls_in_queue ENUM('Y','N') default 'N', call_requeue_button ENUM('Y','N') default 'N', -pause_after_each_call ENUM('Y','N') default 'N' +pause_after_each_call ENUM('Y','N') default 'N', +no_hopper_dialing ENUM('Y','N') default 'N', +agent_dial_owner_only ENUM('NONE','USER','TERRITORY','USER_GROUP') default 'NONE' ); CREATE TABLE vicidial_lists ( @@ -672,7 +677,8 @@ campaign_id VARCHAR(8), active ENUM('Y','N'), list_description VARCHAR(255), list_changedate DATETIME, -list_lastcalldate DATETIME +list_lastcalldate DATETIME, +reset_time VARCHAR(100) default '' ); CREATE TABLE vicidial_statuses ( @@ -1727,7 +1733,7 @@ CREATE INDEX phone_number on vicidial_closer_log (phone_number); CREATE INDEX date_user on vicidial_closer_log (call_date,user); CREATE INDEX comment_a on live_inbound_log (comment_a); -UPDATE system_settings SET db_schema_version='1162'; +UPDATE system_settings SET db_schema_version='1163'; GRANT RELOAD ON *.* TO cron@'%'; GRANT RELOAD ON *.* TO cron@localhost; diff --git a/extras/generic_images/spacer.gif b/extras/generic_images/spacer.gif new file mode 100644 index 00000000..ef3c30b2 Binary files /dev/null and b/extras/generic_images/spacer.gif differ diff --git a/extras/testMULTI_VICIDIAL_lead_fileRANK-OWNER.txt b/extras/testMULTI_VICIDIAL_lead_fileRANK-OWNER.txt new file mode 100644 index 00000000..de94100c --- /dev/null +++ b/extras/testMULTI_VICIDIAL_lead_fileRANK-OWNER.txt @@ -0,0 +1,14 @@ +100001|10001|129|1|7275551213|MR|John|Q|Public01|249 MUNDON ROAD|||MALDON|FL||33709|USA|M|1970-01-01|7275551212|test@test.com|nothing|COMMENTS|1|6666 +100002|10002|129|1|3125551213|MR|John|Q|Public02|249 MUNDON ROAD|||MALDON|FL||33709|USA|M|1970-01-01|3125551212|test@test.com|nothing|COMMENTS|2|6666 +100003|10003|129|1|3035551213|MR|John|Q|Public03|249 MUNDON ROAD|||MALDON|FL||33709|USA|M|1970-01-01|3035551212|test@test.com|nothing|COMMENTS|3|6666 +100004|10004|129|1|8585551213|MR|John|Q|Public04|249 MUNDON ROAD|||MALDON|FL||33709|USA|M|1970-01-01|7275551212|test@test.com|nothing|COMMENTS|4|6666 +100005|10005|129|44|7275551213|MR|John|Q|Public05|249 MUNDON ROAD|||MALDON|FL||33709|USA|M|1970-01-01|7275551212|test@test.com|nothing|COMMENTS|5|6666 +100006|10006|129|61|727555121|MR|John|Q|Public06|249 MUNDON ROAD|||MALDON|NT||33709|USA|M|1970-01-01|7275551212|test@test.com|nothing|COMMENTS|6|6666 +100007|10007|129|61|727555121|MR|John|Q|Public07|249 MUNDON ROAD|||MALDON|NS||33709|USA|M|1970-01-01|7275551212|test@test.com|nothing|COMMENTS|7|6666 +100008|10008|129|52|2485551213|MR|John|Q|Public08|249 MUNDON ROAD|||MALDON|FL||33709|USA|M|1970-01-01|7275551212|test@test.com|nothing|COMMENTS|8|6666 +100009|10009|129|1|7275551213|MR|John|Q|Public09|249 MUNDON ROAD|||MALDON|FL||33709|USA|M|1970-01-01|7275551212|test@test.com|nothing|COMMENTS|9|6666 +100010|10010|129|1|8585551213|MR|John|Q|Public10|249 MUNDON ROAD|||MALDON|FL||33709|USA|M|1970-01-01|7275551212|test@test.com|nothing|COMMENTS|9|ADMIN +100011|10011|129|1|3035551213|MR|John|Q|Public11|249 MUNDON ROAD|||MALDON|FL||33709|USA|M|1970-01-01|3035551212|test@test.com|nothing|COMMENTS|9|1000 +100012|10012|129|1|3125551213|MR|John|Q|Public12|249 MUNDON ROAD|||MALDON|FL||33709|USA|M|1970-01-01|3125551212|test@test.com|nothing|COMMENTS|11|1000 +100013|10013|129|1|7275551213|MR|John|Q|Public13|249 MUNDON ROAD|||MALDON|FL||33709|USA|M|1970-01-01|7275551212|test@test.com|nothing|COMMENTS|15|ADMIN +100014|10014|129|1|7275551213|MR|John|Q|Public14|249 MUNDON ROAD|||MALDON|FL||33709|USA|M|1970-01-01|7275551212|test@test.com|nothing|COMMENTS|99|ADMIN diff --git a/extras/upgrade_2.2.0.sql b/extras/upgrade_2.2.0.sql index bf8ddbc1..e23211cd 100644 --- a/extras/upgrade_2.2.0.sql +++ b/extras/upgrade_2.2.0.sql @@ -301,3 +301,15 @@ ALTER TABLE vicidial_campaigns ADD pause_after_each_call ENUM('Y','N') default ' ALTER TABLE vicidial_auto_calls ADD agent_grab VARCHAR(20) default ''; UPDATE system_settings SET db_schema_version='1162'; + +ALTER TABLE vicidial_list MODIFY list_id BIGINT(14) UNSIGNED NOT NULL DEFAULT '0'; +ALTER TABLE vicidial_list ADD rank SMALLINT(5) NOT NULL default '0'; +ALTER TABLE vicidial_list ADD owner VARCHAR(20) default ''; +CREATE INDEX rank ON vicidial_list (rank); + +ALTER TABLE vicidial_campaigns ADD no_hopper_dialing ENUM('Y','N') default 'N'; +ALTER TABLE vicidial_campaigns ADD agent_dial_owner_only ENUM('NONE','USER','TERRITORY','USER_GROUP') default 'NONE'; + +ALTER TABLE vicidial_lists ADD reset_time VARCHAR(100) default ''; + +UPDATE system_settings SET db_schema_version='1163'; diff --git a/translations/raw_translation_files/TO_BE_TRANSLATED_2.2.0.txt b/translations/raw_translation_files/TO_BE_TRANSLATED_2.2.0.txt index e19b54a4..b8fd25b4 100644 --- a/translations/raw_translation_files/TO_BE_TRANSLATED_2.2.0.txt +++ b/translations/raw_translation_files/TO_BE_TRANSLATED_2.2.0.txt @@ -238,6 +238,19 @@ Agent Call Re-Queue Button|| This option if set to Y will add a Re-Queue Customer button to the agent screen, allowing the agent to send the call into an AGENTDIRECT queue that is reserved for the agent only. Default is N|| Agent Pause After Each Call|| This option if set to Y will pause the agent after every call automatically. Default is N|| +Starts with the highest rank and works its way down|| +Starts with the lowest rank and works its way up|| +Starts with owners beginning with Z and works its way down|| +Starts with owners beginning with A and works its way up|| +No Hopper Dialing|| +If This is enabled, the hopper will not run for this campaign. This option is only available when the dial method is set to MANUAL or INBOUND_MAN. It is recommended that you do not enable this option if you have a very large lead database, over 100,000 leads. With No Hopper Dialing, the following features do not work: lead recycling, auto-alt-dialing, list mix, list ordering with Xth NEW. If you want to use Owner Only Dialing you must have No Hopper Dialing enabled. Default is N for disabled|| +Owner Only Dialing|| +If This is enabled, the agent will only receive leads that they are within the ownership parameters for. If this is set to USER then the agent must be the user defined in the database as the owner of this lead. If this is set to TERRITORY then the owner of the lead must match the territory listed in the User Modification screen for this agent. If this is set to USER_GROUP then the owner of the lead must match the user group that the agent is a member of. For this feature to work the dial method must be set to MANUAL or INBOUND_MAN and No Hopper Dialing must be enabled. Default is NONE for disabled|| +Reset Times|| +This field allows you to put times in, separated by a dash-, that this list will be automatically reset by the system. The times must be in 24 hour format with no punctuation, for example 0800-1700 would reset the list at 8AM and 5PM every day. Default is empty|| +Owner: || +OWNERS WITHIN THIS LIST|| +RANKS WITHIN THIS LIST|| add-file: user_territories.php diff --git a/www/agc/vdc_db_query.php b/www/agc/vdc_db_query.php index e0d361e3..e7b35051 100644 --- a/www/agc/vdc_db_query.php +++ b/www/agc/vdc_db_query.php @@ -205,12 +205,13 @@ # 90706-1431 - Added Agent view transfer selection # 90712-2303 - Added view calls in queue, grab call from queue # 90717-0638 - Fixed alt dial on overflow in-group calls +# 90722-1542 - Added no hopper dialing # -$version = '2.2.0-116'; -$build = '90717-0638'; +$version = '2.2.0-117'; +$build = '90722-1542'; $mel=1; # Mysql Error Log enabled = 1 -$mysql_log_count=235; +$mysql_log_count=244; $one_mysql_log=0; require("dbconnect.php"); @@ -948,12 +949,452 @@ if ($ACTION == 'manDiaLnextCaLL') } else { - ### grab the next lead in the hopper for this campaign and reserve it for the user - $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";} + ##### gather no hopper dialing settings from campaign + $stmt="SELECT no_hopper_dialing,agent_dial_owner_only,local_call_time,dial_statuses,drop_lockout_time,lead_filter_id,lead_order FROM vicidial_campaigns where campaign_id='$campaign';"; $rslt=mysql_query($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00024',$user,$server_ip,$session_name,$one_mysql_log);} - $affected_rows = mysql_affected_rows($link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00236',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $camp_nohopper_ct = mysql_num_rows($rslt); + if ($camp_nohopper_ct > 0) + { + $row=mysql_fetch_row($rslt); + $no_hopper_dialing = $row[0]; + $agent_dial_owner_only = $row[1]; + $local_call_time = $row[2]; + $dial_statuses = $row[3]; + $drop_lockout_time = $row[4]; + $lead_filter_id = $row[5]; + $lead_order = $row[6]; + } + if (eregi("N",$no_hopper_dialing)) + { + ### grab the next lead in the hopper for this campaign and reserve it for the user + $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_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00024',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($link); + } + else + { + ### figure out what the next lead that should be dialed is + + ########################################################## + ### BEGIN find the next lead to dial without looking in the hopper + ########################################################## + # $DB=1; + if (strlen($dial_statuses)>2) + { + $g=0; + $p='13'; + $GMT_gmt[0] = ''; + $GMT_hour[0] = ''; + $GMT_day[0] = ''; + 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++; + } + + $stmt="SELECT * FROM vicidial_call_times where call_time_id='$local_call_time';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00237',$user,$server_ip,$session_name,$one_mysql_log);} + $rowx=mysql_fetch_row($rslt); + $Gct_default_start = "$rowx[3]"; + $Gct_default_stop = "$rowx[4]"; + $Gct_sunday_start = "$rowx[5]"; + $Gct_sunday_stop = "$rowx[6]"; + $Gct_monday_start = "$rowx[7]"; + $Gct_monday_stop = "$rowx[8]"; + $Gct_tuesday_start = "$rowx[9]"; + $Gct_tuesday_stop = "$rowx[10]"; + $Gct_wednesday_start = "$rowx[11]"; + $Gct_wednesday_stop = "$rowx[12]"; + $Gct_thursday_start = "$rowx[13]"; + $Gct_thursday_stop = "$rowx[14]"; + $Gct_friday_start = "$rowx[15]"; + $Gct_friday_stop = "$rowx[16]"; + $Gct_saturday_start = "$rowx[17]"; + $Gct_saturday_stop = "$rowx[18]"; + $Gct_state_call_times = "$rowx[19]"; + + $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 * from vicidial_state_call_times where state_call_time_id='$state_rules[$b]';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00238',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_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]"; + + $ct_states .="'$Gstate_call_time_state',"; + + $r=0; + $state_gmt=''; + while($r < $g) + { + if ($GMT_day[$r]==0) #### Sunday local time + { + if (($Gsct_sunday_start==0) and ($Gsct_sunday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_sunday_start) and ($GMT_hour[$r]<$Gsct_sunday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==1) #### Monday local time + { + if (($Gsct_monday_start==0) and ($Gsct_monday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_monday_start) and ($GMT_hour[$r]<$Gsct_monday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==2) #### Tuesday local time + { + if (($Gsct_tuesday_start==0) and ($Gsct_tuesday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_tuesday_start) and ($GMT_hour[$r]<$Gsct_tuesday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==3) #### Wednesday local time + { + if (($Gsct_wednesday_start==0) and ($Gsct_wednesday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_wednesday_start) and ($GMT_hour[$r]<$Gsct_wednesday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==4) #### Thursday local time + { + if (($Gsct_thursday_start==0) and ($Gsct_thursday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_thursday_start) and ($GMT_hour[$r]<$Gsct_thursday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==5) #### Friday local time + { + if (($Gsct_friday_start==0) and ($Gsct_friday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_friday_start) and ($GMT_hour[$r]<$Gsct_friday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==6) #### Saturday local time + { + if (($Gsct_saturday_start==0) and ($Gsct_saturday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_saturday_start) and ($GMT_hour[$r]<$Gsct_saturday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + $r++; + } + $state_gmt = "$state_gmt'99'"; + $ct_state_gmt_SQL .= "or (state='$Gstate_call_time_state' and gmt_offset_now IN($state_gmt)) "; + } + + $b++; + } + if (strlen($ct_states)>2) + { + $ct_states = eregi_replace(",$",'',$ct_states); + $ct_statesSQL = "and state NOT IN($ct_states)"; + } + else + { + $ct_statesSQL = ""; + } + + $r=0; + $default_gmt=''; + while($r < $g) + { + if ($GMT_day[$r]==0) #### Sunday local time + { + if (($Gct_sunday_start==0) and ($Gct_sunday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_sunday_start) and ($GMT_hour[$r]<$Gct_sunday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==1) #### Monday local time + { + if (($Gct_monday_start==0) and ($Gct_monday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_monday_start) and ($GMT_hour[$r]<$Gct_monday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==2) #### Tuesday local time + { + if (($Gct_tuesday_start==0) and ($Gct_tuesday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_tuesday_start) and ($GMT_hour[$r]<$Gct_tuesday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==3) #### Wednesday local time + { + if (($Gct_wednesday_start==0) and ($Gct_wednesday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_wednesday_start) and ($GMT_hour[$r]<$Gct_wednesday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==4) #### Thursday local time + { + if (($Gct_thursday_start==0) and ($Gct_thursday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_thursday_start) and ($GMT_hour[$r]<$Gct_thursday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==5) #### Friday local time + { + if (($Gct_friday_start==0) and ($Gct_friday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_friday_start) and ($GMT_hour[$r]<$Gct_friday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==6) #### Saturday local time + { + if (($Gct_saturday_start==0) and ($Gct_saturday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_saturday_start) and ($GMT_hour[$r]<$Gct_saturday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + } + $r++; + } + + $default_gmt = "$default_gmt'99'"; + $all_gmtSQL = "(gmt_offset_now IN($default_gmt) $ct_statesSQL) $ct_state_gmt_SQL"; + + $dial_statuses = preg_replace("/ -$/","",$dial_statuses); + $Dstatuses = explode(" ", $dial_statuses); + $Ds_to_print = (count($Dstatuses) - 0); + $Dsql = ''; + $o=0; + while ($Ds_to_print > $o) + { + $o++; + $Dsql .= "'$Dstatuses[$o]',"; + } + $Dsql = preg_replace("/,$/","",$Dsql); + if (strlen($Dsql) < 2) {$Dsql = "''";} + + $DLTsql=''; + if ($drop_lockout_time > 0) + { + $DLseconds = ($drop_lockout_time * 3600); + $DLseconds = floor($DLseconds); + $DLseconds = intval("$DLseconds"); + $DLTsql = "and ( ( (status IN('DROP','XDROP')) and (last_local_call_time < CONCAT(DATE_ADD(NOW(), INTERVAL -$DLseconds SECOND),' ',CURTIME()) ) ) or (status NOT IN('DROP','XDROP')) )"; + } + + $stmt="SELECT lead_filter_sql FROM vicidial_lead_filters where lead_filter_id='$lead_filter_id';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00239',$user,$server_ip,$session_name,$one_mysql_log);} + $filtersql_ct = mysql_num_rows($rslt); + if ($DB) {echo "$filtersql_ct|$stmt\n";} + if ($filtersql_ct > 0) + { + $row=mysql_fetch_row($rslt); + $fSQL = $row[0]; + } + + $stmt="SELECT list_id FROM vicidial_lists where campaign_id='$campaign' and active='Y';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00240',$user,$server_ip,$session_name,$one_mysql_log);} + $camplists_ct = mysql_num_rows($rslt); + if ($DB) {echo "$camplists_ct|$stmt\n";} + $k=0; + $camp_lists=''; + while ($camplists_ct > $k) + { + $row=mysql_fetch_row($rslt); + $camp_lists .= "'$row[0]',"; + $k++; + } + $camp_lists = eregi_replace(".$","",$camp_lists); + if (strlen($camp_lists) < 4) {$camp_lists="''";} + + $stmt="SELECT user_group,territory FROM vicidial_users where user='$user';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00241',$user,$server_ip,$session_name,$one_mysql_log);} + $userterr_ct = mysql_num_rows($rslt); + if ($DB) {echo "$userterr_ct|$stmt\n";} + if ($userterr_ct > 0) + { + $row=mysql_fetch_row($rslt); + $user_group = $row[0]; + $territory = $row[1]; + } + + $adooSQL = ''; + if (eregi("USER",$agent_dial_owner_only)) {$adooSQL = "and owner='$user'";} + if (eregi("TERRITORY",$agent_dial_owner_only)) {$adooSQL = "and owner='$territory'";} + if (eregi("USER_GROUP",$agent_dial_owner_only)) {$adooSQL = "and owner='$user_group'";} + + $order_stmt = ''; + if (eregi("DOWN",$lead_order)){$order_stmt = 'order by lead_id asc';} + if (eregi("UP",$lead_order)){$order_stmt = 'order by lead_id desc';} + if (eregi("UP LAST NAME",$lead_order)){$order_stmt = 'order by last_name desc, lead_id asc';} + if (eregi("DOWN LAST NAME",$lead_order)){$order_stmt = 'order by last_name, lead_id asc';} + if (eregi("UP PHONE",$lead_order)){$order_stmt = 'order by phone_number desc, lead_id asc';} + if (eregi("DOWN PHONE",$lead_order)){$order_stmt = 'order by phone_number, lead_id asc';} + if (eregi("UP COUNT",$lead_order)){$order_stmt = 'order by called_count desc, lead_id asc';} + if (eregi("DOWN COUNT",$lead_order)){$order_stmt = 'order by called_count, lead_id asc';} + if (eregi("UP LAST CALL TIME",$lead_order)){$order_stmt = 'order by last_local_call_time desc, lead_id asc';} + if (eregi("DOWN LAST CALL TIME",$lead_order)){$order_stmt = 'order by last_local_call_time, lead_id asc';} + if (eregi("RANDOM",$lead_order)){$order_stmt = 'order by RAND()';} + if (eregi("UP RANK",$lead_order)){$order_stmt = 'order by rank desc, lead_id asc';} + if (eregi("DOWN RANK",$lead_order)){$order_stmt = 'order by rank, lead_id asc';} + if (eregi("UP OWNER",$lead_order)){$order_stmt = 'order by owner desc, lead_id asc';} + if (eregi("DOWN OWNER",$lead_order)){$order_stmt = 'order by owner, lead_id asc';} + + $stmt="UPDATE vicidial_list SET status='QUEUE',user='$user' where called_since_last_reset='N' and status IN($Dsql) and list_id IN($camp_lists) and ($all_gmtSQL) $DLTsql $fSQL $adooSQL $order_stmt LIMIT 1;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00242',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($link); + + if ($affected_rows > 0) + { + $stmt="SELECT lead_id,list_id,gmt_offset_now,state FROM vicidial_list where status='QUEUE' and user='$user' order by modify_date desc LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00243',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $leadpick_ct = mysql_num_rows($rslt); + if ($leadpick_ct > 0) + { + $row=mysql_fetch_row($rslt); + $lead_id = $row[0]; + $list_id = $row[1]; + $gmt_offset_now = $row[2]; + $state = $row[3]; + + $stmt = "INSERT INTO vicidial_hopper SET lead_id='$lead_id',campaign_id='$campaign',status='QUEUE',list_id='$list_id',gmt_offset_now='$gmt_offset_now',state='$state',alt_dial='MAIN',user='$user',priority='0';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00244',$user,$server_ip,$session_name,$one_mysql_log);} + } + } + } + ########################################################## + ### END find the next lead to dial without looking in the hopper + ########################################################## + # $DB=0; + } } } @@ -975,7 +1416,7 @@ if ($ACTION == 'manDiaLnextCaLL') } ##### grab the data from vicidial_list for the lead_id - $stmt="SELECT * FROM vicidial_list where lead_id='$lead_id' LIMIT 1;"; + $stmt="SELECT lead_id,entry_date,modify_date,status,user,vendor_lead_code,source_id,list_id,gmt_offset_now,called_since_last_reset,phone_code,phone_number,title,first_name,middle_initial,last_name,address1,address2,address3,city,state,province,postal_code,country_code,gender,date_of_birth,alt_phone,email,security_phrase,comments,called_count,last_local_call_time,rank,owner FROM vicidial_list where lead_id='$lead_id' LIMIT 1;"; $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00026',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} @@ -1013,6 +1454,8 @@ if ($ACTION == 'manDiaLnextCaLL') $security = trim("$row[28]"); $comments = stripslashes(trim("$row[29]")); $called_count = trim("$row[30]"); + $rank = trim("$row[32]"); + $owner = trim("$row[33]"); } $called_count++; @@ -1267,6 +1710,8 @@ if ($ACTION == 'manDiaLnextCaLL') $LeaD_InfO .= $phone_number . "\n"; $LeaD_InfO .= "MAIN\n"; $LeaD_InfO .= $source_id . "\n"; + $LeaD_InfO .= $rank . "\n"; + $LeaD_InfO .= $owner . "\n"; echo $LeaD_InfO; @@ -2736,7 +3181,7 @@ if ($ACTION == 'VDADcheckINCOMING') if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00107',$user,$server_ip,$session_name,$one_mysql_log);} ##### grab the data from vicidial_list for the lead_id - $stmt="SELECT * FROM vicidial_list where lead_id='$lead_id' LIMIT 1;"; + $stmt="SELECT lead_id,entry_date,modify_date,status,user,vendor_lead_code,source_id,list_id,gmt_offset_now,called_since_last_reset,phone_code,phone_number,title,first_name,middle_initial,last_name,address1,address2,address3,city,state,province,postal_code,country_code,gender,date_of_birth,alt_phone,email,security_phrase,comments,called_count,last_local_call_time,rank,owner FROM vicidial_list where lead_id='$lead_id' LIMIT 1;"; $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00108',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} @@ -2772,6 +3217,8 @@ if ($ACTION == 'VDADcheckINCOMING') $security = trim("$row[28]"); $comments = stripslashes(trim("$row[29]")); $called_count = trim("$row[30]"); + $rank = trim("$row[32]"); + $owner = trim("$row[33]"); } ##### if lead is a callback, grab the callback comments @@ -3134,6 +3581,8 @@ if ($ACTION == 'VDADcheckINCOMING') $LeaD_InfO .= $alt_phone_note . "\n"; $LeaD_InfO .= $alt_phone_active . "\n"; $LeaD_InfO .= $alt_phone_count . "\n"; + $LeaD_InfO .= $rank . "\n"; + $LeaD_InfO .= $owner . "\n"; echo $LeaD_InfO; diff --git a/www/agc/vicidial.php b/www/agc/vicidial.php index 46ea4398..8bbc8c1d 100644 --- a/www/agc/vicidial.php +++ b/www/agc/vicidial.php @@ -239,10 +239,11 @@ # 90709-1649 - Fixed alt-number transfers and dispo variable reset for webform # 90712-2304 - Added ADD-ALL group selection, view calls in queue, grab call from queue, requeue button # 90717-0640 - Added dialed_label and dialed_number to script variables +# 90721-1114 - Added rank and owner as vicidial_list fields # -$version = '2.2.0-217'; -$build = '90717-0640'; +$version = '2.2.0-218'; +$build = '90721-1114'; $mel=1; # Mysql Error Log enabled = 1 $mysql_log_count=61; $one_mysql_log=0; @@ -1066,7 +1067,7 @@ $VDloginDISPLAY=0; $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 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 FROM vicidial_campaigns where campaign_id = '$VD_campaign';"; $rslt=mysql_query($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";} @@ -1122,7 +1123,13 @@ $VDloginDISPLAY=0; $view_calls_in_queue_launch = $row[48]; $call_requeue_button = $row[49]; $pause_after_each_call = $row[50]; + $no_hopper_dialing = $row[51]; + $agent_dial_owner_only = $row[52]; + if (preg_match("/Y/",$no_hopper_dialing)) + {$no_hopper_dialing=1;} + else + {$no_hopper_dialing=0;} if (preg_match("/Y/",$call_requeue_button)) {$call_requeue_button=1;} @@ -1516,7 +1523,7 @@ else echo "\n"; } echo "Agent web client\n"; - $stmt="SELECT * from phones where login='$phone_login' and pass='$phone_pass' and active = 'Y';"; + $stmt="SELECT extension,dialplan_number,voicemail_id,phone_ip,computer_ip,server_ip,login,pass,status,active,phone_type,fullname,company,picture,messages,old_messages,protocol,local_gmt,ASTmgrUSERNAME,ASTmgrSECRET,login_user,login_pass,login_campaign,park_on_extension,conf_on_extension,VICIDIAL_park_on_extension,VICIDIAL_park_on_filename,monitor_prefix,recording_exten,voicemail_exten,voicemail_dump_exten,ext_context,dtmf_send_extension,call_out_number_group,client_browser,install_directory,local_web_callerID_URL,VICIDIAL_web_URL,AGI_call_logging_enabled,user_switching_enabled,conferencing_enabled,admin_hangup_enabled,admin_hijack_enabled,admin_monitor_enabled,call_parking_enabled,updater_check_enabled,AFLogging_enabled,QUEUE_ACTION_enabled,CallerID_popup_enabled,voicemail_button_enabled,enable_fast_refresh,fast_refresh_rate,enable_persistant_mysql,auto_dial_next_number,VDstop_rec_after_each_call,DBX_server,DBX_database,DBX_user,DBX_pass,DBX_port,DBY_server,DBY_database,DBY_user,DBY_pass,DBY_port,outbound_cid,enable_sipsak_messages,email,template_id,conf_override,phone_context,phone_ring_timeout,conf_secret from phones where login='$phone_login' and pass='$phone_pass' and active = 'Y';"; if ($DB) {echo "|$stmt|\n";} $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01025',$VD_login,$server_ip,$session_name,$one_mysql_log);} @@ -2485,6 +2492,8 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";} var view_calls_in_queue_launch = ''; var view_calls_in_queue_active = ''; var call_requeue_button = ''; + var no_hopper_dialing = ''; + var agent_dial_owner_only = ''; var no_empty_session_warnings = ''; var DiaLControl_auto_HTML = "\"\"Resume\""; var DiaLControl_auto_HTML_ready = "\"\"Resume\""; @@ -2720,6 +2729,11 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";} threeway_end=0; leaving_threeway=1; + if (customerparked > 0) + { + mainxfer_send_redirect('FROMParK',lastcustchannel,lastcustserverip); + } + mainxfer_send_redirect('3WAY','','',tempvarattempt); // if (threeway_end == '0') @@ -4398,6 +4412,7 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";} if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { var MDnextResponse = null; + // alert(manDiaLnext_query); // alert(xmlhttp.responseText); MDnextResponse = xmlhttp.responseText; @@ -4493,7 +4508,9 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";} dialed_number = MDnextResponse_array[32]; dialed_label = MDnextResponse_array[33]; source_id = MDnextResponse_array[34]; - + document.vicidial_form.rank.value = MDnextResponse_array[35]; + document.vicidial_form.owner.value = MDnextResponse_array[36]; + lead_dial_number = document.vicidial_form.phone_number.value; var dispnum = document.vicidial_form.phone_number.value; var status_display_number = phone_number_format(dispnum); @@ -4568,6 +4585,8 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";} "&dialed_number=" + dialed_number + '' + "&dialed_label=" + dialed_label + '' + "&source_id=" + source_id + '' + + "&rank=" + document.vicidial_form.rank.value + '' + + "&owner=" + document.vicidial_form.owner.value + '' + webform_session; var regWFspace = new RegExp(" ","ig"); @@ -4728,7 +4747,7 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";} var tmp_pn = document.getElementById("phone_numberDISP"); tmp_pn.innerHTML = '                     '; } - document.vicidial_form.phone_number.value = ''; + document.vicidial_form.phone_number.value =''; document.vicidial_form.title.value =''; document.vicidial_form.first_name.value =''; document.vicidial_form.middle_initial.value =''; @@ -4748,6 +4767,8 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";} document.vicidial_form.security_phrase.value=''; document.vicidial_form.comments.value =''; document.vicidial_form.called_count.value =''; + document.vicidial_form.rank.value =''; + document.vicidial_form.owner.value =''; VDCL_group_id = ''; fronter = ''; previous_called_count = ''; @@ -5318,7 +5339,9 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";} EAalt_phone_notes = check_VDIC_array[41]; EAalt_phone_active = check_VDIC_array[42]; EAalt_phone_count = check_VDIC_array[43]; - + document.vicidial_form.rank.value = check_VDIC_array[44]; + document.vicidial_form.owner.value = check_VDIC_array[45]; + var gIndex = 0; if (document.vicidial_form.gender.value == 'M') {var gIndex = 1;} if (document.vicidial_form.gender.value == 'F') {var gIndex = 2;} @@ -5514,6 +5537,8 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";} "&dialed_number=" + dialed_number + '' + "&dialed_label=" + dialed_label + '' + "&source_id=" + source_id + '' + + "&rank=" + document.vicidial_form.rank.value + '' + + "&owner=" + document.vicidial_form.owner.value + '' + webform_session; var regWFspace = new RegExp(" ","ig"); @@ -5658,6 +5683,8 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";} "&dialed_number=" + dialed_number + '' + "&dialed_label=" + dialed_label + '' + "&source_id=" + source_id + '' + + "&rank=" + document.vicidial_form.rank.value + '' + + "&owner=" + document.vicidial_form.owner.value + '' + webform_session; var regWFspace = new RegExp(" ","ig"); @@ -7084,6 +7111,8 @@ encoded=utf8_decode(xtest); var SCsession_id = session_id; var SCdialed_number = dialed_number; var SCdialed_label = dialed_label; + var SCrank = document.vicidial_form.rank.value; + var SCowner = document.vicidial_form.owner.value; var SCweb_vars = LIVE_web_vars; if (encoded.match(RGiframe)) @@ -7129,6 +7158,8 @@ encoded=utf8_decode(xtest); SCSIPexten = SCSIPexten.replace(RGplus,'+'); SCdialed_number = SCdialed_number.replace(RGplus,'+'); SCdialed_label = SCdialed_label.replace(RGplus,'+'); + SCrank = SCrank.replace(RGplus,'+'); + SCowner = SCowner.replace(RGplus,'+'); SCweb_vars = SCweb_vars.replace(RGplus,'+'); } @@ -7175,6 +7206,8 @@ encoded=utf8_decode(xtest); var RGsession_id = new RegExp("--A--session_id--B--","g"); var RGdialed_number = new RegExp("--A--dialed_number--B--","g"); var RGdialed_label = new RegExp("--A--dialed_label--B--","g"); + var RGrank = new RegExp("--A--rank--B--","g"); + var RGowner = new RegExp("--A--owner--B--","g"); var RGweb_vars = new RegExp("--A--web_vars--B--","g"); encoded = encoded.replace(RGvendor_lead_code, SCvendor_lead_code); @@ -7220,6 +7253,8 @@ encoded=utf8_decode(xtest); encoded = encoded.replace(RGsession_id, SCsession_id); encoded = encoded.replace(RGdialed_number, SCdialed_number); encoded = encoded.replace(RGdialed_label, SCdialed_label); + encoded = encoded.replace(RGrank, SCrank); + encoded = encoded.replace(RGowner, SCowner); encoded = encoded.replace(RGweb_vars, SCweb_vars); } decoded=encoded; // simple no ? @@ -9038,6 +9073,8 @@ if ($call_requeue_button > 0) + + diff --git a/www/vicidial/admin.php b/www/vicidial/admin.php index 58e91530..2e32d667 100644 --- a/www/vicidial/admin.php +++ b/www/vicidial/admin.php @@ -1081,6 +1081,12 @@ if (isset($_GET["call_requeue_button"])) {$call_requeue_button=$_GET["call_req elseif (isset($_POST["call_requeue_button"])) {$call_requeue_button=$_POST["call_requeue_button"];} if (isset($_GET["pause_after_each_call"])) {$pause_after_each_call=$_GET["pause_after_each_call"];} elseif (isset($_POST["pause_after_each_call"])) {$pause_after_each_call=$_POST["pause_after_each_call"];} +if (isset($_GET["no_hopper_dialing"])) {$no_hopper_dialing=$_GET["no_hopper_dialing"];} + elseif (isset($_POST["no_hopper_dialing"])) {$no_hopper_dialing=$_POST["no_hopper_dialing"];} +if (isset($_GET["agent_dial_owner_only"])) {$agent_dial_owner_only=$_GET["agent_dial_owner_only"];} + elseif (isset($_POST["agent_dial_owner_only"])) {$agent_dial_owner_only=$_POST["agent_dial_owner_only"];} +if (isset($_GET["reset_time"])) {$reset_time=$_GET["reset_time"];} + elseif (isset($_POST["reset_time"])) {$reset_time=$_POST["reset_time"];} if (isset($script_id)) {$script_id= strtoupper($script_id);} if (isset($lead_filter_id)) {$lead_filter_id = strtoupper($lead_filter_id);} @@ -1335,6 +1341,7 @@ if ($non_latin < 1) $sounds_update = ereg_replace("[^NY]","",$sounds_update); $carrier_logging_active = ereg_replace("[^NY]","",$carrier_logging_active); $agent_status_view_time = ereg_replace("[^NY]","",$agent_status_view_time); + $no_hopper_dialing = ereg_replace("[^NY]","",$no_hopper_dialing); $qc_enabled = ereg_replace("[^0-9NY]","",$qc_enabled); $active = ereg_replace("[^0-9NY]","",$active); @@ -1522,6 +1529,8 @@ if ($non_latin < 1) $prepopulate_transfer_preset = ereg_replace("[^-_0-9a-zA-Z]","",$prepopulate_transfer_preset); $tts_id = ereg_replace("[^-_0-9a-zA-Z]","",$tts_id); $drop_rate_group = ereg_replace("[^-_0-9a-zA-Z]","",$drop_rate_group); + $agent_dial_owner_only = ereg_replace("[^-_0-9a-zA-Z]","",$agent_dial_owner_only); + $reset_time = ereg_replace("[^-_0-9a-zA-Z]","",$reset_time); ### ALPHA-NUMERIC and underscore and dash and slash and dot $menu_prompt = ereg_replace("[^-\/\|\._0-9a-zA-Z]","",$menu_prompt); @@ -1884,11 +1893,13 @@ else # 90705-0926 - Added User Group agent view options # 90710-1528 - Added Agent view and grab queue calls and every call pause options # 90717-0646 - Added dialed_label and dialed_number to script variables +# 90721-1350 - Added RANK and OWNER as list order options and list screen display tables +# 90722-1235 - Added list reset time and campaign no hopper dialing, agent dial owner only options # # make sure you have added a user to the vicidial_users MySQL table with at least user_level 8 to access this page the first time -$admin_version = '2.2.0-206'; -$build = '90717-0646'; +$admin_version = '2.2.0-208'; +$build = '90722-1235'; $STARTtime = date("U"); $SQLdate = date("Y-m-d H:i:s"); @@ -1924,15 +1935,15 @@ $dtmf[17]='TIMEOUT'; $dtmf_key[17]='TIMEOUT'; $dtmf[18]='INVALID'; $dtmf_key[18]='INVALID'; if ($force_logout) -{ - if( (strlen($PHP_AUTH_USER)>0) or (strlen($PHP_AUTH_PW)>0) ) { - Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); - Header("HTTP/1.0 401 Unauthorized"); + if( (strlen($PHP_AUTH_USER)>0) or (strlen($PHP_AUTH_PW)>0) ) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + } + echo "You have now logged out. Thank you\n"; + exit; } - echo "You have now logged out. Thank you\n"; - exit; -} ############################################# ##### START SYSTEM_SETTINGS LOOKUP ##### @@ -3135,7 +3146,7 @@ if ($SSqc_features_active > 0)

-Export Reports - This setting if set to 1 will allow a manager to access the export call reports on the REPORTS screen. Default is 0. For the Export Calls Report, the following field order is used for exports:
call_date, phone_number, status, user, full_name, campaign_id/in-group, vendor_lead_code, source_id, list_id, gmt_offset_now, phone_code, phone_number, title, first_name, middle_initial, last_name, address1, address2, address3, city, state, province, postal_code, country_code, gender, date_of_birth, alt_phone, email, security_phrase, comments, length_in_sec, user_group, alt_dial/queue_seconds +Export Reports - This setting if set to 1 will allow a manager to access the export call reports on the REPORTS screen. Default is 0. For the Export Calls Report, the following field order is used for exports:
call_date, phone_number, status, user, full_name, campaign_id/in-group, vendor_lead_code, source_id, list_id, gmt_offset_now, phone_code, phone_number, title, first_name, middle_initial, last_name, address1, address2, address3, city, state, province, postal_code, country_code, gender, date_of_birth, alt_phone, email, security_phrase, comments, length_in_sec, user_group, alt_dial/queue_seconds, rank, owner
@@ -3251,6 +3262,10 @@ if ($SSoutbound_autodial_active > 0)
  - RANDOM: Randomly grabs lead within the statuses and lists defined
  - UP LAST CALL TIME: Sorts by the newest local call time for the leads
  - DOWN LAST CALL TIME: Sorts by the oldest local call time for the leads +
  - UP RANK: Starts with the highest rank and works its way down +
  - DOWN RANK: Starts with the lowest rank and works its way up +
  - UP OWNER: Starts with owners beginning with Z and works its way down +
  - DOWN OWNER: Starts with owners beginning with A and works its way up
@@ -3399,6 +3414,16 @@ if ($SSoutbound_autodial_active > 0)
Allow No-Hopper-Leads Logins - If set to Y, allows agents to login to the campaign even if there are no leads loaded into the hopper for that campaign. This function is not needed in CLOSER-type campaigns. Default is N. +
+
+
+ No Hopper Dialing - If This is enabled, the hopper will not run for this campaign. This option is only available when the dial method is set to MANUAL or INBOUND_MAN. It is recommended that you do not enable this option if you have a very large lead database, over 100,000 leads. With No Hopper Dialing, the following features do not work: lead recycling, auto-alt-dialing, list mix, list ordering with Xth NEW. If you want to use Owner Only Dialing you must have No Hopper Dialing enabled. Default is N for disabled. + +
+
+
+ Owner Only Dialing - If This is enabled, the agent will only receive leads that they are within the ownership parameters for. If this is set to USER then the agent must be the user defined in the database as the owner of this lead. If this is set to TERRITORY then the owner of the lead must match the territory listed in the User Modification screen for this agent. If this is set to USER_GROUP then the owner of the lead must match the user group that the agent is a member of. For this feature to work the dial method must be set to MANUAL or INBOUND_MAN and No Hopper Dialing must be enabled. Default is NONE for disabled. +

@@ -3818,6 +3843,11 @@ if ($SSqc_features_active > 0)
Reset Lead-Called-Status for this list - This resets all leads in this list to N for "not called since last reset" and means that any lead can now be called if it is the right status as defined in the campaign screen. +
+
+
+Reset Times - This field allows you to put times in, separated by a dash-, that this list will be automatically reset by the system. The times must be in 24 hour format with no punctuation, for example 0800-1700 would reset the list at 8AM and 5PM every day. Default is empty. +

@@ -4497,10 +4527,10 @@ if ($SSqc_features_active > 0)
-Script Text - This is where you place the content of a Vicidial Script. Minimum of 2 characters. You can have customer information be auto-populated in this script using "--A--field--B--" where field is one of the following fieldnames: vendor_lead_code, source_id, list_id, gmt_offset_now, called_since_last_reset, phone_code, phone_number, title, first_name, middle_initial, last_name, address1, address2, address3, city, state, province, postal_code, country_code, gender, date_of_birth, alt_phone, email, security_phrase, comments, lead_id, campaign, phone_login, group, channel_group, SQLdate, epoch, uniqueid, customer_zap_channel, server_ip, SIPexten, session_id, dialed_number, dialed_label. For example, this sentence would print the persons name in it----

Hello, can I speak with --A--first_name--B-- --A--last_name--B-- please? Well hello --A--title--B-- --A--last_name--B-- how are you today?

This would read----

Hello, can I speak with John Doe please? Well hello Mr. Doe how are you today?

You can also use an iframe to load a separate window within the SCRIPT tab, here is an example with prepopulated variables: +Script Text - This is where you place the content of a Vicidial Script. Minimum of 2 characters. You can have customer information be auto-populated in this script using "--A--field--B--" where field is one of the following fieldnames: vendor_lead_code, source_id, list_id, gmt_offset_now, called_since_last_reset, phone_code, phone_number, title, first_name, middle_initial, last_name, address1, address2, address3, city, state, province, postal_code, country_code, gender, date_of_birth, alt_phone, email, security_phrase, comments, lead_id, campaign, phone_login, group, channel_group, SQLdate, epoch, uniqueid, customer_zap_channel, server_ip, SIPexten, session_id, dialed_number, dialed_label, rank, owner. For example, this sentence would print the persons name in it----

Hello, can I speak with --A--first_name--B-- --A--last_name--B-- please? Well hello --A--title--B-- --A--last_name--B-- how are you today?

This would read----

Hello, can I speak with John Doe please? Well hello Mr. Doe how are you today?

You can also use an iframe to load a separate window within the SCRIPT tab, here is an example with prepopulated variables:
-<iframe src="http://astguiclient.sf.net/test_VICIDIAL_output.php?lead_id=--A--lead_id--B--&vendor_id=--A--vendor_lead_code--B--&list_id=--A--list_id--B--&gmt_offset_now=--A--gmt_offset_now--B--&phone_code=--A--phone_code--B--&phone_number=--A--phone_number--B--&title=--A--title--B--&first_name=--A--first_name--B--&middle_initial=--A--middle_initial--B--&last_name=--A--last_name--B--&address1=--A--address1--B--&address2=--A--address2--B--&address3=--A--address3--B--&city=--A--city--B--&state=--A--state--B--&province=--A--province--B--&postal_code=--A--postal_code--B--&country_code=--A--country_code--B--&gender=--A--gender--B--&date_of_birth=--A--date_of_birth--B--&alt_phone=--A--alt_phone--B--&email=--A--email--B--&security_phrase=--A--security_phrase--B--&comments=--A--comments--B--&user=--A--user--B--&campaign=--A--campaign--B--&phone_login=--A--phone_login--B--&fronter=--A--fronter--B--&closer=--A--user--B--&group=--A--group--B--&channel_group=--A--group--B--&SQLdate=--A--SQLdate--B--&epoch=--A--epoch--B--&uniqueid=--A--uniqueid--B--&customer_zap_channel=--A--customer_zap_channel--B--&server_ip=--A--server_ip--B--&SIPexten=--A--SIPexten--B--&session_id=--A--session_id--B--&dialed_number=--A--dialed_number--B--&dialed_label=--A--dialed_label--B--&phone=--A--phone--B--" style="width:580;height:290;background-color:transparent;" scrolling="auto" frameborder="0" allowtransparency="true" id="popupFrame" name="popupFrame" width="460" height="290" STYLE="z-index:17"> +<iframe src="http://astguiclient.sf.net/test_VICIDIAL_output.php?lead_id=--A--lead_id--B--&vendor_id=--A--vendor_lead_code--B--&list_id=--A--list_id--B--&gmt_offset_now=--A--gmt_offset_now--B--&phone_code=--A--phone_code--B--&phone_number=--A--phone_number--B--&title=--A--title--B--&first_name=--A--first_name--B--&middle_initial=--A--middle_initial--B--&last_name=--A--last_name--B--&address1=--A--address1--B--&address2=--A--address2--B--&address3=--A--address3--B--&city=--A--city--B--&state=--A--state--B--&province=--A--province--B--&postal_code=--A--postal_code--B--&country_code=--A--country_code--B--&gender=--A--gender--B--&date_of_birth=--A--date_of_birth--B--&alt_phone=--A--alt_phone--B--&email=--A--email--B--&security_phrase=--A--security_phrase--B--&comments=--A--comments--B--&user=--A--user--B--&campaign=--A--campaign--B--&phone_login=--A--phone_login--B--&fronter=--A--fronter--B--&closer=--A--user--B--&group=--A--group--B--&channel_group=--A--group--B--&SQLdate=--A--SQLdate--B--&epoch=--A--epoch--B--&uniqueid=--A--uniqueid--B--&customer_zap_channel=--A--customer_zap_channel--B--&server_ip=--A--server_ip--B--&SIPexten=--A--SIPexten--B--&session_id=--A--session_id--B--&dialed_number=--A--dialed_number--B--&dialed_label=--A--dialed_label--B--&rank=--A--rank--B--&owner=--A--owner--B--&phone=--A--phone--B--" style="width:580;height:290;background-color:transparent;" scrolling="auto" frameborder="0" allowtransparency="true" id="popupFrame" name="popupFrame" width="460" height="290" STYLE="z-index:17"> </iframe>
@@ -4626,7 +4656,7 @@ if ($SSoutbound_autodial_active > 0)
-TTS Text - This is the actual Text To Speech data field that is sent to Cepstral for creation of the audio file to be played to the customer. you can use Speech Synthesis Markup Language -SSML- in this field, for example, <break time='1000ms'/> for a 1 second break. You can also use several variables such as first name, last name and title as ViciDial variables just like you do in a Script: --A--first_name--B--. Here is a list of the available variables: lead_id, entry_date, modify_date, status, user, vendor_lead_code, source_id, list_id, phone_number, title, first_name, middle_initial, last_name, address1, address2, address3, city, state, province, postal_code, country_code, gender, date_of_birth, alt_phone, email, security_phrase, comments, called_count, last_local_call_time +TTS Text - This is the actual Text To Speech data field that is sent to Cepstral for creation of the audio file to be played to the customer. you can use Speech Synthesis Markup Language -SSML- in this field, for example, <break time='1000ms'/> for a 1 second break. You can also use several variables such as first name, last name and title as ViciDial variables just like you do in a Script: --A--first_name--B--. Here is a list of the available variables: lead_id, entry_date, modify_date, status, user, vendor_lead_code, source_id, list_id, phone_number, title, first_name, middle_initial, last_name, address1, address2, address3, city, state, province, postal_code, country_code, gender, date_of_birth, alt_phone, email, security_phrase, comments, called_count, last_local_call_time, rank, owner @@ -5764,6 +5794,8 @@ if ($ADD==7111111) $RGsession_id = '8600051'; $RGdialed_number = '3125551111'; $RGdialed_label = 'ALT'; + $RGrank = '99'; + $RGowner = '6666'; echo "\n"; echo "\n"; @@ -5817,6 +5849,8 @@ if ($ADD==7111111) $RGsession_id = eregi_replace(' ','+',$RGsession_id); $RGdialed_number = eregi_replace(' ','+',$RGdialed_number); $RGdialed_label = eregi_replace(' ','+',$RGdialed_label); + $RGrank = eregi_replace(' ','+',$RGrank); + $RGowner = eregi_replace(' ','+',$RGowner); } $script_text = eregi_replace('--A--vendor_lead_code--B--',"$vendor_lead_code",$script_text); @@ -5859,6 +5893,8 @@ if ($ADD==7111111) $script_text = eregi_replace('--A--session_id--B--',"$RGsession_id",$script_text); $script_text = eregi_replace('--A--dialed_number--B--',"$RGdialed_number",$script_text); $script_text = eregi_replace('--A--dialed_label--B--',"$RGdialed_label",$script_text); + $script_text = eregi_replace('--A--rank--B--',"$RGrank",$script_text); + $script_text = eregi_replace('--A--owner--B--',"$RGowner",$script_text); $script_text = eregi_replace("\n","
",$script_text); @@ -6898,6 +6934,8 @@ if ($ADD==1111111) echo ""; echo ""; echo ""; + echo ""; + echo ""; echo ""; echo "
"; # END Insert Field @@ -8089,7 +8127,7 @@ if ($ADD==20) { echo "
CAMPAIGN COPIED: $campaign_id copied from $source_campaign_id\n"; - $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) 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 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) 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 from vicidial_campaigns where campaign_id='$source_campaign_id';"; $rslt=mysql_query($stmt, $link); $stmtA="INSERT INTO vicidial_campaign_stats (campaign_id) values('$campaign_id');"; @@ -10540,10 +10578,21 @@ if ($ADD==41) { echo "
CAMPAIGN MODIFIED: $campaign_id\n"; + if ( ($dial_method != 'MANUAL') and ($dial_method != 'INBOUND_MAN') ) + { + $no_hopper_dialing='N'; + $agent_dial_owner_only='NONE'; + } + if ($no_hopper_dialing == 'Y') + { + $auto_alt_dial='NONE'; + $list_order_mix='DISABLED'; + } if ($dial_method == 'MANUAL') { $auto_dial_level='0'; $adlSQL = "auto_dial_level='0',"; + $campaign_allow_inbound='N'; } else { @@ -10572,7 +10621,7 @@ if ($ADD==41) if ( (!ereg("DISABLED",$list_order_mix)) and ($hopper_level < 100) ) {$hopper_level='100';} - $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', $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='" . mysql_real_escape_string($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='$groups_value',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' 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', $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='" . mysql_real_escape_string($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='$groups_value',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' where campaign_id='$campaign_id';"; $rslt=mysql_query($stmtA, $link); if ($reset_hopper == 'Y') @@ -11318,9 +11367,11 @@ if ($ADD==411) } else { + if (strlen($reset_time) < 4) {$reset_time='';} + echo "
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' 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' where list_id='$list_id';"; $rslt=mysql_query($stmt, $link); ### LOG INSERTION Admin Log Table ### @@ -14748,7 +14799,7 @@ if ($ADD==31) $enable_vtiger_integration_LU = $row[0]; $vtiger_url_LU = $row[1]; - $stmt="SELECT * from vicidial_campaigns where campaign_id='$campaign_id';"; + $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 from vicidial_campaigns where campaign_id='$campaign_id';"; $rslt=mysql_query($stmt, $link); $row=mysql_fetch_row($rslt); $campaign_name = $row[1]; @@ -14872,7 +14923,8 @@ if ($ADD==31) $grab_calls_in_queue = $row[122]; $call_requeue_button = $row[123]; $pause_after_each_call = $row[124]; - + $no_hopper_dialing = $row[125]; + $agent_dial_owner_only = $row[126]; if (ereg("DISABLED",$list_order_mix)) {$DEFlistDISABLE = ''; $DEFstatusDISABLED=0;} @@ -15142,6 +15194,7 @@ if ($ADD==31) echo "     $NWB#vicidial_campaigns-dial_status$NWE\n"; echo "List Order: $NWB#vicidial_campaigns-lead_order$NWE\n"; + + + + + + + + + + + + + + + + + + + + + $NWB#vicidial_campaigns-lead_order$NWE\n"; echo "
List Mix: $NWB#vicidial_campaigns-no_hopper_leads_logins$NWE\n"; + + echo "No Hopper Dialing: $NWB#vicidial_campaigns-no_hopper_dialing$NWE\n"; + + echo "Owner Only Dialing: $NWB#vicidial_campaigns-agent_dial_owner_only$NWE\n"; } + echo "Agent Display Queue Count: $NWB#vicidial_campaigns-display_queue_count$NWE\n"; echo "Agent View Calls in Queue: $NWB#vicidial_campaigns-view_calls_in_queue$NWE\n"; @@ -16397,6 +16479,7 @@ if ($ADD==34) echo "     $NWB#vicidial_campaigns-dial_status$NWE\n"; echo "List Order: $NWB#vicidial_campaigns-lead_order$NWE\n"; + + + + + + + + + + + + + + + + + + + + + $NWB#vicidial_campaigns-lead_order$NWE\n"; echo "List Mix: $NWB#vicidial_lists-campaign_id$NWE\n"; echo "Active: $NWB#vicidial_lists-active$NWE\n"; echo "Reset Lead-Called-Status for this list: $NWB#vicidial_lists-reset_list$NWE\n"; + echo "Reset Times: $NWB#vicidial_lists-reset_time$NWE\n"; echo "List Change Date: $list_changedate   $NWB#vicidial_lists-list_changedate$NWE\n"; echo "List Last Call Date: $list_lastcalldate   $NWB#vicidial_lists-list_lastcalldate$NWE\n"; echo "\n"; @@ -17451,33 +17562,33 @@ if ($ADD==311) $lead_list['Y_count'] = 0; $lead_list['N_count'] = 0; while ($statuses_to_print > $o) - { + { $rowx=mysql_fetch_row($rslt); $lead_list['count'] = ($lead_list['count'] + $rowx[2]); if ($rowx[1] == 'N') - { - $since_reset = 'N'; - $since_resetX = 'Y'; - } + { + $since_reset = 'N'; + $since_resetX = 'Y'; + } else - { - $since_reset = 'Y'; - $since_resetX = 'N'; - } + { + $since_reset = 'Y'; + $since_resetX = 'N'; + } $lead_list[$since_reset][$rowx[0]] = ($lead_list[$since_reset][$rowx[0]] + $rowx[2]); $lead_list[$since_reset.'_count'] = ($lead_list[$since_reset.'_count'] + $rowx[2]); #If opposite side is not set, it may not in the future so give it a value of zero if (!isset($lead_list[$since_resetX][$rowx[0]])) - { - $lead_list[$since_resetX][$rowx[0]]=0; - } - $o++; - } + { + $lead_list[$since_resetX][$rowx[0]]=0; + } + $o++; + } $o=0; if ($lead_list['count'] > 0) - { + { while (list($dispo,) = each($lead_list[$since_reset])) { @@ -17574,6 +17685,150 @@ if ($ADD==311) + + + echo "
\n"; + echo "
OWNERS WITHIN THIS LIST:
\n"; + echo "\n"; + echo "\n"; + + $leads_in_list = 0; + $leads_in_list_N = 0; + $leads_in_list_Y = 0; + $stmt="SELECT owner,called_since_last_reset,count(*) from vicidial_list where list_id='$list_id' group by owner,called_since_last_reset order by owner,called_since_last_reset"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $owners_to_print = mysql_num_rows($rslt); + + $o=0; + $lead_list['count'] = 0; + $lead_list['Y_count'] = 0; + $lead_list['N_count'] = 0; + while ($owners_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + + $lead_list['count'] = ($lead_list['count'] + $rowx[2]); + if ($rowx[1] == 'N') + { + $since_reset = 'N'; + $since_resetX = 'Y'; + } + else + { + $since_reset = 'Y'; + $since_resetX = 'N'; + } + $lead_list[$since_reset][$rowx[0]] = ($lead_list[$since_reset][$rowx[0]] + $rowx[2]); + $lead_list[$since_reset.'_count'] = ($lead_list[$since_reset.'_count'] + $rowx[2]); + #If opposite side is not set, it may not in the future so give it a value of zero + if (!isset($lead_list[$since_resetX][$rowx[0]])) + { + $lead_list[$since_resetX][$rowx[0]]=0; + } + $o++; + } + + $o=0; + if ($lead_list['count'] > 0) + { + while (list($owner,) = each($lead_list[$since_reset])) + { + + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + $CLB=''; + $CLE=''; + + echo "\n"; + $o++; + } + } + + echo "\n"; + echo "\n"; + + echo "
OWNERCALLEDNOT CALLED
$CLB$owner$CLE".$lead_list['Y'][$owner]."".$lead_list['N'][$owner]."
SUBTOTALS$lead_list[Y_count]$lead_list[N_count]
TOTAL$lead_list[count]

\n"; + unset($lead_list); + + + + + + echo "
\n"; + echo "
RANKS WITHIN THIS LIST:
\n"; + echo "\n"; + echo "\n"; + + $leads_in_list = 0; + $leads_in_list_N = 0; + $leads_in_list_Y = 0; + $stmt="SELECT rank,called_since_last_reset,count(*) from vicidial_list where list_id='$list_id' group by rank,called_since_last_reset order by rank,called_since_last_reset"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $ranks_to_print = mysql_num_rows($rslt); + + $o=0; + $lead_list['count'] = 0; + $lead_list['Y_count'] = 0; + $lead_list['N_count'] = 0; + while ($ranks_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + + $lead_list['count'] = ($lead_list['count'] + $rowx[2]); + if ($rowx[1] == 'N') + { + $since_reset = 'N'; + $since_resetX = 'Y'; + } + else + { + $since_reset = 'Y'; + $since_resetX = 'N'; + } + $lead_list[$since_reset][$rowx[0]] = ($lead_list[$since_reset][$rowx[0]] + $rowx[2]); + $lead_list[$since_reset.'_count'] = ($lead_list[$since_reset.'_count'] + $rowx[2]); + #If opposite side is not set, it may not in the future so give it a value of zero + if (!isset($lead_list[$since_resetX][$rowx[0]])) + { + $lead_list[$since_resetX][$rowx[0]]=0; + } + $o++; + } + + $o=0; + if ($lead_list['count'] > 0) + { + while (list($rank,) = each($lead_list[$since_reset])) + { + + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + $CLB=''; + $CLE=''; + + echo "\n"; + $o++; + } + } + + echo "\n"; + echo "\n"; + + echo "
RANKCALLEDNOT CALLED
$CLB$rank$CLE".$lead_list['Y'][$rank]."".$lead_list['N'][$rank]."
SUBTOTALS$lead_list[Y_count]$lead_list[N_count]
TOTAL$lead_list[count]

\n"; + unset($lead_list); + + + + + $leads_in_list = 0; $leads_in_list_N = 0; $leads_in_list_Y = 0; @@ -19003,6 +19258,8 @@ if ($ADD==3111111) echo ""; echo ""; echo ""; + echo ""; + echo ""; echo ""; echo "
"; # END Insert Field @@ -21359,7 +21616,7 @@ if ($ADD==100) if (eregi("CAMPAIGNDOWN",$stage)) {$SQLorder='order by campaign_id desc'; $CAMPAIGNlink='stage=CAMPAIGNUP';} if (eregi("CALLDATEUP",$stage)) {$SQLorder='order by list_lastcalldate asc'; $CALLDATElink='stage=CALLDATEDOWN';} if (eregi("CALLDATEDOWN",$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 from vicidial_lists vls,vicidial_list vl where vls.list_id=vl.list_id group by list_id $SQLorder"; + $stmt="SELECT vls.list_id,list_name,list_description,count(*) as tally,active,list_lastcalldate,campaign_id,reset_time from vicidial_lists vls,vicidial_list vl where vls.list_id=vl.list_id group by list_id $SQLorder"; $rslt=mysql_query($stmt, $link); $lists_to_print = mysql_num_rows($rslt); @@ -21369,6 +21626,7 @@ if ($ADD==100) echo "LIST ID"; echo "LIST NAME"; echo "DESCRIPTION\n"; + echo "RTIME\n"; echo "LEADS COUNT\n"; echo "ACTIVE"; echo "LAST CALL DATE"; @@ -21389,6 +21647,7 @@ if ($ADD==100) echo " $row[1]"; echo " $row[2]"; echo " $row[3]"; + echo " $row[7]"; echo " $row[4]"; echo " $row[5]"; echo " $row[6]"; diff --git a/www/vicidial/admin_modify_lead.php b/www/vicidial/admin_modify_lead.php index 2ecbbf52..093e967e 100644 --- a/www/vicidial/admin_modify_lead.php +++ b/www/vicidial/admin_modify_lead.php @@ -31,6 +31,7 @@ # 90309-1829 - Added admin_log logging # 90508-0644 - Changed to PHP long tags # 90708-1549 - Added phone number dialed to outbound log +# 90721-1246 - Added rank and owner as vicidial_list fields # require("dbconnect.php"); @@ -102,6 +103,10 @@ if (isset($_GET["comments"])) {$comments=$_GET["comments"];} elseif (isset($_POST["comments"])) {$comments=$_POST["comments"];} if (isset($_GET["status"])) {$status=$_GET["status"];} elseif (isset($_POST["status"])) {$status=$_POST["status"];} +if (isset($_GET["rank"])) {$rank=$_GET["rank"];} + elseif (isset($_POST["rank"])) {$rank=$_POST["rank"];} +if (isset($_GET["owner"])) {$owner=$_GET["owner"];} + elseif (isset($_POST["owner"])) {$owner=$_POST["owner"];} if (isset($_GET["submit"])) {$submit=$_GET["submit"];} elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} @@ -170,23 +175,23 @@ $date = date("r"); $ip = getenv("REMOTE_ADDR"); $browser = getenv("HTTP_USER_AGENT"); - if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) +if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) { Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); Header("HTTP/1.0 401 Unauthorized"); echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; exit; } - else +else { if($auth>0) { - $stmt="SELECT full_name,modify_leads from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; - $rslt=mysql_query($stmt, $link); - $row=mysql_fetch_row($rslt); - $LOGfullname =$row[0]; - $LOGmodify_leads =$row[1]; + $stmt="SELECT full_name,modify_leads from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname =$row[0]; + $LOGmodify_leads =$row[1]; if ($WeBRooTWritablE > 0) { @@ -216,15 +221,14 @@ $browser = getenv("HTTP_USER_AGENT"); echo "ADMINISTRATION: Lead record modification
\n"; if ($end_call > 0) -{ - + { ### update the lead record in the vicidial_list table - $stmt="UPDATE vicidial_list set status='" . mysql_real_escape_string($status) . "',first_name='" . mysql_real_escape_string($first_name) . "',last_name='" . mysql_real_escape_string($last_name) . "',address1='" . mysql_real_escape_string($address1) . "',address2='" . mysql_real_escape_string($address2) . "',address3='" . mysql_real_escape_string($address3) . "',city='" . mysql_real_escape_string($city) . "',state='" . mysql_real_escape_string($state) . "',province='" . mysql_real_escape_string($province) . "',postal_code='" . mysql_real_escape_string($postal_code) . "',country_code='" . mysql_real_escape_string($country_code) . "',alt_phone='" . mysql_real_escape_string($alt_phone) . "',phone_number='$phone_number',email='" . mysql_real_escape_string($email) . "',security_phrase='" . mysql_real_escape_string($security) . "',comments='" . mysql_real_escape_string($comments) . "' where lead_id='" . mysql_real_escape_string($lead_id) . "'"; + $stmt="UPDATE vicidial_list set status='" . mysql_real_escape_string($status) . "',first_name='" . mysql_real_escape_string($first_name) . "',last_name='" . mysql_real_escape_string($last_name) . "',address1='" . mysql_real_escape_string($address1) . "',address2='" . mysql_real_escape_string($address2) . "',address3='" . mysql_real_escape_string($address3) . "',city='" . mysql_real_escape_string($city) . "',state='" . mysql_real_escape_string($state) . "',province='" . mysql_real_escape_string($province) . "',postal_code='" . mysql_real_escape_string($postal_code) . "',country_code='" . mysql_real_escape_string($country_code) . "',alt_phone='" . mysql_real_escape_string($alt_phone) . "',phone_number='$phone_number',email='" . mysql_real_escape_string($email) . "',security_phrase='" . mysql_real_escape_string($security) . "',comments='" . mysql_real_escape_string($comments) . "',rank='" . mysql_real_escape_string($rank) . "',owner='" . mysql_real_escape_string($owner) . "' where lead_id='" . mysql_real_escape_string($lead_id) . "'"; if ($DB) {echo "|$stmt|\n";} $rslt=mysql_query($stmt, $link); - echo "information modified

\n"; - echo "
\n"; + echo "information modified

\n"; + echo "
\n"; ### LOG INSERTION Admin Log Table ### $SQL_log = "$stmt|"; @@ -235,69 +239,69 @@ if ($end_call > 0) $rslt=mysql_query($stmt, $link); if ( ($dispo != $status) and ($dispo == 'CBHOLD') ) - { + { ### inactivate vicidial_callbacks record for this lead $stmt="UPDATE vicidial_callbacks set status='INACTIVE' where lead_id='" . mysql_real_escape_string($lead_id) . "' and status='ACTIVE';"; if ($DB) {echo "|$stmt|\n";} $rslt=mysql_query($stmt, $link); echo "
vicidial_callback record inactivated: $lead_id
\n"; - } + } if ( ($dispo != $status) and ($dispo == 'CALLBK') ) - { + { ### inactivate vicidial_callbacks record for this lead $stmt="UPDATE vicidial_callbacks set status='INACTIVE' where lead_id='" . mysql_real_escape_string($lead_id) . "' and status IN('ACTIVE','LIVE');"; if ($DB) {echo "|$stmt|\n";} $rslt=mysql_query($stmt, $link); echo "
vicidial_callback record inactivated: $lead_id
\n"; - } + } if ( ($dispo != $status) and ($status == 'DNC') ) - { + { ### add lead to the internal DNC list $stmt="INSERT INTO vicidial_dnc (phone_number) values('" . mysql_real_escape_string($phone_number) . "');"; if ($DB) {echo "|$stmt|\n";} $rslt=mysql_query($stmt, $link); echo "
Lead added to DNC List: $lead_id - $phone_number
\n"; - } + } ### update last record in vicidial_log table if (($dispo != $status) and ($modify_logs > 0)) - { + { $stmt="UPDATE vicidial_log set status='" . mysql_real_escape_string($status) . "' where lead_id='" . mysql_real_escape_string($lead_id) . "' order by call_date desc limit 1"; if ($DB) {echo "|$stmt|\n";} $rslt=mysql_query($stmt, $link); - } + } ### update last record in vicidial_closer_log table if (($dispo != $status) and ($modify_closer_logs > 0)) - { + { $stmt="UPDATE vicidial_closer_log set status='" . mysql_real_escape_string($status) . "' where lead_id='" . mysql_real_escape_string($lead_id) . "' order by call_date desc limit 1"; if ($DB) {echo "|$stmt|\n";} $rslt=mysql_query($stmt, $link); - } + } ### update last record in vicidial_agent_log table if (($dispo != $status) and ($modify_agent_logs > 0)) - { + { $stmt="UPDATE vicidial_agent_log set status='" . mysql_real_escape_string($status) . "' where lead_id='" . mysql_real_escape_string($lead_id) . "' order by agent_log_id desc limit 1"; if ($DB) {echo "|$stmt|\n";} $rslt=mysql_query($stmt, $link); - } + } if ($add_closer_record > 0) - { + { ### insert a NEW record to the vicidial_closer_log table $stmt="INSERT INTO vicidial_closer_log (lead_id,list_id,campaign_id,call_date,start_epoch,end_epoch,length_in_sec,status,phone_code,phone_number,user,comments,processed) values('" . mysql_real_escape_string($lead_id) . "','" . mysql_real_escape_string($list_id) . "','" . mysql_real_escape_string($campaign_id) . "','" . mysql_real_escape_string($parked_time) . "','$NOW_TIME','$STARTtime','1','" . mysql_real_escape_string($status) . "','" . mysql_real_escape_string($phone_code) . "','" . mysql_real_escape_string($phone_number) . "','$PHP_AUTH_USER','" . mysql_real_escape_string($comments) . "','Y')"; if ($DB) {echo "|$stmt|\n";} $rslt=mysql_query($stmt, $link); + } + + } - - -} else -{ + { if ($CBchangeUSERtoANY == 'YES') { @@ -336,24 +340,23 @@ else $lead_count = $row[0]; if ($lead_count > 0) - { - - ##### grab vicidial_log records ##### - $stmt="select * from vicidial_log where lead_id='" . mysql_real_escape_string($lead_id) . "' order by uniqueid desc limit 500;"; - $rslt=mysql_query($stmt, $link); - $logs_to_print = mysql_num_rows($rslt); - - $u=0; - $call_log = ''; - $log_campaign = ''; - while ($logs_to_print > $u) { - $row=mysql_fetch_row($rslt); - if (strlen($log_campaign)<1) {$log_campaign = $row[3];} - if (eregi("1$|3$|5$|7$|9$", $u)) - {$bgcolor='bgcolor="#B9CBFD"';} - else - {$bgcolor='bgcolor="#9BB9FB"';} + ##### grab vicidial_log records ##### + $stmt="select uniqueid,lead_id,list_id,campaign_id,call_date,start_epoch,end_epoch,length_in_sec,status,phone_code,phone_number,user,comments,processed,user_group,term_reason,alt_dial from vicidial_log where lead_id='" . mysql_real_escape_string($lead_id) . "' order by uniqueid desc limit 500;"; + $rslt=mysql_query($stmt, $link); + $logs_to_print = mysql_num_rows($rslt); + + $u=0; + $call_log = ''; + $log_campaign = ''; + while ($logs_to_print > $u) + { + $row=mysql_fetch_row($rslt); + if (strlen($log_campaign)<1) {$log_campaign = $row[3];} + if (eregi("1$|3$|5$|7$|9$", $u)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} $u++; $call_log .= ""; @@ -369,24 +372,24 @@ else $call_log .= "  $row[10] \n"; $campaign_id = $row[3]; - } + } - ##### grab vicidial_agent_log records ##### - $stmt="select * from vicidial_agent_log where lead_id='" . mysql_real_escape_string($lead_id) . "' order by agent_log_id desc limit 500;"; - $rslt=mysql_query($stmt, $link); - $Alogs_to_print = mysql_num_rows($rslt); + ##### grab vicidial_agent_log records ##### + $stmt="select agent_log_id,user,server_ip,event_time,lead_id,campaign_id,pause_epoch,pause_sec,wait_epoch,wait_sec,talk_epoch,talk_sec,dispo_epoch,dispo_sec,status,user_group,comments,sub_status from vicidial_agent_log where lead_id='" . mysql_real_escape_string($lead_id) . "' order by agent_log_id desc limit 500;"; + $rslt=mysql_query($stmt, $link); + $Alogs_to_print = mysql_num_rows($rslt); - $y=0; - $agent_log = ''; - $Alog_campaign = ''; - while ($Alogs_to_print > $y) - { - $row=mysql_fetch_row($rslt); - if (strlen($Alog_campaign)<1) {$Alog_campaign = $row[5];} - if (eregi("1$|3$|5$|7$|9$", $y)) - {$bgcolor='bgcolor="#B9CBFD"';} - else - {$bgcolor='bgcolor="#9BB9FB"';} + $y=0; + $agent_log = ''; + $Alog_campaign = ''; + while ($Alogs_to_print > $y) + { + $row=mysql_fetch_row($rslt); + if (strlen($Alog_campaign)<1) {$Alog_campaign = $row[5];} + if (eregi("1$|3$|5$|7$|9$", $y)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} $y++; $agent_log .= ""; @@ -403,24 +406,24 @@ else $agent_log .= "   $row[17] \n"; $campaign_id = $row[5]; - } + } - ##### grab vicidial_closer_log records ##### - $stmt="select * from vicidial_closer_log where lead_id='" . mysql_real_escape_string($lead_id) . "' order by closecallid desc limit 500;"; - $rslt=mysql_query($stmt, $link); - $Clogs_to_print = mysql_num_rows($rslt); + ##### grab vicidial_closer_log records ##### + $stmt="select closecallid,lead_id,list_id,campaign_id,call_date,start_epoch,end_epoch,length_in_sec,status,phone_code,phone_number,user,comments,processed,queue_seconds,user_group,xfercallid,term_reason,uniqueid,agent_only from vicidial_closer_log where lead_id='" . mysql_real_escape_string($lead_id) . "' order by closecallid desc limit 500;"; + $rslt=mysql_query($stmt, $link); + $Clogs_to_print = mysql_num_rows($rslt); - $y=0; - $closer_log = ''; - $Clog_campaign = ''; - while ($Clogs_to_print > $y) - { - $row=mysql_fetch_row($rslt); - if (strlen($Clog_campaign)<1) {$Clog_campaign = $row[3];} - if (eregi("1$|3$|5$|7$|9$", $y)) - {$bgcolor='bgcolor="#B9CBFD"';} - else - {$bgcolor='bgcolor="#9BB9FB"';} + $y=0; + $closer_log = ''; + $Clog_campaign = ''; + while ($Clogs_to_print > $y) + { + $row=mysql_fetch_row($rslt); + if (strlen($Clog_campaign)<1) {$Clog_campaign = $row[3];} + if (eregi("1$|3$|5$|7$|9$", $y)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} $y++; $closer_log .= ""; @@ -436,39 +439,43 @@ else $closer_log .= "   $row[17] \n"; $campaign_id = $row[3]; - } + } - ##### grab vicidial_list data for lead ##### - $stmt="SELECT * from vicidial_list where lead_id='" . mysql_real_escape_string($lead_id) . "'"; + ##### grab vicidial_list data for lead ##### + $stmt="SELECT lead_id,entry_date,modify_date,status,user,vendor_lead_code,source_id,list_id,gmt_offset_now,called_since_last_reset,phone_code,phone_number,title,first_name,middle_initial,last_name,address1,address2,address3,city,state,province,postal_code,country_code,gender,date_of_birth,alt_phone,email,security_phrase,comments,called_count,last_local_call_time,rank,owner from vicidial_list where lead_id='" . mysql_real_escape_string($lead_id) . "'"; $rslt=mysql_query($stmt, $link); if ($DB) {echo "$stmt\n";} $row=mysql_fetch_row($rslt); - $lead_id = "$row[0]"; - $dispo = "$row[3]"; - $tsr = "$row[4]"; - $vendor_id = "$row[5]"; - $list_id = "$row[7]"; - $gmt_offset_now = "$row[8]"; - $phone_code = "$row[10]"; - $phone_number = "$row[11]"; - $title = "$row[12]"; - $first_name = "$row[13]"; # - $middle_initial = "$row[14]"; - $last_name = "$row[15]"; # - $address1 = "$row[16]"; # - $address2 = "$row[17]"; # - $address3 = "$row[18]"; # - $city = "$row[19]"; # - $state = "$row[20]"; # - $province = "$row[21]"; # - $postal_code = "$row[22]"; # - $country_code = "$row[23]"; # - $gender = "$row[24]"; - $date_of_birth = "$row[25]"; - $alt_phone = "$row[26]"; # - $email = "$row[27]"; # - $security = "$row[28]"; # - $comments = "$row[29]"; # + $lead_id = "$row[0]"; + $dispo = "$row[3]"; + $tsr = "$row[4]"; + $vendor_id = "$row[5]"; + $list_id = "$row[7]"; + $gmt_offset_now = "$row[8]"; + $phone_code = "$row[10]"; + $phone_number = "$row[11]"; + $title = "$row[12]"; + $first_name = "$row[13]"; + $middle_initial = "$row[14]"; + $last_name = "$row[15]"; + $address1 = "$row[16]"; + $address2 = "$row[17]"; + $address3 = "$row[18]"; + $city = "$row[19]"; + $state = "$row[20]"; + $province = "$row[21]"; + $postal_code = "$row[22]"; + $country_code = "$row[23]"; + $gender = "$row[24]"; + $date_of_birth = "$row[25]"; + $alt_phone = "$row[26]"; + $email = "$row[27]"; + $security = "$row[28]"; + $comments = "$row[29]"; + $called_count = "$row[30]"; + $last_local_call_time = "$row[31]"; + $rank = "$row[32]"; + $owner = "$row[33]"; echo "
Call information: $first_name $last_name - $phone_number

\n"; echo "\n"; @@ -502,45 +509,47 @@ else echo "Alt Phone : \n"; echo "Email : \n"; echo "Security : \n"; + echo "Rank : \n"; + echo "Owner : \n"; echo "Comments : \n"; - echo "Disposition: \n"; - $stmt="SELECT * from vicidial_statuses where selectable='Y' order by status"; - $rslt=mysql_query($stmt, $link); - $statuses_to_print = mysql_num_rows($rslt); - $statuses_list=''; + $stmt="SELECT status,status_name,selectable,human_answered,category,sale,dnc,customer_contact,not_interested,unworkable from vicidial_statuses where selectable='Y' order by status"; + $rslt=mysql_query($stmt, $link); + $statuses_to_print = mysql_num_rows($rslt); + $statuses_list=''; - $o=0; - $DS=0; - while ($statuses_to_print > $o) - { - $rowx=mysql_fetch_row($rslt); - if ( (strlen($dispo) == strlen($rowx[0])) and (eregi($dispo,$rowx[0])) ) - {$statuses_list .= "\n"; $DS++;} - else - {$statuses_list .= "\n";} - $o++; - } + $o=0; + $DS=0; + while ($statuses_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + if ( (strlen($dispo) == strlen($rowx[0])) and (eregi($dispo,$rowx[0])) ) + {$statuses_list .= "\n"; $DS++;} + else + {$statuses_list .= "\n";} + $o++; + } - $stmt="SELECT * from vicidial_campaign_statuses where selectable='Y' and campaign_id='$log_campaign' order by status"; - $rslt=mysql_query($stmt, $link); - $CAMPstatuses_to_print = mysql_num_rows($rslt); + $stmt="SELECT status,status_name,selectable,campaign_id,human_answered,category,sale,dnc,customer_contact,not_interested,unworkable from vicidial_campaign_statuses where selectable='Y' and campaign_id='$log_campaign' order by status"; + $rslt=mysql_query($stmt, $link); + $CAMPstatuses_to_print = mysql_num_rows($rslt); - $o=0; - while ($CAMPstatuses_to_print > $o) - { - $rowx=mysql_fetch_row($rslt); - if ( (strlen($dispo) == strlen($rowx[0])) and (eregi($dispo,$rowx[0])) ) - {$statuses_list .= "\n"; $DS++;} - else - {$statuses_list .= "\n";} - $o++; - } + $o=0; + while ($CAMPstatuses_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + if ( (strlen($dispo) == strlen($rowx[0])) and (eregi($dispo,$rowx[0])) ) + {$statuses_list .= "\n"; $DS++;} + else + {$statuses_list .= "\n";} + $o++; + } - if ($DS < 1) {$statuses_list .= "\n";} - echo "$statuses_list"; - echo " (with $log_campaign statuses)\n"; + if ($DS < 1) {$statuses_list .= "\n";} + echo "$statuses_list"; + echo " (with $log_campaign statuses)\n"; echo "Modify vicidial log \n"; @@ -554,9 +563,9 @@ else echo "


\n"; if ( ($dispo == 'CALLBK') or ($dispo == 'CBHOLD') ) - { + { ### find any vicidial_callback records for this lead - $stmt="select * from vicidial_callbacks where lead_id='" . mysql_real_escape_string($lead_id) . "' and status IN('ACTIVE','LIVE') order by callback_id desc LIMIT 1;"; + $stmt="select callback_id,lead_id,list_id,campaign_id,status,entry_time,callback_time,modify_date,user,recipient,comments,user_group from vicidial_callbacks where lead_id='" . mysql_real_escape_string($lead_id) . "' and status IN('ACTIVE','LIVE') order by callback_id desc LIMIT 1;"; if ($DB) {echo "|$stmt|\n";} $rslt=mysql_query($stmt, $link); $CB_to_print = mysql_num_rows($rslt); @@ -596,62 +605,56 @@ else { echo "
No Callback records found
\n"; } + } + } + else + { + echo "lead lookup FAILED for lead_id $lead_id       $NOW_TIME\n

\n"; +# echo "Close this window\n

\n"; } + echo "

\n"; + echo "
\n"; - - } - else - { - echo "lead lookup FAILED for lead_id $lead_id       $NOW_TIME\n

\n"; -# echo "Close this window\n

\n"; - } - - - -echo "

\n"; - -echo "
\n"; - -echo "CALLS TO THIS LEAD:\n"; -echo "\n"; -echo "\n"; + echo "CALLS TO THIS LEAD:\n"; + echo "
# DATE/TIME LENGTH STATUS TSR CAMPAIGN LIST LEAD HANGUP REASON PHONE
\n"; + echo "\n"; echo "$call_log\n"; -echo "
# DATE/TIME LENGTH STATUS TSR CAMPAIGN LIST LEAD HANGUP REASON PHONE
\n"; -echo "

\n"; + echo "\n"; + echo "

\n"; -echo "CLOSER RECORDS FOR THIS LEAD:\n"; -echo "\n"; -echo "\n"; + echo "CLOSER RECORDS FOR THIS LEAD:\n"; + echo "
# DATE/TIME LENGTH STATUS TSR CAMPAIGN LIST LEAD WAIT HANGUP REASON
\n"; + echo "\n"; echo "$closer_log\n"; -echo "
# DATE/TIME LENGTH STATUS TSR CAMPAIGN LIST LEAD WAIT HANGUP REASON
\n"; -echo "

\n"; + echo "
\n"; + echo "

\n"; -echo "AGENT LOG RECORDS FOR THIS LEAD:\n"; -echo "\n"; -echo "\n"; + echo "AGENT LOG RECORDS FOR THIS LEAD:\n"; + echo "
# DATE/TIME CAMPAIGN TSR PAUSE WAIT TALK DISPO STATUS GROUP SUB
\n"; + echo "\n"; - echo "$agent_log\n"; + echo "$agent_log\n"; -echo "
# DATE/TIME CAMPAIGN TSR PAUSE WAIT TALK DISPO STATUS GROUP SUB
\n"; -echo "

\n"; + echo "\n"; + echo "

\n"; -echo "RECORDINGS FOR THIS LEAD:\n"; -echo "\n"; -echo "\n"; + echo "RECORDINGS FOR THIS LEAD:\n"; + echo "
# LEADDATE/TIME SECONDS   RECIDFILENAMELOCATIONTSR
\n"; + echo "\n"; -$stmt="select * from recording_log where lead_id='" . mysql_real_escape_string($lead_id) . "' order by recording_id desc limit 500;"; -$rslt=mysql_query($stmt, $link); -$logs_to_print = mysql_num_rows($rslt); + $stmt="select recording_id,channel,server_ip,extension,start_time,start_epoch,end_time,end_epoch,length_in_sec,length_in_min,filename,location,lead_id,user,vicidial_id from recording_log where lead_id='" . mysql_real_escape_string($lead_id) . "' order by recording_id desc limit 500;"; + $rslt=mysql_query($stmt, $link); + $logs_to_print = mysql_num_rows($rslt); $u=0; while ($logs_to_print > $u) @@ -710,12 +713,8 @@ $logs_to_print = mysql_num_rows($rslt); } -echo "
# LEADDATE/TIME SECONDS   RECIDFILENAMELOCATIONTSR
\n"; - - - - -} + echo "\n"; + } $ENDtime = date("U"); @@ -739,10 +738,4 @@ echo "\n\n\n


\nscript runtime: $RUNtime seconds
"; exit; - ?> - - - - - diff --git a/www/vicidial/call_report_export.php b/www/vicidial/call_report_export.php index 3230f9be..f24bffc3 100644 --- a/www/vicidial/call_report_export.php +++ b/www/vicidial/call_report_export.php @@ -12,6 +12,7 @@ # 90310-2247 - First build # 90330-1343 - Added more debug info, bug fixes # 90508-0644 - Changed to PHP long tags +# 90721-1137 - Added rank and owner as vicidial_list fields # require("dbconnect.php"); @@ -214,7 +215,7 @@ if ($run_export > 0) if ($RUNcampaign > 0) { $export_campaign_rows=''; - $stmt = "SELECT vl.call_date,vl.phone_number,vl.status,vl.user,vu.full_name,vl.campaign_id,vi.vendor_lead_code,vi.source_id,vi.list_id,vi.gmt_offset_now,vi.phone_code,vi.phone_number,vi.title,vi.first_name,vi.middle_initial,vi.last_name,vi.address1,vi.address2,vi.address3,vi.city,vi.state,vi.province,vi.postal_code,vi.country_code,vi.gender,vi.date_of_birth,vi.alt_phone,vi.email,vi.security_phrase,vi.comments,vl.length_in_sec,vl.user_group,vl.alt_dial from vicidial_users vu,vicidial_log vl,vicidial_list vi where vl.call_date >= '$query_date 00:00:00' and vl.call_date <= '$end_date 23:59:59' and vu.user=vl.user and vi.lead_id=vl.lead_id $list_SQL $campaign_SQL $user_group_SQL $status_SQL order by vl.call_date limit 100000;"; + $stmt = "SELECT vl.call_date,vl.phone_number,vl.status,vl.user,vu.full_name,vl.campaign_id,vi.vendor_lead_code,vi.source_id,vi.list_id,vi.gmt_offset_now,vi.phone_code,vi.phone_number,vi.title,vi.first_name,vi.middle_initial,vi.last_name,vi.address1,vi.address2,vi.address3,vi.city,vi.state,vi.province,vi.postal_code,vi.country_code,vi.gender,vi.date_of_birth,vi.alt_phone,vi.email,vi.security_phrase,vi.comments,vl.length_in_sec,vl.user_group,vl.alt_dial,vi.rank,vi.owner from vicidial_users vu,vicidial_log vl,vicidial_list vi where vl.call_date >= '$query_date 00:00:00' and vl.call_date <= '$end_date 23:59:59' and vu.user=vl.user and vi.lead_id=vl.lead_id $list_SQL $campaign_SQL $user_group_SQL $status_SQL order by vl.call_date limit 100000;"; $rslt=mysql_query($stmt, $link); if ($DB) {echo "$stmt\n";} $outbound_to_print = mysql_num_rows($rslt); @@ -230,7 +231,7 @@ if ($run_export > 0) { $row=mysql_fetch_row($rslt); - $export_campaign_rows .= "$row[0]\t$row[1]\t$row[2]\t$row[3]\t$row[4]\t$row[5]\t$row[6]\t$row[7]\t$row[8]\t$row[9]\t$row[10]\t$row[11]\t$row[12]\t$row[13]\t$row[14]\t$row[15]\t$row[16]\t$row[17]\t$row[18]\t$row[19]\t$row[20]\t$row[21]\t$row[22]\t$row[23]\t$row[24]\t$row[25]\t$row[26]\t$row[27]\t$row[28]\t$row[29]\t$row[30]\t$row[31]\t$row[32]\r\n"; + $export_campaign_rows .= "$row[0]\t$row[1]\t$row[2]\t$row[3]\t$row[4]\t$row[5]\t$row[6]\t$row[7]\t$row[8]\t$row[9]\t$row[10]\t$row[11]\t$row[12]\t$row[13]\t$row[14]\t$row[15]\t$row[16]\t$row[17]\t$row[18]\t$row[19]\t$row[20]\t$row[21]\t$row[22]\t$row[23]\t$row[24]\t$row[25]\t$row[26]\t$row[27]\t$row[28]\t$row[29]\t$row[30]\t$row[31]\t$row[32]\t$row[33]\t$row[34]\r\n"; $i++; $outbound_calls++; } @@ -240,7 +241,7 @@ if ($run_export > 0) if ($RUNgroup > 0) { $export_group_rows=''; - $stmtA = "SELECT vl.call_date,vl.phone_number,vl.status,vl.user,vu.full_name,vl.campaign_id,vi.vendor_lead_code,vi.source_id,vi.list_id,vi.gmt_offset_now,vi.phone_code,vi.phone_number,vi.title,vi.first_name,vi.middle_initial,vi.last_name,vi.address1,vi.address2,vi.address3,vi.city,vi.state,vi.province,vi.postal_code,vi.country_code,vi.gender,vi.date_of_birth,vi.alt_phone,vi.email,vi.security_phrase,vi.comments,vl.length_in_sec,vl.user_group,vl.queue_seconds from vicidial_users vu,vicidial_closer_log vl,vicidial_list vi where vl.call_date >= '$query_date 00:00:00' and vl.call_date <= '$end_date 23:59:59' and vu.user=vl.user and vi.lead_id=vl.lead_id $list_SQL $group_SQL $user_group_SQL $status_SQL order by vl.call_date limit 100000;"; + $stmtA = "SELECT vl.call_date,vl.phone_number,vl.status,vl.user,vu.full_name,vl.campaign_id,vi.vendor_lead_code,vi.source_id,vi.list_id,vi.gmt_offset_now,vi.phone_code,vi.phone_number,vi.title,vi.first_name,vi.middle_initial,vi.last_name,vi.address1,vi.address2,vi.address3,vi.city,vi.state,vi.province,vi.postal_code,vi.country_code,vi.gender,vi.date_of_birth,vi.alt_phone,vi.email,vi.security_phrase,vi.comments,vl.length_in_sec,vl.user_group,vl.queue_seconds,vi.rank,vi.owner from vicidial_users vu,vicidial_closer_log vl,vicidial_list vi where vl.call_date >= '$query_date 00:00:00' and vl.call_date <= '$end_date 23:59:59' and vu.user=vl.user and vi.lead_id=vl.lead_id $list_SQL $group_SQL $user_group_SQL $status_SQL order by vl.call_date limit 100000;"; $rslt=mysql_query($stmtA, $link); if ($DB) {echo "$stmt\n";} $inbound_to_print = mysql_num_rows($rslt); @@ -256,7 +257,7 @@ if ($run_export > 0) { $row=mysql_fetch_row($rslt); - $export_group_rows .= "$row[0]\t$row[1]\t$row[2]\t$row[3]\t$row[4]\t$row[5]\t$row[6]\t$row[7]\t$row[8]\t$row[9]\t$row[10]\t$row[11]\t$row[12]\t$row[13]\t$row[14]\t$row[15]\t$row[16]\t$row[17]\t$row[18]\t$row[19]\t$row[20]\t$row[21]\t$row[22]\t$row[23]\t$row[24]\t$row[25]\t$row[26]\t$row[27]\t$row[28]\t$row[29]\t$row[30]\t$row[31]\t$row[32]\r\n"; + $export_group_rows .= "$row[0]\t$row[1]\t$row[2]\t$row[3]\t$row[4]\t$row[5]\t$row[6]\t$row[7]\t$row[8]\t$row[9]\t$row[10]\t$row[11]\t$row[12]\t$row[13]\t$row[14]\t$row[15]\t$row[16]\t$row[17]\t$row[18]\t$row[19]\t$row[20]\t$row[21]\t$row[22]\t$row[23]\t$row[24]\t$row[25]\t$row[26]\t$row[27]\t$row[28]\t$row[29]\t$row[30]\t$row[31]\t$row[32]\t$row[33]\t$row[34]\r\n"; $i++; } } diff --git a/www/vicidial/list_download.php b/www/vicidial/list_download.php index e6153a4b..440f143a 100644 --- a/www/vicidial/list_download.php +++ b/www/vicidial/list_download.php @@ -10,6 +10,7 @@ # # 90209-1310 - First build # 90508-0644 - Changed to PHP long tags +# 90721-1238 - Added rank and owner as vicidial_list fields # require("dbconnect.php"); @@ -112,7 +113,7 @@ header('Pragma: public'); ob_clean(); flush(); -$stmt="select * from vicidial_list where list_id='$list_id';"; +$stmt="select lead_id,entry_date,modify_date,status,user,vendor_lead_code,source_id,list_id,gmt_offset_now,called_since_last_reset,phone_code,phone_number,title,first_name,middle_initial,last_name,address1,address2,address3,city,state,province,postal_code,country_code,gender,date_of_birth,alt_phone,email,security_phrase,comments,called_count,last_local_call_time,rank,owner from vicidial_list where list_id='$list_id';"; $rslt=mysql_query($stmt, $link); if ($DB) {echo "$stmt\n";} $leads_to_print = mysql_num_rows($rslt); @@ -121,7 +122,7 @@ while ($i < $leads_to_print) { $row=mysql_fetch_row($rslt); - echo "$row[0]\t$row[1]\t$row[2]\t$row[3]\t$row[4]\t$row[5]\t$row[6]\t$row[7]\t$row[8]\t$row[9]\t$row[10]\t$row[11]\t$row[12]\t$row[13]\t$row[14]\t$row[15]\t$row[16]\t$row[17]\t$row[18]\t$row[19]\t$row[20]\t$row[21]\t$row[22]\t$row[23]\t$row[24]\t$row[25]\t$row[26]\t$row[27]\t$row[28]\t$row[29]\t$row[30]\t$row[31]\r\n"; + echo "$row[0]\t$row[1]\t$row[2]\t$row[3]\t$row[4]\t$row[5]\t$row[6]\t$row[7]\t$row[8]\t$row[9]\t$row[10]\t$row[11]\t$row[12]\t$row[13]\t$row[14]\t$row[15]\t$row[16]\t$row[17]\t$row[18]\t$row[19]\t$row[20]\t$row[21]\t$row[22]\t$row[23]\t$row[24]\t$row[25]\t$row[26]\t$row[27]\t$row[28]\t$row[29]\t$row[30]\t$row[31]\t$row[32]\t$row[33]\r\n"; $i++; } diff --git a/www/vicidial/listloader.pl b/www/vicidial/listloader.pl index b8f9e064..8b202aec 100644 --- a/www/vicidial/listloader.pl +++ b/www/vicidial/listloader.pl @@ -1,8 +1,8 @@ #!/usr/bin/perl # -# listloader.pl version 2.0.5 +# listloader.pl version 2.2.0 # -# Copyright (C) 2008 Matt Florell,Joe Johnson LICENSE: AGPLv2 +# Copyright (C) 2009 Matt Florell,Joe Johnson LICENSE: AGPLv2 # # # CHANGES @@ -19,6 +19,7 @@ # 70510-1518 - Added campaign and system duplicate check and phonecode override # 80428-0144 - UTF8 cleanup # 80713-0023 - added last_local_call_time field default of 2008-01-01 +# 90721-1425 - Added rank and owner as vicidial_list fields # ### begin parsing run-time options ### @@ -258,6 +259,11 @@ foreach $oWkS (@{$oBook->{Worksheet}}) { $oWkC = $oWkS->{Cells}[$iR][22]; if ($oWkC) {$comments=$oWkC->Value; } $comments=~s/^\s*(.*?)\s*$/$1/; + $oWkC = $oWkS->{Cells}[$iR][23]; + if ($oWkC) {$rank=$oWkC->Value; } + if (length($rank)<1) {$rank='0';} + $oWkC = $oWkS->{Cells}[$iR][24]; + if ($oWkC) {$owner=$oWkC->Value; } if (length($forcelistid) > 0) { @@ -565,14 +571,14 @@ foreach $oWkS (@{$oBook->{Worksheet}}) { if ($multi_insert_counter > 8) { ### insert good deal into pending_transactions table ### - $stmtZ = "INSERT INTO vicidial_list values$multistmt('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0,'2008-01-01 00:00:00');"; + $stmtZ = "INSERT INTO vicidial_list (lead_id,entry_date,modify_date,status,user,vendor_lead_code,source_id,list_id,gmt_offset_now,called_since_last_reset,phone_code,phone_number,title,first_name,middle_initial,last_name,address1,address2,address3,city,state,province,postal_code,country_code,gender,date_of_birth,alt_phone,email,security_phrase,comments,called_count,last_local_call_time,rank,owner) values$multistmt('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0,'2008-01-01 00:00:00','$rank','$owner');"; $affected_rows = $dbhA->do($stmtZ); print STMT_FILE $stmtZ."\r\n"; $multistmt=''; $multi_insert_counter=0; } else { - $multistmt .= "('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0,'2008-01-01 00:00:00'),"; + $multistmt .= "('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0,'2008-01-01 00:00:00','$rank','$owner'),"; $multi_insert_counter++; } @@ -591,7 +597,7 @@ foreach $oWkS (@{$oBook->{Worksheet}}) { } if ($multi_insert_counter > 0) { - $stmtZ = "INSERT INTO vicidial_list values ".substr($multistmt, 0, -1).";"; + $stmtZ = "INSERT INTO vicidial_list (lead_id,entry_date,modify_date,status,user,vendor_lead_code,source_id,list_id,gmt_offset_now,called_since_last_reset,phone_code,phone_number,title,first_name,middle_initial,last_name,address1,address2,address3,city,state,province,postal_code,country_code,gender,date_of_birth,alt_phone,email,security_phrase,comments,called_count,last_local_call_time,rank,owner) values ".substr($multistmt, 0, -1).";"; $affected_rows = $dbhA->do($stmtZ); print STMT_FILE $stmtZ."\r\n"; } diff --git a/www/vicidial/listloader_rowdisplay.pl b/www/vicidial/listloader_rowdisplay.pl index bbfc8170..9caaeab2 100644 --- a/www/vicidial/listloader_rowdisplay.pl +++ b/www/vicidial/listloader_rowdisplay.pl @@ -1,14 +1,15 @@ #!/usr/bin/perl # -# listloader_rowdisplay.pl version 2.0.5 +# listloader_rowdisplay.pl version 2.2.0 # -# Copyright (C) 2008 Matt Florell,Joe Johnson LICENSE: AGPLv2 +# Copyright (C) 2009 Matt Florell,Joe Johnson LICENSE: AGPLv2 # # # CHANGES # # 60811-1232 - Changed to DBI # 60811-1329 - changed to use /etc/astguiclient.conf for configs +# 90721-1340 - Added rank and owner as vicidial_list fields # ### begin parsing run-time options ### @@ -116,7 +117,7 @@ foreach $oWkS (@{$oBook->{Worksheet}}) { @xls_row=split(/\|/, $var_str); -$stmtA = "select vendor_lead_code, source_id, list_id, phone_code, phone_number, title, first_name, middle_initial, last_name, address1, address2, address3, city, state, province, postal_code, country_code, gender, date_of_birth, alt_phone, email, security_phrase, comments from vicidial_list limit 1;"; +$stmtA = "select vendor_lead_code, source_id, list_id, phone_code, phone_number, title, first_name, middle_initial, last_name, address1, address2, address3, city, state, province, postal_code, country_code, gender, date_of_birth, alt_phone, email, security_phrase, comments, rank, owner from vicidial_list limit 1;"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthArows=$sthA->rows; diff --git a/www/vicidial/listloader_super.pl b/www/vicidial/listloader_super.pl index 3af97f37..114eeb55 100644 --- a/www/vicidial/listloader_super.pl +++ b/www/vicidial/listloader_super.pl @@ -1,8 +1,8 @@ #!/usr/bin/perl # -# listloader_super.pl version 2.0.5 +# listloader_super.pl version 2.2.0 # -# Copyright (C) 2008 Matt Florell,Joe Johnson LICENSE: AGPLv2 +# Copyright (C) 2009 Matt Florell,Joe Johnson LICENSE: AGPLv2 # # # CHANGES @@ -18,6 +18,7 @@ # 70510-1518 - Added campaign and system duplicate check and phonecode override # 80428-0144 - UTF8 cleanup # 80713-0023 - added last_local_call_time field default of 2008-01-01 +# 90721-1341 - Added rank and owner as vicidial_list fields # ### begin parsing run-time options ### @@ -258,6 +259,11 @@ foreach $oWkS (@{$oBook->{Worksheet}}) { $oWkC = $oWkS->{Cells}[$iR][$xls_fields[22]]; if ($oWkC) {$comments=$oWkC->Value; } $comments=~s/^\s*(.*?)\s*$/$1/; + $oWkC = $oWkS->{Cells}[$iR][$xls_fields[23]]; + if ($oWkC) {$rank=$oWkC->Value; } + if (length($rank)<1) {$rank='0';} + $oWkC = $oWkS->{Cells}[$iR][$xls_fields[24]]; + if ($oWkC) {$owner=$oWkC->Value; } @@ -567,14 +573,14 @@ foreach $oWkS (@{$oBook->{Worksheet}}) { if ($multi_insert_counter > 8) { ### insert good deal into pending_transactions table ### - $stmtZ = "INSERT INTO vicidial_list values$multistmt('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0,'2008-01-01 00:00:00');"; + $stmtZ = "INSERT INTO vicidial_list (lead_id,entry_date,modify_date,status,user,vendor_lead_code,source_id,list_id,gmt_offset_now,called_since_last_reset,phone_code,phone_number,title,first_name,middle_initial,last_name,address1,address2,address3,city,state,province,postal_code,country_code,gender,date_of_birth,alt_phone,email,security_phrase,comments,called_count,last_local_call_time,rank,owner) values$multistmt('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0,'2008-01-01 00:00:00','$rank','$owner');"; $affected_rows = $dbhA->do($stmtZ); print STMT_FILE $stmtZ."\r\n"; $multistmt=''; $multi_insert_counter=0; } else { - $multistmt .= "('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0,'2008-01-01 00:00:00'),"; + $multistmt .= "('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0,'2008-01-01 00:00:00','$rank','$owner'),"; $multi_insert_counter++; } @@ -593,7 +599,7 @@ foreach $oWkS (@{$oBook->{Worksheet}}) { } if ($multi_insert_counter > 0) { - $stmtZ = "INSERT INTO vicidial_list values ".substr($multistmt, 0, -1).";"; + $stmtZ = "INSERT INTO vicidial_list (lead_id,entry_date,modify_date,status,user,vendor_lead_code,source_id,list_id,gmt_offset_now,called_since_last_reset,phone_code,phone_number,title,first_name,middle_initial,last_name,address1,address2,address3,city,state,province,postal_code,country_code,gender,date_of_birth,alt_phone,email,security_phrase,comments,called_count,last_local_call_time,rank,owner) values ".substr($multistmt, 0, -1).";"; $affected_rows = $dbhA->do($stmtZ); print STMT_FILE $stmtZ."\r\n"; } diff --git a/www/vicidial/new_listloader_superL.php b/www/vicidial/new_listloader_superL.php index be3e9a51..2723e682 100644 --- a/www/vicidial/new_listloader_superL.php +++ b/www/vicidial/new_listloader_superL.php @@ -27,11 +27,12 @@ # 90310-2128 - Added admin header # 90508-0644 - Changed to PHP long tags # 90522-0506 - Security fix +# 90721-1339 - Added rank and owner as vicidial_list fields # # make sure vicidial_list exists and that your file follows the formatting correctly. This page does not dedupe or do any other lead filtering actions yet at this time. -$version = '2.2.0-31'; -$build = '90522-0506'; +$version = '2.2.0-32'; +$build = '90721-1339'; require("dbconnect.php"); @@ -47,44 +48,44 @@ $PHP_SELF=$_SERVER['PHP_SELF']; $leadfile=$_FILES["leadfile"]; $LF_orig = $_FILES['leadfile']['name']; $LF_path = $_FILES['leadfile']['tmp_name']; -if (isset($_GET["submit_file"])) {$submit_file=$_GET["submit_file"];} - elseif (isset($_POST["submit_file"])) {$submit_file=$_POST["submit_file"];} +if (isset($_GET["submit_file"])) {$submit_file=$_GET["submit_file"];} + elseif (isset($_POST["submit_file"])) {$submit_file=$_POST["submit_file"];} if (isset($_GET["submit"])) {$submit=$_GET["submit"];} - elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} - elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} -if (isset($_GET["leadfile_name"])) {$leadfile_name=$_GET["leadfile_name"];} - elseif (isset($_POST["leadfile_name"])) {$leadfile_name=$_POST["leadfile_name"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} +if (isset($_GET["leadfile_name"])) {$leadfile_name=$_GET["leadfile_name"];} + elseif (isset($_POST["leadfile_name"])) {$leadfile_name=$_POST["leadfile_name"];} if (isset($_FILES["leadfile"])) {$leadfile_name=$_FILES["leadfile"]['name'];} if (isset($_GET["file_layout"])) {$file_layout=$_GET["file_layout"];} elseif (isset($_POST["file_layout"])) {$file_layout=$_POST["file_layout"];} if (isset($_GET["OK_to_process"])) {$OK_to_process=$_GET["OK_to_process"];} elseif (isset($_POST["OK_to_process"])) {$OK_to_process=$_POST["OK_to_process"];} if (isset($_GET["vendor_lead_code_field"])) {$vendor_lead_code_field=$_GET["vendor_lead_code_field"];} - elseif (isset($_POST["vendor_lead_code_field"])) {$vendor_lead_code_field=$_POST["vendor_lead_code_field"];} -if (isset($_GET["source_id_field"])) {$source_id_field=$_GET["source_id_field"];} - elseif (isset($_POST["source_id_field"])) {$source_id_field=$_POST["source_id_field"];} + elseif (isset($_POST["vendor_lead_code_field"])) {$vendor_lead_code_field=$_POST["vendor_lead_code_field"];} +if (isset($_GET["source_id_field"])) {$source_id_field=$_GET["source_id_field"];} + elseif (isset($_POST["source_id_field"])) {$source_id_field=$_POST["source_id_field"];} if (isset($_GET["list_id_field"])) {$list_id_field=$_GET["list_id_field"];} elseif (isset($_POST["list_id_field"])) {$list_id_field=$_POST["list_id_field"];} -if (isset($_GET["phone_code_field"])) {$phone_code_field=$_GET["phone_code_field"];} - elseif (isset($_POST["phone_code_field"])) {$phone_code_field=$_POST["phone_code_field"];} +if (isset($_GET["phone_code_field"])) {$phone_code_field=$_GET["phone_code_field"];} + elseif (isset($_POST["phone_code_field"])) {$phone_code_field=$_POST["phone_code_field"];} if (isset($_GET["phone_number_field"])) {$phone_number_field=$_GET["phone_number_field"];} - elseif (isset($_POST["phone_number_field"])) {$phone_number_field=$_POST["phone_number_field"];} + elseif (isset($_POST["phone_number_field"])) {$phone_number_field=$_POST["phone_number_field"];} if (isset($_GET["title_field"])) {$title_field=$_GET["title_field"];} elseif (isset($_POST["title_field"])) {$title_field=$_POST["title_field"];} -if (isset($_GET["first_name_field"])) {$first_name_field=$_GET["first_name_field"];} - elseif (isset($_POST["first_name_field"])) {$first_name_field=$_POST["first_name_field"];} -if (isset($_GET["middle_initial_field"])) {$middle_initial_field=$_GET["middle_initial_field"];} - elseif (isset($_POST["middle_initial_field"])) {$middle_initial_field=$_POST["middle_initial_field"];} -if (isset($_GET["last_name_field"])) {$last_name_field=$_GET["last_name_field"];} - elseif (isset($_POST["last_name_field"])) {$last_name_field=$_POST["last_name_field"];} +if (isset($_GET["first_name_field"])) {$first_name_field=$_GET["first_name_field"];} + elseif (isset($_POST["first_name_field"])) {$first_name_field=$_POST["first_name_field"];} +if (isset($_GET["middle_initial_field"])) {$middle_initial_field=$_GET["middle_initial_field"];} + elseif (isset($_POST["middle_initial_field"])) {$middle_initial_field=$_POST["middle_initial_field"];} +if (isset($_GET["last_name_field"])) {$last_name_field=$_GET["last_name_field"];} + elseif (isset($_POST["last_name_field"])) {$last_name_field=$_POST["last_name_field"];} if (isset($_GET["address1_field"])) {$address1_field=$_GET["address1_field"];} - elseif (isset($_POST["address1_field"])) {$address1_field=$_POST["address1_field"];} + elseif (isset($_POST["address1_field"])) {$address1_field=$_POST["address1_field"];} if (isset($_GET["address2_field"])) {$address2_field=$_GET["address2_field"];} - elseif (isset($_POST["address2_field"])) {$address2_field=$_POST["address2_field"];} + elseif (isset($_POST["address2_field"])) {$address2_field=$_POST["address2_field"];} if (isset($_GET["address3_field"])) {$address3_field=$_GET["address3_field"];} - elseif (isset($_POST["address3_field"])) {$address3_field=$_POST["address3_field"];} -if (isset($_GET["city_field"])) {$city_field=$_GET["city_field"];} + elseif (isset($_POST["address3_field"])) {$address3_field=$_POST["address3_field"];} +if (isset($_GET["city_field"])) {$city_field=$_GET["city_field"];} elseif (isset($_POST["city_field"])) {$city_field=$_POST["city_field"];} if (isset($_GET["state_field"])) {$state_field=$_GET["state_field"];} elseif (isset($_POST["state_field"])) {$state_field=$_POST["state_field"];} @@ -93,21 +94,25 @@ if (isset($_GET["province_field"])) {$province_field=$_GET["province_field"]; if (isset($_GET["postal_code_field"])) {$postal_code_field=$_GET["postal_code_field"];} elseif (isset($_POST["postal_code_field"])) {$postal_code_field=$_POST["postal_code_field"];} if (isset($_GET["country_code_field"])) {$country_code_field=$_GET["country_code_field"];} - elseif (isset($_POST["country_code_field"])) {$country_code_field=$_POST["country_code_field"];} + elseif (isset($_POST["country_code_field"])) {$country_code_field=$_POST["country_code_field"];} if (isset($_GET["gender_field"])) {$gender_field=$_GET["gender_field"];} elseif (isset($_POST["gender_field"])) {$gender_field=$_POST["gender_field"];} -if (isset($_GET["date_of_birth_field"])) {$date_of_birth_field=$_GET["date_of_birth_field"];} - elseif (isset($_POST["date_of_birth_field"])) {$date_of_birth_field=$_POST["date_of_birth_field"];} -if (isset($_GET["alt_phone_field"])) {$alt_phone_field=$_GET["alt_phone_field"];} - elseif (isset($_POST["alt_phone_field"])) {$alt_phone_field=$_POST["alt_phone_field"];} +if (isset($_GET["date_of_birth_field"])) {$date_of_birth_field=$_GET["date_of_birth_field"];} + elseif (isset($_POST["date_of_birth_field"])) {$date_of_birth_field=$_POST["date_of_birth_field"];} +if (isset($_GET["alt_phone_field"])) {$alt_phone_field=$_GET["alt_phone_field"];} + elseif (isset($_POST["alt_phone_field"])) {$alt_phone_field=$_POST["alt_phone_field"];} if (isset($_GET["email_field"])) {$email_field=$_GET["email_field"];} elseif (isset($_POST["email_field"])) {$email_field=$_POST["email_field"];} -if (isset($_GET["security_phrase_field"])) {$security_phrase_field=$_GET["security_phrase_field"];} - elseif (isset($_POST["security_phrase_field"])) {$security_phrase_field=$_POST["security_phrase_field"];} +if (isset($_GET["security_phrase_field"])) {$security_phrase_field=$_GET["security_phrase_field"];} + elseif (isset($_POST["security_phrase_field"])) {$security_phrase_field=$_POST["security_phrase_field"];} if (isset($_GET["comments_field"])) {$comments_field=$_GET["comments_field"];} - elseif (isset($_POST["comments_field"])) {$comments_field=$_POST["comments_field"];} -if (isset($_GET["list_id_override"])) {$list_id_override=$_GET["list_id_override"];} - elseif (isset($_POST["list_id_override"])) {$list_id_override=$_POST["list_id_override"];} + elseif (isset($_POST["comments_field"])) {$comments_field=$_POST["comments_field"];} +if (isset($_GET["rank_field"])) {$rank_field=$_GET["rank_field"];} + elseif (isset($_POST["rank_field"])) {$rank_field=$_POST["rank_field"];} +if (isset($_GET["owner_field"])) {$owner_field=$_GET["owner_field"];} + elseif (isset($_POST["owner_field"])) {$owner_field=$_POST["owner_field"];} +if (isset($_GET["list_id_override"])) {$list_id_override=$_GET["list_id_override"];} + elseif (isset($_POST["list_id_override"])) {$list_id_override=$_POST["list_id_override"];} $list_id_override = (preg_replace("/\D/","",$list_id_override)); if (isset($_GET["lead_file"])) {$lead_file=$_GET["lead_file"];} elseif (isset($_POST["lead_file"])) {$lead_file=$_POST["lead_file"];} @@ -453,6 +458,8 @@ echo "
"; $email = $row[$email_field]; $security_phrase = $row[$security_phrase_field]; $comments = trim($row[$comments_field]); + $rank = $row[$rank_field]; + $owner = $row[$owner_field]; if (strlen($list_id_override)>0) { @@ -560,7 +567,7 @@ echo "
"; if ($multi_insert_counter > 8) { ### insert good deal into pending_transactions table ### - $stmtZ = "INSERT INTO vicidial_list values$multistmt('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0,'2008-01-01 00:00:00');"; + $stmtZ = "INSERT INTO vicidial_list (lead_id,entry_date,modify_date,status,user,vendor_lead_code,source_id,list_id,gmt_offset_now,called_since_last_reset,phone_code,phone_number,title,first_name,middle_initial,last_name,address1,address2,address3,city,state,province,postal_code,country_code,gender,date_of_birth,alt_phone,email,security_phrase,comments,called_count,last_local_call_time,rank,owner) values$multistmt('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0,'2008-01-01 00:00:00','$rank','$owner');"; $rslt=mysql_query($stmtZ, $link); if ($WeBRooTWritablE > 0) {fwrite($stmt_file, $stmtZ."\r\n");} @@ -568,7 +575,7 @@ echo "
"; $multi_insert_counter=0; } else { - $multistmt .= "('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0,'2008-01-01 00:00:00'),"; + $multistmt .= "('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0,'2008-01-01 00:00:00','$rank','$owner'),"; $multi_insert_counter++; } @@ -586,7 +593,7 @@ echo "
"; } } if ($multi_insert_counter!=0) { - $stmtZ = "INSERT INTO vicidial_list values".substr($multistmt, 0, -1).";"; + $stmtZ = "INSERT INTO vicidial_list (lead_id,entry_date,modify_date,status,user,vendor_lead_code,source_id,list_id,gmt_offset_now,called_since_last_reset,phone_code,phone_number,title,first_name,middle_initial,last_name,address1,address2,address3,city,state,province,postal_code,country_code,gender,date_of_birth,alt_phone,email,security_phrase,comments,called_count,last_local_call_time,rank,owner) values".substr($multistmt, 0, -1).";"; mysql_query($stmtZ, $link); if ($WeBRooTWritablE > 0) {fwrite($stmt_file, $stmtZ."\r\n");} @@ -610,13 +617,13 @@ echo "
"; { print "

PHONE CODE OVERRIDE FOR THIS FILE: $phone_code_override

\n"; } - # print "|$WeBServeRRooT/vicidial/listloader_super.pl $vendor_lead_code_field,$source_id_field,$list_id_field,$phone_code_field,$phone_number_field,$title_field,$first_name_field,$middle_initial_field,$last_name_field,$address1_field,$address2_field,$address3_field,$city_field,$state_field,$province_field,$postal_code_field,$country_code_field,$gender_field,$date_of_birth_field,$alt_phone_field,$email_field,$security_phrase_field,$comments_field, --forcelistid=$list_id_override --lead_file=$lead_file|"; + # print "|$WeBServeRRooT/vicidial/listloader_super.pl $vendor_lead_code_field,$source_id_field,$list_id_field,$phone_code_field,$phone_number_field,$title_field,$first_name_field,$middle_initial_field,$last_name_field,$address1_field,$address2_field,$address3_field,$city_field,$state_field,$province_field,$postal_code_field,$country_code_field,$gender_field,$date_of_birth_field,$alt_phone_field,$email_field,$security_phrase_field,$comments_field,$rank_field,$owner_field, --forcelistid=$list_id_override --lead_file=$lead_file|"; $dupcheckCLI=''; $postalgmtCLI=''; if (eregi("DUPLIST",$dupcheck)) {$dupcheckCLI='--duplicate-check';} if (eregi("DUPCAMP",$dupcheck)) {$dupcheckCLI='--duplicate-campaign-check';} if (eregi("DUPSYS",$dupcheck)) {$dupcheckCLI='--duplicate-system-check';} if (eregi("POSTAL",$postalgmt)) {$postalgmtCLI='--postal-code-gmt';} - passthru("$WeBServeRRooT/vicidial/listloader_super.pl $vendor_lead_code_field,$source_id_field,$list_id_field,$phone_code_field,$phone_number_field,$title_field,$first_name_field,$middle_initial_field,$last_name_field,$address1_field,$address2_field,$address3_field,$city_field,$state_field,$province_field,$postal_code_field,$country_code_field,$gender_field,$date_of_birth_field,$alt_phone_field,$email_field,$security_phrase_field,$comments_field, --forcelistid=$list_id_override --forcephonecode=$phone_code_override --lead-file=$lead_file $postalgmtCLI $dupcheckCLI"); + passthru("$WeBServeRRooT/vicidial/listloader_super.pl $vendor_lead_code_field,$source_id_field,$list_id_field,$phone_code_field,$phone_number_field,$title_field,$first_name_field,$middle_initial_field,$last_name_field,$address1_field,$address2_field,$address3_field,$city_field,$state_field,$province_field,$postal_code_field,$country_code_field,$gender_field,$date_of_birth_field,$alt_phone_field,$email_field,$security_phrase_field,$comments_field,$rank_field,$owner_field, --forcelistid=$list_id_override --forcephonecode=$phone_code_override --lead-file=$lead_file $postalgmtCLI $dupcheckCLI"); } else { # copy($leadfile, "./vicidial_temp_file.csv"); $file=fopen("$lead_file", "r"); @@ -669,6 +676,10 @@ echo "
"; $email = $row[$email_field]; $security_phrase = $row[$security_phrase_field]; $comments = trim($row[$comments_field]); + $rank = $row[$rank_field]; + $owner = $row[$owner_field]; + + if (strlen($rank)<1) {$rank='0';} if (strlen($list_id_override)>0) { @@ -775,7 +786,7 @@ echo "
"; if ($multi_insert_counter > 8) { ### insert good deal into pending_transactions table ### - $stmtZ = "INSERT INTO vicidial_list values$multistmt('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0,'2008-01-01 00:00:00');"; + $stmtZ = "INSERT INTO vicidial_list (lead_id,entry_date,modify_date,status,user,vendor_lead_code,source_id,list_id,gmt_offset_now,called_since_last_reset,phone_code,phone_number,title,first_name,middle_initial,last_name,address1,address2,address3,city,state,province,postal_code,country_code,gender,date_of_birth,alt_phone,email,security_phrase,comments,called_count,last_local_call_time,rank,owner) values$multistmt('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0,'2008-01-01 00:00:00','$rank','$owner');"; $rslt=mysql_query($stmtZ, $link); if ($WeBRooTWritablE > 0) {fwrite($stmt_file, $stmtZ."\r\n");} @@ -783,7 +794,7 @@ echo "
"; $multi_insert_counter=0; } else { - $multistmt .= "('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0,'2008-01-01 00:00:00'),"; + $multistmt .= "('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0,'2008-01-01 00:00:00','$rank','$owner'),"; $multi_insert_counter++; } @@ -800,7 +811,7 @@ echo "\r\n"; print " \r\n"; - $rslt=mysql_query("select vendor_lead_code, source_id, list_id, phone_code, phone_number, title, first_name, middle_initial, last_name, address1, address2, address3, city, state, province, postal_code, country_code, gender, date_of_birth, alt_phone, email, security_phrase, comments from vicidial_list limit 1", $link); + $rslt=mysql_query("select vendor_lead_code, source_id, list_id, phone_code, phone_number, title, first_name, middle_initial, last_name, address1, address2, address3, city, state, province, postal_code, country_code, gender, date_of_birth, alt_phone, email, security_phrase, comments, rank, owner from vicidial_list limit 1", $link); if (!eregi(".csv", $leadfile_name) && !eregi(".xls", $leadfile_name)) diff --git a/www/vicidial/non_agent_api.php b/www/vicidial/non_agent_api.php index d020596d..da8d1ad4 100644 --- a/www/vicidial/non_agent_api.php +++ b/www/vicidial/non_agent_api.php @@ -24,10 +24,11 @@ # 90514-0602 - Added sounds_list function # 90522-0506 - Security fix # 90530-0946 - Added QueueMetrics blind monitoring option +# 90721-1428 - Added rank and owner as vicidial_list fields # -$version = '2.2.0-10'; -$build = '90530-0946'; +$version = '2.2.0-11'; +$build = '90721-1428'; require("dbconnect.php"); @@ -114,6 +115,10 @@ if (isset($_GET["stage"])) {$stage=$_GET["stage"];} elseif (isset($_POST["stage"])) {$stage=$_POST["stage"];} if (isset($_GET["DB"])) {$DB=$_GET["DB"];} elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["rank"])) {$rank=$_GET["rank"];} + elseif (isset($_POST["rank"])) {$rank=$_POST["rank"];} +if (isset($_GET["owner"])) {$owner=$_GET["owner"];} + elseif (isset($_POST["owner"])) {$owner=$_POST["owner"];} header ("Content-type: text/html; charset=utf-8"); header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 @@ -193,6 +198,8 @@ if ($non_latin < 1) $session_id = ereg_replace("[^0-9]","",$session_id); $server_ip = ereg_replace("[^\.0-9]","",$server_ip); $stage = ereg_replace("[^a-zA-Z]","",$stage); + $rank = ereg_replace("[^0-9]","",$rank); + $owner = ereg_replace("[^-_0-9a-zA-Z]","",$owner); } else { @@ -206,6 +213,7 @@ if (strlen($phone_code)<1) {$phone_code='1';} $USarea = substr($phone_number, 0, 3); if (strlen($hopper_priority)<1) {$hopper_priority=0;} if (strlen($gender)<1) {$gender='U';} +if (strlen($rank)<1) {$rank='0';} $StarTtime = date("U"); $NOW_DATE = date("Y-m-d"); @@ -663,7 +671,7 @@ if ($function == 'add_lead') ### 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='NEW',user='$user',vendor_lead_code='$vendor_lead_code',source_id='$source_id',gmt_offset_now='$gmt_offset',title='$title',first_name='$first_name',middle_initial='$middle_initial',last_name='$last_name',address1='$address1',address2='$address2',address3='$address3',city='$city',state='$state',province='$province',postal_code='$postal_code',country_code='$country_code',gender='$gender',date_of_birth='$date_of_birth',alt_phone='$alt_phone',email='$email',security_phrase='$security_phrase',comments='$comments',called_since_last_reset='N',entry_date='$ENTRYdate',last_local_call_time='$NOW_TIME';"; + $stmt = "INSERT INTO vicidial_list SET phone_code='$phone_code',phone_number='$phone_number',list_id='$list_id',status='NEW',user='$user',vendor_lead_code='$vendor_lead_code',source_id='$source_id',gmt_offset_now='$gmt_offset',title='$title',first_name='$first_name',middle_initial='$middle_initial',last_name='$last_name',address1='$address1',address2='$address2',address3='$address3',city='$city',state='$state',province='$province',postal_code='$postal_code',country_code='$country_code',gender='$gender',date_of_birth='$date_of_birth',alt_phone='$alt_phone',email='$email',security_phrase='$security_phrase',comments='$comments',called_since_last_reset='N',entry_date='$ENTRYdate',last_local_call_time='$NOW_TIME',rank='$rank',owner='$owner';"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $link); $affected_rows = mysql_affected_rows($link);
"; } } if ($multi_insert_counter!=0) { - $stmtZ = "INSERT INTO vicidial_list values".substr($multistmt, 0, -1).";"; + $stmtZ = "INSERT INTO vicidial_list (lead_id,entry_date,modify_date,status,user,vendor_lead_code,source_id,list_id,gmt_offset_now,called_since_last_reset,phone_code,phone_number,title,first_name,middle_initial,last_name,address1,address2,address3,city,state,province,postal_code,country_code,gender,date_of_birth,alt_phone,email,security_phrase,comments,called_count,last_local_call_time,rank,owner) values".substr($multistmt, 0, -1).";"; mysql_query($stmtZ, $link); if ($WeBRooTWritablE > 0) {fwrite($stmt_file, $stmtZ."\r\n");} @@ -899,6 +910,8 @@ if ($leadfile) { $email = $row[20]; $security_phrase = $row[21]; $comments = trim($row[22]); + $rank = $row[23]; + $owner = $row[24]; if (strlen($list_id_override)>0) { @@ -1005,7 +1018,7 @@ if ($leadfile) { if ($multi_insert_counter > 8) { ### insert good deal into pending_transactions table ### - $stmtZ = "INSERT INTO vicidial_list values$multistmt('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0,'2008-01-01 00:00:00');"; + $stmtZ = "INSERT INTO vicidial_list (lead_id,entry_date,modify_date,status,user,vendor_lead_code,source_id,list_id,gmt_offset_now,called_since_last_reset,phone_code,phone_number,title,first_name,middle_initial,last_name,address1,address2,address3,city,state,province,postal_code,country_code,gender,date_of_birth,alt_phone,email,security_phrase,comments,called_count,last_local_call_time,rank,owner) values$multistmt('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0,'2008-01-01 00:00:00','$rank','$owner');"; $rslt=mysql_query($stmtZ, $link); if ($WeBRooTWritablE > 0) {fwrite($stmt_file, $stmtZ."\r\n");} @@ -1013,7 +1026,7 @@ if ($leadfile) { $multi_insert_counter=0; } else { - $multistmt .= "('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0,'2008-01-01 00:00:00'),"; + $multistmt .= "('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0,'2008-01-01 00:00:00','$rank','$owner'),"; $multi_insert_counter++; } @@ -1031,7 +1044,7 @@ if ($leadfile) { } } if ($multi_insert_counter!=0) { - $stmtZ = "INSERT INTO vicidial_list values".substr($multistmt, 0, -1).";"; + $stmtZ = "INSERT INTO vicidial_list (lead_id,entry_date,modify_date,status,user,vendor_lead_code,source_id,list_id,gmt_offset_now,called_since_last_reset,phone_code,phone_number,title,first_name,middle_initial,last_name,address1,address2,address3,city,state,province,postal_code,country_code,gender,date_of_birth,alt_phone,email,security_phrase,comments,called_count,last_local_call_time,rank,owner) values".substr($multistmt, 0, -1).";"; mysql_query($stmtZ, $link); if ($WeBRooTWritablE > 0) {fwrite($stmt_file, $stmtZ."\r\n");} @@ -1125,6 +1138,8 @@ if ($leadfile) { $email = $row[20]; $security_phrase = $row[21]; $comments = trim($row[22]); + $rank = $row[23]; + $owner = $row[24]; if (strlen($list_id_override)>0) { @@ -1231,7 +1246,7 @@ if ($leadfile) { if ($multi_insert_counter > 8) { ### insert good deal into pending_transactions table ### - $stmtZ = "INSERT INTO vicidial_list values$multistmt('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0,'2008-01-01 00:00:00');"; + $stmtZ = "INSERT INTO vicidial_list (lead_id,entry_date,modify_date,status,user,vendor_lead_code,source_id,list_id,gmt_offset_now,called_since_last_reset,phone_code,phone_number,title,first_name,middle_initial,last_name,address1,address2,address3,city,state,province,postal_code,country_code,gender,date_of_birth,alt_phone,email,security_phrase,comments,called_count,last_local_call_time,rank,owner) values$multistmt('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0,'2008-01-01 00:00:00','$rank','$owner');"; $rslt=mysql_query($stmtZ, $link); if ($WeBRooTWritablE > 0) {fwrite($stmt_file, $stmtZ."\r\n");} @@ -1239,7 +1254,7 @@ if ($leadfile) { $multi_insert_counter=0; } else { - $multistmt .= "('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0,'2008-01-01 00:00:00'),"; + $multistmt .= "('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0,'2008-01-01 00:00:00','$rank','$owner'),"; $multi_insert_counter++; } @@ -1256,7 +1271,7 @@ if ($leadfile) { } } if ($multi_insert_counter!=0) { - $stmtZ = "INSERT INTO vicidial_list values".substr($multistmt, 0, -1).";"; + $stmtZ = "INSERT INTO vicidial_list (lead_id,entry_date,modify_date,status,user,vendor_lead_code,source_id,list_id,gmt_offset_now,called_since_last_reset,phone_code,phone_number,title,first_name,middle_initial,last_name,address1,address2,address3,city,state,province,postal_code,country_code,gender,date_of_birth,alt_phone,email,security_phrase,comments,called_count,last_local_call_time,rank,owner) values".substr($multistmt, 0, -1).";"; mysql_query($stmtZ, $link); if ($WeBRooTWritablE > 0) {fwrite($stmt_file, $stmtZ."\r\n");} @@ -1276,7 +1291,7 @@ if ($leadfile) { print " File data