dolibarr  13.0.2
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 <https://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->socid) $socid = $user->socid;
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 centpercent">';
74  print '<tr class="liste_titre"><td>'.$langs->trans("Orders").'</td><td class="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 class="center">'.$row[0].'</td>';
84  print '<td class="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 } else {
93  dol_print_error($db);
94 }
95 
96 
97 // Draft orders
98 if (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled))
99 {
100  $langs->load("orders");
101 
102  $sql = "SELECT cf.rowid, cf.ref, cf.total_ttc,";
103  $sql .= " s.nom as name, s.rowid as socid";
104  $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as cf";
105  $sql .= ", ".MAIN_DB_PREFIX."societe as s";
106  if (!$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc";
107  $sql .= " WHERE cf.fk_soc = s.rowid";
108  if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND sc.fk_user = ".$user->id;
109  $sql .= " AND cf.entity = ".$conf->entity;
110  $sql .= " AND cf.fk_statut = 0";
111  if ($socid) $sql .= " AND cf.fk_soc = ".$socid;
112 
113  $resql = $db->query($sql);
114  if ($resql)
115  {
116  $total = 0;
117  $num = $db->num_rows($resql);
118  if ($num)
119  {
120  print '<table class="noborder centpercent">';
121  print '<tr class="liste_titre">';
122  print '<td colspan="3">'.$langs->trans("DraftOrders").'<span class="badge marginleftonlyshort">'.$num.'</span></td></tr>';
123 
124  $i = 0;
125  while ($i < $num)
126  {
127  $obj = $db->fetch_object($resql);
128 
129  print '<tr class="oddeven"><td class="nowrap">';
130  $commandestatic->id = $obj->rowid;
131  $commandestatic->ref = $obj->ref;
132  print $commandestatic->getNomUrl(1, '', 16);
133  print '</td>';
134  print '<td class="nowrap">';
135  $companystatic->id = $obj->socid;
136  $companystatic->name = $obj->name;
137  $companystatic->client = 0;
138  print $companystatic->getNomUrl(1, '', 16);
139  print '</td>';
140  print '<td class="right nowrap">'.price($obj->total_ttc).'</td></tr>';
141  $i++;
142  $total += $obj->total_ttc;
143  }
144  if ($total > 0)
145  {
146  print '<tr class="liste_total"><td>'.$langs->trans("Total").'</td><td colspan="2" class="right">'.price($total)."</td></tr>";
147  }
148  print "</table>";
149  print "<br>\n";
150  }
151  }
152 }
153 
154 // Draft invoices
155 if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_invoice->enabled)) && $user->rights->fournisseur->facture->lire)
156 {
157  $sql = "SELECT ff.ref_supplier, ff.rowid, ff.total_ttc, ff.type";
158  $sql .= ", s.nom as name, s.rowid as socid";
159  $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as ff";
160  $sql .= ", ".MAIN_DB_PREFIX."societe as s";
161  if (!$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc";
162  $sql .= " WHERE s.rowid = ff.fk_soc";
163  if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND sc.fk_user = ".$user->id;
164  $sql .= " AND ff.entity = ".$conf->entity;
165  $sql .= " AND ff.fk_statut = 0";
166  if ($socid) $sql .= " AND f.fk_soc = ".$socid;
167 
168  $resql = $db->query($sql);
169 
170  if ($resql)
171  {
172  $num = $db->num_rows($resql);
173  if ($num)
174  {
175  print '<table class="noborder centpercent">';
176  print '<tr class="liste_titre">';
177  print '<td colspan="3">'.$langs->trans("DraftBills").'<span class="badge marginleftonlyshort">'.$num.'</span></td></tr>';
178  $i = 0;
179  $tot_ttc = 0;
180 
181  while ($i < $num && $i < 20)
182  {
183  $obj = $db->fetch_object($resql);
184 
185  print '<tr class="oddeven"><td class="nowrap">';
186  $facturestatic->ref = $obj->ref;
187  $facturestatic->id = $obj->rowid;
188  $facturestatic->type = $obj->type;
189  print $facturestatic->getNomUrl(1, '');
190  print '</td>';
191  print '<td class="nowrap">';
192  $companystatic->id = $obj->socid;
193  $companystatic->name = $obj->name;
194  $companystatic->client = 0;
195  print $companystatic->getNomUrl(1, '', 16);
196  print '</td>';
197  print '<td class="right">'.price($obj->total_ttc).'</td>';
198  print '</tr>';
199  $tot_ttc += $obj->total_ttc;
200  $i++;
201  }
202 
203  print '<tr class="liste_total"><td class="left">'.$langs->trans("Total").'</td>';
204  print '<td colspan="2" class="right">'.price($tot_ttc).'</td>';
205  print '</tr>';
206 
207  print "</table>";
208  print "<br>\n";
209  }
210  $db->free($resql);
211  } else {
212  dol_print_error($db);
213  }
214 }
215 
216 
217 //print '</td><td valign="top" width="70%" class="notopnoleftnoright">';
218 print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
219 
220 
221 /*
222  * List last modified supliers
223  */
224 $max = 10;
225 $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";
226 $sql .= ", st.libelle as stcomm";
227 $sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
228 $sql .= ", ".MAIN_DB_PREFIX."c_stcomm as st";
229 if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
230 $sql .= " WHERE s.fk_stcomm = st.id";
231 $sql .= " AND s.fournisseur = 1";
232 $sql .= " AND s.entity IN (".getEntity('societe').")";
233 if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
234 if ($socid) $sql .= " AND s.rowid = ".$socid;
235 $sql .= " ORDER BY s.tms DESC";
236 $sql .= $db->plimit($max, 0);
237 
238 $resql = $db->query($sql);
239 if ($resql)
240 {
241  $langs->load("boxes");
242  $num = $db->num_rows($resql);
243  $i = 0;
244 
245  print '<table class="noborder centpercent">';
246  print '<tr class="liste_titre">';
247  print '<td colspan="2">'.$langs->trans("BoxTitleLastSuppliers", min($max, $num))."</td>\n";
248  print '<td class="right">'.$langs->trans("DateModification")."</td>\n";
249  print "</tr>\n";
250 
251  while ($obj = $db->fetch_object($resql))
252  {
253  print '<tr class="oddeven">';
254  print '<td><a href="card.php?socid='.$obj->socid.'">'.img_object($langs->trans("ShowSupplier"), "company").'</a>';
255  print "&nbsp;<a href=\"card.php?socid=".$obj->socid."\">".$obj->name."</a></td>\n";
256  print '<td class="left">'.$obj->code_fournisseur.'&nbsp;</td>';
257  print '<td class="right">'.dol_print_date($db->jdate($obj->tms), 'day').'</td>';
258  print "</tr>\n";
259  }
260  print "</table>\n";
261 
262  $db->free($resql);
263 } else {
264  dol_print_error($db);
265 }
266 
267 
268 /*
269  * List of suppliers categories
270  */
271 $companystatic->LoadSupplierCateg();
272 $categstatic = new Categorie($db);
273 
274 if (count($companystatic->SupplierCategories))
275 {
276  print '<br>';
277 
278  print '<table class="liste centpercent">';
279  print '<tr class="liste_titre"><td colspan="2">';
280  print $langs->trans("Category");
281  print "</td></tr>\n";
282 
283  foreach ($companystatic->SupplierCategories as $rowid => $label)
284  {
285  print '<tr class="oddeven">'."\n";
286  print '<td>';
287  $categstatic->id = $rowid;
288  $categstatic->ref = $label;
289  $categstatic->label = $label;
290  print $categstatic->getNomUrl(1);
291  print '</td>'."\n";
292  // TODO this page not exist
293  /*
294  print '<td class="right">';
295  print '<a href="stats.php?cat='.$rowid.'">('.$langs->trans("Stats").')</a>';
296  print "</tr>\n";
297  */
298  }
299  print "</table>\n";
300  print "<br>\n";
301 }
302 
303 
304 //print "</td></tr></table>\n";
305 print '</div></div></div>';
306 
307 // End of page
308 llxFooter();
309 $db->close();
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Class to manage suppliers invoices.
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...
llxHeader()
Empty header.
Definition: wrapper.php:45
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage categories.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $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)
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.
Class to manage predefined suppliers products.
print
Draft customers invoices.
Definition: index.php:89
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->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)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1232
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
llxFooter()
Empty footer.
Definition: wrapper.php:59