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.
'/core/class/html.form.class.php';
33 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.commande.class.php';
34 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
35 require_once
'./lib/replenishment.lib.php';
38 $langs->loadLangs(array(
'products',
'stocks',
'orders'));
42 $socid = $user->socid;
47 $hookmanager->initHooks(array(
'stockreplenishlist'));
51 $action =
GETPOST(
'action',
'aZ09');
52 $search_ref =
GETPOST(
'search_ref',
'alpha');
53 $search_label =
GETPOST(
'search_label',
'alpha');
54 $sall = trim((
GETPOST(
'search_all',
'alphanohtml') !=
'') ?
GETPOST(
'search_all',
'alphanohtml') :
GETPOST(
'sall',
'alphanohtml'));
56 $tobuy =
GETPOST(
'tobuy',
'int');
57 $salert =
GETPOST(
'salert',
'alpha');
58 $includeproductswithoutdesiredqty =
GETPOST(
'includeproductswithoutdesiredqty',
'alpha');
59 $mode =
GETPOST(
'mode',
'alpha');
60 $draftorder =
GETPOST(
'draftorder',
'alpha');
63 $fourn_id =
GETPOST(
'fourn_id',
'int');
64 $fk_supplier =
GETPOST(
'fk_supplier',
'int');
65 $fk_entrepot =
GETPOST(
'fk_entrepot',
'int');
68 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
69 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
71 if (empty($page) || $page == -1) { $page = 0; }
72 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
73 $offset = $limit * $page;
83 $virtualdiffersfromphysical = 0;
84 if (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT)
85 || !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)
86 || !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)
87 || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION)
88 || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE)
89 || !empty($conf->mrp->enabled))
91 $virtualdiffersfromphysical = 1;
94 if ($virtualdiffersfromphysical) {
95 $usevirtualstock = empty($conf->global->STOCK_USE_REAL_STOCK_BY_DEFAULT_FOR_REPLENISHMENT) ? 1 : 0;
99 if ($mode ==
'physical') $usevirtualstock = 0;
100 if ($mode ==
'virtual') $usevirtualstock = 1;
102 $parameters = array();
103 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
104 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
111 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha') ||
GETPOST(
'valid'))
117 $includeproductswithoutdesiredqty =
'';
120 if ($draftorder ==
'on') $draftchecked =
"checked";
123 if ($action ==
'order' &&
GETPOST(
'valid'))
125 $linecount =
GETPOST(
'linecount',
'int');
128 unset($_POST[
'linecount']);
133 $suppliers = array();
134 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.product.class.php';
136 for ($i = 0; $i < $linecount; $i++)
138 if (
GETPOST(
'choose'.$i,
'alpha') ===
'on' &&
GETPOST(
'fourn'.$i,
'int') > 0)
142 $supplierpriceid =
GETPOST(
'fourn'.$i,
'int');
144 $qty =
GETPOST(
'tobuy'.$i,
'int');
145 $idprod = $productsupplier->get_buyprice($supplierpriceid, $qty);
146 $res = $productsupplier->fetch($idprod);
147 if ($res && $idprod > 0)
154 $line->fk_product = $idprod;
158 if (!empty($conf->global->MAIN_MULTILANGS))
160 $productsupplier->getMultiLangs();
164 if (!empty($productsupplier->desc_supplier) && !empty($conf->global->PRODUIT_FOURN_TEXTS)) {
165 $desc = $productsupplier->desc_supplier;
167 $desc = $productsupplier->description;
170 if (!empty($conf->global->MAIN_MULTILANGS))
175 $line->tva_tx = $productsupplier->vatrate_supplier;
176 $line->subprice = $productsupplier->fourn_pu;
177 $line->total_ht = $productsupplier->fourn_pu * $qty;
178 $tva = $line->tva_tx / 100;
179 $line->total_tva = $line->total_ht * $tva;
180 $line->total_ttc = $line->total_ht + $line->total_tva;
181 $line->remise_percent = $productsupplier->remise_percent;
182 $line->ref_fourn = $productsupplier->ref_supplier;
183 $line->type = $productsupplier->type;
184 $line->fk_unit = $productsupplier->fk_unit;
185 $suppliers[$productsupplier->fourn_socid][
'lines'][] = $line;
187 } elseif ($idprod == -1)
191 $error = $db->lasterror();
195 unset($_POST[
'fourn'.$i]);
204 $suppliersid = array_keys($suppliers);
205 foreach ($suppliers as $supplier)
209 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"commande_fournisseur";
210 $sql .=
" WHERE fk_soc = ".$suppliersid[$i];
211 $sql .=
" AND source = 42 AND fk_statut = 0";
212 $sql .=
" AND entity IN (".getEntity(
'commande_fournisseur').
")";
213 $sql .=
" ORDER BY date_creation DESC";
214 $resql = $db->query($sql);
216 $obj = $db->fetch_object(
$resql);
217 $order->fetch($obj->rowid);
218 foreach ($supplier[
'lines'] as $line) {
219 $result = $order->addline(
229 $line->remise_percent,
243 $msg = $langs->trans(
'OrderFail').
" : ";
244 $msg .= $order->error;
250 $order->socid = $suppliersid[$i];
251 $order->fetch_thirdparty();
254 foreach ($supplier[
'lines'] as $line) {
255 $order->lines[] = $line;
257 $order->cond_reglement_id = $order->thirdparty->cond_reglement_supplier_id;
258 $order->mode_reglement_id = $order->thirdparty->mode_reglement_supplier_id;
259 $id = $order->create($user);
262 $msg = $langs->trans(
'OrderFail').
" : ";
263 $msg .= $order->error;
270 if ($errorQty)
setEventMessages($langs->trans(
'ErrorOrdersNotCreatedQtyTooLow'), null,
'warnings');
277 header(
'Location: replenishorders.php');
285 setEventMessages($langs->trans(
'SelectProductWithNotNullQty'), null,
'warnings');
294 $form =
new Form($db);
298 $title = $langs->trans(
'MissingStocks');
300 if (!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE) && $fk_entrepot > 0) {
301 $sqldesiredtock = $db->ifsql(
"pse.desiredstock IS NULL",
"p.desiredstock",
"pse.desiredstock");
302 $sqlalertstock = $db->ifsql(
"pse.seuil_stock_alerte IS NULL",
"p.seuil_stock_alerte",
"pse.seuil_stock_alerte");
304 $sqldesiredtock =
'p.desiredstock';
305 $sqlalertstock =
'p.seuil_stock_alerte';
308 $sql =
'SELECT p.rowid, p.ref, p.label, p.description, p.price,';
309 $sql .=
' p.price_ttc, p.price_base_type,p.fk_product_type,';
310 $sql .=
' p.tms as datem, p.duration, p.tobuy,';
311 $sql .=
' p.desiredstock, p.seuil_stock_alerte,';
312 if (!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE) && $fk_entrepot > 0) {
313 $sql .=
' pse.desiredstock as desiredstockpse, pse.seuil_stock_alerte as seuil_stock_alertepse,';
315 $sql .=
' '.$sqldesiredtock.
' as desiredstockcombined, '.$sqlalertstock.
' as seuil_stock_alertecombined,';
316 $sql .=
' s.fk_product,';
317 $sql .=
' SUM('.$db->ifsql(
"s.reel IS NULL",
"0",
"s.reel").
') as stock_physique';
318 if (!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE) && $fk_entrepot > 0) {
319 $sql .=
', SUM('.$db->ifsql(
"s.reel IS NULL OR s.fk_entrepot <> ".$fk_entrepot,
"0",
"s.reel").
') as stock_real_warehouse';
323 $parameters = array();
324 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters);
325 $sql .= $hookmanager->resPrint;
327 $sql .=
' FROM '.MAIN_DB_PREFIX.
'product as p';
328 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'product_stock as s ON p.rowid = s.fk_product';
329 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'entrepot AS ent ON s.fk_entrepot = ent.rowid AND ent.entity IN('.
getEntity(
'stock').
')';
330 if ($fk_supplier > 0) {
331 $sql .=
' INNER JOIN '.MAIN_DB_PREFIX.
'product_fournisseur_price pfp ON (pfp.fk_product = p.rowid AND pfp.fk_soc = '.$fk_supplier.
')';
333 if (!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE) && $fk_entrepot > 0) {
334 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'product_warehouse_properties AS pse ON (p.rowid = pse.fk_product AND pse.fk_entrepot = '.$fk_entrepot.
')';
338 $parameters = array();
339 $reshook = $hookmanager->executeHooks(
'printFieldListJoin', $parameters);
340 $sql .= $hookmanager->resPrint;
342 $sql .=
' WHERE p.entity IN ('.getEntity(
'product').
')';
343 if ($sall) $sql .=
natural_search(array(
'p.ref',
'p.label',
'p.description',
'p.note'), $sall);
347 $sql .=
' AND p.fk_product_type = 1';
349 $sql .=
' AND p.fk_product_type <> 1';
353 if ($search_label) $sql .=
natural_search(
'p.label', $search_label);
354 $sql .=
' AND p.tobuy = 1';
355 if (empty($conf->global->VARIANT_ALLOW_STOCK_MOVEMENT_ON_VARIANT_PARENT)) {
356 $sql .=
' AND p.rowid NOT IN (SELECT pac.fk_product_parent FROM '.MAIN_DB_PREFIX.
'product_attribute_combination as pac WHERE pac.entity IN ('.
getEntity(
'product').
'))';
358 $sql .=
' GROUP BY p.rowid, p.ref, p.label, p.description, p.price';
359 $sql .=
', p.price_ttc, p.price_base_type,p.fk_product_type, p.tms';
360 $sql .=
', p.duration, p.tobuy';
361 $sql .=
', p.desiredstock';
362 $sql .=
', p.seuil_stock_alerte';
363 if (!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE) && $fk_entrepot > 0) {
364 $sql .=
', pse.desiredstock';
365 $sql .=
', pse.seuil_stock_alerte';
367 $sql .=
', s.fk_product';
369 if ($usevirtualstock)
371 if (!empty($conf->commande->enabled)) {
372 $sqlCommandesCli =
"(SELECT ".$db->ifsql(
"SUM(cd1.qty) IS NULL",
"0",
"SUM(cd1.qty)").
" as qty";
373 $sqlCommandesCli .=
" FROM ".MAIN_DB_PREFIX.
"commandedet as cd1, ".MAIN_DB_PREFIX.
"commande as c1";
374 $sqlCommandesCli .=
" WHERE c1.rowid = cd1.fk_commande AND c1.entity IN (".getEntity(!empty($conf->global->STOCK_CALCULATE_VIRTUAL_STOCK_TRANSVERSE_MODE) ?
'stock' :
'commande').
")";
375 $sqlCommandesCli .=
" AND cd1.fk_product = p.rowid";
376 $sqlCommandesCli .=
" AND c1.fk_statut IN (1,2))";
378 $sqlCommandesCli =
'0';
381 if (!empty($conf->expedition->enabled)) {
382 $sqlExpeditionsCli =
"(SELECT ".$db->ifsql(
"SUM(ed2.qty) IS NULL",
"0",
"SUM(ed2.qty)").
" as qty";
383 $sqlExpeditionsCli .=
" FROM ".MAIN_DB_PREFIX.
"expedition as e2,";
384 $sqlExpeditionsCli .=
" ".MAIN_DB_PREFIX.
"expeditiondet as ed2,";
385 $sqlExpeditionsCli .=
" ".MAIN_DB_PREFIX.
"commande as c2,";
386 $sqlExpeditionsCli .=
" ".MAIN_DB_PREFIX.
"commandedet as cd2";
387 $sqlExpeditionsCli .=
" WHERE ed2.fk_expedition = e2.rowid AND cd2.rowid = ed2.fk_origin_line AND e2.entity IN (".getEntity(!empty($conf->global->STOCK_CALCULATE_VIRTUAL_STOCK_TRANSVERSE_MODE) ?
'stock' :
'expedition').
")";
388 $sqlExpeditionsCli .=
" AND cd2.fk_commande = c2.rowid";
389 $sqlExpeditionsCli .=
" AND c2.fk_statut IN (1,2)";
390 $sqlExpeditionsCli .=
" AND cd2.fk_product = p.rowid";
391 $sqlExpeditionsCli .=
" AND e2.fk_statut IN (1,2))";
393 $sqlExpeditionsCli =
'0';
396 if (!empty($conf->fournisseur->enabled)) {
397 $sqlCommandesFourn =
"(SELECT ".$db->ifsql(
"SUM(cd3.qty) IS NULL",
"0",
"SUM(cd3.qty)").
" as qty";
398 $sqlCommandesFourn .=
" FROM ".MAIN_DB_PREFIX.
"commande_fournisseurdet as cd3,";
399 $sqlCommandesFourn .=
" ".MAIN_DB_PREFIX.
"commande_fournisseur as c3";
400 $sqlCommandesFourn .=
" WHERE c3.rowid = cd3.fk_commande";
401 $sqlCommandesFourn .=
" AND c3.entity IN (".getEntity(!empty($conf->global->STOCK_CALCULATE_VIRTUAL_STOCK_TRANSVERSE_MODE) ?
'stock' :
'supplier_order').
")";
402 $sqlCommandesFourn .=
" AND cd3.fk_product = p.rowid";
403 $sqlCommandesFourn .=
" AND c3.fk_statut IN (3,4))";
405 $sqlReceptionFourn =
"(SELECT ".$db->ifsql(
"SUM(fd4.qty) IS NULL",
"0",
"SUM(fd4.qty)").
" as qty";
406 $sqlReceptionFourn .=
" FROM ".MAIN_DB_PREFIX.
"commande_fournisseur as cf4,";
407 $sqlReceptionFourn .=
" ".MAIN_DB_PREFIX.
"commande_fournisseur_dispatch as fd4";
408 $sqlReceptionFourn .=
" WHERE fd4.fk_commande = cf4.rowid AND cf4.entity IN (".getEntity(!empty($conf->global->STOCK_CALCULATE_VIRTUAL_STOCK_TRANSVERSE_MODE) ?
'stock' :
'supplier_order').
")";
409 $sqlReceptionFourn .=
" AND fd4.fk_product = p.rowid";
410 $sqlReceptionFourn .=
" AND cf4.fk_statut IN (3,4))";
412 $sqlCommandesFourn =
'0';
413 $sqlReceptionFourn =
'0';
416 if (!empty($conf->mrp->enabled)) {
417 $sqlProductionToConsume =
"(SELECT GREATEST(0, ".$db->ifsql(
"SUM(".$db->ifsql(
"mp5.role = 'toconsume'",
'mp5.qty',
'- mp5.qty').
") IS NULL",
"0",
"SUM(".$db->ifsql(
"mp5.role = 'toconsume'",
'mp5.qty',
'- mp5.qty').
")").
") as qty";
418 $sqlProductionToConsume .=
" FROM ".MAIN_DB_PREFIX.
"mrp_mo as mm5,";
419 $sqlProductionToConsume .=
" ".MAIN_DB_PREFIX.
"mrp_production as mp5";
420 $sqlProductionToConsume .=
" WHERE mm5.rowid = mp5.fk_mo AND mm5.entity IN (".getEntity(!empty($conf->global->STOCK_CALCULATE_VIRTUAL_STOCK_TRANSVERSE_MODE) ?
'stock' :
'mo').
")";
421 $sqlProductionToConsume .=
" AND mp5.fk_product = p.rowid";
422 $sqlProductionToConsume .=
" AND mp5.role IN ('toconsume', 'consummed')";
423 $sqlProductionToConsume .=
" AND mm5.status IN (1,2))";
425 $sqlProductionToProduce =
"(SELECT GREATEST(0, ".$db->ifsql(
"SUM(".$db->ifsql(
"mp5.role = 'toproduce'",
'mp5.qty',
'- mp5.qty').
") IS NULL",
"0",
"SUM(".$db->ifsql(
"mp5.role = 'toconsume'",
'mp5.qty',
'- mp5.qty').
")").
") as qty";
426 $sqlProductionToProduce .=
" FROM ".MAIN_DB_PREFIX.
"mrp_mo as mm5,";
427 $sqlProductionToProduce .=
" ".MAIN_DB_PREFIX.
"mrp_production as mp5";
428 $sqlProductionToProduce .=
" WHERE mm5.rowid = mp5.fk_mo AND mm5.entity IN (".getEntity(!empty($conf->global->STOCK_CALCULATE_VIRTUAL_STOCK_TRANSVERSE_MODE) ?
'stock' :
'mo').
")";
429 $sqlProductionToProduce .=
" AND mp5.fk_product = p.rowid";
430 $sqlProductionToProduce .=
" AND mp5.role IN ('toproduce', 'produced')";
431 $sqlProductionToProduce .=
" AND mm5.status IN (1,2))";
433 $sqlProductionToConsume =
'0';
434 $sqlProductionToProduce =
'0';
438 $sql .=
' ('.$sqldesiredtock.
' >= 0 AND ('.$sqldesiredtock.
' > SUM('.$db->ifsql(
"s.reel IS NULL",
"0",
"s.reel").
')';
439 $sql .=
' - ('.$sqlCommandesCli.
' - '.$sqlExpeditionsCli.
') + ('.$sqlCommandesFourn.
' - '.$sqlReceptionFourn.
') + ('.$sqlProductionToProduce.
' - '.$sqlProductionToConsume.
')))';
441 if ($includeproductswithoutdesiredqty ==
'on') {
442 $sql .=
' (('.$sqlalertstock.
' >= 0 OR '.$sqlalertstock.
' IS NULL) AND ('.$db->ifsql(
"$sqlalertstock IS NULL",
"0", $sqlalertstock).
' > SUM('.$db->ifsql(
"s.reel IS NULL",
"0",
"s.reel").
')';
444 $sql .=
' ('.$sqlalertstock.
' >= 0 AND ('.$sqlalertstock.
' > SUM('.$db->ifsql(
"s.reel IS NULL",
"0",
"s.reel").
')';
446 $sql .=
' - ('.$sqlCommandesCli.
' - '.$sqlExpeditionsCli.
') + ('.$sqlCommandesFourn.
' - '.$sqlReceptionFourn.
') + ('.$sqlProductionToProduce.
' - '.$sqlProductionToConsume.
')))';
452 if ($includeproductswithoutdesiredqty ==
'on') {
453 $sql .=
'('.$sqlalertstock.
' >= 0 OR '.$sqlalertstock.
' IS NULL) AND ('.$db->ifsql(
"$sqlalertstock IS NULL",
"0", $sqlalertstock).
' > SUM('.$db->ifsql(
"s.reel IS NULL",
"0",
"s.reel").
')';
455 $sql .= $sqlalertstock.
' >= 0 AND ('.$sqlalertstock.
' > SUM('.$db->ifsql(
"s.reel IS NULL",
"0",
"s.reel").
')';
457 $sql .=
' - ('.$sqlCommandesCli.
' - '.$sqlExpeditionsCli.
') + ('.$sqlCommandesFourn.
' - '.$sqlReceptionFourn.
') + ('.$sqlProductionToProduce.
' - '.$sqlProductionToConsume.
'))';
459 $alertchecked =
'checked';
463 $sql .=
'('.$sqldesiredtock.
' >= 0 AND ('.$sqldesiredtock.
' > SUM('.$db->ifsql(
"s.reel IS NULL",
"0",
"s.reel").
')))';
465 if ($includeproductswithoutdesiredqty ==
'on') {
466 $sql .=
' (('.$sqlalertstock.
' >= 0 OR '.$sqlalertstock.
' IS NULL) AND ('.$db->ifsql(
"$sqlalertstock IS NULL",
"0", $sqlalertstock).
' > SUM('.$db->ifsql(
"s.reel IS NULL",
"0",
"s.reel").
')))';
468 $sql .=
' ('.$sqlalertstock.
' >= 0 AND ('.$sqlalertstock.
' > SUM('.$db->ifsql(
"s.reel IS NULL",
"0",
"s.reel").
')))';
475 if ($includeproductswithoutdesiredqty ==
'on') {
476 $sql .=
' ('.$sqlalertstock.
' >= 0 OR '.$sqlalertstock.
' IS NULL) AND ('.$db->ifsql(
"$sqlalertstock IS NULL",
"0", $sqlalertstock).
' > SUM('.$db->ifsql(
"s.reel IS NULL",
"0",
"s.reel").
'))';
478 $sql .=
' '.$sqlalertstock.
' >= 0 AND ('.$sqlalertstock.
' > SUM('.$db->ifsql(
"s.reel IS NULL",
"0",
"s.reel").
'))';
481 $alertchecked =
'checked';
485 $includeproductswithoutdesiredqtychecked =
'';
486 if ($includeproductswithoutdesiredqty ==
'on') {
487 $includeproductswithoutdesiredqtychecked =
'checked';
491 $parameters = array();
492 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters);
493 $sql .= $hookmanager->resPrint;
495 $nbtotalofrecords =
'';
496 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
497 $result = $db->query($sql);
498 $nbtotalofrecords = $db->num_rows($result);
499 if (($page * $limit) > $nbtotalofrecords) {
505 $sql .= $db->order($sortfield, $sortorder);
506 $sql .= $db->plimit($limit + 1, $offset);
509 $resql = $db->query($sql);
516 $num = $db->num_rows(
$resql);
519 $helpurl =
'EN:Module_Stocks_En|FR:Module_Stock|';
520 $helpurl .=
'ES:Módulo_Stocks';
526 $head[0][0] = DOL_URL_ROOT.
'/product/stock/replenish.php';
527 $head[0][1] = $title;
528 $head[0][2] =
'replenish';
530 $head[1][0] = DOL_URL_ROOT.
'/product/stock/replenishorders.php';
531 $head[1][1] = $langs->trans(
"ReplenishmentOrders");
532 $head[1][2] =
'replenishorders';
539 print '<span class="opacitymedium">'.$langs->trans(
"ReplenishmentStatusDesc").
'</span>'.
"\n";
540 if (empty($fk_warhouse) && !empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE)) {
541 print '<span class="opacitymedium">'.$langs->trans(
"ReplenishmentStatusDescPerWarehouse").
'</span>'.
"\n";
544 if ($usevirtualstock == 1)
546 print $langs->trans(
"CurentSelectionMode").
': ';
547 print '<span class="a-mesure">'.$langs->trans(
"UseVirtualStock").
'</span>';
548 print ' <a class="a-mesure-disabled" href="'.$_SERVER[
"PHP_SELF"].
'?mode=physical'.($fk_supplier > 0 ?
'&fk_supplier='.$fk_supplier :
'').($fk_entrepot > 0 ?
'&fk_entrepot='.$fk_entrepot :
'').
'">'.$langs->trans(
"UsePhysicalStock").
'</a>';
551 if ($usevirtualstock == 0)
553 print $langs->trans(
"CurentSelectionMode").
': ';
554 print '<a class="a-mesure-disabled" href="'.$_SERVER[
"PHP_SELF"].
'?mode=virtual'.($fk_supplier > 0 ?
'&fk_supplier='.$fk_supplier :
'').($fk_entrepot > 0 ?
'&fk_entrepot='.$fk_entrepot :
'').
'">'.$langs->trans(
"UseVirtualStock").
'</a>';
555 print ' <span class="a-mesure">'.$langs->trans(
"UsePhysicalStock").
'</span>';
560 print '<form name="formFilterWarehouse" method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
561 print '<input type="hidden" name="token" value="'.newToken().
'">';
562 print '<input type="hidden" name="action" value="filter">';
563 print '<input type="hidden" name="search_ref" value="'.$search_ref.
'">';
564 print '<input type="hidden" name="search_label" value="'.$search_label.
'">';
565 print '<input type="hidden" name="salert" value="'.$salert.
'">';
566 print '<input type="hidden" name="includeproductswithoutdesiredqty" value="'.$includeproductswithoutdesiredqty.
'">';
567 print '<input type="hidden" name="draftorder" value="'.$draftorder.
'">';
568 print '<input type="hidden" name="mode" value="'.$mode.
'">';
569 if ($limit > 0 && $limit != $conf->liste_limit) {
570 print '<input type="hidden" name="limit" value="'.$limit.
'">';
572 if (!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE))
574 print '<div class="inline-block valignmiddle" style="padding-right: 20px;">';
575 print $langs->trans(
'Warehouse').
' '.$formproduct->selectWarehouses($fk_entrepot,
'fk_entrepot',
'', 1);
578 print '<div class="inline-block valignmiddle" style="padding-right: 20px;">';
579 print $langs->trans(
'Supplier').
' '.$form->select_company($fk_supplier,
'fk_supplier',
'fournisseur=1', 1);
582 $parameters = array();
583 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters);
584 if (empty($reshook))
print $hookmanager->resPrint;
586 print '<div class="inline-block valignmiddle">';
587 print '<input class="button" type="submit" name="valid" value="'.$langs->trans(
'ToFilter').
'">';
592 print '<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST" name="formulaire">';
593 print '<input type="hidden" name="token" value="'.newToken().
'">';
594 print '<input type="hidden" name="fk_supplier" value="'.$fk_supplier.
'">';
595 print '<input type="hidden" name="fk_entrepot" value="'.$fk_entrepot.
'">';
596 print '<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
597 print '<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
598 print '<input type="hidden" name="type" value="'.$type.
'">';
599 print '<input type="hidden" name="linecount" value="'.$num.
'">';
600 print '<input type="hidden" name="action" value="order">';
601 print '<input type="hidden" name="mode" value="'.$mode.
'">';
604 if ($search_ref || $search_label || $sall || $salert || $draftorder ||
GETPOST(
'search',
'alpha')) {
605 $filters =
'&search_ref='.urlencode($search_ref).
'&search_label='.urlencode($search_label);
606 $filters .=
'&sall='.urlencode($sall);
607 $filters .=
'&salert='.urlencode($salert);
608 $filters .=
'&draftorder='.urlencode($draftorder);
609 $filters .=
'&mode='.urlencode($mode);
610 if ($fk_supplier > 0) $filters .=
'&fk_supplier='.urlencode($fk_supplier);
611 if ($fk_entrepot > 0) $filters .=
'&fk_entrepot='.urlencode($fk_entrepot);
613 $filters =
'&search_ref='.urlencode($search_ref).
'&search_label='.urlencode($search_label);
614 $filters .=
'&fourn_id='.urlencode($fourn_id);
615 $filters .= (isset($type) ?
'&type='.urlencode($type) :
'');
616 $filters .=
'&='.urlencode($salert);
617 $filters .=
'&draftorder='.urlencode($draftorder);
618 $filters .=
'&mode='.urlencode($mode);
619 if ($fk_supplier > 0) $filters .=
'&fk_supplier='.urlencode($fk_supplier);
620 if ($fk_entrepot > 0) $filters .=
'&fk_entrepot='.urlencode($fk_entrepot);
622 if ($limit > 0 && $limit != $conf->liste_limit) {
623 $filters .=
'&limit='.urlencode($limit);
626 $param = (isset($type) ?
'&type='.urlencode($type) :
'');
627 $param .=
'&fourn_id='.urlencode($fourn_id).
'&search_label='.urlencode($search_label).
'&includeproductswithoutdesiredqty='.urlencode($includeproductswithoutdesiredqty).
'&salert='.urlencode($salert).
'&draftorder='.urlencode($draftorder);
628 $param .=
'&search_ref='.urlencode($search_ref);
629 $param .=
'&mode='.urlencode($mode);
630 $param .=
'&fk_supplier='.urlencode($fk_supplier);
631 $param .=
'&fk_entrepot='.urlencode($fk_entrepot);
633 $stocklabel = $langs->trans(
'Stock');
634 $stocklabelbis = $langs->trans(
'Stock');
635 if ($usevirtualstock == 1) $stocklabel = $langs->trans(
'VirtualStock');
636 if ($usevirtualstock == 0) $stocklabel = $langs->trans(
'PhysicalStock');
637 if (!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE) && $fk_entrepot > 0)
639 $stocklabelbis = $stocklabel.
' (Selected warehouse)';
640 $stocklabel .=
' ('.$langs->trans(
"AllWarehouses").
')';
642 $texte = $langs->trans(
'Replenishment');
646 print '<div class="div-table-responsive">';
648 if (!empty($conf->global->REPLENISH_ALLOW_VARIABLESIZELIST)) {
680 print '<table class="liste centpercent">';
683 print '<tr class="liste_titre_filter">';
684 print '<td class="liste_titre"> </td>';
685 print '<td class="liste_titre"><input class="flat" type="text" name="search_ref" size="8" value="'.dol_escape_htmltag($search_ref).
'"></td>';
686 print '<td class="liste_titre"><input class="flat" type="text" name="search_label" size="8" value="'.dol_escape_htmltag($search_label).
'"></td>';
687 if (!empty($conf->service->enabled) && $type == 1)
print '<td class="liste_titre"> </td>';
688 print '<td class="liste_titre right">'.$form->textwithpicto($langs->trans(
'IncludeEmptyDesiredStock'), $langs->trans(
'IncludeProductWithUndefinedAlerts')).
' <input type="checkbox" id="includeproductswithoutdesiredqty" name="includeproductswithoutdesiredqty" '.(!empty($includeproductswithoutdesiredqtychecked) ? $includeproductswithoutdesiredqtychecked :
'').
'></td>';
689 print '<td class="liste_titre right"></td>';
690 print '<td class="liste_titre right">'.$langs->trans(
'AlertOnly').
' <input type="checkbox" id="salert" name="salert" '.(!empty($alertchecked) ? $alertchecked :
'').
'></td>';
691 if (!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE) && $fk_entrepot > 0)
693 print '<td class="liste_titre"> </td>';
695 print '<td class="liste_titre right">';
696 if (!empty($conf->global->STOCK_REPLENISH_ADD_CHECKBOX_INCLUDE_DRAFT_ORDER)) {
697 print $langs->trans(
'IncludeAlsoDraftOrders').
' <input type="checkbox" id="draftorder" name="draftorder" '.(!empty($draftchecked) ? $draftchecked :
'').
'>';
700 print '<td class="liste_titre"> </td>';
702 $parameters = array(
'param'=>$param,
'sortfield'=>$sortfield,
'sortorder'=>$sortorder);
703 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters);
704 print $hookmanager->resPrint;
706 print '<td class="liste_titre maxwidthsearch right">';
707 $searchpicto = $form->showFilterAndCheckAddButtons(0);
713 print '<tr class="liste_titre">';
717 if (!empty($conf->service->enabled) && $type == 1)
print_liste_field_titre(
'Duration',
$_SERVER[
"PHP_SELF"],
'p.duration', $param,
'',
'', $sortfield, $sortorder,
'center ');
721 if (!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE) && $fk_entrepot > 0)
730 $parameters = array(
'param'=>$param,
'sortfield'=>$sortfield,
'sortorder'=>$sortorder);
731 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters);
732 print $hookmanager->resPrint;
736 while ($i < ($limit ? min($num, $limit) : $num))
738 $objp = $db->fetch_object(
$resql);
740 if (!empty($conf->global->STOCK_SUPPORTS_SERVICES) || $objp->fk_product_type == 0)
742 $prod->fetch($objp->rowid);
743 $prod->load_stock(
'warehouseopen, warehouseinternal', $draftchecked);
746 if (!empty($conf->global->MAIN_MULTILANGS))
748 $sql =
'SELECT label,description';
749 $sql .=
' FROM '.MAIN_DB_PREFIX.
'product_lang';
750 $sql .=
' WHERE fk_product = '.$objp->rowid;
751 $sql .=
' AND lang = "'.$langs->getDefaultLang().
'"';
754 $resqlm = $db->query($sql);
757 $objtp = $db->fetch_object($resqlm);
758 if (!empty($objtp->description)) $objp->description = $objtp->description;
759 if (!empty($objtp->label)) $objp->label = $objtp->label;
764 if ($usevirtualstock)
767 $stock = $prod->stock_theorique;
770 $stock = $prod->stock_reel;
771 $stockwarehouse = $prod->stock_warehouse[$fk_entrepot]->real;
775 if (isset($draftchecked)) {
776 $result = $prod->load_stats_commande_fournisseur(0,
'0,1,2,3,4');
778 $result = $prod->load_stats_commande_fournisseur(0,
'1,2,3,4');
781 $result = $prod->load_stats_reception(0,
'4');
785 $ordered = $prod->stats_commande_fournisseur[
'qty'] - $prod->stats_reception[
'qty'];
787 $desiredstock = $objp->desiredstock;
788 $alertstock = $objp->seuil_stock_alerte;
789 $desiredstockwarehouse = ($objp->desiredstockpse ? $objp->desiredstockpse : 0);
790 $alertstockwarehouse = ($objp->seuil_stock_alertepse ? $objp->seuil_stock_alertepse : 0);
793 if ($alertstock && ($stock < $alertstock))
795 $warning =
img_warning($langs->trans(
'StockTooLow')).
' ';
797 $warningwarehouse =
'';
798 if ($alertstockwarehouse && ($stockwarehouse < $alertstockwarehouse))
800 $warningwarehouse =
img_warning($langs->trans(
'StockTooLow')).
' ';
806 if (empty($usevirtualstock)) $stocktobuy = max(max($desiredstock, $alertstock) - $stock - $ordered, 0);
807 else $stocktobuy = max(max($desiredstock, $alertstock) - $stock, 0);
808 if (empty($usevirtualstock)) $stocktobuywarehouse = max(max($desiredstockwarehouse, $alertstockwarehouse) - $stockwarehouse - $ordered, 0);
809 else $stocktobuywarehouse = max(max($desiredstockwarehouse, $alertstockwarehouse) - $stockwarehouse, 0);
814 $stockforcompare = ($usevirtualstock ? $stock : $stock + $ordered);
822 $picto =
img_picto($langs->trans(
"NoPendingReceptionOnSupplierOrder"),
'help');
825 print '<tr class="oddeven">';
828 print '<td><input type="checkbox" class="check" name="choose'.$i.
'"></td>';
830 print '<td class="nowrap">'.$prod->getNomUrl(1,
'stock').
'</td>';
832 print '<td>'.$objp->label;
836 if (!empty($conf->service->enabled) && $type == 1)
839 if (preg_match(
'/([0-9]+)y/i', $objp->duration, $regs)) {
840 $duration = $regs[1].
' '.$langs->trans(
'DurationYear');
841 } elseif (preg_match(
'/([0-9]+)m/i', $objp->duration, $regs)) {
842 $duration = $regs[1].
' '.$langs->trans(
'DurationMonth');
843 } elseif (preg_match(
'/([0-9]+)d/i', $objp->duration, $regs)) {
844 $duration = $regs[1].
' '.$langs->trans(
'DurationDay');
846 $duration = $objp->duration;
848 print '<td class="center">'.$duration.
'</td>';
852 print '<td class="right">'.($fk_entrepot > 0 ? $desiredstockwarehouse : $desiredstock).
'</td>';
855 print '<td class="right">'.($fk_entrepot > 0 ? $alertstockwarehouse : $alertstock).
'</td>';
858 print '<td class="right">'.$warning.$stock.
'</td>';
861 if (!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE) && $fk_entrepot > 0)
863 print '<td class="right">'.$warningwarehouse.$stockwarehouse.
'</td>';
867 print '<td class="right"><a href="replenishorders.php?search_product='.$prod->id.
'">'.$ordered.
'</a> '.$picto.
'</td>';
870 print '<td class="right"><input type="text" size="4" name="tobuy'.$i.
'" value="'.($fk_entrepot > 0 ? $stocktobuywarehouse : $stocktobuy).
'"></td>';
873 print '<td class="right">';
874 print $form->select_product_fourn_price($prod->id,
'fourn'.$i, $fk_supplier);
878 $parameters = array(
'objp'=>$objp);
879 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters);
880 print $hookmanager->resPrint;
887 $parameters = array(
'sql'=>$sql);
888 $reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters);
889 print $hookmanager->resPrint;
899 $value = $langs->trans(
"CreateOrders");
900 print '<div class="center"><input class="button" type="submit" name="valid" value="'.$value.
'"></div>';
908 <script type="text/javascript">
909 function toggle(source)
911 checkboxes = document.getElementsByClassName("check");
912 for (var i=0; i < checkboxes.length;i++) {
913 if (!checkboxes[i].disabled) {
914 checkboxes[i].checked = source.checked;
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.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
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.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
dol_strlen($string, $stringencoding= 'UTF-8')
Make a strlen call.
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it's its name (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.
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...
Class to manage predefined suppliers products.
print $_SERVER["PHP_SELF"]
Edit parameters.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
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...
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Class to manage predefined suppliers products.
Class to manage line orders.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $keepmoretags= '', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...