sub fixedsystem_build_table_and_or_excel { my ($report) = @_ ; our @sql_col_display = ("cnt","event","start_date","start_time","venue","region","system_name","online_status","network_test","system_test","test_event","sound_test","overall_status","additional_comments") ; &report_xlsx_export_header("$xlsxreportname",$xlsxdir,'',$xlsx_title_heading) ; $xlsxrow-- ; my $event_cnt = 0 ; our $found_after_date = 0 ; # $format84->set_align('center'); # $format88->set_align('center'); # $format89->set_align('center'); # $format90->set_align('center'); # $format91->set_align('center'); my %defualt_color = () ; $defualt_color{-1} = "#F90D0D" ; $defualt_color{1} = "#51B529" ; my %defualt_color2 = () ; $defualt_color2{1} = "#51B529" ; $defualt_color2{2} = "#F6E305" ; $defualt_color2{3} = "#F90D0D" ; foreach my $id (sort {$db{$table}{$a}{date_from} cmp $db{$table}{$b}{date_from}} keys %{$db{$table}}) { next unless $id ; unless (&common_check_if_string_contains_an_integer($db{$table}{$id}{event_system_id_multiple})) { $db{$table}{$id}{event_system_id_multiple} = ";-1;" ; } my $now_date = int("$now_year$now_mm$now_dd") ; my $end_date = substr($db{$table}{$id}{date_to},0,10) ; $end_date =~ s/\-//g ; $end_date = int($end_date) ; my $is_in_future = ($now_date < $end_date) ? 1 : 0 ; my @system_name_ids = split(/\;/,$db{$table}{$id}{event_system_id_multiple}) ; my @fixed_system_online_status = split(/\;/,$db{$table}{$id}{fixed_system_online_status}) ; my @fixed_system_network_test = split(/\;/,$db{$table}{$id}{fixed_system_network_test}) ; my @fixed_system_system_test = split(/\;/,$db{$table}{$id}{fixed_system_system_test}) ; my @fixed_system_test_event = split(/\;/,$db{$table}{$id}{fixed_system_test_event}) ; my @fixed_system_sound_test = split(/\;/,$db{$table}{$id}{fixed_system_sound_test}) ; my @fixed_system_overall_status = split(/\;/,$db{$table}{$id}{fixed_system_overall_status}) ; my @fixed_system_additional_comments = split(/\;/,$db{$table}{$id}{fixed_system_additional_comments}) ; my $cnt_sys_ids = -1 ; # my @table_op_ids = () ; # for (1 .. $cnt_rows) { # push @table_op_ids,$op_ids[$_ - 1] if $op_ids[$_ - 1] ; # push @table_op_ids,0 unless $op_ids[$_ - 1] ; # } my $system_count = 0 ; # foreach my $event_id (split(";",$db{$table}{$id}{event_system_id_multiple})) { foreach my $event_id (@system_name_ids) { $cnt_sys_ids++ ; next unless $event_id ; next unless $db{event_systems}{$event_id}{system_type} eq 'fixed' ; next if $i{overall_status} ne 'all' and $i{overall_status} and $i{overall_status} ne $fixed_system_overall_status[$cnt_sys_ids] ; $event_cnt++ ; $system_count++ ; $xlsxcol = 0 ; $print_tbody .= qq~~ if $report ; foreach (@sql_col_display) { next unless $_ ; # blank for the buttons column my $formatting = $format84 ; my $val = $db{$table}{$id}{$_} ; my $val_min = $val ; my $align = '' ; my $nowrap = '' ; if ($_ eq 'cnt') { $val = $event_cnt ; } elsif ($_ eq 'event') { $val = "$db{$table}{$id}{ref} ($id)" ; } elsif ($_ eq 'start_date') { $nowrap = 'nowrap' ; $val = substr($db{$table}{$id}{date_from},0,10) ; $align = qq~ class="dt-center"~ ; } elsif ($_ eq 'venue') { my @oids = split(/\,/,$db{$table}{$id}{organisation_ids}) ; foreach $_oid (@oids) { $val .= $db{organisations}{$_oid}{name} . '
' ; } $val = substr($val,0,-4) if $val ; ; } elsif ($_ eq 'region') { $val = $db{regions}{$db{$table}{$id}{region_id}}{code} ; $align = qq~ class="dt-center"~ ; } elsif ($_ eq 'system_name') { $val = '' ; $val = qq~$db{event_systems}{$event_id}{name}~ ; $val .= qq~ ($db{event_systems}{$event_id}{description})~ if $db{event_systems}{$event_id}{description} ; } elsif ($_ eq 'sport') { $val = '' ; foreach my $sport_id (split(",",$db{$table}{$id}{sport_type_ids})) { $db{sport_types}{$sport_id}{name} = uc $db{sport_types}{$sport_id}{name} ; $val .= qq~$db{sport_types}{$sport_id}{name}
~ ; } $val = substr($val,0,-4) if $val ; } elsif ($_ eq 'operator') { $val = '' ; $val = $db{users}{$op_ids[$system_count - 1]}{name} if $op_ids[$system_count - 1] ; } elsif ($_ eq 'start_time') { $val = substr($db{$table}{$id}{date_from},11,5) ; $align = qq~ class="dt-center"~ ; } elsif ($_ eq 'online_status') { if ($is_in_future && $report && ($glod_user_level > 2 || $is_installation_partner || $is_schools_manager)) { my $field = "online_status_$id\_$event_id" ; $align = qq~ class="dt-center $_"~ ; $preferred_title{$field} = "Online Status" ; $opts{$field} = $opts{$_} ; $allow_deselect{$field} = 1 ; $useropts{'common'}{'css'} .= qq~.$_ { min-width:170px; } ~ ; my $ucfirstfield = ucfirst $field ; $val = qq~~ ; if ($fixed_system_online_status[$cnt_sys_ids]) { $trigger_jquery_raw .= qq~ \$("#select$ucfirstfield").val("$fixed_system_online_status[$cnt_sys_ids]") ; \$("#select$ucfirstfield").trigger("chosen:updated") ; ~ ; } $trigger_jquery_raw .= qq~\$("#select$ucfirstfield").chosen({ allow_single_deselect:true });~ ; $val_min = "Online" if $fixed_system_online_status[$cnt_sys_ids] eq '1' ; $val_min = "Offline" if $fixed_system_online_status[$cnt_sys_ids] eq '-1' ; $val_min = "None" unless $val_min ; } else { $val = "Online" if $fixed_system_online_status[$cnt_sys_ids] eq '1' ; $val = "Offline" if $fixed_system_online_status[$cnt_sys_ids] eq '-1' ; $val = "None" unless $val ; $val_min = $val ; } $trigger_jquery_raw .= qq~\$("#itv-table tr:eq($event_cnt) td:nth-last-child(7)").css("background-color","$defualt_color{$fixed_system_online_status[$cnt_sys_ids]}");~ if $fixed_system_online_status[$cnt_sys_ids] ; $formatting = $format94 if $fixed_system_online_status[$cnt_sys_ids] eq '1' ; $formatting = $format96 if $fixed_system_online_status[$cnt_sys_ids] eq '-1' ; } elsif ($_ eq 'network_test') { if ($is_in_future && $report && ($glod_user_level > 2 || $is_installation_partner || $is_schools_manager)) { my $field = "network_test_$id\_$event_id" ; $align = qq~ class="dt-center $_"~ ; $preferred_title{$field} = "Test Network" ; $opts{$field} = $opts{$_} ; $allow_deselect{$field} = 1 ; $useropts{'common'}{'css'} .= qq~.$_ { min-width:170px; } ~ ; my $ucfirstfield = ucfirst $field ; $val = qq~~ ; if ($fixed_system_network_test[$cnt_sys_ids]) { $trigger_jquery_raw .= qq~ \$("#select$ucfirstfield").val("$fixed_system_network_test[$cnt_sys_ids]") ; \$("#select$ucfirstfield").trigger("chosen:updated") ; ~ ; } $trigger_jquery_raw .= qq~\$("#select$ucfirstfield").chosen({ allow_single_deselect:true });~ ; $val_min = "Passed" if $fixed_system_network_test[$cnt_sys_ids] eq '1' ; $val_min = "Failed" if $fixed_system_network_test[$cnt_sys_ids] eq '-1' ; $val_min = "None" unless $val_min ; } else { $val = "Passed" if $fixed_system_network_test[$cnt_sys_ids] eq '1' ; $val = "Failed" if $fixed_system_network_test[$cnt_sys_ids] eq '-1' ; $val = "None" unless $val ; $val_min = $val ; } $trigger_jquery_raw .= qq~\$("#itv-table tr:eq($event_cnt) td:nth-last-child(6)").css("background-color","$defualt_color{$fixed_system_network_test[$cnt_sys_ids]}");~ if $fixed_system_network_test[$cnt_sys_ids] ; $formatting = $format94 if $fixed_system_network_test[$cnt_sys_ids] eq '1' ; $formatting = $format96 if $fixed_system_network_test[$cnt_sys_ids] eq '-1' ; } elsif ($_ eq 'system_test') { if ($is_in_future && $report && ($glod_user_level > 2 || $is_installation_partner || $is_schools_manager)) { my $field = "system_test_$id\_$event_id" ; $align = qq~ class="dt-center $_"~ ; $preferred_title{$field} = "System Test" ; $opts{$field} = $opts{$_} ; $allow_deselect{$field} = 1 ; $useropts{'common'}{'css'} .= qq~.$_ { min-width:170px; } ~ ; # $val = &common_min_form_select_col($field,'') ; my $ucfirstfield = ucfirst $field ; $val = qq~~ ; if ($fixed_system_system_test[$cnt_sys_ids]) { $trigger_jquery_raw .= qq~ \$("#select$ucfirstfield").val("$fixed_system_system_test[$cnt_sys_ids]") ; \$("#select$ucfirstfield").trigger("chosen:updated") ; ~ ; } $trigger_jquery_raw .= qq~\$("#select$ucfirstfield").chosen({ allow_single_deselect:true });~ ; $val_min = "Passed" if $fixed_system_system_test[$cnt_sys_ids] eq '1' ; $val_min = "Failed" if $fixed_system_system_test[$cnt_sys_ids] eq '-1' ; $val_min = "None" unless $val_min ; } else { $val = "Passed" if $fixed_system_system_test[$cnt_sys_ids] eq '1' ; $val = "Failed" if $fixed_system_system_test[$cnt_sys_ids] eq '-1' ; $val = "None" unless $val ; $val_min = $val ; } $trigger_jquery_raw .= qq~\$("#itv-table tr:eq($event_cnt) td:nth-last-child(5)").css("background-color","$defualt_color{$fixed_system_system_test[$cnt_sys_ids]}");~ if $fixed_system_system_test[$cnt_sys_ids] ; $formatting = $format94 if $fixed_system_system_test[$cnt_sys_ids] eq '1' ; $formatting = $format96 if $fixed_system_system_test[$cnt_sys_ids] eq '-1' ; } elsif ($_ eq 'test_event') { if ($is_in_future && $report && ($glod_user_level > 2 || $is_installation_partner || $is_schools_manager)) { my $field = "test_event_$id\_$event_id" ; $align = qq~ class="dt-center $_"~ ; $preferred_title{$field} = "Test Event" ; $opts{$field} = $opts{$_} ; $allow_deselect{$field} = 1 ; $useropts{'common'}{'css'} .= qq~.$_ { min-width:170px; } ~ ; # $val = &common_min_form_select_col($field,'') ; my $ucfirstfield = ucfirst $field ; $val = qq~~ ; if ($fixed_system_test_event[$cnt_sys_ids]) { $trigger_jquery_raw .= qq~ \$("#select$ucfirstfield").val("$fixed_system_test_event[$cnt_sys_ids]") ; \$("#select$ucfirstfield").trigger("chosen:updated") ; ~ ; } $trigger_jquery_raw .= qq~\$("#select$ucfirstfield").chosen({ allow_single_deselect:true });~ ; $val_min = "Good" if $fixed_system_test_event[$cnt_sys_ids] eq '1' ; $val_min = "Not Good" if $fixed_system_test_event[$cnt_sys_ids] eq '-1' ; $val_min = "None" unless $val_min ; } else { $val = "Good" if $fixed_system_test_event[$cnt_sys_ids] eq '1' ; $val = "Not Good" if $fixed_system_test_event[$cnt_sys_ids] eq '-1' ; $val = "None" unless $val ; $val_min = $val ; } $trigger_jquery_raw .= qq~\$("#itv-table tr:eq($event_cnt) td:nth-last-child(4)").css("background-color","$defualt_color{$fixed_system_test_event[$cnt_sys_ids]}");~ if $fixed_system_test_event[$cnt_sys_ids] ; $formatting = $format94 if $fixed_system_test_event[$cnt_sys_ids] eq '1' ; $formatting = $format96 if $fixed_system_test_event[$cnt_sys_ids] eq '-1' ; } elsif ($_ eq 'sound_test') { if ($is_in_future && $report && ($glod_user_level > 2 || $is_installation_partner || $is_schools_manager)) { my $field = "sound_test_$id\_$event_id" ; $align = qq~ class="dt-center $_"~ ; $preferred_title{$field} = "Test Sound" ; $opts{$field} = $opts{$_} ; $allow_deselect{$field} = 1 ; $useropts{'common'}{'css'} .= qq~.$_ { min-width:170px; } ~ ; # $val = &common_min_form_select_col($field,'') ; my $ucfirstfield = ucfirst $field ; $val = qq~~ ; if ($fixed_system_sound_test[$cnt_sys_ids]) { $trigger_jquery_raw .= qq~ \$("#select$ucfirstfield").val("$fixed_system_sound_test[$cnt_sys_ids]") ; \$("#select$ucfirstfield").trigger("chosen:updated") ; ~ ; } $trigger_jquery_raw .= qq~\$("#select$ucfirstfield").chosen({ allow_single_deselect:true });~ ; $val = "None" unless $val ; $val_min = $db{fixed_system_sound_test}{$fixed_system_sound_test[$cnt_sys_ids]}{name} if $fixed_system_sound_test[$cnt_sys_ids] ; $val_min = "None" unless $val_min ; } else { $val = $db{fixed_system_sound_test}{$fixed_system_sound_test[$cnt_sys_ids]}{name} if $fixed_system_sound_test[$cnt_sys_ids] ; $val = "None" unless $val ; $val_min = $val ; } $trigger_jquery_raw .= qq~\$("#itv-table tr:eq($event_cnt) td:nth-last-child(3)").css("background-color","$defualt_color2{$fixed_system_sound_test[$cnt_sys_ids]}");~ if $fixed_system_sound_test[$cnt_sys_ids] ; $formatting = $format94 if $fixed_system_sound_test[$cnt_sys_ids] eq '1' ; $formatting = $format95 if $fixed_system_sound_test[$cnt_sys_ids] eq '2' ; $formatting = $format96 if $fixed_system_sound_test[$cnt_sys_ids] eq '3' ; } elsif ($_ eq 'overall_status') { if ($is_in_future && $report && ($glod_user_level > 2 || $is_installation_partner || $is_schools_manager)) { $found_after_date = 1 ; my $field = "overall_status_$id\_$event_id" ; $align = qq~ class="dt-center $_"~ ; $preferred_title{$field} = "Overall Status" ; $opts{$field} = $opts{$_} ; $allow_deselect{$field} = 1 ; $useropts{'common'}{'css'} .= qq~.$_ { min-width:170px; } ~ ; # $val = &common_min_form_select_col($field,'') ; my $ucfirstfield = ucfirst $field ; $val = qq~~ ; if ($fixed_system_overall_status[$cnt_sys_ids]) { $trigger_jquery_raw .= qq~ \$("#select$ucfirstfield").val("$fixed_system_overall_status[$cnt_sys_ids]") ; \$("#select$ucfirstfield").trigger("chosen:updated") ; ~ ; } $trigger_jquery_raw .= qq~\$("#select$ucfirstfield").chosen({ allow_single_deselect:true });~ ; $val_min = $db{fixed_system_status}{$fixed_system_overall_status[$cnt_sys_ids]}{status} if $fixed_system_overall_status[$cnt_sys_ids] ; $val_min = "None" unless $val_min ; } else { $val = $db{fixed_system_status}{$fixed_system_overall_status[$cnt_sys_ids]}{status} if $fixed_system_overall_status[$cnt_sys_ids] ; $val = "None" unless $val ; $val_min = $val ; } $trigger_jquery_raw .= qq~\$("#itv-table tr:eq($event_cnt) td:nth-last-child(2)").css("background-color","$defualt_color2{$fixed_system_overall_status[$cnt_sys_ids]}");~ if $fixed_system_overall_status[$cnt_sys_ids] ; $formatting = $format94 if $fixed_system_overall_status[$cnt_sys_ids] eq '1' ; $formatting = $format95 if $fixed_system_overall_status[$cnt_sys_ids] eq '2' ; $formatting = $format96 if $fixed_system_overall_status[$cnt_sys_ids] eq '3' ; } elsif ($_ eq 'additional_comments') { if ($is_in_future && $report && ($glod_user_level > 2 || $is_installation_partner || $is_schools_manager)) { my $field = "additional_comments_$id\_$event_id" ; my $ucfirstfield = ucfirst $field ; $align = qq~ class="dt-center $_ controls"~ ; $preferred_title{$field} = "Additional Comments" ; $useropts{'common'}{'css'} .= qq~.$_ { min-width:170px; } ~ ; # $val = &common_min_form_input_col($field,'') ; $val = qq~~ ; if ($fixed_system_additional_comments[$cnt_sys_ids]) { $trigger_jquery_raw .= qq~ \$("#inputAdditional_comments_$id\_$event_id").val("$fixed_system_additional_comments[$cnt_sys_ids]") ; ~ ; } $val_min = $fixed_system_additional_comments[$cnt_sys_ids] ; $val_min = "None" unless $val_min ; } else { $val = $fixed_system_additional_comments[$cnt_sys_ids] ; $val = "None" unless $val ; $val_min = $val ; } } if ($_ ne 'online_status' && $_ ne 'network_test' && $_ ne 'system_test' && $_ ne 'test_event' && $_ ne 'sound_test' && $_ ne 'overall_status' && $_ ne 'additional_comments') { $val_min = $val ; $val_min =~ s/\
/\;/g ; } $print_tbody .= qq~$val~ if $report ; &xlsxcreator_write_xlsx($ws,$xlsxrow,$xlsxcol,$val_min,$formatting) ; $xlsxcol++ ; } $print_tbody .= qq~~ if $report ; $xlsxrow++ ; } } $worksheet{$ws}->set_column(0,0,10); $worksheet{$ws}->set_column(1,1,30); $worksheet{$ws}->set_column(2,3,15); $worksheet{$ws}->set_column(4,4,45); $worksheet{$ws}->set_column(5,5,15); $worksheet{$ws}->set_column(6,6,45); $worksheet{$ws}->set_column(7,12,15); $worksheet{$ws}->set_column(13,13,45); &report_xlsx_export_footer('N',15,$xlsxdir) ; } #------------------------------------------------------------------------------- sub fixedsystem_check_for_overlapping_dates { my ($check_table,$checked_column,$date_from_input,$date_to_input,$sys_ids_input,$get_periods) = @_ ; my %seen_system_id = () ; my %checked_system_id = () ; my %system_start_date = () ; my %system_end_date = () ; my $sys_ids = "" ; if ($get_periods) { $sys_ids = $sys_ids_input ; } foreach my $id (sort keys %{$db{$table}}) { unless ($get_periods) { $sys_ids = $db{$table}{$id}{$checked_column} ; } foreach (split(";",$sys_ids)) { $system_start_date{$_}{$id} = $db{$table}{$id}{date_from} ; $system_end_date{$_}{$id} = $db{$table}{$id}{date_to} ; } } if ($date_from_input and $date_to_input and $sys_ids_input) { foreach (split(";",$sys_ids_input)) { $system_start_date{$_}{-1} = $date_from_input ; $system_end_date{$_}{-1} = $date_to_input ; } } foreach my $id (sort keys %{$db{$table}}) { unless ($get_periods) { $sys_ids = $db{$table}{$id}{$checked_column} ; } foreach my $sys_id (split(";",$sys_ids)) { next unless $sys_id ; if ($seen_system_id{$sys_id} and not $checked_system_id{$sys_id}) { $checked_system_id{$sys_id} = 1 ; foreach my $id2 (keys %{$system_start_date{$sys_id}}) { next if $id2 eq $id ; my $t1 = &common_check_if_time_is_greater($system_start_date{$sys_id}{$id2},$db{$table}{$id}{date_to}) ; ## 21<12 my $t2 = &common_check_if_time_is_greater($system_end_date{$sys_id}{$id2},$db{$table}{$id}{date_to}) ; ## 22<12 my $t3 = &common_check_if_time_is_greater($system_start_date{$sys_id}{$id2},$db{$table}{$id}{date_from}) ; ## 21<11 my $t4 = &common_check_if_time_is_greater($system_end_date{$sys_id}{$id2},$db{$table}{$id}{date_from}) ; ## 22<11 if (($t1 and not $t2) or ($t3 and not $t4) or (not $t3 and $t2) or ($t3 and not $t2)) { my $system_name = qq~$db{$check_table}{$sys_id}{name}~ ; $system_name .= qq~ ($db{$check_table}{$sys_id}{description})~ if $db{$check_table}{$sys_id}{description} ; if ($get_periods) { $overlap_dates{$sys_id}{$id2} = "$db{$table}{$id2}{date_from} - $db{$table}{$id2}{date_to}" ; } else { $trigger_jquery_raw .= qq~ noty({text:'System $system_name and cannot be used in both event $db{$table}{$id}{ref} and $db{$table}{$id2}{ref} as the times ovelap!!',layout:"center",type:"error",timeout:30000}) ; ~ ; } } } } $seen_system_id{$sys_id} = 1 ; } } } #------------------------------------------------------------------------------- 1 ;