From d6a31f60cdcd9136d6aadb68fb13cb9beac9fde1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 22 Jan 2020 14:39:00 +0100 Subject: [PATCH] Clean code --- htdocs/core/modules/commande/doc/pdf_einstein.modules.php | 6 ++---- .../core/modules/commande/doc/pdf_eratosthene.modules.php | 6 ++---- .../core/modules/expensereport/doc/pdf_standard.modules.php | 2 -- htdocs/core/modules/facture/doc/pdf_crabe.modules.php | 6 ++---- htdocs/core/modules/facture/doc/pdf_sponge.modules.php | 6 ++---- htdocs/core/modules/facture/modules_facture.php | 4 ++++ htdocs/core/modules/livraison/doc/pdf_typhon.modules.php | 2 -- htdocs/core/modules/propale/doc/pdf_azur.modules.php | 6 ++---- htdocs/core/modules/propale/doc/pdf_cyan.modules.php | 6 ++---- .../modules/supplier_invoice/doc/pdf_canelle.modules.php | 2 -- .../core/modules/supplier_order/doc/pdf_cornas.modules.php | 6 ++---- .../modules/supplier_order/doc/pdf_muscadet.modules.php | 6 ++---- .../modules/supplier_payment/doc/pdf_standard.modules.php | 2 -- .../modules/supplier_proposal/doc/pdf_aurore.modules.php | 2 -- 14 files changed, 20 insertions(+), 42 deletions(-) diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php index 6bfee834b9b..e8a09515d91 100644 --- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php @@ -160,8 +160,6 @@ class pdf_einstein extends ModelePDFCommandes $this->option_freetext = 1; // Support add of a personalised text $this->option_draft_watermark = 1; // Support add of a watermark on drafts - $this->franchise=!$mysoc->tva_assuj; - // Get source company $this->emetteur=$mysoc; if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang, -2); // By default, if was not defined @@ -678,13 +676,13 @@ class pdf_einstein extends ModelePDFCommandes protected function _tableau_info(&$pdf, $object, $posy, $outputlangs) { // phpcs:enable - global $conf; + global $conf, $mysoc; $default_font_size = pdf_getPDFFontSize($outputlangs); $pdf->SetFont('', '', $default_font_size - 1); // If France, show VAT mention if not applicable - if ($this->emetteur->country_code == 'FR' && $this->franchise == 1) + if ($this->emetteur->country_code == 'FR' && empty($mysoc->tva_assuj)) { $pdf->SetFont('', 'B', $default_font_size - 2); $pdf->SetXY($this->marge_gauche, $posy); diff --git a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php index d310f176039..29ba0cffc81 100644 --- a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php @@ -160,8 +160,6 @@ class pdf_eratosthene extends ModelePDFCommandes $this->option_freetext = 1; // Support add of a personalised text $this->option_draft_watermark = 1; // Support add of a watermark on drafts - $this->franchise=!$mysoc->tva_assuj; - // Get source company $this->emetteur=$mysoc; if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang, -2); // By default, if was not defined @@ -877,13 +875,13 @@ class pdf_eratosthene extends ModelePDFCommandes */ protected function drawInfoTable(&$pdf, $object, $posy, $outputlangs) { - global $conf; + global $conf, $mysoc; $default_font_size = pdf_getPDFFontSize($outputlangs); $pdf->SetFont('', '', $default_font_size - 1); // If France, show VAT mention if not applicable - if ($this->emetteur->country_code == 'FR' && $this->franchise == 1) + if ($this->emetteur->country_code == 'FR' && empty($mysoc->tva_assuj)) { $pdf->SetFont('', 'B', $default_font_size - 2); $pdf->SetXY($this->marge_gauche, $posy); diff --git a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php index a2cefcf9ff0..3936dccae95 100644 --- a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php @@ -155,8 +155,6 @@ class pdf_standard extends ModeleExpenseReport $this->option_freetext = 1; // Support add of a personalised text $this->option_draft_watermark = 1; // Support add of a watermark on drafts - $this->franchise = !$mysoc->tva_assuj; - // Get source company $this->emetteur=$mysoc; diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index 0f7b892cf9a..9ab176186a6 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -171,8 +171,6 @@ class pdf_crabe extends ModelePDFFactures $this->option_freetext = 1; // Support add of a personalised text $this->option_draft_watermark = 1; // Support add of a watermark on drafts - $this->franchise = !$mysoc->tva_assuj; - // Get source company $this->emetteur = $mysoc; if (empty($this->emetteur->country_code)) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined @@ -965,14 +963,14 @@ class pdf_crabe extends ModelePDFFactures protected function _tableau_info(&$pdf, $object, $posy, $outputlangs) { // phpcs:enable - global $conf; + global $conf, $mysoc; $default_font_size = pdf_getPDFFontSize($outputlangs); $pdf->SetFont('', '', $default_font_size - 1); // If France, show VAT mention if not applicable - if ($this->emetteur->country_code == 'FR' && $this->franchise == 1) + if ($this->emetteur->country_code == 'FR' && empty($mysoc->tva_assuj)) { $pdf->SetFont('', 'B', $default_font_size - 2); $pdf->SetXY($this->marge_gauche, $posy); diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index 70b2a1f989f..ead9b843c06 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -171,8 +171,6 @@ class pdf_sponge extends ModelePDFFactures $this->option_freetext = 1; // Support add of a personalised text $this->option_draft_watermark = 1; // Support add of a watermark on drafts - $this->franchise=!$mysoc->tva_assuj; - // Get source company $this->emetteur=$mysoc; if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang, -2); // By default, if was not defined @@ -1051,14 +1049,14 @@ class pdf_sponge extends ModelePDFFactures */ protected function drawInfoTable(&$pdf, $object, $posy, $outputlangs) { - global $conf; + global $conf, $mysoc; $default_font_size = pdf_getPDFFontSize($outputlangs); $pdf->SetFont('', '', $default_font_size - 1); // If France, show VAT mention if not applicable - if ($this->emetteur->country_code == 'FR' && $this->franchise == 1) + if ($this->emetteur->country_code == 'FR' && empty($mysoc->tva_assuj)) { $pdf->SetFont('', 'B', $default_font_size - 2); $pdf->SetXY($this->marge_gauche, $posy); diff --git a/htdocs/core/modules/facture/modules_facture.php b/htdocs/core/modules/facture/modules_facture.php index ba65eeeca9c..f27f086ec7d 100644 --- a/htdocs/core/modules/facture/modules_facture.php +++ b/htdocs/core/modules/facture/modules_facture.php @@ -42,6 +42,10 @@ abstract class ModelePDFFactures extends CommonDocGenerator */ public $error=''; + public $atleastonediscount = 0; + public $atleastoneratenotnull = 0; + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active generation modules diff --git a/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php b/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php index 00268810ce8..fca1df1386d 100644 --- a/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php +++ b/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php @@ -142,8 +142,6 @@ class pdf_typhon extends ModelePDFDeliveryOrder $this->option_tva = 1; // Manage the vat option FACTURE_TVAOPTION $this->option_codeproduitservice = 1; // Display product-service code - $this->franchise=!$mysoc->tva_assuj; - // Get source company $this->emetteur=$mysoc; if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang, -2); // By default, if was not defined diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index cd0240c4da7..fada0b8a142 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -160,8 +160,6 @@ class pdf_azur extends ModelePDFPropales $this->option_freetext = 1; // Support add of a personalised text $this->option_draft_watermark = 1; // Support add of a watermark on drafts - $this->franchise = !$mysoc->tva_assuj; - // Get source company $this->emetteur = $mysoc; if (empty($this->emetteur->country_code)) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined @@ -866,13 +864,13 @@ class pdf_azur extends ModelePDFPropales protected function _tableau_info(&$pdf, $object, $posy, $outputlangs) { // phpcs:enable - global $conf; + global $conf, $mysoc; $default_font_size = pdf_getPDFFontSize($outputlangs); $pdf->SetFont('', '', $default_font_size - 1); // If France, show VAT mention if not applicable - if ($this->emetteur->country_code == 'FR' && $this->franchise == 1) + if ($this->emetteur->country_code == 'FR' && empty($mysoc->tva_assuj)) { $pdf->SetFont('', 'B', $default_font_size - 2); $pdf->SetXY($this->marge_gauche, $posy); diff --git a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php index 6809f234eda..ed4a3210763 100644 --- a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php @@ -159,8 +159,6 @@ class pdf_cyan extends ModelePDFPropales $this->option_freetext = 1; // Support add of a personalised text $this->option_draft_watermark = 1; // Support add of a watermark on drafts - $this->franchise=!$mysoc->tva_assuj; - // Get source company $this->emetteur=$mysoc; if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang, -2); // By default, if was not defined @@ -978,13 +976,13 @@ class pdf_cyan extends ModelePDFPropales */ public function drawInfoTable(&$pdf, $object, $posy, $outputlangs) { - global $conf; + global $conf, $mysoc; $default_font_size = pdf_getPDFFontSize($outputlangs); $pdf->SetFont('', '', $default_font_size - 1); // If France, show VAT mention if not applicable - if ($this->emetteur->country_code == 'FR' && $this->franchise == 1) + if ($this->emetteur->country_code == 'FR' && empty($mysoc->tva_assuj)) { $pdf->SetFont('', 'B', $default_font_size - 2); $pdf->SetXY($this->marge_gauche, $posy); diff --git a/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php b/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php index bd3ca0002e5..f318237a43e 100644 --- a/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php +++ b/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php @@ -152,8 +152,6 @@ class pdf_canelle extends ModelePDFSuppliersInvoices $this->option_codeproduitservice = 1; // Affiche code produit-service $this->option_multilang = 1; // Dispo en plusieurs langues - $this->franchise = !$mysoc->tva_assuj; - // Define column position $this->posxdesc = $this->marge_gauche + 1; $this->posxtva = 112; 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 fc18f18cca0..2fbeb7ccdca 100644 --- a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php +++ b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php @@ -153,8 +153,6 @@ class pdf_cornas extends ModelePDFSuppliersOrders $this->option_freetext = 1; // Support add of a personalised text $this->option_draft_watermark = 1; // Support add of a watermark on drafts - $this->franchise = !$mysoc->tva_assuj; - // Get source company $this->emetteur = $mysoc; if (empty($this->emetteur->country_code)) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined @@ -835,11 +833,11 @@ class pdf_cornas extends ModelePDFSuppliersOrders protected function _tableau_info(&$pdf, $object, $posy, $outputlangs) { // phpcs:enable - global $conf; + global $conf, $mysoc; $default_font_size = pdf_getPDFFontSize($outputlangs); // If France, show VAT mention if not applicable - if ($this->emetteur->country_code == 'FR' && $this->franchise == 1) + if ($this->emetteur->country_code == 'FR' && empty($mysoc->tva_assuj)) { $pdf->SetFont('', 'B', $default_font_size - 2); $pdf->SetXY($this->marge_gauche, $posy); diff --git a/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php b/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php index 8961644a2aa..2da47c09205 100644 --- a/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php +++ b/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php @@ -153,8 +153,6 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $this->option_freetext = 1; // Support add of a personalised text $this->option_draft_watermark = 1; // Support add of a watermark on drafts - $this->franchise=!$mysoc->tva_assuj; - // Get source company $this->emetteur=$mysoc; if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang, -2); // By default, if was not defined @@ -732,11 +730,11 @@ class pdf_muscadet extends ModelePDFSuppliersOrders protected function _tableau_info(&$pdf, $object, $posy, $outputlangs) { // phpcs:enable - global $conf; + global $conf, $mysoc; $default_font_size = pdf_getPDFFontSize($outputlangs); // If France, show VAT mention if not applicable - if ($this->emetteur->country_code == 'FR' && $this->franchise == 1) + if ($this->emetteur->country_code == 'FR' && empty($mysoc->tva_assuj)) { $pdf->SetFont('', 'B', $default_font_size - 2); $pdf->SetXY($this->marge_gauche, $posy); diff --git a/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php b/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php index e8b97224aad..9979509f027 100644 --- a/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php @@ -142,8 +142,6 @@ class pdf_standard extends ModelePDFSuppliersPayments $this->option_logo = 1; // Affiche logo $this->option_multilang = 1; // Dispo en plusieurs langues - $this->franchise=!$mysoc->tva_assuj; - // Define column position $this->posxdate=$this->marge_gauche+1; $this->posxreffacturefourn=30; diff --git a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php index ff8ab76c674..cb73468f6fd 100644 --- a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php +++ b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php @@ -150,8 +150,6 @@ class pdf_aurore extends ModelePDFSupplierProposal $this->option_freetext = 1; // Support add of a personalised text $this->option_draft_watermark = 1; //Support add of a watermark on drafts - $this->franchise=!$mysoc->tva_assuj; - // Get source company $this->emetteur=$mysoc; if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang, -2); // By default, if was not defined