Update pdf_paiement.class.php

Minors bug fix (first page with bad numbering)
improvement compute of number of page
better fillment of page with line (save the tree is good for karma)
This commit is contained in:
BENKE Charlie 2015-04-11 12:22:42 +02:00
parent d76c1a9f42
commit 59bff8afac

View File

@ -60,8 +60,8 @@ class pdf_paiement
$this->tab_top = 30;
$this->line_height = 5;
$this->line_per_page = 25;
$this->tab_height = 230; //$this->line_height * $this->line_per_page;
$this->line_per_page = 46;
$this->tab_height = 250; //$this->line_height * $this->line_per_page;
$this->posxdate=$this->marge_gauche+2;
$this->posxpaymenttype=42;
@ -145,6 +145,17 @@ class pdf_paiement
$num=0;
$lines=array();
// count number of ligne of payement
$sql = "SELECT p.rowid as prowid";
$sql.= " FROM ".MAIN_DB_PREFIX."paiement as p";
$sql.= " WHERE p.datep BETWEEN '".$this->db->idate(dol_get_first_day($year,$month))."' AND '".$this->db->idate(dol_get_last_day($year,$month))."'";
$result = $this->db->query($sql);
if ($result)
{
$numpaiement = $this->db->num_rows($result);
}
// number of bill
$sql = "SELECT p.datep as dp, f.facnumber";
//$sql .= ", c.libelle as paiement_type, p.num_paiement";
$sql.= ", c.code as paiement_code, p.num_paiement";
@ -201,9 +212,9 @@ class pdf_paiement
dol_print_error($this->db);
}
$pages = intval($num / $this->line_per_page);
$pages = intval(($num + $numpaiement) / $this->line_per_page);
if (($lines % $this->line_per_page)>0)
if ((($num + $numpaiement) % $this->line_per_page)>0)
{
$pages++;
}
@ -231,7 +242,7 @@ class pdf_paiement
// New page
$pdf->AddPage();
$pagenb++;
$this->_pagehead($pdf, $pages, 1, $outputlangs);
$this->_pagehead($pdf, $pagenb, 1, $outputlangs);
$pdf->SetFont('','', 9);
$pdf->MultiCell(0, 3, ''); // Set interline to 3
$pdf->SetTextColor(0,0,0);
@ -292,8 +303,8 @@ class pdf_paiement
$pdf->SetXY($this->posxdate, 16);
$pdf->MultiCell(80, 2, $outputlangs->transnoentities("DateBuild")." : ".dol_print_date(time(),"day",false,$outputlangs,true), 0, 'L');
$pdf->SetXY($this->posxdate, 22);
$pdf->MultiCell(80, 2, $outputlangs->transnoentities("Page")." : ".$page, 0, 'L');
$pdf->SetXY($this->posxdate+100, 16);
$pdf->MultiCell(80, 2, $outputlangs->transnoentities("Page")." : ".$page, 0, 'R');
// Title line
@ -348,9 +359,17 @@ class pdf_paiement
for ($j = 0 ; $j < $numlines ; $j++)
{
$i = $j;
if ($yp > $this->tab_height -5)
{
$page++;
$pdf->AddPage();
$this->_pagehead($pdf, $page, 0, $outputlangs);
$pdf->SetFont('','', $default_font_size - 1);
$yp = 0;
}
if ($oldprowid <> $lines[$j][7])
{
if ($yp > 200)
if ($yp > $this->tab_height -10)
{
$page++;
$pdf->AddPage();