diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php
index e9358624fe2..51b9972260e 100644
--- a/htdocs/fourn/facture/paiement.php
+++ b/htdocs/fourn/facture/paiement.php
@@ -185,8 +185,8 @@ $form=new Form($db);
if ($action == 'create' || $action == 'add_paiement')
{
- $facture = new FactureFournisseur($db);
- $facture->fetch($facid);
+ $object = new FactureFournisseur($db);
+ $object->fetch($facid);
$datefacture=dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear'));
$dateinvoice=($datefacture==''?(empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0):$datefacture);
@@ -248,91 +248,98 @@ if ($action == 'create' || $action == 'add_paiement')
}
print '';
- /*
- * Autres factures impayees
- */
- $sql = 'SELECT f.rowid as facid, f.rowid as ref, f.facnumber, f.total_ht, f.total_ttc, f.datef as df';
- $sql.= ', SUM(pf.amount) as am';
- $sql.= ' FROM '.MAIN_DB_PREFIX.'facture_fourn as f';
- $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf ON pf.fk_facturefourn = f.rowid';
- $sql.= " WHERE f.entity = ".$conf->entity;
- $sql.= ' AND f.fk_soc = '.$facture->socid;
- $sql.= ' AND f.paye = 0';
- $sql.= ' AND f.fk_statut = 1'; // Statut=0 => non validee, Statut=2 => annulee
- $sql.= ' GROUP BY f.rowid, f.facnumber, f.total_ht, f.total_ttc, f.datef';
- $resql = $db->query($sql);
- if ($resql)
- {
- $num = $db->num_rows($resql);
- if ($num > 0)
- {
- $i = 0;
- print '
';
- print $langs->trans('Invoices').'
';
- print '
';
- print '';
- print '| '.$langs->trans('Ref').' | ';
- print ''.$langs->trans('RefSupplier').' | ';
- print ''.$langs->trans('Date').' | ';
- print ''.$langs->trans('AmountTTC').' | ';
- print ''.$langs->trans('AlreadyPaid').' | ';
- print ''.$langs->trans('RemainderToPay').' | ';
- print ''.$langs->trans('Amount').' | ';
- print '
';
+ $parameters=array('facid'=>$facid, 'ref'=>$ref, 'objcanvas'=>$objcanvas);
+ $reshook=$hookmanager->executeHooks('paymentsupplierinvoices',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
+ $error=$hookmanager->error; $errors=$hookmanager->errors;
+ if (empty($reshook))
+ {
+ /*
+ * Autres factures impayees
+ */
+ $sql = 'SELECT f.rowid as facid, f.rowid as ref, f.facnumber, f.total_ht, f.total_ttc, f.datef as df';
+ $sql.= ', SUM(pf.amount) as am';
+ $sql.= ' FROM '.MAIN_DB_PREFIX.'facture_fourn as f';
+ $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf ON pf.fk_facturefourn = f.rowid';
+ $sql.= " WHERE f.entity = ".$conf->entity;
+ $sql.= ' AND f.fk_soc = '.$object->socid;
+ $sql.= ' AND f.paye = 0';
+ $sql.= ' AND f.fk_statut = 1'; // Statut=0 => non validee, Statut=2 => annulee
+ $sql.= ' GROUP BY f.rowid, f.facnumber, f.total_ht, f.total_ttc, f.datef';
+ $resql = $db->query($sql);
+ if ($resql)
+ {
+ $num = $db->num_rows($resql);
+ if ($num > 0)
+ {
+ $i = 0;
+ print '
';
- $var=True;
- $total=0;
- $total_ttc=0;
- $totalrecu=0;
- while ($i < $num)
- {
- $objp = $db->fetch_object($resql);
- $var=!$var;
- print '';
- print '| '.img_object($langs->trans('ShowBill'),'bill').' '.$objp->ref;
- print ' | ';
- print ''.$objp->facnumber.' | ';
- if ($objp->df > 0 )
- {
- print '';
- print dol_print_date($db->jdate($objp->df)).' | ';
- }
- else
- {
- print '!!! | ';
- }
- print ''.price($objp->total_ttc).' | ';
- print ''.price($objp->am).' | ';
- print ''.price($objp->total_ttc - $objp->am).' | ';
- print '';
- $namef = 'amount_'.$objp->facid;
- print '';
- print " |
\n";
- $total+=$objp->total_ht;
- $total_ttc+=$objp->total_ttc;
- $totalrecu+=$objp->am;
- $i++;
- }
- if ($i > 1)
- {
- // Print total
- print '';
- print '| '.$langs->trans('TotalTTC').': | ';
- print ''.price($total_ttc).' | ';
- print ''.price($totalrecu).' | ';
- print ''.price($total_ttc - $totalrecu).' | ';
- print ' | ';
- print "
\n";
- }
- print "
\n";
- }
- $db->free($resql);
- }
- else
- {
- dol_print_error($db);
- }
+ print $langs->trans('Invoices').'
';
+ print '\n";
+ }
+ $db->free($resql);
+ }
+ else
+ {
+ dol_print_error($db);
+ }
+ }
// print '';
print ' '.$langs->trans("ClosePaidInvoicesAutomatically");
|