New: Add the "supplier preview" from a patch
This commit is contained in:
parent
75fce79852
commit
e3562687be
@ -82,7 +82,7 @@ if ($socid > 0)
|
|||||||
if ($conf->facture->enabled && $user->rights->facture->lire)
|
if ($conf->facture->enabled && $user->rights->facture->lire)
|
||||||
{
|
{
|
||||||
// Factures
|
// Factures
|
||||||
print_fiche_titre($langs->trans("AccountancyPreview"));
|
print_fiche_titre($langs->trans("CustomerPreview"));
|
||||||
|
|
||||||
print '<table class="noborder" width="100%">';
|
print '<table class="noborder" width="100%">';
|
||||||
|
|
||||||
|
|||||||
@ -26,10 +26,10 @@
|
|||||||
|
|
||||||
require("../main.inc.php");
|
require("../main.inc.php");
|
||||||
require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php");
|
require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php");
|
||||||
require_once(DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php");
|
require_once(DOL_DOCUMENT_ROOT."/fourn/class/fournisseur.facture.class.php");
|
||||||
|
|
||||||
$langs->load("companies");
|
$langs->load("companies");
|
||||||
if ($conf->facture->enabled) $langs->load("bills");
|
$langs->load("bills");
|
||||||
|
|
||||||
// Security check
|
// Security check
|
||||||
$socid = $_GET["socid"];
|
$socid = $_GET["socid"];
|
||||||
@ -80,7 +80,132 @@ if ($socid > 0)
|
|||||||
print '</div>';
|
print '</div>';
|
||||||
|
|
||||||
|
|
||||||
print $langs->trans("FeatureNotYetAvailable");
|
|
||||||
|
|
||||||
|
if ($conf->fournisseur->enabled && $user->rights->facture->lire)
|
||||||
|
{
|
||||||
|
// Factures
|
||||||
|
print_fiche_titre($langs->trans("SupplierPreview"));
|
||||||
|
|
||||||
|
print '<table class="noborder" width="100%">';
|
||||||
|
|
||||||
|
$sql = "SELECT s.nom, s.rowid as socid, f.facnumber, f.amount, f.datef as df,";
|
||||||
|
$sql.= " f.paye as paye, f.fk_statut as statut, f.rowid as facid,";
|
||||||
|
$sql.= " u.login, u.rowid as userid";
|
||||||
|
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture_fourn as f,".MAIN_DB_PREFIX."user as u";
|
||||||
|
$sql.= " WHERE f.fk_soc = s.rowid AND s.rowid = ".$societe->id;
|
||||||
|
$sql.= " AND f.fk_user_valid = u.rowid";
|
||||||
|
$sql.= " ORDER BY f.datef DESC";
|
||||||
|
|
||||||
|
$resql=$db->query($sql);
|
||||||
|
if ($resql)
|
||||||
|
{
|
||||||
|
$var=true;
|
||||||
|
$num = $db->num_rows($resql);
|
||||||
|
|
||||||
|
print '<tr class="liste_titre">';
|
||||||
|
print '<td width="100" align="center">'.$langs->trans("Date").'</td>';
|
||||||
|
print '<td> </td>';
|
||||||
|
print '<td>'.$langs->trans("Status").'</td>';
|
||||||
|
print '<td align="right">'.$langs->trans("Debit").'</td>';
|
||||||
|
print '<td align="right">'.$langs->trans("Credit").'</td>';
|
||||||
|
print '<td align="right">'.$langs->trans("Balance").'</td>';
|
||||||
|
print '<td> </td>';
|
||||||
|
print '</tr>';
|
||||||
|
|
||||||
|
if (! $num > 0)
|
||||||
|
{
|
||||||
|
print '<tr><td colspan="7">'.$langs->trans("NoInvoice").'</td></tr>';
|
||||||
|
}
|
||||||
|
|
||||||
|
$solde = 0;
|
||||||
|
|
||||||
|
// Boucle sur chaque facture
|
||||||
|
for ($i = 0 ; $i < $num ; $i++)
|
||||||
|
{
|
||||||
|
$objf = $db->fetch_object($resql);
|
||||||
|
|
||||||
|
$fac = new FactureFournisseur($db);
|
||||||
|
$ret=$fac->fetch($objf->facid);
|
||||||
|
if ($ret < 0)
|
||||||
|
{
|
||||||
|
print $fac->error."<br>";
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$totalpaye = $fac->getSommePaiement();
|
||||||
|
|
||||||
|
$var=!$var;
|
||||||
|
print "<tr $bc[$var]>";
|
||||||
|
|
||||||
|
print "<td align=\"center\">".dol_print_date($fac->date)."</td>\n";
|
||||||
|
print "<td><a href=\"facture/fiche.php?facid=$fac->id\">".img_object($langs->trans("ShowBill"),"bill")." ".$fac->ref."</a></td>\n";
|
||||||
|
|
||||||
|
print '<td aling="left">'.$fac->getLibStatut(2,$totalpaye).'</td>';
|
||||||
|
print '<td align="right">'.price($fac->total_ttc)."</td>\n";
|
||||||
|
$solde = $solde + $fac->total_ttc;
|
||||||
|
|
||||||
|
print '<td align="right"> </td>';
|
||||||
|
print '<td align="right">'.price($solde)."</td>\n";
|
||||||
|
|
||||||
|
// Auteur
|
||||||
|
print '<td nowrap="nowrap" width="50"><a href="'.DOL_URL_ROOT.'/user/fiche.php?id='.$objf->userid.'">'.img_object($langs->trans("ShowUser"),'user').' '.$objf->login.'</a></td>';
|
||||||
|
|
||||||
|
print "</tr>\n";
|
||||||
|
|
||||||
|
// Payments
|
||||||
|
$sql = "SELECT p.rowid, p.datep as dp, pf.amount, p.statut,";
|
||||||
|
$sql.= " p.fk_user_creat, u.login, u.rowid as userid";
|
||||||
|
$sql.= " FROM ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf,";
|
||||||
|
$sql.= " ".MAIN_DB_PREFIX."paiement as p";
|
||||||
|
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON p.fk_user_creat = u.rowid";
|
||||||
|
$sql.= " WHERE pf.fk_paiementfourn = p.rowid";
|
||||||
|
$sql.= " AND pf.fk_facturefourn = ".$fac->id;
|
||||||
|
|
||||||
|
$resqlp = $db->query($sql);
|
||||||
|
if ($resqlp)
|
||||||
|
{
|
||||||
|
$nump = $db->num_rows($resqlp);
|
||||||
|
$j = 0;
|
||||||
|
|
||||||
|
while ($j < $nump)
|
||||||
|
{
|
||||||
|
$objp = $db->fetch_object($resqlp);
|
||||||
|
//$var=!$var;
|
||||||
|
print "<tr $bc[$var]>";
|
||||||
|
print '<td align="center">'.dol_print_date($db->jdate($objp->dp))."</td>\n";
|
||||||
|
print '<td>';
|
||||||
|
print ' '; // Decalage
|
||||||
|
print '<a href="paiement/fiche.php?id='.$objp->rowid.'">'.img_object($langs->trans("ShowPayment"),"payment").' '.$langs->trans("Payment").' '.$objp->rowid.'</td>';
|
||||||
|
print "<td> </td>\n";
|
||||||
|
print "<td> </td>\n";
|
||||||
|
print '<td align="right">'.price($objp->amount).'</td>';
|
||||||
|
$solde = $solde - $objp->amount;
|
||||||
|
print '<td align="right">'.price($solde)."</td>\n";
|
||||||
|
|
||||||
|
// Auteur
|
||||||
|
print '<td nowrap="nowrap" width="50"><a href="'.DOL_URL_ROOT.'/user/fiche.php?id='.$objp->userid.'">'.img_object($langs->trans("ShowUser"),'user').' '.$objp->login.'</a></td>';
|
||||||
|
|
||||||
|
print '</tr>';
|
||||||
|
|
||||||
|
$j++;
|
||||||
|
}
|
||||||
|
|
||||||
|
$db->free($resqlp);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dol_print_error($db);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dol_print_error($db);
|
||||||
|
}
|
||||||
|
print "</table>";
|
||||||
|
print "<br>";
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user