';
- print '| '.$langs->trans('Payments').' | '.$langs->trans('Type').' | ';
- print ''.$langs->trans('Amount').' | |
';
-
- $var=True;
- while ($i < $num)
+
+ if ($fac->type != 2)
{
- $objp = $db->fetch_object($result);
- $var=!$var;
- print '| ';
- print ''.img_object($langs->trans('ShowPayment'),'payment').' ';
- print dolibarr_print_date($objp->dp).' | ';
- print ''.$objp->paiement_type.' '.$objp->num_paiement.' | ';
- print ''.price($objp->amount).' | '.$langs->trans('Currency'.$conf->monnaie).' | ';
- print '
';
- $i++;
- }
+ // Liste des paiements
+ print '| '.$langs->trans('Payments').' | '.$langs->trans('Type').' | ';
+ print ''.$langs->trans('Amount').' | |
';
+
+ $var=True;
+ while ($i < $num)
+ {
+ $objp = $db->fetch_object($result);
+ $var=!$var;
+ print '| ';
+ print ''.img_object($langs->trans('ShowPayment'),'payment').' ';
+ print dolibarr_print_date($objp->dp).' | ';
+ print ''.$objp->paiement_type.' '.$objp->num_paiement.' | ';
+ print ''.price($objp->amount).' | '.$langs->trans('Currency'.$conf->monnaie).' | ';
+ print '
';
+ $i++;
+ }
- print '| '.$langs->trans('AlreadyPayed').' : | '.price($totalpaye).' | '.$langs->trans('Currency'.$conf->monnaie).' |
';
- print '| '.$langs->trans("Billed").' : | '.price($fac->total_ttc).' | '.$langs->trans('Currency'.$conf->monnaie).' |
';
- if ($fac->close_code == 'escompte')
+ // Solde facture
+ print '| '.$langs->trans('AlreadyPayed').' : | '.price($totalpaye).' | '.$langs->trans('Currency'.$conf->monnaie).' |
';
+ print '| '.$langs->trans("Billed").' : | '.price($fac->total_ttc).' | '.$langs->trans('Currency'.$conf->monnaie).' |
';
+ if ($fac->close_code == 'escompte')
+ {
+ print '| ';
+ print $html->textwithhelp($langs->trans("Escompte").':',$langs->trans("HelpEscompte"),-1);
+ print ' | '.price($fac->total_ttc - $totalpaye).' | '.$langs->trans('Currency'.$conf->monnaie).' |
';
+ }
+ print '| '.$langs->trans('RemainderToPay').' : | ';
+ print ''.price($resteapayer).' | '.$langs->trans('Currency'.$conf->monnaie).' |
';
+ }
+ else
{
- print '| ';
- print $html->textwithhelp($langs->trans("Escompte").':',$langs->trans("HelpEscompte"),-1);
- print ' | '.price($fac->total_ttc - $totalpaye).' | '.$langs->trans('Currency'.$conf->monnaie).' |
';
- }
- print '| '.$langs->trans('RemainderToPay').' : | ';
- print ''.price($resteapayer).' | '.$langs->trans('Currency'.$conf->monnaie).' |
';
-
+ // Solde avoir
+ print '| '.$langs->trans('TotalTTCToYourCredit').' : | ';
+ print ''.price(abs($fac->total_ttc)).' | '.$langs->trans('Currency'.$conf->monnaie).' |
';
+ }
print '
';
$db->free($result);
}
@@ -1840,8 +1850,16 @@ else
// Date limite reglement
print '';
print '| '.$langs->trans('DateMaxPayment').' | ';
- print '' . dolibarr_print_date($fac->date_lim_reglement,'%A %d %B %Y');
- if ($fac->date_lim_reglement < (time() - $conf->facture->client->warning_delay) && ! $fac->paye && $fac->statut == 1 && ! $fac->am) print img_warning($langs->trans('Late'));
+ print ' | ';
+ if ($fac->type != 2)
+ {
+ print dolibarr_print_date($fac->date_lim_reglement,'%A %d %B %Y');
+ if ($fac->date_lim_reglement < (time() - $conf->facture->client->warning_delay) && ! $fac->paye && $fac->statut == 1 && ! $fac->am) print img_warning($langs->trans('Late'));
+ }
+ else
+ {
+ print ' ';
+ }
print ' |
';
// Conditions de réglement
@@ -1849,16 +1867,23 @@ else
print '';
print '| '.$langs->trans("Date").' | ';
print ' | ';
- print ' | ';
+ print ''.$langs->trans("Status").' | ';
print ''.$langs->trans("Debit").' | ';
print ''.$langs->trans("Credit").' | ';
print ''.$langs->trans("Balance").' | ';
@@ -137,6 +137,7 @@ if ($socid > 0)
print $fac->error."
";
continue;
}
+ $totalpaye = $fac->getSommePaiement();
$var=!$var;
print "
";
@@ -144,7 +145,7 @@ if ($socid > 0)
print "| ".dolibarr_print_date($fac->date)." | \n";
print "id\">".img_object($langs->trans("ShowBill"),"bill")." ".$fac->ref." | \n";
- print ''.$fac->getLibStatut(2).' | ';
+ print ''.$fac->getLibStatut(2,$totalpaye).' | ';
print ''.price($fac->total_ttc)." | \n";
$solde = $solde + $fac->total_ttc;
@@ -207,6 +208,7 @@ if ($socid > 0)
dolibarr_print_error($db);
}
print "";
+ print "
";
}
}
else
diff --git a/htdocs/facture.class.php b/htdocs/facture.class.php
index 744909f4aae..88fd3d1ea69 100644
--- a/htdocs/facture.class.php
+++ b/htdocs/facture.class.php
@@ -382,14 +382,16 @@ class Facture extends CommonObject
$sql.= ','.$this->db->pdate('f.datef').' as df, f.fk_projet';
$sql.= ','.$this->db->pdate('f.date_lim_reglement').' as dlr';
$sql.= ', f.note, f.note_public, f.fk_statut, f.paye, f.close_code, f.close_note, f.fk_user_author, f.model_pdf';
- $sql.= ', f.fk_mode_reglement, p.code as mode_reglement_code, p.libelle as mode_reglement_libelle';
- $sql.= ', f.fk_cond_reglement, c.code as cond_reglement_code, c.libelle as cond_reglement_libelle, c.libelle_facture as cond_reglement_libelle_facture';
$sql.= ', f.fk_facture_source';
+ $sql.= ', f.fk_mode_reglement, f.fk_cond_reglement';
+ $sql.= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle';
+ $sql.= ', c.code as cond_reglement_code, c.libelle as cond_reglement_libelle, c.libelle_facture as cond_reglement_libelle_facture';
$sql.= ', cf.fk_commande';
- $sql.= ' FROM '.MAIN_DB_PREFIX.'cond_reglement as c, '.MAIN_DB_PREFIX.'facture as f';
+ $sql.= ' FROM '.MAIN_DB_PREFIX.'facture as f';
+ $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'cond_reglement as c ON f.fk_cond_reglement = c.rowid';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON f.fk_mode_reglement = p.id';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'co_fa as cf ON cf.fk_facture = f.rowid';
- $sql.= ' WHERE f.rowid='.$rowid.' AND c.rowid = f.fk_cond_reglement';
+ $sql.= ' WHERE f.rowid='.$rowid;
if ($societe_id > 0)
{
$sql.= ' AND f.fk_soc = '.$societe_id;
diff --git a/htdocs/includes/modules/facture/pdf_crabe.modules.php b/htdocs/includes/modules/facture/pdf_crabe.modules.php
index 2017cc4a183..c44349ca483 100644
--- a/htdocs/includes/modules/facture/pdf_crabe.modules.php
+++ b/htdocs/includes/modules/facture/pdf_crabe.modules.php
@@ -884,17 +884,30 @@ class pdf_crabe extends ModelePDFFactures
$pdf->SetTextColor(0,0,60);
$pdf->MultiCell(100, 3, $outputlangs->trans("ReplaceInvoice", $objectreplaced->ref), '', 'R');
}
+ if ($object->type == 2)
+ {
+ $objectreplaced=new Facture($this->db);
+ $objectreplaced->fetch($object->fk_facture_source);
+
+ $posy+=5;
+ $pdf->SetXY(100,$posy);
+ $pdf->SetTextColor(0,0,60);
+ $pdf->MultiCell(100, 3, $outputlangs->trans("CorrectInvoice", $objectreplaced->ref), '', 'R');
+ }
$posy+=5;
$pdf->SetXY(100,$posy);
$pdf->SetTextColor(0,0,60);
$pdf->MultiCell(100, 3, $outputlangs->trans("DateInvoice")." : " . dolibarr_print_date($object->date,"%d %b %Y"), '', 'R');
- $posy+=5;
- $pdf->SetXY(100,$posy);
- $pdf->SetTextColor(0,0,60);
- $pdf->MultiCell(100, 3, $outputlangs->trans("DateEcheance")." : " . dolibarr_print_date($object->date_lim_reglement,"%d %b %Y"), '', 'R');
-
+ if ($object->type != 2)
+ {
+ $posy+=5;
+ $pdf->SetXY(100,$posy);
+ $pdf->SetTextColor(0,0,60);
+ $pdf->MultiCell(100, 3, $outputlangs->trans("DateEcheance")." : " . dolibarr_print_date($object->date_lim_reglement,"%d %b %Y"), '', 'R');
+ }
+
if ($showadress)
{
// Emetteur