31require
'../../main.inc.php';
32require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
33require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
34require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/entrepot.class.php';
35require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/mouvementstock.class.php';
36require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/productlot.class.php';
37require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
38require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
39require_once DOL_DOCUMENT_ROOT.
'/core/lib/stock.lib.php';
40require_once DOL_DOCUMENT_ROOT.
'/core/lib/product.lib.php';
41require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
42if (isModEnabled(
'project')) {
43 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
44 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
48$langs->loadLangs(array(
'products',
'stocks',
'orders'));
49if (isModEnabled(
'productbatch')) {
50 $langs->load(
"productbatch");
60$action =
GETPOST(
'action',
'aZ09');
61$cancel =
GETPOST(
'cancel',
'alpha');
62$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'movementlist';
67$search_ref =
GETPOST(
'search_ref',
'alpha');
68$search_movement =
GETPOST(
"search_movement",
'alpha');
69$search_product_ref = trim(
GETPOST(
"search_product_ref",
'alpha'));
70$search_product = trim(
GETPOST(
"search_product",
'alpha'));
71$search_warehouse = trim(
GETPOST(
"search_warehouse",
'alpha'));
72$search_inventorycode = trim(
GETPOST(
"search_inventorycode",
'alpha'));
73$search_user = trim(
GETPOST(
"search_user",
'alpha'));
74$search_batch = trim(
GETPOST(
"search_batch",
'alpha'));
75$search_qty = trim(
GETPOST(
"search_qty",
'alpha'));
76$search_type_mouvement =
GETPOST(
'search_type_mouvement',
"intcomma");
80$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
81$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
82if (empty($page) || $page == -1) {
85$offset = $limit * $page;
87 $sortfield =
"m.datem";
97$hookmanager->initHooks(array(
'movementlist'));
102$extrafields->fetch_name_optionals_label(
$object->table_element);
104$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
107 'm.rowid' => array(
'label' => $langs->trans(
"Ref"),
'checked' => 1),
108 'm.datem' => array(
'label' => $langs->trans(
"Date"),
'checked' => 1),
109 'p.ref' => array(
'label' => $langs->trans(
"ProductRef"),
'checked' => 1,
'css' =>
'maxwidth100'),
110 'p.label' => array(
'label' => $langs->trans(
"ProductLabel"),
'checked' => 1),
111 'm.batch' => array(
'label' => $langs->trans(
"BatchNumberShort"),
'checked' => 1,
'enabled' => (isModEnabled(
'productbatch'))),
112 'pl.eatby' => array(
'label' => $langs->trans(
"EatByDate"),
'checked' => 0,
'position' => 10,
'enabled' => (isModEnabled(
'productbatch'))),
113 'pl.sellby' => array(
'label' => $langs->trans(
"SellByDate"),
'checked' => 0,
'position' => 10,
'enabled' => (isModEnabled(
'productbatch'))),
114 'e.ref' => array(
'label' => $langs->trans(
"Warehouse"),
'checked' => 1,
'enabled' => (!($id > 0))),
115 'm.fk_user_author' => array(
'label' => $langs->trans(
"Author"),
'checked' => 0),
116 'm.inventorycode' => array(
'label' => $langs->trans(
"InventoryCodeShort"),
'checked' => 1),
117 'm.label' => array(
'label' => $langs->trans(
"MovementLabel"),
'checked' => 1),
118 'm.type_mouvement' => array(
'label' => $langs->trans(
"TypeMovement"),
'checked' => 1),
119 'origin' => array(
'label' => $langs->trans(
"Origin"),
'checked' => 1),
120 'm.value' => array(
'label' => $langs->trans(
"Qty"),
'checked' => 1),
121 'm.price' => array(
'label' => $langs->trans(
"UnitPurchaseValue"),
'checked' => 0),
126$usercanread = (($user->hasRight(
'stock',
'mouvement',
'lire')));
127$usercancreate = (($user->hasRight(
'stock',
'mouvement',
'creer')));
128$usercandelete = (($user->hasRight(
'stock',
'mouvement',
'supprimer')));
136if (
GETPOST(
'cancel',
'alpha')) {
140if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
144$parameters = array();
145$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
150include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
153if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
157 $search_movement =
"";
158 $search_type_mouvement =
"";
159 $search_inventorycode =
"";
160 $search_product_ref =
"";
161 $search_product =
"";
162 $search_warehouse =
"";
168 $search_array_options = array();
172if ($action ==
"correct_stock" && !$cancel && $usercancreate) {
174 if (!empty($product_id)) {
175 $result = $product->fetch($product_id);
180 if (empty($product_id)) {
182 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Product")),
null,
'errors');
183 $action =
'correction';
185 if (!is_numeric(
GETPOST(
"nbpiece"))) {
187 setEventMessages($langs->trans(
"ErrorFieldMustBeANumeric", $langs->transnoentitiesnoconv(
"NumberOfUnit")),
null,
'errors');
188 $action =
'correction';
192 $origin_element =
'';
196 $origin_element =
'project';
200 if ($product->hasbatch()) {
201 $batch =
GETPOST(
'batch_number',
'alpha');
208 $result = $product->correct_stock_batch(
218 GETPOST(
'inventorycode',
'alpha'),
223 $result = $product->correct_stock(
230 GETPOST(
'inventorycode',
'alpha'),
237 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
242 $action =
'correction';
252if ($action ==
"transfert_stock" && !$cancel && $usercancreate) {
255 if (!empty($product_id)) {
256 $result = $product->fetch($product_id);
259 if (!(
GETPOSTINT(
"id_entrepot_destination") > 0)) {
260 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Warehouse")),
null,
'errors');
262 $action =
'transfert';
264 if (empty($product_id)) {
266 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Product")),
null,
'errors');
267 $action =
'transfert';
270 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"NumberOfUnit")),
null,
'errors');
272 $action =
'transfert';
274 if ($id ==
GETPOSTINT(
"id_entrepot_destination")) {
275 setEventMessages($langs->trans(
"ErrorSrcAndTargetWarehouseMustDiffers"),
null,
'errors');
277 $action =
'transfert';
280 if (isModEnabled(
'productbatch')) {
282 $result = $product->fetch($product_id);
284 if ($product->hasbatch() && !
GETPOST(
"batch_number",
'alpha')) {
285 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"batch_number")),
null,
'errors');
287 $action =
'transfert';
298 $product->load_stock(
'novirtual');
302 if (isset($product->pmp)) {
303 $pricesrc = $product->pmp;
305 $pricedest = $pricesrc;
307 if ($product->hasbatch()) {
311 $result = $pdluo->fetch($pdluoid);
313 $srcwarehouseid = $pdluo->warehouseid;
314 $batch = $pdluo->batch;
315 $eatby = $pdluo->eatby;
316 $sellby = $pdluo->sellby;
322 $srcwarehouseid = $id;
323 $batch =
GETPOST(
'batch_number',
'alpha');
330 $result1 = $product->correct_stock_batch(
340 GETPOST(
'inventorycode',
'alpha')
343 $result2 = $product->correct_stock_batch(
353 GETPOST(
'inventorycode',
'alpha')
358 $result1 = $product->correct_stock(
365 GETPOST(
'inventorycode',
'alpha')
369 $result2 = $product->correct_stock(
371 GETPOST(
"id_entrepot_destination"),
376 GETPOST(
'inventorycode',
'alpha')
379 if (!$error && $result1 >= 0 && $result2 >= 0) {
383 header(
"Location: ".$backtopage);
386 header(
"Location: movement_list.php?id=".
$object->id);
392 $action =
'transfert';
404$upload_dir = $conf->stock->dir_output.
"movement/";
405$permissiontoadd = $user->hasRight(
'stock',
'creer');
406include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
409if (empty($reshook) && $action !=
'remove_file') {
410 $objectclass =
'MouvementStock';
411 $objectlabel =
'Movements';
412 $permissiontoread = $user->hasRight(
'stock',
'lire');
413 $permissiontodelete = $user->hasRight(
'stock',
'supprimer');
414 $uploaddir = $conf->stock->dir_output.
"/movement/";
415 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
425$productstatic =
new Product($db);
426$warehousestatic =
new Entrepot($db);
428$userstatic =
new User($db);
429$form =
new Form($db);
432if (isModEnabled(
'project')) {
436$sql =
"SELECT p.rowid, p.ref as product_ref, p.label as produit, p.tobatch, p.fk_product_type as type, p.entity,";
437$sql .=
" e.ref as warehouse_ref, e.rowid as entrepot_id, e.lieu,";
438$sql .=
" m.rowid as mid, m.value as qty, m.datem, m.fk_user_author, m.label, m.inventorycode, m.fk_origin, m.origintype,";
439$sql .=
" m.batch, m.price,";
440$sql .=
" m.type_mouvement,";
441$sql .=
" pl.rowid as lotid, pl.eatby, pl.sellby,";
442$sql .=
" u.login, u.photo, u.lastname, u.firstname";
444if (!empty($extrafields->attributes[
$object->table_element][
'label'])) {
445 foreach ($extrafields->attributes[
$object->table_element][
'label'] as $key => $val) {
446 $sql .= ($extrafields->attributes[
$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
450$parameters = array();
451$reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters);
452$sql .= $hookmanager->resPrint;
453$sql .=
" FROM ".MAIN_DB_PREFIX.
"entrepot as e,";
454$sql .=
" ".MAIN_DB_PREFIX.
"product as p,";
455$sql .=
" ".MAIN_DB_PREFIX.
"stock_mouvement as m";
456if (isset($extrafields->attributes[
$object->table_element][
'label']) && is_array($extrafields->attributes[
$object->table_element][
'label']) && count($extrafields->attributes[
$object->table_element][
'label'])) {
457 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element.
"_extrafields as ef on (m.rowid = ef.fk_object)";
459$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u ON m.fk_user_author = u.rowid";
460$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product_lot as pl ON m.batch = pl.batch AND m.fk_product = pl.fk_product";
461$sql .=
" WHERE m.fk_product = p.rowid";
463 $sql .=
" AND m.rowid = ".((int) $msid);
465$sql .=
" AND m.fk_entrepot = e.rowid";
466$sql .=
" AND e.entity IN (".getEntity(
'stock').
")";
468 $sql .=
" AND p.fk_product_type = 0";
471 $sql .=
" AND e.rowid = ".((int) $id);
475 $sql .=
" AND p.rowid = ".((int) $idproduct);
477if (!empty($search_ref)) {
480if (!empty($search_movement)) {
483if (!empty($search_inventorycode)) {
486if (!empty($search_product_ref)) {
489if (!empty($search_product)) {
492if ($search_warehouse !=
'' && $search_warehouse !=
'-1') {
495if (!empty($search_user)) {
496 $sql .=
natural_search(array(
'u.lastname',
'u.firstname',
'u.login'), $search_user);
498if (!empty($search_batch)) {
501if ($search_qty !=
'') {
504if ($search_type_mouvement !=
'' && $search_type_mouvement !=
'-1') {
505 $sql .=
natural_search(
'm.type_mouvement', $search_type_mouvement, 2);
508include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
510$parameters = array();
511$reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters);
512$sql .= $hookmanager->resPrint;
513$sql .= $db->order($sortfield, $sortorder);
515$nbtotalofrecords =
'';
517 $result = $db->query($sql);
518 $nbtotalofrecords = $db->num_rows($result);
519 if (($page * $limit) > $nbtotalofrecords) {
527$resql = $db->query($sql);
533 if ($idproduct > 0) {
534 $product->fetch($idproduct);
536 if ($id > 0 || $ref) {
537 $result =
$object->fetch($id, $ref);
543 $num = $db->num_rows($resql);
545 $arrayofselected = is_array($toselect) ? $toselect : array();
549 $help_url =
'EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks';
551 $texte = $langs->trans(
'StockMovementForId', $msid);
553 $texte = $langs->trans(
"ListOfStockMovements");
555 $texte .=
' ('.$langs->trans(
"ForThisWarehouse").
')';
558 llxHeader(
"", $texte, $help_url,
'', 0, 0,
'',
'',
'',
'mod-product page-stock_movement_card');
566 print
dol_get_fiche_head($head,
'movements', $langs->trans(
"Warehouse"), -1,
'stock');
569 $linkback =
'<a href="'.DOL_URL_ROOT.
'/product/stock/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
571 $morehtmlref =
'<div class="refidno">';
572 $morehtmlref .= $langs->trans(
"LocationSummary").
' : '.
$object->lieu;
573 $morehtmlref .=
'</div>';
576 if ($user->socid && !in_array(
'stock', explode(
',',
getDolGlobalString(
'MAIN_MODULES_FOR_EXTERNAL')))) {
580 dol_banner_tab($object,
'ref', $linkback, $shownav,
'ref',
'ref', $morehtmlref);
583 print
'<div class="fichecenter">';
584 print
'<div class="fichehalfleft">';
585 print
'<div class="underbanner clearboth"></div>';
587 print
'<table class="border centpercent">';
592 print
'<td class="titlefield tdtop">'.$langs->trans(
"Description").
'</td><td>'.
dol_htmlentitiesbr(
$object->description).
'</td></tr>';
594 $calcproductsunique =
$object->nb_different_products();
595 $calcproducts =
$object->nb_products();
598 print
'<tr><td>'.$langs->trans(
"NumberOfDifferentProducts").
'</td><td>';
599 print empty($calcproductsunique[
'nb']) ?
'0' : $calcproductsunique[
'nb'];
603 print
'<tr><td>'.$langs->trans(
"NumberOfProducts").
'</td><td>';
604 $valtoshow =
price2num($calcproducts[
'nb'],
'MS');
605 print empty($valtoshow) ?
'0' : $valtoshow;
611 print
'<div class="fichehalfright">';
612 print
'<div class="underbanner clearboth"></div>';
614 print
'<table class="border centpercent">';
617 print
'<tr><td class="titlefield">'.$langs->trans(
"EstimatedStockValueShort").
'</td><td>';
618 print
price((empty($calcproducts[
'value']) ?
'0' :
price2num($calcproducts[
'value'],
'MT')), 0, $langs, 0, -1, -1, $conf->currency);
622 $sql =
"SELECT MAX(m.datem) as datem";
623 $sql .=
" FROM ".MAIN_DB_PREFIX.
"stock_mouvement as m";
624 $sql .=
" WHERE m.fk_entrepot = ".(int)
$object->id;
625 $resqlbis = $db->query($sql);
627 $obj = $db->fetch_object($resqlbis);
628 $lastmovementdate = $db->jdate($obj->datem);
633 print
'<tr><td>'.$langs->trans(
"LastMovement").
'</td><td>';
634 if ($lastmovementdate) {
637 print $langs->trans(
"None");
646 print
'<div class="clearboth"></div>';
655 if ($action ==
"correction") {
656 include DOL_DOCUMENT_ROOT.
'/product/stock/tpl/stockcorrection.tpl.php';
663 if ($action ==
"transfert") {
664 include DOL_DOCUMENT_ROOT.
'/product/stock/tpl/stocktransfer.tpl.php';
672 if ((empty($action) || $action ==
'list') && $id > 0) {
673 print
"<div class=\"tabsAction\">\n";
675 if ($user->hasRight(
'stock',
'mouvement',
'creer')) {
676 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$id.
'&action=correction&token='.
newToken().
'">'.$langs->trans(
"CorrectStock").
'</a>';
679 if ($user->hasRight(
'stock',
'mouvement',
'creer')) {
680 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$id.
'&action=transfert&token='.
newToken().
'">'.$langs->trans(
"TransferStock").
'</a>';
687 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
688 $param .=
'&contextpage='.urlencode($contextpage);
690 if ($limit > 0 && $limit != $conf->liste_limit) {
691 $param .=
'&limit='.((int) $limit);
694 $param .=
'&id='.urlencode((
string) ($id));
696 if ($search_movement) {
697 $param .=
'&search_movement='.urlencode($search_movement);
699 if ($search_inventorycode) {
700 $param .=
'&search_inventorycode='.urlencode($search_inventorycode);
702 if ($search_type_mouvement) {
703 $param .=
'&search_type_mouvement='.urlencode($search_type_mouvement);
705 if ($search_product_ref) {
706 $param .=
'&search_product_ref='.urlencode($search_product_ref);
708 if ($search_product) {
709 $param .=
'&search_product='.urlencode($search_product);
712 $param .=
'&search_batch='.urlencode($search_batch);
714 if ($search_warehouse > 0) {
715 $param .=
'&search_warehouse='.urlencode($search_warehouse);
718 $param .=
'&search_user='.urlencode($search_user);
720 if ($idproduct > 0) {
721 $param .=
'&idproduct='.urlencode((
string) ($idproduct));
724 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
727 $arrayofmassactions = array(
732 if (in_array($massaction, array(
'presend',
'predelete'))) {
733 $arrayofmassactions = array();
735 $massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
737 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
738 if ($optioncss !=
'') {
739 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
741 print
'<input type="hidden" name="token" value="'.newToken().
'">';
742 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
743 print
'<input type="hidden" name="action" value="list">';
744 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
745 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
746 print
'<input type="hidden" name="page" value="'.$page.
'">';
747 print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
749 print
'<input type="hidden" name="id" value="'.$id.
'">';
753 print_barre_liste($texte, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'', 0,
'',
'', $limit);
755 print_barre_liste($texte, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'generic', 0,
'',
'', $limit);
759 if (!isset($fieldstosearchall) || !is_array($fieldstosearchall)) {
761 $fieldstosearchall = array();
763 foreach ($fieldstosearchall as $key => $val) {
764 $fieldstosearchall[$key] = $langs->trans($val);
766 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $sall).implode(
', ', $fieldstosearchall).
'</div>';
771 $parameters = array();
772 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters);
773 if (empty($reshook)) {
774 $moreforfilter .= $hookmanager->resPrint;
776 $moreforfilter = $hookmanager->resPrint;
779 if (!empty($moreforfilter)) {
780 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
781 print $moreforfilter;
785 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
786 $selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage);
788 print
'<div class="div-table-responsive">';
789 print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
792 print
'<tr class="liste_titre_filter">';
793 if (!empty($arrayfields[
'm.rowid'][
'checked'])) {
795 print
'<td class="liste_titre left">';
796 print
'<input class="flat maxwidth25" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).
'">';
799 if (!empty($arrayfields[
'm.datem'][
'checked'])) {
800 print
'<td class="liste_titre nowraponall">';
801 print
'<input class="flat" type="text" size="2" maxlength="2" placeholder="'.dol_escape_htmltag($langs->trans(
"Month")).
'" name="month" value="'.$month.
'">';
802 if (empty($conf->productbatch->enabled)) {
806 $syear = $year ? $year : -1;
807 print
'<input class="flat maxwidth50" type="text" maxlength="4" placeholder="'.dol_escape_htmltag($langs->trans(
"Year")).
'" name="year" value="'.($syear > 0 ? $syear :
'').
'">';
811 if (!empty($arrayfields[
'p.ref'][
'checked'])) {
813 print
'<td class="liste_titre left">';
814 print
'<input class="flat maxwidth75" type="text" name="search_product_ref" value="'.dol_escape_htmltag($idproduct ? $product->ref : $search_product_ref).
'">';
817 if (!empty($arrayfields[
'p.label'][
'checked'])) {
819 print
'<td class="liste_titre left">';
820 print
'<input class="flat maxwidth100" type="text" name="search_product" value="'.dol_escape_htmltag($idproduct ? $product->label : $search_product).
'">';
824 if (!empty($arrayfields[
'm.batch'][
'checked'])) {
825 print
'<td class="liste_titre center"><input class="flat maxwidth75" type="text" name="search_batch" value="'.dol_escape_htmltag($search_batch).
'"></td>';
827 if (!empty($arrayfields[
'pl.eatby'][
'checked'])) {
828 print
'<td class="liste_titre left">';
831 if (!empty($arrayfields[
'pl.sellby'][
'checked'])) {
832 print
'<td class="liste_titre left">';
836 if (!empty($arrayfields[
'e.ref'][
'checked'])) {
837 print
'<td class="liste_titre maxwidthonsmartphone left">';
839 print $formproduct->selectWarehouses($search_warehouse,
'search_warehouse',
'warehouseopen,warehouseinternal', 1, 0, 0,
'', 0, 0,
null,
'maxwidth200');
842 if (!empty($arrayfields[
'm.fk_user_author'][
'checked'])) {
844 print
'<td class="liste_titre left">';
845 print
'<input class="flat" type="text" size="6" name="search_user" value="'.dol_escape_htmltag($search_user).
'">';
848 if (!empty($arrayfields[
'm.inventorycode'][
'checked'])) {
850 print
'<td class="liste_titre left">';
851 print
'<input class="flat" type="text" size="4" name="search_inventorycode" value="'.dol_escape_htmltag($search_inventorycode).
'">';
854 if (!empty($arrayfields[
'm.label'][
'checked'])) {
856 print
'<td class="liste_titre left">';
857 print
'<input class="flat" type="text" size="8" name="search_movement" value="'.dol_escape_htmltag($search_movement).
'">';
860 if (!empty($arrayfields[
'm.type_mouvement'][
'checked'])) {
862 print
'<td class="liste_titre center">';
864 print
'<select id="search_type_mouvement" name="search_type_mouvement" class="maxwidth150">';
865 print
'<option value="" '.(($search_type_mouvement ==
"") ?
'selected="selected"' :
'').
'></option>';
866 print
'<option value="0" '.(($search_type_mouvement ==
"0") ?
'selected="selected"' :
'').
'>'.$langs->trans(
'StockIncreaseAfterCorrectTransfer').
'</option>';
867 print
'<option value="1" '.(($search_type_mouvement ==
"1") ?
'selected="selected"' :
'').
'>'.$langs->trans(
'StockDecreaseAfterCorrectTransfer').
'</option>';
868 print
'<option value="2" '.(($search_type_mouvement ==
"2") ?
'selected="selected"' :
'').
'>'.$langs->trans(
'StockDecrease').
'</option>';
869 print
'<option value="3" '.(($search_type_mouvement ==
"3") ?
'selected="selected"' :
'').
'>'.$langs->trans(
'StockIncrease').
'</option>';
876 if (!empty($arrayfields[
'origin'][
'checked'])) {
878 print
'<td class="liste_titre left">';
882 if (!empty($arrayfields[
'm.value'][
'checked'])) {
884 print
'<td class="liste_titre right">';
885 print
'<input class="flat" type="text" size="4" name="search_qty" value="'.dol_escape_htmltag($search_qty).
'">';
888 if (!empty($arrayfields[
'm.price'][
'checked'])) {
890 print
'<td class="liste_titre left">';
897 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
900 $parameters = array(
'arrayfields' => $arrayfields);
901 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters);
902 print $hookmanager->resPrint;
904 if (!empty($arrayfields[
'm.datec'][
'checked'])) {
905 print
'<td class="liste_titre">';
909 if (!empty($arrayfields[
'm.tms'][
'checked'])) {
910 print
'<td class="liste_titre">';
914 print
'<td class="liste_titre maxwidthsearch">';
915 $searchpicto = $form->showFilterAndCheckAddButtons(0);
920 print
'<tr class="liste_titre">';
921 if (!empty($arrayfields[
'm.rowid'][
'checked'])) {
922 print_liste_field_titre($arrayfields[
'm.rowid'][
'label'], $_SERVER[
"PHP_SELF"],
'm.rowid',
'', $param,
'', $sortfield, $sortorder);
924 if (!empty($arrayfields[
'm.datem'][
'checked'])) {
925 print_liste_field_titre($arrayfields[
'm.datem'][
'label'], $_SERVER[
"PHP_SELF"],
'm.datem',
'', $param,
'', $sortfield, $sortorder);
927 if (!empty($arrayfields[
'p.ref'][
'checked'])) {
928 print_liste_field_titre($arrayfields[
'p.ref'][
'label'], $_SERVER[
"PHP_SELF"],
'p.ref',
'', $param,
'', $sortfield, $sortorder);
930 if (!empty($arrayfields[
'p.label'][
'checked'])) {
931 print_liste_field_titre($arrayfields[
'p.label'][
'label'], $_SERVER[
"PHP_SELF"],
'p.label',
'', $param,
'', $sortfield, $sortorder);
933 if (!empty($arrayfields[
'm.batch'][
'checked'])) {
934 print_liste_field_titre($arrayfields[
'm.batch'][
'label'], $_SERVER[
"PHP_SELF"],
'm.batch',
'', $param,
'', $sortfield, $sortorder,
'center ');
936 if (!empty($arrayfields[
'pl.eatby'][
'checked'])) {
937 print_liste_field_titre($arrayfields[
'pl.eatby'][
'label'], $_SERVER[
"PHP_SELF"],
'pl.eatby',
'', $param,
'', $sortfield, $sortorder,
'center ');
939 if (!empty($arrayfields[
'pl.sellby'][
'checked'])) {
940 print_liste_field_titre($arrayfields[
'pl.sellby'][
'label'], $_SERVER[
"PHP_SELF"],
'pl.sellby',
'', $param,
'', $sortfield, $sortorder,
'center ');
942 if (!empty($arrayfields[
'e.ref'][
'checked'])) {
944 print_liste_field_titre($arrayfields[
'e.ref'][
'label'], $_SERVER[
"PHP_SELF"],
"e.ref",
"", $param,
"", $sortfield, $sortorder);
946 if (!empty($arrayfields[
'm.fk_user_author'][
'checked'])) {
947 print_liste_field_titre($arrayfields[
'm.fk_user_author'][
'label'], $_SERVER[
"PHP_SELF"],
"m.fk_user_author",
"", $param,
"", $sortfield, $sortorder);
949 if (!empty($arrayfields[
'm.inventorycode'][
'checked'])) {
950 print_liste_field_titre($arrayfields[
'm.inventorycode'][
'label'], $_SERVER[
"PHP_SELF"],
"m.inventorycode",
"", $param,
"", $sortfield, $sortorder);
952 if (!empty($arrayfields[
'm.label'][
'checked'])) {
953 print_liste_field_titre($arrayfields[
'm.label'][
'label'], $_SERVER[
"PHP_SELF"],
"m.label",
"", $param,
"", $sortfield, $sortorder);
955 if (!empty($arrayfields[
'm.type_mouvement'][
'checked'])) {
956 print_liste_field_titre($arrayfields[
'm.type_mouvement'][
'label'], $_SERVER[
"PHP_SELF"],
"m.type_mouvement",
"", $param,
'', $sortfield, $sortorder,
'center ');
958 if (!empty($arrayfields[
'origin'][
'checked'])) {
959 print_liste_field_titre($arrayfields[
'origin'][
'label'], $_SERVER[
"PHP_SELF"],
"",
"", $param,
"", $sortfield, $sortorder);
961 if (!empty($arrayfields[
'm.value'][
'checked'])) {
962 print_liste_field_titre($arrayfields[
'm.value'][
'label'], $_SERVER[
"PHP_SELF"],
"m.value",
"", $param,
'', $sortfield, $sortorder,
'right ');
964 if (!empty($arrayfields[
'm.price'][
'checked'])) {
965 print_liste_field_titre($arrayfields[
'm.price'][
'label'], $_SERVER[
"PHP_SELF"],
"m.price",
"", $param,
'', $sortfield, $sortorder,
'right ');
969 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
972 $parameters = array(
'arrayfields' => $arrayfields,
'param' => $param,
'sortfield' => $sortfield,
'sortorder' => $sortorder);
973 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters);
974 print $hookmanager->resPrint;
975 if (!empty($arrayfields[
'm.datec'][
'checked'])) {
976 print_liste_field_titre($arrayfields[
'm.datec'][
'label'], $_SERVER[
"PHP_SELF"],
"m.datec",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
978 if (!empty($arrayfields[
'm.tms'][
'checked'])) {
979 print_liste_field_titre($arrayfields[
'm.tms'][
'label'], $_SERVER[
"PHP_SELF"],
"m.tms",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
981 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
985 $arrayofuniqueproduct = array();
986 while ($i < ($limit ? min($num, $limit) : $num)) {
987 $objp = $db->fetch_object($resql);
989 $userstatic->id = $objp->fk_user_author;
990 $userstatic->login = $objp->login;
991 $userstatic->lastname = $objp->lastname;
992 $userstatic->firstname = $objp->firstname;
993 $userstatic->photo = $objp->photo;
995 $productstatic->id = $objp->rowid;
996 $productstatic->ref = $objp->product_ref;
997 $productstatic->label = $objp->produit;
998 $productstatic->type = $objp->type;
999 $productstatic->entity = $objp->entity;
1000 $productstatic->status_batch = $objp->tobatch;
1002 $productlot->id = $objp->lotid;
1003 $productlot->batch = $objp->batch;
1004 $productlot->eatby = $objp->eatby;
1005 $productlot->sellby = $objp->sellby;
1007 $warehousestatic->id = $objp->entrepot_id;
1008 $warehousestatic->label = $objp->warehouse_ref;
1009 $warehousestatic->lieu = $objp->lieu;
1011 $arrayofuniqueproduct[$objp->rowid] = $objp->produit;
1012 if (!empty($objp->fk_origin)) {
1013 $origin = $movement->get_origin($objp->fk_origin, $objp->origintype);
1018 print
'<tr class="oddeven">';
1020 if (!empty($arrayfields[
'm.rowid'][
'checked'])) {
1022 print
'<td>'.$objp->mid.
'</td>';
1024 if (!empty($arrayfields[
'm.datem'][
'checked'])) {
1026 print
'<td>'.dol_print_date($db->jdate($objp->datem),
'dayhour').
'</td>';
1028 if (!empty($arrayfields[
'p.ref'][
'checked'])) {
1030 print
'<td class="nowraponall">';
1031 print $productstatic->getNomUrl(1,
'stock', 16);
1034 if (!empty($arrayfields[
'p.label'][
'checked'])) {
1041 print $productstatic->label;
1044 if (!empty($arrayfields[
'm.batch'][
'checked'])) {
1045 print
'<td class="center nowraponall">';
1046 if ($productlot->id > 0) {
1047 print $productlot->getNomUrl(1);
1049 print $productlot->batch;
1053 if (!empty($arrayfields[
'pl.eatby'][
'checked'])) {
1054 print
'<td class="center">'.dol_print_date($objp->eatby,
'day').
'</td>';
1056 if (!empty($arrayfields[
'pl.sellby'][
'checked'])) {
1057 print
'<td class="center">'.dol_print_date($objp->sellby,
'day').
'</td>';
1060 if (!empty($arrayfields[
'e.ref'][
'checked'])) {
1062 print $warehousestatic->getNomUrl(1);
1066 if (!empty($arrayfields[
'm.fk_user_author'][
'checked'])) {
1067 print
'<td class="tdoverflowmax100">';
1068 print $userstatic->getNomUrl(-1);
1071 if (!empty($arrayfields[
'm.inventorycode'][
'checked'])) {
1073 print
'<td><a href="'
1074 .DOL_URL_ROOT.
'/product/stock/movement_card.php?id='.urlencode($objp->entrepot_id)
1075 .
'&search_inventorycode='.urlencode($objp->inventorycode)
1076 .
'&search_type_mouvement='.urlencode($objp->type_mouvement)
1078 .$objp->inventorycode
1081 if (!empty($arrayfields[
'm.label'][
'checked'])) {
1083 print
'<td class="tdoverflowmax100aaa">'.$objp->label.
'</td>';
1085 if (!empty($arrayfields[
'm.type_mouvement'][
'checked'])) {
1087 switch ($objp->type_mouvement) {
1089 print
'<td class="center">'.$langs->trans(
'StockIncreaseAfterCorrectTransfer').
'</td>';
1092 print
'<td class="center">'.$langs->trans(
'StockDecreaseAfterCorrectTransfer').
'</td>';
1095 print
'<td class="center">'.$langs->trans(
'StockDecrease').
'</td>';
1098 print
'<td class="center">'.$langs->trans(
'StockIncrease').
'</td>';
1102 if (!empty($arrayfields[
'origin'][
'checked'])) {
1104 print
'<td class="nowraponall">'.$origin.
'</td>';
1106 if (!empty($arrayfields[
'm.value'][
'checked'])) {
1108 print
'<td class="right">';
1109 if ($objp->qt > 0) {
1115 if (!empty($arrayfields[
'm.price'][
'checked'])) {
1117 print
'<td class="right">';
1118 if ($objp->price != 0) {
1119 print
price($objp->price);
1124 print
'<td class="nowrap center">';
1125 if ($massactionbutton || $massaction) {
1127 if (in_array($obj->rowid, $arrayofselected)) {
1130 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
1134 $totalarray[
'nbfield']++;
1147 if (count($arrayofuniqueproduct) == 1 && is_numeric($year)) {
1150 $productidselected = 0;
1151 foreach ($arrayofuniqueproduct as $key => $val) {
1152 $productidselected = $key;
1153 $productlabelselected = $val;
1157 $balancebefore = $movement->calculateBalanceForProductBefore($productidselected, $datebefore);
1158 $balanceafter = $movement->calculateBalanceForProductBefore($productidselected, $dateafter);
1161 print $langs->trans(
"NbOfProductBeforePeriod", $productlabelselected,
dol_print_date($datebefore,
'day',
'gmt'));
1164 print
': '.$balancebefore;
1168 print $langs->trans(
"NbOfProductAfterPeriod", $productlabelselected,
dol_print_date($dateafter,
'day',
'gmt'));
1171 print
': '.$balanceafter;
1185$modulepart =
'movement';
1187if ($action !=
'create' && $action !=
'edit' && $action !=
'delete' && $id > 0) {
1189 print
'<div class="fichecenter"><div class="fichehalfleft">';
1190 print
'<a name="builddoc"></a>';
1195 if (!empty($search_inventorycode)) {
1196 $objectref .=
"_".$id.
"_".$search_inventorycode;
1198 if ($search_type_mouvement) {
1199 $objectref .=
"_".$search_type_mouvement;
1201 $relativepath = $comref.
'/'.$objectref.
'.pdf';
1202 $filedir = $conf->stock->dir_output.
'/movement/'.$objectref;
1204 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".
$object->id.
"&search_inventorycode=".$search_inventorycode.
"&search_type_mouvement=$search_type_mouvement";
1205 $genallowed = $usercanread;
1206 $delallowed = $usercancreate;
1208 $genallowed = $user->hasRight(
'stock',
'lire');
1209 $delallowed = $user->hasRight(
'stock',
'creer');
1211 print $formfile->showdocuments($modulepart, $objectref, $filedir, $urlsource, $genallowed, $delallowed,
'', 0, 0, 0, 28, 0,
'', 0,
'',
$object->default_lang,
'', $object);
1212 $somethingshown = $formfile->numoffiles;
1214 print
'</div><div class="fichehalfright">';
1218 $morehtmlcenter =
dolGetButtonTitle($langs->trans(
'SeeAll'),
'',
'fa fa-bars imgforviewmode', DOL_URL_ROOT.
'/product/agenda.php?id='.
$object->id);
1221 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
1223 $somethingshown = $formactions->showactions($object,
'mouvement', 0, 1,
'', $MAXEVENT,
'', $morehtmlcenter);
1225 print
'</div></div>';
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
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_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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 '.
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.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
newToken()
Return the value of token currently saved into session with name 'newtoken'.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
print_barre_liste($title, $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.
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.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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.