30require
'../../main.inc.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
32require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
33require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/entrepot.class.php';
34require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/mouvementstock.class.php';
35require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/productlot.class.php';
36require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
37require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
38require_once DOL_DOCUMENT_ROOT.
'/core/lib/stock.lib.php';
39require_once DOL_DOCUMENT_ROOT.
'/core/lib/product.lib.php';
40require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
41require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.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");
53$action =
GETPOST(
'action',
'aZ09');
54$massaction =
GETPOST(
'massaction',
'alpha');
55$confirm =
GETPOST(
'confirm',
'alpha');
56$cancel =
GETPOST(
'cancel',
'alpha');
57$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') : str_replace(
'_',
'', basename(dirname(__FILE__)).basename(__FILE__,
'.php'));
58$toselect =
GETPOST(
'toselect',
'array');
59$backtopage =
GETPOST(
"backtopage",
"alpha");
60$optioncss =
GETPOST(
'optioncss',
'aZ');
61$show_files =
GETPOST(
'show_files',
'aZ');
67$idproduct =
GETPOST(
'idproduct',
'int');
68$product_id =
GETPOST(
"product_id",
'int');
70$search_all = trim((
GETPOST(
'search_all',
'alphanohtml') !=
'') ?
GETPOST(
'search_all',
'alphanohtml') :
GETPOST(
'sall',
'alphanohtml'));
71$search_date_startday =
GETPOST(
'search_date_startday',
'int');
72$search_date_startmonth =
GETPOST(
'search_date_startmonth',
'int');
73$search_date_startyear =
GETPOST(
'search_date_startyear',
'int');
74$search_date_endday =
GETPOST(
'search_date_endday',
'int');
75$search_date_endmonth =
GETPOST(
'search_date_endmonth',
'int');
76$search_date_endyear =
GETPOST(
'search_date_endyear',
'int');
77$search_date_start =
dol_mktime(0, 0, 0,
GETPOST(
'search_date_startmonth',
'int'),
GETPOST(
'search_date_startday',
'int'),
GETPOST(
'search_date_startyear',
'int'),
'tzuserrel');
78$search_date_end =
dol_mktime(23, 59, 59,
GETPOST(
'search_date_endmonth',
'int'),
GETPOST(
'search_date_endday',
'int'),
GETPOST(
'search_date_endyear',
'int'),
'tzuserrel');
79$search_ref =
GETPOST(
'search_ref',
'alpha');
80$search_movement =
GETPOST(
"search_movement");
81$search_product_ref = trim(
GETPOST(
"search_product_ref"));
82$search_product = trim(
GETPOST(
"search_product"));
83$search_warehouse = trim(
GETPOST(
"search_warehouse"));
84$search_inventorycode = trim(
GETPOST(
"search_inventorycode"));
85$search_user = trim(
GETPOST(
"search_user"));
86$search_batch = trim(
GETPOST(
"search_batch"));
87$search_qty = trim(
GETPOST(
"search_qty"));
88$search_type_mouvement =
GETPOST(
'search_type_mouvement',
'int');
89$search_fk_project=
GETPOST(
"search_fk_project",
'int');
94$limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
95$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
96$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
97$page = GETPOSTISSET(
'pageplusone') ? (
GETPOST(
'pageplusone') - 1) :
GETPOST(
"page",
'int');
98if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
102$offset = $limit * $page;
103$pageprev = $page - 1;
104$pagenext = $page + 1;
107 $sortfield =
"m.datem";
113$pdluoid =
GETPOST(
'pdluoid',
'int');
118$diroutputmassaction = $conf->stock->dir_output.
'/temp/massgeneration/'.$user->id;
119$hookmanager->initHooks(array($contextpage));
124$extrafields->fetch_name_optionals_label($object->table_element);
126$search_array_options = $extrafields->getOptionalsFromPost($object->table_element,
'',
'search_');
129 'm.rowid'=>array(
'label'=>
"Ref",
'checked'=>1,
'position'=>1),
130 'm.datem'=>array(
'label'=>
"Date",
'checked'=>1,
'position'=>2),
131 'p.ref'=>array(
'label'=>
"ProductRef",
'checked'=>1,
'css'=>
'maxwidth100',
'position'=>3),
132 'p.label'=>array(
'label'=>
"ProductLabel",
'checked'=>0,
'position'=>5),
133 'm.batch'=>array(
'label'=>
"BatchNumberShort",
'checked'=>1,
'position'=>8,
'enabled'=>(isModEnabled(
'productbatch'))),
134 'pl.eatby'=>array(
'label'=>
"EatByDate",
'checked'=>0,
'position'=>9,
'enabled'=>(isModEnabled(
'productbatch'))),
135 'pl.sellby'=>array(
'label'=>
"SellByDate",
'checked'=>0,
'position'=>10,
'enabled'=>(isModEnabled(
'productbatch'))),
136 'e.ref'=>array(
'label'=>
"Warehouse",
'checked'=>1,
'position'=>100,
'enabled'=>(!($id > 0))),
137 'm.fk_user_author'=>array(
'label'=>
"Author",
'checked'=>0,
'position'=>120),
138 'm.inventorycode'=>array(
'label'=>
"InventoryCodeShort",
'checked'=>1,
'position'=>130),
139 'm.label'=>array(
'label'=>
"MovementLabel",
'checked'=>1,
'position'=>140),
140 'm.type_mouvement'=>array(
'label'=>
"TypeMovement",
'checked'=>0,
'position'=>150),
141 'origin'=>array(
'label'=>
"Origin",
'checked'=>1,
'position'=>155),
142 'm.fk_projet'=>array(
'label'=>
'Project',
'checked'=>0,
'position'=>180),
143 'm.value'=>array(
'label'=>
"Qty",
'checked'=>1,
'position'=>200),
144 'm.price'=>array(
'label'=>
"UnitPurchaseValue",
'checked'=>0,
'position'=>210,
'enabled'=>(!
getDolGlobalInt(
'STOCK_MOVEMENT_LIST_HIDE_UNIT_PRICE')))
149include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
152 unset($arrayfields[
'pl.sellby']);
155 unset($arrayfields[
'pl.eatby']);
160if ($id > 0 || !empty($ref)) {
161 $tmpwarehouse->fetch($id, $ref);
162 $id = $tmpwarehouse->id;
171if (!$user->hasRight(
'stock',
'mouvement',
'lire')) {
175$uploaddir = $conf->stock->dir_output.
'/movements';
177$permissiontoread = $user->rights->stock->mouvement->lire;
178$permissiontoadd = $user->rights->stock->mouvement->creer;
179$permissiontodelete = $user->rights->stock->mouvement->creer;
181$usercanread = $user->rights->stock->mouvement->lire;
182$usercancreate = $user->rights->stock->mouvement->creer;
183$usercandelete = $user->rights->stock->mouvement->creer;
192if (
GETPOST(
'cancel',
'alpha')) {
196if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
200$parameters = array();
201$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
206if (empty($reshook)) {
208 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
211 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
212 $search_date_startday =
'';
213 $search_date_startmonth =
'';
214 $search_date_startyear =
'';
215 $search_date_endday =
'';
216 $search_date_endmonth =
'';
217 $search_date_endyear =
'';
218 $search_date_start =
'';
219 $search_date_end =
'';
221 $search_movement =
"";
222 $search_type_mouvement =
"";
223 $search_inventorycode =
"";
224 $search_product_ref =
"";
225 $search_product =
"";
226 $search_warehouse =
"";
230 $search_fk_project =
"";
233 $search_array_options = array();
235 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')
236 ||
GETPOST(
'button_search_x',
'alpha') ||
GETPOST(
'button_search.x',
'alpha') ||
GETPOST(
'button_search',
'alpha')) {
241 $objectclass =
'MouvementStock';
242 $objectlabel =
'MouvementStock';
244 if (!$error && $massaction ==
"builddoc" && $permissiontoread && !
GETPOST(
'button_search')) {
245 if (empty($diroutputmassaction)) {
246 dol_print_error(
null,
'include of actions_massactions.inc.php is done but var $diroutputmassaction was not defined');
250 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
251 require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
252 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
254 $objecttmp =
new $objectclass($db);
255 $listofobjectid = array();
256 foreach ($toselect as $toselectid) {
257 $objecttmp =
new $objectclass($db);
258 $result = $objecttmp->fetch($toselectid);
260 $listofobjectid[$toselectid] = $toselectid;
264 $arrayofinclusion = array();
265 foreach ($listofobjectref as $tmppdf) {
268 foreach ($listofobjectref as $tmppdf) {
269 $arrayofinclusion[] =
'^'.preg_quote(
dol_sanitizeFileName($tmppdf),
'/').
'_[a-zA-Z0-9-_]+\.pdf$';
271 $listoffiles =
dol_dir_list($uploaddir,
'all', 1, implode(
'|', $arrayofinclusion),
'\.meta$|\.png',
'date', SORT_DESC, 0,
true);
274 $outputlangs = $langs;
277 $newlang =
GETPOST(
'lang_id',
'aZ09');
282 if (!empty($newlang)) {
284 $outputlangs->setDefaultLang($newlang);
292 $filename = preg_replace(
'/\s/',
'_', $filename);
304 $file = $diroutputmassaction.
'/'.$filename.
'_'.
dol_print_date($now,
'dayhourlog').
'.pdf';
313 $langs->load(
"exports");
321 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
324if ($action ==
'update_extras') {
325 $tmpwarehouse->oldcopy =
dol_clone($tmpwarehouse);
328 $ret = $extrafields->setOptionalsFromPost(
null, $tmpwarehouse,
GETPOST(
'attribute',
'restricthtml'));
333 $result = $tmpwarehouse->insertExtraFields();
340 $action =
'edit_extras';
345if ($action ==
"correct_stock") {
347 if (!empty($product_id)) {
348 $result = $product->fetch($product_id);
353 if (empty($product_id)) {
355 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Product")),
null,
'errors');
356 $action =
'correction';
358 if (!is_numeric(
GETPOST(
"nbpiece"))) {
360 setEventMessages($langs->trans(
"ErrorFieldMustBeANumeric", $langs->transnoentitiesnoconv(
"NumberOfUnit")),
null,
'errors');
361 $action =
'correction';
365 $origin_element =
'';
368 if (
GETPOST(
'projectid',
'int')) {
369 $origin_element =
'project';
370 $origin_id =
GETPOST(
'projectid',
'int');
373 if ($product->hasbatch()) {
374 $batch =
GETPOST(
'batch_number',
'alphanohtml');
381 $result = $product->correct_stock_batch(
386 GETPOST(
"label",
'alphanohtml'),
391 GETPOST(
'inventorycode',
'alphanohtml'),
398 $result = $product->correct_stock(
403 GETPOST(
"label",
'alphanohtml'),
405 GETPOST(
'inventorycode',
'alphanohtml'),
414 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
419 $action =
'correction';
429if ($action ==
"transfert_stock" && !$cancel) {
431 if (!empty($product_id)) {
432 $result = $product->fetch($product_id);
435 if (!(
GETPOST(
"id_entrepot_destination",
'int') > 0)) {
436 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Warehouse")),
null,
'errors');
438 $action =
'transfert';
440 if (empty($product_id)) {
442 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Product")),
null,
'errors');
443 $action =
'transfert';
445 if (!
GETPOST(
"nbpiece",
'int')) {
446 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"NumberOfUnit")),
null,
'errors');
448 $action =
'transfert';
450 if ($id ==
GETPOST(
"id_entrepot_destination",
'int')) {
451 setEventMessages($langs->trans(
"ErrorSrcAndTargetWarehouseMustDiffers"),
null,
'errors');
453 $action =
'transfert';
456 if (isModEnabled(
'productbatch')) {
458 $result = $product->fetch($product_id);
460 if ($product->hasbatch() && !
GETPOST(
"batch_number")) {
461 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"batch_number")),
null,
'errors');
463 $action =
'transfert';
470 $result = $object->fetch($id);
474 $product->load_stock(
'novirtual');
478 if (isset($product->pmp)) {
479 $pricesrc = $product->pmp;
481 $pricedest = $pricesrc;
483 if ($product->hasbatch()) {
487 $result = $pdluo->fetch($pdluoid);
489 $srcwarehouseid = $pdluo->warehouseid;
490 $batch = $pdluo->batch;
491 $eatby = $pdluo->eatby;
492 $sellby = $pdluo->sellby;
498 $srcwarehouseid = $id;
499 $batch =
GETPOST(
'batch_number',
'alphanohtml');
506 $result1 = $product->correct_stock_batch(
523 $result2 = $product->correct_stock_batch(
525 GETPOST(
"id_entrepot_destination",
'int'),
533 GETPOST(
'inventorycode',
'alphanohtml'),
542 $result1 = $product->correct_stock(
549 GETPOST(
'inventorycode',
'alphanohtml'),
557 $result2 = $product->correct_stock(
559 GETPOST(
"id_entrepot_destination"),
564 GETPOST(
'inventorycode',
'alphanohtml'),
571 if (!$error && $result1 >= 0 && $result2 >= 0) {
575 header(
"Location: ".$backtopage);
578 header(
"Location: movement_list.php?id=".$object->id);
584 $action =
'transfert';
591if ($action ==
'confirm_reverse' && $confirm ==
"yes") {
592 $listMouvement = array();
593 $toselect = array_map(
'intval', $toselect);
595 $sql =
"SELECT rowid, label, inventorycode, datem";
596 $sql .=
" FROM ".MAIN_DB_PREFIX.
"stock_mouvement";
597 $sql .=
" WHERE rowid IN (";
598 foreach ($toselect as $id) {
599 $sql .= ((int) $id).
",";
601 $sql = rtrim($sql,
',');
604 $resql = $db->query($sql);
606 $num = $db->num_rows($resql);
609 $obj = $db->fetch_object($resql);
610 $object->fetch($obj->rowid);
611 $reverse = $object->reverseMouvement();
620 setEventMessages($langs->trans(
"WarningAlreadyReverse", $langs->transnoentities($idAlreadyReverse)),
null,
'warnings');
625 header(
"Location: ".$_SERVER[
"PHP_SELF"]);
634$form =
new Form($db);
636if (isModEnabled(
'project')) {
640$productstatic =
new Product($db);
641$warehousestatic =
new Entrepot($db);
643$userstatic =
new User($db);
649$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,";
650$sql .=
" e.ref as warehouse_ref, e.rowid as entrepot_id, e.lieu, e.fk_parent, e.statut,";
651$sql .=
" m.rowid as mid, m.value as qty, m.datem, m.fk_user_author, m.label, m.inventorycode, m.fk_origin, m.origintype,";
652$sql .=
" m.batch, m.price,";
653$sql .=
" m.type_mouvement,";
654$sql .=
" m.fk_projet as fk_project,";
655$sql .=
" pl.rowid as lotid, pl.eatby, pl.sellby,";
656$sql .=
" u.login, u.photo, u.lastname, u.firstname, u.email as user_email, u.statut as user_status";
658if (!empty($extrafields->attributes[$object->table_element][
'label'])) {
659 foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $val) {
660 $sql .= ($extrafields->attributes[$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
664$parameters = array();
665$reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object, $action);
666$sql .= $hookmanager->resPrint;
667$sql = preg_replace(
'/,\s*$/',
'', $sql);
671$sql .=
" FROM ".MAIN_DB_PREFIX.
"entrepot as e,";
672$sql .=
" ".MAIN_DB_PREFIX.
"product as p,";
673$sql .=
" ".MAIN_DB_PREFIX.
"stock_mouvement as m";
674if (!empty($extrafields->attributes[$object->table_element][
'label']) && is_array($extrafields->attributes[$object->table_element][
'label']) && count($extrafields->attributes[$object->table_element][
'label'])) {
675 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element.
"_extrafields as ef on (m.rowid = ef.fk_object)";
677$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u ON m.fk_user_author = u.rowid";
678$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product_lot as pl ON m.batch = pl.batch AND m.fk_product = pl.fk_product";
681$parameters = array();
682$reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters, $object, $action);
683$sql .= $hookmanager->resPrint;
685$sql .=
" WHERE m.fk_product = p.rowid";
687 $sql .=
" AND m.rowid = ".((int) $msid);
689$sql .=
" AND m.fk_entrepot = e.rowid";
690$sql .=
" AND e.entity IN (".getEntity(
'stock').
")";
692 $sql .=
" AND p.fk_product_type = 0";
695 $sql .=
" AND e.rowid = ".((int) $id);
697if (!empty($search_date_start)) {
698 $sql .=
" AND m.datem >= '" . $db->idate($search_date_start) .
"'";
700if (!empty($search_date_end)) {
701 $sql .=
" AND m.datem <= '" . $db->idate($search_date_end) .
"'";
704 $sql .=
" AND p.rowid = ".((int) $idproduct);
706if (!empty($search_ref)) {
709if (!empty($search_movement)) {
712if (!empty($search_inventorycode)) {
715if (!empty($search_product_ref)) {
718if (!empty($search_product)) {
721if ($search_warehouse !=
'' && $search_warehouse !=
'-1') {
724if (!empty($search_user)) {
725 $sql .=
natural_search(array(
'u.lastname',
'u.firstname',
'u.login'), $search_user);
727if (!empty($search_batch)) {
730if (!empty($product_id) && $product_id !=
'-1') {
733if (!empty($search_fk_project) && $search_fk_project !=
'-1') {
736if ($search_qty !=
'') {
739if ($search_type_mouvement !=
'' && $search_type_mouvement !=
'-1') {
740 $sql .=
natural_search(
'm.type_mouvement', $search_type_mouvement, 2);
743include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
745$parameters = array();
746$reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object, $action);
747$sql .= $hookmanager->resPrint;
750$nbtotalofrecords =
'';
753 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
754 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
755 $resql = $db->query($sqlforcount);
757 $objforcount = $db->fetch_object($resql);
758 $nbtotalofrecords = $objforcount->nbtotalofrecords;
763 if (($page * $limit) > $nbtotalofrecords) {
771$sql .= $db->order($sortfield, $sortorder);
773 $sql .= $db->plimit($limit + 1, $offset);
776$resql = $db->query($sql);
782$num = $db->num_rows($resql);
789 $product->fetch($idproduct);
791if ($id > 0 || $ref) {
792 $result = $object->fetch($id, $ref);
803$help_url =
'EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks';
805 $title = $langs->trans(
'StockMovementForId', $msid);
807 $title = $langs->trans(
"ListOfStockMovements");
809 if (!empty($object->ref)) {
810 $title .=
' ('.$object->ref.
')';
812 $title .=
' ('.$langs->trans(
"ForThisWarehouse").
')';
826if ($object->id > 0) {
829 print
dol_get_fiche_head($head,
'movements', $langs->trans(
"Warehouse"), -1,
'stock');
832 $linkback =
'<a href="'.DOL_URL_ROOT.
'/product/stock/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
834 $morehtmlref =
'<div class="refidno">';
835 $morehtmlref .= $langs->trans(
"LocationSummary").
' : '.$object->lieu;
838 if (isModEnabled(
'project')) {
839 $langs->load(
"projects");
840 $morehtmlref .=
'<br>'.img_picto(
'',
'project').
' '.$langs->trans(
'Project').
' ';
841 if ($usercancreate && 1 == 2) {
842 if ($action !=
'classify') {
843 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.newToken().
'&id='.$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> : ';
845 if ($action ==
'classify') {
846 $projectid = $object->fk_project;
847 $morehtmlref .=
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'">';
848 $morehtmlref .=
'<input type="hidden" name="action" value="classin">';
849 $morehtmlref .=
'<input type="hidden" name="token" value="'.newToken().
'">';
850 $morehtmlref .= $formproject->select_projects(($socid > 0 ? $socid : -1), $projectid,
'projectid', 0, 0, 1, 1, 0, 0, 0,
'', 1, 0,
'maxwidth500');
851 $morehtmlref .=
'<input type="submit" class="button valignmiddle" value="'.$langs->trans(
"Modify").
'">';
852 $morehtmlref .=
'</form>';
854 $morehtmlref .= $form->form_project($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->socid, $object->fk_project,
'none', 0, 0, 0, 1,
'',
'maxwidth300');
857 if (!empty($object->fk_project)) {
859 $proj->fetch($object->fk_project);
860 $morehtmlref .=
' : '.$proj->getNomUrl(1);
862 $morehtmlref .=
' - '.$proj->title;
869 $morehtmlref .=
'</div>';
872 if ($user->socid && !in_array(
'stock', explode(
',',
getDolGlobalString(
'MAIN_MODULES_FOR_EXTERNAL')))) {
876 dol_banner_tab($object,
'ref', $linkback, $shownav,
'ref',
'ref', $morehtmlref);
879 print
'<div class="fichecenter">';
880 print
'<div class="fichehalfleft">';
881 print
'<div class="underbanner clearboth"></div>';
883 print
'<table class="border centpercent tableforfield">';
888 print
'<td class="titlefield tdtop">'.$langs->trans(
"Description").
'</td><td>'.
dol_htmlentitiesbr($object->description).
'</td></tr>';
890 $calcproductsunique = $object->nb_different_products();
891 $calcproducts = $object->nb_products();
894 print
'<tr><td>'.$langs->trans(
"NumberOfDifferentProducts").
'</td><td>';
895 print empty($calcproductsunique[
'nb']) ?
'0' : $calcproductsunique[
'nb'];
899 print
'<tr><td>'.$langs->trans(
"NumberOfProducts").
'</td><td>';
900 $valtoshow =
price2num($calcproducts[
'nb'],
'MS');
901 print empty($valtoshow) ?
'0' : $valtoshow;
907 print
'<div class="fichehalfright">';
908 print
'<div class="underbanner clearboth"></div>';
910 print
'<table class="border centpercent tableforfield">';
913 print
'<tr><td class="titlefield">'.$langs->trans(
"EstimatedStockValueShort").
'</td><td>';
914 print
price((empty($calcproducts[
'value']) ?
'0' :
price2num($calcproducts[
'value'],
'MT')), 0, $langs, 0, -1, -1, $conf->currency);
918 $sql =
"SELECT MAX(m.datem) as datem";
919 $sql .=
" FROM ".MAIN_DB_PREFIX.
"stock_mouvement as m";
920 $sql .=
" WHERE m.fk_entrepot = ".((int) $object->id);
921 $resqlbis = $db->query($sql);
923 $objbis = $db->fetch_object($resqlbis);
924 $lastmovementdate = $db->jdate($objbis->datem);
929 print
'<tr><td>'.$langs->trans(
"LastMovement").
'</td><td>';
930 if ($lastmovementdate) {
933 print $langs->trans(
"None");
938 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
941 if (isModEnabled(
'categorie')) {
942 print
'<tr><td valign="middle">'.$langs->trans(
"Categories").
'</td><td colspan="3">';
943 print $form->showCategories($object->id, Categorie::TYPE_WAREHOUSE, 1);
952 print
'<div class="clearboth"></div>';
959if ($action ==
"correction") {
960 include DOL_DOCUMENT_ROOT.
'/product/stock/tpl/stockcorrection.tpl.php';
965if ($action ==
"transfert") {
966 include DOL_DOCUMENT_ROOT.
'/product/stock/tpl/stocktransfer.tpl.php';
972if ((empty($action) || $action ==
'list') && $id > 0) {
973 print
"<div class=\"tabsAction\">\n";
975 $parameters = array();
976 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
978 if (empty($reshook)) {
979 if ($user->hasRight(
'stock',
'mouvement',
'creer')) {
980 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$id.
'&action=correction">'.$langs->trans(
"CorrectStock").
'</a>';
983 if ($user->hasRight(
'stock',
'mouvement',
'creer')) {
984 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$id.
'&action=transfert">'.$langs->trans(
"TransferStock").
'</a>';
991$arrayofselected = is_array($toselect) ? $toselect : array();
995 $param .=
'&mode='.urlencode($mode);
997if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
998 $param .=
'&contextpage='.urlencode($contextpage);
1000if ($limit > 0 && $limit != $conf->liste_limit) {
1001 $param .=
'&limit='.((int) $limit);
1004 $param .=
'&id='.urlencode($id);
1006if ($search_date_startday) {
1007 $param .=
'&search_date_startday='.urlencode($search_date_startday);
1009if ($search_date_startmonth) {
1010 $param .=
'&search_date_startmonth='.urlencode($search_date_startmonth);
1012if ($search_date_startyear) {
1013 $param .=
'&search_date_startyear='.urlencode($search_date_startyear);
1015if ($search_date_endday) {
1016 $param .=
'&search_date_endday='.urlencode($search_date_endday);
1018if ($search_date_endmonth) {
1019 $param .=
'&search_date_endmonth='.urlencode($search_date_endmonth);
1021if ($search_date_endyear) {
1022 $param .=
'&search_date_endyear='.urlencode($search_date_endyear);
1024if ($search_movement) {
1025 $param .=
'&search_movement='.urlencode($search_movement);
1027if ($search_inventorycode) {
1028 $param .=
'&search_inventorycode='.urlencode($search_inventorycode);
1030if ($search_type_mouvement) {
1031 $param .=
'&search_type_mouvement='.urlencode($search_type_mouvement);
1033if ($search_product_ref) {
1034 $param .=
'&search_product_ref='.urlencode($search_product_ref);
1036if ($search_product) {
1037 $param .=
'&search_product='.urlencode($search_product);
1040 $param .=
'&search_batch='.urlencode($search_batch);
1042if ($search_warehouse > 0) {
1043 $param .=
'&search_warehouse='.urlencode($search_warehouse);
1046 $param .=
'&search_user='.urlencode($search_user);
1048if ($idproduct > 0) {
1049 $param .=
'&idproduct='.urlencode($idproduct);
1051if ($search_fk_project !=
'' && $search_fk_project !=
'-1') {
1052 $param .=
'&search_fk_project='.urlencode($search_fk_project);
1055include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
1057$parameters = array(
'param' => &$param);
1058$reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object, $action);
1059$param .= $hookmanager->resPrint;
1062$arrayofmassactions = array();
1064 $arrayofmassactions[
'builddoc'] =
img_picto(
'',
'pdf',
'class="pictofixedwidth"').$langs->trans(
"GeneratePDF");
1068 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
1070if (!empty($permissiontoadd)) {
1071 $arrayofmassactions[
'prereverse'] =
img_picto(
'',
'add',
'class="pictofixedwidth"').$langs->trans(
"Reverse");
1073if (
GETPOST(
'nomassaction',
'int') || in_array($massaction, array(
'presend',
'predelete',
'prereverse'))) {
1074 $arrayofmassactions = array();
1077$massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
1079print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
1080if ($optioncss !=
'') {
1081 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
1083print
'<input type="hidden" name="token" value="'.newToken().
'">';
1084print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
1085print
'<input type="hidden" name="action" value="list">';
1086print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
1087print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
1088print
'<input type="hidden" name="type" value="'.$type.
'">';
1089print
'<input type="hidden" name="page" value="'.$page.
'">';
1090print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
1091print
'<input type="hidden" name="page_y" value="">';
1092print
'<input type="hidden" name="mode" value="'.$mode.
'">';
1094 print
'<input type="hidden" name="id" value="'.$id.
'">';
1101 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'movement', 0,
'',
'', $limit, 0, 0, 1);
1103 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'movement', 0,
'',
'', $limit, 0, 0, 1);
1107$topicmail =
"SendStockMovement";
1108$modelmail =
"movementstock";
1110$trackid =
'mov'.$object->id;
1111include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
1112if ($massaction ==
'prereverse') {
1113 print $form->formconfirm($_SERVER[
"PHP_SELF"], $langs->trans(
"ConfirmMassReverse"), $langs->trans(
"ConfirmMassReverseQuestion", count($toselect)),
"confirm_reverse",
null,
'', 0, 200, 500, 1,
'Yes');
1119 foreach ($fieldstosearchall as $key => $val) {
1120 $fieldstosearchall[$key] = $langs->trans($val);
1121 $setupstring .= $key.
"=".$val.
";";
1123 print
'<!-- Search done like if STOCK_QUICKSEARCH_ON_FIELDS = '.$setupstring.
' -->'.
"\n";
1124 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $search_all).join(
', ', $fieldstosearchall).
'</div>'.
"\n";
1129$parameters = array(
'arrayfields'=>&$arrayfields);
1130$reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
1131if (empty($reshook)) {
1132 $moreforfilter .= $hookmanager->resPrint;
1134 $moreforfilter = $hookmanager->resPrint;
1137if (!empty($moreforfilter)) {
1138 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
1139 print $moreforfilter;
1143$varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
1144$selectedfields = ($mode !=
'kanban' ? $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN',
'')) :
'');
1145$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
1147print
'<div class="div-table-responsive">';
1148print
'<table class="tagtable nobottomiftotal liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
1152print
'<tr class="liste_titre">';
1155 print
'<td class="liste_titre center maxwidthsearch">';
1156 $searchpicto = $form->showFilterButtons(
'left');
1160if (!empty($arrayfields[
'm.rowid'][
'checked'])) {
1162 print
'<td class="liste_titre left">';
1163 print
'<input class="flat maxwidth40" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).
'">';
1166if (!empty($arrayfields[
'm.datem'][
'checked'])) {
1168 print
'<td class="liste_titre center">';
1169 print
'<div class="nowrapfordate">';
1170 print $form->selectDate($search_date_start ? $search_date_start : -1,
'search_date_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'),
'tzuserrel');
1172 print
'<div class="nowrapfordate">';
1173 print $form->selectDate($search_date_end ? $search_date_end : -1,
'search_date_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'),
'tzuserrel');
1177if (!empty($arrayfields[
'p.ref'][
'checked'])) {
1179 print
'<td class="liste_titre left">';
1180 print
'<input class="flat maxwidth75" type="text" name="search_product_ref" value="'.dol_escape_htmltag($idproduct ? $product->ref : $search_product_ref).
'">';
1183if (!empty($arrayfields[
'p.label'][
'checked'])) {
1185 print
'<td class="liste_titre left">';
1186 print
'<input class="flat maxwidth100" type="text" name="search_product" value="'.dol_escape_htmltag($idproduct ? $product->label : $search_product).
'">';
1190if (!empty($arrayfields[
'm.batch'][
'checked'])) {
1191 print
'<td class="liste_titre center"><input class="flat maxwidth75" type="text" name="search_batch" value="'.dol_escape_htmltag($search_batch).
'"></td>';
1193if (!empty($arrayfields[
'pl.eatby'][
'checked'])) {
1194 print
'<td class="liste_titre left">';
1197if (!empty($arrayfields[
'pl.sellby'][
'checked'])) {
1198 print
'<td class="liste_titre left">';
1202if (!empty($arrayfields[
'e.ref'][
'checked'])) {
1203 print
'<td class="liste_titre maxwidthonsmartphone left">';
1205 print $formproduct->selectWarehouses($search_warehouse,
'search_warehouse',
'warehouseopen,warehouseinternal', 1, 0, 0,
'', 0, 0,
null,
'maxwidth200');
1208if (!empty($arrayfields[
'm.fk_user_author'][
'checked'])) {
1210 print
'<td class="liste_titre left">';
1211 print
'<input class="flat" type="text" size="6" name="search_user" value="'.dol_escape_htmltag($search_user).
'">';
1214if (!empty($arrayfields[
'm.inventorycode'][
'checked'])) {
1216 print
'<td class="liste_titre left">';
1217 print
'<input class="flat" type="text" size="4" name="search_inventorycode" value="'.dol_escape_htmltag($search_inventorycode).
'">';
1220if (!empty($arrayfields[
'm.label'][
'checked'])) {
1222 print
'<td class="liste_titre left">';
1223 print
'<input class="flat" type="text" size="8" name="search_movement" value="'.dol_escape_htmltag($search_movement).
'">';
1226if (!empty($arrayfields[
'origin'][
'checked'])) {
1228 print
'<td class="liste_titre left">';
1232if (!empty($arrayfields[
'm.fk_projet'][
'checked'])) {
1234 print
'<td class="liste_titre" align="left">';
1235 print $object->showInputField($object->fields[
'fk_project'],
'fk_project', $search_fk_project,
'',
'',
'search_',
'maxwidth125', 1);
1238if (!empty($arrayfields[
'm.type_mouvement'][
'checked'])) {
1240 print
'<td class="liste_titre center">';
1242 print
'<select id="search_type_mouvement" name="search_type_mouvement" class="maxwidth150">';
1243 print
'<option value="" '.(($search_type_mouvement ==
"") ?
'selected="selected"' :
'').
'> </option>';
1244 print
'<option value="0" '.(($search_type_mouvement ==
"0") ?
'selected="selected"' :
'').
'>'.$langs->trans(
'StockIncreaseAfterCorrectTransfer').
'</option>';
1245 print
'<option value="1" '.(($search_type_mouvement ==
"1") ?
'selected="selected"' :
'').
'>'.$langs->trans(
'StockDecreaseAfterCorrectTransfer').
'</option>';
1246 print
'<option value="2" '.(($search_type_mouvement ==
"2") ?
'selected="selected"' :
'').
'>'.$langs->trans(
'StockDecrease').
'</option>';
1247 print
'<option value="3" '.(($search_type_mouvement ==
"3") ?
'selected="selected"' :
'').
'>'.$langs->trans(
'StockIncrease').
'</option>';
1254if (!empty($arrayfields[
'm.value'][
'checked'])) {
1256 print
'<td class="liste_titre right">';
1257 print
'<input class="flat" type="text" size="4" name="search_qty" value="'.dol_escape_htmltag($search_qty).
'">';
1260if (!empty($arrayfields[
'm.price'][
'checked'])) {
1262 print
'<td class="liste_titre" align="left">';
1268include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
1271$parameters = array(
'arrayfields'=>$arrayfields);
1272$reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $object, $action);
1273print $hookmanager->resPrint;
1275if (!empty($arrayfields[
'm.datec'][
'checked'])) {
1276 print
'<td class="liste_titre">';
1280if (!empty($arrayfields[
'm.tms'][
'checked'])) {
1281 print
'<td class="liste_titre">';
1286 print
'<td class="liste_titre center maxwidthsearch">';
1287 $searchpicto = $form->showFilterButtons();
1293$totalarray = array();
1294$totalarray[
'nbfield'] = 0;
1298print
'<tr class="liste_titre">';
1301 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
1302 $totalarray[
'nbfield']++;
1304if (!empty($arrayfields[
'm.rowid'][
'checked'])) {
1305 print_liste_field_titre($arrayfields[
'm.rowid'][
'label'], $_SERVER[
"PHP_SELF"],
'm.rowid',
'', $param,
'', $sortfield, $sortorder);
1307if (!empty($arrayfields[
'm.datem'][
'checked'])) {
1308 print_liste_field_titre($arrayfields[
'm.datem'][
'label'], $_SERVER[
"PHP_SELF"],
'm.datem',
'', $param,
'', $sortfield, $sortorder,
'center ');
1310if (!empty($arrayfields[
'p.ref'][
'checked'])) {
1311 print_liste_field_titre($arrayfields[
'p.ref'][
'label'], $_SERVER[
"PHP_SELF"],
'p.ref',
'', $param,
'', $sortfield, $sortorder);
1313if (!empty($arrayfields[
'p.label'][
'checked'])) {
1314 print_liste_field_titre($arrayfields[
'p.label'][
'label'], $_SERVER[
"PHP_SELF"],
'p.label',
'', $param,
'', $sortfield, $sortorder);
1316if (!empty($arrayfields[
'm.batch'][
'checked'])) {
1317 print_liste_field_titre($arrayfields[
'm.batch'][
'label'], $_SERVER[
"PHP_SELF"],
'm.batch',
'', $param,
'', $sortfield, $sortorder,
'center ');
1319if (!empty($arrayfields[
'pl.eatby'][
'checked'])) {
1320 print_liste_field_titre($arrayfields[
'pl.eatby'][
'label'], $_SERVER[
"PHP_SELF"],
'pl.eatby',
'', $param,
'', $sortfield, $sortorder,
'center ');
1322if (!empty($arrayfields[
'pl.sellby'][
'checked'])) {
1323 print_liste_field_titre($arrayfields[
'pl.sellby'][
'label'], $_SERVER[
"PHP_SELF"],
'pl.sellby',
'', $param,
'', $sortfield, $sortorder,
'center ');
1325if (!empty($arrayfields[
'e.ref'][
'checked'])) {
1327 print_liste_field_titre($arrayfields[
'e.ref'][
'label'], $_SERVER[
"PHP_SELF"],
"e.ref",
"", $param,
"", $sortfield, $sortorder);
1329if (!empty($arrayfields[
'm.fk_user_author'][
'checked'])) {
1330 print_liste_field_titre($arrayfields[
'm.fk_user_author'][
'label'], $_SERVER[
"PHP_SELF"],
"m.fk_user_author",
"", $param,
"", $sortfield, $sortorder);
1332if (!empty($arrayfields[
'm.inventorycode'][
'checked'])) {
1333 print_liste_field_titre($arrayfields[
'm.inventorycode'][
'label'], $_SERVER[
"PHP_SELF"],
"m.inventorycode",
"", $param,
"", $sortfield, $sortorder);
1335if (!empty($arrayfields[
'm.label'][
'checked'])) {
1336 print_liste_field_titre($arrayfields[
'm.label'][
'label'], $_SERVER[
"PHP_SELF"],
"m.label",
"", $param,
"", $sortfield, $sortorder);
1338if (!empty($arrayfields[
'origin'][
'checked'])) {
1339 print_liste_field_titre($arrayfields[
'origin'][
'label'], $_SERVER[
"PHP_SELF"],
"",
"", $param,
"", $sortfield, $sortorder);
1341if (!empty($arrayfields[
'm.fk_projet'][
'checked'])) {
1342 print_liste_field_titre($arrayfields[
'm.fk_projet'][
'label'], $_SERVER[
"PHP_SELF"],
"m.fk_projet",
"", $param,
'', $sortfield, $sortorder);
1344if (!empty($arrayfields[
'm.type_mouvement'][
'checked'])) {
1345 print_liste_field_titre($arrayfields[
'm.type_mouvement'][
'label'], $_SERVER[
"PHP_SELF"],
"m.type_mouvement",
"", $param,
'', $sortfield, $sortorder,
'center ');
1347if (!empty($arrayfields[
'm.value'][
'checked'])) {
1348 print_liste_field_titre($arrayfields[
'm.value'][
'label'], $_SERVER[
"PHP_SELF"],
"m.value",
"", $param,
'', $sortfield, $sortorder,
'right ');
1350if (!empty($arrayfields[
'm.price'][
'checked'])) {
1351 print_liste_field_titre($arrayfields[
'm.price'][
'label'], $_SERVER[
"PHP_SELF"],
"m.price",
"", $param,
'', $sortfield, $sortorder,
'right ');
1355include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
1358$parameters = array(
'arrayfields'=>$arrayfields,
'param'=>$param,
'sortfield'=>$sortfield,
'sortorder'=>$sortorder,
'totalarray'=>&$totalarray);
1359$reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
1360print $hookmanager->resPrint;
1361if (!empty($arrayfields[
'm.datec'][
'checked'])) {
1362 print_liste_field_titre($arrayfields[
'p.datec'][
'label'], $_SERVER[
"PHP_SELF"],
"p.datec",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
1364if (!empty($arrayfields[
'm.tms'][
'checked'])) {
1365 print_liste_field_titre($arrayfields[
'p.tms'][
'label'], $_SERVER[
"PHP_SELF"],
"p.tms",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
1369 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
1370 $totalarray[
'nbfield']++;
1375$arrayofuniqueproduct = array();
1381$savnbfield = $totalarray[
'nbfield'];
1382$totalarray = array();
1383$totalarray[
'nbfield'] = 0;
1384$imaxinloop = ($limit ? min($num, $limit) : $num);
1385while ($i < $imaxinloop) {
1386 $obj = $db->fetch_object($resql);
1391 $userstatic->id = $obj->fk_user_author;
1392 $userstatic->login = $obj->login;
1393 $userstatic->lastname = $obj->lastname;
1394 $userstatic->firstname = $obj->firstname;
1395 $userstatic->photo = $obj->photo;
1396 $userstatic->email = $obj->user_email;
1397 $userstatic->statut = $obj->user_status;
1402 $sql =
"SELECT label";
1403 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_lang";
1404 $sql .=
" WHERE fk_product = ".((int) $obj->rowid);
1405 $sql .=
" AND lang = '".$db->escape($langs->getDefaultLang()).
"'";
1408 $result = $db->query($sql);
1410 $objtp = $db->fetch_object($result);
1411 if (!empty($objtp->label)) {
1412 $obj->produit = $objtp->label;
1417 $productstatic->id = $obj->rowid;
1418 $productstatic->ref = $obj->product_ref;
1419 $productstatic->label = $obj->produit;
1420 $productstatic->type = $obj->type;
1421 $productstatic->entity = $obj->entity;
1422 $productstatic->status = $obj->tosell;
1423 $productstatic->status_buy = $obj->tobuy;
1424 $productstatic->status_batch = $obj->tobatch;
1426 $productlot->id = $obj->lotid;
1427 $productlot->batch = $obj->batch;
1428 $productlot->eatby = $obj->eatby;
1429 $productlot->sellby = $obj->sellby;
1431 $warehousestatic->id = $obj->entrepot_id;
1432 $warehousestatic->ref = $obj->warehouse_ref;
1433 $warehousestatic->label = $obj->warehouse_ref;
1434 $warehousestatic->lieu = $obj->lieu;
1435 $warehousestatic->fk_parent = $obj->fk_parent;
1436 $warehousestatic->statut = $obj->statut;
1438 $movement->type = $obj->type_mouvement;
1440 $arrayofuniqueproduct[$obj->rowid] = $obj->produit;
1441 if (!empty($obj->fk_origin)) {
1442 $origin = $movement->get_origin($obj->fk_origin, $obj->origintype);
1447 if ($mode ==
'kanban') {
1449 print
'<tr class="trkanban"><td colspan="'.$savnbfield.
'">';
1450 print
'<div class="box-flex-container kanban">';
1454 if ($massactionbutton || $massaction) {
1456 if (in_array($object->id, $arrayofselected)) {
1460 print $object->getKanbanView(
'', array(
'selected' => $selected));
1461 if ($i == ($imaxinloop - 1)) {
1468 print
'<tr data-rowid="'.$object->id.
'" class="oddeven">';
1471 print
'<td class="nowrap center">';
1472 if ($massactionbutton || $massaction) {
1474 if (in_array($obj->mid, $arrayofselected)) {
1477 print
'<input id="cb'.$obj->mid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->mid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
1481 $totalarray[
'nbfield']++;
1485 if (!empty($arrayfields[
'm.rowid'][
'checked'])) {
1486 print
'<td class="nowraponall">';
1487 print
img_picto($langs->trans(
"StockMovement"),
'movement',
'class="pictofixedwidth"');
1491 if (!empty($arrayfields[
'm.datem'][
'checked'])) {
1493 print
'<td class="nowraponall center">'.dol_print_date($db->jdate($obj->datem),
'dayhour',
'tzuserrel').
'</td>';
1495 if (!empty($arrayfields[
'p.ref'][
'checked'])) {
1497 print
'<td class="nowraponall">';
1498 print $productstatic->getNomUrl(1,
'stock', 16);
1501 if (!empty($arrayfields[
'p.label'][
'checked'])) {
1503 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($productstatic->label).
'">';
1504 print $productstatic->label;
1507 if (!empty($arrayfields[
'm.batch'][
'checked'])) {
1508 print
'<td class="center nowraponall">';
1509 if ($productlot->id > 0) {
1510 print $productlot->getNomUrl(1);
1512 print $productlot->batch;
1516 if (!empty($arrayfields[
'pl.eatby'][
'checked'])) {
1517 print
'<td class="center">'.dol_print_date($obj->eatby,
'day').
'</td>';
1519 if (!empty($arrayfields[
'pl.sellby'][
'checked'])) {
1520 print
'<td class="center">'.dol_print_date($obj->sellby,
'day').
'</td>';
1523 if (!empty($arrayfields[
'e.ref'][
'checked'])) {
1524 print
'<td class="tdoverflowmax100">';
1525 print $warehousestatic->getNomUrl(1);
1529 if (!empty($arrayfields[
'm.fk_user_author'][
'checked'])) {
1530 print
'<td class="tdoverflowmax100">';
1531 print $userstatic->getNomUrl(-1);
1534 if (!empty($arrayfields[
'm.inventorycode'][
'checked'])) {
1536 print
'<td><a href="'.$_SERVER[
"PHP_SELF"].
'?search_inventorycode='.urlencode(
'^'.$obj->inventorycode.
'$').
'">'.
dol_escape_htmltag($obj->inventorycode).
'</a></td>';
1538 if (!empty($arrayfields[
'm.label'][
'checked'])) {
1540 print
'<td class="tdoverflowmax200" title="'.dol_escape_htmltag($obj->label).
'">'.
dol_escape_htmltag($obj->label).
'</td>';
1542 if (!empty($arrayfields[
'origin'][
'checked'])) {
1544 print
'<td class="nowraponall">'.$origin.
'</td>';
1546 if (!empty($arrayfields[
'm.fk_projet'][
'checked'])) {
1549 if ($obj->fk_project != 0) {
1550 print $movement->get_origin($obj->fk_project,
'project');
1554 if (!empty($arrayfields[
'm.type_mouvement'][
'checked'])) {
1556 print
'<td class="center">';
1557 print $movement->getTypeMovement();
1560 if (!empty($arrayfields[
'm.value'][
'checked'])) {
1562 print
'<td class="right">';
1563 if ($obj->qty > 0) {
1564 print
'<span class="stockmovemententry">';
1569 print
'<span class="stockmovementexit">';
1575 if (!empty($arrayfields[
'm.price'][
'checked'])) {
1577 print
'<td class="right">';
1578 if ($obj->price != 0) {
1579 print
price($obj->price);
1585 $object = $movement;
1586 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
1588 $parameters = array(
'arrayfields'=>$arrayfields,
'object'=>$object,
'obj'=>$obj,
'i'=>$i,
'totalarray'=>&$totalarray);
1589 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
1590 print $hookmanager->resPrint;
1594 print
'<td class="nowrap center">';
1595 if ($massactionbutton || $massaction) {
1597 if (in_array($obj->mid, $arrayofselected)) {
1600 print
'<input id="cb'.$obj->mid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->mid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
1604 $totalarray[
'nbfield']++;
1617 foreach ($arrayfields as $key => $val) {
1618 if (!empty($val[
'checked'])) {
1622 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
1627$parameters = array(
'arrayfields'=>$arrayfields,
'sql'=>$sql);
1628$reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
1629print $hookmanager->resPrint;
1631print
'</table>'.
"\n";
1634print
'</form>'.
"\n";
1637if (count($arrayofuniqueproduct) == 1 && !empty($year) && is_numeric($year)) {
1640 $productidselected = 0;
1641 foreach ($arrayofuniqueproduct as $key => $val) {
1642 $productidselected = $key;
1643 $productlabelselected = $val;
1645 $datebefore =
dol_get_first_day($year ? $year : strftime(
"%Y", time()), $month ? $month : 1, true);
1646 $dateafter =
dol_get_last_day($year ? $year : strftime(
"%Y", time()), $month ? $month : 12, true);
1647 $balancebefore = $movement->calculateBalanceForProductBefore($productidselected, $datebefore);
1648 $balanceafter = $movement->calculateBalanceForProductBefore($productidselected, $dateafter);
1651 print $langs->trans(
"NbOfProductBeforePeriod", $productlabelselected,
dol_print_date($datebefore,
'day',
'gmt'));
1654 print
': '.$balancebefore;
1658 print $langs->trans(
"NbOfProductAfterPeriod", $productlabelselected,
dol_print_date($dateafter,
'day',
'gmt'));
1661 print
': '.$balanceafter;
1666if (in_array(
'builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords ===
'' || $nbtotalofrecords)) {
1667 $hidegeneratedfilelistifempty = 1;
1668 if ($massaction ==
'builddoc' || $action ==
'remove_file' || $show_files) {
1669 $hidegeneratedfilelistifempty = 0;
1672 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
1676 $urlsource = $_SERVER[
'PHP_SELF'].
'?sortfield='.$sortfield.
'&sortorder='.$sortorder;
1677 $urlsource .= str_replace(
'&',
'&', $param);
1679 $filedir = $diroutputmassaction;
1680 $genallowed = $permissiontoread;
1681 $delallowed = $permissiontoadd;
1683 print $formfile->showdocuments(
'massfilesarea_'.$object->module,
'', $filedir, $urlsource, 0, $delallowed,
'', 1, 1, 0, 48, 1, $param, $title,
'',
'',
'',
null, $hidegeneratedfilelistifempty);
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.
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($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_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='')
Show tab footer of a card.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_get_fiche_end($notab=0)
Return tab footer of a card.
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom='UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
img_edit($titlealt='default', $float=0, $other='')
Show logo editer/modifier 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.