dolibarr  9.0.0
index.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2001-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
4  * Copyright (C) 2005-2011 Regis Houssin <regis.houssin@inodbox.com>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
26 require '../main.inc.php';
27 require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
28 require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
29 require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
30 
31 $langs->loadLangs(array("suppliers", "orders", "companies"));
32 
33 // Security check
34 $socid = GETPOST("socid", 'int');
35 if ($user->societe_id) $socid=$user->societe_id;
36 $result = restrictedArea($user, 'societe',$socid,'');
37 
38 
39 /*
40  * View
41  */
42 
43 $commandestatic=new CommandeFournisseur($db);
44 $facturestatic=new FactureFournisseur($db);
45 $companystatic=new Societe($db);
46 
47 llxHeader("",$langs->trans("SuppliersArea"));
48 
49 print load_fiche_titre($langs->trans("SuppliersArea"));
50 
51 
52 //print '<table border="0" width="100%" class="notopnoleftnoright">';
53 //print '<tr><td valign="top" width="30%" class="notopnoleft">';
54 print '<div class="fichecenter"><div class="fichethirdleft">';
55 
56 
57 // Orders
58 $sql = "SELECT count(cf.rowid), cf.fk_statut";
59 $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as cf,";
60 $sql.= " ".MAIN_DB_PREFIX."societe as s";
61 if (!$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc";
62 $sql.= " WHERE cf.fk_soc = s.rowid ";
63 if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND sc.fk_user = " .$user->id;
64 $sql.= " AND cf.entity = ".$conf->entity;
65 $sql.= " GROUP BY cf.fk_statut";
66 
67 $resql = $db->query($sql);
68 if ($resql)
69 {
70  $num = $db->num_rows($resql);
71  $i = 0;
72 
73  print '<table class="noborder" width="100%">';
74  print '<tr class="liste_titre"><td>'.$langs->trans("Orders").'</td><td align="center">'.$langs->trans("Nb").'</td><td>&nbsp;</td>';
75  print "</tr>\n";
76 
77  while ($i < $num)
78  {
79  $row = $db->fetch_row($resql);
80 
81  print '<tr class="oddeven">';
82  print '<td>'.$commandestatic->LibStatut($row[1]).'</td>';
83  print '<td align="center">'.$row[0].'</td>';
84  print '<td align="center"><a href="'.DOL_URL_ROOT.'/fourn/commande/list.php?statut='.$row[1].'">'.$commandestatic->LibStatut($row[1],3).'</a></td>';
85 
86  print "</tr>\n";
87  $i++;
88  }
89  print "</table>";
90  print "<br>\n";
91  $db->free($resql);
92 }
93 else
94 {
95  dol_print_error($db);
96 }
97 
98 
99 // Draft orders
100 if (! empty($conf->fournisseur->enabled))
101 {
102  $langs->load("orders");
103 
104  $sql = "SELECT cf.rowid, cf.ref, cf.total_ttc,";
105  $sql.= " s.nom as name, s.rowid as socid";
106  $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as cf";
107  $sql.= ", ".MAIN_DB_PREFIX."societe as s";
108  if (!$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc";
109  $sql.= " WHERE cf.fk_soc = s.rowid";
110  if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND sc.fk_user = " .$user->id;
111  $sql.= " AND cf.entity = ".$conf->entity;
112  $sql.= " AND cf.fk_statut = 0";
113  if ($socid) $sql .= " AND cf.fk_soc = ".$socid;
114 
115  $resql = $db->query($sql);
116  if ($resql)
117  {
118  $total = 0;
119  $num = $db->num_rows($resql);
120  if ($num)
121  {
122  print '<table class="noborder" width="100%">';
123  print '<tr class="liste_titre">';
124  print '<td colspan="3">'.$langs->trans("DraftOrders").' <span class="badge">'.$num.'</span></td></tr>';
125 
126  $i = 0;
127  while ($i < $num)
128  {
129  $obj = $db->fetch_object($resql);
130 
131  print '<tr class="oddeven"><td class="nowrap">';
132  $commandestatic->id=$obj->rowid;
133  $commandestatic->ref=$obj->ref;
134  print $commandestatic->getNomUrl(1,'',16);
135  print '</td>';
136  print '<td class="nowrap">';
137  $companystatic->id=$obj->socid;
138  $companystatic->name=$obj->name;
139  $companystatic->client=0;
140  print $companystatic->getNomUrl(1,'',16);
141  print '</td>';
142  print '<td align="right" class="nowrap">'.price($obj->total_ttc).'</td></tr>';
143  $i++;
144  $total += $obj->total_ttc;
145  }
146  if ($total>0)
147  {
148 
149  print '<tr class="liste_total"><td>'.$langs->trans("Total").'</td><td colspan="2" align="right">'.price($total)."</td></tr>";
150  }
151  print "</table>";
152  print "<br>\n";
153  }
154  }
155 }
156 
157 // Draft invoices
158 if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire)
159 {
160  $sql = "SELECT ff.ref_supplier, ff.rowid, ff.total_ttc, ff.type";
161  $sql.= ", s.nom as name, s.rowid as socid";
162  $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn as ff";
163  $sql.= ", ".MAIN_DB_PREFIX."societe as s";
164  if (!$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc";
165  $sql.= " WHERE s.rowid = ff.fk_soc";
166  if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND sc.fk_user = " .$user->id;
167  $sql.= " AND ff.entity = ".$conf->entity;
168  $sql.= " AND ff.fk_statut = 0";
169  if ($socid) $sql .= " AND f.fk_soc = ".$socid;
170 
171  $resql = $db->query($sql);
172 
173  if ( $resql )
174  {
175  $num = $db->num_rows($resql);
176  if ($num)
177  {
178  print '<table class="noborder" width="100%">';
179  print '<tr class="liste_titre">';
180  print '<td colspan="3">'.$langs->trans("DraftBills").' <span class="badge">'.$num.'</span></td></tr>';
181  $i = 0;
182  $tot_ttc = 0;
183 
184  while ($i < $num && $i < 20)
185  {
186  $obj = $db->fetch_object($resql);
187 
188  print '<tr class="oddeven"><td class="nowrap">';
189  $facturestatic->ref=$obj->ref;
190  $facturestatic->id=$obj->rowid;
191  $facturestatic->type=$obj->type;
192  print $facturestatic->getNomUrl(1,'');
193  print '</td>';
194  print '<td class="nowrap">';
195  $companystatic->id=$obj->socid;
196  $companystatic->name=$obj->name;
197  $companystatic->client=0;
198  print $companystatic->getNomUrl(1,'',16);
199  print '</td>';
200  print '<td align="right">'.price($obj->total_ttc).'</td>';
201  print '</tr>';
202  $tot_ttc+=$obj->total_ttc;
203  $i++;
204  }
205 
206  print '<tr class="liste_total"><td align="left">'.$langs->trans("Total").'</td>';
207  print '<td colspan="2" align="right">'.price($tot_ttc).'</td>';
208  print '</tr>';
209 
210  print "</table>";
211  print "<br>\n";
212  }
213  $db->free($resql);
214  }
215  else
216  {
217  dol_print_error($db);
218  }
219 }
220 
221 
222 //print '</td><td valign="top" width="70%" class="notopnoleftnoright">';
223 print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
224 
225 
226 /*
227  * List last modified supliers
228  */
229 $max=10;
230 $sql = "SELECT s.rowid as socid, s.nom as name, s.town, s.datec, s.tms, s.prefix_comm, s.code_fournisseur, s.code_compta_fournisseur";
231 $sql.= ", st.libelle as stcomm";
232 $sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
233 $sql.= ", ".MAIN_DB_PREFIX."c_stcomm as st";
234 if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
235 $sql.= " WHERE s.fk_stcomm = st.id";
236 $sql.= " AND s.fournisseur = 1";
237 $sql.= " AND s.entity IN (".getEntity('societe').")";
238 if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
239 if ($socid) $sql .= " AND s.rowid = ".$socid;
240 $sql.= " ORDER BY s.tms DESC";
241 $sql .= $db->plimit($max, 0);
242 
243 $resql = $db->query($sql);
244 if ($resql)
245 {
246  $langs->load("boxes");
247  $num = $db->num_rows($resql);
248  $i = 0;
249 
250  print '<table class="noborder" width="100%">';
251  print '<tr class="liste_titre">';
252  print '<td colspan="2">'.$langs->trans("BoxTitleLastSuppliers",min($max,$num))."</td>\n";
253  print '<td align="right">'.$langs->trans("DateModification")."</td>\n";
254  print "</tr>\n";
255 
256  while ($obj = $db->fetch_object($resql) )
257  {
258  print '<tr class="oddeven">';
259  print '<td><a href="card.php?socid='.$obj->socid.'">'.img_object($langs->trans("ShowSupplier"),"company").'</a>';
260  print "&nbsp;<a href=\"card.php?socid=".$obj->socid."\">".$obj->name."</a></td>\n";
261  print '<td align="left">'.$obj->code_fournisseur.'&nbsp;</td>';
262  print '<td align="right">'.dol_print_date($db->jdate($obj->tms),'day').'</td>';
263  print "</tr>\n";
264  }
265  print "</table>\n";
266 
267  $db->free($resql);
268 }
269 else
270 {
271  dol_print_error($db);
272 }
273 
274 
275 /*
276  * List of suppliers categories
277  */
278 $companystatic->LoadSupplierCateg();
279 $categstatic=new Categorie($db);
280 
281 if (count($companystatic->SupplierCategories))
282 {
283  print '<br>';
284 
285  print '<table class="liste" width="100%">';
286  print '<tr class="liste_titre"><td colspan="2">';
287  print $langs->trans("Category");
288  print "</td></tr>\n";
289 
290  foreach ($companystatic->SupplierCategories as $rowid => $label)
291  {
292  print '<tr class="oddeven">'."\n";
293  print '<td>';
294  $categstatic->id=$rowid;
295  $categstatic->ref=$label;
296  $categstatic->label=$label;
297  print $categstatic->getNomUrl(1);
298  print '</td>'."\n";
299  // TODO this page not exist
300  /*
301  print '<td align="right">';
302  print '<a href="stats.php?cat='.$rowid.'">('.$langs->trans("Stats").')</a>';
303  print "</tr>\n";
304  */
305  }
306  print "</table>\n";
307  print "<br>\n";
308 }
309 
310 
311 //print "</td></tr></table>\n";
312 print '</div></div></div>';
313 
314 // End of page
315 llxFooter();
316 $db->close();
llxFooter()
Footer empty.
Definition: index.php:44
load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
GETPOST($paramname, $check='none', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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:1053
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.
Class to manage third parties objects (customers, suppliers, prospects...)
llxHeader()
Header empty.
Definition: index.php:36
Class to manage categories.
Class to manage predefined suppliers products.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages...
restrictedArea($user, $features, $objectid=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0)
Check permissions of a user to show a page and an object.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)