diff --git a/bin/AST_VDhopper.pl b/bin/AST_VDhopper.pl index f78489c5..27f3abcd 100644 --- a/bin/AST_VDhopper.pl +++ b/bin/AST_VDhopper.pl @@ -552,40 +552,75 @@ foreach(@campaign_id) else {$lct_begin = $Gct_saturday_start;} } - if ($wyesterday < 1) #### Sunday local time + + $dayBACKsec=0; + $weekBACK=0; + while ( ($lct_end < 1) && ($weekBACK <= 1) ) { - 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;} + 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); @@ -595,7 +630,7 @@ foreach(@campaign_id) $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) ); + $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";} @@ -1219,9 +1254,9 @@ foreach(@campaign_id) @REC_user_to_hopper=@MT; if ($rec_ct[$i] > 0) { - if ($DB) {print " looking for RECYCLE leads, maximum of 100\n";} + 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] limit 100;"; + $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] 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; diff --git a/bin/AST_VDhopper_MIXtest.pl b/bin/AST_VDhopper_MIXtest.pl index 0e989c6d..77377a3a 100644 --- a/bin/AST_VDhopper_MIXtest.pl +++ b/bin/AST_VDhopper_MIXtest.pl @@ -558,40 +558,75 @@ foreach(@campaign_id) else {$lct_begin = $Gct_saturday_start;} } - if ($wyesterday < 1) #### Sunday local time + + $dayBACKsec=0; + $weekBACK=0; + while ( ($lct_end < 1) && ($weekBACK <= 1) ) { - 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;} + 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); @@ -601,7 +636,7 @@ foreach(@campaign_id) $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) ); + $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";} @@ -1267,9 +1302,9 @@ foreach(@campaign_id) @REC_status_to_hopper=@MT; if ($rec_ct[$i] > 0) { - if ($DB) {print " looking for RECYCLE leads, maximum of 100\n";} + 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 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] limit 100;"; + $stmtA = "SELECT lead_id,list_id,gmt_offset_now,phone_number,state,status 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] 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; diff --git a/bin/VICIDIAL_last_local_call_time_UPDATE.pl b/bin/VICIDIAL_last_local_call_time_UPDATE.pl index 4f0f2c0a..4c6e7c54 100644 --- a/bin/VICIDIAL_last_local_call_time_UPDATE.pl +++ b/bin/VICIDIAL_last_local_call_time_UPDATE.pl @@ -12,6 +12,10 @@ # 80714-0530 - first build # +$DB=0; +$liveupdate=0; +$calculate_recycle_counts=1; + $secX = time(); ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); @@ -27,7 +31,6 @@ $inSD = $pulldate0; $dsec = ( ( ($hour * 3600) + ($min * 60) ) + $sec ); - # default path to astguiclient configuration file: $PATHconf = '/etc/astguiclient.conf'; @@ -76,9 +79,6 @@ 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";} @@ -86,7 +86,7 @@ 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;"; +$stmtA = "select lead_id,list_id,called_count from vicidial_list limit 10000000;"; if($DBX){print STDERR "\n|$stmtA|\n";} $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; @@ -100,6 +100,7 @@ while ( ($sthArows > $i) && ($nonDUP=='0') ) { $lead_id[$i] = "$aryA[0]"; $list_id[$i] = "$aryA[1]"; + $Ncount[$i] = "$aryA[2]"; } $i++; } @@ -143,9 +144,20 @@ foreach(@lead_id) 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]';"; + if ($calculate_recycle_counts > 0) + { + if ( ($Ncount[$b]==0) or ($Ncount[$b]=='') ) {$Ncount[$b] = 'N';} + if ($Ncount[$b]==1) {$Ncount[$b] = 'Y';} + if ( ($Ncount[$b]>1) && ($Ncount[$b]<11) ) {$Ncount[$b] = ($Ncount[$b] - 1); $Ncount[$b] = "Y$Ncount[$b]";} + if ($Ncount[$b]>10) {$Ncount[$b] = 'Y10';} + $called_since_last_resetSQL = ",called_since_last_reset='$Ncount[$b]'"; + } + else + {$called_since_last_resetSQL = "";} + + $stmtA = "UPDATE vicidial_list set last_local_call_time='$NEWcall_date' $called_since_last_resetSQL 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";} + if($DB){print STDERR "|$b|$lead_id[$b]|$Ncall_date|$Ccall_date|$list_id[$b]|$Ncount[$b]|$stmtA|\n";} $b++; diff --git a/www/agc/vdc_db_query.php b/www/agc/vdc_db_query.php index 6b71dd97..29e757ce 100644 --- a/www/agc/vdc_db_query.php +++ b/www/agc/vdc_db_query.php @@ -669,6 +669,7 @@ if ($ACTION == 'manDiaLnextCaLL') $source_id = trim("$row[6]"); $list_id = trim("$row[7]"); $gmt_offset_now = trim("$row[8]"); + $called_since_last_reset = trim("$row[9]"); $phone_code = trim("$row[10]"); $phone_number = trim("$row[11]"); $title = trim("$row[12]"); @@ -753,8 +754,16 @@ if ($ACTION == 'manDiaLnextCaLL') $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"))); + if (ereg('Y',$called_since_last_reset)) + { + $called_since_last_reset = ereg_replace('Y','',$called_since_last_reset); + if (strlen($called_since_last_reset) < 1) {$called_since_last_reset = 0;} + $called_since_last_reset++; + $called_since_last_reset = "Y$called_since_last_reset"; + } + else {$called_since_last_reset = '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',last_local_call_time='$LLCT_DATE' where lead_id='$lead_id';"; + $stmt = "UPDATE vicidial_list set status='INCALL', called_since_last_reset='$called_since_last_reset', 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);