aisa/scripts/get/get_db_cameras.pl

59 lines
1.3 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 ;
&today ;
#------------------------------------------------------------------------------------------
@ARGV = split(/\\*\&/, $ENV{'QUERY_STRING'});
foreach $ARG (@ARGV) { ($par,$val) = split(/\=/,$ARG) ; $param{$par} = $val ; }
# https://itvadmin.co.za/cgi-bin/scripts/get/get_db_cameras.pl
our $debug = 1 if $param{debug} == 1 ;
#------------------------------------------------------------------------------------------
print "Content-type: text/html\n\n";
exit unless $param{clientid} ;
use DBI;
use CGI::Carp qw(fatalsToBrowser);
&get_db_cameras ;
print $json ;
exit ;
#------------------------------------------------------------------------------------------
sub get_db_cameras {
$json = '[' ;
my $t1 = 'cameras' ;
my $t2 = 'quotes' ;
my $tables = "$t1,$t2" ;
&db_min_ro($tables,"$t1.id,$t1.camera_nr,$t1.serial_nr","$t1.quote_nr = $t2.quote_nr AND $t2.quote_to = '$param{clientid}'",'','') ;
foreach my $id (keys %{$db{$tables}}) {
$json .= qq~{"id":"$id","camera_nr":"$db{$tables}{$id}{camera_nr}","serial_nr":"$db{$tables}{$id}{serial_nr}"},~ ;
}
chop $json if $json ;
$json .= ']' ;
} #------------------------------------------------------------------------------------------
use db ;
use today ;
use common ;
1;