From 860f89cc442125c04ba5f6411e0766a126f3f31e Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Tue, 10 Dec 2024 17:14:33 +0100 Subject: [PATCH] Debug v21 --- .../modules/facture/doc/pdf_crabe.modules.php | 22 ++++++++------- .../facture/doc/pdf_octopus.modules.php | 27 +++++++++---------- .../facture/doc/pdf_sponge.modules.php | 11 +++++--- 3 files changed, 32 insertions(+), 28 deletions(-) diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index 0fdcf740020d8..5297f1839cb16 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -102,7 +102,7 @@ class pdf_crabe extends ModelePDFFactures */ public function __construct($db) { - global $conf, $langs, $mysoc; + global $langs, $mysoc; // Translations $langs->loadLangs(array("main", "bills")); @@ -359,10 +359,10 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede $certprivate = empty($user->conf->CERTIFICATE_CRT_PRIVATE) ? '' : $user->conf->CERTIFICATE_CRT_PRIVATE; // If user has no certificate, we try to take the company one if (!$cert) { - $cert = !getDolGlobalString('CERTIFICATE_CRT') ? '' : $conf->global->CERTIFICATE_CRT; + $cert = getDolGlobalString('CERTIFICATE_CRT'); } if (!$certprivate) { - $certprivate = !getDolGlobalString('CERTIFICATE_CRT_PRIVATE') ? '' : $conf->global->CERTIFICATE_CRT_PRIVATE; + $certprivate = getDolGlobalString('CERTIFICATE_CRT_PRIVATE'); } // If a certificate is found if ($cert) { @@ -1162,7 +1162,7 @@ protected function _tableau_versements_header($pdf, $object, $outputlangs, $defa protected function _tableau_info(&$pdf, $object, $posy, $outputlangs, $outputlangsbis) { // phpcs:enable - global $conf, $mysoc, $hookmanager; + global $mysoc, $hookmanager; $default_font_size = pdf_getPDFFontSize($outputlangs); @@ -1170,6 +1170,9 @@ protected function _tableau_info(&$pdf, $object, $posy, $outputlangs, $outputlan krsort($this->tva_array); + // Clean data type + $object->total_tva = (float) $object->total_tva; + // Show VAT details if ($object->total_tva != 0 && getDolGlobalInt('PDF_INVOICE_SHOW_VAT_ANALYSIS')) { $pdf->SetFillColor(224, 224, 224); @@ -1227,7 +1230,7 @@ protected function _tableau_info(&$pdf, $object, $posy, $outputlangs, $outputlan } } - // If France, show VAT mention if not applicable + // If France, show VAT mention if applicable if ($this->emetteur->country_code == 'FR' && empty($object->total_tva) && (empty($mysoc->tva_assuj) || ($this->emetteur->isInEEC() && $object->thirdparty->isInEEC()))) { $pdf->SetFont('', 'B', $default_font_size - 2); $pdf->SetXY($this->marge_gauche, $posy); @@ -1367,7 +1370,7 @@ protected function _tableau_info(&$pdf, $object, $posy, $outputlangs, $outputlan if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ') { // If payment mode unregulated or payment mode forced to CHQ if (getDolGlobalInt('FACTURE_CHQ_NUMBER')) { - $diffsizetitle = (!getDolGlobalString('PDF_DIFFSIZE_TITLE') ? 3 : $conf->global->PDF_DIFFSIZE_TITLE); + $diffsizetitle = getDolGlobalInt('PDF_DIFFSIZE_TITLE', 3); if (getDolGlobalInt('FACTURE_CHQ_NUMBER') > 0) { $account = new Account($this->db); @@ -1385,7 +1388,7 @@ protected function _tableau_info(&$pdf, $object, $posy, $outputlangs, $outputlan $posy = $pdf->GetY() + 2; } } - if ($conf->global->FACTURE_CHQ_NUMBER == -1) { + if (getDolGlobalInt('FACTURE_CHQ_NUMBER') == -1) { $pdf->SetXY($this->marge_gauche, $posy); $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle); $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $this->emetteur->name), 0, 'L', 0); @@ -1404,7 +1407,7 @@ protected function _tableau_info(&$pdf, $object, $posy, $outputlangs, $outputlan // If payment mode not forced or forced to VIR, show payment with BAN if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR') { if ($object->fk_account > 0 || $object->fk_bank > 0 || getDolGlobalInt('FACTURE_RIB_NUMBER')) { - $bankid = ($object->fk_account <= 0 ? $conf->global->FACTURE_RIB_NUMBER : $object->fk_account); + $bankid = ($object->fk_account <= 0 ? getDolGlobalString('FACTURE_RIB_NUMBER') : $object->fk_account); if ($object->fk_bank > 0) { $bankid = $object->fk_bank; // For backward compatibility when object->fk_account is forced with object->fk_bank } @@ -1828,7 +1831,7 @@ protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs $index++; $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($col2x - $col1x, $tab2_hl, $conf->global->BILL_TEXT_TOTAL_FOOTER, 0, 'L', 0); + $pdf->MultiCell($col2x - $col1x, $tab2_hl, getDolGlobalString('BILL_TEXT_TOTAL_FOOTER'), 0, 'L', 0); } return ($tab2_top + ($tab2_hl * $index)); @@ -1877,7 +1880,6 @@ protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $ $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4); $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); - //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230'; if (getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR')) { $pdf->RoundedRect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5, $this->corner_radius, '1001', 'F', null, explode(',', getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR'))); } diff --git a/htdocs/core/modules/facture/doc/pdf_octopus.modules.php b/htdocs/core/modules/facture/doc/pdf_octopus.modules.php index 06fa8d0c9d53d..b59ecd85c045c 100644 --- a/htdocs/core/modules/facture/doc/pdf_octopus.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_octopus.modules.php @@ -1329,7 +1329,7 @@ public function drawPaymentsTable(&$pdf, $object, $posy, $outputlangs) */ protected function drawInfoTable(&$pdf, $object, $posy, $outputlangs, $outputlangsbis) { - global $conf, $mysoc, $hookmanager; + global $mysoc, $hookmanager; $default_font_size = pdf_getPDFFontSize($outputlangs); @@ -1337,6 +1337,9 @@ protected function drawInfoTable(&$pdf, $object, $posy, $outputlangs, $outputlan krsort($this->tva_array); + // Clean data type + $object->total_tva = (float) $object->total_tva; + // Show VAT details if ($object->total_tva != 0 && getDolGlobalInt('PDF_INVOICE_SHOW_VAT_ANALYSIS')) { $pdf->SetFillColor(224, 224, 224); @@ -1394,7 +1397,7 @@ protected function drawInfoTable(&$pdf, $object, $posy, $outputlangs, $outputlan } } - // If France, show VAT mention if not applicable + // If France, show VAT mention if applicable if ($this->emetteur->country_code == 'FR' && empty($object->total_tva) && (empty($mysoc->tva_assuj) || ($this->emetteur->isInEEC() && $object->thirdparty->isInEEC()))) { $pdf->SetFont('', 'B', $default_font_size - 2); $pdf->SetXY($this->marge_gauche, $posy); @@ -1664,7 +1667,7 @@ protected function drawTotalTable(&$pdf, $object, $deja_regle, $posy, $outputlan $pdf->SetXY($col1x, $tab2_top + 0); $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("TotalHT") : ''), 0, 'L', 1); - $total_ht = ((!empty($conf->multicurrency->enabled) && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht); + $total_ht = ((isModEnabled('multicurrency') && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht); $pdf->SetXY($col2x, $tab2_top + 0); $pdf->MultiCell($largcol2, $tab2_hl, price($total_ht, 0, $outputlangs), 0, 'R', 1); @@ -2549,7 +2552,7 @@ protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) */ public function defineColumnField($object, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0) { - global $conf, $hookmanager; + global $hookmanager; // Default field style for content $this->defaultContentsFieldsStyle = array( @@ -2871,7 +2874,6 @@ public function _tableFirstPage(&$pdf, $tab_top, $tab_height, $nexY, $outputlang $width = $this->page_largeur - $this->marge_gauche - $this->marge_droite - 83; - //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230'; if (getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR')) { //$pdf->Rect($this->posx_cumul_anterieur - 1, $tab_top, $width, 5, 'F', null, explode(',', getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR'))); $pdf->RoundedRect($this->posx_cumul_anterieur - 1, $tab_top, $width, 5, $this->corner_radius, '1001', 'F', explode(',', getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR'))); @@ -3069,8 +3071,6 @@ public function _tableFirstPage(&$pdf, $tab_top, $tab_height, $nexY, $outputlang */ public function getDataSituation(&$object) { - global $conf, $db; - // Fetch previous and next situations invoices. // Return all previous and next invoices (both standard and credit notes) $object->fetchPreviousNextSituationInvoice(); @@ -3233,7 +3233,6 @@ public function displayRetainedWarranty($object) return $object->displayRetainedWarranty(); } else { // FOR RETROCOMPATIBILITY - global $conf; // TODO : add a flag on invoices to store this conf USE_RETAINED_WARRANTY_ONLY_FOR_SITUATION_FINAL @@ -3365,7 +3364,7 @@ public function printRoundedRectBtp($pdf, $x, $y, $w, $h, $r, $hidetop = 0, $hid */ public function btpGetInvoiceAmounts($id, $forceReadFromDB = false) { - global $user,$langs,$conf,$mysoc,$db,$hookmanager,$nblignes; + global $user, $langs, $mysoc, $db, $hookmanager, $nblignes; $object = new Facture($db); $object->fetch($id); @@ -3517,7 +3516,7 @@ public function resumeLastPage(&$pdf, $object, $deja_regle, $posy, $outputlangs, if (count($propals)) { $propal = array_pop($propals); - $total_ht = ($conf->multicurrency->enabled && $propal->multicurrency_tx != 1) ? $propal->multicurrency_total_ht : $propal->total_ht; + $total_ht = (isModEnabled('multicurrency') && $propal->multicurrency_tx != 1) ? $propal->multicurrency_total_ht : $propal->total_ht; $remain_to_pay = $total_ht; $pdf->SetTextColor(0, 0, 60); @@ -3540,7 +3539,7 @@ public function resumeLastPage(&$pdf, $object, $deja_regle, $posy, $outputlangs, } elseif (count($orders)) { $order = array_pop($orders); - $total_ht = ($conf->multicurrency->enabled && $order->multicurrency_tx != 1 ? $order->multicurrency_total_ht : $order->total_ht); + $total_ht = (isModEnabled('multicurrency') && $order->multicurrency_tx != 1 ? $order->multicurrency_total_ht : $order->total_ht); $remain_to_pay = $total_ht; } @@ -3608,7 +3607,7 @@ public function resumeLastPage(&$pdf, $object, $deja_regle, $posy, $outputlangs, $pdf->SetXY($posx, $posy); $pdf->MultiCell($width, $height, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1); - $total_ht = ($conf->multicurrency->enabled && $invoice->multicurrency_tx != 1 ? $invoice->multicurrency_total_ht : $invoice->total_ht); + $total_ht = (isModEnabled('multicurrency') && $invoice->multicurrency_tx != 1 ? $invoice->multicurrency_total_ht : $invoice->total_ht); $pdf->SetXY($posx + $width, $posy); $pdf->MultiCell($width2, $height, price($sign * ($total_ht + (!empty($invoice->remise) ? $invoice->remise : 0)), 0, $outputlangs), 0, 'R', 1); @@ -3651,8 +3650,8 @@ public function resumeLastPage(&$pdf, $object, $deja_regle, $posy, $outputlangs, $index++; - $total_ht = ($conf->multicurrency->enabled && $invoice->multicurrency_tx != 1) ? $invoice->multicurrency_total_ht : $invoice->total_ht; - $total_ttc = ($conf->multicurrency->enabled && $invoice->multicurrency_tx != 1) ? $invoice->multicurrency_total_ttc : $invoice->total_ttc; + $total_ht = (isModEnabled('multicurrency') && $invoice->multicurrency_tx != 1) ? $invoice->multicurrency_total_ht : $invoice->total_ht; + $total_ttc = (isModEnabled('multicurrency') && $invoice->multicurrency_tx != 1) ? $invoice->multicurrency_total_ttc : $invoice->total_ttc; // Total TTC $pdf->SetXY($posx, $posy + $height * $index); diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index f2e54f08d90de..908d9d2f328d2 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -1268,6 +1268,9 @@ protected function drawInfoTable(&$pdf, $object, $posy, $outputlangs, $outputlan krsort($this->tva_array); + // Clean data type + $object->total_tva = (float) $object->total_tva; + // Show VAT details if ($object->total_tva != 0 && getDolGlobalInt('PDF_INVOICE_SHOW_VAT_ANALYSIS')) { $pdf->SetFillColor(224, 224, 224); @@ -1325,7 +1328,7 @@ protected function drawInfoTable(&$pdf, $object, $posy, $outputlangs, $outputlan } } - // If France, show VAT mention if not applicable + // If France, show VAT mention if applicable if ($this->emetteur->country_code == 'FR' && empty($object->total_tva) && (empty($mysoc->tva_assuj) || ($this->emetteur->isInEEC() && $object->thirdparty->isInEEC()))) { $pdf->SetFont('', '', $default_font_size - 2); $pdf->SetXY($this->marge_gauche, $posy); @@ -1468,7 +1471,7 @@ protected function drawInfoTable(&$pdf, $object, $posy, $outputlangs, $outputlan if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ') { // If payment mode unregulated or payment mode forced to CHQ if (getDolGlobalInt('FACTURE_CHQ_NUMBER')) { - $diffsizetitle = (!getDolGlobalString('PDF_DIFFSIZE_TITLE') ? 3 : $conf->global->PDF_DIFFSIZE_TITLE); + $diffsizetitle = getDolGlobalInt('PDF_DIFFSIZE_TITLE', 3); if (getDolGlobalInt('FACTURE_CHQ_NUMBER') > 0) { $account = new Account($this->db); @@ -1486,7 +1489,7 @@ protected function drawInfoTable(&$pdf, $object, $posy, $outputlangs, $outputlan $posy = $pdf->GetY() + 2; } } - if ($conf->global->FACTURE_CHQ_NUMBER == -1) { + if (getDolGlobalInt('FACTURE_CHQ_NUMBER') == -1) { $pdf->SetXY($this->marge_gauche, $posy); $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle); $pdf->MultiCell($posxend - $this->marge_gauche, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $this->emetteur->name), 0, 'L', 0); @@ -1570,7 +1573,7 @@ protected function drawInfoTable(&$pdf, $object, $posy, $outputlangs, $outputlan */ protected function drawTotalTable(&$pdf, $object, $deja_regle, $posy, $outputlangs, $outputlangsbis) { - global $conf, $mysoc, $hookmanager; + global $mysoc, $hookmanager; $sign = 1; if ($object->type == 2 && getDolGlobalString('INVOICE_POSITIVE_CREDIT_NOTE')) {