From 9aa657bc350d5923b939b88f09924fb77319885c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 26 Nov 2020 18:48:51 +0100 Subject: [PATCH] Debug v13 --- .../commande/doc/pdf_einstein.modules.php | 5 +- .../commande/doc/pdf_eratosthene.modules.php | 58 +++++++++++++------ .../expedition/doc/pdf_espadon.modules.php | 3 +- .../facture/doc/pdf_sponge.modules.php | 15 +++-- .../modules/propale/doc/pdf_cyan.modules.php | 3 +- .../supplier_order/doc/pdf_cornas.modules.php | 3 +- 6 files changed, 59 insertions(+), 28 deletions(-) diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php index 7b50d24f557..3536daab5eb 100644 --- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php @@ -224,8 +224,9 @@ class pdf_einstein extends ModelePDFCommandes // Load translation files required by the page $outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "orders", "deliveries")); + global $outputlangsbis; + $outputlangsbis = null; if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) { - global $outputlangsbis; $outputlangsbis = new Translate('', $conf); $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE); $outputlangsbis->loadLangs(array("main", "dict", "companies", "bills", "products", "orders", "deliveries")); @@ -332,7 +333,7 @@ class pdf_einstein extends ModelePDFCommandes $pdf->AddPage(); if (!empty($tplidx)) $pdf->useTemplate($tplidx); $pagenb++; - $top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs, $outputlangsbis); + $top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs, (is_object($outputlangsbis) ? $outputlangsbis : null)); $pdf->SetFont('', '', $default_font_size - 1); $pdf->MultiCell(0, 3, ''); // Set interline to 3 $pdf->SetTextColor(0, 0, 0); diff --git a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php index a84e6fed4a2..d278ff3a6de 100644 --- a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php @@ -208,8 +208,9 @@ class pdf_eratosthene extends ModelePDFCommandes // Load translation files required by the page $outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "orders", "deliveries")); + global $outputlangsbis; + $outputlangsbis = null; if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) { - global $outputlangsbis; $outputlangsbis = new Translate('', $conf); $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE); $outputlangsbis->loadLangs(array("main", "dict", "companies", "bills", "products", "orders", "deliveries")); @@ -390,7 +391,7 @@ class pdf_eratosthene extends ModelePDFCommandes $pdf->SetFont('', '', $default_font_size - 1); $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($desc_incoterms), 0, 1); - $nexY = $pdf->GetY(); + $nexY = max($pdf->GetY(), $nexY); $height_incoterms = $nexY - $tab_top; // Rect takes a length in 3rd parameter @@ -541,7 +542,7 @@ class pdf_eratosthene extends ModelePDFCommandes // Use new auto column system $this->prepareArrayColumnField($object, $outputlangs, $hidedetails, $hidedesc, $hideref); - // tab simulation to know line height + // Table simulation to know the height of the title line $pdf->startTransaction(); $this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop); $pdf->rollbackTransaction(true); @@ -568,6 +569,7 @@ class pdf_eratosthene extends ModelePDFCommandes $showpricebeforepagebreak = 1; $posYAfterImage = 0; + $posYAfterDescription = 0; if ($this->getColumnStatus('photo')) { @@ -600,8 +602,8 @@ class pdf_eratosthene extends ModelePDFCommandes $pdf->startTransaction(); $this->printColDescContent($pdf, $curY, 'desc', $object, $i, $outputlangs, $hideref, $hidedesc); - $pageposafter = $pdf->getPage(); + if ($pageposafter > $pageposbefore) // There is a pagebreak { $pdf->rollbackTransaction(true); @@ -632,6 +634,7 @@ class pdf_eratosthene extends ModelePDFCommandes { $pdf->commitTransaction(); } + $posYAfterDescription = $pdf->GetY(); } @@ -1243,8 +1246,8 @@ class pdf_eratosthene extends ModelePDFCommandes } $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalLT1", $mysoc->country_code) : ''); $totalvat .= ' '; - $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); @@ -1324,7 +1327,7 @@ class pdf_eratosthene extends ModelePDFCommandes $pdf->SetTextColor(0, 0, 60); $pdf->SetFillColor(224, 224, 224); $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("AlreadyPaid") : ''), $useborder, 'L', 1); + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("RemainderToPay") : ''), $useborder, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer, 0, $outputlangs), $useborder, 'R', 1); @@ -1451,8 +1454,7 @@ class pdf_eratosthene extends ModelePDFCommandes } else { $logo = $logodir.'/logos/'.$this->emetteur->logo; } - if (is_readable($logo)) - { + if (is_readable($logo)) { $height = pdf_getHeightForLogo($logo); $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) } else { @@ -1471,17 +1473,28 @@ class pdf_eratosthene extends ModelePDFCommandes $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); $title = $outputlangs->transnoentities($titlekey); - $pdf->MultiCell($w, 4, $title, '', 'R'); + if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && is_object($outputlangsbis)) { + $title .= ' - '; + $title .= $outputlangsbis->transnoentities($titlekey); + } + + $pdf->MultiCell($w, 3, $title, '', 'R'); $pdf->SetFont('', 'B', $default_font_size); $posy += 5; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : ".$outputlangs->convToOutputCharset($object->ref), '', 'R'); + $textref = $outputlangs->transnoentities("Ref")." : ".$outputlangs->convToOutputCharset($object->ref); + if ($object->statut == $object::STATUS_DRAFT) + { + $pdf->SetTextColor(128, 0, 0); + $textref .= ' - '.$outputlangs->transnoentities("NotValidated"); + } + $pdf->MultiCell($w, 4, $textref, '', 'R'); $posy += 1; - $pdf->SetFont('', '', $default_font_size - 1); + $pdf->SetFont('', '', $default_font_size - 2); if ($object->ref_client) { @@ -1519,7 +1532,11 @@ class pdf_eratosthene extends ModelePDFCommandes $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("OrderDate")." : ".dol_print_date($object->date, "day", false, $outputlangs, true), '', 'R'); + $title = $outputlangs->transnoentities("OrderDate"); + if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && is_object($outputlangsbis)) { + $title .= ' - '.$outputlangsbis->transnoentities("DateInvoice"); + } + $pdf->MultiCell($w, 3, $title." : ".dol_print_date($object->date, "day", false, $outputlangs, true), '', 'R'); if (!empty($conf->global->DOC_SHOW_CUSTOMER_CODE) && !empty($object->thirdparty->code_client)) { @@ -1571,11 +1588,15 @@ class pdf_eratosthene extends ModelePDFCommandes $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object); // Show sender - $posy = 42 + $top_shift; + $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42; + $posy += $top_shift; $posx = $this->marge_gauche; if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->page_largeur - $this->marge_droite - 80; - $hautcadre = 40; + $hautcadre = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40; + $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82; + + // Show sender frame $pdf->SetTextColor(0, 0, 0); $pdf->SetFont('', '', $default_font_size - 2); @@ -1583,20 +1604,19 @@ class pdf_eratosthene extends ModelePDFCommandes $pdf->MultiCell(66, 5, $outputlangs->transnoentities("BillFrom").":", 0, 'L'); $pdf->SetXY($posx, $posy); $pdf->SetFillColor(230, 230, 230); - $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1); + $pdf->MultiCell($widthrecbox, $hautcadre, "", 0, 'R', 1); $pdf->SetTextColor(0, 0, 60); // Show sender name $pdf->SetXY($posx + 2, $posy + 3); $pdf->SetFont('', 'B', $default_font_size); - $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L'); + $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L'); $posy = $pdf->getY(); // Show sender information $pdf->SetXY($posx + 2, $posy); $pdf->SetFont('', '', $default_font_size - 1); - $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L'); - + $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, 'L'); // If CUSTOMER contact defined, we use it $usecontact = false; @@ -1750,7 +1770,7 @@ class pdf_eratosthene extends ModelePDFCommandes 'border-left' => false, // remove left line separator ); - if (!empty($conf->global->MAIN_GENERATE_ORDERS_WITH_PICTURE)) + if (!empty($conf->global->MAIN_GENERATE_ORDERS_WITH_PICTURE) && !empty($this->atleastonephoto)) { $this->cols['photo']['status'] = true; } diff --git a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php index 7e88a739a73..a48e28ecef6 100644 --- a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php @@ -168,8 +168,9 @@ class pdf_espadon extends ModelePdfExpedition // Load traductions files required by page $outputlangs->loadLangs(array("main", "bills", "products", "dict", "companies", "propal", "deliveries", "sendings", "productbatch")); + global $outputlangsbis; + $outputlangsbis = null; if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) { - global $outputlangsbis; $outputlangsbis = new Translate('', $conf); $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE); $outputlangsbis->loadLangs(array("main", "bills", "products", "dict", "companies", "propal", "deliveries", "sendings", "productbatch")); diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index b295150488b..b814e99a669 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -219,8 +219,9 @@ class pdf_sponge extends ModelePDFFactures // Load translation files required by the page $outputlangs->loadLangs(array("main", "bills", "products", "dict", "companies")); + global $outputlangsbis; + $outputlangsbis = null; if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) { - global $outputlangsbis; $outputlangsbis = new Translate('', $conf); $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE); $outputlangsbis->loadLangs(array("main", "bills", "products", "dict", "companies")); @@ -260,7 +261,11 @@ class pdf_sponge extends ModelePDFFactures { if (!$arephoto) { - $dir = $conf->product->dir_output.'/'.$midir; + if ($conf->product->entity != $objphoto->entity) { + $dir = $conf->product->multidir_output[$objphoto->entity].'/'.$midir; //Check repertories of current entities + } else { + $dir = $conf->product->dir_output.'/'.$midir; //Check repertory of the current product + } foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) { @@ -646,6 +651,7 @@ class pdf_sponge extends ModelePDFFactures if ($pageposafter > $pageposbefore) // There is a pagebreak { $pdf->rollbackTransaction(true); + $pageposafter = $pageposbefore; $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. $this->printColDescContent($pdf, $curY, 'desc', $object, $i, $outputlangs, $hideref, $hidedesc); @@ -675,7 +681,8 @@ class pdf_sponge extends ModelePDFFactures $posYAfterDescription = $pdf->GetY(); } - $nexY = $pdf->GetY(); + $nexY = max($pdf->GetY(), $posYAfterImage, $posYAfterDescription); + $pageposafter = $pdf->getPage(); $pdf->setPage($pageposbefore); $pdf->setTopMargin($this->marge_haute); @@ -2000,7 +2007,7 @@ class pdf_sponge extends ModelePDFFactures if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && is_object($outputlangsbis)) { $title .= ' - '.$outputlangsbis->transnoentities("DateInvoice"); } - $pdf->MultiCell($w, 3, $title." : ".dol_print_date($object->date, "day", false, $outputlangs), '', 'R'); + $pdf->MultiCell($w, 3, $title." : ".dol_print_date($object->date, "day", false, $outputlangs, true), '', 'R'); if (!empty($conf->global->INVOICE_POINTOFTAX_DATE)) { diff --git a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php index 5524460bfc8..1baf9712cdb 100644 --- a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php @@ -209,8 +209,9 @@ class pdf_cyan extends ModelePDFPropales // Load translation files required by page $outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "propal")); + global $outputlangsbis; + $outputlangsbis = null; if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) { - global $outputlangsbis; $outputlangsbis = new Translate('', $conf); $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE); $outputlangsbis->loadLangs(array("main", "dict", "companies", "bills", "products", "propal")); diff --git a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php index 12092153e83..0d66fe5b83b 100644 --- a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php +++ b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php @@ -192,8 +192,9 @@ class pdf_cornas extends ModelePDFSuppliersOrders // Load translation files required by the page $outputlangs->loadLangs(array("main", "orders", "companies", "bills", "dict", "products")); + global $outputlangsbis; + $outputlangsbis = null; if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) { - global $outputlangsbis; $outputlangsbis = new Translate('', $conf); $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE); $outputlangsbis->loadLangs(array("main", "orders", "companies", "bills", "dict", "products"));