aisa/scripts/get/get_dates_from_event_quote.pl

70 lines
2.0 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 ; }
print "Content-type: text/html\n\n";
use CGI::Carp qw(fatalsToBrowser);
use Fcntl qw(:flock);
use JSON::Repair ':all';
require cfg ;
#------------------------------------------------------------------------------------------
@ARGV = split(/\\*\&/, $ENV{'QUERY_STRING'});
foreach $ARG (@ARGV) { ($par,$val) = split(/\=/,$ARG) ; $val =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $param{$par} = $val ; }
# my $json_type = $param{json_type} ;
# e.g. https://itvadmin.co.za/cgi-bin/scripts/get/get_typeahead_json.pl?json_type=additional_services
# our $debug = 1 ;
#------------------------------------------------------------------------------------------
$json = '' ;
&db_open_upd ;
$db_ignore_open_close = 1 ;
&load_json ;
$db_ignore_open_close = 0 ;
&db_close_conn ;
print $json ;
exit ;
#------------------------------------------------------------------------------------------
sub load_json {
return unless $param{event_quote_id} ;
our @months = ("","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec") ;
$param{start_date_time} = &common_min_date_as_string($param{start_date_time}) ;
$param{end_date_time} = &common_min_date_as_string($param{end_date_time}) ;
&db_min_ro('event_quotes','1,date_from,date_to',"id = '$param{event_quote_id}'",'','') ;
$json = '[' ;
$db{event_quotes}{1}{date_from} = &common_min_date_as_string($db{event_quotes}{1}{date_from}) ;
$db{event_quotes}{1}{date_to} = &common_min_date_as_string($db{event_quotes}{1}{date_to}) ;
$json .= qq~{"date_from":"$db{event_quotes}{1}{date_from}","date_to":"$db{event_quotes}{1}{date_to}","start_date_time":"$param{start_date_time}","end_date_time":"$param{end_date_time}"}~ ;
if ($json =~ /\^,/) { $json = substr($json,0,-1) ; }
$json =~ s/\\//g ;
$json .= ']' ;
} #------------------------------------------------------------------------------------------
use db ;
use common ;
use common_min ;
1;