702 lines
26 KiB
Perl
702 lines
26 KiB
Perl
|
|
#!/usr/bin/perl
|
||
|
|
|
||
|
|
BEGIN { use lib '/usr/home/cfg' ; require push_inc ; }
|
||
|
|
|
||
|
|
require cfg ;
|
||
|
|
|
||
|
|
print "Content-type: text/html\n\n";
|
||
|
|
|
||
|
|
# unless ($useropts{it}{$username}) { print "<<<<<<<<<<<< MAINTENANCE IN PROGRESS >>>>>>>>>" ; exit ; }
|
||
|
|
|
||
|
|
#---------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||
|
|
|
||
|
|
use CGI::Carp qw(fatalsToBrowser);
|
||
|
|
use CGI;
|
||
|
|
use Mail::Sendmail;
|
||
|
|
use Fcntl qw(:flock);
|
||
|
|
use File::Copy;
|
||
|
|
use File::Basename;
|
||
|
|
use Date::Calc qw(:all);
|
||
|
|
use Excel::Writer::XLSX;
|
||
|
|
use Time::Piece ;
|
||
|
|
use LWP::UserAgent;
|
||
|
|
use XML::LibXML;
|
||
|
|
use LWP::Simple;
|
||
|
|
use XML::Simple ;
|
||
|
|
use JSON ;
|
||
|
|
|
||
|
|
&today;
|
||
|
|
|
||
|
|
#---------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||
|
|
|
||
|
|
@ARGV = split(/\\*\&/, $ENV{'QUERY_STRING'});
|
||
|
|
$action = $ARGV[0] ;
|
||
|
|
|
||
|
|
our ($q) = CGI -> new() ;
|
||
|
|
our $iaction = $q -> param('iaction') || $action ;
|
||
|
|
our $isaved = $q -> param('isaved') || '' ;
|
||
|
|
|
||
|
|
$iaction = 'report' unless $iaction ;
|
||
|
|
|
||
|
|
# our $debug = 1 ;
|
||
|
|
# our $testing = 1 ;
|
||
|
|
# our $testdcd = 1 ;
|
||
|
|
|
||
|
|
# if ($username ne 'handre') {
|
||
|
|
# print "<< MAINTENANCE IN PROGRESS >>" ; exit ;
|
||
|
|
# }
|
||
|
|
|
||
|
|
# -------- page opts --------------------------------------------------------------------------------------------------------------------------------------------------
|
||
|
|
|
||
|
|
&page_opts ;
|
||
|
|
|
||
|
|
#---------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||
|
|
|
||
|
|
our $srchscr = 1 ;
|
||
|
|
|
||
|
|
if ($iaction eq 'save') {
|
||
|
|
|
||
|
|
&db_open_upd ;
|
||
|
|
our $db_ignore_open_close = 1 ; # do one open and one close instead of repeating it
|
||
|
|
&common_min_load_params ;
|
||
|
|
&report_ifields;
|
||
|
|
&update ;
|
||
|
|
$iaction = 'report' ;
|
||
|
|
&list_screen ;
|
||
|
|
exit if ($username eq 'handre' || $username eq 'rory') && $testing ;
|
||
|
|
$s{no} = 1 ;
|
||
|
|
&screen2 ;
|
||
|
|
$db_ignore_open_close = 0 ; # do one open and one close instead of repeating it
|
||
|
|
&db_close_conn ;
|
||
|
|
|
||
|
|
} elsif ($iaction eq 'delete') {
|
||
|
|
|
||
|
|
&db_open_upd ;
|
||
|
|
our $db_ignore_open_close = 1 ; # do one open and one close instead of repeating it
|
||
|
|
&common_min_load_params ;
|
||
|
|
&report_ifields;
|
||
|
|
&delete ;
|
||
|
|
&list_screen ;
|
||
|
|
exit if ($username eq 'handre' || $username eq 'rory') && $testing ;
|
||
|
|
&screen3;
|
||
|
|
&redirect_screen;
|
||
|
|
$db_ignore_open_close = 0 ; # do one open and one close instead of repeating it
|
||
|
|
&db_close_conn ;
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
&db_open_ro ;
|
||
|
|
our $db_ignore_open_close = 1 ; # do one open and one close instead of repeating it
|
||
|
|
|
||
|
|
&report_screen if $iaction eq '' ;
|
||
|
|
|
||
|
|
if ($iaction eq 'report') {
|
||
|
|
&common_min_load_params ;
|
||
|
|
&report_ifields;
|
||
|
|
&list_screen ;
|
||
|
|
&screen3;
|
||
|
|
}
|
||
|
|
|
||
|
|
&common_min_action;
|
||
|
|
$db_ignore_open_close = 0 ; # do one open and one close instead of repeating it
|
||
|
|
&db_close_conn ;
|
||
|
|
|
||
|
|
exit;
|
||
|
|
|
||
|
|
#------------------------------------------------------------------------------------------
|
||
|
|
|
||
|
|
sub delete {
|
||
|
|
|
||
|
|
&db_min_delete($table,"`id`='$i{id}'") ;
|
||
|
|
|
||
|
|
} #------------------------------------------------------------------------------------------
|
||
|
|
|
||
|
|
sub update {
|
||
|
|
|
||
|
|
my $update_something = 0 ;
|
||
|
|
|
||
|
|
foreach (keys %i) {
|
||
|
|
next if !$i{$_} and substr($_,0,6) eq 'update' ;
|
||
|
|
local @abc = split(/\_/,$_) ;
|
||
|
|
if (substr($_,0,6) eq 'update') {
|
||
|
|
$seen_site_survey_id{$abc[-1]} = 1 if $abc[-1] ne 'row' ;
|
||
|
|
$update_something = 1 ;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
local @site_survey_ids = () ;
|
||
|
|
foreach (keys %seen_site_survey_id) {
|
||
|
|
push @site_survey_ids , "`id` = '$_'" ;
|
||
|
|
}
|
||
|
|
local $e_q_sql = join (" OR ",@site_survey_ids) ;
|
||
|
|
|
||
|
|
return unless $update_something ;
|
||
|
|
|
||
|
|
&db_min_ro($table,'*',"$e_q_sql",'','') if $e_q_sql ;
|
||
|
|
|
||
|
|
my %ii = () ; my %iii = %i ;
|
||
|
|
foreach (keys %i) {
|
||
|
|
local @a = split("_",$_) ;
|
||
|
|
my $row_id = $a[-1] ;
|
||
|
|
$row_id = 'add_row' if $row_id eq 'row' ;
|
||
|
|
next unless $i{"update_$row_id"} ;
|
||
|
|
|
||
|
|
if (substr($_,0,6) eq 'venue_') {
|
||
|
|
$ii{$a[-1]}{venue} = $i{$_} ;
|
||
|
|
} elsif (substr($_,0,6) eq 'field_') {
|
||
|
|
$ii{$a[-1]}{field} = $i{$_} ;
|
||
|
|
} elsif (substr($_,0,6) eq 'sport_') {
|
||
|
|
$ii{$a[-1]}{sport_ids} = $i{$_} ;
|
||
|
|
} elsif (substr($_,0,9) eq 'date_due_') {
|
||
|
|
$ii{$a[-1]}{date_due} = $i{$_} ;
|
||
|
|
} elsif (substr($_,0,25) eq 'event_operations_manager_') {
|
||
|
|
$ii{$a[-1]}{event_operations_manager_id} = $i{$_} ;
|
||
|
|
} elsif (substr($_,0,7) eq 'status_') {
|
||
|
|
$ii{$a[-1]}{status_id} = $i{$_} ;
|
||
|
|
} elsif (substr($_,0,8) eq 'comment_') {
|
||
|
|
$ii{$a[-1]}{comment} = $i{$_} ;
|
||
|
|
} elsif (substr($_,0,8) eq 'outcome_') {
|
||
|
|
$ii{$a[-1]}{outcome_id} = $i{$_} ;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
my %upd_site_survey = () ;
|
||
|
|
|
||
|
|
foreach my $site_survey_id (sort keys %ii) {
|
||
|
|
%i = () ;
|
||
|
|
$upd_site_survey{$site_survey_id} = 0 ;
|
||
|
|
foreach my $col (keys %{$ii{$site_survey_id}}) {
|
||
|
|
next if !$ii{$site_survey_id}{$col} && !$db{$table}{$site_survey_id}{$col} ;
|
||
|
|
next if $ii{$site_survey_id}{$col} eq $db{$table}{$site_survey_id}{$col} ;
|
||
|
|
$upd_site_survey{$site_survey_id} = 1 ;
|
||
|
|
$i{$col} = qq~$ii{$site_survey_id}{$col}~ ;
|
||
|
|
}
|
||
|
|
next unless $upd_site_survey{$site_survey_id} ;
|
||
|
|
|
||
|
|
if ($site_survey_id eq 'row') {
|
||
|
|
$i{id} = &db_min_get_max($table,'id') ;
|
||
|
|
&db_min_insert($table) ;
|
||
|
|
} else {
|
||
|
|
&db_min_upd($table,"`id`='$site_survey_id'") ;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
%i = %iii ;
|
||
|
|
|
||
|
|
} #------------------------------------------------------------------------------------------
|
||
|
|
|
||
|
|
sub report_screen {
|
||
|
|
|
||
|
|
# our $lcol = 3 ;
|
||
|
|
# our $fcol = 5 ;
|
||
|
|
|
||
|
|
# &common_min_select_opts('client_id','customers','name',$i{client_id},'') ;
|
||
|
|
# &common_min_select_opts('organisation_ids','organisations','name','','','','','','','','name') ;
|
||
|
|
# &common_min_select_opts('supplier_id','logistics_suppliers','supplier','','','','','','','','supplier') ;
|
||
|
|
# &common_min_select_opts('region_id','regions','name','','','code','','','','','name') ;
|
||
|
|
|
||
|
|
# local %status_hash = (1 =>"Booked",2 => "Pending",3=>"In Transit",4 =>"Delivered") ;
|
||
|
|
# $selected{$i{status_id}} = "SELECTED" if $i{status_id} ;
|
||
|
|
# for (1 .. 4) {
|
||
|
|
# $opts{status_id} .= qq~<option value="$_" $selected{$_}>$status_hash{$_}</option>~ ;
|
||
|
|
# }
|
||
|
|
|
||
|
|
# $preferred_title{organisation_ids} = "Venue" ;
|
||
|
|
|
||
|
|
$print_box_content_rows .= &common_min_forms_start('report') ;
|
||
|
|
|
||
|
|
# $print_box_content_rows .= &common_min_form_select('client_id',$i{client_id}) ;
|
||
|
|
# $print_box_content_rows .= &common_min_form_datepicker('date_from',"$now_year-$now_mm-$now_dd") ; #unless $i{date_from} ;
|
||
|
|
# $print_box_content_rows .= &common_min_form_select('organisation_ids','') ;
|
||
|
|
# $print_box_content_rows .= &common_min_form_select('supplier_id','') ;
|
||
|
|
# $print_box_content_rows .= &common_min_form_select('status_id','') ;
|
||
|
|
# $print_box_content_rows .= &common_min_form_select('region_id','') ;
|
||
|
|
|
||
|
|
$print_box_content_rows .= &common_min_forms_end('','','report') ;
|
||
|
|
|
||
|
|
&common_min_search_screen ;
|
||
|
|
|
||
|
|
} #-------------------------------------------------------------------------------
|
||
|
|
|
||
|
|
sub report_ifields {
|
||
|
|
|
||
|
|
# # &load_search_vars ;
|
||
|
|
|
||
|
|
# # if ($i{region_id}) {
|
||
|
|
# # push @report_sql, "`region_id` = '$i{region_id}'" ;
|
||
|
|
# # push @report_results, "Region = `$db{regions}{$i{region_id}}{name} [$db{regions}{$i{region_id}}{code}]`" ;
|
||
|
|
# # }
|
||
|
|
|
||
|
|
# # $report_results_msg = uc join(', ', @report_results) ;
|
||
|
|
|
||
|
|
# # if (not $report_results_msg) {
|
||
|
|
# # $error = qq~ENTER AT LEAST ONE SEARCH PARAMETER~ ;
|
||
|
|
# # &report_screen;
|
||
|
|
# # } else {
|
||
|
|
# # $isaved = qq~SELECT WHERE $report_results_msg~ ;
|
||
|
|
# # }
|
||
|
|
|
||
|
|
# # our $srch_where_sql = join(' AND ',@report_sql) ;
|
||
|
|
|
||
|
|
} #------------------------------------------------------------------------------------------
|
||
|
|
|
||
|
|
sub load_search_vars {
|
||
|
|
|
||
|
|
} #------------------------------------------------------------------------------------------
|
||
|
|
|
||
|
|
sub load_list_vars {
|
||
|
|
|
||
|
|
my ($where) = @_ ;
|
||
|
|
|
||
|
|
&db_min_ro($table,"*","$where",'','') ;
|
||
|
|
|
||
|
|
$opts{status_id} .= qq~<option value='2'>Complete</option>~ ;
|
||
|
|
$opts{status_id} .= qq~<option value='1'>Pending</option>~ ;
|
||
|
|
|
||
|
|
&db_min_ro('users','id,username',"user_type = 'casual_c'",'','') ;
|
||
|
|
|
||
|
|
foreach (sort {$db{users}{$a}{username} cmp $db{users}{$b}{username}} keys %{$db{users}}) {
|
||
|
|
next if substr($db{users}{$_}{username},0,4) eq 'rory' || substr($db{users}{$_}{username},0,6) eq 'handre' ;
|
||
|
|
$opts{event_operations_manager} .= qq~<option value='$_'>$db{users}{$_}{username}</option>~ ;
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
# $opts{event_operations_manager} .= qq~<option value='1'>Benji</option>~ ;
|
||
|
|
# $opts{event_operations_manager} .= qq~<option value='2'>Blaine</option>~ ;
|
||
|
|
# $opts{event_operations_manager} .= qq~<option value='3'>Seb</option>~ ;
|
||
|
|
# $opts{event_operations_manager} .= qq~<option value='4'>Tristan</option>~ ;
|
||
|
|
# $opts{event_operations_manager} .= qq~<option value='5'>Vusi</option>~ ;
|
||
|
|
# $opts{event_operations_manager} .= qq~<option value='44'>Jodi</option>~ ;
|
||
|
|
|
||
|
|
&db_min_ro('sport_types','*','','','') ; my $other_id = 0 ;
|
||
|
|
|
||
|
|
foreach (sort {$db{sport_types}{$a}{name} cmp $db{sport_types}{$b}{name}} keys %{$db{sport_types}}) {
|
||
|
|
if ($db{sport_types}{$_}{name} eq 'Rugby' || $db{sport_types}{$_}{name} eq 'Hockey' || $db{sport_types}{$_}{name} eq 'Netball' || $db{sport_types}{$_}{name} eq 'Soccer' || $db{sport_types}{$_}{name} eq 'Basketball' || $db{sport_types}{$_}{name} eq 'Water Polo' || $db{sport_types}{$_}{name} eq 'Indoor Center' || $db{sport_types}{$_}{name} eq 'Tennis' || $db{sport_types}{$_}{name} eq 'Cricket') {
|
||
|
|
$opts{sport} .= qq~<option value='$_'>$db{sport_types}{$_}{name}</option>~ ;
|
||
|
|
} elsif ($db{sport_types}{$_}{name} eq 'Other') {
|
||
|
|
$other_id = $_ ;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
$opts{sport} .= qq~<option value='$other_id'>Other</option>~ ;
|
||
|
|
|
||
|
|
} #------------------------------------------------------------------------------------------
|
||
|
|
|
||
|
|
sub list_screen {
|
||
|
|
|
||
|
|
$print_box_content_rows .= &common_min_forms_start("$lcpage") ;
|
||
|
|
|
||
|
|
&load_list_vars($srch_where_sql) ;
|
||
|
|
|
||
|
|
$fcol = 12 ;
|
||
|
|
|
||
|
|
our @sql_col_display = ("venue","field","sport","date_allocated","date_due","event_operations_manager","status_id","outcome","comment") ;
|
||
|
|
|
||
|
|
our $xlsx_title_heading = "Mobile Site Survey Report" ;
|
||
|
|
our $xlsxdir = "mobile_site_survey" ;
|
||
|
|
our $xlsxreportname = "Mobile_Site_Survey_Report" ;
|
||
|
|
|
||
|
|
&report_xlsx_export_header("$xlsxreportname",$xlsxdir,'',$xlsx_title_heading) ;
|
||
|
|
|
||
|
|
push @sql_col_display,"update" ;
|
||
|
|
push @sql_col_display,"" ;
|
||
|
|
|
||
|
|
my @rev_sql_col_display = reverse @sql_col_display ;
|
||
|
|
|
||
|
|
foreach (@rev_sql_col_display) { $lastchild++ ; $last_child{$_} = $lastchild ; } # &common_debug("last-child : $_ [$last_child{$_}]");
|
||
|
|
|
||
|
|
$xlsxrow-- ;
|
||
|
|
|
||
|
|
our $current_date = int("$now_year$now_mm$now_dd") ; our $found_editable = 0 ;
|
||
|
|
|
||
|
|
our %seen_field_id = () ; our %all_location_ids_per_system = () ; our $all_ids = qq~~ ;
|
||
|
|
|
||
|
|
local @month_names = ("","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec") ;
|
||
|
|
|
||
|
|
our $quote_and_ops_ids = qq~~ ;
|
||
|
|
|
||
|
|
our @selects_with_default_ids = () ; our @table_with_default_ids = () ; our @dropdown_chosen_ids = () ; our @update_ids = () ;
|
||
|
|
|
||
|
|
$print_box_content_rows .= qq~<span style="display:none;" id="from_to">$from_to</span>~ ;
|
||
|
|
|
||
|
|
my $table_row = 0 ; my $placeholder_row_cnt = 0 ;
|
||
|
|
|
||
|
|
# foreach my $id (sort {$b cmp $a} keys %{$db{$table}}) {
|
||
|
|
# $placeholder_row_cnt++ ;
|
||
|
|
# }
|
||
|
|
|
||
|
|
$db{$table}{"999999999999999999999999"}{extra_row} = 1 ;
|
||
|
|
|
||
|
|
my %status_val = (1 => "Pending", 2 => "Complete") ;
|
||
|
|
|
||
|
|
my %outcome_val = (1 => "Passed", 2 => "Conditional", 3 => "Failed") ;
|
||
|
|
|
||
|
|
$opts{outcome} = join( '' , map { "<option value='$_'>$outcome_val{$_}</option>" } sort { $a <=> $b } keys %outcome_val ) ;
|
||
|
|
|
||
|
|
my %event_operations_manager_val = (1 => "Benji",2 => "Blaine",3 => "Seb",4 => "Tristan",5 => "Vusi",44 => "Jodi") ;
|
||
|
|
|
||
|
|
our @date_value_ids = () ; our @default_javascript_by_id = () ; our @all_update_field_ids = () ;
|
||
|
|
|
||
|
|
foreach my $id (sort {$a <=> $b} keys %{$db{$table}}) {
|
||
|
|
|
||
|
|
my $only_display_val = 0 ;
|
||
|
|
|
||
|
|
# if ($db{$table}{$id}{date_due}) {
|
||
|
|
# my $due_date = $db{$table}{$id}{date_due} ;
|
||
|
|
# $due_date =~ s/\-//g ;
|
||
|
|
# $due_date = int($due_date) ;
|
||
|
|
# $only_display_val = 1 if $due_date < int("$now_year$now_mm$now_dd") && $db{$table}{$id}{status_id} eq '2' ;
|
||
|
|
# }
|
||
|
|
# && $db{$table}{$id}{status_id} eq '2'
|
||
|
|
next if $only_display_val ;
|
||
|
|
|
||
|
|
$table_row++ ;
|
||
|
|
|
||
|
|
$id = 'add_row' if $id eq '999999999999999999999999' ;
|
||
|
|
|
||
|
|
$print_tbody .= qq~<tr id="$id">~ ;
|
||
|
|
|
||
|
|
our %field = () ;
|
||
|
|
|
||
|
|
$field{venue} = qq~venue_$id~ ;
|
||
|
|
$field{field} = qq~field_$id~ ;
|
||
|
|
$field{sport} = qq~sport_$id~ ;
|
||
|
|
$field{date_allocated} = qq~date_allocated_$id~ ;
|
||
|
|
$field{date_due} = qq~date_due_$id~ ;
|
||
|
|
$field{event_operations_manager} = qq~event_operations_manager_$id~ ;
|
||
|
|
$field{status_id} = qq~status_$id~ ;
|
||
|
|
$field{outcome} = qq~outcome_$id~ ;
|
||
|
|
$field{comment} = qq~comment_$id~ ;
|
||
|
|
$field{update} = qq~update_$id~ ;
|
||
|
|
|
||
|
|
$opts{$field{status_id}} = $opts{status_id} ;
|
||
|
|
$opts{$field{sport}} = $opts{sport} ;
|
||
|
|
$opts{$field{event_operations_manager}} = $opts{event_operations_manager} ;
|
||
|
|
|
||
|
|
our %ucfirstfield = () ;
|
||
|
|
|
||
|
|
foreach (keys %field) {
|
||
|
|
$ucfirstfield{$field{$_}} = ucfirst $field{$_} ;
|
||
|
|
if ($_ eq 'update') {
|
||
|
|
$ucfirstfield{$field{$_}} = qq~checkbox~ . $ucfirstfield{$field{$_}} ;
|
||
|
|
} elsif ($_ eq 'venue' || $_ eq 'field' || $_ eq 'comment' ) {
|
||
|
|
$ucfirstfield{$field{$_}} = qq~textarea~ . $ucfirstfield{$field{$_}} ;
|
||
|
|
} elsif ($_ eq 'date_due') {
|
||
|
|
$ucfirstfield{$field{$_}} = qq~input~ . $ucfirstfield{$field{$_}} ;
|
||
|
|
} else {
|
||
|
|
$ucfirstfield{$field{$_}} = qq~select~ . $ucfirstfield{$field{$_}} ;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
our $default_javascript = qq~~ ;
|
||
|
|
$xlsxcol = 0 ;
|
||
|
|
|
||
|
|
$placeholder_row_cnt++ if $id ne 'add_row' && !$only_display_val ;
|
||
|
|
|
||
|
|
foreach (@sql_col_display) {
|
||
|
|
|
||
|
|
next unless $_ ; # blank for the buttons column
|
||
|
|
|
||
|
|
# our $formatting = $format84 ;
|
||
|
|
our $formatting = $format84 ;
|
||
|
|
my $val = $db{$table}{$id}{$_} ;
|
||
|
|
our $val_min = '' ;
|
||
|
|
our $align = qq~ class="dt-center"~ ;
|
||
|
|
our $nowrap = '' ;
|
||
|
|
|
||
|
|
my $due_date = 0 ;
|
||
|
|
|
||
|
|
my $default_val_is_saved = ($db{$table}{$id}{$_}) ? 1 : 0 ;
|
||
|
|
|
||
|
|
my $result = $_ ;
|
||
|
|
|
||
|
|
$result =~ s/\_id//g ;
|
||
|
|
|
||
|
|
$result = join(' ', map { ucfirst $_ } split /\_/, $result);
|
||
|
|
|
||
|
|
$preferred_placeholder{$field{$_}} = ($id ne 'add_row') ? $result . ' ' . $placeholder_row_cnt : $result . ' Add Row' ;
|
||
|
|
|
||
|
|
if ($_ eq "venue") {
|
||
|
|
my $sort_id = sprintf("%09d",$id) ;
|
||
|
|
my $hidden_val = ($id eq 'add_row') ? qq~<span style="display:none;">ZZZZZZZZZZZZZZZ</span>~ : qq~<span style="display:none;">$sort_id</span>~ ;
|
||
|
|
$val = $hidden_val . &common_min_table_textarea($field{venue},$db{$table}{$id}{venue},$only_display_val,$table_row,$last_child{venue},'',$default_val_is_saved) ;
|
||
|
|
} elsif ($_ eq "field") {
|
||
|
|
$val = &common_min_table_textarea($field{field},$db{$table}{$id}{field},$only_display_val,$table_row,$last_child{field},'',$default_val_is_saved) ;
|
||
|
|
} elsif ($_ eq "sport") {
|
||
|
|
$val_min = $db{sport_types}{$db{$table}{$id}{sport_ids}}{name} ;
|
||
|
|
$default_val_is_saved = ($db{$table}{$id}{sport_ids}) ? 1 : 0 ;
|
||
|
|
$db{$table}{$id}{sport_ids} = ($only_display_val && $db{$table}{$id}{sport_ids}) ? $db{sport_types}{$db{$table}{$id}{sport_ids}}{name} : $db{$table}{$id}{sport_ids} ;
|
||
|
|
$preferred_placeholder{$field{sport}} = 'Select ' . $preferred_placeholder{$field{sport}} ;
|
||
|
|
$val = &common_min_table_select($field{sport},$db{$table}{$id}{sport_ids},$only_display_val,$table_row,$last_child{sport},'',$default_val_is_saved,$_) ;
|
||
|
|
} elsif ($_ eq "date_due") {
|
||
|
|
my $def_date = "" ;
|
||
|
|
if (!$db{$table}{$id}{date_due}) {
|
||
|
|
my ($next_year,$next_month,$next_day) = Add_Delta_Days($now_year,$now_mm,$now_dd,1) ;
|
||
|
|
$next_month = sprintf("%02d",$next_month) ;
|
||
|
|
$next_day = sprintf("%02d",$next_day) ;
|
||
|
|
$db{$table}{$id}{date_due} = "$next_year-$next_month-$next_day" ;
|
||
|
|
}
|
||
|
|
$val = &common_min_table_input($field{date_due},$db{$table}{$id}{date_due},$only_display_val,$table_row,$last_child{date_due},'',$default_val_is_saved) ;
|
||
|
|
push @date_value_ids,"#$ucfirstfield{$field{date_due}}" ;
|
||
|
|
} elsif ($_ eq "date_allocated") {
|
||
|
|
$nowrap = 'nowrap' ;
|
||
|
|
} elsif ($_ eq "event_operations_manager") {
|
||
|
|
$default_val_is_saved = ($db{$table}{$id}{event_operations_manager_id}) ? 1 : 0 ;
|
||
|
|
$val_min = $event_operations_manager_val{$db{$table}{$id}{event_operations_manager_id}} ;
|
||
|
|
$db{$table}{$id}{event_operations_manager_id} = ($only_display_val && $db{$table}{$id}{event_operations_manager_id}) ? $event_operations_manager_val{$db{$table}{$id}{event_operations_manager_id}} : $db{$table}{$id}{event_operations_manager_id} ;
|
||
|
|
$val = &common_min_table_select($field{event_operations_manager},$db{$table}{$id}{event_operations_manager_id},$only_display_val,$table_row,$last_child{event_operations_manager},'',$default_val_is_saved,$_) ;
|
||
|
|
} elsif ($_ eq "status_id") {
|
||
|
|
my $background_color = ($db{$table}{$id}{status_id} eq '1') ? "rgb(249,13,13)" : ($db{$table}{$id}{status_id} eq '2') ? "rgb(81,181,41)" : "" ;
|
||
|
|
$formatting = ($db{$table}{$id}{status_id} eq '1') ? $format90 : $format88 ;
|
||
|
|
$val_min = $status_val{$db{$table}{$id}{status_id}} ;
|
||
|
|
$db{$table}{$id}{status_id} = ($only_display_val && $db{$table}{$id}{status_id}) ? $status_val{$db{$table}{$id}{status_id}} : $db{$table}{$id}{status_id} ;
|
||
|
|
$preferred_placeholder{$field{status_id}} = 'Select ' . $preferred_placeholder{$field{status_id}} ;
|
||
|
|
$val = &common_min_table_select($field{status_id},$db{$table}{$id}{status_id},$only_display_val,$table_row,$last_child{status_id},$background_color,$default_val_is_saved,$_) ;
|
||
|
|
} elsif ($_ eq 'outcome') {
|
||
|
|
$val_min = $outcome_val{$db{$table}{$id}{outcome_id}} ;
|
||
|
|
$preferred_placeholder{$field{outcome}} = 'Select ' . $preferred_placeholder{$field{outcome}} ;
|
||
|
|
$opts{$field{outcome}} = $opts{outcome} ;
|
||
|
|
my $background_color = ($db{$table}{$id}{outcome_id} eq '1') ? "rgb(81,181,41)" : ($db{$table}{$id}{outcome_id} eq '2') ? "rgb(246,227,5)" : ($db{$table}{$id}{outcome_id} eq '3') ? "rgb(249,13,13)" : "" ;
|
||
|
|
$default_val_is_saved = ($db{$table}{$id}{outcome_id}) ? 1 : 0 ;
|
||
|
|
$val = &common_min_table_select($field{outcome},$db{$table}{$id}{outcome_id},$only_display_val,$table_row,$last_child{outcome},$background_color,$default_val_is_saved,$_) ;
|
||
|
|
} elsif ($_ eq "comment") {
|
||
|
|
$val = &common_min_table_textarea($field{comment},$db{$table}{$id}{comment},$only_display_val,$table_row,$last_child{comment},'',$default_val_is_saved) ;
|
||
|
|
} elsif ($_ eq 'update') {
|
||
|
|
$val = &common_min_table_checkbox($field{update}) ;
|
||
|
|
chop $default_javascript if $default_javascript ;
|
||
|
|
if ($default_javascript) {
|
||
|
|
push @default_javascript_by_id, qq~"$id":{$default_javascript}~ ;
|
||
|
|
push @all_update_field_ids,"#$ucfirstfield{$field{venue}},#$ucfirstfield{$field{field}},#$ucfirstfield{$field{sport}},#$ucfirstfield{$field{date_due}},#$ucfirstfield{$field{event_operations_manager}},#$ucfirstfield{$field{status_id}},#$ucfirstfield{$field{comment}}" ;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
unless ($val_min) {
|
||
|
|
$val_min = $val ;
|
||
|
|
}
|
||
|
|
$val_min =~ s/\MUSTBEBLANK//g ;
|
||
|
|
|
||
|
|
if ($_ eq 'sport') {
|
||
|
|
$val_min =~ s/\<br>/\;/g ;
|
||
|
|
}
|
||
|
|
|
||
|
|
$print_tbody .= qq~<td $align $nowrap>$val</td>~ ;
|
||
|
|
next if $_ eq 'update' || $id eq 'add_row' ;
|
||
|
|
|
||
|
|
&xlsxcreator_write_xlsx($ws,$xlsxrow,$xlsxcol,$val_min,$formatting) ;
|
||
|
|
$xlsxcol++ ;
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
$del_butt = ($id eq 'add_row') ? qq~~ : ($only_display_val) ? qq~ <a class="btn btn-default btn-xs" href="#"><i class="glyphicon glyphicon-trash icon-white"></i></a>~ : qq~ <a class="btn btn-danger btn-xs" href="javascript:deleteMinItem('','$id')"><i class="glyphicon glyphicon-trash icon-white"></i></a>~ ;
|
||
|
|
|
||
|
|
$print_tbody .= qq~<td $align $nowrap>$del_butt</td>~ ;
|
||
|
|
$print_tbody .= qq~</tr>~ ;
|
||
|
|
$xlsxrow++ if $id ne 'add_row' ;
|
||
|
|
|
||
|
|
chop $system_location_ids if $system_location_ids ; chop $event_venue_ids if $event_venue_ids ;
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
&common_min_table_textarea_jquery ;
|
||
|
|
|
||
|
|
&common_min_table_validate_date_inputs_jquery ;
|
||
|
|
|
||
|
|
&common_min_table_update_checkbox_col ;
|
||
|
|
|
||
|
|
&common_min_table_select_jquery("#$useropts{table_id} td:nth-last-child($last_child{outcome}),#$useropts{table_id} td:nth-last-child($last_child{sport}),#$useropts{table_id} td:nth-last-child($last_child{event_operations_manager}),#$useropts{table_id} td:nth-last-child($last_child{status_id})") if $iaction ne 'save' and $iaction ne 'delete' and $iaction ne 'report' ;
|
||
|
|
|
||
|
|
$trigger_jquery .= qq~
|
||
|
|
\$("#$useropts{table_id} tr th").slice(-11, -8).css("width","12.25%");
|
||
|
|
\$("#$useropts{table_id} tr th").slice(-7, -2).css("width","12.25%");
|
||
|
|
\$("#$useropts{table_id} tr th:nth-last-child($last_child{date_allocated})").css("width","8.25%");
|
||
|
|
\$("#$useropts{table_id} tr th:nth-last-child($last_child{update})").css("width","4%");
|
||
|
|
\$("#$useropts{table_id} tr th:nth-last-child(1)").css("width","2%");
|
||
|
|
~ ;
|
||
|
|
|
||
|
|
$worksheet{$ws}->set_column("A:A",40);
|
||
|
|
$worksheet{$ws}->set_column("B:G",20);
|
||
|
|
$worksheet{$ws}->set_column("H:H",40);
|
||
|
|
|
||
|
|
&report_xlsx_export_footer('L',15,$xlsxdir) ;
|
||
|
|
|
||
|
|
$fnsortorder = 'desc' ;
|
||
|
|
|
||
|
|
&common_min_extra_crumb("$lcpage","Search Screen") ;
|
||
|
|
|
||
|
|
$trigger_jquery_raw .= qq~
|
||
|
|
\$("#savebutt").click(function() {
|
||
|
|
let item_val ;
|
||
|
|
$jquery_chosen_sel
|
||
|
|
\$("#$lcpage-form").submit() ;
|
||
|
|
}) ;
|
||
|
|
~ ;
|
||
|
|
|
||
|
|
$extra_form_footer = qq~
|
||
|
|
<form role="form" id="logisticsform" method="post">
|
||
|
|
<input type="hidden" id="logisticsaction" name="iaction" value="">
|
||
|
|
<input type="hidden" name="date_from" value="$i{date_from}">
|
||
|
|
</form>
|
||
|
|
~ ;
|
||
|
|
# From Venue To Venue
|
||
|
|
|
||
|
|
$trigger_jquery_raw .= qq~
|
||
|
|
function toggleToFrom (ft) {
|
||
|
|
\$('#logisticsaction').val(ft);
|
||
|
|
\$('#logisticsform').submit();
|
||
|
|
}
|
||
|
|
~;
|
||
|
|
|
||
|
|
|
||
|
|
} #------------------------------------------------------------------------------------------
|
||
|
|
|
||
|
|
sub thead {
|
||
|
|
|
||
|
|
&common_min_thead ;
|
||
|
|
|
||
|
|
} #-------------------------------------------------------------------------------
|
||
|
|
|
||
|
|
sub page_opts {
|
||
|
|
|
||
|
|
our $glyphicon = 'list' ;
|
||
|
|
our $lcpage = 'mobile-site-surveys' ;
|
||
|
|
|
||
|
|
&common_page_name ;
|
||
|
|
|
||
|
|
our $table = 'mobile_site_surveys' ;
|
||
|
|
$page_title = 'Mobile Site Surveys Report' ;
|
||
|
|
|
||
|
|
our $blank_action = 1 ;
|
||
|
|
|
||
|
|
} #-------------------------------------------------------------------------------
|
||
|
|
|
||
|
|
sub screen2 {
|
||
|
|
|
||
|
|
my $page = "mobile-site-surveys-report" ;
|
||
|
|
|
||
|
|
# # if ($i{id} && $redirsave eq 'edit') {
|
||
|
|
# if ($redirsave eq 'edit') {
|
||
|
|
# $input_hidden_id = qq~<input type="hidden" name="id" value="$i{id}">~ ;
|
||
|
|
# }
|
||
|
|
|
||
|
|
# my $doc_ready_jquery = qq~\$(document).ready(function(){ \$('#$redirsave-form').submit(); })~ unless $username eq 'rory' ;
|
||
|
|
|
||
|
|
# &common_min_table_select_jquery("#itv-table td:nth-last-child(4),#itv-table td:nth-last-child(4),#itv-table td:nth-last-child(5),#itv-table td:nth-last-child(8)") ;
|
||
|
|
&common_min_table_select_jquery("#$useropts{table_id} td:nth-last-child($last_child{outcome}),#$useropts{table_id} td:nth-last-child($last_child{sport}),#$useropts{table_id} td:nth-last-child($last_child{event_operations_manager}),#$useropts{table_id} td:nth-last-child($last_child{status_id})") ;
|
||
|
|
|
||
|
|
my $form_name = $redirsave . 'form' ;
|
||
|
|
|
||
|
|
our $success = "SUCCESSFULLY SAVED" ;
|
||
|
|
|
||
|
|
&common_min_alert_type ;
|
||
|
|
|
||
|
|
print <<ENDOFTEXT;
|
||
|
|
<!DOCTYPE html>
|
||
|
|
<html lang="en">
|
||
|
|
<head>
|
||
|
|
<meta charset="utf-8">
|
||
|
|
<title>$useropts{title}</title>
|
||
|
|
<script src="$useropts{'bower_components'}/jquery/jquery.min.js"></script>
|
||
|
|
</head>
|
||
|
|
<body>
|
||
|
|
<script>
|
||
|
|
\$(document).ready(function(){ \$('#$redirsave-form').submit(); })
|
||
|
|
</script>
|
||
|
|
</body>
|
||
|
|
|
||
|
|
<form role="form" name="$form_name" id="$redirsave-form" method="post" action="$page">
|
||
|
|
<input type="hidden" name="iaction" value="$redirsave">
|
||
|
|
<input type="hidden" name="isaved" value="$success">
|
||
|
|
$input_hidden_id
|
||
|
|
</form>
|
||
|
|
|
||
|
|
</html>
|
||
|
|
ENDOFTEXT
|
||
|
|
#
|
||
|
|
|
||
|
|
exit ;
|
||
|
|
|
||
|
|
} #------------------------------------------------------------------------------------------
|
||
|
|
|
||
|
|
sub screen3 {
|
||
|
|
|
||
|
|
$custom_column_styles{venue} = qq~style="min-width:150px;"~ ;
|
||
|
|
$custom_column_styles{field} = qq~style="min-width:150px;"~ ;
|
||
|
|
$custom_column_styles{sport} = qq~style="min-width:150px;"~ ;
|
||
|
|
$custom_column_styles{date_due} = qq~style="min-width:150px;"~ ;
|
||
|
|
$custom_column_styles{event_operations_manager} = qq~style="min-width:150px;"~ ;
|
||
|
|
$custom_column_styles{status_id} = qq~style="min-width:150px;"~ ;
|
||
|
|
$custom_column_styles{comment} = qq~style="min-width:150px;"~ ;
|
||
|
|
|
||
|
|
&thead;
|
||
|
|
|
||
|
|
if ($isaved) { $alert = &common_min_alert('success',"$ucpage $isaved!",'ok') ; } else { &common_min_alert_type ; }
|
||
|
|
|
||
|
|
# my $page = "$lcpage\s" ;
|
||
|
|
|
||
|
|
my $page = "mobile-site-surveys-report" ;
|
||
|
|
|
||
|
|
if ($s{no}) { $page = $lcpage ; }
|
||
|
|
|
||
|
|
&common_min_table('id',$page,'list') ;
|
||
|
|
|
||
|
|
# &common_min_table_select_jquery("#itv-table td:nth-last-child(4),#itv-table td:nth-last-child(5),#itv-table td:nth-last-child(8)") ;
|
||
|
|
&common_min_table_select_jquery("#$useropts{table_id} td:nth-last-child($last_child{outcome}),#$useropts{table_id} td:nth-last-child($last_child{sport}),#$useropts{table_id} td:nth-last-child($last_child{event_operations_manager}),#$useropts{table_id} td:nth-last-child($last_child{status_id})") ;
|
||
|
|
|
||
|
|
our $savjqy = 1 ;
|
||
|
|
|
||
|
|
# &common_min_extra_crumb("manage-$lcpage\s","Manage $ucfirstpage\s") ;
|
||
|
|
|
||
|
|
$extra_form_fields .= qq~
|
||
|
|
<input type="hidden" name="oaction" value="$iaction">
|
||
|
|
~;
|
||
|
|
|
||
|
|
$print_box_content_rows .= &common_min_forms_end('','','save') ;
|
||
|
|
|
||
|
|
require _blank ;
|
||
|
|
|
||
|
|
exit ;
|
||
|
|
|
||
|
|
} #------------------------------------------------------------------------------------------
|
||
|
|
|
||
|
|
sub redirect_screen {
|
||
|
|
|
||
|
|
&common_min_alert_type ;
|
||
|
|
|
||
|
|
print <<ENDOFTEXT;
|
||
|
|
<!DOCTYPE html>
|
||
|
|
<html lang="en">
|
||
|
|
<head>
|
||
|
|
<meta charset="utf-8">
|
||
|
|
<title>$useropts{title}</title>
|
||
|
|
<script src="$useropts{'bower_components'}/jquery/jquery.min.js"></script>
|
||
|
|
</head>
|
||
|
|
<body>
|
||
|
|
<script>
|
||
|
|
|
||
|
|
\$(document).ready(function(){ \$('#$lcpage-form').submit(); })
|
||
|
|
|
||
|
|
</script>
|
||
|
|
</body>
|
||
|
|
|
||
|
|
<form role="form" id="$lcpage-form" method="post" action="$lcpage">
|
||
|
|
<input type="hidden" name="iaction" value="report">
|
||
|
|
<input type="hidden" name="oaction" value="report">
|
||
|
|
|
||
|
|
</form>
|
||
|
|
|
||
|
|
</html>
|
||
|
|
ENDOFTEXT
|
||
|
|
#
|
||
|
|
|
||
|
|
exit ;
|
||
|
|
|
||
|
|
# <input type="hidden" name="oaction" value="$iaction">
|
||
|
|
|
||
|
|
} #------------------------------------------------------------------------------------------
|
||
|
|
|
||
|
|
use db ;
|
||
|
|
use today ;
|
||
|
|
use common ;
|
||
|
|
use report ;
|
||
|
|
use xlsxcreator ;
|
||
|
|
|
||
|
|
1;
|