dolibarr  16.0.5
movement_list.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2001-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2004-2017 Laurent Destailleur <eldy@users.sourceforge.net>
4  * Copyright (C) 2005-2014 Regis Houssin <regis.houssin@inodbox.com>
5  * Copyright (C) 2015 Juanjo Menent <jmenent@2byte.es>
6  * Copyright (C) 2018-2022 Ferran Marcet <fmarcet@2byte.es>
7  * Copyright (C) 2019 Frédéric France <frederic.france@netlogic.fr>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program. If not, see <https://www.gnu.org/licenses/>.
21  */
22 
29 require '../../main.inc.php';
30 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.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 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
36 require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
37 require_once DOL_DOCUMENT_ROOT.'/core/lib/stock.lib.php';
38 require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php';
39 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
40 require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
41 if (!empty($conf->project->enabled)) {
42  require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
43  require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
44 }
45 
46 // Load translation files required by the page
47 $langs->loadLangs(array('products', 'stocks', 'orders'));
48 if (!empty($conf->productbatch->enabled)) {
49  $langs->load("productbatch");
50 }
51 
52 $id = GETPOST('id', 'int');
53 $ref = GETPOST('ref', 'alpha');
54 $msid = GETPOST('msid', 'int');
55 $product_id = GETPOST("product_id", 'int');
56 $action = GETPOST('action', 'aZ09');
57 $massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
58 $confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation
59 $cancel = GETPOST('cancel', 'alpha');
60 $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'movementlist';
61 $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list
62 $backtopage = GETPOST("backtopage", "alpha");
63 
64 $idproduct = GETPOST('idproduct', 'int');
65 $sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'));
66 $search_date_startday = GETPOST('search_date_startday', 'int');
67 $search_date_startmonth = GETPOST('search_date_startmonth', 'int');
68 $search_date_startyear = GETPOST('search_date_startyear', 'int');
69 $search_date_endday = GETPOST('search_date_endday', 'int');
70 $search_date_endmonth = GETPOST('search_date_endmonth', 'int');
71 $search_date_endyear = GETPOST('search_date_endyear', 'int');
72 $search_date_start = dol_mktime(0, 0, 0, GETPOST('search_date_startmonth', 'int'), GETPOST('search_date_startday', 'int'), GETPOST('search_date_startyear', 'int'), 'tzuserrel');
73 $search_date_end = dol_mktime(23, 59, 59, GETPOST('search_date_endmonth', 'int'), GETPOST('search_date_endday', 'int'), GETPOST('search_date_endyear', 'int'), 'tzuserrel');
74 $search_ref = GETPOST('search_ref', 'alpha');
75 $search_movement = GETPOST("search_movement");
76 $search_product_ref = trim(GETPOST("search_product_ref"));
77 $search_product = trim(GETPOST("search_product"));
78 $search_warehouse = trim(GETPOST("search_warehouse"));
79 $search_inventorycode = trim(GETPOST("search_inventorycode"));
80 $search_user = trim(GETPOST("search_user"));
81 $search_batch = trim(GETPOST("search_batch"));
82 $search_qty = trim(GETPOST("search_qty"));
83 $search_type_mouvement = GETPOST('search_type_mouvement', 'int');
84 $search_fk_projet=GETPOST("search_fk_projet", 'int');
85 $optioncss = GETPOST('optioncss', 'alpha');
86 $type = GETPOST("type", "int");
87 
88 // Load variable for pagination
89 $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
90 $sortfield = GETPOST('sortfield', 'aZ09comma');
91 $sortorder = GETPOST('sortorder', 'aZ09comma');
92 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
93 if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
94  // If $page is not defined, or '' or -1 or if we click on clear filters
95  $page = 0;
96 }
97 $offset = $limit * $page;
98 $pageprev = $page - 1;
99 $pagenext = $page + 1;
100 
101 if (!$sortfield) {
102  $sortfield = "m.datem";
103 }
104 if (!$sortorder) {
105  $sortorder = "DESC";
106 }
107 
108 $pdluoid = GETPOST('pdluoid', 'int');
109 
110 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
111 $object = new MouvementStock($db);
112 $extrafields = new ExtraFields($db);
113 $diroutputmassaction = $conf->stock->dir_output.'/temp/massgeneration/'.$user->id;
114 $hookmanager->initHooks(array('movementlist'));
115 
116 $formfile = new FormFile($db);
117 
118 // fetch optionals attributes and labels
119 $extrafields->fetch_name_optionals_label($object->table_element);
120 
121 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
122 
123 $arrayfields = array(
124  'm.rowid'=>array('label'=>"Ref", 'checked'=>1, 'position'=>1),
125  'm.datem'=>array('label'=>"Date", 'checked'=>1, 'position'=>2),
126  'p.ref'=>array('label'=>"ProductRef", 'checked'=>1, 'css'=>'maxwidth100', 'position'=>3),
127  'p.label'=>array('label'=>"ProductLabel", 'checked'=>0, 'position'=>5),
128  'm.batch'=>array('label'=>"BatchNumberShort", 'checked'=>1, 'position'=>8, 'enabled'=>(!empty($conf->productbatch->enabled))),
129  'pl.eatby'=>array('label'=>"EatByDate", 'checked'=>0, 'position'=>9, 'enabled'=>(!empty($conf->productbatch->enabled))),
130  'pl.sellby'=>array('label'=>"SellByDate", 'checked'=>0, 'position'=>10, 'enabled'=>(!empty($conf->productbatch->enabled))),
131  'e.ref'=>array('label'=>"Warehouse", 'checked'=>1, 'position'=>100, 'enabled'=>(!($id > 0))), // If we are on specific warehouse, we hide it
132  'm.fk_user_author'=>array('label'=>"Author", 'checked'=>0, 'position'=>120),
133  'm.inventorycode'=>array('label'=>"InventoryCodeShort", 'checked'=>1, 'position'=>130),
134  'm.label'=>array('label'=>"MovementLabel", 'checked'=>1, 'position'=>140),
135  'm.type_mouvement'=>array('label'=>"TypeMovement", 'checked'=>0, 'position'=>150),
136  'origin'=>array('label'=>"Origin", 'checked'=>1, 'position'=>155),
137  'm.fk_projet'=>array('label'=>'Project', 'checked'=>0, 'position'=>180),
138  'm.value'=>array('label'=>"Qty", 'checked'=>1, 'position'=>200),
139  'm.price'=>array('label'=>"UnitPurchaseValue", 'checked'=>0, 'position'=>210, 'enabled'=>empty($conf->global->STOCK_MOVEMENT_LIST_HIDE_UNIT_PRICE))
140  //'m.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500),
141  //'m.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500)
142 );
143 
144 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
145 
146 if (!empty($conf->global->PRODUCT_DISABLE_SELLBY)) {
147  unset($arrayfields['pl.sellby']);
148 }
149 if (!empty($conf->global->PRODUCT_DISABLE_EATBY)) {
150  unset($arrayfields['pl.eatby']);
151 }
152 
153 
154 $tmpwarehouse = new Entrepot($db);
155 if ($id > 0 || !empty($ref)) {
156  $tmpwarehouse->fetch($id, $ref);
157  $id = $tmpwarehouse->id;
158 }
159 
160 
161 // Security check
162 //$result=restrictedArea($user, 'stock', $id, 'entrepot&stock');
163 $result = restrictedArea($user, 'stock');
164 
165 // Security check
166 if (!$user->rights->stock->mouvement->lire) {
167  accessforbidden();
168 }
169 
170 $uploaddir = $conf->stock->dir_output.'/movements';
171 
172 $permissiontoread = $user->rights->stock->mouvement->lire;
173 $permissiontoadd = $user->rights->stock->mouvement->creer;
174 $permissiontodelete = $user->rights->stock->mouvement->creer; // There is no deletion permission for stock movement as we shoul dnever delete
175 
176 $usercanread = $user->rights->stock->mouvement->lire;
177 $usercancreate = $user->rights->stock->mouvement->creer;
178 $usercandelete = $user->rights->stock->mouvement->creer;
179 
180 $error = 0;
181 
182 
183 /*
184  * Actions
185  */
186 
187 if (GETPOST('cancel', 'alpha')) {
188  $action = 'list';
189  $massaction = '';
190 }
191 if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
192  $massaction = '';
193 }
194 
195 $parameters = array();
196 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
197 if ($reshook < 0) {
198  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
199 }
200 
201 if (empty($reshook)) {
202  // Selection of new fields
203  include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
204 
205  // Purge search criteria
206  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
207  $search_date_startday = '';
208  $search_date_startmonth = '';
209  $search_date_startyear = '';
210  $search_date_endday = '';
211  $search_date_endmonth = '';
212  $search_date_endyear = '';
213  $search_date_start = '';
214  $search_date_end = '';
215  $search_ref = '';
216  $search_movement = "";
217  $search_type_mouvement = "";
218  $search_inventorycode = "";
219  $search_product_ref = "";
220  $search_product = "";
221  $search_warehouse = "";
222  $search_user = "";
223  $search_batch = "";
224  $search_qty = '';
225  $search_fk_projet=0;
226  $sall = "";
227  $toselect = array();
228  $search_array_options = array();
229  }
230  if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
231  || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) {
232  $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
233  }
234 
235  // Mass actions
236  $objectclass = 'MouvementStock';
237  $objectlabel = 'MouvementStock';
238 
239  if (!$error && $massaction == "builddoc" && $permissiontoread && !GETPOST('button_search')) {
240  if (empty($diroutputmassaction)) {
241  dol_print_error(null, 'include of actions_massactions.inc.php is done but var $diroutputmassaction was not defined');
242  exit;
243  }
244 
245  require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
246  require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
247  require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
248 
249  $objecttmp = new $objectclass($db);
250  $listofobjectid = array();
251  foreach ($toselect as $toselectid) {
252  $objecttmp = new $objectclass($db); // must create new instance because instance is saved into $listofobjectref array for future use
253  $result = $objecttmp->fetch($toselectid);
254  if ($result > 0) {
255  $listofobjectid[$toselectid] = $toselectid;
256  }
257  }
258 
259  $arrayofinclusion = array();
260  foreach ($listofobjectref as $tmppdf) {
261  $arrayofinclusion[] = '^'.preg_quote(dol_sanitizeFileName($tmppdf), '/').'\.pdf$';
262  }
263  foreach ($listofobjectref as $tmppdf) {
264  $arrayofinclusion[] = '^'.preg_quote(dol_sanitizeFileName($tmppdf), '/').'_[a-zA-Z0-9-_]+\.pdf$'; // To include PDF generated from ODX files
265  }
266  $listoffiles = dol_dir_list($uploaddir, 'all', 1, implode('|', $arrayofinclusion), '\.meta$|\.png', 'date', SORT_DESC, 0, true);
267 
268  // Define output language (Here it is not used because we do only merging existing PDF)
269  $outputlangs = $langs;
270  $newlang = '';
271  if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
272  $newlang = GETPOST('lang_id', 'aZ09');
273  }
274  //elseif ($conf->global->MAIN_MULTILANGS && empty($newlang) && is_object($objecttmp->thirdparty)) { // On massaction, we can have several values for $objecttmp->thirdparty
275  // $newlang = $objecttmp->thirdparty->default_lang;
276  //}
277  if (!empty($newlang)) {
278  $outputlangs = new Translate("", $conf);
279  $outputlangs->setDefaultLang($newlang);
280  }
281 
282  // Create output dir if not exists
283  dol_mkdir($diroutputmassaction);
284 
285  // Defined name of merged file
286  $filename = strtolower(dol_sanitizeFileName($langs->transnoentities($objectlabel)));
287  $filename = preg_replace('/\s/', '_', $filename);
288 
289  // Save merged file
290  /*
291  if ($year) {
292  $filename .= '_'.$year;
293  }
294  if ($month) {
295  $filename .= '_'.$month;
296  }
297  */
298  $now = dol_now();
299  $file = $diroutputmassaction.'/'.$filename.'_'.dol_print_date($now, 'dayhourlog').'.pdf';
300 
301 
302  // Create PDF
303  // TODO Create the pdf including list of movement ids found into $listofobjectid
304  // ...
305 
306 
307  if (!$error) {
308  $langs->load("exports");
309  setEventMessages($langs->trans('FileSuccessfullyBuilt', $filename.'_'.dol_print_date($now, 'dayhourlog')), null, 'mesgs');
310  }
311 
312  $massaction = '';
313  $action = '';
314  }
315 
316  include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
317 }
318 
319 if ($action == 'update_extras') {
320  $tmpwarehouse->oldcopy = dol_clone($tmpwarehouse);
321 
322  // Fill array 'array_options' with data from update form
323  $ret = $extrafields->setOptionalsFromPost(null, $tmpwarehouse, GETPOST('attribute', 'restricthtml'));
324  if ($ret < 0) {
325  $error++;
326  }
327  if (!$error) {
328  $result = $tmpwarehouse->insertExtraFields();
329  if ($result < 0) {
330  setEventMessages($tmpwarehouse->error, $tmpwarehouse->errors, 'errors');
331  $error++;
332  }
333  }
334  if ($error) {
335  $action = 'edit_extras';
336  }
337 }
338 
339 // Correct stock
340 if ($action == "correct_stock") {
341  $product = new Product($db);
342  if (!empty($product_id)) {
343  $result = $product->fetch($product_id);
344  }
345 
346  $error = 0;
347 
348  if (empty($product_id)) {
349  $error++;
350  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Product")), null, 'errors');
351  $action = 'correction';
352  }
353  if (!is_numeric(GETPOST("nbpiece"))) {
354  $error++;
355  setEventMessages($langs->trans("ErrorFieldMustBeANumeric", $langs->transnoentitiesnoconv("NumberOfUnit")), null, 'errors');
356  $action = 'correction';
357  }
358 
359  if (!$error) {
360  $origin_element = '';
361  $origin_id = null;
362 
363  if (GETPOST('projectid', 'int')) {
364  $origin_element = 'project';
365  $origin_id = GETPOST('projectid', 'int');
366  }
367 
368  if ($product->hasbatch()) {
369  $batch = GETPOST('batch_number', 'alphanohtml');
370 
371  //$eatby=GETPOST('eatby');
372  //$sellby=GETPOST('sellby');
373  $eatby = dol_mktime(0, 0, 0, GETPOST('eatbymonth', 'int'), GETPOST('eatbyday', 'int'), GETPOST('eatbyyear', 'int'));
374  $sellby = dol_mktime(0, 0, 0, GETPOST('sellbymonth', 'int'), GETPOST('sellbyday', 'int'), GETPOST('sellbyyear', 'int'));
375 
376  $result = $product->correct_stock_batch(
377  $user,
378  $id,
379  GETPOST("nbpiece", 'int'),
380  GETPOST("mouvement", 'int'),
381  GETPOST("label", 'alphanohtml'),
382  price2num(GETPOST('unitprice'), 'MT'),
383  $eatby,
384  $sellby,
385  $batch,
386  GETPOST('inventorycode', 'alphanohtml'),
387  $origin_element,
388  $origin_id,
389  0,
390  $extrafields
391  ); // We do not change value of stock for a correction
392  } else {
393  $result = $product->correct_stock(
394  $user,
395  $id,
396  GETPOST("nbpiece", 'int'),
397  GETPOST("mouvement", "int"),
398  GETPOST("label", 'alphanohtml'),
399  price2num(GETPOST('unitprice'), 'MT'),
400  GETPOST('inventorycode', 'alphanohtml'),
401  $origin_element,
402  $origin_id,
403  0,
404  $extrafields
405  ); // We do not change value of stock for a correction
406  }
407 
408  if ($result > 0) {
409  header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
410  exit;
411  } else {
412  $error++;
413  setEventMessages($product->error, $product->errors, 'errors');
414  $action = 'correction';
415  }
416  }
417 
418  if (!$error) {
419  $action = '';
420  }
421 }
422 
423 // Transfer stock from a warehouse to another warehouse
424 if ($action == "transfert_stock" && !$cancel) {
425  $product = new Product($db);
426  if (!empty($product_id)) {
427  $result = $product->fetch($product_id);
428  }
429 
430  if (!(GETPOST("id_entrepot_destination", 'int') > 0)) {
431  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Warehouse")), null, 'errors');
432  $error++;
433  $action = 'transfert';
434  }
435  if (empty($product_id)) {
436  $error++;
437  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Product")), null, 'errors');
438  $action = 'transfert';
439  }
440  if (!GETPOST("nbpiece", 'int')) {
441  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NumberOfUnit")), null, 'errors');
442  $error++;
443  $action = 'transfert';
444  }
445  if ($id == GETPOST("id_entrepot_destination", 'int')) {
446  setEventMessages($langs->trans("ErrorSrcAndTargetWarehouseMustDiffers"), null, 'errors');
447  $error++;
448  $action = 'transfert';
449  }
450 
451  if (!empty($conf->productbatch->enabled)) {
452  $product = new Product($db);
453  $result = $product->fetch($product_id);
454 
455  if ($product->hasbatch() && !GETPOST("batch_number")) {
456  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("batch_number")), null, 'errors');
457  $error++;
458  $action = 'transfert';
459  }
460  }
461 
462  if (!$error) {
463  if ($id) {
464  $object = new Entrepot($db);
465  $result = $object->fetch($id);
466 
467  $db->begin();
468 
469  $product->load_stock('novirtual'); // Load array product->stock_warehouse
470 
471  // Define value of products moved
472  $pricesrc = 0;
473  if (isset($product->pmp)) {
474  $pricesrc = $product->pmp;
475  }
476  $pricedest = $pricesrc;
477 
478  if ($product->hasbatch()) {
479  $pdluo = new Productbatch($db);
480 
481  if ($pdluoid > 0) {
482  $result = $pdluo->fetch($pdluoid);
483  if ($result) {
484  $srcwarehouseid = $pdluo->warehouseid;
485  $batch = $pdluo->batch;
486  $eatby = $pdluo->eatby;
487  $sellby = $pdluo->sellby;
488  } else {
489  setEventMessages($pdluo->error, $pdluo->errors, 'errors');
490  $error++;
491  }
492  } else {
493  $srcwarehouseid = $id;
494  $batch = GETPOST('batch_number', 'alphanohtml');
495  $eatby = $d_eatby;
496  $sellby = $d_sellby;
497  }
498 
499  if (!$error) {
500  // Remove stock
501  $result1 = $product->correct_stock_batch(
502  $user,
503  $srcwarehouseid,
504  GETPOST("nbpiece", 'int'),
505  1,
506  GETPOST("label", 'san_alpha'),
507  $pricesrc,
508  $eatby,
509  $sellby,
510  $batch,
511  GETPOST('inventorycode'),
512  '',
513  null,
514  0,
515  $extrafields
516  );
517  // Add stock
518  $result2 = $product->correct_stock_batch(
519  $user,
520  GETPOST("id_entrepot_destination", 'int'),
521  GETPOST("nbpiece", 'int'),
522  0,
523  GETPOST("label", 'san_alpha'),
524  $pricedest,
525  $eatby,
526  $sellby,
527  $batch,
528  GETPOST('inventorycode', 'alphanohtml'),
529  '',
530  null,
531  0,
532  $extrafields
533  );
534  }
535  } else {
536  // Remove stock
537  $result1 = $product->correct_stock(
538  $user,
539  $id,
540  GETPOST("nbpiece"),
541  1,
542  GETPOST("label", 'san_alpha'),
543  $pricesrc,
544  GETPOST('inventorycode', 'alphanohtml'),
545  '',
546  null,
547  0,
548  $extrafields
549  );
550 
551  // Add stock
552  $result2 = $product->correct_stock(
553  $user,
554  GETPOST("id_entrepot_destination"),
555  GETPOST("nbpiece"),
556  0,
557  GETPOST("label", 'san_alpha'),
558  $pricedest,
559  GETPOST('inventorycode', 'alphanohtml'),
560  '',
561  null,
562  0,
563  $extrafields
564  );
565  }
566  if (!$error && $result1 >= 0 && $result2 >= 0) {
567  $db->commit();
568 
569  if ($backtopage) {
570  header("Location: ".$backtopage);
571  exit;
572  } else {
573  header("Location: movement_list.php?id=".$object->id);
574  exit;
575  }
576  } else {
577  setEventMessages($product->error, $product->errors, 'errors');
578  $db->rollback();
579  $action = 'transfert';
580  }
581  }
582  }
583 }
584 
585 
586 /*
587  * View
588  */
589 
590 $productlot = new ProductLot($db);
591 $productstatic = new Product($db);
592 $warehousestatic = new Entrepot($db);
593 $movement = new MouvementStock($db);
594 $userstatic = new User($db);
595 $form = new Form($db);
596 $formproduct = new FormProduct($db);
597 if (!empty($conf->project->enabled)) {
598  $formproject = new FormProjets($db);
599 }
600 
601 // Build and execute select
602 // --------------------------------------------------------------------
603 $sql = "SELECT p.rowid, p.ref as product_ref, p.label as produit, p.tosell, p.tobuy, p.tobatch, p.fk_product_type as type, p.entity,";
604 $sql .= " e.ref as warehouse_ref, e.rowid as entrepot_id, e.lieu, e.fk_parent, e.statut,";
605 $sql .= " m.rowid as mid, m.value as qty, m.datem, m.fk_user_author, m.label, m.inventorycode, m.fk_origin, m.origintype,";
606 $sql .= " m.batch, m.price,";
607 $sql .= " m.type_mouvement,";
608 $sql .= " m.fk_projet as fk_project,";
609 $sql .= " pl.rowid as lotid, pl.eatby, pl.sellby,";
610 $sql .= " u.login, u.photo, u.lastname, u.firstname, u.email as user_email, u.statut as user_status";
611 // Add fields from extrafields
612 if (!empty($extrafields->attributes[$object->table_element]['label'])) {
613  foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
614  $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
615  }
616 }
617 // Add fields from hooks
618 $parameters = array();
619 $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
620 $sql .= preg_replace('/^,/', '', $hookmanager->resPrint);
621 $sql = preg_replace('/,\s*$/', '', $sql);
622 
623 $sqlfields = $sql;
624 
625 $sql .= " FROM ".MAIN_DB_PREFIX."entrepot as e,";
626 $sql .= " ".MAIN_DB_PREFIX."product as p,";
627 $sql .= " ".MAIN_DB_PREFIX."stock_mouvement as m";
628 if (!empty($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
629  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (m.rowid = ef.fk_object)";
630 }
631 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON m.fk_user_author = u.rowid";
632 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_lot as pl ON m.batch = pl.batch AND m.fk_product = pl.fk_product";
633 $sql .= " WHERE m.fk_product = p.rowid";
634 if ($msid > 0) {
635  $sql .= " AND m.rowid = ".((int) $msid);
636 }
637 $sql .= " AND m.fk_entrepot = e.rowid";
638 $sql .= " AND e.entity IN (".getEntity('stock').")";
639 if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) {
640  $sql .= " AND p.fk_product_type = 0";
641 }
642 if ($id > 0) {
643  $sql .= " AND e.rowid = ".((int) $id);
644 }
645 if (!empty($search_date_start)) {
646  $sql .= " AND m.datem >= '" . $db->idate($search_date_start) . "'";
647 }
648 if (!empty($search_date_end)) {
649  $sql .= " AND m.datem <= '" . $db->idate($search_date_end) . "'";
650 }
651 if ($idproduct > 0) {
652  $sql .= " AND p.rowid = ".((int) $idproduct);
653 }
654 if (!empty($search_ref)) {
655  $sql .= natural_search('m.rowid', $search_ref, 1);
656 }
657 if (!empty($search_movement)) {
658  $sql .= natural_search('m.label', $search_movement);
659 }
660 if (!empty($search_inventorycode)) {
661  $sql .= natural_search('m.inventorycode', $search_inventorycode);
662 }
663 if (!empty($search_product_ref)) {
664  $sql .= natural_search('p.ref', $search_product_ref);
665 }
666 if (!empty($search_product)) {
667  $sql .= natural_search('p.label', $search_product);
668 }
669 if ($search_warehouse != '' && $search_warehouse != '-1') {
670  $sql .= natural_search('e.rowid', $search_warehouse, 2);
671 }
672 if (!empty($search_user)) {
673  $sql .= natural_search(array('u.lastname', 'u.firstname', 'u.login'), $search_user);
674 }
675 if (!empty($search_batch)) {
676  $sql .= natural_search('m.batch', $search_batch);
677 }
678 if (!empty($product_id) && $product_id != '-1') {
679  $sql .= natural_search('p.rowid', $product_id);
680 }
681 if (!empty($search_fk_projet) && $search_fk_projet != '-1') {
682  $sql .= natural_search('m.fk_projet', $search_fk_projet);
683 }
684 if ($search_qty != '') {
685  $sql .= natural_search('m.value', $search_qty, 1);
686 }
687 if ($search_type_mouvement != '' && $search_type_mouvement != '-1') {
688  $sql .= natural_search('m.type_mouvement', $search_type_mouvement, 2);
689 }
690 // Add where from extra fields
691 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
692 // Add where from hooks
693 $parameters = array();
694 $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
695 $sql .= $hookmanager->resPrint;
696 
697 /* If a group by is required
698  $sql .= " GROUP BY ";
699  foreach($object->fields as $key => $val) {
700  $sql .= "t.".$key.", ";
701  }
702  // Add fields from extrafields
703  if (!empty($extrafields->attributes[$object->table_element]['label'])) {
704  foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
705  $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.', ' : '');
706  }
707  }
708  // Add where from hooks
709  $parameters = array();
710  $reshook = $hookmanager->executeHooks('printFieldListGroupBy', $parameters, $object); // Note that $action and $object may have been modified by hook
711  $sql .= $hookmanager->resPrint;
712  $sql = preg_replace('/,\s*$/', '', $sql);
713  */
714 
715 // Add HAVING from hooks
716 /*
717  $parameters = array();
718  $reshook = $hookmanager->executeHooks('printFieldListHaving', $parameters, $object); // Note that $action and $object may have been modified by hook
719  $sql .= empty($hookmanager->resPrint) ? "" : " HAVING 1=1 ".$hookmanager->resPrint;
720  */
721 
722 // Count total nb of records
723 $nbtotalofrecords = '';
724 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
725  /* This old and fast method to get and count full list returns all record so use a high amount of memory.
726  $resql = $db->query($sql);
727  $nbtotalofrecords = $db->num_rows($resql);
728  */
729  /* The slow method does not consume memory on mysql (not tested on pgsql) */
730  /*$resql = $db->query($sql, 0, 'auto', 1);
731  while ($db->fetch_object($resql)) {
732  $nbtotalofrecords++;
733  }*/
734  /* The fast and low memory method to get and count full list converts the sql into a sql count */
735  $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
736  $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
737  $resql = $db->query($sqlforcount);
738  if (! $resql) {
739  dol_print_error($db);
740  } else {
741  $objforcount = $db->fetch_object($resql);
742  $nbtotalofrecords = $objforcount->nbtotalofrecords;
743  if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
744  $page = 0;
745  $offset = 0;
746  }
747  $db->free($resql);
748  }
749 }
750 
751 // Complete request and execute it with limit
752 $sql .= $db->order($sortfield, $sortorder);
753 if ($limit) {
754  $sql .= $db->plimit($limit + 1, $offset);
755 }
756 
757 $resql = $db->query($sql);
758 if (!$resql) {
759  dol_print_error($db);
760  exit;
761 }
762 
763 $product = new Product($db);
764 $object = new Entrepot($db);
765 
766 if ($idproduct > 0) {
767  $product->fetch($idproduct);
768 }
769 if ($id > 0 || $ref) {
770  $result = $object->fetch($id, $ref);
771  if ($result < 0) {
772  dol_print_error($db);
773  }
774 }
775 
776 $num = $db->num_rows($resql);
777 
778 
779 // Output page
780 // --------------------------------------------------------------------
781 
782 $i = 0;
783 $help_url = 'EN:Module_Stocks_En|FR:Module_Stock|ES:M&oacute;dulo_Stocks';
784 if ($msid) {
785  $title = $langs->trans('StockMovementForId', $msid);
786 } else {
787  $title = $langs->trans("ListOfStockMovements");
788  if ($id) {
789  $title .= ' ('.$langs->trans("ForThisWarehouse").')';
790  }
791 }
792 
793 llxHeader('', $title, $help_url);
794 
795 $arrayofselected = is_array($toselect) ? $toselect : array();
796 
797 /*
798  * Show tab only if we ask a particular warehouse
799  */
800 if ($object->id > 0) {
801  $head = stock_prepare_head($object);
802 
803  print dol_get_fiche_head($head, 'movements', $langs->trans("Warehouse"), -1, 'stock');
804 
805 
806  $linkback = '<a href="'.DOL_URL_ROOT.'/product/stock/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
807 
808  $morehtmlref = '<div class="refidno">';
809  $morehtmlref .= $langs->trans("LocationSummary").' : '.$object->lieu;
810 
811  // Project
812  if (!empty($conf->project->enabled)) {
813  $langs->load("projects");
814  $morehtmlref .= '<br>'.img_picto('', 'project').' '.$langs->trans('Project').' ';
815  if ($usercancreate && 1 == 2) {
816  if ($action != 'classify') {
817  $morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> : ';
818  }
819  if ($action == 'classify') {
820  $projectid = $object->fk_project;
821  $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
822  $morehtmlref .= '<input type="hidden" name="action" value="classin">';
823  $morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">';
824  $morehtmlref .= $formproject->select_projects(($socid > 0 ? $socid : -1), $projectid, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 1, 0, 'maxwidth500');
825  $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
826  $morehtmlref .= '</form>';
827  } else {
828  $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
829  }
830  } else {
831  if (!empty($object->fk_project)) {
832  $proj = new Project($db);
833  $proj->fetch($object->fk_project);
834  $morehtmlref .= ' : '.$proj->getNomUrl(1);
835  if ($proj->title) {
836  $morehtmlref .= ' - '.$proj->title;
837  }
838  } else {
839  $morehtmlref .= '';
840  }
841  }
842  }
843  $morehtmlref .= '</div>';
844 
845  $shownav = 1;
846  if ($user->socid && !in_array('stock', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) {
847  $shownav = 0;
848  }
849 
850  dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref', 'ref', $morehtmlref);
851 
852 
853  print '<div class="fichecenter">';
854  print '<div class="fichehalfleft">';
855  print '<div class="underbanner clearboth"></div>';
856 
857  print '<table class="border centpercent tableforfield">';
858 
859  print '<tr>';
860 
861  // Description
862  print '<td class="titlefield tdtop">'.$langs->trans("Description").'</td><td>'.dol_htmlentitiesbr($object->description).'</td></tr>';
863 
864  $calcproductsunique = $object->nb_different_products();
865  $calcproducts = $object->nb_products();
866 
867  // Total nb of different products
868  print '<tr><td>'.$langs->trans("NumberOfDifferentProducts").'</td><td>';
869  print empty($calcproductsunique['nb']) ? '0' : $calcproductsunique['nb'];
870  print "</td></tr>";
871 
872  // Nb of products
873  print '<tr><td>'.$langs->trans("NumberOfProducts").'</td><td>';
874  $valtoshow = price2num($calcproducts['nb'], 'MS');
875  print empty($valtoshow) ? '0' : $valtoshow;
876  print "</td></tr>";
877 
878  print '</table>';
879 
880  print '</div>';
881  print '<div class="fichehalfright">';
882  print '<div class="underbanner clearboth"></div>';
883 
884  print '<table class="border centpercent tableforfield">';
885 
886  // Value
887  print '<tr><td class="titlefield">'.$langs->trans("EstimatedStockValueShort").'</td><td>';
888  print price((empty($calcproducts['value']) ? '0' : price2num($calcproducts['value'], 'MT')), 0, $langs, 0, -1, -1, $conf->currency);
889  print "</td></tr>";
890 
891  // Last movement
892  $sql = "SELECT MAX(m.datem) as datem";
893  $sql .= " FROM ".MAIN_DB_PREFIX."stock_mouvement as m";
894  $sql .= " WHERE m.fk_entrepot = ".((int) $object->id);
895  $resqlbis = $db->query($sql);
896  if ($resqlbis) {
897  $objbis = $db->fetch_object($resqlbis);
898  $lastmovementdate = $db->jdate($objbis->datem);
899  } else {
900  dol_print_error($db);
901  }
902 
903  print '<tr><td>'.$langs->trans("LastMovement").'</td><td>';
904  if ($lastmovementdate) {
905  print dol_print_date($lastmovementdate, 'dayhour');
906  } else {
907  print $langs->trans("None");
908  }
909  print "</td></tr>";
910 
911  // Other attributes
912  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
913 
914  // Categories
915  if (isModEnabled('categorie')) {
916  print '<tr><td valign="middle">'.$langs->trans("Categories").'</td><td colspan="3">';
917  print $form->showCategories($object->id, Categorie::TYPE_WAREHOUSE, 1);
918  print "</td></tr>";
919  }
920 
921  print "</table>";
922 
923  print '</div>';
924  print '</div>';
925 
926  print '<div class="clearboth"></div>';
927 
928  print dol_get_fiche_end();
929 }
930 
931 
932 // Correct stock
933 if ($action == "correction") {
934  include DOL_DOCUMENT_ROOT.'/product/stock/tpl/stockcorrection.tpl.php';
935  print '<br>';
936 }
937 
938 // Transfer of units
939 if ($action == "transfert") {
940  include DOL_DOCUMENT_ROOT.'/product/stock/tpl/stocktransfer.tpl.php';
941  print '<br>';
942 }
943 
944 
945 // Action bar
946 if ((empty($action) || $action == 'list') && $id > 0) {
947  print "<div class=\"tabsAction\">\n";
948 
949  if ($user->rights->stock->mouvement->creer) {
950  print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$id.'&action=correction">'.$langs->trans("CorrectStock").'</a>';
951  }
952 
953  if ($user->rights->stock->mouvement->creer) {
954  print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$id.'&action=transfert">'.$langs->trans("TransferStock").'</a>';
955  }
956 
957  print '</div><br>';
958 }
959 
960 $param = '';
961 if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
962  $param .= '&contextpage='.urlencode($contextpage);
963 }
964 if ($limit > 0 && $limit != $conf->liste_limit) {
965  $param .= '&limit='.urlencode($limit);
966 }
967 if ($id > 0) {
968  $param .= '&id='.urlencode($id);
969 }
970 if ($search_date_startday) {
971  $param .= '&search_date_startday='.urlencode($search_date_startday);
972 }
973 if ($search_date_startmonth) {
974  $param .= '&search_date_startmonth='.urlencode($search_date_startmonth);
975 }
976 if ($search_date_startyear) {
977  $param .= '&search_date_startyear='.urlencode($search_date_startyear);
978 }
979 if ($search_date_endday) {
980  $param .= '&search_date_endday='.urlencode($search_date_endday);
981 }
982 if ($search_date_endmonth) {
983  $param .= '&search_date_endmonth='.urlencode($search_date_endmonth);
984 }
985 if ($search_date_endyear) {
986  $param .= '&search_date_endyear='.urlencode($search_date_endyear);
987 }
988 if ($search_movement) {
989  $param .= '&search_movement='.urlencode($search_movement);
990 }
991 if ($search_inventorycode) {
992  $param .= '&search_inventorycode='.urlencode($search_inventorycode);
993 }
994 if ($search_type_mouvement) {
995  $param .= '&search_type_mouvement='.urlencode($search_type_mouvement);
996 }
997 if ($search_product_ref) {
998  $param .= '&search_product_ref='.urlencode($search_product_ref);
999 }
1000 if ($search_product) {
1001  $param .= '&search_product='.urlencode($search_product);
1002 }
1003 if ($search_batch) {
1004  $param .= '&search_batch='.urlencode($search_batch);
1005 }
1006 if ($search_warehouse > 0) {
1007  $param .= '&search_warehouse='.urlencode($search_warehouse);
1008 }
1009 if ($search_user) {
1010  $param .= '&search_user='.urlencode($search_user);
1011 }
1012 if ($idproduct > 0) {
1013  $param .= '&idproduct='.urlencode($idproduct);
1014 }
1015 // Add $param from extra fields
1016 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
1017 
1018 // List of mass actions available
1019 $arrayofmassactions = array();
1020 if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) {
1021  $arrayofmassactions['builddoc'] = img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("GeneratePDF");
1022 }
1023 // By default, we should never accept deletion of stock movement
1024 if (!empty($conf->global->STOCK_ALLOW_DELETE_OF_MOVEMENT) && $permissiontodelete) {
1025  $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
1026 }
1027 if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) {
1028  $arrayofmassactions = array();
1029 }
1030 $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
1031 
1032 print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
1033 if ($optioncss != '') {
1034  print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
1035 }
1036 print '<input type="hidden" name="token" value="'.newToken().'">';
1037 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
1038 print '<input type="hidden" name="action" value="list">';
1039 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
1040 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
1041 print '<input type="hidden" name="type" value="'.$type.'">';
1042 print '<input type="hidden" name="page" value="'.$page.'">';
1043 print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
1044 if ($id > 0) {
1045  print '<input type="hidden" name="id" value="'.$id.'">';
1046 }
1047 
1048 if ($id > 0) {
1049  print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'movement', 0, '', '', $limit, 0, 0, 1);
1050 } else {
1051  print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'movement', 0, '', '', $limit, 0, 0, 1);
1052 }
1053 
1054 // Add code for pre mass action (confirmation or email presend form)
1055 $topicmail = "SendStockMovement";
1056 $modelmail = "movementstock";
1057 $objecttmp = new MouvementStock($db);
1058 $trackid = 'mov'.$object->id;
1059 include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
1060 
1061 if ($sall) {
1062  foreach ($fieldstosearchall as $key => $val) {
1063  $fieldstosearchall[$key] = $langs->trans($val);
1064  }
1065  print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>';
1066 }
1067 
1068 $moreforfilter = '';
1069 
1070 $parameters = array('arrayfields'=>&$arrayfields);
1071 $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
1072 if (empty($reshook)) {
1073  $moreforfilter .= $hookmanager->resPrint;
1074 } else {
1075  $moreforfilter = $hookmanager->resPrint;
1076 }
1077 
1078 if (!empty($moreforfilter)) {
1079  print '<div class="liste_titre liste_titre_bydiv centpercent">';
1080  print $moreforfilter;
1081  print '</div>';
1082 }
1083 
1084 $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
1085 $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
1086 $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
1087 
1088 print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
1089 print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
1090 
1091 // Fields title search
1092 // --------------------------------------------------------------------
1093 print '<tr class="liste_titre">';
1094 if (!empty($arrayfields['m.rowid']['checked'])) {
1095  // Ref
1096  print '<td class="liste_titre left">';
1097  print '<input class="flat maxwidth25" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
1098  print '</td>';
1099 }
1100 if (! empty($arrayfields['m.datem']['checked'])) {
1101  // Date
1102  print '<td class="liste_titre center">';
1103  print '<div class="nowrap">';
1104  print $form->selectDate($search_date_start?$search_date_start:-1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'), 'tzuserrel');
1105  print '</div>';
1106  print '<div class="nowrap">';
1107  print $form->selectDate($search_date_end?$search_date_end:-1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'), 'tzuserrel');
1108  print '</div>';
1109  print '</td>';
1110 }
1111 if (!empty($arrayfields['p.ref']['checked'])) {
1112  // Product Ref
1113  print '<td class="liste_titre left">';
1114  print '<input class="flat maxwidth75" type="text" name="search_product_ref" value="'.dol_escape_htmltag($idproduct ? $product->ref : $search_product_ref).'">';
1115  print '</td>';
1116 }
1117 if (!empty($arrayfields['p.label']['checked'])) {
1118  // Product label
1119  print '<td class="liste_titre left">';
1120  print '<input class="flat maxwidth100" type="text" name="search_product" value="'.dol_escape_htmltag($idproduct ? $product->label : $search_product).'">';
1121  print '</td>';
1122 }
1123 // Batch
1124 if (!empty($arrayfields['m.batch']['checked'])) {
1125  print '<td class="liste_titre center"><input class="flat maxwidth75" type="text" name="search_batch" value="'.dol_escape_htmltag($search_batch).'"></td>';
1126 }
1127 if (!empty($arrayfields['pl.eatby']['checked'])) {
1128  print '<td class="liste_titre left">';
1129  print '</td>';
1130 }
1131 if (!empty($arrayfields['pl.sellby']['checked'])) {
1132  print '<td class="liste_titre left">';
1133  print '</td>';
1134 }
1135 // Warehouse
1136 if (!empty($arrayfields['e.ref']['checked'])) {
1137  print '<td class="liste_titre maxwidthonsmartphone left">';
1138  //print '<input class="flat" type="text" size="8" name="search_warehouse" value="'.($search_warehouse).'">';
1139  print $formproduct->selectWarehouses($search_warehouse, 'search_warehouse', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, null, 'maxwidth200');
1140  print '</td>';
1141 }
1142 if (!empty($arrayfields['m.fk_user_author']['checked'])) {
1143  // Author
1144  print '<td class="liste_titre left">';
1145  print '<input class="flat" type="text" size="6" name="search_user" value="'.dol_escape_htmltag($search_user).'">';
1146  print '</td>';
1147 }
1148 if (!empty($arrayfields['m.inventorycode']['checked'])) {
1149  // Inventory code
1150  print '<td class="liste_titre left">';
1151  print '<input class="flat" type="text" size="4" name="search_inventorycode" value="'.dol_escape_htmltag($search_inventorycode).'">';
1152  print '</td>';
1153 }
1154 if (!empty($arrayfields['m.label']['checked'])) {
1155  // Label of movement
1156  print '<td class="liste_titre left">';
1157  print '<input class="flat" type="text" size="8" name="search_movement" value="'.dol_escape_htmltag($search_movement).'">';
1158  print '</td>';
1159 }
1160 if (!empty($arrayfields['origin']['checked'])) {
1161  // Origin of movement
1162  print '<td class="liste_titre left">';
1163  print '&nbsp; ';
1164  print '</td>';
1165 }
1166 if (!empty($arrayfields['m.fk_projet']['checked'])) {
1167  // fk_project
1168  print '<td class="liste_titre" align="left">';
1169  print '&nbsp; ';
1170  print '</td>';
1171 }
1172 if (!empty($arrayfields['m.type_mouvement']['checked'])) {
1173  // Type of movement
1174  print '<td class="liste_titre center">';
1175  //print '<input class="flat" type="text" size="3" name="search_type_mouvement" value="'.dol_escape_htmltag($search_type_mouvement).'">';
1176  print '<select id="search_type_mouvement" name="search_type_mouvement" class="maxwidth150">';
1177  print '<option value="" '.(($search_type_mouvement == "") ? 'selected="selected"' : '').'>&nbsp;</option>';
1178  print '<option value="0" '.(($search_type_mouvement == "0") ? 'selected="selected"' : '').'>'.$langs->trans('StockIncreaseAfterCorrectTransfer').'</option>';
1179  print '<option value="1" '.(($search_type_mouvement == "1") ? 'selected="selected"' : '').'>'.$langs->trans('StockDecreaseAfterCorrectTransfer').'</option>';
1180  print '<option value="2" '.(($search_type_mouvement == "2") ? 'selected="selected"' : '').'>'.$langs->trans('StockDecrease').'</option>';
1181  print '<option value="3" '.(($search_type_mouvement == "3") ? 'selected="selected"' : '').'>'.$langs->trans('StockIncrease').'</option>';
1182  print '</select>';
1183  print ajax_combobox('search_type_mouvement');
1184  // TODO: add new function $formentrepot->selectTypeOfMovement(...) like
1185  // print $formproduct->selectWarehouses($search_warehouse, 'search_warehouse', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, null, 'maxwidth200');
1186  print '</td>';
1187 }
1188 if (!empty($arrayfields['m.value']['checked'])) {
1189  // Qty
1190  print '<td class="liste_titre right">';
1191  print '<input class="flat" type="text" size="4" name="search_qty" value="'.dol_escape_htmltag($search_qty).'">';
1192  print '</td>';
1193 }
1194 if (!empty($arrayfields['m.price']['checked'])) {
1195  // Price
1196  print '<td class="liste_titre" align="left">';
1197  print '&nbsp; ';
1198  print '</td>';
1199 }
1200 
1201 // Extra fields
1202 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
1203 
1204 // Fields from hook
1205 $parameters = array('arrayfields'=>$arrayfields);
1206 $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook
1207 print $hookmanager->resPrint;
1208 // Date creation
1209 if (!empty($arrayfields['m.datec']['checked'])) {
1210  print '<td class="liste_titre">';
1211  print '</td>';
1212 }
1213 // Date modification
1214 if (!empty($arrayfields['m.tms']['checked'])) {
1215  print '<td class="liste_titre">';
1216  print '</td>';
1217 }
1218 // Action column
1219 print '<td class="liste_titre maxwidthsearch">';
1220 $searchpicto = $form->showFilterButtons();
1221 print $searchpicto;
1222 print '</td>';
1223 print '</tr>'."\n";
1224 
1225 
1226 // Fields title label
1227 // --------------------------------------------------------------------
1228 print '<tr class="liste_titre">';
1229 if (!empty($arrayfields['m.rowid']['checked'])) {
1230  print_liste_field_titre($arrayfields['m.rowid']['label'], $_SERVER["PHP_SELF"], 'm.rowid', '', $param, '', $sortfield, $sortorder);
1231 }
1232 if (!empty($arrayfields['m.datem']['checked'])) {
1233  print_liste_field_titre($arrayfields['m.datem']['label'], $_SERVER["PHP_SELF"], 'm.datem', '', $param, '', $sortfield, $sortorder, 'center ');
1234 }
1235 if (!empty($arrayfields['p.ref']['checked'])) {
1236  print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], 'p.ref', '', $param, '', $sortfield, $sortorder);
1237 }
1238 if (!empty($arrayfields['p.label']['checked'])) {
1239  print_liste_field_titre($arrayfields['p.label']['label'], $_SERVER["PHP_SELF"], 'p.label', '', $param, '', $sortfield, $sortorder);
1240 }
1241 if (!empty($arrayfields['m.batch']['checked'])) {
1242  print_liste_field_titre($arrayfields['m.batch']['label'], $_SERVER["PHP_SELF"], 'm.batch', '', $param, '', $sortfield, $sortorder, 'center ');
1243 }
1244 if (!empty($arrayfields['pl.eatby']['checked'])) {
1245  print_liste_field_titre($arrayfields['pl.eatby']['label'], $_SERVER["PHP_SELF"], 'pl.eatby', '', $param, '', $sortfield, $sortorder, 'center ');
1246 }
1247 if (!empty($arrayfields['pl.sellby']['checked'])) {
1248  print_liste_field_titre($arrayfields['pl.sellby']['label'], $_SERVER["PHP_SELF"], 'pl.sellby', '', $param, '', $sortfield, $sortorder, 'center ');
1249 }
1250 if (!empty($arrayfields['e.ref']['checked'])) {
1251  // We are on a specific warehouse card, no filter on other should be possible
1252  print_liste_field_titre($arrayfields['e.ref']['label'], $_SERVER["PHP_SELF"], "e.ref", "", $param, "", $sortfield, $sortorder);
1253 }
1254 if (!empty($arrayfields['m.fk_user_author']['checked'])) {
1255  print_liste_field_titre($arrayfields['m.fk_user_author']['label'], $_SERVER["PHP_SELF"], "m.fk_user_author", "", $param, "", $sortfield, $sortorder);
1256 }
1257 if (!empty($arrayfields['m.inventorycode']['checked'])) {
1258  print_liste_field_titre($arrayfields['m.inventorycode']['label'], $_SERVER["PHP_SELF"], "m.inventorycode", "", $param, "", $sortfield, $sortorder);
1259 }
1260 if (!empty($arrayfields['m.label']['checked'])) {
1261  print_liste_field_titre($arrayfields['m.label']['label'], $_SERVER["PHP_SELF"], "m.label", "", $param, "", $sortfield, $sortorder);
1262 }
1263 if (!empty($arrayfields['origin']['checked'])) {
1264  print_liste_field_titre($arrayfields['origin']['label'], $_SERVER["PHP_SELF"], "", "", $param, "", $sortfield, $sortorder);
1265 }
1266 if (!empty($arrayfields['m.fk_projet']['checked'])) {
1267  print_liste_field_titre($arrayfields['m.fk_projet']['label'], $_SERVER["PHP_SELF"], "m.fk_projet", "", $param, '', $sortfield, $sortorder);
1268 }
1269 if (!empty($arrayfields['m.type_mouvement']['checked'])) {
1270  print_liste_field_titre($arrayfields['m.type_mouvement']['label'], $_SERVER["PHP_SELF"], "m.type_mouvement", "", $param, '', $sortfield, $sortorder, 'center ');
1271 }
1272 if (!empty($arrayfields['m.value']['checked'])) {
1273  print_liste_field_titre($arrayfields['m.value']['label'], $_SERVER["PHP_SELF"], "m.value", "", $param, '', $sortfield, $sortorder, 'right ');
1274 }
1275 if (!empty($arrayfields['m.price']['checked'])) {
1276  print_liste_field_titre($arrayfields['m.price']['label'], $_SERVER["PHP_SELF"], "m.price", "", $param, '', $sortfield, $sortorder, 'right ');
1277 }
1278 
1279 // Extra fields
1280 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
1281 
1282 // Hook fields
1283 $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
1284 $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
1285 print $hookmanager->resPrint;
1286 if (!empty($arrayfields['m.datec']['checked'])) {
1287  print_liste_field_titre($arrayfields['p.datec']['label'], $_SERVER["PHP_SELF"], "p.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
1288 }
1289 if (!empty($arrayfields['m.tms']['checked'])) {
1290  print_liste_field_titre($arrayfields['p.tms']['label'], $_SERVER["PHP_SELF"], "p.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
1291 }
1292 // Action column
1293 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
1294 print '</tr>'."\n";
1295 
1296 
1297 $arrayofuniqueproduct = array();
1298 
1299 
1300 // Loop on record
1301 // --------------------------------------------------------------------
1302 $i = 0;
1303 $totalarray = array();
1304 $totalarray['nbfield'] = 0;
1305 while ($i < ($limit ? min($num, $limit) : $num)) {
1306  $obj = $db->fetch_object($resql);
1307  if (empty($obj)) {
1308  break; // Should not happen
1309  }
1310 
1311  $userstatic->id = $obj->fk_user_author;
1312  $userstatic->login = $obj->login;
1313  $userstatic->lastname = $obj->lastname;
1314  $userstatic->firstname = $obj->firstname;
1315  $userstatic->photo = $obj->photo;
1316  $userstatic->email = $obj->user_email;
1317  $userstatic->statut = $obj->user_status;
1318 
1319  // Multilangs
1320  if (!empty($conf->global->MAIN_MULTILANGS)) { // If multilang is enabled
1321  // TODO Use a cache
1322  $sql = "SELECT label";
1323  $sql .= " FROM ".MAIN_DB_PREFIX."product_lang";
1324  $sql .= " WHERE fk_product = ".((int) $obj->rowid);
1325  $sql .= " AND lang = '".$db->escape($langs->getDefaultLang())."'";
1326  $sql .= " LIMIT 1";
1327 
1328  $result = $db->query($sql);
1329  if ($result) {
1330  $objtp = $db->fetch_object($result);
1331  if (!empty($objtp->label)) {
1332  $obj->produit = $objtp->label;
1333  }
1334  }
1335  }
1336 
1337  $productstatic->id = $obj->rowid;
1338  $productstatic->ref = $obj->product_ref;
1339  $productstatic->label = $obj->produit;
1340  $productstatic->type = $obj->type;
1341  $productstatic->entity = $obj->entity;
1342  $productstatic->status = $obj->tosell;
1343  $productstatic->status_buy = $obj->tobuy;
1344  $productstatic->status_batch = $obj->tobatch;
1345 
1346  $productlot->id = $obj->lotid;
1347  $productlot->batch = $obj->batch;
1348  $productlot->eatby = $obj->eatby;
1349  $productlot->sellby = $obj->sellby;
1350 
1351  $warehousestatic->id = $obj->entrepot_id;
1352  $warehousestatic->ref = $obj->warehouse_ref;
1353  $warehousestatic->label = $obj->warehouse_ref;
1354  $warehousestatic->lieu = $obj->lieu;
1355  $warehousestatic->fk_parent = $obj->fk_parent;
1356  $warehousestatic->statut = $obj->statut;
1357 
1358  $movement->type = $obj->type_mouvement;
1359 
1360  $arrayofuniqueproduct[$obj->rowid] = $obj->produit;
1361  if (!empty($obj->fk_origin)) {
1362  $origin = $movement->get_origin($obj->fk_origin, $obj->origintype);
1363  } else {
1364  $origin = '';
1365  }
1366 
1367  print '<tr class="oddeven">';
1368  // Id movement
1369  if (!empty($arrayfields['m.rowid']['checked'])) {
1370  print '<td>';
1371  print img_picto($langs->trans("StockMovement"), 'movement', 'class="pictofixedwidth"');
1372  print $obj->mid;
1373  print '</td>'; // This is primary not movement id
1374  }
1375  if (!empty($arrayfields['m.datem']['checked'])) {
1376  // Date
1377  print '<td class="nowraponall center">'.dol_print_date($db->jdate($obj->datem), 'dayhour', 'tzuserrel').'</td>';
1378  }
1379  if (!empty($arrayfields['p.ref']['checked'])) {
1380  // Product ref
1381  print '<td class="nowraponall">';
1382  print $productstatic->getNomUrl(1, 'stock', 16);
1383  print "</td>\n";
1384  }
1385  if (!empty($arrayfields['p.label']['checked'])) {
1386  // Product label
1387  print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($productstatic->label).'">';
1388  print $productstatic->label;
1389  print "</td>\n";
1390  }
1391  if (!empty($arrayfields['m.batch']['checked'])) {
1392  print '<td class="center nowraponall">';
1393  if ($productlot->id > 0) {
1394  print $productlot->getNomUrl(1);
1395  } else {
1396  print $productlot->batch; // the id may not be defined if movement was entered when lot was not saved or if lot was removed after movement.
1397  }
1398  print '</td>';
1399  }
1400  if (!empty($arrayfields['pl.eatby']['checked'])) {
1401  print '<td class="center">'.dol_print_date($obj->eatby, 'day').'</td>';
1402  }
1403  if (!empty($arrayfields['pl.sellby']['checked'])) {
1404  print '<td class="center">'.dol_print_date($obj->sellby, 'day').'</td>';
1405  }
1406  // Warehouse
1407  if (!empty($arrayfields['e.ref']['checked'])) {
1408  print '<td class="tdoverflowmax100">';
1409  print $warehousestatic->getNomUrl(1);
1410  print "</td>\n";
1411  }
1412  // Author
1413  if (!empty($arrayfields['m.fk_user_author']['checked'])) {
1414  print '<td class="tdoverflowmax100">';
1415  print $userstatic->getNomUrl(-1);
1416  print "</td>\n";
1417  }
1418  if (!empty($arrayfields['m.inventorycode']['checked'])) {
1419  // Inventory code
1420  print '<td><a href="'.$_SERVER["PHP_SELF"].'?search_inventorycode='.urlencode('^'.$obj->inventorycode.'$').'&search_type_mouvement='.urlencode($obj->type_mouvement).'">'.$obj->inventorycode.'</a></td>';
1421  }
1422  if (!empty($arrayfields['m.label']['checked'])) {
1423  // Label of movement
1424  print '<td class="tdoverflowmax200" title="'.dol_escape_htmltag($obj->label).'">'.$obj->label.'</td>';
1425  }
1426  if (!empty($arrayfields['origin']['checked'])) {
1427  // Origin of movement
1428  print '<td class="nowraponall">'.$origin.'</td>';
1429  }
1430  if (!empty($arrayfields['m.fk_projet']['checked'])) {
1431  // fk_project
1432  print '<td>';
1433  if ($obj->fk_project != 0) {
1434  print $movement->get_origin($obj->fk_project, 'project');
1435  }
1436  print '</td>';
1437  }
1438  if (!empty($arrayfields['m.type_mouvement']['checked'])) {
1439  // Type of movement
1440  print '<td class="center">';
1441  print $movement->getTypeMovement();
1442  print '</td>';
1443  }
1444  if (!empty($arrayfields['m.value']['checked'])) {
1445  // Qty
1446  print '<td class="right">';
1447  if ($obj->qty > 0) {
1448  print '<span class="stockmovemententry">';
1449  print '+';
1450  print $obj->qty;
1451  print '</span>';
1452  } else {
1453  print '<span class="stockmovementexit">';
1454  print $obj->qty;
1455  print '</span>';
1456  }
1457  print '</td>';
1458  }
1459  if (!empty($arrayfields['m.price']['checked'])) {
1460  // Price
1461  print '<td class="right">';
1462  if ($obj->price != 0) {
1463  print price($obj->price);
1464  }
1465  print '</td>';
1466  }
1467 
1468  // Extra fields
1469  $object = $movement;
1470  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
1471  // Fields from hook
1472  $parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
1473  $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook
1474  print $hookmanager->resPrint;
1475 
1476  // Action column
1477  print '<td class="nowrap center">';
1478  if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
1479  $selected = 0;
1480  if (in_array($obj->mid, $arrayofselected)) {
1481  $selected = 1;
1482  }
1483  print '<input id="cb'.$obj->mid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->mid.'"'.($selected ? ' checked="checked"' : '').'>';
1484  }
1485  print '</td>';
1486  if (!$i) {
1487  $totalarray['nbfield']++;
1488  }
1489 
1490  print '</tr>'."\n";
1491 
1492  $i++;
1493 }
1494 
1495 $db->free($resql);
1496 
1497 print "</table>";
1498 print '</div>';
1499 print "</form>";
1500 
1501 // Add number of product when there is a filter on period
1502 if (count($arrayofuniqueproduct) == 1 && is_numeric($year)) {
1503  print "<br>";
1504 
1505  $productidselected = 0;
1506  foreach ($arrayofuniqueproduct as $key => $val) {
1507  $productidselected = $key;
1508  $productlabelselected = $val;
1509  }
1510  $datebefore = dol_get_first_day($year ? $year : strftime("%Y", time()), $month ? $month : 1, true);
1511  $dateafter = dol_get_last_day($year ? $year : strftime("%Y", time()), $month ? $month : 12, true);
1512  $balancebefore = $movement->calculateBalanceForProductBefore($productidselected, $datebefore);
1513  $balanceafter = $movement->calculateBalanceForProductBefore($productidselected, $dateafter);
1514 
1515  //print '<tr class="total"><td class="liste_total">';
1516  print $langs->trans("NbOfProductBeforePeriod", $productlabelselected, dol_print_date($datebefore, 'day', 'gmt'));
1517  //print '</td>';
1518  //print '<td class="liste_total right" colspan="6">';
1519  print ': '.$balancebefore;
1520  print "<br>\n";
1521  //print '</td></tr>';
1522  //print '<tr class="total"><td class="liste_total">';
1523  print $langs->trans("NbOfProductAfterPeriod", $productlabelselected, dol_print_date($dateafter, 'day', 'gmt'));
1524  //print '</td>';
1525  //print '<td class="liste_total right" colspan="6">';
1526  print ': '.$balanceafter;
1527  print "<br>\n";
1528  //print '</td></tr>';
1529 }
1530 
1531 if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) {
1532  $hidegeneratedfilelistifempty = 1;
1533  if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
1534  $hidegeneratedfilelistifempty = 0;
1535  }
1536 
1537  require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
1538  $formfile = new FormFile($db);
1539 
1540  // Show list of available documents
1541  $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
1542  $urlsource .= str_replace('&amp;', '&', $param);
1543 
1544  $filedir = $diroutputmassaction;
1545  $genallowed = $permissiontoread;
1546  $delallowed = $permissiontoadd;
1547 
1548  print $formfile->showdocuments('massfilesarea_mymodule', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
1549 }
1550 
1551 // End of page
1552 llxFooter();
1553 $db->close();
ajax_combobox
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:438
Productbatch
Manage record for batch number management.
Definition: productbatch.class.php:31
dol_sanitizeFileName
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
Definition: functions.lib.php:1226
restrictedArea
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.
Definition: security.lib.php:234
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:73
Project
Class to manage projects.
Definition: project.class.php:35
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:484
dol_print_error
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
Definition: functions.lib.php:4844
Translate
Class to manage translations.
Definition: translate.class.php:30
FormProjets
Class to manage building of HTML components.
Definition: html.formprojet.class.php:30
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:142
dol_dir_list
dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0)
Scan a directory and return a list of files/directories.
Definition: files.lib.php:60
dol_clone
dol_clone($object, $native=0)
Create a clone of instance of object (new instance with same value for each properties) With native =...
Definition: functions.lib.php:1158
img_edit
img_edit($titlealt='default', $float=0, $other='')
Show logo editer/modifier fiche.
Definition: functions.lib.php:4389
dol_banner_tab
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.
Definition: functions.lib.php:2046
$help_url
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
price2num
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
Definition: functions.lib.php:5661
dol_print_date
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
Definition: functions.lib.php:2514
img_picto
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
Definition: functions.lib.php:3880
FormFile
Class to offer components to list and upload files.
Definition: html.formfile.class.php:36
MouvementStock
Class to manage stock movements.
Definition: mouvementstock.class.php:31
print_barre_liste
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.
Definition: functions.lib.php:5257
dol_get_first_day
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
Definition: date.lib.php:551
dol_get_fiche_head
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
Definition: functions.lib.php:1822
dol_get_last_day
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
Definition: date.lib.php:570
FormProduct
Class with static methods for building HTML components related to products Only components common to ...
Definition: html.formproduct.class.php:30
newToken
newToken()
Return the value of token currently saved into session with name 'newtoken'.
Definition: functions.lib.php:10878
dol_get_fiche_end
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Definition: functions.lib.php:2018
isModEnabled
isModEnabled($module)
Is Dolibarr module enabled.
Definition: functions.lib.php:105
User
Class to manage Dolibarr users.
Definition: user.class.php:44
GETPOSTISSET
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
Definition: functions.lib.php:386
print_liste_field_titre
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
Definition: functions.lib.php:5026
natural_search
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...
Definition: functions.lib.php:9420
ExtraFields
Class to manage standard extra fields.
Definition: extrafields.class.php:39
Product
Class to manage products or services.
Definition: product.class.php:46
Form
Class to manage generation of HTML components Only common components must be here.
Definition: html.form.class.php:52
dol_htmlentitiesbr
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom='UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
Definition: functions.lib.php:6991
Entrepot
Class to manage warehouses.
Definition: entrepot.class.php:35
dol_now
dol_now($mode='auto')
Return date for now.
Definition: functions.lib.php:2845
$resql
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
price
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.
Definition: functions.lib.php:5541
setEventMessages
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
Definition: functions.lib.php:8137
accessforbidden
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
Definition: security.lib.php:933
dol_mkdir
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
Definition: functions.lib.php:6603
dol_mktime
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
Definition: functions.lib.php:2757
getDolGlobalInt
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
Definition: functions.lib.php:93
llxHeader
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
stock_prepare_head
stock_prepare_head($object)
Prepare array with list of tabs.
Definition: stock.lib.php:30