aisa/scripts/fixtures_report.pl

663 lines
24 KiB
Perl
Raw Normal View History

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 $open_new_tab = qq~target="_blank"~ ; # opens booking page in a new tab
# our $debug = 1 ;
# our $testing = 1 ;
# if ($username ne 'handre') {
# print "<< MAINTENANCE IN PROGRESS >>" ; exit ;
# }
#-------- page opts --------------------------------------------------------------------------------------------------------------------------------------------------
our %fixtures_status = (1 => 'Pending',2 => 'Booked',3 => 'Completed') ;
# our %coding_provider = (1 => 'SportVot',2 => 'iSport') ;
2026-02-03 12:35:43 +00:00
# our %footage_type = ("s" => "SSS","r" => "Raw") ;
our %footage_type = ("s" => "Pixellot","r" => "YouTube") ;
our %service_types = (1 => "Live Coding",2 => "Individual 48 hrs",3 => "Post Coding 24 hrs") ;
our %coding_type = ("s" => "Standard","p" => "Premium","i" => "Individual") ;
2025-11-26 09:31:54 +00:00
our @months = ("","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec") ;
&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 $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 validate {
} #------------------------------------------------------------------------------------------
sub insert {
} #------------------------------------------------------------------------------------------
sub update {
&db_min_ro($table,"id,fixtures_saved_values","",'','') ;
my %seen_event_id = () ; my %ii = %i ; %i = () ;
foreach (keys %ii) {
# next if $_ !~ /update_/ || ($_ =~ /update_/ && !$ii{$_}) ;
next if $_ !~ /update_/ ;
my @abc = split(/\_/,$_) ;
my $event_id = @abc[-1] ; # or -2?
next if $seen_event_id{$event_id} ;
$seen_event_id{$event_id} = 1 ;
$i{fixtures_saved_values} = qq~~ ;
my @fixtures_saved_values_split = split(/\|/,$db{$table}{$event_id}{fixtures_saved_values}) ;
for my $row_nr (1 .. 100) {
my $input_vals = qq~~ ;
my $upd_field = "update_$row_nr\_$event_id" ;
my $coding_provider_field = "coding_provider_$row_nr\_$event_id" ;
my $status_field = "status_$row_nr\_$event_id" ;
my @parts = split(/\;/, $fixtures_saved_values_split[$row_nr - 1]);
# splice(@parts, -2) if @parts >= 2;
2026-02-03 12:35:43 +00:00
$i{fixtures_saved_values} .= ($ii{$upd_field}) ? join(";",@parts[0..9]) . ';' . qq~$ii{$coding_provider_field}~ . ';' . qq~$ii{$status_field}~ . ';' . qq~$parts[12];$parts[13]~ : qq~$fixtures_saved_values_split[$row_nr - 1]~ ;
$i{fixtures_saved_values} =~ s/;+$//g ;
$i{fixtures_saved_values} .= qq~|~ ;
2025-11-26 09:31:54 +00:00
$ignore{$coding_provider_field} = 1 ;
$ignore{$status_field} = 1 ;
2026-02-03 12:35:43 +00:00
$ignore{$upd_field} = 1 ;
2025-11-26 09:31:54 +00:00
}
2026-02-03 12:35:43 +00:00
$i{fixtures_saved_values} =~ s/\|+$//g ;
2025-11-26 09:31:54 +00:00
# $i{fixtures_saved_values} =~ s/([a-zA-Z0-9;])\|+\z/$1/;
$i{fixtures_saved_values} =~ s/([a-zA-Z0-9]);+(\|)/$1$2/g;
$i{fixtures_saved_values} =~ s/([a-zA-Z0-9])\|+$/$1/;
2026-02-03 12:35:43 +00:00
$ignore{fixtures_saved_values} = (($i{fixtures_saved_values} && $db{$table}{$event_id}{fixtures_saved_values} && $i{fixtures_saved_values} eq $db{$table}{$event_id}{fixtures_saved_values}) || (!$i{fixtures_saved_values} && !$db{$table}{$event_id}{fixtures_saved_values})) ? 1 : 0 ;
2025-11-26 09:31:54 +00:00
&db_min_upd($table,"id='$event_id'") ;
}
%i = %ii ;
} #------------------------------------------------------------------------------------------
sub report_ifields {
&load_search_vars ;
if ($i{client_id}) {
push @report_sql, "(client_id = '$i{client_id}')" ;
&db_min_ro('customers','id,name',"`id`='$i{client_id}'",'','') ;
push @report_results, "customer = `$db{customers}{$i{client_id}}{name}`" ;
}
2026-02-03 12:35:43 +00:00
if ($i{date_from} && $i{date_to}) {
push @report_sql, " (('$i{date_from} 00:00:00' <= start_date_time AND start_date_time <= '$i{date_to} 23:59:59') OR ('$i{date_from} 00:00:00' <= end_date_time AND end_date_time <= '$i{date_to} 23:59:59' AND end_date_time IS NOT NULL) OR (start_date_time <= '$i{date_from} 00:00:00' AND '$i{date_to} 23:59:59' <= end_date_time AND end_date_time IS NOT NULL)) " ;
our @months = ("","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec") ;
my $start_date_from = &common_min_date_as_string($i{date_from}) ;
my $start_date_to = &common_min_date_as_string($i{date_to}) ;
push @report_results, " (DATE BETWEEN '$start_date_from' AND '$start_date_to') " ;
} elsif ($i{date_from} && !$i{date_to}) {
push @report_sql, " ('$i{date_from} 00:00:00' <= start_date_time) " ;
our @months = ("","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec") ;
my $start_date_from = &common_min_date_as_string($i{date_from}) ;
push @report_results, " (DATE AFTER '$start_date_from') " ;
} elsif (!$i{date_from} && $i{date_to}) {
push @report_sql, " ('$i{date_to} 23:59:59' <= end_date_time AND end_date_time IS NOT NULL) " ;
our @months = ("","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec") ;
my $start_date_to = &common_min_date_as_string($i{date_to}) ;
push @report_results, " (DATE BEFORE '$start_date_to') " ;
}
# if ($i{date_from}) {
# push @report_sql, "(start_date_time >= '$i{date_from} 00:00:00')" ;
# my $date_from = &common_min_date_as_string($i{date_from}) ;
# push @report_results, "Start Date Is After `$date_from`" ;
# }
# if ($i{date_to}) {
# push @report_sql, "(start_date_time <= '$i{date_to} 23:59:59')" ;
# my $date_to = &common_min_date_as_string($i{date_to}) ;
# push @report_results, "Start Date Is Before `$date_to`" ;
# }
2025-11-26 09:31:54 +00:00
if ($i{footage_type_id}) {
2026-02-03 12:35:43 +00:00
# push @report_sql, "(fixtures_saved_values REGEXP ';$i{footage_type_id};[0-9a-z];[0-9a-z]+\\|' OR fixtures_saved_values REGEXP ';$i{footage_type_id};[0-9a-z];[0-9a-z]+\$')" ;
2025-11-26 09:31:54 +00:00
push @report_results, "Footage Type is `$footage_type{$i{footage_type_id}}`" ;
}
if ($i{service_type_id}) {
2026-02-03 12:35:43 +00:00
# push @report_sql, "(service_type_id = '$i{service_type_id}')" ;
2025-11-26 09:31:54 +00:00
push @report_results, "Service Type is `$service_types{$i{service_type_id}}`" ;
}
if ($i{coding_provider_id}) {
2026-02-03 12:35:43 +00:00
# push @report_sql, "(fixtures_saved_values REGEXP ';$i{coding_provider_id};[0-9a-z]+\\|' OR fixtures_saved_values REGEXP ';$i{coding_provider_id};[0-9a-z]+\$')" ;
2025-11-26 09:31:54 +00:00
push @report_results, "Coding Provider is `$coding_type{$i{coding_provider_id}}`" ;
}
if ($i{status_id}) {
2026-02-03 12:35:43 +00:00
# push @report_sql, "(fixtures_saved_values LIKE '%;$i{status_id}' OR fixtures_saved_values LIKE '%;$i{status_id}|%')" ;
2025-11-26 09:31:54 +00:00
push @report_results, "Coding Provider is `$fixtures_status{$i{status_id}}`" ;
}
$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 list_screen {
$print_box_content_rows .= &common_min_forms_start("$lcpage") ;
our $set_up_groups = 1 ;
&load_list_vars("$srch_where_sql") ;
$fcol = 12 ;
my $report = 1 ;
our $xlsxdir = "fixtures_report" ;
our $xlsxreportname = "Fixtures_Report" ;
my $date = &common_write_date_interval($i{date_from},$i{date_to}) ;
our $xlsx_title_heading = "Fixtures Report $date" ;
&build_table_and_or_excel(1) ;
$fnsortorder = 'asc' ;
&common_min_extra_crumb("$lcpage","Search Screen") ;
$trigger_jquery_raw .= qq~
\$("#savebutt").click(function() {
\$("#$lcpage-form").submit() ;
}) ;
~ ;
} #------------------------------------------------------------------------------------------
sub build_table_and_or_excel {
my ($report) = @_ ;
2026-02-03 12:35:43 +00:00
our @sql_col_display = ("nr","start_date_time","sport","age_group","team","home_team","ht_colour","away_team","coding_type","footage_type","service_type","coding_provider","status") ;
2025-11-26 09:31:54 +00:00
&report_xlsx_export_header("$xlsxreportname",$xlsxdir,'',$xlsx_title_heading) ;
push @sql_col_display,"update" ;
my $nr_of_cols = scalar @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-- ;
my $cali_cnt = 0 ; my $found_editable = 0 ; my @all_select_ids = () ;
$format84 -> set_align("center") ;
2026-02-03 12:35:43 +00:00
my $start_date_input = "$i{date_from}000000" ;
$start_date_input =~ s/-//g ;
my $end_date_input = "$i{date_to}235959" ;
$end_date_input =~ s/-//g ;
2025-11-26 09:31:54 +00:00
# foreach my $id (sort {$db{$table}{$a}{date_from} cmp $db{$table}{$b}{date_from}} keys %{$db{$table}}) {
foreach my $id (sort { $b <=> $a } keys %{$db{$table}}) {
my @fixtures_split = split(/\|/,$db{$table}{$id}{fixtures_saved_values}) ;
my @sport_type_ids = split(/\;/,$db{$table}{$id}{sport_type_ids}) ;
my $row_cnt = - 1;
# foreach my $row (@fixtures_split) {
foreach my $row_nr (1 .. $db{$table}{$id}{total_fixtures}) {
my @fixtures_split_2 = split(/\;/,$fixtures_split[$row_nr - 1]) ;
my $col_cnt = -2 ;
2026-02-03 12:35:43 +00:00
2025-11-26 09:31:54 +00:00
$row_cnt++ ;
2026-02-03 12:35:43 +00:00
next if $i{footage_type_id} && $i{footage_type_id} ne 'all' && $fixtures_split_2[8] ne $i{footage_type_id} ;
next if $i{service_type_id} && $i{service_type_id} ne 'all' && (($fixtures_split_2[9] && $fixtures_split_2[9] ne $i{service_type_id}) || (!$fixtures_split_2[9] && $db{$table}{$id}{service_type_id} ne $i{service_type_id})) ;
next if $i{coding_provider_id} && $i{coding_provider_id} ne 'all' && $fixtures_split_2[10] ne $i{coding_provider_id} ;
next if $i{status_id} && $i{status_id} ne 'all' && $fixtures_split_2[11] ne $i{status_id} ;
2025-11-26 09:31:54 +00:00
# last if $db{$table}{$id}{total_fixtures} eq $row_cnt ;
2026-02-03 12:35:43 +00:00
my $date_val = ($fixtures_split_2[0]) ? $fixtures_split_2[0] : $db{$table}{$id}{start_date_time} ;
$date_val =~ s/://g ;
$date_val =~ s/-//g ;
$date_val =~ s/ //g ;
next if ($date_val < $start_date_input && $start_date_input) || ($date_val > $end_date_input && $end_date_input) ;
$cali_cnt++ ;
2025-11-26 09:31:54 +00:00
$xlsxcol = 0 ;
our $default_javascript = qq~~ ;
foreach (@sql_col_display) {
# &common_debug("1. XLSX >>> $_") if !$report ;
$nr_of_cols_cnt-- ;
next unless $_ ; # blank for the buttons column
my $formatting = $format84 ;
my $val = $db{$table}{$id}{$_} ;
my $val_xlsx = 'MUSTBEBLANK' ;
my $align = qq~ class="dt-center"~ ;
my $nowrap = '' ;
# &common_debug("2. XLSX >>> val_min=$val_min") if !$report ;
my $sys_day_cnt = $cnt{$event_sys_id}{$id} ;
$col_cnt++ ;
my $field = "" ; my $default_val = $fixtures_split_2[$col_cnt] ; my $only_display_val = 0 ; my $background_color = "#424949" ; my $default_val_is_saved = ($default_val) ? 1 : 0 ;
# our %fixtures_status = (1 => 'Pending',2 => 'Booked',3 => 'Completed') ;
# our %coding_provider = (1 => 'SportVot',2 => 'iSport') ;
# our %footage_type = ("s" => "SSS","r" => "Raw") ;
# our %service_types = (1 => "Live Coding",2 => "Post Coding 12 hrs",3 => "Post Coding 24 hrs") ;
# our %coding_type = ("s" => "Standard","p" => "Premium") ;
# our @months = ("","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec") ;
if ($_ eq 'nr') {
$val = &common_min_get_event_quote_button($id,$table,'analytics-event-bookings') ;
2026-02-03 12:35:43 +00:00
$val .= qq~<span title="Event Quote : $db{$table}{$id}{event_quote_id}" data-toggle="tooltip" data-placement="top"><a href="javascript:editMinItem('$db{$table}{$id}{event_quote_id}','event-quotes');" style="color:black;"><i class="glyphicons glyphicons-paired icon-white"></i></a></span>~ if $db{$table}{$id}{event_quote_id} && $db{$table}{$id}{event_quote_id} > 0 ;
2025-11-26 09:31:54 +00:00
$val_xlsx = $id ;
} elsif ($_ eq "start_date_time") {
$val = ($fixtures_split_2[0]) ? &common_min_date_as_string($fixtures_split_2[0]) : &common_min_date_as_string($db{$table}{$id}{start_date_time}) ;
} elsif ($_ eq "sport") {
$val = ($fixtures_split_2[1] && $db{$table}{$id}{sport_type_ids} =~ /\b$fixtures_split_2[1]\b/) ? $db{sport_types}{$fixtures_split_2[1]}{name} : ($db{$table}{$id}{sport_type_ids} !~ /;/ && !$fixtures_split_2[1]) ? $db{sport_types}{$db{$table}{$id}{sport_type_ids}}{name} : "" ;
} elsif ($_ eq "age_group") {
$val = ucfirst $fixtures_split_2[2] ;
} elsif ($_ eq "team") {
$val = uc $fixtures_split_2[3] ;
} elsif ($_ eq "home_team") {
$val = $db{teams}{$fixtures_split_2[4]}{name} ;
} elsif ($_ eq "ht_colour") {
$val = $db{analytics_ht_colors}{$fixtures_split_2[5]}{name} ;
} elsif ($_ eq "away_team") {
$val = $db{teams}{$fixtures_split_2[6]}{name} ;
} elsif ($_ eq "coding_type") {
$val = $coding_type{$fixtures_split_2[7]} ;
} elsif ($_ eq "footage_type") {
$val = $footage_type{$fixtures_split_2[8]} ;
2026-02-03 12:35:43 +00:00
} elsif ($_ eq "service_type") {
$val = ($fixtures_split_2[9]) ? $service_types{$fixtures_split_2[9]} : $service_types{$db{$table}{$id}{service_type_id}} ;
2025-11-26 09:31:54 +00:00
} elsif ($_ eq 'coding_provider') {
$field = "coding_provider_$row_nr\_$id" ;
$opts{$field} = $opts{coding_provider_id} ;
$val = &common_min_table_select($field,$default_val,$only_display_val,$cali_cnt,$last_child{$_},$background_color,$default_val,$_) ;
$val_xlsx = $coding_provider{$default_val} ;
} elsif ($_ eq 'status') {
# if ($default_val eq '1') { #calibrating
# $background_color = "#FFA500" ; orange
# $formatting = $format89 ;
# } elsif ($default_val eq '2') { #cancelled
# $background_color = "#AD0502" ; red
# $formatting = $format90 ;
# } elsif ($default_val eq '3') { #done
# $background_color = "#2ECC71" ; greeen
# $formatting = $format88 ;
# } elsif ($default_val eq '4') {
# $background_color = "#424949" ;
# }
# rgb(81, 203, 242) blue
if ($default_val eq '1') {
$background_color = "#FFA500" ;
} elsif ($default_val eq '2') { #
$background_color = "rgb(81, 203, 242)" ;
} elsif ($default_val eq '3') {
$background_color = "#2ECC71" ;
}
$field = "status_$row_nr\_$id" ;
$opts{$field} = $opts{status_id} ;
# 1;;;open;a;7495;1;6684;s;s;s;s|2;;;u19;b;845;1;778;p;r;p;r|3;2025-06-18 06:00:00;8;u17;c;54;1;3975;s;s;s;s
$val = &common_min_table_select($field,$default_val,$only_display_val,$cali_cnt,$last_child{$_},$background_color,$default_val,$_) ;
$val_xlsx = $fixtures_status{$default_val} ;
} elsif ($_ eq 'update') {
$val = &common_min_table_checkbox("update_$row_nr\_$id") ;
chop $default_javascript if $default_javascript ;
if ($default_javascript) {
push @default_javascript_by_id, qq~"$row_nr\_$id":{$default_javascript}~ ;
push @all_update_field_ids,"#selectStatus_$row_nr\_$id,#selectCoding_provider_$row_nr\_$id" ;
}
}
$print_tbody .= qq~<td $align $nowrap>$val</td>~ if $report ;
$val_xlsx = $val if $val_xlsx eq 'MUSTBEBLANK' ;
&xlsxcreator_write_xlsx($ws,$xlsxrow,$xlsxcol,$val_xlsx,$formatting) if $val_xlsx && $_ ne 'update' ;
$xlsxcol++ ;
}
$print_tbody .= qq~</tr>~ if $report ;
$xlsxrow++ ;
}
}
# \$("#itv-table tr th:nth-last-child(1)").css("width","0%") ;
# \$("#itv-table tr th:nth-last-child(1)").css("display","none") ;
my $all_select_ids_string = join(",",@all_select_ids) ;
$trigger_jquery_raw .= qq~\$("$all_select_ids_string").chosen({allow_single_deselect:true});~ ;
&common_min_table_select_jquery("#$useropts{table_id} td:nth-last-child(3),#$useropts{table_id} td:nth-last-child(2)") ;
&common_min_table_update_checkbox_col("2") ;
$worksheet{$ws}->set_column(0,0,10) ;
$worksheet{$ws}->set_column(1,11,20) ;
&report_xlsx_export_footer('L',15,$xlsxdir) ;
} #-------------------------------------------------------------------------------
sub thead {
&common_min_thead ;
} #-------------------------------------------------------------------------------
sub page_opts {
our $glyphicon = 'list' ;
our $lcpage = 'fixtures-report' ; $ucpage = uc $lcpage ; $ucfirstpage = ucfirst $lcpage ;
&common_page_name ;
our $table = 'analytics_event_bookings' ;
$page_title = 'Fixtures Report' ;
} #-------------------------------------------------------------------------------
sub report_screen {
our $lcol = 3 ;
our $fcol = 5 ;
my %select = () ;
&common_min_select_opts('client_id','customers','name','','','',"events='1'") ;
$opts{client_id} =~ s/value="$i{client_id}"/value="$i{client_id}" SELECTED/g if $i{client_id} ;
my ($sql_next_day) = &common_add_delta_days(10) ;
my ($next_year,$next_month,$next_day) = split(/\-/,$sql_next_day) ;
foreach (sort {$a <=> $b} keys %coding_provider) {
$opts{coding_provider_id} .= qq~<option value="$_">$coding_provider{$_}</option>~ ;
}
$opts{coding_provider_id} =~ s/value="$i{coding_provider_id}"/value="$i{coding_provider_id}" SELECTED/g if $i{coding_provider_id} ;
foreach (keys %footage_type) {
$opts{footage_type_id} .= qq~<option value="$_">$footage_type{$_}</option>~ ;
}
$opts{footage_type_id} =~ s/value="$i{footage_type_id}"/value="$i{footage_type_id}" SELECTED/g if $i{footage_type_id} ;
foreach (keys %service_types) {
$opts{service_type_id} .= qq~<option value="$_">$service_types{$_}</option>~ ;
}
$opts{service_type_id} =~ s/value="$i{service_type_id}"/value="$i{service_type_id}" SELECTED/g if $i{service_type_id} ;
foreach (keys %fixtures_status) {
$opts{status_id} .= qq~<option value="$_">$fixtures_status{$_}</option>~ ;
}
$opts{status_id} =~ s/value="$i{status_id}"/value="$i{status_id}" SELECTED/g if $i{status_id} ;
$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_datepicker('date_to',"$next_year-$next_month-$next_day") ;
$print_box_content_rows .= &common_min_form_select('coding_provider_id',$i{coding_provider_id}) ;
$print_box_content_rows .= &common_min_form_select('footage_type_id',$i{footage_type_id}) ;
$print_box_content_rows .= &common_min_form_select('service_type_id',$i{service_type_id}) ;
$print_box_content_rows .= &common_min_form_select('status_id',$i{status_id}) ;
$print_box_content_rows .= &common_min_forms_end('','','report') ;
&common_min_search_screen ;
} #-------------------------------------------------------------------------------
sub screen3 {
$custom_column_styles{coding_provider} = qq~style="width:12.5%;min-width:120px;"~ ;
$custom_column_styles{status} = qq~style="width:12.5%;min-width:120px;"~ ;
&thead;
if ($isaved) { $alert = &common_min_alert('success',"$ucpage $isaved!",'ok') ; } else { &common_min_alert_type ; }
# my $page = "$lcpage\s" ;
my $page = "analytics-event-bookings" ;
if ($s{no}) { $page = $lcpage ; }
&common_min_table('id',$page,'list') ;
our $savjqy = 1 ;
# &common_min_extra_crumb("manage-$lcpage\s","Manage $ucfirstpage\s") ;
$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="coding_provider_id" value="$i{coding_provider_id}">
<input type="hidden" name="footage_type_id" value="$i{footage_type_id}">
<input type="hidden" name="service_type_id" value="$i{service_type_id}">
<input type="hidden" name="status_id" value="$i{status_id}">
~;
$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="coding_provider_id" value="$i{coding_provider_id}">
<input type="hidden" name="footage_type_id" value="$i{footage_type_id}">
<input type="hidden" name="service_type_id" value="$i{service_type_id}">
<input type="hidden" name="status_id" value="$i{status_id}">
<input type="hidden" name="isaved" value="$success">
</form>
</html>
ENDOFTEXT
#
exit ;
} #------------------------------------------------------------------------------------------
sub load_list_vars {
my ($where) = @_ ;
2026-02-03 12:35:43 +00:00
&db_min_ro($table,'id,event_quote_id,fixtures_saved_values,event_completed,event_accepted,event_pending,event_cancelled,event_rejected,sport_type_ids,start_date_time,region_id,client_id,total_fixtures,service_type_id',$where,'','') ;
2025-11-26 09:31:54 +00:00
my %seen_region = () ; my %seen_client = () ; my $cnt_client = 0 ;
foreach (keys %{$db{$table}}) {
$seen_region{$db{$table}{$_}{region_id}} = 1 ;
$seen_client{$db{$table}{$_}{client_id}} = 1 ;
$cnt_client++ ;
}
&db_min_ro('sport_types','id,name','','','') ;
&db_min_ro('analytics_ht_colors','id,name','','','') ;
2026-02-03 12:35:43 +00:00
&db_min_ro('users','id,name,username',"user_type='coding_provider'",'','') ;
2025-11-26 09:31:54 +00:00
# my $teams_sql_where = join (" OR ", map { "region_id='$_' OR (region_id='0' AND matched_region_id ='$_')" } keys %seen_region) ;
# $teams_sql_where .= qq~ OR ~ if $cnt_client && $teams_sql_where ;
# my $teams_sql_where .= join (" OR ", map { "aisa_client_id='$_'" } keys %seen_client) ;
&db_switch_conn('sss') ;
&db_min_ro('teams','id,name',"",'','') ;
&db_switch_conn('aisa') ;
foreach (keys %{$db{users}}) {
2026-02-03 12:35:43 +00:00
$opts{coding_provider_id} .= qq~<option value="$_">$db{users}{$_}{name} [$db{users}{$_}{username}]</option>~ ;
2025-11-26 09:31:54 +00:00
}
# # our %coding_provider = (1 => 'SportVot',2 => 'iSport') ;
# foreach (keys %coding_provider) {
foreach (keys %fixtures_status) {
$opts{status_id} .= qq~<option value="$_">$fixtures_status{$_}</option>~ ;
}
} #------------------------------------------------------------------------------------------
use common ;
use report ;
use xlsxcreator ;
use today ;
1;