Skip to content

Commit

Permalink
initial work on #13, basic pagination is done
Browse files Browse the repository at this point in the history
  • Loading branch information
alkali147 committed Sep 1, 2015
1 parent 5d52405 commit b9fd9a5
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions functions.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit b9fd9a5

Please sign in to comment.