aisa/scripts/admin/oneoff/change_event_cost_items.pl

93 lines
3.7 KiB
Perl
Raw 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/change_event_cost_items.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,item_costing_event,description_workings_event',"",'','') ;
# my $cnt = 0 ;
foreach (sort keys %{$db{event_quotes_min}}) {
# last if $cnt > 100 ;
my $costing1 = $db{event_quotes_min}{$_}{item_costing_event} ;
my $costing2 = $db{event_quotes_min}{$_}{description_workings_event} ;
$costing1 =~ s/11/22/g if $costing1 =~ /11/ ; # Mobile Camera Operation - SSS [11] >>> Mobile S1 System - SSS[22]
$costing1 =~ s/18/23/g if $costing1 =~ /18/ ; # Mobile Camera Operation - AISA [18] >>> Mobile S1 System - AISA [23]
$costing1 =~ s/10/26/g if $costing1 =~ /10/ ; # Fixed Camera Operation [10] >>> Fixed System - SSS [26]
$costing1 =~ s/12/21/g if $costing1 =~ /12/ ; # Cricket Camera Operation [12] >>> Mobile Cricket System - SSS [21]
$costing1 =~ s/19/27/g if $costing1 =~ /19/ ; # Fixed Camera Operation - Linear [19] >>>> Fixed System - Linear - SSS [27]
$costing1 =~ s/20/28/g if $costing1 =~ /20/ ; # Mobile Camera Operation - Linear [20] >>> Mobile S1 System - Linear - SSS [28]
$costing2 =~ s/11/22/g if $costing2 =~ /11/ ; #
$costing2 =~ s/18/23/g if $costing2 =~ /18/ ; #
$costing2 =~ s/10/26/g if $costing2 =~ /10/ ; #
$costing2 =~ s/12/21/g if $costing2 =~ /12/ ; #
$costing2 =~ s/19/27/g if $costing2 =~ /19/ ; #
$costing2 =~ s/20/28/g if $costing2 =~ /20/ ; #
%i = () ;
$ignore{item_costing_event} = ($costing1 eq $db{event_quotes_min}{$_}{item_costing_event}) ? 1 : 0 ;
$ignore{description_workings_event} = ($costing2 eq $db{event_quotes_min}{$_}{description_workings_event}) ? 1 : 0 ;
$costing1 =~ s/;+$//g unless $ignore{item_costing_event} ;
$costing2 =~ s/;+$//g unless $ignore{description_workings_event} ;
# if ($costing1 ne $db{event_quotes_min}{$_}{item_costing_event} || $costing2 ne $db{event_quotes_min}{$_}{description_workings_event}) {
if ($costing1 ne $db{event_quotes_min}{$_}{item_costing_event} || $costing2 ne $db{event_quotes_min}{$_}{description_workings_event}) {
$i{item_costing_event} = $costing1 ;
$i{description_workings_event} = $costing2 ;
# print "\n UPDATE event_quotes_min SET item_costing_event = '$i{item_costing_event} FROM $db{event_quotes_min}{$_}{item_costing_event}', description_workings_event = '$i{description_workings_event} FROM $db{event_quotes_min}{$_}{description_workings_event}' WHERE id='$_'" ;
&common_debug("WAS item_costing_event=$db{event_quotes_min}{$_}{item_costing_event}, description_workings_event=$db{event_quotes_min}{$_}{description_workings_event}") ;
# &db_min_upd('event_quotes_min',"id='$_'") ;
# $cnt++ ;
}
}
} #-------------------------------------------------------------------------------
use db ;
use today ;
use common ;
use common_min ;