#!/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'});

my $qt_id     = $ARGV[0] ;
my $cam_id    = $ARGV[1] ;

# 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 = '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($table,"*","`id`='$qt_id'",'','') ;

our $custid   = $db{$table}{$qt_id}{quote_to} ;
our $quote_nr = $db{$table}{$qt_id}{quote_nr} ;

&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('price_list','id,description','','','') ;
foreach my $id (keys %{$db{price_list}}) { $price_list{$id} = $db{price_list}{$id}{description} ; }

our $countryid = $db{$table}{$qt_id}{country_shipped} ;
&db_min_ro('countries','*',"`id`='$countryid'",'','') ;
$country{$countryid} = $db{countries}{$countryid}{name} ;

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} ;
    
&db_min_ro('cameras','*',"`quote_nr`='$quote_nr'",'','') ;

foreach my $id (keys %{$db{cameras}}) { 
	$camera_nr{$id}   = $db{cameras}{$id}{camera_nr} ; 
	$serial_nr{$id}   = $db{cameras}{$id}{serial_nr} ; 
	$camera_desc{$id} = $db{cameras}{$id}{quote_cam_desc} ; 
	$linked_vpu{$id}  = $db{cameras}{$id}{quote_linked_vpu} ;
	$date_start{$id}  = $db{cameras}{$id}{quote_ew_date_from};
	$date_end{$id}    = $db{cameras}{$id}{quote_ew_date_to};
	}
	
# &db_min_ro('quotes','quote_date, quote_expiry',"`quote_nr`='$quote_nr'",'','') ;
	
	# 
    
} #------------------------------------------------------------------------------------------
    
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/warranty" ;
our $pdfname = "EW-$qt_id-" . $now_ccyymmdd . '.pdf' ;

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

&tab_curr_symbols;
&pdf_initialise_page ;
$up = 292 ;
# &warranty_pdf_page_header ;

&pdf_box_block_top(5,205,'#009bc8') ;
	
	$up       = 260 ;
	$across   = 1 ;
	$blue_box = 1 ;
	&pdf_page_header ;	
	&warranty_pdf_vars ;
	&warranty_out_to_pdf ;
	#&warranty_pdf_footer ;
$up = 5 ;	
&pdf_box_block_bottom(5,205,'#009bc8') ;
} #------------------------------------------------------------------------------------------

# sub warranty_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 warranty_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_right (180, $up, "Quote Nr. :") ;
# # &pdf_small_text_right (198, $up, $qt_id) ;
# &pdf_small_text_right (198, $up, $db{$table}{$qt_id}{warranty_nr}) ;
# &pdf_nl;

#&pdf_small_bold_text_right  (180, $up, "Date :") ; 
# my $dttxt = &custom_date_txt($db{$table}{$qt_id}{warranty_date});
#&pdf_small_text_right (198, $up, $dttxt) ;

# &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','WARRANTY CERTIFICATE',20,98) ;
# &pdf_large_bold_text(85,$up,'WARRANTY CERTIFICATE') ;
$up = $up - 10;
&pdf_xxx_large_bold_text(53,$up,'WARRANTY CERTIFICATE') ;
&pdf_nl;

 # # start block -------------------------------------

	# if ($custid) {
		
		# my ($warranty_year,$warranty_month,$warranty_day) = split(/\-/,$db{$table}{$qt_id}{quote_date});
		# my ($expiry_year,$expiry_month,$expiry_day) = Add_Delta_Days($warranty_year,$warranty_month,$warranty_day,14); # Add 7 days to warranty date
		# $expiry_month  = sprintf("%02s", $expiry_month) ;
		# $expiry_day    = sprintf("%02s", $expiry_day) ;
		# my $expiry_date = &custom_date_txt("$expiry_year-$expiry_month-$expiry_day");
		# # my $expiry_date = "$expiry_year-$expiry_month-$expiry_day";
		# &pdf_box_block_top(10,200,'#009bc8') ;
		# &pdf_nl_gap_1;
		# &pdf_small_bold_text (13, $up, "Customer :") ;
		# &pdf_small_text (29, $up, $customer_name{$custid}) ;
		# &pdf_small_bold_text (113, $up, "Country :") ;
		# &pdf_small_text (133, $up, $country{$countryid}) ;
		# &pdf_nl;
		# &pdf_small_bold_text (13, $up, "Adress :") ;
		# &pdf_small_text (29, $up, $customer_address{$custid}) ;
		# &pdf_small_bold_text (113, $up, "Tax/VAT Nr :") ;
		# &pdf_small_text (133, $up, $customer_vat_nr{$custid}) ;
		# &pdf_nl;
		# &pdf_nl;
		# &pdf_small_bold_text (13, $up, "Contact :") ;
		# &pdf_small_text (29, $up, $customer_contact_name{$custid}) ;
		# &pdf_small_bold_text (113, $up, "Quote Expiry :") ;
		# &pdf_small_text (133, $up, $expiry_date) ;
		# &pdf_nl;
		# &pdf_small_bold_text (13, $up, "Phone Nr :") ;
		# &pdf_small_text (29, $up, $customer_phone{$custid}) ;
		# &pdf_nl;
		# &pdf_small_bold_text (13, $up, "Email :") ;
		# &pdf_small_text (29, $up, $customer_email{$custid}) ;
		# &pdf_small_bold_text (113, $up, "Reference :") ;
		# &pdf_small_text (133, $up, $db{$table}{$qt_id}{ref}) ;
		# &pdf_nl;
		# &pdf_small_bold_text (113, $up, "PO Nr :") ;
		# &pdf_small_text (133, $up, $db{$table}{$qt_id}{po_nr}) ;
		# &pdf_nl;
		# &pdf_small_bold_text (13, $up, "Notes :") ;
		# # &pdf_small_text (29, $up, $db{$table}{$qt_id}{notes}) ;
		# &pdf_text_block (29,$db{$table}{$qt_id}{notes},60,5) ; $up+=2.7;
		# &pdf_small_bold_text (113, $up, "System :") ;
		# &pdf_small_text (133, $up, $camera_system{$camera_system_id}) ;
		# &pdf_nl;
		# &pdf_box_block_bottom(10,200,'#009bc8') ;
	# }
	

 # # end block -------------------------------------
&pdf_nl_gap_1;
&pdf_thin_black_line ($blocks[1],$up,200,$up,'#009bc8') ;
$top = $up - 30;
&pdf_thin_black_line ($blocks[1],$top,$blocks[1],$up,'#009bc8') ;
pdf_thin_black_line (200,$top,200,$up,'#009bc8') ;
&vertical_lines_inner_box;
$up = $up - 4;
&pdf_medium_bold_text ($boxtxt[1],$up,'Issued To') ; 
&pdf_medium_text ($boxtxt[2],$up, $customer_name{$custid}) ; 
&pdf_medium_bold_text ($boxtxt[3],$up,'Invoice Nr') ;
&pdf_medium_text ($boxtxt[3]+30, $up, $db{$table}{$qt_id}{invoice_nr}) ;	
$up = $up - 2;
&pdf_thin_black_line ($blocks[2],$up,200,$up,'#009bc8') ;
$up = $up - 4;
&pdf_medium_bold_text ($boxtxt[3],$up,'PO Nr') ;
&pdf_medium_text ($boxtxt[3]+30, $up, $db{$table}{$qt_id}{po_nr}) ;
$up = $up - 2;
&pdf_thin_black_line ($blocks[2],$up,200,$up,'#009bc8') ;
$up = $up - 4;
&pdf_medium_bold_text ($boxtxt[3],$up,'Quote Nr') ;
&pdf_medium_text ($boxtxt[3]+30, $up, $db{$table}{$qt_id}{quote_nr}) ;	
$up = $up - 2;
&pdf_thin_black_line ($blocks[2],$up,200,$up,'#009bc8') ;
$up = $up - 4;
&pdf_medium_bold_text ($boxtxt[3],$up,'Ref') ;
&pdf_medium_text ($boxtxt[3]+30, $up, $db{$table}{$qt_id}{ref}) ;
$up = $up - 2;
&pdf_thin_black_line ($blocks[2],$up,200,$up,'#009bc8') ;
$up = $up - 6;
&pdf_thin_black_line ($blocks[1],$up,200,$up,'#009bc8') ;
&pdf_nl_gap_1;
#&pdf_nl_gap_3;#&pdf_nl;

#$top = $up - 55;
#&pdf_thin_black_line (10,$top,10,$up,'#009bc8') ;
#&pdf_thin_black_line (200,$top,200,$up,'#009bc8') ;
#&pdf_thin_black_line (10,$up,200,$up,'#009bc8') ;
#&pdf_thin_black_line (10,$top,200,$top,'#009bc8') ;
$top = $up ;

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

$up = $up - 7.5;

#my $txt = qq~This certificate serves to extend the existing warranty on the exact same terms and conditions of the initial warranty applicable to the following items as described below and for a period of 36 months from the date of delivery. This extended warranty only covers the repair or replacement of a broken item or part thereof, which shall be at the sole descretion of Interactive Television Africa (Pty) Ltd, or Pixellot Ltd. The extended warranty is limited to the replacement value of part or the item concerned.~;
my $txt = "This certificate serves as a warranty as per the terms and conditions of Interactivce Televisision Africa (Pty) Ltd for a
period of 15 months from the date of delivery. This warranty only covers the repair or replacement of a broken item or
part thereof, which shall be at the sole descretion of Interactive Television Africa (Pty) Ltd, or Pixellot Ltd. The warranty
is limited to the replacement value of part or the item concerned and do not cover any damage caused by lightning. The
warranty shall be void if repairs are not done by an authorized Pixellot technician";
&pdf_text_block (15, $txt ,130,3) ;

$up = $up - 2.5;

# my $txt1 = qq~This certificate does not provide coverage:~;
# &pdf_tiny_text (15,$up,$txt1)  ;
# $up = $up - 5;
# my $txt3 = qq~1.    for lost parts/items; ~;
# &pdf_tiny_text (15,$up,$txt3)  ;
# $up = $up - 5;
# my $txt4 = qq~2.    for parts/items which are damaged or destroyed as a result of the fault or negligence of the purchaser or of its employees/agents;~;
# &pdf_tiny_text (15,$up,$txt4)  ;
# $up = $up - 5;
# my $txt5 = qq~3.    for loss or damage caused by lightning or fire;~;
# &pdf_tiny_text (15,$up,$txt5)  ;
# $up = $up - 5;
# my $txt6 = qq~4.    for parts/items which are not supplied by Interactive Television Africa (Pty) Ltd;~;
# &pdf_tiny_text (15,$up,$txt6)  ;
# $up = $up - 5;
# my $txt7 = qq~5.    where re-used or recycled parts/items have been used or attached;~;
# &pdf_tiny_text (15,$up,$txt7)  ;
# $up = $up - 5;
# my $txt8 = qq~6.    in the event of loss or damage due to faulty installation or negligent tampering;~;
# &pdf_tiny_text (15,$up,$txt8)  ;
# $up = $up - 5;
# my $txt9 = qq~7.    in the event of loss or damage due to use of non-compliant parts/items on installation~;
# &pdf_tiny_text (15,$up,$txt9)  ;
# $up = $up - 5;
# my $txt10 = qq~The extended warranty shall be void if repairs are not done by an authorized Pixellot technician.~;
# &pdf_tiny_text (15,$up,$txt10)  ;
# $up = $up - 5;  
#&pdf_box_block_bottom($blocks[1],200,'#009bc8') ; # end block -------------------------------------	
#&pdf_nl_gap_3; &pdf_nl_gap_3;
#&pdf_tiny_bold_text (15,$up,'Notes:') ;
#for (1 .. 20) {
#	unless ($db{$table}{$qt_id}{"excl_$_\_notes"}) {
#		my $note = $db{$table}{$qt_id}{"note_$_"};
#		if ($note) {
#			&pdf_nl; 
#			&pdf_tiny_text (15,$up,"* $note")  ;
#		}		
#	}
#}

&pdf_thin_black_line (200,$top,200,$up,'#009bc8') ;
&pdf_thin_black_line ($blocks[1],$top,$blocks[1],$up,'#009bc8') ;
&pdf_thin_black_line (200,$top,$blocks[1],$top,'#009bc8') ;
&pdf_thin_black_line (200,$up,$blocks[1],$up,'#009bc8') ;

$up = $up - 5;
$top = $up - 8;
&pdf_box_block_top(0,200,'#009bc8') ; # start block -------------------------------------
&pdf_thin_black_line ($blocks[1],$top,$blocks[1],$up,'#009bc8') ;
&pdf_thin_black_line ($blocks[2],$top,$blocks[2],$up,'#009bc8') ;
&pdf_thin_black_line ($blocks[3],$top,$blocks[3],$up,'#009bc8') ;
&pdf_thin_black_line ($blocks[4],$top,$blocks[4],$up,'#009bc8') ;
&pdf_thin_black_line (200,$top,200,$up,'#009bc8') ;
	$up = $up - 5;
	#&pdf_nl_t;
	&pdf_medium_bold_text ($boxtxt[1]+4,$up,'Valid From') ;	
	&pdf_small_text ($boxtxt[2]+22,$up, $date_start{$cam_id}) ;	
	&pdf_small_text ($boxtxt[4]+22,$up, "$date_end{$cam_id}") ;	
	&pdf_medium_bold_text ($boxtxt[3]+6,$up,'Valid To') ;	
$up = $up - 3;
&pdf_thin_black_line ($blocks[1],$up,200,$up,'#009bc8') ; 
$up = $up - 5;
# &pdf_bar(10,$up,200,$up,'#009bc8','Item List',20,97) ;
&pdf_check_value_of_up(20);
&pdf_box_block_top($blocks[1],200,'#009bc8') ; # start block -------------------------------------
$top=$up;
	&pdf_nl_gap_1;
	#&pdf_nl_t;
	&pdf_medium_bold_text ($boxtxt[1]+7,$up,'Unit Nr') ;	
	&pdf_medium_bold_text ($boxtxt[2]+20,$up,'Description') ;	
	&pdf_medium_bold_text ($boxtxt[3]+9.5,$up,'Qty') ;	
	&pdf_medium_bold_text ($boxtxt[4]+19,$up,'Serial Number') ;
	&pdf_nl_t;
	&vertical_lines_inner_box;
	&pdf_box_block_bottom($blocks[1],200,'#009bc8') ; # end block -------------------------------------	
	#&pdf_thin_black_line ($blocks[1],$up,200,$up,'#009bc8') ; 	
	$up = $up - 3;
	#&pdf_thin_black_line ($blocks[1],$up,200,$up,'#009bc8') ;	
	&pdf_box_block_top($blocks[1],200,'#009bc8') ; # start block -------------------------------------
	$up = $up ;	
	$inner_blue_box = 1 ;
	$top=$up ;
	#$up = $up - 5;
	# foreach (sort keys %sec_cnt) {		
		# &pdf_check_value_of_up(15);	if ($up>280){ $up=280; }
		# $_k = substr($_,1) ;
		# my @parts = split(/\-/,$sec_cnt{$_}) ;
		
		# my $sec = '_costing' ; my $suffix = "$sec$_k" ;
		
		# unless ($db{$table}{$qt_id}{"item_1$suffix"}) { next ; }
		
		# # &pdf_small_bold_text ($boxtxt[1],$up,$parts[1]) ;
		# # &pdf_nl;
	# #
			
		# for (1 .. $parts[0]) {
			# $up = $up - 4;
			# if ($db{$table}{$qt_id}{"excl_$_$suffix"}) { next ; }
			
			# &pdf_check_value_of_up(15);	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"} ;
			
			# &pdf_medium_text($boxtxt[1]+2,$up,'') ; # unit nr	
			# &pdf_medium_text($boxtxt[2]+2,$up,$disp_item) ;	
			# &pdf_medium_text($boxtxt[3]+2,$up,$db{$table}{$qt_id}{"qty_$_$suffix"}) ;
			# &pdf_medium_text($boxtxt[4],$up,$db{$table}{$qt_id}{"serial_nr_$_$suffix"}) ;
			# # &pdf_small_text_right($rboxtxt[4],$up,&common_commify($db{$table}{$qt_id}{"curr_amnt_$_$suffix"})) ;
			
			# $up = $up - 2;
			# &pdf_thin_black_line ($blocks[1],$up,200,$up,'#009bc8') ;
		# }	
	# }
	my $count = 0;
	foreach (sort keys %serial_nr) {	
		next unless $cam_id eq $_ or $serial_nr{$cam_id} eq $linked_vpu{$_} ;
		&pdf_check_value_of_up(15);	if ($up>280){ $up=280; }
		$up = $up - 4;
		&pdf_small_text($boxtxt[1]+2,$up,$camera_nr{$_}) ; # unit nr	
		&pdf_small_text($boxtxt[2]+2,$up,$camera_desc{$_}) ;	
		&pdf_small_text($boxtxt[3]+12,$up,1) ;
		&pdf_small_text($boxtxt[4],$up,$serial_nr{$_}) ;
		$up = $up - 2;
		&pdf_thin_black_line ($blocks[1],$up,200,$up,'#009bc8') ;
		$count++;
	}
	
	if($count < 9){
		
		while ($count < 9){
			
			$up = $up - 6;
			&pdf_thin_black_line ($blocks[1],$up,200,$up,'#009bc8') ;
			$count++;
			
		}
		
		
	}
		
	&vertical_lines_inner_box;	

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

$inner_blue_box = 0 ;
#&pdf_nl_gap_1;
#&pdf_nl_gap_3;
&pdf_check_value_of_up(50);

###OWN CODE _-------------------------------------------------------------------------

$up = $up - 5;
$top = $up;
	#&pdf_nl_t;
	&pdf_thin_black_line ($blocks[1],$up,200,$up,'#009bc8') ; 
	$up = $up - 9;
	&pdf_medium_bold_text ($boxtxt[1]+3.75,$up,'Date Issued') ;	&pdf_small_text ($boxtxt[2]+22,$up, $date_start{$cam_id}) ;	
	&pdf_medium_bold_text ($boxtxt[3]+5,$up,'Signature') ;	

$up = $up - 7;
&pdf_thin_black_line ($blocks[1],$up,200,$up,'#009bc8') ; 
&vertical_lines_inner_box;
&pdf_thin_black_line (200,$top,200,$up,'#009bc8') ;
&pdf_thin_black_line (10,$top,10,$up,'#009bc8') ;

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

#&vertical_lines_inner_box

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[6],$top,$blocks[6],$up,'#009bc8') ; # vertical
	
} #----------------------------------------------------------------------------------------------------

sub warranty_pdf_footer {
	
&pdf_check_value_of_up(70);
&pdf_nl_gap_3;&pdf_nl_gap_3;&pdf_nl_gap_3; 
#&pdf_nl_gap_3;&pdf_nl_gap_3;&pdf_nl_gap_3; 


&pdf_tiny_bold_text (10, $up, "Name:")  ; &pdf_tiny_text (30, $up, "__________________________________________") ;
&pdf_tiny_bold_text (140, $up, "Date:") ; &pdf_tiny_text (155, $up, "__________________________") ;
&pdf_nl;
&pdf_tiny_text (10, $up, "(Duly Authorised)") ;
&pdf_nl_gap_3;
&pdf_tiny_bold_text (10, $up, "Company:") ; &pdf_tiny_text (30, $up, "__________________________________________") ;
&pdf_tiny_bold_text (140, $up, "Signature:") ; &pdf_tiny_text (155, $up, "__________________________") ;
&pdf_nl_gap_2;
&pdf_tiny_bold_text (10, $up, "Name:")  ; &pdf_tiny_text (30, $up, "__________________________________________") ;
&pdf_tiny_bold_text (140, $up, "Date:") ; &pdf_tiny_text (155, $up, "__________________________") ;
&pdf_nl;
&pdf_tiny_text (10, $up, "(Duly Authorised on behalf of Interactive Television Africa)") ;
&pdf_nl;
&pdf_nl;
&pdf_tiny_bold_text (140, $up, "Signature:") ; &pdf_tiny_text (155, $up, "__________________________") ;
	
} #------------------------------------------------------------------------------------------

sub warranty_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,30,103,116,143,170,197) ;
our @boxtxt   = (0,12,42,107,137,157,174) ;
our @blocks   = (0,10,40,105,135,155,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) = @_ ;
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 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/warranty/$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;