732 lines
23 KiB
Perl
732 lines
23 KiB
Perl
|
|
#!/usr/bin/perl
|
||
|
|
|
||
|
|
BEGIN { use lib '/usr/home/cfg' ; require push_inc ; }
|
||
|
|
|
||
|
|
require cfg ;
|
||
|
|
|
||
|
|
use DBI;
|
||
|
|
use CGI::Carp qw(fatalsToBrowser);
|
||
|
|
use Date::Manip;
|
||
|
|
use Date::Calc qw(:all);
|
||
|
|
|
||
|
|
use PDF::API2::Lite;
|
||
|
|
use constant mm => 25.4/72;
|
||
|
|
use constant in => 1/72;
|
||
|
|
use constant pt => 1;
|
||
|
|
|
||
|
|
#------------------------------------------------------------------------------------------
|
||
|
|
|
||
|
|
@ARGV = split(/\\*\&/, $ENV{'QUERY_STRING'});
|
||
|
|
|
||
|
|
our $start_date = $ARGV[0] ;
|
||
|
|
our $end_date = $ARGV[1] ;
|
||
|
|
our $operator_id = $ARGV[2] ;
|
||
|
|
our $event_id = $ARGV[3] ;
|
||
|
|
|
||
|
|
$operator_id = "" unless $operator_id ;
|
||
|
|
|
||
|
|
exit if not $start_date or not $end_date ;
|
||
|
|
|
||
|
|
#------------------------------------------------------------------------------------------
|
||
|
|
|
||
|
|
print "Content-type: text/html\n\n";
|
||
|
|
|
||
|
|
&today ;
|
||
|
|
|
||
|
|
&db_open_ro ;
|
||
|
|
our $db_ignore_open_close = 1 ; # do one open and one close instead of repeating it
|
||
|
|
&prep_pdf ;
|
||
|
|
$db_ignore_open_close = 0 ; # do one open and one close instead of repeating it
|
||
|
|
&db_close_conn ;
|
||
|
|
|
||
|
|
&start_pdf ;
|
||
|
|
&build_pdf ;
|
||
|
|
&finish_pdf ;
|
||
|
|
&screen2 ;
|
||
|
|
|
||
|
|
exit ;
|
||
|
|
|
||
|
|
#------------------------------------------------------------------------------------------
|
||
|
|
|
||
|
|
sub prep_pdf {
|
||
|
|
|
||
|
|
&db_min_ro('event_quotes_min','*',"`operator_workings_event` LIKE '%;$operator_id;%'") ;
|
||
|
|
|
||
|
|
foreach (keys %{$db{event_quotes_min}}) {
|
||
|
|
|
||
|
|
# push @abc,"`quote_nr`='$db{event_quotes_min}{$_}{quote_nr}'" ;
|
||
|
|
push @abc,"`id`='$_'" ;
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
my $event_ids = qq~~ ; $event_ids = join(" OR ",@abc) ; $event_ids = qq~($event_ids)~ ;
|
||
|
|
my $start_sql = qq~~ ; my $end_sql = qq~~ ; my $event_id2 = qq~~ ;
|
||
|
|
|
||
|
|
if ($start_date) {
|
||
|
|
$start_sql .= qq~ AND ~ if $event_ids ;
|
||
|
|
$start_sql .= qq~`quote_date`>='$start_date'~ ;
|
||
|
|
}
|
||
|
|
|
||
|
|
if ($end_date) {
|
||
|
|
$end_sql .= qq~ AND ~ if $start_sql or $event_ids ;
|
||
|
|
$end_sql .= qq~`quote_date`<='$end_date'~ ;
|
||
|
|
}
|
||
|
|
if ($event_id) {
|
||
|
|
$event_id .= qq~ AND ~ if $event_ids or $start_sql or $end_sql ;
|
||
|
|
# $event_id2 .= qq~`quote_nr`='$event_id'~ ;
|
||
|
|
$event_id2 .= qq~`id`='$event_id'~ ;
|
||
|
|
}
|
||
|
|
|
||
|
|
&db_min_ro('event_quotes','id,ref,date_to,date_from',"$event_ids$start_sql$end_sql$event_id",'','') ;
|
||
|
|
|
||
|
|
my $payments_exist = 0 ;
|
||
|
|
|
||
|
|
foreach (keys %{$db{event_quotes}}) {
|
||
|
|
$payments_exist++ ;
|
||
|
|
}
|
||
|
|
|
||
|
|
unless ($payments_exist) {
|
||
|
|
print "No Payments have been made!!!" ;
|
||
|
|
exit ;
|
||
|
|
}
|
||
|
|
|
||
|
|
&db_min_ro('event_cost_items','*','','','') ;
|
||
|
|
|
||
|
|
} #------------------------------------------------------------------------------------------
|
||
|
|
|
||
|
|
sub exclusions {
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
} #------------------------------------------------------------------------------------------
|
||
|
|
|
||
|
|
sub start_pdf {
|
||
|
|
|
||
|
|
my $qtpdfpath = "$pdfpath/operators_invoices" ;
|
||
|
|
our $pdfname = "Operators_Invoice-$start_date-$end_date-$operator_id" . '.pdf' ;
|
||
|
|
|
||
|
|
&pdf_delete_previous_pdf($qtpdfpath) ;
|
||
|
|
&pdf_initialise($qtpdfpath,$pdfname,'ITV Operators Invoice') ;
|
||
|
|
|
||
|
|
} #------------------------------------------------------------------------------------------
|
||
|
|
|
||
|
|
sub build_pdf {
|
||
|
|
|
||
|
|
&tab_curr_symbols;
|
||
|
|
&pdf_initialise_page ;
|
||
|
|
|
||
|
|
$up = 292 ;
|
||
|
|
# "e_pdf_page_header ;
|
||
|
|
|
||
|
|
&pdf_box_block_top(5,205,'#009bc8') ;
|
||
|
|
|
||
|
|
$up = 260 ;
|
||
|
|
$across = 1 ;
|
||
|
|
$blue_box = 1 ;
|
||
|
|
|
||
|
|
&pdf_page_header ;
|
||
|
|
"e_pdf_vars ;
|
||
|
|
"e_out_to_pdf ;
|
||
|
|
# "e_pdf_footer ;
|
||
|
|
|
||
|
|
$up = 5 ;
|
||
|
|
&pdf_box_block_bottom(5,205,'#009bc8') ;
|
||
|
|
|
||
|
|
} #------------------------------------------------------------------------------------------
|
||
|
|
|
||
|
|
# sub quote_pdf_page_header {
|
||
|
|
|
||
|
|
# $page_num++ ;
|
||
|
|
|
||
|
|
# my $image1 = $page->gfx(1) ;
|
||
|
|
# my $image1_thumb = "$htmlpath/img/pdf_logo.png";
|
||
|
|
# $pdf_image1_file = $pdf->image_png($image1_thumb);
|
||
|
|
# $image1->image($pdf_image1_file, 7/mm, $up/mm, 90/mm, 29/mm);
|
||
|
|
|
||
|
|
# $up+=18 ;
|
||
|
|
|
||
|
|
# &pdf_nl_gap_3 ;
|
||
|
|
# &pdf_xx_large_bold_text (156,$up,"QUOTE") ;
|
||
|
|
# &pdf_nl_gap_1 ;
|
||
|
|
|
||
|
|
# } #-------------------------------------------------------------------------------
|
||
|
|
|
||
|
|
|
||
|
|
# sub pdf_small_white_text_bold {
|
||
|
|
|
||
|
|
# my ($along, $up, $text) = @_ ; $small_bold_text_white->translate( $along/mm, $up/mm ); $small_bold_text_white->text( $text );
|
||
|
|
# }
|
||
|
|
|
||
|
|
# sub pdf_medium_white_text_bold {
|
||
|
|
|
||
|
|
# my ($along, $up, $text) = @_ ; $medium_bold_text_white->translate( $along/mm, $up/mm ); $medium_bold_text_white->text( $text );
|
||
|
|
# }
|
||
|
|
|
||
|
|
# sub pdf_large_white_text_bold {
|
||
|
|
|
||
|
|
# my ($along, $up, $text) = @_ ; $large_bold_text_white->translate( $along/mm, $up/mm ); $large_bold_text_white->text( $text );
|
||
|
|
# }
|
||
|
|
|
||
|
|
# sub pdf_grey_text_above_right {
|
||
|
|
|
||
|
|
# my ($along, $up, $text) = @_ ; $grey_text_above_right->translate( $along/mm, $up/mm ); $grey_text_above_right->text( $text );
|
||
|
|
# }
|
||
|
|
|
||
|
|
# sub pdf_small_white_text_bold_right {
|
||
|
|
|
||
|
|
# my ($along, $up, $text) = @_ ; $grey_text_above_right->translate( $along/mm, $up/mm ); $grey_text_above_right->text_right( $text );
|
||
|
|
# }
|
||
|
|
|
||
|
|
# sub pdf_medium_white_text_bold_right {
|
||
|
|
|
||
|
|
# my ($along, $up, $text) = @_ ; $medium_bold_text_white->translate( $along/mm, $up/mm ); $medium_bold_text_white->text_right( $text );
|
||
|
|
# }
|
||
|
|
|
||
|
|
# sub pdf_large_white_text_bold_right {
|
||
|
|
|
||
|
|
# my ($along, $up, $text) = @_ ; $large_bold_text_white->translate( $along/mm, $up/mm ); $large_bold_text_white->text_right( $text );
|
||
|
|
# }
|
||
|
|
|
||
|
|
sub quote_out_to_pdf {
|
||
|
|
|
||
|
|
our @cell_width = (15,70,110,132.5,155,177.5,200) ;
|
||
|
|
|
||
|
|
&db_min_ro('users','*',"`id`='$operator_id'",'','') ;
|
||
|
|
|
||
|
|
&pdf_nl_t;
|
||
|
|
# unless ($db{$table}{$qt_id}{currency} eq 'ZAR') { &pdf_medium_red_bold_text (70, $up, "$db{$table}{$qt_id}{currency} ROE : $db{$table}{$qt_id}{roe}") ; } # hidden for client
|
||
|
|
# &pdf_medium_bold_text (157, $up, "Nr. :") ;
|
||
|
|
|
||
|
|
&pdf_small_bold_text(172.5, $up, "Date :") ;
|
||
|
|
my $dttxt = &custom_date_txt("$now_year-$now_mm-$now_dd");
|
||
|
|
&pdf_small_bold_text_right (198, $up, $dttxt) ;
|
||
|
|
|
||
|
|
# &pdf_nl;
|
||
|
|
|
||
|
|
# &pdf_small_bold_text(150, $up, "Quote Nr") ;
|
||
|
|
# &pdf_small_text_right (198, $up, $qt_id) ;
|
||
|
|
# &pdf_small_bold_text_right (198, $up, $db{$table}{$qt_id}{quote_nr}) ;
|
||
|
|
|
||
|
|
# &pdf_large_bold_text (10, $up, $db{$table}{$qt_id}{ref}) if $db{$table}{$qt_id}{ref} ;
|
||
|
|
|
||
|
|
# &pdf_nl_gap_1;
|
||
|
|
|
||
|
|
&pdf_nl;
|
||
|
|
|
||
|
|
&pdf_nl_t;
|
||
|
|
&pdf_bar(10,$up,200,$up,'#009bc8','OPERATOR DETAILS',20,80) ;
|
||
|
|
$up = $up - 5 ;
|
||
|
|
|
||
|
|
&pdf_box_block_top(10,200,'#009bc8') ; #
|
||
|
|
$up = $up - 5 ;
|
||
|
|
$top = $up ;
|
||
|
|
&pdf_thin_box_block_top(15,100,'#009bc8') ;
|
||
|
|
$top3 = $up ;
|
||
|
|
$up = $up - 5 ;
|
||
|
|
&pdf_small_bold_text (16, $up, "Name") ;
|
||
|
|
my $pos2 = 38 ;
|
||
|
|
&pdf_small_text ($pos2, $up, "$db{users}{$operator_id}{name}") ;
|
||
|
|
$up = $up - 3 ;
|
||
|
|
&pdf_thin_box_block_bottom(15,100,'#009bc8') ;
|
||
|
|
&pdf_extra_thin_black_line ($pos2-1,$top,$pos2-1,$up,'#009bc8') ;
|
||
|
|
$up = $up - 5 ;
|
||
|
|
|
||
|
|
&pdf_thin_box_block_top(15,100,'#009bc8') ;
|
||
|
|
$top = $up ;
|
||
|
|
$up = $up - 3.25 ;
|
||
|
|
&pdf_small_bold_text (16, $up, "Username") ; &pdf_small_text ($pos2,$up,"$db{users}{$operator_id}{username}") ;
|
||
|
|
$up = $up - 1.25 ;
|
||
|
|
&pdf_extra_thin_black_line (15,$up,100,$up,'#009bc8') ;
|
||
|
|
$up = $up - 3.25 ;
|
||
|
|
my $tpe = $db{users}{$operator_id}{user_type} ; my $tpe2 = qq~~ ;
|
||
|
|
foreach (split("_",$tpe)) {
|
||
|
|
$tpe2 .= ucfirst $_ ;
|
||
|
|
$tpe2 .= " " ;
|
||
|
|
}
|
||
|
|
&pdf_small_bold_text (16, $up, "User Type") ; &pdf_small_text ($pos2, $up, "$tpe2") ;
|
||
|
|
$up = $up - 1.25 ;
|
||
|
|
&pdf_extra_thin_black_line (15,$up,100,$up,'#009bc8') ;
|
||
|
|
$up = $up - 3.25 ;
|
||
|
|
|
||
|
|
# my $cty = $db{users}{$operator_id}{based_in} ;
|
||
|
|
# $cty = "Cape Town" if $db{users}{$operator_id}{based_in} eq 'CPT' ;
|
||
|
|
# $cty = "Johannesburg" if $db{users}{$operator_id}{based_in} eq 'JNB' ;
|
||
|
|
|
||
|
|
# $selected{based_in}{$db{users}{$operator_id}{based_in}} = 'SELECTED' ;
|
||
|
|
|
||
|
|
&db_min_ro('regions','code,name','','','') ;
|
||
|
|
|
||
|
|
# &pdf_small_bold_text (16, $up, "Based In") ; &pdf_small_text ($pos2, $up, "$cty") ;
|
||
|
|
&pdf_small_bold_text (16, $up, "Based In") ; &pdf_small_text ($pos2, $up, "$db{regions}{$db{users}{$operator_id}{based_in}}{name}") ;
|
||
|
|
$up = $up - 1.25 ;
|
||
|
|
&pdf_extra_thin_black_line (15,$up,100,$up,'#009bc8') ;
|
||
|
|
$up = $up - 3.25 ;
|
||
|
|
my $act = "Yes" ;
|
||
|
|
$act = "No" if $db{users}{$operator_id}{inactive} ;
|
||
|
|
&pdf_small_bold_text (16, $up, "Active") ; &pdf_small_text ($pos2,$up,"$act") ;
|
||
|
|
$up = $up - 1.25 ;
|
||
|
|
|
||
|
|
&pdf_extra_thin_black_line ($pos2-1,$top,$pos2-1,$up,'#009bc8') ;
|
||
|
|
&pdf_thin_box_block_bottom(15,100,'#009bc8') ;
|
||
|
|
$top4 = $up ;
|
||
|
|
|
||
|
|
|
||
|
|
$up = $up - 5 ;
|
||
|
|
$up = $top3 ;
|
||
|
|
$pos2 = 133 ;
|
||
|
|
|
||
|
|
|
||
|
|
&pdf_thin_box_block_top(110,195,'#009bc8') ;
|
||
|
|
$top = $up ;
|
||
|
|
$up = $up - 3.25 ;
|
||
|
|
&pdf_small_bold_text (111, $up, "Phone Nr") ; &pdf_small_text ($pos2, $up, "$db{users}{$operator_id}{phone}") ;
|
||
|
|
$up = $up - 1.25 ;
|
||
|
|
&pdf_extra_thin_black_line (110,$up,195,$up,'#009bc8') ;
|
||
|
|
$up = $up - 3.25 ;
|
||
|
|
&pdf_small_bold_text (111, $up, "Email") ; &pdf_small_text ($pos2, $up, "$db{users}{$operator_id}{email}") ;
|
||
|
|
$up = $up - 1.25 ;
|
||
|
|
&pdf_extra_thin_black_line ($pos2-1,$top,$pos2-1,$up,'#009bc8') ;
|
||
|
|
&pdf_thin_box_block_bottom(110,195,'#009bc8') ;
|
||
|
|
$up = $up - 5 ;
|
||
|
|
# &pdf_thin_box_block_bottom(10,200,'#009bc8') ;
|
||
|
|
# $up = $up - 5 ;
|
||
|
|
&pdf_thin_box_block_top(110,195,'#009bc8') ;
|
||
|
|
$top = $up ;
|
||
|
|
$up = $up - 3.25 ;
|
||
|
|
&pdf_small_bold_text (111, $up, "Bank Details") ; &pdf_small_text ($pos2, $up, "$db{users}{$operator_id}{bank}") ;
|
||
|
|
$up = $up - 1.25 ;
|
||
|
|
$up = $up - 3.25 ;
|
||
|
|
&pdf_small_text ($pos2, $up, "$db{users}{$operator_id}{bank_acc_no}") ;
|
||
|
|
$up = $up - 1.25 ;
|
||
|
|
&pdf_extra_thin_black_line ($pos2-1,$top,$pos2-1,$up,'#009bc8') ;
|
||
|
|
&pdf_thin_box_block_bottom(110,195,'#009bc8') ;
|
||
|
|
|
||
|
|
$up = $top4 if $top4 < $up ;
|
||
|
|
$up -= 5 ;
|
||
|
|
&pdf_box_block_bottom(10,200,'#009bc8') ;
|
||
|
|
|
||
|
|
$up -= 5 ;
|
||
|
|
|
||
|
|
my @abc = () ;
|
||
|
|
|
||
|
|
&pdf_bar(10,$up,200,$up,'#009bc8','PAYMENTS',20,90) ;
|
||
|
|
$up = $up - 5 ;
|
||
|
|
|
||
|
|
&pdf_box_block_top(10,200,'#009bc8') ; #
|
||
|
|
|
||
|
|
$top = $up ;
|
||
|
|
|
||
|
|
$up = $up - 5 ;
|
||
|
|
|
||
|
|
&pdf_small_bold_text ($cell_width[0],$up,"Event") ;
|
||
|
|
&pdf_small_bold_text (0.5*($cell_width[2]+$cell_width[1])-8,$up,"Description") ;
|
||
|
|
&pdf_small_bold_text (0.5*($cell_width[3]+$cell_width[2])-6,$up,"Amount") ;
|
||
|
|
&pdf_small_bold_text (0.5*($cell_width[4]+$cell_width[3])-7,$up,"Dates Paid") ;
|
||
|
|
&pdf_small_bold_text (0.5*($cell_width[5]+$cell_width[4])-9,$up,"Amount Paid") ;
|
||
|
|
&pdf_small_bold_text (0.5*(200+$cell_width[5])-9,$up,"Outstanding") ;
|
||
|
|
|
||
|
|
# &pdf_small_bold_text ($cell_width[1]+1,$up,"Description") ;
|
||
|
|
# &pdf_small_bold_text ($cell_width[2]+1,$up,"Amount") ;
|
||
|
|
# &pdf_small_bold_text ($cell_width[3]+1,$up,"Date Paid") ;
|
||
|
|
# &pdf_small_bold_text ($cell_width[4]+1,$up,"Amount Paid") ;
|
||
|
|
# &pdf_small_bold_text ($cell_width[5]+1,$up,"Outstanding") ;
|
||
|
|
|
||
|
|
$up = $up - 3 ;
|
||
|
|
|
||
|
|
&pdf_thin_black_line (10,$up,200,$up,'#009bc8') ;
|
||
|
|
|
||
|
|
my $tot_all_amnts = 0 ; my $tot_all_amnts_paid = 0 ; my $tot_all_oust = 0 ;
|
||
|
|
|
||
|
|
# $up = 48 ;
|
||
|
|
|
||
|
|
foreach my $id (sort keys %{$db{event_quotes}}) {
|
||
|
|
|
||
|
|
next unless $db{event_quotes_min}{$id}{operator_dates_paid} ;
|
||
|
|
|
||
|
|
$up = $up - 5 ;
|
||
|
|
|
||
|
|
&next_page(15) if length($db{event_quotes}{$id}{ref}) <= 37 ;
|
||
|
|
&next_page(19.5) if length($db{event_quotes}{$id}{ref}) > 37 ;
|
||
|
|
|
||
|
|
# &pdf_small_bold_text ($cell_width[0],$up,"$db{event_quotes}{$db{event_quotes_min}{$id}{quote_nr}}{ref}") ;
|
||
|
|
|
||
|
|
&pdf_small_bold_text ($cell_width[0],$up,"$db{event_quotes}{$id}{ref}") if length($db{event_quotes}{$id}{ref}) <= 37 ;
|
||
|
|
if (length($db{event_quotes}{$id}{ref}) > 37) {
|
||
|
|
|
||
|
|
my @a = split(" ",$db{event_quotes}{$id}{ref}) ;
|
||
|
|
my $line2 = qq~~ ; my $line1 = qq~~ ;
|
||
|
|
foreach (@a) {
|
||
|
|
$line1 = $line2 ; $line2 .= qq~$_ ~ ;
|
||
|
|
if (length($line2) > 38 and length($line1) <= 38) {
|
||
|
|
chop $line1 ;
|
||
|
|
&pdf_small_bold_text ($cell_width[0],$up,"$line1") ;
|
||
|
|
$line1 = qq~~ ; $line2 = qq~$_ ~ ;
|
||
|
|
$up -= 4.5 ;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
&pdf_small_bold_text ($cell_width[0],$up,"$line2") ;
|
||
|
|
$up += 4.5 ;
|
||
|
|
|
||
|
|
}
|
||
|
|
&pdf_small_bold_text ($cell_width[1]+2.5,$up,"Total") ;
|
||
|
|
|
||
|
|
my @a = split(";",$db{event_quotes_min}{$id}{operator_amounts_paid}) ;
|
||
|
|
my @b = split(";",$db{event_quotes_min}{$id}{amount_workings_event}) ;
|
||
|
|
my @c = split(";",$db{event_quotes_min}{$id}{operator_workings_event}) ;
|
||
|
|
my @d = split(";",$db{event_quotes_min}{$id}{description_workings_event}) ;
|
||
|
|
my @e = split(";",$db{event_quotes_min}{$id}{operator_dates_paid}) ;
|
||
|
|
|
||
|
|
my $cnt = 0 ; my $tot_amnt = 0 ; my %des_tot = () ; my $paid = 0 ; my %amnt_date = () ; my $out_stand = 0 ;
|
||
|
|
|
||
|
|
foreach (@b) {
|
||
|
|
if ($operator_id eq $c[$cnt]) {
|
||
|
|
$tot_amnt += $_ ;
|
||
|
|
$des_tot{$d[$cnt]} += $_ ;
|
||
|
|
}
|
||
|
|
$cnt++ ;
|
||
|
|
}
|
||
|
|
local $tot_amnt_old = $tot_amnt ;
|
||
|
|
$tot_all_amnts += $tot_amnt ;
|
||
|
|
$tot_amnt = &common_commify(sprintf("%.2f",$tot_amnt)) ;
|
||
|
|
&pdf_small_bold_text_right ($cell_width[3]-2.5,$up,$tot_amnt) ;
|
||
|
|
|
||
|
|
# $top2 = $up ;
|
||
|
|
$cnt = 0 ;
|
||
|
|
foreach (@a) {
|
||
|
|
my @f = split(":",$_) ;
|
||
|
|
$paid += $f[1] if $f[0] eq $operator_id ;
|
||
|
|
$amnt_date{$e[$cnt]}{$cnt}{$f[1]} = 1 if $f[0] eq $operator_id ;
|
||
|
|
$cnt++ ;
|
||
|
|
}
|
||
|
|
$out_stand = $tot_amnt_old - $paid ;
|
||
|
|
|
||
|
|
$paid = &common_commify(sprintf("%.2f",$paid)) ;
|
||
|
|
&pdf_small_bold_text_right ($cell_width[5]-2.5,$up,$paid) ;
|
||
|
|
$out_stand = &common_commify(sprintf("%.2f",$out_stand)) ;
|
||
|
|
&pdf_small_bold_text_right ($cell_width[6]-2.5,$up,$out_stand) ;
|
||
|
|
|
||
|
|
$up = $up - 1.5 ; my $cnr_des = 0 ; my $new_date1 = qq~~ ; my $new_date2 = qq~~ ;
|
||
|
|
|
||
|
|
$up -= 5 if length($db{event_quotes}{$id}{ref}) > 37 ;
|
||
|
|
|
||
|
|
foreach (sort {$db{event_cost_items}{$a}{name} cmp $db{event_cost_items}{$b}{name}} keys %des_tot) {
|
||
|
|
|
||
|
|
$up = $up - 3.25 ;
|
||
|
|
&next_page(15) if $up < 15 ;
|
||
|
|
unless ($cnr_des) {
|
||
|
|
$new_date1 = &custom_date_txt(substr($db{event_quotes}{$id}{date_from},0,10)) ;
|
||
|
|
$new_date2 = &custom_date_txt(substr($db{event_quotes}{$id}{date_to},0,10)) ;
|
||
|
|
|
||
|
|
my $dates = qq~~ ;
|
||
|
|
|
||
|
|
if ($new_date1 eq $new_date2) {
|
||
|
|
$dates = qq~$new_date2~ ;
|
||
|
|
} elsif (substr($db{event_quotes}{$id}{date_from},0,4) eq substr($db{event_quotes}{$id}{date_to},0,4) and substr($db{event_quotes}{$id}{date_from},5,2) eq substr($db{event_quotes}{$id}{date_to},5,2)) {
|
||
|
|
$new_date1 = substr($new_date1,0,2) ;
|
||
|
|
$dates = qq~$new_date1 to $new_date2~ ;
|
||
|
|
} elsif (substr($db{event_quotes}{$id}{date_from},0,4) eq substr($db{event_quotes}{$id}{date_to},0,4)) {
|
||
|
|
$new_date1 = substr($new_date1,0,6) ;
|
||
|
|
$dates = qq~$new_date1 to $new_date2~ ;
|
||
|
|
} else {
|
||
|
|
$dates = qq~$new_date1 to $new_date2~ ;
|
||
|
|
}
|
||
|
|
|
||
|
|
&pdf_small_text ($cell_width[0],$up,"($dates)") ;
|
||
|
|
}
|
||
|
|
$cnr_des++ ;
|
||
|
|
&pdf_small_text ($cell_width[1]+5,$up,$db{event_cost_items}{$_}{name}) if length($db{event_cost_items}{$_}{name}) <= 20 ;
|
||
|
|
|
||
|
|
if (length($db{event_cost_items}{$_}{name}) > 24) {
|
||
|
|
|
||
|
|
my @b = split(" ",$db{event_cost_items}{$_}{name}) ;
|
||
|
|
my $lines1 = qq~~ ; my $lines2 = qq~~ ;
|
||
|
|
foreach (@b) {
|
||
|
|
$lines1 = $lines2 ; $lines2 .= qq~$_ ~ ;
|
||
|
|
if (length($lines2) > 26 and length($lines1) <= 26) {
|
||
|
|
chop $lines1 ;
|
||
|
|
&pdf_small_text ($cell_width[1]+5,$up,"$lines1") ;
|
||
|
|
$up -= 4.5 ;
|
||
|
|
$lines1 = qq~~ ; $lines2 = qq~$_ ~ ;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
&pdf_small_text ($cell_width[1]+5,$up,"$lines2") ;
|
||
|
|
$up += 4.5 ;
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
$des_tot{$_} = &common_commify(sprintf("%.2f",$des_tot{$_})) ;
|
||
|
|
&pdf_small_text_right ($cell_width[3]-2.5,$up,$des_tot{$_}) ;
|
||
|
|
$up = $up - 1.25 ;
|
||
|
|
$up -= 5 if length($db{event_cost_items}{$_}{name}) > 20 ;
|
||
|
|
}
|
||
|
|
$out_stand = $tot_amnt_old ;
|
||
|
|
|
||
|
|
foreach my $date (sort keys %amnt_date) {
|
||
|
|
foreach my $ct (keys %{$amnt_date{$date}}) {
|
||
|
|
foreach my $amnt (keys %{$amnt_date{$date}{$ct}}) {
|
||
|
|
$up = $up - 3.25 ;
|
||
|
|
&next_page(15) if $up < 15 ;
|
||
|
|
my $date_name = &custom_date_txt($date) ;
|
||
|
|
&pdf_small_text (0.5*($cell_width[3]+$cell_width[4])-7,$up,$date_name) ;
|
||
|
|
$tot_all_amnts_paid += $amnt ;
|
||
|
|
$out_stand -= $amnt ;
|
||
|
|
$amnt = &common_commify(sprintf("%.2f",$amnt)) ;
|
||
|
|
&pdf_small_text_right ($cell_width[5]-2.5,$up,$amnt) ;
|
||
|
|
# $paid += $amnt ;
|
||
|
|
$out_stand = &common_commify(sprintf("%.2f",$out_stand)) ;
|
||
|
|
&pdf_small_text_right ($cell_width[6]-2.5,$up,$out_stand) ;
|
||
|
|
$up = $up - 1.25 ;
|
||
|
|
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
# $up = $up - 3 ;
|
||
|
|
}
|
||
|
|
$up -= 1.75 ;
|
||
|
|
# $top = $up ;
|
||
|
|
&pdf_thin_black_line (10,$up,200,$up,'#009bc8') ;
|
||
|
|
|
||
|
|
&pdf_extra_thin_black_line ($cell_width[1],$top,$cell_width[1],$up,'#009bc8') ;
|
||
|
|
&pdf_extra_thin_black_line ($cell_width[2],$top,$cell_width[2],$up,'#009bc8') ;
|
||
|
|
&pdf_extra_thin_black_line ($cell_width[3],$top,$cell_width[3],$up,'#009bc8') ;
|
||
|
|
&pdf_extra_thin_black_line ($cell_width[4],$top,$cell_width[4],$up,'#009bc8') ;
|
||
|
|
&pdf_extra_thin_black_line ($cell_width[5],$top,$cell_width[5],$up,'#009bc8') ;
|
||
|
|
|
||
|
|
&next_page(18) if $up < 18 ;
|
||
|
|
|
||
|
|
$top = $up ;
|
||
|
|
$up -= 5 ;
|
||
|
|
$tot_all_oust = $tot_all_amnts - $tot_all_amnts_paid ;
|
||
|
|
$tot_all_amnts = &common_commify(sprintf("%.2f",$tot_all_amnts)) ;
|
||
|
|
$tot_all_amnts_paid = &common_commify(sprintf("%.2f",$tot_all_amnts_paid)) ;
|
||
|
|
$tot_all_oust = &common_commify(sprintf("%.2f",$tot_all_oust)) ;
|
||
|
|
|
||
|
|
&pdf_small_bold_text_right ($cell_width[2]-2.5,$up,"Total") ;
|
||
|
|
&pdf_small_bold_text_right ($cell_width[3]-2.5,$up,"$tot_all_amnts ") ;
|
||
|
|
&pdf_small_bold_text_right ($cell_width[5]-2.5,$up,"$tot_all_amnts_paid") ;
|
||
|
|
&pdf_small_bold_text_right ($cell_width[6]-2.5,$up,"$tot_all_oust") ;
|
||
|
|
|
||
|
|
$up -= 3 ;
|
||
|
|
|
||
|
|
&pdf_thin_black_line (10,$up,200,$up,'#009bc8') ;
|
||
|
|
|
||
|
|
# &pdf_extra_thin_black_line ($cell_width[1],$top,$cell_width[1],$up,'#009bc8') ;
|
||
|
|
&pdf_extra_thin_black_line ($cell_width[2],$top,$cell_width[2],$up,'#009bc8') ;
|
||
|
|
&pdf_extra_thin_black_line ($cell_width[3],$top,$cell_width[3],$up,'#009bc8') ;
|
||
|
|
&pdf_extra_thin_black_line ($cell_width[4],$top,$cell_width[4],$up,'#009bc8') ;
|
||
|
|
&pdf_extra_thin_black_line ($cell_width[5],$top,$cell_width[5],$up,'#009bc8') ;
|
||
|
|
|
||
|
|
&pdf_box_block_bottom(10,200,'#009bc8') ; #
|
||
|
|
|
||
|
|
} #------------------------------------------------------------------------------------------
|
||
|
|
|
||
|
|
sub vertical_lines_inner_box {
|
||
|
|
|
||
|
|
&pdf_thin_black_line ($blocks[2],$top,$blocks[2],$up,'#009bc8') ; # vertical
|
||
|
|
&pdf_thin_black_line ($blocks[3],$top,$blocks[3],$up,'#009bc8') ; # vertical
|
||
|
|
&pdf_thin_black_line ($blocks[4],$top,$blocks[4],$up,'#009bc8') ; # vertical
|
||
|
|
&pdf_thin_black_line ($blocks[5],$top,$blocks[5],$up,'#009bc8') ; # vertical
|
||
|
|
} #----------------------------------------------------------------------------------------------------
|
||
|
|
|
||
|
|
sub vertical_lines_inner_box_t {
|
||
|
|
|
||
|
|
&pdf_thin_black_line ($tblocks[2],$top,$tblocks[2],$up,'#009bc8') ; # vertical
|
||
|
|
&pdf_thin_black_line ($tblocks[3],$top,$tblocks[3],$up,'#009bc8') ; # vertical
|
||
|
|
&pdf_thin_black_line ($tblocks[4],$top,$tblocks[4],$up,'#009bc8') ; # vertical
|
||
|
|
&pdf_thin_black_line ($tblocks[5],$top,$tblocks[5],$up,'#009bc8') ; # vertical
|
||
|
|
} #----------------------------------------------------------------------------------------------------
|
||
|
|
|
||
|
|
sub quote_pdf_footer {
|
||
|
|
|
||
|
|
|
||
|
|
} #------------------------------------------------------------------------------------------
|
||
|
|
|
||
|
|
sub quote_pdf_vars {
|
||
|
|
|
||
|
|
# our @htxt = (0,0,115,0,146,172,0) ;
|
||
|
|
# our @boxtxt = (0,12,102,117,142,167) ;
|
||
|
|
# our @blocks = (0,10,100,115,140,165) ;
|
||
|
|
|
||
|
|
# our @rboxtxt = (0,97,122,147,172,197) ;
|
||
|
|
# our @boxtxt = (0,12,102,127,152,177) ;
|
||
|
|
# our @blocks = (0,10,100,125,150,175) ;
|
||
|
|
|
||
|
|
our @rboxtxt = (0,103,116,143,170,197) ;
|
||
|
|
our @boxtxt = (0,12,106,120,147,174) ;
|
||
|
|
our @blocks = (0,10,104,118,145,172) ;
|
||
|
|
|
||
|
|
our @tboxrtxt = (0,77,107,137,167,197) ;
|
||
|
|
our @tboxtxt = (0,12,82,112,142,172) ;
|
||
|
|
our @tblocks = (0,10,80,110,140,170) ;
|
||
|
|
} #-------------------------------------------------------------------------------
|
||
|
|
|
||
|
|
sub custom_date_txt {
|
||
|
|
|
||
|
|
my ($date) = @_ ;
|
||
|
|
|
||
|
|
return "Unknown" if not $date;
|
||
|
|
|
||
|
|
my $dt_txt = Date_to_Text(substr($date,0,4),substr($date,5,2),substr($date,8,2));
|
||
|
|
|
||
|
|
$dt_txt = substr($dt_txt,4) ;
|
||
|
|
|
||
|
|
if (substr($dt_txt,1,1) eq '-') {
|
||
|
|
local $day = int(substr($dt_txt,0,1)) ;
|
||
|
|
$dt_txt = substr($dt_txt,1) ;
|
||
|
|
$day = sprintf("%02d",$day) ;
|
||
|
|
$dt_txt = qq~$day$dt_txt~ ;
|
||
|
|
}
|
||
|
|
|
||
|
|
return ($dt_txt) ;
|
||
|
|
|
||
|
|
} #------------------------------------------------------------------------------------------
|
||
|
|
|
||
|
|
sub check_space_on_page_custom {
|
||
|
|
|
||
|
|
my ($value) = @_ ;
|
||
|
|
|
||
|
|
if ($up < $value) {
|
||
|
|
&pdf_thin_black_line (10,$top,10,$up) ;
|
||
|
|
&vertical_lines_table; # draw vertical_lines on prematurely ended table
|
||
|
|
&pdf_initialise_page ;
|
||
|
|
$up=282 ;
|
||
|
|
$top=$up;
|
||
|
|
&pdf_thin_black_line(10,$up,200,$up) ;
|
||
|
|
$across = 1 ;
|
||
|
|
}
|
||
|
|
} #----------------------------------------------------------------------------------------------------
|
||
|
|
|
||
|
|
sub get_val {
|
||
|
|
|
||
|
|
my ($val,$cur) = @_ ;
|
||
|
|
|
||
|
|
my $disp_val = $val ;
|
||
|
|
|
||
|
|
if ($val eq '0.00') {
|
||
|
|
$disp_val = '' ;
|
||
|
|
|
||
|
|
} elsif ($val) {
|
||
|
|
$disp_val = $cur . ' ' . $val ;
|
||
|
|
}
|
||
|
|
# &common_min_debug($val);
|
||
|
|
|
||
|
|
return($disp_val);
|
||
|
|
} #------------------------------------------------------------------------------------------
|
||
|
|
|
||
|
|
sub vertical_lines_table {
|
||
|
|
|
||
|
|
unless ($exclude_rate) {
|
||
|
|
&pdf_thin_black_line ($blocks[2],$top,$blocks[2],$up) ; # vertical
|
||
|
|
&pdf_thin_black_line ($blocks[3],$top,$blocks[3],$up) ; # vertical
|
||
|
|
}
|
||
|
|
|
||
|
|
unless ($exclude_vat) {
|
||
|
|
&pdf_thin_black_line ($blocks[4],$top,$blocks[4],$up) ; # vertical
|
||
|
|
}
|
||
|
|
|
||
|
|
&pdf_thin_black_line ($blocks[5],$top,$blocks[5],$up) ; # vertical
|
||
|
|
&pdf_thin_black_line ($blocks[6],$top,$blocks[6],$up) ; # vertical
|
||
|
|
|
||
|
|
} #------------------------------------------------------------------------------------------
|
||
|
|
|
||
|
|
sub next_page {
|
||
|
|
|
||
|
|
my ($up2) = @_ ;
|
||
|
|
|
||
|
|
if ($up < $up2) {
|
||
|
|
$up = 10 ;
|
||
|
|
&pdf_extra_thin_black_line ($cell_width[1],$top,$cell_width[1],$up,'#009bc8') ;
|
||
|
|
&pdf_extra_thin_black_line ($cell_width[2],$top,$cell_width[2],$up,'#009bc8') ;
|
||
|
|
&pdf_extra_thin_black_line ($cell_width[3],$top,$cell_width[3],$up,'#009bc8') ;
|
||
|
|
&pdf_extra_thin_black_line ($cell_width[4],$top,$cell_width[4],$up,'#009bc8') ;
|
||
|
|
&pdf_extra_thin_black_line ($cell_width[5],$top,$cell_width[5],$up,'#009bc8') ;
|
||
|
|
|
||
|
|
&pdf_box_block_bottom(10,200,'#009bc8') ;
|
||
|
|
$up-=5 ;
|
||
|
|
&pdf_box_block_bottom(5,205,'#009bc8') ;
|
||
|
|
&pdf_initialise_page ;
|
||
|
|
$up = 292 ;
|
||
|
|
|
||
|
|
&pdf_box_block_top(5,205,'#009bc8') ;
|
||
|
|
$up -= 5 ;
|
||
|
|
&pdf_box_block_top(10,200,'#009bc8') ;
|
||
|
|
$top = $up ;
|
||
|
|
$up -= 5 ;
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
} #------------------------------------------------------------------------------------------
|
||
|
|
|
||
|
|
# sub pdf_extra_thin_black_line {
|
||
|
|
|
||
|
|
# my ($x1,$y1,$x2,$y2,$color) = @_ ;
|
||
|
|
|
||
|
|
# $color = 'black' if not $color ; # $color = '#009bc8' ;
|
||
|
|
|
||
|
|
# unless ($x1) { $x1 = 10 ; }
|
||
|
|
# unless ($y1) { $y1 = $up ; }
|
||
|
|
# unless ($x2) { $x2 = 200 ; }
|
||
|
|
# unless ($y2) { $y2 = $up ; }
|
||
|
|
|
||
|
|
# my $pdf_black_line = $page->gfx(1);
|
||
|
|
# $pdf_black_line->strokecolor($color);
|
||
|
|
# $pdf_black_line->linewidth( '0.5' );
|
||
|
|
# $pdf_black_line->linedash();
|
||
|
|
# $pdf_black_line->move($x1/mm,$y1/mm);
|
||
|
|
# $pdf_black_line->line($x2/mm,$y2/mm);
|
||
|
|
# $pdf_black_line->stroke;
|
||
|
|
|
||
|
|
# } #-------------------------------------------------------------------------------
|
||
|
|
|
||
|
|
# sub pdf_thin_box_block_top {
|
||
|
|
|
||
|
|
# my ($st,$en,$color) = @_ ; unless ($color) { $color = 'black' ; } # $color = '#009bc8' ;
|
||
|
|
|
||
|
|
# $box_start{$st} = $up ;
|
||
|
|
|
||
|
|
# &pdf_extra_thin_black_line($st,$up,$en,$up,$color) ; # horizontal
|
||
|
|
|
||
|
|
# } #-------------------------------------------------------------------------------
|
||
|
|
|
||
|
|
# sub pdf_thin_box_block_bottom {
|
||
|
|
|
||
|
|
# my ($st,$en,$color) = @_ ; unless ($color) { $color = 'black' ; } # $color = '#009bc8' ;
|
||
|
|
|
||
|
|
# &pdf_extra_thin_black_line($st,$up,$en,$up,$color) ; # horizontal
|
||
|
|
|
||
|
|
# &pdf_extra_thin_black_line ($st,$box_start{$st},$st,$up,$color) ; # vertical
|
||
|
|
# &pdf_extra_thin_black_line ($en,$box_start{$st},$en,$up,$color) ; # vertical
|
||
|
|
|
||
|
|
# } #-------------------------------------------------------------------------------
|
||
|
|
|
||
|
|
sub screen2 {
|
||
|
|
|
||
|
|
print <<ENDOFTEXT;
|
||
|
|
$dialog{'common'}{'head'}
|
||
|
|
<div id="content" class="col-lg-12 col-sm-12">
|
||
|
|
<CENTER>
|
||
|
|
<table height='100%' width='100%'>
|
||
|
|
<tr>
|
||
|
|
<td align='center'>
|
||
|
|
<iframe src='$useropts{'$domain'}/pdf/operators_invoices/$pdfname' width='100%' height='100%' frameborder='0'></iframe>
|
||
|
|
</td>
|
||
|
|
</tr>
|
||
|
|
</table>
|
||
|
|
</div>
|
||
|
|
</body>
|
||
|
|
</html>
|
||
|
|
ENDOFTEXT
|
||
|
|
#
|
||
|
|
|
||
|
|
} #------------------------------------------------------------------------------------------
|
||
|
|
|
||
|
|
use db ;
|
||
|
|
use db_min ;
|
||
|
|
use dialog ;
|
||
|
|
use today ;
|
||
|
|
use common ;
|
||
|
|
use pdf ;
|
||
|
|
use tabs ;
|
||
|
|
|
||
|
|
1;
|