29 require
'../../main.inc.php';
30 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
31 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
32 require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/entrepot.class.php';
33 require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/mouvementstock.class.php';
34 require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/productlot.class.php';
35 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
36 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
37 require_once DOL_DOCUMENT_ROOT.
'/core/lib/stock.lib.php';
38 require_once DOL_DOCUMENT_ROOT.
'/core/lib/product.lib.php';
39 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
40 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
41 if (!empty($conf->projet->enabled)) {
42 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
43 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
47 $langs->loadLangs(array(
'products',
'stocks',
'orders'));
48 if (!empty($conf->productbatch->enabled)) $langs->load(
"productbatch");
56 $product_id =
GETPOST(
"product_id",
'int');
57 $action =
GETPOST(
'action',
'aZ09');
58 $massaction =
GETPOST(
'massaction',
'alpha');
59 $confirm =
GETPOST(
'confirm',
'alpha');
60 $cancel =
GETPOST(
'cancel',
'alpha');
61 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'movementlist';
62 $toselect =
GETPOST(
'toselect',
'array');
68 $idproduct =
GETPOST(
'idproduct',
'int');
71 $search_ref =
GETPOST(
'search_ref',
'alpha');
72 $search_movement =
GETPOST(
"search_movement");
73 $search_product_ref = trim(
GETPOST(
"search_product_ref"));
74 $search_product = trim(
GETPOST(
"search_product"));
75 $search_warehouse = trim(
GETPOST(
"search_warehouse"));
76 $search_inventorycode = trim(
GETPOST(
"search_inventorycode"));
77 $search_user = trim(
GETPOST(
"search_user"));
78 $search_batch = trim(
GETPOST(
"search_batch"));
79 $search_qty = trim(
GETPOST(
"search_qty"));
80 $search_type_mouvement =
GETPOST(
'search_type_mouvement',
'int');
82 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
84 $sortfield =
GETPOST(
"sortfield",
'alpha');
85 $sortorder =
GETPOST(
"sortorder",
'alpha');
86 if (empty($page) || $page == -1) { $page = 0; }
87 $offset = $limit * $page;
88 if (!$sortfield) $sortfield =
"m.datem";
89 if (!$sortorder) $sortorder =
"DESC";
91 $pdluoid =
GETPOST(
'pdluoid',
'int');
95 $hookmanager->initHooks(array(
'movementlist'));
100 $extrafields->fetch_name_optionals_label($object->table_element);
102 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element,
'',
'search_');
104 $arrayfields = array(
105 'm.rowid'=>array(
'label'=>$langs->trans(
"Ref"),
'checked'=>1),
106 'm.datem'=>array(
'label'=>$langs->trans(
"Date"),
'checked'=>1),
107 'p.ref'=>array(
'label'=>$langs->trans(
"ProductRef"),
'checked'=>1,
'css'=>
'maxwidth100'),
108 'p.label'=>array(
'label'=>$langs->trans(
"ProductLabel"),
'checked'=>1),
109 'm.batch'=>array(
'label'=>$langs->trans(
"BatchNumberShort"),
'checked'=>1,
'enabled'=>(!empty($conf->productbatch->enabled))),
110 'pl.eatby'=>array(
'label'=>$langs->trans(
"EatByDate"),
'checked'=>0,
'enabled'=>(!empty($conf->productbatch->enabled))),
111 'pl.sellby'=>array(
'label'=>$langs->trans(
"SellByDate"),
'checked'=>0,
'position'=>10,
'enabled'=>(!empty($conf->productbatch->enabled))),
112 'e.ref'=>array(
'label'=>$langs->trans(
"Warehouse"),
'checked'=>1,
'enabled'=>(!$id > 0)),
113 'm.fk_user_author'=>array(
'label'=>$langs->trans(
"Author"),
'checked'=>0),
114 'm.inventorycode'=>array(
'label'=>$langs->trans(
"InventoryCodeShort"),
'checked'=>1),
115 'm.label'=>array(
'label'=>$langs->trans(
"MovementLabel"),
'checked'=>1),
116 'm.type_mouvement'=>array(
'label'=>$langs->trans(
"TypeMovement"),
'checked'=>1),
117 'origin'=>array(
'label'=>$langs->trans(
"Origin"),
'checked'=>1),
118 'm.value'=>array(
'label'=>$langs->trans(
"Qty"),
'checked'=>1),
119 'm.price'=>array(
'label'=>$langs->trans(
"UnitPurchaseValue"),
'checked'=>0),
120 'm.fk_projet'=>array(
'label'=>$langs->trans(
'Project'),
'checked'=>0)
124 if (!empty($conf->global->PRODUCT_DISABLE_EATBY)) {
125 unset($arrayfields[
'pl.eatby']);
127 if (!empty($conf->global->PRODUCT_DISABLE_SELLBY)) {
128 unset($arrayfields[
'pl.sellby']);
132 if (!$user->rights->stock->mouvement->lire) {
136 $permissiontoread = $user->rights->stock->mouvement->lire;
137 $permissiontoadd = $user->rights->stock->mouvement->creer;
138 $permissiontodelete = $user->rights->stock->mouvement->creer;
140 $usercanread = $user->rights->stock->mouvement->lire;
141 $usercancreate = $user->rights->stock->mouvement->creer;
142 $usercandelete = $user->rights->stock->mouvement->creer;
151 if (
GETPOST(
'cancel',
'alpha')) { $action =
'list'; $massaction =
''; }
152 if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') { $massaction =
''; }
154 $parameters = array();
155 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
156 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
160 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
163 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha'))
168 $search_movement =
"";
169 $search_type_mouvement =
"";
170 $search_inventorycode =
"";
171 $search_product_ref =
"";
172 $search_product =
"";
173 $search_warehouse =
"";
179 $search_array_options = array();
183 $objectclass =
'MouvementStock';
184 $objectlabel =
'MouvementStock';
185 $uploaddir = $conf->stock->dir_output;
186 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
189 if ($action ==
'update_extras') {
191 $tmpwarehouse->fetch($id);
193 $tmpwarehouse->oldcopy =
dol_clone($tmpwarehouse);
196 $ret = $extrafields->setOptionalsFromPost(null, $tmpwarehouse,
GETPOST(
'attribute',
'restricthtml'));
197 if ($ret < 0) $error++;
199 $result = $tmpwarehouse->insertExtraFields();
205 if ($error) $action =
'edit_extras';
209 if ($action ==
"correct_stock")
212 if (!empty($product_id)) $result = $product->fetch($product_id);
216 if (empty($product_id))
219 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Product")), null,
'errors');
220 $action =
'correction';
222 if (!is_numeric($_POST[
"nbpiece"]))
225 setEventMessages($langs->trans(
"ErrorFieldMustBeANumeric", $langs->transnoentitiesnoconv(
"NumberOfUnit")), null,
'errors');
226 $action =
'correction';
231 $origin_element =
'';
234 if (
GETPOST(
'projectid',
'int'))
236 $origin_element =
'project';
237 $origin_id =
GETPOST(
'projectid',
'int');
240 if ($product->hasbatch())
242 $batch =
GETPOST(
'batch_number',
'alphanohtml');
249 $result = $product->correct_stock_batch(
256 $eatby, $sellby, $batch,
257 GETPOST(
'inventorycode',
'alphanohtml'),
262 $result = $product->correct_stock(
269 GETPOST(
'inventorycode',
'alphanohtml'),
277 header(
"Location: ".
$_SERVER[
"PHP_SELF"].
"?id=".$id);
282 $action =
'correction';
286 if (!$error) $action =
'';
290 if ($action ==
"transfert_stock" && !$cancel)
293 if (!empty($product_id)) $result = $product->fetch($product_id);
295 if (!(
GETPOST(
"id_entrepot_destination",
'int') > 0))
297 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Warehouse")), null,
'errors');
299 $action =
'transfert';
301 if (empty($product_id))
304 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Product")), null,
'errors');
305 $action =
'transfert';
307 if (!
GETPOST(
"nbpiece",
'int'))
309 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"NumberOfUnit")), null,
'errors');
311 $action =
'transfert';
313 if ($id ==
GETPOST(
"id_entrepot_destination",
'int'))
315 setEventMessages($langs->trans(
"ErrorSrcAndTargetWarehouseMustDiffers"), null,
'errors');
317 $action =
'transfert';
320 if (!empty($conf->productbatch->enabled))
323 $result = $product->fetch($product_id);
325 if ($product->hasbatch() && !
GETPOST(
"batch_number"))
327 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"batch_number")), null,
'errors');
329 $action =
'transfert';
338 $result = $object->fetch($id);
342 $product->load_stock(
'novirtual');
346 if (isset($product->pmp)) $pricesrc = $product->pmp;
347 $pricedest = $pricesrc;
349 if ($product->hasbatch())
355 $result = $pdluo->fetch($pdluoid);
358 $srcwarehouseid = $pdluo->warehouseid;
359 $batch = $pdluo->batch;
360 $eatby = $pdluo->eatby;
361 $sellby = $pdluo->sellby;
367 $srcwarehouseid = $id;
368 $batch =
GETPOST(
'batch_number',
'alphanohtml');
376 $result1 = $product->correct_stock_batch(
383 $eatby, $sellby, $batch,
387 $result2 = $product->correct_stock_batch(
389 GETPOST(
"id_entrepot_destination",
'int'),
394 $eatby, $sellby, $batch,
395 GETPOST(
'inventorycode',
'alphanohtml')
400 $result1 = $product->correct_stock(
407 GETPOST(
'inventorycode',
'alphanohtml')
411 $result2 = $product->correct_stock(
413 GETPOST(
"id_entrepot_destination"),
418 GETPOST(
'inventorycode',
'alphanohtml')
421 if (!$error && $result1 >= 0 && $result2 >= 0)
427 header(
"Location: ".$backtopage);
430 header(
"Location: movement_list.php?id=".$object->id);
436 $action =
'transfert';
447 $productlot =
new ProductLot($db);
448 $productstatic =
new Product($db);
449 $warehousestatic =
new Entrepot($db);
451 $userstatic =
new User($db);
452 $form =
new Form($db);
455 if (!empty($conf->projet->enabled)) $formproject =
new FormProjets($db);
457 $sql =
"SELECT p.rowid, p.ref as product_ref, p.label as produit, p.tosell, p.tobuy, p.tobatch, p.fk_product_type as type, p.entity,";
458 $sql .=
" e.ref as warehouse_ref, e.rowid as entrepot_id, e.lieu, e.fk_parent, e.statut,";
459 $sql .=
" m.rowid as mid, m.value as qty, m.datem, m.fk_user_author, m.label, m.inventorycode, m.fk_origin, m.origintype,";
460 $sql .=
" m.batch, m.price,";
461 $sql .=
" m.type_mouvement,";
462 $sql .=
" m.fk_projet as fk_project,";
463 $sql .=
" pl.rowid as lotid, pl.eatby, pl.sellby,";
464 $sql .=
" u.login, u.photo, u.lastname, u.firstname";
466 if (!empty($extrafields->attributes[$object->table_element][
'label'])) {
467 foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
' as options_'.$key :
'');
470 $parameters = array();
471 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters);
472 $sql .= $hookmanager->resPrint;
473 $sql .=
" FROM ".MAIN_DB_PREFIX.
"entrepot as e,";
474 $sql .=
" ".MAIN_DB_PREFIX.
"product as p,";
475 $sql .=
" ".MAIN_DB_PREFIX.
"stock_mouvement as m";
476 if (is_array($extrafields->attributes[$object->table_element][
'label']) && count($extrafields->attributes[$object->table_element][
'label'])) $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element.
"_extrafields as ef on (m.rowid = ef.fk_object)";
477 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u ON m.fk_user_author = u.rowid";
478 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product_lot as pl ON m.batch = pl.batch AND m.fk_product = pl.fk_product";
479 $sql .=
" WHERE m.fk_product = p.rowid";
480 if ($msid > 0) $sql .=
" AND m.rowid = ".$msid;
481 $sql .=
" AND m.fk_entrepot = e.rowid";
482 $sql .=
" AND e.entity IN (".getEntity(
'stock').
")";
483 if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) $sql .=
" AND p.fk_product_type = 0";
484 if ($id > 0) $sql .=
" AND e.rowid ='".$id.
"'";
486 if ($idproduct > 0) $sql .=
" AND p.rowid = ".((int) $idproduct);
487 if (!empty($search_ref)) $sql .=
natural_search(
'm.rowid', $search_ref, 1);
488 if (!empty($search_movement)) $sql .=
natural_search(
'm.label', $search_movement);
489 if (!empty($search_inventorycode)) $sql .=
natural_search(
'm.inventorycode', $search_inventorycode);
490 if (!empty($search_product_ref)) $sql .=
natural_search(
'p.ref', $search_product_ref);
491 if (!empty($search_product)) $sql .=
natural_search(
'p.label', $search_product);
492 if ($search_warehouse !=
'' && $search_warehouse !=
'-1') $sql .=
natural_search(
'e.rowid', $search_warehouse, 2);
493 if (!empty($search_user)) $sql .=
natural_search(
'u.login', $search_user);
494 if (!empty($search_batch)) $sql .=
natural_search(
'm.batch', $search_batch);
495 if (!empty($product_id)) $sql .=
natural_search(
'p.rowid', $product_id);
496 if ($search_qty !=
'') $sql .=
natural_search(
'm.value', $search_qty, 1);
497 if ($search_type_mouvement !=
'' && $search_type_mouvement !=
'-1') $sql .=
natural_search(
'm.type_mouvement', $search_type_mouvement, 2);
499 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
501 $parameters = array();
502 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters);
503 $sql .= $hookmanager->resPrint;
504 $sql .= $db->order($sortfield, $sortorder);
506 $nbtotalofrecords =
'';
507 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
509 $result = $db->query($sql);
510 $nbtotalofrecords = $db->num_rows($result);
511 if (($page * $limit) > $nbtotalofrecords)
518 if (empty($search_inventorycode))
520 $sql .= $db->plimit($limit + 1, $offset);
527 $resql = $db->query($sql);
529 if (!empty($search_inventorycode)) $limit = $db->num_rows(
$resql);
538 $product->fetch($idproduct);
542 $result = $object->fetch($id, $ref);
549 $num = $db->num_rows(
$resql);
551 $arrayofselected = is_array($toselect) ? $toselect : array();
555 $help_url =
'EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks';
556 if ($msid) $texte = $langs->trans(
'StockMovementForId', $msid);
558 $texte = $langs->trans(
"ListOfStockMovements");
559 if ($id) $texte .=
' ('.$langs->trans(
"ForThisWarehouse").
')';
573 $linkback =
'<a href="'.DOL_URL_ROOT.
'/product/stock/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
575 $morehtmlref =
'<div class="refidno">';
576 $morehtmlref .= $langs->trans(
"LocationSummary").
' : '.$object->lieu;
577 $morehtmlref .=
'</div>';
580 if ($user->socid && !in_array(
'stock', explode(
',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0;
582 dol_banner_tab($object,
'ref', $linkback, $shownav,
'ref',
'ref', $morehtmlref);
585 print '<div class="fichecenter">';
586 print '<div class="fichehalfleft">';
587 print '<div class="underbanner clearboth"></div>';
589 print '<table class="border centpercent tableforfield">';
594 print '<td class="titlefield tdtop">'.$langs->trans(
"Description").
'</td><td>'.
dol_htmlentitiesbr($object->description).
'</td></tr>';
596 $calcproductsunique = $object->nb_different_products();
597 $calcproducts = $object->nb_products();
600 print '<tr><td>'.$langs->trans(
"NumberOfDifferentProducts").
'</td><td>';
601 print empty($calcproductsunique[
'nb']) ?
'0' : $calcproductsunique[
'nb'];
605 print '<tr><td>'.$langs->trans(
"NumberOfProducts").
'</td><td>';
606 $valtoshow =
price2num($calcproducts[
'nb'],
'MS');
607 print empty($valtoshow) ?
'0' : $valtoshow;
613 print '<div class="fichehalfright">';
614 print '<div class="ficheaddleft">';
615 print '<div class="underbanner clearboth"></div>';
617 print '<table class="border centpercent tableforfield">';
620 print '<tr><td class="titlefield">'.$langs->trans(
"EstimatedStockValueShort").
'</td><td>';
621 print price((empty($calcproducts[
'value']) ?
'0' :
price2num($calcproducts[
'value'],
'MT')), 0, $langs, 0, -1, -1, $conf->currency);
625 $sql =
"SELECT MAX(m.datem) as datem";
626 $sql .=
" FROM ".MAIN_DB_PREFIX.
"stock_mouvement as m";
627 $sql .=
" WHERE m.fk_entrepot = ".((int) $object->id);
628 $resqlbis = $db->query($sql);
631 $objbis = $db->fetch_object($resqlbis);
632 $lastmovementdate = $db->jdate($objbis->datem);
637 print '<tr><td>'.$langs->trans(
"LastMovement").
'</td><td>';
638 if ($lastmovementdate)
642 print $langs->trans(
"None");
647 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
650 if ($conf->categorie->enabled) {
651 print '<tr><td valign="middle">'.$langs->trans(
"Categories").
'</td><td colspan="3">';
652 print $form->showCategories($object->id, Categorie::TYPE_WAREHOUSE, 1);
662 print '<div class="clearboth"></div>';
671 if ($action ==
"correction")
673 include DOL_DOCUMENT_ROOT.
'/product/stock/tpl/stockcorrection.tpl.php';
680 if ($action ==
"transfert")
682 include DOL_DOCUMENT_ROOT.
'/product/stock/tpl/stocktransfer.tpl.php';
693 if ((empty($action) || $action ==
'list') && $id > 0)
695 print "<div class=\"tabsAction\">\n";
697 if ($user->rights->stock->mouvement->creer)
699 print '<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$id.
'&action=correction">'.$langs->trans(
"CorrectStock").
'</a>';
702 if ($user->rights->stock->mouvement->creer)
704 print '<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$id.
'&action=transfert">'.$langs->trans(
"TransferStock").
'</a>';
711 if (!empty($contextpage) && $contextpage !=
$_SERVER[
"PHP_SELF"]) $param .=
'&contextpage='.urlencode($contextpage);
712 if ($limit > 0 && $limit != $conf->liste_limit) $param .=
'&limit='.urlencode($limit);
713 if ($id > 0) $param .=
'&id='.urlencode($id);
714 if ($search_movement) $param .=
'&search_movement='.urlencode($search_movement);
715 if ($search_inventorycode) $param .=
'&search_inventorycode='.urlencode($search_inventorycode);
716 if ($search_type_mouvement) $param .=
'&search_type_mouvement='.urlencode($search_type_mouvement);
717 if ($search_product_ref) $param .=
'&search_product_ref='.urlencode($search_product_ref);
718 if ($search_product) $param .=
'&search_product='.urlencode($search_product);
719 if ($search_batch) $param .=
'&search_batch='.urlencode($search_batch);
720 if ($search_warehouse > 0) $param .=
'&search_warehouse='.urlencode($search_warehouse);
721 if ($search_user) $param .=
'&search_user='.urlencode($search_user);
722 if ($idproduct > 0) $param .=
'&idproduct='.urlencode($idproduct);
724 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
727 $arrayofmassactions = array(
732 if (!empty($conf->global->STOCK_ALLOW_DELETE_OF_MOVEMENT) && $permissiontodelete) $arrayofmassactions[
'predelete'] =
'<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans(
"Delete");
733 if (
GETPOST(
'nomassaction',
'int') || in_array($massaction, array(
'presend',
'predelete'))) $arrayofmassactions = array();
734 $massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
736 print '<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
737 if ($optioncss !=
'')
print '<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
738 print '<input type="hidden" name="token" value="'.newToken().
'">';
739 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
740 print '<input type="hidden" name="action" value="list">';
741 print '<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
742 print '<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
743 print '<input type="hidden" name="type" value="'.$type.
'">';
744 print '<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
745 if ($id > 0)
print '<input type="hidden" name="id" value="'.$id.
'">';
747 if ($id > 0)
print_barre_liste($texte, $page,
$_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'stock', 0,
'',
'', $limit, 0, 0, 1);
748 else print_barre_liste($texte, $page,
$_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'stock', 0,
'',
'', $limit, 0, 0, 1);
751 $topicmail =
"SendStockMovement";
752 $modelmail =
"movementstock";
754 $trackid =
'mov'.$object->id;
755 include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
759 foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val);
760 print '<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $sall).join(
', ', $fieldstosearchall).
'</div>';
765 $parameters = array();
766 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters);
767 if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint;
768 else $moreforfilter = $hookmanager->resPrint;
770 if (!empty($moreforfilter))
772 print '<div class="liste_titre liste_titre_bydiv centpercent">';
773 print $moreforfilter;
777 $varpage = empty($contextpage) ?
$_SERVER[
"PHP_SELF"] : $contextpage;
778 $selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage);
780 print '<div class="div-table-responsive">';
781 print '<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
784 print '<tr class="liste_titre_filter">';
785 if (!empty($arrayfields[
'm.rowid'][
'checked']))
788 print
'<td class="liste_titre left">';
789 print
'<input class="flat maxwidth25" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).
'">';
792 if (!empty($arrayfields[
'm.datem'][
'checked']))
795 print
'<td class="liste_titre nowraponall">';
796 print
'<input class="flat" type="text" size="2" maxlength="2" placeholder="'.dol_escape_htmltag($langs->trans(
"Month")).
'" name="month" value="'.$month.
'">';
797 if (empty($conf->productbatch->enabled)) print
' ';
799 $syear = $year ? $year : -1;
800 print
'<input class="flat maxwidth50" type="text" maxlength="4" placeholder="'.dol_escape_htmltag($langs->trans(
"Year")).
'" name="year" value="'.($syear > 0 ? $syear :
'').
'">';
804 if (!empty($arrayfields[
'p.ref'][
'checked']))
807 print
'<td class="liste_titre left">';
808 print
'<input class="flat maxwidth75" type="text" name="search_product_ref" value="'.dol_escape_htmltag($idproduct ? $product->ref : $search_product_ref).
'">';
811 if (!empty($arrayfields[
'p.label'][
'checked']))
814 print
'<td class="liste_titre left">';
815 print
'<input class="flat maxwidth100" type="text" name="search_product" value="'.dol_escape_htmltag($idproduct ? $product->label : $search_product).
'">';
819 if (!empty($arrayfields[
'm.batch'][
'checked']))
821 print
'<td class="liste_titre center"><input class="flat maxwidth75" type="text" name="search_batch" value="'.dol_escape_htmltag($search_batch).
'"></td>';
823 if (!empty($arrayfields[
'pl.eatby'][
'checked']))
825 print
'<td class="liste_titre left">';
828 if (!empty($arrayfields[
'pl.sellby'][
'checked']))
830 print
'<td class="liste_titre left">';
834 if (!empty($arrayfields[
'e.ref'][
'checked']))
836 print
'<td class="liste_titre maxwidthonsmartphone left">';
838 print $formproduct->selectWarehouses($search_warehouse,
'search_warehouse',
'warehouseopen,warehouseinternal', 1, 0, 0,
'', 0, 0, null,
'maxwidth200');
841 if (!empty($arrayfields[
'm.fk_user_author'][
'checked']))
844 print
'<td class="liste_titre left">';
845 print
'<input class="flat" type="text" size="6" name="search_user" value="'.dol_escape_htmltag($search_user).
'">';
848 if (!empty($arrayfields[
'm.inventorycode'][
'checked']))
851 print
'<td class="liste_titre left">';
852 print
'<input class="flat" type="text" size="4" name="search_inventorycode" value="'.dol_escape_htmltag($search_inventorycode).
'">';
855 if (!empty($arrayfields[
'm.label'][
'checked']))
858 print
'<td class="liste_titre left">';
859 print
'<input class="flat" type="text" size="8" name="search_movement" value="'.dol_escape_htmltag($search_movement).
'">';
862 if (!empty($arrayfields[
'm.type_mouvement'][
'checked']))
865 print
'<td class="liste_titre center">';
867 print
'<select id="search_type_mouvement" name="search_type_mouvement" class="maxwidth150">';
868 print
'<option value="" '.(($search_type_mouvement ==
"") ?
'selected="selected"' :
'').
'></option>';
869 print
'<option value="0" '.(($search_type_mouvement ==
"0") ?
'selected="selected"' :
'').
'>'.$langs->trans(
'StockIncreaseAfterCorrectTransfer').
'</option>';
870 print
'<option value="1" '.(($search_type_mouvement ==
"1") ?
'selected="selected"' :
'').
'>'.$langs->trans(
'StockDecreaseAfterCorrectTransfer').
'</option>';
871 print
'<option value="2" '.(($search_type_mouvement ==
"2") ?
'selected="selected"' :
'').
'>'.$langs->trans(
'StockDecrease').
'</option>';
872 print
'<option value="3" '.(($search_type_mouvement ==
"3") ?
'selected="selected"' :
'').
'>'.$langs->trans(
'StockIncrease').
'</option>';
879 if (!empty($arrayfields[
'origin'][
'checked']))
882 print
'<td class="liste_titre left">';
886 if (!empty($arrayfields[
'm.value'][
'checked']))
889 print
'<td class="liste_titre right">';
890 print
'<input class="flat" type="text" size="4" name="search_qty" value="'.dol_escape_htmltag($search_qty).
'">';
893 if (!empty($arrayfields[
'm.price'][
'checked']))
896 print
'<td class="liste_titre" align="left">';
900 if (!empty($arrayfields[
'm.fk_projet'][
'checked']))
903 print
'<td class="liste_titre" align="left">';
910 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
913 $parameters = array(
'arrayfields'=>$arrayfields);
914 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters);
915 print $hookmanager->resPrint;
917 if (!empty($arrayfields[
'm.datec'][
'checked']))
919 print
'<td class="liste_titre">';
923 if (!empty($arrayfields[
'm.tms'][
'checked']))
925 print
'<td class="liste_titre">';
929 print
'<td class="liste_titre maxwidthsearch">';
930 $searchpicto = $form->showFilterAndCheckAddButtons(0);
935 print
'<tr class="liste_titre">';
936 if (!empty($arrayfields[
'm.rowid'][
'checked'])) {
939 if (!empty($arrayfields[
'm.datem'][
'checked'])) {
942 if (!empty($arrayfields[
'p.ref'][
'checked'])) {
945 if (!empty($arrayfields[
'p.label'][
'checked'])) {
948 if (!empty($arrayfields[
'm.batch'][
'checked'])) {
951 if (!empty($arrayfields[
'pl.eatby'][
'checked'])) {
954 if (!empty($arrayfields[
'pl.sellby'][
'checked'])) {
957 if (!empty($arrayfields[
'e.ref'][
'checked'])) {
961 if (!empty($arrayfields[
'm.fk_user_author'][
'checked'])) {
964 if (!empty($arrayfields[
'm.inventorycode'][
'checked'])) {
967 if (!empty($arrayfields[
'm.label'][
'checked'])) {
970 if (!empty($arrayfields[
'm.type_mouvement'][
'checked'])) {
971 print_liste_field_titre($arrayfields[
'm.type_mouvement'][
'label'],
$_SERVER[
"PHP_SELF"],
"m.type_mouvement",
"", $param,
'', $sortfield, $sortorder,
'center ');
973 if (!empty($arrayfields[
'origin'][
'checked'])) {
976 if (!empty($arrayfields[
'm.value'][
'checked'])) {
979 if (!empty($arrayfields[
'm.price'][
'checked'])) {
982 if (!empty($arrayfields[
'm.fk_projet'][
'checked'])) {
983 print_liste_field_titre($arrayfields[
'm.fk_projet'][
'label'],
$_SERVER[
"PHP_SELF"],
"m.fk_projet",
"", $param,
'align="right"', $sortfield, $sortorder);
987 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
990 $parameters = array(
'arrayfields'=>$arrayfields,
'param'=>$param,
'sortfield'=>$sortfield,
'sortorder'=>$sortorder);
991 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters);
992 print $hookmanager->resPrint;
993 if (!empty($arrayfields[
'm.datec'][
'checked'])) {
996 if (!empty($arrayfields[
'm.tms'][
'checked'])) {
1003 $arrayofuniqueproduct = array();
1006 $totalarray = array();
1007 while ($i < min($num, $limit))
1009 $objp = $db->fetch_object(
$resql);
1011 $userstatic->id = $objp->fk_user_author;
1012 $userstatic->login = $objp->login;
1013 $userstatic->lastname = $objp->lastname;
1014 $userstatic->firstname = $objp->firstname;
1015 $userstatic->photo = $objp->photo;
1017 $productstatic->id = $objp->rowid;
1018 $productstatic->ref = $objp->product_ref;
1019 $productstatic->label = $objp->produit;
1020 $productstatic->type = $objp->type;
1021 $productstatic->entity = $objp->entity;
1022 $productstatic->status = $objp->tosell;
1023 $productstatic->status_buy = $objp->tobuy;
1024 $productstatic->status_batch = $objp->tobatch;
1026 $productlot->id = $objp->lotid;
1027 $productlot->batch = $objp->batch;
1028 $productlot->eatby = $objp->eatby;
1029 $productlot->sellby = $objp->sellby;
1031 $warehousestatic->id = $objp->entrepot_id;
1032 $warehousestatic->ref = $objp->warehouse_ref;
1033 $warehousestatic->label = $objp->warehouse_ref;
1034 $warehousestatic->lieu = $objp->lieu;
1035 $warehousestatic->fk_parent = $objp->fk_parent;
1036 $warehousestatic->statut = $objp->statut;
1038 $arrayofuniqueproduct[$objp->rowid] = $objp->produit;
1039 if (!empty($objp->fk_origin)) {
1040 $origin = $movement->get_origin($objp->fk_origin, $objp->origintype);
1045 print
'<tr class="oddeven">';
1047 if (!empty($arrayfields[
'm.rowid'][
'checked']))
1049 print
'<td>'.$objp->mid.
'</td>';
1051 if (!empty($arrayfields[
'm.datem'][
'checked']))
1054 print
'<td class="nowraponall">'.dol_print_date($db->jdate($objp->datem),
'dayhour',
'tzuserrel').
'</td>';
1056 if (!empty($arrayfields[
'p.ref'][
'checked']))
1059 print
'<td class="nowraponall">';
1060 print $productstatic->getNomUrl(1,
'stock', 16);
1063 if (!empty($arrayfields[
'p.label'][
'checked']))
1071 print $productstatic->label;
1074 if (!empty($arrayfields[
'm.batch'][
'checked']))
1076 print
'<td class="center nowraponall">';
1077 if ($productlot->id > 0) print $productlot->getNomUrl(1);
1078 else print $productlot->batch;
1081 if (!empty($arrayfields[
'pl.eatby'][
'checked']))
1083 print
'<td class="center">'.dol_print_date($objp->eatby,
'day').
'</td>';
1085 if (!empty($arrayfields[
'pl.sellby'][
'checked']))
1087 print
'<td class="center">'.dol_print_date($objp->sellby,
'day').
'</td>';
1090 if (!empty($arrayfields[
'e.ref'][
'checked']))
1093 print $warehousestatic->getNomUrl(1);
1097 if (!empty($arrayfields[
'm.fk_user_author'][
'checked']))
1099 print
'<td class="tdoverflowmax100">';
1100 print $userstatic->getNomUrl(-1);
1103 if (!empty($arrayfields[
'm.inventorycode'][
'checked']))
1106 print
'<td><a href="'
1107 .DOL_URL_ROOT.
'/product/stock/movement_card.php?id='.urlencode($objp->entrepot_id)
1108 .
'&search_inventorycode='.urlencode($objp->inventorycode)
1109 .
'&search_type_mouvement='.urlencode($objp->type_mouvement)
1110 .
'">'.$objp->inventorycode.
'</a></td>';
1112 if (!empty($arrayfields[
'm.label'][
'checked']))
1115 print
'<td class="tdoverflowmax100aaa">'.$objp->label.
'</td>';
1117 if (!empty($arrayfields[
'm.type_mouvement'][
'checked']))
1120 switch ($objp->type_mouvement) {
1122 print
'<td class="center">'.$langs->trans(
'StockIncreaseAfterCorrectTransfer').
'</td>';
1125 print
'<td class="center">'.$langs->trans(
'StockDecreaseAfterCorrectTransfer').
'</td>';
1128 print
'<td class="center">'.$langs->trans(
'StockDecrease').
'</td>';
1131 print
'<td class="center">'.$langs->trans(
'StockIncrease').
'</td>';
1135 if (!empty($arrayfields[
'origin'][
'checked']))
1138 print
'<td class="nowraponall">'.$origin.
'</td>';
1140 if (!empty($arrayfields[
'm.value'][
'checked']))
1143 print
'<td class="right">';
1144 if ($objp->qt > 0) print
'+';
1148 if (!empty($arrayfields[
'm.price'][
'checked']))
1151 print
'<td class="right">';
1152 if ($objp->price != 0) print
price($objp->price);
1155 if (!empty($arrayfields[
'm.fk_projet'][
'checked']))
1158 print
'<td align="right">';
1159 if ($objp->fk_project != 0) print $movement->get_origin($objp->fk_project,
'project');
1163 print
'<td class="nowrap center">';
1164 if ($massactionbutton || $massaction)
1167 if (in_array($objp->mid, $arrayofselected)) $selected = 1;
1168 print
'<input id="cb'.$objp->mid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$objp->mid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
1171 if (!$i) $totalarray[
'nbfield']++;
1183 if (count($arrayofuniqueproduct) == 1 && is_numeric($year))
1187 $productidselected = 0;
1188 foreach ($arrayofuniqueproduct as $key => $val)
1190 $productidselected = $key;
1191 $productlabelselected = $val;
1193 $datebefore =
dol_get_first_day($year ? $year : strftime(
"%Y", time()), $month ? $month : 1,
true);
1194 $dateafter =
dol_get_last_day($year ? $year : strftime(
"%Y", time()), $month ? $month : 12,
true);
1195 $balancebefore = $movement->calculateBalanceForProductBefore($productidselected, $datebefore);
1196 $balanceafter = $movement->calculateBalanceForProductBefore($productidselected, $dateafter);
1199 print $langs->trans(
"NbOfProductBeforePeriod", $productlabelselected,
dol_print_date($datebefore,
'day',
'gmt'));
1202 print
': '.$balancebefore;
1206 print $langs->trans(
"NbOfProductAfterPeriod", $productlabelselected,
dol_print_date($dateafter,
'day',
'gmt'));
1209 print
': '.$balanceafter;
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 stock movements.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm= 'auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
Class to manage products or services.
Class to manage Dolibarr users.
dol_clone($object, $native=0)
Create a clone of instance of object (new instance with same value for properties) With native = 0: P...
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete= 'resolve')
Convert a html select field into an ajax combobox.
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom= 'UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
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...
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.
stock_prepare_head($object)
Prepare array with list of tabs.
price2num($amount, $rounding= '', $option=0)
Function that return a number with universal decimal format (decimal separator is '...
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.
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
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...
dolSqlDateFilter($datefield, $day_date, $month_date, $year_date, $excludefirstand=0)
Generate a SQL string to make a filter into a range (for second of date until last second of date) ...
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.
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
Manage record for batch number management.
print
Draft customers invoices.
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
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.
dol_banner_tab($object, $paramid, $morehtml= '', $shownav=1, $fieldid= 'rowid', $fieldref= 'ref', $morehtmlref= '', $moreparam= '', $nodbprefix=0, $morehtmlleft= '', $morehtmlstatus= '', $onlybanner=0, $morehtmlright= '')
Show tab footer of a card.
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.
Class to manage warehouses.