31 require
'../../main.inc.php';
32 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
33 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
34 require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/entrepot.class.php';
35 require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/mouvementstock.class.php';
36 require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/productlot.class.php';
37 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
38 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
39 require_once DOL_DOCUMENT_ROOT.
'/core/lib/stock.lib.php';
40 require_once DOL_DOCUMENT_ROOT.
'/core/lib/product.lib.php';
41 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
42 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
44 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
45 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
49 $langs->loadLangs(array(
'products',
'stocks',
'orders'));
51 $langs->load(
"productbatch");
54 $action =
GETPOST(
'action',
'aZ09');
55 $massaction =
GETPOST(
'massaction',
'alpha');
56 $confirm =
GETPOST(
'confirm',
'alpha');
57 $cancel =
GETPOST(
'cancel',
'alpha');
58 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') : str_replace(
'_',
'', basename(dirname(__FILE__)).basename(__FILE__,
'.php'));
59 $toselect =
GETPOST(
'toselect',
'array');
60 $backtopage =
GETPOST(
"backtopage",
"alpha");
61 $optioncss =
GETPOST(
'optioncss',
'aZ');
62 $show_files =
GETPOST(
'show_files',
'aZ');
68 $idproduct =
GETPOST(
'idproduct',
'intcomma');
69 $product_id =
GETPOST(
"product_id",
'intcomma');
72 $search_all = trim((
GETPOST(
'search_all',
'alphanohtml') !=
'') ?
GETPOST(
'search_all',
'alphanohtml') :
GETPOST(
'sall',
'alphanohtml'));
73 $search_date_startday =
GETPOSTINT(
'search_date_startday');
74 $search_date_startmonth =
GETPOSTINT(
'search_date_startmonth');
75 $search_date_startyear =
GETPOSTINT(
'search_date_startyear');
76 $search_date_endday =
GETPOSTINT(
'search_date_endday');
77 $search_date_endmonth =
GETPOSTINT(
'search_date_endmonth');
78 $search_date_endyear =
GETPOSTINT(
'search_date_endyear');
81 $search_ref =
GETPOST(
'search_ref',
'alpha');
82 $search_movement =
GETPOST(
"search_movement");
83 $search_product_ref = trim(
GETPOST(
"search_product_ref"));
84 $search_product = trim(
GETPOST(
"search_product"));
85 $search_warehouse = trim(
GETPOST(
"search_warehouse"));
86 $search_inventorycode = trim(
GETPOST(
"search_inventorycode"));
87 $search_user = trim(
GETPOST(
"search_user"));
88 $search_batch = trim(
GETPOST(
"search_batch"));
89 $search_qty = trim(
GETPOST(
"search_qty"));
90 $search_type_mouvement =
GETPOST(
'search_type_mouvement');
91 $search_fk_project =
GETPOST(
"search_fk_project");
97 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
98 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
100 if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
104 $offset = $limit * $page;
105 $pageprev = $page - 1;
106 $pagenext = $page + 1;
109 $sortfield =
"m.datem";
120 $diroutputmassaction = $conf->stock->dir_output.
'/temp/massgeneration/'.$user->id;
121 $hookmanager->initHooks(array($contextpage));
126 $extrafields->fetch_name_optionals_label(
$object->table_element);
128 $search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
130 $arrayfields = array(
131 'm.rowid' => array(
'label' =>
"Ref",
'checked' => 1,
'position' => 1),
132 'm.datem' => array(
'label' =>
"Date",
'checked' => 1,
'position' => 2),
133 'p.ref' => array(
'label' =>
"ProductRef",
'checked' => 1,
'css' =>
'maxwidth100',
'position' => 3),
134 'p.label' => array(
'label' =>
"ProductLabel",
'checked' => 0,
'position' => 5),
135 'm.batch' => array(
'label' =>
"BatchNumberShort",
'checked' => 1,
'position' => 8,
'enabled' => (
isModEnabled(
'productbatch'))),
136 'pl.eatby' => array(
'label' =>
"EatByDate",
'checked' => 0,
'position' => 9,
'enabled' => (
isModEnabled(
'productbatch'))),
137 'pl.sellby' => array(
'label' =>
"SellByDate",
'checked' => 0,
'position' => 10,
'enabled' => (
isModEnabled(
'productbatch'))),
138 'e.ref' => array(
'label' =>
"Warehouse",
'checked' => 1,
'position' => 100,
'enabled' => (!($id > 0))),
139 'm.fk_user_author' => array(
'label' =>
"Author",
'checked' => 0,
'position' => 120),
140 'm.inventorycode' => array(
'label' =>
"InventoryCodeShort",
'checked' => 1,
'position' => 130),
141 'm.label' => array(
'label' =>
"MovementLabel",
'checked' => 1,
'position' => 140),
142 'm.type_mouvement' => array(
'label' =>
"TypeMovement",
'checked' => 0,
'position' => 150),
143 'origin' => array(
'label' =>
"Origin",
'checked' => 1,
'position' => 155),
144 'm.fk_projet' => array(
'label' =>
'Project',
'checked' => 0,
'position' => 180),
145 'm.value' => array(
'label' =>
"Qty",
'checked' => 1,
'position' => 200),
146 'm.price' => array(
'label' =>
"UnitPurchaseValue",
'checked' => 0,
'position' => 210,
'enabled' => (!
getDolGlobalInt(
'STOCK_MOVEMENT_LIST_HIDE_UNIT_PRICE')))
151 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
154 unset($arrayfields[
'pl.sellby']);
157 unset($arrayfields[
'pl.eatby']);
162 if ($id > 0 || !empty($ref)) {
163 $tmpwarehouse->fetch($id, $ref);
164 $id = $tmpwarehouse->id;
173 if (!$user->hasRight(
'stock',
'mouvement',
'lire')) {
177 $uploaddir = $conf->stock->dir_output.
'/movements';
179 $permissiontoread = $user->hasRight(
'stock',
'mouvement',
'lire');
180 $permissiontoadd = $user->hasRight(
'stock',
'mouvement',
'creer');
181 $permissiontodelete = $user->hasRight(
'stock',
'mouvement',
'creer');
183 $usercanread = $user->hasRight(
'stock',
'mouvement',
'lire');
184 $usercancreate = $user->hasRight(
'stock',
'mouvement',
'creer');
185 $usercandelete = $user->hasRight(
'stock',
'mouvement',
'creer');
194 if (
GETPOST(
'cancel',
'alpha')) {
198 if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
202 $parameters = array();
203 $reshook = $hookmanager->executeHooks(
'doActions', $parameters,
$object, $action);
208 if (empty($reshook)) {
210 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
213 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
214 $search_date_startday =
'';
215 $search_date_startmonth =
'';
216 $search_date_startyear =
'';
217 $search_date_endday =
'';
218 $search_date_endmonth =
'';
219 $search_date_endyear =
'';
220 $search_date_start =
'';
221 $search_date_end =
'';
223 $search_movement =
"";
224 $search_type_mouvement =
"";
225 $search_inventorycode =
"";
226 $search_product_ref =
"";
227 $search_product =
"";
228 $search_warehouse =
"";
232 $search_fk_project =
"";
235 $search_array_options = array();
237 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')
238 ||
GETPOST(
'button_search_x',
'alpha') ||
GETPOST(
'button_search.x',
'alpha') ||
GETPOST(
'button_search',
'alpha')) {
243 $objectclass =
'MouvementStock';
244 $objectlabel =
'MouvementStock';
246 if (!$error && $massaction ==
"builddoc" && $permissiontoread && !
GETPOST(
'button_search')) {
247 if (empty($diroutputmassaction)) {
248 dol_print_error(
null,
'include of actions_massactions.inc.php is done but var $diroutputmassaction was not defined');
252 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
253 require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
254 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
257 $listofobjectid = array();
258 foreach ($toselect as $toselectid) {
260 $result = $objecttmp->fetch($toselectid);
262 $listofobjectid[$toselectid] = $toselectid;
266 $arrayofinclusion = array();
267 foreach ($listofobjectref as $tmppdf) {
270 foreach ($listofobjectref as $tmppdf) {
271 $arrayofinclusion[] =
'^'.preg_quote(
dol_sanitizeFileName($tmppdf),
'/').
'_[a-zA-Z0-9-_]+\.pdf$';
273 $listoffiles =
dol_dir_list($uploaddir,
'all', 1, implode(
'|', $arrayofinclusion),
'\.meta$|\.png',
'date', SORT_DESC, 0,
true);
276 $outputlangs = $langs;
279 $newlang =
GETPOST(
'lang_id',
'aZ09');
284 if (!empty($newlang)) {
286 $outputlangs->setDefaultLang($newlang);
294 $filename = preg_replace(
'/\s/',
'_', $filename);
306 $file = $diroutputmassaction.
'/'.$filename.
'_'.
dol_print_date($now,
'dayhourlog').
'.pdf';
315 $langs->load(
"exports");
324 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
327 if ($action ==
'update_extras' && $permissiontoadd) {
328 $tmpwarehouse->oldcopy =
dol_clone($tmpwarehouse, 2);
331 $ret = $extrafields->setOptionalsFromPost(
null, $tmpwarehouse,
GETPOST(
'attribute',
'restricthtml'));
336 $result = $tmpwarehouse->insertExtraFields();
343 $action =
'edit_extras';
348 if ($action ==
"correct_stock" && $permissiontoadd) {
350 if (!empty($product_id)) {
351 $result = $product->fetch($product_id);
356 if (empty($product_id)) {
358 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Product")),
null,
'errors');
359 $action =
'correction';
361 if (!is_numeric(
GETPOST(
"nbpiece"))) {
363 setEventMessages($langs->trans(
"ErrorFieldMustBeANumeric", $langs->transnoentitiesnoconv(
"NumberOfUnit")),
null,
'errors');
364 $action =
'correction';
368 $origin_element =
'';
372 $origin_element =
'project';
376 if ($product->hasbatch()) {
377 $batch =
GETPOST(
'batch_number',
'alphanohtml');
384 $result = $product->correct_stock_batch(
389 GETPOST(
"label",
'alphanohtml'),
394 GETPOST(
'inventorycode',
'alphanohtml'),
401 $result = $product->correct_stock(
406 GETPOST(
"label",
'alphanohtml'),
408 GETPOST(
'inventorycode',
'alphanohtml'),
417 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
422 $action =
'correction';
432 if ($action ==
"transfert_stock" && $permissiontoadd && !$cancel) {
435 if (!empty($product_id)) {
436 $result = $product->fetch($product_id);
439 if (!(
GETPOSTINT(
"id_entrepot_destination") > 0)) {
440 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Warehouse")),
null,
'errors');
442 $action =
'transfert';
444 if (empty($product_id)) {
446 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Product")),
null,
'errors');
447 $action =
'transfert';
450 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"NumberOfUnit")),
null,
'errors');
452 $action =
'transfert';
454 if ($id ==
GETPOSTINT(
"id_entrepot_destination")) {
455 setEventMessages($langs->trans(
"ErrorSrcAndTargetWarehouseMustDiffers"),
null,
'errors');
457 $action =
'transfert';
462 $result = $product->fetch($product_id);
464 if ($product->hasbatch() && !
GETPOST(
"batch_number")) {
465 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"batch_number")),
null,
'errors');
467 $action =
'transfert';
474 $result = $warehouse->fetch($id);
478 $product->load_stock(
'novirtual');
482 if (isset($product->pmp)) {
483 $pricesrc = $product->pmp;
485 $pricedest = $pricesrc;
487 if ($product->hasbatch()) {
491 $result = $pdluo->fetch($pdluoid);
493 $srcwarehouseid = $pdluo->warehouseid;
494 $batch = $pdluo->batch;
495 $eatby = $pdluo->eatby;
496 $sellby = $pdluo->sellby;
502 $srcwarehouseid = $id;
503 $batch =
GETPOST(
'batch_number',
'alphanohtml');
510 $result1 = $product->correct_stock_batch(
527 $result2 = $product->correct_stock_batch(
537 GETPOST(
'inventorycode',
'alphanohtml'),
546 $result1 = $product->correct_stock(
553 GETPOST(
'inventorycode',
'alphanohtml'),
561 $result2 = $product->correct_stock(
563 GETPOST(
"id_entrepot_destination"),
568 GETPOST(
'inventorycode',
'alphanohtml'),
575 if (!$error && $result1 >= 0 && $result2 >= 0) {
579 header(
"Location: ".$backtopage);
582 header(
"Location: movement_list.php?id=".$warehouse->id);
588 $action =
'transfert';
595 if ($action ==
'confirm_reverse' && $confirm ==
"yes" && $permissiontoadd) {
596 $toselect = array_map(
'intval', $toselect);
598 $sql =
"SELECT rowid, label, inventorycode, datem";
599 $sql .=
" FROM ".MAIN_DB_PREFIX.
"stock_mouvement";
600 $sql .=
" WHERE rowid IN (";
601 foreach ($toselect as $id) {
602 $sql .= ((int) $id).
",";
607 $resql = $db->query(
$sql);
609 $num = $db->num_rows($resql);
612 $obj = $db->fetch_object($resql);
614 $reverse =
$object->reverseMouvement();
623 setEventMessages($langs->trans(
"WarningAlreadyReverse", $langs->transnoentities($idAlreadyReverse)),
null,
'warnings');
628 header(
"Location: ".$_SERVER[
"PHP_SELF"]);
637 $form =
new Form($db);
643 $productstatic =
new Product($db);
644 $warehousestatic =
new Entrepot($db);
646 $userstatic =
new User($db);
652 $sql =
"SELECT p.rowid, p.ref as product_ref, p.label as produit, p.tosell, p.tobuy, p.tobatch, p.fk_product_type as type, p.entity,";
653 $sql .=
" e.ref as warehouse_ref, e.rowid as entrepot_id, e.lieu, e.fk_parent, e.statut,";
654 $sql .=
" m.rowid as mid, m.value as qty, m.datem, m.fk_user_author, m.label, m.inventorycode, m.fk_origin, m.origintype,";
655 $sql .=
" m.batch, m.price,";
656 $sql .=
" m.type_mouvement,";
657 $sql .=
" m.fk_projet as fk_project,";
658 $sql .=
" pl.rowid as lotid, pl.eatby, pl.sellby,";
659 $sql .=
" u.login, u.photo, u.lastname, u.firstname, u.email as user_email, u.statut as user_status";
661 if (!empty($extrafields->attributes[
$object->table_element][
'label'])) {
662 foreach ($extrafields->attributes[
$object->table_element][
'label'] as $key => $val) {
663 $sql .= ($extrafields->attributes[
$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
667 $parameters = array();
668 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters,
$object, $action);
669 $sql .= $hookmanager->resPrint;
670 $sql = preg_replace(
'/,\s*$/',
'',
$sql);
674 $sql .=
" FROM ".MAIN_DB_PREFIX.
"entrepot as e,";
675 $sql .=
" ".MAIN_DB_PREFIX.
"product as p,";
676 $sql .=
" ".MAIN_DB_PREFIX.
"stock_mouvement as m";
677 if (!empty($extrafields->attributes[
$object->table_element][
'label']) && is_array($extrafields->attributes[
$object->table_element][
'label']) && count($extrafields->attributes[
$object->table_element][
'label'])) {
678 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element.
"_extrafields as ef on (m.rowid = ef.fk_object)";
680 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u ON m.fk_user_author = u.rowid";
681 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product_lot as pl ON m.batch = pl.batch AND m.fk_product = pl.fk_product";
684 $parameters = array();
685 $reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters,
$object, $action);
686 $sql .= $hookmanager->resPrint;
688 $sql .=
" WHERE m.fk_product = p.rowid";
690 $sql .=
" AND m.rowid = ".((int) $msid);
692 $sql .=
" AND m.fk_entrepot = e.rowid";
693 $sql .=
" AND e.entity IN (".getEntity(
'stock').
")";
695 $sql .=
" AND p.fk_product_type = 0";
698 $sql .=
" AND e.rowid = ".((int) $id);
700 if (!empty($search_date_start)) {
701 $sql .=
" AND m.datem >= '" . $db->idate($search_date_start) .
"'";
703 if (!empty($search_date_end)) {
704 $sql .=
" AND m.datem <= '" . $db->idate($search_date_end) .
"'";
706 if ($idproduct > 0) {
707 $sql .=
" AND p.rowid = ".((int) $idproduct);
709 if (!empty($search_ref)) {
712 if (!empty($search_movement)) {
715 if (!empty($search_inventorycode)) {
718 if (!empty($search_product_ref)) {
721 if (!empty($search_product)) {
724 if ($search_warehouse !=
'' && $search_warehouse !=
'-1') {
727 if (!empty($search_user)) {
730 if (!empty($search_batch)) {
733 if (!empty($product_id) && $product_id !=
'-1') {
736 if (!empty($search_fk_project) && $search_fk_project !=
'-1') {
739 if ($search_qty !=
'') {
742 if ($search_type_mouvement !=
'' && $search_type_mouvement !=
'-1') {
746 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
748 $parameters = array();
749 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters,
$object, $action);
750 $sql .= $hookmanager->resPrint;
753 $nbtotalofrecords =
'';
756 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords',
$sql);
757 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
758 $resql = $db->query($sqlforcount);
760 $objforcount = $db->fetch_object($resql);
761 $nbtotalofrecords = $objforcount->nbtotalofrecords;
766 if (($page * $limit) > $nbtotalofrecords) {
774 $sql .= $db->order($sortfield, $sortorder);
776 $sql .= $db->plimit($limit + 1, $offset);
779 $resql = $db->query(
$sql);
785 $num = $db->num_rows($resql);
791 if ($idproduct > 0) {
792 $product->fetch($idproduct);
794 if ($id > 0 || $ref) {
795 $result = $warehouse->fetch($id, $ref);
806 $help_url =
'EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks';
808 $title = $langs->trans(
'StockMovementForId', $msid);
810 $title = $langs->trans(
"ListOfStockMovements");
812 if (!empty($warehouse->ref)) {
813 $title .=
' ('.$warehouse->ref.
')';
815 $title .=
' ('.$langs->trans(
"ForThisWarehouse").
')';
829 if ($warehouse->id > 0) {
832 print
dol_get_fiche_head($head,
'movements', $langs->trans(
"Warehouse"), -1,
'stock');
835 $linkback =
'<a href="'.DOL_URL_ROOT.
'/product/stock/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
837 $morehtmlref =
'<div class="refidno">';
838 $morehtmlref .= $langs->trans(
"LocationSummary").
' : '.$warehouse->lieu;
842 $langs->load(
"projects");
843 $morehtmlref .=
'<br>'.img_picto(
'',
'project').
' '.$langs->trans(
'Project').
' ';
844 if ($usercancreate && 1 == 2) {
845 if ($action !=
'classify') {
846 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.
newToken().
'&id='.$warehouse->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> : ';
848 if ($action ==
'classify') {
849 $projectid = $warehouse->fk_project;
850 $morehtmlref .=
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?id='.$warehouse->id.
'">';
851 $morehtmlref .=
'<input type="hidden" name="action" value="classin">';
852 $morehtmlref .=
'<input type="hidden" name="token" value="'.newToken().
'">';
853 $morehtmlref .= $formproject->select_projects(($socid > 0 ? $socid : -1), $projectid,
'projectid', 0, 0, 1, 1, 0, 0, 0,
'', 1, 0,
'maxwidth500');
854 $morehtmlref .=
'<input type="submit" class="button valignmiddle" value="'.$langs->trans(
"Modify").
'">';
855 $morehtmlref .=
'</form>';
857 $morehtmlref .= $form->form_project($_SERVER[
'PHP_SELF'].
'?id='.$warehouse->id, $warehouse->socid, $warehouse->fk_project,
'none', 0, 0, 0, 1,
'',
'maxwidth300');
860 if (!empty($warehouse->fk_project)) {
862 $proj->fetch($warehouse->fk_project);
863 $morehtmlref .=
' : '.$proj->getNomUrl(1);
865 $morehtmlref .=
' - '.$proj->title;
872 $morehtmlref .=
'</div>';
875 if ($user->socid && !in_array(
'stock', explode(
',',
getDolGlobalString(
'MAIN_MODULES_FOR_EXTERNAL')))) {
879 dol_banner_tab($warehouse,
'ref', $linkback, $shownav,
'ref',
'ref', $morehtmlref);
882 print
'<div class="fichecenter">';
883 print
'<div class="fichehalfleft">';
884 print
'<div class="underbanner clearboth"></div>';
886 print
'<table class="border centpercent tableforfield">';
891 print
'<td class="titlefield tdtop">'.$langs->trans(
"Description").
'</td><td>'.
dol_htmlentitiesbr($warehouse->description).
'</td></tr>';
893 $calcproductsunique = $warehouse->nb_different_products();
894 $calcproducts = $warehouse->nb_products();
897 print
'<tr><td>'.$langs->trans(
"NumberOfDifferentProducts").
'</td><td>';
898 print empty($calcproductsunique[
'nb']) ?
'0' : $calcproductsunique[
'nb'];
902 print
'<tr><td>'.$langs->trans(
"NumberOfProducts").
'</td><td>';
903 $valtoshow =
price2num($calcproducts[
'nb'],
'MS');
904 print empty($valtoshow) ?
'0' : $valtoshow;
910 print
'<div class="fichehalfright">';
911 print
'<div class="underbanner clearboth"></div>';
913 print
'<table class="border centpercent tableforfield">';
916 print
'<tr><td class="titlefield">'.$langs->trans(
"EstimatedStockValueShort").
'</td><td>';
917 print
price((empty($calcproducts[
'value']) ?
'0' :
price2num($calcproducts[
'value'],
'MT')), 0, $langs, 0, -1, -1, $conf->currency);
921 $sql =
"SELECT MAX(m.datem) as datem";
922 $sql .=
" FROM ".MAIN_DB_PREFIX.
"stock_mouvement as m";
923 $sql .=
" WHERE m.fk_entrepot = ".((int) $warehouse->id);
924 $resqlbis = $db->query(
$sql);
926 $objbis = $db->fetch_object($resqlbis);
927 $lastmovementdate = $db->jdate($objbis->datem);
932 print
'<tr><td>'.$langs->trans(
"LastMovement").
'</td><td>';
933 if ($lastmovementdate) {
936 print $langs->trans(
"None");
941 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
945 print
'<tr><td valign="middle">'.$langs->trans(
"Categories").
'</td><td colspan="3">';
946 print $form->showCategories($warehouse->id, Categorie::TYPE_WAREHOUSE, 1);
955 print
'<div class="clearboth"></div>';
962 if ($action ==
"correction") {
963 include DOL_DOCUMENT_ROOT.
'/product/stock/tpl/stockcorrection.tpl.php';
968 if ($action ==
"transfert") {
969 include DOL_DOCUMENT_ROOT.
'/product/stock/tpl/stocktransfer.tpl.php';
975 if ((empty($action) || $action ==
'list') && $id > 0) {
976 print
"<div class=\"tabsAction\">\n";
978 $parameters = array();
979 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $warehouse, $action);
981 if (empty($reshook)) {
982 if ($user->hasRight(
'stock',
'mouvement',
'creer')) {
983 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$id.
'&action=correction">'.$langs->trans(
"CorrectStock").
'</a>';
986 if ($user->hasRight(
'stock',
'mouvement',
'creer')) {
987 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$id.
'&action=transfert">'.$langs->trans(
"TransferStock").
'</a>';
994 $arrayofselected = is_array($toselect) ? $toselect : array();
998 $param .=
'&mode='.urlencode($mode);
1000 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
1001 $param .=
'&contextpage='.urlencode($contextpage);
1003 if ($limit > 0 && $limit != $conf->liste_limit) {
1004 $param .=
'&limit='.((int) $limit);
1007 $param .=
'&id='.urlencode((
string) ($id));
1010 $param .=
'&show_files='.urlencode((
string) ($show_files));
1012 if ($search_date_startday) {
1013 $param .=
'&search_date_startday='.urlencode((
string) ($search_date_startday));
1015 if ($search_date_startmonth) {
1016 $param .=
'&search_date_startmonth='.urlencode((
string) ($search_date_startmonth));
1018 if ($search_date_startyear) {
1019 $param .=
'&search_date_startyear='.urlencode((
string) ($search_date_startyear));
1021 if ($search_date_endday) {
1022 $param .=
'&search_date_endday='.urlencode((
string) ($search_date_endday));
1024 if ($search_date_endmonth) {
1025 $param .=
'&search_date_endmonth='.urlencode((
string) ($search_date_endmonth));
1027 if ($search_date_endyear) {
1028 $param .=
'&search_date_endyear='.urlencode((
string) ($search_date_endyear));
1030 if ($search_movement) {
1031 $param .=
'&search_movement='.urlencode($search_movement);
1033 if ($search_inventorycode) {
1034 $param .=
'&search_inventorycode='.urlencode($search_inventorycode);
1036 if ($search_type_mouvement) {
1037 $param .=
'&search_type_mouvement='.urlencode($search_type_mouvement);
1039 if ($search_product_ref) {
1040 $param .=
'&search_product_ref='.urlencode($search_product_ref);
1042 if ($search_product) {
1043 $param .=
'&search_product='.urlencode($search_product);
1045 if ($search_batch) {
1046 $param .=
'&search_batch='.urlencode($search_batch);
1048 if ($search_warehouse > 0) {
1049 $param .=
'&search_warehouse='.urlencode($search_warehouse);
1052 $param .=
'&search_user='.urlencode($search_user);
1054 if ($idproduct > 0) {
1055 $param .=
'&idproduct='.urlencode((
string) ($idproduct));
1057 if ($search_fk_project !=
'' && $search_fk_project !=
'-1') {
1058 $param .=
'&search_fk_project='.urlencode((
string) ($search_fk_project));
1061 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
1063 $parameters = array(
'param' => &$param);
1064 $reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $warehouse, $action);
1065 $param .= $hookmanager->resPrint;
1068 $arrayofmassactions = array();
1070 $arrayofmassactions[
'builddoc'] =
img_picto(
'',
'pdf',
'class="pictofixedwidth"').$langs->trans(
"GeneratePDF");
1074 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
1076 if (!empty($permissiontoadd)) {
1077 $arrayofmassactions[
'prereverse'] =
img_picto(
'',
'add',
'class="pictofixedwidth"').$langs->trans(
"Reverse");
1079 if (
GETPOSTINT(
'nomassaction') || in_array($massaction, array(
'presend',
'predelete',
'prereverse'))) {
1080 $arrayofmassactions = array();
1083 $massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
1085 print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
1086 if ($optioncss !=
'') {
1087 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
1089 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1090 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
1091 print
'<input type="hidden" name="action" value="list">';
1092 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
1093 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
1094 print
'<input type="hidden" name="type" value="'.$type.
'">';
1095 print
'<input type="hidden" name="page" value="'.$page.
'">';
1096 print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
1097 print
'<input type="hidden" name="page_y" value="">';
1098 print
'<input type="hidden" name="mode" value="'.$mode.
'">';
1100 print
'<input type="hidden" name="id" value="'.$id.
'">';
1104 $newcardbutton =
'';
1106 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'movement', 0,
'',
'', $limit, 0, 0, 1);
1109 $topicmail =
"SendStockMovement";
1110 $modelmail =
"movementstock";
1112 $trackid =
'mov'.$warehouse->id;
1113 include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
1114 if ($massaction ==
'prereverse') {
1115 print $form->formconfirm($_SERVER[
"PHP_SELF"], $langs->trans(
"ConfirmMassReverse"), $langs->trans(
"ConfirmMassReverseQuestion", count($toselect)),
"confirm_reverse",
null,
'', 0, 200, 500, 1,
'Yes');
1121 if (!isset($fieldstosearchall) || !is_array($fieldstosearchall)) {
1123 $fieldstosearchall = array();
1125 foreach ($fieldstosearchall as $key => $val) {
1126 $fieldstosearchall[$key] = $langs->trans($val);
1127 $setupstring .= $key.
"=".$val.
";";
1129 print
'<!-- Search done like if STOCK_QUICKSEARCH_ON_FIELDS = '.$setupstring.
' -->'.
"\n";
1130 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $search_all).implode(
', ', $fieldstosearchall).
'</div>'.
"\n";
1133 $moreforfilter =
'';
1135 $parameters = array(
'arrayfields' => &$arrayfields);
1136 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $warehouse, $action);
1137 if (empty($reshook)) {
1138 $moreforfilter .= $hookmanager->resPrint;
1140 $moreforfilter = $hookmanager->resPrint;
1143 if (!empty($moreforfilter)) {
1144 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
1145 print $moreforfilter;
1149 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
1150 $htmlofselectarray = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
1151 $selectedfields = ($mode !=
'kanban' ? $htmlofselectarray :
'');
1152 $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
1154 print
'<div class="div-table-responsive">';
1155 print
'<table class="tagtable nobottomiftotal liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
1159 print
'<tr class="liste_titre">';
1162 print
'<td class="liste_titre center maxwidthsearch">';
1163 $searchpicto = $form->showFilterButtons(
'left');
1167 if (!empty($arrayfields[
'm.rowid'][
'checked'])) {
1169 print
'<td class="liste_titre left">';
1170 print
'<input class="flat maxwidth40" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).
'">';
1173 if (!empty($arrayfields[
'm.datem'][
'checked'])) {
1175 print
'<td class="liste_titre center">';
1176 print
'<div class="nowrapfordate">';
1177 print $form->selectDate($search_date_start ? $search_date_start : -1,
'search_date_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'),
'tzuserrel');
1179 print
'<div class="nowrapfordate">';
1180 print $form->selectDate($search_date_end ? $search_date_end : -1,
'search_date_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'),
'tzuserrel');
1184 if (!empty($arrayfields[
'p.ref'][
'checked'])) {
1186 print
'<td class="liste_titre left">';
1187 print
'<input class="flat maxwidth75" type="text" name="search_product_ref" value="'.dol_escape_htmltag($idproduct ? $product->ref : $search_product_ref).
'">';
1190 if (!empty($arrayfields[
'p.label'][
'checked'])) {
1192 print
'<td class="liste_titre left">';
1193 print
'<input class="flat maxwidth100" type="text" name="search_product" value="'.dol_escape_htmltag($idproduct ? $product->label : $search_product).
'">';
1197 if (!empty($arrayfields[
'm.batch'][
'checked'])) {
1198 print
'<td class="liste_titre center"><input class="flat maxwidth75" type="text" name="search_batch" value="'.dol_escape_htmltag($search_batch).
'"></td>';
1200 if (!empty($arrayfields[
'pl.eatby'][
'checked'])) {
1201 print
'<td class="liste_titre left">';
1204 if (!empty($arrayfields[
'pl.sellby'][
'checked'])) {
1205 print
'<td class="liste_titre left">';
1209 if (!empty($arrayfields[
'e.ref'][
'checked'])) {
1210 print
'<td class="liste_titre maxwidthonsmartphone left">';
1212 print $formproduct->selectWarehouses($search_warehouse,
'search_warehouse',
'warehouseopen,warehouseinternal', 1, 0, 0,
'', 0, 0,
null,
'maxwidth200');
1215 if (!empty($arrayfields[
'm.fk_user_author'][
'checked'])) {
1217 print
'<td class="liste_titre left">';
1218 print
'<input class="flat" type="text" size="6" name="search_user" value="'.dol_escape_htmltag($search_user).
'">';
1221 if (!empty($arrayfields[
'm.inventorycode'][
'checked'])) {
1223 print
'<td class="liste_titre left">';
1224 print
'<input class="flat" type="text" size="4" name="search_inventorycode" value="'.dol_escape_htmltag($search_inventorycode).
'">';
1227 if (!empty($arrayfields[
'm.label'][
'checked'])) {
1229 print
'<td class="liste_titre left">';
1230 print
'<input class="flat" type="text" size="8" name="search_movement" value="'.dol_escape_htmltag($search_movement).
'">';
1233 if (!empty($arrayfields[
'origin'][
'checked'])) {
1235 print
'<td class="liste_titre left">';
1239 if (!empty($arrayfields[
'm.fk_projet'][
'checked'])) {
1241 print
'<td class="liste_titre" align="left">';
1242 print $warehouse->showInputField($warehouse->fields[
'fk_project'],
'fk_project', $search_fk_project,
'',
'',
'search_',
'maxwidth125', 1);
1245 if (!empty($arrayfields[
'm.type_mouvement'][
'checked'])) {
1247 print
'<td class="liste_titre center">';
1249 print
'<select id="search_type_mouvement" name="search_type_mouvement" class="maxwidth150">';
1250 print
'<option value="" '.(($search_type_mouvement ==
"") ?
'selected="selected"' :
'').
'> </option>';
1251 print
'<option value="0" '.(($search_type_mouvement ==
"0") ?
'selected="selected"' :
'').
'>'.$langs->trans(
'StockIncreaseAfterCorrectTransfer').
'</option>';
1252 print
'<option value="1" '.(($search_type_mouvement ==
"1") ?
'selected="selected"' :
'').
'>'.$langs->trans(
'StockDecreaseAfterCorrectTransfer').
'</option>';
1253 print
'<option value="2" '.(($search_type_mouvement ==
"2") ?
'selected="selected"' :
'').
'>'.$langs->trans(
'StockDecrease').
'</option>';
1254 print
'<option value="3" '.(($search_type_mouvement ==
"3") ?
'selected="selected"' :
'').
'>'.$langs->trans(
'StockIncrease').
'</option>';
1261 if (!empty($arrayfields[
'm.value'][
'checked'])) {
1263 print
'<td class="liste_titre right">';
1264 print
'<input class="flat" type="text" size="4" name="search_qty" value="'.dol_escape_htmltag($search_qty).
'">';
1267 if (!empty($arrayfields[
'm.price'][
'checked'])) {
1269 print
'<td class="liste_titre" align="left">';
1275 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
1278 $parameters = array(
'arrayfields' => $arrayfields);
1279 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $warehouse, $action);
1280 print $hookmanager->resPrint;
1282 if (!empty($arrayfields[
'm.datec'][
'checked'])) {
1283 print
'<td class="liste_titre">';
1287 if (!empty($arrayfields[
'm.tms'][
'checked'])) {
1288 print
'<td class="liste_titre">';
1293 print
'<td class="liste_titre center maxwidthsearch">';
1294 $searchpicto = $form->showFilterButtons();
1300 $totalarray = array();
1301 $totalarray[
'nbfield'] = 0;
1305 print
'<tr class="liste_titre">';
1308 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
1309 $totalarray[
'nbfield']++;
1311 if (!empty($arrayfields[
'm.rowid'][
'checked'])) {
1312 print_liste_field_titre($arrayfields[
'm.rowid'][
'label'], $_SERVER[
"PHP_SELF"],
'm.rowid',
'', $param,
'', $sortfield, $sortorder);
1314 if (!empty($arrayfields[
'm.datem'][
'checked'])) {
1315 print_liste_field_titre($arrayfields[
'm.datem'][
'label'], $_SERVER[
"PHP_SELF"],
'm.datem',
'', $param,
'', $sortfield, $sortorder,
'center ');
1317 if (!empty($arrayfields[
'p.ref'][
'checked'])) {
1318 print_liste_field_titre($arrayfields[
'p.ref'][
'label'], $_SERVER[
"PHP_SELF"],
'p.ref',
'', $param,
'', $sortfield, $sortorder);
1320 if (!empty($arrayfields[
'p.label'][
'checked'])) {
1321 print_liste_field_titre($arrayfields[
'p.label'][
'label'], $_SERVER[
"PHP_SELF"],
'p.label',
'', $param,
'', $sortfield, $sortorder);
1323 if (!empty($arrayfields[
'm.batch'][
'checked'])) {
1324 print_liste_field_titre($arrayfields[
'm.batch'][
'label'], $_SERVER[
"PHP_SELF"],
'm.batch',
'', $param,
'', $sortfield, $sortorder,
'center ');
1326 if (!empty($arrayfields[
'pl.eatby'][
'checked'])) {
1327 print_liste_field_titre($arrayfields[
'pl.eatby'][
'label'], $_SERVER[
"PHP_SELF"],
'pl.eatby',
'', $param,
'', $sortfield, $sortorder,
'center ');
1329 if (!empty($arrayfields[
'pl.sellby'][
'checked'])) {
1330 print_liste_field_titre($arrayfields[
'pl.sellby'][
'label'], $_SERVER[
"PHP_SELF"],
'pl.sellby',
'', $param,
'', $sortfield, $sortorder,
'center ');
1332 if (!empty($arrayfields[
'e.ref'][
'checked'])) {
1334 print_liste_field_titre($arrayfields[
'e.ref'][
'label'], $_SERVER[
"PHP_SELF"],
"e.ref",
"", $param,
"", $sortfield, $sortorder);
1336 if (!empty($arrayfields[
'm.fk_user_author'][
'checked'])) {
1337 print_liste_field_titre($arrayfields[
'm.fk_user_author'][
'label'], $_SERVER[
"PHP_SELF"],
"m.fk_user_author",
"", $param,
"", $sortfield, $sortorder);
1339 if (!empty($arrayfields[
'm.inventorycode'][
'checked'])) {
1340 print_liste_field_titre($arrayfields[
'm.inventorycode'][
'label'], $_SERVER[
"PHP_SELF"],
"m.inventorycode",
"", $param,
"", $sortfield, $sortorder);
1342 if (!empty($arrayfields[
'm.label'][
'checked'])) {
1343 print_liste_field_titre($arrayfields[
'm.label'][
'label'], $_SERVER[
"PHP_SELF"],
"m.label",
"", $param,
"", $sortfield, $sortorder);
1345 if (!empty($arrayfields[
'origin'][
'checked'])) {
1346 print_liste_field_titre($arrayfields[
'origin'][
'label'], $_SERVER[
"PHP_SELF"],
"",
"", $param,
"", $sortfield, $sortorder);
1348 if (!empty($arrayfields[
'm.fk_projet'][
'checked'])) {
1349 print_liste_field_titre($arrayfields[
'm.fk_projet'][
'label'], $_SERVER[
"PHP_SELF"],
"m.fk_projet",
"", $param,
'', $sortfield, $sortorder);
1351 if (!empty($arrayfields[
'm.type_mouvement'][
'checked'])) {
1352 print_liste_field_titre($arrayfields[
'm.type_mouvement'][
'label'], $_SERVER[
"PHP_SELF"],
"m.type_mouvement",
"", $param,
'', $sortfield, $sortorder,
'center ');
1354 if (!empty($arrayfields[
'm.value'][
'checked'])) {
1355 print_liste_field_titre($arrayfields[
'm.value'][
'label'], $_SERVER[
"PHP_SELF"],
"m.value",
"", $param,
'', $sortfield, $sortorder,
'right ');
1357 if (!empty($arrayfields[
'm.price'][
'checked'])) {
1358 print_liste_field_titre($arrayfields[
'm.price'][
'label'], $_SERVER[
"PHP_SELF"],
"m.price",
"", $param,
'', $sortfield, $sortorder,
'right ');
1362 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
1365 $parameters = array(
'arrayfields' => $arrayfields,
'param' => $param,
'sortfield' => $sortfield,
'sortorder' => $sortorder,
'totalarray' => &$totalarray);
1366 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $warehouse, $action);
1367 print $hookmanager->resPrint;
1368 if (!empty($arrayfields[
'm.datec'][
'checked'])) {
1369 print_liste_field_titre($arrayfields[
'm.datec'][
'label'], $_SERVER[
"PHP_SELF"],
"m.datec",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
1371 if (!empty($arrayfields[
'm.tms'][
'checked'])) {
1372 print_liste_field_titre($arrayfields[
'm.tms'][
'label'], $_SERVER[
"PHP_SELF"],
"m.tms",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
1376 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
1377 $totalarray[
'nbfield']++;
1382 $arrayofuniqueproduct = array();
1388 $savnbfield = $totalarray[
'nbfield'];
1389 $totalarray = array();
1390 $totalarray[
'nbfield'] = 0;
1391 $imaxinloop = ($limit ? min($num, $limit) : $num);
1392 while ($i < $imaxinloop) {
1393 $obj = $db->fetch_object($resql);
1398 $userstatic->id = $obj->fk_user_author;
1399 $userstatic->login = $obj->login;
1400 $userstatic->lastname = $obj->lastname;
1401 $userstatic->firstname = $obj->firstname;
1402 $userstatic->photo = $obj->photo;
1403 $userstatic->email = $obj->user_email;
1404 $userstatic->status = $obj->user_status;
1409 $sql =
"SELECT label";
1410 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_lang";
1411 $sql .=
" WHERE fk_product = ".((int) $obj->rowid);
1412 $sql .=
" AND lang = '".$db->escape($langs->getDefaultLang()).
"'";
1415 $result = $db->query(
$sql);
1417 $objtp = $db->fetch_object($result);
1418 if (!empty($objtp->label)) {
1419 $obj->produit = $objtp->label;
1424 $productstatic->id = $obj->rowid;
1425 $productstatic->ref = $obj->product_ref;
1426 $productstatic->label = $obj->produit;
1427 $productstatic->type = $obj->type;
1428 $productstatic->entity = $obj->entity;
1429 $productstatic->status = $obj->tosell;
1430 $productstatic->status_buy = $obj->tobuy;
1431 $productstatic->status_batch = $obj->tobatch;
1433 $productlot->id = $obj->lotid;
1434 $productlot->batch = $obj->batch;
1435 $productlot->eatby = $obj->eatby;
1436 $productlot->sellby = $obj->sellby;
1438 $warehousestatic->id = $obj->entrepot_id;
1439 $warehousestatic->ref = $obj->warehouse_ref;
1440 $warehousestatic->label = $obj->warehouse_ref;
1441 $warehousestatic->lieu = $obj->lieu;
1442 $warehousestatic->fk_parent = $obj->fk_parent;
1443 $warehousestatic->statut = $obj->statut;
1449 $object->warehouse_id = $obj->entrepot_id;
1450 $object->type = $obj->type_mouvement;
1452 $arrayofuniqueproduct[$obj->rowid] = $obj->produit;
1453 if (!empty($obj->fk_origin)) {
1454 $origin =
$object->get_origin($obj->fk_origin, $obj->origintype);
1459 if ($mode ==
'kanban') {
1461 print
'<tr class="trkanban"><td colspan="'.$savnbfield.
'">';
1462 print
'<div class="box-flex-container kanban">';
1466 if ($massactionbutton || $massaction) {
1468 if (in_array($warehouse->id, $arrayofselected)) {
1472 print $warehouse->getKanbanView(
'', array(
'selected' => $selected));
1473 if ($i == ($imaxinloop - 1)) {
1480 print
'<tr data-rowid="'.$warehouse->id.
'" class="oddeven">';
1483 print
'<td class="nowrap center">';
1484 if ($massactionbutton || $massaction) {
1486 if (in_array($obj->mid, $arrayofselected)) {
1489 print
'<input id="cb'.$obj->mid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->mid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
1493 $totalarray[
'nbfield']++;
1497 if (!empty($arrayfields[
'm.rowid'][
'checked'])) {
1498 print
'<td class="nowraponall">';
1504 if (!empty($arrayfields[
'm.datem'][
'checked'])) {
1506 print
'<td class="nowraponall center">'.dol_print_date($db->jdate($obj->datem),
'dayhour',
'tzuserrel').
'</td>';
1508 if (!empty($arrayfields[
'p.ref'][
'checked'])) {
1510 print
'<td class="nowraponall">';
1511 print $productstatic->getNomUrl(1,
'stock', 16);
1514 if (!empty($arrayfields[
'p.label'][
'checked'])) {
1516 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($productstatic->label).
'">';
1517 print $productstatic->label;
1520 if (!empty($arrayfields[
'm.batch'][
'checked'])) {
1521 print
'<td class="center nowraponall">';
1522 if ($productlot->id > 0) {
1523 print $productlot->getNomUrl(1);
1525 print $productlot->batch;
1529 if (!empty($arrayfields[
'pl.eatby'][
'checked'])) {
1530 print
'<td class="center">'.dol_print_date($obj->eatby,
'day').
'</td>';
1532 if (!empty($arrayfields[
'pl.sellby'][
'checked'])) {
1533 print
'<td class="center">'.dol_print_date($obj->sellby,
'day').
'</td>';
1536 if (!empty($arrayfields[
'e.ref'][
'checked'])) {
1537 print
'<td class="tdoverflowmax100">';
1538 print $warehousestatic->getNomUrl(1);
1542 if (!empty($arrayfields[
'm.fk_user_author'][
'checked'])) {
1543 print
'<td class="tdoverflowmax100">';
1544 print $userstatic->getNomUrl(-1);
1547 if (!empty($arrayfields[
'm.inventorycode'][
'checked'])) {
1549 print
'<td><a href="'.$_SERVER[
"PHP_SELF"].
'?search_inventorycode='.urlencode(
'^'.$obj->inventorycode.
'$').
'">'.
dol_escape_htmltag($obj->inventorycode).
'</a></td>';
1551 if (!empty($arrayfields[
'm.label'][
'checked'])) {
1553 print
'<td class="tdoverflowmax200" title="'.dol_escape_htmltag($obj->label).
'">'.
dol_escape_htmltag($obj->label).
'</td>';
1555 if (!empty($arrayfields[
'origin'][
'checked'])) {
1557 print
'<td class="nowraponall">'.$origin.
'</td>';
1559 if (!empty($arrayfields[
'm.fk_projet'][
'checked'])) {
1562 if ($obj->fk_project != 0) {
1563 print
$object->get_origin($obj->fk_project,
'project');
1567 if (!empty($arrayfields[
'm.type_mouvement'][
'checked'])) {
1569 print
'<td class="center">';
1570 print
$object->getTypeMovement();
1573 if (!empty($arrayfields[
'm.value'][
'checked'])) {
1575 print
'<td class="right">';
1576 if ($obj->qty > 0) {
1577 print
'<span class="stockmovemententry">';
1582 print
'<span class="stockmovementexit">';
1588 if (!empty($arrayfields[
'm.price'][
'checked'])) {
1590 print
'<td class="right">';
1591 if ($obj->price != 0) {
1592 print
price($obj->price);
1598 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
1600 $parameters = array(
'arrayfields' => $arrayfields,
'object' =>
$object,
'obj' => $obj,
'i' => $i,
'totalarray' => &$totalarray);
1601 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters,
$object, $action);
1602 print $hookmanager->resPrint;
1606 print
'<td class="nowrap center">';
1607 if ($massactionbutton || $massaction) {
1609 if (in_array($obj->mid, $arrayofselected)) {
1612 print
'<input id="cb'.$obj->mid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->mid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
1616 $totalarray[
'nbfield']++;
1629 foreach ($arrayfields as $key => $val) {
1630 if (!empty($val[
'checked'])) {
1634 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
1639 $parameters = array(
'arrayfields' => $arrayfields,
'sql' =>
$sql);
1640 $reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters,
$object, $action);
1641 print $hookmanager->resPrint;
1643 print
'</table>'.
"\n";
1644 print
'</div>'.
"\n";
1646 print
'</form>'.
"\n";
1649 if (count($arrayofuniqueproduct) == 1 && !empty($year) && is_numeric($year)) {
1652 $productidselected = 0;
1653 foreach ($arrayofuniqueproduct as $key => $val) {
1654 $productidselected = $key;
1655 $productlabelselected = $val;
1659 $balancebefore =
$object->calculateBalanceForProductBefore($productidselected, $datebefore);
1660 $balanceafter =
$object->calculateBalanceForProductBefore($productidselected, $dateafter);
1663 print $langs->trans(
"NbOfProductBeforePeriod", $productlabelselected,
dol_print_date($datebefore,
'day',
'gmt'));
1666 print
': '.$balancebefore;
1670 print $langs->trans(
"NbOfProductAfterPeriod", $productlabelselected,
dol_print_date($dateafter,
'day',
'gmt'));
1673 print
': '.$balanceafter;
1678 if (in_array(
'builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords ===
'' || $nbtotalofrecords)) {
1679 $hidegeneratedfilelistifempty = 1;
1680 if ($massaction ==
'builddoc' || $action ==
'remove_file' || $show_files) {
1681 $hidegeneratedfilelistifempty = 0;
1684 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
1688 $urlsource = $_SERVER[
'PHP_SELF'].
'?sortfield='.$sortfield.
'&sortorder='.$sortorder;
1689 $urlsource .= str_replace(
'&',
'&', $param);
1691 $filedir = $diroutputmassaction;
1692 $genallowed = $permissiontoread;
1693 $delallowed = $permissiontoadd;
1695 print $formfile->showdocuments(
'massfilesarea_stock',
'', $filedir, $urlsource, 0, $delallowed,
'', 1, 1, 0, 48, 1, $param, $title,
'',
'',
'',
null, $hidegeneratedfilelistifempty);
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 projects.
Class to manage translations.
Class to manage Dolibarr users.
if(isModEnabled('invoice') && $user->hasRight('facture', 'lire')) if((isModEnabled('fournisseur') &&!getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD') && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') && $user->hasRight('don', 'lire')) if(isModEnabled('tax') && $user->hasRight('tax', 'charges', 'lire')) if(isModEnabled('invoice') &&isModEnabled('order') && $user->hasRight("commande", "lire") &&!getDolGlobalString('WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER')) $sql
Social contributions to pay.
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_dir_list($utf8_path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
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...
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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 '.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
setEventMessage($mesgs, $style='mesgs', $noduplicate=0)
Set event message in dol_events session object.
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_now($mode='auto')
Return date for now.
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'.
dol_clone($object, $native=0)
Create a clone of instance of object (new instance with same value for each properties) With native =...
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get 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...
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
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.
isModEnabled($module)
Is Dolibarr module enabled.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
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.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.
stock_prepare_head($object)
Prepare array with list of tabs.