From a7cef459d632b099f07c25b10bd673da341c5f2e Mon Sep 17 00:00:00 2001 From: mattf Date: Sun, 13 Jul 2008 15:45:22 +0000 Subject: [PATCH] added last_local_call_time field to vicidial_list table. This change affected many scripts from the hopper loaders to the lead loaders to the vdc_db_query.php agent-side script. A script was created to populate this field from the logs: VICIDIAL_last_local_call_time_UPDATE.pl git-svn-id: svn://192.168.202.10@921 3d104415-ff17-0410-8863-d5cf3c621b8a --- UPGRADE | 5 + bin/AST_VDauto_dial.pl | 17 +- bin/AST_VDauto_dial_FILL.pl | 17 +- bin/AST_VDhopper.pl | 270 +++++++++++++----- bin/AST_VDhopper_MIXtest.pl | 270 +++++++++++++----- bin/VICIDIAL_IN_new_leads_file.pl | 5 +- bin/VICIDIAL_last_local_call_time_UPDATE.pl | 176 ++++++++++++ extras/MySQL_AST_CREATE_tables.sql | 8 +- extras/upgrade_2.0.5.sql | 5 + .../TO_BE_TRANSLATED_2.0.5.txt | 1 + www/agc/vdc_db_query.php | 23 +- www/vicidial/admin.php | 8 +- www/vicidial/listloader.pl | 5 +- www/vicidial/listloader_super.pl | 5 +- www/vicidial/new_listloader_superL.php | 22 +- 15 files changed, 663 insertions(+), 174 deletions(-) create mode 100644 bin/VICIDIAL_last_local_call_time_UPDATE.pl diff --git a/UPGRADE b/UPGRADE index 599f2ea0..25816cd5 100644 --- a/UPGRADE +++ b/UPGRADE @@ -135,6 +135,11 @@ NOTE: Upgrading from 1.1.12-3 to 2.0.1 is at the bottom 30. Added some basic agent interface API functions and an agc/api.php script +31. A field has been added to vicidial_list(last_local_call_time) to sort by + the last time a lead was called as well as for lead recycling changes. + + + ########## UPGRADING FROM 2.0.3 TO 2.0.4 ########## diff --git a/bin/AST_VDauto_dial.pl b/bin/AST_VDauto_dial.pl index 6ddf48fa..9cbffe42 100644 --- a/bin/AST_VDauto_dial.pl +++ b/bin/AST_VDauto_dial.pl @@ -67,6 +67,7 @@ # 71030-2054 - Added hopper priority sorting # 80227-0406 - added queue_priority # 80525-1040 - Added IVR vac status compatibility for inbound calls +# 80713-0624 - Added vicidial_list_last_local_call_time field # @@ -780,6 +781,18 @@ while($one_day_interval > 0) } } else {$CSLR = 'Y';} + + $LLCT_DATE_offset = ($LOCAL_GMT_OFF - $gmt_offset_now); + $LLCT_DATE_offset_epoch = ( $secX - ($LLCT_DATE_offset * 3600) ); + ($Lsec,$Lmin,$Lhour,$Lmday,$Lmon,$Lyear,$Lwday,$Lyday,$Lisdst) = localtime($LLCT_DATE_offset_epoch); + $Lyear = ($Lyear + 1900); + $Lmon++; + if ($Lmon < 10) {$Lmon = "0$Lmon";} + if ($Lmday < 10) {$Lmday = "0$Lmday";} + if ($Lhour < 10) {$Lhour = "0$Lhour";} + if ($Lmin < 10) {$Lmin = "0$Lmin";} + if ($Lsec < 10) {$Lsec = "0$Lsec";} + $LLCT_DATE = "$Lyear-$Lmon-$Lmday $Lhour:$Lmin:$Lsec"; if ( ($alt_dial =~ /ALT|ADDR3/) && ($DBIPautoaltdial[$user_CIPct] =~ /ALT|ADDR/) ) { @@ -793,11 +806,11 @@ while($one_day_interval > 0) $address3 =~ s/\D//gi; $phone_number = $address3; } - $stmtA = "UPDATE vicidial_list set called_since_last_reset='$CSLR',user='VDAD' where lead_id='$lead_id'"; + $stmtA = "UPDATE vicidial_list set called_since_last_reset='$CSLR',user='VDAD',last_local_call_time='$LLCT_DATE' where lead_id='$lead_id'"; } else { - $stmtA = "UPDATE vicidial_list set called_since_last_reset='$CSLR', called_count='$called_count',user='VDAD' where lead_id='$lead_id'"; + $stmtA = "UPDATE vicidial_list set called_since_last_reset='$CSLR', called_count='$called_count',user='VDAD',last_local_call_time='$LLCT_DATE' where lead_id='$lead_id'"; } $affected_rows = $dbhA->do($stmtA); diff --git a/bin/AST_VDauto_dial_FILL.pl b/bin/AST_VDauto_dial_FILL.pl index 2bcb71b8..8113c66f 100644 --- a/bin/AST_VDauto_dial_FILL.pl +++ b/bin/AST_VDauto_dial_FILL.pl @@ -21,6 +21,7 @@ # 71030-2054 - Added hopper priority sorting # 71111-2349 - fixed overdialing bug # 80227-0406 - fixed auto-alt-dial and added queue_priority +# 80713-0624 - Added vicidial_list_last_local_call_time field # @@ -631,6 +632,18 @@ while($one_day_interval > 0) } else {$CSLR = 'Y';} + $LLCT_DATE_offset = ($LOCAL_GMT_OFF - $gmt_offset_now); + $LLCT_DATE_offset_epoch = ( $secX - ($LLCT_DATE_offset * 3600) ); + ($Lsec,$Lmin,$Lhour,$Lmday,$Lmon,$Lyear,$Lwday,$Lyday,$Lisdst) = localtime($LLCT_DATE_offset_epoch); + $Lyear = ($Lyear + 1900); + $Lmon++; + if ($Lmon < 10) {$Lmon = "0$Lmon";} + if ($Lmday < 10) {$Lmday = "0$Lmday";} + if ($Lhour < 10) {$Lhour = "0$Lhour";} + if ($Lmin < 10) {$Lmin = "0$Lmin";} + if ($Lsec < 10) {$Lsec = "0$Lsec";} + $LLCT_DATE = "$Lyear-$Lmon-$Lmday $Lhour:$Lmin:$Lsec"; + if ( ($alt_dial =~ /ALT|ADDR3/) && ($DBIPautoaltdial[$camp_CIPct] =~ /ALT|ADDR/) ) { if ( ($alt_dial =~ /ALT/) && ($DBIPautoaltdial[$camp_CIPct] =~ /ALT/) ) @@ -643,11 +656,11 @@ while($one_day_interval > 0) $address3 =~ s/\D//gi; $phone_number = $address3; } - $stmtA = "UPDATE vicidial_list set called_since_last_reset='$CSLR',user='VDAD' where lead_id='$lead_id'"; + $stmtA = "UPDATE vicidial_list set called_since_last_reset='$CSLR',user='VDAD',last_local_call_time='$LLCT_DATE' where lead_id='$lead_id'"; } else { - $stmtA = "UPDATE vicidial_list set called_since_last_reset='$CSLR', called_count='$called_count',user='VDAD' where lead_id='$lead_id'"; + $stmtA = "UPDATE vicidial_list set called_since_last_reset='$CSLR', called_count='$called_count',user='VDAD',last_local_call_time='$LLCT_DATE' where lead_id='$lead_id'"; } $affected_rows = $dbhA->do($stmtA); diff --git a/bin/AST_VDhopper.pl b/bin/AST_VDhopper.pl index f2f8820c..f78489c5 100644 --- a/bin/AST_VDhopper.pl +++ b/bin/AST_VDhopper.pl @@ -48,6 +48,7 @@ # 71030-2043 - Added hopper priority for callbacks # 80112-0221 - Added 2nd, 3rd,... NEW for LAST NAME/PHONE Sort # 80125-0821 - Added detail logging of each lead inserted +# 80713-0028 - Changed Recycling methodology # # constants @@ -66,6 +67,7 @@ $secX = time(); ($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";} @@ -505,6 +507,101 @@ foreach(@campaign_id) } $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;} + } + + if ($wyesterday < 1) #### Sunday local time + { + if (($Gct_sunday_start < 1) && ($Gct_sunday_stop < 1)) {$lct_end = $Gct_default_stop;} + else {$lct_end = $Gct_sunday_stop;} + } + if ($wyesterday==1) #### Monday local time + { + if (($Gct_monday_start < 1) && ($Gct_monday_stop < 1)) {$lct_end = $Gct_default_stop;} + else {$lct_end = $Gct_monday_stop;} + } + if ($wyesterday==2) #### Tuesday local time + { + if (($Gct_tuesday_start < 1) && ($Gct_tuesday_stop < 1)) {$lct_end = $Gct_default_stop;} + else {$lct_end = $Gct_tuesday_stop;} + } + if ($wyesterday==3) #### Wednesday local time + { + if (($Gct_wednesday_start < 1) && ($Gct_wednesday_stop < 1)) {$lct_end = $Gct_default_stop;} + else {$lct_end = $Gct_wednesday_stop;} + } + if ($wyesterday==4) #### Thursday local time + { + if (($Gct_thursday_start < 1) && ($Gct_thursday_stop < 1)) {$lct_end = $Gct_default_stop;} + else {$lct_end = $Gct_thursday_stop;} + } + if ($wyesterday==5) #### Friday local time + { + if (($Gct_friday_start < 1) && ($Gct_friday_stop < 1)) {$lct_end = $Gct_default_stop;} + else {$lct_end = $Gct_friday_stop;} + } + if ($wyesterday==6) #### Saturday local time + { + if (($Gct_saturday_start < 1) && ($Gct_saturday_stop < 1)) {$lct_end = $Gct_default_stop;} + else {$lct_end = $Gct_saturday_stop;} + } + + $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) ); + + 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 = ''; @@ -558,16 +655,16 @@ foreach(@campaign_id) { if ($GMT_day[$r]==0) #### Sunday local time { - if (($Gsct_sunday_start==0) and ($Gsct_sunday_stop==0)) + if (($Gsct_sunday_start==0) && ($Gsct_sunday_stop==0)) { - if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + 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) and ($GMT_hour[$r]<$Gsct_sunday_stop) ) + 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]',";} @@ -575,16 +672,16 @@ foreach(@campaign_id) } if ($GMT_day[$r]==1) #### Monday local time { - if (($Gsct_monday_start==0) and ($Gsct_monday_stop==0)) + if (($Gsct_monday_start==0) && ($Gsct_monday_stop==0)) { - if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + 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) and ($GMT_hour[$r]<$Gsct_monday_stop) ) + 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]',";} @@ -592,16 +689,16 @@ foreach(@campaign_id) } if ($GMT_day[$r]==2) #### Tuesday local time { - if (($Gsct_tuesday_start==0) and ($Gsct_tuesday_stop==0)) + if (($Gsct_tuesday_start==0) && ($Gsct_tuesday_stop==0)) { - if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + 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) and ($GMT_hour[$r]<$Gsct_tuesday_stop) ) + 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]',";} @@ -609,16 +706,16 @@ foreach(@campaign_id) } if ($GMT_day[$r]==3) #### Wednesday local time { - if (($Gsct_wednesday_start==0) and ($Gsct_wednesday_stop==0)) + if (($Gsct_wednesday_start==0) && ($Gsct_wednesday_stop==0)) { - if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + 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) and ($GMT_hour[$r]<$Gsct_wednesday_stop) ) + 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]',";} @@ -626,16 +723,16 @@ foreach(@campaign_id) } if ($GMT_day[$r]==4) #### Thursday local time { - if (($Gsct_thursday_start==0) and ($Gsct_thursday_stop==0)) + if (($Gsct_thursday_start==0) && ($Gsct_thursday_stop==0)) { - if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + 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) and ($GMT_hour[$r]<$Gsct_thursday_stop) ) + 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]',";} @@ -643,16 +740,16 @@ foreach(@campaign_id) } if ($GMT_day[$r]==5) #### Friday local time { - if (($Gsct_friday_start==0) and ($Gsct_friday_stop==0)) + if (($Gsct_friday_start==0) && ($Gsct_friday_stop==0)) { - if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + 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) and ($GMT_hour[$r]<$Gsct_friday_stop) ) + 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]',";} @@ -660,16 +757,16 @@ foreach(@campaign_id) } if ($GMT_day[$r]==6) #### Saturday local time { - if (($Gsct_saturday_start==0) and ($Gsct_saturday_stop==0)) + if (($Gsct_saturday_start==0) && ($Gsct_saturday_stop==0)) { - if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + 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) and ($GMT_hour[$r]<$Gsct_saturday_stop) ) + 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]',";} @@ -679,8 +776,8 @@ foreach(@campaign_id) } $state_gmt = "$state_gmt'99'"; $del_state_gmt = "$del_state_gmt'99'"; - $ct_state_gmt_SQL .= "or (state='$Gstate_call_time_state' and gmt_offset_now IN($state_gmt)) "; - $del_state_gmt_SQL .= "or (state='$Gstate_call_time_state' and gmt_offset_now IN($del_state_gmt)) "; + $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++; @@ -696,125 +793,127 @@ foreach(@campaign_id) } $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) and ($Gct_sunday_stop==0)) + if (($Gct_sunday_start==0) && ($Gct_sunday_stop==0)) { - if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) - {$default_gmt.="'$GMT_gmt[$r]',";} + 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) and ($GMT_hour[$r]<$Gct_sunday_stop) ) - {$default_gmt.="'$GMT_gmt[$r]',";} + 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) and ($Gct_monday_stop==0)) + if (($Gct_monday_start==0) && ($Gct_monday_stop==0)) { - if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) - {$default_gmt.="'$GMT_gmt[$r]',";} + 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) and ($GMT_hour[$r]<$Gct_monday_stop) ) - {$default_gmt.="'$GMT_gmt[$r]',";} + 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) and ($Gct_tuesday_stop==0)) + if (($Gct_tuesday_start==0) && ($Gct_tuesday_stop==0)) { - if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) - {$default_gmt.="'$GMT_gmt[$r]',";} + 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) and ($GMT_hour[$r]<$Gct_tuesday_stop) ) - {$default_gmt.="'$GMT_gmt[$r]',";} + 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) and ($Gct_wednesday_stop==0)) + if (($Gct_wednesday_start==0) && ($Gct_wednesday_stop==0)) { - if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) - {$default_gmt.="'$GMT_gmt[$r]',";} + 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) and ($GMT_hour[$r]<$Gct_wednesday_stop) ) - {$default_gmt.="'$GMT_gmt[$r]',";} + 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) and ($Gct_thursday_stop==0)) + if (($Gct_thursday_start==0) && ($Gct_thursday_stop==0)) { - if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) - {$default_gmt.="'$GMT_gmt[$r]',";} + 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) and ($GMT_hour[$r]<$Gct_thursday_stop) ) - {$default_gmt.="'$GMT_gmt[$r]',";} + 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) and ($Gct_friday_stop==0)) + if (($Gct_friday_start==0) && ($Gct_friday_stop==0)) { - if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) - {$default_gmt.="'$GMT_gmt[$r]',";} + 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) and ($GMT_hour[$r]<$Gct_friday_stop) ) - {$default_gmt.="'$GMT_gmt[$r]',";} + 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) and ($Gct_saturday_stop==0)) + if (($Gct_saturday_start==0) && ($Gct_saturday_stop==0)) { - if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) - {$default_gmt.="'$GMT_gmt[$r]',";} + 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) and ($GMT_hour[$r]<$Gct_saturday_stop) ) - {$default_gmt.="'$GMT_gmt[$r]',";} + 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]',";} } @@ -858,17 +957,6 @@ foreach(@campaign_id) $recycle_SQL[$i] = "( "; while($rc < $rec_ct[$i]) { - $secX = time(); - $Rtarget = ($secX - $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";} - $RSQLdate[$rc] = "$Ryear-$Rmon-$Rmday $Rhour:$Rmin:$Rsec"; $Y=1; $recycle_Y = "'Y'"; while ($Y < $recycle_maximum[$rc]) @@ -876,12 +964,52 @@ foreach(@campaign_id) $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 (modify_date < \"$RSQLdate[$rc]\") )"; + $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++; } diff --git a/bin/AST_VDhopper_MIXtest.pl b/bin/AST_VDhopper_MIXtest.pl index b1ef61c8..0e989c6d 100644 --- a/bin/AST_VDhopper_MIXtest.pl +++ b/bin/AST_VDhopper_MIXtest.pl @@ -50,6 +50,7 @@ # 71030-2043 - Added hopper priority for callbacks # 80112-0221 - Added 2nd, 3rd,... NEW for LAST NAME/PHONE Sort # 80125-0821 - Added detail logging of each lead inserted +# 80713-0028 - Changed Recycling methodology # # constants @@ -68,6 +69,7 @@ $secX = time(); ($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";} @@ -511,6 +513,101 @@ foreach(@campaign_id) } $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;} + } + + if ($wyesterday < 1) #### Sunday local time + { + if (($Gct_sunday_start < 1) && ($Gct_sunday_stop < 1)) {$lct_end = $Gct_default_stop;} + else {$lct_end = $Gct_sunday_stop;} + } + if ($wyesterday==1) #### Monday local time + { + if (($Gct_monday_start < 1) && ($Gct_monday_stop < 1)) {$lct_end = $Gct_default_stop;} + else {$lct_end = $Gct_monday_stop;} + } + if ($wyesterday==2) #### Tuesday local time + { + if (($Gct_tuesday_start < 1) && ($Gct_tuesday_stop < 1)) {$lct_end = $Gct_default_stop;} + else {$lct_end = $Gct_tuesday_stop;} + } + if ($wyesterday==3) #### Wednesday local time + { + if (($Gct_wednesday_start < 1) && ($Gct_wednesday_stop < 1)) {$lct_end = $Gct_default_stop;} + else {$lct_end = $Gct_wednesday_stop;} + } + if ($wyesterday==4) #### Thursday local time + { + if (($Gct_thursday_start < 1) && ($Gct_thursday_stop < 1)) {$lct_end = $Gct_default_stop;} + else {$lct_end = $Gct_thursday_stop;} + } + if ($wyesterday==5) #### Friday local time + { + if (($Gct_friday_start < 1) && ($Gct_friday_stop < 1)) {$lct_end = $Gct_default_stop;} + else {$lct_end = $Gct_friday_stop;} + } + if ($wyesterday==6) #### Saturday local time + { + if (($Gct_saturday_start < 1) && ($Gct_saturday_stop < 1)) {$lct_end = $Gct_default_stop;} + else {$lct_end = $Gct_saturday_stop;} + } + + $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) ); + + 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 = ''; @@ -564,16 +661,16 @@ foreach(@campaign_id) { if ($GMT_day[$r]==0) #### Sunday local time { - if (($Gsct_sunday_start==0) and ($Gsct_sunday_stop==0)) + if (($Gsct_sunday_start==0) && ($Gsct_sunday_stop==0)) { - if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + 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) and ($GMT_hour[$r]<$Gsct_sunday_stop) ) + 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]',";} @@ -581,16 +678,16 @@ foreach(@campaign_id) } if ($GMT_day[$r]==1) #### Monday local time { - if (($Gsct_monday_start==0) and ($Gsct_monday_stop==0)) + if (($Gsct_monday_start==0) && ($Gsct_monday_stop==0)) { - if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + 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) and ($GMT_hour[$r]<$Gsct_monday_stop) ) + 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]',";} @@ -598,16 +695,16 @@ foreach(@campaign_id) } if ($GMT_day[$r]==2) #### Tuesday local time { - if (($Gsct_tuesday_start==0) and ($Gsct_tuesday_stop==0)) + if (($Gsct_tuesday_start==0) && ($Gsct_tuesday_stop==0)) { - if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + 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) and ($GMT_hour[$r]<$Gsct_tuesday_stop) ) + 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]',";} @@ -615,16 +712,16 @@ foreach(@campaign_id) } if ($GMT_day[$r]==3) #### Wednesday local time { - if (($Gsct_wednesday_start==0) and ($Gsct_wednesday_stop==0)) + if (($Gsct_wednesday_start==0) && ($Gsct_wednesday_stop==0)) { - if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + 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) and ($GMT_hour[$r]<$Gsct_wednesday_stop) ) + 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]',";} @@ -632,16 +729,16 @@ foreach(@campaign_id) } if ($GMT_day[$r]==4) #### Thursday local time { - if (($Gsct_thursday_start==0) and ($Gsct_thursday_stop==0)) + if (($Gsct_thursday_start==0) && ($Gsct_thursday_stop==0)) { - if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + 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) and ($GMT_hour[$r]<$Gsct_thursday_stop) ) + 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]',";} @@ -649,16 +746,16 @@ foreach(@campaign_id) } if ($GMT_day[$r]==5) #### Friday local time { - if (($Gsct_friday_start==0) and ($Gsct_friday_stop==0)) + if (($Gsct_friday_start==0) && ($Gsct_friday_stop==0)) { - if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + 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) and ($GMT_hour[$r]<$Gsct_friday_stop) ) + 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]',";} @@ -666,16 +763,16 @@ foreach(@campaign_id) } if ($GMT_day[$r]==6) #### Saturday local time { - if (($Gsct_saturday_start==0) and ($Gsct_saturday_stop==0)) + if (($Gsct_saturday_start==0) && ($Gsct_saturday_stop==0)) { - if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + 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) and ($GMT_hour[$r]<$Gsct_saturday_stop) ) + 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]',";} @@ -685,8 +782,8 @@ foreach(@campaign_id) } $state_gmt = "$state_gmt'99'"; $del_state_gmt = "$del_state_gmt'99'"; - $ct_state_gmt_SQL .= "or (state='$Gstate_call_time_state' and gmt_offset_now IN($state_gmt)) "; - $del_state_gmt_SQL .= "or (state='$Gstate_call_time_state' and gmt_offset_now IN($del_state_gmt)) "; + $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++; @@ -702,125 +799,127 @@ foreach(@campaign_id) } $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) and ($Gct_sunday_stop==0)) + if (($Gct_sunday_start==0) && ($Gct_sunday_stop==0)) { - if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) - {$default_gmt.="'$GMT_gmt[$r]',";} + 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) and ($GMT_hour[$r]<$Gct_sunday_stop) ) - {$default_gmt.="'$GMT_gmt[$r]',";} + 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) and ($Gct_monday_stop==0)) + if (($Gct_monday_start==0) && ($Gct_monday_stop==0)) { - if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) - {$default_gmt.="'$GMT_gmt[$r]',";} + 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) and ($GMT_hour[$r]<$Gct_monday_stop) ) - {$default_gmt.="'$GMT_gmt[$r]',";} + 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) and ($Gct_tuesday_stop==0)) + if (($Gct_tuesday_start==0) && ($Gct_tuesday_stop==0)) { - if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) - {$default_gmt.="'$GMT_gmt[$r]',";} + 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) and ($GMT_hour[$r]<$Gct_tuesday_stop) ) - {$default_gmt.="'$GMT_gmt[$r]',";} + 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) and ($Gct_wednesday_stop==0)) + if (($Gct_wednesday_start==0) && ($Gct_wednesday_stop==0)) { - if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) - {$default_gmt.="'$GMT_gmt[$r]',";} + 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) and ($GMT_hour[$r]<$Gct_wednesday_stop) ) - {$default_gmt.="'$GMT_gmt[$r]',";} + 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) and ($Gct_thursday_stop==0)) + if (($Gct_thursday_start==0) && ($Gct_thursday_stop==0)) { - if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) - {$default_gmt.="'$GMT_gmt[$r]',";} + 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) and ($GMT_hour[$r]<$Gct_thursday_stop) ) - {$default_gmt.="'$GMT_gmt[$r]',";} + 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) and ($Gct_friday_stop==0)) + if (($Gct_friday_start==0) && ($Gct_friday_stop==0)) { - if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) - {$default_gmt.="'$GMT_gmt[$r]',";} + 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) and ($GMT_hour[$r]<$Gct_friday_stop) ) - {$default_gmt.="'$GMT_gmt[$r]',";} + 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) and ($Gct_saturday_stop==0)) + if (($Gct_saturday_start==0) && ($Gct_saturday_stop==0)) { - if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) - {$default_gmt.="'$GMT_gmt[$r]',";} + 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) and ($GMT_hour[$r]<$Gct_saturday_stop) ) - {$default_gmt.="'$GMT_gmt[$r]',";} + 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]',";} } @@ -864,17 +963,6 @@ foreach(@campaign_id) $recycle_SQL[$i] = "( "; while($rc < $rec_ct[$i]) { - $secX = time(); - $Rtarget = ($secX - $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";} - $RSQLdate[$rc] = "$Ryear-$Rmon-$Rmday $Rhour:$Rmin:$Rsec"; $Y=1; $recycle_Y = "'Y'"; while ($Y < $recycle_maximum[$rc]) @@ -882,12 +970,52 @@ foreach(@campaign_id) $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 (modify_date < \"$RSQLdate[$rc]\") )"; + $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++; } diff --git a/bin/VICIDIAL_IN_new_leads_file.pl b/bin/VICIDIAL_IN_new_leads_file.pl index 886961cb..46f902b7 100644 --- a/bin/VICIDIAL_IN_new_leads_file.pl +++ b/bin/VICIDIAL_IN_new_leads_file.pl @@ -27,6 +27,7 @@ # 70815-2128 - Added entry_date to import leads format (field 26) # 80128-0105 - Fixed bugs in file loading # 80428-0320 - UTF8 update +# 80713-0023 - added last_local_call_time field default of 2008-01-01 # $secX = time(); @@ -675,7 +676,7 @@ if ($DB) {print "SEED TIME $secX : $year-$mon-$mday $hour:$min:$sec LOC if ($multi_insert_counter > 8) { ### insert good deal 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');"; + $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');"; if (!$T) {$affected_rows = $dbhA->do($stmtZ); } # or die "Couldn't execute query: |$stmtZ|\n"; if($DB){print STDERR "\n|$affected_rows|$stmtZ|\n";} @@ -685,7 +686,7 @@ if ($DB) {print "SEED TIME $secX : $year-$mon-$mday $hour:$min:$sec LOC } 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'),"; + $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'),"; $multi_insert_counter++; } diff --git a/bin/VICIDIAL_last_local_call_time_UPDATE.pl b/bin/VICIDIAL_last_local_call_time_UPDATE.pl new file mode 100644 index 00000000..4f0f2c0a --- /dev/null +++ b/bin/VICIDIAL_last_local_call_time_UPDATE.pl @@ -0,0 +1,176 @@ +#!/usr/bin/perl +# +# VICIDIAL_last_local_call_time_UPDATE.pl version 2.0.5 +# +# DESCRIPTION: +# populates the new last_local_call_time field in the vicidial_list table from +# records in the vicidial_log and vicidial_closer_log table +# +# Copyright (C) 2008 Matt Florell LICENSE: AGPLv2 +# +# CHANGES +# 80714-0530 - first build +# + +$secX = time(); + +($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); +$year = ($year + 1900); +$mon++; +if ($hour < 10) {$hour = "0$hour";} +if ($min < 10) {$min = "0$min";} +if ($sec < 10) {$sec = "0$sec";} +if ($mon < 10) {$mon = "0$mon";} +if ($mday < 10) {$mday = "0$mday";} +$pulldate0 = "$year-$mon-$mday $hour:$min:$sec"; +$inSD = $pulldate0; +$dsec = ( ( ($hour * 3600) + ($min * 60) ) + $sec ); + + + +# default path to astguiclient configuration file: +$PATHconf = '/etc/astguiclient.conf'; + +open(conf, "$PATHconf") || die "can't open $PATHconf: $!\n"; +@conf = ; +close(conf); +$i=0; +foreach(@conf) + { + $line = $conf[$i]; + $line =~ s/ |>|\n|\r|\t|\#.*|;.*//gi; + if ( ($line =~ /^PATHhome/) && ($CLIhome < 1) ) + {$PATHhome = $line; $PATHhome =~ s/.*=//gi;} + if ( ($line =~ /^PATHlogs/) && ($CLIlogs < 1) ) + {$PATHlogs = $line; $PATHlogs =~ s/.*=//gi;} + if ( ($line =~ /^PATHagi/) && ($CLIagi < 1) ) + {$PATHagi = $line; $PATHagi =~ s/.*=//gi;} + if ( ($line =~ /^PATHweb/) && ($CLIweb < 1) ) + {$PATHweb = $line; $PATHweb =~ s/.*=//gi;} + if ( ($line =~ /^PATHsounds/) && ($CLIsounds < 1) ) + {$PATHsounds = $line; $PATHsounds =~ s/.*=//gi;} + if ( ($line =~ /^PATHmonitor/) && ($CLImonitor < 1) ) + {$PATHmonitor = $line; $PATHmonitor =~ s/.*=//gi;} + if ( ($line =~ /^VARserver_ip/) && ($CLIserver_ip < 1) ) + {$VARserver_ip = $line; $VARserver_ip =~ s/.*=//gi;} + if ( ($line =~ /^VARDB_server/) && ($CLIDB_server < 1) ) + {$VARDB_server = $line; $VARDB_server =~ s/.*=//gi;} + if ( ($line =~ /^VARDB_database/) && ($CLIDB_database < 1) ) + {$VARDB_database = $line; $VARDB_database =~ s/.*=//gi;} + if ( ($line =~ /^VARDB_user/) && ($CLIDB_user < 1) ) + {$VARDB_user = $line; $VARDB_user =~ s/.*=//gi;} + if ( ($line =~ /^VARDB_pass/) && ($CLIDB_pass < 1) ) + {$VARDB_pass = $line; $VARDB_pass =~ s/.*=//gi;} + if ( ($line =~ /^VARDB_port/) && ($CLIDB_port < 1) ) + {$VARDB_port = $line; $VARDB_port =~ s/.*=//gi;} + $i++; + } + +# Customized Variables +$server_ip = $VARserver_ip; # Asterisk server IP + +if (!$VARDB_port) {$VARDB_port='3306';} + +use DBI; + +$dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VARDB_user", "$VARDB_pass") + or die "Couldn't connect to database: " . DBI->errstr; + +#$DB=1; + +$liveupdate=0; + +if (!$VDHLOGfile) {$VDHLOGfile = "$PATHlogs/dupleads.$year-$mon-$mday";} + +print "\n\n\n\n\n\n\n\n\n\n\n\n-- VICIDIAL_last_local_call_time_UPDATE.pl --\n\n"; +print "populates the new last_local_call_time field in the vicidial_list table from records in the vicidial_log and vicidial_closer_log table. \n\n"; + + +$stmtA = "select lead_id,list_id from vicidial_list;"; +if($DBX){print STDERR "\n|$stmtA|\n";} +$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; +$sthA->execute or die "executing: $stmtA ", $dbhA->errstr; +$sthArows=$sthA->rows; +$i=0; +$nonDUP='0'; +while ( ($sthArows > $i) && ($nonDUP=='0') ) + { + @aryA = $sthA->fetchrow_array; + if ($aryA[0] > 1) + { + $lead_id[$i] = "$aryA[0]"; + $list_id[$i] = "$aryA[1]"; + } + $i++; + } +$sthA->finish(); + +$b=0; +foreach(@lead_id) + { + $Ncall_date='2008-01-01 00:00:00'; + $Nepoch=0; + $Ccall_date='2008-01-01 00:00:00'; + $Cepoch=0; + $stmtA = "select call_date,start_epoch from vicidial_log where lead_id='$lead_id[$b]' order by call_date desc LIMIT 1;"; + if($DBX){print STDERR "\n|$stmtA|\n";} + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + if ($sthArows > 0) + { + @aryA = $sthA->fetchrow_array; + $Ncall_date = $aryA[0]; + $Nepoch = $aryA[1]; + $rec_count++; + } + $sthA->finish(); + + $stmtA = "select call_date,start_epoch from vicidial_closer_log where lead_id='$lead_id[$b]' order by closecallid desc LIMIT 1;"; + if($DBX){print STDERR "\n|$stmtA|\n";} + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + if ($sthArows > 0) + { + @aryA = $sthA->fetchrow_array; + $Ccall_date = $aryA[0]; + $Cepoch = $aryA[1]; + $rec_count++; + } + $sthA->finish(); + + if ($Cepoch > $Nepoch) {$NEWcall_date = $Ccall_date;} + else {$NEWcall_date = $Ncall_date;} + + $stmtA = "UPDATE vicidial_list set last_local_call_time='$NEWcall_date' where lead_id='$lead_id[$b]';"; + $affected_rows = $dbhA->do($stmtA); # or die "Couldn't execute query:|$stmtA|\n"; + if($DB){print STDERR "|$b|$lead_id[$b]|$Ncall_date|$Ccall_date|$list_id[$b]||$stmtA|\n";} + + $b++; + + if ($b =~ /100$/i) {print STDERR "0 $b\r";} + if ($b =~ /200$/i) {print STDERR "+ $b\r";} + if ($b =~ /300$/i) {print STDERR "| $b\r";} + if ($b =~ /400$/i) {print STDERR "\\ $b\r";} + if ($b =~ /500$/i) {print STDERR "- $b\r";} + if ($b =~ /600$/i) {print STDERR "/ $b\r";} + if ($b =~ /700$/i) {print STDERR "| $b\r";} + if ($b =~ /800$/i) {print STDERR "+ $b\r";} + if ($b =~ /900$/i) {print STDERR "0 $b\r";} + if ($b =~ /000$/i) {print "|$b|$lead_id[$b]|$Ncall_date|$Ccall_date|$list_id[$b]|\n";} + + } + + +$dbhA->disconnect(); + +### calculate time to run script ### +$secY = time(); +$secZ = ($secY - $secX); +$secZm = ($secZ /60); + +print "script execution time in seconds: $secZ minutes: $secZm\n"; + +exit; + diff --git a/extras/MySQL_AST_CREATE_tables.sql b/extras/MySQL_AST_CREATE_tables.sql index 9e94459c..65449f99 100644 --- a/extras/MySQL_AST_CREATE_tables.sql +++ b/extras/MySQL_AST_CREATE_tables.sql @@ -271,12 +271,14 @@ email VARCHAR(70), security_phrase VARCHAR(100), comments VARCHAR(255), called_count SMALLINT(5) UNSIGNED default '0', +last_local_call_time DATETIME index (phone_number), index (list_id), index (called_since_last_reset), index (status), index (gmt_offset_now), -index (postal_code) +index (postal_code), +index (last_local_call_time) ); CREATE TABLE vicidial_hopper ( @@ -911,7 +913,7 @@ recycle_id INT(9) UNSIGNED AUTO_INCREMENT PRIMARY KEY NOT NULL, campaign_id VARCHAR(8), status VARCHAR(6) NOT NULL, attempt_delay SMALLINT(5) UNSIGNED default '1800', -attempt_maximum TINYINT(3) UNSIGNED default '32', +attempt_maximum TINYINT(3) UNSIGNED default '2', active ENUM('Y','N') default 'N', index (campaign_id) ); @@ -1223,5 +1225,5 @@ INSERT INTO vicidial_state_call_times SET state_call_time_id='utah',state_call_t INSERT INTO vicidial_state_call_times SET state_call_time_id='washington',state_call_time_state='WA',state_call_time_name='Washington 8am',sct_default_start='800',sct_default_stop='2100'; INSERT INTO vicidial_state_call_times SET state_call_time_id='wyoming',state_call_time_state='WY',state_call_time_name='Wyoming 8am-8pm',sct_default_start='800',sct_default_stop='2000'; -UPDATE system_settings SET db_schema_version='1098'; +UPDATE system_settings SET db_schema_version='1100'; diff --git a/extras/upgrade_2.0.5.sql b/extras/upgrade_2.0.5.sql index 145d6b06..d023b39b 100644 --- a/extras/upgrade_2.0.5.sql +++ b/extras/upgrade_2.0.5.sql @@ -309,3 +309,8 @@ UPDATE system_settings SET db_schema_version='1098'; ALTER TABLE vicidial_campaigns MODIFY manual_dial_list_id BIGINT(14) UNSIGNED default '998'; UPDATE system_settings SET db_schema_version='1099'; + +ALTER TABLE vicidial_list ADD last_local_call_time DATETIME; +CREATE INDEX last_local_call_time ON vicidial_list (last_local_call_time); + +UPDATE system_settings SET db_schema_version='1100'; diff --git a/translations/raw_translation_files/TO_BE_TRANSLATED_2.0.5.txt b/translations/raw_translation_files/TO_BE_TRANSLATED_2.0.5.txt index be0fdc80..bc404a3c 100644 --- a/translations/raw_translation_files/TO_BE_TRANSLATED_2.0.5.txt +++ b/translations/raw_translation_files/TO_BE_TRANSLATED_2.0.5.txt @@ -229,6 +229,7 @@ Agent Display Queue Count -<\/B> If set to Y, when a customer is waiting for an Agent Display Queue Count: || agents in dead calls|| QC Last Pull Time: || +and less than 43200 seconds or 12 hours|| ############################################################ CLIENT diff --git a/www/agc/vdc_db_query.php b/www/agc/vdc_db_query.php index ad5600ff..6b71dd97 100644 --- a/www/agc/vdc_db_query.php +++ b/www/agc/vdc_db_query.php @@ -152,10 +152,11 @@ # 80630-2153 - Added queue_log logging for Manual dial calls # 80703-0139 - Added alter customer phone permissions # 80707-2325 - Added vicidial_id to recording_log for tracking of vicidial or closer log to recording +# 80713-0624 - Added vicidial_list_last_local_call_time field # -$version = '2.0.5-76'; -$build = '80707-2325'; +$version = '2.0.5-77'; +$build = '80713-0624'; require("dbconnect.php"); @@ -608,7 +609,7 @@ if ($ACTION == 'manDiaLnextCaLL') else { ### insert a new lead in the system with this phone number - $stmt = "INSERT INTO vicidial_list SET phone_code='$phone_code',phone_number='$phone_number',list_id='$list_id',status='QUEUE',user='$user',called_since_last_reset='Y',entry_date='$ENTRYdate';"; + $stmt = "INSERT INTO vicidial_list SET phone_code='$phone_code',phone_number='$phone_number',list_id='$list_id',status='QUEUE',user='$user',called_since_last_reset='Y',entry_date='$ENTRYdate',last_local_call_time='$NOW_TIME';"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $link); $affected_rows = mysql_affected_rows($link); @@ -619,7 +620,7 @@ if ($ACTION == 'manDiaLnextCaLL') else { ### insert a new lead in the system with this phone number - $stmt = "INSERT INTO vicidial_list SET phone_code='$phone_code',phone_number='$phone_number',list_id='$list_id',status='QUEUE',user='$user',called_since_last_reset='Y',entry_date='$ENTRYdate';"; + $stmt = "INSERT INTO vicidial_list SET phone_code='$phone_code',phone_number='$phone_number',list_id='$list_id',status='QUEUE',user='$user',called_since_last_reset='Y',entry_date='$ENTRYdate',last_local_call_time='$NOW_TIME';"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $link); $affected_rows = mysql_affected_rows($link); @@ -740,8 +741,20 @@ if ($ACTION == 'manDiaLnextCaLL') } } + $stmt = "SELECT local_gmt FROM servers where active='Y' limit 1;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $server_ct = mysql_num_rows($rslt); + if ($server_ct > 0) + { + $row=mysql_fetch_row($rslt); + $local_gmt = $row[0]; + } + $LLCT_DATE_offset = ($local_gmt - $gmt_offset_now); + $LLCT_DATE = date("Y-m-d H:i:s", mktime(date("H")-$LLCT_DATE_offset,date("i"),date("s"),date("m"),date("d"),date("Y"))); + ### flag the lead as called and change it's status to INCALL - $stmt = "UPDATE vicidial_list set status='INCALL', called_since_last_reset='Y', called_count='$called_count',user='$user' where lead_id='$lead_id';"; + $stmt = "UPDATE vicidial_list set status='INCALL', called_since_last_reset='Y', called_count='$called_count',user='$user',last_local_call_time='$LLCT_DATE' where lead_id='$lead_id';"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $link); diff --git a/www/vicidial/admin.php b/www/vicidial/admin.php index 1159535b..e7b95281 100644 --- a/www/vicidial/admin.php +++ b/www/vicidial/admin.php @@ -5935,11 +5935,11 @@ if ($ADD==25) {echo "
CAMPAIGN LEAD RECYCLE NOT ADDED - there is already a lead-recycle for this campaign with this status\n";} else { - if ( (strlen($campaign_id) < 2) or (strlen($status) < 1) or ($attempt_delay < 120) or ($attempt_maximum < 1) or ($attempt_maximum > 10) ) + if ( (strlen($campaign_id) < 2) or (strlen($status) < 1) or ($attempt_delay < 120) or ($attempt_delay >= 43200) or ($attempt_maximum < 1) or ($attempt_maximum > 10) ) { echo "
CAMPAIGN LEAD RECYCLE NOT ADDED - Please go back and look at the data you entered\n"; echo "
status must be between 1 and 6 characters in length\n"; - echo "
attempt delay must be at least 120 seconds\n"; + echo "
attempt delay must be at least 120 seconds and less than 43200 seconds or 12 hours\n"; echo "
maximum attempts must be from 1 to 10\n"; } else @@ -7314,11 +7314,11 @@ if ($ADD==45) { echo ""; - if ( (strlen($campaign_id) < 2) or (strlen($status) < 1) or ($attempt_delay < 120) or ($attempt_maximum < 1) or ($attempt_maximum > 10) ) + if ( (strlen($campaign_id) < 2) or (strlen($status) < 1) or ($attempt_delay < 120) or ($attempt_delay >= 43200) or ($attempt_maximum < 1) or ($attempt_maximum > 10) ) { echo "
CAMPAIGN LEAD RECYCLE NOT MODIFIED - Please go back and look at the data you entered\n"; echo "
status must be between 1 and 6 characters in length\n"; - echo "
attempt delay must be at least 120 seconds\n"; + echo "
attempt delay must be at least 120 seconds and less than 43200 seconds or 12 hours\n"; echo "
maximum attempts must be from 1 to 10\n"; } else diff --git a/www/vicidial/listloader.pl b/www/vicidial/listloader.pl index 7ea00e6e..b8f9e064 100644 --- a/www/vicidial/listloader.pl +++ b/www/vicidial/listloader.pl @@ -18,6 +18,7 @@ # 70417-1059 - Fixed default phone_code bug # 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 # ### begin parsing run-time options ### @@ -564,14 +565,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);"; + $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');"; $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),"; + $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'),"; $multi_insert_counter++; } diff --git a/www/vicidial/listloader_super.pl b/www/vicidial/listloader_super.pl index 7e7270c0..3af97f37 100644 --- a/www/vicidial/listloader_super.pl +++ b/www/vicidial/listloader_super.pl @@ -17,6 +17,7 @@ # 70417-1059 - Fixed default phone_code bug # 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 # ### begin parsing run-time options ### @@ -566,14 +567,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);"; + $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');"; $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),"; + $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'),"; $multi_insert_counter++; } diff --git a/www/vicidial/new_listloader_superL.php b/www/vicidial/new_listloader_superL.php index 1a592300..ba100f0e 100644 --- a/www/vicidial/new_listloader_superL.php +++ b/www/vicidial/new_listloader_superL.php @@ -21,11 +21,13 @@ # 70510-1518 - Added campaign and system duplicate check and phonecode override # 80428-0417 - UTF8 changes # 80514-1030 - removed filesize limit and raised number of errors to be displayed +# 80713-0023 - added last_local_call_time field default of 2008-01-01 +# # # 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.0.5-25'; -$build = '80514-1030'; +$version = '2.0.5-26'; +$build = '80713-0023'; require("dbconnect.php"); @@ -538,7 +540,7 @@ function ParseFileName() { 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);"; + $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');"; $rslt=mysql_query($stmtZ, $link); if ($WeBRooTWritablE > 0) {fwrite($stmt_file, $stmtZ."\r\n");} @@ -546,7 +548,7 @@ function ParseFileName() { $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),"; + $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'),"; $multi_insert_counter++; } @@ -753,7 +755,7 @@ function ParseFileName() { 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);"; + $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');"; $rslt=mysql_query($stmtZ, $link); if ($WeBRooTWritablE > 0) {fwrite($stmt_file, $stmtZ."\r\n");} @@ -761,7 +763,7 @@ function ParseFileName() { $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),"; + $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'),"; $multi_insert_counter++; } @@ -977,7 +979,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);"; + $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');"; $rslt=mysql_query($stmtZ, $link); if ($WeBRooTWritablE > 0) {fwrite($stmt_file, $stmtZ."\r\n");} @@ -985,7 +987,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),"; + $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'),"; $multi_insert_counter++; } @@ -1203,7 +1205,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);"; + $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');"; $rslt=mysql_query($stmtZ, $link); if ($WeBRooTWritablE > 0) {fwrite($stmt_file, $stmtZ."\r\n");} @@ -1211,7 +1213,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),"; + $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'),"; $multi_insert_counter++; }