30require
'../../main.inc.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
32require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
33require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/entrepot.class.php';
34require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/mouvementstock.class.php';
35require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/productlot.class.php';
36require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
37require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
38require_once DOL_DOCUMENT_ROOT.
'/core/lib/stock.lib.php';
39require_once DOL_DOCUMENT_ROOT.
'/core/lib/product.lib.php';
40require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
41if (isModEnabled(
'project')) {
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'));
48if (isModEnabled(
'productbatch')) {
49 $langs->load(
"productbatch");
58$product_id =
GETPOST(
"product_id",
'int');
59$action =
GETPOST(
'action',
'aZ09');
60$cancel =
GETPOST(
'cancel',
'alpha');
61$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'movementlist';
63$idproduct =
GETPOST(
'idproduct',
'int');
65$month =
GETPOST(
"month",
'int');
66$search_ref =
GETPOST(
'search_ref',
'alpha');
67$search_movement =
GETPOST(
"search_movement",
'alpha');
68$search_product_ref = trim(
GETPOST(
"search_product_ref",
'alpha'));
69$search_product = trim(
GETPOST(
"search_product",
'alpha'));
70$search_warehouse = trim(
GETPOST(
"search_warehouse",
'alpha'));
71$search_inventorycode = trim(
GETPOST(
"search_inventorycode",
'alpha'));
72$search_user = trim(
GETPOST(
"search_user",
'alpha'));
73$search_batch = trim(
GETPOST(
"search_batch",
'alpha'));
74$search_qty = trim(
GETPOST(
"search_qty",
'alpha'));
75$search_type_mouvement =
GETPOST(
'search_type_mouvement',
'int');
77$limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
78$page = GETPOSTISSET(
'pageplusone') ? (
GETPOST(
'pageplusone') - 1) :
GETPOST(
"page",
'int');
79$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
80$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
81if (empty($page) || $page == -1) {
84$offset = $limit * $page;
86 $sortfield =
"m.datem";
92$pdluoid =
GETPOST(
'pdluoid',
'int');
96$hookmanager->initHooks(array(
'movementlist'));
101$extrafields->fetch_name_optionals_label($object->table_element);
103$search_array_options = $extrafields->getOptionalsFromPost($object->table_element,
'',
'search_');
106 'm.rowid'=>array(
'label'=>$langs->trans(
"Ref"),
'checked'=>1),
107 'm.datem'=>array(
'label'=>$langs->trans(
"Date"),
'checked'=>1),
108 'p.ref'=>array(
'label'=>$langs->trans(
"ProductRef"),
'checked'=>1,
'css'=>
'maxwidth100'),
109 'p.label'=>array(
'label'=>$langs->trans(
"ProductLabel"),
'checked'=>1),
110 'm.batch'=>array(
'label'=>$langs->trans(
"BatchNumberShort"),
'checked'=>1,
'enabled'=>(isModEnabled(
'productbatch'))),
111 'pl.eatby'=>array(
'label'=>$langs->trans(
"EatByDate"),
'checked'=>0,
'position'=>10,
'enabled'=>(isModEnabled(
'productbatch'))),
112 'pl.sellby'=>array(
'label'=>$langs->trans(
"SellByDate"),
'checked'=>0,
'position'=>10,
'enabled'=>(isModEnabled(
'productbatch'))),
113 'e.ref'=>array(
'label'=>$langs->trans(
"Warehouse"),
'checked'=>1,
'enabled'=>(!($id > 0))),
114 'm.fk_user_author'=>array(
'label'=>$langs->trans(
"Author"),
'checked'=>0),
115 'm.inventorycode'=>array(
'label'=>$langs->trans(
"InventoryCodeShort"),
'checked'=>1),
116 'm.label'=>array(
'label'=>$langs->trans(
"MovementLabel"),
'checked'=>1),
117 'm.type_mouvement'=>array(
'label'=>$langs->trans(
"TypeMovement"),
'checked'=>1),
118 'origin'=>array(
'label'=>$langs->trans(
"Origin"),
'checked'=>1),
119 'm.value'=>array(
'label'=>$langs->trans(
"Qty"),
'checked'=>1),
120 'm.price'=>array(
'label'=>$langs->trans(
"UnitPurchaseValue"),
'checked'=>0),
125$usercanread = (($user->rights->stock->mouvement->lire));
126$usercancreate = (($user->rights->stock->mouvement->creer));
127$usercandelete = (($user->rights->stock->mouvement->supprimer));
135if (
GETPOST(
'cancel',
'alpha')) {
136 $action =
'list'; $massaction =
'';
138if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
142$parameters = array();
143$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
148include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
151if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
155 $search_movement =
"";
156 $search_type_mouvement =
"";
157 $search_inventorycode =
"";
158 $search_product_ref =
"";
159 $search_product =
"";
160 $search_warehouse =
"";
166 $search_array_options = array();
170if ($action ==
"correct_stock") {
172 if (!empty($product_id)) {
173 $result = $product->fetch($product_id);
178 if (empty($product_id)) {
180 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Product")),
null,
'errors');
181 $action =
'correction';
183 if (!is_numeric(
GETPOST(
"nbpiece"))) {
185 setEventMessages($langs->trans(
"ErrorFieldMustBeANumeric", $langs->transnoentitiesnoconv(
"NumberOfUnit")),
null,
'errors');
186 $action =
'correction';
190 $origin_element =
'';
193 if (
GETPOST(
'projectid',
'int')) {
194 $origin_element =
'project';
195 $origin_id =
GETPOST(
'projectid',
'int');
198 if ($product->hasbatch()) {
199 $batch =
GETPOST(
'batch_number',
'alpha');
206 $result = $product->correct_stock_batch(
216 GETPOST(
'inventorycode',
'alpha'),
221 $result = $product->correct_stock(
228 GETPOST(
'inventorycode',
'alpha'),
235 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
240 $action =
'correction';
250if ($action ==
"transfert_stock" && !$cancel) {
252 if (!empty($product_id)) {
253 $result = $product->fetch($product_id);
256 if (!(
GETPOST(
"id_entrepot_destination",
'int') > 0)) {
257 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Warehouse")),
null,
'errors');
259 $action =
'transfert';
261 if (empty($product_id)) {
263 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Product")),
null,
'errors');
264 $action =
'transfert';
266 if (!
GETPOST(
"nbpiece",
'int')) {
267 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"NumberOfUnit")),
null,
'errors');
269 $action =
'transfert';
271 if ($id ==
GETPOST(
"id_entrepot_destination",
'int')) {
272 setEventMessages($langs->trans(
"ErrorSrcAndTargetWarehouseMustDiffers"),
null,
'errors');
274 $action =
'transfert';
277 if (isModEnabled(
'productbatch')) {
279 $result = $product->fetch($product_id);
281 if ($product->hasbatch() && !
GETPOST(
"batch_number",
'alpha')) {
282 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"batch_number")),
null,
'errors');
284 $action =
'transfert';
291 $result = $object->fetch($id);
295 $product->load_stock(
'novirtual');
299 if (isset($product->pmp)) {
300 $pricesrc = $product->pmp;
302 $pricedest = $pricesrc;
304 if ($product->hasbatch()) {
308 $result = $pdluo->fetch($pdluoid);
310 $srcwarehouseid = $pdluo->warehouseid;
311 $batch = $pdluo->batch;
312 $eatby = $pdluo->eatby;
313 $sellby = $pdluo->sellby;
319 $srcwarehouseid = $id;
320 $batch =
GETPOST(
'batch_number',
'alpha');
327 $result1 = $product->correct_stock_batch(
337 GETPOST(
'inventorycode',
'alpha')
340 $result2 = $product->correct_stock_batch(
342 GETPOST(
"id_entrepot_destination",
'int'),
350 GETPOST(
'inventorycode',
'alpha')
355 $result1 = $product->correct_stock(
362 GETPOST(
'inventorycode',
'alpha')
366 $result2 = $product->correct_stock(
368 GETPOST(
"id_entrepot_destination"),
373 GETPOST(
'inventorycode',
'alpha')
376 if (!$error && $result1 >= 0 && $result2 >= 0) {
380 header(
"Location: ".$backtopage);
383 header(
"Location: movement_list.php?id=".$object->id);
389 $action =
'transfert';
401$upload_dir = $conf->stock->dir_output.
"movement/";
402$permissiontoadd = $user->rights->stock->creer;
403include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
406if (empty($reshook) && $action !=
'remove_file') {
407 $objectclass =
'MouvementStock';
408 $objectlabel =
'Movements';
409 $permissiontoread = $user->rights->stock->lire;
410 $permissiontodelete = $user->rights->stock->supprimer;
411 $uploaddir = $conf->stock->dir_output.
"/movement/";
412 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
422$productstatic =
new Product($db);
423$warehousestatic =
new Entrepot($db);
425$userstatic =
new User($db);
426$form =
new Form($db);
429if (isModEnabled(
'project')) {
433$sql =
"SELECT p.rowid, p.ref as product_ref, p.label as produit, p.tobatch, p.fk_product_type as type, p.entity,";
434$sql .=
" e.ref as warehouse_ref, e.rowid as entrepot_id, e.lieu,";
435$sql .=
" m.rowid as mid, m.value as qty, m.datem, m.fk_user_author, m.label, m.inventorycode, m.fk_origin, m.origintype,";
436$sql .=
" m.batch, m.price,";
437$sql .=
" m.type_mouvement,";
438$sql .=
" pl.rowid as lotid, pl.eatby, pl.sellby,";
439$sql .=
" u.login, u.photo, u.lastname, u.firstname";
441if (!empty($extrafields->attributes[$object->table_element][
'label'])) {
442 foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $val) {
443 $sql .= ($extrafields->attributes[$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
447$parameters = array();
448$reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters);
449$sql .= $hookmanager->resPrint;
450$sql .=
" FROM ".MAIN_DB_PREFIX.
"entrepot as e,";
451$sql .=
" ".MAIN_DB_PREFIX.
"product as p,";
452$sql .=
" ".MAIN_DB_PREFIX.
"stock_mouvement as m";
453if (isset($extrafields->attributes[$object->table_element][
'label']) && is_array($extrafields->attributes[$object->table_element][
'label']) && count($extrafields->attributes[$object->table_element][
'label'])) {
454 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element.
"_extrafields as ef on (m.rowid = ef.fk_object)";
456$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u ON m.fk_user_author = u.rowid";
457$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product_lot as pl ON m.batch = pl.batch AND m.fk_product = pl.fk_product";
458$sql .=
" WHERE m.fk_product = p.rowid";
460 $sql .=
" AND m.rowid = ".((int) $msid);
462$sql .=
" AND m.fk_entrepot = e.rowid";
463$sql .=
" AND e.entity IN (".getEntity(
'stock').
")";
464if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) {
465 $sql .=
" AND p.fk_product_type = 0";
468 $sql .=
" AND e.rowid = ".((int) $id);
472 $sql .=
" AND p.rowid = ".((int) $idproduct);
474if (!empty($search_ref)) {
477if (!empty($search_movement)) {
480if (!empty($search_inventorycode)) {
483if (!empty($search_product_ref)) {
486if (!empty($search_product)) {
489if ($search_warehouse !=
'' && $search_warehouse !=
'-1') {
492if (!empty($search_user)) {
493 $sql .=
natural_search(array(
'u.lastname',
'u.firstname',
'u.login'), $search_user);
495if (!empty($search_batch)) {
498if ($search_qty !=
'') {
501if ($search_type_mouvement !=
'' && $search_type_mouvement !=
'-1') {
502 $sql .=
natural_search(
'm.type_mouvement', $search_type_mouvement, 2);
505include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
507$parameters = array();
508$reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters);
509$sql .= $hookmanager->resPrint;
510$sql .= $db->order($sortfield, $sortorder);
512$nbtotalofrecords =
'';
514 $result = $db->query($sql);
515 $nbtotalofrecords = $db->num_rows($result);
516 if (($page * $limit) > $nbtotalofrecords) {
524$resql = $db->query($sql);
530 if ($idproduct > 0) {
531 $product->fetch($idproduct);
533 if ($id > 0 || $ref) {
534 $result = $object->fetch($id, $ref);
540 $num = $db->num_rows($resql);
542 $arrayofselected = is_array($toselect) ? $toselect : array();
546 $help_url =
'EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks';
548 $texte = $langs->trans(
'StockMovementForId', $msid);
550 $texte = $langs->trans(
"ListOfStockMovements");
552 $texte .=
' ('.$langs->trans(
"ForThisWarehouse").
')';
560 if ($object->id > 0) {
563 print
dol_get_fiche_head($head,
'movements', $langs->trans(
"Warehouse"), -1,
'stock');
566 $linkback =
'<a href="'.DOL_URL_ROOT.
'/product/stock/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
568 $morehtmlref =
'<div class="refidno">';
569 $morehtmlref .= $langs->trans(
"LocationSummary").
' : '.$object->lieu;
570 $morehtmlref .=
'</div>';
573 if ($user->socid && !in_array(
'stock', explode(
',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) {
577 dol_banner_tab($object,
'ref', $linkback, $shownav,
'ref',
'ref', $morehtmlref);
580 print
'<div class="fichecenter">';
581 print
'<div class="fichehalfleft">';
582 print
'<div class="underbanner clearboth"></div>';
584 print
'<table class="border centpercent">';
589 print
'<td class="titlefield tdtop">'.$langs->trans(
"Description").
'</td><td>'.
dol_htmlentitiesbr($object->description).
'</td></tr>';
591 $calcproductsunique = $object->nb_different_products();
592 $calcproducts = $object->nb_products();
595 print
'<tr><td>'.$langs->trans(
"NumberOfDifferentProducts").
'</td><td>';
596 print empty($calcproductsunique[
'nb']) ?
'0' : $calcproductsunique[
'nb'];
600 print
'<tr><td>'.$langs->trans(
"NumberOfProducts").
'</td><td>';
601 $valtoshow =
price2num($calcproducts[
'nb'],
'MS');
602 print empty($valtoshow) ?
'0' : $valtoshow;
608 print
'<div class="fichehalfright">';
609 print
'<div class="underbanner clearboth"></div>';
611 print
'<table class="border centpercent">';
614 print
'<tr><td class="titlefield">'.$langs->trans(
"EstimatedStockValueShort").
'</td><td>';
615 print
price((empty($calcproducts[
'value']) ?
'0' :
price2num($calcproducts[
'value'],
'MT')), 0, $langs, 0, -1, -1, $conf->currency);
619 $sql =
"SELECT MAX(m.datem) as datem";
620 $sql .=
" FROM ".MAIN_DB_PREFIX.
"stock_mouvement as m";
621 $sql .=
" WHERE m.fk_entrepot = ".(int) $object->id;
622 $resqlbis = $db->query($sql);
624 $obj = $db->fetch_object($resqlbis);
625 $lastmovementdate = $db->jdate($obj->datem);
630 print
'<tr><td>'.$langs->trans(
"LastMovement").
'</td><td>';
631 if ($lastmovementdate) {
634 print $langs->trans(
"None");
643 print
'<div class="clearboth"></div>';
652 if ($action ==
"correction") {
653 include DOL_DOCUMENT_ROOT.
'/product/stock/tpl/stockcorrection.tpl.php';
660 if ($action ==
"transfert") {
661 include DOL_DOCUMENT_ROOT.
'/product/stock/tpl/stocktransfer.tpl.php';
669 if ((empty($action) || $action ==
'list') && $id > 0) {
670 print
"<div class=\"tabsAction\">\n";
672 if ($user->rights->stock->mouvement->creer) {
673 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$id.
'&action=correction">'.$langs->trans(
"CorrectStock").
'</a>';
676 if ($user->rights->stock->mouvement->creer) {
677 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$id.
'&action=transfert">'.$langs->trans(
"TransferStock").
'</a>';
684 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
685 $param .=
'&contextpage='.urlencode($contextpage);
687 if ($limit > 0 && $limit != $conf->liste_limit) {
688 $param .=
'&limit='.((int) $limit);
691 $param .=
'&id='.urlencode($id);
693 if ($search_movement) {
694 $param .=
'&search_movement='.urlencode($search_movement);
696 if ($search_inventorycode) {
697 $param .=
'&search_inventorycode='.urlencode($search_inventorycode);
699 if ($search_type_mouvement) {
700 $param .=
'&search_type_mouvement='.urlencode($search_type_mouvement);
702 if ($search_product_ref) {
703 $param .=
'&search_product_ref='.urlencode($search_product_ref);
705 if ($search_product) {
706 $param .=
'&search_product='.urlencode($search_product);
709 $param .=
'&search_batch='.urlencode($search_batch);
711 if ($search_warehouse > 0) {
712 $param .=
'&search_warehouse='.urlencode($search_warehouse);
715 $param .=
'&search_user='.urlencode($search_user);
717 if ($idproduct > 0) {
718 $param .=
'&idproduct='.urlencode($idproduct);
721 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
724 $arrayofmassactions = array(
729 if (in_array($massaction, array(
'presend',
'predelete'))) {
730 $arrayofmassactions = array();
732 $massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
734 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
735 if ($optioncss !=
'') {
736 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="page" value="'.$page.
'">';
744 print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
746 print
'<input type="hidden" name="id" value="'.$id.
'">';
750 print_barre_liste($texte, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'', 0,
'',
'', $limit);
752 print_barre_liste($texte, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'generic', 0,
'',
'', $limit);
756 foreach ($fieldstosearchall as $key => $val) {
757 $fieldstosearchall[$key] = $langs->trans($val);
759 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $sall).join(
', ', $fieldstosearchall).
'</div>';
764 $parameters = array();
765 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters);
766 if (empty($reshook)) {
767 $moreforfilter .= $hookmanager->resPrint;
769 $moreforfilter = $hookmanager->resPrint;
772 if (!empty($moreforfilter)) {
773 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
774 print $moreforfilter;
778 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
779 $selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage);
781 print
'<div class="div-table-responsive">';
782 print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
785 print
'<tr class="liste_titre_filter">';
786 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'])) {
793 print
'<td class="liste_titre nowraponall">';
794 print
'<input class="flat" type="text" size="2" maxlength="2" placeholder="'.dol_escape_htmltag($langs->trans(
"Month")).
'" name="month" value="'.$month.
'">';
795 if (empty($conf->productbatch->enabled)) {
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'])) {
806 print
'<td class="liste_titre left">';
807 print
'<input class="flat maxwidth75" type="text" name="search_product_ref" value="'.dol_escape_htmltag($idproduct ? $product->ref : $search_product_ref).
'">';
810 if (!empty($arrayfields[
'p.label'][
'checked'])) {
812 print
'<td class="liste_titre left">';
813 print
'<input class="flat maxwidth100" type="text" name="search_product" value="'.dol_escape_htmltag($idproduct ? $product->label : $search_product).
'">';
817 if (!empty($arrayfields[
'm.batch'][
'checked'])) {
818 print
'<td class="liste_titre center"><input class="flat maxwidth75" type="text" name="search_batch" value="'.dol_escape_htmltag($search_batch).
'"></td>';
820 if (!empty($arrayfields[
'pl.eatby'][
'checked'])) {
821 print
'<td class="liste_titre left">';
824 if (!empty($arrayfields[
'pl.sellby'][
'checked'])) {
825 print
'<td class="liste_titre left">';
829 if (!empty($arrayfields[
'e.ref'][
'checked'])) {
830 print
'<td class="liste_titre maxwidthonsmartphone left">';
832 print $formproduct->selectWarehouses($search_warehouse,
'search_warehouse',
'warehouseopen,warehouseinternal', 1, 0, 0,
'', 0, 0,
null,
'maxwidth200');
835 if (!empty($arrayfields[
'm.fk_user_author'][
'checked'])) {
837 print
'<td class="liste_titre left">';
838 print
'<input class="flat" type="text" size="6" name="search_user" value="'.dol_escape_htmltag($search_user).
'">';
841 if (!empty($arrayfields[
'm.inventorycode'][
'checked'])) {
843 print
'<td class="liste_titre left">';
844 print
'<input class="flat" type="text" size="4" name="search_inventorycode" value="'.dol_escape_htmltag($search_inventorycode).
'">';
847 if (!empty($arrayfields[
'm.label'][
'checked'])) {
849 print
'<td class="liste_titre left">';
850 print
'<input class="flat" type="text" size="8" name="search_movement" value="'.dol_escape_htmltag($search_movement).
'">';
853 if (!empty($arrayfields[
'm.type_mouvement'][
'checked'])) {
855 print
'<td class="liste_titre center">';
857 print
'<select id="search_type_mouvement" name="search_type_mouvement" class="maxwidth150">';
858 print
'<option value="" '.(($search_type_mouvement ==
"") ?
'selected="selected"' :
'').
'></option>';
859 print
'<option value="0" '.(($search_type_mouvement ==
"0") ?
'selected="selected"' :
'').
'>'.$langs->trans(
'StockIncreaseAfterCorrectTransfer').
'</option>';
860 print
'<option value="1" '.(($search_type_mouvement ==
"1") ?
'selected="selected"' :
'').
'>'.$langs->trans(
'StockDecreaseAfterCorrectTransfer').
'</option>';
861 print
'<option value="2" '.(($search_type_mouvement ==
"2") ?
'selected="selected"' :
'').
'>'.$langs->trans(
'StockDecrease').
'</option>';
862 print
'<option value="3" '.(($search_type_mouvement ==
"3") ?
'selected="selected"' :
'').
'>'.$langs->trans(
'StockIncrease').
'</option>';
869 if (!empty($arrayfields[
'origin'][
'checked'])) {
871 print
'<td class="liste_titre left">';
875 if (!empty($arrayfields[
'm.value'][
'checked'])) {
877 print
'<td class="liste_titre right">';
878 print
'<input class="flat" type="text" size="4" name="search_qty" value="'.dol_escape_htmltag($search_qty).
'">';
881 if (!empty($arrayfields[
'm.price'][
'checked'])) {
883 print
'<td class="liste_titre left">';
890 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
893 $parameters = array(
'arrayfields'=>$arrayfields);
894 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters);
895 print $hookmanager->resPrint;
897 if (!empty($arrayfields[
'm.datec'][
'checked'])) {
898 print
'<td class="liste_titre">';
902 if (!empty($arrayfields[
'm.tms'][
'checked'])) {
903 print
'<td class="liste_titre">';
907 print
'<td class="liste_titre maxwidthsearch">';
908 $searchpicto = $form->showFilterAndCheckAddButtons(0);
913 print
'<tr class="liste_titre">';
914 if (!empty($arrayfields[
'm.rowid'][
'checked'])) {
915 print_liste_field_titre($arrayfields[
'm.rowid'][
'label'], $_SERVER[
"PHP_SELF"],
'm.rowid',
'', $param,
'', $sortfield, $sortorder);
917 if (!empty($arrayfields[
'm.datem'][
'checked'])) {
918 print_liste_field_titre($arrayfields[
'm.datem'][
'label'], $_SERVER[
"PHP_SELF"],
'm.datem',
'', $param,
'', $sortfield, $sortorder);
920 if (!empty($arrayfields[
'p.ref'][
'checked'])) {
921 print_liste_field_titre($arrayfields[
'p.ref'][
'label'], $_SERVER[
"PHP_SELF"],
'p.ref',
'', $param,
'', $sortfield, $sortorder);
923 if (!empty($arrayfields[
'p.label'][
'checked'])) {
924 print_liste_field_titre($arrayfields[
'p.label'][
'label'], $_SERVER[
"PHP_SELF"],
'p.label',
'', $param,
'', $sortfield, $sortorder);
926 if (!empty($arrayfields[
'm.batch'][
'checked'])) {
927 print_liste_field_titre($arrayfields[
'm.batch'][
'label'], $_SERVER[
"PHP_SELF"],
'm.batch',
'', $param,
'', $sortfield, $sortorder,
'center ');
929 if (!empty($arrayfields[
'pl.eatby'][
'checked'])) {
930 print_liste_field_titre($arrayfields[
'pl.eatby'][
'label'], $_SERVER[
"PHP_SELF"],
'pl.eatby',
'', $param,
'', $sortfield, $sortorder,
'center ');
932 if (!empty($arrayfields[
'pl.sellby'][
'checked'])) {
933 print_liste_field_titre($arrayfields[
'pl.sellby'][
'label'], $_SERVER[
"PHP_SELF"],
'pl.sellby',
'', $param,
'', $sortfield, $sortorder,
'center ');
935 if (!empty($arrayfields[
'e.ref'][
'checked'])) {
937 print_liste_field_titre($arrayfields[
'e.ref'][
'label'], $_SERVER[
"PHP_SELF"],
"e.ref",
"", $param,
"", $sortfield, $sortorder);
939 if (!empty($arrayfields[
'm.fk_user_author'][
'checked'])) {
940 print_liste_field_titre($arrayfields[
'm.fk_user_author'][
'label'], $_SERVER[
"PHP_SELF"],
"m.fk_user_author",
"", $param,
"", $sortfield, $sortorder);
942 if (!empty($arrayfields[
'm.inventorycode'][
'checked'])) {
943 print_liste_field_titre($arrayfields[
'm.inventorycode'][
'label'], $_SERVER[
"PHP_SELF"],
"m.inventorycode",
"", $param,
"", $sortfield, $sortorder);
945 if (!empty($arrayfields[
'm.label'][
'checked'])) {
946 print_liste_field_titre($arrayfields[
'm.label'][
'label'], $_SERVER[
"PHP_SELF"],
"m.label",
"", $param,
"", $sortfield, $sortorder);
948 if (!empty($arrayfields[
'm.type_mouvement'][
'checked'])) {
949 print_liste_field_titre($arrayfields[
'm.type_mouvement'][
'label'], $_SERVER[
"PHP_SELF"],
"m.type_mouvement",
"", $param,
'', $sortfield, $sortorder,
'center ');
951 if (!empty($arrayfields[
'origin'][
'checked'])) {
952 print_liste_field_titre($arrayfields[
'origin'][
'label'], $_SERVER[
"PHP_SELF"],
"",
"", $param,
"", $sortfield, $sortorder);
954 if (!empty($arrayfields[
'm.value'][
'checked'])) {
955 print_liste_field_titre($arrayfields[
'm.value'][
'label'], $_SERVER[
"PHP_SELF"],
"m.value",
"", $param,
'', $sortfield, $sortorder,
'right ');
957 if (!empty($arrayfields[
'm.price'][
'checked'])) {
958 print_liste_field_titre($arrayfields[
'm.price'][
'label'], $_SERVER[
"PHP_SELF"],
"m.price",
"", $param,
'', $sortfield, $sortorder,
'right ');
962 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
965 $parameters = array(
'arrayfields'=>$arrayfields,
'param'=>$param,
'sortfield'=>$sortfield,
'sortorder'=>$sortorder);
966 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters);
967 print $hookmanager->resPrint;
968 if (!empty($arrayfields[
'm.datec'][
'checked'])) {
969 print_liste_field_titre($arrayfields[
'p.datec'][
'label'], $_SERVER[
"PHP_SELF"],
"p.datec",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
971 if (!empty($arrayfields[
'm.tms'][
'checked'])) {
972 print_liste_field_titre($arrayfields[
'p.tms'][
'label'], $_SERVER[
"PHP_SELF"],
"p.tms",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
974 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
978 $arrayofuniqueproduct = array();
979 while ($i < ($limit ? min($num, $limit) : $num)) {
980 $objp = $db->fetch_object($resql);
982 $userstatic->id = $objp->fk_user_author;
983 $userstatic->login = $objp->login;
984 $userstatic->lastname = $objp->lastname;
985 $userstatic->firstname = $objp->firstname;
986 $userstatic->photo = $objp->photo;
988 $productstatic->id = $objp->rowid;
989 $productstatic->ref = $objp->product_ref;
990 $productstatic->label = $objp->produit;
991 $productstatic->type = $objp->type;
992 $productstatic->entity = $objp->entity;
993 $productstatic->status_batch = $objp->tobatch;
995 $productlot->id = $objp->lotid;
996 $productlot->batch = $objp->batch;
997 $productlot->eatby = $objp->eatby;
998 $productlot->sellby = $objp->sellby;
1000 $warehousestatic->id = $objp->entrepot_id;
1001 $warehousestatic->label = $objp->warehouse_ref;
1002 $warehousestatic->lieu = $objp->lieu;
1004 $arrayofuniqueproduct[$objp->rowid] = $objp->produit;
1005 if (!empty($objp->fk_origin)) {
1006 $origin = $movement->get_origin($objp->fk_origin, $objp->origintype);
1011 print
'<tr class="oddeven">';
1013 if (!empty($arrayfields[
'm.rowid'][
'checked'])) {
1015 print
'<td>'.$objp->mid.
'</td>';
1017 if (!empty($arrayfields[
'm.datem'][
'checked'])) {
1019 print
'<td>'.dol_print_date($db->jdate($objp->datem),
'dayhour').
'</td>';
1021 if (!empty($arrayfields[
'p.ref'][
'checked'])) {
1023 print
'<td class="nowraponall">';
1024 print $productstatic->getNomUrl(1,
'stock', 16);
1027 if (!empty($arrayfields[
'p.label'][
'checked'])) {
1034 print $productstatic->label;
1037 if (!empty($arrayfields[
'm.batch'][
'checked'])) {
1038 print
'<td class="center nowraponall">';
1039 if ($productlot->id > 0) {
1040 print $productlot->getNomUrl(1);
1042 print $productlot->batch;
1046 if (!empty($arrayfields[
'pl.eatby'][
'checked'])) {
1047 print
'<td class="center">'.dol_print_date($objp->eatby,
'day').
'</td>';
1049 if (!empty($arrayfields[
'pl.sellby'][
'checked'])) {
1050 print
'<td class="center">'.dol_print_date($objp->sellby,
'day').
'</td>';
1053 if (!empty($arrayfields[
'e.ref'][
'checked'])) {
1055 print $warehousestatic->getNomUrl(1);
1059 if (!empty($arrayfields[
'm.fk_user_author'][
'checked'])) {
1060 print
'<td class="tdoverflowmax100">';
1061 print $userstatic->getNomUrl(-1);
1064 if (!empty($arrayfields[
'm.inventorycode'][
'checked'])) {
1066 print
'<td><a href="'
1067 .DOL_URL_ROOT.
'/product/stock/movement_card.php?id='.urlencode($objp->entrepot_id)
1068 .
'&search_inventorycode='.urlencode($objp->inventorycode)
1069 .
'&search_type_mouvement='.urlencode($objp->type_mouvement)
1071 .$objp->inventorycode
1074 if (!empty($arrayfields[
'm.label'][
'checked'])) {
1076 print
'<td class="tdoverflowmax100aaa">'.$objp->label.
'</td>';
1078 if (!empty($arrayfields[
'm.type_mouvement'][
'checked'])) {
1080 switch ($objp->type_mouvement) {
1082 print
'<td class="center">'.$langs->trans(
'StockIncreaseAfterCorrectTransfer').
'</td>';
1085 print
'<td class="center">'.$langs->trans(
'StockDecreaseAfterCorrectTransfer').
'</td>';
1088 print
'<td class="center">'.$langs->trans(
'StockDecrease').
'</td>';
1091 print
'<td class="center">'.$langs->trans(
'StockIncrease').
'</td>';
1095 if (!empty($arrayfields[
'origin'][
'checked'])) {
1097 print
'<td class="nowraponall">'.$origin.
'</td>';
1099 if (!empty($arrayfields[
'm.value'][
'checked'])) {
1101 print
'<td class="right">';
1102 if ($objp->qt > 0) {
1108 if (!empty($arrayfields[
'm.price'][
'checked'])) {
1110 print
'<td class="right">';
1111 if ($objp->price != 0) {
1112 print
price($objp->price);
1117 print
'<td class="nowrap center">';
1118 if ($massactionbutton || $massaction) {
1120 if (in_array($obj->rowid, $arrayofselected)) {
1123 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
1127 $totalarray[
'nbfield']++;
1140 if (count($arrayofuniqueproduct) == 1 && is_numeric($year)) {
1143 $productidselected = 0;
1144 foreach ($arrayofuniqueproduct as $key => $val) {
1145 $productidselected = $key;
1146 $productlabelselected = $val;
1148 $datebefore =
dol_get_first_day($year ? $year : strftime(
"%Y", time()), $month ? $month : 1, true);
1149 $dateafter =
dol_get_last_day($year ? $year : strftime(
"%Y", time()), $month ? $month : 12, true);
1150 $balancebefore = $movement->calculateBalanceForProductBefore($productidselected, $datebefore);
1151 $balanceafter = $movement->calculateBalanceForProductBefore($productidselected, $dateafter);
1154 print $langs->trans(
"NbOfProductBeforePeriod", $productlabelselected,
dol_print_date($datebefore,
'day',
'gmt'));
1157 print
': '.$balancebefore;
1161 print $langs->trans(
"NbOfProductAfterPeriod", $productlabelselected,
dol_print_date($dateafter,
'day',
'gmt'));
1164 print
': '.$balanceafter;
1178$modulepart =
'movement';
1180if ($action !=
'create' && $action !=
'edit' && $action !=
'delete' && $id > 0) {
1182 print
'<div class="fichecenter"><div class="fichehalfleft">';
1183 print
'<a name="builddoc"></a>';
1188 if (!empty($search_inventorycode)) {
1189 $objectref .=
"_".$id.
"_".$search_inventorycode;
1191 if ($search_type_mouvement) {
1192 $objectref .=
"_".$search_type_mouvement;
1194 $relativepath = $comref.
'/'.$objectref.
'.pdf';
1195 $filedir = $conf->stock->dir_output.
'/movement/'.$objectref;
1197 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".$object->id.
"&search_inventorycode=".$search_inventorycode.
"&search_type_mouvement=$search_type_mouvement";
1198 $genallowed = $usercanread;
1199 $delallowed = $usercancreate;
1201 $genallowed = $user->rights->stock->lire;
1202 $delallowed = $user->rights->stock->creer;
1204 print $formfile->showdocuments($modulepart, $objectref, $filedir, $urlsource, $genallowed, $delallowed,
'', 0, 0, 0, 28, 0,
'', 0,
'', $object->default_lang,
'', $object);
1205 $somethingshown = $formfile->numoffiles;
1207 print
'</div><div class="fichehalfright">';
1211 $morehtmlcenter =
dolGetButtonTitle($langs->trans(
'SeeAll'),
'',
'fa fa-bars imgforviewmode', DOL_URL_ROOT.
'/product/agenda.php?id='.$object->id);
1214 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
1216 $somethingshown =
$formactions->showactions($object,
'mouvement', 0, 1,
'', $MAXEVENT,
'', $morehtmlcenter);
1218 print
'</div></div>';
if(preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) if(preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) if($action=='set') elseif( $action=='specimen') elseif($action=='setmodel') elseif( $action=='del') elseif($action=='setdoc') $formactions
View.
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve', $idforemptyvalue='-1', $morecss='')
Convert a html select field into an ajax combobox.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage warehouses.
Class to manage stock movements.
Class to manage products or services.
Manage record for batch number management.
Class with list of lots and properties.
Class to manage Dolibarr users.
dolSqlDateFilter($datefield, $day_date, $month_date, $year_date, $excludefirstand=0, $gm=false)
Generate a SQL string to make a filter into a range (for second of date until last second of date).
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
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.
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...
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
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...
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.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
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.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
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...
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
stock_prepare_head($object)
Prepare array with list of tabs.