dolibarr  7.0.0-beta
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@capnetworks.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->load("suppliers");
32 $langs->load("orders");
33 $langs->load("companies");
34 
35 // Security check
36 $socid = GETPOST("socid", 'int');
37 if ($user->societe_id) $socid=$user->societe_id;
38 $result = restrictedArea($user, 'societe',$socid,'');
39 
40 
41 /*
42  * View
43  */
44 
45 $commandestatic=new CommandeFournisseur($db);
46 $facturestatic=new FactureFournisseur($db);
47 $companystatic=new Societe($db);
48 
49 llxHeader("",$langs->trans("SuppliersArea"));
50 
51 print load_fiche_titre($langs->trans("SuppliersArea"));
52 
53 
54 //print '<table border="0" width="100%" class="notopnoleftnoright">';
55 //print '<tr><td valign="top" width="30%" class="notopnoleft">';
56 print '<div class="fichecenter"><div class="fichethirdleft">';
57 
58 
59 // Orders
60 $commande = new CommandeFournisseur($db);
61 $sql = "SELECT count(cf.rowid), cf.fk_statut";
62 $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as cf,";
63 $sql.= " ".MAIN_DB_PREFIX."societe as s";
64 if (!$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc";
65 $sql.= " WHERE cf.fk_soc = s.rowid ";
66 if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND sc.fk_user = " .$user->id;
67 $sql.= " AND cf.entity = ".$conf->entity;
68 $sql.= " GROUP BY cf.fk_statut";
69 
70 $resql = $db->query($sql);
71 if ($resql)
72 {
73  $num = $db->num_rows($resql);
74  $i = 0;
75 
76  print '<table class="noborder" width="100%">';
77  print '<tr class="liste_titre"><td>'.$langs->trans("Orders").'</td><td align="center">'.$langs->trans("Nb").'</td><td>&nbsp;</td>';
78  print "</tr>\n";
79  $var=True;
80 
81  while ($i < $num)
82  {
83  $row = $db->fetch_row($resql);
84 
85 
86  print '<tr class="oddeven">';
87  print '<td>'.$langs->trans($commande->statuts[$row[1]]).'</td>';
88  print '<td align="center">'.$row[0].'</td>';
89  print '<td align="center"><a href="'.DOL_URL_ROOT.'/fourn/commande/list.php?statut='.$row[1].'">'.$commande->LibStatut($row[1],3).'</a></td>';
90 
91  print "</tr>\n";
92  $i++;
93  }
94  print "</table>";
95  print "<br>\n";
96  $db->free($resql);
97 }
98 else
99 {
100  dol_print_error($db);
101 }
102 
103 
104 // Draft orders
105 if (! empty($conf->fournisseur->enabled))
106 {
107  $langs->load("orders");
108 
109  $sql = "SELECT cf.rowid, cf.ref, cf.total_ttc,";
110  $sql.= " s.nom as name, s.rowid as socid";
111  $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as cf";
112  $sql.= ", ".MAIN_DB_PREFIX."societe as s";
113  if (!$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc";
114  $sql.= " WHERE cf.fk_soc = s.rowid";
115  if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND sc.fk_user = " .$user->id;
116  $sql.= " AND cf.entity = ".$conf->entity;
117  $sql.= " AND cf.fk_statut = 0";
118  if ($socid) $sql .= " AND cf.fk_soc = ".$socid;
119 
120  $resql = $db->query($sql);
121  if ($resql)
122  {
123  $total = 0;
124  $num = $db->num_rows($resql);
125  if ($num)
126  {
127  print '<table class="noborder" width="100%">';
128  print '<tr class="liste_titre">';
129  print '<td colspan="3">'.$langs->trans("DraftOrders").' <span class="badge">'.$num.'</span></td></tr>';
130 
131  $i = 0;
132  $var = true;
133  while ($i < $num)
134  {
135 
136  $obj = $db->fetch_object($resql);
137  print '<tr class="oddeven"><td class="nowrap">';
138  $commandestatic->id=$obj->rowid;
139  $commandestatic->ref=$obj->ref;
140  print $commandestatic->getNomUrl(1,'',16);
141  print '</td>';
142  print '<td class="nowrap">';
143  $companystatic->id=$obj->socid;
144  $companystatic->name=$obj->name;
145  $companystatic->client=0;
146  print $companystatic->getNomUrl(1,'',16);
147  print '</td>';
148  print '<td align="right" class="nowrap">'.price($obj->total_ttc).'</td></tr>';
149  $i++;
150  $total += $obj->total_ttc;
151  }
152  if ($total>0)
153  {
154 
155  print '<tr class="liste_total"><td>'.$langs->trans("Total").'</td><td colspan="2" align="right">'.price($total)."</td></tr>";
156  }
157  print "</table>";
158  print "<br>\n";
159  }
160  }
161 }
162 
163 // Draft invoices
164 if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire)
165 {
166  $sql = "SELECT ff.ref_supplier, ff.rowid, ff.total_ttc, ff.type";
167  $sql.= ", s.nom as name, s.rowid as socid";
168  $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn as ff";
169  $sql.= ", ".MAIN_DB_PREFIX."societe as s";
170  if (!$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc";
171  $sql.= " WHERE s.rowid = ff.fk_soc";
172  if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND sc.fk_user = " .$user->id;
173  $sql.= " AND ff.entity = ".$conf->entity;
174  $sql.= " AND ff.fk_statut = 0";
175  if ($socid) $sql .= " AND f.fk_soc = ".$socid;
176 
177  $resql = $db->query($sql);
178 
179  if ( $resql )
180  {
181  $num = $db->num_rows($resql);
182  if ($num)
183  {
184  print '<table class="noborder" width="100%">';
185  print '<tr class="liste_titre">';
186  print '<td colspan="3">'.$langs->trans("DraftBills").' <span class="badge">'.$num.'</span></td></tr>';
187  $i = 0;
188  $tot_ttc = 0;
189  $var = True;
190  while ($i < $num && $i < 20)
191  {
192  $obj = $db->fetch_object($resql);
193 
194  print '<tr class="oddeven"><td class="nowrap">';
195  $facturestatic->ref=$obj->ref;
196  $facturestatic->id=$obj->rowid;
197  $facturestatic->type=$obj->type;
198  print $facturestatic->getNomUrl(1,'');
199  print '</td>';
200  print '<td class="nowrap">';
201  $companystatic->id=$obj->socid;
202  $companystatic->name=$obj->name;
203  $companystatic->client=0;
204  print $companystatic->getNomUrl(1,'',16);
205  print '</td>';
206  print '<td align="right">'.price($obj->total_ttc).'</td>';
207  print '</tr>';
208  $tot_ttc+=$obj->total_ttc;
209  $i++;
210  }
211 
212  print '<tr class="liste_total"><td align="left">'.$langs->trans("Total").'</td>';
213  print '<td colspan="2" align="right">'.price($tot_ttc).'</td>';
214  print '</tr>';
215 
216  print "</table>";
217  print "<br>\n";
218  }
219  $db->free($resql);
220  }
221  else
222  {
223  dol_print_error($db);
224  }
225 }
226 
227 
228 //print '</td><td valign="top" width="70%" class="notopnoleftnoright">';
229 print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
230 
231 
232 /*
233  * List last modified supliers
234  */
235 $max=10;
236 $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";
237 $sql.= ", st.libelle as stcomm";
238 $sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
239 $sql.= ", ".MAIN_DB_PREFIX."c_stcomm as st";
240 if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
241 $sql.= " WHERE s.fk_stcomm = st.id";
242 $sql.= " AND s.fournisseur = 1";
243 $sql.= " AND s.entity IN (".getEntity('societe').")";
244 if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
245 if ($socid) $sql .= " AND s.rowid = ".$socid;
246 $sql.= " ORDER BY s.tms DESC";
247 $sql .= $db->plimit($max, 0);
248 
249 $resql = $db->query($sql);
250 if ($resql)
251 {
252  $langs->load("boxes");
253  $num = $db->num_rows($resql);
254  $i = 0;
255 
256  print '<table class="noborder" width="100%">';
257  print '<tr class="liste_titre">';
258  print '<td colspan="2">'.$langs->trans("BoxTitleLastSuppliers",min($max,$num))."</td>\n";
259  print '<td align="right">'.$langs->trans("DateModification")."</td>\n";
260  print "</tr>\n";
261 
262  $var=True;
263 
264  while ($obj = $db->fetch_object($resql) )
265  {
266 
267 
268  print '<tr class="oddeven">';
269  print '<td><a href="card.php?socid='.$obj->socid.'">'.img_object($langs->trans("ShowSupplier"),"company").'</a>';
270  print "&nbsp;<a href=\"card.php?socid=".$obj->socid."\">".$obj->name."</a></td>\n";
271  print '<td align="left">'.$obj->code_fournisseur.'&nbsp;</td>';
272  print '<td align="right">'.dol_print_date($db->jdate($obj->tms),'day').'</td>';
273  print "</tr>\n";
274  }
275  print "</table>\n";
276 
277  $db->free($resql);
278 }
279 else
280 {
281  dol_print_error($db);
282 }
283 
284 
285 /*
286  * List of suppliers categories
287  */
288 $companystatic->LoadSupplierCateg();
289 $categstatic=new Categorie($db);
290 
291 if (count($companystatic->SupplierCategories))
292 {
293  print '<br>';
294 
295  print '<table class="liste" width="100%">';
296  print '<tr class="liste_titre"><td colspan="2">';
297  print $langs->trans("Category");
298  print "</td></tr>\n";
299  $var=True;
300 
301  foreach ($companystatic->SupplierCategories as $rowid => $label)
302  {
303 
304  print "<tr ".$bc[$var].">\n";
305  print '<td>';
306  $categstatic->id=$rowid;
307  $categstatic->ref=$label;
308  $categstatic->label=$label;
309  print $categstatic->getNomUrl(1);
310  print '</td>'."\n";
311  // TODO this page not exist
312  /*
313  print '<td align="right">';
314  print '<a href="stats.php?cat='.$rowid.'">('.$langs->trans("Stats").')</a>';
315  print "</tr>\n";
316  */
317  }
318  print "</table>\n";
319  print "<br>\n";
320 }
321 
322 
323 //print "</td></tr></table>\n";
324 print '</div></div></div>';
325 
326 llxFooter();
327 
328 $db->close();
llxFooter()
Footer empty.
Definition: index.php:43
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.
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 third parties objects (customers, suppliers, prospects...)
llxHeader()
Header empty.
Definition: index.php:37
Class to manage categories.
load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png', $pictoisfullpath=0, $id=0, $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_object($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
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...
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
restrictedArea($user, $features, $objectid=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $objcanvas=null)
Check permissions of a user to show a page and an object.