From e3562687bebfe4717ff99cc1a43ad679171f7e0c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 13 Dec 2010 16:38:21 +0000 Subject: [PATCH] New: Add the "supplier preview" from a patch --- htdocs/compta/recap-compta.php | 2 +- htdocs/fourn/recap-fourn.php | 141 +++++++++++++++++++++++++++++++-- 2 files changed, 134 insertions(+), 9 deletions(-) diff --git a/htdocs/compta/recap-compta.php b/htdocs/compta/recap-compta.php index ef66b156e0e..d877e37b702 100644 --- a/htdocs/compta/recap-compta.php +++ b/htdocs/compta/recap-compta.php @@ -82,7 +82,7 @@ if ($socid > 0) if ($conf->facture->enabled && $user->rights->facture->lire) { // Factures - print_fiche_titre($langs->trans("AccountancyPreview")); + print_fiche_titre($langs->trans("CustomerPreview")); print ''; diff --git a/htdocs/fourn/recap-fourn.php b/htdocs/fourn/recap-fourn.php index b6e77ca5bfb..506dab6307c 100644 --- a/htdocs/fourn/recap-fourn.php +++ b/htdocs/fourn/recap-fourn.php @@ -26,17 +26,17 @@ require("../main.inc.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"); -if ($conf->facture->enabled) $langs->load("bills"); +$langs->load("bills"); // Security check $socid = $_GET["socid"]; if ($user->societe_id > 0) { - $action = ''; - $socid = $user->societe_id; + $action = ''; + $socid = $user->societe_id; } @@ -55,7 +55,7 @@ if ($socid > 0) /* * Affichage onglets */ - $head = societe_prepare_head($societe); + $head = societe_prepare_head($societe); dol_fiche_head($head, 'supplier', $langs->trans("ThirdParty"), 0, 'company'); @@ -68,7 +68,7 @@ if ($socid > 0) // Nom print ''; - // Prefix + // Prefix print ''; @@ -80,11 +80,136 @@ if ($socid > 0) print ''; - print $langs->trans("FeatureNotYetAvailable"); + + + if ($conf->fournisseur->enabled && $user->rights->facture->lire) + { + // Factures + print_fiche_titre($langs->trans("SupplierPreview")); + + print '
'.$langs->trans("Name").''.$societe->nom.'
'.$langs->trans("Prefix").''; print ($societe->prefix_comm?$societe->prefix_comm:' '); print '
'; + + $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 ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + if (! $num > 0) + { + print ''; + } + + $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."
"; + continue; + } + $totalpaye = $fac->getSommePaiement(); + + $var=!$var; + print ""; + + print "\n"; + print "\n"; + + print ''; + print '\n"; + $solde = $solde + $fac->total_ttc; + + print ''; + print '\n"; + + // Auteur + print ''; + + print "\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 ""; + print '\n"; + print ''; + print "\n"; + print "\n"; + print ''; + $solde = $solde - $objp->amount; + print '\n"; + + // Auteur + print ''; + + print ''; + + $j++; + } + + $db->free($resqlp); + } + else + { + dol_print_error($db); + } + } + } + else + { + dol_print_error($db); + } + print "
'.$langs->trans("Date").' '.$langs->trans("Status").''.$langs->trans("Debit").''.$langs->trans("Credit").''.$langs->trans("Balance").' 
'.$langs->trans("NoInvoice").'
".dol_print_date($fac->date)."id\">".img_object($langs->trans("ShowBill"),"bill")." ".$fac->ref."'.$fac->getLibStatut(2,$totalpaye).''.price($fac->total_ttc)." '.price($solde)."'.img_object($langs->trans("ShowUser"),'user').' '.$objf->login.'
'.dol_print_date($db->jdate($objp->dp))."'; + print '      '; // Decalage + print ''.img_object($langs->trans("ShowPayment"),"payment").' '.$langs->trans("Payment").' '.$objp->rowid.'  '.price($objp->amount).''.price($solde)."'.img_object($langs->trans("ShowUser"),'user').' '.$objp->login.'
"; + print "
"; + } + } else { - dol_print_error($db); + dol_print_error($db); }