168 lines
3.7 KiB
Perl
168 lines
3.7 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] ;
|
|
$selectfield = $ARGV[1] ;
|
|
|
|
# our $debug = 1 ;
|
|
our $table = 'customers' ;
|
|
|
|
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{user_id} = $userid ;
|
|
|
|
$i{id} = &db_min_get_max($table,'id') ;
|
|
|
|
$i{date_time} = "$now_ccyy_mm_dd $now_hour:$now_min:$now_sec" ;
|
|
$i{last_updated} = "$now_ccyy_mm_dd $now_hour:$now_min:$now_sec" ;
|
|
|
|
&db_min_insert($table) ;
|
|
|
|
} #------------------------------------------------------------------------------------------
|
|
|
|
sub add_screen {
|
|
|
|
$box_header_title = 'Add Customer' ;
|
|
$hidden_action = 'save' ;
|
|
$head_col_width = 2 ;
|
|
|
|
} #------------------------------------------------------------------------------------------
|
|
|
|
sub add_db_fields {
|
|
|
|
&common_customer_hidden_db_fields ;
|
|
|
|
$hidden{id} = 2 ;
|
|
|
|
} #------------------------------------------------------------------------------------------
|
|
|
|
sub thead {
|
|
|
|
&common_min_thead ;
|
|
|
|
} #-------------------------------------------------------------------------------
|
|
|
|
sub screen1 {
|
|
|
|
&dialog_common ;
|
|
|
|
print <<ENDOFTEXT;
|
|
$dialog{'common'}{'head'}
|
|
|
|
<div id="content" class="col-lg-12 col-sm-12">
|
|
<!-- content starts -->
|
|
|
|
$alert
|
|
|
|
<div class="row">
|
|
<div class="box col-md-12">
|
|
<div class="box-inner">
|
|
<div class="box-content">
|
|
$print_box_content_rows
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div><!--/row-->
|
|
|
|
</div><!--/fluid-row-->
|
|
|
|
</div><!--/.fluid-container-->
|
|
|
|
<!-- external javascript -->
|
|
|
|
<script src="$useropts{'bower_components'}/chosen/chosen.jquery.min.js"></script>
|
|
<script src="$useropts{'bower_components'}/bootstrap/dist/js/bootstrap.min.js"></script>
|
|
<script src="$useropts{'js'}/jquery.form-validator.min.js"></script>
|
|
|
|
<script>
|
|
\$.validate();
|
|
|
|
\$('#btn-close-customer').click(function (e) {
|
|
parent.BootstrapDialog.closeAll() ;
|
|
});
|
|
|
|
</script>
|
|
|
|
</body>
|
|
</html>
|
|
ENDOFTEXT
|
|
#
|
|
|
|
exit;
|
|
|
|
} #------------------------------------------------------------------------------------------
|
|
|
|
sub screen2 {
|
|
|
|
print <<ENDOFTEXT;
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>ITV Admin</title>
|
|
<script src="$useropts{'bower_components'}/jquery/jquery.min.js"></script>
|
|
</head>
|
|
<body>
|
|
<script>
|
|
|
|
\$(function () {
|
|
parent.\$("#$selectfield").append("<option SELECTED value='$i{id}:$i{contact_name}:$i{contact_email}:$i{phone}:$i{physical_address}'>$i{name}</option>");
|
|
parent.\$('#$selectfield').val('$i{id}:$i{contact_name}:$i{contact_email}:$i{phone}:$i{physical_address}').trigger('change');
|
|
parent.\$('#$selectfield').trigger("chosen:updated");
|
|
parent.BootstrapDialog.closeAll() ;
|
|
});
|
|
|
|
</script>
|
|
</body>
|
|
</html>
|
|
ENDOFTEXT
|
|
#
|
|
|
|
exit ;
|
|
|
|
} #------------------------------------------------------------------------------------------
|
|
|
|
use today ;
|
|
use dialog ;
|
|
use common ;
|
|
|
|
1; |