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')) {
139if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
143$parameters = array();
144$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
149include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
152if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
156 $search_movement =
"";
157 $search_type_mouvement =
"";
158 $search_inventorycode =
"";
159 $search_product_ref =
"";
160 $search_product =
"";
161 $search_warehouse =
"";
167 $search_array_options = array();
171if ($action ==
"correct_stock") {
173 if (!empty($product_id)) {
174 $result = $product->fetch($product_id);
179 if (empty($product_id)) {
181 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Product")),
null,
'errors');
182 $action =
'correction';
184 if (!is_numeric(
GETPOST(
"nbpiece"))) {
186 setEventMessages($langs->trans(
"ErrorFieldMustBeANumeric", $langs->transnoentitiesnoconv(
"NumberOfUnit")),
null,
'errors');
187 $action =
'correction';
191 $origin_element =
'';
194 if (
GETPOST(
'projectid',
'int')) {
195 $origin_element =
'project';
196 $origin_id =
GETPOST(
'projectid',
'int');
199 if ($product->hasbatch()) {
200 $batch =
GETPOST(
'batch_number',
'alpha');
207 $result = $product->correct_stock_batch(
217 GETPOST(
'inventorycode',
'alpha'),
222 $result = $product->correct_stock(
229 GETPOST(
'inventorycode',
'alpha'),
236 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
241 $action =
'correction';
251if ($action ==
"transfert_stock" && !$cancel) {
253 if (!empty($product_id)) {
254 $result = $product->fetch($product_id);
257 if (!(
GETPOST(
"id_entrepot_destination",
'int') > 0)) {
258 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Warehouse")),
null,
'errors');
260 $action =
'transfert';
262 if (empty($product_id)) {
264 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Product")),
null,
'errors');
265 $action =
'transfert';
267 if (!
GETPOST(
"nbpiece",
'int')) {
268 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"NumberOfUnit")),
null,
'errors');
270 $action =
'transfert';
272 if ($id ==
GETPOST(
"id_entrepot_destination",
'int')) {
273 setEventMessages($langs->trans(
"ErrorSrcAndTargetWarehouseMustDiffers"),
null,
'errors');
275 $action =
'transfert';
278 if (isModEnabled(
'productbatch')) {
280 $result = $product->fetch($product_id);
282 if ($product->hasbatch() && !
GETPOST(
"batch_number",
'alpha')) {
283 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"batch_number")),
null,
'errors');
285 $action =
'transfert';
292 $result = $object->fetch($id);
296 $product->load_stock(
'novirtual');
300 if (isset($product->pmp)) {
301 $pricesrc = $product->pmp;
303 $pricedest = $pricesrc;
305 if ($product->hasbatch()) {
309 $result = $pdluo->fetch($pdluoid);
311 $srcwarehouseid = $pdluo->warehouseid;
312 $batch = $pdluo->batch;
313 $eatby = $pdluo->eatby;
314 $sellby = $pdluo->sellby;
320 $srcwarehouseid = $id;
321 $batch =
GETPOST(
'batch_number',
'alpha');
328 $result1 = $product->correct_stock_batch(
338 GETPOST(
'inventorycode',
'alpha')
341 $result2 = $product->correct_stock_batch(
343 GETPOST(
"id_entrepot_destination",
'int'),
351 GETPOST(
'inventorycode',
'alpha')
356 $result1 = $product->correct_stock(
363 GETPOST(
'inventorycode',
'alpha')
367 $result2 = $product->correct_stock(
369 GETPOST(
"id_entrepot_destination"),
374 GETPOST(
'inventorycode',
'alpha')
377 if (!$error && $result1 >= 0 && $result2 >= 0) {
381 header(
"Location: ".$backtopage);
384 header(
"Location: movement_list.php?id=".$object->id);
390 $action =
'transfert';
402$upload_dir = $conf->stock->dir_output.
"movement/";
403$permissiontoadd = $user->rights->stock->creer;
404include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
407if (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';
423$productstatic =
new Product($db);
424$warehousestatic =
new Entrepot($db);
426$userstatic =
new User($db);
427$form =
new Form($db);
430if (isModEnabled(
'project')) {
434$sql =
"SELECT p.rowid, p.ref as product_ref, p.label as produit, p.tobatch, p.fk_product_type as type, p.entity,";
435$sql .=
" e.ref as warehouse_ref, e.rowid as entrepot_id, e.lieu,";
436$sql .=
" m.rowid as mid, m.value as qty, m.datem, m.fk_user_author, m.label, m.inventorycode, m.fk_origin, m.origintype,";
437$sql .=
" m.batch, m.price,";
438$sql .=
" m.type_mouvement,";
439$sql .=
" pl.rowid as lotid, pl.eatby, pl.sellby,";
440$sql .=
" u.login, u.photo, u.lastname, u.firstname";
442if (!empty($extrafields->attributes[$object->table_element][
'label'])) {
443 foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $val) {
444 $sql .= ($extrafields->attributes[$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
448$parameters = array();
449$reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters);
450$sql .= $hookmanager->resPrint;
451$sql .=
" FROM ".MAIN_DB_PREFIX.
"entrepot as e,";
452$sql .=
" ".MAIN_DB_PREFIX.
"product as p,";
453$sql .=
" ".MAIN_DB_PREFIX.
"stock_mouvement as m";
454if (isset($extrafields->attributes[$object->table_element][
'label']) && is_array($extrafields->attributes[$object->table_element][
'label']) && count($extrafields->attributes[$object->table_element][
'label'])) {
455 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element.
"_extrafields as ef on (m.rowid = ef.fk_object)";
457$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u ON m.fk_user_author = u.rowid";
458$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product_lot as pl ON m.batch = pl.batch AND m.fk_product = pl.fk_product";
459$sql .=
" WHERE m.fk_product = p.rowid";
461 $sql .=
" AND m.rowid = ".((int) $msid);
463$sql .=
" AND m.fk_entrepot = e.rowid";
464$sql .=
" AND e.entity IN (".getEntity(
'stock').
")";
466 $sql .=
" AND p.fk_product_type = 0";
469 $sql .=
" AND e.rowid = ".((int) $id);
473 $sql .=
" AND p.rowid = ".((int) $idproduct);
475if (!empty($search_ref)) {
478if (!empty($search_movement)) {
481if (!empty($search_inventorycode)) {
484if (!empty($search_product_ref)) {
487if (!empty($search_product)) {
490if ($search_warehouse !=
'' && $search_warehouse !=
'-1') {
493if (!empty($search_user)) {
494 $sql .=
natural_search(array(
'u.lastname',
'u.firstname',
'u.login'), $search_user);
496if (!empty($search_batch)) {
499if ($search_qty !=
'') {
502if ($search_type_mouvement !=
'' && $search_type_mouvement !=
'-1') {
503 $sql .=
natural_search(
'm.type_mouvement', $search_type_mouvement, 2);
506include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
508$parameters = array();
509$reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters);
510$sql .= $hookmanager->resPrint;
511$sql .= $db->order($sortfield, $sortorder);
513$nbtotalofrecords =
'';
515 $result = $db->query($sql);
516 $nbtotalofrecords = $db->num_rows($result);
517 if (($page * $limit) > $nbtotalofrecords) {
525$resql = $db->query($sql);
531 if ($idproduct > 0) {
532 $product->fetch($idproduct);
534 if ($id > 0 || $ref) {
535 $result = $object->fetch($id, $ref);
541 $num = $db->num_rows($resql);
543 $arrayofselected = is_array($toselect) ? $toselect : array();
547 $help_url =
'EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks';
549 $texte = $langs->trans(
'StockMovementForId', $msid);
551 $texte = $langs->trans(
"ListOfStockMovements");
553 $texte .=
' ('.$langs->trans(
"ForThisWarehouse").
')';
561 if ($object->id > 0) {
564 print
dol_get_fiche_head($head,
'movements', $langs->trans(
"Warehouse"), -1,
'stock');
567 $linkback =
'<a href="'.DOL_URL_ROOT.
'/product/stock/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
569 $morehtmlref =
'<div class="refidno">';
570 $morehtmlref .= $langs->trans(
"LocationSummary").
' : '.$object->lieu;
571 $morehtmlref .=
'</div>';
574 if ($user->socid && !in_array(
'stock', explode(
',',
getDolGlobalString(
'MAIN_MODULES_FOR_EXTERNAL')))) {
578 dol_banner_tab($object,
'ref', $linkback, $shownav,
'ref',
'ref', $morehtmlref);
581 print
'<div class="fichecenter">';
582 print
'<div class="fichehalfleft">';
583 print
'<div class="underbanner clearboth"></div>';
585 print
'<table class="border centpercent">';
590 print
'<td class="titlefield tdtop">'.$langs->trans(
"Description").
'</td><td>'.
dol_htmlentitiesbr($object->description).
'</td></tr>';
592 $calcproductsunique = $object->nb_different_products();
593 $calcproducts = $object->nb_products();
596 print
'<tr><td>'.$langs->trans(
"NumberOfDifferentProducts").
'</td><td>';
597 print empty($calcproductsunique[
'nb']) ?
'0' : $calcproductsunique[
'nb'];
601 print
'<tr><td>'.$langs->trans(
"NumberOfProducts").
'</td><td>';
602 $valtoshow =
price2num($calcproducts[
'nb'],
'MS');
603 print empty($valtoshow) ?
'0' : $valtoshow;
609 print
'<div class="fichehalfright">';
610 print
'<div class="underbanner clearboth"></div>';
612 print
'<table class="border centpercent">';
615 print
'<tr><td class="titlefield">'.$langs->trans(
"EstimatedStockValueShort").
'</td><td>';
616 print
price((empty($calcproducts[
'value']) ?
'0' :
price2num($calcproducts[
'value'],
'MT')), 0, $langs, 0, -1, -1, $conf->currency);
620 $sql =
"SELECT MAX(m.datem) as datem";
621 $sql .=
" FROM ".MAIN_DB_PREFIX.
"stock_mouvement as m";
622 $sql .=
" WHERE m.fk_entrepot = ".(int) $object->id;
623 $resqlbis = $db->query($sql);
625 $obj = $db->fetch_object($resqlbis);
626 $lastmovementdate = $db->jdate($obj->datem);
631 print
'<tr><td>'.$langs->trans(
"LastMovement").
'</td><td>';
632 if ($lastmovementdate) {
635 print $langs->trans(
"None");
644 print
'<div class="clearboth"></div>';
653 if ($action ==
"correction") {
654 include DOL_DOCUMENT_ROOT.
'/product/stock/tpl/stockcorrection.tpl.php';
661 if ($action ==
"transfert") {
662 include DOL_DOCUMENT_ROOT.
'/product/stock/tpl/stocktransfer.tpl.php';
670 if ((empty($action) || $action ==
'list') && $id > 0) {
671 print
"<div class=\"tabsAction\">\n";
673 if ($user->hasRight(
'stock',
'mouvement',
'creer')) {
674 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$id.
'&action=correction">'.$langs->trans(
"CorrectStock").
'</a>';
677 if ($user->hasRight(
'stock',
'mouvement',
'creer')) {
678 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$id.
'&action=transfert">'.$langs->trans(
"TransferStock").
'</a>';
685 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
686 $param .=
'&contextpage='.urlencode($contextpage);
688 if ($limit > 0 && $limit != $conf->liste_limit) {
689 $param .=
'&limit='.((int) $limit);
692 $param .=
'&id='.urlencode($id);
694 if ($search_movement) {
695 $param .=
'&search_movement='.urlencode($search_movement);
697 if ($search_inventorycode) {
698 $param .=
'&search_inventorycode='.urlencode($search_inventorycode);
700 if ($search_type_mouvement) {
701 $param .=
'&search_type_mouvement='.urlencode($search_type_mouvement);
703 if ($search_product_ref) {
704 $param .=
'&search_product_ref='.urlencode($search_product_ref);
706 if ($search_product) {
707 $param .=
'&search_product='.urlencode($search_product);
710 $param .=
'&search_batch='.urlencode($search_batch);
712 if ($search_warehouse > 0) {
713 $param .=
'&search_warehouse='.urlencode($search_warehouse);
716 $param .=
'&search_user='.urlencode($search_user);
718 if ($idproduct > 0) {
719 $param .=
'&idproduct='.urlencode($idproduct);
722 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
725 $arrayofmassactions = array(
730 if (in_array($massaction, array(
'presend',
'predelete'))) {
731 $arrayofmassactions = array();
733 $massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
735 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
736 if ($optioncss !=
'') {
737 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
739 print
'<input type="hidden" name="token" value="'.newToken().
'">';
740 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
741 print
'<input type="hidden" name="action" value="list">';
742 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
743 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
744 print
'<input type="hidden" name="page" value="'.$page.
'">';
745 print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
747 print
'<input type="hidden" name="id" value="'.$id.
'">';
751 print_barre_liste($texte, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'', 0,
'',
'', $limit);
753 print_barre_liste($texte, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'generic', 0,
'',
'', $limit);
757 foreach ($fieldstosearchall as $key => $val) {
758 $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)) {
768 $moreforfilter .= $hookmanager->resPrint;
770 $moreforfilter = $hookmanager->resPrint;
773 if (!empty($moreforfilter)) {
774 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
775 print $moreforfilter;
779 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
780 $selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage);
782 print
'<div class="div-table-responsive">';
783 print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
786 print
'<tr class="liste_titre_filter">';
787 if (!empty($arrayfields[
'm.rowid'][
'checked'])) {
789 print
'<td class="liste_titre left">';
790 print
'<input class="flat maxwidth25" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).
'">';
793 if (!empty($arrayfields[
'm.datem'][
'checked'])) {
794 print
'<td class="liste_titre nowraponall">';
795 print
'<input class="flat" type="text" size="2" maxlength="2" placeholder="'.dol_escape_htmltag($langs->trans(
"Month")).
'" name="month" value="'.$month.
'">';
796 if (empty($conf->productbatch->enabled)) {
800 $syear = $year ? $year : -1;
801 print
'<input class="flat maxwidth50" type="text" maxlength="4" placeholder="'.dol_escape_htmltag($langs->trans(
"Year")).
'" name="year" value="'.($syear > 0 ? $syear :
'').
'">';
805 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'])) {
813 print
'<td class="liste_titre left">';
814 print
'<input class="flat maxwidth100" type="text" name="search_product" value="'.dol_escape_htmltag($idproduct ? $product->label : $search_product).
'">';
818 if (!empty($arrayfields[
'm.batch'][
'checked'])) {
819 print
'<td class="liste_titre center"><input class="flat maxwidth75" type="text" name="search_batch" value="'.dol_escape_htmltag($search_batch).
'"></td>';
821 if (!empty($arrayfields[
'pl.eatby'][
'checked'])) {
822 print
'<td class="liste_titre left">';
825 if (!empty($arrayfields[
'pl.sellby'][
'checked'])) {
826 print
'<td class="liste_titre left">';
830 if (!empty($arrayfields[
'e.ref'][
'checked'])) {
831 print
'<td class="liste_titre maxwidthonsmartphone left">';
833 print $formproduct->selectWarehouses($search_warehouse,
'search_warehouse',
'warehouseopen,warehouseinternal', 1, 0, 0,
'', 0, 0,
null,
'maxwidth200');
836 if (!empty($arrayfields[
'm.fk_user_author'][
'checked'])) {
838 print
'<td class="liste_titre left">';
839 print
'<input class="flat" type="text" size="6" name="search_user" value="'.dol_escape_htmltag($search_user).
'">';
842 if (!empty($arrayfields[
'm.inventorycode'][
'checked'])) {
844 print
'<td class="liste_titre left">';
845 print
'<input class="flat" type="text" size="4" name="search_inventorycode" value="'.dol_escape_htmltag($search_inventorycode).
'">';
848 if (!empty($arrayfields[
'm.label'][
'checked'])) {
850 print
'<td class="liste_titre left">';
851 print
'<input class="flat" type="text" size="8" name="search_movement" value="'.dol_escape_htmltag($search_movement).
'">';
854 if (!empty($arrayfields[
'm.type_mouvement'][
'checked'])) {
856 print
'<td class="liste_titre center">';
858 print
'<select id="search_type_mouvement" name="search_type_mouvement" class="maxwidth150">';
859 print
'<option value="" '.(($search_type_mouvement ==
"") ?
'selected="selected"' :
'').
'></option>';
860 print
'<option value="0" '.(($search_type_mouvement ==
"0") ?
'selected="selected"' :
'').
'>'.$langs->trans(
'StockIncreaseAfterCorrectTransfer').
'</option>';
861 print
'<option value="1" '.(($search_type_mouvement ==
"1") ?
'selected="selected"' :
'').
'>'.$langs->trans(
'StockDecreaseAfterCorrectTransfer').
'</option>';
862 print
'<option value="2" '.(($search_type_mouvement ==
"2") ?
'selected="selected"' :
'').
'>'.$langs->trans(
'StockDecrease').
'</option>';
863 print
'<option value="3" '.(($search_type_mouvement ==
"3") ?
'selected="selected"' :
'').
'>'.$langs->trans(
'StockIncrease').
'</option>';
870 if (!empty($arrayfields[
'origin'][
'checked'])) {
872 print
'<td class="liste_titre left">';
876 if (!empty($arrayfields[
'm.value'][
'checked'])) {
878 print
'<td class="liste_titre right">';
879 print
'<input class="flat" type="text" size="4" name="search_qty" value="'.dol_escape_htmltag($search_qty).
'">';
882 if (!empty($arrayfields[
'm.price'][
'checked'])) {
884 print
'<td class="liste_titre left">';
891 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
894 $parameters = array(
'arrayfields'=>$arrayfields);
895 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters);
896 print $hookmanager->resPrint;
898 if (!empty($arrayfields[
'm.datec'][
'checked'])) {
899 print
'<td class="liste_titre">';
903 if (!empty($arrayfields[
'm.tms'][
'checked'])) {
904 print
'<td class="liste_titre">';
908 print
'<td class="liste_titre maxwidthsearch">';
909 $searchpicto = $form->showFilterAndCheckAddButtons(0);
914 print
'<tr class="liste_titre">';
915 if (!empty($arrayfields[
'm.rowid'][
'checked'])) {
916 print_liste_field_titre($arrayfields[
'm.rowid'][
'label'], $_SERVER[
"PHP_SELF"],
'm.rowid',
'', $param,
'', $sortfield, $sortorder);
918 if (!empty($arrayfields[
'm.datem'][
'checked'])) {
919 print_liste_field_titre($arrayfields[
'm.datem'][
'label'], $_SERVER[
"PHP_SELF"],
'm.datem',
'', $param,
'', $sortfield, $sortorder);
921 if (!empty($arrayfields[
'p.ref'][
'checked'])) {
922 print_liste_field_titre($arrayfields[
'p.ref'][
'label'], $_SERVER[
"PHP_SELF"],
'p.ref',
'', $param,
'', $sortfield, $sortorder);
924 if (!empty($arrayfields[
'p.label'][
'checked'])) {
925 print_liste_field_titre($arrayfields[
'p.label'][
'label'], $_SERVER[
"PHP_SELF"],
'p.label',
'', $param,
'', $sortfield, $sortorder);
927 if (!empty($arrayfields[
'm.batch'][
'checked'])) {
928 print_liste_field_titre($arrayfields[
'm.batch'][
'label'], $_SERVER[
"PHP_SELF"],
'm.batch',
'', $param,
'', $sortfield, $sortorder,
'center ');
930 if (!empty($arrayfields[
'pl.eatby'][
'checked'])) {
931 print_liste_field_titre($arrayfields[
'pl.eatby'][
'label'], $_SERVER[
"PHP_SELF"],
'pl.eatby',
'', $param,
'', $sortfield, $sortorder,
'center ');
933 if (!empty($arrayfields[
'pl.sellby'][
'checked'])) {
934 print_liste_field_titre($arrayfields[
'pl.sellby'][
'label'], $_SERVER[
"PHP_SELF"],
'pl.sellby',
'', $param,
'', $sortfield, $sortorder,
'center ');
936 if (!empty($arrayfields[
'e.ref'][
'checked'])) {
938 print_liste_field_titre($arrayfields[
'e.ref'][
'label'], $_SERVER[
"PHP_SELF"],
"e.ref",
"", $param,
"", $sortfield, $sortorder);
940 if (!empty($arrayfields[
'm.fk_user_author'][
'checked'])) {
941 print_liste_field_titre($arrayfields[
'm.fk_user_author'][
'label'], $_SERVER[
"PHP_SELF"],
"m.fk_user_author",
"", $param,
"", $sortfield, $sortorder);
943 if (!empty($arrayfields[
'm.inventorycode'][
'checked'])) {
944 print_liste_field_titre($arrayfields[
'm.inventorycode'][
'label'], $_SERVER[
"PHP_SELF"],
"m.inventorycode",
"", $param,
"", $sortfield, $sortorder);
946 if (!empty($arrayfields[
'm.label'][
'checked'])) {
947 print_liste_field_titre($arrayfields[
'm.label'][
'label'], $_SERVER[
"PHP_SELF"],
"m.label",
"", $param,
"", $sortfield, $sortorder);
949 if (!empty($arrayfields[
'm.type_mouvement'][
'checked'])) {
950 print_liste_field_titre($arrayfields[
'm.type_mouvement'][
'label'], $_SERVER[
"PHP_SELF"],
"m.type_mouvement",
"", $param,
'', $sortfield, $sortorder,
'center ');
952 if (!empty($arrayfields[
'origin'][
'checked'])) {
953 print_liste_field_titre($arrayfields[
'origin'][
'label'], $_SERVER[
"PHP_SELF"],
"",
"", $param,
"", $sortfield, $sortorder);
955 if (!empty($arrayfields[
'm.value'][
'checked'])) {
956 print_liste_field_titre($arrayfields[
'm.value'][
'label'], $_SERVER[
"PHP_SELF"],
"m.value",
"", $param,
'', $sortfield, $sortorder,
'right ');
958 if (!empty($arrayfields[
'm.price'][
'checked'])) {
959 print_liste_field_titre($arrayfields[
'm.price'][
'label'], $_SERVER[
"PHP_SELF"],
"m.price",
"", $param,
'', $sortfield, $sortorder,
'right ');
963 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
966 $parameters = array(
'arrayfields'=>$arrayfields,
'param'=>$param,
'sortfield'=>$sortfield,
'sortorder'=>$sortorder);
967 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters);
968 print $hookmanager->resPrint;
969 if (!empty($arrayfields[
'm.datec'][
'checked'])) {
970 print_liste_field_titre($arrayfields[
'p.datec'][
'label'], $_SERVER[
"PHP_SELF"],
"p.datec",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
972 if (!empty($arrayfields[
'm.tms'][
'checked'])) {
973 print_liste_field_titre($arrayfields[
'p.tms'][
'label'], $_SERVER[
"PHP_SELF"],
"p.tms",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
975 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
979 $arrayofuniqueproduct = array();
980 while ($i < ($limit ? min($num, $limit) : $num)) {
981 $objp = $db->fetch_object($resql);
983 $userstatic->id = $objp->fk_user_author;
984 $userstatic->login = $objp->login;
985 $userstatic->lastname = $objp->lastname;
986 $userstatic->firstname = $objp->firstname;
987 $userstatic->photo = $objp->photo;
989 $productstatic->id = $objp->rowid;
990 $productstatic->ref = $objp->product_ref;
991 $productstatic->label = $objp->produit;
992 $productstatic->type = $objp->type;
993 $productstatic->entity = $objp->entity;
994 $productstatic->status_batch = $objp->tobatch;
996 $productlot->id = $objp->lotid;
997 $productlot->batch = $objp->batch;
998 $productlot->eatby = $objp->eatby;
999 $productlot->sellby = $objp->sellby;
1001 $warehousestatic->id = $objp->entrepot_id;
1002 $warehousestatic->label = $objp->warehouse_ref;
1003 $warehousestatic->lieu = $objp->lieu;
1005 $arrayofuniqueproduct[$objp->rowid] = $objp->produit;
1006 if (!empty($objp->fk_origin)) {
1007 $origin = $movement->get_origin($objp->fk_origin, $objp->origintype);
1012 print
'<tr class="oddeven">';
1014 if (!empty($arrayfields[
'm.rowid'][
'checked'])) {
1016 print
'<td>'.$objp->mid.
'</td>';
1018 if (!empty($arrayfields[
'm.datem'][
'checked'])) {
1020 print
'<td>'.dol_print_date($db->jdate($objp->datem),
'dayhour').
'</td>';
1022 if (!empty($arrayfields[
'p.ref'][
'checked'])) {
1024 print
'<td class="nowraponall">';
1025 print $productstatic->getNomUrl(1,
'stock', 16);
1028 if (!empty($arrayfields[
'p.label'][
'checked'])) {
1035 print $productstatic->label;
1038 if (!empty($arrayfields[
'm.batch'][
'checked'])) {
1039 print
'<td class="center nowraponall">';
1040 if ($productlot->id > 0) {
1041 print $productlot->getNomUrl(1);
1043 print $productlot->batch;
1047 if (!empty($arrayfields[
'pl.eatby'][
'checked'])) {
1048 print
'<td class="center">'.dol_print_date($objp->eatby,
'day').
'</td>';
1050 if (!empty($arrayfields[
'pl.sellby'][
'checked'])) {
1051 print
'<td class="center">'.dol_print_date($objp->sellby,
'day').
'</td>';
1054 if (!empty($arrayfields[
'e.ref'][
'checked'])) {
1056 print $warehousestatic->getNomUrl(1);
1060 if (!empty($arrayfields[
'm.fk_user_author'][
'checked'])) {
1061 print
'<td class="tdoverflowmax100">';
1062 print $userstatic->getNomUrl(-1);
1065 if (!empty($arrayfields[
'm.inventorycode'][
'checked'])) {
1067 print
'<td><a href="'
1068 .DOL_URL_ROOT.
'/product/stock/movement_card.php?id='.urlencode($objp->entrepot_id)
1069 .
'&search_inventorycode='.urlencode($objp->inventorycode)
1070 .
'&search_type_mouvement='.urlencode($objp->type_mouvement)
1072 .$objp->inventorycode
1075 if (!empty($arrayfields[
'm.label'][
'checked'])) {
1077 print
'<td class="tdoverflowmax100aaa">'.$objp->label.
'</td>';
1079 if (!empty($arrayfields[
'm.type_mouvement'][
'checked'])) {
1081 switch ($objp->type_mouvement) {
1083 print
'<td class="center">'.$langs->trans(
'StockIncreaseAfterCorrectTransfer').
'</td>';
1086 print
'<td class="center">'.$langs->trans(
'StockDecreaseAfterCorrectTransfer').
'</td>';
1089 print
'<td class="center">'.$langs->trans(
'StockDecrease').
'</td>';
1092 print
'<td class="center">'.$langs->trans(
'StockIncrease').
'</td>';
1096 if (!empty($arrayfields[
'origin'][
'checked'])) {
1098 print
'<td class="nowraponall">'.$origin.
'</td>';
1100 if (!empty($arrayfields[
'm.value'][
'checked'])) {
1102 print
'<td class="right">';
1103 if ($objp->qt > 0) {
1109 if (!empty($arrayfields[
'm.price'][
'checked'])) {
1111 print
'<td class="right">';
1112 if ($objp->price != 0) {
1113 print
price($objp->price);
1118 print
'<td class="nowrap center">';
1119 if ($massactionbutton || $massaction) {
1121 if (in_array($obj->rowid, $arrayofselected)) {
1124 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
1128 $totalarray[
'nbfield']++;
1141 if (count($arrayofuniqueproduct) == 1 && is_numeric($year)) {
1144 $productidselected = 0;
1145 foreach ($arrayofuniqueproduct as $key => $val) {
1146 $productidselected = $key;
1147 $productlabelselected = $val;
1149 $datebefore =
dol_get_first_day($year ? $year : strftime(
"%Y", time()), $month ? $month : 1, true);
1150 $dateafter =
dol_get_last_day($year ? $year : strftime(
"%Y", time()), $month ? $month : 12, true);
1151 $balancebefore = $movement->calculateBalanceForProductBefore($productidselected, $datebefore);
1152 $balanceafter = $movement->calculateBalanceForProductBefore($productidselected, $dateafter);
1155 print $langs->trans(
"NbOfProductBeforePeriod", $productlabelselected,
dol_print_date($datebefore,
'day',
'gmt'));
1158 print
': '.$balancebefore;
1162 print $langs->trans(
"NbOfProductAfterPeriod", $productlabelselected,
dol_print_date($dateafter,
'day',
'gmt'));
1165 print
': '.$balanceafter;
1179$modulepart =
'movement';
1181if ($action !=
'create' && $action !=
'edit' && $action !=
'delete' && $id > 0) {
1183 print
'<div class="fichecenter"><div class="fichehalfleft">';
1184 print
'<a name="builddoc"></a>';
1189 if (!empty($search_inventorycode)) {
1190 $objectref .=
"_".$id.
"_".$search_inventorycode;
1192 if ($search_type_mouvement) {
1193 $objectref .=
"_".$search_type_mouvement;
1195 $relativepath = $comref.
'/'.$objectref.
'.pdf';
1196 $filedir = $conf->stock->dir_output.
'/movement/'.$objectref;
1198 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".$object->id.
"&search_inventorycode=".$search_inventorycode.
"&search_type_mouvement=$search_type_mouvement";
1199 $genallowed = $usercanread;
1200 $delallowed = $usercancreate;
1202 $genallowed = $user->rights->stock->lire;
1203 $delallowed = $user->rights->stock->creer;
1205 print $formfile->showdocuments($modulepart, $objectref, $filedir, $urlsource, $genallowed, $delallowed,
'', 0, 0, 0, 28, 0,
'', 0,
'', $object->default_lang,
'', $object);
1206 $somethingshown = $formfile->numoffiles;
1208 print
'</div><div class="fichehalfright">';
1212 $morehtmlcenter =
dolGetButtonTitle($langs->trans(
'SeeAll'),
'',
'fa fa-bars imgforviewmode', DOL_URL_ROOT.
'/product/agenda.php?id='.$object->id);
1215 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
1217 $somethingshown =
$formactions->showactions($object,
'mouvement', 0, 1,
'', $MAXEVENT,
'', $morehtmlcenter);
1219 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 a 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...
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
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.