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';
56$langs->loadLangs(array(
'products',
'stocks',
'orders'));
57if (isModEnabled(
'productbatch')) {
58 $langs->load(
"productbatch");
65$action =
GETPOST(
'action',
'aZ09');
66$cancel =
GETPOST(
'cancel',
'alpha');
67$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'movementlist';
68$optioncss =
GETPOST(
'optioncss',
'alpha');
73$search_ref =
GETPOST(
'search_ref',
'alpha');
74$search_movement =
GETPOST(
"search_movement",
'alpha');
75$search_product_ref = trim(
GETPOST(
"search_product_ref",
'alpha'));
76$search_product = trim(
GETPOST(
"search_product",
'alpha'));
77$search_warehouse = trim(
GETPOST(
"search_warehouse",
'alpha'));
78$search_inventorycode = trim(
GETPOST(
"search_inventorycode",
'alpha'));
79$search_user = trim(
GETPOST(
"search_user",
'alpha'));
80$search_batch = trim(
GETPOST(
"search_batch",
'alpha'));
81$search_qty = trim(
GETPOST(
"search_qty",
'alpha'));
82$search_type_mouvement =
GETPOST(
'search_type_mouvement',
"intcomma");
86$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
87$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
88if (empty($page) || $page == -1) {
91$offset = $limit * $page;
93 $sortfield =
"m.datem";
101$hookmanager->initHooks(array(
'movementlist'));
112$extrafields->fetch_name_optionals_label(
$object->table_element);
114$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
117 'm.rowid' => array(
'label' => $langs->trans(
"Ref"),
'checked' => 1),
118 'm.datem' => array(
'label' => $langs->trans(
"Date"),
'checked' => 1),
119 'p.ref' => array(
'label' => $langs->trans(
"ProductRef"),
'checked' => 1,
'css' =>
'maxwidth100'),
120 'p.label' => array(
'label' => $langs->trans(
"ProductLabel"),
'checked' => 1),
121 'm.batch' => array(
'label' => $langs->trans(
"BatchNumberShort"),
'checked' => 1,
'enabled' => (isModEnabled(
'productbatch'))),
122 'pl.eatby' => array(
'label' => $langs->trans(
"EatByDate"),
'checked' => 0,
'position' => 10,
'enabled' => (isModEnabled(
'productbatch'))),
123 'pl.sellby' => array(
'label' => $langs->trans(
"SellByDate"),
'checked' => 0,
'position' => 10,
'enabled' => (isModEnabled(
'productbatch'))),
124 'e.ref' => array(
'label' => $langs->trans(
"Warehouse"),
'checked' => 1,
'enabled' => (!($id > 0))),
125 'm.fk_user_author' => array(
'label' => $langs->trans(
"Author"),
'checked' => 0),
126 'm.inventorycode' => array(
'label' => $langs->trans(
"InventoryCodeShort"),
'checked' => 1),
127 'm.label' => array(
'label' => $langs->trans(
"MovementLabel"),
'checked' => 1),
128 'm.type_mouvement' => array(
'label' => $langs->trans(
"TypeMovement"),
'checked' => 1),
129 'origin' => array(
'label' => $langs->trans(
"Origin"),
'checked' => 1),
130 'm.value' => array(
'label' => $langs->trans(
"Qty"),
'checked' => 1),
131 'm.price' => array(
'label' => $langs->trans(
"UnitPurchaseValue"),
'checked' => 0),
136$usercanread = (($user->hasRight(
'stock',
'mouvement',
'lire')));
137$usercancreate = (($user->hasRight(
'stock',
'mouvement',
'creer')));
138$usercandelete = (($user->hasRight(
'stock',
'mouvement',
'supprimer')));
146if (
GETPOST(
'cancel',
'alpha')) {
150if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
154$parameters = array();
155$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
160include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
163if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
167 $search_movement =
"";
168 $search_type_mouvement =
"";
169 $search_inventorycode =
"";
170 $search_product_ref =
"";
171 $search_product =
"";
172 $search_warehouse =
"";
178 $search_array_options = array();
182if ($action ==
"correct_stock" && !$cancel && $usercancreate) {
184 if (!empty($product_id)) {
185 $result = $product->fetch($product_id);
190 if (empty($product_id)) {
192 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Product")),
null,
'errors');
193 $action =
'correction';
195 if (!is_numeric(
GETPOST(
"nbpiece"))) {
197 setEventMessages($langs->trans(
"ErrorFieldMustBeANumeric", $langs->transnoentitiesnoconv(
"NumberOfUnit")),
null,
'errors');
198 $action =
'correction';
202 $origin_element =
'';
206 $origin_element =
'project';
210 if ($product->hasbatch()) {
211 $batch =
GETPOST(
'batch_number',
'alpha');
218 $result = $product->correct_stock_batch(
228 GETPOST(
'inventorycode',
'alpha'),
233 $result = $product->correct_stock(
240 GETPOST(
'inventorycode',
'alpha'),
247 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
252 $action =
'correction';
262if ($action ==
"transfert_stock" && !$cancel && $usercancreate) {
265 if (!empty($product_id)) {
266 $result = $product->fetch($product_id);
269 if (!(
GETPOSTINT(
"id_entrepot_destination") > 0)) {
270 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Warehouse")),
null,
'errors');
272 $action =
'transfert';
274 if (empty($product_id)) {
276 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Product")),
null,
'errors');
277 $action =
'transfert';
280 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"NumberOfUnit")),
null,
'errors');
282 $action =
'transfert';
284 if ($id ==
GETPOSTINT(
"id_entrepot_destination")) {
285 setEventMessages($langs->trans(
"ErrorSrcAndTargetWarehouseMustDiffers"),
null,
'errors');
287 $action =
'transfert';
290 if (isModEnabled(
'productbatch')) {
292 $result = $product->fetch($product_id);
294 if ($product->hasbatch() && !
GETPOST(
"batch_number",
'alpha')) {
295 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"batch_number")),
null,
'errors');
297 $action =
'transfert';
308 $product->load_stock(
'novirtual');
312 if (isset($product->pmp)) {
313 $pricesrc = $product->pmp;
315 $pricedest = $pricesrc;
317 if ($product->hasbatch()) {
321 $result = $pdluo->fetch($pdluoid);
323 $srcwarehouseid = $pdluo->warehouseid;
324 $batch = $pdluo->batch;
325 $eatby = $pdluo->eatby;
326 $sellby = $pdluo->sellby;
332 $srcwarehouseid =
$id;
333 $batch =
GETPOST(
'batch_number',
'alpha');
340 $result1 = $product->correct_stock_batch(
350 GETPOST(
'inventorycode',
'alpha')
353 $result2 = $product->correct_stock_batch(
363 GETPOST(
'inventorycode',
'alpha')
368 $result1 = $product->correct_stock(
375 GETPOST(
'inventorycode',
'alpha')
379 $result2 = $product->correct_stock(
381 GETPOST(
"id_entrepot_destination"),
386 GETPOST(
'inventorycode',
'alpha')
389 if (!$error && $result1 >= 0 && $result2 >= 0) {
393 header(
"Location: ".$backtopage);
396 header(
"Location: movement_list.php?id=".
$object->id);
402 $action =
'transfert';
414$upload_dir =
$conf->stock->dir_output.
"movement/";
415$permissiontoadd = $user->hasRight(
'stock',
'creer');
416include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
419if (empty($reshook) && $action !=
'remove_file') {
420 $objectclass =
'MouvementStock';
421 $objectlabel =
'Movements';
422 $permissiontoread = $user->hasRight(
'stock',
'lire');
423 $permissiontodelete = $user->hasRight(
'stock',
'supprimer');
424 $uploaddir =
$conf->stock->dir_output.
"/movement/";
425 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
435$productstatic =
new Product($db);
436$warehousestatic =
new Entrepot($db);
438$userstatic =
new User($db);
439$form =
new Form($db);
442if (isModEnabled(
'project')) {
446$sql =
"SELECT p.rowid, p.ref as product_ref, p.label as produit, p.tobatch, p.fk_product_type as type, p.entity,";
447$sql .=
" e.ref as warehouse_ref, e.rowid as entrepot_id, e.lieu,";
448$sql .=
" m.rowid as mid, m.value as qty, m.datem, m.fk_user_author, m.label, m.inventorycode, m.fk_origin, m.origintype,";
449$sql .=
" m.batch, m.price,";
450$sql .=
" m.type_mouvement,";
451$sql .=
" pl.rowid as lotid, pl.eatby, pl.sellby,";
452$sql .=
" u.login, u.photo, u.lastname, u.firstname";
454if (!empty($extrafields->attributes[
$object->table_element][
'label'])) {
455 foreach ($extrafields->attributes[
$object->table_element][
'label'] as $key => $val) {
456 $sql .= ($extrafields->attributes[
$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
460$parameters = array();
461$reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters);
462$sql .= $hookmanager->resPrint;
463$sql .=
" FROM ".MAIN_DB_PREFIX.
"entrepot as e,";
464$sql .=
" ".MAIN_DB_PREFIX.
"product as p,";
465$sql .=
" ".MAIN_DB_PREFIX.
"stock_mouvement as m";
466if (isset($extrafields->attributes[
$object->table_element][
'label']) && is_array($extrafields->attributes[
$object->table_element][
'label']) && count($extrafields->attributes[
$object->table_element][
'label'])) {
467 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element.
"_extrafields as ef on (m.rowid = ef.fk_object)";
469$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u ON m.fk_user_author = u.rowid";
470$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product_lot as pl ON m.batch = pl.batch AND m.fk_product = pl.fk_product";
471$sql .=
" WHERE m.fk_product = p.rowid";
473 $sql .=
" AND m.rowid = ".((int) $msid);
475$sql .=
" AND m.fk_entrepot = e.rowid";
476$sql .=
" AND e.entity IN (".getEntity(
'stock').
")";
478 $sql .=
" AND p.fk_product_type = 0";
481 $sql .=
" AND e.rowid = ".((int) $id);
485 $sql .=
" AND p.rowid = ".((int) $idproduct);
487if (!empty($search_ref)) {
490if (!empty($search_movement)) {
493if (!empty($search_inventorycode)) {
496if (!empty($search_product_ref)) {
499if (!empty($search_product)) {
502if ($search_warehouse !=
'' && $search_warehouse !=
'-1') {
505if (!empty($search_user)) {
506 $sql .=
natural_search(array(
'u.lastname',
'u.firstname',
'u.login'), $search_user);
508if (!empty($search_batch)) {
511if ($search_qty !=
'') {
514if ($search_type_mouvement !=
'' && $search_type_mouvement !=
'-1') {
515 $sql .=
natural_search(
'm.type_mouvement', $search_type_mouvement, 2);
518include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
520$parameters = array();
521$reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters);
522$sql .= $hookmanager->resPrint;
523$sql .= $db->order($sortfield, $sortorder);
525$nbtotalofrecords =
'';
527 $result = $db->query($sql);
528 $nbtotalofrecords = $db->num_rows($result);
529 if (($page * $limit) > $nbtotalofrecords) {
537$resql = $db->query($sql);
543 if ($idproduct > 0) {
544 $product->fetch($idproduct);
546 if ($id > 0 || $ref) {
547 $result =
$object->fetch($id, $ref);
553 $num = $db->num_rows($resql);
555 $arrayofselected = is_array($toselect) ? $toselect : array();
559 $help_url =
'EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks';
561 $texte = $langs->trans(
'StockMovementForId', $msid);
563 $texte = $langs->trans(
"StockMovements");
565 $texte .=
' ('.$langs->trans(
"ForThisWarehouse").
')';
568 llxHeader(
"", $texte, $help_url,
'', 0, 0,
'',
'',
'',
'mod-product page-stock_movement_card');
576 print
dol_get_fiche_head($head,
'movements', $langs->trans(
"Warehouse"), -1,
'stock');
579 $linkback =
'<a href="'.DOL_URL_ROOT.
'/product/stock/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
581 $morehtmlref =
'<div class="refidno">';
582 $morehtmlref .= $langs->trans(
"LocationSummary").
' : '.
$object->lieu;
583 $morehtmlref .=
'</div>';
586 if ($user->socid && !in_array(
'stock', explode(
',',
getDolGlobalString(
'MAIN_MODULES_FOR_EXTERNAL')))) {
590 dol_banner_tab($object,
'ref', $linkback, $shownav,
'ref',
'ref', $morehtmlref);
593 print
'<div class="fichecenter">';
594 print
'<div class="fichehalfleft">';
595 print
'<div class="underbanner clearboth"></div>';
597 print
'<table class="border centpercent">';
602 print
'<td class="titlefield tdtop">'.$langs->trans(
"Description").
'</td><td>'.
dol_htmlentitiesbr(
$object->description).
'</td></tr>';
604 $calcproductsunique =
$object->nb_different_products();
605 $calcproducts =
$object->nb_products();
608 print
'<tr><td>'.$langs->trans(
"NumberOfDifferentProducts").
'</td><td>';
609 print empty($calcproductsunique[
'nb']) ?
'0' : $calcproductsunique[
'nb'];
613 print
'<tr><td>'.$langs->trans(
"NumberOfProducts").
'</td><td>';
614 $valtoshow =
price2num($calcproducts[
'nb'],
'MS');
615 print empty($valtoshow) ?
'0' : $valtoshow;
621 print
'<div class="fichehalfright">';
622 print
'<div class="underbanner clearboth"></div>';
624 print
'<table class="border centpercent">';
627 print
'<tr><td class="titlefield">'.$langs->trans(
"EstimatedStockValueShort").
'</td><td>';
628 print
price((empty($calcproducts[
'value']) ?
'0' :
price2num($calcproducts[
'value'],
'MT')), 0, $langs, 0, -1, -1,
$conf->currency);
632 $sql =
"SELECT MAX(m.datem) as datem";
633 $sql .=
" FROM ".MAIN_DB_PREFIX.
"stock_mouvement as m";
634 $sql .=
" WHERE m.fk_entrepot = ".(int)
$object->id;
635 $resqlbis = $db->query($sql);
637 $obj = $db->fetch_object($resqlbis);
638 $lastmovementdate = $db->jdate($obj->datem);
643 print
'<tr><td>'.$langs->trans(
"LastMovement").
'</td><td>';
644 if ($lastmovementdate) {
647 print $langs->trans(
"None");
656 print
'<div class="clearboth"></div>';
665 if ($action ==
"correction") {
666 include DOL_DOCUMENT_ROOT.
'/product/stock/tpl/stockcorrection.tpl.php';
673 if ($action ==
"transfert") {
674 include DOL_DOCUMENT_ROOT.
'/product/stock/tpl/stocktransfer.tpl.php';
682 if ((empty($action) || $action ==
'list') && $id > 0) {
683 print
"<div class=\"tabsAction\">\n";
685 if ($user->hasRight(
'stock',
'mouvement',
'creer')) {
686 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$id.
'&action=correction&token='.
newToken().
'">'.$langs->trans(
"CorrectStock").
'</a>';
689 if ($user->hasRight(
'stock',
'mouvement',
'creer')) {
690 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$id.
'&action=transfert&token='.
newToken().
'">'.$langs->trans(
"TransferStock").
'</a>';
697 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
698 $param .=
'&contextpage='.urlencode($contextpage);
700 if ($limit > 0 && $limit !=
$conf->liste_limit) {
701 $param .=
'&limit='.((int) $limit);
704 $param .=
'&id='.urlencode((
string) (
$id));
706 if ($search_movement) {
707 $param .=
'&search_movement='.urlencode($search_movement);
709 if ($search_inventorycode) {
710 $param .=
'&search_inventorycode='.urlencode($search_inventorycode);
712 if ($search_type_mouvement) {
713 $param .=
'&search_type_mouvement='.urlencode($search_type_mouvement);
715 if ($search_product_ref) {
716 $param .=
'&search_product_ref='.urlencode($search_product_ref);
718 if ($search_product) {
719 $param .=
'&search_product='.urlencode($search_product);
722 $param .=
'&search_batch='.urlencode($search_batch);
724 if ($search_warehouse > 0) {
725 $param .=
'&search_warehouse='.urlencode($search_warehouse);
728 $param .=
'&search_user='.urlencode($search_user);
730 if ($idproduct > 0) {
731 $param .=
'&idproduct='.urlencode((
string) ($idproduct));
734 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
737 $arrayofmassactions = array(
742 if (in_array($massaction, array(
'presend',
'predelete'))) {
743 $arrayofmassactions = array();
745 $massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
747 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
748 if ($optioncss !=
'') {
749 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
751 print
'<input type="hidden" name="token" value="'.newToken().
'">';
752 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
753 print
'<input type="hidden" name="action" value="list">';
754 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
755 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
756 print
'<input type="hidden" name="page" value="'.$page.
'">';
757 print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
759 print
'<input type="hidden" name="id" value="'.$id.
'">';
763 print_barre_liste($texte, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'', 0,
'',
'', $limit);
765 print_barre_liste($texte, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'generic', 0,
'',
'', $limit);
769 if (!isset($fieldstosearchall) || !is_array($fieldstosearchall)) {
771 $fieldstosearchall = array();
773 foreach ($fieldstosearchall as $key => $val) {
774 $fieldstosearchall[$key] = $langs->trans($val);
776 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $sall).implode(
', ', $fieldstosearchall).
'</div>';
781 $parameters = array();
782 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters);
783 if (empty($reshook)) {
784 $moreforfilter .= $hookmanager->resPrint;
786 $moreforfilter = $hookmanager->resPrint;
789 if (!empty($moreforfilter)) {
790 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
791 print $moreforfilter;
795 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
796 $selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage);
798 print
'<div class="div-table-responsive">';
799 print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
802 print
'<tr class="liste_titre_filter">';
803 if (!empty($arrayfields[
'm.rowid'][
'checked'])) {
805 print
'<td class="liste_titre left">';
806 print
'<input class="flat maxwidth25" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).
'">';
809 if (!empty($arrayfields[
'm.datem'][
'checked'])) {
810 print
'<td class="liste_titre nowraponall">';
811 print
'<input class="flat" type="text" size="2" maxlength="2" placeholder="'.dol_escape_htmltag($langs->trans(
"Month")).
'" name="month" value="'.$month.
'">';
812 if (empty(
$conf->productbatch->enabled)) {
816 $syear = $year ? $year : -1;
817 print
'<input class="flat maxwidth50" type="text" maxlength="4" placeholder="'.dol_escape_htmltag($langs->trans(
"Year")).
'" name="year" value="'.($syear > 0 ? $syear :
'').
'">';
821 if (!empty($arrayfields[
'p.ref'][
'checked'])) {
823 print
'<td class="liste_titre left">';
824 print
'<input class="flat maxwidth75" type="text" name="search_product_ref" value="'.dol_escape_htmltag($idproduct ? $product->ref : $search_product_ref).
'">';
827 if (!empty($arrayfields[
'p.label'][
'checked'])) {
829 print
'<td class="liste_titre left">';
830 print
'<input class="flat maxwidth100" type="text" name="search_product" value="'.dol_escape_htmltag($idproduct ? $product->label : $search_product).
'">';
834 if (!empty($arrayfields[
'm.batch'][
'checked'])) {
835 print
'<td class="liste_titre center"><input class="flat maxwidth75" type="text" name="search_batch" value="'.dol_escape_htmltag($search_batch).
'"></td>';
837 if (!empty($arrayfields[
'pl.eatby'][
'checked'])) {
838 print
'<td class="liste_titre left">';
841 if (!empty($arrayfields[
'pl.sellby'][
'checked'])) {
842 print
'<td class="liste_titre left">';
846 if (!empty($arrayfields[
'e.ref'][
'checked'])) {
847 print
'<td class="liste_titre maxwidthonsmartphone left">';
849 print $formproduct->selectWarehouses($search_warehouse,
'search_warehouse',
'warehouseopen,warehouseinternal', 1, 0, 0,
'', 0, 0, array(),
'maxwidth200');
852 if (!empty($arrayfields[
'm.fk_user_author'][
'checked'])) {
854 print
'<td class="liste_titre left">';
855 print
'<input class="flat" type="text" size="6" name="search_user" value="'.dol_escape_htmltag($search_user).
'">';
858 if (!empty($arrayfields[
'm.inventorycode'][
'checked'])) {
860 print
'<td class="liste_titre left">';
861 print
'<input class="flat" type="text" size="4" name="search_inventorycode" value="'.dol_escape_htmltag($search_inventorycode).
'">';
864 if (!empty($arrayfields[
'm.label'][
'checked'])) {
866 print
'<td class="liste_titre left">';
867 print
'<input class="flat" type="text" size="8" name="search_movement" value="'.dol_escape_htmltag($search_movement).
'">';
870 if (!empty($arrayfields[
'm.type_mouvement'][
'checked'])) {
872 print
'<td class="liste_titre center">';
874 print
'<select id="search_type_mouvement" name="search_type_mouvement" class="maxwidth150">';
875 print
'<option value="" '.(($search_type_mouvement ==
"") ?
'selected="selected"' :
'').
'></option>';
876 print
'<option value="0" '.(($search_type_mouvement ==
"0") ?
'selected="selected"' :
'').
'>'.$langs->trans(
'StockIncreaseAfterCorrectTransfer').
'</option>';
877 print
'<option value="1" '.(($search_type_mouvement ==
"1") ?
'selected="selected"' :
'').
'>'.$langs->trans(
'StockDecreaseAfterCorrectTransfer').
'</option>';
878 print
'<option value="2" '.(($search_type_mouvement ==
"2") ?
'selected="selected"' :
'').
'>'.$langs->trans(
'StockDecrease').
'</option>';
879 print
'<option value="3" '.(($search_type_mouvement ==
"3") ?
'selected="selected"' :
'').
'>'.$langs->trans(
'StockIncrease').
'</option>';
886 if (!empty($arrayfields[
'origin'][
'checked'])) {
888 print
'<td class="liste_titre left">';
892 if (!empty($arrayfields[
'm.value'][
'checked'])) {
894 print
'<td class="liste_titre right">';
895 print
'<input class="flat" type="text" size="4" name="search_qty" value="'.dol_escape_htmltag($search_qty).
'">';
898 if (!empty($arrayfields[
'm.price'][
'checked'])) {
900 print
'<td class="liste_titre left">';
907 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
910 $parameters = array(
'arrayfields' => $arrayfields);
911 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters);
912 print $hookmanager->resPrint;
914 if (!empty($arrayfields[
'm.datec'][
'checked'])) {
915 print
'<td class="liste_titre">';
919 if (!empty($arrayfields[
'm.tms'][
'checked'])) {
920 print
'<td class="liste_titre">';
924 print
'<td class="liste_titre maxwidthsearch">';
925 $searchpicto = $form->showFilterAndCheckAddButtons(0);
930 print
'<tr class="liste_titre">';
931 if (!empty($arrayfields[
'm.rowid'][
'checked'])) {
932 print_liste_field_titre($arrayfields[
'm.rowid'][
'label'], $_SERVER[
"PHP_SELF"],
'm.rowid',
'', $param,
'', $sortfield, $sortorder);
934 if (!empty($arrayfields[
'm.datem'][
'checked'])) {
935 print_liste_field_titre($arrayfields[
'm.datem'][
'label'], $_SERVER[
"PHP_SELF"],
'm.datem',
'', $param,
'', $sortfield, $sortorder);
937 if (!empty($arrayfields[
'p.ref'][
'checked'])) {
938 print_liste_field_titre($arrayfields[
'p.ref'][
'label'], $_SERVER[
"PHP_SELF"],
'p.ref',
'', $param,
'', $sortfield, $sortorder);
940 if (!empty($arrayfields[
'p.label'][
'checked'])) {
941 print_liste_field_titre($arrayfields[
'p.label'][
'label'], $_SERVER[
"PHP_SELF"],
'p.label',
'', $param,
'', $sortfield, $sortorder);
943 if (!empty($arrayfields[
'm.batch'][
'checked'])) {
944 print_liste_field_titre($arrayfields[
'm.batch'][
'label'], $_SERVER[
"PHP_SELF"],
'm.batch',
'', $param,
'', $sortfield, $sortorder,
'center ');
946 if (!empty($arrayfields[
'pl.eatby'][
'checked'])) {
947 print_liste_field_titre($arrayfields[
'pl.eatby'][
'label'], $_SERVER[
"PHP_SELF"],
'pl.eatby',
'', $param,
'', $sortfield, $sortorder,
'center ');
949 if (!empty($arrayfields[
'pl.sellby'][
'checked'])) {
950 print_liste_field_titre($arrayfields[
'pl.sellby'][
'label'], $_SERVER[
"PHP_SELF"],
'pl.sellby',
'', $param,
'', $sortfield, $sortorder,
'center ');
952 if (!empty($arrayfields[
'e.ref'][
'checked'])) {
954 print_liste_field_titre($arrayfields[
'e.ref'][
'label'], $_SERVER[
"PHP_SELF"],
"e.ref",
"", $param,
"", $sortfield, $sortorder);
956 if (!empty($arrayfields[
'm.fk_user_author'][
'checked'])) {
957 print_liste_field_titre($arrayfields[
'm.fk_user_author'][
'label'], $_SERVER[
"PHP_SELF"],
"m.fk_user_author",
"", $param,
"", $sortfield, $sortorder);
959 if (!empty($arrayfields[
'm.inventorycode'][
'checked'])) {
960 print_liste_field_titre($arrayfields[
'm.inventorycode'][
'label'], $_SERVER[
"PHP_SELF"],
"m.inventorycode",
"", $param,
"", $sortfield, $sortorder);
962 if (!empty($arrayfields[
'm.label'][
'checked'])) {
963 print_liste_field_titre($arrayfields[
'm.label'][
'label'], $_SERVER[
"PHP_SELF"],
"m.label",
"", $param,
"", $sortfield, $sortorder);
965 if (!empty($arrayfields[
'm.type_mouvement'][
'checked'])) {
966 print_liste_field_titre($arrayfields[
'm.type_mouvement'][
'label'], $_SERVER[
"PHP_SELF"],
"m.type_mouvement",
"", $param,
'', $sortfield, $sortorder,
'center ');
968 if (!empty($arrayfields[
'origin'][
'checked'])) {
969 print_liste_field_titre($arrayfields[
'origin'][
'label'], $_SERVER[
"PHP_SELF"],
"",
"", $param,
"", $sortfield, $sortorder);
971 if (!empty($arrayfields[
'm.value'][
'checked'])) {
972 print_liste_field_titre($arrayfields[
'm.value'][
'label'], $_SERVER[
"PHP_SELF"],
"m.value",
"", $param,
'', $sortfield, $sortorder,
'right ');
974 if (!empty($arrayfields[
'm.price'][
'checked'])) {
975 print_liste_field_titre($arrayfields[
'm.price'][
'label'], $_SERVER[
"PHP_SELF"],
"m.price",
"", $param,
'', $sortfield, $sortorder,
'right ');
979 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
982 $parameters = array(
'arrayfields' => $arrayfields,
'param' => $param,
'sortfield' => $sortfield,
'sortorder' => $sortorder);
983 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters);
984 print $hookmanager->resPrint;
985 if (!empty($arrayfields[
'm.datec'][
'checked'])) {
986 print_liste_field_titre($arrayfields[
'm.datec'][
'label'], $_SERVER[
"PHP_SELF"],
"m.datec",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
988 if (!empty($arrayfields[
'm.tms'][
'checked'])) {
989 print_liste_field_titre($arrayfields[
'm.tms'][
'label'], $_SERVER[
"PHP_SELF"],
"m.tms",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
991 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
995 $arrayofuniqueproduct = array();
996 while ($i < ($limit ? min($num, $limit) : $num)) {
997 $objp = $db->fetch_object($resql);
999 $userstatic->id = $objp->fk_user_author;
1000 $userstatic->login = $objp->login;
1001 $userstatic->lastname = $objp->lastname;
1002 $userstatic->firstname = $objp->firstname;
1003 $userstatic->photo = $objp->photo;
1005 $productstatic->id = $objp->rowid;
1006 $productstatic->ref = $objp->product_ref;
1007 $productstatic->label = $objp->produit;
1008 $productstatic->type = $objp->type;
1009 $productstatic->entity = $objp->entity;
1010 $productstatic->status_batch = $objp->tobatch;
1012 $productlot->id = $objp->lotid;
1013 $productlot->batch = $objp->batch;
1014 $productlot->eatby = $objp->eatby;
1015 $productlot->sellby = $objp->sellby;
1017 $warehousestatic->id = $objp->entrepot_id;
1018 $warehousestatic->label = $objp->warehouse_ref;
1019 $warehousestatic->lieu = $objp->lieu;
1021 $arrayofuniqueproduct[$objp->rowid] = $objp->produit;
1022 if (!empty($objp->fk_origin)) {
1023 $origin = $movement->get_origin($objp->fk_origin, $objp->origintype);
1028 print
'<tr class="oddeven">';
1030 if (!empty($arrayfields[
'm.rowid'][
'checked'])) {
1032 print
'<td>'.$objp->mid.
'</td>';
1034 if (!empty($arrayfields[
'm.datem'][
'checked'])) {
1036 print
'<td>'.dol_print_date($db->jdate($objp->datem),
'dayhour').
'</td>';
1038 if (!empty($arrayfields[
'p.ref'][
'checked'])) {
1040 print
'<td class="nowraponall">';
1041 print $productstatic->getNomUrl(1,
'stock', 16);
1044 if (!empty($arrayfields[
'p.label'][
'checked'])) {
1051 print $productstatic->label;
1054 if (!empty($arrayfields[
'm.batch'][
'checked'])) {
1055 print
'<td class="center nowraponall">';
1056 if ($productlot->id > 0) {
1057 print $productlot->getNomUrl(1);
1059 print $productlot->batch;
1063 if (!empty($arrayfields[
'pl.eatby'][
'checked'])) {
1064 print
'<td class="center">'.dol_print_date($objp->eatby,
'day').
'</td>';
1066 if (!empty($arrayfields[
'pl.sellby'][
'checked'])) {
1067 print
'<td class="center">'.dol_print_date($objp->sellby,
'day').
'</td>';
1070 if (!empty($arrayfields[
'e.ref'][
'checked'])) {
1072 print $warehousestatic->getNomUrl(1);
1076 if (!empty($arrayfields[
'm.fk_user_author'][
'checked'])) {
1077 print
'<td class="tdoverflowmax100">';
1078 print $userstatic->getNomUrl(-1);
1081 if (!empty($arrayfields[
'm.inventorycode'][
'checked'])) {
1083 print
'<td><a href="'
1084 .DOL_URL_ROOT.
'/product/stock/movement_card.php?id='.urlencode($objp->entrepot_id)
1085 .
'&search_inventorycode='.urlencode($objp->inventorycode)
1086 .
'&search_type_mouvement='.urlencode($objp->type_mouvement)
1088 .$objp->inventorycode
1091 if (!empty($arrayfields[
'm.label'][
'checked'])) {
1093 print
'<td class="tdoverflowmax100">'.$objp->label.
'</td>';
1095 if (!empty($arrayfields[
'm.type_mouvement'][
'checked'])) {
1097 switch ($objp->type_mouvement) {
1099 print
'<td class="center">'.$langs->trans(
'StockIncreaseAfterCorrectTransfer').
'</td>';
1102 print
'<td class="center">'.$langs->trans(
'StockDecreaseAfterCorrectTransfer').
'</td>';
1105 print
'<td class="center">'.$langs->trans(
'StockDecrease').
'</td>';
1108 print
'<td class="center">'.$langs->trans(
'StockIncrease').
'</td>';
1112 if (!empty($arrayfields[
'origin'][
'checked'])) {
1114 print
'<td class="nowraponall">'.$origin.
'</td>';
1116 if (!empty($arrayfields[
'm.value'][
'checked'])) {
1118 print
'<td class="right">';
1119 if ($objp->qt > 0) {
1125 if (!empty($arrayfields[
'm.price'][
'checked'])) {
1127 print
'<td class="right">';
1128 if ($objp->price != 0) {
1129 print
price($objp->price);
1134 print
'<td class="nowrap center">';
1135 if ($massactionbutton || $massaction) {
1137 if (in_array($obj->rowid, $arrayofselected)) {
1140 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
1144 $totalarray[
'nbfield']++;
1157 if (count($arrayofuniqueproduct) == 1 && is_numeric($year)) {
1160 $productidselected = 0;
1161 foreach ($arrayofuniqueproduct as $key => $val) {
1162 $productidselected = $key;
1163 $productlabelselected = $val;
1167 $balancebefore = $movement->calculateBalanceForProductBefore($productidselected, $datebefore);
1168 $balanceafter = $movement->calculateBalanceForProductBefore($productidselected, $dateafter);
1171 print $langs->trans(
"NbOfProductBeforePeriod", $productlabelselected,
dol_print_date($datebefore,
'day',
'gmt'));
1174 print
': '.$balancebefore;
1178 print $langs->trans(
"NbOfProductAfterPeriod", $productlabelselected,
dol_print_date($dateafter,
'day',
'gmt'));
1181 print
': '.$balanceafter;
1195$modulepart =
'movement';
1197if ($action !=
'create' && $action !=
'edit' && $action !=
'delete' && $id > 0) {
1199 print
'<div class="fichecenter"><div class="fichehalfleft">';
1200 print
'<a name="builddoc"></a>';
1205 if (!empty($search_inventorycode)) {
1206 $objectref .=
"_".$id.
"_".$search_inventorycode;
1208 if ($search_type_mouvement) {
1209 $objectref .=
"_".$search_type_mouvement;
1211 $relativepath = $comref.
'/'.$objectref.
'.pdf';
1212 $filedir =
$conf->stock->dir_output.
'/movement/'.$objectref;
1214 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".
$object->id.
"&search_inventorycode=".$search_inventorycode.
"&search_type_mouvement=$search_type_mouvement";
1215 $genallowed = $usercanread;
1216 $delallowed = $usercancreate;
1218 $genallowed = $user->hasRight(
'stock',
'lire');
1219 $delallowed = $user->hasRight(
'stock',
'creer');
1221 print $formfile->showdocuments($modulepart, $objectref, $filedir, $urlsource, $genallowed, $delallowed,
'', 0, 0, 0, 28, 0,
'', 0,
'',
$object->default_lang,
'', $object);
1222 $somethingshown = $formfile->numoffiles;
1224 print
'</div><div class="fichehalfright">';
1228 $morehtmlcenter =
dolGetButtonTitle($langs->trans(
'SeeAll'),
'',
'fa fa-bars imgforviewmode', DOL_URL_ROOT.
'/product/agenda.php?id='.
$object->id);
1231 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
1233 $somethingshown = $formactions->showactions($object,
'mouvement', 0, 1,
'', $MAXEVENT,
'', $morehtmlcenter);
1235 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.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
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.