From b9fd9a5f6f50aba3aba7e0cebbb49d2ad342bb2f Mon Sep 17 00:00:00 2001 From: Roman Khomasuridze Date: Tue, 1 Sep 2015 16:08:13 -0400 Subject: [PATCH] initial work on #13, basic pagination is done --- functions.inc.php | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/functions.inc.php b/functions.inc.php index 952f171..72a02a1 100755 --- a/functions.inc.php +++ b/functions.inc.php @@ -400,10 +400,20 @@ function fbilling_generate_invoice ($src,$search_results) { # generate pdf $pdf = new PDF(); $pdf->SetFont('Arial','',12); - $pdf->AddPage(); - $pdf->Cell(40,10,"Invoice for extension $src"); - $pdf->Ln(); - $pdf->generate_table($search_results); + # fwarning, ugly things coming through! + # for PDF pagination, we loop through number of pages we have + for ($page=0; $page < $number_of_pages; $page++) { + $pdf->AddPage(); # createnew page + if ($page == 0) { # we need PDF header on first page + $pdf->Cell(40,10,"Invoice for extension $src"); + } else { + $pdf->Cell(40,10,"Continued from page $page"); + } + $pdf->Ln(); + # since we need pagination, we'd rather slice array then run several queries... + $page_rows = array_chunk($search_results, 40); + $pdf->generate_table($page_rows[$page]); + } $pdf->Output($filename,'F'); // insert into invoice table $fields = array("extension_id","creation_date","filename");