Skip to content
Snippets Groups Projects
Commit 5d97ce03 authored by Laurent Destailleur's avatar Laurent Destailleur
Browse files

Fix page break when using a large html footer.

parent 74a9bbbf
No related branches found
No related tags found
No related merge requests found
...@@ -36,7 +36,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; ...@@ -36,7 +36,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
/** /**
* Classe permettant de generer les commandes au modele Einstein * Classe to generate PDF orders with template Einstein
*/ */
class pdf_einstein extends ModelePDFCommandes class pdf_einstein extends ModelePDFCommandes
{ {
...@@ -173,7 +173,7 @@ class pdf_einstein extends ModelePDFCommandes ...@@ -173,7 +173,7 @@ class pdf_einstein extends ModelePDFCommandes
{ {
$object->fetch_thirdparty(); $object->fetch_thirdparty();
$deja_regle = ""; $deja_regle = 0;
// Definition of $dir and $file // Definition of $dir and $file
if ($object->specimen) if ($object->specimen)
...@@ -213,11 +213,12 @@ class pdf_einstein extends ModelePDFCommandes ...@@ -213,11 +213,12 @@ class pdf_einstein extends ModelePDFCommandes
// Create pdf instance // Create pdf instance
$pdf=pdf_getInstance($this->format); $pdf=pdf_getInstance($this->format);
$default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
$heightforinfotot = 50; // Height reserved to output the info and total part $pdf->SetAutoPageBreak(1,0);
$heightforinfotot = 40; // Height reserved to output the info and total part
$heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page
$heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
$pdf->SetAutoPageBreak(1,0);
if (class_exists('TCPDF')) if (class_exists('TCPDF'))
{ {
$pdf->setPrintHeader(false); $pdf->setPrintHeader(false);
...@@ -552,11 +553,13 @@ class pdf_einstein extends ModelePDFCommandes ...@@ -552,11 +553,13 @@ class pdf_einstein extends ModelePDFCommandes
$posy=$this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs); $posy=$this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
// Affiche zone versements // Affiche zone versements
/*
if ($deja_regle) if ($deja_regle)
{ {
$posy=$this->_tableau_versements($pdf, $object, $posy, $outputlangs); $posy=$this->_tableau_versements($pdf, $object, $posy, $outputlangs);
} }
*/
// Pied de page // Pied de page
$this->_pagefoot($pdf,$object,$outputlangs); $this->_pagefoot($pdf,$object,$outputlangs);
if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
......
...@@ -251,15 +251,17 @@ class pdf_crabe extends ModelePDFFactures ...@@ -251,15 +251,17 @@ class pdf_crabe extends ModelePDFFactures
// Set nblignes with the new facture lines content after hook // Set nblignes with the new facture lines content after hook
$nblignes = count($object->lines); $nblignes = count($object->lines);
$nbpayments = count($object->getListOfPayments());
// Create pdf instance // Create pdf instance
$pdf=pdf_getInstance($this->format); $pdf=pdf_getInstance($this->format);
$default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
$heightforinfotot = 50; // Height reserved to output the info and total part $pdf->SetAutoPageBreak(1,0);
$heightforinfotot = 50+(4*$nbpayments); // Height reserved to output the info and total part and payment part
$heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page
$heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
$pdf->SetAutoPageBreak(1,0);
if (class_exists('TCPDF')) if (class_exists('TCPDF'))
{ {
$pdf->setPrintHeader(false); $pdf->setPrintHeader(false);
...@@ -746,6 +748,7 @@ class pdf_crabe extends ModelePDFFactures ...@@ -746,6 +748,7 @@ class pdf_crabe extends ModelePDFFactures
$pdf->SetFont('','', $default_font_size - 4); $pdf->SetFont('','', $default_font_size - 4);
// Loop on each deposits and credit notes included // Loop on each deposits and credit notes included
$sql = "SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,"; $sql = "SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,";
$sql.= " re.description, re.fk_facture_source,"; $sql.= " re.description, re.fk_facture_source,";
...@@ -790,12 +793,15 @@ class pdf_crabe extends ModelePDFFactures ...@@ -790,12 +793,15 @@ class pdf_crabe extends ModelePDFFactures
} }
// Loop on each payment // Loop on each payment
$sql = "SELECT p.datep as date, p.fk_paiement as type, p.num_paiement as num, pf.amount as amount,"; // TODO Call getListOfPaymentsgetListOfPayments instead of hard coded sql
$sql = "SELECT p.datep as date, p.fk_paiement, p.num_paiement as num, pf.amount as amount,";
$sql.= " cp.code"; $sql.= " cp.code";
$sql.= " FROM ".MAIN_DB_PREFIX."paiement_facture as pf, ".MAIN_DB_PREFIX."paiement as p"; $sql.= " FROM ".MAIN_DB_PREFIX."paiement_facture as pf, ".MAIN_DB_PREFIX."paiement as p";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as cp ON p.fk_paiement = cp.id"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as cp ON p.fk_paiement = cp.id";
$sql.= " WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = ".$object->id; $sql.= " WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = ".$object->id;
//$sql.= " WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = 1";
$sql.= " ORDER BY p.datep"; $sql.= " ORDER BY p.datep";
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
if ($resql) if ($resql)
{ {
......
...@@ -91,8 +91,8 @@ class pdf_azur extends ModelePDFPropales ...@@ -91,8 +91,8 @@ class pdf_azur extends ModelePDFPropales
$this->option_condreg = 1; // Affiche conditions reglement $this->option_condreg = 1; // Affiche conditions reglement
$this->option_codeproduitservice = 1; // Affiche code produit-service $this->option_codeproduitservice = 1; // Affiche code produit-service
$this->option_multilang = 1; // Dispo en plusieurs langues $this->option_multilang = 1; // Dispo en plusieurs langues
$this->option_escompte = 1; // Affiche si il y a eu escompte $this->option_escompte = 0; // Affiche si il y a eu escompte
$this->option_credit_note = 1; // Support credit notes $this->option_credit_note = 0; // Support credit notes
$this->option_freetext = 1; // Support add of a personalised text $this->option_freetext = 1; // Support add of a personalised text
$this->option_draft_watermark = 1; //Support add of a watermark on drafts $this->option_draft_watermark = 1; //Support add of a watermark on drafts
...@@ -230,7 +230,7 @@ class pdf_azur extends ModelePDFPropales ...@@ -230,7 +230,7 @@ class pdf_azur extends ModelePDFPropales
{ {
$object->fetch_thirdparty(); $object->fetch_thirdparty();
// $deja_regle = 0; $deja_regle = 0;
// Definition of $dir and $file // Definition of $dir and $file
if ($object->specimen) if ($object->specimen)
...@@ -270,11 +270,8 @@ class pdf_azur extends ModelePDFPropales ...@@ -270,11 +270,8 @@ class pdf_azur extends ModelePDFPropales
// Create pdf instance // Create pdf instance
$pdf=pdf_getInstance($this->format); $pdf=pdf_getInstance($this->format);
$default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
$heightforinfotot = 50; // Height reserved to output the info and total part $pdf->SetAutoPageBreak(1,0);
$heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page
$heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
$pdf->SetAutoPageBreak(1,0);
if (class_exists('TCPDF')) if (class_exists('TCPDF'))
{ {
$pdf->setPrintHeader(false); $pdf->setPrintHeader(false);
...@@ -323,12 +320,20 @@ class pdf_azur extends ModelePDFPropales ...@@ -323,12 +320,20 @@ class pdf_azur extends ModelePDFPropales
$pdf->AddPage(); $pdf->AddPage();
if (! empty($tplidx)) $pdf->useTemplate($tplidx); if (! empty($tplidx)) $pdf->useTemplate($tplidx);
$pagenb++; $pagenb++;
$heightforinfotot = 40; // Height reserved to output the info and total part
$heightforsignature = empty($conf->global->PROPAL_DISABLE_SIGNATURE)?(pdfGetHeightForHtmlContent($pdf, $outputlangs->transnoentities("ProposalCustomerSignature"))+10):0;
$heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page
$heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
//print $heightforinfotot + $heightforsignature + $heightforfreetext + $heightforfooter;exit;
$this->_pagehead($pdf, $object, 1, $outputlangs); $this->_pagehead($pdf, $object, 1, $outputlangs);
$pdf->SetFont('','', $default_font_size - 1); $pdf->SetFont('','', $default_font_size - 1);
$pdf->MultiCell(0, 3, ''); // Set interline to 3 $pdf->MultiCell(0, 3, ''); // Set interline to 3
$pdf->SetTextColor(0,0,0); $pdf->SetTextColor(0,0,0);
$tab_top = 90;
$tab_top = 90;
$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10); $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10);
$tab_height = 130; $tab_height = 130;
$tab_height_newpage = 150; $tab_height_newpage = 150;
...@@ -406,7 +411,7 @@ class pdf_azur extends ModelePDFPropales ...@@ -406,7 +411,7 @@ class pdf_azur extends ModelePDFPropales
if (! empty($realpatharray[$i])) $imglinesize=pdf_getSizeForImage($realpatharray[$i]); if (! empty($realpatharray[$i])) $imglinesize=pdf_getSizeForImage($realpatharray[$i]);
$pdf->setTopMargin($tab_top_newpage); $pdf->setTopMargin($tab_top_newpage);
$pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforsignature+$heightforinfotot); // The only function to edit the bottom margin of current page to set it.
$pageposbefore=$pdf->getPage(); $pageposbefore=$pdf->getPage();
$showpricebeforepagebreak=1; $showpricebeforepagebreak=1;
...@@ -414,7 +419,7 @@ class pdf_azur extends ModelePDFPropales ...@@ -414,7 +419,7 @@ class pdf_azur extends ModelePDFPropales
$posYAfterDescription=0; $posYAfterDescription=0;
// We start with Photo of product line // We start with Photo of product line
if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforinfotot))) // If photo too high, we moved completely on new page if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforsignature+$heightforinfotot))) // If photo too high, we moved completely on new page
{ {
$pdf->AddPage('','',true); $pdf->AddPage('','',true);
if (! empty($tplidx)) $pdf->useTemplate($tplidx); if (! empty($tplidx)) $pdf->useTemplate($tplidx);
...@@ -436,9 +441,10 @@ class pdf_azur extends ModelePDFPropales ...@@ -436,9 +441,10 @@ class pdf_azur extends ModelePDFPropales
// Description of product line // Description of product line
$curX = $this->posxdesc-1; $curX = $this->posxdesc-1;
$showpricebeforepagebreak=1;
$pdf->startTransaction(); $pdf->startTransaction();
pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxpicture-$curX,3,$curX,$curY,$hideref,$hidedesc); pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxpicture-$curX,3,$curX,$curY,$hideref,$hidedesc);
$pageposafter=$pdf->getPage(); $pageposafter=$pdf->getPage();
if ($pageposafter > $pageposbefore) // There is a pagebreak if ($pageposafter > $pageposbefore) // There is a pagebreak
{ {
...@@ -451,7 +457,7 @@ class pdf_azur extends ModelePDFPropales ...@@ -451,7 +457,7 @@ class pdf_azur extends ModelePDFPropales
$pageposafter=$pdf->getPage(); $pageposafter=$pdf->getPage();
$posyafter=$pdf->GetY(); $posyafter=$pdf->GetY();
//var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit; //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforsignature+$heightforinfotot))) // There is no space left for total+free text
{ {
if ($i == ($nblignes-1)) // No more lines, and no space left to show total, so we create a new page if ($i == ($nblignes-1)) // No more lines, and no space left to show total, so we create a new page
{ {
...@@ -624,13 +630,13 @@ class pdf_azur extends ModelePDFPropales ...@@ -624,13 +630,13 @@ class pdf_azur extends ModelePDFPropales
// Show square // Show square
if ($pagenb == 1) if ($pagenb == 1)
{ {
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code); $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code);
$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter + 1;
} }
else else
{ {
$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code); $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter + 1;
} }
// Affiche zone infos // Affiche zone infos
...@@ -765,7 +771,7 @@ class pdf_azur extends ModelePDFPropales ...@@ -765,7 +771,7 @@ class pdf_azur extends ModelePDFPropales
/** /**
* Show payments table * Show payments table
* *
* @param PDF $pdf Object PDF * @param TCPDF $pdf Object PDF
* @param Object $object Object proposal * @param Object $object Object proposal
* @param int $posy Position y in PDF * @param int $posy Position y in PDF
* @param Translate $outputlangs Object langs for output * @param Translate $outputlangs Object langs for output
...@@ -780,7 +786,7 @@ class pdf_azur extends ModelePDFPropales ...@@ -780,7 +786,7 @@ class pdf_azur extends ModelePDFPropales
/** /**
* Show miscellaneous information (payment mode, payment term, ...) * Show miscellaneous information (payment mode, payment term, ...)
* *
* @param PDF $pdf Object PDF * @param TCPDF $pdf Object PDF
* @param Object $object Object to show * @param Object $object Object to show
* @param int $posy Y * @param int $posy Y
* @param Translate $outputlangs Langs object * @param Translate $outputlangs Langs object
...@@ -1581,7 +1587,6 @@ class pdf_azur extends ModelePDFPropales ...@@ -1581,7 +1587,6 @@ class pdf_azur extends ModelePDFPropales
$default_font_size = pdf_getPDFFontSize($outputlangs); $default_font_size = pdf_getPDFFontSize($outputlangs);
$tab_top = $posy + 4; $tab_top = $posy + 4;
$tab_hl = 4; $tab_hl = 4;
$pdf->SetFont('','', $default_font_size - 1);
$posx = 120; $posx = 120;
$largcol = ($this->page_largeur - $this->marge_droite - $posx); $largcol = ($this->page_largeur - $this->marge_droite - $posx);
...@@ -1594,7 +1599,7 @@ class pdf_azur extends ModelePDFPropales ...@@ -1594,7 +1599,7 @@ class pdf_azur extends ModelePDFPropales
$pdf->MultiCell($largcol, $tab_hl, $outputlangs->transnoentities("ProposalCustomerSignature"), 0, 'L', 1); $pdf->MultiCell($largcol, $tab_hl, $outputlangs->transnoentities("ProposalCustomerSignature"), 0, 'L', 1);
$pdf->SetXY($posx, $tab_top + $tab_hl); $pdf->SetXY($posx, $tab_top + $tab_hl);
$pdf->MultiCell($largcol, $tab_hl*6, '', 1, 'R'); $pdf->MultiCell($largcol, $tab_hl*3, '', 1, 'R');
return ($tab_hl*7); return ($tab_hl*7);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment