#!/usr/bin/perl BEGIN { use lib '/usr/home/cfg' ; require push_inc ; } require cfg ; use CGI::Carp qw(fatalsToBrowser); use DBI; use CGI; use POSIX; #--------------------------------------------------------------------------------------------------------------------------------------------------------------------- my ($q) = CGI -> new() ; $iaction = $q -> param('iaction') || '' ; #--------------------------------------------------------------------------------------------------------------------------------------------------------------------- print "Content-type: text/html\n\n"; &today; if ($iaction eq ''){ &display_screen ; } if ($iaction eq 'search'){ &search_ifields ; &db_load_airports ; &db_get_supplier_opts ; $supplier_invoice = 1 ; &db_load_journeys ; &search_waybills ; &search_waybills_no_parcels ; # must come after &display_screen ; } exit ; #-------------------------------------------------------------------------------------------- sub search_ifields { for my $p ($q->param) { my $val = $q->param($p); $isrch{$p} = $val ; } @origins = split(/\,/,$isrch{'origins'}) ; @destinations = split(/\,/,$isrch{'destinations'}) ; foreach (@origins) { my ($origin_id,$origin_name) = split(/\:/,$_) ; if ($isrch{'iallexceptorig'}){ $add_destination_sql .= qq( (waybills.originid <> '$origin_id') AND) ; push @search_results, "Origin <> $origin_name" ; } else { $add_origin_sql .= qq((waybills.originid = '$origin_id') OR ) ; push @search_results, "Origin = $origin_name" ; } } if ($add_origin_sql) { $add_origin_sql = substr($add_origin_sql,0,-4); $add_sql .= qq( AND ($add_origin_sql)) ; } foreach (@destinations) { our ($dest_id,$dest_name) = split(/\:/,$_) ; $dest_names .= $dest_name . ', ' ; if ($isrch{'iallexceptdest'}){ $add_destination_sql .= qq( (waybills.destid <> '$dest_id') AND) ; push @search_results, "Destination <> $dest_name" ; } else { $add_destination_sql .= qq((waybills.destid = '$dest_id') OR ) ; push @search_results, "Destination = $dest_name" ; } } $dest_names = substr($dest_names,0,-2); if ($add_destination_sql) { $add_destination_sql = substr($add_destination_sql,0,-4); $add_sql .= qq( AND ($add_destination_sql)) ; } if ($isrch{'inopod'}){ push @search_results, "POD Date = ''" ; $add_sql .= qq( AND (poddate = '0000-00-00') ) ; $print_pdf_butt = qq( Print) ; $add_search_print_col = 1 ; } $search_results_msg = join(', ', @search_results) ; $search_results_param = $search_results_msg ; $search_results_param =~ s/, POD Date = ''//gi ; $search_results_param =~ s/'//gi ; unless ($search_results_msg) { $error = qq(ENTER AT LEAST ONE SEARCH PARAMETER) ; &display_screen ; } } #------------------------------------------------------------------------------------------ sub search_waybills { &db_open_ro ; my $select = &db_waybill_list_select ; my $sql = qq($select FROM waybills, parcels WHERE parcels.waybillno = waybills.waybillno $add_sql ORDER BY waybills.capturedate DESC $limit) ; # &common_debug($sql) ; my $sth = $dbh->prepare($sql) ; $sth -> execute() or die "Could not execute SQL statement $sql ... maybe invalid? $!"; $id_array_ref = $sth->fetchall_arrayref(); $sth->finish(); &db_close_conn ; &db_process_waybill_list ; } #------------------------------------------------------------------------------------------ sub search_waybills_no_parcels { &db_open_ro ; # if (substr($add_sql,4) eq ' AND') { $add_sql = substr($add_sql,4) ; } $add_sql = substr($add_sql,5) ; my $sql = qq(SELECT * FROM waybills WHERE $add_sql ORDER BY waybills.capturedate DESC $limit) ; # &common_debug($sql) ; exit ; my $sth = $dbh->prepare($sql) ; $sth -> execute() or die "Could not execute SQL statement $sql ... maybe invalid? $!"; my $id_array_ref = $sth->fetchall_arrayref(); $sth->finish(); &db_close_conn ; foreach $row (@$id_array_ref) { &db_waybills_fields; if ($contents{$wb{waybillno}}) { next ; } &db_process_wb_list_tbody; } } #------------------------------------------------------------------------------------------ sub display_screen { &get_opts ; if ($add_search_print_col) { $print_extra_th = qq(
) ; } if ($tbody) { $print_results_table .= qq(| HAWB | COLDATE | INV | POD | MAWB | FLAGS | BILL TO | SENDER | ORIG | CONSIGNEE | DEST | CONTENTS | PCS | KG | SERVICE | $print_pdf_butt | $print_extra_th
|---|