#!/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; &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 $debug = 1 ; #-------- page opts -------------------------------------------------------------------------------------------------------------------------------------------------- &page_opts ; #--------------------------------------------------------------------------------------------------------------------------------------------------------------------- our $srchscr = 1 ; &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; } if ($iaction eq 'save') { &common_min_load_params ; &update ; &screen4; } &common_min_action; $db_ignore_open_close = 0 ; # do one open and one close instead of repeating it &db_close_conn ; exit; #------------------------------------------------------------------------------------------ sub update { my %iii = %i ; my %ii = () ; local $min_id = 0 ; local $max_id = 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]"}) { if ($a[0] eq 'amount') { $i{$_} = sprintf("%.2f",$i{$_}) ; $ii{$a[-2]}{$a[-1]}{operator_amounts_paid} .= qq~$a[-1]:$i{$_}~ ; } elsif ($a[0] eq 'date') { $ii{$a[-2]}{$a[-1]}{operator_dates_paid} .= qq~$i{$_}~ ; } } $min_id = $a[-2] if ($min_id and $a[-2] < $min_id) or not $min_id ; $max_id = $a[-2] if $a[-2] > $max_id ; } &db_min_ro('event_quotes_min',"id,operator_dates_paid,operator_amounts_paid","`id` <= '$max_id' AND `id` >= '$min_id'",'','') ; &common_debug("SELECT id,operator_dates_paid,operator_dates_paid FROM event_quotes_min WHERE `id` <= '$max_id' AND `id` >= '$min_id'") ; foreach my $id (sort keys %ii) { %i = () ; $i{operator_dates_paid} = '' ; $i{operator_amounts_paid} = '' ; foreach my $op_id (keys %{$ii{$id}}) { $i{operator_dates_paid} .= qq~;~ if $i{operator_dates_paid} ; $i{operator_amounts_paid} .= qq~;~ if $i{operator_amounts_paid} ; $i{operator_dates_paid} .= qq~$ii{$id}{$op_id}{operator_dates_paid}~ ; $i{operator_amounts_paid} .= qq~$ii{$id}{$op_id}{operator_amounts_paid}~ ; } $i{operator_amounts_paid} = qq~$db{event_quotes_min}{$id}{operator_amounts_paid};$i{operator_amounts_paid}~ if $db{event_quotes_min}{$id}{operator_amounts_paid} ; $ignore{operator_amounts_paid} = 1 unless $i{operator_amounts_paid} ; $i{operator_dates_paid} = qq~$db{event_quotes_min}{$id}{operator_dates_paid};$i{operator_dates_paid}~ if $db{event_quotes_min}{$id}{operator_dates_paid} ; $ignore{operator_dates_paid} = 1 unless $i{operator_dates_paid} ; &db_min_upd("event_quotes_min","id='$id'") if $i{operator_dates_paid} or $i{operator_amounts_paid} ; &common_debug("UPDATE event_quotes_min SET operator_dates_paid = $i{operator_dates_paid},operator_amounts_paid = $i{operator_amounts_paid} WHERE id = '$id'") if $i{operator_dates_paid} or $i{operator_amounts_paid} ; } %i = %iii ; } #------------------------------------------------------------------------------------------ sub report_ifields { 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, "((e.date_from >= '$i{date_from} 00:00:00' AND e.date_from <= '$i{date_to} 23:59:59') OR (e.date_to <= '$i{date_to} 23:59:59' AND e.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{operator_id}) { &db_min_ro('users','1,name',"`id` = '$i{operator_id}'",'','') ; # $where_min = "(m.operator_workings_event LIKE '%;$i{operator_id};%' OR m.operator_workings_event LIKE '$i{operator_id};%' OR m.operator_workings_event LIKE '%;$i{operator_id}')" ; $where_min = "FIND_IN_SET($i{operator_id},REPLACE(m.operator_workings_event,';',','))" ; push @report_results,"OPERATOR = $db{users}{1}{name}" ; } if ($i{event_quote_id}) { &db_min_ro('event_quotes','1,ref',"`id`='$i{event_quote_id}'",'','') ; push @report_sql, "(e.id = '$i{event_quote_id}')" ; push @report_results,"EVENT QUOTE = $db{event_quotes}{1}{ref}" ; } if ($i{paid_status} eq 'paid') { push @report_results,"OPERATOR ARE ALL PAID" ; } elsif ($i{paid_status} eq 'outstanding') { push @report_results,"OPERATORS 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 list_screen { $print_box_content_rows .= &common_min_forms_start('invoice') ; our $open_new_tab = qq~target="_blank"~ ; # opens booking page in a new tab push @report_sql, "(e.quote_completed = '1')" ; my $srch_where_sql = join(' AND ', @report_sql) ; our @sql_col_display = ($i{paid_status} eq 'all') ? ("event_quote_nr","operator_names","event_name","event_date_from","event_date_to","description","amount","date_paid","amount_paid","date_payable","amount_payable","paid") : ($i{paid_status} eq 'paid') ? ("event_quote_nr","operator_names","event_name","event_date_from","event_date_to","description","amount","date_paid","amount_paid","paid") : ("event_quote_nr","operator_names","event_name","event_date_from","event_date_to","description","amount","date_payable","amount_payable","paid") ; my $table_colspan = 0 ; foreach (@sql_col_display) { $table_colspan += 1 ; } &report_xlsx_export_header("Operators_Report$xlsreportname",'operators_report') ; &load_list_vars("$srch_where_sql","$where_min") ; my $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 = 2 ; $print_box_content_rows .= qq~
~ ; $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("operator_id",$i{operator_id}) ; #operator_id_i_field $print_box_content_rows .= &common_min_form_input_col("event_quote_id",$i{event_quote_id}) ; $print_box_content_rows .= &common_min_form_input_col("operators_paid",$i{operators_paid}) ; $print_box_content_rows .= qq~
~ ; $fcol = 12 ; my $val_min = 0 ; $row_cnt = 0 ; my $date_pay = qq~~ ; my $quote_and_ops_ids = qq~~ ; my $op_ids = qq~~ ; my %historic_payments_tooltip = () ; our @months = ("","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec") ; foreach my $id (sort {$a <=> $b} keys %{$db{$tables}}) { if ($i{client_id}) { next unless $client{$i{client_id}} eq $quote_customer{$id} ; } $cnt_in_stock = -1 ; my $in_stock = "" ; @date_pay = split(";",$db{$tables}{$id}{operator_dates_paid}) ; @amount_pay = split(";",$db{$tables}{$id}{operator_amounts_paid}) ; # @paid = split(";",$db{$tables}{$id}{amount_is_paid_workings_event}) ; @qty_work = split(";", $db{$tables}{$id}{qty_workings_event}) ; @amnt_usd_work = split(";", $db{$tables}{$id}{amount_usd_workings_event}) ; @amnt_work = split(";", $db{$tables}{$id}{amount_workings_event}) ; @op_work = split(";", $db{$tables}{$id}{operator_workings_event}) ; @paid_work = split(";", $db{$tables}{$id}{paid_workings_event}) ; # ???? @description = split(";", $db{$tables}{$id}{description_workings_event}) ; # &common_debug("[$tables] $id -> $db{$tables}{$id}{operator_ids} [amount_workings_event=$db{$tables}{$id}{amount_workings_event}]") ; my $tot_amnt_work = 0 ; my %tot_amnt = () ; my %amnt_paid = () ; my $amount_paid = 0 ; my %historic_payments_tooltip = () ; my %historic_payments = () ; my $amnt_cnt = 0 ; foreach (@amount_pay) { $amount_paid += $_ ; my ($op_id,$amnt_paid) = split(/\:/,$_) ; $historic_payments_tooltip{$op_id} .= qq~
~ if $historic_payments_tooltip{$op_id} ; $historic_payments_tooltip{$op_id} .= qq~$date_pay[$amnt_cnt]:$amnt_paid~ ; $historic_payments{$op_id}{date} .= qq~
~ if $historic_payments{$op_id}{date} ; $historic_payments{$op_id}{date} .= qq~$date_pay[$amnt_cnt]~ ; $historic_payments{$op_id}{amnt} .= qq~
~ if $historic_payments{$op_id}{amnt} ; $historic_payments{$op_id}{amnt} .= qq~$amnt_paid~ ; $amnt_cnt++ ; } my %description_toolip = () ; my %seen_des = () ; my $cnt_des = -1 ; my %seen_op = () ; foreach (@description) { $cnt_des++ ; next if $op_work[$cnt_des] != $i{operator_id} and $i{operator_id} ; next unless $op_work[$cnt_des] ; next if $seen_des{$_} and $seen_op{$_} ; $seen_des{$_} = 1 ; $seen_op{$op_work[$cnt_des] } = 1 ; $description_toolip{$op_work[$cnt_des]} .= qq~
~ if $description_toolip{$op_work[$cnt_des]} ; $description_toolip{$op_work[$cnt_des]} .= qq~$db{event_cost_items}{$_}{name}~ ; } my $operator_toolip = qq~~ ; my %seen_op = () ; my $cnt_op = -1 ; foreach (@op_work) { $cnt_op++ ; next if $op_work[$cnt_op] != $i{operator_id} and $i{operator_id} ; next unless $op_work[$cnt_op] ; next if $seen_op{$_} ; $seen_op{$_} = 1 ; $operator_toolip .= qq~
~ if $cnt_op ; $operator_toolip .= qq~$casual_names_from_ids{$_}~ ; } my %amnt_toolip = () ; my $cnt_amnt = -1 ; foreach (@amnt_work) { $cnt_amnt++ ; next if $op_work[$cnt_amnt] != $i{operator_id} and $i{operator_id} ; next unless $op_work[$cnt_amnt] ; $amnt_toolip{$op_work[$cnt_amnt]} .= qq~
~ if $amnt_toolip{$op_work[$cnt_amnt]} ; $amnt_toolip{$op_work[$cnt_amnt]} .= qq~$_~ ; $tot_amnt{$op_work[$cnt_amnt]} += $_ ; } foreach (@amount_pay) { my @abc = split(":",$_) ; $amnt_paid{$abc[0]} += $abc[1] ; } my $amnt_usd_toolip = qq~~ ; my $cnt_usd_amnt = 0 ; my $column_count = 0 ; # $row_cnt = 0 ; $op_ids = qq~~ ; # my $operators_count = 0 ; foreach my $op_id (sort {$casual_names_from_ids{$a} cmp $casual_names_from_ids{$b}} keys %seen_op) { local $amnt_owed = $tot_amnt{$op_id} - $amnt_paid{$op_id} ; if ($amnt_owed <= 0.00001 && $amnt_owed >= -0.00001) { $amnt_owed = 0 ; } next if $i{paid_status} eq 'outstanding' && $amnt_owed <= 0 ; next if $i{paid_status} eq 'paid' && $amnt_owed > 0 ; $first_id = $id unless $first_id ; $last_id = $id if $last_id < $id ; $amnt_owed = sprintf("%.2f",$amnt_owed) ; $count_outstanding++ if $amnt_owed > 0 ; $op_ids .= qq~$op_id,~ ; $column_count++ ; $xlsxcol = 0 ; $print_tbody .= qq~~ ; $row_cnt++ ; foreach (@sql_col_display) { next unless $_ ; # blank for the buttons column $display = 1 ; my $val = $db{$tables}{$id}{$_} ; my $align = '' ; my $center = qq~ class="dt-center"~ ; $align = $center ; if ($_ eq 'event_date_from' or $_ eq 'event_date_to') { $val = $db{$tables}{$id}{date_from} if $_ eq 'event_date_from' ; $val = $db{$tables}{$id}{date_to} if $_ eq 'event_date_to' ; $val = &common_min_date_as_string(substr($val,0,10)) ; } elsif ($_ eq 'operator_names') { $val = $casual_names_from_ids{$op_id} ; } elsif ($_ eq 'amount') { $tot_amnt{$op_id} = sprintf("%.2f",$tot_amnt{$op_id}) ; $val = qq~
$tot_amnt{$op_id}
~ ; $amnt_toolip{$op_id} = s/\
/\;/g ; $val_min = "$tot_amnt{$op_id}" ; # $val_min .= " [$amnt_toolip{$op_id}]" if $amnt_toolip{$op_id} && $amnt_toolip{$op_id} =~ /;/ ; } elsif ($_ eq 'event_quote_nr') { # my $class = 'info' ; # if ($quote_status{$id} == 1) { # $class = 'danger' ; # } elsif ($quote_status{$id} == 2) { # $class = 'success' ; # } elsif ($quote_status{$id} == 3) { # $class = 'danger' ; # } elsif ($quote_status{$id} == 4) { # $class = 'warning' ; # } # $val = qq~$id~ ; my $sort_val = sprintf("%09d",$id) ; $val = qq~$sort_val~ . &common_min_get_event_quote_button($id,$table) ; } elsif ($_ eq 'date_paid') { $val = join("
", map { &common_min_date_as_string($_) } split(/\
/,$historic_payments{$op_id}{date})) ; $val_min = $val ; $val_min =~ s/\
/\;/g ; } elsif ($_ eq 'amount_paid') { $val = $historic_payments{$op_id}{amnt} ; $val_min = $val ; $val_min =~ s/\
/\;/g ; } elsif ($_ eq 'date_payable') { if ($date_pay[$column_count - 1]) { # $val = ($amnt_owed > 0) ? &common_min_form_input_col("date_$id\_$op_id",$date_pay[$column_count - 1]) : "N/A" ; # $historic_payments_tooltip{$op_id} = qq~PAID
$historic_payments_tooltip{$op_id}~ if $historic_payments_tooltip{$op_id} ; $historic_payments_tooltip{$op_id} = qq~~ ; $val = ($amnt_owed > 0) ? &common_min_form_input_col("date_$id\_$op_id",$date_pay[$column_count - 1]) : ($historic_payments_tooltip{$op_id}) ? qq~N/A~ : "N/A" ; $val_min = ($amnt_owed > 0) ? $date_pay[$column_count - 1] : "N/A" ; } else { # my $date_payable = ($i{date_to}) ? $i{date_to} : "$now_year-$now_mm-$now_dd" ; my $date_payable = "$now_year-$now_mm-$now_dd" ; $val = &common_min_form_input_col("date_$id\_$op_id",$date_payable) ; $val_min = $date_payable ; } } elsif ($_ eq 'amount_payable') { $val = ($amnt_owed > 0) ? &common_min_form_input_col("amount_payble_$id\_$op_id",$amnt_owed) : $amnt_owed ; $val_min = $amnt_owed ; } elsif ($_ eq 'paid') { if ($amount_pay[$column_count - 1]) { $val = ($amnt_owed > 0) ? &common_min_form_checkbox_col("paid_$id\_$op_id",1) : '' ; } else { $val = ($amnt_owed > 0) ? &common_min_form_checkbox_col("paid_$id\_$op_id",0) : '' ; } $val_min = ($amnt_owed > 0) ? "No" : "Yes" ; } elsif ($_ eq 'event_name') { $val = $db{$tables}{$id}{ref} ; } elsif ($_ eq 'description') { if ($description_toolip{$op_id} =~ '
') { $val = qq~~ ; $description_toolip{$op_id} = s/\
/\;/g ; } else { $val = $description_toolip{$op_id} ; } $val_min = $description_toolip{$op_id} ; $val_min =~ s/\
/\;/g ; } if ($_ ne 'event_quote_nr' and $_ ne 'availablity' and $_ ne 'qty' and $_ ne 'date_payable' and $_ ne 'amount_payable' and $_ ne 'paid' and $_ ne 'amount' and $_ ne 'description' and $_ ne 'amount_paid' and $_ ne 'date_paid') { &xlsxcreator_write_xlsx($ws,$xlsxrow,$xlsxcol,$val,$format_management_report_data) ; } elsif ($_ eq 'event_quote_nr') { &xlsxcreator_write_xlsx($ws,$xlsxrow,$xlsxcol,$id,$format_management_report_data_ref_nr) ; } elsif ($_ eq 'availablity') { if ($availability{$id}{$db{$tables}{$id}{$field}}) { &xlsxcreator_write_xlsx($ws,$xlsxrow,$xlsxcol,$availability{$id}{$db{$tables}{$id}{$field}},$format_management_report_data) ; } else { &xlsxcreator_write_xlsx($ws,$xlsxrow,$xlsxcol,"No Response",$format_management_report_data) ; } } elsif ($_ eq 'qty'){ &xlsxcreator_write_xlsx($ws,$xlsxrow,$xlsxcol,$val,$format_management_report_data_ref_nr) ; } elsif ($_ eq 'date_paid' or $_ eq 'amount_paid' or $_ eq 'date_payable' or $_ eq 'amount_payable' or $_ eq 'paid' or $_ eq 'amount' or $_ eq 'description') { &xlsxcreator_write_xlsx($ws,$xlsxrow,$xlsxcol,$val_min,$format_management_report_data) ; } $xlsxcol++; # if ($_ eq 'ref_nr' or $_ eq 'camera_nr') { $val = &common_camera_links($tables,$id,$val) ;} $print_tbody .= qq~$val~ ; } $print_tbody .= qq~~ ; $xlsxrow++ ; $quote_and_ops_ids .= qq~"$row_cnt\_$id":"$op_id",~ if $op_id ; } chop $op_ids if $op_ids ; # $quote_and_ops_ids .= qq~"$row_cnt_$id":[$op_ids],~ if $op_ids ; } chop $quote_and_ops_ids if $quote_and_ops_ids ; # $print_tbody .= qq~~ ; # $print_tbody .= qq~~ ; $worksheet{$ws} -> set_column(0, 0, 15) ; $worksheet{$ws} -> set_column(1, 1, 20) ; $worksheet{$ws} -> set_column(2, 2, 40) ; $worksheet{$ws} -> set_column(3, 8, 20) ; if ($i{paid_status} eq 'all') { $worksheet{$ws} -> set_column(9, 10, 20) ; $worksheet{$ws} -> set_column(11, 11, 10) ; } else { $worksheet{$ws} -> set_column(9, 9, 10) ; } # $worksheet{$ws} -> set_column(10, 10, 25) ; $worksheet{$ws} -> set_row(0, 30) ; $worksheet{$ws} -> set_row(2, 20) ; $box_icon .= qq~
~ ; &report_xlsx_export_footer('L',15,'operators_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 $savebuttjs = ($count_outstanding > 0) ? '$("#invoice-form").submit();' : 'noty({text:"There are no operators to pay!",layout:"center",type:"error",timeout:3000});return;' ; $trigger_jquery_raw .= qq~\$("#savebutt").click(function() { $savebuttjs }); ~ ; } #------------------------------------------------------------------------------------------ sub set_tick { my ($color,$tooltip) = @_ ; $tick{green} = qq~2~ ; $tick{orange} = qq~1~ ; $tick{red} = qq~0~ ; return ($tick{$color}) ; } #------------------------------------------------------------------------------------------ sub set_cross { my ($color,$tooltip) = @_ ; $tick{green} = qq~2~ ; $tick{orange} = qq~1~ ; $tick{red} = qq~0~ ; return ($tick{$color}) ; } #------------------------------------------------------------------------------------------ sub load_list_vars { my ($where,$where_min) = @_ ; our %quote_status = () ; # &db_min_ro('event_quotes',"id, quote_cancelled, quote_accepted, if(concat(quote_expiry, ' 00:00:00') < now(), 1, 0) as 'expired', quote_pending","$where",'',''); # &db_min_ro('event_quotes',"id, quote_cancelled, quote_accepted, quote_pending, quote_completed","$where",'',''); my $t1 = "$table" ; my $t2 = 'event_quotes_min' ; our $tables = "$t1,$t2" ; &db_min_raw("SELECT e.id,e.quote_cancelled,e.quote_accepted,e.quote_pending,e.quote_completed,e.quote_rejected FROM $t1 e WHERE $where;"); foreach $row (@$rows_array_ref) { for (0 .. $col_cnt){ $db{$table}{@$row[0]}{$col_name{$_}} = @$row[$_] ; } } foreach my $id (keys %{$db{$table}}) { if ($db{$table}{$id}{quote_cancelled} == 1){ $quote_status{$id} = 1 ; } elsif ($db{$table}{$id}{quote_accepted} == 1 || $db{$table}{$id}{quote_completed} == 1){ $quote_status{$id} = 2 ; } elsif ($db{$table}{$id}{quote_rejected} == 1){ $quote_status{$id} = 3 ; } elsif ($db{$table}{$id}{quote_pending} == 1) { $quote_status{$id} = 4 ; } } our %availability = () ; &db_min_raw(" SELECT e.event_quote_nr, e.user_id, e.category FROM events e LEFT JOIN ( select id, name, user_type FROM users WHERE user_type like '%casual%' ) u on u.id = e.user_id ; ") ; foreach $row (@$rows_array_ref) { if (@$row[2] eq 'available') { $availability{@$row[0]}{@$row[1]} = "Available" ; } elsif (@$row[2] ne 'available' and @$row[2]) { $availability{@$row[0]}{@$row[1]} = "Not Available" ; } } our %type_a_users = () ; our %type_b_users = () ; our %casual_names_from_ids = () ; &db_min_ro('users','id,name,user_type',"user_type LIKE 'casual%'",'','') ; foreach my $id (keys %{$db{'users'}}){ $type_a_users{$id} = "A" if $db{'users'}{$id}{user_type} eq "casual_a" ; $type_b_users{$id} = "B" if $db{'users'}{$id}{user_type} eq "casual_b" ; # &common_debug("[$db{'users'}{$id}{user_type}] $db{'users'}{$id}{name}") ; $casual_names_from_ids{$id} = $db{'users'}{$id}{name} ; } my @event_quote_ids = () ; # &db_min_ro($table,'*',"$where",'','') ; # &db_min_ro('event_quotes_min','*',"$where_min",'','') ; $where .= " AND $where_min" if $where_min ; &db_min_raw("SELECT e.*, m.* FROM $t1 e LEFT JOIN $t2 m ON e.id = m.id WHERE $where;"); foreach $row (@$rows_array_ref) { for (0 .. $col_cnt){ # &common_debug("[$_] $col_name{$_} -> @$row[$_]") ; $db{$tables}{@$row[0]}{$col_name{$_}} = @$row[$_] ; } } &db_min_ro('event_cost_items','id,name','','','') ; if ($i{paid_status} eq 'paid') { &db_min_ro('shift_operator_ids','date,temp_calibrator_amounts_paid,temp_calibrator_dates_paid',"`date`<='$i{date_to}' AND `date`>='$i{date_from}'",'','') ; } } #------------------------------------------------------------------------------------------ sub thead { &common_min_thead ; } #------------------------------------------------------------------------------- sub page_opts { our $glyphicon = 'list' ; our $lcpage = 'operator-payment' ; &common_page_name ; our $table = 'event_quotes' ; $page_title = 'Operators Payments' ; } #------------------------------------------------------------------------------- sub report_screen { our $lcol = 3 ; our $fcol = 5 ; $print_box_content_rows .= &common_min_forms_start('report') ; &common_min_select_opts('operator_id','users',"name",$i{operator_id},'','',"user_type LIKE 'casual%'") ; &common_min_select_opts('event_quote_id','event_quotes',"ref",$i{event_quote_id},'','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") ; $opts{paid_status} .= qq~~ ; $opts{paid_status} .= qq~~ ; $opts{paid_status} .= qq~~ ; $print_box_content_rows .= &common_min_form_select('operator_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 ; } #------------------------------------------------------------------------------- sub screen3 { &thead; if ($isaved) { $alert = &common_min_alert('success',"$ucpage $isaved!",'ok') ; } else { &common_min_alert_type ; } # my $page = "$lcpage\s" ; my $page = "event-quotes" ; if ($s{no}) { $page = $lcpage ; } &common_min_table('id',$page,'list') ; our $savjqy = 1 ; # &common_min_extra_crumb("manage-$lcpage\s","Manage $ucfirstpage\s") ; $extra_form_fields .= qq~ ~; $print_box_content_rows .= &common_min_forms_end('','','save') ; require _blank ; exit ; } #------------------------------------------------------------------------------------------ sub screen4 { &common_min_alert_type ; print < $useropts{title}
ENDOFTEXT # exit ; } #------------------------------------------------------------------------------------------ use common ; use report ; use xlsxcreator ; use today ; 1;