From f3df7a2fecc9442dc98aad13aebd9fc83e58b0a2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 8 Jan 2013 22:59:36 +0100 Subject: [PATCH] Fix: An easier to understand fix. Remove also not recommanded "continue 2" instructions. --- .../commande/doc/pdf_einstein.modules.php | 64 +++++------------ .../modules/facture/doc/pdf_crabe.modules.php | 66 ++++++------------ .../modules/propale/doc/pdf_azur.modules.php | 68 ++++++------------- 3 files changed, 60 insertions(+), 138 deletions(-) diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php index bcfba485824..538599c72db 100644 --- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php @@ -722,20 +722,10 @@ class pdf_einstein extends ModelePDFCommandes //Local tax 1 before VAT if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on') { - foreach( $this->localtax1 as $localtax_type => $localtax_rate ) { - switch ($localtax_type) { - case '1': - case '3': - case '5': - case '7': - //TODO: Place into a function to control showing by country or study better option - if($mysoc->country_code!='ES') - { - continue 2; - break; - } - - } + foreach( $this->localtax1 as $localtax_type => $localtax_rate ) + { + // TODO: Place into a function to control showing by country or study better option + if (in_array((string) $localtax_type, array('1','3','5','7')) && $mysoc->country_code != 'ES') continue; foreach( $localtax_rate as $tvakey => $tvaval ) { if ($tvakey!=0) // On affiche pas taux 0 @@ -761,23 +751,13 @@ class pdf_einstein extends ModelePDFCommandes } } } - //Local tax 2 before VAT + //Local tax 2 before VAT if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on') { - foreach( $this->localtax2 as $localtax_type => $localtax_rate ) { - switch ($localtax_type) { - case '1': - case '3': - case '5': - case '7': - //TODO: Place into a function to control showing by country or study better option - if($mysoc->country_code!='ES') - { - continue 2; - break; - } - - } + foreach( $this->localtax2 as $localtax_type => $localtax_rate ) + { + // TODO: Place into a function to control showing by country or study better option + if (in_array((string) $localtax_type, array('1','3','5','7')) && $mysoc->country_code != 'ES') continue; foreach( $localtax_rate as $tvakey => $tvaval ) { if ($tvakey!=0) // On affiche pas taux 0 @@ -834,14 +814,10 @@ class pdf_einstein extends ModelePDFCommandes //Local tax 1 after VAT if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on') { - foreach( $this->localtax1 as $localtax_type => $localtax_rate ) { - switch ($localtax_type) { - case '2': - case '4': - case '6': - continue 2; - break; - } + foreach( $this->localtax1 as $localtax_type => $localtax_rate ) + { + if (in_array((string) $localtax_type, array('2','4','6'))) continue; + foreach( $localtax_rate as $tvakey => $tvaval ) { if ($tvakey>0) // On affiche pas taux 0 @@ -875,17 +851,13 @@ class pdf_einstein extends ModelePDFCommandes } } } - //Local tax 2 after VAT + //Local tax 2 after VAT if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on') { - foreach( $this->localtax2 as $localtax_type => $localtax_rate ) { - switch ($localtax_type) { - case '2': - case '4': - case '6': - continue 2; - break; - } + foreach( $this->localtax2 as $localtax_type => $localtax_rate ) + { + if (in_array((string) $localtax_type, array('2','4','6'))) continue; + foreach( $localtax_rate as $tvakey => $tvaval ) { if ($tvakey>0) // On affiche pas taux 0 diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index aa883b74ed0..4d4a42d4579 100755 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -852,19 +852,11 @@ class pdf_crabe extends ModelePDFFactures //Local tax 1 before VAT if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on') { - foreach( $this->localtax1 as $localtax_type => $localtax_rate ) { - switch ($localtax_type) { - case '1': - case '3': - case '5': - case '7': - //TODO: Place into a function to control showing by country or study better option - if($mysoc->country_code!='ES') - { - continue 2; - break; - } - } + foreach( $this->localtax1 as $localtax_type => $localtax_rate ) + { + // TODO: Place into a function to control showing by country or study better option + if (in_array((string) $localtax_type, array('1','3','5','7')) && $mysoc->country_code != 'ES') continue; + foreach( $localtax_rate as $tvakey => $tvaval ) { if ($tvakey!=0) // On affiche pas taux 0 @@ -889,23 +881,15 @@ class pdf_crabe extends ModelePDFFactures } } } - } - //Local tax 2 before VAT + } + //Local tax 2 before VAT if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on') { - foreach( $this->localtax2 as $localtax_type => $localtax_rate ) { - switch ($localtax_type) { - case '1': - case '3': - case '5': - case '7': - //TODO: Place into a function to control showing by country or study better option - if($mysoc->country_code!='ES') - { - continue 2; - break; - } - } + foreach( $this->localtax2 as $localtax_type => $localtax_rate ) + { + // TODO: Place into a function to control showing by country or study better option + if (in_array((string) $localtax_type, array('1','3','5','7')) && $mysoc->country_code != 'ES') continue; + foreach( $localtax_rate as $tvakey => $tvaval ) { if ($tvakey!=0) // On affiche pas taux 0 @@ -962,14 +946,10 @@ class pdf_crabe extends ModelePDFFactures //Local tax 1 after VAT if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on') { - foreach( $this->localtax1 as $localtax_type => $localtax_rate ) { - switch ($localtax_type) { - case '2': - case '4': - case '6': - continue 2; - break; - } + foreach( $this->localtax1 as $localtax_type => $localtax_rate ) + { + if (in_array((string) $localtax_type, array('2','4','6'))) continue; + foreach( $localtax_rate as $tvakey => $tvaval ) { if ($tvakey>0) // On affiche pas taux 0 @@ -1003,17 +983,13 @@ class pdf_crabe extends ModelePDFFactures } } } - //Local tax 2 after VAT + //Local tax 2 after VAT if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on') { - foreach( $this->localtax2 as $localtax_type => $localtax_rate ) { - switch ($localtax_type) { - case '2': - case '4': - case '6': - continue 2; - break; - } + foreach( $this->localtax2 as $localtax_type => $localtax_rate ) + { + if (in_array((string) $localtax_type, array('2','4','6'))) continue; + foreach( $localtax_rate as $tvakey => $tvaval ) { // retrieve global local tax diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index 9eaa7ae2788..3a99182f47f 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -755,20 +755,11 @@ class pdf_azur extends ModelePDFPropales //Local tax 1 before VAT if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on') { - foreach( $this->localtax1 as $localtax_type => $localtax_rate ) { - switch ($localtax_type) { - case '1': - case '3': - case '5': - case '7': - //TODO: Place into a function to control showing by country or study better option - if($mysoc->country_code!='ES') - { - continue 2; - break; - } - - } + foreach( $this->localtax1 as $localtax_type => $localtax_rate ) + { + // TODO: Place into a function to control showing by country or study better option + if (in_array((string) $localtax_type, array('1','3','5','7')) && $mysoc->country_code != 'ES') continue; + foreach( $localtax_rate as $tvakey => $tvaval ) { if ($tvakey!=0) // On affiche pas taux 0 @@ -793,24 +784,15 @@ class pdf_azur extends ModelePDFPropales } } } - } - //Local tax 2 before VAT + } + //Local tax 2 before VAT if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on') { - foreach( $this->localtax2 as $localtax_type => $localtax_rate ) { - switch ($localtax_type) { - case '1': - case '3': - case '5': - case '7': - //TODO: Place into a function to control showing by country or study better option - if($mysoc->country_code!='ES') - { - continue 2; - break; - } - - } + foreach( $this->localtax2 as $localtax_type => $localtax_rate ) + { + // TODO: Place into a function to control showing by country or study better option + if (in_array((string) $localtax_type, array('1','3','5','7')) && $mysoc->country_code != 'ES') continue; + foreach( $localtax_rate as $tvakey => $tvaval ) { if ($tvakey!=0) // On affiche pas taux 0 @@ -867,14 +849,10 @@ class pdf_azur extends ModelePDFPropales //Local tax 1 after VAT if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on') { - foreach( $this->localtax1 as $localtax_type => $localtax_rate ) { - switch ($localtax_type) { - case '2': - case '4': - case '6': - continue 2; - break; - } + foreach( $this->localtax1 as $localtax_type => $localtax_rate ) + { + if (in_array((string) $localtax_type, array('2','4','6'))) continue; + foreach( $localtax_rate as $tvakey => $tvaval ) { if ($tvakey>0) // On affiche pas taux 0 @@ -908,17 +886,13 @@ class pdf_azur extends ModelePDFPropales } } } - //Local tax 2 after VAT + //Local tax 2 after VAT if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on') { - foreach( $this->localtax2 as $localtax_type => $localtax_rate ) { - switch ($localtax_type) { - case '2': - case '4': - case '6': - continue 2; - break; - } + foreach( $this->localtax2 as $localtax_type => $localtax_rate ) + { + if (in_array((string) $localtax_type, array('2','4','6'))) continue; + foreach( $localtax_rate as $tvakey => $tvaval ) { if ($tvakey>0) // On affiche pas taux 0