From 0601e71c9149e488ac91b95e3efe4c2a2a8c8a10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Thu, 8 Feb 2024 22:21:45 +0100 Subject: [PATCH] fix warnings --- .../doc/doc_easydoc_order_html.modules.php | 7 +- .../doc/doc_easydoc_contract_html.modules.php | 14 +--- .../doc/doc_easydoc_invoice_html.modules.php | 5 +- .../doc/doc_easydoc_product_html.modules.php | 69 +++++++++---------- .../doc/doc_easydoc_propale_html.modules.php | 5 +- .../doc/doc_easydoc_stock_html.modules.php | 18 ++--- 6 files changed, 57 insertions(+), 61 deletions(-) diff --git a/core/modules/commande/doc/doc_easydoc_order_html.modules.php b/core/modules/commande/doc/doc_easydoc_order_html.modules.php index 6559557..f4f9ccf 100644 --- a/core/modules/commande/doc/doc_easydoc_order_html.modules.php +++ b/core/modules/commande/doc/doc_easydoc_order_html.modules.php @@ -259,7 +259,7 @@ public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails $hookmanager = new HookManager($this->db); } $hookmanager->initHooks(['pdfgeneration']); - $parameters = ['file' => $file, 'object' => $object, 'outputlangs' => $outputlangs]; + $parameters = ['object' => $object, 'outputlangs' => $outputlangs]; global $action; $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks @@ -321,7 +321,7 @@ public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails $this->errors = $e->getMessage(); return -1; } - + $logo = ''; if ($this->emetteur->logo) { $logodir = $conf->mycompany->dir_output; if (!getDolGlobalInt('MAIN_PDF_USE_LARGE_LOGO')) { @@ -352,6 +352,7 @@ public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails $tmparray = explode('_', $mysoc->country_code); $flagImage = empty($tmparray[1]) ? $tmparray[0] : $tmparray[1]; } + $label_payment_conditions = ''; if ($object->cond_reglement_code) { $label_payment_conditions = ($outputlangs->transnoentities("PaymentCondition" . $object->cond_reglement_code) != 'PaymentCondition' . $object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition" . $object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc ? $object->cond_reglement_doc : $object->cond_reglement_label); $label_payment_conditions = str_replace('\n', "\n", $label_payment_conditions); @@ -396,7 +397,7 @@ public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails $substitutionarray = array_merge(getCommonSubstitutionArray($outputlangs, 0, null, $object), $substitutionarray); // Call the ODTSubstitution hook - $parameters = ['file' => $file, 'object' => $object, 'outputlangs' => $outputlangs, 'substitutionarray' => &$substitutionarray]; + $parameters = ['object' => $object, 'outputlangs' => $outputlangs, 'substitutionarray' => &$substitutionarray]; $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Line of free text diff --git a/core/modules/contract/doc/doc_easydoc_contract_html.modules.php b/core/modules/contract/doc/doc_easydoc_contract_html.modules.php index 2508b56..45baeca 100644 --- a/core/modules/contract/doc/doc_easydoc_contract_html.modules.php +++ b/core/modules/contract/doc/doc_easydoc_contract_html.modules.php @@ -259,7 +259,7 @@ public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails $hookmanager = new HookManager($this->db); } $hookmanager->initHooks(['pdfgeneration']); - $parameters = ['file' => $file, 'object' => $object, 'outputlangs' => $outputlangs]; + $parameters = ['object' => $object, 'outputlangs' => $outputlangs]; global $action; $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks @@ -321,7 +321,7 @@ public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails $this->errors = $e->getMessage(); return -1; } - + $logo = ''; if ($this->emetteur->logo) { $logodir = $conf->mycompany->dir_output; if (!getDolGlobalInt('MAIN_PDF_USE_LARGE_LOGO')) { @@ -352,13 +352,6 @@ public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails $tmparray = explode('_', $mysoc->country_code); $flagImage = empty($tmparray[1]) ? $tmparray[0] : $tmparray[1]; } - if ($object->cond_reglement_code) { - $label_payment_conditions = ($outputlangs->transnoentities("PaymentCondition" . $object->cond_reglement_code) != 'PaymentCondition' . $object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition" . $object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc ? $object->cond_reglement_doc : $object->cond_reglement_label); - $label_payment_conditions = str_replace('\n', "\n", $label_payment_conditions); - if ($object->deposit_percent > 0) { - $label_payment_conditions = str_replace('__DEPOSIT_PERCENT__', $object->deposit_percent, $label_payment_conditions); - } - } // If CUSTOMER contact defined on contract, we use it $usecontact = false; $arrayidcontact = $object->getIdContact('external', 'CUSTOMER'); @@ -396,7 +389,7 @@ public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails $substitutionarray = array_merge(getCommonSubstitutionArray($outputlangs, 0, null, $object), $substitutionarray); // Call the ODTSubstitution hook - $parameters = ['file' => $file, 'object' => $object, 'outputlangs' => $outputlangs, 'substitutionarray' => &$substitutionarray]; + $parameters = ['object' => $object, 'outputlangs' => $outputlangs, 'substitutionarray' => &$substitutionarray]; $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Line of free text @@ -458,7 +451,6 @@ public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails 'lines' => [], 'linkedObjects' => $linkedObjects, 'footerinfo' => getPdfPagefoot($outputlangs, $paramfreetext, $mysoc, $object), - 'labelpaymentconditions' => $label_payment_conditions, 'currency' => $currency, 'currencyinfo' => $outputlangs->trans("AmountInCurrency", $outputlangs->trans("Currency" . $currency)), ]); diff --git a/core/modules/facture/doc/doc_easydoc_invoice_html.modules.php b/core/modules/facture/doc/doc_easydoc_invoice_html.modules.php index 31667ae..39e55a0 100644 --- a/core/modules/facture/doc/doc_easydoc_invoice_html.modules.php +++ b/core/modules/facture/doc/doc_easydoc_invoice_html.modules.php @@ -260,7 +260,7 @@ public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails $hookmanager = new HookManager($this->db); } $hookmanager->initHooks(['pdfgeneration']); - $parameters = ['file' => $file, 'object' => $object, 'outputlangs' => $outputlangs]; + $parameters = ['object' => $object, 'outputlangs' => $outputlangs]; global $action; $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks @@ -322,7 +322,7 @@ public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails $this->errors = $e->getMessage(); return -1; } - + $logo = ''; if ($this->emetteur->logo) { $logodir = $conf->mycompany->dir_output; if (!getDolGlobalInt('MAIN_PDF_USE_LARGE_LOGO')) { @@ -353,6 +353,7 @@ public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails $tmparray = explode('_', $mysoc->country_code); $flagImage = empty($tmparray[1]) ? $tmparray[0] : $tmparray[1]; } + $label_payment_conditions = ''; if ($object->cond_reglement_code) { $label_payment_conditions = ($outputlangs->transnoentities("PaymentCondition" . $object->cond_reglement_code) != 'PaymentCondition' . $object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition" . $object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc ? $object->cond_reglement_doc : $object->cond_reglement_label); $label_payment_conditions = str_replace('\n', "\n", $label_payment_conditions); diff --git a/core/modules/product/doc/doc_easydoc_product_html.modules.php b/core/modules/product/doc/doc_easydoc_product_html.modules.php index 89a1d99..a7a8fc9 100644 --- a/core/modules/product/doc/doc_easydoc_product_html.modules.php +++ b/core/modules/product/doc/doc_easydoc_product_html.modules.php @@ -69,7 +69,7 @@ public function __construct($db) // Name of constant that is used to save list of directories to scan $this->scandir = 'PRODUCT_ADDON_EASYDOC_TEMPLATES_PATH'; // Save the name of generated file as the main doc when generating a doc with this template - $this->update_main_doc_field = ((int) DOL_VERSION < 20) ? 0 : 1; + $this->update_main_doc_field = ((int) DOL_VERSION < 21) ? 0 : 1; // Page size for A4 format $this->type = 'pdf'; @@ -259,7 +259,7 @@ public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails $hookmanager = new HookManager($this->db); } $hookmanager->initHooks(['pdfgeneration']); - $parameters = ['file' => $file, 'object' => $object, 'outputlangs' => $outputlangs]; + $parameters = ['object' => $object, 'outputlangs' => $outputlangs]; global $action; $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks @@ -321,7 +321,7 @@ public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails $this->errors = $e->getMessage(); return -1; } - + $logo = ''; if ($this->emetteur->logo) { $logodir = $conf->mycompany->dir_output; if (!getDolGlobalInt('MAIN_PDF_USE_LARGE_LOGO')) { @@ -382,7 +382,7 @@ public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails $substitutionarray = array_merge(getCommonSubstitutionArray($outputlangs, 0, null, $object), $substitutionarray); // Call the ODTSubstitution hook - $parameters = ['file' => $file, 'object' => $object, 'outputlangs' => $outputlangs, 'substitutionarray' => &$substitutionarray]; + $parameters = ['object' => $object, 'outputlangs' => $outputlangs, 'substitutionarray' => &$substitutionarray]; $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Line of free text @@ -407,7 +407,6 @@ public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails 'lines' => [], 'linkedObjects' => $linkedObjects, 'footerinfo' => getPdfPagefoot($outputlangs, $paramfreetext, $mysoc, $object), - 'labelpaymentconditions' => $label_payment_conditions, 'currency' => $currency, 'currencyinfo' => $outputlangs->trans("AmountInCurrency", $outputlangs->trans("Currency" . $currency)), ]); @@ -415,36 +414,36 @@ public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails $subtotal_ht = 0; $subtotal_ttc = 0; $linenumber = 1; - foreach ($object->lines as $key => $line) { - $subtotal_ht += $line->total_ht; - $subtotal_ttc += $line->total_ttc; - if ($line->special_code == 104777 && $line->qty == 99) { - $line->total_ht = $subtotal_ht; - $line->total_ttc = $subtotal_ttc; - $subtotal_ht = 0; - $subtotal_ttc = 0; - } - $substitutions['lines'][$key] = [ - 'linenumber' => $linenumber, - 'qty' => $line->qty, - 'ref' => $line->product_ref, - 'label' => $line->label, - 'description' => $line->desc, - 'product_label' => $line->product_label, - 'product_description' => $line->product_desc, - 'subprice' => price($line->subprice), - 'total_ht' => price($line->total_ht), - 'total_ttc' => price($line->total_ttc), - 'vatrate' => price($line->tva_tx) . '%', - 'special_code' => $line->special_code, - 'product_type' => $line->product_type, - 'line_options' => [], - 'product_options' => [], - ]; - if (empty($line->special_code)) { - $linenumber++; - } - } + // foreach ($object->lines as $key => $line) { + // $subtotal_ht += $line->total_ht; + // $subtotal_ttc += $line->total_ttc; + // if ($line->special_code == 104777 && $line->qty == 99) { + // $line->total_ht = $subtotal_ht; + // $line->total_ttc = $subtotal_ttc; + // $subtotal_ht = 0; + // $subtotal_ttc = 0; + // } + // $substitutions['lines'][$key] = [ + // 'linenumber' => $linenumber, + // 'qty' => $line->qty, + // 'ref' => $line->product_ref, + // 'label' => $line->label, + // 'description' => $line->desc, + // 'product_label' => $line->product_label, + // 'product_description' => $line->product_desc, + // 'subprice' => price($line->subprice), + // 'total_ht' => price($line->total_ht), + // 'total_ttc' => price($line->total_ttc), + // 'vatrate' => price($line->tva_tx) . '%', + // 'special_code' => $line->special_code, + // 'product_type' => $line->product_type, + // 'line_options' => [], + // 'product_options' => [], + // ]; + // if (empty($line->special_code)) { + // $linenumber++; + // } + // } // var_dump($substitutions); $substitutions['debug'] = '
' . print_r($substitutions, true) . '
'; diff --git a/core/modules/propale/doc/doc_easydoc_propale_html.modules.php b/core/modules/propale/doc/doc_easydoc_propale_html.modules.php index bf4de73..4391c3b 100644 --- a/core/modules/propale/doc/doc_easydoc_propale_html.modules.php +++ b/core/modules/propale/doc/doc_easydoc_propale_html.modules.php @@ -260,7 +260,7 @@ public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails $hookmanager = new HookManager($this->db); } $hookmanager->initHooks(['pdfgeneration']); - $parameters = ['file' => $file, 'object' => $object, 'outputlangs' => $outputlangs]; + $parameters = ['object' => $object, 'outputlangs' => $outputlangs]; global $action; $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks @@ -322,7 +322,7 @@ public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails $this->errors = $e->getMessage(); return -1; } - + $logo = ''; if ($this->emetteur->logo) { $logodir = $conf->mycompany->dir_output; if (!getDolGlobalInt('MAIN_PDF_USE_LARGE_LOGO')) { @@ -353,6 +353,7 @@ public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails $tmparray = explode('_', $mysoc->country_code); $flagImage = empty($tmparray[1]) ? $tmparray[0] : $tmparray[1]; } + $label_payment_conditions = ''; if ($object->cond_reglement_code) { $label_payment_conditions = ($outputlangs->transnoentities("PaymentCondition" . $object->cond_reglement_code) != 'PaymentCondition' . $object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition" . $object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc ? $object->cond_reglement_doc : $object->cond_reglement_label); $label_payment_conditions = str_replace('\n', "\n", $label_payment_conditions); diff --git a/core/modules/stock/doc/doc_easydoc_stock_html.modules.php b/core/modules/stock/doc/doc_easydoc_stock_html.modules.php index 0e6e6e1..ff3b338 100644 --- a/core/modules/stock/doc/doc_easydoc_stock_html.modules.php +++ b/core/modules/stock/doc/doc_easydoc_stock_html.modules.php @@ -260,7 +260,7 @@ public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails $hookmanager = new HookManager($this->db); } $hookmanager->initHooks(['pdfgeneration']); - $parameters = ['file' => $file, 'object' => $object, 'outputlangs' => $outputlangs]; + $parameters = ['object' => $object, 'outputlangs' => $outputlangs]; global $action; $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks @@ -322,7 +322,7 @@ public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails $this->errors = $e->getMessage(); return -1; } - + $logo = ''; if ($this->emetteur->logo) { $logodir = $conf->mycompany->dir_output; if (!getDolGlobalInt('MAIN_PDF_USE_LARGE_LOGO')) { @@ -390,7 +390,7 @@ public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails $substitutionarray = array_merge(getCommonSubstitutionArray($outputlangs, 0, null, $object), $substitutionarray); // Call the ODTSubstitution hook - $parameters = ['file' => $file, 'object' => $object, 'outputlangs' => $outputlangs, 'substitutionarray' => &$substitutionarray]; + $parameters = ['object' => $object, 'outputlangs' => $outputlangs, 'substitutionarray' => &$substitutionarray]; $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Line of free text @@ -409,10 +409,12 @@ public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails $substitutions = array_merge($substitutions, getEachVarObject($object, $outputlangs, 0)); // thirdparty - $substitutions = array_merge($substitutions, getEachVarObject($object->thirdparty, $outputlangs, 1, 'thirdparty')); - $substitutions['thirdparty']['flag'] = DOL_DOCUMENT_ROOT . '/theme/common/flags/' . strtolower($object->thirdparty->country_code) . '.png'; - $substitutions['thirdparty']['phone_formatted'] = dol_print_phone($object->thirdparty->phone, $object->thirdparty->country_code, 0, 0, '', ' '); - $substitutions['thirdparty']['fax_formatted'] = dol_print_phone($object->thirdparty->fax, $object->thirdparty->country_code, 0, 0, '', ' '); + if (!empty($object->thirdparty)) { + $substitutions = array_merge($substitutions, getEachVarObject($object->thirdparty, $outputlangs, 1, 'thirdparty')); + $substitutions['thirdparty']['flag'] = DOL_DOCUMENT_ROOT . '/theme/common/flags/' . strtolower($object->thirdparty->country_code) . '.png'; + $substitutions['thirdparty']['phone_formatted'] = dol_print_phone($object->thirdparty->phone, $object->thirdparty->country_code, 0, 0, '', ' '); + $substitutions['thirdparty']['fax_formatted'] = dol_print_phone($object->thirdparty->fax, $object->thirdparty->country_code, 0, 0, '', ' '); + } $typescontact = [ 'external' => [ @@ -508,7 +510,7 @@ public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails $mpdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); $mpdf->SetCreator('Dolibarr ' . DOL_VERSION); $mpdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); - $mpdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref) . " " . $outputlangs->transnoentities("PdfStockTitle") . " " . $outputlangs->convToOutputCharset($object->thirdparty->name)); + $mpdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref) . " " . $outputlangs->transnoentities("PdfStockTitle")); // Watermark $text = getDolGlobalString('STOCK_DRAFT_WATERMARK'); $substitutionarray = pdf_getSubstitutionArray($outputlangs, null, null);