Fix: credit note support on pdf invoice
This commit is contained in:
parent
4250c4c982
commit
3ada34c736
@ -44,12 +44,12 @@ class DiscountAbsolute
|
|||||||
var $datec; // Date creation
|
var $datec; // Date creation
|
||||||
var $fk_facture_line; // Id invoice line when a discount linked to invoice line
|
var $fk_facture_line; // Id invoice line when a discount linked to invoice line
|
||||||
var $fk_facture; // Id invoice when a discoutn linked to invoice
|
var $fk_facture; // Id invoice when a discoutn linked to invoice
|
||||||
var $fk_facture_source; // Id facture avoir à l'origine de la remise
|
var $fk_facture_source; // Id facture avoir <EFBFBD> l'origine de la remise
|
||||||
var $ref_facture_source; // Ref facture avoir à l'origine de la remise
|
var $ref_facture_source; // Ref facture avoir <EFBFBD> l'origine de la remise
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Constructeur de la classe
|
* \brief Constructeur de la classe
|
||||||
* \param DB handler accès base de données
|
* \param DB handler acc<EFBFBD>s base de donn<EFBFBD>es
|
||||||
*/
|
*/
|
||||||
function DiscountAbsolute($DB)
|
function DiscountAbsolute($DB)
|
||||||
{
|
{
|
||||||
@ -59,9 +59,9 @@ class DiscountAbsolute
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Charge objet remise depuis la base
|
* \brief Charge objet remise depuis la base
|
||||||
* \param rowid id du projet à charger
|
* \param rowid id du projet <EFBFBD> charger
|
||||||
* \param fk_facture_source fk_facture_source
|
* \param fk_facture_source fk_facture_source
|
||||||
* \return int <0 si ko, =0 si non trouvé, >0 si ok
|
* \return int <0 si ko, =0 si non trouv<EFBFBD>, >0 si ok
|
||||||
*/
|
*/
|
||||||
function fetch($rowid,$fk_facture_source=0)
|
function fetch($rowid,$fk_facture_source=0)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -393,9 +393,9 @@ class Facture extends CommonObject
|
|||||||
function createFromClone($fromid,$invertdetail=0)
|
function createFromClone($fromid,$invertdetail=0)
|
||||||
{
|
{
|
||||||
global $user,$langs;
|
global $user,$langs;
|
||||||
|
|
||||||
$error=0;
|
$error=0;
|
||||||
|
|
||||||
$object=new Facture($this->db);
|
$object=new Facture($this->db);
|
||||||
|
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
@ -415,24 +415,24 @@ class Facture extends CommonObject
|
|||||||
$object->close_code = '';
|
$object->close_code = '';
|
||||||
$object->close_note = '';
|
$object->close_note = '';
|
||||||
$object->products = $object->lignes; // Tant que products encore utilisé
|
$object->products = $object->lignes; // Tant que products encore utilisé
|
||||||
|
|
||||||
// Create clone
|
// Create clone
|
||||||
$result=$object->create($user);
|
$result=$object->create($user);
|
||||||
|
|
||||||
// Other options
|
// Other options
|
||||||
if ($result < 0)
|
if ($result < 0)
|
||||||
{
|
{
|
||||||
$this->error=$object->error;
|
$this->error=$object->error;
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $error)
|
if (! $error)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// End
|
// End
|
||||||
if (! $error)
|
if (! $error)
|
||||||
{
|
{
|
||||||
@ -682,7 +682,7 @@ class Facture extends CommonObject
|
|||||||
{
|
{
|
||||||
global $conf, $langs;
|
global $conf, $langs;
|
||||||
$error=0;
|
$error=0;
|
||||||
|
|
||||||
// Clean parameters
|
// Clean parameters
|
||||||
|
|
||||||
if (isset($this->facnumber)) $this->facnumber=trim($this->ref);
|
if (isset($this->facnumber)) $this->facnumber=trim($this->ref);
|
||||||
@ -711,7 +711,7 @@ class Facture extends CommonObject
|
|||||||
if (isset($this->note_public)) $this->note_public=trim($this->note_public);
|
if (isset($this->note_public)) $this->note_public=trim($this->note_public);
|
||||||
if (isset($this->modelpdf)) $this->modelpdf=trim($this->modelpdf);
|
if (isset($this->modelpdf)) $this->modelpdf=trim($this->modelpdf);
|
||||||
if (isset($this->import_key)) $this->import_key=trim($this->import_key);
|
if (isset($this->import_key)) $this->import_key=trim($this->import_key);
|
||||||
|
|
||||||
// Check parameters
|
// Check parameters
|
||||||
// Put here code to add control on parameters values
|
// Put here code to add control on parameters values
|
||||||
|
|
||||||
@ -1913,15 +1913,15 @@ class Facture extends CommonObject
|
|||||||
{
|
{
|
||||||
$obj = $this->db->fetch_object($resql);
|
$obj = $this->db->fetch_object($resql);
|
||||||
if ($obj)
|
if ($obj)
|
||||||
{
|
{
|
||||||
// Si il y en a
|
// Si il y en a
|
||||||
return $obj->rowid;
|
return $obj->rowid;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Si aucune facture ne remplace
|
// Si aucune facture ne remplace
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -2167,7 +2167,7 @@ class Facture extends CommonObject
|
|||||||
if ($this->statut >= 0 && $this->paye == 0)
|
if ($this->statut >= 0 && $this->paye == 0)
|
||||||
{
|
{
|
||||||
// Define cond_reglement_id and datelim
|
// Define cond_reglement_id and datelim
|
||||||
if (strval($date) != '')
|
if (strval($date) != '')
|
||||||
{
|
{
|
||||||
$datelim=$date;
|
$datelim=$date;
|
||||||
$cond_reglement_id=0;
|
$cond_reglement_id=0;
|
||||||
@ -2343,8 +2343,8 @@ class Facture extends CommonObject
|
|||||||
while ($obj=$this->db->fetch_object($resql))
|
while ($obj=$this->db->fetch_object($resql))
|
||||||
{
|
{
|
||||||
$return[$obj->rowid]=array( 'id' => $obj->rowid,
|
$return[$obj->rowid]=array( 'id' => $obj->rowid,
|
||||||
'ref' => $obj->facnumber,
|
'ref' => $obj->facnumber,
|
||||||
'status' => $obj->fk_statut);
|
'status' => $obj->fk_statut);
|
||||||
}
|
}
|
||||||
//print_r($return);
|
//print_r($return);
|
||||||
return $return;
|
return $return;
|
||||||
@ -2361,7 +2361,7 @@ class Facture extends CommonObject
|
|||||||
/**
|
/**
|
||||||
* \brief Renvoi liste des factures qualifiables pour correction par avoir
|
* \brief Renvoi liste des factures qualifiables pour correction par avoir
|
||||||
* Les factures qui respectent les regles suivantes sont retournees:
|
* Les factures qui respectent les regles suivantes sont retournees:
|
||||||
* (validée + paiement en cours) ou classée (payée completement ou payée partiellement) + pas deja remplacée + pas deja avoir
|
* (validée + paiement en cours) ou classée (payée completement ou payée partiellement) + pas deja remplacée + pas deja avoi
|
||||||
* \param socid Id societe
|
* \param socid Id societe
|
||||||
* \return array Tableau des factures ($id => $ref)
|
* \return array Tableau des factures ($id => $ref)
|
||||||
*/
|
*/
|
||||||
@ -2423,7 +2423,7 @@ class Facture extends CommonObject
|
|||||||
$soc = new Societe($this->db);
|
$soc = new Societe($this->db);
|
||||||
$soc->id = $this->socid;
|
$soc->id = $this->socid;
|
||||||
$soc->load_ban();
|
$soc->load_ban();
|
||||||
|
|
||||||
if ($this->statut > 0 && $this->paye == 0 && $this->mode_reglement_id == 3)
|
if ($this->statut > 0 && $this->paye == 0 && $this->mode_reglement_id == 3)
|
||||||
{
|
{
|
||||||
$sql = 'SELECT count(*) FROM '.MAIN_DB_PREFIX.'prelevement_facture_demande';
|
$sql = 'SELECT count(*) FROM '.MAIN_DB_PREFIX.'prelevement_facture_demande';
|
||||||
|
|||||||
@ -469,7 +469,9 @@ class pdf_crabe extends ModelePDFFactures
|
|||||||
|
|
||||||
$y=0;
|
$y=0;
|
||||||
|
|
||||||
// Loop on each credit note included
|
$pdf->SetFont('Arial','',6);
|
||||||
|
|
||||||
|
// Loop on each credit note included
|
||||||
$sql = "SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,";
|
$sql = "SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,";
|
||||||
$sql.= " re.description, re.fk_facture_source, re.fk_facture_source";
|
$sql.= " re.description, re.fk_facture_source, re.fk_facture_source";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX ."societe_remise_except as re";
|
$sql.= " FROM ".MAIN_DB_PREFIX ."societe_remise_except as re";
|
||||||
@ -516,7 +518,6 @@ class pdf_crabe extends ModelePDFFactures
|
|||||||
$resql=$this->db->query($sql);
|
$resql=$this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
$pdf->SetFont('Arial','',6);
|
|
||||||
$num = $this->db->num_rows($resql);
|
$num = $this->db->num_rows($resql);
|
||||||
$i=0;
|
$i=0;
|
||||||
while ($i < $num) {
|
while ($i < $num) {
|
||||||
@ -729,16 +730,15 @@ class pdf_crabe extends ModelePDFFactures
|
|||||||
// Tableau total
|
// Tableau total
|
||||||
$lltot = 200; $col1x = 120; $col2x = 182; $largcol2 = $lltot - $col2x;
|
$lltot = 200; $col1x = 120; $col2x = 182; $largcol2 = $lltot - $col2x;
|
||||||
|
|
||||||
|
$index = 0;
|
||||||
|
|
||||||
// Total HT
|
// Total HT
|
||||||
$pdf->SetFillColor(255,255,255);
|
$pdf->SetFillColor(255,255,255);
|
||||||
$pdf->SetXY ($col1x, $tab2_top + 0);
|
$pdf->SetXY ($col1x, $tab2_top + 0);
|
||||||
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
|
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
|
||||||
|
|
||||||
$pdf->SetXY ($col2x, $tab2_top + 0);
|
$pdf->SetXY ($col2x, $tab2_top + 0);
|
||||||
$pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ht + $object->remise), 0, 'R', 1);
|
$pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ht + $object->remise), 0, 'R', 1);
|
||||||
|
|
||||||
$index = 0;
|
|
||||||
|
|
||||||
// Affichage des totaux de TVA par taux (conformement a la reglementation)
|
// Affichage des totaux de TVA par taux (conformement a la reglementation)
|
||||||
$pdf->SetFillColor(248,248,248);
|
$pdf->SetFillColor(248,248,248);
|
||||||
|
|
||||||
@ -750,7 +750,6 @@ class pdf_crabe extends ModelePDFFactures
|
|||||||
|
|
||||||
$index++;
|
$index++;
|
||||||
$pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index);
|
$pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index);
|
||||||
|
|
||||||
$tvacompl='';
|
$tvacompl='';
|
||||||
if (eregi('\*',$tvakey))
|
if (eregi('\*',$tvakey))
|
||||||
{
|
{
|
||||||
@ -760,7 +759,6 @@ class pdf_crabe extends ModelePDFFactures
|
|||||||
$totalvat =$outputlangs->transnoentities("TotalVAT").' ';
|
$totalvat =$outputlangs->transnoentities("TotalVAT").' ';
|
||||||
$totalvat.=vatrate($tvakey,1).$tvacompl;
|
$totalvat.=vatrate($tvakey,1).$tvacompl;
|
||||||
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
|
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 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($tvaval), 0, 'R', 1);
|
$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1);
|
||||||
}
|
}
|
||||||
@ -770,13 +768,13 @@ class pdf_crabe extends ModelePDFFactures
|
|||||||
$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("TotalVAT"), 0, 'L', 1);
|
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalVAT"), 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_tva), 0, 'R', 1);
|
$pdf->MultiCell($largcol2, $tab2_hl, price($object->total_tva), 0, 'R', 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
$useborder=0;
|
$useborder=0;
|
||||||
|
|
||||||
|
// Total TTC
|
||||||
$index++;
|
$index++;
|
||||||
$pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index);
|
$pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index);
|
||||||
$pdf->SetTextColor(0,0,60);
|
$pdf->SetTextColor(0,0,60);
|
||||||
@ -784,24 +782,37 @@ class pdf_crabe extends ModelePDFFactures
|
|||||||
$text=$outputlangs->transnoentities("TotalTTC");
|
$text=$outputlangs->transnoentities("TotalTTC");
|
||||||
if ($object->type == 2) $text=$outputlangs->transnoentities("TotalTTCToYourCredit");
|
if ($object->type == 2) $text=$outputlangs->transnoentities("TotalTTCToYourCredit");
|
||||||
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $text, $useborder, 'L', 1);
|
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $text, $useborder, '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_ttc), $useborder, 'R', 1);
|
$pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc), $useborder, 'R', 1);
|
||||||
$pdf->SetTextColor(0,0,0);
|
$pdf->SetTextColor(0,0,0);
|
||||||
|
|
||||||
if ($deja_regle > 0)
|
$creditnoteamount=$object->getSommeCreditNote();
|
||||||
|
$resteapayer = $object->total_ttc - $deja_regle - $creditnoteamount;
|
||||||
|
if ($object->paye) $resteapayer=0;
|
||||||
|
|
||||||
|
if ($deja_regle > 0 || $creditnoteamount > 0)
|
||||||
{
|
{
|
||||||
|
// Already payed
|
||||||
$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("AlreadyPayed"), 0, 'L', 0);
|
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPayed"), 0, 'L', 0);
|
||||||
|
|
||||||
$pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index);
|
$pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index);
|
||||||
$pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle), 0, 'R', 0);
|
$pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle), 0, 'R', 0);
|
||||||
|
|
||||||
$resteapayer = $object->total_ttc - $deja_regle;
|
// Credit note
|
||||||
|
if ($creditnoteamount)
|
||||||
|
{
|
||||||
|
$index++;
|
||||||
|
$pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index);
|
||||||
|
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("CreditNotes"), 0, 'L', 0);
|
||||||
|
$pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index);
|
||||||
|
$pdf->MultiCell($largcol2, $tab2_hl, price($creditnoteamount), 0, 'R', 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
$resteapayer = $object->total_ttc - $deja_regle - $creditnoteamount;
|
||||||
if ($object->paye) $resteapayer=0;
|
if ($object->paye) $resteapayer=0;
|
||||||
|
|
||||||
|
// Escompte
|
||||||
if ($object->close_code == 'discount_vat')
|
if ($object->close_code == 'discount_vat')
|
||||||
{
|
{
|
||||||
$index++;
|
$index++;
|
||||||
@ -809,19 +820,17 @@ class pdf_crabe extends ModelePDFFactures
|
|||||||
|
|
||||||
$pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index);
|
$pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index);
|
||||||
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("EscompteOffered"), $useborder, 'L', 1);
|
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("EscompteOffered"), $useborder, '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_ttc - $deja_regle), $useborder, 'R', 1);
|
$pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc - $deja_regle), $useborder, 'R', 1);
|
||||||
|
|
||||||
$resteapayer=0;
|
$resteapayer=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
$index++;
|
$index++;
|
||||||
$pdf->SetTextColor(0,0,60);
|
$pdf->SetTextColor(0,0,60);
|
||||||
$pdf->SetFillColor(224,224,224);
|
$pdf->SetFillColor(224,224,224);
|
||||||
$pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index);
|
$pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index);
|
||||||
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1);
|
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1);
|
||||||
|
|
||||||
$pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index);
|
$pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index);
|
||||||
$pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer), $useborder, 'R', 1);
|
$pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer), $useborder, 'R', 1);
|
||||||
|
|
||||||
|
|||||||
@ -311,7 +311,7 @@ class pdf_oursin extends ModelePDFFactures
|
|||||||
$pdf->MultiCell(80, 5, $titre, 0, 'L');
|
$pdf->MultiCell(80, 5, $titre, 0, 'L');
|
||||||
$pdf->SetFont('Arial','',10);
|
$pdf->SetFont('Arial','',10);
|
||||||
$pdf->SetXY($this->marges['g']+44, 217);
|
$pdf->SetXY($this->marges['g']+44, 217);
|
||||||
$lib_condition_paiement=$outputlangs->transnoentities("PaymentCondition".$fac->cond_reglement_code)!=('PaymentCondition'.$fac->cond_reglement_code)?$outputlangs->transnoentities("PaymentCondition".$fac->cond_reglement_code):$fac->cond_reglement;
|
$lib_condition_paiement=$outputlangs->transnoentities("PaymentCondition".$fac->cond_reglement_code)!=('PaymentCondition'.$fac->cond_reglement_code)?$outputlangs->transnoentities("PaymentCondition".$fac->cond_reglement_code):$outputlangs->convToOutputCharset($fac->cond_reglement);
|
||||||
$pdf->MultiCell(80, 5, $lib_condition_paiement,0,'L');
|
$pdf->MultiCell(80, 5, $lib_condition_paiement,0,'L');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -358,7 +358,7 @@ class pdf_oursin extends ModelePDFFactures
|
|||||||
function _tableau_versements(&$pdf, $fac, $posy, $outputlangs)
|
function _tableau_versements(&$pdf, $fac, $posy, $outputlangs)
|
||||||
{
|
{
|
||||||
$tab3_posx = $this->marges['g']+110;
|
$tab3_posx = $this->marges['g']+110;
|
||||||
$tab3_top = $this->marges['h']+235;
|
$tab3_top = $posy + 8;
|
||||||
$tab3_width = 80;
|
$tab3_width = 80;
|
||||||
$tab3_height = 4;
|
$tab3_height = 4;
|
||||||
|
|
||||||
@ -379,6 +379,8 @@ class pdf_oursin extends ModelePDFFactures
|
|||||||
|
|
||||||
$y=0;
|
$y=0;
|
||||||
|
|
||||||
|
$pdf->SetFont('Arial','',6);
|
||||||
|
|
||||||
// Loop on each credit note included
|
// Loop on each credit note included
|
||||||
$sql = "SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,";
|
$sql = "SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,";
|
||||||
$sql.= " re.description, re.fk_facture_source, re.fk_facture_source";
|
$sql.= " re.description, re.fk_facture_source, re.fk_facture_source";
|
||||||
@ -426,7 +428,6 @@ class pdf_oursin extends ModelePDFFactures
|
|||||||
$resql=$this->db->query($sql);
|
$resql=$this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
$pdf->SetFont('Arial','',6);
|
|
||||||
$num = $this->db->num_rows($resql);
|
$num = $this->db->num_rows($resql);
|
||||||
$i=0;
|
$i=0;
|
||||||
while ($i < $num)
|
while ($i < $num)
|
||||||
@ -508,48 +509,73 @@ class pdf_oursin extends ModelePDFFactures
|
|||||||
$pdf->MultiCell(100, $tab2_hl, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0);
|
$pdf->MultiCell(100, $tab2_hl, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tableau total
|
$index = 0;
|
||||||
|
|
||||||
|
// Total TTC
|
||||||
$col1x=$this->marges['g']+110; $col2x=$this->marges['g']+164;
|
$col1x=$this->marges['g']+110; $col2x=$this->marges['g']+164;
|
||||||
$pdf->SetXY ($col1x, $tab2_top + 0);
|
$pdf->SetXY ($col1x, $tab2_top + 0);
|
||||||
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 0);
|
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 0);
|
||||||
|
|
||||||
$pdf->SetXY ($col2x, $tab2_top + 0);
|
$pdf->SetXY ($col2x, $tab2_top + 0);
|
||||||
$pdf->MultiCell(26, $tab2_hl, price($fac->total_ht + $fac->remise), 0, 'R', 0);
|
$pdf->MultiCell(26, $tab2_hl, price($fac->total_ht + $fac->remise), 0, 'R', 0);
|
||||||
|
|
||||||
$index = 1;
|
// Total VAT
|
||||||
|
$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("TotalVAT"), 0, 'L', 0);
|
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalVAT"), 0, 'L', 0);
|
||||||
|
|
||||||
$pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index);
|
$pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index);
|
||||||
$pdf->MultiCell(26, $tab2_hl, price($fac->total_tva), 0, 'R', 0);
|
$pdf->MultiCell(26, $tab2_hl, price($fac->total_tva), 0, 'R', 0);
|
||||||
|
|
||||||
$pdf->SetXY ($col1x, $tab2_top + $tab2_hl * ($index+1));
|
// Total TTC
|
||||||
|
$index++;
|
||||||
|
$pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index);
|
||||||
$pdf->SetTextColor(22,137,210);
|
$pdf->SetTextColor(22,137,210);
|
||||||
$pdf->SetFont('Arial','B', 11);
|
$pdf->SetFont('Arial','B', 11);
|
||||||
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), 0, 'L', 0);
|
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), 0, 'L', 0);
|
||||||
|
$pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index);
|
||||||
$pdf->SetXY ($col2x, $tab2_top + $tab2_hl * ($index+1));
|
|
||||||
$pdf->MultiCell(26, $tab2_hl, price($fac->total_ttc), 0, 'R', 0);
|
$pdf->MultiCell(26, $tab2_hl, price($fac->total_ttc), 0, 'R', 0);
|
||||||
$pdf->SetTextColor(0,0,0);
|
$pdf->SetTextColor(0,0,0);
|
||||||
|
|
||||||
if ($deja_regle > 0)
|
$creditnoteamount=$fac->getSommeCreditNote();
|
||||||
{
|
$resteapayer = $fac->total_ttc - $deja_regle - $creditnoteamount;
|
||||||
$pdf->SetXY ($col1x, $tab2_top + $tab2_hl * ($index+2));
|
if ($object->paye) $resteapayer=0;
|
||||||
|
|
||||||
|
if ($deja_regle > 0 || $creditnoteamount > 0)
|
||||||
|
{
|
||||||
|
$pdf->SetFont('Arial','', 10);
|
||||||
|
|
||||||
|
// Already payed
|
||||||
|
$index++;
|
||||||
|
$pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index);
|
||||||
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPayed"), 0, 'L', 0);
|
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPayed"), 0, 'L', 0);
|
||||||
|
$pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index);
|
||||||
$pdf->SetXY ($col2x, $tab2_top + $tab2_hl * ($index+2));
|
|
||||||
$pdf->MultiCell(26, $tab2_hl, price($deja_regle), 0, 'R', 0);
|
$pdf->MultiCell(26, $tab2_hl, price($deja_regle), 0, 'R', 0);
|
||||||
|
|
||||||
$pdf->SetXY ($col1x, $tab2_top + $tab2_hl * ($index+3));
|
// Credit note
|
||||||
$pdf->SetTextColor(22,137,210);
|
if ($creditnoteamount)
|
||||||
$pdf->SetFont('Arial','B', 11);
|
{
|
||||||
|
$index++;
|
||||||
|
$pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index);
|
||||||
|
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("CreditNotes"), 0, 'L', 0);
|
||||||
|
$pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index);
|
||||||
|
$pdf->MultiCell($largcol2, $tab2_hl, price($creditnoteamount), 0, 'R', 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
$resteapayer = $object->total_ttc - $deja_regle - $creditnoteamount;
|
||||||
|
if ($object->paye) $resteapayer=0;
|
||||||
|
|
||||||
|
$index++;
|
||||||
|
$pdf->SetTextColor(0,0,60);
|
||||||
|
$pdf->SetFont('Arial','B', 11);
|
||||||
|
$pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index);
|
||||||
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), 0, 'L', 0);
|
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), 0, 'L', 0);
|
||||||
|
$pdf->SetFillColor(224,224,224);
|
||||||
$pdf->SetXY ($col2x, $tab2_top + $tab2_hl * ($index+3));
|
$pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index);
|
||||||
$pdf->MultiCell(26, $tab2_hl, price($fac->total_ttc - $deja_regle), 0, 'R', 0);
|
$pdf->MultiCell(26, $tab2_hl, price($fac->total_ttc - $deja_regle), 0, 'R', 0);
|
||||||
$pdf->SetTextColor(0,0,0);
|
$pdf->SetTextColor(0,0,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$index++;
|
||||||
|
return ($tab2_top + ($tab2_hl * $index));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -577,7 +603,7 @@ class pdf_oursin extends ModelePDFFactures
|
|||||||
for ($i = 0 ; $i < $nblignes ; $i++)
|
for ($i = 0 ; $i < $nblignes ; $i++)
|
||||||
if ($fac->lignes[$i]->remise_percent)
|
if ($fac->lignes[$i]->remise_percent)
|
||||||
{
|
{
|
||||||
$rem=1;
|
$rem=1;
|
||||||
}
|
}
|
||||||
if ($rem==1)
|
if ($rem==1)
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user