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