#!/usr/bin/perl

BEGIN { use lib '/usr/home/cfg' ; require push_inc ; }
    
require cfg ;

# unless ($username eq 'handre') { print "<<<<<<<<<<<< MAINTENANCE IN PROGRESS >>>>>>>>>" ; exit ; }

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 $qt_id     = $ARGV[0] ;
our $tab_no    = $ARGV[1] ;
our $tab_secs  = $ARGV[2] ;

# my @sections  = split(/\|/,$tab_secs); 

my @prefix_arr = qw( cost_desc_ curr_amnt_ qty_cost_ zar_amnt_ );

# our $debug = 1 ;
our $label = 1 ; # used in pdf_check_value_of_up

#------------------------------------------------------------------------------------------

print "Content-type: text/html\n\n";

&today ;
&pdf_curr_symbols ;

my $table = 'event_quotes' ;

&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 ;

&exclusions ;
&start_pdf ;
&build_pdf ;
&finish_pdf ;
&screen2 ;
    
exit ;

#------------------------------------------------------------------------------------------

sub prep_pdf {

	my @cols = () ;

	&tab_hash ;

	&db_min_ro('event_quotes',"*","`id`='$qt_id'",'','') ;
	
	our $countryid = $db{$table}{$qt_id}{country_id} ;
	our $custid = $db{$table}{$qt_id}{quote_to} ;
	our $date_from_for_pdf = $db{$table}{$qt_id}{date_from} ;
	our $type_id = $db{$table}{$qt_id}{type} ;
	
	my @month_array = ( "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ) ; 
	my $year = substr($date_from_for_pdf, 0, 4) ; 
	my $month = substr($date_from_for_pdf, 5, 2) ; 
	$month = int($month); 
	$month = $month_array[$month - 1] ;
	my $day = substr($date_from_for_pdf, 8, 2) ; 
	$date_from_for_pdf = "$day-" ; 
	$date_from_for_pdf .= "$month-" ;
	$date_from_for_pdf .= "$year" ;
	
	our %country = () ; 
	# print "COUNTty ID: $countryid, $custid \n" ;

	&db_min_ro('customers','id,name,physical_address,contact_email,phone,contact_name,vat_nr',"`id`='$custid'",'','') ;
	$customer_name{$custid}         = $db{customers}{$custid}{name} ; 
	$customer_address{$custid}      = $db{customers}{$custid}{physical_address} ; 
	$customer_email{$custid}        = $db{customers}{$custid}{contact_email} ; 
	$customer_phone{$custid}        = $db{customers}{$custid}{phone} ; 
	$customer_contact_name{$custid} = $db{customers}{$custid}{contact_name} ; 
	$customer_vat_nr{$custid}       = $db{customers}{$custid}{vat_nr} ; 

	&db_min_ro('event_cost_items','id,name','','','') ;
	foreach my $id (keys %{$db{event_cost_items}}) { $price_list{$id} = $db{event_cost_items}{$id}{name} ; }

	
	&db_min_ro('countries','*',"`id`='$countryid'",'','') ;
	$country{$countryid} = $db{countries}{$countryid}{name} ;
	# print "Country : $country{$countryid}" ; 
	$country{$countryid} = "Unknown" if not $country{$countryid} ;

	our $camera_system_id = $db{$table}{$qt_id}{camera_system_id} ;
	&db_min_ro('camera_systems','*',"`id`='$camera_system_id'",'','') ;
	$camera_system{$camera_system_id} = $db{camera_systems}{$camera_system_id}{name} ;
	
	our %event_type_for_pdf = () ; 
	&db_min_ro('event_types','id, name',"`id`='$type_id'",'','') ;
	$event_type_for_pdf{$type_id} = $db{event_types}{$type_id}{name} ;
	
	&db_min_ro('event_quotes_min','id, excl_costing_event, item_costing_event, qty_costing_event , usd_amnt_costing_event , item_ttl_costing_event , vat_costing_event, curr_amnt_costing_event ',"id = $qt_id",, '', '' );
		
} #------------------------------------------------------------------------------------------
    
sub exclusions {

	our $exclude_rate = 0 ;
	our $exclude_vat  = 0 ;
		
	if ($db{$table}{$qt_id}{currency} ne 'ZAR') {
		$exclude_vat = 1 ;
	}
	
} #------------------------------------------------------------------------------------------
    
sub start_pdf {

	my  $qtpdfpath = "$pdfpath/event_quotes_added_by_handre" ;
	our $pdfname = "EQT-$qt_id-" . $now_ccyymmdd . '.pdf' ;

	&pdf_delete_previous_pdf($qtpdfpath) ;
	&pdf_initialise($qtpdfpath,$pdfname,'ITV Event Quote') ;
    
} #------------------------------------------------------------------------------------------
    
sub build_pdf {

	&tab_curr_symbols;
	&pdf_initialise_page ;

	$up = 292 ;
	# &quote_pdf_page_header ;

	&pdf_box_block_top(5,205,'#009bc8') ;
	
	$up       = 260 ;
	$across   = 1 ;
	$blue_box = 1 ;
	
	&pdf_page_header ;
	&quote_pdf_vars ;
	&quote_out_to_pdf ;
	# &quote_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 {

	&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(150, $up, "Date") ; 
	my $dttxt = &custom_date_txt($db{$table}{$qt_id}{quote_date});
	&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','QUOTE',20,98) ;
	$up = $up - 5;

	&pdf_box_block_top(10,200,'#009bc8') ; # start block -------------------------------------

	if ($custid) {
		
		# my ($quote_year,$quote_month,$quote_day) = split(/\-/,$db{$table}{$qt_id}{quote_date});
		# my ($expiry_year,$expiry_month,$expiry_day) = Add_Delta_Days($quote_year,$quote_month,$quote_day,14); # Add 7 days to quote date
		# $expiry_month  = sprintf("%02s", $expiry_month) ;
		# $expiry_day    = sprintf("%02s", $expiry_day) ;
		my ($expiry_year,$expiry_month,$expiry_day) = split(/\-/,$db{$table}{$qt_id}{quote_expiry});
		my $expiry_date = &custom_date_txt("$expiry_year-$expiry_month-$expiry_day");
		# my $expiry_date = "$expiry_year-$expiry_month-$expiry_day";
		
		&pdf_nl;
		&pdf_thin_box_block_top(15,100,'#009bc8'); 
		# &pdf_thin_box_block_top(110,195,'#009bc8'); 
		
		$top = $up;
		my $pos = 37;
		my $pos2 = $pos + 1;
		my $pos3 = 132;
		my $pos4 = $pos3 + 1;
		
		$up = $up - 5.5 ;
		# $up = $up + 1.75;
		
		# $up = $up - 1.75;
		&pdf_small_bold_text (16, $up, "Customer") ;
		&pdf_small_text ($pos2, $up, $customer_name{$custid}) ;	
		
		$up = $up + 5.5 ;
		$up = $up - 3.25;
		# &pdf_small_bold_text (111, $up, "Event Start") ;
		# my $start_date = &custom_date_txt(substr($db{$table}{$qt_id}{date_from}, 0, 10));
		# $start_date .= substr($db{$table}{$qt_id}{date_from}, 10);
		# &pdf_small_text ($pos4, $up, $start_date) ;
		$up = $up -1.25;
		# &pdf_extra_thin_black_line (110,$up, 195 ,$up,'#009bc8') ;	
		$up = $up - 3.25;
		# &pdf_small_bold_text (111, $up, "Event End") ;
		# my $end_date = &custom_date_txt(substr($db{$table}{$qt_id}{date_to}, 0, 10));
		# $end_date .= substr($db{$table}{$qt_id}{date_to}, 10);
		# &pdf_small_text ($pos4, $up, $end_date) ;
		$up = $up -1.25;
		# &pdf_extra_thin_black_line ($pos3,$top, $pos3 ,$up,'#009bc8') ;	

		&pdf_extra_thin_black_line ($pos,$top, $pos ,$up,'#009bc8') ;	
		&pdf_thin_box_block_bottom(15,100,'#009bc8');	
		# &pdf_thin_box_block_bottom(110,195,'#009bc8');	
		&pdf_thin_box_block_top(15,100,'#009bc8');
		&pdf_thin_box_block_top(110,195,'#009bc8');
		
		$top = $up;
		$up = $up - 3.25;		
		
		&pdf_small_bold_text (111, $up, "Country") ;
		&pdf_small_text ($pos4, $up, $country{$countryid}) ;		
		$up = $up -1.25;
		&pdf_thin_box_block_bottom(110,195,'#009bc8');	
		&pdf_small_bold_text (16, $up, "Address") ;		
		my @waypoint = split(/\, / , $customer_address{$custid});	
		my $top2 = $up;
		my $count = 0;
		for my $py (@waypoint){
			&pdf_small_text ($pos2, $up, $waypoint[$count]) ;
			$count++;
			$up = $up - 4;
		}
		$up = $top2;
		&pdf_thin_box_block_top(110,195,'#009bc8');
		$up = $up - 3.25;		
		&pdf_small_bold_text (111, $up, "Tax/VAT Nr") ;
		&pdf_small_text ($pos4, $up, $customer_vat_nr{$custid}) ;
		$up = $up - 1.25;
		&pdf_thin_box_block_bottom(110,195,'#009bc8');	
		&pdf_extra_thin_black_line ($pos3,$top, $pos3 ,$up,'#009bc8') ;		
		$up = $up - 4.5;
		&pdf_extra_thin_black_line ($pos,$top, $pos ,$up,'#009bc8') ;	
		$top = $up;
		&pdf_thin_box_block_top(110,195,'#009bc8');		
		$up = $up - 3.25;
		&pdf_small_bold_text (111, $up, "Quote Expiry") ; 
		&pdf_small_text ($pos4, $up, $expiry_date) ;		
		$up = $up - 1.25;
		&pdf_thin_box_block_bottom(110,195,'#009bc8');
		&pdf_thin_box_block_bottom(15,100,'#009bc8');	
		&pdf_extra_thin_black_line ($pos,$top, $pos ,$up,'#009bc8') ;	
		&pdf_extra_thin_black_line ($pos3,$top, $pos3 ,$up,'#009bc8') ;			
		$up = $up - 4.5;
		&pdf_thin_box_block_top(15,100,'#009bc8'); 
		$top = $up; 
		&pdf_thin_box_block_top(110,195,'#009bc8'); 
		$up = $up - 3.25;
		&pdf_small_bold_text (16, $up, "Contact") ;
		&pdf_small_text ($pos2, $up, $customer_contact_name{$custid}) ;		
		&pdf_small_bold_text (111, $up, "Reference") ;
		&pdf_small_text ($pos4, $up, $db{$table}{$qt_id}{ref}) ;	
		$up = $up -1.25;
		&pdf_thin_box_block_bottom(15,100,'#009bc8');
		&pdf_thin_box_block_bottom(110,195,'#009bc8');	
		&pdf_thin_box_block_top(110,195,'#009bc8');
		&pdf_thin_box_block_top(15,100,'#009bc8');
		$up = $up - 3.25;
		&pdf_small_bold_text (16, $up, "Phone Nr") ;
		&pdf_small_text ($pos2, $up, $customer_phone{$custid}) ;		
		&pdf_small_bold_text (111, $up, "Date") ;		
		&pdf_small_text ($pos4, $up, $date_from_for_pdf) ;	
		# &pdf_small_text ($pos4, $up, $db{$table}{$qt_id}{po_nr}) ;
		$up = $up - 1.25;
		&pdf_thin_box_block_bottom(110,195,'#009bc8');
		&pdf_thin_box_block_bottom(15,100,'#009bc8');
		&pdf_extra_thin_black_line ($pos3,$top, $pos3 ,$up,'#009bc8') ;			
		&pdf_thin_box_block_top(15,100,'#009bc8');
		$up = $up - 3.25;	
		&pdf_small_bold_text (16, $up, "Email") ;
		&pdf_small_text ($pos2, $up, $customer_email{$custid}) ;
		$up = $up - 1.25;		
		&pdf_extra_thin_black_line ($pos,$top, $pos ,$up,'#009bc8') ;	
		&pdf_thin_box_block_bottom(15,100,'#009bc8');
		&pdf_nl;
		&pdf_thin_box_block_top(15,100,'#009bc8'); 
		&pdf_thin_box_block_top(110,195,'#009bc8');
		$top = $up;
		$up = $up - 3.25;
		&pdf_small_bold_text (16, $up, "Notes") ;
		&pdf_small_bold_text (111, $up, "Type") ;
		$up = $up - 1.25;
		&pdf_extra_thin_black_line ($pos3,$top, $pos3 ,$up,'#009bc8') ;	
		&pdf_thin_box_block_bottom(110,195,'#009bc8');	
		$up = $up + 1.25;
		# &pdf_small_text ($pos4, $up, $camera_system{$camera_system_id}) ;
		&pdf_small_text ($pos4, $up, $event_type_for_pdf{$type_id}) ; 
		# &pdf_small_text (29, $up, $db{$table}{$qt_id}{notes}) ;
		&pdf_text_block ($pos2 ,$db{$table}{$qt_id}{notes},60,5) ; 		
		$up = $up - 9;
		&pdf_thin_box_block_bottom(15,100,'#009bc8');
		&pdf_extra_thin_black_line ($pos,$top, $pos ,$up,'#009bc8') ;	
		$up = $up - 4.5;	
	}

	&pdf_box_block_bottom(10,200,'#009bc8') ; # end block -------------------------------------
	
	$up = $up - 6;
	#&pdf_nl_gap_1;
	&pdf_bar(9.75,$up,200.25,$up,'#009bc8','Item List',20,97) ;

	$top=$up;

	#&pdf_check_value_of_up(20);
	$up = $up - 3;
	&pdf_box_block_top($blocks[1],200,'#009bc8') ; # start block -------------------------------------
		
	$up = $up - 6;
	&pdf_small_bold_text ($boxtxt[1]+5,$up,'Item') ;	
	$up += 2;
	&pdf_small_bold_text (87,$up,'Per Day') ;	
	$up -= 4;
	&pdf_small_bold_text (87,$up,'/Venue') ;	
	$up += 2;
	&pdf_small_bold_text ($boxtxt[2]+2,$up,'Qty') ;	
	&pdf_small_bold_text ($boxtxt[3]+2.5,$up,'Per x Day Qty') ;	
	&pdf_small_bold_text ($boxtxt[4]+7.5,$up,'VAT') ;	
	&pdf_small_bold_text ($boxtxt[5]+7.5,$up,'Total') ;	
	$up = $up - 4;
	&pdf_thin_black_line ($blocks[1],$up,200,$up,'#009bc8') ; 
	
	&pdf_thin_black_line ($blocks[2],$top,$blocks[2],$up,'#009bc8') ;
	&pdf_thin_black_line (80,$top,80,$up,'#009bc8') ;
	&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') ;
	$top = $up;
	&pdf_nl_gap_1;
	my $price_times_qty = 0 ; 
	$inner_blue_box = 1 ;
	my %sec_cnt2 = ('a_costing_event' => "30-Event Costings");
	
	foreach (sort keys %sec_cnt2) {		

		if ($up>280){ $up=280; }
		$_k = substr($_,1) ;
		my @parts = split(/\-/,$sec_cnt2{$_}) ;
		
		# my $sec = '_costing' ; 
		# my $suffix = "$sec$_k" ;
		
		my $sec = '_costing_event' ; 
		my $suffix = "$sec" ;
		my $vat_amnt = 0 ;		
		# unless ($db{$table}{$qt_id}{"item_1$suffix"}) { next ; }
		
		&pdf_small_bold_text ($boxtxt[1]+5,$up,$parts[1]) ;	
		# &build_cost_form($id,$tab,$parts[0],"$sec$_k"); 
		&pdf_nl;

		my @excl_cost = split(";", $db{event_quotes_min}{$qt_id}{excl_costing_event});
		my @qty_cost = split(";", $db{event_quotes_min}{$qt_id}{qty_costing_event});
		my @usd_amnt_cost = split(";", $db{event_quotes_min}{$qt_id}{usd_amnt_costing_event});
		my @item_ttl_cost = split(";", $db{event_quotes_min}{$qt_id}{item_ttl_costing_event});
		my @vat_cost = split(";", $db{event_quotes_min}{$qt_id}{vat_costing_event});
		my @item_cost = split(";", $db{event_quotes_min}{$qt_id}{item_costing_event});
		my @curr_amnt_cost = split(";", $db{event_quotes_min}{$qt_id}{curr_amnt_costing_event});

		for (1 .. $parts[0]) {
			
			# &pdf_check_value_of_up(60) if $_ == 25 ;
			# next if $db{$table}{$qt_id}{"excl_$_$suffix"};		
			next if $excl_cost[$_ - 1];		
			
			next if not $qty_cost[$_ - 1] and not $curr_amnt_cost[$_ - 1] ;
			
			if ($up < 10){
				&pdf_thin_black_line (80,$top,80,10,'#009bc8') ;
				&pdf_check_value_of_up(10) if $_ > 15;
				$new_page = 1 ; 
			}				
			
			if ($up>280){ $up=280; }		
			# my $disp_item = $price_list{$db{$table}{$qt_id}{"item_$_$suffix"}} ? $price_list{$db{$table}{$qt_id}{"item_$_$suffix"}} : $db{$table}{$qt_id}{"item_$_$suffix"} ;
			my $disp_item = $price_list{$item_cost[$_ - 1]} ? $price_list{$item_cost[$_ - 1]} : $item_cost[$_ - 1] ;
			
			&pdf_small_text($boxtxt[1]+5,$up,"$disp_item") ;	
			# &pdf_small_text($boxtxt[2]+4.4,$up,$db{$table}{$qt_id}{"qty_$_$suffix"}) ;	
			&pdf_small_text($boxtxt[2]+4.4,$up,$qty_cost[$_ - 1]) ;	
			# &pdf_small_text ($boxtxt[3]+2,$up,&common_commify($db{$table}{$qt_id}{"curr_amnt_$_$suffix"})) ;
			&pdf_small_text($boxtxt[3],$up,$curr_symb{$db{$table}{$qt_id}{currency}}) ;
			# &pdf_small_text_right(102,$up,&common_commify($db{$table}{$qt_id}{"curr_amnt_$_$suffix"})) ;
			# &pdf_small_text_right(102,$up,&common_commify($db{$table}{$qt_id}{"curr_amnt_$_$suffix"})) ;
			&pdf_small_text_right(102,$up,&common_commify($curr_amnt_cost[$_ - 1])) ;
			&pdf_small_text_right(84,$up,"R") ;
			# $price_times_qty = $db{$table}{$qt_id}{"curr_amnt_$_$suffix"} * $db{$table}{$qt_id}{"qty_$_$suffix"} ;
			 $price_times_qty = $curr_amnt_cost[$_ - 1] * $qty_cost[$_ - 1] ;
			$price_times_qty = sprintf("%.2f", $price_times_qty) ; 
			$price_times_qty = &common_commify($price_times_qty) ; 
			&pdf_small_text_right($rboxtxt[3],$up,$price_times_qty);

			# if ($db{$table}{$qt_id}{"vat_$_$suffix"}) {
			if ($vat_cost[$_ - 1]) {
				# $vat_amnt = sprintf("%0.2f",$db{$table}{$qt_id}{"curr_amnt_$_$suffix"} * $db{$table}{$qt_id}{"qty_$_$suffix"} * 0.15) ;
				$vat_amnt = sprintf("%0.2f",$curr_amnt_cost[$_ - 1] * $qty_cost[$_ - 1] * 0.15) ;
				# &pdf_small_text ($boxtxt[4]+2,$up,&common_commify($vat_amnt)) ;	
				&pdf_small_text($boxtxt[4],$up,$curr_symb{$db{$table}{$qt_id}{currency}}) ;
				&pdf_small_text_right($rboxtxt[4],$up,&common_commify($vat_amnt)) ;	
			}
			
			# &pdf_small_text ($boxtxt[5]+2,$up,&common_commify($db{$table}{$qt_id}{"curr_amnt_$_$suffix"}+$vat_amnt)) ;
			&pdf_small_text($boxtxt[5],$up,$curr_symb{$db{$table}{$qt_id}{currency}}) ;
			# my $ttl_amnt = sprintf("%0.2f",$db{$table}{$qt_id}{"curr_amnt_$_$suffix"}*$db{$table}{$qt_id}{"qty_$_$suffix"}+$vat_amnt) ;
			my $ttl_amnt = sprintf("%0.2f",$curr_amnt_cost[$_ - 1]*$qty_cost[$_ - 1]+$vat_amnt) ;
			&pdf_small_text_right($rboxtxt[5],$up,&common_commify($ttl_amnt)) ;
			&pdf_nl;
		}
		
		if (not $new_page and $up < 65){
			&pdf_check_value_of_up(65) ; 
			$new_page = 1 ;
		}
		
		if ($_k eq '_systems' and $db{$table}{$qt_id}{systems_included}) {
			my @para = split /^/m, $db{$table}{$qt_id}{systems_included} ;
			foreach (@para) {
				&pdf_small_text($boxtxt[1]+5,$up,$_) ;	
				&pdf_nl_s;
			}
			# &pdf_text_block ($boxtxt[1]+2,$db{$table}{$qt_id}{systems_included},50,5) ;
		}
			
		if ($_k eq '_rental' and $db{$table}{$qt_id}{rental_included}) {
			my @para = split /^/m, $db{$table}{$qt_id}{rental_included} ;
			foreach (@para) {
				&pdf_small_text($boxtxt[1]+5,$up,$_) ;	
				&pdf_nl_s;
			}
		}
		&pdf_nl;
	}
		#$up=80;
	#&pdf_box_block_bottom($blocks[1],200,'#009bc8') ; # end block -------------------------------------	

	$inner_blue_box = 0 ;

	# ------------- totals ------------------------------------------------------------------


	#$top=$up;

	#&pdf_box_block_top($blocks[1],200,'#009bc8') ; # start block -------------------------------------

	# &pdf_nl_gap_1;#&pdf_nl_t;
	# &pdf_small_bold_text ($boxtxt[1]+2,$up,'') ;	
	# &pdf_small_bold_text ($boxtxt[2],$up,'') ;	
	# &pdf_small_bold_text ($boxtxt[3],$up,'Sub Total') ;	
	# &pdf_small_bold_text ($boxtxt[4],$up,'Vat Total') ;
	# &pdf_small_bold_text ($boxtxt[5],$up,'Grand Total') ;
	# &pdf_nl_t;
	
	#$top = $up;
	my $a = 0;
	my $b = 0;
	my $c = 0;
	
	if ($up < 65){
		&pdf_check_value_of_up(65);
		$new_page = 1 ; 
	}	
	
	$up = 55;
	
	# if ($db{$table}{$qt_id}{subtotal_one_time_fee} ne '0.00' or $db{$table}{$qt_id}{vat_one_time_fee} ne '0.00' or $db{$table}{$qt_id}{total_one_time_fee} ne '0.00'){
		$a = 1; 
		$up = $up + 8;
	# }
	# if ($db{$table}{$qt_id}{subtotal_monthly_recurring_fee} ne '0.00' or $db{$table}{$qt_id}{vat_monthly_recurring_fee} ne '0.00' or $db{$table}{$qt_id}{total_monthly_recurring_fee} ne '0.00' ){$b = 1;$up = $up + 8;}
	# if ($db{$table}{$qt_id}{subtotal_annual_fee} ne '0.00' or $db{$table}{$qt_id}{vat_annual_fee} ne '0.00' or $db{$table}{$qt_id}{total_annual_fee} ne '0.00'){$c = 1;$up = $up + 8;}
	
	unless ($new_page){
		&pdf_thin_black_line (80,$top,80,$up,'#009bc8') ; 
		&pdf_thin_black_line ($blocks[2],$top,$blocks[2],$up,'#009bc8') ; 
		&pdf_thin_black_line ($blocks[3],$top,$blocks[3],$up-8,'#009bc8') ; # vertical
		&pdf_thin_black_line ($blocks[4],$top,$blocks[4],$up-8,'#009bc8') ; # vertical
		&pdf_thin_black_line ($blocks[5],$top,$blocks[5],$up-8,'#009bc8') ;
	}
	
	$top = $up ; 
	
	$top = 287 if $new_page; 
	&pdf_thin_black_line ($blocks[2],$top,$blocks[2],$up,'#009bc8') ;
	&pdf_thin_black_line (80,$top,80,$up,'#009bc8') ;
	
	if ($a == 1) {		
		&pdf_thin_black_line ($blocks[1],$up,200,$up,'#009bc8') ; 
		$up = $up - 5;
		$inner_blue_box = 1 ;
		&pdf_small_bold_text ($boxtxt[1]+2,$up,'Total') ;	
		&pdf_small_text($boxtxt[3],$up,$curr_symb{$db{$table}{$qt_id}{currency}}) ;
		&pdf_small_text_right($rboxtxt[3],$up,&common_commify($db{$table}{$qt_id}{sub_total})) ;
		&pdf_small_text($boxtxt[4],$up,$curr_symb{$db{$table}{$qt_id}{currency}}) ;
		&pdf_small_text_right($rboxtxt[4],$up,&common_commify($db{$table}{$qt_id}{vat_total})) ;
		&pdf_small_text($boxtxt[5],$up,$curr_symb{$db{$table}{$qt_id}{currency}}) ;
		&pdf_small_text_right($rboxtxt[5],$up,&common_commify($db{$table}{$qt_id}{grand_total})) ;
		$up = $up - 3;
	 }
	
	 # if ($b == 1) {		
		# &pdf_thin_black_line ($blocks[1],$up,200,$up,'#009bc8') ; 
		# $up = $up - 5;
		# &pdf_small_bold_text ($boxtxt[1]+2,$up,'Monthly Recurring Fee') ;	
		# &pdf_small_text($boxtxt[3],$up,$curr_symb{$db{$table}{$qt_id}{currency}}) ;
		# &pdf_small_text_right($rboxtxt[3],$up,&common_commify($db{$table}{$qt_id}{subtotal_monthly_recurring_fee})) ;
		# &pdf_small_text($boxtxt[4],$up,$curr_symb{$db{$table}{$qt_id}{currency}}) ;
		# &pdf_small_text_right($rboxtxt[4],$up,&common_commify($db{$table}{$qt_id}{vat_monthly_recurring_fee})) ;
		# &pdf_small_text($boxtxt[5],$up,$curr_symb{$db{$table}{$qt_id}{currency}}) ;
		# &pdf_small_text_right($rboxtxt[5],$up,&common_commify($db{$table}{$qt_id}{total_monthly_recurring_fee})) ;
		# $up = $up - 3;
	# }
	
	# if ($c == 1) {
		# &pdf_thin_black_line ($blocks[1],$up,200,$up,'#009bc8') ; 
		# $up = $up - 5;
		# &pdf_small_bold_text ($boxtxt[1]+2,$up,'Annual Fee') ;	
		# &pdf_small_text($boxtxt[3],$up,$curr_symb{$db{$table}{$qt_id}{currency}}) ;
		# &pdf_small_text_right($rboxtxt[3],$up,&common_commify($db{$table}{$qt_id}{subtotal_annual_fee})) ;
		# &pdf_small_text($boxtxt[4],$up,$curr_symb{$db{$table}{$qt_id}{currency}}) ;
		# &pdf_small_text_right($rboxtxt[4],$up,&common_commify($db{$table}{$qt_id}{vat_annual_fee})) ;
		# &pdf_small_text($boxtxt[5],$up,$curr_symb{$db{$table}{$qt_id}{currency}}) ;
		# &pdf_small_text_right($rboxtxt[5],$up,&common_commify($db{$table}{$qt_id}{total_annual_fee})) ;
		# $up = $up - 3;
	# }
	# &pdf_extra_thin_black_line ($blocks[2],$top,$blocks[2],$up,'#009bc8') ; 
	 # 
	if ($new_page){
		&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') ;
	}
	&pdf_thin_black_line (10,$up,200,$up,'#009bc8') ;
	#&vertical_lines_inner_box;
	$up -= 5;
	
	# &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') ;
	
	&pdf_box_block_bottom($blocks[1],200,'#009bc8') ; # end block -------------------------------------	

	$inner_blue_box = 0 ;
		
	# ------------- totals ------------------------------------------------------------------

	# ------------- purchase summary ------------------------------------------------------------------

	# # &pdf_check_value_of_up(200);

	unless ($db{$table}{$qt_id}{excl_purchase_summary}) {
		
		# &pdf_box_block_top($tblocks[1],200,'#009bc8') ; # start block ---------
		# $up = $up - 3.5;
		
		
		# &pdf_bar(10,$up,200,$up,'#009bc8','Purchase Summary',20,90, 'med') ;
		
		# $up = $up - 10;
		# $top = $up ;
		# &pdf_bar(10,$up,200,$up,'#009bc8','Description',20, 14, 'med');
		# &pdf_bar (10,$up,200,$up,'#009bc8','Year 1', 20, 90, 'med') ;	
		# &pdf_bar (10,$up,200,$up,'#009bc8','Year 2', 20, 120, 'med') ;	
		# &pdf_bar (10,$up,200,$up,'#009bc8','Year 3', 20, 150, 'med') ;	
		# &pdf_bar (10,$up,200,$up,'#009bc8','TOTAL', 20, 180, 'med') ;
		# $up = $up - 8;
		# # $top=$up;

		# # &pdf_check_value_of_up(20);

		# # # ----------------------------

			# # &pdf_nl_gap_1;&pdf_nl_t;
			# # &pdf_small_bold_text ($tboxtxt[1]+2,$up,'Description') ;	
			# # &pdf_small_bold_text ($tboxtxt[2],$up,'Year 1') ;	
			# # &pdf_small_bold_text ($tboxtxt[3],$up,'Year 2') ;	
			# # &pdf_small_bold_text ($tboxtxt[4],$up,'Year 3') ;	
			# # &pdf_small_bold_text ($tboxtxt[5],$up,'Total') ;	
			# # &pdf_nl_t;
			# # &pdf_thin_black_line ($tblocks[1],$up,200,$up,'#009bc8') ; 
			# # &pdf_nl_gap_1;
			
			# $inner_blue_box = 1 ;
			
			# my $suffix = "_purchase_summary" ;
			
			# foreach (1 .. 3) {		
				# &pdf_check_value_of_up(15);	if ($up>280){ $up=280; }
				
				# if ($db{$table}{$qt_id}{"excl_$_$suffix"}) { next ; }
				
				# &pdf_small_bold_text ($tboxtxt[1]+2,$up,$db{$table}{$qt_id}{"item_$_$suffix"}) ;	
				# $box=1;
				# for my $y_ (1 .. 3) {				
					# $box++;
					# $ttl{$y_} += $db{$table}{$qt_id}{"year_$y_\_$_$suffix"} ;
					# # &pdf_small_text ($tboxtxt[$box],$up,&common_commify($db{$table}{$qt_id}{"year_$y_\_$_$suffix"})) ;	
					# &pdf_small_bold_text($tboxtxt[$box],$up,$curr_symb{$db{$table}{$qt_id}{currency}}) ;
					# &pdf_small_bold_text_right($tboxrtxt[$box],$up,&common_commify($db{$table}{$qt_id}{"year_$y_\_$_$suffix"})) ;
				# }
				# $box++;
				# $ttl += $db{$table}{$qt_id}{"total_$_$suffix"} ;
				# # &pdf_small_text ($tboxtxt[$box],$up,&common_commify($db{$table}{$qt_id}{"total_$_$suffix"})) ;	
				# &pdf_small_bold_text($tboxtxt[$box],$up,$curr_symb{$db{$table}{$qt_id}{currency}}) ;
				# &pdf_small_bold_text_right($tboxrtxt[$box],$up,&common_commify($db{$table}{$qt_id}{"total_$_$suffix"})) ;
				# $up = $up - 6;
			# }
			
			# #$up = $up - 4;
			# #&pdf_thin_black_line ($tblocks[1],$up,200,$up,'#009bc8') ; 
			
			# &pdf_bar (10,$up,200,$up,'#009bc8','Total', 20, 14, 'med') ;
			# #&pdf_large_bold_text(22, $up, 'Total');
			# #&pdf_large_white_text_bold(12, $up, 'Total');
			
			# # our @tboxrtxt = (0,77,107,137,167,197) ;	
			# #our @tboxtxt  = (0,12,82,112,142,172) ;
			# # &pdf_small_bold_text ($tboxtxt[2],$up,&common_commify($ttl{1})) ;	
			# # &pdf_small_bold_text ($tboxtxt[3],$up,&common_commify($ttl{2})) ;	
			# # &pdf_small_bold_text ($tboxtxt[4],$up,&common_commify($ttl{3})) ;	
			# # &pdf_small_bold_text ($tboxtxt[5],$up,&common_commify($ttl)) ;	
			# # &pdf_small_bold_text($tboxtxt[2],$up,$curr_symb{$db{$table}{$qt_id}{currency}}) ;
			# # &pdf_small_bold_text_right($tboxrtxt[2],$up,&common_commify(sprintf("%0.2f",$ttl{1}))) ;	
			# # &pdf_small_bold_text($tboxtxt[3],$up,$curr_symb{$db{$table}{$qt_id}{currency}}) ;
			# # &pdf_small_bold_text_right($tboxrtxt[3],$up,&common_commify(sprintf("%0.2f",$ttl{2}))) ;	
			# # &pdf_small_bold_text($tboxtxt[4],$up,$curr_symb{$db{$table}{$qt_id}{currency}}) ;
			# # &pdf_small_bold_text_right($tboxrtxt[4],$up,&common_commify(sprintf("%0.2f",$ttl{3}))) ;	
			# # &pdf_small_bold_text($tboxtxt[5],$up,$curr_symb{$db{$table}{$qt_id}{currency}}) ;
			# # &pdf_small_bold_text_right($tboxrtxt[5],$up,&common_commify(sprintf("%0.2f",$ttl))) ;	
			
			# &pdf_bar( 10, $up, 200, $up, '#009bc8', $curr_symb{$db{$table}{$qt_id}{currency}}, 20, $tboxtxt[2], 'small') ;
			# &pdf_bar( 10, $up, 200, $up, '#009bc8', &common_commify(sprintf("%0.2f",$ttl{1})), 20, $tboxrtxt[2], 'small_right') ;	
			# &pdf_bar( 10, $up, 200, $up, '#009bc8', $curr_symb{$db{$table}{$qt_id}{currency}}, 20, $tboxtxt[3], 'small') ;
			# &pdf_bar( 10, $up, 200, $up, '#009bc8', &common_commify(sprintf("%0.2f",$ttl{2})), 20, $tboxrtxt[3], 'small_right') ;	
			# &pdf_bar( 10, $up, 200, $up, '#009bc8', $curr_symb{$db{$table}{$qt_id}{currency}}, 20, $tboxtxt[4], 'small') ;
			# &pdf_bar( 10, $up, 200, $up, '#009bc8', &common_commify(sprintf("%0.2f",$ttl{3})), 20, $tboxrtxt[4], 'small_right') ;	
			# &pdf_bar( 10, $up, 200, $up, '#009bc8', $curr_symb{$db{$table}{$qt_id}{currency}}, 20, $tboxtxt[5], 'small') ;
			# &pdf_bar( 10, $up, 200, $up, '#009bc8', &common_commify(sprintf("%0.2f",$ttl)),    20, $tboxrtxt[5], 'small_right') ;	
			
			# #&pdf_nl_t;
			
			# #&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

		# &pdf_box_block_bottom($tblocks[1],200,'#009bc8') ; # end block -------------------------------------	

		# $inner_blue_box = 0 ;
}

# ------------- purchase summary ------------------------------------------------------------------

	#&pdf_nl_gap_1;
	#&pdf_nl_gap_3;
	# $up = $up - 15;
	#$&pdf_check_value_of_up(50);
	
	for (1 .. 20) {
		next if $db{$table}{$qt_id}{"excl_$_\_notes"} || $db{$table}{$qt_id}{"note_$_"} eq '';
		$notes_exist = 1 ;
	}
	$up -= 8;
	if ($notes_exist) {
		&pdf_medium_bold_text ($blocks[1],$up,'Notes:') ;
		$up = $up - 1;
		for (1 .. 20) {
			unless ($db{$table}{$qt_id}{"excl_$_\_notes"}) {
				my $note = $db{$table}{$qt_id}{"note_$_"};
				if ($note) {
					&pdf_nl; $up = $up - 1; 
					&pdf_medium_text ($blocks[1],$up,"$note")  ;

				}		
			}
		}
	}

	for (1 .. 20) {
		next if $db{$table}{$qt_id}{"excl_$_\_payment_terms"} || $db{$table}{$qt_id}{"payment_term_$_"} eq '';
		$payment_terms_exists = 1 ;
	}
	
	if ($payment_terms_exists) {
		&pdf_nl_gap_3;
		# &pdf_check_value_of_up(50);
		&pdf_medium_bold_text ($blocks[1],$up,'Payment Terms:') ;
		$up = $up - 1;
		for (1 .. 20) {
			unless ($db{$table}{$qt_id}{"excl_$_\_payment_terms"}) {
				my $payment_term = $db{$table}{$qt_id}{"payment_term_$_"};
				if (length($payment_term)>2) {
					$up = $up - 6; 
					&pdf_medium_text ($blocks[1],$up,"$payment_term")  ;
				}		
			}
		}
	}

	# for (1 .. 20) {
		# next if $db{$table}{$qt_id}{"excl_$_\_roes"} || $db{$table}{$qt_id}{"roe_$_"} eq '';
		# $roe_exists = 1 ;
	# }
	
	# if ($roe_exists) {
		# &pdf_nl_gap_3;
		# &pdf_check_value_of_up(50);
		# &pdf_medium_bold_text ($blocks[1],$up,'ROE:') ;
		# $up = $up - 1;
		# for (1 .. 20) {
			# unless ($db{$table}{$qt_id}{"excl_$_\_roes"}) {
				# my $roe = $db{$table}{$qt_id}{"roe_$_"};
				# if ($roe) {
					# &pdf_nl; 
					# $up = $up - 1; 
					# &pdf_medium_text ($blocks[1],$up,"- $roe")  ;
				# }		
			# }
		# }
	# }
	
	# for (1 .. 20) {
		# next if $db{$table}{$qt_id}{"excl_$_\_delivery_times"} || $db{$table}{$qt_id}{"delivery_time_$_"} eq '';
		# $delivery_time_exists = 1 ;
	# }
	
	# if ($delivery_time_exists) {
		# &pdf_nl_gap_3;
		# &pdf_check_value_of_up(50);
		# &pdf_medium_bold_text ($blocks[1],$up,'Manufacturing time:') ;
		# $up = $up - 1;

		# for (1 .. 20) {
			# unless ($db{$table}{$qt_id}{"excl_$_\_delivery_times"}) {
				# my $delivery_time = $db{$table}{$qt_id}{"delivery_time_$_"};
				# if ($delivery_time) {
					# &pdf_nl; $up = $up - 1; 
					# &pdf_medium_text ($blocks[1],$up,"- $delivery_time")  ;
				# }		
			# }
		# }
	# }
} #------------------------------------------------------------------------------------------

sub vertical_lines_inner_box {
	
	&pdf_thin_black_line ($blocks[1],$top,$blocks[1],$up,'#009bc8') ; # vertical
	&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[1],$top,$tblocks[1],$up,'#009bc8') ; # vertical
	&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 {
	
	&pdf_check_value_of_up(60);
	$up = 90;
	my $txt = qq~The parties hereby accept and agree to this quote, which incorporates by reference all the terms and conditions set forth in the Interactive Television Africa's Terms and Conditions document, attached hereto as Annexure A and the Service Level Agreement attached hereto as Annexure B (all, collectively with this quote, the "Agreement") effective as of the later of the signature dates below.~;
	&pdf_text_block (10,$txt,120,3) ;
	$up = $up - 10;
	&pdf_medium_bold_text (10, $up, "Name:")  ; &pdf_thin_black_line (30,$up,100,$up,'#009bc8') ; #&pdf_tiny_text (25, $up, "________________________________________________") ;
	&pdf_medium_bold_text (110, $up, "Date:") ; &pdf_thin_black_line (130,$up,200,$up,'#009bc8') ;
	$up = $up - 5;
	&pdf_small_text (10, $up, "(Duly Authorised)") ;
	$up = $up - 10;
	&pdf_medium_bold_text (10, $up, "Company:") ;    &pdf_thin_black_line (30,$up,100,$up,'#009bc8') ;
	&pdf_medium_bold_text (110, $up, "Signature:") ; &pdf_thin_black_line (130,$up,200,$up,'#009bc8') ;
	$up = $up - 15;
	&pdf_medium_bold_text (10, $up, "Name:")  ;     &pdf_thin_black_line (30,$up,100,$up,'#009bc8') ;
	&pdf_medium_bold_text (110, $up, "Date:") ;     &pdf_thin_black_line (130,$up,200,$up,'#009bc8') ;
	$up = $up - 5;
	&pdf_small_text (10, $up, "(Duly Authorised on behalf of Interactive Television Africa)") ;
	$up = $up - 10;
	&pdf_medium_bold_text (110, $up, "Signature:") ; 
	&pdf_thin_black_line (130,$up,200,$up,'#009bc8') ;
} #------------------------------------------------------------------------------------------

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) ;

	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 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/event_quotes_added_by_handre/$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;