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