dolibarr  7.0.0-beta
recap-fourn.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
25 require '../main.inc.php';
26 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
27 require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
28 
29 $langs->load("companies");
30 $langs->load("bills");
31 
32 // Security check
33 $socid = GETPOST("socid",'int');
34 if ($user->societe_id > 0)
35 {
36  $action = '';
37  $socid = $user->societe_id;
38 }
39 
40 
41 
42 /*
43  * View
44  */
45 
46 $form = new Form($db);
47 $userstatic=new User($db);
48 
49 llxHeader();
50 
51 if ($socid > 0)
52 {
53  $societe = new Societe($db);
54  $societe->fetch($socid);
55 
56  /*
57  * Affichage onglets
58  */
59  $head = societe_prepare_head($societe);
60 
61  dol_fiche_head($head, 'supplier', $langs->trans("ThirdParty"), 0, 'company');
62  dol_banner_tab($societe, 'socid', '', ($user->societe_id?0:1), 'rowid', 'nom');
63  dol_fiche_end();
64 
65  if (! empty($conf->fournisseur->enabled) && $user->rights->facture->lire)
66  {
67  // Invoice list
68  print load_fiche_titre($langs->trans("SupplierPreview"));
69 
70  print '<table class="noborder" width="100%">';
71 
72  $sql = "SELECT s.nom, s.rowid as socid, f.ref_supplier, f.amount, f.datef as df,";
73  $sql.= " f.paye as paye, f.fk_statut as statut, f.rowid as facid,";
74  $sql.= " u.login, u.rowid as userid";
75  $sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture_fourn as f,".MAIN_DB_PREFIX."user as u";
76  $sql.= " WHERE f.fk_soc = s.rowid AND s.rowid = ".$societe->id;
77  $sql.= " AND f.fk_user_valid = u.rowid";
78  $sql.= " ORDER BY f.datef DESC";
79 
80  $resql=$db->query($sql);
81  if ($resql)
82  {
83  $var=true;
84  $num = $db->num_rows($resql);
85 
86  print '<tr class="liste_titre">';
87  print '<td width="100" align="center">'.$langs->trans("Date").'</td>';
88  print '<td>&nbsp;</td>';
89  print '<td>'.$langs->trans("Status").'</td>';
90  print '<td align="right">'.$langs->trans("Debit").'</td>';
91  print '<td align="right">'.$langs->trans("Credit").'</td>';
92  print '<td align="right">'.$langs->trans("Balance").'</td>';
93  print '<td>&nbsp;</td>';
94  print '</tr>';
95 
96  if (! $num > 0)
97  {
98  print '<tr><td colspan="7">'.$langs->trans("NoInvoice").'</td></tr>';
99  }
100 
101  $solde = 0;
102 
103  // Boucle sur chaque facture
104  for ($i = 0 ; $i < $num ; $i++)
105  {
106  $objf = $db->fetch_object($resql);
107 
108  $fac = new FactureFournisseur($db);
109  $ret=$fac->fetch($objf->facid);
110  if ($ret < 0)
111  {
112  print $fac->error."<br>";
113  continue;
114  }
115  $totalpaye = $fac->getSommePaiement();
116 
117 
118  print '<tr class="oddeven">';
119 
120  print "<td align=\"center\">".dol_print_date($fac->date)."</td>\n";
121  print "<td><a href=\"facture/card.php?facid=$fac->id\">".img_object($langs->trans("ShowBill"),"bill")." ".$fac->ref."</a></td>\n";
122 
123  print '<td aling="left">'.$fac->getLibStatut(2,$totalpaye).'</td>';
124  print '<td align="right">'.price($fac->total_ttc)."</td>\n";
125  $solde = $solde + $fac->total_ttc;
126 
127  print '<td align="right">&nbsp;</td>';
128  print '<td align="right">'.price($solde)."</td>\n";
129 
130  // Author
131  print '<td class="nowrap" width="50"><a href="'.DOL_URL_ROOT.'/user/card.php?id='.$objf->userid.'">'.img_object($langs->trans("ShowUser"),'user').' '.$objf->login.'</a></td>';
132 
133  print "</tr>\n";
134 
135  // Payments
136  $sql = "SELECT p.rowid, p.datep as dp, pf.amount, p.statut,";
137  $sql.= " p.fk_user_author, u.login, u.rowid as userid";
138  $sql.= " FROM ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf,";
139  $sql.= " ".MAIN_DB_PREFIX."paiementfourn as p";
140  $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON p.fk_user_author = u.rowid";
141  $sql.= " WHERE pf.fk_paiementfourn = p.rowid";
142  $sql.= " AND pf.fk_facturefourn = ".$fac->id;
143 
144  $resqlp = $db->query($sql);
145  if ($resqlp)
146  {
147  $nump = $db->num_rows($resqlp);
148  $j = 0;
149 
150  while ($j < $nump)
151  {
152  $objp = $db->fetch_object($resqlp);
153  //
154  print '<tr class="oddeven">';
155  print '<td align="center">'.dol_print_date($db->jdate($objp->dp))."</td>\n";
156  print '<td>';
157  print '&nbsp; &nbsp; &nbsp; '; // Decalage
158  print '<a href="paiement/card.php?id='.$objp->rowid.'">'.img_object($langs->trans("ShowPayment"),"payment").' '.$langs->trans("Payment").' '.$objp->rowid.'</td>';
159  print "<td>&nbsp;</td>\n";
160  print "<td>&nbsp;</td>\n";
161  print '<td align="right">'.price($objp->amount).'</td>';
162  $solde = $solde - $objp->amount;
163  print '<td align="right">'.price($solde)."</td>\n";
164 
165  // Auteur
166  print '<td class="nowrap" width="50"><a href="'.DOL_URL_ROOT.'/user/card.php?id='.$objp->userid.'">'.img_object($langs->trans("ShowUser"),'user').' '.$objp->login.'</a></td>';
167 
168  print '</tr>';
169 
170  $j++;
171  }
172 
173  $db->free($resqlp);
174  }
175  else
176  {
177  dol_print_error($db);
178  }
179  }
180  }
181  else
182  {
183  dol_print_error($db);
184  }
185 
186  print "</table>";
187  }
188 }
189 else
190 {
191  dol_print_error($db);
192 }
193 
194 llxFooter();
195 $db->close();
llxFooter()
Empty footer.
Definition: wrapper.php:58
dol_fiche_head($links=array(), $active='0', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='')
Show tab header of a card.
dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='')
Show tab footer of a card.
Class to manage Dolibarr users.
Definition: user.class.php:39
dol_print_error($db='', $error='', $errors=null)
Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remonte...
Class to manage suppliers invoices.
if(empty($reshook)) $form
View.
Definition: perms.php:103
GETPOST($paramname, $check='none', $method=0, $filter=NULL, $options=NULL, $noreplace=0)
Return value of a param into GET or POST supervariable.
Class to manage generation of HTML components Only common components must be here.
Class to manage third parties objects (customers, suppliers, prospects...)
dol_fiche_end($notab=0)
Show tab footer of a card.
load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png', $pictoisfullpath=0, $id=0, $morecssontable='', $morehtmlcenter='')
Load a title with picto.
llxHeader()
Empty header.
Definition: wrapper.php:46
img_object($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
societe_prepare_head(Societe $object)
Return array of tabs to used on pages for third parties cards.
Definition: company.lib.php:40
print
Draft customers invoices.
Definition: index.php:91
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if(!empty($conf->fournisseur->enabled)&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->societe->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if(!empty($conf->fournisseur->enabled)&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1013