diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php index 28289c90024cb267d20e154083f8bb7e009ff791..2dbd0bbea8e4c0decf02efdbd1df8fe090c7f5fb 100644 --- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php @@ -627,130 +627,136 @@ class pdf_einstein extends ModelePDFCommandes $this->atleastoneratenotnull=0; if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) { - foreach( $this->tva as $tvakey => $tvaval ) + $tvaisnull=((! empty($this->tva) && count($this->tva) == 1 && $this->tva['0.000'] == (float) 0) ? true : false); + if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_ISNULL) && $tvaisnull) { - if ($tvakey > 0) // On affiche pas taux 0 + // Nothing to do + } + else + { + foreach($this->tva as $tvakey => $tvaval) { - $this->atleastoneratenotnull++; - - $index++; - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - - $tvacompl=''; - if (preg_match('/\*/',$tvakey)) + if ($tvakey > 0) // On affiche pas taux 0 { - $tvakey=str_replace('*','',$tvakey); - $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; - } - $totalvat =$outputlangs->transnoentities("TotalVAT").' '; - $totalvat.=vatrate($tvakey,1).$tvacompl; - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); + $this->atleastoneratenotnull++; - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1); - } - } - if (! $this->atleastoneratenotnull) // If no vat at all - { - $index++; - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalVAT"), 0, 'L', 1); + $index++; + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_tva), 0, 'R', 1); + $tvacompl=''; + if (preg_match('/\*/',$tvakey)) + { + $tvakey=str_replace('*','',$tvakey); + $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; + } + $totalvat =$outputlangs->transnoentities("TotalVAT").' '; + $totalvat.=vatrate($tvakey,1).$tvacompl; + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); - // Total LocalTax1 - if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on' && $object->total_localtax1>0) - { - $index++; - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalLT1".$mysoc->country_code), $useborder, 'L', 1); - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax1), $useborder, 'R', 1); + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1); + } } - - // Total LocalTax2 - if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on' && $object->total_localtax2>0) + if (! $this->atleastoneratenotnull) // If no vat at all { $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalLT2".$mysoc->country_code), $useborder, 'L', 1); + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalVAT"), 0, 'L', 1); + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax2), $useborder, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_tva), 0, 'R', 1); + + // Total LocalTax1 + if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on' && $object->total_localtax1>0) + { + $index++; + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalLT1".$mysoc->country_code), $useborder, 'L', 1); + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax1), $useborder, 'R', 1); + } + + // Total LocalTax2 + if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on' && $object->total_localtax2>0) + { + $index++; + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalLT2".$mysoc->country_code), $useborder, 'L', 1); + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax2), $useborder, 'R', 1); + } } - } - else - { - //Local tax 1 - if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on') + else { - foreach( $this->localtax1 as $tvakey => $tvaval ) + //Local tax 1 + if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on') { - if ($tvakey>0) // On affiche pas taux 0 + foreach($this->localtax1 as $tvakey => $tvaval) { - //$this->atleastoneratenotnull++; - - $index++; - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - - $tvacompl=''; - if (preg_match('/\*/',$tvakey)) + if ($tvakey>0) // On affiche pas taux 0 { - $tvakey=str_replace('*','',$tvakey); - $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; + //$this->atleastoneratenotnull++; + + $index++; + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + + $tvacompl=''; + if (preg_match('/\*/',$tvakey)) + { + $tvakey=str_replace('*','',$tvakey); + $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; + } + $totalvat =$outputlangs->transnoentities("TotalLT1".$mysoc->country_code).' '; + $totalvat.=vatrate($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, 'R', 1); } - $totalvat =$outputlangs->transnoentities("TotalLT1".$mysoc->country_code).' '; - $totalvat.=vatrate($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, 'R', 1); } } - } - //Local tax 2 - if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on') - { - foreach( $this->localtax2 as $tvakey => $tvaval ) + //Local tax 2 + if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on') { - if ($tvakey>0) // On affiche pas taux 0 + foreach($this->localtax2 as $tvakey => $tvaval) { - //$this->atleastoneratenotnull++; - - $index++; - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - - $tvacompl=''; - if (preg_match('/\*/',$tvakey)) + if ($tvakey>0) // On affiche pas taux 0 { - $tvakey=str_replace('*','',$tvakey); - $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; + //$this->atleastoneratenotnull++; + + $index++; + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + + $tvacompl=''; + if (preg_match('/\*/',$tvakey)) + { + $tvakey=str_replace('*','',$tvakey); + $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; + } + $totalvat =$outputlangs->transnoentities("TotalLT2".$mysoc->country_code).' '; + $totalvat.=vatrate($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, 'R', 1); } - $totalvat =$outputlangs->transnoentities("TotalLT2".$mysoc->country_code).' '; - $totalvat.=vatrate($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, 'R', 1); } } } - } - } - // Total TTC - if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) - { - $index++; - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $pdf->SetTextColor(0,0,60); - $pdf->SetFillColor(224,224,224); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1); + // Total TTC + $index++; + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + $pdf->SetTextColor(0,0,60); + $pdf->SetFillColor(224,224,224); + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1); - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc), $useborder, 'R', 1); + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc), $useborder, 'R', 1); + } } + $pdf->SetFont('','', $default_font_size - 1); $pdf->SetTextColor(0,0,0); diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index 5cd9b1f699ae0145f1df2d1ee3821544b5247995..175ce45e26cd7ae2c7a3b78cdcd795e8af495335 100755 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -743,129 +743,135 @@ class pdf_crabe extends ModelePDFFactures $this->atleastoneratenotnull=0; if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) { - foreach( $this->tva as $tvakey => $tvaval ) + $tvaisnull=((! empty($this->tva) && count($this->tva) == 1 && $this->tva['0.000'] == (float) 0) ? true : false); + if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_ISNULL) && $tvaisnull) { - if ($tvakey > 0) // On affiche pas taux 0 + // Nothing to do + } + else + { + foreach($this->tva as $tvakey => $tvaval) { - $this->atleastoneratenotnull++; - - $index++; - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $tvacompl=''; - if (preg_match('/\*/',$tvakey)) + if ($tvakey > 0) // On affiche pas taux 0 { - $tvakey=str_replace('*','',$tvakey); - $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; + $this->atleastoneratenotnull++; + + $index++; + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + $tvacompl=''; + if (preg_match('/\*/',$tvakey)) + { + $tvakey=str_replace('*','',$tvakey); + $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; + } + $totalvat =$outputlangs->transnoentities("TotalVAT").' '; + $totalvat.=vatrate($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($sign * $tvaval), 0, 'R', 1); } - $totalvat =$outputlangs->transnoentities("TotalVAT").' '; - $totalvat.=vatrate($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($sign * $tvaval), 0, 'R', 1); } - } - if (! $this->atleastoneratenotnull) // If no vat at all - { - $index++; - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalVAT"), 0, 'L', 1); - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($sign * $object->total_tva), 0, 'R', 1); - - // Total LocalTax1 - if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on' && $object->total_localtax1>0) + if (! $this->atleastoneratenotnull) // If no vat at all { $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalLT1".$mysoc->pays_code), $useborder, 'L', 1); + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalVAT"), 0, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($sign * $object->total_localtax1), $useborder, 'R', 1); - } + $pdf->MultiCell($largcol2, $tab2_hl, price($sign * $object->total_tva), 0, 'R', 1); - // Total LocalTax2 - if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on' && $object->total_localtax2>0) - { - $index++; - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalLT2".$mysoc->pays_code), $useborder, 'L', 1); - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($sign * $object->total_localtax2), $useborder, 'R', 1); + // Total LocalTax1 + if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on' && $object->total_localtax1>0) + { + $index++; + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalLT1".$mysoc->pays_code), $useborder, 'L', 1); + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($sign * $object->total_localtax1), $useborder, 'R', 1); + } + + // Total LocalTax2 + if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on' && $object->total_localtax2>0) + { + $index++; + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalLT2".$mysoc->pays_code), $useborder, 'L', 1); + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($sign * $object->total_localtax2), $useborder, 'R', 1); + } } - } - else - { - if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on') + else { - //Local tax 1 - foreach( $this->localtax1 as $tvakey => $tvaval ) + if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on') { - if ($tvakey>0) // On affiche pas taux 0 + //Local tax 1 + foreach($this->localtax1 as $tvakey => $tvaval) { - //$this->atleastoneratenotnull++; - - $index++; - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - - $tvacompl=''; - if (preg_match('/\*/',$tvakey)) + if ($tvakey>0) // On affiche pas taux 0 { - $tvakey=str_replace('*','',$tvakey); - $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; + //$this->atleastoneratenotnull++; + + $index++; + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + + $tvacompl=''; + if (preg_match('/\*/',$tvakey)) + { + $tvakey=str_replace('*','',$tvakey); + $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; + } + $totalvat =$outputlangs->transnoentities("TotalLT1".$mysoc->pays_code).' '; + $totalvat.=vatrate($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($sign * $tvaval), 0, 'R', 1); } - $totalvat =$outputlangs->transnoentities("TotalLT1".$mysoc->pays_code).' '; - $totalvat.=vatrate($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($sign * $tvaval), 0, 'R', 1); } } - } - if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on') - { - //Local tax 2 - foreach( $this->localtax2 as $tvakey => $tvaval ) + if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on') { - if ($tvakey>0) // On affiche pas taux 0 + //Local tax 2 + foreach($this->localtax2 as $tvakey => $tvaval) { - //$this->atleastoneratenotnull++; - - $index++; - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - - $tvacompl=''; - if (preg_match('/\*/',$tvakey)) + if ($tvakey>0) // On affiche pas taux 0 { - $tvakey=str_replace('*','',$tvakey); - $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; + //$this->atleastoneratenotnull++; + + $index++; + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + + $tvacompl=''; + if (preg_match('/\*/',$tvakey)) + { + $tvakey=str_replace('*','',$tvakey); + $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; + } + $totalvat =$outputlangs->transnoentities("TotalLT2".$mysoc->country_code).' '; + $totalvat.=vatrate($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($sign * $tvaval), 0, 'R', 1); } - $totalvat =$outputlangs->transnoentities("TotalLT2".$mysoc->country_code).' '; - $totalvat.=vatrate($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($sign * $tvaval), 0, 'R', 1); } } } + + // Total TTC + $index++; + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + $pdf->SetTextColor(0,0,60); + $pdf->SetFillColor(224,224,224); + $text=$outputlangs->transnoentities("TotalTTC"); + if ($object->type == 2) $text=$outputlangs->transnoentities("TotalTTCToYourCredit"); + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $text, $useborder, 'L', 1); + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($sign * $object->total_ttc), $useborder, 'R', 1); } } - // Total TTC - if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) - { - $index++; - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $pdf->SetTextColor(0,0,60); - $pdf->SetFillColor(224,224,224); - $text=$outputlangs->transnoentities("TotalTTC"); - if ($object->type == 2) $text=$outputlangs->transnoentities("TotalTTCToYourCredit"); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $text, $useborder, 'L', 1); - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($sign * $object->total_ttc), $useborder, 'R', 1); - } $pdf->SetTextColor(0,0,0); $creditnoteamount=$object->getSumCreditNotesUsed(); diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index d3e82df991062656f843e924da95f5c0350e1576..984e6ad32c2ed68ed7ce6d24aa14a1fbafc33048 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -640,134 +640,139 @@ class pdf_azur extends ModelePDFPropales $this->atleastoneratenotnull=0; if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) { - foreach( $this->tva as $tvakey => $tvaval ) + $tvaisnull=((! empty($this->tva) && count($this->tva) == 1 && $this->tva['0.000'] == (float) 0) ? true : false); + if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_ISNULL) && $tvaisnull) { - if ($tvakey > 0) // On affiche pas taux 0 + // Nothing to do + } + else + { + foreach($this->tva as $tvakey => $tvaval) { - $this->atleastoneratenotnull++; - - $index++; - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - - $tvacompl=''; - if (preg_match('/\*/',$tvakey)) + if ($tvakey > 0) // On affiche pas taux 0 { - $tvakey=str_replace('*','',$tvakey); - $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; - } - $totalvat =$outputlangs->transnoentities("TotalVAT").' '; - $totalvat.=vatrate($tvakey,1).$tvacompl; - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); + $this->atleastoneratenotnull++; - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1); - } - } - - if (! $this->atleastoneratenotnull) // If not vat at all - { - $index++; - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalVAT"), 0, 'L', 1); + $index++; + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_tva), 0, 'R', 1); + $tvacompl=''; + if (preg_match('/\*/',$tvakey)) + { + $tvakey=str_replace('*','',$tvakey); + $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; + } + $totalvat =$outputlangs->transnoentities("TotalVAT").' '; + $totalvat.=vatrate($tvakey,1).$tvacompl; + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); - // Total LocalTax1 - if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on' && $object->total_localtax1>0) - { - $index++; - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalLT1".$mysoc->pays_code), 0, 'L', 1); - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax1), 0, 'R', 1); + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1); + } } - // Total LocalTax2 - if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on' && $object->total_localtax2>0) + if (! $this->atleastoneratenotnull) // If not vat at all { $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalLT2".$mysoc->pays_code), 0, 'L', 1); + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalVAT"), 0, 'L', 1); + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax2), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_tva), 0, 'R', 1); + + // Total LocalTax1 + if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on' && $object->total_localtax1>0) + { + $index++; + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalLT1".$mysoc->pays_code), 0, 'L', 1); + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax1), 0, 'R', 1); + } + + // Total LocalTax2 + if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on' && $object->total_localtax2>0) + { + $index++; + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalLT2".$mysoc->pays_code), 0, 'L', 1); + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax2), 0, 'R', 1); + } } - } - else - { - //Local tax 1 - if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on') + else { - foreach( $this->localtax1 as $tvakey => $tvaval ) + //Local tax 1 + if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on') { - if ($tvakey>0) // On affiche pas taux 0 + foreach($this->localtax1 as $tvakey => $tvaval) { - //$this->atleastoneratenotnull++; - - $index++; - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - - $tvacompl=''; - if (preg_match('/\*/',$tvakey)) + if ($tvakey>0) // On affiche pas taux 0 { - $tvakey=str_replace('*','',$tvakey); - $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; + //$this->atleastoneratenotnull++; + + $index++; + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + + $tvacompl=''; + if (preg_match('/\*/',$tvakey)) + { + $tvakey=str_replace('*','',$tvakey); + $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; + } + $totalvat = $outputlangs->transnoentities("TotalLT1".$mysoc->pays_code).' '; + $totalvat.=vatrate($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, 'R', 1); } - $totalvat = $outputlangs->transnoentities("TotalLT1".$mysoc->pays_code).' '; - $totalvat.=vatrate($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, 'R', 1); } } - } - //Local tax 2 - if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on') + //Local tax 2 + if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on') { - foreach( $this->localtax2 as $tvakey => $tvaval ) - { - if ($tvakey>0) // On affiche pas taux 0 + foreach($this->localtax2 as $tvakey => $tvaval) { - //$this->atleastoneratenotnull++; + if ($tvakey>0) // On affiche pas taux 0 + { + //$this->atleastoneratenotnull++; - $index++; - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + $index++; + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $tvacompl=''; - if (preg_match('/\*/',$tvakey)) - { - $tvakey=str_replace('*','',$tvakey); - $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; - } - $totalvat = $outputlangs->transnoentities("TotalLT2".$mysoc->pays_code).' '; - $totalvat.=vatrate($tvakey,1).$tvacompl; - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); + $tvacompl=''; + if (preg_match('/\*/',$tvakey)) + { + $tvakey=str_replace('*','',$tvakey); + $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; + } + $totalvat = $outputlangs->transnoentities("TotalLT2".$mysoc->pays_code).' '; + $totalvat.=vatrate($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, 'R', 1); + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1); + } } } - } - } - } + } - $useborder=0; + $useborder=0; - // Total TTC - if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) - { - $index++; - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $pdf->SetTextColor(0,0,60); - $pdf->SetFillColor(224,224,224); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1); + // Total TTC + $index++; + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + $pdf->SetTextColor(0,0,60); + $pdf->SetFillColor(224,224,224); + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1); - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc), $useborder, 'R', 1); - $pdf->SetTextColor(0,0,0); + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc), $useborder, 'R', 1); + $pdf->SetTextColor(0,0,0); + } } if ($deja_regle > 0)