#!/usr/bin/perl

print "Content-type: text/html\n\n";

BEGIN { use lib '/usr/home/cfg' ; require push_inc ; }
    
use CGI::Carp qw(fatalsToBrowser);

require cfg ;

# my $referer = $ENV{HTTP_REFERER} ; exit unless $referer =~ m/itvadmin/iog ;

&today;

#------------------------------------------------------------------------------------------

@ARGV = split(/\\*\&/, $ENV{'QUERY_STRING'}); foreach $ARG (@ARGV) { ($par,$val) = split(/\=/,$ARG) ; $param{$par} = $val ; }

# https://itvadmin.co.za/cgi-bin/get/get/get_db_delete_temp_support.pl?start=2024-02-01 00:00:00&end=2024-02-28 00:00:00&debug=1
	
# our $debug = $param{debug} ; # our $username = 'rory' if $debug == 1 ;

#------------------------------------------------------------------------------------------

# our $testing = 1 ; 
# our $debug = 1 ; 

&delete ;

exit ;

sub delete {

	return unless $param{date} ; 
	return unless $param{row_cnt} ; 

	&db_min_ro('shift_operator_ids','1,temp_calibrator_support_shifts',"date='$param{date}'",'','1') ;

	%i = () ;
	my $row_cnt = 0 ; 
	
	foreach my $support_to_shift (split(/\|/,$db{shift_operator_ids}{1}{temp_calibrator_support_shifts})) {
		$row_cnt++ ;	
		if ($row_cnt ne $param{row_cnt}) {
			$i{temp_calibrator_support_shifts} .= qq~$support_to_shift|~ ;
		} else {
			$i{temp_calibrator_support_shifts} .= qq~~ ;
		}
	}

	chop $i{temp_calibrator_support_shifts} if $i{temp_calibrator_support_shifts} ;
	&db_min_upd("shift_operator_ids","`date`='$param{date}'") ; 		
	
} #------------------------------------------------------------------------------------------
 
use common ;
use session ;
use today ;

1;