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 if (!empty($conf->projet->enabled)) {
41 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
42 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
46 $langs->loadLangs(array(
'products',
'stocks',
'orders'));
47 if (!empty($conf->productbatch->enabled)) $langs->load(
"productbatch");
55 $product_id =
GETPOST(
"product_id",
'int');
56 $action =
GETPOST(
'action',
'aZ09');
57 $cancel =
GETPOST(
'cancel',
'alpha');
58 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'movementlist';
60 $idproduct =
GETPOST(
'idproduct',
'int');
62 $month =
GETPOST(
"month",
'int');
63 $search_ref =
GETPOST(
'search_ref',
'alpha');
64 $search_movement =
GETPOST(
"search_movement",
'alpha');
65 $search_product_ref = trim(
GETPOST(
"search_product_ref",
'alpha'));
66 $search_product = trim(
GETPOST(
"search_product",
'alpha'));
67 $search_warehouse = trim(
GETPOST(
"search_warehouse",
'alpha'));
68 $search_inventorycode = trim(
GETPOST(
"search_inventorycode",
'alpha'));
69 $search_user = trim(
GETPOST(
"search_user",
'alpha'));
70 $search_batch = trim(
GETPOST(
"search_batch",
'alpha'));
71 $search_qty = trim(
GETPOST(
"search_qty",
'alpha'));
72 $search_type_mouvement =
GETPOST(
'search_type_mouvement',
'int');
74 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
76 $sortfield =
GETPOST(
"sortfield",
'alpha');
77 $sortorder =
GETPOST(
"sortorder",
'alpha');
78 if (empty($page) || $page == -1) { $page = 0; }
79 $offset = $limit * $page;
80 if (!$sortfield) $sortfield =
"m.datem";
81 if (!$sortorder) $sortorder =
"DESC";
83 $pdluoid =
GETPOST(
'pdluoid',
'int');
87 $hookmanager->initHooks(array(
'movementlist'));
92 $extrafields->fetch_name_optionals_label($object->table_element);
94 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element,
'',
'search_');
97 'm.rowid'=>array(
'label'=>$langs->trans(
"Ref"),
'checked'=>1),
98 'm.datem'=>array(
'label'=>$langs->trans(
"Date"),
'checked'=>1),
99 'p.ref'=>array(
'label'=>$langs->trans(
"ProductRef"),
'checked'=>1,
'css'=>
'maxwidth100'),
100 'p.label'=>array(
'label'=>$langs->trans(
"ProductLabel"),
'checked'=>1),
101 'm.batch'=>array(
'label'=>$langs->trans(
"BatchNumberShort"),
'checked'=>1,
'enabled'=>(!empty($conf->productbatch->enabled))),
102 'pl.eatby'=>array(
'label'=>$langs->trans(
"EatByDate"),
'checked'=>0,
'position'=>10,
'enabled'=>(!empty($conf->productbatch->enabled))),
103 'pl.sellby'=>array(
'label'=>$langs->trans(
"SellByDate"),
'checked'=>0,
'position'=>10,
'enabled'=>(!empty($conf->productbatch->enabled))),
104 'e.ref'=>array(
'label'=>$langs->trans(
"Warehouse"),
'checked'=>1,
'enabled'=>(!$id > 0)),
105 'm.fk_user_author'=>array(
'label'=>$langs->trans(
"Author"),
'checked'=>0),
106 'm.inventorycode'=>array(
'label'=>$langs->trans(
"InventoryCodeShort"),
'checked'=>1),
107 'm.label'=>array(
'label'=>$langs->trans(
"MovementLabel"),
'checked'=>1),
108 'm.type_mouvement'=>array(
'label'=>$langs->trans(
"TypeMovement"),
'checked'=>1),
109 'origin'=>array(
'label'=>$langs->trans(
"Origin"),
'checked'=>1),
110 'm.value'=>array(
'label'=>$langs->trans(
"Qty"),
'checked'=>1),
111 'm.price'=>array(
'label'=>$langs->trans(
"UnitPurchaseValue"),
'checked'=>0),
116 $usercanread = (($user->rights->stock->mouvement->lire));
117 $usercancreate = (($user->rights->stock->mouvement->creer));
118 $usercandelete = (($user->rights->stock->mouvement->supprimer));
126 if (
GETPOST(
'cancel',
'alpha')) { $action =
'list'; $massaction =
''; }
127 if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') { $massaction =
''; }
129 $parameters = array();
130 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
131 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
133 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
136 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha'))
141 $search_movement =
"";
142 $search_type_mouvement =
"";
143 $search_inventorycode =
"";
144 $search_product_ref =
"";
145 $search_product =
"";
146 $search_warehouse =
"";
152 $search_array_options = array();
156 if ($action ==
"correct_stock")
159 if (!empty($product_id)) $result = $product->fetch($product_id);
163 if (empty($product_id))
166 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Product")), null,
'errors');
167 $action =
'correction';
169 if (!is_numeric($_POST[
"nbpiece"]))
172 setEventMessages($langs->trans(
"ErrorFieldMustBeANumeric", $langs->transnoentitiesnoconv(
"NumberOfUnit")), null,
'errors');
173 $action =
'correction';
178 $origin_element =
'';
181 if (
GETPOST(
'projectid',
'int'))
183 $origin_element =
'project';
184 $origin_id =
GETPOST(
'projectid',
'int');
187 if ($product->hasbatch())
189 $batch =
GETPOST(
'batch_number',
'alpha');
196 $result = $product->correct_stock_batch(
206 GETPOST(
'inventorycode',
'alpha'),
211 $result = $product->correct_stock(
218 GETPOST(
'inventorycode',
'alpha'),
226 header(
"Location: ".
$_SERVER[
"PHP_SELF"].
"?id=".$id);
231 $action =
'correction';
235 if (!$error) $action =
'';
239 if ($action ==
"transfert_stock" && !$cancel)
242 if (!empty($product_id)) $result = $product->fetch($product_id);
244 if (!(
GETPOST(
"id_entrepot_destination",
'int') > 0))
246 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Warehouse")), null,
'errors');
248 $action =
'transfert';
250 if (empty($product_id))
253 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Product")), null,
'errors');
254 $action =
'transfert';
256 if (!
GETPOST(
"nbpiece",
'int'))
258 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"NumberOfUnit")), null,
'errors');
260 $action =
'transfert';
262 if ($id ==
GETPOST(
"id_entrepot_destination",
'int'))
264 setEventMessages($langs->trans(
"ErrorSrcAndTargetWarehouseMustDiffers"), null,
'errors');
266 $action =
'transfert';
269 if (!empty($conf->productbatch->enabled))
272 $result = $product->fetch($product_id);
274 if ($product->hasbatch() && !
GETPOST(
"batch_number",
'alpha'))
276 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"batch_number")), null,
'errors');
278 $action =
'transfert';
287 $result = $object->fetch($id);
291 $product->load_stock(
'novirtual');
295 if (isset($product->pmp)) $pricesrc = $product->pmp;
296 $pricedest = $pricesrc;
298 if ($product->hasbatch())
304 $result = $pdluo->fetch($pdluoid);
307 $srcwarehouseid = $pdluo->warehouseid;
308 $batch = $pdluo->batch;
309 $eatby = $pdluo->eatby;
310 $sellby = $pdluo->sellby;
316 $srcwarehouseid = $id;
317 $batch =
GETPOST(
'batch_number',
'alpha');
325 $result1 = $product->correct_stock_batch(
335 GETPOST(
'inventorycode',
'alpha')
338 $result2 = $product->correct_stock_batch(
340 GETPOST(
"id_entrepot_destination",
'int'),
348 GETPOST(
'inventorycode',
'alpha')
353 $result1 = $product->correct_stock(
360 GETPOST(
'inventorycode',
'alpha')
364 $result2 = $product->correct_stock(
366 GETPOST(
"id_entrepot_destination"),
371 GETPOST(
'inventorycode',
'alpha')
374 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;
403 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
406 if (empty($reshook) && $action !=
'remove_file')
408 $objectclass =
'MouvementStock';
409 $objectlabel =
'Movements';
410 $permissiontoread = $user->rights->stock->lire;
411 $permissiontodelete = $user->rights->stock->supprimer;
412 $uploaddir = $conf->stock->dir_output.
"/movement/";
413 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
422 $productlot =
new ProductLot($db);
423 $productstatic =
new Product($db);
424 $warehousestatic =
new Entrepot($db);
426 $userstatic =
new User($db);
427 $form =
new Form($db);
430 if (!empty($conf->projet->enabled)) $formproject =
new FormProjets($db);
432 $sql =
"SELECT p.rowid, p.ref as product_ref, p.label as produit, p.tobatch, p.fk_product_type as type, p.entity,";
433 $sql .=
" e.ref as warehouse_ref, e.rowid as entrepot_id, e.lieu,";
434 $sql .=
" m.rowid as mid, m.value as qty, m.datem, m.fk_user_author, m.label, m.inventorycode, m.fk_origin, m.origintype,";
435 $sql .=
" m.batch, m.price,";
436 $sql .=
" m.type_mouvement,";
437 $sql .=
" pl.rowid as lotid, pl.eatby, pl.sellby,";
438 $sql .=
" u.login, u.photo, u.lastname, u.firstname";
440 if (!empty($extrafields->attributes[$object->table_element][
'label'])) {
441 foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
' as options_'.$key :
'');
444 $parameters = array();
445 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters);
446 $sql .= $hookmanager->resPrint;
447 $sql .=
" FROM ".MAIN_DB_PREFIX.
"entrepot as e,";
448 $sql .=
" ".MAIN_DB_PREFIX.
"product as p,";
449 $sql .=
" ".MAIN_DB_PREFIX.
"stock_mouvement as m";
450 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)";
451 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u ON m.fk_user_author = u.rowid";
452 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product_lot as pl ON m.batch = pl.batch AND m.fk_product = pl.fk_product";
453 $sql .=
" WHERE m.fk_product = p.rowid";
454 if ($msid > 0) $sql .=
" AND m.rowid = ".$msid;
455 $sql .=
" AND m.fk_entrepot = e.rowid";
456 $sql .=
" AND e.entity IN (".getEntity(
'stock').
")";
457 if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) $sql .=
" AND p.fk_product_type = 0";
458 if ($id > 0) $sql .=
" AND e.rowid ='".$id.
"'";
460 if ($idproduct > 0) $sql .=
" AND p.rowid = ".((int) $idproduct);
461 if (!empty($search_ref)) $sql .=
natural_search(
'm.rowid', $search_ref, 1);
462 if (!empty($search_movement)) $sql .=
natural_search(
'm.label', $search_movement);
463 if (!empty($search_inventorycode)) $sql .=
natural_search(
'm.inventorycode', $search_inventorycode);
464 if (!empty($search_product_ref)) $sql .=
natural_search(
'p.ref', $search_product_ref);
465 if (!empty($search_product)) $sql .=
natural_search(
'p.label', $search_product);
466 if ($search_warehouse !=
'' && $search_warehouse !=
'-1') $sql .=
natural_search(
'e.rowid', $search_warehouse, 2);
467 if (!empty($search_user)) $sql .=
natural_search(
'u.login', $search_user);
468 if (!empty($search_batch)) $sql .=
natural_search(
'm.batch', $search_batch);
469 if ($search_qty !=
'') $sql .=
natural_search(
'm.value', $search_qty, 1);
470 if ($search_type_mouvement !=
'' && $search_type_mouvement !=
'-1') $sql .=
natural_search(
'm.type_mouvement', $search_type_mouvement, 2);
472 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
474 $parameters = array();
475 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters);
476 $sql .= $hookmanager->resPrint;
477 $sql .= $db->order($sortfield, $sortorder);
479 $nbtotalofrecords =
'';
480 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
482 $result = $db->query($sql);
483 $nbtotalofrecords = $db->num_rows($result);
484 if (($page * $limit) > $nbtotalofrecords)
493 $resql = $db->query($sql);
502 $product->fetch($idproduct);
506 $result = $object->fetch($id, $ref);
513 $num = $db->num_rows(
$resql);
515 $arrayofselected = is_array($toselect) ? $toselect : array();
519 $help_url =
'EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks';
520 if ($msid) $texte = $langs->trans(
'StockMovementForId', $msid);
522 $texte = $langs->trans(
"ListOfStockMovements");
523 if ($id) $texte .=
' ('.$langs->trans(
"ForThisWarehouse").
')';
537 $linkback =
'<a href="'.DOL_URL_ROOT.
'/product/stock/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
539 $morehtmlref =
'<div class="refidno">';
540 $morehtmlref .= $langs->trans(
"LocationSummary").
' : '.$object->lieu;
541 $morehtmlref .=
'</div>';
544 if ($user->socid && !in_array(
'stock', explode(
',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0;
546 dol_banner_tab($object,
'ref', $linkback, $shownav,
'ref',
'ref', $morehtmlref);
549 print '<div class="fichecenter">';
550 print '<div class="fichehalfleft">';
551 print '<div class="underbanner clearboth"></div>';
553 print '<table class="border centpercent">';
558 print '<td class="titlefield tdtop">'.$langs->trans(
"Description").
'</td><td>'.
dol_htmlentitiesbr($object->description).
'</td></tr>';
560 $calcproductsunique = $object->nb_different_products();
561 $calcproducts = $object->nb_products();
564 print '<tr><td>'.$langs->trans(
"NumberOfDifferentProducts").
'</td><td>';
565 print empty($calcproductsunique[
'nb']) ?
'0' : $calcproductsunique[
'nb'];
569 print '<tr><td>'.$langs->trans(
"NumberOfProducts").
'</td><td>';
570 $valtoshow =
price2num($calcproducts[
'nb'],
'MS');
571 print empty($valtoshow) ?
'0' : $valtoshow;
577 print '<div class="fichehalfright">';
578 print '<div class="ficheaddleft">';
579 print '<div class="underbanner clearboth"></div>';
581 print '<table class="border centpercent">';
584 print '<tr><td class="titlefield">'.$langs->trans(
"EstimatedStockValueShort").
'</td><td>';
585 print price((empty($calcproducts[
'value']) ?
'0' :
price2num($calcproducts[
'value'],
'MT')), 0, $langs, 0, -1, -1, $conf->currency);
589 $sql =
"SELECT MAX(m.datem) as datem";
590 $sql .=
" FROM ".MAIN_DB_PREFIX.
"stock_mouvement as m";
591 $sql .=
" WHERE m.fk_entrepot = ".(int) $object->id;
592 $resqlbis = $db->query($sql);
595 $obj = $db->fetch_object($resqlbis);
596 $lastmovementdate = $db->jdate($obj->datem);
601 print '<tr><td>'.$langs->trans(
"LastMovement").
'</td><td>';
602 if ($lastmovementdate)
606 print $langs->trans(
"None");
616 print '<div class="clearboth"></div>';
625 if ($action ==
"correction")
627 include DOL_DOCUMENT_ROOT.
'/product/stock/tpl/stockcorrection.tpl.php';
634 if ($action ==
"transfert")
636 include DOL_DOCUMENT_ROOT.
'/product/stock/tpl/stocktransfer.tpl.php';
647 if ((empty($action) || $action ==
'list') && $id > 0)
649 print "<div class=\"tabsAction\">\n";
651 if ($user->rights->stock->mouvement->creer)
653 print '<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$id.
'&action=correction">'.$langs->trans(
"CorrectStock").
'</a>';
656 if ($user->rights->stock->mouvement->creer)
658 print '<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$id.
'&action=transfert">'.$langs->trans(
"TransferStock").
'</a>';
665 if (!empty($contextpage) && $contextpage !=
$_SERVER[
"PHP_SELF"]) $param .=
'&contextpage='.urlencode($contextpage);
666 if ($limit > 0 && $limit != $conf->liste_limit) $param .=
'&limit='.urlencode($limit);
667 if ($id > 0) $param .=
'&id='.urlencode($id);
668 if ($search_movement) $param .=
'&search_movement='.urlencode($search_movement);
669 if ($search_inventorycode) $param .=
'&search_inventorycode='.urlencode($search_inventorycode);
670 if ($search_type_mouvement) $param .=
'&search_type_mouvement='.urlencode($search_type_mouvement);
671 if ($search_product_ref) $param .=
'&search_product_ref='.urlencode($search_product_ref);
672 if ($search_product) $param .=
'&search_product='.urlencode($search_product);
673 if ($search_batch) $param .=
'&search_batch='.urlencode($search_batch);
674 if ($search_warehouse > 0) $param .=
'&search_warehouse='.urlencode($search_warehouse);
675 if ($search_user) $param .=
'&search_user='.urlencode($search_user);
676 if ($idproduct > 0) $param .=
'&idproduct='.urlencode($idproduct);
678 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
681 $arrayofmassactions = array(
686 if (in_array($massaction, array(
'presend',
'predelete'))) $arrayofmassactions = array();
687 $massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
689 print '<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
690 if ($optioncss !=
'')
print '<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
691 print '<input type="hidden" name="token" value="'.newToken().
'">';
692 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
693 print '<input type="hidden" name="action" value="list">';
694 print '<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
695 print '<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
696 print '<input type="hidden" name="page" value="'.$page.
'">';
697 print '<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
698 if ($id > 0)
print '<input type="hidden" name="id" value="'.$id.
'">';
700 if ($id > 0)
print_barre_liste($texte, $page,
$_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'', 0,
'',
'', $limit);
701 else print_barre_liste($texte, $page,
$_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'generic', 0,
'',
'', $limit);
705 foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val);
706 print '<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $sall).join(
', ', $fieldstosearchall).
'</div>';
711 $parameters = array();
712 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters);
713 if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint;
714 else $moreforfilter = $hookmanager->resPrint;
716 if (!empty($moreforfilter))
718 print '<div class="liste_titre liste_titre_bydiv centpercent">';
719 print $moreforfilter;
723 $varpage = empty($contextpage) ?
$_SERVER[
"PHP_SELF"] : $contextpage;
724 $selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage);
726 print '<div class="div-table-responsive">';
727 print '<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
730 print '<tr class="liste_titre_filter">';
731 if (!empty($arrayfields[
'm.rowid'][
'checked']))
734 print
'<td class="liste_titre left">';
735 print
'<input class="flat maxwidth25" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).
'">';
738 if (!empty($arrayfields[
'm.datem'][
'checked']))
740 print
'<td class="liste_titre nowraponall">';
741 print
'<input class="flat" type="text" size="2" maxlength="2" placeholder="'.dol_escape_htmltag($langs->trans(
"Month")).
'" name="month" value="'.$month.
'">';
742 if (empty($conf->productbatch->enabled)) print
' ';
744 $syear = $year ? $year : -1;
745 print
'<input class="flat maxwidth50" type="text" maxlength="4" placeholder="'.dol_escape_htmltag($langs->trans(
"Year")).
'" name="year" value="'.($syear > 0 ? $syear :
'').
'">';
749 if (!empty($arrayfields[
'p.ref'][
'checked']))
752 print
'<td class="liste_titre left">';
753 print
'<input class="flat maxwidth75" type="text" name="search_product_ref" value="'.dol_escape_htmltag($idproduct ? $product->ref : $search_product_ref).
'">';
756 if (!empty($arrayfields[
'p.label'][
'checked']))
759 print
'<td class="liste_titre left">';
760 print
'<input class="flat maxwidth100" type="text" name="search_product" value="'.dol_escape_htmltag($idproduct ? $product->label : $search_product).
'">';
764 if (!empty($arrayfields[
'm.batch'][
'checked']))
766 print
'<td class="liste_titre center"><input class="flat maxwidth75" type="text" name="search_batch" value="'.dol_escape_htmltag($search_batch).
'"></td>';
768 if (!empty($arrayfields[
'pl.eatby'][
'checked']))
770 print
'<td class="liste_titre left">';
773 if (!empty($arrayfields[
'pl.sellby'][
'checked']))
775 print
'<td class="liste_titre left">';
779 if (!empty($arrayfields[
'e.ref'][
'checked']))
781 print
'<td class="liste_titre maxwidthonsmartphone left">';
783 print $formproduct->selectWarehouses($search_warehouse,
'search_warehouse',
'warehouseopen,warehouseinternal', 1, 0, 0,
'', 0, 0, null,
'maxwidth200');
786 if (!empty($arrayfields[
'm.fk_user_author'][
'checked']))
789 print
'<td class="liste_titre left">';
790 print
'<input class="flat" type="text" size="6" name="search_user" value="'.dol_escape_htmltag($search_user).
'">';
793 if (!empty($arrayfields[
'm.inventorycode'][
'checked']))
796 print
'<td class="liste_titre left">';
797 print
'<input class="flat" type="text" size="4" name="search_inventorycode" value="'.dol_escape_htmltag($search_inventorycode).
'">';
800 if (!empty($arrayfields[
'm.label'][
'checked']))
803 print
'<td class="liste_titre left">';
804 print
'<input class="flat" type="text" size="8" name="search_movement" value="'.dol_escape_htmltag($search_movement).
'">';
807 if (!empty($arrayfields[
'm.type_mouvement'][
'checked']))
810 print
'<td class="liste_titre center">';
812 print
'<select id="search_type_mouvement" name="search_type_mouvement" class="maxwidth150">';
813 print
'<option value="" '.(($search_type_mouvement ==
"") ?
'selected="selected"' :
'').
'></option>';
814 print
'<option value="0" '.(($search_type_mouvement ==
"0") ?
'selected="selected"' :
'').
'>'.$langs->trans(
'StockIncreaseAfterCorrectTransfer').
'</option>';
815 print
'<option value="1" '.(($search_type_mouvement ==
"1") ?
'selected="selected"' :
'').
'>'.$langs->trans(
'StockDecreaseAfterCorrectTransfer').
'</option>';
816 print
'<option value="2" '.(($search_type_mouvement ==
"2") ?
'selected="selected"' :
'').
'>'.$langs->trans(
'StockDecrease').
'</option>';
817 print
'<option value="3" '.(($search_type_mouvement ==
"3") ?
'selected="selected"' :
'').
'>'.$langs->trans(
'StockIncrease').
'</option>';
824 if (!empty($arrayfields[
'origin'][
'checked']))
827 print
'<td class="liste_titre left">';
831 if (!empty($arrayfields[
'm.value'][
'checked']))
834 print
'<td class="liste_titre right">';
835 print
'<input class="flat" type="text" size="4" name="search_qty" value="'.dol_escape_htmltag($search_qty).
'">';
838 if (!empty($arrayfields[
'm.price'][
'checked']))
841 print
'<td class="liste_titre left">';
848 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
851 $parameters = array(
'arrayfields'=>$arrayfields);
852 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters);
853 print $hookmanager->resPrint;
855 if (!empty($arrayfields[
'm.datec'][
'checked']))
857 print
'<td class="liste_titre">';
861 if (!empty($arrayfields[
'm.tms'][
'checked']))
863 print
'<td class="liste_titre">';
867 print
'<td class="liste_titre maxwidthsearch">';
868 $searchpicto = $form->showFilterAndCheckAddButtons(0);
873 print
'<tr class="liste_titre">';
874 if (!empty($arrayfields[
'm.rowid'][
'checked']))
876 if (!empty($arrayfields[
'm.datem'][
'checked']))
878 if (!empty($arrayfields[
'p.ref'][
'checked']))
880 if (!empty($arrayfields[
'p.label'][
'checked']))
882 if (!empty($arrayfields[
'm.batch'][
'checked']))
884 if (!empty($arrayfields[
'pl.eatby'][
'checked']))
886 if (!empty($arrayfields[
'pl.sellby'][
'checked']))
888 if (!empty($arrayfields[
'e.ref'][
'checked'])) {
892 if (!empty($arrayfields[
'm.fk_user_author'][
'checked']))
894 if (!empty($arrayfields[
'm.inventorycode'][
'checked']))
896 if (!empty($arrayfields[
'm.label'][
'checked']))
898 if (!empty($arrayfields[
'm.type_mouvement'][
'checked']))
899 print_liste_field_titre($arrayfields[
'm.type_mouvement'][
'label'],
$_SERVER[
"PHP_SELF"],
"m.type_mouvement",
"", $param,
'', $sortfield, $sortorder,
'center ');
900 if (!empty($arrayfields[
'origin'][
'checked']))
902 if (!empty($arrayfields[
'm.value'][
'checked']))
904 if (!empty($arrayfields[
'm.price'][
'checked']))
908 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
911 $parameters = array(
'arrayfields'=>$arrayfields,
'param'=>$param,
'sortfield'=>$sortfield,
'sortorder'=>$sortorder);
912 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters);
913 print $hookmanager->resPrint;
914 if (!empty($arrayfields[
'm.datec'][
'checked'])) {
917 if (!empty($arrayfields[
'm.tms'][
'checked'])) {
924 $arrayofuniqueproduct = array();
925 while ($i < ($limit ? min($num, $limit) : $num)) {
926 $objp = $db->fetch_object(
$resql);
928 $userstatic->id = $objp->fk_user_author;
929 $userstatic->login = $objp->login;
930 $userstatic->lastname = $objp->lastname;
931 $userstatic->firstname = $objp->firstname;
932 $userstatic->photo = $objp->photo;
934 $productstatic->id = $objp->rowid;
935 $productstatic->ref = $objp->product_ref;
936 $productstatic->label = $objp->produit;
937 $productstatic->type = $objp->type;
938 $productstatic->entity = $objp->entity;
939 $productstatic->status_batch = $objp->tobatch;
941 $productlot->id = $objp->lotid;
942 $productlot->batch = $objp->batch;
943 $productlot->eatby = $objp->eatby;
944 $productlot->sellby = $objp->sellby;
946 $warehousestatic->id = $objp->entrepot_id;
947 $warehousestatic->label = $objp->warehouse_ref;
948 $warehousestatic->lieu = $objp->lieu;
950 $arrayofuniqueproduct[$objp->rowid] = $objp->produit;
951 if (!empty($objp->fk_origin)) {
952 $origin = $movement->get_origin($objp->fk_origin, $objp->origintype);
957 print
'<tr class="oddeven">';
959 if (!empty($arrayfields[
'm.rowid'][
'checked']))
962 print
'<td>'.$objp->mid.
'</td>';
964 if (!empty($arrayfields[
'm.datem'][
'checked']))
967 print
'<td>'.dol_print_date($db->jdate($objp->datem),
'dayhour').
'</td>';
969 if (!empty($arrayfields[
'p.ref'][
'checked']))
972 print
'<td class="nowraponall">';
973 print $productstatic->getNomUrl(1,
'stock', 16);
976 if (!empty($arrayfields[
'p.label'][
'checked']))
984 print $productstatic->label;
987 if (!empty($arrayfields[
'm.batch'][
'checked']))
989 print
'<td class="center nowraponall">';
990 if ($productlot->id > 0) print $productlot->getNomUrl(1);
991 else print $productlot->batch;
994 if (!empty($arrayfields[
'pl.eatby'][
'checked']))
996 print
'<td class="center">'.dol_print_date($objp->eatby,
'day').
'</td>';
998 if (!empty($arrayfields[
'pl.sellby'][
'checked']))
1000 print
'<td class="center">'.dol_print_date($objp->sellby,
'day').
'</td>';
1003 if (!empty($arrayfields[
'e.ref'][
'checked']))
1006 print $warehousestatic->getNomUrl(1);
1010 if (!empty($arrayfields[
'm.fk_user_author'][
'checked']))
1012 print
'<td class="tdoverflowmax100">';
1013 print $userstatic->getNomUrl(-1);
1016 if (!empty($arrayfields[
'm.inventorycode'][
'checked']))
1019 print
'<td><a href="'
1020 .DOL_URL_ROOT.
'/product/stock/movement_card.php?id='.urlencode($objp->entrepot_id)
1021 .
'&search_inventorycode='.urlencode($objp->inventorycode)
1022 .
'&search_type_mouvement='.urlencode($objp->type_mouvement)
1024 .$objp->inventorycode
1027 if (!empty($arrayfields[
'm.label'][
'checked']))
1030 print
'<td class="tdoverflowmax100aaa">'.$objp->label.
'</td>';
1032 if (!empty($arrayfields[
'm.type_mouvement'][
'checked']))
1035 switch ($objp->type_mouvement) {
1037 print
'<td class="center">'.$langs->trans(
'StockIncreaseAfterCorrectTransfer').
'</td>';
1040 print
'<td class="center">'.$langs->trans(
'StockDecreaseAfterCorrectTransfer').
'</td>';
1043 print
'<td class="center">'.$langs->trans(
'StockDecrease').
'</td>';
1046 print
'<td class="center">'.$langs->trans(
'StockIncrease').
'</td>';
1050 if (!empty($arrayfields[
'origin'][
'checked']))
1053 print
'<td class="nowraponall">'.$origin.
'</td>';
1055 if (!empty($arrayfields[
'm.value'][
'checked']))
1058 print
'<td class="right">';
1059 if ($objp->qt > 0) print
'+';
1063 if (!empty($arrayfields[
'm.price'][
'checked']))
1066 print
'<td class="right">';
1067 if ($objp->price != 0) print
price($objp->price);
1071 print
'<td class="nowrap center">';
1072 if ($massactionbutton || $massaction)
1075 if (in_array($obj->rowid, $arrayofselected)) $selected = 1;
1076 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
1079 if (!$i) $totalarray[
'nbfield']++;
1091 if (count($arrayofuniqueproduct) == 1 && is_numeric($year))
1095 $productidselected = 0;
1096 foreach ($arrayofuniqueproduct as $key => $val) {
1097 $productidselected = $key;
1098 $productlabelselected = $val;
1100 $datebefore =
dol_get_first_day($year ? $year : strftime(
"%Y", time()), $month ? $month : 1,
true);
1101 $dateafter =
dol_get_last_day($year ? $year : strftime(
"%Y", time()), $month ? $month : 12,
true);
1102 $balancebefore = $movement->calculateBalanceForProductBefore($productidselected, $datebefore);
1103 $balanceafter = $movement->calculateBalanceForProductBefore($productidselected, $dateafter);
1106 print $langs->trans(
"NbOfProductBeforePeriod", $productlabelselected,
dol_print_date($datebefore,
'day',
'gmt'));
1109 print
': '.$balancebefore;
1113 print $langs->trans(
"NbOfProductAfterPeriod", $productlabelselected,
dol_print_date($dateafter,
'day',
'gmt'));
1116 print
': '.$balanceafter;
1130 $modulepart =
'movement';
1132 if ($action !=
'create' && $action !=
'edit' && $action !=
'delete' && $id > 0)
1135 print
'<div class="fichecenter"><div class="fichehalfleft">';
1136 print
'<a name="builddoc"></a>';
1141 if (!empty($search_inventorycode)) $objectref .=
"_".$id.
"_".$search_inventorycode;
1142 if ($search_type_mouvement) $objectref .=
"_".$search_type_mouvement;
1143 $relativepath = $comref.
'/'.$objectref.
'.pdf';
1144 $filedir = $conf->stock->dir_output.
'/movement/'.$objectref;
1146 $urlsource =
$_SERVER[
"PHP_SELF"].
"?id=".$object->id.
"&search_inventorycode=".$search_inventorycode.
"&search_type_mouvement=$search_type_mouvement";
1147 $genallowed = $usercanread;
1148 $delallowed = $usercancreate;
1150 $genallowed = $user->rights->stock->lire;
1151 $delallowed = $user->rights->stock->creer;
1153 print $formfile->showdocuments($modulepart, $objectref, $filedir, $urlsource, $genallowed, $delallowed,
'', 0, 0, 0, 28, 0,
'', 0,
'', $object->default_lang,
'', $object);
1154 $somethingshown = $formfile->numoffiles;
1156 print
'</div><div class="fichehalfright"><div class="ficheaddleft">';
1160 $morehtmlright =
'<a href="'.DOL_URL_ROOT.
'/product/agenda.php?id='.$object->id.
'">';
1161 $morehtmlright .= $langs->trans(
"SeeAll");
1162 $morehtmlright .=
'</a>';
1165 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
1167 $somethingshown =
$formactions->showactions($object,
'mouvement', 0, 1,
'', $MAXEVENT,
'', $morehtmlright);
1169 print
'</div></div></div>';
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.
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.
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.
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.
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...
dol_sanitizeFileName($str, $newstr= '_', $unaccent=1)
Clean a string to use it as a file name.
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.