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");
57$action =
GETPOST(
'action',
'aZ09');
58$cancel =
GETPOST(
'cancel',
'alpha');
59$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'movementlist';
64$search_ref =
GETPOST(
'search_ref',
'alpha');
65$search_movement =
GETPOST(
"search_movement",
'alpha');
66$search_product_ref = trim(
GETPOST(
"search_product_ref",
'alpha'));
67$search_product = trim(
GETPOST(
"search_product",
'alpha'));
68$search_warehouse = trim(
GETPOST(
"search_warehouse",
'alpha'));
69$search_inventorycode = trim(
GETPOST(
"search_inventorycode",
'alpha'));
70$search_user = trim(
GETPOST(
"search_user",
'alpha'));
71$search_batch = trim(
GETPOST(
"search_batch",
'alpha'));
72$search_qty = trim(
GETPOST(
"search_qty",
'alpha'));
73$search_type_mouvement =
GETPOST(
'search_type_mouvement',
"intcomma");
77$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
78$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
79if (empty($page) || $page == -1) {
82$offset = $limit * $page;
84 $sortfield =
"m.datem";
92$hookmanager->initHooks(array(
'movementlist'));
103$extrafields->fetch_name_optionals_label(
$object->table_element);
105$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
108 'm.rowid' => array(
'label' => $langs->trans(
"Ref"),
'checked' => 1),
109 'm.datem' => array(
'label' => $langs->trans(
"Date"),
'checked' => 1),
110 'p.ref' => array(
'label' => $langs->trans(
"ProductRef"),
'checked' => 1,
'css' =>
'maxwidth100'),
111 'p.label' => array(
'label' => $langs->trans(
"ProductLabel"),
'checked' => 1),
112 'm.batch' => array(
'label' => $langs->trans(
"BatchNumberShort"),
'checked' => 1,
'enabled' => (isModEnabled(
'productbatch'))),
113 'pl.eatby' => array(
'label' => $langs->trans(
"EatByDate"),
'checked' => 0,
'position' => 10,
'enabled' => (isModEnabled(
'productbatch'))),
114 'pl.sellby' => array(
'label' => $langs->trans(
"SellByDate"),
'checked' => 0,
'position' => 10,
'enabled' => (isModEnabled(
'productbatch'))),
115 'e.ref' => array(
'label' => $langs->trans(
"Warehouse"),
'checked' => 1,
'enabled' => (!($id > 0))),
116 'm.fk_user_author' => array(
'label' => $langs->trans(
"Author"),
'checked' => 0),
117 'm.inventorycode' => array(
'label' => $langs->trans(
"InventoryCodeShort"),
'checked' => 1),
118 'm.label' => array(
'label' => $langs->trans(
"MovementLabel"),
'checked' => 1),
119 'm.type_mouvement' => array(
'label' => $langs->trans(
"TypeMovement"),
'checked' => 1),
120 'origin' => array(
'label' => $langs->trans(
"Origin"),
'checked' => 1),
121 'm.value' => array(
'label' => $langs->trans(
"Qty"),
'checked' => 1),
122 'm.price' => array(
'label' => $langs->trans(
"UnitPurchaseValue"),
'checked' => 0),
127$usercanread = (($user->hasRight(
'stock',
'mouvement',
'lire')));
128$usercancreate = (($user->hasRight(
'stock',
'mouvement',
'creer')));
129$usercandelete = (($user->hasRight(
'stock',
'mouvement',
'supprimer')));
137if (
GETPOST(
'cancel',
'alpha')) {
141if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
145$parameters = array();
146$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
151include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
154if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
158 $search_movement =
"";
159 $search_type_mouvement =
"";
160 $search_inventorycode =
"";
161 $search_product_ref =
"";
162 $search_product =
"";
163 $search_warehouse =
"";
169 $search_array_options = array();
173if ($action ==
"correct_stock" && !$cancel && $usercancreate) {
175 if (!empty($product_id)) {
176 $result = $product->fetch($product_id);
181 if (empty($product_id)) {
183 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Product")),
null,
'errors');
184 $action =
'correction';
186 if (!is_numeric(
GETPOST(
"nbpiece"))) {
188 setEventMessages($langs->trans(
"ErrorFieldMustBeANumeric", $langs->transnoentitiesnoconv(
"NumberOfUnit")),
null,
'errors');
189 $action =
'correction';
193 $origin_element =
'';
197 $origin_element =
'project';
201 if ($product->hasbatch()) {
202 $batch =
GETPOST(
'batch_number',
'alpha');
209 $result = $product->correct_stock_batch(
219 GETPOST(
'inventorycode',
'alpha'),
224 $result = $product->correct_stock(
231 GETPOST(
'inventorycode',
'alpha'),
238 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
243 $action =
'correction';
253if ($action ==
"transfert_stock" && !$cancel && $usercancreate) {
256 if (!empty($product_id)) {
257 $result = $product->fetch($product_id);
260 if (!(
GETPOSTINT(
"id_entrepot_destination") > 0)) {
261 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Warehouse")),
null,
'errors');
263 $action =
'transfert';
265 if (empty($product_id)) {
267 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Product")),
null,
'errors');
268 $action =
'transfert';
271 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"NumberOfUnit")),
null,
'errors');
273 $action =
'transfert';
275 if ($id ==
GETPOSTINT(
"id_entrepot_destination")) {
276 setEventMessages($langs->trans(
"ErrorSrcAndTargetWarehouseMustDiffers"),
null,
'errors');
278 $action =
'transfert';
281 if (isModEnabled(
'productbatch')) {
283 $result = $product->fetch($product_id);
285 if ($product->hasbatch() && !
GETPOST(
"batch_number",
'alpha')) {
286 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"batch_number")),
null,
'errors');
288 $action =
'transfert';
299 $product->load_stock(
'novirtual');
303 if (isset($product->pmp)) {
304 $pricesrc = $product->pmp;
306 $pricedest = $pricesrc;
308 if ($product->hasbatch()) {
312 $result = $pdluo->fetch($pdluoid);
314 $srcwarehouseid = $pdluo->warehouseid;
315 $batch = $pdluo->batch;
316 $eatby = $pdluo->eatby;
317 $sellby = $pdluo->sellby;
323 $srcwarehouseid =
$id;
324 $batch =
GETPOST(
'batch_number',
'alpha');
331 $result1 = $product->correct_stock_batch(
341 GETPOST(
'inventorycode',
'alpha')
344 $result2 = $product->correct_stock_batch(
354 GETPOST(
'inventorycode',
'alpha')
359 $result1 = $product->correct_stock(
366 GETPOST(
'inventorycode',
'alpha')
370 $result2 = $product->correct_stock(
372 GETPOST(
"id_entrepot_destination"),
377 GETPOST(
'inventorycode',
'alpha')
380 if (!$error && $result1 >= 0 && $result2 >= 0) {
384 header(
"Location: ".$backtopage);
387 header(
"Location: movement_list.php?id=".
$object->id);
393 $action =
'transfert';
405$upload_dir = $conf->stock->dir_output.
"movement/";
406$permissiontoadd = $user->hasRight(
'stock',
'creer');
407include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
410if (empty($reshook) && $action !=
'remove_file') {
411 $objectclass =
'MouvementStock';
412 $objectlabel =
'Movements';
413 $permissiontoread = $user->hasRight(
'stock',
'lire');
414 $permissiontodelete = $user->hasRight(
'stock',
'supprimer');
415 $uploaddir = $conf->stock->dir_output.
"/movement/";
416 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
426$productstatic =
new Product($db);
427$warehousestatic =
new Entrepot($db);
429$userstatic =
new User($db);
430$form =
new Form($db);
433if (isModEnabled(
'project')) {
437$sql =
"SELECT p.rowid, p.ref as product_ref, p.label as produit, p.tobatch, p.fk_product_type as type, p.entity,";
438$sql .=
" e.ref as warehouse_ref, e.rowid as entrepot_id, e.lieu,";
439$sql .=
" m.rowid as mid, m.value as qty, m.datem, m.fk_user_author, m.label, m.inventorycode, m.fk_origin, m.origintype,";
440$sql .=
" m.batch, m.price,";
441$sql .=
" m.type_mouvement,";
442$sql .=
" pl.rowid as lotid, pl.eatby, pl.sellby,";
443$sql .=
" u.login, u.photo, u.lastname, u.firstname";
445if (!empty($extrafields->attributes[
$object->table_element][
'label'])) {
446 foreach ($extrafields->attributes[
$object->table_element][
'label'] as $key => $val) {
447 $sql .= ($extrafields->attributes[
$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
451$parameters = array();
452$reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters);
453$sql .= $hookmanager->resPrint;
454$sql .=
" FROM ".MAIN_DB_PREFIX.
"entrepot as e,";
455$sql .=
" ".MAIN_DB_PREFIX.
"product as p,";
456$sql .=
" ".MAIN_DB_PREFIX.
"stock_mouvement as m";
457if (isset($extrafields->attributes[
$object->table_element][
'label']) && is_array($extrafields->attributes[
$object->table_element][
'label']) && count($extrafields->attributes[
$object->table_element][
'label'])) {
458 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element.
"_extrafields as ef on (m.rowid = ef.fk_object)";
460$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u ON m.fk_user_author = u.rowid";
461$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product_lot as pl ON m.batch = pl.batch AND m.fk_product = pl.fk_product";
462$sql .=
" WHERE m.fk_product = p.rowid";
464 $sql .=
" AND m.rowid = ".((int) $msid);
466$sql .=
" AND m.fk_entrepot = e.rowid";
467$sql .=
" AND e.entity IN (".getEntity(
'stock').
")";
469 $sql .=
" AND p.fk_product_type = 0";
472 $sql .=
" AND e.rowid = ".((int) $id);
476 $sql .=
" AND p.rowid = ".((int) $idproduct);
478if (!empty($search_ref)) {
481if (!empty($search_movement)) {
484if (!empty($search_inventorycode)) {
487if (!empty($search_product_ref)) {
490if (!empty($search_product)) {
493if ($search_warehouse !=
'' && $search_warehouse !=
'-1') {
496if (!empty($search_user)) {
497 $sql .=
natural_search(array(
'u.lastname',
'u.firstname',
'u.login'), $search_user);
499if (!empty($search_batch)) {
502if ($search_qty !=
'') {
505if ($search_type_mouvement !=
'' && $search_type_mouvement !=
'-1') {
506 $sql .=
natural_search(
'm.type_mouvement', $search_type_mouvement, 2);
509include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
511$parameters = array();
512$reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters);
513$sql .= $hookmanager->resPrint;
514$sql .= $db->order($sortfield, $sortorder);
516$nbtotalofrecords =
'';
518 $result = $db->query($sql);
519 $nbtotalofrecords = $db->num_rows($result);
520 if (($page * $limit) > $nbtotalofrecords) {
528$resql = $db->query($sql);
534 if ($idproduct > 0) {
535 $product->fetch($idproduct);
537 if ($id > 0 || $ref) {
538 $result =
$object->fetch($id, $ref);
544 $num = $db->num_rows($resql);
546 $arrayofselected = is_array($toselect) ? $toselect : array();
550 $help_url =
'EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks';
552 $texte = $langs->trans(
'StockMovementForId', $msid);
554 $texte = $langs->trans(
"ListOfStockMovements");
556 $texte .=
' ('.$langs->trans(
"ForThisWarehouse").
')';
559 llxHeader(
"", $texte, $help_url,
'', 0, 0,
'',
'',
'',
'mod-product page-stock_movement_card');
567 print
dol_get_fiche_head($head,
'movements', $langs->trans(
"Warehouse"), -1,
'stock');
570 $linkback =
'<a href="'.DOL_URL_ROOT.
'/product/stock/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
572 $morehtmlref =
'<div class="refidno">';
573 $morehtmlref .= $langs->trans(
"LocationSummary").
' : '.
$object->lieu;
574 $morehtmlref .=
'</div>';
577 if ($user->socid && !in_array(
'stock', explode(
',',
getDolGlobalString(
'MAIN_MODULES_FOR_EXTERNAL')))) {
581 dol_banner_tab($object,
'ref', $linkback, $shownav,
'ref',
'ref', $morehtmlref);
584 print
'<div class="fichecenter">';
585 print
'<div class="fichehalfleft">';
586 print
'<div class="underbanner clearboth"></div>';
588 print
'<table class="border centpercent">';
593 print
'<td class="titlefield tdtop">'.$langs->trans(
"Description").
'</td><td>'.
dol_htmlentitiesbr(
$object->description).
'</td></tr>';
595 $calcproductsunique =
$object->nb_different_products();
596 $calcproducts =
$object->nb_products();
599 print
'<tr><td>'.$langs->trans(
"NumberOfDifferentProducts").
'</td><td>';
600 print empty($calcproductsunique[
'nb']) ?
'0' : $calcproductsunique[
'nb'];
604 print
'<tr><td>'.$langs->trans(
"NumberOfProducts").
'</td><td>';
605 $valtoshow =
price2num($calcproducts[
'nb'],
'MS');
606 print empty($valtoshow) ?
'0' : $valtoshow;
612 print
'<div class="fichehalfright">';
613 print
'<div class="underbanner clearboth"></div>';
615 print
'<table class="border centpercent">';
618 print
'<tr><td class="titlefield">'.$langs->trans(
"EstimatedStockValueShort").
'</td><td>';
619 print
price((empty($calcproducts[
'value']) ?
'0' :
price2num($calcproducts[
'value'],
'MT')), 0, $langs, 0, -1, -1, $conf->currency);
623 $sql =
"SELECT MAX(m.datem) as datem";
624 $sql .=
" FROM ".MAIN_DB_PREFIX.
"stock_mouvement as m";
625 $sql .=
" WHERE m.fk_entrepot = ".(int)
$object->id;
626 $resqlbis = $db->query($sql);
628 $obj = $db->fetch_object($resqlbis);
629 $lastmovementdate = $db->jdate($obj->datem);
634 print
'<tr><td>'.$langs->trans(
"LastMovement").
'</td><td>';
635 if ($lastmovementdate) {
638 print $langs->trans(
"None");
647 print
'<div class="clearboth"></div>';
656 if ($action ==
"correction") {
657 include DOL_DOCUMENT_ROOT.
'/product/stock/tpl/stockcorrection.tpl.php';
664 if ($action ==
"transfert") {
665 include DOL_DOCUMENT_ROOT.
'/product/stock/tpl/stocktransfer.tpl.php';
673 if ((empty($action) || $action ==
'list') && $id > 0) {
674 print
"<div class=\"tabsAction\">\n";
676 if ($user->hasRight(
'stock',
'mouvement',
'creer')) {
677 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$id.
'&action=correction&token='.
newToken().
'">'.$langs->trans(
"CorrectStock").
'</a>';
680 if ($user->hasRight(
'stock',
'mouvement',
'creer')) {
681 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$id.
'&action=transfert&token='.
newToken().
'">'.$langs->trans(
"TransferStock").
'</a>';
688 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
689 $param .=
'&contextpage='.urlencode($contextpage);
691 if ($limit > 0 && $limit != $conf->liste_limit) {
692 $param .=
'&limit='.((int) $limit);
695 $param .=
'&id='.urlencode((
string) (
$id));
697 if ($search_movement) {
698 $param .=
'&search_movement='.urlencode($search_movement);
700 if ($search_inventorycode) {
701 $param .=
'&search_inventorycode='.urlencode($search_inventorycode);
703 if ($search_type_mouvement) {
704 $param .=
'&search_type_mouvement='.urlencode($search_type_mouvement);
706 if ($search_product_ref) {
707 $param .=
'&search_product_ref='.urlencode($search_product_ref);
709 if ($search_product) {
710 $param .=
'&search_product='.urlencode($search_product);
713 $param .=
'&search_batch='.urlencode($search_batch);
715 if ($search_warehouse > 0) {
716 $param .=
'&search_warehouse='.urlencode($search_warehouse);
719 $param .=
'&search_user='.urlencode($search_user);
721 if ($idproduct > 0) {
722 $param .=
'&idproduct='.urlencode((
string) ($idproduct));
725 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
728 $arrayofmassactions = array(
733 if (in_array($massaction, array(
'presend',
'predelete'))) {
734 $arrayofmassactions = array();
736 $massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
738 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
739 if ($optioncss !=
'') {
740 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
742 print
'<input type="hidden" name="token" value="'.newToken().
'">';
743 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
744 print
'<input type="hidden" name="action" value="list">';
745 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
746 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
747 print
'<input type="hidden" name="page" value="'.$page.
'">';
748 print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
750 print
'<input type="hidden" name="id" value="'.$id.
'">';
754 print_barre_liste($texte, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'', 0,
'',
'', $limit);
756 print_barre_liste($texte, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'generic', 0,
'',
'', $limit);
760 if (!isset($fieldstosearchall) || !is_array($fieldstosearchall)) {
762 $fieldstosearchall = array();
764 foreach ($fieldstosearchall as $key => $val) {
765 $fieldstosearchall[$key] = $langs->trans($val);
767 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $sall).implode(
', ', $fieldstosearchall).
'</div>';
772 $parameters = array();
773 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters);
774 if (empty($reshook)) {
775 $moreforfilter .= $hookmanager->resPrint;
777 $moreforfilter = $hookmanager->resPrint;
780 if (!empty($moreforfilter)) {
781 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
782 print $moreforfilter;
786 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
787 $selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage);
789 print
'<div class="div-table-responsive">';
790 print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
793 print
'<tr class="liste_titre_filter">';
794 if (!empty($arrayfields[
'm.rowid'][
'checked'])) {
796 print
'<td class="liste_titre left">';
797 print
'<input class="flat maxwidth25" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).
'">';
800 if (!empty($arrayfields[
'm.datem'][
'checked'])) {
801 print
'<td class="liste_titre nowraponall">';
802 print
'<input class="flat" type="text" size="2" maxlength="2" placeholder="'.dol_escape_htmltag($langs->trans(
"Month")).
'" name="month" value="'.$month.
'">';
803 if (empty($conf->productbatch->enabled)) {
807 $syear = $year ? $year : -1;
808 print
'<input class="flat maxwidth50" type="text" maxlength="4" placeholder="'.dol_escape_htmltag($langs->trans(
"Year")).
'" name="year" value="'.($syear > 0 ? $syear :
'').
'">';
812 if (!empty($arrayfields[
'p.ref'][
'checked'])) {
814 print
'<td class="liste_titre left">';
815 print
'<input class="flat maxwidth75" type="text" name="search_product_ref" value="'.dol_escape_htmltag($idproduct ? $product->ref : $search_product_ref).
'">';
818 if (!empty($arrayfields[
'p.label'][
'checked'])) {
820 print
'<td class="liste_titre left">';
821 print
'<input class="flat maxwidth100" type="text" name="search_product" value="'.dol_escape_htmltag($idproduct ? $product->label : $search_product).
'">';
825 if (!empty($arrayfields[
'm.batch'][
'checked'])) {
826 print
'<td class="liste_titre center"><input class="flat maxwidth75" type="text" name="search_batch" value="'.dol_escape_htmltag($search_batch).
'"></td>';
828 if (!empty($arrayfields[
'pl.eatby'][
'checked'])) {
829 print
'<td class="liste_titre left">';
832 if (!empty($arrayfields[
'pl.sellby'][
'checked'])) {
833 print
'<td class="liste_titre left">';
837 if (!empty($arrayfields[
'e.ref'][
'checked'])) {
838 print
'<td class="liste_titre maxwidthonsmartphone left">';
840 print $formproduct->selectWarehouses($search_warehouse,
'search_warehouse',
'warehouseopen,warehouseinternal', 1, 0, 0,
'', 0, 0, array(),
'maxwidth200');
843 if (!empty($arrayfields[
'm.fk_user_author'][
'checked'])) {
845 print
'<td class="liste_titre left">';
846 print
'<input class="flat" type="text" size="6" name="search_user" value="'.dol_escape_htmltag($search_user).
'">';
849 if (!empty($arrayfields[
'm.inventorycode'][
'checked'])) {
851 print
'<td class="liste_titre left">';
852 print
'<input class="flat" type="text" size="4" name="search_inventorycode" value="'.dol_escape_htmltag($search_inventorycode).
'">';
855 if (!empty($arrayfields[
'm.label'][
'checked'])) {
857 print
'<td class="liste_titre left">';
858 print
'<input class="flat" type="text" size="8" name="search_movement" value="'.dol_escape_htmltag($search_movement).
'">';
861 if (!empty($arrayfields[
'm.type_mouvement'][
'checked'])) {
863 print
'<td class="liste_titre center">';
865 print
'<select id="search_type_mouvement" name="search_type_mouvement" class="maxwidth150">';
866 print
'<option value="" '.(($search_type_mouvement ==
"") ?
'selected="selected"' :
'').
'></option>';
867 print
'<option value="0" '.(($search_type_mouvement ==
"0") ?
'selected="selected"' :
'').
'>'.$langs->trans(
'StockIncreaseAfterCorrectTransfer').
'</option>';
868 print
'<option value="1" '.(($search_type_mouvement ==
"1") ?
'selected="selected"' :
'').
'>'.$langs->trans(
'StockDecreaseAfterCorrectTransfer').
'</option>';
869 print
'<option value="2" '.(($search_type_mouvement ==
"2") ?
'selected="selected"' :
'').
'>'.$langs->trans(
'StockDecrease').
'</option>';
870 print
'<option value="3" '.(($search_type_mouvement ==
"3") ?
'selected="selected"' :
'').
'>'.$langs->trans(
'StockIncrease').
'</option>';
877 if (!empty($arrayfields[
'origin'][
'checked'])) {
879 print
'<td class="liste_titre left">';
883 if (!empty($arrayfields[
'm.value'][
'checked'])) {
885 print
'<td class="liste_titre right">';
886 print
'<input class="flat" type="text" size="4" name="search_qty" value="'.dol_escape_htmltag($search_qty).
'">';
889 if (!empty($arrayfields[
'm.price'][
'checked'])) {
891 print
'<td class="liste_titre left">';
898 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
901 $parameters = array(
'arrayfields' => $arrayfields);
902 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters);
903 print $hookmanager->resPrint;
905 if (!empty($arrayfields[
'm.datec'][
'checked'])) {
906 print
'<td class="liste_titre">';
910 if (!empty($arrayfields[
'm.tms'][
'checked'])) {
911 print
'<td class="liste_titre">';
915 print
'<td class="liste_titre maxwidthsearch">';
916 $searchpicto = $form->showFilterAndCheckAddButtons(0);
921 print
'<tr class="liste_titre">';
922 if (!empty($arrayfields[
'm.rowid'][
'checked'])) {
923 print_liste_field_titre($arrayfields[
'm.rowid'][
'label'], $_SERVER[
"PHP_SELF"],
'm.rowid',
'', $param,
'', $sortfield, $sortorder);
925 if (!empty($arrayfields[
'm.datem'][
'checked'])) {
926 print_liste_field_titre($arrayfields[
'm.datem'][
'label'], $_SERVER[
"PHP_SELF"],
'm.datem',
'', $param,
'', $sortfield, $sortorder);
928 if (!empty($arrayfields[
'p.ref'][
'checked'])) {
929 print_liste_field_titre($arrayfields[
'p.ref'][
'label'], $_SERVER[
"PHP_SELF"],
'p.ref',
'', $param,
'', $sortfield, $sortorder);
931 if (!empty($arrayfields[
'p.label'][
'checked'])) {
932 print_liste_field_titre($arrayfields[
'p.label'][
'label'], $_SERVER[
"PHP_SELF"],
'p.label',
'', $param,
'', $sortfield, $sortorder);
934 if (!empty($arrayfields[
'm.batch'][
'checked'])) {
935 print_liste_field_titre($arrayfields[
'm.batch'][
'label'], $_SERVER[
"PHP_SELF"],
'm.batch',
'', $param,
'', $sortfield, $sortorder,
'center ');
937 if (!empty($arrayfields[
'pl.eatby'][
'checked'])) {
938 print_liste_field_titre($arrayfields[
'pl.eatby'][
'label'], $_SERVER[
"PHP_SELF"],
'pl.eatby',
'', $param,
'', $sortfield, $sortorder,
'center ');
940 if (!empty($arrayfields[
'pl.sellby'][
'checked'])) {
941 print_liste_field_titre($arrayfields[
'pl.sellby'][
'label'], $_SERVER[
"PHP_SELF"],
'pl.sellby',
'', $param,
'', $sortfield, $sortorder,
'center ');
943 if (!empty($arrayfields[
'e.ref'][
'checked'])) {
945 print_liste_field_titre($arrayfields[
'e.ref'][
'label'], $_SERVER[
"PHP_SELF"],
"e.ref",
"", $param,
"", $sortfield, $sortorder);
947 if (!empty($arrayfields[
'm.fk_user_author'][
'checked'])) {
948 print_liste_field_titre($arrayfields[
'm.fk_user_author'][
'label'], $_SERVER[
"PHP_SELF"],
"m.fk_user_author",
"", $param,
"", $sortfield, $sortorder);
950 if (!empty($arrayfields[
'm.inventorycode'][
'checked'])) {
951 print_liste_field_titre($arrayfields[
'm.inventorycode'][
'label'], $_SERVER[
"PHP_SELF"],
"m.inventorycode",
"", $param,
"", $sortfield, $sortorder);
953 if (!empty($arrayfields[
'm.label'][
'checked'])) {
954 print_liste_field_titre($arrayfields[
'm.label'][
'label'], $_SERVER[
"PHP_SELF"],
"m.label",
"", $param,
"", $sortfield, $sortorder);
956 if (!empty($arrayfields[
'm.type_mouvement'][
'checked'])) {
957 print_liste_field_titre($arrayfields[
'm.type_mouvement'][
'label'], $_SERVER[
"PHP_SELF"],
"m.type_mouvement",
"", $param,
'', $sortfield, $sortorder,
'center ');
959 if (!empty($arrayfields[
'origin'][
'checked'])) {
960 print_liste_field_titre($arrayfields[
'origin'][
'label'], $_SERVER[
"PHP_SELF"],
"",
"", $param,
"", $sortfield, $sortorder);
962 if (!empty($arrayfields[
'm.value'][
'checked'])) {
963 print_liste_field_titre($arrayfields[
'm.value'][
'label'], $_SERVER[
"PHP_SELF"],
"m.value",
"", $param,
'', $sortfield, $sortorder,
'right ');
965 if (!empty($arrayfields[
'm.price'][
'checked'])) {
966 print_liste_field_titre($arrayfields[
'm.price'][
'label'], $_SERVER[
"PHP_SELF"],
"m.price",
"", $param,
'', $sortfield, $sortorder,
'right ');
970 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
973 $parameters = array(
'arrayfields' => $arrayfields,
'param' => $param,
'sortfield' => $sortfield,
'sortorder' => $sortorder);
974 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters);
975 print $hookmanager->resPrint;
976 if (!empty($arrayfields[
'm.datec'][
'checked'])) {
977 print_liste_field_titre($arrayfields[
'm.datec'][
'label'], $_SERVER[
"PHP_SELF"],
"m.datec",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
979 if (!empty($arrayfields[
'm.tms'][
'checked'])) {
980 print_liste_field_titre($arrayfields[
'm.tms'][
'label'], $_SERVER[
"PHP_SELF"],
"m.tms",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
982 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
986 $arrayofuniqueproduct = array();
987 while ($i < ($limit ? min($num, $limit) : $num)) {
988 $objp = $db->fetch_object($resql);
990 $userstatic->id = $objp->fk_user_author;
991 $userstatic->login = $objp->login;
992 $userstatic->lastname = $objp->lastname;
993 $userstatic->firstname = $objp->firstname;
994 $userstatic->photo = $objp->photo;
996 $productstatic->id = $objp->rowid;
997 $productstatic->ref = $objp->product_ref;
998 $productstatic->label = $objp->produit;
999 $productstatic->type = $objp->type;
1000 $productstatic->entity = $objp->entity;
1001 $productstatic->status_batch = $objp->tobatch;
1003 $productlot->id = $objp->lotid;
1004 $productlot->batch = $objp->batch;
1005 $productlot->eatby = $objp->eatby;
1006 $productlot->sellby = $objp->sellby;
1008 $warehousestatic->id = $objp->entrepot_id;
1009 $warehousestatic->label = $objp->warehouse_ref;
1010 $warehousestatic->lieu = $objp->lieu;
1012 $arrayofuniqueproduct[$objp->rowid] = $objp->produit;
1013 if (!empty($objp->fk_origin)) {
1014 $origin = $movement->get_origin($objp->fk_origin, $objp->origintype);
1019 print
'<tr class="oddeven">';
1021 if (!empty($arrayfields[
'm.rowid'][
'checked'])) {
1023 print
'<td>'.$objp->mid.
'</td>';
1025 if (!empty($arrayfields[
'm.datem'][
'checked'])) {
1027 print
'<td>'.dol_print_date($db->jdate($objp->datem),
'dayhour').
'</td>';
1029 if (!empty($arrayfields[
'p.ref'][
'checked'])) {
1031 print
'<td class="nowraponall">';
1032 print $productstatic->getNomUrl(1,
'stock', 16);
1035 if (!empty($arrayfields[
'p.label'][
'checked'])) {
1042 print $productstatic->label;
1045 if (!empty($arrayfields[
'm.batch'][
'checked'])) {
1046 print
'<td class="center nowraponall">';
1047 if ($productlot->id > 0) {
1048 print $productlot->getNomUrl(1);
1050 print $productlot->batch;
1054 if (!empty($arrayfields[
'pl.eatby'][
'checked'])) {
1055 print
'<td class="center">'.dol_print_date($objp->eatby,
'day').
'</td>';
1057 if (!empty($arrayfields[
'pl.sellby'][
'checked'])) {
1058 print
'<td class="center">'.dol_print_date($objp->sellby,
'day').
'</td>';
1061 if (!empty($arrayfields[
'e.ref'][
'checked'])) {
1063 print $warehousestatic->getNomUrl(1);
1067 if (!empty($arrayfields[
'm.fk_user_author'][
'checked'])) {
1068 print
'<td class="tdoverflowmax100">';
1069 print $userstatic->getNomUrl(-1);
1072 if (!empty($arrayfields[
'm.inventorycode'][
'checked'])) {
1074 print
'<td><a href="'
1075 .DOL_URL_ROOT.
'/product/stock/movement_card.php?id='.urlencode($objp->entrepot_id)
1076 .
'&search_inventorycode='.urlencode($objp->inventorycode)
1077 .
'&search_type_mouvement='.urlencode($objp->type_mouvement)
1079 .$objp->inventorycode
1082 if (!empty($arrayfields[
'm.label'][
'checked'])) {
1084 print
'<td class="tdoverflowmax100">'.$objp->label.
'</td>';
1086 if (!empty($arrayfields[
'm.type_mouvement'][
'checked'])) {
1088 switch ($objp->type_mouvement) {
1090 print
'<td class="center">'.$langs->trans(
'StockIncreaseAfterCorrectTransfer').
'</td>';
1093 print
'<td class="center">'.$langs->trans(
'StockDecreaseAfterCorrectTransfer').
'</td>';
1096 print
'<td class="center">'.$langs->trans(
'StockDecrease').
'</td>';
1099 print
'<td class="center">'.$langs->trans(
'StockIncrease').
'</td>';
1103 if (!empty($arrayfields[
'origin'][
'checked'])) {
1105 print
'<td class="nowraponall">'.$origin.
'</td>';
1107 if (!empty($arrayfields[
'm.value'][
'checked'])) {
1109 print
'<td class="right">';
1110 if ($objp->qt > 0) {
1116 if (!empty($arrayfields[
'm.price'][
'checked'])) {
1118 print
'<td class="right">';
1119 if ($objp->price != 0) {
1120 print
price($objp->price);
1125 print
'<td class="nowrap center">';
1126 if ($massactionbutton || $massaction) {
1128 if (in_array($obj->rowid, $arrayofselected)) {
1131 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
1135 $totalarray[
'nbfield']++;
1148 if (count($arrayofuniqueproduct) == 1 && is_numeric($year)) {
1151 $productidselected = 0;
1152 foreach ($arrayofuniqueproduct as $key => $val) {
1153 $productidselected = $key;
1154 $productlabelselected = $val;
1158 $balancebefore = $movement->calculateBalanceForProductBefore($productidselected, $datebefore);
1159 $balanceafter = $movement->calculateBalanceForProductBefore($productidselected, $dateafter);
1162 print $langs->trans(
"NbOfProductBeforePeriod", $productlabelselected,
dol_print_date($datebefore,
'day',
'gmt'));
1165 print
': '.$balancebefore;
1169 print $langs->trans(
"NbOfProductAfterPeriod", $productlabelselected,
dol_print_date($dateafter,
'day',
'gmt'));
1172 print
': '.$balanceafter;
1186$modulepart =
'movement';
1188if ($action !=
'create' && $action !=
'edit' && $action !=
'delete' && $id > 0) {
1190 print
'<div class="fichecenter"><div class="fichehalfleft">';
1191 print
'<a name="builddoc"></a>';
1196 if (!empty($search_inventorycode)) {
1197 $objectref .=
"_".$id.
"_".$search_inventorycode;
1199 if ($search_type_mouvement) {
1200 $objectref .=
"_".$search_type_mouvement;
1202 $relativepath = $comref.
'/'.$objectref.
'.pdf';
1203 $filedir = $conf->stock->dir_output.
'/movement/'.$objectref;
1205 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".
$object->id.
"&search_inventorycode=".$search_inventorycode.
"&search_type_mouvement=$search_type_mouvement";
1206 $genallowed = $usercanread;
1207 $delallowed = $usercancreate;
1209 $genallowed = $user->hasRight(
'stock',
'lire');
1210 $delallowed = $user->hasRight(
'stock',
'creer');
1212 print $formfile->showdocuments($modulepart, $objectref, $filedir, $urlsource, $genallowed, $delallowed,
'', 0, 0, 0, 28, 0,
'', 0,
'',
$object->default_lang,
'', $object);
1213 $somethingshown = $formfile->numoffiles;
1215 print
'</div><div class="fichehalfright">';
1219 $morehtmlcenter =
dolGetButtonTitle($langs->trans(
'SeeAll'),
'',
'fa fa-bars imgforviewmode', DOL_URL_ROOT.
'/product/agenda.php?id='.
$object->id);
1222 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
1224 $somethingshown = $formactions->showactions($object,
'mouvement', 0, 1,
'', $MAXEVENT,
'', $morehtmlcenter);
1226 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($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
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...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
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.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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 a 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.