#!/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 = 'analytics_ht_colors' ; our ($q) = CGI -> new() ; $iaction = $q -> param('iaction') || $action ; our $dialog = 1 ; #--------------------------------------------------------------------------------------------------------------------------------------------------------------------- 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') ; $i{name} = lc $i{name} ; $i{name} = ucfirst $i{name} ; &db_min_insert($table) ; } #------------------------------------------------------------------------------------------ sub validate { return ; # called from common_min_action my $exists = '' ; $i{name} = &common_fix_str($i{name}) ; # &db_min_ro($table,'id,name','','','') ; foreach my $id (keys %{$db{$table}}) { if (lc $db{$table}{$id}{name} eq lc $i{name}) { $exists = 1 ; } } if ($exists) { $alert = &common_min_alert('warning',"'$i{name}' AS AN HT COLOUR NAME ALREADY EXISTS!",'warning-sign') ; %col_name = () ; &common_min_add_screen; &screen1; } } #------------------------------------------------------------------------------------------ sub add_screen { $box_header_title = 'Add HT Colour' ; $hidden_action = 'save' ; $head_col_width = 2 ; } #------------------------------------------------------------------------------------------ sub add_db_fields { $ignore{iaction} = 1 ; $hidden{id} = 2 ; $hidden{sel_field} = 2 ; $required{name} = 1 ; $sort_field{1} = "name" ; $db{$table}{''}{sel_field} = $selectfield if $selectfield ; } #------------------------------------------------------------------------------------------ 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 { $trigger_jquery_raw .= qq~ for (let i = 1; i <= 10; i++) { if (!parent.\$("#fixtures_"+i).html()) { continue ; } parent.\$("#selectHt_colour_fixtures_"+i).append("").trigger("chosen:updated") ; } parent.BootstrapDialog.closeAll() ; ~; &common_min_dialog_save_screen ; } #------------------------------------------------------------------------------------------ use today ; use dialog ; use common ; 1;