83 lines
1.7 KiB
Perl
83 lines
1.7 KiB
Perl
#!/usr/bin/perl
|
|
|
|
print "Content-type: text/html\n\n";
|
|
|
|
BEGIN { use lib '/usr/home/cfg' ; require push_inc ; }
|
|
|
|
require cfg ;
|
|
|
|
use DBI;
|
|
use CGI::Carp qw(fatalsToBrowser);
|
|
|
|
#------------------------------------------------------------------------------------------
|
|
|
|
@ARGV = split(/\\*\&/, $ENV{'QUERY_STRING'});
|
|
|
|
$id = $ARGV[0] ;
|
|
|
|
#------------------------------------------------------------------------------------------
|
|
|
|
&get_town_waybills_details ;
|
|
&delete_town ;
|
|
|
|
print $json ;
|
|
|
|
exit ;
|
|
|
|
#------------------------------------------------------------------------------------------
|
|
|
|
sub get_town_waybills_details {
|
|
|
|
unless ($id) { return ; }
|
|
|
|
&db_open_ro ;
|
|
|
|
my $sql = qq(SELECT * FROM waybills WHERE originid = '$id' or destid = '$id') ;
|
|
|
|
my $sth = $dbh->prepare($sql) ;
|
|
|
|
$sth -> execute() or die "Could not execute SQL statement $sql ... maybe invalid? $!";
|
|
my $waybill_array_ref = $sth->fetchall_arrayref();
|
|
|
|
$sth->finish();
|
|
|
|
&db_close_conn ;
|
|
|
|
$json = '[' ;
|
|
|
|
foreach $row (@$waybill_array_ref) {
|
|
|
|
&db_waybills_fields ;
|
|
|
|
$do_not_delete = 1 ;
|
|
|
|
$json .= qq(
|
|
{"waybillno":"$wb{'waybillno'}"},) ;
|
|
}
|
|
|
|
$json = substr($json,0,-1) ;
|
|
$json =~ s/\\//g ;
|
|
$json .= ']' ;
|
|
|
|
} #------------------------------------------------------------------------------------------
|
|
|
|
sub delete_town {
|
|
|
|
unless ($id) { return ; }
|
|
if ($do_not_delete) { return ; }
|
|
|
|
&db_open_upd ;
|
|
|
|
$sql = qq(DELETE FROM towns WHERE townid = '$id') ;
|
|
|
|
$sth = $dbh -> do ($sql) or die "could not execute :<BR>$sql<BR>$!" ;
|
|
|
|
&db_close_conn ;
|
|
|
|
$json = qq([{"deleted":"1"}]) ;
|
|
|
|
} #------------------------------------------------------------------------------------------
|
|
|
|
use db ;
|
|
|
|
1; |