dolibarr  18.0.6
list.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2004-2016 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) 2020 Tobias Sekan <tobias.sekan@startmail.com>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <https://www.gnu.org/licenses/>.
20  */
21 
28 // Load Dolibarr environment
29 require '../../main.inc.php';
30 require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php';
31 
32 if (isModEnabled('categorie')) {
33  require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcategory.class.php';
34  require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
35 }
36 
37 // Load translation files required by the page
38 $langs->loadLangs(array("stocks", "other"));
39 
40 $action = GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view'; // The action 'create'/'add', 'edit'/'update', 'view', ...
41 $massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
42 $show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ?
43 $confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation
44 $cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button
45 $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list
46 $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'stocklist'; // To manage different context of search
47 $backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
48 $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
49 $toselect = GETPOST('toselect', 'array');
50 $mode = GETPOST('mode', 'aZ'); // The output mode ('list', 'kanban', 'hierarchy', 'calendar', ...)
51 
52 $search_all = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'));
53 $search_ref = GETPOST("sref", "alpha") ?GETPOST("sref", "alpha") : GETPOST("search_ref", "alpha");
54 $search_label = GETPOST("snom", "alpha") ?GETPOST("snom", "alpha") : GETPOST("search_label", "alpha");
55 $search_status = GETPOST("search_status", "int");
56 
57 if (isModEnabled('categorie')) {
58  $search_category_list = GETPOST("search_category_".Categorie::TYPE_WAREHOUSE."_list", "array");
59 }
60 
61 // Load variable for pagination
62 $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
63 $sortfield = GETPOST('sortfield', 'aZ09comma');
64 $sortorder = GETPOST('sortorder', 'aZ09comma');
65 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
66 if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
67  // If $page is not defined, or '' or -1 or if we click on clear filters
68  $page = 0;
69 }
70 // Initialize technical objects
71 $offset = $limit * $page;
72 $pageprev = $page - 1;
73 $pagenext = $page + 1;
74 if (!$sortfield) {
75  $sortfield = "t.ref";
76 }
77 if (!$sortorder) {
78  $sortorder = "ASC";
79 }
80 
81 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
82 $object = new Entrepot($db);
83 $extrafields = new ExtraFields($db);
84 $diroutputmassaction = $conf->stock->dir_output.'/temp/massgeneration/'.$user->id;
85 $hookmanager->initHooks(array($contextpage));
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 = GETPOST("search_all", 'alphanohtml');
94 $search = array();
95 foreach ($object->fields as $key => $val) {
96  $search_key = $key;
97  if ($search_key == 'statut') {
98  $search_key = 'status'; // remove this after refactor entrepot.class property statut to status
99  }
100  if (GETPOST('search_'.$search_key, 'alpha') !== '') {
101  $search[$search_key] = GETPOST('search_'.$search_key, 'alpha');
102  }
103 }
104 
105 // List of fields to search into when doing a "search in all"
106 $fieldstosearchall = array();
107 foreach ($object->fields as $key => $val) {
108  if (!empty($val['searchall'])) {
109  $fieldstosearchall['t.'.$key] = $val['label'];
110  }
111 }
112 
113 // Definition of array of fields for columns
114 $arrayfields = array(
115  'stockqty'=>array('type'=>'float', 'label'=>'PhysicalStock', 'enabled'=>1, 'visible'=>-2, 'checked'=>0, 'position'=>170),
116  'estimatedvalue'=>array('type'=>'float', 'label'=>'EstimatedStockValue', 'enabled'=>1, 'visible'=>1, 'checked'=>1, 'position'=>171),
117  'estimatedstockvaluesell'=>array('type'=>'float', 'label'=>'EstimatedStockValueSell', 'enabled'=>1, 'checked'=>1, 'visible'=>2, 'position'=>172),
118 );
119 foreach ($object->fields as $key => $val) {
120  // If $val['visible']==0, then we never show the field
121  if (!empty($val['visible'])) {
122  $visible = (int) dol_eval($val['visible'], 1);
123  $arrayfields['t.'.$key] = array(
124  'label'=>$val['label'],
125  'checked'=>(($visible < 0) ? 0 : 1),
126  'enabled'=>(abs($visible) != 3 && dol_eval($val['enabled'], 1)),
127  'position'=>$val['position'],
128  'help'=> isset($val['help']) ? $val['help'] : ''
129  );
130  }
131 }
132 // Extra fields
133 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
134 
135 $object->fields = dol_sort_array($object->fields, 'position');
136 $arrayfields = dol_sort_array($arrayfields, 'position');
137 
138 $permissiontoread = $user->rights->stock->lire;
139 $permissiontodelete = $user->rights->stock->supprimer;
140 $permissiontoadd = $user->rights->stock->creer;
141 
142 // Security check
143 $result = restrictedArea($user, 'stock');
144 
145 
146 /*
147  * Actions
148  */
149 
150 if (GETPOST('cancel', 'alpha')) {
151  $action = 'list';
152  $massaction = '';
153 }
154 if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
155  $massaction = '';
156 }
157 
158 $parameters = array();
159 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
160 if ($reshook < 0) {
161  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
162 }
163 
164 if (empty($reshook)) {
165  // Selection of new fields
166  include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
167 
168  // Purge search criteria
169  if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
170  foreach ($object->fields as $key => $val) {
171  $search[$key] = '';
172  if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
173  $search[$key.'_dtstart'] = '';
174  $search[$key.'_dtend'] = '';
175  }
176  }
177  $toselect = array();
178  $search_array_options = array();
179  $search_category_list = array();
180  }
181  if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
182  || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) {
183  $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
184  }
185 
186  // Mass actions
187  $objectclass = 'Entrepot';
188  $objectlabel = 'Warehouse';
189  $uploaddir = $conf->stock->dir_output;
190  include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
191 }
192 
193 
194 /*
195  * View
196  */
197 
198 $form = new Form($db);
199 $warehouse = new Entrepot($db);
200 
201 $now = dol_now();
202 
203 $title = $langs->trans("Warehouses");
204 $help_url = 'EN:Module_Stocks_En|FR:Module_Stock|ES:M&oacute;dulo_Stocks';
205 
206 
207 // Build and execute select
208 // --------------------------------------------------------------------
209 $sql = 'SELECT ';
210 $sql .= $object->getFieldList('t');
211 // Add fields from extrafields
212 if (!empty($extrafields->attributes[$object->table_element]['label'])) {
213  foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
214  $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
215  }
216 }
217 
218 //For Multicompany PMP per entity
219 $separatedPMP = false;
220 if (!empty($conf->global->MULTICOMPANY_PRODUCT_SHARING_ENABLED) && !empty($conf->global->MULTICOMPANY_PMP_PER_ENTITY_ENABLED)) {
221  $separatedPMP = true;
222  $sql .= ", SUM(pa.pmp * ps.reel) as estimatedvalue, SUM(p.price * ps.reel) as sellvalue, SUM(ps.reel) as stockqty";
223 } else {
224  $sql .= ", SUM(p.pmp * ps.reel) as estimatedvalue, SUM(p.price * ps.reel) as sellvalue, SUM(ps.reel) as stockqty";
225 }
226 
227 
228 // Add fields from hooks
229 $parameters = array();
230 $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook
231 $sql .= $hookmanager->resPrint;
232 $sql = preg_replace('/,\s*$/', '', $sql);
233 
234 $sqlfields = $sql; // $sql fields to remove for count total
235 
236 $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t";
237 if (!empty($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
238  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)";
239 }
240 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON t.rowid = ps.fk_entrepot";
241 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON ps.fk_product = p.rowid";
242 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as c_dep ON c_dep.rowid = t.fk_departement";
243 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as ccount ON ccount.rowid = t.fk_pays";
244 if ($separatedPMP) {
245  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_perentity as pa ON pa.fk_product = p.rowid AND pa.fk_product = ps.fk_product AND pa.entity = ". (int) $conf->entity;
246 }
247 $sql .= " WHERE t.entity IN (".getEntity('stock').")";
248 foreach ($search as $key => $val) {
249  if (array_key_exists($key, $object->fields)) {
250  $class_key = $key;
251  if ($class_key == 'status') {
252  $class_key = 'statut'; // remove this after refactoring entrepot.class property statut to status
253  }
254  if (($key == 'status' && $search[$key] == -1) || $key == 'entity') {
255  continue;
256  }
257  $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0);
258  if ((strpos($object->fields[$key]['type'], 'integer:') === 0) || (strpos($object->fields[$key]['type'], 'sellist:') === 0) || !empty($object->fields[$key]['arrayofkeyval'])) {
259  if ($search[$key] == '-1' || ($search[$key] === '0' && (empty($object->fields[$key]['arrayofkeyval']) || !array_key_exists('0', $object->fields[$key]['arrayofkeyval'])))) {
260  $search[$key] = '';
261  }
262  $mode_search = 2;
263  }
264  if ($search[$key] != '') {
265  $sql .= natural_search((($key == "ref") ? "t.ref" : "t.".$class_key), $search[$key], (($key == 'status') ? 2 : $mode_search));
266  }
267  } else {
268  if (preg_match('/(_dtstart|_dtend)$/', $key) && $search[$key] != '') {
269  $columnName = preg_replace('/(_dtstart|_dtend)$/', '', $key);
270  if (preg_match('/^(date|timestamp|datetime)/', $object->fields[$columnName]['type'])) {
271  if (preg_match('/_dtstart$/', $key)) {
272  $sql .= " AND t.".$db->escape($columnName)." >= '".$db->idate($search[$key])."'";
273  }
274  if (preg_match('/_dtend$/', $key)) {
275  $sql .= " AND t.".$db->escape($columnName)." <= '".$db->idate($search[$key])."'";
276  }
277  }
278  }
279  }
280 }
281 if ($search_all) {
282  $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
283 }
284 // Search for tag/category ($searchCategoryWarehouseList is an array of ID)
285 $searchCategoryWarehouseList = $search_category_list;
286 $searchCategoryWarehouseOperator = 0;
287 if (!empty($searchCategoryWarehouseList)) {
288  $searchCategoryWarehouseSqlList = array();
289  $listofcategoryid = '';
290  foreach ($searchCategoryWarehouseList as $searchCategoryWarehouse) {
291  if (intval($searchCategoryWarehouse) == -2) {
292  $searchCategoryWarehouseSqlList[] = " NOT EXISTS (SELECT ck.fk_warehouse FROM ".MAIN_DB_PREFIX."categorie_warehouse as ck WHERE t.rowid = ck.fk_warehouse)";
293  } elseif (intval($searchCategoryWarehouse) > 0) {
294  if ($searchCategoryWarehouseOperator == 0) {
295  $searchCategoryWarehouseSqlList[] = " EXISTS (SELECT ck.fk_warehouse FROM ".MAIN_DB_PREFIX."categorie_warehouse as ck WHERE t.rowid = ck.fk_warehouse AND ck.fk_categorie = ".((int) $searchCategoryWarehouse).")";
296  } else {
297  $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryWarehouse);
298  }
299  }
300  }
301  if ($listofcategoryid) {
302  $searchCategoryWarehouseSqlList[] = " EXISTS (SELECT ck.fk_warehouse FROM ".MAIN_DB_PREFIX."categorie_warehouse as ck WHERE t.rowid = ck.fk_warehouse AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid)."))";
303  }
304  if ($searchCategoryWarehouseOperator == 1) {
305  if (!empty($searchCategoryWarehouseSqlList)) {
306  $sql .= " AND (".implode(' OR ', $searchCategoryWarehouseSqlList).")";
307  }
308  } else {
309  if (!empty($searchCategoryWarehouseSqlList)) {
310  $sql .= " AND (".implode(' AND ', $searchCategoryWarehouseSqlList).")";
311  }
312  }
313 }
314 
315 // Add where from extra fields
316 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
317 // Add where from hooks
318 $parameters = array();
319 $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
320 $sql .= $hookmanager->resPrint;
321 
322 $sql .= " GROUP BY ";
323 foreach ($object->fields as $key => $val) {
324  $sql .= "t.".$db->escape($key).", ";
325 }
326 // Add fields from extrafields
327 if (!empty($extrafields->attributes[$object->table_element]['label'])) {
328  foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
329  $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.', ' : '');
330  }
331 }
332 // Add groupby from hooks
333 $parameters = array();
334 $reshook = $hookmanager->executeHooks('printFieldListGroupBy', $parameters); // Note that $action and $object may have been modified by hook
335 $sql .= $hookmanager->resPrint;
336 $sql = preg_replace('/,\s*$/', '', $sql);
337 
338 $result = $db->query($sql);
339 if ($result) {
340  $totalnboflines = $db->num_rows($result);
341  // fetch totals
342  $line = $total = $totalsell = $totalStock = 0;
343  while ($line < $totalnboflines) {
344  $objp = $db->fetch_object($result);
345  $total += $objp->estimatedvalue;
346  $totalsell += $objp->sellvalue;
347  $totalStock += $objp->stockqty;
348  $line++;
349  }
350  $totalarray['val']['stockqty'] = price2num($totalStock, 'MS');
351  $totalarray['val']['estimatedvalue'] = price2num($total, 'MT');
352  $totalarray['val']['estimatedstockvaluesell'] = price2num($totalsell, 'MT');
353 }
354 
355 // Count total nb of records
356 $nbtotalofrecords = '';
357 if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
358  /* The fast and low memory method to get and count full list converts the sql into a sql count */
359  $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
360  $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
361  $resql = $db->query($sqlforcount);
362  if ($resql) {
363  $objforcount = $db->fetch_object($resql);
364  $nbtotalofrecords = $objforcount->nbtotalofrecords;
365  } else {
366  dol_print_error($db);
367  }
368 
369  if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller than the paging size (filtering), goto and load page 0
370  $page = 0;
371  $offset = 0;
372  }
373  $db->free($resql);
374 }
375 
376 // Complete request and execute it with limit
377 $sql .= $db->order($sortfield, $sortorder);
378 if ($limit) {
379  $sql .= $db->plimit($limit + 1, $offset);
380 }
381 
382 $resql = $db->query($sql);
383 if (!$resql) {
384  dol_print_error($db);
385  exit;
386 }
387 
388 $num = $db->num_rows($resql);
389 
390 // Direct jump if only one record found
391 if ($num == 1 && !getDolGlobalInt('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) {
392  $obj = $db->fetch_object($resql);
393  $id = $obj->rowid;
394  header("Location: ".DOL_URL_ROOT.'/product/stock/card.php?id='.$id);
395  exit;
396 }
397 
398 
399 // Output page
400 // --------------------------------------------------------------------
401 
402 llxHeader('', $title, $help_url);
403 
404 $arrayofselected = is_array($toselect) ? $toselect : array();
405 
406 $param = '';
407 if (!empty($mode)) {
408  $param .= '&mode='.urlencode($mode);
409 }
410 if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
411  $param .= '&contextpage='.urlencode($contextpage);
412 }
413 if ($limit > 0 && $limit != $conf->liste_limit) {
414  $param .= '&limit='.((int) $limit);
415 }
416 if ($optioncss != '') {
417  $param .= '&optioncss='.urlencode($optioncss);
418 }
419 foreach ($search as $key => $val) {
420  if (is_array($search[$key])) {
421  foreach ($search[$key] as $skey) {
422  if ($skey != '') {
423  $param .= '&search_'.$key.'[]='.urlencode($skey);
424  }
425  }
426  } elseif (preg_match('/(_dtstart|_dtend)$/', $key) && !empty($val)) {
427  $param .= '&search_'.$key.'month='.((int) GETPOST('search_'.$key.'month', 'int'));
428  $param .= '&search_'.$key.'day='.((int) GETPOST('search_'.$key.'day', 'int'));
429  $param .= '&search_'.$key.'year='.((int) GETPOST('search_'.$key.'year', 'int'));
430  } elseif ($search[$key] != '') {
431  $param .= '&search_'.$key.'='.urlencode($search[$key]);
432  }
433 }
434 // Add $param from extra fields
435 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
436 // Add $param from hooks
437 $parameters = array();
438 $reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
439 $param .= $hookmanager->resPrint;
440 
441 // List of mass actions available
442 $arrayofmassactions = array(
443  //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
444  //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
445 );
446 //if ($user->rights->stock->supprimer) $arrayofmassactions['predelete']=img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
447 if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete','preaffecttag'))) {
448  $arrayofmassactions = array();
449 }
450 if (isModEnabled('category') && $user->rights->stock->creer) {
451  $arrayofmassactions['preaffecttag'] = img_picto('', 'label', 'class="pictofixedwidth"').$langs->trans("AffectTag");
452 }
453 $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
454 
455 print '<form action="'.$_SERVER["PHP_SELF"].'" id="searchFormList" method="POST" name="formulaire">';
456 if ($optioncss != '') {
457  print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
458 }
459 print '<input type="hidden" name="token" value="'.newToken().'">';
460 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
461 print '<input type="hidden" name="action" value="list">';
462 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
463 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
464 print '<input type="hidden" name="page" value="'.$page.'">';
465 print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
466 print '<input type="hidden" name="page_y" value="">';
467 print '<input type="hidden" name="mode" value="'.$mode.'">';
468 
469 
470 $newcardbutton = '';
471 $newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition'));
472 $newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition'));
473 $newcardbutton .= dolGetButtonTitleSeparator();
474 $newcardbutton .= dolGetButtonTitle($langs->trans('MenuNewWarehouse'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/product/stock/card.php?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $user->rights->stock->creer);
475 
476 print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'stock', 0, $newcardbutton, '', $limit, 0, 0, 1);
477 
478 // Add code for pre mass action (confirmation or email presend form)
479 $topicmail = "Information";
480 $modelmail = "warehouse";
481 $objecttmp = new Entrepot($db);
482 $trackid = 'ware'.$object->id;
483 include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
484 
485 
486 if ($search_all) {
487  $setupstring = '';
488  foreach ($fieldstosearchall as $key => $val) {
489  $fieldstosearchall[$key] = $langs->trans($val);
490  $setupstring .= $key."=".$val.";";
491  }
492  print '<!-- Search done like if STOCK_QUICKSEARCH_ON_FIELDS = '.$setupstring.' -->'."\n";
493  print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>';
494 }
495 
496 $moreforfilter = '';
497 
498 if (isModEnabled('categorie') && $user->hasRight('categorie', 'lire')) {
499  $formcategory = new FormCategory($db);
500  $moreforfilter .= $formcategory->getFilterBox(Categorie::TYPE_WAREHOUSE, $search_category_list);
501 }
502 
503 /*$moreforfilter.='<div class="divsearchfield">';
504  $moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escape_htmltag($search_myfield).'">';
505  $moreforfilter.= '</div>';*/
506 
507 $parameters = array();
508 $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
509 if (empty($reshook)) {
510  $moreforfilter .= $hookmanager->resPrint;
511 } else {
512  $moreforfilter = $hookmanager->resPrint;
513 }
514 
515 if (!empty($moreforfilter)) {
516  print '<div class="liste_titre liste_titre_bydiv centpercent">';
517  print $moreforfilter;
518  $parameters = array();
519  $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
520  print $hookmanager->resPrint;
521  print '</div>';
522 }
523 
524 $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
525 $selectedfields = ($mode != 'kanban' ? $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')) : ''); // This also change content of $arrayfields
526 $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
527 
528 print '<div class="div-table-responsive">';
529 print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
530 
531 // Fields title search
532 // --------------------------------------------------------------------
533 print '<tr class="liste_titre_filter">';
534 // Action column
535 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
536  print '<td class="liste_titre center maxwidthsearch">';
537  $searchpicto = $form->showFilterButtons('left');
538  print $searchpicto;
539  print '</td>';
540 }
541 foreach ($object->fields as $key => $val) {
542  if ($key == 'statut') {
543  continue;
544  }
545  $searchkey = empty($search[$key]) ? '' : $search[$key];
546  $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
547  if ($key == 'status') {
548  $cssforfield .= ($cssforfield ? ' ' : '').'center';
549  } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
550  $cssforfield .= ($cssforfield ? ' ' : '').'center';
551  } elseif (in_array($val['type'], array('timestamp'))) {
552  $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
553  } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('id', 'rowid', 'ref', 'status')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) {
554  $cssforfield .= ($cssforfield ? ' ' : '').'right';
555  }
556  if (!empty($arrayfields['t.'.$key]['checked'])) {
557  print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').($key == 'status' ? ' parentonrightofpage' : '').'">';
558  if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) {
559  print $form->selectarray('search_'.$key, $val['arrayofkeyval'], (isset($search[$key]) ? $search[$key] : ''), $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100'.($key == 'status' ? ' search_status width100 onrightofpage' : ''), 1);
560  } elseif ((strpos($val['type'], 'integer:') === 0) || (strpos($val['type'], 'sellist:') === 0)) {
561  print $object->showInputField($val, $key, (isset($search[$key]) ? $search[$key] : ''), '', '', 'search_', $cssforfield.' maxwidth250', 1);
562  } elseif (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
563  print '<div class="nowrap">';
564  print $form->selectDate($search[$key.'_dtstart'] ? $search[$key.'_dtstart'] : '', "search_".$key."_dtstart", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
565  print '</div>';
566  print '<div class="nowrap">';
567  print $form->selectDate($search[$key.'_dtend'] ? $search[$key.'_dtend'] : '', "search_".$key."_dtend", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
568  print '</div>';
569  } elseif ($key == 'lang') {
570  require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
571  $formadmin = new FormAdmin($db);
572  print $formadmin->select_language($search[$key], 'search_lang', 0, null, 1, 0, 0, 'minwidth150 maxwidth200', 2);
573  } else {
574  print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag(isset($search[$key]) ? $search[$key] : '').'">';
575  }
576  print '</td>';
577  }
578 }
579 
580 if (!empty($arrayfields["stockqty"]['checked'])) {
581  print '<td class="liste_titre"></td>';
582 }
583 
584 if (!empty($arrayfields["estimatedvalue"]['checked'])) {
585  print '<td class="liste_titre"></td>';
586 }
587 
588 if (!empty($arrayfields["estimatedstockvaluesell"]['checked'])) {
589  print '<td class="liste_titre"></td>';
590 }
591 
592 // Extra fields
593 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
594 
595 // Fields from hook
596 $parameters = array('arrayfields'=>$arrayfields);
597 $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
598 print $hookmanager->resPrint;
599 
600 // Status
601 if (!empty($arrayfields['t.statut']['checked'])) {
602  print '<td class="liste_titre center parentonrightofpage">';
603  print $form->selectarray('search_status', $warehouse->statuts, $search_status, 1, 0, 0, '', 1, 0, 0, '', 'search_status width100 onrightofpage');
604  print '</td>';
605 }
606 
607 // Action column
608 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
609  print '<td class="liste_titre center maxwidthsearch">';
610  $searchpicto = $form->showFilterButtons();
611  print $searchpicto;
612  print '</td>';
613 }
614 print '</tr>'."\n";
615 
616 $totalarray['nbfield'] = 0;
617 
618 // Fields title label
619 // --------------------------------------------------------------------
620 print '<tr class="liste_titre">';
621 // Action column
622 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
623  print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
624  $totalarray['nbfield']++;
625 }
626 foreach ($object->fields as $key => $val) {
627  if ($key == 'statut') {
628  continue;
629  }
630  $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
631  if ($key == 'status') {
632  $cssforfield .= ($cssforfield ? ' ' : '').'center';
633  } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
634  $cssforfield .= ($cssforfield ? ' ' : '').'center';
635  } elseif (in_array($val['type'], array('timestamp'))) {
636  $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
637  } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('id', 'rowid', 'ref', 'status')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) {
638  $cssforfield .= ($cssforfield ? ' ' : '').'right';
639  }
640  $cssforfield = preg_replace('/small\s*/', '', $cssforfield); // the 'small' css must not be used for the title label
641  if (!empty($arrayfields['t.'.$key]['checked'])) {
642  print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''), 0, (empty($val['helplist']) ? '' : $val['helplist']))."\n";
643  $totalarray['nbfield']++;
644  }
645 }
646 
647 if (!empty($arrayfields["stockqty"]['checked'])) {
648  print_liste_field_titre("PhysicalStock", $_SERVER["PHP_SELF"], "stockqty", '', $param, '', $sortfield, $sortorder, 'right ');
649  $totalarray['nbfield']++;
650 }
651 
652 if (!empty($arrayfields["estimatedvalue"]['checked'])) {
653  print_liste_field_titre("EstimatedStockValue", $_SERVER["PHP_SELF"], "estimatedvalue", '', $param, '', $sortfield, $sortorder, 'right ');
654  $totalarray['nbfield']++;
655 }
656 
657 if (!empty($arrayfields["estimatedstockvaluesell"]['checked'])) {
658  print_liste_field_titre("EstimatedStockValueSell", $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'right ');
659  $totalarray['nbfield']++;
660 }
661 
662 // Extra fields
663 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
664 
665 // Hook fields
666 $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
667 $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
668 print $hookmanager->resPrint;
669 
670 if (!empty($arrayfields['t.statut']['checked'])) {
671  print_liste_field_titre($arrayfields['t.statut']['label'], $_SERVER["PHP_SELF"], "t.statut", '', $param, '', $sortfield, $sortorder, 'center ');
672  $totalarray['nbfield']++;
673 }
674 
675 // Action column
676 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
677  print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
678  $totalarray['nbfield']++;
679 }
680 print '</tr>'."\n";
681 
682 $warehouse = new Entrepot($db);
683 
684 // Loop on record
685 // --------------------------------------------------------------------
686 $i = 0;
687 $savnbfield = $totalarray['nbfield'];
688 $totalarray['nbfield'] = 0;
689 $imaxinloop = ($limit ? min($num, $limit) : $num);
690 while ($i < $imaxinloop) {
691  $obj = $db->fetch_object($resql);
692  if (empty($obj)) {
693  break; // Should not happen
694  }
695 
696  // Store properties in $object
697  $warehouse->setVarsFromFetchObj($obj);
698 
699  $warehouse->label = $warehouse->ref;
700  $warehouse->sellvalue = $obj->sellvalue;
701 
702  $object = $warehouse;
703 
704  if ($mode == 'kanban') {
705  if ($i == 0) {
706  print '<tr class="trkanban"><td colspan="'.$savnbfield.'">';
707  print '<div class="box-flex-container kanban">';
708  }
709  // Output Kanban
710  $selected = -1;
711  if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
712  $selected = 0;
713  if (in_array($object->id, $arrayofselected)) {
714  $selected = 1;
715  }
716  }
717  print $object->getKanbanView('', array('selected' => $selected));
718  if ($i == ($imaxinloop - 1)) {
719  print '</div>';
720  print '</td></tr>';
721  }
722  } else {
723  // Show line of result
724  $j = 0;
725  print '<tr data-rowid="'.$object->id.'" class="oddeven">';
726 
727  // Action column
728  if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
729  print '<td class="nowrap center">';
730  if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
731  $selected = 0;
732  if (in_array($object->id, $arrayofselected)) {
733  $selected = 1;
734  }
735  print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
736  }
737  print '</td>';
738  if (!$i) {
739  $totalarray['nbfield']++;
740  }
741  }
742  foreach ($object->fields as $key => $val) {
743  if ($key == 'statut') {
744  continue;
745  }
746  $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
747  if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
748  $cssforfield .= ($cssforfield ? ' ' : '').'center';
749  } elseif ($key == 'status') {
750  $cssforfield .= ($cssforfield ? ' ' : '').'center';
751  }
752 
753  if (in_array($val['type'], array('timestamp'))) {
754  $cssforfield .= ($cssforfield ? ' ' : '').'nowraponall';
755  } elseif ($key == 'ref') {
756  $cssforfield .= ($cssforfield ? ' ' : '').'nowraponall';
757  }
758 
759  if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('id', 'rowid', 'ref', 'status')) && empty($val['arrayofkeyval'])) {
760  $cssforfield .= ($cssforfield ? ' ' : '').'right';
761  }
762  if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) {
763  $cssforfield = 'tdoverflowmax100';
764  }
765 
766  if (!empty($arrayfields['t.'.$key]['checked'])) {
767  print '<td'.($cssforfield ? ' class="'.$cssforfield.(preg_match('/tdoverflow/', $cssforfield) ? ' classfortooltip' : '').'"' : '');
768  if (preg_match('/tdoverflow/', $cssforfield) && !is_numeric($object->$key)) {
769  print ' title="'.dol_escape_htmltag($object->$key).'"';
770  }
771  print '>';
772  if ($key == 'statut') {
773  print $object->getLibStatut(5);
774  }
775  if ($key == 'phone') {
776  print dol_print_phone($object->phone, '', 0, $object->id, 'AC_TEL');
777  } elseif ($key == 'fax') {
778  print dol_print_phone($object->fax, '', 0, $object->id, 'AC_FAX');
779  } else {
780  print $warehouse->showOutputField($val, $key, $object->$key, '');
781  }
782  print '</td>';
783  if (!$i) {
784  $totalarray['nbfield']++;
785  }
786  if (!empty($val['isameasure']) && $val['isameasure'] == 1) {
787  if (!$i) {
788  $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key;
789  }
790  if (!isset($totalarray['val'])) {
791  $totalarray['val'] = array();
792  }
793  if (!isset($totalarray['val']['t.'.$key])) {
794  $totalarray['val']['t.'.$key] = 0;
795  }
796  $totalarray['val']['t.'.$key] += $object->$key;
797  }
798  }
799  }
800 
801  // Stock qty
802  if (!empty($arrayfields["stockqty"]['checked'])) {
803  print '<td class="right">'.price(price2num($obj->stockqty, 'MS')).'</td>';
804  if (!$i) {
805  $totalarray['nbfield']++;
806  }
807  if (!$i) {
808  $totalarray['pos'][$totalarray['nbfield']] = 'stockqty';
809  }
810  }
811 
812  // PMP value
813  if (!empty($arrayfields["estimatedvalue"]['checked'])) {
814  print '<td class="right">';
815  if (price2num($obj->estimatedvalue, 'MT')) {
816  print '<span class="amount">'.price(price2num($obj->estimatedvalue, 'MT'), 1).'</span>';
817  } else {
818  print '';
819  }
820  print '</td>';
821  if (!$i) {
822  $totalarray['nbfield']++;
823  }
824  if (!$i) {
825  $totalarray['pos'][$totalarray['nbfield']] = 'estimatedvalue';
826  }
827  }
828 
829  // Selling value
830  if (!empty($arrayfields["estimatedstockvaluesell"]['checked'])) {
831  print '<td class="right">';
832  if (empty($conf->global->PRODUIT_MULTIPRICES)) {
833  if ($obj->sellvalue) {
834  print '<span class="amount">'.price(price2num($obj->sellvalue, 'MT'), 1).'</span>';
835  }
836  } else {
837  $htmltext = $langs->trans("OptionMULTIPRICESIsOn");
838  print $form->textwithtooltip('<span class="opacitymedium">'.$langs->trans("Variable").'</span>', $htmltext);
839  }
840  print '</td>';
841  if (!$i) {
842  $totalarray['nbfield']++;
843  }
844  if (!$i) {
845  $totalarray['pos'][$totalarray['nbfield']] = 'estimatedstockvaluesell';
846  }
847  }
848 
849  // Extra fields
850  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
851  // Fields from hook
852  $parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
853  $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
854  print $hookmanager->resPrint;
855 
856  // Status
857  if (!empty($arrayfields['t.statut']['checked'])) {
858  print '<td class="center">'.$warehouse->LibStatut($obj->statut, 5).'</td>';
859  if (!$i) {
860  $totalarray['nbfield']++;
861  }
862  }
863 
864  // Action column
865  if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
866  print '<td class="nowrap center">';
867  if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
868  $selected = 0;
869  if (in_array($object->id, $arrayofselected)) {
870  $selected = 1;
871  }
872  print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
873  }
874  print '</td>';
875  if (!$i) {
876  $totalarray['nbfield']++;
877  }
878  }
879 
880  print '</tr>'."\n";
881  }
882 
883  $i++;
884 }
885 
886 if ($totalnboflines - $offset <= $limit) {
887  // Show total line
888  include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
889 }
890 
891 // If no record found
892 if ($num == 0) {
893  $colspan = 1;
894  foreach ($arrayfields as $key => $val) {
895  if (!empty($val['checked'])) {
896  $colspan++;
897  }
898  }
899  print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
900 }
901 
902 $db->free($resql);
903 
904 $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
905 $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook
906 print $hookmanager->resPrint;
907 
908 print '</table>'."\n";
909 print '</div>'."\n";
910 
911 print '</form>'."\n";
912 
913 if (in_array('builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords === '' || $nbtotalofrecords)) {
914  $hidegeneratedfilelistifempty = 1;
915  if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
916  $hidegeneratedfilelistifempty = 0;
917  }
918 
919  require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
920  $formfile = new FormFile($db);
921 
922  // Show list of available documents
923  $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
924  $urlsource .= str_replace('&amp;', '&', $param);
925 
926  $filedir = $diroutputmassaction;
927  $genallowed = $user->rights->stock->lire;
928  $delallowed = $user->rights->stock->creer;
929 
930  print $formfile->showdocuments('massfilesarea_stock', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
931 }
932 
933 // End of page
934 llxFooter();
935 $db->close();
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
Definition: agenda.php:118
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:56
llxFooter()
Empty footer.
Definition: wrapper.php:70
Class to manage warehouses.
Class to manage standard extra fields.
Class to generate html code for admin pages.
Class to manage forms for categories.
Class to offer components to list and upload files.
Class to manage generation of HTML components Only common components must be here.
if(isModEnabled('facture') && $user->hasRight('facture', 'lire')) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') && $user->hasRight('don', 'lire')) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $sql
Social contributions to pay.
Definition: index.php:746
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
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...
dol_print_phone($phone, $countrycode='', $cid=0, $socid=0, $addlink='', $separ="&nbsp;", $withpicto='', $titlealt='', $adddivfloat=0)
Format phone numbers according to country.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by second index function, which produces ascending (default) or descending output...
dol_eval($s, $returnvalue=0, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get title line of an array.
dolGetButtonTitleSeparator($moreClass="")
Add space between dolGetButtonTitle.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.