26require
'../main.inc.php';
27require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
28require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
29require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
30require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
31require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
32require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/entrepot.class.php';
33require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/mouvementstock.class.php';
34require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/productlot.class.php';
39$langs->loadLangs(array(
"mrp",
"stocks",
"other"));
44$action =
GETPOST(
'action',
'aZ09');
45$confirm =
GETPOST(
'confirm',
'alpha');
46$cancel =
GETPOST(
'cancel',
'aZ09');
47$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'mostockmovement';
48$backtopage =
GETPOST(
'backtopage',
'alpha');
49$optioncss =
GETPOST(
'optioncss',
'aZ');
50$massaction =
GETPOST(
'massaction',
'aZ09');
51$lineid =
GETPOST(
'lineid',
'int');
55$month =
GETPOST(
"month",
'int');
56$search_ref =
GETPOST(
'search_ref',
'alpha');
57$search_movement =
GETPOST(
"search_movement",
'alpha');
58$search_product_ref = trim(
GETPOST(
"search_product_ref",
'alpha'));
59$search_product = trim(
GETPOST(
"search_product",
'alpha'));
60$search_warehouse = trim(
GETPOST(
"search_warehouse",
'alpha'));
61$search_inventorycode = trim(
GETPOST(
"search_inventorycode",
'alpha'));
62$search_user = trim(
GETPOST(
"search_user",
'alpha'));
63$search_batch = trim(
GETPOST(
"search_batch",
'alpha'));
64$search_qty = trim(
GETPOST(
"search_qty",
'alpha'));
65$search_type_mouvement =
GETPOST(
'search_type_mouvement',
'int');
67$limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
68$page = GETPOSTISSET(
'pageplusone') ? (
GETPOST(
'pageplusone') - 1) :
GETPOST(
"page",
'int');
69$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
70$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
71if (empty($page) || $page == -1) {
74$offset = $limit * $page;
76 $sortfield =
"m.datem";
85$diroutputmassaction = $conf->mrp->dir_output.
'/temp/massgeneration/'.$user->id;
86$hookmanager->initHooks(array(
'mocard',
'globalcard'));
89$extrafields->fetch_name_optionals_label($object->table_element);
91$search_array_options = $extrafields->getOptionalsFromPost($object->table_element,
'',
'search_');
94$search_all = trim(
GETPOST(
"search_all",
'alpha'));
96foreach ($object->fields as $key => $val) {
97 if (
GETPOST(
'search_'.$key,
'alpha')) {
98 $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
102if (empty($action) && empty($id) && empty($ref)) {
107include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
112$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
113$result =
restrictedArea($user,
'mrp', $object->id,
'mrp_mo',
'',
'fk_soc',
'rowid', $isdraft);
119 'm.rowid'=>array(
'label'=>
"Ref",
'checked'=>1,
'position'=>1),
120 'm.datem'=>array(
'label'=>
"Date",
'checked'=>1,
'position'=>2),
121 'p.ref'=>array(
'label'=>
"ProductRef",
'checked'=>1,
'css'=>
'maxwidth100',
'position'=>3),
122 'p.label'=>array(
'label'=>
"ProductLabel",
'checked'=>0,
'position'=>5),
123 'm.batch'=>array(
'label'=>
"BatchNumberShort",
'checked'=>1,
'position'=>8,
'enabled'=>(isModEnabled(
'productbatch'))),
124 'pl.eatby'=>array(
'label'=>
"EatByDate",
'checked'=>0,
'position'=>9,
'enabled'=>(isModEnabled(
'productbatch'))),
125 'pl.sellby'=>array(
'label'=>
"SellByDate",
'checked'=>0,
'position'=>10,
'enabled'=>(isModEnabled(
'productbatch'))),
126 'e.ref'=>array(
'label'=>
"Warehouse",
'checked'=>1,
'position'=>100,
'enabled'=>(!($id > 0))),
127 'm.fk_user_author'=>array(
'label'=>
"Author",
'checked'=>0,
'position'=>120),
128 'm.inventorycode'=>array(
'label'=>
"InventoryCodeShort",
'checked'=>1,
'position'=>130),
129 'm.label'=>array(
'label'=>
"MovementLabel",
'checked'=>1,
'position'=>140),
130 'm.type_mouvement'=>array(
'label'=>
"TypeMovement",
'checked'=>0,
'position'=>150),
131 'origin'=>array(
'label'=>
"Origin",
'checked'=>1,
'position'=>155),
132 'm.fk_projet'=>array(
'label'=>
'Project',
'checked'=>0,
'position'=>180),
133 'm.value'=>array(
'label'=>
"Qty",
'checked'=>1,
'position'=>200),
134 'm.price'=>array(
'label'=>
"UnitPurchaseValue",
'checked'=>0,
'position'=>210)
138if (!empty($conf->global->PRODUCT_DISABLE_SELLBY)) {
139 unset($arrayfields[
'pl.sellby']);
141if (!empty($conf->global->PRODUCT_DISABLE_EATBY)) {
142 unset($arrayfields[
'pl.eatby']);
144$objectlist->fields =
dol_sort_array($objectlist->fields,
'position');
147$permissionnote = $user->rights->mrp->write;
148$permissiondellink = $user->rights->mrp->write;
149$permissiontoadd = $user->rights->mrp->write;
150$permissiontodelete = $user->rights->mrp->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
151$upload_dir = $conf->mrp->multidir_output[isset($object->entity) ? $object->entity : 1];
153$permissiontoproduce = $permissiontoadd;
154$permissiontoupdatecost = $user->hasRight(
'bom',
'write');
156if ($permissiontoupdatecost) {
157 $arrayfields[
'm.price'][
'enabled'] = 1;
160$arrayofselected = array();
167if (
GETPOST(
'cancel',
'alpha')) {
168 $action =
'list'; $massaction =
'';
170if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
174$parameters = array();
175$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
180include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
183if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
187 $search_movement =
"";
188 $search_type_mouvement =
"";
189 $search_inventorycode =
"";
190 $search_product_ref =
"";
191 $search_product =
"";
192 $search_warehouse =
"";
198 $search_array_options = array();
201if (empty($reshook)) {
206 if (empty($backtopage) || ($cancel && empty($id))) {
208 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
209 $backtopage = $backurlforlist;
211 $backtopage = DOL_URL_ROOT.
'/mrp/mo_production.php?id='.($id > 0 ? $id :
'__ID__');
214 $triggermodname =
'MO_MODIFY';
217 include DOL_DOCUMENT_ROOT.
'/core/actions_addupdatedelete.inc.php';
220 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
223 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
226 $triggersendname =
'MO_SENTBYMAIL';
227 $autocopy =
'MAIN_MAIL_AUTOCOPY_MO_TO';
228 $trackid =
'mo'.$object->id;
229 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
234 if ($action ==
'set_thirdparty' && $permissiontoadd) {
235 $object->setValueFrom(
'fk_soc',
GETPOST(
'fk_soc',
'int'),
'',
'',
'date',
'', $user, $triggermodname);
237 if ($action ==
'classin' && $permissiontoadd) {
238 $object->setProject(
GETPOST(
'projectid',
'int'));
241 if ($action ==
'confirm_reopen') {
242 $result = $object->setStatut($object::STATUS_INPROGRESS, 0,
'',
'MRP_REOPEN');
252$form =
new Form($db);
255$productstatic =
new Product($db);
257$warehousestatic =
new Entrepot($db);
258$userstatic =
new User($db);
260$help_url =
'EN:Module_Manufacturing_Orders|FR:Module_Ordres_de_Fabrication|DE:Modul_Fertigungsauftrag';
262llxHeader(
'', $langs->trans(
'Mo'), $help_url);
265if ($object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create'))) {
266 $res = $object->fetch_thirdparty();
267 $res = $object->fetch_optionals();
271 print
dol_get_fiche_head($head,
'stockmovement', $langs->trans(
"ManufacturingOrder"), -1, $object->picto);
276 if ($action ==
'delete') {
277 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'DeleteMo'), $langs->trans(
'ConfirmDeleteMo'),
'confirm_delete',
'', 0, 1);
280 if ($action ==
'deleteline') {
281 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&lineid='.$lineid, $langs->trans(
'DeleteLine'), $langs->trans(
'ConfirmDeleteLine'),
'confirm_deleteline',
'', 0, 1);
284 if ($action ==
'clone') {
286 $formquestion = array();
287 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneMo', $object->ref),
'confirm_clone', $formquestion,
'yes', 1);
291 if ($action ==
'xxx') {
292 $formquestion = array();
303 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'XXX'), $text,
'confirm_xxx', $formquestion, 0, 1, 220);
307 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
308 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
309 if (empty($reshook)) {
310 $formconfirm .= $hookmanager->resPrint;
311 } elseif ($reshook > 0) {
312 $formconfirm = $hookmanager->resPrint;
321 $linkback =
'<a href="'.dol_buildpath(
'/mrp/mo_list.php', 1).
'?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
323 $morehtmlref =
'<div class="refidno">';
329 if (is_object($object->thirdparty)) {
330 $morehtmlref .= $object->thirdparty->getNomUrl(1,
'customer');
331 if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) {
332 $morehtmlref .=
' (<a href="'.DOL_URL_ROOT.
'/commande/list.php?socid='.$object->thirdparty->id.
'&search_societe='.urlencode($object->thirdparty->name).
'">'.$langs->trans(
"OtherOrders").
'</a>)';
336 if (isModEnabled(
'project')) {
337 $langs->load(
"projects");
338 if (is_object($object->thirdparty)) {
339 $morehtmlref .=
'<br>';
341 if ($permissiontoadd) {
342 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
343 if ($action !=
'classify') {
344 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.newToken().
'&id='.$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
346 $morehtmlref .= $form->form_project($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->socid, $object->fk_project, ($action ==
'classify' ?
'projectid' :
'none'), 0, 0, 0, 1,
'',
'maxwidth300');
348 if (!empty($object->fk_project)) {
350 $proj->fetch($object->fk_project);
351 $morehtmlref .= $proj->getNomUrl(1);
353 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
358 $morehtmlref .=
'</div>';
361 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
364 print
'<div class="fichecenter">';
365 print
'<div class="fichehalfleft">';
366 print
'<div class="underbanner clearboth"></div>';
367 print
'<table class="border centpercent tableforfield">'.
"\n";
370 $keyforbreak =
'fk_warehouse';
371 unset($object->fields[
'fk_project']);
372 unset($object->fields[
'fk_soc']);
373 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_view.tpl.php';
376 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
382 print
'<div class="clearboth"></div>';
420 $sql =
"SELECT p.rowid, p.ref as product_ref, p.label as produit, p.tobatch, p.fk_product_type as type, p.entity,";
421 $sql .=
" e.ref as warehouse_ref, e.rowid as entrepot_id, e.lieu,";
422 $sql .=
" m.rowid as mid, m.value as qty, m.datem, m.fk_user_author, m.label, m.inventorycode, m.fk_origin, m.origintype,";
423 $sql .=
" m.batch, m.price,";
424 $sql .=
" m.type_mouvement,";
425 $sql .=
" pl.rowid as lotid, pl.eatby, pl.sellby,";
426 $sql .=
" u.login, u.photo, u.lastname, u.firstname";
428 if (!empty($extrafields->attributes[$objectlist->table_element][
'label'])) {
429 foreach ($extrafields->attributes[$objectlist->table_element][
'label'] as $key => $val) {
430 $sql .= ($extrafields->attributes[$objectlist->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
434 $parameters = array();
435 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters);
436 $sql .= $hookmanager->resPrint;
437 $sql .=
" FROM ".MAIN_DB_PREFIX.
"entrepot as e,";
438 $sql .=
" ".MAIN_DB_PREFIX.
"product as p,";
439 $sql .=
" ".MAIN_DB_PREFIX.
"stock_mouvement as m";
440 if (!empty($extrafields->attributes[$objectlist->table_element]) && is_array($extrafields->attributes[$objectlist->table_element][
'label']) && count($extrafields->attributes[$objectlist->table_element][
'label'])) {
441 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$objectlist->table_element.
"_extrafields as ef on (m.rowid = ef.fk_object)";
443 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u ON m.fk_user_author = u.rowid";
444 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product_lot as pl ON m.batch = pl.batch AND m.fk_product = pl.fk_product";
445 $sql .=
" WHERE m.fk_product = p.rowid";
446 $sql .=
" AND m.origintype = 'mo' AND m.fk_origin = ".(int) $object->id;
448 $sql .=
" AND m.rowid = ".((int) $msid);
450 $sql .=
" AND m.fk_entrepot = e.rowid";
451 $sql .=
" AND e.entity IN (".getEntity(
'stock').
")";
452 if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) {
453 $sql .=
" AND p.fk_product_type = 0";
456 if (!empty($search_ref)) {
459 if (!empty($search_movement)) {
462 if (!empty($search_inventorycode)) {
465 if (!empty($search_product_ref)) {
468 if (!empty($search_product)) {
471 if ($search_warehouse !=
'' && $search_warehouse !=
'-1') {
474 if (!empty($search_user)) {
475 $sql .=
natural_search(array(
'u.lastname',
'u.firstname',
'u.login'), $search_user);
477 if (!empty($search_batch)) {
480 if ($search_qty !=
'') {
483 if ($search_type_mouvement !=
'' && $search_type_mouvement !=
'-1') {
484 $sql .=
natural_search(
'm.type_mouvement', $search_type_mouvement, 2);
487 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
489 $parameters = array();
490 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters);
491 $sql .= $hookmanager->resPrint;
492 $sql .= $db->order($sortfield, $sortorder);
494 $nbtotalofrecords =
'';
496 $result = $db->query($sql);
497 $nbtotalofrecords = $db->num_rows($result);
498 if (($page * $limit) > $nbtotalofrecords) {
503 $sql .= $db->plimit($limit + 1, $offset);
505 $resql = $db->query($sql);
509 $num = $db->num_rows($resql);
512 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
513 $param .=
'&contextpage='.urlencode($contextpage);
515 if ($limit > 0 && $limit != $conf->liste_limit) {
516 $param .=
'&limit='.((int) $limit);
519 $param .=
'&id='.urlencode($id);
521 if ($search_movement) {
522 $param .=
'&search_movement='.urlencode($search_movement);
524 if ($search_inventorycode) {
525 $param .=
'&search_inventorycode='.urlencode($search_inventorycode);
527 if ($search_type_mouvement) {
528 $param .=
'&search_type_mouvement='.urlencode($search_type_mouvement);
530 if ($search_product_ref) {
531 $param .=
'&search_product_ref='.urlencode($search_product_ref);
533 if ($search_product) {
534 $param .=
'&search_product='.urlencode($search_product);
537 $param .=
'&search_batch='.urlencode($search_batch);
539 if ($search_warehouse > 0) {
540 $param .=
'&search_warehouse='.urlencode($search_warehouse);
543 $param .=
'&search_user='.urlencode($search_user);
547 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
550 $arrayofmassactions = array(
555 if (in_array($massaction, array(
'presend',
'predelete'))) {
556 $arrayofmassactions = array();
558 $massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
560 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
561 if ($optioncss !=
'') {
562 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
564 print
'<input type="hidden" name="token" value="'.newToken().
'">';
565 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
566 print
'<input type="hidden" name="action" value="list">';
567 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
568 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
569 print
'<input type="hidden" name="page" value="'.$page.
'">';
570 print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
572 print
'<input type="hidden" name="id" value="'.$id.
'">';
576 print_barre_liste(
'', $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'', 0,
'',
'', $limit);
578 print_barre_liste(
'', $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'generic', 0,
'',
'', $limit);
583 $parameters = array();
584 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters);
585 if (empty($reshook)) {
586 $moreforfilter .= $hookmanager->resPrint;
588 $moreforfilter = $hookmanager->resPrint;
591 if (!empty($moreforfilter)) {
592 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
593 print $moreforfilter;
597 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
598 $selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage);
600 print
'<div class="div-table-responsive">';
601 print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
604 print
'<tr class="liste_titre_filter">';
605 if (!empty($arrayfields[
'm.rowid'][
'checked'])) {
607 print
'<td class="liste_titre left">';
608 print
'<input class="flat maxwidth25" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).
'">';
611 if (!empty($arrayfields[
'm.datem'][
'checked'])) {
612 print
'<td class="liste_titre nowraponall">';
613 print
'<input class="flat" type="text" size="2" maxlength="2" placeholder="'.dol_escape_htmltag($langs->trans(
"Month")).
'" name="month" value="'.$month.
'">';
614 if (!isModEnabled(
'productbatch')) {
618 $syear = $year ? $year : -1;
619 print
'<input class="flat maxwidth50" type="text" maxlength="4" placeholder="'.dol_escape_htmltag($langs->trans(
"Year")).
'" name="year" value="'.($syear > 0 ? $syear :
'').
'">';
623 if (!empty($arrayfields[
'p.ref'][
'checked'])) {
625 print
'<td class="liste_titre left">';
626 print
'<input class="flat maxwidth75" type="text" name="search_product_ref" value="'.dol_escape_htmltag($search_product_ref).
'">';
629 if (!empty($arrayfields[
'p.label'][
'checked'])) {
631 print
'<td class="liste_titre left">';
632 print
'<input class="flat maxwidth100" type="text" name="search_product" value="'.dol_escape_htmltag($search_product).
'">';
636 if (!empty($arrayfields[
'm.batch'][
'checked'])) {
637 print
'<td class="liste_titre center"><input class="flat maxwidth75" type="text" name="search_batch" value="'.dol_escape_htmltag($search_batch).
'"></td>';
639 if (!empty($arrayfields[
'pl.eatby'][
'checked'])) {
640 print
'<td class="liste_titre left">';
643 if (!empty($arrayfields[
'pl.sellby'][
'checked'])) {
644 print
'<td class="liste_titre left">';
648 if (!empty($arrayfields[
'e.ref'][
'checked'])) {
649 print
'<td class="liste_titre maxwidthonsmartphone left">';
651 print $formproduct->selectWarehouses($search_warehouse,
'search_warehouse',
'warehouseopen,warehouseinternal', 1, 0, 0,
'', 0, 0,
null,
'maxwidth200');
654 if (!empty($arrayfields[
'm.fk_user_author'][
'checked'])) {
656 print
'<td class="liste_titre left">';
657 print
'<input class="flat" type="text" size="6" name="search_user" value="'.dol_escape_htmltag($search_user).
'">';
660 if (!empty($arrayfields[
'm.inventorycode'][
'checked'])) {
662 print
'<td class="liste_titre left">';
663 print
'<input class="flat" type="text" size="4" name="search_inventorycode" value="'.dol_escape_htmltag($search_inventorycode).
'">';
666 if (!empty($arrayfields[
'm.label'][
'checked'])) {
668 print
'<td class="liste_titre left">';
669 print
'<input class="flat" type="text" size="8" name="search_movement" value="'.dol_escape_htmltag($search_movement).
'">';
672 if (!empty($arrayfields[
'm.type_mouvement'][
'checked'])) {
674 print
'<td class="liste_titre center">';
676 print
'<select id="search_type_mouvement" name="search_type_mouvement" class="maxwidth150">';
677 print
'<option value="" '.(($search_type_mouvement ==
"") ?
'selected="selected"' :
'').
'> </option>';
678 print
'<option value="0" '.(($search_type_mouvement ==
"0") ?
'selected="selected"' :
'').
'>'.$langs->trans(
'StockIncreaseAfterCorrectTransfer').
'</option>';
679 print
'<option value="1" '.(($search_type_mouvement ==
"1") ?
'selected="selected"' :
'').
'>'.$langs->trans(
'StockDecreaseAfterCorrectTransfer').
'</option>';
680 print
'<option value="2" '.(($search_type_mouvement ==
"2") ?
'selected="selected"' :
'').
'>'.$langs->trans(
'StockDecrease').
'</option>';
681 print
'<option value="3" '.(($search_type_mouvement ==
"3") ?
'selected="selected"' :
'').
'>'.$langs->trans(
'StockIncrease').
'</option>';
688 if (!empty($arrayfields[
'origin'][
'checked'])) {
690 print
'<td class="liste_titre left">';
694 if (!empty($arrayfields[
'm.fk_projet'][
'checked'])) {
696 print
'<td class="liste_titre" align="left">';
700 if (!empty($arrayfields[
'm.value'][
'checked'])) {
702 print
'<td class="liste_titre right">';
703 print
'<input class="flat" type="text" size="4" name="search_qty" value="'.dol_escape_htmltag($search_qty).
'">';
706 if (!empty($arrayfields[
'm.price'][
'checked'])) {
708 print
'<td class="liste_titre left">';
715 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
718 $parameters = array(
'arrayfields'=>$arrayfields);
719 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters);
720 print $hookmanager->resPrint;
722 if (!empty($arrayfields[
'm.datec'][
'checked'])) {
723 print
'<td class="liste_titre">';
727 if (!empty($arrayfields[
'm.tms'][
'checked'])) {
728 print
'<td class="liste_titre">';
732 print
'<td class="liste_titre maxwidthsearch">';
733 $searchpicto = $form->showFilterAndCheckAddButtons(0);
738 $totalarray = array();
739 $totalarray[
'nbfield'] = 0;
741 print
'<tr class="liste_titre">';
742 if (!empty($arrayfields[
'm.rowid'][
'checked'])) {
743 print_liste_field_titre($arrayfields[
'm.rowid'][
'label'], $_SERVER[
"PHP_SELF"],
'm.rowid',
'', $param,
'', $sortfield, $sortorder);
744 $totalarray[
'nbfield']++;
746 if (!empty($arrayfields[
'm.datem'][
'checked'])) {
747 print_liste_field_titre($arrayfields[
'm.datem'][
'label'], $_SERVER[
"PHP_SELF"],
'm.datem',
'', $param,
'', $sortfield, $sortorder);
748 $totalarray[
'nbfield']++;
750 if (!empty($arrayfields[
'p.ref'][
'checked'])) {
751 print_liste_field_titre($arrayfields[
'p.ref'][
'label'], $_SERVER[
"PHP_SELF"],
'p.ref',
'', $param,
'', $sortfield, $sortorder);
752 $totalarray[
'nbfield']++;
754 if (!empty($arrayfields[
'p.label'][
'checked'])) {
755 print_liste_field_titre($arrayfields[
'p.label'][
'label'], $_SERVER[
"PHP_SELF"],
'p.label',
'', $param,
'', $sortfield, $sortorder);
756 $totalarray[
'nbfield']++;
758 if (!empty($arrayfields[
'm.batch'][
'checked'])) {
759 print_liste_field_titre($arrayfields[
'm.batch'][
'label'], $_SERVER[
"PHP_SELF"],
'm.batch',
'', $param,
'', $sortfield, $sortorder,
'center ');
760 $totalarray[
'nbfield']++;
762 if (!empty($arrayfields[
'pl.eatby'][
'checked'])) {
763 print_liste_field_titre($arrayfields[
'pl.eatby'][
'label'], $_SERVER[
"PHP_SELF"],
'pl.eatby',
'', $param,
'', $sortfield, $sortorder,
'center ');
764 $totalarray[
'nbfield']++;
766 if (!empty($arrayfields[
'pl.sellby'][
'checked'])) {
767 print_liste_field_titre($arrayfields[
'pl.sellby'][
'label'], $_SERVER[
"PHP_SELF"],
'pl.sellby',
'', $param,
'', $sortfield, $sortorder,
'center ');
768 $totalarray[
'nbfield']++;
770 if (!empty($arrayfields[
'e.ref'][
'checked'])) {
772 print_liste_field_titre($arrayfields[
'e.ref'][
'label'], $_SERVER[
"PHP_SELF"],
"e.ref",
"", $param,
"", $sortfield, $sortorder);
773 $totalarray[
'nbfield']++;
775 if (!empty($arrayfields[
'm.fk_user_author'][
'checked'])) {
776 print_liste_field_titre($arrayfields[
'm.fk_user_author'][
'label'], $_SERVER[
"PHP_SELF"],
"m.fk_user_author",
"", $param,
"", $sortfield, $sortorder);
777 $totalarray[
'nbfield']++;
779 if (!empty($arrayfields[
'm.inventorycode'][
'checked'])) {
780 print_liste_field_titre($arrayfields[
'm.inventorycode'][
'label'], $_SERVER[
"PHP_SELF"],
"m.inventorycode",
"", $param,
"", $sortfield, $sortorder);
781 $totalarray[
'nbfield']++;
783 if (!empty($arrayfields[
'm.label'][
'checked'])) {
784 print_liste_field_titre($arrayfields[
'm.label'][
'label'], $_SERVER[
"PHP_SELF"],
"m.label",
"", $param,
"", $sortfield, $sortorder);
785 $totalarray[
'nbfield']++;
787 if (!empty($arrayfields[
'm.type_mouvement'][
'checked'])) {
788 print_liste_field_titre($arrayfields[
'm.type_mouvement'][
'label'], $_SERVER[
"PHP_SELF"],
"m.type_mouvement",
"", $param,
'', $sortfield, $sortorder,
'center ');
789 $totalarray[
'nbfield']++;
791 if (!empty($arrayfields[
'origin'][
'checked'])) {
792 print_liste_field_titre($arrayfields[
'origin'][
'label'], $_SERVER[
"PHP_SELF"],
"",
"", $param,
"", $sortfield, $sortorder);
793 $totalarray[
'nbfield']++;
795 if (!empty($arrayfields[
'm.fk_projet'][
'checked'])) {
796 print_liste_field_titre($arrayfields[
'm.fk_projet'][
'label'], $_SERVER[
"PHP_SELF"],
"m.fk_projet",
"", $param,
'', $sortfield, $sortorder);
797 $totalarray[
'nbfield']++;
799 if (!empty($arrayfields[
'm.value'][
'checked'])) {
800 print_liste_field_titre($arrayfields[
'm.value'][
'label'], $_SERVER[
"PHP_SELF"],
"m.value",
"", $param,
'', $sortfield, $sortorder,
'right ');
801 $totalarray[
'nbfield']++;
803 if (!empty($arrayfields[
'm.price'][
'checked'])) {
804 print_liste_field_titre($arrayfields[
'm.price'][
'label'], $_SERVER[
"PHP_SELF"],
"m.price",
"", $param,
'', $sortfield, $sortorder,
'right ');
805 $totalarray[
'nbfield']++;
809 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
812 $parameters = array(
'arrayfields' => $arrayfields,
'param' => $param,
'sortfield' => $sortfield,
'sortorder' => $sortorder);
813 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters);
814 print $hookmanager->resPrint;
815 if (!empty($arrayfields[
'm.datec'][
'checked'])) {
816 print_liste_field_titre($arrayfields[
'p.datec'][
'label'], $_SERVER[
"PHP_SELF"],
"p.datec",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
817 $totalarray[
'nbfield']++;
819 if (!empty($arrayfields[
'm.tms'][
'checked'])) {
820 print_liste_field_titre($arrayfields[
'p.tms'][
'label'], $_SERVER[
"PHP_SELF"],
"p.tms",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
821 $totalarray[
'nbfield']++;
823 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
824 $totalarray[
'nbfield']++;
828 $savnbfield = $totalarray[
'nbfield'];
829 $totalarray = array();
830 $totalarray[
'nbfield'] = 0;
831 $imaxinloop = ($limit ? min($num, $limit) : $num);
832 while ($i < $imaxinloop) {
833 $objp = $db->fetch_object($resql);
838 $sql =
"SELECT label";
839 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_lang";
840 $sql .=
" WHERE fk_product = ".((int) $objp->rowid);
841 $sql .=
" AND lang = '".$db->escape($langs->getDefaultLang()).
"'";
844 $result = $db->query($sql);
846 $objtp = $db->fetch_object($result);
847 if (!empty($objtp->label)) {
848 $objp->produit = $objtp->label;
853 $userstatic->id = $objp->fk_user_author;
854 $userstatic->login = $objp->login;
855 $userstatic->lastname = $objp->lastname;
856 $userstatic->firstname = $objp->firstname;
857 $userstatic->photo = $objp->photo;
859 $productstatic->id = $objp->rowid;
860 $productstatic->ref = $objp->product_ref;
861 $productstatic->label = $objp->produit;
862 $productstatic->type = $objp->type;
863 $productstatic->entity = $objp->entity;
864 $productstatic->status_batch = $objp->tobatch;
866 $productlot->id = $objp->lotid;
867 $productlot->batch = $objp->batch;
868 $productlot->eatby = $objp->eatby;
869 $productlot->sellby = $objp->sellby;
871 $warehousestatic->id = $objp->entrepot_id;
872 $warehousestatic->libelle = $objp->warehouse_ref;
873 $warehousestatic->label = $objp->warehouse_ref;
874 $warehousestatic->lieu = $objp->lieu;
876 if (!empty($objp->fk_origin)) {
877 $origin = $objectlist->get_origin($objp->fk_origin, $objp->origintype);
882 print
'<tr class="oddeven">';
884 if (!empty($arrayfields[
'm.rowid'][
'checked'])) {
886 print
'<td>'.dol_escape_htmltag($objp->mid).
'</td>';
888 if (!empty($arrayfields[
'm.datem'][
'checked'])) {
890 print
'<td>'.dol_print_date($db->jdate($objp->datem),
'dayhour').
'</td>';
892 if (!empty($arrayfields[
'p.ref'][
'checked'])) {
894 print
'<td class="nowraponall">';
895 print $productstatic->getNomUrl(1,
'stock', 16);
898 if (!empty($arrayfields[
'p.label'][
'checked'])) {
900 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($productstatic->label).
'">';
901 print $productstatic->label;
904 if (!empty($arrayfields[
'm.batch'][
'checked'])) {
905 print
'<td class="center nowraponall">';
906 if ($productlot->id > 0) {
907 print $productlot->getNomUrl(1);
913 if (!empty($arrayfields[
'pl.eatby'][
'checked'])) {
914 print
'<td class="center">'.dol_print_date($objp->eatby,
'day').
'</td>';
916 if (!empty($arrayfields[
'pl.sellby'][
'checked'])) {
917 print
'<td class="center">'.dol_print_date($objp->sellby,
'day').
'</td>';
920 if (!empty($arrayfields[
'e.ref'][
'checked'])) {
922 print $warehousestatic->getNomUrl(1);
926 if (!empty($arrayfields[
'm.fk_user_author'][
'checked'])) {
927 print
'<td class="tdoverflowmax100">';
928 print $userstatic->getNomUrl(-1);
932 if (!empty($arrayfields[
'm.inventorycode'][
'checked'])) {
933 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($objp->inventorycode).
'">';
940 if (!empty($arrayfields[
'm.label'][
'checked'])) {
941 print
'<td class="tdoverflowmax300" title="'.dol_escape_htmltag($objp->label).
'">'.
dol_escape_htmltag($objp->label).
'</td>';
944 if (!empty($arrayfields[
'm.type_mouvement'][
'checked'])) {
945 switch ($objp->type_mouvement) {
947 print
'<td class="center">'.$langs->trans(
'StockIncreaseAfterCorrectTransfer').
'</td>';
950 print
'<td class="center">'.$langs->trans(
'StockDecreaseAfterCorrectTransfer').
'</td>';
953 print
'<td class="center">'.$langs->trans(
'StockDecrease').
'</td>';
956 print
'<td class="center">'.$langs->trans(
'StockIncrease').
'</td>';
960 if (!empty($arrayfields[
'origin'][
'checked'])) {
962 print
'<td class="nowraponall">'.$origin.
'</td>';
964 if (!empty($arrayfields[
'm.fk_projet'][
'checked'])) {
967 if ($objp->fk_project != 0) {
968 print $movement->get_origin($objp->fk_project,
'project');
972 if (!empty($arrayfields[
'm.value'][
'checked'])) {
974 print
'<td class="right">';
976 print
'<span class="stockmovemententry">+'.$objp->qty.
'</span>';
978 print
'<span class="stockmovementexit">'.$objp->qty.
'<span>';
982 if (!empty($arrayfields[
'm.price'][
'checked'])) {
984 print
'<td class="right">';
985 if ($objp->price != 0) {
986 print
'<span class="opacitymedium">'.price($objp->price).
'</span>';
991 print
'<td class="nowrap center">';
992 if ($massactionbutton || $massaction) {
994 if (in_array($objp->rowid, $arrayofselected)) {
997 print
'<input id="cb'.$objp->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$objp->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
1001 $totalarray[
'nbfield']++;
1008 print
'<tr><td colspan="'.$savnbfield.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
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.
Class with list of lots and properties.
Class to manage projects.
Class to manage Dolibarr users.
dolSqlDateFilter($datefield, $day_date, $month_date, $year_date, $excludefirstand=0, $gm=false)
Generate a SQL string to make a filter into a range (for second of date until last second of date).
dol_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_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
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...
getDolGlobalInt($key, $default=0)
Return 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_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by second index function, which produces ascending (default) or descending output...
if(!function_exists( 'dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
img_edit($titlealt='default', $float=0, $other='')
Show logo editer/modifier fiche.
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...
moPrepareHead($object)
Prepare array of tabs for Mo.
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.