Qual: Uniformize code for pdf generation.

Refactoring of pdf code to make code cleaner and fix a lot of bug into
page breaks.
This commit is contained in:
Laurent Destailleur 2012-08-08 04:12:20 +02:00
parent 6231dd9a10
commit 54c6db5b81
21 changed files with 715 additions and 672 deletions

View File

@ -55,7 +55,7 @@ if ($action == 'updateMask')
{ {
$maskconstorder=GETPOST('maskconstorder','alpha'); $maskconstorder=GETPOST('maskconstorder','alpha');
$maskorder=GETPOST('maskorder','alpha'); $maskorder=GETPOST('maskorder','alpha');
if ($maskconstorder) $res = dolibarr_set_const($db,$maskconstorder,$maskorder,'chaine',0,'',$conf->entity); if ($maskconstorder) $res = dolibarr_set_const($db,$maskconstorder,$maskorder,'chaine',0,'',$conf->entity);
if (! $res > 0) $error++; if (! $res > 0) $error++;
@ -77,7 +77,7 @@ if ($action == 'specimen') // For orders
$commande = new CommandeFournisseur($db); $commande = new CommandeFournisseur($db);
$commande->initAsSpecimen(); $commande->initAsSpecimen();
$commande->thirdparty=$specimenthirdparty; $commande->thirdparty=$specimenthirdparty;
// Search template files // Search template files
$file=''; $classname=''; $filefound=0; $file=''; $classname=''; $filefound=0;
$dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']); $dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']);
@ -91,13 +91,13 @@ if ($action == 'specimen') // For orders
break; break;
} }
} }
if ($filefound) if ($filefound)
{ {
require_once($file); require_once($file);
$module = new $classname($db); $module = new $classname($db,$commande);
if ($module->write_file($commande,$langs) > 0) if ($module->write_file($commande,$langs) > 0)
{ {
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=commande_fournisseur&file=SPECIMEN.pdf"); header("Location: ".DOL_URL_ROOT."/document.php?modulepart=commande_fournisseur&file=SPECIMEN.pdf");
@ -123,7 +123,7 @@ if ($action == 'specimenfacture') // For invoices
$facture = new FactureFournisseur($db); $facture = new FactureFournisseur($db);
$facture->initAsSpecimen(); $facture->initAsSpecimen();
$facture->thirdparty=$specimenthirdparty; // Define who should has build the invoice (so the supplier) $facture->thirdparty=$specimenthirdparty; // Define who should has build the invoice (so the supplier)
// Search template files // Search template files
$file=''; $classname=''; $filefound=0; $file=''; $classname=''; $filefound=0;
$dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']); $dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']);
@ -137,13 +137,13 @@ if ($action == 'specimenfacture') // For invoices
break; break;
} }
} }
if ($filefound) if ($filefound)
{ {
require_once($file); require_once($file);
$module = new $classname($db); $module = new $classname($db,$facture);
if ($module->write_file($facture,$langs) > 0) if ($module->write_file($facture,$langs) > 0)
{ {
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=facture_fournisseur&file=SPECIMEN.pdf"); header("Location: ".DOL_URL_ROOT."/document.php?modulepart=facture_fournisseur&file=SPECIMEN.pdf");
@ -166,7 +166,7 @@ if ($action == 'set')
{ {
$label = GETPOST('label','alpha'); $label = GETPOST('label','alpha');
$scandir = GETPOST('scandir','alpha'); $scandir = GETPOST('scandir','alpha');
$sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)";
$sql.= " VALUES ('".$db->escape($value)."','".$type."',".$conf->entity.", "; $sql.= " VALUES ('".$db->escape($value)."','".$type."',".$conf->entity.", ";
$sql.= ($label?"'".$db->escape($label)."'":'null').", "; $sql.= ($label?"'".$db->escape($label)."'":'null').", ";
@ -198,7 +198,7 @@ if ($action == 'setdoc')
{ {
$label = GETPOST('label','alpha'); $label = GETPOST('label','alpha');
$scandir = GETPOST('scandir','alpha'); $scandir = GETPOST('scandir','alpha');
$db->begin(); $db->begin();
if ($type == 'order_supplier' && dolibarr_set_const($db, "COMMANDE_SUPPLIER_ADDON_PDF",$value,'chaine',0,'',$conf->entity)) if ($type == 'order_supplier' && dolibarr_set_const($db, "COMMANDE_SUPPLIER_ADDON_PDF",$value,'chaine',0,'',$conf->entity))

View File

@ -51,7 +51,7 @@ if ($action == 'updateMask')
{ {
$maskconstproject=GETPOST('maskconstproject','alpha'); $maskconstproject=GETPOST('maskconstproject','alpha');
$maskproject=GETPOST('maskproject','alpha'); $maskproject=GETPOST('maskproject','alpha');
if ($maskconstproject) $res = dolibarr_set_const($db,$maskconstproject,$maskproject,'chaine',0,'',$conf->entity); if ($maskconstproject) $res = dolibarr_set_const($db,$maskconstproject,$maskproject,'chaine',0,'',$conf->entity);
if (! $res > 0) $error++; if (! $res > 0) $error++;
@ -86,7 +86,7 @@ if ($action == 'specimen')
break; break;
} }
} }
if ($filefound) if ($filefound)
{ {
require_once($file); require_once($file);
@ -207,7 +207,7 @@ foreach ($dirmodels as $reldir)
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
if ($module->isEnabled()) if ($module->isEnabled())
{ {
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td>'.$module->nom."</td><td>\n"; print '<tr '.$bc[$var].'><td>'.$module->nom."</td><td>\n";
print $module->info(); print $module->info();
@ -339,10 +339,10 @@ foreach ($dirmodels as $reldir)
// Active // Active
if (in_array($name, $def)) if (in_array($name, $def))
{ {
print "<td align=\"center\">\n"; print "<td align=\"center\">\n";
print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&amp;value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'; print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&amp;value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'">';
print img_picto($langs->trans("Enabled"),'switch_on'); print img_picto($langs->trans("Enabled"),'switch_on');
print '</a>'; print '</a>';
print "</td>"; print "</td>";
} }
else else
@ -371,7 +371,7 @@ foreach ($dirmodels as $reldir)
$htmltooltip.='<br><br><u>'.$langs->trans("FeaturesSupported").':</u>'; $htmltooltip.='<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
$htmltooltip.='<br>'.$langs->trans("Logo").': '.yn($module->option_logo,1,1); $htmltooltip.='<br>'.$langs->trans("Logo").': '.yn($module->option_logo,1,1);
print '<td align="center">'; print '<td align="center">';
$link='<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&amp;module='.$name.'">'.img_object($langs->trans("Preview"),'order').'</a>'; $link='<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&amp;module='.$name.'">'.img_object($langs->trans("Preview"),'project').'</a>';
print $form->textwithpicto(' &nbsp; &nbsp; '.$link,$htmltooltip,-1,0); print $form->textwithpicto(' &nbsp; &nbsp; '.$link,$htmltooltip,-1,0);
print '</td>'; print '</td>';

View File

@ -165,6 +165,24 @@ abstract class CommonDocGenerator
); );
} }
/**
* Rect pdf
*
* @param unknown_type $pdf
* @param unknown_type $x
* @param unknown_type $y
* @param unknown_type $l
* @param unknown_type $h
* @param int $hidetop Hide top
* @param int $hidebottom Hide bottom
*/
function printRect($pdf, $x, $y, $l, $h, $hidetop=0, $hidebottom=0)
{
if (empty($hidetop)) $pdf->line($x, $y, $x+$l, $y);
$pdf->line($x+$l, $y, $x+$l, $y+$h);
if (empty($hidebottom)) $pdf->line($x+$l, $y+$h, $x, $y+$h);
$pdf->line($x, $y+$h, $x, $y);
}
} }
?> ?>

View File

@ -524,12 +524,12 @@ function pdf_bank(&$pdf,$outputlangs,$curx,$cury,$account,$onlynumber=0,$default
* @param Translate $outputlangs Object lang for output * @param Translate $outputlangs Object lang for output
* @param string $paramfreetext Constant name of free text * @param string $paramfreetext Constant name of free text
* @param Societe $fromcompany Object company * @param Societe $fromcompany Object company
* @param int $marge_basse Margin bottom * @param int $marge_basse Margin bottom we use for the autobreak
* @param int $marge_gauche Margin left * @param int $marge_gauche Margin left (no more used)
* @param int $page_hauteur Page height * @param int $page_hauteur Page height (no more used)
* @param Object $object Object shown in PDF * @param Object $object Object shown in PDF
* @param int $showdetails Show company details * @param int $showdetails Show company details into footer. This param seems to not be used by standard version.
* @return void * @return int Return height of bottom margin including footer text
*/ */
function pdf_pagefoot(&$pdf,$outputlangs,$paramfreetext,$fromcompany,$marge_basse,$marge_gauche,$page_hauteur,$object,$showdetails=0) function pdf_pagefoot(&$pdf,$outputlangs,$paramfreetext,$fromcompany,$marge_basse,$marge_gauche,$page_hauteur,$object,$showdetails=0)
{ {
@ -538,6 +538,8 @@ function pdf_pagefoot(&$pdf,$outputlangs,$paramfreetext,$fromcompany,$marge_bass
$outputlangs->load("dict"); $outputlangs->load("dict");
$line=''; $line='';
$dims=$pdf->getPageDimensions();
// Line of free text // Line of free text
if (! empty($conf->global->$paramfreetext)) if (! empty($conf->global->$paramfreetext))
{ {
@ -659,11 +661,12 @@ function pdf_pagefoot(&$pdf,$outputlangs,$paramfreetext,$fromcompany,$marge_bass
$nbofline=dol_nboflines_bis($line,0,$outputlangs->charset_output); $nbofline=dol_nboflines_bis($line,0,$outputlangs->charset_output);
//print 'nbofline='.$nbofline; exit; //print 'nbofline='.$nbofline; exit;
//print 'e'.$line.'t'.dol_nboflines($line);exit; //print 'e'.$line.'t'.dol_nboflines($line);exit;
$posy=$marge_basse + ($nbofline*3) + (! empty($line1)?3:0) + (! empty($line2)?3:0) + (! empty($line3)?3:0) + (! empty($line4)?3:0); $marginwithfooter=$marge_basse + ($nbofline*3) + (! empty($line1)?3:0) + (! empty($line2)?3:0) + (! empty($line3)?3:0) + (! empty($line4)?3:0);
$posy=$marginwithfooter+0;
if ($line) // Free text if ($line) // Free text
{ {
$pdf->SetXY($marge_gauche,-$posy); $pdf->SetXY($dims['lm'],-$posy);
$width=20000; $align='L'; // By default, ask a manual break: We use a large value 20000, to not have automatic wrap. This make user understand, he need to add CR on its text. $width=20000; $align='L'; // By default, ask a manual break: We use a large value 20000, to not have automatic wrap. This make user understand, he need to add CR on its text.
if ($conf->global->MAIN_USE_AUTOWRAP_ON_FREETEXT) { $width=200; $align='C'; } if ($conf->global->MAIN_USE_AUTOWRAP_ON_FREETEXT) { $width=200; $align='C'; }
$pdf->MultiCell($width, 3, $line, 0, $align, 0); $pdf->MultiCell($width, 3, $line, 0, $align, 0);
@ -671,13 +674,13 @@ function pdf_pagefoot(&$pdf,$outputlangs,$paramfreetext,$fromcompany,$marge_bass
} }
$pdf->SetY(-$posy); $pdf->SetY(-$posy);
$pdf->line($marge_gauche, $page_hauteur-$posy, 200, $page_hauteur-$posy); $pdf->line($dims['lm'], $dims['hk']-$posy, $dims['wk']-$dims['rm'], $dims['hk']-$posy);
$posy--; $posy--;
if (! empty($line1)) if (! empty($line1))
{ {
$pdf->SetFont('','B',7); $pdf->SetFont('','B',7);
$pdf->SetXY($marge_gauche,-$posy); $pdf->SetXY($dims['lm'],-$posy);
$pdf->MultiCell(200, 2, $line1, 0, 'C', 0); $pdf->MultiCell(200, 2, $line1, 0, 'C', 0);
$posy-=3; $posy-=3;
$pdf->SetFont('','',7); $pdf->SetFont('','',7);
@ -686,7 +689,7 @@ function pdf_pagefoot(&$pdf,$outputlangs,$paramfreetext,$fromcompany,$marge_bass
if (! empty($line2)) if (! empty($line2))
{ {
$pdf->SetFont('','B',7); $pdf->SetFont('','B',7);
$pdf->SetXY($marge_gauche,-$posy); $pdf->SetXY($dims['lm'],-$posy);
$pdf->MultiCell(200, 2, $line2, 0, 'C', 0); $pdf->MultiCell(200, 2, $line2, 0, 'C', 0);
$posy-=3; $posy-=3;
$pdf->SetFont('','',7); $pdf->SetFont('','',7);
@ -694,14 +697,14 @@ function pdf_pagefoot(&$pdf,$outputlangs,$paramfreetext,$fromcompany,$marge_bass
if (! empty($line3)) if (! empty($line3))
{ {
$pdf->SetXY($marge_gauche,-$posy); $pdf->SetXY($dims['lm'],-$posy);
$pdf->MultiCell(200, 2, $line3, 0, 'C', 0); $pdf->MultiCell(200, 2, $line3, 0, 'C', 0);
} }
if (! empty($line4)) if (! empty($line4))
{ {
$posy-=3; $posy-=3;
$pdf->SetXY($marge_gauche,-$posy); $pdf->SetXY($dims['lm'],-$posy);
$pdf->MultiCell(200, 2, $line4, 0, 'C', 0); $pdf->MultiCell(200, 2, $line4, 0, 'C', 0);
} }
@ -712,6 +715,8 @@ function pdf_pagefoot(&$pdf,$outputlangs,$paramfreetext,$fromcompany,$marge_bass
$pdf->MultiCell(11, 2, $pdf->PageNo().'/'.$pdf->getAliasNbPages(), 0, 'R', 0); $pdf->MultiCell(11, 2, $pdf->PageNo().'/'.$pdf->getAliasNbPages(), 0, 'R', 0);
//print 'xxx'.$pdf->getAliasNbPages().'-'.$pdf->getAliasNumPage();exit; //print 'xxx'.$pdf->getAliasNbPages().'-'.$pdf->getAliasNumPage();exit;
} }
return $marginwithfooter;
} }
/** /**

View File

@ -112,6 +112,9 @@ class CommActionRapport
if (file_exists($dir)) if (file_exists($dir))
{ {
$pdf=pdf_getInstance($this->format); $pdf=pdf_getInstance($this->format);
$heightforinfotot = 80; // Height reserved to output the info and total part (value include bottom margin)
$heightforfooter = 25; // Height reserved to output the footer (value include bottom margin)
$pdf->SetAutoPageBreak(1,0);
if (class_exists('TCPDF')) if (class_exists('TCPDF'))
{ {
@ -132,7 +135,6 @@ class CommActionRapport
$pdf->SetKeywords($outputlangs->convToOutputCharset($this->title." ".$this->subject)); $pdf->SetKeywords($outputlangs->convToOutputCharset($this->title." ".$this->subject));
$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
$pdf->SetAutoPageBreak(1,0);
$nbpage = $this->_pages($pdf, $outputlangs); $nbpage = $this->_pages($pdf, $outputlangs);

View File

@ -117,6 +117,9 @@ class BordereauChequeBlochet extends ModeleChequeReceipts
// Create PDF instance // Create PDF instance
$pdf=pdf_getInstance($this->format); $pdf=pdf_getInstance($this->format);
$heightforinfotot = 80; // Height reserved to output the info and total part (value include bottom margin)
$heightforfooter = 25; // Height reserved to output the footer (value include bottom margin)
$pdf->SetAutoPageBreak(1,0);
if (class_exists('TCPDF')) if (class_exists('TCPDF'))
{ {
@ -137,7 +140,6 @@ class BordereauChequeBlochet extends ModeleChequeReceipts
if ($conf->global->MAIN_DISABLE_PDF_COMPRESSION) $pdf->SetCompression(false); if ($conf->global->MAIN_DISABLE_PDF_COMPRESSION) $pdf->SetCompression(false);
$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
$pdf->SetAutoPageBreak(1,0);
$nboflines=count($this->lines); $nboflines=count($this->lines);
// Define nb of page // Define nb of page

View File

@ -141,6 +141,9 @@ class pdf_edison extends ModelePDFCommandes
$nblignes = count($object->lines); $nblignes = count($object->lines);
$pdf=pdf_getInstance($this->format); $pdf=pdf_getInstance($this->format);
$heightforinfotot = 80; // Height reserved to output the info and total part (value include bottom margin)
$heightforfooter = 25; // Height reserved to output the footer (value include bottom margin)
$pdf->SetAutoPageBreak(1,0);
if (class_exists('TCPDF')) if (class_exists('TCPDF'))
{ {
@ -167,7 +170,6 @@ class pdf_edison extends ModelePDFCommandes
if ($conf->global->MAIN_DISABLE_PDF_COMPRESSION) $pdf->SetCompression(false); if ($conf->global->MAIN_DISABLE_PDF_COMPRESSION) $pdf->SetCompression(false);
$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
$pdf->SetAutoPageBreak(1,0);
// New page // New page
$pdf->AddPage(); $pdf->AddPage();
@ -200,9 +202,16 @@ class pdf_edison extends ModelePDFCommandes
$pdf->SetFont('','', $default_font_size - 1); // Dans boucle pour gerer multi-page $pdf->SetFont('','', $default_font_size - 1); // Dans boucle pour gerer multi-page
$pdf->setPageOrientation('', 1, $this->marge_basse+$heightforfooter+$heightforinfotot); // The only function to edit the bottom margin of current page to set it.
$pageposbefore=$pdf->getPage();
// Description of product line // Description of product line
pdf_writelinedesc($pdf,$object,$i,$outputlangs,100,3,30,$curY,1,$hidedesc,0,$hookmanager); pdf_writelinedesc($pdf,$object,$i,$outputlangs,100,3,30,$curY,1,$hidedesc,0,$hookmanager);
$pageposafter=$pdf->getPage();
$pdf->setPage($pageposbefore);
$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
$pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut
$nexY = $pdf->GetY(); $nexY = $pdf->GetY();
@ -228,39 +237,51 @@ class pdf_edison extends ModelePDFCommandes
$nexY+=2; // Passe espace entre les lignes $nexY+=2; // Passe espace entre les lignes
// cherche nombre de lignes a venir pour savoir si place suffisante // Detect if some page were added automatically and output _tableau for past pages
if ($i < ($nblignes - 1) && empty($hidedesc)) // If it's not last line while ($pagenb < $pageposafter)
{ {
//on recupere la description du produit suivant if ($pagenb == 1)
$follow_descproduitservice = $object->lines[$i+1]->desc; {
//on compte le nombre de ligne afin de verifier la place disponible (largeur de ligne 52 caracteres) $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
$nblineFollowDesc = (dol_nboflines_bis($follow_descproduitservice,52,$outputlangs->charset_output)*4); }
else
{
$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
}
$this->_pagefoot($pdf,$object,$outputlangs);
$pagenb++;
$pdf->setPage($pagenb);
$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
} }
else // If it's last line if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
{ {
$nblineFollowDesc = 0; if ($pagenb == 1)
} {
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
if ((($nexY+$nblineFollowDesc) > ($tab_top+$tab_height) && $i < ($nblignes - 1)) || (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)) }
{ else
$this->_tableau($pdf, $tab_top, $tab_height, $nexY, $outputlangs); {
$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
}
$this->_pagefoot($pdf,$object,$outputlangs);
// New page // New page
$pdf->AddPage(); $pdf->AddPage();
if (! empty($tplidx)) $pdf->useTemplate($tplidx); if (! empty($tplidx)) $pdf->useTemplate($tplidx);
$pagenb++; $pagenb++;
$this->_pagehead($pdf, $object, 0, $outputlangs, $hookmanager);
$pdf->SetFont('','', $default_font_size - 1);
$pdf->MultiCell(0, 3, ''); // Set interline to 3
$pdf->SetTextColor(0,0,0);
$nexY = $tab_top + 8;
} }
} }
$this->_tableau($pdf, $tab_top, $tab_height, $nexY, $outputlangs); // Show square
if ($pagenb == 1)
$bottomlasttab=$tab_top + $tab_height + 1; {
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot, 0, $outputlangs, 0, 0);
$bottomlasttab=$this->page_hauteur - $heightforinfotot + 1;
}
else
{
$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot, 0, $outputlangs, 1, 0);
$bottomlasttab=$this->page_hauteur - $heightforinfotot + 1;
}
// Affiche zone infos // Affiche zone infos
$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs); $this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
@ -467,9 +488,11 @@ class pdf_edison extends ModelePDFCommandes
* @param string $tab_height Height of table (rectangle) * @param string $tab_height Height of table (rectangle)
* @param int $nexY Y * @param int $nexY Y
* @param Translate $outputlangs Langs object * @param Translate $outputlangs Langs object
* @param int $hidetop Hide top bar of array
* @param int $hidebottom Hide bottom bar of array
* @return void * @return void
*/ */
function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs) function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
{ {
global $langs,$conf; global $langs,$conf;
$langs->load("main"); $langs->load("main");

View File

@ -177,6 +177,9 @@ class pdf_einstein extends ModelePDFCommandes
$nblignes = count($object->lines); $nblignes = count($object->lines);
$pdf=pdf_getInstance($this->format); $pdf=pdf_getInstance($this->format);
$heightforinfotot = 80; // Height reserved to output the info and total part (value include bottom margin)
$heightforfooter = 25; // Height reserved to output the footer (value include bottom margin)
$pdf->SetAutoPageBreak(1,0);
if (class_exists('TCPDF')) if (class_exists('TCPDF'))
{ {
@ -203,7 +206,6 @@ class pdf_einstein extends ModelePDFCommandes
if ($conf->global->MAIN_DISABLE_PDF_COMPRESSION) $pdf->SetCompression(false); if ($conf->global->MAIN_DISABLE_PDF_COMPRESSION) $pdf->SetCompression(false);
$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
$pdf->SetAutoPageBreak(1,0);
// Positionne $this->atleastonediscount si on a au moins une remise // Positionne $this->atleastonediscount si on a au moins une remise
for ($i = 0 ; $i < $nblignes ; $i++) for ($i = 0 ; $i < $nblignes ; $i++)
@ -262,10 +264,17 @@ class pdf_einstein extends ModelePDFCommandes
$pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage
$pdf->setPageOrientation('', 1, $this->marge_basse+$heightforfooter+$heightforinfotot); // The only function to edit the bottom margin of current page to set it.
$pageposbefore=$pdf->getPage();
// Description of product line // Description of product line
$curX = $this->posxdesc-1; $curX = $this->posxdesc-1;
pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,$hideref,$hidedesc,0,$hookmanager); pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,$hideref,$hidedesc,0,$hookmanager);
$pageposafter=$pdf->getPage();
$pdf->setPage($pageposbefore);
$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
$pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut
$nexY = $pdf->GetY(); $nexY = $pdf->GetY();
@ -321,71 +330,50 @@ class pdf_einstein extends ModelePDFCommandes
$nexY+=2; // Passe espace entre les lignes $nexY+=2; // Passe espace entre les lignes
// Cherche nombre de lignes a venir pour savoir si place suffisante // Detect if some page were added automatically and output _tableau for past pages
if ($i < ($nblignes - 1) && empty($hidedesc)) // If it's not last line while ($pagenb < $pageposafter)
{
//on recupere la description du produit suivant
$follow_descproduitservice = $object->lines[$i+1]->desc;
//on compte le nombre de ligne afin de verifier la place disponible (largeur de ligne 52 caracteres)
$nblineFollowDesc = (dol_nboflines_bis($follow_descproduitservice,52,$outputlangs->charset_output)*4);
// Et si on affiche dates de validite, on ajoute encore une ligne
if ($object->lines[$i]->date_start && $object->lines[$i]->date_end)
{
$nblineFollowDesc += 4;
}
}
else // If it's last line
{
$nblineFollowDesc = 0;
}
// Test if a new page is required
if ($pagenb == 1)
{
$tab_top_in_current_page=$tab_top;
$tab_height_in_current_page=$tab_height;
}
else
{
$tab_top_in_current_page=$tab_top_newpage;
$tab_height_in_current_page=$tab_height_newpage;
}
if ((($nexY+$nblineFollowDesc) > ($tab_top_in_current_page+$tab_height_in_current_page) && $i < ($nblignes - 1)) || (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak))
{ {
if ($pagenb == 1) if ($pagenb == 1)
{ {
$this->_tableau($pdf, $tab_top, $tab_height + 20, $nexY, $outputlangs); $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
} }
else else
{ {
$this->_tableau($pdf, $tab_top_newpage, $tab_height_newpage, $nexY, $outputlangs); $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
}
$this->_pagefoot($pdf,$object,$outputlangs);
$pagenb++;
$pdf->setPage($pagenb);
$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
}
if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
{
if ($pagenb == 1)
{
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
}
else
{
$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
} }
$this->_pagefoot($pdf,$object,$outputlangs); $this->_pagefoot($pdf,$object,$outputlangs);
// New page // New page
$pdf->AddPage(); $pdf->AddPage();
if (! empty($tplidx)) $pdf->useTemplate($tplidx); if (! empty($tplidx)) $pdf->useTemplate($tplidx);
$pagenb++; $pagenb++;
$this->_pagehead($pdf, $object, 0, $outputlangs, $hookmanager);
$pdf->SetFont('','', $default_font_size - 1);
$pdf->MultiCell(0, 3, ''); // Set interline to 3
$pdf->SetTextColor(0,0,0);
$nexY = $tab_top_newpage + 7;
} }
} }
// Show square // Show square
if ($pagenb == 1) if ($pagenb == 1)
{ {
$this->_tableau($pdf, $tab_top, $tab_height, $nexY, $outputlangs); $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot, 0, $outputlangs, 0, 0);
$bottomlasttab=$tab_top + $tab_height + 1; $bottomlasttab=$this->page_hauteur - $heightforinfotot + 1;
} }
else else
{ {
$this->_tableau($pdf, $tab_top_newpage, $tab_height_newpage, $nexY, $outputlangs); $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot, 0, $outputlangs, 1, 0);
$bottomlasttab=$tab_top_newpage + $tab_height_newpage + 1; $bottomlasttab=$this->page_hauteur - $heightforinfotot + 1;
} }
// Affiche zone infos // Affiche zone infos
@ -797,9 +785,11 @@ class pdf_einstein extends ModelePDFCommandes
* @param string $tab_height Height of table (rectangle) * @param string $tab_height Height of table (rectangle)
* @param int $nexY Y * @param int $nexY Y
* @param Translate $outputlangs Langs object * @param Translate $outputlangs Langs object
* @param int $hidetop Hide top bar of array
* @param int $hidebottom Hide bottom bar of array
* @return void * @return void
*/ */
function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs) function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
{ {
global $conf; global $conf;

View File

@ -147,6 +147,9 @@ class pdf_expedition_merou extends ModelePdfExpedition
if (file_exists($dir)) if (file_exists($dir))
{ {
$pdf=pdf_getInstance($this->format,'mm','l'); $pdf=pdf_getInstance($this->format,'mm','l');
$heightforinfotot = 80; // Height reserved to output the info and total part (value include bottom margin)
$heightforfooter = 25; // Height reserved to output the footer (value include bottom margin)
$pdf->SetAutoPageBreak(1,0);
if (class_exists('TCPDF')) if (class_exists('TCPDF'))
{ {
@ -174,7 +177,6 @@ class pdf_expedition_merou extends ModelePdfExpedition
if ($conf->global->MAIN_DISABLE_PDF_COMPRESSION) $pdf->SetCompression(false); if ($conf->global->MAIN_DISABLE_PDF_COMPRESSION) $pdf->SetCompression(false);
$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
$pdf->SetAutoPageBreak(1,0);
$pdf->SetFont('','', $default_font_size - 3); $pdf->SetFont('','', $default_font_size - 3);
@ -284,9 +286,11 @@ class pdf_expedition_merou extends ModelePdfExpedition
* @param string $tab_height Height of table (rectangle) * @param string $tab_height Height of table (rectangle)
* @param int $nexY Y * @param int $nexY Y
* @param Translate $outputlangs Langs object * @param Translate $outputlangs Langs object
* @param int $hidetop Hide top bar of array
* @param int $hidebottom Hide bottom bar of array
* @return void * @return void
*/ */
function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs) function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
{ {
global $langs; global $langs;
$default_font_size = pdf_getPDFFontSize($outputlangs); $default_font_size = pdf_getPDFFontSize($outputlangs);

View File

@ -126,6 +126,9 @@ class pdf_expedition_rouget extends ModelePdfExpedition
if (file_exists($dir)) if (file_exists($dir))
{ {
$pdf=pdf_getInstance($this->format); $pdf=pdf_getInstance($this->format);
$heightforinfotot = 80; // Height reserved to output the info and total part (value include bottom margin)
$heightforfooter = 25; // Height reserved to output the footer (value include bottom margin)
$pdf->SetAutoPageBreak(1,0);
if (class_exists('TCPDF')) if (class_exists('TCPDF'))
{ {
@ -154,7 +157,6 @@ class pdf_expedition_rouget extends ModelePdfExpedition
if ($conf->global->MAIN_DISABLE_PDF_COMPRESSION) $pdf->SetCompression(false); if ($conf->global->MAIN_DISABLE_PDF_COMPRESSION) $pdf->SetCompression(false);
$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
$pdf->SetAutoPageBreak(1,0);
// New page // New page
$pdf->AddPage(); $pdf->AddPage();
@ -223,9 +225,16 @@ class pdf_expedition_rouget extends ModelePdfExpedition
$pdf->SetFont('','', $default_font_size - 1); // Dans boucle pour gerer multi-page $pdf->SetFont('','', $default_font_size - 1); // Dans boucle pour gerer multi-page
$pdf->setPageOrientation('', 1, $this->marge_basse+$heightforfooter+$heightforinfotot); // The only function to edit the bottom margin of current page to set it.
$pageposbefore=$pdf->getPage();
// Description de la ligne produit // Description de la ligne produit
pdf_writelinedesc($pdf,$object,$i,$outputlangs,150,3,$this->posxdesc,$curY,0,1); pdf_writelinedesc($pdf,$object,$i,$outputlangs,150,3,$this->posxdesc,$curY,0,1);
$pageposafter=$pdf->getPage();
$pdf->setPage($pageposbefore);
$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
$pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut
$nexY = $pdf->GetY(); $nexY = $pdf->GetY();
@ -274,9 +283,11 @@ class pdf_expedition_rouget extends ModelePdfExpedition
* @param string $tab_height Height of table (rectangle) * @param string $tab_height Height of table (rectangle)
* @param int $nexY Y * @param int $nexY Y
* @param Translate $outputlangs Langs object * @param Translate $outputlangs Langs object
* @param int $hidetop Hide top bar of array
* @param int $hidebottom Hide bottom bar of array
* @return void * @return void
*/ */
function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs) function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
{ {
global $conf; global $conf;
@ -385,7 +396,7 @@ class pdf_expedition_rouget extends ModelePdfExpedition
} }
$posx=100; $posx=$this->page_largeur - 100 - $this->marge_droite;
$posy=$this->marge_haute; $posy=$this->marge_haute;
$pdf->SetFont('','B', $default_font_size + 2); $pdf->SetFont('','B', $default_font_size + 2);
@ -467,7 +478,7 @@ class pdf_expedition_rouget extends ModelePdfExpedition
$posx=$this->marge_gauche; $posx=$this->marge_gauche;
$posy=42; $posy=42;
$hautcadre=40; $hautcadre=40;
if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=118; if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur - 80 - $this->marge_droite;
// Show sender frame // Show sender frame
$pdf->SetTextColor(0,0,0); $pdf->SetTextColor(0,0,0);
@ -516,7 +527,7 @@ class pdf_expedition_rouget extends ModelePdfExpedition
// Show recipient // Show recipient
$posy=42; $posy=42;
$posx=100; $posx=$this->page_largeur - 100 - $this->marge_droite;
if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche; if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
// Show recipient frame // Show recipient frame

View File

@ -178,6 +178,9 @@ class pdf_crabe extends ModelePDFFactures
$nblignes = count($object->lines); $nblignes = count($object->lines);
$pdf=pdf_getInstance($this->format); $pdf=pdf_getInstance($this->format);
$heightforinfotot = 80; // Height reserved to output the info and total part (value include bottom margin)
$heightforfooter = 25; // Height reserved to output the footer (value include bottom margin)
$pdf->SetAutoPageBreak(1,0);
if (class_exists('TCPDF')) if (class_exists('TCPDF'))
{ {
@ -204,7 +207,6 @@ class pdf_crabe extends ModelePDFFactures
if ($conf->global->MAIN_DISABLE_PDF_COMPRESSION) $pdf->SetCompression(false); if ($conf->global->MAIN_DISABLE_PDF_COMPRESSION) $pdf->SetCompression(false);
$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
$pdf->SetAutoPageBreak(1,0);
// Positionne $this->atleastonediscount si on a au moins une remise // Positionne $this->atleastonediscount si on a au moins une remise
for ($i = 0 ; $i < $nblignes ; $i++) for ($i = 0 ; $i < $nblignes ; $i++)
@ -225,7 +227,7 @@ class pdf_crabe extends ModelePDFFactures
$pdf->SetTextColor(0,0,0); $pdf->SetTextColor(0,0,0);
$tab_top = 90; $tab_top = 90;
$tab_top_newpage = 50; $tab_top_newpage = 10;
$tab_height = 130; $tab_height = 130;
$tab_height_newpage = 150; $tab_height_newpage = 150;
@ -262,8 +264,9 @@ class pdf_crabe extends ModelePDFFactures
{ {
$curY = $nexY; $curY = $nexY;
$pdf->setPageOrientation('', 1, $this->marge_basse+$heightforfooter+$heightforinfotot); // The only function to edit the bottom margin of current page to set it.
$pageposbefore=$pdf->getPage(); $pageposbefore=$pdf->getPage();
// Description of product line // Description of product line
$pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage
$curX = $this->posxdesc-1; $curX = $this->posxdesc-1;
@ -271,7 +274,8 @@ class pdf_crabe extends ModelePDFFactures
$pageposafter=$pdf->getPage(); $pageposafter=$pdf->getPage();
$pdf->setPage($pageposbefore); $pdf->setPage($pageposbefore);
$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
$pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut
$nexY = $pdf->GetY(); $nexY = $pdf->GetY();
@ -332,84 +336,47 @@ class pdf_crabe extends ModelePDFFactures
// Detect if some page were added automatically and output _tableau for past pages // Detect if some page were added automatically and output _tableau for past pages
while ($pagenb < $pageposafter) while ($pagenb < $pageposafter)
{ {
if ($pagenb == 1) if ($pagenb == 1)
{ {
$this->_tableau($pdf, $tab_top, $tab_height + 40, 0, $outputlangs); $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
} }
else else
{ {
$this->_tableau($pdf, $tab_top_newpage, $tab_height_newpage, 0, $outputlangs); $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
} }
$this->_pagefoot($pdf,$object,$outputlangs);
$pagenb++; $pagenb++;
$pdf->setPage($pagenb); $pdf->setPage($pagenb);
$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
} }
if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
// Cherche nombre de lignes a venir pour savoir si place suffisante
if ($i < ($nblignes - 1) && empty($hidedesc)) // If it's not last line
{ {
//on recupere la description du produit suivant if ($pagenb == 1)
$follow_descproduitservice = $object->lines[$i+1]->desc; {
//on compte le nombre de ligne afin de verifier la place disponible (largeur de ligne 52 caracteres) $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
$nblineFollowDesc = dol_nboflines_bis($follow_descproduitservice,52,$outputlangs->charset_output)*4; }
// Et si on affiche dates de validite, on ajoute encore une ligne else
if ($object->lines[$i]->date_start && $object->lines[$i]->date_end) {
{ $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
$nblineFollowDesc += 4;
} }
$this->_pagefoot($pdf,$object,$outputlangs);
// New page
$pdf->AddPage();
if (! empty($tplidx)) $pdf->useTemplate($tplidx);
$pagenb++;
} }
else // If it's last line
{
$nblineFollowDesc = 0;
}
// Test if a new page is required
if ($pagenb == 1)
{
$tab_top_in_current_page=$tab_top;
$tab_height_in_current_page=$tab_height;
}
else
{
$tab_top_in_current_page=$tab_top_newpage;
$tab_height_in_current_page=$tab_height_newpage;
}
if ((($nexY+$nblineFollowDesc) > ($tab_top_in_current_page+$tab_height_in_current_page) && $i < ($nblignes - 1)) || (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak))
{
if ($pagenb == 1)
{
$this->_tableau($pdf, $tab_top, $tab_height + 40, $nexY, $outputlangs);
}
else
{
$this->_tableau($pdf, $tab_top_newpage, $tab_height_newpage, $nexY, $outputlangs);
}
$this->_pagefoot($pdf,$object,$outputlangs);
// New page
$pdf->AddPage();
if (! empty($tplidx)) $pdf->useTemplate($tplidx);
$pagenb++;
$this->_pagehead($pdf, $object, 0, $outputlangs, $hookmanager);
$pdf->SetFont('','', $default_font_size - 1);
$pdf->MultiCell(0, 3, ''); // Set interline to 3
$pdf->SetTextColor(0,0,0);
$nexY = $tab_top_newpage + 7;
}
} }
// Show square // Show square
if ($pagenb == 1) if ($pagenb == 1)
{ {
$this->_tableau($pdf, $tab_top, $tab_height, $nexY, $outputlangs); $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot, 0, $outputlangs, 0, 0);
$bottomlasttab=$tab_top + $tab_height + 1; $bottomlasttab=$this->page_hauteur - $heightforinfotot + 1;
} }
else else
{ {
$this->_tableau($pdf, $tab_top_newpage, $tab_height_newpage, $nexY, $outputlangs); $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot, 0, $outputlangs, 1, 0);
$bottomlasttab=$tab_top_newpage + $tab_height_newpage + 1; $bottomlasttab=$this->page_hauteur - $heightforinfotot + 1;
} }
// Affiche zone infos // Affiche zone infos
@ -960,11 +927,13 @@ class pdf_crabe extends ModelePDFFactures
* @param PDF &$pdf Object PDF * @param PDF &$pdf Object PDF
* @param string $tab_top Top position of table * @param string $tab_top Top position of table
* @param string $tab_height Height of table (rectangle) * @param string $tab_height Height of table (rectangle)
* @param int $nexY Y * @param int $nexY Y (not used)
* @param Translate $outputlangs Langs object * @param Translate $outputlangs Langs object
* @param int $hidetop Hide top bar of array
* @param int $hidebottom Hide bottom bar of array
* @return void * @return void
*/ */
function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs) function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
{ {
global $conf; global $conf;
@ -973,51 +942,70 @@ class pdf_crabe extends ModelePDFFactures
// Amount in (at tab_top - 1) // Amount in (at tab_top - 1)
$pdf->SetTextColor(0,0,0); $pdf->SetTextColor(0,0,0);
$pdf->SetFont('','', $default_font_size - 2); $pdf->SetFont('','', $default_font_size - 2);
$titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$conf->currency));
$pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4); if (empty($hidetop))
$pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); {
$titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$conf->currency));
$pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4);
$pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
}
$pdf->SetDrawColor(128,128,128); $pdf->SetDrawColor(128,128,128);
$pdf->SetFont('','', $default_font_size - 1);
// Rect prend une longueur en 3eme param et 4eme param // Output Rect
$pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height); $this->printRect($pdf,$this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect prend une longueur en 3eme param et 4eme param
// line prend une position y en 2eme param et 4eme param
$pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5);
$pdf->SetFont('','', $default_font_size - 1); if (empty($hidetop))
{
$pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); // line prend une position y en 2eme param et 4eme param
$pdf->SetXY($this->posxdesc-1, $tab_top+1); $pdf->SetXY($this->posxdesc-1, $tab_top+1);
$pdf->MultiCell(108,2, $outputlangs->transnoentities("Designation"),'','L'); $pdf->MultiCell(108,2, $outputlangs->transnoentities("Designation"),'','L');
}
if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
{ {
$pdf->line($this->posxtva-1, $tab_top, $this->posxtva-1, $tab_top + $tab_height); $pdf->line($this->posxtva-1, $tab_top, $this->posxtva-1, $tab_top + $tab_height);
$pdf->SetXY($this->posxtva-3, $tab_top+1); if (empty($hidetop))
$pdf->MultiCell($this->posxup-$this->posxtva+3,2, $outputlangs->transnoentities("VAT"),'','C'); {
$pdf->SetXY($this->posxtva-3, $tab_top+1);
$pdf->MultiCell($this->posxup-$this->posxtva+3,2, $outputlangs->transnoentities("VAT"),'','C');
}
} }
$pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height); $pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height);
$pdf->SetXY($this->posxup-1, $tab_top+1); if (empty($hidetop))
$pdf->MultiCell($this->posxqty-$this->posxup-1,2, $outputlangs->transnoentities("PriceUHT"),'','C');
$pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height);
$pdf->SetXY($this->posxqty-1, $tab_top+1);
$pdf->MultiCell($this->posxdiscount-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
$pdf->line($this->posxdiscount-1, $tab_top, $this->posxdiscount-1, $tab_top + $tab_height);
if ($this->atleastonediscount)
{ {
$pdf->SetXY($this->posxdiscount-1, $tab_top+1); $pdf->SetXY($this->posxup-1, $tab_top+1);
$pdf->MultiCell($this->postotalht-$this->posxdiscount+1,2, $outputlangs->transnoentities("ReductionShort"),'','C'); $pdf->MultiCell($this->posxqty-$this->posxup-1,2, $outputlangs->transnoentities("PriceUHT"),'','C');
} }
$pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height);
if (empty($hidetop))
{
$pdf->SetXY($this->posxqty-1, $tab_top+1);
$pdf->MultiCell($this->posxdiscount-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
}
$pdf->line($this->posxdiscount-1, $tab_top, $this->posxdiscount-1, $tab_top + $tab_height);
if (empty($hidetop))
{
if ($this->atleastonediscount)
{
$pdf->SetXY($this->posxdiscount-1, $tab_top+1);
$pdf->MultiCell($this->postotalht-$this->posxdiscount+1,2, $outputlangs->transnoentities("ReductionShort"),'','C');
}
}
if ($this->atleastonediscount) if ($this->atleastonediscount)
{ {
$pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height); $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
} }
$pdf->SetXY($this->postotalht-1, $tab_top+1); if (empty($hidetop))
$pdf->MultiCell(30,2, $outputlangs->transnoentities("TotalHT"),'','C'); {
$pdf->SetXY($this->postotalht-1, $tab_top+1);
$pdf->MultiCell(30,2, $outputlangs->transnoentities("TotalHT"),'','C');
}
} }
/** /**
@ -1244,7 +1232,7 @@ class pdf_crabe extends ModelePDFFactures
* @param PDF &$pdf PDF * @param PDF &$pdf PDF
* @param Object $object Object to show * @param Object $object Object to show
* @param Translate $outputlangs Object lang for output * @param Translate $outputlangs Object lang for output
* @return void * @return int Return height of bottom margin including footer text
*/ */
function _pagefoot(&$pdf,$object,$outputlangs) function _pagefoot(&$pdf,$object,$outputlangs)
{ {

View File

@ -166,6 +166,9 @@ class pdf_oursin extends ModelePDFFactures
if (file_exists($dir)) if (file_exists($dir))
{ {
$pdf=pdf_getInstance($this->format); $pdf=pdf_getInstance($this->format);
$heightforinfotot = 80; // Height reserved to output the info and total part (value include bottom margin)
$heightforfooter = 25; // Height reserved to output the footer (value include bottom margin)
$pdf->SetAutoPageBreak(1,0);
if (class_exists('TCPDF')) if (class_exists('TCPDF'))
{ {
@ -191,8 +194,16 @@ class pdf_oursin extends ModelePDFFactures
$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Invoice")); $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Invoice"));
if ($conf->global->MAIN_DISABLE_PDF_COMPRESSION) $pdf->SetCompression(false); if ($conf->global->MAIN_DISABLE_PDF_COMPRESSION) $pdf->SetCompression(false);
$pdf->SetMargins(10, 10, 10); $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
$pdf->SetAutoPageBreak(1,0);
// Positionne $this->atleastonediscount si on a au moins une remise
for ($i = 0 ; $i < $nblignes ; $i++)
{
if ($object->lines[$i]->remise_percent)
{
$this->atleastonediscount++;
}
}
// New page // New page
$pdf->AddPage(); $pdf->AddPage();
@ -204,7 +215,9 @@ class pdf_oursin extends ModelePDFFactures
$pdf->SetTextColor(0,0,0); $pdf->SetTextColor(0,0,0);
$tab_top = $this->marges['h']+90; $tab_top = $this->marges['h']+90;
$tab_top_newpage = $this->marges['h'];
$tab_height = 110; $tab_height = 110;
$tab_height_newpage = 150;
$pdf->SetFillColor(220,220,220); $pdf->SetFillColor(220,220,220);
$pdf->SetFont('','', $default_font_size - 1); $pdf->SetFont('','', $default_font_size - 1);
@ -220,20 +233,24 @@ class pdf_oursin extends ModelePDFFactures
{ {
$curY = $nexY; $curY = $nexY;
$pdf->setPageOrientation('', 1, $this->marge_basse+$heightforfooter+$heightforinfotot); // The only function to edit the bottom margin of current page to set it.
$pageposbefore=$pdf->getPage();
// Description of product line // Description of product line
pdf_writelinedesc($pdf,$object,$i,$outputlangs,108,3,$this->posxdesc-1,$curY+1,$hideref,$hidedesc,0,$hookmanager); pdf_writelinedesc($pdf,$object,$i,$outputlangs,108,3,$this->posxdesc-1,$curY+1,$hideref,$hidedesc,0,$hookmanager);
$pageposafter=$pdf->getPage();
$pdf->setPage($pageposbefore);
$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
$nexY = $pdf->GetY(); $nexY = $pdf->GetY();
// TVA // TVA
if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
{ {
if ($this->franchise!=1) $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails, $hookmanager);
{ $pdf->SetXY($this->marges['g']+118, $curY);
$vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails, $hookmanager); $pdf->MultiCell(12, 3, $vat_rate, 0, 'R');
$pdf->SetXY($this->marges['g']+118, $curY);
$pdf->MultiCell(12, 3, $vat_rate, 0, 'R');
}
} }
// Prix unitaire HT avant remise // Prix unitaire HT avant remise
@ -258,25 +275,64 @@ class pdf_oursin extends ModelePDFFactures
$pdf->SetXY($this->marges['g']+168, $curY); $pdf->SetXY($this->marges['g']+168, $curY);
$pdf->MultiCell(21, 3, $total_excl_tax, 0, 'R', 0); $pdf->MultiCell(21, 3, $total_excl_tax, 0, 'R', 0);
// Detect if some page were added automatically and output _tableau for past pages
if (($nexY > 200 && $i < $nblignes - 1) || (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)) while ($pagenb < $pageposafter)
{ {
$this->_tableau($pdf, $tab_top, $tab_height, $nexY, $object, $outputlangs); if ($pagenb == 1)
$nexY = $iniY; {
$this->_tableau($pdf, $tab_top, $tab_height + 40, 0, $outputlangs, 0, 1);
// New page }
$pdf->AddPage(); else
if (! empty($tplidx)) $pdf->useTemplate($tplidx); {
$pagenb++; $this->_tableau($pdf, $tab_top_newpage, $tab_height_newpage, 0, $outputlangs, 1, 1);
$this->_pagehead($pdf, $object, 0, $outputlangs, $hookmanager); }
$pdf->SetFont('','', $default_font_size - 1); $this->_pagefoot($pdf,$object,$outputlangs);
$pdf->MultiCell(0, 3, ''); // Set interline to 3 $pagenb++;
$pdf->SetTextColor(0,0,0); $pdf->setPage($pagenb);
} }
/*if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
{
if ($pagenb == 1)
{
$this->_tableau($pdf, $tab_top, $tab_height + 40, 0, $outputlangs, 0, 1);
}
else
{
$this->_tableau($pdf, $tab_top_newpage, $tab_height_newpage, 0, $outputlangs, 1, 1);
}
$this->_pagefoot($pdf,$object,$outputlangs);
// New page
$pdf->AddPage();
if (! empty($tplidx)) $pdf->useTemplate($tplidx);
$pagenb++;
}*/
if (($nexY > 200 && $i < $nblignes - 1) || (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak))
{
$this->_tableau($pdf, $tab_top, $tab_height, $nexY, $object, $outputlangs);
$nexY = $iniY;
// New page
$pdf->AddPage();
if (! empty($tplidx)) $pdf->useTemplate($tplidx);
$pagenb++;
$this->_pagehead($pdf, $object, 0, $outputlangs, $hookmanager);
$pdf->SetFont('','', $default_font_size - 1);
$pdf->MultiCell(0, 3, ''); // Set interline to 3
$pdf->SetTextColor(0,0,0);
}
}
// Show square
if ($pagenb == 1)
{
$this->_tableau($pdf, $tab_top, $tab_height, $nexY, $outputlangs);
$bottomlasttab=$tab_top + $tab_height + 1;
}
else
{
$this->_tableau($pdf, $tab_top, $tab_height, $nexY, $outputlangs, 1, 0);
$bottomlasttab=$tab_top + $tab_height + 1;
} }
$posy=$this->_tableau($pdf, $tab_top, $tab_height, $nexY, $object, $outputlangs);
$bottomlasttab=$tab_top + $tab_height + 1;
// Affiche zone infos // Affiche zone infos
$posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs); $posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
@ -744,11 +800,12 @@ class pdf_oursin extends ModelePDFFactures
* @param string $tab_top Top position of table * @param string $tab_top Top position of table
* @param string $tab_height Height of table (rectangle) * @param string $tab_height Height of table (rectangle)
* @param int $nexY Y * @param int $nexY Y
* @param Object $object Object
* @param Translate $outputlangs Langs object * @param Translate $outputlangs Langs object
* @param int $hidetop Hide top bar of array
* @param int $hidebottom Hide bottom bar of array
* @return void * @return void
*/ */
function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $object, $outputlangs) function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
{ {
global $conf,$langs; global $conf,$langs;
$langs->load("main"); $langs->load("main");
@ -775,16 +832,7 @@ class pdf_oursin extends ModelePDFFactures
$pdf->SetXY($this->marges['g']+153,$tab_top + 1); $pdf->SetXY($this->marges['g']+153,$tab_top + 1);
$pdf->MultiCell(0, 4, $outputlangs->transnoentities("Qty"), 0, 'L'); $pdf->MultiCell(0, 4, $outputlangs->transnoentities("Qty"), 0, 'L');
$nblignes = count($object->lines); if ($this->atleastonediscount)
$rem=0;
for ($i = 0 ; $i < $nblignes ; $i++)
{
if ($object->lines[$i]->remise_percent)
{
$rem=1;
}
}
if ($rem==1)
{ {
$pdf->SetXY($this->marges['g']+165,$tab_top + 1); $pdf->SetXY($this->marges['g']+165,$tab_top + 1);
$pdf->MultiCell(0, 4, $outputlangs->transnoentities("%"), 0, 'L'); $pdf->MultiCell(0, 4, $outputlangs->transnoentities("%"), 0, 'L');
@ -1018,7 +1066,7 @@ class pdf_oursin extends ModelePDFFactures
* @param PDF &$pdf PDF * @param PDF &$pdf PDF
* @param Object $object Object to show * @param Object $object Object to show
* @param Translate $outputlangs Object lang for output * @param Translate $outputlangs Object lang for output
* @return void * @return int Return height of bottom margin including footer text
*/ */
function _pagefoot(&$pdf, $object, $outputlangs) function _pagefoot(&$pdf, $object, $outputlangs)
{ {

View File

@ -134,6 +134,9 @@ class pdf_soleil extends ModelePDFFicheinter
if (file_exists($dir)) if (file_exists($dir))
{ {
$pdf=pdf_getInstance($this->format); $pdf=pdf_getInstance($this->format);
$heightforinfotot = 80; // Height reserved to output the info and total part (value include bottom margin)
$heightforfooter = 25; // Height reserved to output the footer (value include bottom margin)
$pdf->SetAutoPageBreak(1,0);
if (class_exists('TCPDF')) if (class_exists('TCPDF'))
{ {
@ -160,7 +163,6 @@ class pdf_soleil extends ModelePDFFicheinter
if ($conf->global->MAIN_DISABLE_PDF_COMPRESSION) $pdf->SetCompression(false); if ($conf->global->MAIN_DISABLE_PDF_COMPRESSION) $pdf->SetCompression(false);
$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
$pdf->SetAutoPageBreak(1,0);
// New page // New page
$pdf->AddPage(); $pdf->AddPage();
@ -268,67 +270,51 @@ class pdf_soleil extends ModelePDFFicheinter
$nexY+=2; // Passe espace entre les lignes $nexY+=2; // Passe espace entre les lignes
// Cherche nombre de lignes a venir pour savoir si place suffisante // Detect if some page were added automatically and output _tableau for past pages
if ($i < ($nblines - 1) && empty($hidedesc)) // If it's not last line while ($pagenb < $pageposafter)
{ {
//on recupere la description du produit suivant if ($pagenb == 1)
$follow_descproduitservice = $objectligne->desc; {
//on compte le nombre de ligne afin de verifier la place disponible (largeur de ligne 52 caracteres) $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
$nblineFollowDesc = (dol_nboflines_bis($follow_descproduitservice,52,$outputlangs->charset_output)*3); }
} else
else // If it's last line {
{ $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
$nblineFollowDesc = 0; }
} $this->_pagefoot($pdf,$object,$outputlangs);
$pagenb++;
// Test if a new page is required $pdf->setPage($pagenb);
if ($pagenb == 1) $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
{ }
$tab_top_in_current_page=$tab_top; if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
$tab_height_in_current_page=$tab_height; {
} if ($pagenb == 1)
else {
{ $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
$tab_top_in_current_page=$tab_top_newpage; }
$tab_height_in_current_page=$tab_height_middlepage; else
} {
if (($nexY+$nblineFollowDesc) > ($tab_top_in_current_page+$tab_height_in_current_page) && $i < ($nblines - 1)) $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
{ }
if ($pagenb == 1) $this->_pagefoot($pdf,$object,$outputlangs);
{ // New page
$this->_tableau($pdf, $tab_top, $tab_height + 20, $nexY, $outputlangs); $pdf->AddPage();
} if (! empty($tplidx)) $pdf->useTemplate($tplidx);
else $pagenb++;
{ }
$this->_tableau($pdf, $tab_top_newpage, $tab_height_middlepage, $nexY, $outputlangs);
}
$this->_pagefoot($pdf,$object,$outputlangs);
// New page
$pdf->AddPage();
if (! empty($tplidx)) $pdf->useTemplate($tplidx);
$pagenb++;
$this->_pagehead($pdf, $object, 0, $outputlangs);
$pdf->SetFont('','', $default_font_size - 1);
$pdf->MultiCell(0, 3, ''); // Set interline to 3
$pdf->SetTextColor(0,0,0);
$nexY = $tab_top_newpage + 7;
}
} }
} }
// Show square // Show square
if ($pagenb == 1) if ($pagenb == 1)
{ {
$this->_tableau($pdf, $tab_top, $tab_height, $nexY, $outputlangs); $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot, 0, $outputlangs, 0, 0);
$bottomlasttab=$tab_top + $tab_height + 1; $bottomlasttab=$this->page_hauteur - $heightforinfotot + 1;
} }
else else
{ {
$this->_tableau($pdf, $tab_top_newpage, $tab_height_newpage, $nexY, $outputlangs); $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot, 0, $outputlangs, 1, 0);
$bottomlasttab=$tab_top_newpage + $tab_height_newpage + 1; $bottomlasttab=$this->page_hauteur - $heightforinfotot + 1;
} }
$pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut
@ -367,9 +353,11 @@ class pdf_soleil extends ModelePDFFicheinter
* @param string $tab_height Height of table (rectangle) * @param string $tab_height Height of table (rectangle)
* @param int $nexY Y * @param int $nexY Y
* @param Translate $outputlangs Langs object * @param Translate $outputlangs Langs object
* @param int $hidetop Hide top bar of array
* @param int $hidebottom Hide bottom bar of array
* @return void * @return void
*/ */
function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs) function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
{ {
global $conf; global $conf;
$default_font_size = pdf_getPDFFontSize($outputlangs); $default_font_size = pdf_getPDFFontSize($outputlangs);
@ -406,13 +394,13 @@ class pdf_soleil extends ModelePDFFicheinter
$pdf->MultiCell(66,5, $outputlangs->transnoentities("NameAndSignatureOfInternalContact"),0,'L',0); $pdf->MultiCell(66,5, $outputlangs->transnoentities("NameAndSignatureOfInternalContact"),0,'L',0);
$pdf->SetXY(20,235); $pdf->SetXY(20,235);
$pdf->MultiCell(80,30, '', 1); $pdf->MultiCell(80,25, '', 1);
$pdf->SetXY(110,230); $pdf->SetXY(110,230);
$pdf->MultiCell(80,5, $outputlangs->transnoentities("NameAndSignatureOfExternalContact"),0,'L',0); $pdf->MultiCell(80,5, $outputlangs->transnoentities("NameAndSignatureOfExternalContact"),0,'L',0);
$pdf->SetXY(110,235); $pdf->SetXY(110,235);
$pdf->MultiCell(80,30, '', 1); $pdf->MultiCell(80,25, '', 1);
} }
/** /**

View File

@ -120,6 +120,9 @@ class pdf_sirocco extends ModelePDFDeliveryOrder
if (file_exists($dir)) if (file_exists($dir))
{ {
$pdf=pdf_getInstance($this->format); $pdf=pdf_getInstance($this->format);
$heightforinfotot = 80; // Height reserved to output the info and total part (value include bottom margin)
$heightforfooter = 25; // Height reserved to output the footer (value include bottom margin)
$pdf->SetAutoPageBreak(1,0);
if (class_exists('TCPDF')) if (class_exists('TCPDF'))
{ {
@ -158,7 +161,6 @@ class pdf_sirocco extends ModelePDFDeliveryOrder
if ($conf->global->MAIN_DISABLE_PDF_COMPRESSION) $pdf->SetCompression(false); if ($conf->global->MAIN_DISABLE_PDF_COMPRESSION) $pdf->SetCompression(false);
$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
$pdf->SetAutoPageBreak(1,0);
// New page // New page
$pdf->AddPage(); $pdf->AddPage();
@ -184,10 +186,15 @@ class pdf_sirocco extends ModelePDFDeliveryOrder
$pdf->SetFont('','', $default_font_size - 1); // Dans boucle pour gerer multi-page $pdf->SetFont('','', $default_font_size - 1); // Dans boucle pour gerer multi-page
// Description de la ligne produit $pdf->setPageOrientation('', 1, $this->marge_basse+$heightforfooter+$heightforinfotot); // The only function to edit the bottom margin of current page to set it.
//$libelleproduitservice=pdf_getlinedesc($object,$i,$outputlangs); $pageposbefore=$pdf->getPage();
// Description de la ligne produit
pdf_writelinedesc($pdf,$object,$i,$outputlangs,100,3,30,$curY,1); pdf_writelinedesc($pdf,$object,$i,$outputlangs,100,3,30,$curY,1);
//$pdf->writeHTMLCell(100, 3, 30, $curY, $outputlangs->convToOutputCharset($libelleproduitservice), 0, 1);
$pageposafter=$pdf->getPage();
$pdf->setPage($pageposbefore);
$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
$pdf->SetFont('','', $default_font_size - 1); // Dans boucle pour gerer multi-page $pdf->SetFont('','', $default_font_size - 1); // Dans boucle pour gerer multi-page
$nexY = $pdf->GetY(); $nexY = $pdf->GetY();
@ -217,66 +224,50 @@ class pdf_sirocco extends ModelePDFDeliveryOrder
$nexY+=2; // Passe espace entre les lignes $nexY+=2; // Passe espace entre les lignes
// Cherche nombre de lignes a venir pour savoir si place suffisante // Detect if some page were added automatically and output _tableau for past pages
if ($i < ($nblines - 1) && empty($hidedesc)) // If it's not last line while ($pagenb < $pageposafter)
{
//on recupere la description du produit suivant
$follow_descproduitservice = $object->lines[$i+1]->desc;
//on compte le nombre de ligne afin de verifier la place disponible (largeur de ligne 52 caracteres)
$nblineFollowDesc = (dol_nboflines_bis($follow_descproduitservice,52,$outputlangs->charset_output)*4);
}
else // If it's last line
{
$nblineFollowDesc = 0;
}
// Test if a new page is required
if ($pagenb == 1)
{
$tab_top_in_current_page=$tab_top;
$tab_height_in_current_page=$tab_height;
}
else
{
$tab_top_in_current_page=$tab_top_newpage;
$tab_height_in_current_page=$tab_height_newpage;
}
if (($nexY+$nblineFollowDesc) > ($tab_top_in_current_page+$tab_height_in_current_page) && $i < ($nblines - 1))
{ {
if ($pagenb == 1) if ($pagenb == 1)
{ {
$this->_tableau($pdf, $tab_top, $tab_height + 20, $nexY, $outputlangs); $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
} }
else else
{ {
$this->_tableau($pdf, $tab_top_newpage, $tab_height_newpage, $nexY, $outputlangs); $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
} }
$this->_pagefoot($pdf,$object,$outputlangs);
$this->_pagefoot($pdf, $object, $outputlangs); $pagenb++;
$pdf->setPage($pagenb);
$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
}
if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
{
if ($pagenb == 1)
{
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
}
else
{
$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
}
$this->_pagefoot($pdf,$object,$outputlangs);
// New page // New page
$pdf->AddPage(); $pdf->AddPage();
if (! empty($tplidx)) $pdf->useTemplate($tplidx);
$pagenb++; $pagenb++;
$this->_pagehead($pdf, $object, 0, $outputlangs);
$pdf->SetFont('','', $default_font_size - 1);
$pdf->MultiCell(0, 3, ''); // Set interline to 3
$pdf->SetTextColor(0,0,0);
$nexY = $tab_top_newpage + 7;
} }
} }
// Show square // Show square
if ($pagenb == 1) if ($pagenb == 1)
{ {
$this->_tableau($pdf, $tab_top, $tab_height, $nexY, $outputlangs); $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot, 0, $outputlangs, 0, 0);
$bottomlasttab=$tab_top + $tab_height + 1; $bottomlasttab=$this->page_hauteur - $heightforinfotot + 1;
} }
else else
{ {
$this->_tableau($pdf, $tab_top_newpage, $tab_height_newpage, $nexY, $outputlangs); $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot, 0, $outputlangs, 1, 0);
$bottomlasttab=$tab_top_newpage + $tab_height_newpage + 1; $bottomlasttab=$this->page_hauteur - $heightforinfotot + 1;
} }
/* /*
@ -309,9 +300,11 @@ class pdf_sirocco extends ModelePDFDeliveryOrder
* @param string $tab_height Height of table (rectangle) * @param string $tab_height Height of table (rectangle)
* @param int $nexY Y * @param int $nexY Y
* @param Translate $outputlangs Langs object * @param Translate $outputlangs Langs object
* @param int $hidetop Hide top bar of array
* @param int $hidebottom Hide bottom bar of array
* @return void * @return void
*/ */
function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs) function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
{ {
$default_font_size = pdf_getPDFFontSize($outputlangs); $default_font_size = pdf_getPDFFontSize($outputlangs);
$pdf->SetFont('','', $default_font_size - 1); $pdf->SetFont('','', $default_font_size - 1);

View File

@ -142,6 +142,9 @@ class pdf_typhon extends ModelePDFDeliveryOrder
if (file_exists($dir)) if (file_exists($dir))
{ {
$pdf=pdf_getInstance($this->format); $pdf=pdf_getInstance($this->format);
$heightforinfotot = 80; // Height reserved to output the info and total part (value include bottom margin)
$heightforfooter = 25; // Height reserved to output the footer (value include bottom margin)
$pdf->SetAutoPageBreak(1,0);
if (class_exists('TCPDF')) if (class_exists('TCPDF'))
{ {
@ -180,7 +183,6 @@ class pdf_typhon extends ModelePDFDeliveryOrder
if ($conf->global->MAIN_DISABLE_PDF_COMPRESSION) $pdf->SetCompression(false); if ($conf->global->MAIN_DISABLE_PDF_COMPRESSION) $pdf->SetCompression(false);
$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
$pdf->SetAutoPageBreak(1,0);
/* /*
// Positionne $this->atleastonediscount si on a au moins une remise // Positionne $this->atleastonediscount si on a au moins une remise
@ -240,10 +242,15 @@ class pdf_typhon extends ModelePDFDeliveryOrder
$pdf->SetFont('','', $default_font_size - 1); // Dans boucle pour gerer multi-page $pdf->SetFont('','', $default_font_size - 1); // Dans boucle pour gerer multi-page
// Description de la ligne produit $pdf->setPageOrientation('', 1, $this->marge_basse+$heightforfooter+$heightforinfotot); // The only function to edit the bottom margin of current page to set it.
//$libelleproduitservice=pdf_getlinedesc($object,$i,$outputlangs); $pageposbefore=$pdf->getPage();
// Description de la ligne produit
pdf_writelinedesc($pdf,$object,$i,$outputlangs,108,3,$this->posxdesc-1,$curY); pdf_writelinedesc($pdf,$object,$i,$outputlangs,108,3,$this->posxdesc-1,$curY);
//$pdf->writeHTMLCell(108, 3, $this->posxdesc-1, $curY, $outputlangs->convToOutputCharset($libelleproduitservice), 0, 1);
$pageposafter=$pdf->getPage();
$pdf->setPage($pageposbefore);
$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
$pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut
$nexY = $pdf->GetY(); $nexY = $pdf->GetY();
@ -281,68 +288,52 @@ class pdf_typhon extends ModelePDFDeliveryOrder
*/ */
$nexY+=2; // Passe espace entre les lignes $nexY+=2; // Passe espace entre les lignes
// Cherche nombre de lignes a venir pour savoir si place suffisante // Detect if some page were added automatically and output _tableau for past pages
if ($i < ($nblines - 1) && empty($hidedesc)) // If it's not last line while ($pagenb < $pageposafter)
{ {
//on recupere la description du produit suivant if ($pagenb == 1)
$follow_descproduitservice = $object->lines[$i+1]->desc; {
//on compte le nombre de ligne afin de verifier la place disponible (largeur de ligne 52 caracteres) $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
$nblineFollowDesc = (dol_nboflines_bis($follow_descproduitservice,52,$outputlangs->charset_output)*4); }
} else
else // If it's last line {
{ $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
$nblineFollowDesc = 0; }
} $this->_pagefoot($pdf,$object,$outputlangs);
$pagenb++;
// Test if a new page is required $pdf->setPage($pagenb);
if ($pagenb == 1) $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
{ }
$tab_top_in_current_page=$tab_top; if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
$tab_height_in_current_page=$tab_height; {
} if ($pagenb == 1)
else {
{ $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
$tab_top_in_current_page=$tab_top_newpage; }
$tab_height_in_current_page=$tab_height_newpage; else
} {
if (($nexY+$nblineFollowDesc) > ($tab_top_in_current_page+$tab_height_in_current_page) && $i < ($nblines - 1)) $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
{ }
if ($pagenb == 1) $this->_pagefoot($pdf,$object,$outputlangs);
{ // New page
$this->_tableau($pdf, $tab_top, $tab_height + 20, $nexY, $outputlangs); $pdf->AddPage();
} if (! empty($tplidx)) $pdf->useTemplate($tplidx);
else $pagenb++;
{ }
$this->_tableau($pdf, $tab_top_newpage, $tab_height_newpage, $nexY, $outputlangs);
}
$this->_pagefoot($pdf, $object, $outputlangs);
// New page
$pdf->AddPage();
$pagenb++;
$this->_pagehead($pdf, $object, 0, $outputlangs);
$pdf->SetFont('','', $default_font_size - 1);
$pdf->MultiCell(0, 3, ''); // Set interline to 3
$pdf->SetTextColor(0,0,0);
$nexY = $tab_top_newpage + 7;
}
} }
// Show square // Show square
if ($pagenb == 1) if ($pagenb == 1)
{ {
$this->_tableau($pdf, $tab_top, $tab_height, $nexY, $outputlangs); $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot, 0, $outputlangs, 0, 0);
$bottomlasttab=$tab_top + $tab_height + 1; $bottomlasttab=$this->page_hauteur - $heightforinfotot + 1;
} }
else else
{ {
$this->_tableau($pdf, $tab_top_newpage, $tab_height_newpage, $nexY, $outputlangs); $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot, 0, $outputlangs, 1, 0);
$bottomlasttab=$tab_top_newpage + $tab_height_newpage + 1; $bottomlasttab=$this->page_hauteur - $heightforinfotot + 1;
} }
/* /*
* Pied de page * Pied de page
*/ */
@ -437,9 +428,11 @@ class pdf_typhon extends ModelePDFDeliveryOrder
* @param string $tab_height Height of table (rectangle) * @param string $tab_height Height of table (rectangle)
* @param int $nexY Y * @param int $nexY Y
* @param Translate $outputlangs Langs object * @param Translate $outputlangs Langs object
* @param int $hidetop Hide top bar of array
* @param int $hidebottom Hide bottom bar of array
* @return void * @return void
*/ */
function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs) function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
{ {
global $conf,$mysoc; global $conf,$mysoc;
$default_font_size = pdf_getPDFFontSize($outputlangs); $default_font_size = pdf_getPDFFontSize($outputlangs);

View File

@ -127,6 +127,9 @@ class pdf_baleine extends ModelePDFProjects
if (file_exists($dir)) if (file_exists($dir))
{ {
$pdf=pdf_getInstance($this->format); $pdf=pdf_getInstance($this->format);
$heightforinfotot = 80; // Height reserved to output the info and total part (value include bottom margin)
$heightforfooter = 25; // Height reserved to output the footer (value include bottom margin)
$pdf->SetAutoPageBreak(1,0);
if (class_exists('TCPDF')) if (class_exists('TCPDF'))
{ {
@ -154,7 +157,6 @@ class pdf_baleine extends ModelePDFProjects
if ($conf->global->MAIN_DISABLE_PDF_COMPRESSION) $pdf->SetCompression(false); if ($conf->global->MAIN_DISABLE_PDF_COMPRESSION) $pdf->SetCompression(false);
$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
$pdf->SetAutoPageBreak(1,0);
// New page // New page
$pdf->AddPage(); $pdf->AddPage();
@ -225,43 +227,51 @@ class pdf_baleine extends ModelePDFProjects
$nexY+=2; // Passe espace entre les lignes $nexY+=2; // Passe espace entre les lignes
// Cherche nombre de lignes a venir pour savoir si place suffisante // Detect if some page were added automatically and output _tableau for past pages
if ($i < ($nblignes - 1) && empty($hidedesc)) // If it's not last line while ($pagenb < $pageposafter)
{ {
//on recupere la description du produit suivant if ($pagenb == 1)
$follow_descproduitservice = $object->lines[$i+1]->desc; {
//on compte le nombre de ligne afin de verifier la place disponible (largeur de ligne 52 caracteres) $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
$nblineFollowDesc = (dol_nboflines_bis($follow_descproduitservice,52,$outputlangs->charset_output)*4); }
} else
else // If it's last line {
{ $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
$nblineFollowDesc = 0; }
} $this->_pagefoot($pdf,$object,$outputlangs);
$pagenb++;
if (($nexY+$nblineFollowDesc) > ($tab_top+$tab_height) && $i < ($nblignes - 1)) $pdf->setPage($pagenb);
{ $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
$this->_tableau($pdf, $tab_top, $tab_height + 20, $nexY, $outputlangs); }
if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
$this->_pagefoot($pdf, $object, $outputlangs); {
if ($pagenb == 1)
// New page {
$pdf->AddPage(); $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
$pagenb++; }
$this->_pagehead($pdf, $object, 0, $outputlangs); else
$pdf->SetFont('','', $default_font_size - 1); {
$pdf->MultiCell(0, 3, ''); // Set interline to 3 $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
$pdf->SetTextColor(0,0,0); }
$this->_pagefoot($pdf,$object,$outputlangs);
$tab_top=$tab_top_newpage; // New page
$tab_height=$tab_height_newpage; $pdf->AddPage();
if (! empty($tplidx)) $pdf->useTemplate($tplidx);
$nexY = $tab_top + 7; $pagenb++;
} }
} }
// Show square // Show square
$this->_tableau($pdf, $tab_top, $tab_height, $nexY, $outputlangs); if ($pagenb == 1)
$bottomlasttab=$tab_top + $tab_height + 1; {
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot, 0, $outputlangs, 0, 0);
$bottomlasttab=$this->page_hauteur - $heightforinfotot + 1;
}
else
{
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot, 0, $outputlangs, 1, 0);
$bottomlasttab=$this->page_hauteur - $heightforinfotot + 1;
}
/* /*
* Pied de page * Pied de page
@ -297,9 +307,11 @@ class pdf_baleine extends ModelePDFProjects
* @param string $tab_height Height of table (rectangle) * @param string $tab_height Height of table (rectangle)
* @param int $nexY Y * @param int $nexY Y
* @param Translate $outputlangs Langs object * @param Translate $outputlangs Langs object
* @param int $hidetop Hide top bar of array
* @param int $hidebottom Hide bottom bar of array
* @return void * @return void
*/ */
function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs) function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
{ {
global $conf,$mysoc; global $conf,$mysoc;

View File

@ -163,6 +163,9 @@ class pdf_azur extends ModelePDFPropales
// Create pdf instance // Create pdf instance
$pdf=pdf_getInstance($this->format); $pdf=pdf_getInstance($this->format);
$heightforinfotot = 80; // Height reserved to output the info and total part (value include bottom margin)
$heightforfooter = 25; // Height reserved to output the footer (value include bottom margin)
$pdf->SetAutoPageBreak(1,0);
if (class_exists('TCPDF')) if (class_exists('TCPDF'))
{ {
@ -189,7 +192,6 @@ class pdf_azur extends ModelePDFPropales
if ($conf->global->MAIN_DISABLE_PDF_COMPRESSION) $pdf->SetCompression(false); if ($conf->global->MAIN_DISABLE_PDF_COMPRESSION) $pdf->SetCompression(false);
$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
$pdf->SetAutoPageBreak(1,0);
// Positionne $this->atleastonediscount si on a au moins une remise // Positionne $this->atleastonediscount si on a au moins une remise
for ($i = 0 ; $i < $nblignes ; $i++) for ($i = 0 ; $i < $nblignes ; $i++)
@ -249,10 +251,17 @@ class pdf_azur extends ModelePDFPropales
$pdf->SetFont('','', $default_font_size - 1); // Dans boucle pour gerer multi-page $pdf->SetFont('','', $default_font_size - 1); // Dans boucle pour gerer multi-page
$pdf->setPageOrientation('', 1, $this->marge_basse+$heightforfooter+$heightforinfotot); // The only function to edit the bottom margin of current page to set it.
$pageposbefore=$pdf->getPage();
// Description de la ligne produit // Description de la ligne produit
$curX = $this->posxdesc-1; $curX = $this->posxdesc-1;
pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,4,$curX,$curY,$hideref,$hidedesc,0,$hookmanager); pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,4,$curX,$curY,$hideref,$hidedesc,0,$hookmanager);
$pageposafter=$pdf->getPage();
$pdf->setPage($pageposbefore);
$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
$pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut
$nexY = $pdf->GetY(); $nexY = $pdf->GetY();
@ -308,67 +317,50 @@ class pdf_azur extends ModelePDFPropales
$nexY+=2; // Passe espace entre les lignes $nexY+=2; // Passe espace entre les lignes
// Cherche nombre de lignes a venir pour savoir si place suffisante // Detect if some page were added automatically and output _tableau for past pages
if ($i < ($nblignes - 1) && empty($hidedesc)) // If it's not last line while ($pagenb < $pageposafter)
{ {
//on recupere la description du produit suivant if ($pagenb == 1)
$follow_descproduitservice = $object->lines[$i+1]->desc; {
//on compte le nombre de ligne afin de verifier la place disponible (largeur de ligne 52 caracteres) $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
$nblineFollowDesc = (dol_nboflines_bis($follow_descproduitservice,52,$outputlangs->charset_output)*4); }
} else
else // If it's last line {
{ $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
$nblineFollowDesc = 0; }
} $this->_pagefoot($pdf,$object,$outputlangs);
$pagenb++;
// Test if a new page is required $pdf->setPage($pagenb);
if ($pagenb == 1) $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
{ }
$tab_top_in_current_page=$tab_top; if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
$tab_height_in_current_page=$tab_height; {
} if ($pagenb == 1)
else {
{ $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
$tab_top_in_current_page=$tab_top_newpage; }
$tab_height_in_current_page=$tab_height_middlepage; else
} {
if ((($nexY+$nblineFollowDesc) > ($tab_top_in_current_page+$tab_height_in_current_page) && $i < ($nblignes - 1)) || (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)) $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
{ }
if ($pagenb == 1) $this->_pagefoot($pdf,$object,$outputlangs);
{ // New page
$this->_tableau($pdf, $tab_top, $tab_height + 20, $nexY, $outputlangs); $pdf->AddPage();
} if (! empty($tplidx)) $pdf->useTemplate($tplidx);
else $pagenb++;
{ }
$this->_tableau($pdf, $tab_top_newpage, $tab_height_middlepage, $nexY, $outputlangs);
}
$this->_pagefoot($pdf,$object,$outputlangs);
// New page
$pdf->AddPage();
if (! empty($tplidx)) $pdf->useTemplate($tplidx);
$pagenb++;
$this->_pagehead($pdf, $object, 0, $outputlangs, $hookmanager);
$pdf->SetFont('','', $default_font_size - 1);
$pdf->MultiCell(0, 3, ''); // Set interline to 3
$pdf->SetTextColor(0,0,0);
$nexY = $tab_top_newpage + 7;
}
} }
// Show square // Show square
if ($pagenb == 1) if ($pagenb == 1)
{ {
$this->_tableau($pdf, $tab_top, $tab_height, $nexY, $outputlangs); $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot, 0, $outputlangs, 0, 0);
$bottomlasttab=$tab_top + $tab_height + 1; $bottomlasttab=$this->page_hauteur - $heightforinfotot + 1;
} }
else else
{ {
$this->_tableau($pdf, $tab_top_newpage, $tab_height_endpage, $nexY, $outputlangs); $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot, 0, $outputlangs, 1, 0);
$bottomlasttab=$tab_top_newpage + $tab_height_endpage + 1; $bottomlasttab=$this->page_hauteur - $heightforinfotot + 1;
} }
// Affiche zone infos // Affiche zone infos
@ -828,9 +820,11 @@ class pdf_azur extends ModelePDFPropales
* @param string $tab_height Height of table (rectangle) * @param string $tab_height Height of table (rectangle)
* @param int $nexY Y * @param int $nexY Y
* @param Translate $outputlangs Langs object * @param Translate $outputlangs Langs object
* @param int $hidetop Hide top bar of array
* @param int $hidebottom Hide bottom bar of array
* @return void * @return void
*/ */
function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs) function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
{ {
global $conf; global $conf;
$default_font_size = pdf_getPDFFontSize($outputlangs); $default_font_size = pdf_getPDFFontSize($outputlangs);

View File

@ -163,6 +163,9 @@ class pdf_jaune extends ModelePDFPropales
// Create pdf instance // Create pdf instance
$pdf=pdf_getInstance($this->format); $pdf=pdf_getInstance($this->format);
$heightforinfotot = 80; // Height reserved to output the info and total part (value include bottom margin)
$heightforfooter = 25; // Height reserved to output the footer (value include bottom margin)
$pdf->SetAutoPageBreak(1,0);
if (class_exists('TCPDF')) if (class_exists('TCPDF'))
{ {
@ -189,7 +192,6 @@ class pdf_jaune extends ModelePDFPropales
if ($conf->global->MAIN_DISABLE_PDF_COMPRESSION) $pdf->SetCompression(false); if ($conf->global->MAIN_DISABLE_PDF_COMPRESSION) $pdf->SetCompression(false);
$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
$pdf->SetAutoPageBreak(1,0);
// Positionne $this->atleastonediscount si on a au moins une remise // Positionne $this->atleastonediscount si on a au moins une remise
for ($i = 0 ; $i < $nblignes ; $i++) for ($i = 0 ; $i < $nblignes ; $i++)
@ -249,10 +251,17 @@ class pdf_jaune extends ModelePDFPropales
$pdf->SetFont('','', $default_font_size - 1); // Dans boucle pour gerer multi-page $pdf->SetFont('','', $default_font_size - 1); // Dans boucle pour gerer multi-page
$pdf->setPageOrientation('', 1, $this->marge_basse+$heightforfooter+$heightforinfotot); // The only function to edit the bottom margin of current page to set it.
$pageposbefore=$pdf->getPage();
// Description de la ligne produit // Description de la ligne produit
$curX = $this->posxdesc-1; $curX = $this->posxdesc-1;
pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,4,$curX,$curY,$hideref,$hidedesc,0,$hookmanager); pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,4,$curX,$curY,$hideref,$hidedesc,0,$hookmanager);
$pageposafter=$pdf->getPage();
$pdf->setPage($pageposbefore);
$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
$pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut
$nexY = $pdf->GetY(); $nexY = $pdf->GetY();
@ -308,67 +317,50 @@ class pdf_jaune extends ModelePDFPropales
$nexY+=2; // Passe espace entre les lignes $nexY+=2; // Passe espace entre les lignes
// Cherche nombre de lignes a venir pour savoir si place suffisante // Detect if some page were added automatically and output _tableau for past pages
if ($i < ($nblignes - 1) && empty($hidedesc)) // If it's not last line while ($pagenb < $pageposafter)
{ {
//on recupere la description du produit suivant if ($pagenb == 1)
$follow_descproduitservice = $object->lines[$i+1]->desc; {
//on compte le nombre de ligne afin de verifier la place disponible (largeur de ligne 52 caracteres) $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
$nblineFollowDesc = (dol_nboflines_bis($follow_descproduitservice,52,$outputlangs->charset_output)*4); }
} else
else // If it's last line {
{ $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
$nblineFollowDesc = 0; }
} $this->_pagefoot($pdf,$object,$outputlangs);
$pagenb++;
// Test if a new page is required $pdf->setPage($pagenb);
if ($pagenb == 1) $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
{ }
$tab_top_in_current_page=$tab_top; if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
$tab_height_in_current_page=$tab_height; {
} if ($pagenb == 1)
else {
{ $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
$tab_top_in_current_page=$tab_top_newpage; }
$tab_height_in_current_page=$tab_height_middlepage; else
} {
if ((($nexY+$nblineFollowDesc) > ($tab_top_in_current_page+$tab_height_in_current_page) && $i < ($nblignes - 1)) || (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)) $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
{ }
if ($pagenb == 1) $this->_pagefoot($pdf,$object,$outputlangs);
{ // New page
$this->_tableau($pdf, $tab_top, $tab_height + 20, $nexY, $outputlangs); $pdf->AddPage();
} if (! empty($tplidx)) $pdf->useTemplate($tplidx);
else $pagenb++;
{ }
$this->_tableau($pdf, $tab_top_newpage, $tab_height_middlepage, $nexY, $outputlangs);
}
$this->_pagefoot($pdf,$object,$outputlangs);
// New page
$pdf->AddPage();
if (! empty($tplidx)) $pdf->useTemplate($tplidx);
$pagenb++;
$this->_pagehead($pdf, $object, 0, $outputlangs);
$pdf->SetFont('','', $default_font_size - 1);
$pdf->MultiCell(0, 3, ''); // Set interline to 3
$pdf->SetTextColor(0,0,0);
$nexY = $tab_top_newpage + 7;
}
} }
// Show square // Show square
if ($pagenb == 1) if ($pagenb == 1)
{ {
$this->_tableau($pdf, $tab_top, $tab_height, $nexY, $outputlangs); $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot, 0, $outputlangs, 0, 0);
$bottomlasttab=$tab_top + $tab_height + 1; $bottomlasttab=$this->page_hauteur - $heightforinfotot + 1;
} }
else else
{ {
$this->_tableau($pdf, $tab_top_newpage, $tab_height_endpage, $nexY, $outputlangs); $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot, 0, $outputlangs, 1, 0);
$bottomlasttab=$tab_top_newpage + $tab_height_endpage + 1; $bottomlasttab=$this->page_hauteur - $heightforinfotot + 1;
} }
// Affiche zone infos // Affiche zone infos
@ -809,9 +801,11 @@ class pdf_jaune extends ModelePDFPropales
* @param string $tab_height Height of table (rectangle) * @param string $tab_height Height of table (rectangle)
* @param int $nexY Y * @param int $nexY Y
* @param Translate $outputlangs Langs object * @param Translate $outputlangs Langs object
* @param int $hidetop Hide top bar of array
* @param int $hidebottom Hide bottom bar of array
* @return void * @return void
*/ */
function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs) function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
{ {
global $conf; global $conf;
$default_font_size = pdf_getPDFFontSize($outputlangs); $default_font_size = pdf_getPDFFontSize($outputlangs);

View File

@ -171,6 +171,9 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
$nblignes = count($object->lines); $nblignes = count($object->lines);
$pdf=pdf_getInstance($this->format); $pdf=pdf_getInstance($this->format);
$heightforinfotot = 80; // Height reserved to output the info and total part (value include bottom margin)
$heightforfooter = 25; // Height reserved to output the footer (value include bottom margin)
$pdf->SetAutoPageBreak(1,0);
if (class_exists('TCPDF')) if (class_exists('TCPDF'))
{ {
@ -197,7 +200,6 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
if ($conf->global->MAIN_DISABLE_PDF_COMPRESSION) $pdf->SetCompression(false); if ($conf->global->MAIN_DISABLE_PDF_COMPRESSION) $pdf->SetCompression(false);
$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
$pdf->SetAutoPageBreak(1,0);
// Positionne $this->atleastonediscount si on a au moins une remise // Positionne $this->atleastonediscount si on a au moins une remise
for ($i = 0 ; $i < $nblignes ; $i++) for ($i = 0 ; $i < $nblignes ; $i++)
@ -253,13 +255,19 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
{ {
$curY = $nexY; $curY = $nexY;
$pdf->SetFont('','', $default_font_size - 1); // Dans boucle pour gerer multi-page
// Description of product line
$pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage
$pdf->setPageOrientation('', 1, $this->marge_basse+$heightforfooter+$heightforinfotot); // The only function to edit the bottom margin of current page to set it.
$pageposbefore=$pdf->getPage();
// Description of product line
$curX = $this->posxdesc-1; $curX = $this->posxdesc-1;
pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,0,0,1); pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,0,0,1);
$pageposafter=$pdf->getPage();
$pdf->setPage($pageposbefore);
$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
$pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut
$nexY = $pdf->GetY(); $nexY = $pdf->GetY();
@ -310,72 +318,50 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
$nexY+=2; // Passe espace entre les lignes $nexY+=2; // Passe espace entre les lignes
// Cherche nombre de lignes a venir pour savoir si place suffisante // Detect if some page were added automatically and output _tableau for past pages
if ($i < ($nblignes - 1) && empty($hidedesc)) // If it's not last line while ($pagenb < $pageposafter)
{ {
//on recupere la description du produit suivant if ($pagenb == 1)
$follow_descproduitservice = $object->lines[$i+1]->desc; {
//on compte le nombre de ligne afin de verifier la place disponible (largeur de ligne 52 caracteres) $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
$nblineFollowDesc = dol_nboflines_bis($follow_descproduitservice,52,$outputlangs->charset_output)*4; }
// Et si on affiche dates de validite, on ajoute encore une ligne else
if ($object->lines[$i]->date_start && $object->lines[$i]->date_end) {
{ $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
$nblineFollowDesc += 4; }
} $this->_pagefoot($pdf,$object,$outputlangs);
} $pagenb++;
else // If it's last line $pdf->setPage($pagenb);
{ $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
$nblineFollowDesc = 0; }
} if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
{
// Test if a new page is required if ($pagenb == 1)
if ($pagenb == 1) {
{ $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
$tab_top_in_current_page=$tab_top; }
$tab_height_in_current_page=$tab_height; else
} {
else $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
{ }
$tab_top_in_current_page=$tab_top_newpage; $this->_pagefoot($pdf,$object,$outputlangs);
$tab_height_in_current_page=$tab_height_newpage; // New page
} $pdf->AddPage();
if (($nexY+$nblineFollowDesc) > ($tab_top_in_current_page+$tab_height_in_current_page) && $i < ($nblignes - 1)) if (! empty($tplidx)) $pdf->useTemplate($tplidx);
{ $pagenb++;
if ($pagenb == 1) }
{
$this->_tableau($pdf, $tab_top, $tab_height + 20, $nexY, $outputlangs);
}
else
{
$this->_tableau($pdf, $tab_top_newpage, $tab_height_newpage, $nexY, $outputlangs);
}
$this->_pagefoot($pdf, $object, $outputlangs);
// New page
$pdf->AddPage();
if (! empty($tplidx)) $pdf->useTemplate($tplidx);
$pagenb++;
$this->_pagehead($pdf, $object, 0, $outputlangs);
$pdf->SetFont('','', $default_font_size - 1);
$pdf->MultiCell(0, 3, ''); // Set interline to 3
$pdf->SetTextColor(0,0,0);
$nexY = $tab_top_newpage + 7;
}
} }
// Show square // Show square
if ($pagenb == 1) if ($pagenb == 1)
{ {
$this->_tableau($pdf, $tab_top, $tab_height, $nexY, $outputlangs); $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot, 0, $outputlangs, 0, 0);
$bottomlasttab=$tab_top + $tab_height + 1; $bottomlasttab=$this->page_hauteur - $heightforinfotot + 1;
} }
else else
{ {
$this->_tableau($pdf, $tab_top_newpage, $tab_height_newpage, $nexY, $outputlangs); $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot, 0, $outputlangs, 1, 0);
$bottomlasttab=$tab_top_newpage + $tab_height_newpage + 1; $bottomlasttab=$this->page_hauteur - $heightforinfotot + 1;
} }
// Affiche zone totaux // Affiche zone totaux
@ -627,9 +613,11 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
* @param string $tab_height Height of table (rectangle) * @param string $tab_height Height of table (rectangle)
* @param int $nexY Y * @param int $nexY Y
* @param Translate $outputlangs Langs object * @param Translate $outputlangs Langs object
* @param int $hidetop Hide top bar of array
* @param int $hidebottom Hide bottom bar of array
* @return void * @return void
*/ */
function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs) function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
{ {
global $conf; global $conf;

View File

@ -188,6 +188,9 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
$nblignes = count($object->lines); $nblignes = count($object->lines);
$pdf=pdf_getInstance($this->format); $pdf=pdf_getInstance($this->format);
$heightforinfotot = 80; // Height reserved to output the info and total part (value include bottom margin)
$heightforfooter = 25; // Height reserved to output the footer (value include bottom margin)
$pdf->SetAutoPageBreak(1,0);
if (class_exists('TCPDF')) if (class_exists('TCPDF'))
{ {
@ -214,7 +217,6 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
if ($conf->global->MAIN_DISABLE_PDF_COMPRESSION) $pdf->SetCompression(false); if ($conf->global->MAIN_DISABLE_PDF_COMPRESSION) $pdf->SetCompression(false);
$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
$pdf->SetAutoPageBreak(1,0);
// Positionne $this->atleastonediscount si on a au moins une remise // Positionne $this->atleastonediscount si on a au moins une remise
for ($i = 0 ; $i < $nblignes ; $i++) for ($i = 0 ; $i < $nblignes ; $i++)
@ -272,10 +274,17 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
$pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage
$pdf->setPageOrientation('', 1, $this->marge_basse+$heightforfooter+$heightforinfotot); // The only function to edit the bottom margin of current page to set it.
$pageposbefore=$pdf->getPage();
// Description of product line // Description of product line
$curX = $this->posxdesc-1; $curX = $this->posxdesc-1;
pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,0,0,1,$hookmanager); pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,0,0,1,$hookmanager);
$pageposafter=$pdf->getPage();
$pdf->setPage($pageposbefore);
$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
$pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut
$nexY = $pdf->GetY(); $nexY = $pdf->GetY();
@ -328,72 +337,50 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
$nexY+=2; // Passe espace entre les lignes $nexY+=2; // Passe espace entre les lignes
// Cherche nombre de lignes a venir pour savoir si place suffisante // Detect if some page were added automatically and output _tableau for past pages
if ($i < ($nblignes - 1) && empty($hidedesc)) // If it's not last line while ($pagenb < $pageposafter)
{ {
//on recupere la description du produit suivant if ($pagenb == 1)
$follow_descproduitservice = $object->lines[$i+1]->desc; {
//on compte le nombre de ligne afin de verifier la place disponible (largeur de ligne 52 caracteres) $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
$nblineFollowDesc = (dol_nboflines_bis($follow_descproduitservice,52,$outputlangs->charset_output)*4); }
// Et si on affiche dates de validite, on ajoute encore une ligne else
if ($object->lines[$i]->date_start && $object->lines[$i]->date_end) {
{ $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
$nblineFollowDesc += 4; }
} $this->_pagefoot($pdf,$object,$outputlangs);
} $pagenb++;
else // If it's last line $pdf->setPage($pagenb);
{ $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
$nblineFollowDesc = 0; }
} if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
{
// Test if a new page is required if ($pagenb == 1)
if ($pagenb == 1) {
{ $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
$tab_top_in_current_page=$tab_top; }
$tab_height_in_current_page=$tab_height; else
} {
else $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
{ }
$tab_top_in_current_page=$tab_top_newpage; $this->_pagefoot($pdf,$object,$outputlangs);
$tab_height_in_current_page=$tab_height_newpage; // New page
} $pdf->AddPage();
if (($nexY+$nblineFollowDesc) > ($tab_top_in_current_page+$tab_height_in_current_page) && $i < ($nblignes - 1)) if (! empty($tplidx)) $pdf->useTemplate($tplidx);
{ $pagenb++;
if ($pagenb == 1) }
{
$this->_tableau($pdf, $tab_top, $tab_height + 20, $nexY, $outputlangs);
}
else
{
$this->_tableau($pdf, $tab_top_newpage, $tab_height_newpage, $nexY, $outputlangs);
}
$this->_pagefoot($pdf, $object, $outputlangs);
// New page
$pdf->AddPage();
if (! empty($tplidx)) $pdf->useTemplate($tplidx);
$pagenb++;
$this->_pagehead($pdf, $object, 0, $outputlangs, $hookmanager);
$pdf->SetFont('','', $default_font_size - 1);
$pdf->MultiCell(0, 3, ''); // Set interline to 3
$pdf->SetTextColor(0,0,0);
$nexY = $tab_top_newpage + 7;
}
} }
// Show square // Show square
if ($pagenb == 1) if ($pagenb == 1)
{ {
$this->_tableau($pdf, $tab_top, $tab_height, $nexY, $outputlangs); $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot, 0, $outputlangs, 0, 0);
$bottomlasttab=$tab_top + $tab_height + 1; $bottomlasttab=$this->page_hauteur - $heightforinfotot + 1;
} }
else else
{ {
$this->_tableau($pdf, $tab_top_newpage, $tab_height_newpage, $nexY, $outputlangs); $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot, 0, $outputlangs, 1, 0);
$bottomlasttab=$tab_top_newpage + $tab_height_newpage + 1; $bottomlasttab=$this->page_hauteur - $heightforinfotot + 1;
} }
// Affiche zone infos // Affiche zone infos
@ -808,9 +795,11 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
* @param string $tab_height Height of table (rectangle) * @param string $tab_height Height of table (rectangle)
* @param int $nexY Y * @param int $nexY Y
* @param Translate $outputlangs Langs object * @param Translate $outputlangs Langs object
* @param int $hidetop Hide top bar of array
* @param int $hidebottom Hide bottom bar of array
* @return void * @return void
*/ */
function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs) function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
{ {
global $conf; global $conf;

View File

@ -1282,6 +1282,7 @@ class FactureFournisseur extends CommonInvoice
function initAsSpecimen() function initAsSpecimen()
{ {
global $langs,$conf; global $langs,$conf;
include_once(DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php');
$now = dol_now(); $now = dol_now();