29 require
'../main.inc.php';
30 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
31 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
32 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
33 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
36 $langs->loadLangs(array(
'products',
'stocks'));
39 if ($user->socid) $socid = $user->socid;
43 $action =
GETPOST(
'action',
'aZ09');
44 $sref =
GETPOST(
"sref",
'alpha');
45 $snom =
GETPOST(
"snom",
'alpha');
46 $sall = trim((
GETPOST(
'search_all',
'alphanohtml') !=
'') ?
GETPOST(
'search_all',
'alphanohtml') :
GETPOST(
'sall',
'alphanohtml'));
48 $search_barcode =
GETPOST(
"search_barcode",
'alpha');
49 $catid =
GETPOST(
'catid',
'int');
50 $toolowstock =
GETPOST(
'toolowstock');
53 $fourn_id =
GETPOST(
"fourn_id",
'int');
55 $sortfield =
GETPOST(
"sortfield",
'alpha');
56 $sortorder =
GETPOST(
"sortorder",
'alpha');
58 if (empty($page) || $page < 0) $page = 0;
59 if (!$sortfield) $sortfield =
"p.ref";
60 if (!$sortorder) $sortorder =
"ASC";
61 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
62 if (empty($page) || $page == -1) { $page = 0; }
63 $offset = $limit * $page;
66 $search_sale =
GETPOST(
"search_sale");
67 $search_categ =
GETPOST(
"search_categ");
74 require_once DOL_DOCUMENT_ROOT.
'/core/class/canvas.class.php';
75 $objcanvas =
new Canvas($db, $action);
76 $objcanvas->getCanvas(
'product',
'list', $canvas);
80 $virtualdiffersfromphysical = 0;
81 if (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT)
82 || !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)
83 || !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)
84 || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION)
85 || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE)
86 || !empty($conf->mrp->enabled))
88 $virtualdiffersfromphysical = 1;
92 $hookmanager->initHooks(array(
'productreassortlist'));
100 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha'))
122 $helpurl =
'EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks';
124 $form =
new Form($db);
127 $sql =
'SELECT p.rowid, p.ref, p.label, p.barcode, p.price, p.price_ttc, p.price_base_type, p.entity,';
128 $sql .=
' p.fk_product_type, p.tms as datem,';
129 $sql .=
' p.duration, p.tosell as statut, p.tobuy, p.seuil_stock_alerte, p.desiredstock,';
130 $sql .=
' SUM(s.reel) as stock_physique';
131 if (!empty($conf->global->PRODUCT_USE_UNITS)) $sql .=
', u.short_label as unit_short';
133 $parameters = array();
134 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters);
135 $sql .= $hookmanager->resPrint;
136 $sql .=
' FROM '.MAIN_DB_PREFIX.
'product as p';
137 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'product_stock as s ON p.rowid = s.fk_product';
138 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'entrepot as e ON s.fk_entrepot = e.rowid AND e.entity IN ('.
getEntity(
'entrepot').
')';
139 if (!empty($conf->global->PRODUCT_USE_UNITS)) $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_units as u on p.fk_unit = u.rowid';
141 if ($search_categ) $sql .=
", ".MAIN_DB_PREFIX.
"categorie_product as cp";
142 $sql .=
" WHERE p.entity IN (".getEntity(
'product').
")";
143 if ($search_categ) $sql .=
" AND p.rowid = cp.fk_product";
144 if ($sall) $sql .=
natural_search(array(
'p.ref',
'p.label',
'p.description',
'p.note'), $sall);
150 $sql .=
" AND p.fk_product_type = '1'";
152 $sql .=
" AND p.fk_product_type <> '1'";
156 if ($search_barcode) $sql .=
natural_search(
'p.barcode', $search_barcode);
158 if (!empty($tosell)) $sql .=
" AND p.tosell = ".$tosell;
159 if (!empty($tobuy)) $sql .=
" AND p.tobuy = ".$tobuy;
160 if (!empty($canvas)) $sql .=
" AND p.canvas = '".$db->escape($canvas).
"'";
161 if ($catid) $sql .=
" AND cp.fk_categorie = ".$catid;
162 if ($fourn_id > 0) $sql .=
" AND p.rowid = pf.fk_product AND pf.fk_soc = ".$fourn_id;
164 if ($search_categ) $sql .=
" AND cp.fk_categorie = ".$db->escape($search_categ);
165 $sql .=
" GROUP BY p.rowid, p.ref, p.label, p.barcode, p.price, p.price_ttc, p.price_base_type, p.entity,";
166 $sql .=
" p.fk_product_type, p.tms, p.duration, p.tosell, p.tobuy, p.seuil_stock_alerte, p.desiredstock";
168 $parameters = array();
169 $reshook = $hookmanager->executeHooks(
'printFieldSelect', $parameters);
170 $sql .= $hookmanager->resPrint;
171 if ($toolowstock) $sql .=
" HAVING SUM(".$db->ifsql(
's.reel IS NULL',
'0',
's.reel').
") < p.seuil_stock_alerte";
172 $sql .= $db->order($sortfield, $sortorder);
175 $nbtotalofrecords =
'';
176 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
178 $result = $db->query($sql);
179 $nbtotalofrecords = $db->num_rows($result);
180 if (($page * $limit) > $nbtotalofrecords)
187 $sql .= $db->plimit($limit + 1, $offset);
189 $resql = $db->query($sql);
192 $num = $db->num_rows(
$resql);
196 if ($num == 1 &&
GETPOST(
'autojumpifoneonly') && ($sall || $snom || $sref))
198 $objp = $db->fetch_object(
$resql);
199 header(
"Location: card.php?id=$objp->rowid");
205 if ($type == 1) { $texte = $langs->trans(
"Services"); }
else { $texte = $langs->trans(
"Products"); }
207 $texte = $langs->trans(
"ProductsAndServices");
209 $texte .=
' ('.$langs->trans(
"MenuStocks").
')';
212 if ($limit > 0 && $limit != $conf->liste_limit) $param .=
'&limit='.urlencode($limit);
213 if ($sall) $param .=
"&sall=".urlencode($sall);
214 if ($tosell) $param .=
"&tosell=".urlencode($tosell);
215 if ($tobuy) $param .=
"&tobuy=".urlencode($tobuy);
216 if ($type) $param .=
"&type=".urlencode($type);
217 if ($fourn_id) $param .=
"&fourn_id=".urlencode($fourn_id);
218 if ($snom) $param .=
"&snom=".urlencode($snom);
219 if ($sref) $param .=
"&sref=".urlencode($sref);
220 if ($search_sale) $param .=
"&search_sale=".urlencode($search_sale);
221 if ($search_categ) $param .=
"&search_categ=".urlencode($search_categ);
222 if ($toolowstock) $param .=
"&toolowstock=".urlencode($toolowstock);
223 if ($sbarcode) $param .=
"&sbarcode=".urlencode($sbarcode);
224 if ($catid) $param .=
"&catid=".urlencode($catid);
228 print '<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post" name="formulaire">';
229 print '<input type="hidden" name="token" value="'.newToken().
'">';
230 print '<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
231 print '<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
232 print '<input type="hidden" name="page" value="'.$page.
'">';
233 print '<input type="hidden" name="type" value="'.$type.
'">';
235 print_barre_liste($texte, $page,
$_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder,
'', $num, $nbtotalofrecords,
'product', 0,
'',
'', $limit);
239 print "<div id='ways'>";
242 $ways = $c->print_all_ways(
' > ',
'product/reassort.php');
243 print " > ".$ways[0].
"<br>\n";
249 if (!empty($conf->categorie->enabled))
251 $moreforfilter .=
'<div class="divsearchfield">';
252 $moreforfilter .= $langs->trans(
'Categories').
': ';
253 $moreforfilter .= $htmlother->select_categories(Categorie::TYPE_PRODUCT, $search_categ,
'search_categ');
254 $moreforfilter .=
'</div>';
257 $moreforfilter .=
'<div class="divsearchfield">';
258 $moreforfilter .= $langs->trans(
"StockTooLow").
' <input type="checkbox" name="toolowstock" value="1"'.($toolowstock ?
' checked' :
'').
'>';
259 $moreforfilter .=
'</div>';
261 if (!empty($moreforfilter))
263 print '<div class="liste_titre liste_titre_bydiv centpercent">';
264 print $moreforfilter;
265 $parameters = array();
266 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters);
267 print $hookmanager->resPrint;
272 if ($tosell) $param .=
"&tosell=".urlencode($tosell);
273 if ($tobuy) $param .=
"&tobuy=".urlencode($tobuy);
274 if ($type) $param .=
"&type=".urlencode($type);
275 if ($fourn_id) $param .=
"&fourn_id=".urlencode($fourn_id);
276 if ($snom) $param .=
"&snom=".urlencode($snom);
277 if ($sref) $param .=
"&sref=".urlencode($sref);
278 if ($toolowstock) $param .=
"&toolowstock=".urlencode($toolowstock);
279 if ($search_categ) $param .=
"&search_categ=".urlencode($search_categ);
282 $formProduct->loadWarehouses();
283 $warehouses_list = $formProduct->cache_warehouses;
284 $nb_warehouse = count($warehouses_list);
285 $colspan_warehouse = 1;
286 if (!empty($conf->global->STOCK_DETAIL_ON_WAREHOUSE)) { $colspan_warehouse = $nb_warehouse > 1 ? $nb_warehouse + 1 : 1; }
288 print '<div class="div-table-responsive">';
289 print '<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">';
292 print '<tr class="liste_titre_filter">';
293 print
'<td class="liste_titre">';
294 print
'<input class="flat" type="text" name="sref" size="6" value="'.$sref.
'">';
296 print
'<td class="liste_titre">';
297 print
'<input class="flat" type="text" name="snom" size="8" value="'.$snom.
'">';
300 if (!empty($conf->service->enabled) && $type == 1)
302 print
'<td class="liste_titre">';
307 print
'<td class="liste_titre"> </td>';
308 print
'<td class="liste_titre right"> </td>';
309 print
'<td class="liste_titre"> </td>';
310 if ($virtualdiffersfromphysical) print
'<td class="liste_titre"> </td>';
311 print
'<td class="liste_titre"> </td>';
312 print
'<td class="liste_titre" colspan="'.$colspan_warehouse.
'"> </td>';
313 print
'<td class="liste_titre"></td>';
314 $parameters = array();
315 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters);
316 print $hookmanager->resPrint;
317 print
'<td class="liste_titre maxwidthsearch">';
318 $searchpicto = $form->showFilterAndCheckAddButtons(0);
324 print
"<tr class=\"liste_titre\">";
327 if (!empty($conf->service->enabled) && $type == 1)
print_liste_field_titre(
"Duration",
$_SERVER[
"PHP_SELF"],
"p.duration", $param,
"",
'', $sortfield, $sortorder,
'center ');
332 if (!empty($conf->global->STOCK_DETAIL_ON_WAREHOUSE))
334 if ($nb_warehouse > 1) {
335 foreach ($warehouses_list as &$wh) {
340 if ($virtualdiffersfromphysical)
print_liste_field_titre(
"VirtualStock",
$_SERVER[
"PHP_SELF"],
"", $param,
"",
'', $sortfield, $sortorder,
'right ',
'VirtualStockDesc');
342 if (!empty($conf->global->PRODUCT_USE_UNITS)) {
349 $parameters = array(
'param'=>$param,
'sortfield'=>$sortfield,
'sortorder'=>$sortorder);
350 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters);
351 print $hookmanager->resPrint;
355 while ($i < min($num, $limit))
357 $objp = $db->fetch_object(
$resql);
360 $product->fetch($objp->rowid);
361 $product->load_stock();
364 print
'<td class="nowrap">';
365 print $product->getNomUrl(1,
'', 16);
368 print
'<td>'.$product->label.
'</td>';
370 if (!empty($conf->service->enabled) && $type == 1)
372 print
'<td class="center">';
373 if (preg_match(
'/([0-9]+)y/i', $objp->duration, $regs)) print $regs[1].
' '.$langs->trans(
"DurationYear");
374 elseif (preg_match(
'/([0-9]+)m/i', $objp->duration, $regs)) print $regs[1].' '.$langs->trans("DurationMonth");
375 elseif (preg_match('/([0-9]+)d/i', $objp->duration, $regs)) print $regs[1].' '.$langs->trans("DurationDay");
376 else print $objp->duration;
380 print '<td class="right">'.$objp->seuil_stock_alerte.'</td>';
381 print '<td class="right">'.$objp->desiredstock.'</td>';
383 print '<td class="right">';
384 if ($objp->seuil_stock_alerte != '' && ($objp->stock_physique < $objp->seuil_stock_alerte)) print
img_warning($langs->trans("StockTooLow")).' ';
385 print
price2num($objp->stock_physique, 'MS');
389 if (!empty($conf->global->STOCK_DETAIL_ON_WAREHOUSE))
391 if ($nb_warehouse > 1) {
392 foreach ($warehouses_list as &$wh) {
393 print
'<td class="right">';
394 print empty($product->stock_warehouse[$wh[
'id']]->real) ?
'0' : $product->stock_warehouse[$wh[
'id']]->real;
401 if ($virtualdiffersfromphysical)
403 print
'<td class="right">';
404 if ($objp->seuil_stock_alerte !=
'' && ($product->stock_theorique < $objp->seuil_stock_alerte)) print
img_warning($langs->trans(
"StockTooLow")).
' ';
405 print
price2num($product->stock_theorique,
'MS');
409 if (!empty($conf->global->PRODUCT_USE_UNITS)) {
410 print
'<td class="left">'.$objp->unit_short.
'</td>';
412 print
'<td class="right"><a href="'.DOL_URL_ROOT.
'/product/stock/movement_list.php?idproduct='.$product->id.
'">'.$langs->trans(
"Movements").
'</a></td>';
413 print
'<td class="right nowrap">'.$product->LibStatut($objp->statut, 5, 0).
'</td>';
414 print
'<td class="right nowrap">'.$product->LibStatut($objp->tobuy, 5, 1).
'</td>';
416 $parameters = array(
'obj'=>$objp);
417 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters);
418 print $hookmanager->resPrint;
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 products or services.
img_warning($titlealt= 'default', $moreatt= '', $morecss= 'pictowarning')
Show warning logo.
print_barre_liste($titre, $page, $file, $options= '', $sortfield= '', $sortorder= '', $morehtmlcenter= '', $num=-1, $totalnboflines= '', $picto= 'generic', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow= '')
Print a title with navigation controls for pagination.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
Class to manage categories.
dol_strlen($string, $stringencoding= 'UTF-8')
Make a strlen call.
price2num($amount, $rounding= '', $option=0)
Function that return a number with universal decimal format (decimal separator is '...
if(!GETPOST('transkey', 'alphanohtml')&&!GETPOST('transphrase', 'alphanohtml')) else
View.
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.
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
print $_SERVER["PHP_SELF"]
Edit parameters.
print
Draft customers invoices.
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.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.