aisa/scripts/admin/oneoff/short_operator_dates_paid.pl

67 lines
1.6 KiB
Perl
Raw Permalink Normal View History

2025-11-26 09:31:54 +00:00
#!/usr/bin/perl
BEGIN { use lib '/usr/home/cfg' ; require push_inc ; }
require cfg ;
use CGI::Carp qw(fatalsToBrowser);
# use Date::Calc qw(:all);
# use DBI;
# https://itvadmin.co.za/cgi-bin/scripts/admin/oneoff/short_operator_dates_paid.pl?1
#-------------------------------------------------------------------------------
my @ARGV = split(/\&/, $ENV{'QUERY_STRING'});
our $debug = $ARGV[0] ;
# our $username = 'rory' ;
if ($debug) { print "Content-type: text/html\n\n"; }
#------------------------------------------------------------------------------------------
&today ;
&db_open_upd ;
# &db_open_ro ;
our $db_ignore_open_close = 1 ; # do one open and one close instead of repeating it
&load_vars ;
$db_ignore_open_close = 0 ; # do one open and one close instead of repeating it
&db_close_conn ;
if ($debug) { print "Done."; }
exit;
#------------------------------------------------------------------------------------------
sub load_vars {
&db_min_ro('event_quotes_min','id,operator_dates_paid,operator_dates_paid_min',"operator_dates_paid IS NOT NULL",'','') ;
foreach my $id (sort keys %{$db{event_quotes_min}}) {
my @dates = split(/\;/,$db{event_quotes_min}{$id}{operator_dates_paid}) ;
my $all_same = 1 ; my $prev_date = "" ;
foreach my $date (@dates) {
if ($prev_date && $date ne $prev_date) {
$all_same = 0;
last;
}
$prev_date = $date ;
}
if ($all_same) {
%i = () ;
$i{operator_dates_paid_min} = $dates[0] ;
&db_min_upd('event_quotes_min',"id='$id'")
}
}
} #-------------------------------------------------------------------------------
use db ;
use today ;
use common ;
use common_min ;