Clean code on pdf templates

This commit is contained in:
Laurent Destailleur 2021-12-02 10:43:44 +01:00
parent c057d6eafe
commit 10e126eb69
23 changed files with 81 additions and 78 deletions

View File

@ -4283,7 +4283,7 @@ if ($action == 'create') {
print '<div class="fichehalfleft">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border tableforfield" width="100%">';
print '<table class="border tableforfield centpercent">';
// Type
print '<tr><td class="titlefield fieldname_type">'.$langs->trans('Type').'</td><td class="valuefield fieldname_type">';
@ -4364,7 +4364,7 @@ if ($action == 'create') {
// Date invoice
print '<tr><td>';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print '<table class="nobordernopadding centpercent"><tr><td>';
print $langs->trans('DateInvoice');
print '</td>';
if ($action != 'editinvoicedate' && !empty($object->brouillon) && $usercancreate && empty($conf->global->FAC_FORCE_DATE_VALIDATION)) {
@ -4385,7 +4385,7 @@ if ($action == 'create') {
if (!empty($conf->global->INVOICE_POINTOFTAX_DATE)) {
// Date invoice
print '<tr><td>';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print '<table class="nobordernopadding centpercent"><tr><td>';
print $langs->trans('DatePointOfTax');
print '</td>';
print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editdate_pointoftax&token='.newToken().'&facid='.$object->id.'">'.img_edit($langs->trans('SetDate'), 1).'</a></td>';
@ -4401,7 +4401,7 @@ if ($action == 'create') {
// Payment term
print '<tr><td>';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print '<table class="nobordernopadding centpercent"><tr><td>';
print $langs->trans('PaymentConditionsShort');
print '</td>';
if ($object->type != Facture::TYPE_CREDIT_NOTE && $action != 'editconditions' && $usercancreate) {
@ -4422,7 +4422,7 @@ if ($action == 'create') {
// Date payment term
print '<tr><td>';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print '<table class="nobordernopadding centpercent"><tr><td>';
print $langs->trans('DateMaxPayment');
print '</td>';
if ($object->type != Facture::TYPE_CREDIT_NOTE && $action != 'editpaymentterm' && $usercancreate) {
@ -4446,7 +4446,7 @@ if ($action == 'create') {
// Payment mode
print '<tr><td>';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print '<table class="nobordernopadding centpercent"><tr><td>';
print $langs->trans('PaymentMode');
print '</td>';
if ($action != 'editmode' && $usercancreate) {
@ -4466,7 +4466,7 @@ if ($action == 'create') {
// Multicurrency code
print '<tr>';
print '<td>';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print '<table class="nobordernopadding centpercent"><tr><td>';
print $form->editfieldkey('Currency', 'multicurrency_code', '', $object, 0);
print '</td>';
if ($usercancreate && $action != 'editmulticurrencycode' && !empty($object->brouillon)) {
@ -4510,7 +4510,7 @@ if ($action == 'create') {
// Bank Account
if (!empty($conf->banque->enabled)) {
print '<tr><td class="nowrap">';
print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
print '<table class="nobordernopadding centpercent"><tr><td class="nowrap">';
print $langs->trans('BankAccount');
print '<td>';
if (($action != 'editbankaccount') && $usercancreate) {
@ -4530,7 +4530,7 @@ if ($action == 'create') {
// Incoterms
if (!empty($conf->incoterm->enabled)) {
print '<tr><td>';
print '<table width="100%" class="nobordernopadding"><tr><td>';
print '<table class="nobordernopadding centpercent"><tr><td>';
print $langs->trans('IncotermLabel');
print '<td><td class="right">';
if ($usercancreate) {
@ -4658,7 +4658,8 @@ if ($action == 'create') {
print '<div class="fichehalfright">';
print '<!-- amounts -->'."\n";
print '<table class="border bordertop tableforfield centpercent">';
print '<div class="underbanner clearboth"></div>'."\n";
print '<table class="border tableforfield centpercent">';
$sign = 1;
if (!empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE_SCREEN) && $object->type == $object::TYPE_CREDIT_NOTE) {

View File

@ -186,9 +186,9 @@ class pdf_ban extends ModeleBankAccountDoc
$pdf->SetTextColor(0, 0, 0);
$tab_top = 50;
$tab_height = 200;
$tab_top_newpage = 40;
$tab_height_newpage = 210;
$tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
// Affiche notes
if (!empty($object->note_public)) {

View File

@ -198,9 +198,9 @@ class pdf_sepamandate extends ModeleBankAccountDoc
$pdf->SetTextColor(0, 0, 0);
$tab_top = 50;
$tab_height = 200;
$tab_top_newpage = 40;
$tab_height_newpage = 210;
$tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
// Show notes
if (!empty($object->note_public)) {

View File

@ -388,6 +388,8 @@ class pdf_eratosthene extends ModelePDFCommandes
$tab_top = 90 + $top_shift;
$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10);
$tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
// Incoterm
$height_incoterms = 0;
if (!empty($conf->incoterm->enabled)) {
@ -521,8 +523,8 @@ class pdf_eratosthene extends ModelePDFCommandes
}
$height_note = $posyafter - $tab_top_newpage;
$pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
} else // No pagebreak
{
} else {
// No pagebreak
$pdf->commitTransaction();
$posyafter = $pdf->GetY();
$height_note = $posyafter - $tab_top;

View File

@ -342,8 +342,8 @@ class pdf_storm extends ModelePDFDeliveryOrder
$tab_top = 90;
$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10);
$tab_height = 130;
$tab_height_newpage = 150;
$tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
$this->posxdesc = $this->marge_gauche + 1;
@ -352,7 +352,7 @@ class pdf_storm extends ModelePDFDeliveryOrder
if (!empty($conf->incoterm->enabled)) {
$desc_incoterms = $object->getIncotermsForPDF();
if ($desc_incoterms) {
$tab_top = 88;
$tab_top -= 2;
$pdf->SetFont('', '', $default_font_size - 1);
$pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($desc_incoterms), 0, 1);

View File

@ -321,15 +321,15 @@ class pdf_typhon extends ModelePDFDeliveryOrder
$tab_top = 90;
$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10);
$tab_height = 130;
$tab_height_newpage = 150;
$tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
// Incoterm
$height_incoterms = 0;
if (!empty($conf->incoterm->enabled)) {
$desc_incoterms = $object->getIncotermsForPDF();
if ($desc_incoterms) {
$tab_top = 88;
$tab_top -= 2;
$pdf->SetFont('', '', $default_font_size - 1);
$pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($desc_incoterms), 0, 1);

View File

@ -324,8 +324,8 @@ class pdf_espadon extends ModelePdfExpedition
$tab_top = 90;
$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift: 10);
$tab_height = 130;
$tab_height_newpage = 150;
$tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
$this->posxdesc = $this->marge_gauche + 1;
@ -334,7 +334,7 @@ class pdf_espadon extends ModelePdfExpedition
if (!empty($conf->incoterm->enabled)) {
$desc_incoterms = $object->getIncotermsForPDF();
if ($desc_incoterms) {
$tab_top = 88;
$tab_top -= 2;
$pdf->SetFont('', '', $default_font_size - 1);
$pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($desc_incoterms), 0, 1);

View File

@ -282,8 +282,8 @@ class pdf_merou extends ModelePdfExpedition
$tab_top = 52;
$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10);
$tab_height = $this->page_hauteur - $tab_top - $heightforfooter;
$tab_height_newpage = $this->page_hauteur - $tab_top_newpage - $heightforfooter;
$tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
// Display notes
if (!empty($object->note_public)) {

View File

@ -349,15 +349,15 @@ class pdf_rouget extends ModelePdfExpedition
$tab_top = 90;
$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10);
$tab_height = 130;
$tab_height_newpage = 150;
$tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
// Incoterm
$height_incoterms = 0;
if (!empty($conf->incoterm->enabled)) {
$desc_incoterms = $object->getIncotermsForPDF();
if ($desc_incoterms) {
$tab_top = 88;
$tab_top -= 2;
$pdf->SetFont('', '', $default_font_size - 1);
$pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($desc_incoterms), 0, 1);

View File

@ -313,8 +313,8 @@ class pdf_standard extends ModeleExpenseReport
$tab_top = 95;
$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 65 : 10);
$tab_height = 130;
$tab_height_newpage = 150;
$tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
// Show notes
$notetoshow = empty($object->note_public) ? '' : $object->note_public;

View File

@ -411,18 +411,21 @@ class pdf_sponge extends ModelePDFFactures
}
$pagenb++;
// Output header (logo, ref and address blocks). This is first call for first page.
$top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs, $outputlangsbis);
$pdf->SetFont('', '', $default_font_size - 1);
$pdf->MultiCell(0, 3, ''); // Set interline to 3
$pdf->SetTextColor(0, 0, 0);
$tab_top = 90 + $top_shift;
// You can add more thing undr header here, if you increase top_shift too.
// TODO
// $tab_top is y where we must continue content (90 = 42 + 48: 42 is height of logo and ref, 48 is address blocks)
$tab_top = 90 + $top_shift; // top_shift is an addition for linked objects or addons (0 in most cases)
$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10);
$tab_height = 130 - $top_shift;
$tab_height_newpage = 150;
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
$tab_height_newpage -= $top_shift;
}
// Define heigth of table for lines (for first page)
$tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
$nexY = $tab_top - 1;
@ -447,7 +450,7 @@ class pdf_sponge extends ModelePDFFactures
}
}
// Displays notes
// Displays notes. Here we are still on code eecuted only for the first page.
$notetoshow = empty($object->note_public) ? '' : $object->note_public;
if (!empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE)) {
// Get first sale rep
@ -560,8 +563,8 @@ class pdf_sponge extends ModelePDFFactures
}
$height_note = $posyafter - $tab_top_newpage;
$pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
} else // No pagebreak
{
} else {
// No pagebreak
$pdf->commitTransaction();
$posyafter = $pdf->GetY();
$height_note = $posyafter - $tab_top;
@ -594,7 +597,7 @@ class pdf_sponge extends ModelePDFFactures
// Use new auto column system
$this->prepareArrayColumnField($object, $outputlangs, $hidedetails, $hidedesc, $hideref);
// Table simulation to know the height of the title line
// Table simulation to know the height of the title line (this set this->tableTitleHeight)
$pdf->startTransaction();
$this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop);
$pdf->rollbackTransaction(true);
@ -1853,11 +1856,11 @@ class pdf_sponge extends ModelePDFFactures
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
/**
* Show top header of page.
* Show top header of page. This include the logo, ref and address blocs
*
* @param TCPDF $pdf Object PDF
* @param Facture $object Object to show
* @param int $showaddress 0=no, 1=yes
* @param int $showaddress 0=no, 1=yes (usually set to 1 for first page, and 0 for next pages)
* @param Translate $outputlangs Object lang for output
* @param Translate $outputlangsbis Object lang for output bis
* @return void

View File

@ -271,8 +271,8 @@ class pdf_soleil extends ModelePDFFicheinter
$tab_top = 90;
$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10);
$tab_height = 130;
$tab_height_newpage = 150;
$tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
// Display notes
$notetoshow = empty($object->note_public) ? '' : $object->note_public;

View File

@ -499,14 +499,10 @@ class pdf_standard extends ModelePDFMovement
$tab_top = 42;
$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10);
$tab_height = 130;
$tab_height_newpage = 150;
/* ************************************************************************** */
/* */
/* Affichage de la liste des produits du MouvementStock */
/* */
/* ************************************************************************** */
$tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
// Show list of product of the MouvementStock
$nexY += 5;
$nexY = $pdf->GetY();

View File

@ -309,6 +309,8 @@ class pdf_vinci extends ModelePDFMo
$tab_top = 90 + $top_shift;
$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10);
$tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
// Affiche notes
$notetoshow = empty($object->note_public) ? '' : $object->note_public;
@ -412,8 +414,8 @@ class pdf_vinci extends ModelePDFMo
}
$height_note = $posyafter - $tab_top_newpage;
$pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
} else // No pagebreak
{
} else {
// No pagebreak
$pdf->commitTransaction();
$posyafter = $pdf->GetY();
$height_note = $posyafter - $tab_top;

View File

@ -270,8 +270,8 @@ class pdf_standard extends ModelePDFProduct
$tab_top = 42;
$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10);
$tab_height = 130;
$tab_height_newpage = 150;
$tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
// Label of product
$pdf->SetFont('', 'B', $default_font_size);

View File

@ -286,8 +286,8 @@ class pdf_baleine extends ModelePDFProjects
$tab_top = 50;
$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10);
$tab_height = 170;
$tab_height_newpage = 190;
$tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
// Show public note
$notetoshow = empty($object->note_public) ? '' : $object->note_public;

View File

@ -327,8 +327,8 @@ class pdf_beluga extends ModelePDFProjects
$tab_top = 50;
$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10);
$tab_height = 170;
$tab_height_newpage = 190;
$tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
// Show public note
$notetoshow = empty($object->note_public) ? '' : $object->note_public;

View File

@ -286,8 +286,8 @@ class pdf_timespent extends ModelePDFProjects
$tab_top = 50;
$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10);
$tab_height = 170;
$tab_height_newpage = 190;
$tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
// Show public note
$notetoshow = empty($object->note_public) ? '' : $object->note_public;

View File

@ -408,6 +408,7 @@ class pdf_cyan extends ModelePDFPropales
$pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
$tab_top = $nexY + 6;
$height_incoterms += 4;
}
}
@ -537,8 +538,8 @@ class pdf_cyan extends ModelePDFPropales
}
$height_note = $posyafter - $tab_top_newpage;
$pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
} else // No pagebreak
{
} else {
// No pagebreak
$pdf->commitTransaction();
$posyafter = $pdf->GetY();
$height_note = $posyafter - $tab_top;

View File

@ -263,15 +263,15 @@ class pdf_squille extends ModelePdfReception
$tab_top = 90;
$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10);
$tab_height = 130;
$tab_height_newpage = 150;
$tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
// Incoterm
$height_incoterms = 0;
if (!empty($conf->incoterm->enabled)) {
$desc_incoterms = $object->getIncotermsForPDF();
if ($desc_incoterms) {
$tab_top = 88;
$tab_top -= 2;
$pdf->SetFont('', '', $default_font_size - 1);
$pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($desc_incoterms), 0, 1);

View File

@ -293,14 +293,10 @@ class pdf_standard extends ModelePDFStock
$tab_top = 80 + $top_shift;
$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10);
$tab_height = 130;
$tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
/* ************************************************************************** */
/* */
/* Show list of product in warehouse */
/* */
/* ************************************************************************** */
// Show list of product in warehouse */
$totalunit = 0;
$totalvalue = $totalvaluesell = 0;

View File

@ -363,6 +363,8 @@ class pdf_cornas extends ModelePDFSuppliersOrders
$tab_top = 90 + $top_shift;
$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10);
$tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
// Incoterm
if (!empty($conf->incoterm->enabled)) {
$desc_incoterms = $object->getIncotermsForPDF();
@ -484,8 +486,8 @@ class pdf_cornas extends ModelePDFSuppliersOrders
}
$height_note = $posyafter - $tab_top_newpage;
$pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
} else // No pagebreak
{
} else {
// No pagebreak
$pdf->commitTransaction();
$posyafter = $pdf->GetY();
$height_note = $posyafter - $tab_top;

View File

@ -317,8 +317,8 @@ class pdf_standard extends ModelePDFSuppliersPayments
$tab_top = 90;
$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10);
$tab_height = 130;
$tab_height_newpage = 150;
$tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
// Incoterm
$height_incoterms = 0;