New: add possibility to hide vat only if null

This commit is contained in:
Regis Houssin 2012-07-04 16:52:08 +02:00
parent cc4b2bf69c
commit 293eab7676
3 changed files with 377 additions and 360 deletions

View File

@ -627,130 +627,136 @@ class pdf_einstein extends ModelePDFCommandes
$this->atleastoneratenotnull=0; $this->atleastoneratenotnull=0;
if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) 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)
{
// Nothing to do
}
else
{ {
if ($tvakey > 0) // On affiche pas taux 0 foreach($this->tva as $tvakey => $tvaval)
{ {
$this->atleastoneratenotnull++; if ($tvakey > 0) // On affiche pas taux 0
{
$index++; $this->atleastoneratenotnull++;
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
$index++;
$tvacompl=''; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
if (preg_match('/\*/',$tvakey))
{ $tvacompl='';
$tvakey=str_replace('*','',$tvakey); if (preg_match('/\*/',$tvakey))
$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; {
} $tvakey=str_replace('*','',$tvakey);
$totalvat =$outputlangs->transnoentities("TotalVAT").' '; $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
$totalvat.=vatrate($tvakey,1).$tvacompl; }
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); $totalvat =$outputlangs->transnoentities("TotalVAT").' ';
$totalvat.=vatrate($tvakey,1).$tvacompl;
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
$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);
if (! $this->atleastoneratenotnull) // If no vat at all }
{ }
$index++; if (! $this->atleastoneratenotnull) // If no vat at all
$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($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalVAT"), 0, 'L', 1);
$pdf->MultiCell($largcol2, $tab2_hl, price($object->total_tva), 0, 'R', 1);
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
// Total LocalTax1 $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_tva), 0, 'R', 1);
if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on' && $object->total_localtax1>0)
{ // Total LocalTax1
$index++; if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on' && $object->total_localtax1>0)
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); {
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalLT1".$mysoc->country_code), $useborder, 'L', 1); $index++;
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax1), $useborder, 'R', 1); $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')
{
foreach($this->localtax1 as $tvakey => $tvaval)
{
if ($tvakey>0) // On affiche pas taux 0
{
//$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);
}
}
}
//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
{
//$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);
}
}
}
} }
// Total LocalTax2 // Total TTC
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);
$index++; $pdf->SetTextColor(0,0,60);
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); $pdf->SetFillColor(224,224,224);
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalLT2".$mysoc->country_code), $useborder, 'L', 1); $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_localtax2), $useborder, 'R', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
} $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc), $useborder, 'R', 1);
}
else
{
//Local tax 1
if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
{
foreach( $this->localtax1 as $tvakey => $tvaval )
{
if ($tvakey>0) // On affiche pas taux 0
{
//$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);
}
}
}
//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
{
//$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);
}
}
}
} }
} }
// 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);
$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->SetFont('','', $default_font_size - 1);
$pdf->SetTextColor(0,0,0); $pdf->SetTextColor(0,0,0);

View File

@ -743,129 +743,135 @@ class pdf_crabe extends ModelePDFFactures
$this->atleastoneratenotnull=0; $this->atleastoneratenotnull=0;
if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) 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)
{
// Nothing to do
}
else
{ {
if ($tvakey > 0) // On affiche pas taux 0 foreach($this->tva as $tvakey => $tvaval)
{ {
$this->atleastoneratenotnull++; if ($tvakey > 0) // On affiche pas taux 0
{
$index++; $this->atleastoneratenotnull++;
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
$tvacompl=''; $index++;
if (preg_match('/\*/',$tvakey)) $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
{ $tvacompl='';
$tvakey=str_replace('*','',$tvakey); if (preg_match('/\*/',$tvakey))
$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; {
} $tvakey=str_replace('*','',$tvakey);
$totalvat =$outputlangs->transnoentities("TotalVAT").' '; $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
$totalvat.=vatrate($tvakey,1).$tvacompl; }
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); $totalvat =$outputlangs->transnoentities("TotalVAT").' ';
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $totalvat.=vatrate($tvakey,1).$tvacompl;
$pdf->MultiCell($largcol2, $tab2_hl, price($sign * $tvaval), 0, 'R', 1); $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++; if (! $this->atleastoneratenotnull) // If no vat at all
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); {
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalVAT"), 0, 'L', 1); $index++;
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($sign * $object->total_tva), 0, 'R', 1); $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalVAT"), 0, 'L', 1);
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
// Total LocalTax1 $pdf->MultiCell($largcol2, $tab2_hl, price($sign * $object->total_tva), 0, 'R', 1);
if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on' && $object->total_localtax1>0)
{ // Total LocalTax1
$index++; if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on' && $object->total_localtax1>0)
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); {
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalLT1".$mysoc->pays_code), $useborder, 'L', 1); $index++;
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($sign * $object->total_localtax1), $useborder, 'R', 1); $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)
{ // Total LocalTax2
$index++; if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on' && $object->total_localtax2>0)
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); {
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalLT2".$mysoc->pays_code), $useborder, 'L', 1); $index++;
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($sign * $object->total_localtax2), $useborder, 'R', 1); $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 if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
foreach( $this->localtax1 as $tvakey => $tvaval ) {
{ //Local tax 1
if ($tvakey>0) // On affiche pas taux 0 foreach($this->localtax1 as $tvakey => $tvaval)
{ {
//$this->atleastoneratenotnull++; if ($tvakey>0) // On affiche pas taux 0
{
$index++; //$this->atleastoneratenotnull++;
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
$index++;
$tvacompl=''; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
if (preg_match('/\*/',$tvakey))
{ $tvacompl='';
$tvakey=str_replace('*','',$tvakey); if (preg_match('/\*/',$tvakey))
$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; {
} $tvakey=str_replace('*','',$tvakey);
$totalvat =$outputlangs->transnoentities("TotalLT1".$mysoc->pays_code).' '; $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
$totalvat.=vatrate($tvakey,1).$tvacompl; }
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); $totalvat =$outputlangs->transnoentities("TotalLT1".$mysoc->pays_code).' ';
$totalvat.=vatrate($tvakey,1).$tvacompl;
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
$pdf->MultiCell($largcol2, $tab2_hl, price($sign * $tvaval), 0, 'R', 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 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 ($tvakey>0) // On affiche pas taux 0 foreach($this->localtax2 as $tvakey => $tvaval)
{ {
//$this->atleastoneratenotnull++; if ($tvakey>0) // On affiche pas taux 0
{
$index++; //$this->atleastoneratenotnull++;
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
$index++;
$tvacompl=''; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
if (preg_match('/\*/',$tvakey))
{ $tvacompl='';
$tvakey=str_replace('*','',$tvakey); if (preg_match('/\*/',$tvakey))
$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; {
} $tvakey=str_replace('*','',$tvakey);
$totalvat =$outputlangs->transnoentities("TotalLT2".$mysoc->country_code).' '; $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
$totalvat.=vatrate($tvakey,1).$tvacompl; }
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); $totalvat =$outputlangs->transnoentities("TotalLT2".$mysoc->country_code).' ';
$totalvat.=vatrate($tvakey,1).$tvacompl;
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
$pdf->MultiCell($largcol2, $tab2_hl, price($sign * $tvaval), 0, 'R', 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); $pdf->SetTextColor(0,0,0);
$creditnoteamount=$object->getSumCreditNotesUsed(); $creditnoteamount=$object->getSumCreditNotesUsed();

View File

@ -640,136 +640,141 @@ class pdf_azur extends ModelePDFPropales
$this->atleastoneratenotnull=0; $this->atleastoneratenotnull=0;
if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) 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
{
$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($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);
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$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 else
{ {
//Local tax 1 foreach($this->tva 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
foreach( $this->localtax1 as $tvakey => $tvaval ) {
{ $this->atleastoneratenotnull++;
if ($tvakey>0) // On affiche pas taux 0
{ $index++;
//$this->atleastoneratenotnull++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
$index++; $tvacompl='';
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); if (preg_match('/\*/',$tvakey))
{
$tvacompl=''; $tvakey=str_replace('*','',$tvakey);
if (preg_match('/\*/',$tvakey)) $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
{ }
$tvakey=str_replace('*','',$tvakey); $totalvat =$outputlangs->transnoentities("TotalVAT").' ';
$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; $totalvat.=vatrate($tvakey,1).$tvacompl;
} $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
$totalvat = $outputlangs->transnoentities("TotalLT1".$mysoc->pays_code).' ';
$totalvat.=vatrate($tvakey,1).$tvacompl; $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); $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);
} if (! $this->atleastoneratenotnull) // If not vat at all
} {
} $index++;
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
//Local tax 2 $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalVAT"), 0, 'L', 1);
if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
{ $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
foreach( $this->localtax2 as $tvakey => $tvaval ) $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_tva), 0, 'R', 1);
{
if ($tvakey>0) // On affiche pas taux 0 // Total LocalTax1
{ if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on' && $object->total_localtax1>0)
//$this->atleastoneratenotnull++; {
$index++;
$index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $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);
$tvacompl=''; $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax1), 0, 'R', 1);
if (preg_match('/\*/',$tvakey)) }
{
$tvakey=str_replace('*','',$tvakey); // Total LocalTax2
$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on' && $object->total_localtax2>0)
} {
$totalvat = $outputlangs->transnoentities("TotalLT2".$mysoc->pays_code).' '; $index++;
$totalvat.=vatrate($tvakey,1).$tvacompl; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalLT2".$mysoc->pays_code), 0, 'L', 1);
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$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($tvaval), 0, 'R', 1); }
}
} else
} {
} //Local tax 1
if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
{
foreach($this->localtax1 as $tvakey => $tvaval)
{
if ($tvakey>0) // On affiche pas taux 0
{
//$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);
}
}
}
//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
{
//$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->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);
}
}
}
}
$useborder=0;
// 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);
} }
} }
$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);
$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) if ($deja_regle > 0)
{ {
$index++; $index++;