157 lines
3.9 KiB
Perl
157 lines
3.9 KiB
Perl
|
|
#!/usr/bin/perl
|
||
|
|
|
||
|
|
BEGIN { use lib '/usr/home/cfg' ; require push_inc ; }
|
||
|
|
|
||
|
|
require cfg ;
|
||
|
|
|
||
|
|
print "Content-type: text/html\n\n";
|
||
|
|
|
||
|
|
&today ;
|
||
|
|
|
||
|
|
#---------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||
|
|
|
||
|
|
use DBI;
|
||
|
|
use CGI::Carp qw(fatalsToBrowser);
|
||
|
|
use CGI;
|
||
|
|
|
||
|
|
@ARGV = split(/\\*\&/, $ENV{'QUERY_STRING'});
|
||
|
|
$action = $ARGV[0] ;
|
||
|
|
$eventids = $ARGV[1] ;
|
||
|
|
$from_to = $ARGV[2] ;
|
||
|
|
|
||
|
|
our $updaterids = $eventids ;
|
||
|
|
our $dialog = 1 ;
|
||
|
|
|
||
|
|
# our $debug = 1 ;
|
||
|
|
our $table = 'logistics_items' ;
|
||
|
|
|
||
|
|
our ($q) = CGI -> new() ;
|
||
|
|
$iaction = $q -> param('iaction') || $action ;
|
||
|
|
|
||
|
|
#--------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||
|
|
|
||
|
|
if ($iaction eq 'add') {
|
||
|
|
&common_min_add_screen;
|
||
|
|
&screen1;
|
||
|
|
}
|
||
|
|
|
||
|
|
if ($iaction eq 'save') {
|
||
|
|
&common_min_load_params ;
|
||
|
|
&insert ;
|
||
|
|
&screen2 ;
|
||
|
|
}
|
||
|
|
|
||
|
|
&common_min_action;
|
||
|
|
|
||
|
|
exit ;
|
||
|
|
|
||
|
|
#------------------------------------------------------------------------------------------
|
||
|
|
|
||
|
|
sub insert {
|
||
|
|
|
||
|
|
&add_db_fields ; # $i{last_edited_by} = $userid ; $i{last_updated} = "$now_ccyy_mm_dd $now_hour:$now_min:$now_sec" ;
|
||
|
|
|
||
|
|
&validate ;
|
||
|
|
|
||
|
|
$ignore{sel_field} = 1 ;
|
||
|
|
|
||
|
|
# $i{id} = &db_min_get_max($table,'id') ;
|
||
|
|
|
||
|
|
&db_min_insert($table) ;
|
||
|
|
|
||
|
|
} #------------------------------------------------------------------------------------------
|
||
|
|
|
||
|
|
sub validate {
|
||
|
|
|
||
|
|
# called from common_min_action
|
||
|
|
|
||
|
|
my $exists = '' ;
|
||
|
|
|
||
|
|
$i{name} = &common_fix_str($i{name}) ;
|
||
|
|
|
||
|
|
&db_min_ro($table,'*',"name='$i{name}'",'','') ;
|
||
|
|
|
||
|
|
foreach my $id (keys %{$db{$table}}) {
|
||
|
|
if ($db{$table}{$id}{name} eq $i{name}) {
|
||
|
|
$exists = 1 ;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
if ($exists) {
|
||
|
|
$alert = &common_min_alert('warning',"ITEM ALREADY EXISTS!",'warning-sign') ;
|
||
|
|
%col_name = () ;
|
||
|
|
&common_min_add_screen;
|
||
|
|
&screen1;
|
||
|
|
}
|
||
|
|
|
||
|
|
} #------------------------------------------------------------------------------------------
|
||
|
|
|
||
|
|
sub add_screen {
|
||
|
|
|
||
|
|
$box_header_title = 'Add Item' ;
|
||
|
|
$hidden_action = 'save' ;
|
||
|
|
$head_col_width = 2 ;
|
||
|
|
|
||
|
|
} #------------------------------------------------------------------------------------------
|
||
|
|
|
||
|
|
sub add_db_fields {
|
||
|
|
|
||
|
|
$ignore{iaction} = 1 ;
|
||
|
|
$ignore{id} = 1 ;
|
||
|
|
$hidden{sel_field} = 2 ;
|
||
|
|
$required{name} = 1 ;
|
||
|
|
# $eventids =~ s/\,/\,#selectItem_$from_to\_/g ;
|
||
|
|
my $abc = ",#selectItem_$from_to\_" ;
|
||
|
|
$eventids =~ s/\,/$abc/g ;
|
||
|
|
$eventids = qq~#selectItem_$from_to\_$eventids~ ;
|
||
|
|
$eventids = substr($eventids,1) ;
|
||
|
|
|
||
|
|
$db{$table}{''}{sel_field} = $eventids if $eventids ;
|
||
|
|
|
||
|
|
} #------------------------------------------------------------------------------------------
|
||
|
|
|
||
|
|
sub thead {
|
||
|
|
|
||
|
|
&common_min_thead ;
|
||
|
|
|
||
|
|
} #-------------------------------------------------------------------------------
|
||
|
|
|
||
|
|
sub screen1 {
|
||
|
|
|
||
|
|
$trigger_jquery_raw .= qq~
|
||
|
|
\$('#btn-close-customer').click(function (e) {
|
||
|
|
parent.BootstrapDialog.closeAll() ;
|
||
|
|
});~ ;
|
||
|
|
|
||
|
|
&common_min_dialog_load_screen ;
|
||
|
|
|
||
|
|
} #------------------------------------------------------------------------------------------
|
||
|
|
|
||
|
|
sub screen2 {
|
||
|
|
|
||
|
|
&db_min_ro($table,'1,id',"`name`='$i{name}'",'','') ;
|
||
|
|
my $id = $db{$table}{1}{id} ;
|
||
|
|
my $name = $i{name} ;
|
||
|
|
|
||
|
|
my $def = ",#checkboxUpdate_$from_to\_" ;
|
||
|
|
$updaterids =~ s/\,/$def/g ;
|
||
|
|
$updaterids = qq~#checkboxUpdate_$from_to\_$updaterids~ ;
|
||
|
|
$updaterids = substr($updaterids,1) ;
|
||
|
|
|
||
|
|
$trigger_jquery_raw .= qq~
|
||
|
|
parent.\$("$i{sel_field}").append("<option value='$id'>$name</option>") ;
|
||
|
|
// parent.\$("$eventids").val('$new_row_id').trigger('change'); // this must stay commented out for multi-selects, otherwise it removes existing selected options
|
||
|
|
parent.\$("$eventids").trigger("chosen:updated");
|
||
|
|
parent.\$("updaterids").prop("checked",true) ;
|
||
|
|
parent.BootstrapDialog.closeAll() ;
|
||
|
|
~;
|
||
|
|
|
||
|
|
&common_min_dialog_save_screen ;
|
||
|
|
|
||
|
|
} #------------------------------------------------------------------------------------------
|
||
|
|
|
||
|
|
use today ;
|
||
|
|
use dialog ;
|
||
|
|
use common ;
|
||
|
|
|
||
|
|
1;
|