dolibarr  20.0.0-alpha
mo_movements.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2019 Laurent Destailleur <eldy@users.sourceforge.net>
3  * Copyright (C) 2022 Ferran Marcet <fmarcet@2byte.es>
4  * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <https://www.gnu.org/licenses/>.
18  */
19 
26 // Load Dolibarr environment
27 require '../main.inc.php';
28 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
29 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
30 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
31 require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
32 require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
33 require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php';
34 require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php';
35 require_once DOL_DOCUMENT_ROOT.'/product/stock/class/productlot.class.php';
36 
37 require_once DOL_DOCUMENT_ROOT.'/mrp/class/mo.class.php';
38 require_once DOL_DOCUMENT_ROOT.'/mrp/lib/mrp_mo.lib.php';
39 
40 // Load translation files required by the page
41 $langs->loadLangs(array("mrp", "stocks", "other"));
42 
43 // Get parameters
44 $id = GETPOSTINT('id');
45 $ref = GETPOST('ref', 'alpha');
46 $action = GETPOST('action', 'aZ09');
47 $confirm = GETPOST('confirm', 'alpha');
48 $cancel = GETPOST('cancel', 'aZ09');
49 $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'mostockmovement'; // To manage different context of search
50 $backtopage = GETPOST('backtopage', 'alpha');
51 $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
52 $massaction = GETPOST('massaction', 'aZ09');
53 $lineid = GETPOSTINT('lineid');
54 
55 $msid = GETPOSTINT('msid');
56 $year = GETPOSTINT("year");
57 $month = GETPOSTINT("month");
58 
59 $search_ref = GETPOST('search_ref', 'alpha');
60 $search_movement = GETPOST("search_movement", 'alpha');
61 $search_product_ref = trim(GETPOST("search_product_ref", 'alpha'));
62 $search_product = trim(GETPOST("search_product", 'alpha'));
63 $search_warehouse = trim(GETPOST("search_warehouse", 'alpha'));
64 $search_inventorycode = trim(GETPOST("search_inventorycode", 'alpha'));
65 $search_user = trim(GETPOST("search_user", 'alpha'));
66 $search_batch = trim(GETPOST("search_batch", 'alpha'));
67 $search_qty = trim(GETPOST("search_qty", 'alpha'));
68 $search_type_mouvement = GETPOST('search_type_mouvement', "intcomma");
69 
70 $limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
71 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOSTINT("page");
72 $sortfield = GETPOST('sortfield', 'aZ09comma');
73 $sortorder = GETPOST('sortorder', 'aZ09comma');
74 if (empty($page) || $page == -1) {
75  $page = 0;
76 } // If $page is not defined, or '' or -1
77 $offset = $limit * $page;
78 if (!$sortfield) {
79  $sortfield = "m.datem";
80 }
81 if (!$sortorder) {
82  $sortorder = "DESC";
83 }
84 
85 // Initialize technical objects
86 $object = new Mo($db);
87 $extrafields = new ExtraFields($db);
88 $diroutputmassaction = $conf->mrp->dir_output.'/temp/massgeneration/'.$user->id;
89 $hookmanager->initHooks(array('mocard', 'globalcard')); // Note that conf->hooks_modules contains array
90 
91 // Fetch optionals attributes and labels
92 $extrafields->fetch_name_optionals_label($object->table_element);
93 
94 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
95 
96 // Initialize array of search criteria
97 $search_all = trim(GETPOST("search_all", 'alpha'));
98 $search = array();
99 foreach ($object->fields as $key => $val) {
100  if (GETPOST('search_'.$key, 'alpha')) {
101  $search[$key] = GETPOST('search_'.$key, 'alpha');
102  }
103 }
104 
105 if (empty($action) && empty($id) && empty($ref)) {
106  $action = 'view';
107 }
108 
109 // Load object
110 include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once.
111 
112 // Security check - Protection if external user
113 //if ($user->socid > 0) accessforbidden();
114 //if ($user->socid > 0) $socid = $user->socid;
115 $isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
116 $result = restrictedArea($user, 'mrp', $object->id, 'mrp_mo', '', 'fk_soc', 'rowid', $isdraft);
117 
118 $objectlist = new MouvementStock($db);
119 
120 // Definition of fields for list
121 $arrayfields = array(
122  'm.rowid' => array('label' => "Ref", 'checked' => 1, 'position' => 1),
123  'm.datem' => array('label' => "Date", 'checked' => 1, 'position' => 2),
124  'p.ref' => array('label' => "ProductRef", 'checked' => 1, 'css' => 'maxwidth100', 'position' => 3),
125  'p.label' => array('label' => "ProductLabel", 'checked' => 0, 'position' => 5),
126  'm.batch' => array('label' => "BatchNumberShort", 'checked' => 1, 'position' => 8, 'enabled' => (isModEnabled('productbatch'))),
127  'pl.eatby' => array('label' => "EatByDate", 'checked' => 0, 'position' => 9, 'enabled' => (isModEnabled('productbatch'))),
128  'pl.sellby' => array('label' => "SellByDate", 'checked' => 0, 'position' => 10, 'enabled' => (isModEnabled('productbatch'))),
129  'e.ref' => array('label' => "Warehouse", 'checked' => 1, 'position' => 100, 'enabled' => (!($id > 0))), // If we are on specific warehouse, we hide it
130  'm.fk_user_author' => array('label' => "Author", 'checked' => 0, 'position' => 120),
131  'm.inventorycode' => array('label' => "InventoryCodeShort", 'checked' => 1, 'position' => 130),
132  'm.label' => array('label' => "MovementLabel", 'checked' => 1, 'position' => 140),
133  'm.type_mouvement' => array('label' => "TypeMovement", 'checked' => 0, 'position' => 150),
134  'origin' => array('label' => "Origin", 'checked' => 1, 'position' => 155),
135  'm.fk_projet' => array('label' => 'Project', 'checked' => 0, 'position' => 180),
136  'm.value' => array('label' => "Qty", 'checked' => 1, 'position' => 200),
137  'm.price' => array('label' => "UnitPurchaseValue", 'checked' => 0, 'position' => 210)
138  //'m.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500),
139  //'m.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500)
140 );
141 if (getDolGlobalString('PRODUCT_DISABLE_SELLBY')) {
142  unset($arrayfields['pl.sellby']);
143 }
144 if (getDolGlobalString('PRODUCT_DISABLE_EATBY')) {
145  unset($arrayfields['pl.eatby']);
146 }
147 $objectlist->fields = dol_sort_array($objectlist->fields, 'position');
148 $arrayfields = dol_sort_array($arrayfields, 'position');
149 
150 // Permissions
151 $permissionnote = $user->hasRight('mrp', 'write'); // Used by the include of actions_setnotes.inc.php
152 $permissiondellink = $user->hasRight('mrp', 'write'); // Used by the include of actions_dellink.inc.php
153 $permissiontoadd = $user->hasRight('mrp', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
154 $permissiontodelete = $user->rights->mrp->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
155 $upload_dir = $conf->mrp->multidir_output[isset($object->entity) ? $object->entity : 1];
156 
157 $permissiontoproduce = $permissiontoadd;
158 $permissiontoupdatecost = $user->hasRight('bom', 'write'); // User who can define cost must have knowledge of pricing
159 
160 if ($permissiontoupdatecost) {
161  $arrayfields['m.price']['enabled'] = 1;
162 }
163 
164 $arrayofselected = array();
165 
166 
167 /*
168  * Actions
169  */
170 
171 if (GETPOST('cancel', 'alpha')) {
172  $action = 'list';
173  $massaction = '';
174 }
175 if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
176  $massaction = '';
177 }
178 
179 $parameters = array();
180 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
181 if ($reshook < 0) {
182  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
183 }
184 
185 include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
186 
187 // Do we click on purge search criteria ?
188 if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // Both test are required to be compatible with all browsers
189  $year = '';
190  $month = '';
191  $search_ref = '';
192  $search_movement = "";
193  $search_type_mouvement = "";
194  $search_inventorycode = "";
195  $search_product_ref = "";
196  $search_product = "";
197  $search_warehouse = "";
198  $search_user = "";
199  $search_batch = "";
200  $search_qty = '';
201  $sall = "";
202  $toselect = array();
203  $search_array_options = array();
204 }
205 
206 if (empty($reshook)) {
207  $error = 0;
208 
209  $backurlforlist = dol_buildpath('/mrp/mo_list.php', 1);
210 
211  if (empty($backtopage) || ($cancel && empty($id))) {
212  //var_dump($backurlforlist);exit;
213  if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) {
214  $backtopage = $backurlforlist;
215  } else {
216  $backtopage = DOL_URL_ROOT.'/mrp/mo_production.php?id='.($id > 0 ? $id : '__ID__');
217  }
218  }
219  $triggermodname = 'MO_MODIFY'; // Name of trigger action code to execute when we modify record
220 
221  // Actions cancel, add, update, delete or clone
222  include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php';
223 
224  // Actions when linking object each other
225  include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php';
226 
227  // Actions when printing a doc from card
228  include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
229 
230  // Actions to send emails
231  $triggersendname = 'MO_SENTBYMAIL';
232  $autocopy = 'MAIN_MAIL_AUTOCOPY_MO_TO';
233  $trackid = 'mo'.$object->id;
234  include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
235 
236  // Action to move up and down lines of object
237  //include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once
238 
239  if ($action == 'set_thirdparty' && $permissiontoadd) {
240  $object->setValueFrom('fk_soc', GETPOSTINT('fk_soc'), '', '', 'date', '', $user, $triggermodname);
241  }
242  if ($action == 'classin' && $permissiontoadd) {
243  $object->setProject(GETPOSTINT('projectid'));
244  }
245 
246  if ($action == 'confirm_reopen') {
247  $result = $object->setStatut($object::STATUS_INPROGRESS, 0, '', 'MRP_REOPEN');
248  }
249 }
250 
251 
252 
253 /*
254  * View
255  */
256 
257 $form = new Form($db);
258 $formproject = new FormProjets($db);
259 $formproduct = new FormProduct($db);
260 $productstatic = new Product($db);
261 $productlot = new Productlot($db);
262 $warehousestatic = new Entrepot($db);
263 $userstatic = new User($db);
264 
265 $help_url = 'EN:Module_Manufacturing_Orders|FR:Module_Ordres_de_Fabrication|DE:Modul_Fertigungsauftrag';
266 
267 llxHeader('', $langs->trans('Mo'), $help_url);
268 
269 // Part to show record
270 if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) {
271  $res = $object->fetch_thirdparty();
272  $res = $object->fetch_optionals();
273 
274  $head = moPrepareHead($object);
275 
276  print dol_get_fiche_head($head, 'stockmovement', $langs->trans("ManufacturingOrder"), -1, $object->picto);
277 
278  $formconfirm = '';
279 
280  // Confirmation to delete
281  if ($action == 'delete') {
282  $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteMo'), $langs->trans('ConfirmDeleteMo'), 'confirm_delete', '', 0, 1);
283  }
284  // Confirmation to delete line
285  if ($action == 'deleteline') {
286  $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1);
287  }
288  // Clone confirmation
289  if ($action == 'clone') {
290  // Create an array for form
291  $formquestion = array();
292  $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneMo', $object->ref), 'confirm_clone', $formquestion, 'yes', 1);
293  }
294 
295  // Confirmation of action xxxx
296  if ($action == 'xxx') {
297  $formquestion = array();
298  /*
299  $forcecombo=0;
300  if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy
301  $formquestion = array(
302  // 'text' => $langs->trans("ConfirmClone"),
303  // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1),
304  // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1),
305  // array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockDecrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo))
306  );
307  */
308  $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('XXX'), $text, 'confirm_xxx', $formquestion, 0, 1, 220);
309  }
310 
311  // Call Hook formConfirm
312  $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid);
313  $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
314  if (empty($reshook)) {
315  $formconfirm .= $hookmanager->resPrint;
316  } elseif ($reshook > 0) {
317  $formconfirm = $hookmanager->resPrint;
318  }
319 
320  // Print form confirm
321  print $formconfirm;
322 
323 
324  // Object card
325  // ------------------------------------------------------------
326  $linkback = '<a href="'.dol_buildpath('/mrp/mo_list.php', 1).'?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
327 
328  $morehtmlref = '<div class="refidno">';
329  /*
330  // Ref bis
331  $morehtmlref.=$form->editfieldkey("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->mrp->creer, 'string', '', 0, 1);
332  $morehtmlref.=$form->editfieldval("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->mrp->creer, 'string', '', null, null, '', 1);*/
333  // Thirdparty
334  if (is_object($object->thirdparty)) {
335  $morehtmlref .= $object->thirdparty->getNomUrl(1, 'customer');
336  if (!getDolGlobalString('MAIN_DISABLE_OTHER_LINK') && $object->thirdparty->id > 0) {
337  $morehtmlref .= ' (<a href="'.DOL_URL_ROOT.'/commande/list.php?socid='.$object->thirdparty->id.'&search_societe='.urlencode($object->thirdparty->name).'">'.$langs->trans("OtherOrders").'</a>)';
338  }
339  }
340  // Project
341  if (isModEnabled('project')) {
342  $langs->load("projects");
343  if (is_object($object->thirdparty)) {
344  $morehtmlref .= '<br>';
345  }
346  if ($permissiontoadd) {
347  $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"');
348  if ($action != 'classify') {
349  $morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> ';
350  }
351  $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300');
352  } else {
353  if (!empty($object->fk_project)) {
354  $proj = new Project($db);
355  $proj->fetch($object->fk_project);
356  $morehtmlref .= $proj->getNomUrl(1);
357  if ($proj->title) {
358  $morehtmlref .= '<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).'</span>';
359  }
360  }
361  }
362  }
363  $morehtmlref .= '</div>';
364 
365 
366  dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
367 
368 
369  print '<div class="fichecenter">';
370  print '<div class="fichehalfleft">';
371  print '<div class="underbanner clearboth"></div>';
372  print '<table class="border centpercent tableforfield">'."\n";
373 
374  // Common attributes
375  $keyforbreak = 'fk_warehouse';
376  unset($object->fields['fk_project']);
377  unset($object->fields['fk_soc']);
378  include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php';
379 
380  // Other attributes
381  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
382 
383  print '</table>';
384  print '</div>';
385  print '</div>';
386 
387  print '<div class="clearboth"></div>';
388 
389  print dol_get_fiche_end();
390 
391  /*
392  print '<div class="tabsAction">';
393 
394  $parameters = array();
395  // Note that $action and $object may be modified by hook
396  $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action);
397  if (empty($reshook)) {
398  // Cancel - Reopen
399  if ($permissiontoadd)
400  {
401  if ($object->status == $object::STATUS_VALIDATED || $object->status == $object::STATUS_INPROGRESS)
402  {
403  print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=confirm_close&confirm=yes">'.$langs->trans("Cancel").'</a>'."\n";
404  }
405 
406  if ($object->status == $object::STATUS_CANCELED)
407  {
408  print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=confirm_reopen&confirm=yes">'.$langs->trans("Re-Open").'</a>'."\n";
409  }
410 
411  if ($object->status == $object::STATUS_PRODUCED) {
412  if ($permissiontoproduce) {
413  print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=confirm_reopen">'.$langs->trans('ReOpen').'</a>';
414  } else {
415  print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans('ReOpen').'</a>';
416  }
417  }
418  }
419  }
420 
421  print '</div>';
422  */
423 
424 
425  $sql = "SELECT p.rowid, p.ref as product_ref, p.label as produit, p.tobatch, p.fk_product_type as type, p.entity,";
426  $sql .= " e.ref as warehouse_ref, e.rowid as entrepot_id, e.lieu,";
427  $sql .= " m.rowid as mid, m.value as qty, m.datem, m.fk_user_author, m.label, m.inventorycode, m.fk_origin, m.origintype,";
428  $sql .= " m.batch, m.price,";
429  $sql .= " m.type_mouvement,";
430  $sql .= " pl.rowid as lotid, pl.eatby, pl.sellby,";
431  $sql .= " u.login, u.photo, u.lastname, u.firstname";
432  // Add fields from extrafields
433  if (!empty($extrafields->attributes[$objectlist->table_element]['label'])) {
434  foreach ($extrafields->attributes[$objectlist->table_element]['label'] as $key => $val) {
435  $sql .= ($extrafields->attributes[$objectlist->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
436  }
437  }
438  // Add fields from hooks
439  $parameters = array();
440  $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $objectlist may have been modified by hook
441  $sql .= $hookmanager->resPrint;
442  $sql .= " FROM ".MAIN_DB_PREFIX."entrepot as e,";
443  $sql .= " ".MAIN_DB_PREFIX."product as p,";
444  $sql .= " ".MAIN_DB_PREFIX."stock_mouvement as m";
445  if (!empty($extrafields->attributes[$objectlist->table_element]) && is_array($extrafields->attributes[$objectlist->table_element]['label']) && count($extrafields->attributes[$objectlist->table_element]['label'])) {
446  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$objectlist->table_element."_extrafields as ef on (m.rowid = ef.fk_object)";
447  }
448  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON m.fk_user_author = u.rowid";
449  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_lot as pl ON m.batch = pl.batch AND m.fk_product = pl.fk_product";
450  $sql .= " WHERE m.fk_product = p.rowid";
451  $sql .= " AND m.origintype = 'mo' AND m.fk_origin = ".(int) $object->id;
452  if ($msid > 0) {
453  $sql .= " AND m.rowid = ".((int) $msid);
454  }
455  $sql .= " AND m.fk_entrepot = e.rowid";
456  $sql .= " AND e.entity IN (".getEntity('stock').")";
457  if (!getDolGlobalString('STOCK_SUPPORTS_SERVICES')) {
458  $sql .= " AND p.fk_product_type = 0";
459  }
460  $sql .= dolSqlDateFilter('m.datem', 0, $month, $year);
461  if (!empty($search_ref)) {
462  $sql .= natural_search('m.rowid', $search_ref, 1);
463  }
464  if (!empty($search_movement)) {
465  $sql .= natural_search('m.label', $search_movement);
466  }
467  if (!empty($search_inventorycode)) {
468  $sql .= natural_search('m.inventorycode', $search_inventorycode);
469  }
470  if (!empty($search_product_ref)) {
471  $sql .= natural_search('p.ref', $search_product_ref);
472  }
473  if (!empty($search_product)) {
474  $sql .= natural_search('p.label', $search_product);
475  }
476  if ($search_warehouse != '' && $search_warehouse != '-1') {
477  $sql .= natural_search('e.rowid', $search_warehouse, 2);
478  }
479  if (!empty($search_user)) {
480  $sql .= natural_search(array('u.lastname', 'u.firstname', 'u.login'), $search_user);
481  }
482  if (!empty($search_batch)) {
483  $sql .= natural_search('m.batch', $search_batch);
484  }
485  if ($search_qty != '') {
486  $sql .= natural_search('m.value', $search_qty, 1);
487  }
488  if ($search_type_mouvement != '' && $search_type_mouvement != '-1') {
489  $sql .= natural_search('m.type_mouvement', $search_type_mouvement, 2);
490  }
491  // Add where from extra fields
492  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
493  // Add where from hooks
494  $parameters = array();
495  $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $objectlist may have been modified by hook
496  $sql .= $hookmanager->resPrint;
497  $sql .= $db->order($sortfield, $sortorder);
498 
499  $nbtotalofrecords = '';
500  if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
501  $result = $db->query($sql);
502  $nbtotalofrecords = $db->num_rows($result);
503  if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
504  $page = 0;
505  $offset = 0;
506  }
507  }
508  $sql .= $db->plimit($limit + 1, $offset);
509 
510  $resql = $db->query($sql);
511  if (!$resql) {
512  dol_print_error($db);
513  }
514  $num = $db->num_rows($resql);
515 
516  $param = '';
517  if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
518  $param .= '&contextpage='.urlencode($contextpage);
519  }
520  if ($limit > 0 && $limit != $conf->liste_limit) {
521  $param .= '&limit='.((int) $limit);
522  }
523  if ($id > 0) {
524  $param .= '&id='.urlencode((string) ($id));
525  }
526  if ($search_movement) {
527  $param .= '&search_movement='.urlencode($search_movement);
528  }
529  if ($search_inventorycode) {
530  $param .= '&search_inventorycode='.urlencode($search_inventorycode);
531  }
532  if ($search_type_mouvement) {
533  $param .= '&search_type_mouvement='.urlencode($search_type_mouvement);
534  }
535  if ($search_product_ref) {
536  $param .= '&search_product_ref='.urlencode($search_product_ref);
537  }
538  if ($search_product) {
539  $param .= '&search_product='.urlencode($search_product);
540  }
541  if ($search_batch) {
542  $param .= '&search_batch='.urlencode($search_batch);
543  }
544  if ($search_warehouse > 0) {
545  $param .= '&search_warehouse='.urlencode($search_warehouse);
546  }
547  if ($search_user) {
548  $param .= '&search_user='.urlencode($search_user);
549  }
550 
551  // Add $param from extra fields
552  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
553 
554  // List of mass actions available
555  $arrayofmassactions = array(
556  // 'presend'=>$langs->trans("SendByMail"),
557  // 'builddoc'=>$langs->trans("PDFMerge"),
558  );
559  //if ($user->rights->stock->supprimer) $arrayofmassactions['predelete']='<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
560  if (in_array($massaction, array('presend', 'predelete'))) {
561  $arrayofmassactions = array();
562  }
563  $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
564 
565  print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
566  if ($optioncss != '') {
567  print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
568  }
569  print '<input type="hidden" name="token" value="'.newToken().'">';
570  print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
571  print '<input type="hidden" name="action" value="list">';
572  print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
573  print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
574  print '<input type="hidden" name="page" value="'.$page.'">';
575  print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
576  if ($id > 0) {
577  print '<input type="hidden" name="id" value="'.$id.'">';
578  }
579 
580  if ($id > 0) {
581  print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, '', 0, '', '', $limit);
582  } else {
583  print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'generic', 0, '', '', $limit);
584  }
585 
586  $moreforfilter = '';
587 
588  $parameters = array();
589  $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
590  if (empty($reshook)) {
591  $moreforfilter .= $hookmanager->resPrint;
592  } else {
593  $moreforfilter = $hookmanager->resPrint;
594  }
595 
596  if (!empty($moreforfilter)) {
597  print '<div class="liste_titre liste_titre_bydiv centpercent">';
598  print $moreforfilter;
599  print '</div>';
600  }
601 
602  $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
603  $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')); // This also change content of $arrayfields
604  $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
605 
606  print '<div class="div-table-responsive">';
607  print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
608 
609  // Fields title search
610  print '<tr class="liste_titre_filter">';
611  // Actions
612  if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
613  print '<td class="liste_titre maxwidthsearch">';
614  $searchpicto = $form->showFilterAndCheckAddButtons(0);
615  print $searchpicto;
616  print '</td>';
617  }
618  if (!empty($arrayfields['m.rowid']['checked'])) {
619  // Ref
620  print '<td class="liste_titre left">';
621  print '<input class="flat maxwidth25" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
622  print '</td>';
623  }
624  if (!empty($arrayfields['m.datem']['checked'])) {
625  print '<td class="liste_titre nowraponall">';
626  print '<input class="flat" type="text" size="2" maxlength="2" placeholder="'.dol_escape_htmltag($langs->trans("Month")).'" name="month" value="'.$month.'">';
627  if (!isModEnabled('productbatch')) {
628  print '&nbsp;';
629  }
630  //else print '<br>';
631  $syear = $year ? $year : -1;
632  print '<input class="flat maxwidth50" type="text" maxlength="4" placeholder="'.dol_escape_htmltag($langs->trans("Year")).'" name="year" value="'.($syear > 0 ? $syear : '').'">';
633  //print $formother->selectyear($syear,'year',1, 20, 5);
634  print '</td>';
635  }
636  if (!empty($arrayfields['p.ref']['checked'])) {
637  // Product Ref
638  print '<td class="liste_titre left">';
639  print '<input class="flat maxwidth75" type="text" name="search_product_ref" value="'.dol_escape_htmltag($search_product_ref).'">';
640  print '</td>';
641  }
642  if (!empty($arrayfields['p.label']['checked'])) {
643  // Product label
644  print '<td class="liste_titre left">';
645  print '<input class="flat maxwidth100" type="text" name="search_product" value="'.dol_escape_htmltag($search_product).'">';
646  print '</td>';
647  }
648  // Batch
649  if (!empty($arrayfields['m.batch']['checked'])) {
650  print '<td class="liste_titre center"><input class="flat maxwidth75" type="text" name="search_batch" value="'.dol_escape_htmltag($search_batch).'"></td>';
651  }
652  if (!empty($arrayfields['pl.eatby']['checked'])) {
653  print '<td class="liste_titre left">';
654  print '</td>';
655  }
656  if (!empty($arrayfields['pl.sellby']['checked'])) {
657  print '<td class="liste_titre left">';
658  print '</td>';
659  }
660  // Warehouse
661  if (!empty($arrayfields['e.ref']['checked'])) {
662  print '<td class="liste_titre maxwidthonsmartphone left">';
663  //print '<input class="flat" type="text" size="8" name="search_warehouse" value="'.($search_warehouse).'">';
664  print $formproduct->selectWarehouses($search_warehouse, 'search_warehouse', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, null, 'maxwidth200');
665  print '</td>';
666  }
667  if (!empty($arrayfields['m.fk_user_author']['checked'])) {
668  // Author
669  print '<td class="liste_titre left">';
670  print '<input class="flat" type="text" size="6" name="search_user" value="'.dol_escape_htmltag($search_user).'">';
671  print '</td>';
672  }
673  if (!empty($arrayfields['m.inventorycode']['checked'])) {
674  // Inventory code
675  print '<td class="liste_titre left">';
676  print '<input class="flat" type="text" size="4" name="search_inventorycode" value="'.dol_escape_htmltag($search_inventorycode).'">';
677  print '</td>';
678  }
679  if (!empty($arrayfields['m.label']['checked'])) {
680  // Label of movement
681  print '<td class="liste_titre left">';
682  print '<input class="flat" type="text" size="8" name="search_movement" value="'.dol_escape_htmltag($search_movement).'">';
683  print '</td>';
684  }
685  if (!empty($arrayfields['m.type_mouvement']['checked'])) {
686  // Type of movement
687  print '<td class="liste_titre center">';
688  //print '<input class="flat" type="text" size="3" name="search_type_mouvement" value="'.dol_escape_htmltag($search_type_mouvement).'">';
689  print '<select id="search_type_mouvement" name="search_type_mouvement" class="maxwidth150">';
690  print '<option value="" '.(($search_type_mouvement == "") ? 'selected="selected"' : '').'>&nbsp;</option>';
691  print '<option value="0" '.(($search_type_mouvement == "0") ? 'selected="selected"' : '').'>'.$langs->trans('StockIncreaseAfterCorrectTransfer').'</option>';
692  print '<option value="1" '.(($search_type_mouvement == "1") ? 'selected="selected"' : '').'>'.$langs->trans('StockDecreaseAfterCorrectTransfer').'</option>';
693  print '<option value="2" '.(($search_type_mouvement == "2") ? 'selected="selected"' : '').'>'.$langs->trans('StockDecrease').'</option>';
694  print '<option value="3" '.(($search_type_mouvement == "3") ? 'selected="selected"' : '').'>'.$langs->trans('StockIncrease').'</option>';
695  print '</select>';
696  print ajax_combobox('search_type_mouvement');
697  // TODO: add new function $formentrepot->selectTypeOfMovement(...) like
698  // print $formproduct->selectWarehouses($search_warehouse, 'search_warehouse', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, null, 'maxwidth200');
699  print '</td>';
700  }
701  if (!empty($arrayfields['origin']['checked'])) {
702  // Origin of movement
703  print '<td class="liste_titre left">';
704  print '&nbsp; ';
705  print '</td>';
706  }
707  if (!empty($arrayfields['m.fk_projet']['checked'])) {
708  // fk_project
709  print '<td class="liste_titre" align="left">';
710  print '&nbsp; ';
711  print '</td>';
712  }
713  if (!empty($arrayfields['m.value']['checked'])) {
714  // Qty
715  print '<td class="liste_titre right">';
716  print '<input class="flat" type="text" size="4" name="search_qty" value="'.dol_escape_htmltag($search_qty).'">';
717  print '</td>';
718  }
719  if (!empty($arrayfields['m.price']['checked'])) {
720  // Price
721  print '<td class="liste_titre left">';
722  print '&nbsp; ';
723  print '</td>';
724  }
725 
726 
727  // Extra fields
728  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
729 
730  // Fields from hook
731  $parameters = array('arrayfields' => $arrayfields);
732  $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
733  print $hookmanager->resPrint;
734  // Date creation
735  if (!empty($arrayfields['m.datec']['checked'])) {
736  print '<td class="liste_titre">';
737  print '</td>';
738  }
739  // Date modification
740  if (!empty($arrayfields['m.tms']['checked'])) {
741  print '<td class="liste_titre">';
742  print '</td>';
743  }
744  // Actions
745  if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
746  print '<td class="liste_titre maxwidthsearch">';
747  $searchpicto = $form->showFilterAndCheckAddButtons(0);
748  print $searchpicto;
749  print '</td>';
750  }
751  print "</tr>\n";
752 
753  $totalarray = array();
754  $totalarray['nbfield'] = 0;
755 
756  print '<tr class="liste_titre">';
757  // Action column
758  if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
759  print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
760  $totalarray['nbfield']++;
761  }
762  if (!empty($arrayfields['m.rowid']['checked'])) {
763  print_liste_field_titre($arrayfields['m.rowid']['label'], $_SERVER["PHP_SELF"], 'm.rowid', '', $param, '', $sortfield, $sortorder);
764  $totalarray['nbfield']++;
765  }
766  if (!empty($arrayfields['m.datem']['checked'])) {
767  print_liste_field_titre($arrayfields['m.datem']['label'], $_SERVER["PHP_SELF"], 'm.datem', '', $param, '', $sortfield, $sortorder);
768  $totalarray['nbfield']++;
769  }
770  if (!empty($arrayfields['p.ref']['checked'])) {
771  print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], 'p.ref', '', $param, '', $sortfield, $sortorder);
772  $totalarray['nbfield']++;
773  }
774  if (!empty($arrayfields['p.label']['checked'])) {
775  print_liste_field_titre($arrayfields['p.label']['label'], $_SERVER["PHP_SELF"], 'p.label', '', $param, '', $sortfield, $sortorder);
776  $totalarray['nbfield']++;
777  }
778  if (!empty($arrayfields['m.batch']['checked'])) {
779  print_liste_field_titre($arrayfields['m.batch']['label'], $_SERVER["PHP_SELF"], 'm.batch', '', $param, '', $sortfield, $sortorder, 'center ');
780  $totalarray['nbfield']++;
781  }
782  if (!empty($arrayfields['pl.eatby']['checked'])) {
783  print_liste_field_titre($arrayfields['pl.eatby']['label'], $_SERVER["PHP_SELF"], 'pl.eatby', '', $param, '', $sortfield, $sortorder, 'center ');
784  $totalarray['nbfield']++;
785  }
786  if (!empty($arrayfields['pl.sellby']['checked'])) {
787  print_liste_field_titre($arrayfields['pl.sellby']['label'], $_SERVER["PHP_SELF"], 'pl.sellby', '', $param, '', $sortfield, $sortorder, 'center ');
788  $totalarray['nbfield']++;
789  }
790  if (!empty($arrayfields['e.ref']['checked'])) {
791  // We are on a specific warehouse card, no filter on other should be possible
792  print_liste_field_titre($arrayfields['e.ref']['label'], $_SERVER["PHP_SELF"], "e.ref", "", $param, "", $sortfield, $sortorder);
793  $totalarray['nbfield']++;
794  }
795  if (!empty($arrayfields['m.fk_user_author']['checked'])) {
796  print_liste_field_titre($arrayfields['m.fk_user_author']['label'], $_SERVER["PHP_SELF"], "m.fk_user_author", "", $param, "", $sortfield, $sortorder);
797  $totalarray['nbfield']++;
798  }
799  if (!empty($arrayfields['m.inventorycode']['checked'])) {
800  print_liste_field_titre($arrayfields['m.inventorycode']['label'], $_SERVER["PHP_SELF"], "m.inventorycode", "", $param, "", $sortfield, $sortorder);
801  $totalarray['nbfield']++;
802  }
803  if (!empty($arrayfields['m.label']['checked'])) {
804  print_liste_field_titre($arrayfields['m.label']['label'], $_SERVER["PHP_SELF"], "m.label", "", $param, "", $sortfield, $sortorder);
805  $totalarray['nbfield']++;
806  }
807  if (!empty($arrayfields['m.type_mouvement']['checked'])) {
808  print_liste_field_titre($arrayfields['m.type_mouvement']['label'], $_SERVER["PHP_SELF"], "m.type_mouvement", "", $param, '', $sortfield, $sortorder, 'center ');
809  $totalarray['nbfield']++;
810  }
811  if (!empty($arrayfields['origin']['checked'])) {
812  print_liste_field_titre($arrayfields['origin']['label'], $_SERVER["PHP_SELF"], "", "", $param, "", $sortfield, $sortorder);
813  $totalarray['nbfield']++;
814  }
815  if (!empty($arrayfields['m.fk_projet']['checked'])) {
816  print_liste_field_titre($arrayfields['m.fk_projet']['label'], $_SERVER["PHP_SELF"], "m.fk_projet", "", $param, '', $sortfield, $sortorder);
817  $totalarray['nbfield']++;
818  }
819  if (!empty($arrayfields['m.value']['checked'])) {
820  print_liste_field_titre($arrayfields['m.value']['label'], $_SERVER["PHP_SELF"], "m.value", "", $param, '', $sortfield, $sortorder, 'right ');
821  $totalarray['nbfield']++;
822  }
823  if (!empty($arrayfields['m.price']['checked'])) {
824  print_liste_field_titre($arrayfields['m.price']['label'], $_SERVER["PHP_SELF"], "m.price", "", $param, '', $sortfield, $sortorder, 'right ');
825  $totalarray['nbfield']++;
826  }
827 
828  // Extra fields
829  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
830 
831  // Hook fields
832  $parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder);
833  $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
834  print $hookmanager->resPrint;
835  if (!empty($arrayfields['m.datec']['checked'])) {
836  print_liste_field_titre($arrayfields['p.datec']['label'], $_SERVER["PHP_SELF"], "p.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
837  $totalarray['nbfield']++;
838  }
839  if (!empty($arrayfields['m.tms']['checked'])) {
840  print_liste_field_titre($arrayfields['p.tms']['label'], $_SERVER["PHP_SELF"], "p.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
841  $totalarray['nbfield']++;
842  }
843  // Action column
844  if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
845  print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
846  $totalarray['nbfield']++;
847  }
848  print "</tr>\n";
849 
850  $i = 0;
851  $savnbfield = $totalarray['nbfield'];
852  $totalarray = array();
853  $totalarray['nbfield'] = 0;
854  $imaxinloop = ($limit ? min($num, $limit) : $num);
855  while ($i < $imaxinloop) {
856  $objp = $db->fetch_object($resql);
857 
858  // Multilangs
859  if (getDolGlobalInt('MAIN_MULTILANGS')) { // If multilang is enabled
860  // TODO Use a cache here
861  $sql = "SELECT label";
862  $sql .= " FROM ".MAIN_DB_PREFIX."product_lang";
863  $sql .= " WHERE fk_product = ".((int) $objp->rowid);
864  $sql .= " AND lang = '".$db->escape($langs->getDefaultLang())."'";
865  $sql .= " LIMIT 1";
866 
867  $result = $db->query($sql);
868  if ($result) {
869  $objtp = $db->fetch_object($result);
870  if (!empty($objtp->label)) {
871  $objp->produit = $objtp->label;
872  }
873  }
874  }
875 
876  $userstatic->id = $objp->fk_user_author;
877  $userstatic->login = $objp->login;
878  $userstatic->lastname = $objp->lastname;
879  $userstatic->firstname = $objp->firstname;
880  $userstatic->photo = $objp->photo;
881 
882  $productstatic->id = $objp->rowid;
883  $productstatic->ref = $objp->product_ref;
884  $productstatic->label = $objp->produit;
885  $productstatic->type = $objp->type;
886  $productstatic->entity = $objp->entity;
887  $productstatic->status_batch = $objp->tobatch;
888 
889  $productlot->id = $objp->lotid;
890  $productlot->batch = $objp->batch;
891  $productlot->eatby = $objp->eatby;
892  $productlot->sellby = $objp->sellby;
893 
894  $warehousestatic->id = $objp->entrepot_id;
895  $warehousestatic->libelle = $objp->warehouse_ref; // deprecated
896  $warehousestatic->label = $objp->warehouse_ref;
897  $warehousestatic->lieu = $objp->lieu;
898 
899  if (!empty($objp->fk_origin)) {
900  $origin = $objectlist->get_origin($objp->fk_origin, $objp->origintype);
901  } else {
902  $origin = '';
903  }
904 
905  print '<tr class="oddeven">';
906  // Action column
907  if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
908  print '<td class="nowrap center">';
909  if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
910  $selected = 0;
911  if (in_array($objp->rowid, $arrayofselected)) {
912  $selected = 1;
913  }
914  print '<input id="cb'.$objp->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$objp->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
915  }
916  print '</td>';
917  if (!$i) {
918  $totalarray['nbfield']++;
919  }
920  }
921  // Id movement
922  if (!empty($arrayfields['m.rowid']['checked'])) {
923  // This is primary not movement id
924  print '<td>'.dol_escape_htmltag($objp->mid).'</td>';
925  }
926  if (!empty($arrayfields['m.datem']['checked'])) {
927  // Date
928  print '<td>'.dol_print_date($db->jdate($objp->datem), 'dayhour').'</td>';
929  }
930  if (!empty($arrayfields['p.ref']['checked'])) {
931  // Product ref
932  print '<td class="nowraponall">';
933  print $productstatic->getNomUrl(1, 'stock', 16);
934  print "</td>\n";
935  }
936  if (!empty($arrayfields['p.label']['checked'])) {
937  // Product label
938  print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($productstatic->label).'">';
939  print $productstatic->label;
940  print "</td>\n";
941  }
942  if (!empty($arrayfields['m.batch']['checked'])) {
943  print '<td class="center nowraponall">';
944  if ($productlot->id > 0) {
945  print $productlot->getNomUrl(1);
946  } else {
947  print dol_escape_htmltag($productlot->batch); // the id may not be defined if movement was entered when lot was not saved or if lot was removed after movement.
948  }
949  print '</td>';
950  }
951  if (!empty($arrayfields['pl.eatby']['checked'])) {
952  print '<td class="center">'.dol_print_date($objp->eatby, 'day').'</td>';
953  }
954  if (!empty($arrayfields['pl.sellby']['checked'])) {
955  print '<td class="center">'.dol_print_date($objp->sellby, 'day').'</td>';
956  }
957  // Warehouse
958  if (!empty($arrayfields['e.ref']['checked'])) {
959  print '<td>';
960  print $warehousestatic->getNomUrl(1);
961  print "</td>\n";
962  }
963  // Author
964  if (!empty($arrayfields['m.fk_user_author']['checked'])) {
965  print '<td class="tdoverflowmax100">';
966  print $userstatic->getNomUrl(-1);
967  print "</td>\n";
968  }
969  // Inventory code
970  if (!empty($arrayfields['m.inventorycode']['checked'])) {
971  print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($objp->inventorycode).'">';
972  //print '<a href="' . DOL_URL_ROOT . '/product/stock/movement_card.php' . '?id=' . $objp->entrepot_id . '&amp;search_inventorycode=' . $objp->inventorycode . '&amp;search_type_mouvement=' . $objp->type_mouvement . '">';
973  print dol_escape_htmltag($objp->inventorycode);
974  //print '</a>';
975  print '</td>';
976  }
977  // Label of movement
978  if (!empty($arrayfields['m.label']['checked'])) {
979  print '<td class="tdoverflowmax300" title="'.dol_escape_htmltag($objp->label).'">'.dol_escape_htmltag($objp->label).'</td>';
980  }
981  // Type of movement
982  if (!empty($arrayfields['m.type_mouvement']['checked'])) {
983  switch ($objp->type_mouvement) {
984  case "0":
985  print '<td class="center">'.$langs->trans('StockIncreaseAfterCorrectTransfer').'</td>';
986  break;
987  case "1":
988  print '<td class="center">'.$langs->trans('StockDecreaseAfterCorrectTransfer').'</td>';
989  break;
990  case "2":
991  print '<td class="center">'.$langs->trans('StockDecrease').'</td>';
992  break;
993  case "3":
994  print '<td class="center">'.$langs->trans('StockIncrease').'</td>';
995  break;
996  }
997  }
998  if (!empty($arrayfields['origin']['checked'])) {
999  // Origin of movement
1000  print '<td class="nowraponall">'.$origin.'</td>';
1001  }
1002  if (!empty($arrayfields['m.fk_projet']['checked'])) {
1003  // fk_project
1004  print '<td>';
1005  if ($objp->fk_project != 0) {
1006  print $movement->get_origin($objp->fk_project, 'project');
1007  }
1008  print '</td>';
1009  }
1010  if (!empty($arrayfields['m.value']['checked'])) {
1011  // Qty
1012  print '<td class="right">';
1013  if ($objp->qty > 0) {
1014  print '<span class="stockmovemententry">+'.$objp->qty.'</span>';
1015  } else {
1016  print '<span class="stockmovementexit">'.$objp->qty.'<span>';
1017  }
1018  print '</td>';
1019  }
1020  if (!empty($arrayfields['m.price']['checked'])) {
1021  // Price
1022  print '<td class="right">';
1023  if ($objp->price != 0) {
1024  print '<span class="opacitymedium">'.price($objp->price).'</span>';
1025  }
1026  print '</td>';
1027  }
1028  // Action column
1029  if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1030  print '<td class="nowrap center">';
1031  if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
1032  $selected = 0;
1033  if (in_array($objp->rowid, $arrayofselected)) {
1034  $selected = 1;
1035  }
1036  print '<input id="cb'.$objp->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$objp->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
1037  }
1038  print '</td>';
1039  if (!$i) {
1040  $totalarray['nbfield']++;
1041  }
1042  }
1043 
1044  print "</tr>\n";
1045  $i++;
1046  }
1047  if (empty($num)) {
1048  print '<tr><td colspan="'.$savnbfield.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
1049  }
1050 
1051  $db->free($resql);
1052 
1053  print "</table>";
1054  print '</div>';
1055  print "</form>";
1056 }
1057 
1058 // End of page
1059 llxFooter();
1060 $db->close();
if($user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition: card.php:58
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
Definition: agenda.php:118
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve', $idforemptyvalue='-1', $morecss='')
Convert a html select field into an ajax combobox.
Definition: ajax.lib.php:463
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:56
llxFooter()
Empty footer.
Definition: wrapper.php:70
Class to manage warehouses.
Class to manage standard extra fields.
Class to manage generation of HTML components Only common components must be here.
Class with static methods for building HTML components related to products Only components common to ...
Class to manage building of HTML components.
Class for Mo.
Definition: mo.class.php:36
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.
Definition: user.class.php:50
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.
Definition: index.php:744
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
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).
Definition: date.lib.php:377
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.
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 a Dolibarr global constant int value.
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
newToken()
Return the value of token currently saved into session with name 'newtoken'.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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.
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.
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_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...
if(!defined( 'CSRFCHECK_WITH_TOKEN'))
$formconfirm
if ($action == 'delbookkeepingyear') {
moPrepareHead($object)
Prepare array of tabs for Mo.
Definition: mrp_mo.lib.php:31
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.