New: Add hook
This commit is contained in:
parent
982b3e9d66
commit
393cecb1c2
@ -185,8 +185,8 @@ $form=new Form($db);
|
|||||||
|
|
||||||
if ($action == 'create' || $action == 'add_paiement')
|
if ($action == 'create' || $action == 'add_paiement')
|
||||||
{
|
{
|
||||||
$facture = new FactureFournisseur($db);
|
$object = new FactureFournisseur($db);
|
||||||
$facture->fetch($facid);
|
$object->fetch($facid);
|
||||||
|
|
||||||
$datefacture=dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear'));
|
$datefacture=dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear'));
|
||||||
$dateinvoice=($datefacture==''?(empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0):$datefacture);
|
$dateinvoice=($datefacture==''?(empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0):$datefacture);
|
||||||
@ -248,91 +248,98 @@ if ($action == 'create' || $action == 'add_paiement')
|
|||||||
}
|
}
|
||||||
print '</table>';
|
print '</table>';
|
||||||
|
|
||||||
/*
|
|
||||||
* 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 '<br>';
|
|
||||||
|
|
||||||
print $langs->trans('Invoices').'<br>';
|
$parameters=array('facid'=>$facid, 'ref'=>$ref, 'objcanvas'=>$objcanvas);
|
||||||
print '<table class="noborder" width="100%">';
|
$reshook=$hookmanager->executeHooks('paymentsupplierinvoices',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
|
||||||
print '<tr class="liste_titre">';
|
$error=$hookmanager->error; $errors=$hookmanager->errors;
|
||||||
print '<td>'.$langs->trans('Ref').'</td>';
|
if (empty($reshook))
|
||||||
print '<td>'.$langs->trans('RefSupplier').'</td>';
|
{
|
||||||
print '<td align="center">'.$langs->trans('Date').'</td>';
|
/*
|
||||||
print '<td align="right">'.$langs->trans('AmountTTC').'</td>';
|
* Autres factures impayees
|
||||||
print '<td align="right">'.$langs->trans('AlreadyPaid').'</td>';
|
*/
|
||||||
print '<td align="right">'.$langs->trans('RemainderToPay').'</td>';
|
$sql = 'SELECT f.rowid as facid, f.rowid as ref, f.facnumber, f.total_ht, f.total_ttc, f.datef as df';
|
||||||
print '<td align="center">'.$langs->trans('Amount').'</td>';
|
$sql.= ', SUM(pf.amount) as am';
|
||||||
print '</tr>';
|
$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 '<br>';
|
||||||
|
|
||||||
$var=True;
|
print $langs->trans('Invoices').'<br>';
|
||||||
$total=0;
|
print '<table class="noborder" width="100%">';
|
||||||
$total_ttc=0;
|
print '<tr class="liste_titre">';
|
||||||
$totalrecu=0;
|
print '<td>'.$langs->trans('Ref').'</td>';
|
||||||
while ($i < $num)
|
print '<td>'.$langs->trans('RefSupplier').'</td>';
|
||||||
{
|
print '<td align="center">'.$langs->trans('Date').'</td>';
|
||||||
$objp = $db->fetch_object($resql);
|
print '<td align="right">'.$langs->trans('AmountTTC').'</td>';
|
||||||
$var=!$var;
|
print '<td align="right">'.$langs->trans('AlreadyPaid').'</td>';
|
||||||
print '<tr '.$bc[$var].'>';
|
print '<td align="right">'.$langs->trans('RemainderToPay').'</td>';
|
||||||
print '<td><a href="fiche.php?facid='.$objp->facid.'">'.img_object($langs->trans('ShowBill'),'bill').' '.$objp->ref;
|
print '<td align="center">'.$langs->trans('Amount').'</td>';
|
||||||
print '</a></td>';
|
print '</tr>';
|
||||||
print '<td>'.$objp->facnumber.'</td>';
|
|
||||||
if ($objp->df > 0 )
|
$var=True;
|
||||||
{
|
$total=0;
|
||||||
print '<td align="center">';
|
$total_ttc=0;
|
||||||
print dol_print_date($db->jdate($objp->df)).'</td>';
|
$totalrecu=0;
|
||||||
}
|
while ($i < $num)
|
||||||
else
|
{
|
||||||
{
|
$objp = $db->fetch_object($resql);
|
||||||
print '<td align="center"><b>!!!</b></td>';
|
$var=!$var;
|
||||||
}
|
print '<tr '.$bc[$var].'>';
|
||||||
print '<td align="right">'.price($objp->total_ttc).'</td>';
|
print '<td><a href="fiche.php?facid='.$objp->facid.'">'.img_object($langs->trans('ShowBill'),'bill').' '.$objp->ref;
|
||||||
print '<td align="right">'.price($objp->am).'</td>';
|
print '</a></td>';
|
||||||
print '<td align="right">'.price($objp->total_ttc - $objp->am).'</td>';
|
print '<td>'.$objp->facnumber.'</td>';
|
||||||
print '<td align="center">';
|
if ($objp->df > 0 )
|
||||||
$namef = 'amount_'.$objp->facid;
|
{
|
||||||
print '<input type="text" size="8" name="'.$namef.'" value="'.GETPOST($namef).'">';
|
print '<td align="center">';
|
||||||
print "</td></tr>\n";
|
print dol_print_date($db->jdate($objp->df)).'</td>';
|
||||||
$total+=$objp->total_ht;
|
}
|
||||||
$total_ttc+=$objp->total_ttc;
|
else
|
||||||
$totalrecu+=$objp->am;
|
{
|
||||||
$i++;
|
print '<td align="center"><b>!!!</b></td>';
|
||||||
}
|
}
|
||||||
if ($i > 1)
|
print '<td align="right">'.price($objp->total_ttc).'</td>';
|
||||||
{
|
print '<td align="right">'.price($objp->am).'</td>';
|
||||||
// Print total
|
print '<td align="right">'.price($objp->total_ttc - $objp->am).'</td>';
|
||||||
print '<tr class="liste_total">';
|
print '<td align="center">';
|
||||||
print '<td colspan="3" align="left">'.$langs->trans('TotalTTC').':</td>';
|
$namef = 'amount_'.$objp->facid;
|
||||||
print '<td align="right"><b>'.price($total_ttc).'</b></td>';
|
print '<input type="text" size="8" name="'.$namef.'" value="'.GETPOST($namef).'">';
|
||||||
print '<td align="right"><b>'.price($totalrecu).'</b></td>';
|
print "</td></tr>\n";
|
||||||
print '<td align="right"><b>'.price($total_ttc - $totalrecu).'</b></td>';
|
$total+=$objp->total_ht;
|
||||||
print '<td align="center"> </td>';
|
$total_ttc+=$objp->total_ttc;
|
||||||
print "</tr>\n";
|
$totalrecu+=$objp->am;
|
||||||
}
|
$i++;
|
||||||
print "</table>\n";
|
}
|
||||||
}
|
if ($i > 1)
|
||||||
$db->free($resql);
|
{
|
||||||
}
|
// Print total
|
||||||
else
|
print '<tr class="liste_total">';
|
||||||
{
|
print '<td colspan="3" align="left">'.$langs->trans('TotalTTC').':</td>';
|
||||||
dol_print_error($db);
|
print '<td align="right"><b>'.price($total_ttc).'</b></td>';
|
||||||
}
|
print '<td align="right"><b>'.price($totalrecu).'</b></td>';
|
||||||
|
print '<td align="right"><b>'.price($total_ttc - $totalrecu).'</b></td>';
|
||||||
|
print '<td align="center"> </td>';
|
||||||
|
print "</tr>\n";
|
||||||
|
}
|
||||||
|
print "</table>\n";
|
||||||
|
}
|
||||||
|
$db->free($resql);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dol_print_error($db);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// print '<tr><td colspan="3" align="center">';
|
// print '<tr><td colspan="3" align="center">';
|
||||||
print '<center><br><input type="checkbox" checked="checked" name="closepaidinvoices"> '.$langs->trans("ClosePaidInvoicesAutomatically");
|
print '<center><br><input type="checkbox" checked="checked" name="closepaidinvoices"> '.$langs->trans("ClosePaidInvoicesAutomatically");
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user