2025-11-26 09:31:54 +00:00
#!/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 ;
& today ;
#---------------------------------------------------------------------------------------------------------------------------------------------------------------------
@ ARGV = split ( /\\*\&/ , $ ENV { 'QUERY_STRING' } ) ;
$ action = $ ARGV [ 0 ] ;
our ( $ q ) = CGI - > new ( ) ;
our $ iaction = $ q - > param ( 'iaction' ) || $ action ;
our $ isaved = $ q - > param ( 'isaved' ) || '' ;
our $ no_dates_in_table = 1 ;
# our $debug = 1 ;
# our $testing = 1 ;
# if ($username ne 'handre') {
2026-02-03 12:35:43 +00:00
# print "print "<< MAINTENANCE IN PROGRESS >>" ; exit ;
2025-11-26 09:31:54 +00:00
# }
#-------- 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 ;
& list_screen ;
$ db_ignore_open_close = 0 ; # do one open and one close instead of repeating it
& db_close_conn ;
# exit if $username eq 'handre' && $testing ;
& screen3 ;
# &redirect_screen;
}
& 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 hidden_fields {
# $ignore{id} = 1 ;
$ ignore { iaction } = 1 ;
$ ignore { date } = 1 ;
$ ignore { monitor_id } = 1 ;
for my $ d_cnt ( 1 .. $ date_counter ) {
for my $ shift_cnt ( 1 .. 4 ) {
$ ignore { "shiftmonitorid_$shift_cnt\_$d_cnt" } = 1 ;
$ ignore { "shift_monitor_$shift_cnt\_$d_cnt" } = 1 ;
}
}
# $ignore{monitor_ids} = 1 ;
$ ignore { update_table_1 } = 1 ;
$ ignore { update } = 1 ;
$ ignore { "itv-table_length" } = 1 ;
} #------------------------------------------------------------------------------------------
sub update {
& schedule_update ( "shift_operator_ids" , "monitor_ids" , "shiftmonitorid" , "monitor_notes" ) ;
# 12=f:;s:|s:1;t:1|f:2;s:2-13=|f:3;s:3|f:4;s:4
2026-02-03 12:35:43 +00:00
& schedule_update_monitor_reports ;
2025-11-26 09:31:54 +00:00
2026-02-03 12:35:43 +00:00
# my @table_sql_where = () ;
# if ($i{client_id}) {
# push @table_sql_where, "`quote_to`='$i{client_id}'" ;
# }
# if ($i{date_from} && $i{date_to}) { # check dates
# push @table_sql_where, "(('$i{date_from} 00:00:00' <= `date_from` AND `date_from` <= '$i{date_to} 23:59:59') OR ('$i{date_from} 00:00:00' <= `date_to` AND `date_to` <= '$i{date_to} 23:59:59') OR (`date_from` <= '$i{date_from} 00:00:00' AND '$i{date_to} 23:59:59' <= `date_to`))" ; ############################################### > OR >=
2025-11-26 09:31:54 +00:00
2026-02-03 12:35:43 +00:00
# }
2025-11-26 09:31:54 +00:00
2026-02-03 12:35:43 +00:00
# # if ($i{monitor_id} and $i{monitor_id} ne 'all') {
# # push @table_sql_where,"`MONITOR` = '$db{users}{1}{name}'" ;
# # }
2025-11-26 09:31:54 +00:00
2026-02-03 12:35:43 +00:00
# my $table_sql_where_str = join(" AND ",@table_sql_where) ;
2025-11-26 09:31:54 +00:00
2026-02-03 12:35:43 +00:00
# &db_min_ro($table,"id,monitor_report_saved_data","$table_sql_where_str",'','') ;
2025-11-26 09:31:54 +00:00
2026-02-03 12:35:43 +00:00
# my %saved_field_hash = () ;
2025-11-26 09:31:54 +00:00
2026-02-03 12:35:43 +00:00
# foreach my $id (keys %{$db{$table}}) {
2025-11-26 09:31:54 +00:00
2026-02-03 12:35:43 +00:00
# # my @saved_data_split_1 = split(/\-/,$db{$table}{$id}{monitor_report_saved_data}) ;
# my @saved_data_split_1 = split /-(?=\d+=(?:blank\||f:\d+|s:\d+|c:))/, $db{$table}{$id}{monitor_report_saved_data};
# foreach my $a (@saved_data_split_1) {
# # my @saved_data_split_2 = split(/\=/,$a) ;
# my @saved_data_split_2 = () ;
# if ($a =~ /^(\d+|none)=(.*)$/) {
# @saved_data_split_2 = ($1, $2);
# } else {
# @saved_data_split_2 = ($a);
# }
# my $event_sys_id = $saved_data_split_2[0] ;
# # my @saved_data_split_3 = split(/\|/,$saved_data_split_2[1]) ;
# # my @saved_data_split_3 = split /\|(?=(?:blank\|f:\d+|blank\|s:\d+|blank\|c:|f:\d+|s:\d+|c:))/, $saved_data_split_2[1];
# my @saved_data_split_3 = split(
# /\|
# (?= # Look ahead for allowed patterns
# # blank$ # 1) blank + end
# blank\|s:\d+ # 2) blank|s:<int>
# | blank\|f:\d+ # 3) blank|f:<int>
# | blank\|c: # 4) blank|c:
# | f:\d+ # 5) f:<int>
# | s:\d+ # 6) s:<int>
# | c: # 7) c:
# | blank\|blank\| # 8) blank|s:<int>
# )
# /x,
# $saved_data_split_2[1]
# );
# my $day_cnt = 0 ;
# foreach my $b (@saved_data_split_3) {
# $day_cnt++ ;
# next if !$b || $b eq 'blank' ;
# $b =~ s/\|/\pipe_in_comment_to_be_removed/g ;
# $saved_field_hash{$id}{$event_sys_id}{$day_cnt} = $b ;
# }
# }
# }
2025-11-26 09:31:54 +00:00
2026-02-03 12:35:43 +00:00
# foreach my $field_name (keys %i) {
2025-11-26 09:31:54 +00:00
2026-02-03 12:35:43 +00:00
# next if ($field_name =~ /update_event/ && !$i{$field_name}) || $field_name !~ /update_event/ ;
2025-11-26 09:31:54 +00:00
2026-02-03 12:35:43 +00:00
# my @fields = split(/\_/,$field_name) ;
2025-11-26 09:31:54 +00:00
2026-02-03 12:35:43 +00:00
# my $system_id = substr($fields[-3],5) ;
# my $day_cnt = $fields[-2] ;
# my $event_id = $fields[-1] ;
2025-11-26 09:31:54 +00:00
2026-02-03 12:35:43 +00:00
# my $fixture_field = "fixture_check_event$system_id\_$day_cnt\_$event_id" ;
# my $status_field = "status_event$system_id\_$day_cnt\_$event_id" ;
# my $comments_field = "comments_event$system_id\_$day_cnt\_$event_id" ;
2025-11-26 09:31:54 +00:00
2026-02-03 12:35:43 +00:00
# $saved_field_hash{$event_id}{$system_id}{$day_cnt} = qq~~ ;
# $saved_field_hash{$event_id}{$system_id}{$day_cnt} = ($i{$fixture_field}) ? qq~f:$i{$fixture_field};~ : qq~~ ;
# $saved_field_hash{$event_id}{$system_id}{$day_cnt} .= ($i{$status_field}) ? qq~s:$i{$status_field};~ : qq~~ ;
# $saved_field_hash{$event_id}{$system_id}{$day_cnt} =~ s/;+$//g unless $i{$comments_field} ;
# $i{$comments_field} =~ s/\|/\pipe_in_comment_to_be_removed/g ;
# $saved_field_hash{$event_id}{$system_id}{$day_cnt} .= qq~c:$i{$comments_field}~ if $i{$comments_field} ;
2025-11-26 09:31:54 +00:00
2026-02-03 12:35:43 +00:00
# }
2025-11-26 09:31:54 +00:00
2026-02-03 12:35:43 +00:00
# %ii = %i ;
# %i = () ;
2025-11-26 09:31:54 +00:00
2026-02-03 12:35:43 +00:00
# foreach my $event_id (keys %saved_field_hash) {
2025-11-26 09:31:54 +00:00
2026-02-03 12:35:43 +00:00
# $i{monitor_report_saved_data} = qq~~ ;
2025-11-26 09:31:54 +00:00
2026-02-03 12:35:43 +00:00
# foreach my $system_id (sort { $a <=> $b } keys %{$saved_field_hash{$event_id}}) {
2025-11-26 09:31:54 +00:00
2026-02-03 12:35:43 +00:00
# # $i{monitor_report_saved_data} .= qq~$system_id\=~ ;
# my $saved_by_system = qq~~ ;
2025-11-26 09:31:54 +00:00
2026-02-03 12:35:43 +00:00
# foreach my $day_max (sort { $b <=> $a } keys %{$saved_field_hash{$event_id}{$system_id}}) {
# for my $day_cnt (1 .. $day_max) {
# # $saved_field_hash{$event_id}{$system_id}{$day_cnt} =~ s/;+$//g ;
# $saved_by_system .= qq~$saved_field_hash{$event_id}{$system_id}{$day_cnt}|~ ;
# }
# # chop $saved_by_system if $day_max ;
# $saved_by_system =~ s/\|+$//g ;
# last ;
# }
# if ($saved_by_system =~ /\||/) {
# $saved_by_system =~ s/\|(?=\|)/|blank/g ;
# }
# if ($saved_by_system =~ /^\|/) {
# $saved_by_system =~ s/^\|/blank|/g ;
# }
# # if ($saved_by_system =~ /\|$/) {
# # $saved_by_system =~ s/\|$/|blank/;
# # }
# $saved_by_system =~ s/pipe_in_comment_to_be_removed/\|/g ;
# $i{monitor_report_saved_data} .= qq~$system_id\=$saved_by_system\-~ if $saved_by_system ;
# }
2025-11-26 09:31:54 +00:00
2026-02-03 12:35:43 +00:00
# chop $i{monitor_report_saved_data} if $i{monitor_report_saved_data} ;
# next if ($i{monitor_report_saved_data} eq $db{$table}{$event_id}{monitor_report_saved_data}) || (!$i{monitor_report_saved_data} && !$db{$table}{$event_id}{monitor_report_saved_data}) ;
2025-11-26 09:31:54 +00:00
# &db_min_upd($table,"id='$event_id'") ;
2026-02-03 12:35:43 +00:00
# }
2025-11-26 09:31:54 +00:00
2026-02-03 12:35:43 +00:00
# %i = %ii ;
2025-11-26 09:31:54 +00:00
} #------------------------------------------------------------------------------------------
sub report_ifields {
& load_search_vars ;
# if ($i{date}) { # check dates
# push @report_sql, " `date_from` <= '$i{date} 23:59:59' AND '$i{date} 00:00:00' <= `date_to` " ;
# push @report_results, "DATE IS '$i{date}'" ;
# } else {
# $error = qq~PLEASE ENTER A DATE!~ ;
# &report_screen;
# }
if ( $ i { client_id } ) {
push @ report_sql , "`quote_to`='$i{client_id}'" ;
& db_min_ro ( 'customers' , 'id,name' , "`id`='$i{client_id}'" ) ;
push @ report_results , "`CLIENT` = '$db{customers}{$i{client_id}}{name}'" ;
}
my $ date_from_val = $ i { date_from } ; my $ date_to_val = $ i { date_to } ;
$ date_from_val =~ s/\-//g ; $ date_to_val =~ s/\-//g ;
if ( $ i { date_from } && $ i { date_to } && $ date_from_val > $ date_to_val ) {
$ error = qq~THE START MUST BE BEFORE THE END DATE!!!~ ;
& report_screen ;
} elsif ( $ i { date_from } && $ i { date_to } ) { # check dates
push @ report_sql , "(('$i{date_from} 00:00:00' <= `date_from` AND `date_from` <= '$i{date_to} 23:59:59') OR ('$i{date_from} 00:00:00' <= `date_to` AND `date_to` <= '$i{date_to} 23:59:59') OR (`date_from` <= '$i{date_from} 00:00:00' AND '$i{date_to} 23:59:59' <= `date_to`))" ; ############################################### > OR >=
push @ report_results , "(EVENT BETWEEN '$i{date_from}' AND '$i{date_to}')" ;
} else {
$ error = qq~PLEASE ENTER A START AND END DATE!!!~ ;
& report_screen ;
}
if ( $ i { monitor_id } and $ i { monitor_id } ne 'all' ) {
push @ report_results , "`MONITOR` = '$db{users}{1}{name}'" ;
push @ report_sql , " `monitor_ids` LIKE '%$i{monitor_id}%' " ;
} elsif ( $ i { monitor_id } and $ i { monitor_id } eq 'all' ) {
push @ report_results , "`MONITORS` = 'ALL'" ;
} else {
# push @report_sql, "(`user_id` = '')" ;
}
$ report_results_msg = uc join ( ', ' , @ report_results ) ;
if ( $ iaction eq 'save' ) {
$ isaved = qq( SUCCESSFULLY SAVED! ) ;
} elsif ( 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 ) ;
my @ date = split ( / / , $ i { date } ) ;
my ( $ year_inp , $ month_inp , $ day_inp ) = split ( /\-/ , $ date [ 0 ] ) ;
our $ date_inp_val = int ( "$year_inp$month_inp$day_inp" ) ;
our $ today_val = int ( "$now_year$now_mm$now_dd" ) ;
} #------------------------------------------------------------------------------------------
sub load_search_vars {
if ( $ i { monitor_id } and $ i { monitor_id } ne 'all' ) {
& db_min_ro ( 'users' , '1,name' , "`id` = '$i{monitor_id}'" , '' , '' ) ;
}
} #------------------------------------------------------------------------------------------
sub list_screen {
$ print_box_content_rows . = & common_min_forms_start ( "$lcpage" ) ;
our $ monitoring_report = 1 ;
our $ extra_column = ",monitor_report_saved_data" ;
& schedule_load_list_vars ( "$srch_where_sql" ) ;
$ fcol = 12 ;
my $ report = 1 ;
our $ xlsxdir = "monitoring_report" ;
our $ xlsxreportname = "Monitor_Allocations" ;
my $ date = & common_write_date_interval ( $ i { date_from } , $ i { date_to } ) ;
our $ xlsx_title_heading = "Monitor Allocations $date" ;
my $ field_name = "shift_monitor" ;
my $ uc_field_name = ucfirst $ field_name ;
our $ print_tbody_extra = qq~~ ;
# our @sql_col_display_extra = ("date","shift_1_(07:00-10:00)","shift_2_(10:00-13:00)","shift_3_(13:00-16:00)","shift_4_(16:00-19:00)") ;
our @ sql_col_display_extra = ( "date" , "shift_1_(08:00-11:00)" , "shift_2_(11:00-14:00)" , "shift_3_(14:00-17:00)" , "shift_4_(17:00-21:00)" , "notes" ) ;
push @ sql_col_display_extra , "update" ;
# if $date_inp_val >= $today_val ;
our @ sql_col_display = ( "count" , "event" , "date" , "day" , "start_date" , "start_time" , "end_time" , "region" , "sport" , "system" , "club_name" , "operator" , "fixture_check" , "status" , "comments" ) ;
# push @sql_col_display,"update" if ($monitoring_report || $temp_calibrator_report) && $date_inp_val >= $today_val ;
& report_xlsx_export_header ( "$xlsxreportname" , $ xlsxdir , '' , $ xlsx_title_heading ) ;
& schedule_build_extra_table ( "shift_monitor" , "shift_operator_ids" , "monitor_ids" , "monitor_notes" , "select_monitors" ) ;
# &common_min_table_update_checkbox_col("3") ;
push @ sql_col_display , "update" ;
my $ table_col_name = "monitor_ids" ;
$ xlsxrow - - ;
my @ rev_sql_col_display = reverse @ sql_col_display ;
foreach ( @ rev_sql_col_display ) { $ lastchild + + ; $ last_child { $ _ } = $ lastchild ; }
2026-02-03 12:35:43 +00:00
& schedule_get_monitor_reports_default_values ;
# our %default_values = () ;
# # 12=f:;s:|s:1;t:1|f:2;s:2-13=|f:3;s:3|f:4;s:4
# foreach my $id (keys %{$db{$table}}) {
2025-11-26 09:31:54 +00:00
2026-02-03 12:35:43 +00:00
# # $db{$table}{$id}{monitor_report_saved_data} = "12=f:1;s:1|s:1;t:1|f:2;s:2;c:1|-23-123=f2-13=blank|f:3;s:3|f:4;s:4-133=blank|blank|f:3;s:3|f:4;s:4-1232=c:as" ;
2025-11-26 09:31:54 +00:00
2026-02-03 12:35:43 +00:00
# # next if $id eq '5136' ;
# # my @saved_data_split_1 = split /\-(?=\d+=[\f:\d+|\s:\d+|\c:|blank\|])/x, $db{$table}{$id}{monitor_report_saved_data};
# my @saved_data_split_1 = split /-(?=\d+=(?:blank\||f:\d+|s:\d+|c:))/, $db{$table}{$id}{monitor_report_saved_data}; ## split on "-" if and only if it it is followed by an integer = blank or f:integer or s:integer or c:
# foreach my $a (@saved_data_split_1) {
# # my @saved_data_split_2 = split /(?<=^(\d+))=/, $a;
# my @saved_data_split_2 = () ;
# if ($a =~ /^(\d+|none)=(.*)$/) {
# @saved_data_split_2 = ($1, $2);
# } else {
# @saved_data_split_2 = ($a);
# }
# # my @saved_data_split_2 = split(/(?<=^\d+)=/,$a) ;
# my $event_sys_id = $saved_data_split_2[0] ;
# # my $remaining_data = join(";", @saved_data_split_3[3 .. $#saved_data_split_3]) ;
# # my @saved_data_split_3 = split(/\|/,$saved_data_split_2[1]) ;
# # my @saved_data_split_3 = split /(?<=^(?:f:(\d+)|s:(\d+)|f:|s:|c:|blank))\|(?=(?:f:|s:|c:|blank))/x, $saved_data_split_2[1];
# my @saved_data_split_3 = () ;
# # while ($saved_data_split_2[1] =~ /\G((?:f:(\d+)|s:(\d+)|f:|s:|c:|blank)?)\|(?=(?:f:|s:|c:|blank|$))/xg) {
# # push @saved_data_split_3, $1;
# # }
# # my $final_element = $saved_data_split_2[1] ;
# # foreach (@saved_data_split_3) {
# # $final_element =~ s/^$_\|//g ;
# # }
# # push @saved_data_split_3, $final_element ;
# # $saved_data_split_2[1] = "blank|s:3|s:3|s:3|blank|blank" ;
# # my @saved_data_split_3 = split(/\|(?=(?:+$|blank\|+$|blank\|blank|blank\|f:\d+|blank\|s:\d+|blank\|c:|f:\d+|s:\d+|c:))/, "$saved_data_split_2[1]") ;
# my @saved_data_split_3 = split(
# /\|
# (?= # Look ahead for allowed patterns
# # blank$ # 1) blank + end
# blank\|s:\d+ # 2) blank|s:<int>
# | blank\|f:\d+ # 3) blank|f:<int>
# | blank\|c: # 4) blank|c:
# | f:\d+ # 5) f:<int>
# | s:\d+ # 6) s:<int>
# | c: # 7) c:
# | blank\|blank\| # 8) blank|s:<int>
# )
# /x,
# $saved_data_split_2[1]
# );
# my $day_cnt = 0 ;
# foreach my $b (@saved_data_split_3) {
# $day_cnt++ ;
2025-11-26 09:31:54 +00:00
2026-02-03 12:35:43 +00:00
# next if !$b || $b eq 'blank' ;
2025-11-26 09:31:54 +00:00
2026-02-03 12:35:43 +00:00
# # $b =~ s/\;+$//g ;
2025-11-26 09:31:54 +00:00
2026-02-03 12:35:43 +00:00
# my @saved_data_split_3 = split(/\;/,$b) ;
# my @saved_data_split_4 = ($saved_data_split_3[0]) ? split(/\:/,$saved_data_split_3[0]) : () ;
# my @saved_data_split_5 = ($saved_data_split_3[1]) ? split(/\:/,$saved_data_split_3[1]) : () ;
# my @saved_data_split_6 = ($saved_data_split_3[2]) ? split(/\:/,$saved_data_split_3[2]) : () ;
# if ($saved_data_split_3[0] =~ /^f:\d+/) {
# $default_values{$sql_col_display[-4]}{$event_sys_id}{$day_cnt}{$id} = $saved_data_split_4[1] ;
# }
2025-11-26 09:31:54 +00:00
2026-02-03 12:35:43 +00:00
# if ($saved_data_split_3[0] =~ /^s:\d+/) {
# $default_values{$sql_col_display[-3]}{$event_sys_id}{$day_cnt}{$id} = $saved_data_split_4[1] ;
# } elsif ($saved_data_split_3[1] =~ /^s:\d+/ && $saved_data_split_3[0] =~ /^f:\d+/) {
# $default_values{$sql_col_display[-3]}{$event_sys_id}{$day_cnt}{$id} = $saved_data_split_5[1] ;
# }
# my $comments_after_semicolon = "" ; ## In case the comments contain a ; when we split on ;
# if ($saved_data_split_3[0] =~ /^c:/) {
# $comments_after_semicolon = join(";", @saved_data_split_3[1 .. $#saved_data_split_3]) ;
# $default_values{$sql_col_display[-2]}{$event_sys_id}{$day_cnt}{$id} = $saved_data_split_4[1] . join(":", @saved_data_split_4[2 .. $#saved_data_split_4]) ;
# } elsif ($saved_data_split_3[1] =~ /^c:/ && ($saved_data_split_3[0] =~ /^f:\d+/ || $saved_data_split_3[0] =~ /^s:\d+/)) {
# $comments_after_semicolon = join(";", @saved_data_split_3[2 .. $#saved_data_split_3]) ;
# $default_values{$sql_col_display[-2]}{$event_sys_id}{$day_cnt}{$id} = $saved_data_split_5[1] . join(":", @saved_data_split_5[2 .. $#saved_data_split_5]) ;
# } elsif ($saved_data_split_3[2] =~ /^c:/ && $saved_data_split_3[1] =~ /^s:\d+/ && $saved_data_split_3[0] =~ /^f:\d+/) {
# $comments_after_semicolon = join(";", @saved_data_split_3[3 .. $#saved_data_split_3]) ;
# $default_values{$sql_col_display[-2]}{$event_sys_id}{$day_cnt}{$id} = $saved_data_split_6[1] . join(":", @saved_data_split_6[2 .. $#saved_data_split_6]) ;
# }
# $default_values{$sql_col_display[-2]}{$event_sys_id}{$day_cnt}{$id} .= ";$comments_after_semicolon" if $comments_after_semicolon || $b =~ /c:;+$/ ;
# }
# }
# }
2025-11-26 09:31:54 +00:00
& common_min_select_opts ( "status" , "monitor_status" , "status" ) ;
our @ default_javascript_by_id_2 = ( ) ;
& schedule_build_table ( "monitor_ids" ) ;
# if ($date_inp_val >= $today_val) {
# $trigger_jquery_raw .= qq~
# \$("#itv-table tr th:nth-last-child(5)").css("width","10%") ;
# \$("#itv-table tr th:nth-last-child(4)").css("width","10%") ;
# \$("#itv-table tr th:nth-last-child(3)").css("width","10%") ;
# \$("#itv-table tr th:nth-last-child(2)").css("width","10%") ;
# ~ ;
# } else {
# $trigger_jquery_raw .= qq~
# \$("#select_monitors tr th:nth-last-child(1)").css("width","23%") ;
# \$("#select_monitors tr th:nth-last-child(4)").css("width","23%") ;
# \$("#select_monitors tr th:nth-last-child(3)").css("width","23%") ;
# \$("#select_monitors tr th:nth-last-child(2)").css("width","23%") ;
# ~ ;
# }
# &calibration_build_table_and_or_excel(1) ;
# if ($found_after_date) {
# } else {
# $trigger_jquery_raw .= qq~
# \$("#itv-table tr th:nth-last-child(2)").css("width", "7.5%") ;
# \$("#itv-table tr th:nth-last-child(3)").css("width", "7.5%") ;
# \$("#itv-table tr th:nth-last-child(4)").css("width", "7.5%") ;
# \$("#itv-table tr th:nth-last-child(5)").css("width", "7.5%") ;
# ~ ;
# }
# my $first_table_multi_select_table_cells_str = join(",",@first_table_multi_select_table_cells) ;
# &common_min_table_select_fixed_width_jquery($first_table_multi_select_table_cells_str ) ;
# &common_min_table_select_default_values_jquery ;
# &common_min_table_update_checkbox_col("3") ;
my $ first_table_multi_select_table_cells_str = join ( "," , @ first_table_multi_select_table_cells ) ;
# $useropts{table_id}
& common_min_table_select_fixed_width_jquery ( $ first_table_multi_select_table_cells_str ) ;
& common_min_table_select_prevent_dropdown_overlap_jquery ;
& common_min_table_select_default_values_jquery ;
& common_min_table_update_checkbox_col ( "3" , "content" , "[id^='textareaComments_'],[id^='selectFixture_check_'],[id^='selectStatus_'],[id^='selectShift_monitor_1_'],[id^='selectShift_monitor_2_'],[id^='selectShift_monitor_3_'],[id^='selectShift_monitor_4_'],[id^='textareaShift_monitor_notes_1_'],[id^='textareaShift_monitor_notes_2_'],[id^='textareaShift_monitor_notes_3_'],[id^='textareaShift_monitor_notes_4_']" ) ;
# my $default_javascript_by_id_str = join (",",@default_javascript_by_id) ;
# $trigger_jquery_raw .= qq~
# all_def_vals = {$default_javascript_by_id_str} ;
# \$("#$useropts{table_id}").on("change","[id^='selectFixture_check_'],[id^='selectStatus_']", function (event) {
# event.preventDefault();
# console.log("2 update : "+this.id) ;
# check_whether_to_update(this.id);
# });
# ~ ;
# &common_min_table_update_checkbox_col("3") ;
$ fnsortorder = 'asc' ;
& common_min_extra_crumb ( "$lcpage" , "Search Screen" ) ;
} #------------------------------------------------------------------------------------------
sub thead {
# &common_min_thead ;
} #-------------------------------------------------------------------------------
sub page_opts {
our $ glyphicon = 'list' ;
# our $lcpage = 'monitor-allocations' ;
our $ lcpage = 'monitoring-report' ;
& common_page_name ;
our $ table = 'event_quotes' ;
$ page_title = 'Monitor Allocations' ;
} #-------------------------------------------------------------------------------
sub report_screen {
our $ lcol = 3 ;
our $ fcol = 5 ;
$ print_box_content_rows . = & common_min_forms_start ( 'report' ) ;
& common_min_select_opts ( 'client_id' , 'customers' , 'name' , '' , '' , '' , "events='1'" ) ;
$ allow_deselect { client_id } = 1 ;
$ opts { client_id } =~ s/value="$i{client_id}"/value="$i{client_id}" SELECTED/g if $ i { client_id } ;
$ print_box_content_rows . = & common_min_form_select ( 'client_id' , '' ) ;
my ( $ sql_next_day ) = & common_add_delta_days ( 1 ) ;
my ( $ next_year , $ next_month , $ next_day ) = split ( /\-/ , $ sql_next_day ) ;
$ 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_datepicker ( 'date_to' , "$next_year-$next_month-$next_day" ) ; #unless $i{date_from} ;
push @ date_value_ids , "input[name='date_from']" ;
push @ date_value_ids , "input[name='date_to']" ;
& common_min_table_validate_date_inputs_jquery ;
$ preferred_title { monitor_id } = "Monitor" ;
# &db_min_ro('users',"id,name","`user_type` = 'support' OR `user_type` = 'casual_calibrator'",'','') ;
# &db_min_ro('users',"id,name,username","`name` NOT LIKE 'Rory%'",'','') ;
$ selected { monitor_id } { all } = 'SELECTED' ;
# if ($i{monitor_id}) {
# $selected{monitor_id}{$i{monitor_id}} = 'SELECTED' ;
# $selected{monitor_id}{all} = '' ;
# }
# foreach (sort {$db{users}{$a}{name} cmp $db{users}{$b}{name}} keys %{$db{users}}) {
# next if $useropts{it}{$db{users}{$_}{username}} ;
# $opts{monitor_id} .= qq~<option value="$_" $selected{monitor_id}{$_}>$db{users}{$_}{name}</option>~ ;
# }
$ opts { monitor_id } . = qq~<option value="all" $selected{monitor_id}{all}>All</option>~ ;
$ print_box_content_rows . = & common_min_form_select ( 'monitor_id' , '' ) ;
$ print_box_content_rows . = & common_min_forms_end ( '' , '' , 'report' ) ;
& common_min_search_screen ;
} #-------------------------------------------------------------------------------
sub screen3 {
& thead ;
if ( $ isaved ) { $ alert = & common_min_alert ( 'success' , "$ucpage $isaved!" , 'ok' ) ; } else { & common_min_alert_type ; }
# my $page = "$lcpage\s" ;
my $ page = "event-quotes" ;
if ( $ s { no } ) { $ page = $ lcpage ; }
# &db_min_ro('daily_monitor_ids','date,monitor_ids') ;
my @ sql_col_display_2 = @ sql_col_display ;
@ sql_col_display = @ sql_col_display_extra ;
our % custom_column_styles = ( ) ;
$ custom_column_styles { fixture_check } = qq~style="width:7%;min-width:150px;"~ ;
$ custom_column_styles { status } = qq~style="width:7%;min-width:150px;"~ ;
$ custom_column_styles { comments } = qq~style="width:7%;min-width:150px;"~ ;
& common_min_thead ;
$ print_box_content_rows . = qq ~
< table id = "select_monitors" class = "table table-striped table-bordered bootstrap-datatable responsive" >
$ print_thead
<tbody>
<tr>
$ print_tbody_extra
</tr>
</tbody>
</table> ~ ;
@ sql_col_display = @ sql_col_display_2 ;
& common_min_thead ;
& common_min_table ( 'id' , $ page , 'list' ) ;
our $ savjqy = 1 ;
$ extra_form_fields . = qq ~
< input type = "hidden" name = "date_from" value = "$i{date_from}" >
< input type = "hidden" name = "date_to" value = "$i{date_to}" >
< input type = "hidden" name = "monitor_id" value = "$i{monitor_id}" >
< input type = "hidden" name = "client_id" value = "$i{client_id}" >
~ ;
for ( 1 .. $ date_cnt ) {
$ extra_form_fields . = qq ~
< input type = "hidden" name = "shiftmonitorid_1_$_" id = "shift-monitor-id-1-$_" value = "" >
< input type = "hidden" name = "shiftmonitorid_2_$_" id = "shift-monitor-id-2-$_" value = "" >
< input type = "hidden" name = "shiftmonitorid_3_$_" id = "shift-monitor-id-3-$_" value = "" >
< input type = "hidden" name = "shiftmonitorid_4_$_" id = "shift-monitor-id-4-$_" value = "" >
~ ;
}
# $print_box_content_rows .= &common_min_forms_end('','','save') if $date_inp_val >= $today_val ;
$ 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 = "date_from" value = "$i{date_from}" >
< input type = "hidden" name = "date_to" value = "$i{date_to}" >
< input type = "hidden" name = "monitor_id" value = "$i{monitor_id}" >
< input type = "hidden" name = "isaved" value = "$success" >
</form>
</html>
ENDOFTEXT
#
exit ;
} #------------------------------------------------------------------------------------------
use common ;
use report ;
use xlsxcreator ;
use today ;
# use calibration_test ;
2026-02-03 12:35:43 +00:00
use schedule ;
2025-11-26 09:31:54 +00:00
1 ;