forked from Wavyzz/dolibarr
Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop
This commit is contained in:
@@ -4217,6 +4217,35 @@ function getCurrencySymbol($currency_code)
|
||||
|
||||
return $currency_sign;
|
||||
}
|
||||
/**
|
||||
* Get type of one localtax
|
||||
*
|
||||
* @param int $vatrate VAT Rate
|
||||
* @param int $number Number of localtax (1 / 2)
|
||||
* @param int $thirdparty company object
|
||||
* @return array array(Type of local tax (1 to 7 / 0 if not found), rate or amount of localtax)
|
||||
*/
|
||||
|
||||
function getTypeOfLocalTaxFromRate($vatrate, $number, $thirdparty)
|
||||
{
|
||||
global $db;
|
||||
|
||||
// Search local taxes
|
||||
$sql = "SELECT t.localtax1, t.localtax1_type, t.localtax2, t.localtax2_type";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_pays as p";
|
||||
$sql .= " WHERE t.fk_pays = p.rowid AND p.code = '".$thirdparty->country_code."'";
|
||||
$sql .= " AND t.taux = ".$vatrate." AND t.active = 1";
|
||||
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$obj = $db->fetch_object($resql);
|
||||
if ($number == 1) return array($obj->localtax1_type, $obj->localtax1);
|
||||
elseif ($number == 2) return array($obj->localtax2_type, $obj->localtax2);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (! function_exists('getmypid'))
|
||||
{
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
* Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
|
||||
* Copyright (C) 2008 Raphael Bertrand <raphael.bertrand@resultic.fr>
|
||||
* Copyright (C) 2010-2012 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -117,10 +118,6 @@ class pdf_einstein extends ModelePDFCommandes
|
||||
}
|
||||
|
||||
$this->tva=array();
|
||||
$this->localtax1=array();
|
||||
$this->localtax2=array();
|
||||
$this->localtax1_type=array();
|
||||
$this->localtax2_type=array();
|
||||
$this->atleastoneratenotnull=0;
|
||||
$this->atleastonediscount=0;
|
||||
}
|
||||
@@ -139,7 +136,7 @@ class pdf_einstein extends ModelePDFCommandes
|
||||
*/
|
||||
function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0,$hookmanager=false)
|
||||
{
|
||||
global $user,$langs,$conf;
|
||||
global $user,$langs,$conf,$mysoc,$db;
|
||||
|
||||
if (! is_object($outputlangs)) $outputlangs=$langs;
|
||||
// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
|
||||
@@ -152,6 +149,8 @@ class pdf_einstein extends ModelePDFCommandes
|
||||
$outputlangs->load("products");
|
||||
$outputlangs->load("orders");
|
||||
|
||||
$default_font_size = pdf_getPDFFontSize($outputlangs);
|
||||
|
||||
if ($conf->commande->dir_output)
|
||||
{
|
||||
$object->fetch_thirdparty();
|
||||
@@ -186,7 +185,6 @@ class pdf_einstein extends ModelePDFCommandes
|
||||
|
||||
// Create pdf instance
|
||||
$pdf=pdf_getInstance($this->format);
|
||||
$default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
|
||||
$heightforinfotot = 50; // Height reserved to output the info and total part
|
||||
$heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page
|
||||
$heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
|
||||
@@ -365,6 +363,10 @@ class pdf_einstein extends ModelePDFCommandes
|
||||
|
||||
$localtax1ligne=$object->lines[$i]->total_localtax1;
|
||||
$localtax2ligne=$object->lines[$i]->total_localtax2;
|
||||
$localtax1_rate=$object->lines[$i]->localtax1_tx;
|
||||
$localtax2_rate=$object->lines[$i]->localtax2_tx;
|
||||
$localtax1_type=$object->lines[$i]->localtax1_type;
|
||||
$localtax2_type=$object->lines[$i]->localtax2_type;
|
||||
|
||||
if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100;
|
||||
if ($object->remise_percent) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100;
|
||||
@@ -372,24 +374,30 @@ class pdf_einstein extends ModelePDFCommandes
|
||||
|
||||
$vatrate=(string) $object->lines[$i]->tva_tx;
|
||||
|
||||
// TODO : store local taxes types into object lines and remove this
|
||||
$localtax1_array=getTypeOfLocalTaxFromRate($vatrate,1,$mysoc);
|
||||
$localtax2_array=getTypeOfLocalTaxFromRate($vatrate,2,$mysoc);
|
||||
if (empty($localtax1_type))
|
||||
$localtax1_type = $localtax1_array[0];
|
||||
if (empty($localtax2_type))
|
||||
$localtax2_type = $localtax2_array[0];
|
||||
//end TODO
|
||||
|
||||
// retrieve global local tax
|
||||
if ($localtax1_type == '7')
|
||||
$localtax1_rate = $localtax1_array[1];
|
||||
if ($localtax2_type == '7')
|
||||
$localtax2_rate = $localtax2_array[1];
|
||||
|
||||
if ($localtax1ligne != 0 || $localtax1_type == '7')
|
||||
$this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne;
|
||||
if ($localtax2ligne != 0 || $localtax2_type == '7')
|
||||
$this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne;
|
||||
|
||||
if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*';
|
||||
if (! isset($this->tva[$vatrate])) $this->tva[$vatrate]='';
|
||||
$this->tva[$vatrate] += $tvaligne;
|
||||
|
||||
// Search local taxes
|
||||
$sql = "SELECT t.localtax1, t.localtax1_type, t.localtax2, t.localtax2_type";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_pays as p";
|
||||
$sql .= " WHERE t.fk_pays = p.rowid AND p.code = '".$object->client->country_code."'";
|
||||
$sql .= " AND t.taux = ".$vatrate." AND t.active = 1";
|
||||
|
||||
$resqlt=$this->db->query($sql);
|
||||
if ($resqlt)
|
||||
{
|
||||
$objt = $this->db->fetch_object($resqlt);
|
||||
$this->localtax1[$objt->localtax1_type][$objt->localtax1]+=$localtax1ligne;
|
||||
$this->localtax2[$objt->localtax2_type][$objt->localtax2]+=$localtax2ligne;
|
||||
}
|
||||
|
||||
// Add line
|
||||
if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
|
||||
{
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
* Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
|
||||
* Copyright (C) 2008 Raphael Bertrand <raphael.bertrand@resultic.fr>
|
||||
* Copyright (C) 2010-2012 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -138,7 +139,7 @@ class pdf_crabe extends ModelePDFFactures
|
||||
*/
|
||||
function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0,$hookmanager=false)
|
||||
{
|
||||
global $user,$langs,$conf;
|
||||
global $user,$langs,$conf,$mysoc,$db;
|
||||
|
||||
if (! is_object($outputlangs)) $outputlangs=$langs;
|
||||
// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
|
||||
@@ -365,22 +366,40 @@ class pdf_crabe extends ModelePDFFactures
|
||||
$tvaligne=$object->lines[$i]->total_tva;
|
||||
$localtax1ligne=$object->lines[$i]->total_localtax1;
|
||||
$localtax2ligne=$object->lines[$i]->total_localtax2;
|
||||
$localtax1_rate=$object->lines[$i]->localtax1_tx;
|
||||
$localtax2_rate=$object->lines[$i]->localtax2_tx;
|
||||
$localtax1_type=$object->lines[$i]->localtax1_type;
|
||||
$localtax2_type=$object->lines[$i]->localtax2_type;
|
||||
|
||||
if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100;
|
||||
if ($object->remise_percent) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100;
|
||||
if ($object->remise_percent) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100;
|
||||
|
||||
$vatrate=(string) $object->lines[$i]->tva_tx;
|
||||
$localtax1rate=(string) $object->lines[$i]->localtax1_tx;
|
||||
$localtax2rate=(string) $object->lines[$i]->localtax2_tx;
|
||||
|
||||
// TODO : store local taxes types into object lines and remove this
|
||||
$localtax1_array=getTypeOfLocalTaxFromRate($vatrate,1,$mysoc);
|
||||
$localtax2_array=getTypeOfLocalTaxFromRate($vatrate,2,$mysoc);
|
||||
if (empty($localtax1_type))
|
||||
$localtax1_type = $localtax1_array[0];
|
||||
if (empty($localtax2_type))
|
||||
$localtax2_type = $localtax2_array[0];
|
||||
//end TODO
|
||||
|
||||
// retrieve global local tax
|
||||
if ($localtax1_type == '7')
|
||||
$localtax1_rate = $localtax1_array[1];
|
||||
if ($localtax2_type == '7')
|
||||
$localtax2_rate = $localtax2_array[1];
|
||||
|
||||
if ($localtax1ligne != 0 || $localtax1_type == '7')
|
||||
$this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne;
|
||||
if ($localtax2ligne != 0 || $localtax2_type == '7')
|
||||
$this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne;
|
||||
|
||||
if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*';
|
||||
if (! isset($this->tva[$vatrate])) $this->tva[$vatrate]='';
|
||||
if (! isset($this->localtax1[$localtax1rate])) $this->localtax1[$localtax1rate]='';
|
||||
if (! isset($this->localtax2[$localtax2rate])) $this->localtax2[$localtax2rate]='';
|
||||
$this->tva[$vatrate] += $tvaligne;
|
||||
$this->localtax1[$localtax1rate]+=$localtax1ligne;
|
||||
$this->localtax2[$localtax2rate]+=$localtax2ligne;
|
||||
|
||||
// Add line
|
||||
if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
|
||||
@@ -822,6 +841,84 @@ class pdf_crabe extends ModelePDFFactures
|
||||
}
|
||||
else
|
||||
{
|
||||
//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':
|
||||
continue 2;
|
||||
break;
|
||||
}
|
||||
foreach( $localtax_rate 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 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':
|
||||
continue 2;
|
||||
break;
|
||||
}
|
||||
foreach( $localtax_rate 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);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// VAT
|
||||
foreach($this->tva as $tvakey => $tvaval)
|
||||
{
|
||||
if ($tvakey > 0) // On affiche pas taux 0
|
||||
@@ -830,6 +927,7 @@ class pdf_crabe extends ModelePDFFactures
|
||||
|
||||
$index++;
|
||||
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
|
||||
|
||||
$tvacompl='';
|
||||
if (preg_match('/\*/',$tvakey))
|
||||
{
|
||||
@@ -839,75 +937,71 @@ class pdf_crabe extends ModelePDFFactures
|
||||
$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);
|
||||
$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1);
|
||||
}
|
||||
}
|
||||
|
||||
if (! $this->atleastoneratenotnull) // If no vat at all
|
||||
//Local tax 1 after VAT
|
||||
if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
|
||||
{
|
||||
$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)
|
||||
{
|
||||
$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($sign * $object->total_localtax1), $useborder, 'R', 1);
|
||||
foreach( $this->localtax1 as $localtax_type => $localtax_rate ) {
|
||||
switch ($localtax_type) {
|
||||
case '2':
|
||||
case '4':
|
||||
case '6':
|
||||
continue 2;
|
||||
break;
|
||||
}
|
||||
|
||||
// Total LocalTax2
|
||||
if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on' && $object->total_localtax2>0)
|
||||
foreach( $localtax_rate as $tvakey => $tvaval )
|
||||
{
|
||||
if ($tvakey>0) // On affiche pas taux 0
|
||||
{
|
||||
//$this->atleastoneratenotnull++;
|
||||
|
||||
$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($sign * $object->total_localtax2), $useborder, 'R', 1);
|
||||
|
||||
$tvacompl='';
|
||||
if (preg_match('/\*/',$tvakey))
|
||||
{
|
||||
$tvakey=str_replace('*','',$tvakey);
|
||||
$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
|
||||
}
|
||||
$totalvat = $outputlangs->transnoentities("TotalLT1".$mysoc->pays_code).' ';
|
||||
if ($localtax_type == '7') { // amount on order
|
||||
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
|
||||
|
||||
$pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index);
|
||||
$pdf->MultiCell($largcol2, $tab2_hl, price($tvakey), 0, 'R', 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
|
||||
{
|
||||
//Local tax 1
|
||||
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($sign * $tvaval), 0, 'R', 1);
|
||||
$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
//Local tax 2 after VAT
|
||||
if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
|
||||
{
|
||||
//Local tax 2
|
||||
foreach($this->localtax2 as $tvakey => $tvaval)
|
||||
foreach( $this->localtax2 as $localtax_type => $localtax_rate ) {
|
||||
switch ($localtax_type) {
|
||||
case '2':
|
||||
case '4':
|
||||
case '6':
|
||||
continue 2;
|
||||
break;
|
||||
}
|
||||
foreach( $localtax_rate as $tvakey => $tvaval )
|
||||
{
|
||||
if ($tvakey!=0) // On affiche pas taux 0
|
||||
// retrieve global local tax
|
||||
if ($tvakey>0) // On affiche pas taux 0
|
||||
{
|
||||
//$this->atleastoneratenotnull++;
|
||||
|
||||
@@ -920,12 +1014,21 @@ class pdf_crabe extends ModelePDFFactures
|
||||
$tvakey=str_replace('*','',$tvakey);
|
||||
$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
|
||||
}
|
||||
$totalvat =$outputlangs->transnoentities("TotalLT2".$mysoc->country_code).' ';
|
||||
$totalvat = $outputlangs->transnoentities("TotalLT2".$mysoc->pays_code).' ';
|
||||
|
||||
if ($localtax_type == '7') { // amount on order
|
||||
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
|
||||
$pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index);
|
||||
$pdf->MultiCell($largcol2, $tab2_hl, price($tvakey), 0, 'R', 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
$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);
|
||||
$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -936,11 +1039,10 @@ class pdf_crabe extends ModelePDFFactures
|
||||
$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->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($sign * $object->total_ttc), $useborder, 'R', 1);
|
||||
$pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc), $useborder, 'R', 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -117,10 +117,6 @@ class pdf_azur extends ModelePDFPropales
|
||||
}
|
||||
|
||||
$this->tva=array();
|
||||
$this->localtax1=array();
|
||||
$this->localtax2=array();
|
||||
$this->localtax1_type=array();
|
||||
$this->localtax2_type=array();
|
||||
$this->atleastoneratenotnull=0;
|
||||
$this->atleastonediscount=0;
|
||||
}
|
||||
@@ -139,7 +135,7 @@ class pdf_azur extends ModelePDFPropales
|
||||
*/
|
||||
function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0,$hookmanager=false)
|
||||
{
|
||||
global $user,$langs,$conf;
|
||||
global $user,$langs,$conf,$mysoc,$db;
|
||||
|
||||
if (! is_object($outputlangs)) $outputlangs=$langs;
|
||||
// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
|
||||
@@ -364,31 +360,40 @@ class pdf_azur extends ModelePDFPropales
|
||||
$tvaligne=$object->lines[$i]->total_tva;
|
||||
$localtax1ligne=$object->lines[$i]->total_localtax1;
|
||||
$localtax2ligne=$object->lines[$i]->total_localtax2;
|
||||
$localtax1_rate=$object->lines[$i]->localtax1_tx;
|
||||
$localtax2_rate=$object->lines[$i]->localtax2_tx;
|
||||
$localtax1_type=$object->lines[$i]->localtax1_type;
|
||||
$localtax2_type=$object->lines[$i]->localtax2_type;
|
||||
|
||||
if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100;
|
||||
if ($object->remise_percent) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100;
|
||||
if ($object->remise_percent) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100;
|
||||
|
||||
$vatrate=(string) $object->lines[$i]->tva_tx;
|
||||
// TODO : store local taxes types into object lines and remove this
|
||||
$localtax1_array=getTypeOfLocalTaxFromRate($vatrate,1,$mysoc);
|
||||
$localtax2_array=getTypeOfLocalTaxFromRate($vatrate,2,$mysoc);
|
||||
if (empty($localtax1_type))
|
||||
$localtax1_type = $localtax1_array[0];
|
||||
if (empty($localtax2_type))
|
||||
$localtax2_type = $localtax2_array[0];
|
||||
//end TODO
|
||||
|
||||
// retrieve global local tax
|
||||
if ($localtax1_type == '7')
|
||||
$localtax1_rate = $localtax1_array[1];
|
||||
if ($localtax2_type == '7')
|
||||
$localtax2_rate = $localtax2_array[1];
|
||||
|
||||
if ($localtax1ligne != 0 || $localtax1_type == '7')
|
||||
$this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne;
|
||||
if ($localtax2ligne != 0 || $localtax2_type == '7')
|
||||
$this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne;
|
||||
|
||||
if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*';
|
||||
if (! isset($this->tva[$vatrate])) $this->tva[$vatrate]='';
|
||||
$this->tva[$vatrate] += $tvaligne;
|
||||
|
||||
// Search local taxes
|
||||
$sql = "SELECT t.localtax1, t.localtax1_type, t.localtax2, t.localtax2_type";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_pays as p";
|
||||
$sql .= " WHERE t.fk_pays = p.rowid AND p.code = '".$object->client->country_code."'";
|
||||
$sql .= " AND t.taux = ".$vatrate." AND t.active = 1";
|
||||
|
||||
$resqlt=$this->db->query($sql);
|
||||
if ($resqlt)
|
||||
{
|
||||
$objt = $this->db->fetch_object($resqlt);
|
||||
$this->localtax1[$objt->localtax1_type][$objt->localtax1]+=$localtax1ligne;
|
||||
$this->localtax2[$objt->localtax2_type][$objt->localtax2]+=$localtax2ligne;
|
||||
}
|
||||
|
||||
// Add line
|
||||
if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
|
||||
{
|
||||
|
||||
@@ -934,22 +934,22 @@ else
|
||||
// Local Taxes
|
||||
if($mysoc->localtax1_assuj=="1" && $mysoc->localtax2_assuj=="1")
|
||||
{
|
||||
print '<tr><td>'.$langs->trans("LocalTax1IsUsed").'</td><td>';
|
||||
print '<tr><td>'.$langs->trans("LocalTax1IsUsed",$mysoc->country_code).'</td><td>';
|
||||
print $form->selectyesno('localtax1assuj_value',0,1);
|
||||
print '</td><td>'.$langs->trans("LocalTax2IsUsed").'</td><td>';
|
||||
print '</td><td>'.$langs->trans("LocalTax2IsUsed",$mysoc->country_code).'</td><td>';
|
||||
print $form->selectyesno('localtax2assuj_value',0,1);
|
||||
print '</td></tr>';
|
||||
|
||||
}
|
||||
elseif($mysoc->localtax1_assuj=="1")
|
||||
{
|
||||
print '<tr><td>'.$langs->trans("LocalTax1IsUsed").'</td><td colspan="3">';
|
||||
print '<tr><td>'.$langs->trans("LocalTax1IsUsed",$mysoc->country_code).'</td><td colspan="3">';
|
||||
print $form->selectyesno('localtax1assuj_value',0,1);
|
||||
print '</td><tr>';
|
||||
}
|
||||
elseif($mysoc->localtax2_assuj=="1")
|
||||
{
|
||||
print '<tr><td>'.$langs->trans("LocalTax2IsUsed").'</td><td colspan="3">';
|
||||
print '<tr><td>'.$langs->trans("LocalTax2IsUsed",$mysoc->country_code).'</td><td colspan="3">';
|
||||
print $form->selectyesno('localtax2assuj_value',0,1);
|
||||
print '</td><tr>';
|
||||
}
|
||||
@@ -1351,23 +1351,23 @@ else
|
||||
// Local Taxes
|
||||
if($mysoc->localtax1_assuj=="1" && $mysoc->localtax2_assuj=="1")
|
||||
{
|
||||
print '<tr><td>'.$langs->trans("LocalTax1IsUsedES").'</td><td>';
|
||||
print '<tr><td>'.$langs->trans("LocalTax1IsUsed",$mysoc->country_code).'</td><td>';
|
||||
print $form->selectyesno('localtax1assuj_value',$object->localtax1_assuj,1);
|
||||
print '</td><td>'.$langs->trans("LocalTax2IsUsedES").'</td><td>';
|
||||
print '</td><td>'.$langs->trans("LocalTax2IsUsed",$mysoc->country_code).'</td><td>';
|
||||
print $form->selectyesno('localtax2assuj_value',$object->localtax2_assuj,1);
|
||||
print '</td></tr>';
|
||||
|
||||
}
|
||||
elseif($mysoc->localtax1_assuj=="1")
|
||||
{
|
||||
print '<tr><td>'.$langs->trans("LocalTax1IsUsedES").'</td><td colspan="3">';
|
||||
print '<tr><td>'.$langs->trans("LocalTax1IsUsed",$mysoc->country_code).'</td><td colspan="3">';
|
||||
print $form->selectyesno('localtax1assuj_value',$object->localtax1_assuj,1);
|
||||
print '</td></tr>';
|
||||
|
||||
}
|
||||
elseif($mysoc->localtax2_assuj=="1")
|
||||
{
|
||||
print '<tr><td>'.$langs->trans("LocalTax2IsUsedES").'</td><td colspan="3">';
|
||||
print '<tr><td>'.$langs->trans("LocalTax2IsUsed",$mysoc->country_code).'</td><td colspan="3">';
|
||||
print $form->selectyesno('localtax2assuj_value',$object->localtax2_assuj,1);
|
||||
print '</td></tr>';
|
||||
}
|
||||
@@ -1667,22 +1667,22 @@ else
|
||||
// Local Taxes
|
||||
if($mysoc->localtax1_assuj=="1" && $mysoc->localtax2_assuj=="1")
|
||||
{
|
||||
print '<tr><td>'.$langs->trans("LocalTax1IsUsedES").'</td><td>';
|
||||
print '<tr><td>'.$langs->trans("LocalTax1IsUsed",$mysoc->country_code).'</td><td>';
|
||||
print yn($object->localtax1_assuj);
|
||||
print '</td><td>'.$langs->trans("LocalTax2IsUsedES").'</td><td>';
|
||||
print '</td><td>'.$langs->trans("LocalTax2IsUsed",$mysoc->country_code).'</td><td>';
|
||||
print yn($object->localtax2_assuj);
|
||||
print '</td></tr>';
|
||||
|
||||
}
|
||||
elseif($mysoc->localtax1_assuj=="1")
|
||||
{
|
||||
print '<tr><td>'.$langs->trans("LocalTax1IsUsedES").'</td><td colspan="3">';
|
||||
print '<tr><td>'.$langs->trans("LocalTax1IsUsed",$mysoc->country_code).'</td><td colspan="3">';
|
||||
print yn($object->localtax1_assuj);
|
||||
print '</td><tr>';
|
||||
}
|
||||
elseif($mysoc->localtax2_assuj=="1")
|
||||
{
|
||||
print '<tr><td>'.$langs->trans("LocalTax2IsUsedES").'</td><td colspan="3">';
|
||||
print '<tr><td>'.$langs->trans("LocalTax2IsUsed",$mysoc->country_code).'</td><td colspan="3">';
|
||||
print yn($object->localtax2_assuj);
|
||||
print '</td><tr>';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user