dolibarr  13.0.2
index.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2003-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net>
4  * Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
5  * Copyright (C) 2019 Nicolas ZABOURI <info@inovea-conseil.com>
6  * Copyright (C) 2020 Tobias Sekan <tobias.sekan@startmail.com>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <https://www.gnu.org/licenses/>.
20  */
21 
28 require '../../main.inc.php';
29 require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php';
30 require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
31 
32 $hookmanager = new HookManager($db);
33 
34 // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array
35 $hookmanager->initHooks(array('stockindex'));
36 
37 // Load translation files required by the page
38 $langs->loadLangs(array('stocks', 'productbatch'));
39 
40 // Security check
41 $result = restrictedArea($user, 'stock');
42 
43 
44 /*
45  * View
46  */
47 
48 $producttmp = new Product($db);
49 $warehouse = new Entrepot($db);
50 
51 $help_url = 'EN:Module_Stocks_En|FR:Module_Stock|ES:M&oacute;dulo_Stocks';
52 llxHeader("", $langs->trans("Stocks"), $help_url);
53 
54 print load_fiche_titre($langs->trans("StocksArea"), '', 'stock');
55 
56 
57 //print '<table border="0" width="100%" class="notopnoleftnoright">';
58 //print '<tr><td valign="top" width="30%" class="notopnoleft">';
59 print '<div class="fichecenter"><div class="fichethirdleft">';
60 
61 
62 if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo
63 {
64  print '<form method="post" action="'.DOL_URL_ROOT.'/product/stock/list.php">';
65  print '<input type="hidden" name="token" value="'.newToken().'">';
66  print '<div class="div-table-responsive-no-min">';
67  print '<table class="noborder nohover centpercent">';
68  print "<tr class=\"liste_titre\">";
69  print '<td colspan="3">'.$langs->trans("Search").'</td></tr>';
70  print '<tr class="oddevene"><td>';
71  print $langs->trans("Warehouse").':</td><td><input class="flat" type="text" size="18" name="sall"></td><td rowspan="2"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td></tr>';
72  print "</table></div></form><br>";
73 }
74 
75 $max = 15;
76 
77 $sql = "SELECT e.rowid, e.ref as label, e.lieu, e.statut as status";
78 $sql .= " FROM ".MAIN_DB_PREFIX."entrepot as e";
79 $sql .= " WHERE e.statut in (".Entrepot::STATUS_CLOSED.",".Entrepot::STATUS_OPEN_ALL.")";
80 $sql .= " AND e.entity IN (".getEntity('stock').")";
81 $sql .= $db->order('e.statut', 'DESC');
82 $sql .= $db->plimit($max + 1, 0);
83 
84 $result = $db->query($sql);
85 
86 if ($result)
87 {
88  $num = $db->num_rows($result);
89 
90  print '<div class="div-table-responsive-no-min">';
91  print '<table class="noborder centpercent">';
92  print '<tr class="liste_titre">';
93  print '<th colspan="2">';
94  print $langs->trans("Warehouses").' ';
95  print '<a href="'.DOL_URL_ROOT.'/product/stock/list.php">';
96  // TODO: "search_status" on "/product/stock/list.php" currently only accept a single integer value
97  //print '<a href="'.DOL_URL_ROOT.'/product/stock/list.php?search_status='.Entrepot::STATUS_CLOSED.','.Entrepot::STATUS_OPEN_ALL.'">';
98  print '<span class="badge">'.$num.'</span>';
99  print '</a>';
100  print '</th>';
101  print '</tr>';
102 
103  $i = 0;
104  if ($num)
105  {
106  while ($i < min($max, $num))
107  {
108  $objp = $db->fetch_object($result);
109 
110  $warehouse->id = $objp->rowid;
111  $warehouse->statut = $objp->status;
112  $warehouse->label = $objp->label;
113  $warehouse->lieu = $objp->lieu;
114 
115  print '<tr class="oddeven">';
116  print '<td>';
117  print $warehouse->getNomUrl(1);
118  print '</td>'."\n";
119  print '<td class="right">';
120  print $warehouse->getLibStatut(5);
121  print '</td>';
122  print "</tr>\n";
123  $i++;
124  }
125  $db->free($result);
126  } else {
127  print '<tr><td>'.$langs->trans("None").'</td><td></td></tr>';
128  }
129  if ($num > $max) {
130  print '<tr><td><span class="opacitymedium">'.$langs->trans("More").'...</span></td><td></td></tr>';
131  }
132 
133  print "</table>";
134  print '</div>';
135 } else {
136  dol_print_error($db);
137 }
138 
139 
140 //print '</td><td valign="top" width="70%" class="notopnoleftnoright">';
141 print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
142 
143 
144 // Latest movements
145 $max = 10;
146 $sql = "SELECT p.rowid, p.label as produit, p.tobatch, p.tosell, p.tobuy,";
147 $sql .= " e.ref as warehouse_ref, e.rowid as warehouse_id, e.ref as warehouse_label, e.lieu, e.statut as warehouse_status,";
148 $sql .= " m.value as qty, m.datem, m.batch, m.eatby, m.sellby";
149 $sql .= " FROM ".MAIN_DB_PREFIX."entrepot as e";
150 $sql .= ", ".MAIN_DB_PREFIX."stock_mouvement as m";
151 $sql .= ", ".MAIN_DB_PREFIX."product as p";
152 $sql .= " WHERE m.fk_product = p.rowid";
153 $sql .= " AND m.fk_entrepot = e.rowid";
154 $sql .= " AND e.entity IN (".getEntity('stock').")";
155 if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) $sql .= " AND p.fk_product_type = ".Product::TYPE_PRODUCT;
156 $sql .= $db->order("datem", "DESC");
157 $sql .= $db->plimit($max, 0);
158 
159 dol_syslog("Index:list stock movements", LOG_DEBUG);
160 $resql = $db->query($sql);
161 if ($resql)
162 {
163  $num = $db->num_rows($resql);
164 
165  print '<div class="div-table-responsive-no-min">';
166  print '<table class="noborder centpercent">';
167  print "<tr class=\"liste_titre\">";
168  print '<th>'.$langs->trans("LastMovements", min($num, $max)).'</th>';
169  print '<th>'.$langs->trans("Product").'</th>';
170  if (!empty($conf->productbatch->enabled))
171  {
172  print '<th>'.$langs->trans("Batch").'</th>';
173  if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) {
174  print '<th>'.$langs->trans("SellByDate").'</th>';
175  }
176  if (empty($conf->global->PRODUCT_DISABLE_EATBY)) {
177  print '<th>'.$langs->trans("EatByDate").'</th>';
178  }
179  }
180  print '<th>'.$langs->trans("Warehouse").'</th>';
181  print '<th class="right"><a class="notasortlink" href="'.DOL_URL_ROOT.'/product/stock/movement_list.php">'.$langs->trans("FullList").'</a></th>';
182  print "</tr>\n";
183 
184  $i = 0;
185  while ($i < min($num, $max))
186  {
187  $objp = $db->fetch_object($resql);
188 
189  $producttmp->id = $objp->rowid;
190  $producttmp->ref = $objp->produit;
191  $producttmp->status_batch = $objp->tobatch;
192  $producttmp->status_sell = $objp->tosell;
193  $producttmp->status_buy = $objp->tobuy;
194 
195  $warehouse->id = $objp->warehouse_id;
196  $warehouse->ref = $objp->warehouse_ref;
197  $warehouse->statut = $objp->warehouse_status;
198  $warehouse->label = $objp->warehouse_label;
199  $warehouse->lieu = $objp->lieu;
200 
201  print '<tr class="oddeven">';
202  print '<td class="nowraponall">'.dol_print_date($db->jdate($objp->datem), 'dayhour').'</td>';
203  print '<td class="tdoverflowmax200">';
204  print $producttmp->getNomUrl(1);
205  print "</td>\n";
206  if (!empty($conf->productbatch->enabled))
207  {
208  print '<td>'.$objp->batch.'</td>';
209  if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) {
210  print '<td>'.dol_print_date($db->jdate($objp->sellby), 'day').'</td>';
211  }
212  if (empty($conf->global->PRODUCT_DISABLE_EATBY)) {
213  print '<td>'.dol_print_date($db->jdate($objp->eatby), 'day').'</td>';
214  }
215  }
216  print '<td class="tdoverflowmax200">';
217  print $warehouse->getNomUrl(1);
218  print "</td>\n";
219  print '<td class="right">';
220  if ($objp->qty > 0) print '+';
221  print $objp->qty.'</td>';
222  print "</tr>\n";
223  $i++;
224  }
225  $db->free($resql);
226 
227  print "</table>";
228  print '</div>';
229 } else {
230  dol_print_error($db);
231 }
232 
233 //print '</td></tr></table>';
234 print '</div></div></div>';
235 
236 $parameters = array('user' => $user);
237 $reshook = $hookmanager->executeHooks('dashboardWarehouse', $parameters, $object); // Note that $action and $object may have been modified by hook
238 
239 // End of page
240 llxFooter();
241 $db->close();
const STATUS_OPEN_ALL
Warehouse open and operations for customer shipping, supplier dispatch, internal stock transfers/corr...
Class to manage products or services.
llxHeader()
Empty header.
Definition: wrapper.php:45
Class to manage hooks.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
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.
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
Class to manage warehouses.