1883 lines
77 KiB
Perl
1883 lines
77 KiB
Perl
sub schedule_load_list_vars {
|
|
|
|
my ($where) = @_ ;
|
|
|
|
&db_min_ro('regions','*','','','') ;
|
|
|
|
&db_min_ro('users','id,name,user_type,username,region_ids',"`name` NOT LIKE 'Rory%' AND `name` NOT LIKE 'Handre%'",'','') ;
|
|
$opts{schedule_users} .= qq~<option value="none">>>>None<<<</option>~ ;
|
|
# $opts{head_operator} .= qq~<option value="none">>>>None<<<</option>~ ;
|
|
foreach my $_uid (sort {$db{users}{$a}{name} cmp $db{users}{$b}{name}} keys %{$db{users}}) {
|
|
next if $useropts{it}{$db{users}{$_uid}{username}} ;
|
|
|
|
my $regions = qq~~ ;
|
|
foreach (split(/\,/,$db{users}{$_uid}{region_ids})) {
|
|
$regions .= qq~$db{regions}{$_}{code},~ ;
|
|
}
|
|
chop $regions if $regions ;
|
|
$regions = qq~[$regions]~ if $regions ;
|
|
|
|
# if ($db{users}{$_uid}{user_type} eq 'support' || $db{users}{$_uid}{user_type} eq 'manager' || $db{users}{$_uid}{user_type} eq 'casual_calibrator' || $monitoring_report) {
|
|
if ($db{users}{$_uid}{user_type} eq 'casual_calibrator' || (($monitoring_report || $troubleshoot_monitoring_report) && $db{users}{$_uid}{user_type} ne 'casual_c' && $db{users}{$_uid}{user_type} ne 'schools_manager' && $db{users}{$_uid}{user_type} ne 'support' && $db{users}{$_uid}{user_type} ne 'permanent')) {
|
|
$opts{schedule_users} .= qq~<option value="$_uid">$db{users}{$_uid}{name} $regions</option>~ ;
|
|
}
|
|
|
|
if (($db{users}{$_uid}{user_type} eq 'support' || $db{users}{$_uid}{user_type} eq 'casual_calibrator') && $temp_calibrator_report) {
|
|
$opts{support_users} .= qq~<option value='$_uid'>$db{users}{$_uid}{name} $regions</option>~ ;
|
|
$tot_support_users_cnt++;
|
|
}
|
|
|
|
if ($db{users}{$_uid}{user_type} eq 'casual_c') {
|
|
$opts{fixture_check} .= qq~<option value='$_uid'>$db{users}{$_uid}{name}</option>~ ;
|
|
}
|
|
}
|
|
|
|
my $event_systems_sql_where = ($monitoring_report || $troubleshoot_monitoring_report) ? "" : "system_type = 'mobile'" ;
|
|
|
|
&db_min_ro('event_systems','*',$event_systems_sql_where,'','') ;
|
|
|
|
&db_min_ro($table,"id,club_ids,qty,ref,organisation_ids,quote_accepted,event_system_id_multiple,region_id,sport_type_ids,operator_ids,date_from,date_to,times_from,times_to,daily_operator_ids,days_active,monitor_ids,temp_calibrator_ids$extra_column","$where AND `quote_accepted` = '1'",'','') ;
|
|
|
|
my $min_id = 0 ; my $max_id = 0 ;
|
|
|
|
foreach my $id (keys %{$db{$table}}) {
|
|
|
|
next unless $id ; my $cnt = 0 ;
|
|
|
|
my @ed_from = &common_split_sql_time($db{$table}{$id}{date_from}) ;
|
|
my @ed_to = &common_split_sql_time($db{$table}{$id}{date_to}) ;
|
|
|
|
&common_date_array("$ed_from[0]$ed_from[1]$ed_from[2]","$ed_to[0]$ed_to[1]$ed_to[2]") ;
|
|
|
|
$sort_calibration_by_time_ref{"$ed_from[0]$ed_from[1]$ed_from[2]$ed_from[3]$ed_from[4]-$id"} = $id ;
|
|
|
|
}
|
|
|
|
&db_min_ro('sport_types','*','','','') ;
|
|
&db_min_ro('organisations','id,name','','','') ;
|
|
&db_min_ro('clubs','id,name','','','') if $monitoring_report || $troubleshoot_monitoring_report ;
|
|
|
|
our $table_ = "shift_operator_ids" ;
|
|
my $col_ = ($monitoring_report) ? "monitor_ids" : ($troubleshoot_monitoring_report) ? "troubleshoot_monitor_ids" : "temp_calibrator_ids,temp_calibrator_support_shifts" ;
|
|
my $col2_ = ($monitoring_report) ? ",monitor_notes" : ($troubleshoot_monitoring_report) ? ",troubleshoot_monitor_notes" : "" ;
|
|
|
|
&db_min_ro($table_,"date$col2_,$col_","`date` >= '$i{date_from}' AND `date` <= '$i{date_to}'") ;
|
|
|
|
} #------------------------------------------------------------------------------------------
|
|
|
|
sub schedule_build_extra_table {
|
|
|
|
my ($field_name,$table_name,$table_col_name,$table_col_name_notes,$table_id) = @_ ;
|
|
|
|
my $ws2 = join ' ', map { ucfirst $_ } split /_/, $field_name ;
|
|
$ws2 .= "s" ;
|
|
|
|
&xlsxcreator_add_worksheet($ws2) ;
|
|
|
|
my $col2 = 0 ;
|
|
foreach (@sql_col_display_extra) {
|
|
next if $_ eq "update" || !$_ || $_ eq 'notes' ;
|
|
my $coltitle = $_ ;
|
|
$coltitle =~ s/\_id//g ;
|
|
$coltitle =~ s/\_/ /g ;
|
|
my $ucfirst = join '', map { ucfirst lc } split /(\s+)/, $coltitle;
|
|
&xlsxcreator_write_xlsx($ws2,0,$col2,$ucfirst,$format_management_report_headings) ;
|
|
$col2++;
|
|
}
|
|
$col2=0 ;
|
|
&xlsxcreator_freeze_panes($ws2,1,0) ; # Freeze the first 3 rows
|
|
|
|
my $uc_field_name = ucfirst $field_name ;
|
|
|
|
# $db{$table_name}{$i{date}}{$table_col_name} = qq~147;132|||~ ;
|
|
|
|
# for (0 .. 3) { $schedule_ids[$_] = "null" unless $schedule_ids[$_] ; }
|
|
$format84 -> set_left('1') ;
|
|
|
|
my ($s_year,$s_mon,$s_day) = split("-",$i{date_from}) ;
|
|
my ($e_year,$e_mon,$e_day) = split("-",$i{date_to}) ;
|
|
$s_mon = sprintf("%02d",$s_mon) ;
|
|
$s_day = sprintf("%02d",$s_day) ;
|
|
|
|
our $date_cnt = 1 ; my $row_cnt = 0 ;
|
|
|
|
return if int("$s_year$s_mon$s_day") > int("$e_year$e_mon$e_day") ;
|
|
|
|
our @months = ("","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec") ;
|
|
|
|
my %row_cnt_shifts = () ; my $max_row_cnt = 0 ;
|
|
|
|
while (int("$s_year$s_mon$s_day") <= int("$e_year$e_mon$e_day")) {
|
|
|
|
$db{$table_name}{"$s_year-$s_mon-$s_day"}{$table_col_name} =~ s/\;/\,/g ;
|
|
my @schedule_ids = split(/\|/,$db{$table_name}{"$s_year-$s_mon-$s_day"}{$table_col_name}) ;
|
|
|
|
my $date = "$s_year-$s_mon-$s_day" ;
|
|
|
|
my $date_str = &common_min_date_as_string($date) ;
|
|
|
|
our $default_javascript = "" ; my %default_javascript_short = () ;
|
|
|
|
my $val_notes = qq~~ ;
|
|
|
|
foreach my $col (@sql_col_display_extra) {
|
|
|
|
my $formatting = $format92 ;
|
|
next if substr($col,0,5) eq 'shift' && substr($col,0,7) ne 'shift_1' ;
|
|
my $val = '' ; my $nowrap = '' ; my $align = qq~~ ; my $val_min = "" ;
|
|
|
|
my $row_span = '' ;
|
|
|
|
if ($col eq 'date') {
|
|
|
|
$row_cnt++ ;
|
|
$row_span = qq~rowspan="2"~ if $monitoring_report || $troubleshoot_monitoring_report ;
|
|
$val = $date_str . qq~<input style="display:none;" value="$date" name="date_$date_cnt">~ ;
|
|
$nowrap = "nowrap" ;
|
|
&xlsxcreator_write_xlsx($ws2,$max_row_cnt+1,0,$date_str ,$formatting) ;
|
|
|
|
} elsif (substr($col,0,7) eq 'shift_1') {
|
|
|
|
$align = qq~ class="dt-center"~ ;
|
|
|
|
local $place_holder = substr($ws2,0,-1) ;
|
|
|
|
for (1 .. 4) {
|
|
$row_cnt_shifts{$_} = $max_row_cnt + 1 ;
|
|
}
|
|
|
|
for my $shift_cnt (1 .. 4) {
|
|
|
|
# $row_cnt_shifts{$shift_cnt} = ($max_row_cnt && $shift_cnt == 1) ? $max_row_cnt + 1 : 1 ;
|
|
my $field = "$field_name\_$shift_cnt\_1_1_$date_cnt" ;
|
|
$opts{$field} = $opts{schedule_users} ;
|
|
$preferred_placeholder{$field} = ($troubleshoot_monitoring_report) ? "Shift Troubleshoot Monitor $shift_cnt $date_cnt" : "$place_holder $shift_cnt $date_cnt" ;
|
|
$multiple{$field} = 1 ;
|
|
|
|
my $table_col = 6-$shift_cnt ;
|
|
push @first_table_multi_select_table_cells,"#$table_id tr:eq($row_cnt) td:nth-last-child($table_col)" ;
|
|
|
|
$val .= &common_min_table_select($field,$schedule_ids[$shift_cnt - 1],'',$row_cnt,$table_col,'',$schedule_ids[$shift_cnt - 1],'shift',$table_id) ;
|
|
foreach (split(/\,/,$schedule_ids[$shift_cnt - 1])) {
|
|
next unless $_ ;
|
|
$trigger_jquery_raw .= qq~\$("#select$uc_field_name\_$shift_cnt\_1_1_$date_cnt option[value='$_']").prop("selected",true);~ ;
|
|
&xlsxcreator_write_xlsx($ws2,$row_cnt_shifts{$shift_cnt},$shift_cnt,"$db{users}{$_}{name}",$formatting) ;
|
|
$row_cnt_shifts{$shift_cnt}++ ;
|
|
}
|
|
$max_row_cnt = $row_cnt_shifts{$shift_cnt} if !$max_row_cnt || $max_row_cnt < $row_cnt_shifts{$shift_cnt} ;
|
|
$val .= qq~</td><td $nowrap $align>~ if $shift_cnt < 4 ;
|
|
}
|
|
|
|
} elsif ($col eq 'notes') {
|
|
|
|
$row_cnt++ ;
|
|
|
|
my @notes = split(/\:\|\:/,$db{$table_name}{$date}{$table_col_name_notes}) ;
|
|
# $max_row_cnt-- ;
|
|
# $max_row_cnt++ if $db{$table_name}{$date}{$table_col_name_notes} =~ /(\d+)/g || $db{$table_name}{$date}{$table_col_name_notes} =~ /[a-zA-Z]/ ;
|
|
|
|
for my $shift_cnt (1 .. 4) {
|
|
|
|
my $field = "$field_name\_notes_$shift_cnt\_1_1_$date_cnt" ;
|
|
$preferred_placeholder{$field} = ($troubleshoot_monitoring_report) ? "Shift Troubleshoot Monitor Notes $shift_cnt $date_cnt" : "Shift Monitor Notes $shift_cnt $date_cnt" ;
|
|
$val_notes .= &common_min_table_textarea($field,$notes[$shift_cnt-1],'',$row_cnt,5-$shift_cnt,'',$notes[$shift_cnt-1],'',$table_id) ;
|
|
&xlsxcreator_write_xlsx($ws2,$max_row_cnt,$shift_cnt,$notes[$shift_cnt-1],$format97) if $db{$table_name}{$date}{$table_col_name_notes} =~ /(\d+)/g || $db{$table_name}{$date}{$table_col_name_notes} =~ /[a-zA-Z]/ ;
|
|
$val_notes .= qq~</td><td id = "notes\_$shift_cnt\_1_1_$date_cnt" $nowrap $align>~ if $shift_cnt < 4 ;
|
|
|
|
}
|
|
|
|
$val_notes = qq~<tr><td>$val_notes</td></tr>~ ;
|
|
|
|
} elsif ($col eq "update") {
|
|
|
|
$row_span = qq~rowspan="2"~ if $monitoring_report || $troubleshoot_monitoring_report ;
|
|
$align = qq~ class="dt-center"~ ;
|
|
my $field = "update_1_1_$date_cnt" ;
|
|
$val = &common_min_form_checkbox_col($field,'') ;
|
|
|
|
chop $default_javascript if $default_javascript ;
|
|
|
|
if ($default_javascript) {
|
|
|
|
push @default_javascript_by_id, qq~"1_1_$date_cnt":{$default_javascript}~ ; ## ???
|
|
|
|
for (1 .. 4) {
|
|
my $field = "#textarea" . ucfirst "$field_name\_notes\_$_\_1_1_$date_cnt" ;
|
|
push @all_update_field_ids,"$field" if $monitoring_report || $troubleshoot_monitoring_report ;
|
|
$field = "#select" . ucfirst "$field_name\_$_\_1_1_$date_cnt" ;
|
|
push @all_update_field_ids,"$field" ;
|
|
}
|
|
}
|
|
}
|
|
|
|
$print_tbody_extra .= qq~<td $nowrap $align $row_span>$val</td>~ if $col ne 'notes' ;
|
|
|
|
$print_tbody_extra .= qq~</tr>$val_notes<tr>~ if $col eq 'update' ;
|
|
|
|
}
|
|
|
|
($s_year,$s_mon,$s_day) = Add_Delta_Days($s_year,$s_mon,$s_day,1) ;
|
|
$s_mon = sprintf("%02d",$s_mon) ;
|
|
$s_day = sprintf("%02d",$s_day) ;
|
|
$date_cnt++ ;
|
|
}
|
|
|
|
$date_cnt-- ;
|
|
|
|
# &common_min_table_select_fixed_width_jquery(1) ;
|
|
# &common_min_table_select_default_values_jquery ;
|
|
|
|
# @all_select_ids = () ; @selects_with_default_ids = () ; %col_name_select_ids = () ; %table_with_default_ids = () ; %selects_by_def_val = () ;
|
|
|
|
@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)","update") if $monitoring_report || $troubleshoot_monitoring_report ;
|
|
|
|
$worksheet{$ws2}->set_column(0,0,10) ;
|
|
$worksheet{$ws2}->set_column(1,5,50) if $monitoring_report || $troubleshoot_monitoring_report ;
|
|
$worksheet{$ws2}->set_column(1,5,20) if $temp_calibrator_report ;
|
|
|
|
$trigger_jquery_raw .= qq~\$("#$table_id tr:eq(0) th:nth-last-child(2),#$table_id tr th:nth-last-child(3),#$table_id tr th:nth-last-child(4),#$table_id tr th:nth-last-child(5)").css("width","23%")~ ;
|
|
|
|
} #------------------------------------------------------------------------------------------
|
|
|
|
sub schedule_build_extra_second_table {
|
|
|
|
my ($field_name,$table_name,$table_col_name) = @_ ;
|
|
|
|
my $ws2 = join ' ', map { ucfirst $_ } split /_/, $field_name ;
|
|
$ws2 .= "s" ;
|
|
|
|
&xlsxcreator_add_worksheet($ws2) ;
|
|
|
|
my $col2 = 0 ;
|
|
foreach (@sql_col_display_2) {
|
|
next if $_ eq "update" || !$_ ;
|
|
my $coltitle = $_ ;
|
|
$coltitle =~ s/\_id//g ;
|
|
$coltitle =~ s/\_/ /g ;
|
|
my $ucfirst = join '', map { ucfirst lc } split /(\s+)/, $coltitle;
|
|
&xlsxcreator_write_xlsx($ws2,0,$col2,$ucfirst,$format_management_report_headings) ;
|
|
$col2++;
|
|
}
|
|
$col2=0 ;
|
|
&xlsxcreator_freeze_panes($ws2,1,0) ; # Freeze the first 3 rows
|
|
|
|
my ($s_year,$s_mon,$s_day) = split("-",$i{date_from}) ;
|
|
my ($e_year,$e_mon,$e_day) = split("-",$i{date_to}) ;
|
|
$s_mon = sprintf("%02d",$s_mon) ;
|
|
$s_day = sprintf("%02d",$s_day) ;
|
|
|
|
$opts{name} = $opts{support_users} ;
|
|
|
|
$radio_opts{shift} = "Half Day (<7 hours);Full Day (7 hours+)" ;
|
|
|
|
my $nr_of_options = scalar split("option><option",$opts{support_users}) ;
|
|
|
|
$xlsxrow = 1 ;
|
|
|
|
return if int("$s_year$s_mon$s_day") > int("$e_year$e_mon$e_day") ;
|
|
|
|
my $date1 = "$s_year-$s_mon-$s_day" ;
|
|
my $date2 = "$e_year-$e_mon-$e_day" ;
|
|
my $d1 = Time::Piece->strptime($date1, "%Y-%m-%d") ;
|
|
my $d2 = Time::Piece->strptime($date2, "%Y-%m-%d") ;
|
|
my $diff_in_days = ($d2 - $d1)->days + 1;
|
|
|
|
my $date_cnt= 0 ;
|
|
|
|
&common_min_thead_2 ;
|
|
|
|
for my $day_cnt (1 .. $diff_in_days) {
|
|
|
|
my $date = "$s_year-$s_mon-$s_day" ;
|
|
|
|
$db{$table_name}{$date}{$table_col_name} = "None" unless $db{$table_name}{$date}{$table_col_name} ;
|
|
|
|
$date_cnt++ ;
|
|
|
|
push @second_table_ids,"#select_temp_calibrators_2_$date_cnt" ;
|
|
push @second_table_ids_2,"#select_temp_calibrators_2_$date_cnt td:nth-last-child(2)" ;
|
|
push @second_table_ids_3,"#select_temp_calibrators_2_$date_cnt td:nth-last-child(3)" ;
|
|
push @second_table_ids_4,"#select_temp_calibrators_2_$date_cnt td:nth-last-child(4)" ;
|
|
push @second_table_ids_5,"#select_temp_calibrators_2_$date_cnt td:nth-last-child(5)" ;
|
|
|
|
$print_tbody_extra_2 .= qq~<table id="select_temp_calibrators_2_$date_cnt" class="table table-striped table-bordered bootstrap-datatable responsive">~ ;
|
|
$print_tbody_extra_2 .= qq~$print_thead_2~ if $date_cnt == 1 ;
|
|
$print_tbody_extra_2 .= qq~<tbody>~ ;
|
|
|
|
my $row_cnt = 0 ;
|
|
|
|
$opts{name} = $opts{support_users} ;
|
|
|
|
my $z_index = $tot_support_users_cnt * ($diff_in_days - $day_cnt + 1) + 1 ;
|
|
|
|
foreach my $row (split(/\|/,$db{$table_name}{$date}{$table_col_name})) {
|
|
|
|
$z_index-- ;
|
|
|
|
next unless $row ;
|
|
|
|
$row_cnt++ ;
|
|
$print_tbody_extra_2 .= qq~<tr id="second_table_$row_cnt\_$date_cnt">~ ;
|
|
|
|
our $default_javascript = qq~~ ;
|
|
|
|
$xlsxrow++ ; $xlsxcol = 0 ;
|
|
|
|
foreach my $col (@sql_col_display_2) {
|
|
|
|
my $formatting = $format84 ;
|
|
my $val = '' ; my $nowrap = '' ; my $align = qq~class="dt-center"~ ;
|
|
|
|
my $field_id = "$col\_2_$row_cnt\_$date_cnt" ;
|
|
|
|
my $default_val_html = qq~~ ;
|
|
|
|
if ($col eq 'date') {
|
|
my $date_str = &common_min_date_as_string($date) ;
|
|
$val = $date_str ;
|
|
$nowrap = "nowrap" ;
|
|
$align = qq~class="dt-left"~ ;
|
|
&xlsxcreator_write_xlsx($ws2,$xlsxrow,$xlsxcol,"$date_str",$formatting) ;
|
|
} elsif ($col eq 'name') {
|
|
my @abc = split(/\:/,$row) ;
|
|
$abc[0] = "" if $abc[0] eq "None" ;
|
|
$default_val = $abc[0] ;
|
|
$default_val_is_saved = ($default_val) ? 1 : 0 ;
|
|
$preferred_placeholder{$field_id} = "Select Temp Support Name $row_cnt" ;
|
|
$opts{$field_id} = $opts{name} ;
|
|
|
|
my $table_row_cnt = ($date_cnt == 1) ? $row_cnt + 1 : $row_cnt - 1 ;
|
|
|
|
$val = &common_min_table_select($field_id,$default_val,'',$table_row_cnt,4,'',$default_val_is_saved,'',"select_temp_calibrators_2_$date_cnt") ;
|
|
# $default_val_html = qq~<span id="default_name_$row_cnt" style="display:none;">$default_val</span>~ ;
|
|
|
|
$trigger_jquery_raw .= qq~
|
|
\$("#select_temp_calibrators_2_$date_cnt tr:eq($table_row_cnt) td:nth-last-child(4)").css("z-index","$z_index") ;
|
|
~ ;
|
|
$support_users_cnt-- ;
|
|
$opts{name} =~ s/<option\s+value='$default_val'>.*?<\/option>// if $default_val ;
|
|
&xlsxcreator_write_xlsx($ws2,$xlsxrow,$xlsxcol,$db{users}{$default_val}{name},$formatting) ;
|
|
} elsif ($col eq 'shift') {
|
|
$radio_opts{$field_id} = $radio_opts{shift} ;
|
|
my @abc = split(/\:/,$row) ;
|
|
$default_val = $abc[1] ;
|
|
$default_val_is_saved = ($default_val) ? 1 : 0 ;
|
|
# $default_val_html = qq~<span id="default_shift_$row_cnt" style="display:none;">$default_val</span>~ ;
|
|
our $val_min = "" ;
|
|
my $table_row_cnt = ($date_cnt == 1) ? $row_cnt + 1 : $row_cnt - 1 ;
|
|
$val = &table_radio_button($field_id,$default_val,'',$table_row_cnt,3,'',$default_val_is_saved,$col,"select_temp_calibrators_2_$date_cnt") ;
|
|
&xlsxcreator_write_xlsx($ws2,$xlsxrow,$xlsxcol,$val_min,$formatting) ;
|
|
} elsif ($col eq 'update') {
|
|
$val = &common_min_table_checkbox($field_id) ;
|
|
chop $default_javascript if $default_javascript ;
|
|
if ($default_javascript) {
|
|
push @default_javascript_by_id, qq~"2_$row_cnt\_$date_cnt":{$default_javascript}~ ;
|
|
push @all_update_field_ids, "#shift_1_2_$row_cnt\_$date_cnt,#shift_2_2_$row_cnt\_$date_cnt,#selectName_2_$row_cnt\_$date_cnt" ;
|
|
}
|
|
} elsif (!$col) {
|
|
$val = ($row ne 'None') ? qq~ <a class="btn btn-danger btn-xs" href="javascript:deleteTempSupport('$row_cnt\_$date_cnt')"><i class="glyphicon glyphicon-trash icon-white"></i></a>~ : qq~~ ;
|
|
}
|
|
|
|
my $styling = ($col eq 'date' && $row_cnt == 1) ? qq~style="width:7%;"~ : ($col eq 'name' && $row_cnt == 2) ? qq~style="width:35%;"~ : '' ;
|
|
|
|
$print_tbody_extra_2 .= qq~<td $nowrap $align $styling>$val</td>~ ;
|
|
$xlsxcol++ ;
|
|
}
|
|
$print_tbody_extra_2 .= qq~</tr>~ ;
|
|
}
|
|
|
|
($s_year,$s_mon,$s_day) = Add_Delta_Days($s_year,$s_mon,$s_day,1) ;
|
|
$s_mon = sprintf("%02d",$s_mon) ;
|
|
$s_day = sprintf("%02d",$s_day) ;
|
|
|
|
if ($nr_of_options <= $row_cnt) {
|
|
$trigger_jquery_raw .= qq~\$("#add_row_table_2_$date_cnt").css("display","none");~ ;
|
|
}
|
|
|
|
my $plus_button_color = ($db{shift_operator_ids}{$date}{temp_calibrator_support_shifts} =~ /\|\|/ || $db{shift_operator_ids}{$date}{temp_calibrator_support_shifts} =~ /\|\:/ || $db{shift_operator_ids}{$date}{temp_calibrator_support_shifts} eq "None") ? "grey" : "blue" ;
|
|
|
|
push @plus_btn_ids,"#add_row_table_2_$date_cnt" ;
|
|
|
|
$plus_button = qq~
|
|
<a href="#" id="add_row_table_2_$date_cnt">
|
|
<div class="row">
|
|
<div class="col-md-1" style="position:relative;bottom:10px;left:5px;">
|
|
<i class="glyphicon glyphicon-plus $plus_button_color" style="font-size:20px;">
|
|
</i>
|
|
</div>
|
|
<div class="col-md-11">
|
|
</div>
|
|
</div>
|
|
</a>
|
|
~ ;
|
|
|
|
$print_tbody_extra_2 .= qq~</tbody></table>$plus_button~ ;
|
|
}
|
|
|
|
$worksheet{$ws2}->set_column('A:C',20);
|
|
|
|
&common_min_table_update_checkbox_col_default ;
|
|
|
|
our $trigger_jquery_raw_default_alt = qq~
|
|
// let all_def_vals = {} ;
|
|
|
|
// all_def_vals[row_nr] = {} ;
|
|
|
|
// let def_name = \$("#default_name_"+row_nr ).text() ;
|
|
// let def_shift = \$("#default_shift_"+row_nr ).text() ;
|
|
|
|
// all_def_vals[row_nr]["selectName_"+row_nr] = def_name ;
|
|
|
|
// if (def_shift == "1") {
|
|
// all_def_vals[row_nr]["shift_1_"+row_nr ] = "true" ;
|
|
// all_def_vals[row_nr]["shift_2_"+row_nr ] = "false" ;
|
|
// } else if (def_shift == "2") {
|
|
// all_def_vals[row_nr]["shift_1_"+row_nr ] = "false" ;
|
|
// all_def_vals[row_nr]["shift_2_"+row_nr ] = "true" ;
|
|
// }
|
|
~ ;
|
|
|
|
my $plus_btn_ids_str = join(",",@plus_btn_ids) ;
|
|
|
|
$trigger_jquery_raw .= qq~
|
|
|
|
function add_Days (date_string,num_days,as_num) {
|
|
let date = new Date(date_string) ;
|
|
date.setDate(date.getDate() + num_days) ;
|
|
let year = date.getFullYear() ;
|
|
let month = String(date.getMonth() + 1).padStart(2,'0') ;
|
|
let day = String(date.getDate()).padStart(2,'0') ;
|
|
if (as_num) {
|
|
return ""+year+"-"+month+"-"+day+"" ;
|
|
} else {
|
|
let month_names = ["","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"] ;
|
|
month = month_names[month] ;
|
|
return ""+day+"-"+month+"-"+year+"" ;
|
|
}
|
|
}
|
|
|
|
function deleteTempSupport (row_cnt) {
|
|
|
|
BootstrapDialog.confirm({
|
|
title: 'Confirm Delete',
|
|
message: 'Are you sure you want to delete <strong>'+name+'</strong>?',
|
|
type: BootstrapDialog.TYPE_DANGER, // <-- Default value is BootstrapDialog.TYPE_PRIMARY <-- Default value is BootstrapDialog.TYPE_WARNING
|
|
callback: function(result) {
|
|
|
|
let [cnt_for_date,table_cnt] = row_cnt.split('_').map(Number) ;
|
|
|
|
if (result) {
|
|
// if (\$("#update_data_base_"+row_cnt).text()) {
|
|
|
|
let curr_date = add_Days("$i{date_from}",table_cnt-1,1) ;
|
|
|
|
let url_delete = "$useropts{scripts}/get/get_db_delete_temp_support.pl?date="+curr_date+"&row_cnt="+cnt_for_date ;
|
|
|
|
console.log("url_delete : "+url_delete) ;
|
|
|
|
// console.log("#select_temp_calibrators_2_"+table_cnt+" #second_table_"+cnt_for_date+"_"+table_cnt) ;
|
|
|
|
\$("#select_temp_calibrators_2_"+table_cnt+" #second_table_"+cnt_for_date+"_"+table_cnt).remove() ;
|
|
|
|
\$.get(url_delete) ;
|
|
// }
|
|
// $("select#selectOriginalId").attr("id", "selectNewId");
|
|
|
|
let table_row_cnt = \$("#select_temp_calibrators_2_"+table_cnt).find('tr').length - 2 ;
|
|
|
|
// let start_row_nr = 2 ; let end_row_nr = table_row_cnt + 1 ;
|
|
|
|
if (table_cnt != '1') {
|
|
table_row_cnt += 2 ;
|
|
// start_row_nr = 0 ;
|
|
// end_row_nr -= 2 ;
|
|
}
|
|
|
|
let all_def_vals_new = {} ;
|
|
|
|
for (let i=2;i<=table_row_cnt+1;i++) {
|
|
|
|
let row_nr = i-1 ;
|
|
let row_val = i ;
|
|
if (table_cnt != '1') {
|
|
row_val -= 2 ;
|
|
}
|
|
|
|
\$("#select_temp_calibrators_2_"+table_cnt+" tr:eq("+row_val+")").attr("id","second_table_"+row_nr+"_"+table_cnt);
|
|
|
|
let zIndex = \$("#select_temp_calibrators_2_"+table_cnt+" tr:eq("+row_val+") td:nth-last-child(4)").css('z-index');
|
|
zIndex++ ;
|
|
\$("#select_temp_calibrators_2_"+table_cnt+" tr:eq("+row_val+") td:nth-last-child(4)").css('z-index',zIndex);
|
|
if (\$("#select_temp_calibrators_2_"+table_cnt+" tr:eq("+row_val+") td:nth-last-child(1)").html()) {
|
|
\$("#select_temp_calibrators_2_"+table_cnt+" tr:eq("+row_val+") td:nth-last-child(1)").html(" <a class='btn btn-danger btn-xs' href=javascript:deleteTempSupport('"+row_nr+"_"+table_cnt+"');><i class='glyphicon glyphicon-trash icon-white'></i></a>");
|
|
}
|
|
|
|
\$("#select_temp_calibrators_2_"+table_cnt+" tr:eq("+row_val+")").find("select[id^='selectName_']").each(function() {
|
|
|
|
var oldId = \$(this).attr("id");
|
|
let old_row_val = get_row_nr(oldId,2) ;
|
|
let new_row_val = row_nr+"_"+table_cnt ;
|
|
|
|
if (typeof all_def_vals["2_"+old_row_val] !== 'undefined') {
|
|
|
|
all_def_vals_new["2_"+new_row_val] = {};
|
|
all_def_vals_new["2_"+new_row_val]["selectName_2_"+new_row_val] = all_def_vals["2_"+old_row_val]["selectName_2_"+old_row_val] ;
|
|
all_def_vals_new["2_"+new_row_val]["shift_1_2_"+new_row_val] = all_def_vals["2_"+old_row_val]["shift_1_2_"+old_row_val] ;
|
|
all_def_vals_new["2_"+new_row_val]["shift_2_2_"+new_row_val] = all_def_vals["2_"+old_row_val]["shift_2_2_"+old_row_val] ;
|
|
|
|
}
|
|
|
|
let old_select_val = \$("#"+oldId).val() ;
|
|
|
|
\$(this).attr("id", "selectName_2_"+new_row_val);
|
|
\$(this).attr("name", "name_2_"+new_row_val);
|
|
\$(this).attr("data-placeholder", "Select Temp Support Name "+row_nr);
|
|
var chosenElementId = oldId + "_chosen";
|
|
\$("#" + chosenElementId).attr("id", "selectName_2_"+row_nr+"_"+table_cnt+"_chosen");
|
|
\$("#selectName_2_"+row_nr+"_"+table_cnt+"_chosen .chosen-single span").text("Select Temp Support Name "+row_nr);
|
|
|
|
\$("#shift_1_2_"+old_row_val).attr("name","shift_2_"+new_row_val);
|
|
\$("#shift_1_2_"+old_row_val).attr("id","shift_1_2_"+new_row_val);
|
|
\$("#shift_2_2_"+old_row_val).attr("name","shift_2_"+new_row_val);
|
|
\$("#shift_2_2_"+old_row_val).attr("id","shift_2_2_"+new_row_val);
|
|
\$("#checkboxUpdate_2_"+old_row_val).attr("name","update_2_"+new_row_val);
|
|
\$("#checkboxUpdate_2_"+old_row_val).attr("id","checkboxUpdate_2_"+new_row_val);
|
|
|
|
// \$("#default_name_"+old_row_nr).attr("id","default_name_"+row_nr);
|
|
// \$("#default_shift_"+old_row_nr).attr("id","default_shift_"+row_nr);
|
|
|
|
\$("#selectName_2_"+new_row_val).val(old_select_val) ;
|
|
\$("#selectName_2_"+new_row_val).trigger("chosen:updated") ;
|
|
|
|
if (\$("#add_row_table_2_"+table_cnt).is(":hidden")) {
|
|
\$("#add_row_table_2_"+table_cnt).css("display","") ;
|
|
}
|
|
|
|
}) ;
|
|
|
|
}
|
|
|
|
all_def_vals = all_def_vals_new ;
|
|
|
|
if (!\$("#second_table_1_"+table_cnt).html()) {
|
|
|
|
let options = "$opts{support_users}" ;
|
|
let select = add_select("name_2_1_"+table_cnt,"selectName_2_1_"+table_cnt,"Select Temp Support Name 1","$opts{support_users}",1,90) ;
|
|
let radio_butt = "<label class='btn btn-default' style='padding: 2px 3px 5px; font-size:12.5px; background-color:rgb(100,100,100);border-color:black;'><input type='radio' name='shift_2_1_"+table_cnt+"' id='shift_1_2_1_"+table_cnt+"' value='1'> Half Day (<7 hours)</label> <label class='btn btn-default' style='padding: 2px 3px 5px; font-size:12.5px; background-color:rgb(100,100,100);border-color:black;'><input type='radio' name='shift_2_1_"+table_cnt+"' id='shift_2_2_1_"+table_cnt+"' value='2'> Full Day (7 hours+)</label>" ;
|
|
let update_butt = "<input name='update_2_1_"+table_cnt+"' data-no-uniform='true' type='checkbox' id='checkboxUpdate_2_1_"+table_cnt+"' value='1'>" ;
|
|
let newRow = "<tr id='second_table_1_"+table_cnt+"'><td style='width:7%;'>"+curr_date+"</td><td style='position:relative;text-align:center;width:40%;'>"+select+"</td><td class='dt-center' style='width:40%;'>"+radio_butt+"</td><td class='dt-center' style='width:10%;'>"+update_butt+"</td><td></td></tr>" ;
|
|
\$("#select_temp_calibrators_2_"+table_cnt+" tbody").append(newRow) ;
|
|
\$("#selectName_2_1_"+table_cnt).chosen({allow_single_deselect:true}) ;
|
|
\$("#selectName_2_1_"+table_cnt+"_chosen").css("position","absolute") ;
|
|
\$("#selectName_2_1_"+table_cnt+"_chosen").css("width","90%") ;
|
|
\$("#selectName_2_1_"+table_cnt+"_chosen").css("left","5%") ;
|
|
\$("#selectName_2_1_"+table_cnt+"_chosen").css("top","50%") ;
|
|
\$("#selectName_2_1_"+table_cnt+"_chosen").css("transform","translateY(-50%)") ;
|
|
|
|
let optionCount = \$("#selectName_2_1_"+table_cnt+" option").length - 1 ;
|
|
|
|
let date_cnt = daysBetween("$i{date_from}","$i{date_to}") ;
|
|
|
|
let z_index = (date_cnt - table_cnt + 1)*optionCount ;
|
|
|
|
let row_val = 2 ;
|
|
if (table_cnt != '1') {
|
|
row_val = 0 ;
|
|
}
|
|
|
|
\$("#select_temp_calibrators_2_"+table_cnt+" tr:eq("+row_val+") td:nth-last-child(4)").css("z-index",z_index) ;
|
|
|
|
\$("#selectName_2_1_"+table_cnt+",#shift_1_2_1_"+table_cnt+",#shift_2_2_1_"+table_cnt).change( function () {
|
|
|
|
let found_blank = 0 ;
|
|
|
|
if ((!\$("#selectName_2_1_"+table_cnt).val() || (!\$("#shift_1_2_1_"+table_cnt).is(":checked") && !\$("#shift_2_2_1_"+table_cnt).is(":checked"))) && \$("#second_table_1_"+table_cnt).html()) {
|
|
found_blank = 1 ;
|
|
}
|
|
|
|
if (!found_blank) {
|
|
\$('#add_row_table_2_'+table_cnt).find('i').removeClass('grey').addClass('blue');
|
|
} else {
|
|
\$('#add_row_table_2_'+table_cnt).find('i').removeClass('blue').addClass('grey');
|
|
}
|
|
|
|
let tick_update = 0 ;
|
|
|
|
if ((\$("#"+this.id).attr('type') == 'radio' && \$("#"+this.id).is(":checked")) || (\$("#"+this.id).val() && \$("#"+this.id).attr('type') != 'radio')) {
|
|
tick_update = 1 ;
|
|
}
|
|
|
|
if (tick_update && !\$("#checkboxUpdate_2_1_"+table_cnt).is(":checked")) {
|
|
\$("#checkboxUpdate_2_1_"+table_cnt).prop("checked",true) ;
|
|
} else if (!tick_update && \$("#checkboxUpdate_2_1_"+table_cnt).is(":checked")) {
|
|
\$("#checkboxUpdate_2_1_"+table_cnt).prop("checked",false) ;
|
|
}
|
|
|
|
}) ;
|
|
}
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
~ ;
|
|
|
|
$trigger_jquery_raw .= qq~
|
|
|
|
function daysBetween(date1,date2) {
|
|
|
|
const oneDay = 24 * 60 * 60 * 1000 ;
|
|
const firstDate = new Date(date1) ;
|
|
const secondDate = new Date(date2) ;
|
|
const diffInTime = Math.abs(secondDate - firstDate) ;
|
|
|
|
return Math.ceil(diffInTime/oneDay) + 1 ;
|
|
|
|
}
|
|
|
|
function add_select (field_name,field_id,placeholder,options,tindex,width) {
|
|
|
|
let select_raw = "<select class='form-control' style='margin:2px 0 2px 0; width: "+width+"%;' name='"+field_name+"' id='"+field_id+"'data-placeholder='"+placeholder+"' data-rel='chosen' tabindex='"+tindex+"'><option value=''></option>"+options+"</select>" ;
|
|
|
|
return select_raw ;
|
|
}
|
|
|
|
\$("$plus_btn_ids_str").click( function () {
|
|
|
|
let table_nr = get_row_nr(this.id) ;
|
|
|
|
let table_row_cnt = \$("#select_temp_calibrators_2_"+table_nr).find('tr').length ;
|
|
|
|
if (table_nr == '1') {
|
|
table_row_cnt -= 2 ;
|
|
}
|
|
|
|
let found_blank = 0 ;
|
|
// console.log("table_row_cnt : "+table_row_cnt) ;
|
|
|
|
// let lastRowId = \$("#select_temp_calibrators_2 tr:last").attr("id");
|
|
// let table_row_cnt = get_row_nr(lastRowId) ;
|
|
|
|
for (i=1;i<=table_row_cnt;i++) {
|
|
if ((!\$("#selectName_2_"+i+"_"+table_nr).val() || \$("#selectName_2_"+i+"_"+table_nr).val() == null || (!\$("#shift_1_2_"+i+"_"+table_nr).is(":checked") && !\$("#shift_2_2_"+i+"_"+table_nr).is(":checked"))) && \$("#second_table_"+i+"_"+table_nr).html()) {
|
|
found_blank = 1 ;
|
|
}
|
|
}
|
|
|
|
if (!found_blank) {
|
|
|
|
\$('#add_row_table_2_'+table_nr).find('i').removeClass('blue').addClass('grey');
|
|
|
|
table_row_cnt++ ;
|
|
|
|
let options = "$opts{support_users}" ;
|
|
|
|
let select = add_select("name_2_"+table_row_cnt+"_"+table_nr,"selectName_2_"+table_row_cnt+"_"+table_nr,"Select Temp Support Name "+table_row_cnt,"$opts{support_users}",1,90) ;
|
|
// "Half Day (<7 hours);Full Day (7 hours+)"
|
|
let radio_butt = "<label class='btn btn-default' style='padding: 2px 3px 5px; font-size:12.5px; background-color:rgb(100,100,100);border-color:black;'><input type='radio' name='shift_2_"+table_row_cnt+"_"+table_nr+"' id='shift_1_2_"+table_row_cnt+"_"+table_nr+"' value='1'> Half Day (<7 hours)</label> <label class='btn btn-default' style='padding: 2px 3px 5px; font-size:12.5px; background-color:rgb(100,100,100);border-color:black;'><input type='radio' name='shift_2_"+table_row_cnt+"_"+table_nr+"' id='shift_2_2_"+table_row_cnt+"_"+table_nr+"' value='2'> Full Day (7 hours+)</label>" ;
|
|
|
|
// let delete_butt = " <a class='btn btn-danger btn-xs' href=javascript:deleteMinItem('','$row_cnt');><i class='glyphicon glyphicon-trash icon-white'></i></a>" ;
|
|
let delete_butt = "" ;
|
|
|
|
let update_butt = "<input name='update_2_"+table_row_cnt+"_"+table_nr+"' data-no-uniform='true' type='checkbox' id='checkboxUpdate_2_"+table_row_cnt+"_"+table_nr+"' value='1'>" ;
|
|
|
|
let curr_date = add_Days("$i{date_from}",table_nr-1) ;
|
|
|
|
let newRow = "<tr id='second_table_"+table_row_cnt+"_"+table_nr+"'><td>"+curr_date+"</td><td style='position:relative;text-align:center;'>"+select+"</td><td class='dt-center'>"+radio_butt+"</td><td class='dt-center'>"+update_butt+"</td><td>"+delete_butt+"</td></tr>" ;
|
|
|
|
\$("#select_temp_calibrators_2_"+table_nr+" tbody").append(newRow) ;
|
|
|
|
// let optionCount = \$("#selectName_2_"+table_row_cnt+"_"+table_nr+" option").length - 1 ;
|
|
let optionCount = \$("#selectName_2_1_"+table_nr+" option").length - 1 ;
|
|
|
|
let date_cnt = daysBetween("$i{date_from}","$i{date_to}") ;
|
|
|
|
// my $support_users_cnt = $potential_support_users_cnt - ($day_cnt - 1)*$tot_support_users_cnt ;
|
|
|
|
let z_index = (date_cnt - table_nr + 1)*optionCount - table_row_cnt + 1 ;
|
|
|
|
// let optionCount = "$tot_support_users_cnt" ;
|
|
|
|
// \$("#selectName_"+table_row_cnt).chosen({allow_single_deselect:true}) ;
|
|
|
|
for (i=1;i<table_row_cnt;i++) {
|
|
|
|
let selected_temp_cal = \$("#selectName_2_"+i+"_"+table_nr).val() ;
|
|
|
|
if (selected_temp_cal) {
|
|
\$("#selectName_2_"+table_row_cnt+"_"+table_nr+" option[value='"+selected_temp_cal+"']").remove();
|
|
// optionCount-- ;
|
|
}
|
|
}
|
|
|
|
if (table_nr == '1') {
|
|
table_row_cnt++ ;
|
|
} else {
|
|
table_row_cnt-- ;
|
|
}
|
|
|
|
\$("#select_temp_calibrators_2_"+table_nr+" tr:eq("+table_row_cnt+") td:nth-last-child(4)").css("z-index",z_index) ;
|
|
|
|
if (table_nr == '1') {
|
|
table_row_cnt-- ;
|
|
} else {
|
|
table_row_cnt++ ;
|
|
}
|
|
// optionCount-- ;
|
|
|
|
if (optionCount == table_row_cnt) {
|
|
\$("#add_row_table_2_"+table_nr).css("display","none") ;
|
|
}
|
|
|
|
\$("#selectName_2_"+table_row_cnt+"_"+table_nr).chosen({allow_single_deselect:true}) ;
|
|
\$("#selectName_2_"+table_row_cnt+"_"+table_nr+"_chosen").css("position","absolute") ;
|
|
\$("#selectName_2_"+table_row_cnt+"_"+table_nr+"_chosen").css("width","90%") ;
|
|
\$("#selectName_2_"+table_row_cnt+"_"+table_nr+"_chosen").css("left","5%") ;
|
|
\$("#selectName_2_"+table_row_cnt+"_"+table_nr+"_chosen").css("top","50%") ;
|
|
\$("#selectName_2_"+table_row_cnt+"_"+table_nr+"_chosen").css("transform","translateY(-50%)") ;
|
|
|
|
\$("#selectName_2_"+table_row_cnt+"_"+table_nr+",#shift_1_2_"+table_row_cnt+"_"+table_nr+",#shift_2_2_"+table_row_cnt+"_"+table_nr).change( function () {
|
|
|
|
// if (this.id.includes('selectName_')) {
|
|
|
|
let selected_val = \$(this).val() ;
|
|
|
|
// let table_row_cnt_2 = \$("#select_temp_calibrators_2").find('tr').length - 2 ;
|
|
|
|
// let lastRowId = \$("#select_temp_calibrators_2 tr:last").attr("id");
|
|
// let table_row_cnt_2 = get_row_nr(lastRowId) ;
|
|
|
|
// let selected_values = {} ;
|
|
let found_blank = 0 ;
|
|
|
|
for (i=1;i<=table_row_cnt;i++) {
|
|
if ((!\$("#selectName_2_"+i+"_"+table_nr).val() || (!\$("#shift_1_2_"+i+"_"+table_nr).is(":checked") && !\$("#shift_2_2_"+i+"_"+table_nr).is(":checked"))) && \$("#second_table_"+i+"_"+table_nr).html()) {
|
|
found_blank = 1 ;
|
|
}
|
|
}
|
|
if (!found_blank) {
|
|
\$('#add_row_table_2_'+table_nr).find('i').removeClass('grey').addClass('blue');
|
|
} else {
|
|
\$('#add_row_table_2_'+table_nr).find('i').removeClass('blue').addClass('grey');
|
|
}
|
|
// }
|
|
|
|
let tick_update = 0 ;
|
|
|
|
if ((\$("#"+this.id).attr('type') == 'radio' && \$("#"+this.id).is(":checked")) || (\$("#"+this.id).val() && \$("#"+this.id).attr('type') != 'radio')) {
|
|
tick_update = 1 ;
|
|
}
|
|
|
|
if (tick_update && !\$("#checkboxUpdate_2_"+table_row_cnt+"_"+table_nr).is(":checked")) {
|
|
\$("#checkboxUpdate_2_"+table_row_cnt+"_"+table_nr).prop("checked",true) ;
|
|
} else if (!tick_update && \$("#checkboxUpdate_2_"+table_row_cnt+"_"+table_nr).is(":checked")) {
|
|
\$("#checkboxUpdate_2_"+table_row_cnt+"_"+table_nr).prop("checked",false) ;
|
|
}
|
|
|
|
}) ;
|
|
|
|
} else {
|
|
noty({text:'Please Select a Temp Support Name and a Shift in all Rows',layout:"center",type:"error",timeout:3000}) ;
|
|
}
|
|
|
|
});
|
|
|
|
// \$("#select_temp_calibrators_2_length").css("display","none");
|
|
// \$("#select_temp_calibrators_2_filter").css("display","none");
|
|
// \$("#select_temp_calibrators_2_info").css("display","none");
|
|
// \$("#select_temp_calibrators_2_paginate").css("display","none");
|
|
|
|
~ ;
|
|
|
|
$trigger_jquery_raw .= qq~
|
|
// \$("#select_temp_calibrators_2_length").css("display","none");
|
|
// \$("#select_temp_calibrators_2_filter").css("display","none");
|
|
// \$("#select_temp_calibrators_2_info").css("display","none");
|
|
// \$("#select_temp_calibrators_2_paginate").css("display","none");
|
|
~ ;
|
|
|
|
|
|
my $all_select_ids_str = join(",",@all_select_ids) ;
|
|
my $all_radio_ids_str = join(",",@all_radio_ids) ;
|
|
|
|
$trigger_jquery_raw .= qq~
|
|
// \$("#selectName_"+table_row_cnt+" option[value='"+\$("#selectName_"+i).val()+"']").remove();
|
|
|
|
\$("$all_radio_ids_str,$all_select_ids_str").change( function () {
|
|
|
|
let table_cnt = get_row_nr(this.id) ;
|
|
|
|
// let [cnt_for_date,table_cnt] = str.split('_').map(table_row_nr) ;
|
|
|
|
let selected_val = \$(this).val() ;
|
|
let table_row_cnt = \$("#select_temp_calibrators_2_"+table_cnt).find('tr').length ;
|
|
|
|
if (table_cnt == '1') { table_row_cnt -= 2 ; }
|
|
|
|
// let selected_values = {} ;
|
|
|
|
// let lastRowId = \$("#select_temp_calibrators_2 tr:last").attr("id");
|
|
// let table_row_cnt = get_row_nr(lastRowId) ;
|
|
|
|
let found_blank = 0 ;
|
|
|
|
for (i=1;i<=table_row_cnt;i++) {
|
|
if ((!\$("#selectName_2_"+i+"_"+table_cnt).val() || (!\$("#shift_1_2_"+i+"_"+table_cnt).is(":checked") && !\$("#shift_2_2_"+i+"_"+table_cnt).is(":checked"))) && \$("#second_table_"+i+"_"+table_cnt).html()) {
|
|
found_blank = 1 ;
|
|
}
|
|
}
|
|
|
|
if (table_row_cnt > 1) {
|
|
// let row_nr = get_row_nr(this.id) ;
|
|
// for (i=1;i<=table_row_cnt;i++) {
|
|
// for (j=1;j<=table_row_cnt;j++) {
|
|
|
|
// }
|
|
// }
|
|
|
|
}
|
|
|
|
if (!found_blank) {
|
|
\$('#add_row_table_2_'+table_cnt).find('i').removeClass('grey').addClass('blue');
|
|
} else {
|
|
\$('#add_row_table_2_'+table_cnt).find('i').removeClass('blue').addClass('grey');
|
|
}
|
|
|
|
}) ;
|
|
|
|
~ ;
|
|
|
|
my $second_table_ids_str = join(",",@second_table_ids) ;
|
|
my $second_table_ids_str_2 = join(",",@second_table_ids_2) ;
|
|
my $second_table_ids_str_3 = join(",",@second_table_ids_3) ;
|
|
our $second_table_ids_str_4 = join(",",@second_table_ids_4) ;
|
|
my $second_table_ids_str_5 = join(",",@second_table_ids_5) ;
|
|
|
|
&common_min_table_select_fixed_width_jquery("$second_table_ids_str_4") ;
|
|
|
|
&common_min_table_select_default_values_jquery ;
|
|
|
|
# &common_min_table_select_jquery("#select_temp_calibrators_2 td:nth-last-child(4)","") ;
|
|
|
|
&common_min_table_update_checkbox_col_jquery("3") ;
|
|
|
|
$trigger_jquery .= qq~
|
|
\$("#select_temp_calibrators_2_length").css("display","none") ;
|
|
\$("#select_temp_calibrators_2_filter").css("display","none") ;
|
|
\$("#select_temp_calibrators_2_info").css("display","none") ;
|
|
\$("#select_temp_calibrators_2_paginate").css("display","none") ;
|
|
~ ;
|
|
|
|
$trigger_jquery .= qq~
|
|
// \$("#select_temp_calibrators_2").css("width","66.66666%");
|
|
\$("$second_table_ids_str_5").css("width","7%") ;
|
|
\$("$second_table_ids_str_4").css("width","40%") ;
|
|
// \$("$second_table_ids_str_4").css("position","relative") ;
|
|
// \$("$second_table_ids_str_4").css("text-align","center") ;
|
|
\$("$second_table_ids_str_3").css("width","40%") ;
|
|
\$("$second_table_ids_str_2").css("width","10%") ;
|
|
~ ;
|
|
|
|
|
|
} #------------------------------------------------------------------------------------------
|
|
|
|
sub table_radio_button {
|
|
|
|
my ($field,$default_val,$only_display_val,$table_row,$table_col,$background_color,$default_val_is_saved,$col_name,$table_id) = @_ ;
|
|
|
|
return unless $col_name ;
|
|
|
|
$field = "$col_name\_$table_row" unless $field ;
|
|
|
|
my $field_cnt = $field ;
|
|
$field_cnt =~ s/$col_name\_//g ;
|
|
|
|
my $ucfirst_field = ucfirst $field ;
|
|
my $print_field = &common_min_print_field($field) ; if ($preferred_title{$field}) { $print_field = $preferred_title{$field} ; }
|
|
|
|
my @opts = ($radio_opts{$field}) ? split(/\;/,$radio_opts{$field}) : split(/\;/,$options);
|
|
|
|
my $row = qq~~ ;
|
|
|
|
my $cnt = 0 ;
|
|
|
|
if ($default_val && $default_val_is_saved) {
|
|
$background_color = "#424949" unless $background_color ;
|
|
$table_with_default_ids{$background_color} .= "#$table_id tr:eq($table_row) td:nth-last-child($table_col)," ;
|
|
}
|
|
|
|
foreach (@opts) {
|
|
$cnt++ ;
|
|
my $checked = ($cnt eq $default_val) ? 'CHECKED' : '' ;
|
|
$val_min = ($checked) ? $_ : $val_min ;
|
|
$row .= qq(<label class="btn btn-default" style="padding: 2px 3px 5px; font-size:12.5px; background-color:rgb(100,100,100);border-color:black;"><input type="radio" name="$field" id="$col_name\_$cnt\_$field_cnt" value="$cnt" $checked> $_</label> ) ;
|
|
if (!$default_val_is_saved || !$default_val) {
|
|
$default_javascript .= qq~"$col_name\_$cnt\_$field_cnt":"false",~ ;
|
|
} else {
|
|
my $default_val_boolian = ($cnt eq $default_val) ? "true" : "false" ;
|
|
$default_javascript .= qq~"$col_name\_$cnt\_$field_cnt":"$default_val_boolian",~ ;
|
|
}
|
|
push @all_radio_ids,"#shift_$cnt\_$field_cnt" ;
|
|
}
|
|
|
|
$row = substr($row,0,-12) ;
|
|
|
|
# my $row = qq($print_radios) ;
|
|
|
|
return ($row) ;
|
|
|
|
} #------------------------------------------------------------------------------------------
|
|
|
|
sub schedule_build_table {
|
|
|
|
my ($table_col_name,$field_name) = @_ ;
|
|
|
|
my $cali_cnt = 0 ; my $found_editable = 0 ; my @all_select_ids = () ;
|
|
|
|
$format84 -> set_align("center") ;
|
|
|
|
my $table_row = 0 ; my %default_vals = () ;
|
|
|
|
# foreach my $id (sort {$db{$table}{$a}{date_from} cmp $db{$table}{$b}{date_from}} keys %{$db{$table}}) {
|
|
foreach my $date_ref (sort keys %sort_calibration_by_time_ref) {
|
|
|
|
my $id = $sort_calibration_by_time_ref{$date_ref} ;
|
|
|
|
next unless $id ;
|
|
|
|
my $system_count = 0 ; my $system_day_cnt = 0 ;
|
|
|
|
my %default_monitors = () ;
|
|
|
|
my $day_cnt = 0 ;
|
|
my $sql_col = "$table_col_name" ;
|
|
my $inp_field = substr($sql_col,0,-1) ;
|
|
my $found_inp_field = 0 ;
|
|
foreach my $day_row (split(/\|/,$db{$table}{$id}{$sql_col})) {
|
|
$day_cnt++ ; $system_count = 0 ;
|
|
foreach my $system_row (split(/\;/,$day_row)) {
|
|
$system_count++ ; my $shift_cnt = 0 ;
|
|
foreach my $shift_monitor (split(/\:/,$system_row)) {
|
|
$shift_cnt++ ;
|
|
$default_monitors{$day_cnt}{$system_count}{$shift_cnt} = $shift_monitor ;
|
|
$found_inp_field = 1 if $shift_monitor eq $i{$inp_field} ;
|
|
}
|
|
}
|
|
}
|
|
$system_count = 0 ;
|
|
|
|
my %system_has_daily_op = () ; my %default_op_ids = () ;
|
|
|
|
foreach my $system_row (split(/\|/,$db{$table}{$id}{daily_operator_ids})) {
|
|
$system_count++ ;
|
|
next unless $system_row ;
|
|
$system_day_cnt = 0 ;
|
|
foreach my $col (split(/\;/,$system_row)) {
|
|
$system_day_cnt++ ;
|
|
next unless $col ;
|
|
$default_op_ids{$system_count}{$system_day_cnt} = $col if $col ;
|
|
$system_has_daily_op{$system_count} = 1 if $col ;
|
|
}
|
|
}
|
|
$system_count = 0 ;
|
|
|
|
unless (&common_check_if_string_contains_an_integer($db{$table}{$id}{event_system_id_multiple})) {
|
|
$db{$table}{$id}{event_system_id_multiple} = ";none;" ;
|
|
}
|
|
|
|
# my @system_name_ids = split(";",$db{$table}{$id}{event_system_id_multiple}) ;
|
|
|
|
my @system_name_ids = split(/\;/,$db{$table}{$id}{event_system_id_multiple}) ;
|
|
my @club_ids = split(/\;/,$db{$table}{$id}{club_ids}) ;
|
|
my @op_ids = split(/\,/,$db{$table}{$id}{operator_ids}) ;
|
|
my @days_active = split(/\;/,$db{$table}{$id}{days_active}) ;
|
|
my @start_times = ($db{$table}{$id}{qty} eq '1' && $days_active[0]) ? () : split(/\;/,";".$db{$table}{$id}{times_from}) ;
|
|
my @end_times = ($db{$table}{$id}{qty} eq '1' && $days_active[0]) ? () : split(/\;/,$db{$table}{$id}{times_to}) ;
|
|
|
|
my $cnt_rows = 0 ;
|
|
for (1 .. 50) {
|
|
$cnt_rows = $_ if $system_name_ids[$_ - 1] or $club_ids[$_ - 1] ;
|
|
}
|
|
|
|
my $system_count = 0 ; my $system_day_cnt = 0 ;
|
|
|
|
foreach my $event_sys_id (@system_name_ids) {
|
|
|
|
$system_count++ ;
|
|
|
|
next unless $event_sys_id ;
|
|
next if $db{event_systems}{$event_sys_id}{system_type} ne 'mobile' && !$monitoring_report && !$troubleshoot_monitoring_report ;
|
|
|
|
# &common_debug(">>>>>>>>> 2. $system_count [$id] $db{$table}{$id}{ref} [$db{event_systems}{$event_sys_id}{system_type}]") ;
|
|
|
|
# $event_cnt++ ;
|
|
|
|
# foreach my $cal_date (sort {$day_of_week{$a} cmp $day_of_week{$b}} keys %day_of_week) {
|
|
|
|
$system_day_cnt = 0 ;
|
|
|
|
foreach my $cal_date (sort keys %day_of_week) {
|
|
|
|
# my $srch_date_from_comp = $i{date_from} ; $srch_date_from_comp =~ s/\-//g ;
|
|
# my $srch_date_to_comp = $i{date_to} ; $srch_date_to_comp =~ s/\-//g ;
|
|
my $date_from_comp = substr($db{$table}{$id}{date_from},0,10) ; $date_from_comp =~ s/\-//g ;
|
|
my $date_to_comp = substr($db{$table}{$id}{date_to},0,10) ; $date_to_comp =~ s/\-//g ;
|
|
my $cal_date_comp = $cal_date ; # $cal_date_comp =~ s/\-//g ;
|
|
$cal_date = substr($cal_date,0,4) . '-' . substr($cal_date,4,2) . '-' . substr($cal_date,6,2) ;
|
|
my $date_from = substr($db{$table}{$id}{date_from},0,10) ;
|
|
$system_day_cnt++ ;
|
|
|
|
# &common_debug("[$cnt{$event_sys_id}{$id}] : $event_sys_id [$id] $cal_date") ;
|
|
|
|
# &common_debug("1. DATE >>> $cal_date_comp < $date_from_comp") if !$report ;
|
|
next if $cal_date_comp < $date_from_comp ;
|
|
# &common_debug("2. DATE >>> $cal_date_comp > $date_to_comp") if !$report ;
|
|
next if $cal_date_comp > $date_to_comp ;
|
|
|
|
$cnt{$event_sys_id}{$id}++ ;
|
|
|
|
next if $db{$table}{$id}{days_active} && !$days_active[$cnt{$event_sys_id}{$id}-1] ;
|
|
|
|
my $cal_date_val = $cal_date ; my $date_from_val = $i{date_from} ; my $date_to_val = $i{date_to} ;
|
|
|
|
$cal_date_val =~ s/\-//g ; $date_from_val =~ s/\-//g ; $date_to_val =~ s/\-//g ;
|
|
|
|
next if $cal_date_val < $date_from_val || $cal_date_val > $date_to_val ;
|
|
|
|
# # &common_debug("3. DATE >>> $cal_date_comp > $srch_date_to_comp") if !$report ;
|
|
# next if ($calibration_report) && $cal_date_comp > $srch_date_to_comp ;
|
|
# # &common_debug("4. DATE >>> $cal_date_comp < $srch_date_from_comp") if !$report ;
|
|
# next if ($calibration_report) && $cal_date_comp < $srch_date_from_comp ;
|
|
|
|
# &common_debug(">>>>>>>>> 3. $system_count [$id] $db{$table}{$id}{ref} [$db{event_systems}{$event_sys_id}{system_type}]") ;
|
|
|
|
# &common_debug("[$cnt{$event_sys_id}{$id}] : $event_sys_id [$id] $cal_date [$cal_date_comp > $srch_date_to_comp]") ;
|
|
|
|
$cali_cnt++;
|
|
|
|
$xlsxcol = 0 ;
|
|
$print_tbody .= qq~<tr id="$id$dow">~ ;
|
|
$table_row++ ;
|
|
|
|
our $default_javascript = "" ;
|
|
|
|
foreach (@sql_col_display) {
|
|
|
|
# &common_debug("1. XLSX >>> $_") if !$report ;
|
|
|
|
next unless $_ ; # blank for the buttons column
|
|
|
|
my $formatting = $format84 ;
|
|
my $val = $db{$table}{$id}{$_} ;
|
|
my $val_min = $val ;
|
|
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} ;
|
|
|
|
if ($_ eq 'count') {
|
|
# $val = $event_cnt ;
|
|
$val = $cali_cnt ;
|
|
} elsif ($_ eq 'event_nr') {
|
|
$val = "$id" ;
|
|
} elsif ($_ eq 'event') {
|
|
$val = "$db{$table}{$id}{ref} [$id]" ;
|
|
} elsif ($_ eq 'calibration_date' || $_ eq 'date') {
|
|
# $val = "$cal_date [$day_of_week{$cal_date}]" ;
|
|
$val = &common_min_date_as_string($cal_date) ;
|
|
$nowrap = "nowrap" ;
|
|
} elsif ($_ eq 'day') {
|
|
$val = "$sys_day_cnt" ;
|
|
} elsif ($_ eq 'start_date') {
|
|
$nowrap = "nowrap" ;
|
|
$val = &common_min_date_as_string($date_from) ;
|
|
} elsif ($_ eq 'venue') {
|
|
my @oids = split(/\,/,$db{$table}{$id}{organisation_ids}) ;
|
|
foreach $_oid (@oids) {
|
|
$val .= $db{organisations}{$_oid}{name} . '<br>' ;
|
|
}
|
|
$val = substr($val,0,-4) if $val ; ;
|
|
} elsif ($_ eq 'region') {
|
|
$val = $db{regions}{$db{$table}{$id}{region_id}}{code} ;
|
|
} elsif ($_ eq 'type') {
|
|
$val = (lc $db{event_systems}{$event_sys_id}{description} =~ /cricket/) ? "C" :
|
|
($db{event_systems}{$event_sys_id}{system_type} eq 'mobile') ? "M" :
|
|
($db{event_systems}{$event_sys_id}{system_type} eq 'fixed') ? "F" : "";
|
|
} elsif ($_ eq 'system') {
|
|
$val = '' ;
|
|
$val = qq~$db{event_systems}{$event_sys_id}{name}~ ;
|
|
$val .= qq~ ($db{event_systems}{$event_sys_id}{description})~ if $db{event_systems}{$event_sys_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}<br>~ ;
|
|
}
|
|
$val = substr($val,0,-4) if $val ;
|
|
} elsif ($_ eq 'club_name') {
|
|
$val = $db{clubs}{$club_ids[$system_count - 1]}{name} ;
|
|
} elsif ($_ eq 'operator') {
|
|
$val = '' ;
|
|
# $val = $db{users}{$table_op_ids[$system_count - 1]}{name} if $table_op_ids[$system_count - 1] ;
|
|
$val = ($default_op_ids{$system_count}{$cnt{$event_sys_id}{$id}}) ? $db{users}{$default_op_ids{$system_count}{$cnt{$event_sys_id}{$id}}}{name} : (!$default_op_ids{$system_count}{$system_day_cnt} && $system_has_daily_op{$system_count}) ? "None" : $db{users}{$op_ids[$system_count - 1]}{name} ;
|
|
# $formatting = $format92 if $event_cnt == 2 ;
|
|
$formatting = $format92 if $cali_cnt == 2 ;
|
|
} elsif ($_ eq 'start_time') {
|
|
if (!$start_times[$sys_day_cnt-1]) {
|
|
$val = substr($db{$table}{$id}{date_from},11,5) ;
|
|
} else {
|
|
$val = substr($start_times[$sys_day_cnt-1],0,5) ;
|
|
}
|
|
} elsif ($_ eq 'end_time') {
|
|
if (!$end_times[$sys_day_cnt-1]) {
|
|
$val = substr($db{$table}{$id}{date_to},11,5) ;
|
|
} else {
|
|
$val = substr($end_times[$sys_day_cnt-1],0,5) ;
|
|
}
|
|
} elsif ($_ eq 'status' || $_ eq 'fixture_check') {
|
|
push @first_table_multi_select_table_cells,"#$useropts{table_id} tr:eq($table_row) td:nth-last-child($last_child{$_})" ;
|
|
$field{$_} = "$_\_event$event_sys_id\_$sys_day_cnt\_$id" ;
|
|
$opts{$field{$_}} = $opts{$_} ;
|
|
my $background_color = qq~~ ;
|
|
if ($_ eq 'status' && $default_values{$_}{$event_sys_id}{$sys_day_cnt}{$id}) {
|
|
$val_min = $db{monitor_status}{$default_values{$_}{$event_sys_id}{$sys_day_cnt}{$id}}{status} ;
|
|
if ($default_values{$_}{$event_sys_id}{$sys_day_cnt}{$id} eq '1') {
|
|
$background_color = qq~rgb(81, 181, 41)~ ;
|
|
$formatting = $format94 ;
|
|
} elsif ($default_values{$_}{$event_sys_id}{$sys_day_cnt}{$id} eq '2') {
|
|
$background_color = qq~rgb(246, 227, 5)~ ;
|
|
$formatting = $format95 ;
|
|
} else {
|
|
$background_color = qq~rgb(249, 13, 13)~ ;
|
|
$formatting = $format96 ;
|
|
}
|
|
} elsif ($default_values{$_}{$event_sys_id}{$sys_day_cnt}{$id}) {
|
|
$val_min = $db{users}{$default_values{$_}{$event_sys_id}{$sys_day_cnt}{$id}}{name} ;
|
|
}
|
|
|
|
$val = &common_min_table_select($field{$_},$default_values{$_}{$event_sys_id}{$sys_day_cnt}{$id},'',$table_row,$last_child{$_},$background_color,$default_values{$_}{$event_sys_id}{$sys_day_cnt}{$id},$_) ;
|
|
} elsif ($_ eq 'update') {
|
|
|
|
my $field = "update_event$event_sys_id\_$sys_day_cnt\_$id" ;
|
|
$val = &common_min_form_checkbox_col($field,'') ;
|
|
|
|
chop $default_javascript if $default_javascript ;
|
|
# 12=s:;t:|s:1;t:1|s:2;t:2-13=|s:3;t:3|s:4;t:4
|
|
if ($default_javascript) {
|
|
push @default_javascript_by_id, qq~"event$event_sys_id\_$sys_day_cnt\_$id":{$default_javascript}~ ;
|
|
}
|
|
}
|
|
if ($_ ne 'status' && $_ ne 'calibrator' && substr($_,0,5) ne 'shift' && $_ ne 'update' && $_ ne 'status' && $_ ne 'fixture_check') {
|
|
$val_min = $val ;
|
|
$val_min =~ s/\<br>/\;/g ;
|
|
}
|
|
$print_tbody .= qq~<td $align $nowrap>$val</td>~ ;
|
|
|
|
# &common_debug("XLSX >>> $event_system_calibration_ids{$id}{$event_sys_id}{$sys_day_cnt} [$id] [$event_sys_id] [$sys_day_cnt] [$field]") ;
|
|
|
|
&xlsxcreator_write_xlsx($ws,$xlsxrow,$xlsxcol,$val_min,$formatting) ;
|
|
$xlsxcol++ ;
|
|
}
|
|
|
|
$print_tbody .= qq~</tr>~ ;
|
|
|
|
$xlsxrow++ ;
|
|
}
|
|
|
|
# next if $i{calibration_status} ne 'all' and $i{calibration_status} and $i{calibration_status} ne $db{event_systems}{$event_sys_id}{calibration_status} ;
|
|
# next if $i{calibrator_id} ne 'all' and $i{calibrator_id} and $i{calibrator_id} ne $db{event_systems}{$event_sys_id}{calibrator_id} ;
|
|
|
|
}
|
|
}
|
|
# || $troubleshoot_monitoring_report ;
|
|
my $html_id = ($monitoring_report) ? "selectShift_monitor_" : ($troubleshoot_monitoring_report) ? "selectShift_troubleshoot_monitor_" : "selectShift_temp_calibrator_" ;
|
|
my $html_id2 = ($monitoring_report) ? "shift-monitor-id-" : ($troubleshoot_monitoring_report) ? "shift-troubleshoot-monitor-id-" : "shift-temp-calibrator-id-" ;
|
|
$row_cnt++ if $monitoring_report || $troubleshoot_monitoring_report ;
|
|
|
|
$trigger_jquery_raw .= ($monitoring_report || $troubleshoot_monitoring_report) ? qq~
|
|
|
|
\$("#savebutt").click(function() {
|
|
for (let table_cnt = 1; table_cnt<= $date_cnt; table_cnt++) {
|
|
for (let i=1; i<=4; i++) {
|
|
let mon_id = \$("#$html_id"+i+"_1_1_"+table_cnt).chosen().val() ;
|
|
if (mon_id && typeof(mon_id) !== 'undefined') {
|
|
\$("#$html_id2"+i+"-"+table_cnt).val(mon_id) ;
|
|
}
|
|
}
|
|
}
|
|
\$("#$lcpage-form").submit() ;
|
|
}) ;
|
|
|
|
~ : qq~
|
|
\$("#savebutt").click(function() {
|
|
|
|
for (let table_cnt = 1; table_cnt<= $date_cnt; table_cnt++) {
|
|
|
|
for (let i=1; i<=4; i++) {
|
|
let mon_id = \$("#$html_id"+i+"_1_1_"+table_cnt).chosen().val() ;
|
|
if (mon_id) {
|
|
\$("#$html_id2"+i+"-"+table_cnt).val(mon_id) ;
|
|
}
|
|
}
|
|
|
|
let table_row_cnt = \$("#select_temp_calibrators_2_"+table_cnt).find('tr').length - 2 ;
|
|
|
|
if (table_cnt > 1) {
|
|
table_row_cnt += 2 ;
|
|
}
|
|
|
|
let seen_support = {} ;
|
|
|
|
for (i=1;i<=table_row_cnt;i++) {
|
|
|
|
let sel_val = \$("#selectName_2_"+i+"_"+table_cnt).val() ;
|
|
// if (!sel_val) {
|
|
// noty({text:'Please Select a Temp Support Name in all Rows',layout:"center",type:"error",timeout:3000}) ;
|
|
// return ;
|
|
// } else
|
|
if (seen_support[sel_val]) {
|
|
noty({text:'Please do not Select the same Temp Support Name in Multiple Rows for the Same Date',layout:"center",type:"error",timeout:3000}) ;
|
|
return ;
|
|
} else if (sel_val) {
|
|
seen_support[sel_val] = 1 ;
|
|
}
|
|
}
|
|
}
|
|
\$("#$lcpage-form").submit() ;
|
|
}) ;
|
|
~ ;
|
|
|
|
$worksheet{$ws}->set_column(0,0,10) ;
|
|
$worksheet{$ws}->set_column(1,1,30) ;
|
|
$worksheet{$ws}->set_column(2,2,15) ;
|
|
$worksheet{$ws}->set_column(3,3,5) ;
|
|
$worksheet{$ws}->set_column(4,4,15) ;
|
|
$worksheet{$ws}->set_column(5,6,10) ;
|
|
$worksheet{$ws}->set_column(7,7,30) ;
|
|
$worksheet{$ws}->set_column(8,9,10) ;
|
|
$worksheet{$ws}->set_column(10,10,30) ;
|
|
$worksheet{$ws}->set_column(11,11,15) ;
|
|
$worksheet{$ws}->set_column(12,16,20) ;
|
|
|
|
&report_xlsx_export_footer('L',15,$xlsxdir) ;
|
|
|
|
} #------------------------------------------------------------------------------------------
|
|
|
|
sub schedule_update {
|
|
|
|
my ($table,$table_field,$other_field,$table_field_2) = @_ ;
|
|
|
|
unless ($table_field_2) {
|
|
$table_field_2 = "blank" ;
|
|
$ignore{$table_field_2} = 1 ;
|
|
}
|
|
|
|
my ($s_year,$s_mon,$s_day) = split("-",$i{date_from}) ;
|
|
my ($e_year,$e_mon,$e_day) = split("-",$i{date_to}) ;
|
|
|
|
our $date_counter = 1 ;
|
|
|
|
while (int("$s_year$s_mon$s_day") <= int("$e_year$e_mon$e_day")) {
|
|
$date_cnt_to_date{$date_counter} = "$s_year-$s_mon-$s_day" ;
|
|
$date_counter++ ;
|
|
($s_year,$s_mon,$s_day) = Add_Delta_Days ($s_year,$s_mon,$s_day,1) ;
|
|
$s_mon = sprintf("%02d",$s_mon) ;
|
|
$s_day = sprintf("%02d",$s_day) ;
|
|
}
|
|
|
|
$date_cnt_to_date{$date_counter} = "$s_year-$s_mon-$s_day" ;
|
|
$date_counter-- ;
|
|
|
|
my %i_per_date = () ; my $temp_support_diff = 0 ;
|
|
|
|
if ($temp_calibrator_report) {
|
|
|
|
&db_min_ro($table,"date,temp_calibrator_support_shifts,$table_field","`date` >= '$i{date_from}' AND`date` <= '$i{date_to}'") ;
|
|
|
|
for my $date_cnt (1 .. $date_counter) {
|
|
|
|
my $table_pos = 0 ; my $cnt_per_date = 0 ; my $table_cnt = 0 ;
|
|
|
|
# $db{$table}{1}{temp_calibrator_support_shifts} =~ s/\|\|/\|/g ;
|
|
# $db{$table}{1}{temp_calibrator_support_shifts} =~ s/^\|//;
|
|
# $db{$table}{1}{temp_calibrator_support_shifts} =~ s/\|$//;
|
|
|
|
my @temp_calibrator_support_shifts_split = split(/\|/,$db{$table}{$date_cnt_to_date{$date_cnt}}{temp_calibrator_support_shifts}) ;
|
|
|
|
foreach (sort keys %i) {
|
|
|
|
$ignore{$_} = 1 ;
|
|
|
|
if ($_ =~ /^name_2_.*_$date_cnt$/) {
|
|
|
|
my @aaa = split(/\_/,$_) ;
|
|
$table_pos = $aaa[-3] ;
|
|
$cnt_per_date = $aaa[-2] ;
|
|
# $table_cnt = $aaa[-1] ;
|
|
|
|
my $update_field = "update_$table_pos\_$cnt_per_date\_$date_cnt" ;
|
|
my $name_field = "name_$table_pos\_$cnt_per_date\_$date_cnt" ;
|
|
my $shift_field = "shift_$table_pos\_$cnt_per_date\_$date_cnt" ;
|
|
|
|
if ($i{$update_field} && $i{$name_field} && $i{$shift_field}) {
|
|
$i_per_date{$date_cnt}{temp_calibrator_support_shifts} .= qq~$i{$name_field}:$i{$shift_field}|~ ;
|
|
} elsif ($temp_calibrator_support_shifts_split[$cnt_per_date-1]) {
|
|
my $abcde = $temp_calibrator_support_shifts_split[$cnt_per_date-1] ;
|
|
$i_per_date{$date_cnt}{temp_calibrator_support_shifts} .= qq~$abcde|~ ;
|
|
}
|
|
}
|
|
}
|
|
|
|
chop $i_per_date{$date_cnt}{temp_calibrator_support_shifts} if $i_per_date{$date_cnt}{temp_calibrator_support_shifts} ;
|
|
# $temp_support_exists = 1 if $i_per_date{$date_cnt}{temp_calibrator_support_shifts} ;
|
|
$temp_support_diff = 1 if $i_per_date{$date_cnt}{temp_calibrator_support_shifts} && $i_per_date{$date_cnt}{temp_calibrator_support_shifts} ne $db{$table}{$date_cnt_to_date{$date_cnt}}{temp_calibrator_support_shifts} ;
|
|
}
|
|
|
|
} else {
|
|
# return unless $i{update_table_1} ;
|
|
&db_min_ro($table,"date,$table_field,$table_field_2","`date` >= '$i{date_from}' AND `date` <= '$i{date_to}'") ;
|
|
}
|
|
|
|
my $some_update = 0 ;
|
|
|
|
for my $date_cnt (1 .. $date_counter) {
|
|
$some_update = 1 if $i{"update_1_1_$date_cnt"} || ($i{"update_2_1_$date_cnt"} || $temp_calibrator_report) ;
|
|
}
|
|
|
|
|
|
# return if !$i{update_table_1} && $temp_calibrator_report && $i{temp_calibrator_support_shifts} eq $db{$table}{1}{temp_calibrator_support_shifts} ;
|
|
return if !$some_update && !$temp_support_diff ;
|
|
|
|
&hidden_fields ;
|
|
my %ii = %i ;
|
|
|
|
# $ignore{blank} = 1 ;
|
|
|
|
for my $date_cnt (1 .. $date_counter) {
|
|
|
|
%i = () ;
|
|
|
|
# my $date_val = $ii{"date_$date_cnt"} ;
|
|
my $date_val = $date_cnt_to_date{$date_cnt} ;
|
|
|
|
# my $update_field = "update_1_1_$date_cnt" ;
|
|
|
|
next if !$ii{"update_1_1_$date_cnt"} && !$ii{"update_2_1_$date_cnt"} ;
|
|
|
|
if ($ii{"update_1_1_$date_cnt"}) {
|
|
|
|
my $ops_exists = 0 ; my $notes_exists = 0 ;
|
|
|
|
for my $shift_cnt (1 .. 4) {
|
|
$ii{"$other_field\_$shift_cnt\_$date_cnt"} =~ s/\,/\;/g ;
|
|
$i{$table_field} .= qq~$ii{"$other_field\_$shift_cnt\_$date_cnt"}|~ ;
|
|
$ops_exists = 1 if $ii{"$other_field\_$shift_cnt\_$date_cnt"} ;
|
|
$notes_exists = 1 if $table_field_2 && $ii{"shift_$table_field_2\_$shift_cnt\_1_1_$date_cnt"} ;
|
|
|
|
my $field_ = "shift_$table_field_2\_$shift_cnt\_1_1_$date_cnt" ;
|
|
|
|
$i{$table_field_2} .= qq~$ii{"shift_$table_field_2\_$shift_cnt\_1_1_$date_cnt"}:|:~ if $table_field_2 ;
|
|
}
|
|
chop $i{$table_field} ;
|
|
|
|
$i{$table_field} = qq~~ unless $ops_exists ;
|
|
$i{$table_field_2} = qq~~ if $table_field_2 && !$notes_exists ;
|
|
|
|
$i{$table_field_2} = substr($i{$table_field_2},0,-3) if $table_field_2 && $i{$table_field_2} ;
|
|
$ignore{$table_field} = 0 ;
|
|
$ignore{$table_field_2} = 0 if $table_field_2 && $table_field_2 ne 'blank' ;
|
|
} else {
|
|
$ignore{$table_field} = 1 ;
|
|
$ignore{$table_field_2} = 1 ;
|
|
}
|
|
# my $table_field_old = $table_field ;
|
|
|
|
# $table_field = $table_field_old ;
|
|
|
|
$i{temp_calibrator_support_shifts} = $i_per_date{$date_cnt}{temp_calibrator_support_shifts} if $temp_calibrator_report ;
|
|
|
|
if (!$db{$table}{$date_val}{date}) {
|
|
|
|
&db_min_ro($table,"1,MAX(id) + 1 AS 'max_id'","","","") ;
|
|
|
|
$i{id} = $db{$table}{1}{max_id} ;
|
|
$i{id} = 1 unless $i{id} ;
|
|
$i{date} = $date_val ;
|
|
|
|
$ignore{date} = 0 ;
|
|
$ignore{$table_field} = 1 unless $i{$table_field} ;
|
|
$ignore{temp_calibrator_support_shifts} = 1 if !$temp_calibrator_report || !$i{temp_calibrator_support_shifts} ;
|
|
|
|
&db_min_insert("$table") ;
|
|
|
|
} else {
|
|
|
|
$ignore{$table_field} = 1 if $db{$table}{$date_val}{$table_field} eq $i{$table_field} ;
|
|
$ignore{temp_calibrator_support_shifts} = 1 if $db{$table}{$date_val}{temp_calibrator_support_shifts} eq $i{temp_calibrator_support_shifts} || !$temp_calibrator_report ;
|
|
&db_min_upd($table,"`date`='$date_val'") if !$ignore{$table_field} || !$ignore{$table_field_2}|| !$ignore{temp_calibrator_support_shifts} ;
|
|
|
|
}
|
|
}
|
|
|
|
%i = %ii ;
|
|
|
|
} #------------------------------------------------------------------------------------------
|
|
|
|
sub schedule_payments_update {
|
|
|
|
my ($field) = @_ ;
|
|
|
|
my %iii = %i ;
|
|
my %ii = () ;
|
|
local $min_date = 0 ; local $max_date = 0 ;
|
|
foreach (sort keys %i) {
|
|
|
|
local $cell_name = $_ ;
|
|
local @a = split("_") ;
|
|
next if $a[-2] ne int($a[-2]) ;
|
|
|
|
if ($i{"paid_$a[-2]\_$a[-1]"} and $i{"amount_payble_$a[-2]\_$a[-1]"}) {
|
|
# my $date = substr($a[-1],0,4) . '-' . substr($a[-1],4,2) . '-' . substr($a[-1],6,2) ;
|
|
if ($a[0] eq 'amount') {
|
|
$i{$_} = sprintf("%.2f",$i{$_}) ;
|
|
$ii{$a[-1]}{"$field\_amounts_paid"} .= ($ii{$a[-1]}{"$field\_amounts_paid"}) ? qq~;$a[-2]:$i{$_}~ : qq~$a[-2]:$i{$_}~ ;
|
|
} elsif ($a[0] eq 'date') {
|
|
$ii{$a[-1]}{"$field\_dates_paid"} .= ($ii{$a[-1]}{"$field\_dates_paid"}) ? qq~;$i{$_}~ : qq~$i{$_}~ ;
|
|
}
|
|
}
|
|
$min_date = $a[-1] if ($min_id and $a[-1] < $min_id) or not $min_id ;
|
|
$max_date = $a[-1] if $a[-1] > $max_id ;
|
|
}
|
|
|
|
$min_date = substr($min_date,0,4) . '-' . substr($min_date,4,2) . '-' . substr($min_date,6,2) ;
|
|
$max_date = substr($max_date,0,4) . '-' . substr($max_date,4,2) . '-' . substr($max_date,6,2) ;
|
|
|
|
&db_min_ro($table,"date,$field\_dates_paid,$field\_amounts_paid","`date` <= '$max_date' AND `date` >= '$min_date'",'','') ;
|
|
|
|
foreach my $date (sort keys %ii) {
|
|
|
|
%i = () ;
|
|
|
|
# $i{"$field\_dates_paid"} .= qq~$ii{$date}{"$field\_dates_paid"}~ ;
|
|
|
|
my $date_string = substr($date,0,4) . '-' . substr($date,4,2) . '-' . substr($date,6,2) ;
|
|
|
|
$i{"$field\_amounts_paid"} = qq~$db{$table}{$date_string}{"$field\_amounts_paid"}~ ;
|
|
$i{"$field\_amounts_paid"} .= qq~;~ if $db{$table}{$date_string}{"$field\_amounts_paid"} && $ii{$date}{"$field\_amounts_paid"} ;
|
|
$i{"$field\_amounts_paid"} .= qq~$ii{$date}{"$field\_amounts_paid"}~ ;
|
|
|
|
$ignore{"$field\_amounts_paid"} = 1 if $i{"$field\_amounts_paid"} eq $db{$table}{$date_string}{"$field\_amounts_paid"} || !$i{"$field\_amounts_paid"} ;
|
|
|
|
$i{"$field\_dates_paid"} = qq~$db{$table}{$date_string}{"$field\_dates_paid"}~ ;
|
|
$i{"$field\_dates_paid"} .= qq~;~ if $db{$table}{$date_string}{"$field\_dates_paid"} && $ii{$date}{"$field\_dates_paid"} ;
|
|
$i{"$field\_dates_paid"} .= qq~$ii{$date}{"$field\_dates_paid"}~ ;
|
|
|
|
$ignore{"$field\_dates_paid"} = 1 if $i{"$field\_dates_paid"} eq $db{$table}{$date_string}{"$field\_dates_paid"} || !$i{"$field\_dates_paid"} ;
|
|
|
|
&db_min_upd($table,"`date`='$date_string'") if $i{"$field\_dates_paid"} || $i{"$field\_amounts_paid"} ;
|
|
|
|
}
|
|
|
|
%i = %iii ;
|
|
|
|
} #------------------------------------------------------------------------------------------
|
|
|
|
sub schedule_payments_report_ifields {
|
|
|
|
my ($field) = @_ ;
|
|
|
|
my $field2 = join(/ /, map { uc($_) } split(/\_/,$field)) ;
|
|
|
|
if ($i{date_from} and $i{date_to}) { # check dates
|
|
my $date_from_check = $i{date_from} ;
|
|
$date_from_check =~ s/\-//g ;
|
|
my $date_to_check = $i{date_to} ;
|
|
$date_to_check =~ s/\-//g ;
|
|
if ($date_from_check > $date_to_check) {
|
|
$error = qq~'$i{date_from}' > '$i{date_to}'~ ; &report_screen ;
|
|
}
|
|
push @report_sql, "((`date_from` >= '$i{date_from} 00:00:00' AND `date_from` <= '$i{date_to} 23:59:59') OR (`date_to` <= '$i{date_to} 23:59:59' AND `date_to` >= '$i{date_from} 00:00:00'))" ;
|
|
push @report_results, "(BETWEEN '$i{date_from}' AND '$i{date_to}')" ;
|
|
} elsif (not $i{date_from}) {
|
|
$error = qq~PLEASE ENTER A START DATE!~ ;
|
|
} elsif (not $i{date_to}) {
|
|
$error = qq~PLEASE ENTER A END DATE!~ ;
|
|
}
|
|
|
|
our $where_min = qq~~ ;
|
|
if ($i{"$field\_id"}) {
|
|
my $ifield = "$field\_id" ;
|
|
&db_min_ro('users','1,name',"`id` = '$i{$ifield}'",'','') ;
|
|
$where_min = " AND `$field\_ids` LIKE '%$i{$ifield}%'" ;
|
|
push @report_results,"$field2 = $db{users}{1}{name}" ;
|
|
}
|
|
|
|
if ($i{paid_status} eq 'paid') {
|
|
push @report_results,"$field2 AMOUNTS PAID" ;
|
|
} elsif ($i{paid_status} eq 'outstanding') {
|
|
push @report_results,"$field2 PAY OUTSTANDING" ;
|
|
}
|
|
|
|
$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) ;
|
|
}
|
|
|
|
} #------------------------------------------------------------------------------------------
|
|
|
|
sub schedule_payments_list_screen {
|
|
|
|
my ($field) = @_ ;
|
|
|
|
my $field2 = $field ;
|
|
|
|
$field2 =~ s/\_/\-/g ;
|
|
|
|
# &db_min_ro('event_cost_items','1,rates',"`name` LIKE '$field3%'",'','') ;
|
|
|
|
our @sql_col_display = ($i{paid_status} eq 'paid') ? ("date","$field\_names","shifts_count","dates_paid","amounts_paid","all_paid") : ($i{paid_status} eq 'all') ? ("date","$field\_names","shifts_count","dates_paid","amounts_paid","date_payable","amount_payable","paid") : ("date","$field\_names","shifts_count","date_payable","amount_payable","paid") ;
|
|
|
|
my $table_colspan = 0 ;
|
|
|
|
foreach (@sql_col_display) {
|
|
$table_colspan += 1 ;
|
|
}
|
|
|
|
local @month_arr = ("","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec") ;
|
|
|
|
my ($year1,$month1,$day1) = split(/\-/,$i{date_from}) ;
|
|
my ($year2,$month2,$day2) = split(/\-/,$i{date_to}) ;
|
|
|
|
my $date_string = qq~~ ;
|
|
|
|
if ($year1 ne $year2 && $month1 ne $month2 && $day1 ne $day2) {
|
|
$date_string = qq~ $day1 $month_arr[$month1] $year1 - $day2 $month_arr[$month2] $year2~ ;
|
|
} elsif ($year1 eq $year2 && $month1 ne $month2) {
|
|
$date_string = qq~ $day1 $month_arr[$month1] - $month_arr[$month2] $year2~ ;
|
|
} elsif ($year1 eq $year2 && $month1 eq $month2 && $day1 ne $day2) {
|
|
$date_string = qq~ $day1 - $day2 $month_arr[$month2] $year2~ ;
|
|
} elsif ($year1 eq $year2 && $month1 eq $month2 && $day1 eq $day2) {
|
|
$date_string = qq~ $day2 $month_arr[$month2] $year2~ ;
|
|
}
|
|
|
|
my $field_heading = join(" ", map { ucfirst($_) } split(/\_/,$field)) ;
|
|
|
|
our $xlsxheading = "$field_heading Payments Report$xlsreportname$date_string" ;
|
|
|
|
&report_xlsx_export_header("$field_heading Payments$xlsreportname","$field\_payments_report") ;
|
|
|
|
&schedule_payments_load_list_vars("$where_min","$field") ;
|
|
|
|
my @qty_work = () ;
|
|
my @amnt_usd_work = () ;
|
|
my @amnt_work = () ;
|
|
my @op_work = () ;
|
|
my @description = () ;
|
|
my @paid_work = () ;
|
|
my $row_cnt = 0 ;
|
|
my $first_id = 0 ;
|
|
my $last_id = 0 ;
|
|
my %row_cnt_to_id = () ;
|
|
|
|
$fcol = 12 ; my $val_min = 0 ; $row_cnt = 0 ;
|
|
|
|
my $date_pay = qq~~ ; my $quote_and_ops_ids = qq~~ ; my $op_ids = qq~~ ;
|
|
|
|
my ($next_year,$next_month,$next_day) = Add_Delta_Days($now_year,$now_mm,$now_dd,1) ;
|
|
|
|
my $row_cnt = 0 ; my $quote_and_ops_ids = qq~~ ;
|
|
|
|
my %amnt_tots = () ;
|
|
|
|
foreach my $date (sort {$a <=> $b} keys %{$db{$table}}) {
|
|
|
|
my @date_pay = split(/\;/,$db{$table}{$date}{"$field\_paid"}) ;
|
|
my @amount_pay = split(/\;/,$db{$table}{$date}{"$field\_amounts_paid"}) ;
|
|
my $date_val = $date ;
|
|
$date_val =~ s/\-//g ;
|
|
|
|
foreach my $temp_id (sort {$db{users}{$a}{name} cmp $db{users}{$b}{name}} keys %{$operator_count{$date}}) {
|
|
|
|
next if $i{"$field\_id"} && $i{"$field\_id"} ne $temp_id ;
|
|
|
|
next if $temp_id eq 'none' ;
|
|
|
|
my $amnt_owed = ($db{event_cost_items}{1}{rates}) ? $db{event_cost_items}{1}{rates} * $operator_count{$date}{$temp_id} : ($field =~ /calibrator/) ? 500 * $operator_count{$date}{$temp_id} : ($field =~ /monitor/ && $field !~ /troubleshoot/) ? 300 * $operator_count{$date}{$temp_id} : 450 * $operator_count{$date}{$temp_id} ;
|
|
$amnt_owed += $temp_support_rates{half_day}*$temp_calibrator_support{shift_count}{$date}{$temp_id}{1} ;
|
|
$amnt_owed += $temp_support_rates{full_day}*$temp_calibrator_support{shift_count}{$date}{$temp_id}{2} ;
|
|
# $temp_calibrator_support{count}{$date}{1} += ($abc[1] eq '1') ? 0.5 : 1 ;
|
|
# $temp_calibrator_support{shift_count}{$date}{1} += 1 ;
|
|
|
|
$amnt_owed = $amnt_owed - $amounts_paid{$date}{$temp_id} ;
|
|
|
|
$amnt_owed = 0 if $amounts_paid{$date}{$temp_id} ;
|
|
|
|
next if $i{paid_status} eq 'outstanding' && $amnt_owed == 0 ;
|
|
next if $i{paid_status} eq 'paid' && $amounts_paid{$date}{$temp_id} == 0 ;
|
|
|
|
$amnt_owed = sprintf("%0.2f",$amnt_owed) ;
|
|
$xlsxcol = 0 ;
|
|
|
|
foreach my $col (@sql_col_display) {
|
|
|
|
next unless $col ; # blank for the buttons column
|
|
$display = 1 ;
|
|
my $val = '' ;
|
|
my $align = '' ;
|
|
my $center = qq~ class="dt-center"~ ;
|
|
$align = $center ;
|
|
my $val_min = '' ;
|
|
|
|
if ($col eq 'date') {
|
|
$val = $date ;
|
|
} elsif ($col eq "$field\_names") {
|
|
$val = $db{users}{$temp_id}{name} ;
|
|
$val .= " [Support]" if $support_user{$temp_id} ;
|
|
} elsif ($col eq 'shifts_count') {
|
|
chop $operator_shifts_string{$date}{$temp_id} if $operator_shifts_string{$date}{$temp_id} ;
|
|
my $shifts_cnt = $operator_count{$date}{$temp_id} + $temp_calibrator_support{count}{$date}{$temp_id}{1} + $temp_calibrator_support{count}{$date}{$temp_id}{2} ;
|
|
$val_min = "$shifts_cnt" ;
|
|
$val_min .= " [$operator_shifts_string{$date}{$temp_id}]" if $operator_shifts_string{$date}{$temp_id} ;
|
|
$operator_shifts_string{$date}{$temp_id} =~ s/\;/\<br>/g ;
|
|
$val = ($operator_shifts_string{$date}{$temp_id}) ? qq~<a href="#" title="$operator_shifts_string{$date}{$temp_id}" data-toggle="tooltip" data-placement="top">$shifts_cnt</a>~ : $shifts_cnt ;
|
|
# $val = $operator_shifts{$date}{$temp_id}
|
|
} elsif ($col eq 'dates_paid') {
|
|
foreach (sort keys %{$dates_amounts_paid{$temp_id}}) {
|
|
$val .= ($val) ? qq~<br>$_~ : qq~$_~ ;
|
|
}
|
|
$val = "None" unless $val ;
|
|
$val_min = $val ;
|
|
$val_min =~ s/\<br>/\;/g ;
|
|
$val = qq~<i class="glyphicon glyphicon-list-alt" title="$val" data-toggle="tooltip" data-placement="top"></i>~ if $val =~ /<br>/ ;
|
|
} elsif ($col eq 'amounts_paid') {
|
|
foreach (sort keys %{$dates_amounts_paid{$temp_id}}) {
|
|
$dates_amounts_paid{$temp_id}{$_} = sprintf("%0.2f",$dates_amounts_paid{$temp_id}{$_}) ;
|
|
$val .= ($val) ? qq~<br>$dates_amounts_paid{$temp_id}{$_}~ : qq~$dates_amounts_paid{$temp_id}{$_}~ ;
|
|
$amnt_tots{"amounts_paid"} += $dates_amounts_paid{$temp_id}{$_} ;
|
|
}
|
|
$val = "None" unless $val ;
|
|
$val_min = $val ;
|
|
$val_min =~ s/\<br>/\;/g ;
|
|
$val = qq~<i class="glyphicon glyphicon-list-alt" title="$val" data-toggle="tooltip" data-placement="top"></i>~ if $val =~ /<br>/ ;
|
|
} elsif ($col eq 'date_payable') {
|
|
my $date_payable = "$now_year-$now_mm-$now_dd" ;
|
|
$val = ($amnt_owed != 0) ? &common_min_form_input_col("date_$temp_id\_$date_val",$date_payable) : "N/A" ;
|
|
$val_min = ($amnt_owed != 0) ? $date_payable : "N/A" ;
|
|
} elsif ($col eq 'amount_payable') { #dates_amounts_paid
|
|
$count_outstanding++ if $amnt_owed > 0 ;
|
|
$amnt_tots{"amount_payable"} += $amnt_owed ;
|
|
$val = ($amnt_owed != 0) ? &common_min_form_input_col("amount_payble_$temp_id\_$date_val",$amnt_owed) : "None" ;
|
|
$val_min = $amnt_owed ;
|
|
} elsif ($col eq 'paid') {
|
|
$val = ($amnt_owed != 0) ? &common_min_form_checkbox_col("paid_$temp_id\_$date_val",0) : '<i class="glyphicons glyphicons-tick"></i>' ;
|
|
$val_min = ($amnt_owed != 0) ? "No" : "Yes" ;
|
|
} elsif ($col eq 'all_paid') {
|
|
$val = ($amnt_owed != 0) ? '<i class="glyphicons glyphicons-remove"></i>' : '<i class="glyphicons glyphicons-tick"></i>' ;
|
|
$val_min = ($amnt_owed != 0) ? "No" : "Yes" ;
|
|
}
|
|
$val_min = $val if $col eq 'date' || $col eq "$field\_names" ;
|
|
|
|
&xlsxcreator_write_xlsx($ws,$xlsxrow,$xlsxcol,$val_min,$format_management_report_data) if $col ne 'shifts_count' ;
|
|
&xlsxcreator_write_xlsx($ws,$xlsxrow,$xlsxcol,$val_min,$format_management_report_data_ref_nr) if $col eq 'shifts_count' ;
|
|
$xlsxcol++ ;
|
|
# if ($_ eq 'ref_nr' or $_ eq 'camera_nr') { $val = &common_camera_links($tables,$id,$val) ;}
|
|
$print_tbody .= qq~<td $align>$val</td>~ ;
|
|
|
|
}
|
|
$print_tbody .= qq~</tr>~ ;
|
|
$xlsxrow++ ;
|
|
$row_cnt++ ;
|
|
$quote_and_ops_ids .= qq~"$row_cnt\_$temp_id":"$date_val",~ ;
|
|
}
|
|
# chop $op_ids if $op_ids ;
|
|
# $quote_and_ops_ids .= qq~"$row_cnt_$id":[$op_ids],~ if $op_ids ;
|
|
}
|
|
|
|
my $col_cnt = 0 ;
|
|
|
|
foreach my $col (@sql_col_display) {
|
|
|
|
if ($col eq 'date') {
|
|
&xlsxcreator_write_xlsx($ws,$xlsxrow,$col_cnt,"TOTALS",$format_management_report_total) ;
|
|
} elsif ($col eq "amounts_paid" || $col eq "amount_payable") {
|
|
&xlsxcreator_write_xlsx($ws,$xlsxrow,$col_cnt,"$amnt_tots{$col}",$format_management_report_totals) ;
|
|
} else {
|
|
&xlsxcreator_write_xlsx($ws,$xlsxrow,$col_cnt,"-",$format_management_report_totals) ;
|
|
}
|
|
$col_cnt++ ;
|
|
}
|
|
|
|
chop $quote_and_ops_ids if $quote_and_ops_ids ;
|
|
|
|
# $print_tbody .= qq~<tr>~ ;
|
|
# $print_tbody .= qq~</tr>~ ;
|
|
$worksheet{$ws} -> set_column(0,0,15) ;
|
|
$worksheet{$ws} -> set_column(1,1,25) ;
|
|
$worksheet{$ws} -> set_column(2,7,20) if $i{paid_status} eq 'all' ;
|
|
$worksheet{$ws} -> set_column(2,5,20) if $i{paid_status} ne 'all' ;
|
|
|
|
$box_icon .= qq~<div class="box-icon" title='Toggle all Selected' data-toggle="tooltip" data-placement="left"><a class="btn btn-default btn-round" href="javascript:selectAll();" style="padding-top:1px;"><i class="glyphicon glyphicon-usd icon-white"></i></a></div>~ if $i{paid_status} ne 'paid' && $count_outstanding > 0 ;
|
|
|
|
&report_xlsx_export_footer('L',15,"$field\_payments_report") ;
|
|
|
|
$fnsortcol = 0;
|
|
$fnsortorder = 'asc' ;
|
|
&common_min_extra_crumb("$lcpage\s","Search Screen") ;
|
|
|
|
$trigger_jquery_raw .= qq~
|
|
function selectAll() {
|
|
let jsObject = {
|
|
$quote_and_ops_ids
|
|
} ;
|
|
for (let key in jsObject) {
|
|
let op_id = jsObject[key] ;
|
|
let parts = key.split("_") ;
|
|
let event_id = parts[1] ;
|
|
\$(\$("#itv-table").dataTable().fnGetNodes()).find(\$("input[name=paid_"+event_id+"_"+op_id+"]")).each(function () {
|
|
// console.log("input[name=paid_"+event_id+"_"+op_id+"]") ;
|
|
if(\$(this).is(':checked')) {
|
|
\$(this).prop('checked',false) ;
|
|
} else {
|
|
\$(this).prop('checked',true) ;
|
|
}
|
|
}) ;
|
|
}
|
|
}
|
|
~;
|
|
|
|
my $field_id = "#$field2\-payment-form" ;
|
|
|
|
# my $savebuttjs = ($count_outstanding > 0) ? qq~$("$field_id").submit();' : 'noty({text:"There are no calibrators to pay!",layout:"center",type:"error",timeout:3000});return;~ ;
|
|
|
|
$trigger_jquery_raw .= qq~
|
|
\$("#savebutt").click(function() {
|
|
// $savebuttjs
|
|
\$("$field_id").submit();
|
|
}) ;
|
|
~ ;
|
|
|
|
$fcol = 2 ;
|
|
|
|
$print_box_content_rows .= qq~<div style = "display:none;">~ ;
|
|
$print_box_content_rows .= &common_min_form_input_col("date_from",$i{date_from}) ; #date_from_i_field
|
|
$print_box_content_rows .= &common_min_form_input_col("date_to",$i{date_to}) ; #date_to_i_field
|
|
$print_box_content_rows .= &common_min_form_input_col("$field\_id",$i{"$field\_id"}) ; #temp_calibrator_id_i_field
|
|
$print_box_content_rows .= &common_min_form_input_col("$field\s_paid",$i{"$field\s_paid"}) ;
|
|
$print_box_content_rows .= qq~</div>~ ;
|
|
|
|
$print_box_content_rows .= &common_min_forms_start("$field2\-payment") if $count_outstanding ;
|
|
|
|
} #------------------------------------------------------------------------------------------
|
|
|
|
sub schedule_payments_load_list_vars {
|
|
|
|
my ($where,$field) = @_ ;
|
|
|
|
my $users_sql = ($field =~ /calibrator/) ? "`user_type` = 'casual_calibrator' OR `user_type` = 'support'" : "" ;
|
|
|
|
&db_min_ro('users','id,name',"$users_sql",'','') ;
|
|
|
|
&db_min_ro($table,"date,$field\_ids,$field\_dates_paid,$field\_amounts_paid,temp_calibrator_support_shifts","`date`>='$i{date_from}' AND `date`<='$i{date_to}' $where",'','') ;
|
|
|
|
# &db_min_ro('shift_monitor_ids','date,monitor_ids',"`date`>='$i{date_from}' AND `date`<='$i{date_to}' $where",'','') ;
|
|
|
|
our %operator_count = () ; our %amounts_paid = () ; our %dates_amounts_paid = () ; our %operator_shifts_string = () ;
|
|
|
|
# my @monitor_shifts = ("","08:00-11:00","11:00-14:00","14:00-17:00","17:00-21:00") ;
|
|
my @operator_shifts = ($field =~ /calibrator/) ? ("","07:00-10:00","10:00-13:00","13:00-16:00","16:00-19:00") : ("","08:00-11:00","11:00-14:00","14:00-17:00","17:00-21:00") ;
|
|
|
|
foreach my $date (keys %{$db{$table}}) {
|
|
my $shift_cnt = 0 ;
|
|
foreach my $shift (split(/\|/,$db{$table}{$date}{"$field\_ids"})) {
|
|
$shift_cnt++ ;
|
|
next unless $shift ;
|
|
foreach my $temp_id (split(/\;/,$shift)) {
|
|
next unless $temp_id ;
|
|
$operator_count{$date}{$temp_id} += 1 ;
|
|
$operator_shifts_string{$date}{$temp_id} .= qq~$operator_shifts[$shift_cnt];~ ;
|
|
}
|
|
}
|
|
$shift_cnt = 0 ;
|
|
# foreach my $shift (split(/\|/,$db{$table}{$date}{monitor_ids})) {
|
|
# $shift_cnt++ ;
|
|
# next unless $shift ;
|
|
# foreach my $temp_id (split(/\;/,$shift)) {
|
|
# next unless $temp_id ;
|
|
# $operator_count{$date}{$temp_id} += 1 ;
|
|
# $operator_shifts{$date}{$temp_id} .= qq~$monitor_shifts[$shift_cnt],~ ;
|
|
# }
|
|
# }
|
|
my @date_pay = split(/\;/,$db{$table}{$date}{"$field\_dates_paid"}) ;
|
|
my @amount_pay = split(/\;/,$db{$table}{$date}{"$field\_amounts_paid"}) ;
|
|
my $cnt = 0 ;
|
|
foreach my $temp_id_amnt (@amount_pay) {
|
|
my @temp_amnt = split(/\:/,$temp_id_amnt) ;
|
|
$amounts_paid{$date}{$temp_amnt[0]} += $temp_amnt[1] ;
|
|
$dates_amounts_paid{$temp_amnt[0]}{$date_pay[$cnt]} += $temp_amnt[1] ;
|
|
$cnt++ ;
|
|
}
|
|
|
|
if ($temp_calibrator_payments_report && $db{$table}{$date}{temp_calibrator_support_shifts}) {
|
|
|
|
foreach my $shift (split(/\|/,$db{$table}{$date}{temp_calibrator_support_shifts})) {
|
|
|
|
$shift_cnt++ ;
|
|
next unless $shift ;
|
|
my @abc = split(/\:/,$shift) ;
|
|
next unless $abc[0] ;
|
|
|
|
$operator_count{$date}{$abc[0]} += 0 ;
|
|
# $operator_count{$date}{$abc[0]} += ($abc[1] eq '1') ? 0.5 : 1 ;
|
|
$temp_calibrator_support{count}{$date}{$abc[0]}{$abc[1]} += ($abc[1] eq '1') ? 0.5 : 1 ;
|
|
$temp_calibrator_support{shift_count}{$date}{$abc[0]}{$abc[1]} += 1 ;
|
|
$operator_shifts_string{$date}{$abc[0]} .= ($abc[1] eq '1') ? qq~Half Day (<7 hours);~ : qq~Full Day (7 hours+);~ ;
|
|
$support_user{$abc[0]} = 1 ;
|
|
}
|
|
}
|
|
}
|
|
|
|
} #------------------------------------------------------------------------------------------
|
|
|
|
sub schedule_payments_report_screen {
|
|
|
|
my ($field) = @_ ;
|
|
|
|
our $lcol = 3 ;
|
|
our $fcol = 5 ;
|
|
|
|
$print_box_content_rows .= &common_min_forms_start('report') ;
|
|
|
|
&common_min_select_opts("$field\_id",'users',"name",$i{"$field\_id"},'','',"`name` NOT LIKE 'Rory%' AND `name` NOT LIKE 'Handre%'") ;
|
|
# &common_min_select_opts('event_quote_id','event_quotes',"ref",$i{event_quote_id},'','',"") ;
|
|
|
|
$first_day_month = sprintf("%02d",$first_day_month) ; $first_day = sprintf("%02d",$first_day) ;
|
|
$print_box_content_rows .= &common_min_form_datepicker('date_from',"$now_year-$now_mm-01") unless $i{date_from} ;
|
|
|
|
my $days_in_month = Days_in_Month($now_year,$now_mm) ;
|
|
|
|
$print_box_content_rows .= &common_min_form_datepicker('date_to',"$now_year-$now_mm-$days_in_month") ;
|
|
|
|
# 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',"$next_year-$next_month-$next_day") ; #unless $i{date_from} ;
|
|
|
|
$opts{paid_status} .= qq~<option value="all">All</option>~ ;
|
|
$opts{paid_status} .= qq~<option value="paid">Paid</option>~ ;
|
|
$opts{paid_status} .= qq~<option value="outstanding" SELECTED>Outstanding</option>~ ;
|
|
|
|
$print_box_content_rows .= &common_min_form_select("$field\_id",'') ;
|
|
# $print_box_content_rows .= &common_min_form_select('event_quote_id','') ;
|
|
$print_box_content_rows .= &common_min_form_select('paid_status','') ;
|
|
$print_box_content_rows .= &common_min_forms_end('','','report') ;
|
|
|
|
&common_min_search_screen ;
|
|
|
|
} #------------------------------------------------------------------------------------------
|
|
|
|
1 ; |