dolibarr  13.0.2
mo_list.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2007-2017 Laurent Destailleur <eldy@users.sourceforge.net>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
24 // Load Dolibarr environment
25 require '../main.inc.php';
26 
27 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
28 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
29 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
30 
31 // load mrp libraries
32 require_once __DIR__.'/class/mo.class.php';
33 
34 // for other modules
35 //dol_include_once('/othermodule/class/otherobject.class.php');
36 
37 // Load translation files required by the page
38 $langs->loadLangs(array("mrp", "other"));
39 
40 $action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', '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') : 'molist'; // 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 
50 $id = GETPOST('id', 'int');
51 
52 // Load variable for pagination
53 $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
54 $sortfield = GETPOST('sortfield', 'aZ09comma');
55 $sortorder = GETPOST('sortorder', 'aZ09comma');
56 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
57 if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action
58 $offset = $limit * $page;
59 $pageprev = $page - 1;
60 $pagenext = $page + 1;
61 //if (! $sortfield) $sortfield="p.date_fin";
62 //if (! $sortorder) $sortorder="DESC";
63 
64 // Initialize technical objects
65 $object = new Mo($db);
66 $extrafields = new ExtraFields($db);
67 $diroutputmassaction = $conf->mrp->dir_output.'/temp/massgeneration/'.$user->id;
68 $hookmanager->initHooks(array('molist')); // Note that conf->hooks_modules contains array
69 
70 // Fetch optionals attributes and labels
71 $extrafields->fetch_name_optionals_label($object->table_element);
72 
73 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
74 
75 // Default sort order (if not yet defined by previous GETPOST)
76 if (!$sortfield) $sortfield = "t.ref"; // Set here default search field. By default 1st field in definition.
77 if (!$sortorder) $sortorder = "ASC";
78 
79 // Security check
80 if (empty($conf->mrp->enabled)) accessforbidden('Module not enabled');
81 $socid = 0;
82 if ($user->socid > 0) // Protection if external user
83 {
84  //$socid = $user->socid;
86 }
87 //$result = restrictedArea($user, 'mrp', $id, '');
88 
89 
90 // Initialize array of search criterias
91 $search_all = GETPOST('search_all', 'alphanohtml') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml');
92 $search = array();
93 foreach ($object->fields as $key => $val)
94 {
95  if (GETPOST('search_'.$key, 'alpha') !== '') $search[$key] = GETPOST('search_'.$key, 'alpha');
96 }
97 
98 // List of fields to search into when doing a "search in all"
99 $fieldstosearchall = array();
100 foreach ($object->fields as $key => $val)
101 {
102  if ($val['searchall']) $fieldstosearchall['t.'.$key] = $val['label'];
103 }
104 
105 // Definition of fields for list
106 $arrayfields = array();
107 foreach ($object->fields as $key => $val)
108 {
109  // If $val['visible']==0, then we never show the field
110  if (!empty($val['visible'])) $arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>($val['enabled'] && ($val['visible'] != 3)), 'position'=>$val['position']);
111 }
112 // Extra fields
113 if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0)
114 {
115  foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val)
116  {
117  if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) {
118  $arrayfields["ef.".$key] = array(
119  'label'=>$extrafields->attributes[$object->table_element]['label'][$key],
120  'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1),
121  'position'=>$extrafields->attributes[$object->table_element]['pos'][$key],
122  'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])
123  );
124  }
125  }
126 }
127 $object->fields = dol_sort_array($object->fields, 'position');
128 $arrayfields = dol_sort_array($arrayfields, 'position');
129 
130 $permissiontoread = $user->rights->mrp->read;
131 $permissiontoadd = $user->rights->mrp->write;
132 $permissiontodelete = $user->rights->mrp->delete;
133 
134 
135 /*
136  * Actions
137  */
138 
139 if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; }
140 if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; }
141 
142 $parameters = array();
143 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
144 if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
145 
146 if (empty($reshook))
147 {
148  // Selection of new fields
149  include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
150 
151  // Purge search criteria
152  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
153  {
154  foreach ($object->fields as $key => $val)
155  {
156  $search[$key] = '';
157  }
158  $toselect = '';
159  $search_array_options = array();
160  }
161  if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
162  || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha'))
163  {
164  $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
165  }
166 
167  // Mass actions
168  $objectclass = 'Mo';
169  $objectlabel = 'Mo';
170  $uploaddir = $conf->mrp->dir_output;
171  include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
172 }
173 
174 
175 
176 /*
177  * View
178  */
179 
180 $form = new Form($db);
181 
182 $now = dol_now();
183 
184 //$help_url="EN:Module_Mo|FR:Module_Mo_FR|ES:Módulo_Mo";
185 $help_url = '';
186 $title = $langs->trans('ListOfManufacturingOrders');
187 
188 
189 // Build and execute select
190 // --------------------------------------------------------------------
191 $sql = 'SELECT ';
192 foreach ($object->fields as $key => $val)
193 {
194  $sql .= 't.'.$key.', ';
195 }
196 // Add fields from extrafields
197 if (!empty($extrafields->attributes[$object->table_element]['label'])) {
198  foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : '');
199 }
200 // Add fields from hooks
201 $parameters = array();
202 $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook
203 $sql .= preg_replace('/^,/', '', $hookmanager->resPrint);
204 $sql = preg_replace('/,\s*$/', '', $sql);
205 $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t";
206 if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)";
207 if ($object->ismultientitymanaged == 1) $sql .= " WHERE t.entity IN (".getEntity($object->element).")";
208 else $sql .= " WHERE 1 = 1";
209 foreach ($search as $key => $val)
210 {
211  if ($key == 'status' && $search[$key] == -1) continue;
212  $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0);
213  if (strpos($object->fields[$key]['type'], 'integer:') === 0) {
214  if ($search[$key] == '-1') $search[$key] = '';
215  $mode_search = 2;
216  }
217  if ($search[$key] != '') $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search));
218 }
219 if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
220 //$sql.= dolSqlDateFilter("t.field", $search_xxxday, $search_xxxmonth, $search_xxxyear);
221 // Add where from extra fields
222 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
223 // Add where from hooks
224 $parameters = array();
225 $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook
226 $sql .= $hookmanager->resPrint;
227 
228 /* If a group by is required
229 $sql.= " GROUP BY "
230 foreach($object->fields as $key => $val)
231 {
232  $sql.='t.'.$key.', ';
233 }
234 // Add fields from extrafields
235 if (! empty($extrafields->attributes[$object->table_element]['label'])) {
236  foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.', ' : '');
237 }
238 // Add where from hooks
239 $parameters=array();
240 $reshook=$hookmanager->executeHooks('printFieldListGroupBy',$parameters); // Note that $action and $object may have been modified by hook
241 $sql.=$hookmanager->resPrint;
242 $sql=preg_replace('/,\s*$/','', $sql);
243 */
244 
245 $sql .= $db->order($sortfield, $sortorder);
246 
247 // Count total nb of records
248 $nbtotalofrecords = '';
249 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
250 {
251  $resql = $db->query($sql);
252  $nbtotalofrecords = $db->num_rows($resql);
253  if (($page * $limit) > $nbtotalofrecords) // if total of record found is smaller than page * limit, goto and load page 0
254  {
255  $page = 0;
256  $offset = 0;
257  }
258 }
259 // if total of record found is smaller than limit, no need to do paging and to restart another select with limits set.
260 if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit)))
261 {
262  $num = $nbtotalofrecords;
263 } else {
264  if ($limit) $sql .= $db->plimit($limit + 1, $offset);
265 
266  $resql = $db->query($sql);
267  if (!$resql)
268  {
269  dol_print_error($db);
270  exit;
271  }
272 
273  $num = $db->num_rows($resql);
274 }
275 
276 // Direct jump if only one record found
277 if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page)
278 {
279  $obj = $db->fetch_object($resql);
280  $id = $obj->rowid;
281  header("Location: ".dol_buildpath('/mrp/mo_card.php', 1).'?id='.$id);
282  exit;
283 }
284 
285 
286 // Output page
287 // --------------------------------------------------------------------
288 
289 llxHeader('', $title, $help_url);
290 
291 // Example : Adding jquery code
292 print '<script type="text/javascript" language="javascript">
293 jQuery(document).ready(function() {
294  function init_myfunc()
295  {
296  jQuery("#myid").removeAttr(\'disabled\');
297  jQuery("#myid").attr(\'disabled\',\'disabled\');
298  }
299  init_myfunc();
300  jQuery("#mybutton").click(function() {
301  init_myfunc();
302  });
303 });
304 </script>';
305 
306 $arrayofselected = is_array($toselect) ? $toselect : array();
307 
308 $param = '';
309 if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
310 if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
311 foreach ($search as $key => $val)
312 {
313  if (is_array($search[$key]) && count($search[$key])) foreach ($search[$key] as $skey) $param .= '&search_'.$key.'[]='.urlencode($skey);
314  else $param .= '&search_'.$key.'='.urlencode($search[$key]);
315 }
316 if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
317 // Add $param from extra fields
318 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
319 
320 // List of mass actions available
321 $arrayofmassactions = array(
322  //'validate'=>$langs->trans("Validate"),
323  //'generate_doc'=>$langs->trans("ReGeneratePDF"),
324  //'builddoc'=>$langs->trans("PDFMerge"),
325  //'presend'=>$langs->trans("SendByMail"),
326 );
327 if ($permissiontodelete) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
328 if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array();
329 $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
330 
331 print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
332 if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
333 print '<input type="hidden" name="token" value="'.newToken().'">';
334 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
335 print '<input type="hidden" name="action" value="list">';
336 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
337 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
338 print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
339 
340 $newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/mrp/mo_card.php?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $permissiontoadd);
341 
342 print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'mrp', 0, $newcardbutton, '', $limit, 0, 0, 1);
343 
344 // Add code for pre mass action (confirmation or email presend form)
345 $topicmail = "SendMoRef";
346 $modelmail = "mo";
347 $objecttmp = new Mo($db);
348 $trackid = 'mo'.$object->id;
349 include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
350 
351 if ($search_all)
352 {
353  foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val);
354  print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>';
355 }
356 
357 $moreforfilter = '';
358 /*$moreforfilter.='<div class="divsearchfield">';
359 $moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escape_htmltag($search_myfield).'">';
360 $moreforfilter.= '</div>';*/
361 
362 $parameters = array();
363 $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
364 if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint;
365 else $moreforfilter = $hookmanager->resPrint;
366 
367 if (!empty($moreforfilter))
368 {
369  print '<div class="liste_titre liste_titre_bydiv centpercent">';
370  print $moreforfilter;
371  print '</div>';
372 }
373 
374 $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
375 $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
376 $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
377 
378 print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
379 print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
380 
381 
382 // Fields title search
383 // --------------------------------------------------------------------
384 print '<tr class="liste_titre">';
385 foreach ($object->fields as $key => $val)
386 {
387  $cssforfield = (empty($val['css']) ? '' : $val['css']);
388  if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center';
389  elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center';
390  elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
391  elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right';
392  if (!empty($arrayfields['t.'.$key]['checked']))
393  {
394  print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').'">';
395  if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1);
396  elseif (strpos($val['type'], 'integer:') === 0) {
397  print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth125', 1);
398  } elseif (!preg_match('/^(date|timestamp)/', $val['type'])) print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'">';
399  print '</td>';
400  }
401 }
402 // Extra fields
403 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
404 
405 // Fields from hook
406 $parameters = array('arrayfields'=>$arrayfields);
407 $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook
408 print $hookmanager->resPrint;
409 // Action column
410 print '<td class="liste_titre maxwidthsearch">';
411 $searchpicto = $form->showFilterButtons();
412 print $searchpicto;
413 print '</td>';
414 print '</tr>'."\n";
415 
416 
417 // Fields title label
418 // --------------------------------------------------------------------
419 print '<tr class="liste_titre">';
420 foreach ($object->fields as $key => $val)
421 {
422  $cssforfield = (empty($val['css']) ? '' : $val['css']);
423  if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center';
424  elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center';
425  elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
426  elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right';
427  if (!empty($arrayfields['t.'.$key]['checked']))
428  {
429  print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n";
430  }
431 }
432 // Extra fields
433 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
434 // Hook fields
435 $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
436 $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
437 print $hookmanager->resPrint;
438 // Action column
439 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
440 print '</tr>'."\n";
441 
442 
443 // Detect if we need a fetch on each output line
444 $needToFetchEachLine = 0;
445 if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0)
446 {
447  foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val)
448  {
449  if (preg_match('/\$object/', $val)) $needToFetchEachLine++; // There is at least one compute field that use $object
450  }
451 }
452 
453 
454 // Loop on record
455 // --------------------------------------------------------------------
456 $i = 0;
457 $totalarray = array();
458 while ($i < ($limit ? min($num, $limit) : $num))
459 {
460  $obj = $db->fetch_object($resql);
461  if (empty($obj)) break; // Should not happen
462 
463  // Store properties in $object
464  $object->setVarsFromFetchObj($obj);
465 
466  // Show here line of result
467  print '<tr class="oddeven">';
468  foreach ($object->fields as $key => $val)
469  {
470  $cssforfield = (empty($val['css']) ? '' : $val['css']);
471  if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center';
472  elseif ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center';
473 
474  if (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
475  elseif ($key == 'ref') $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
476 
477  if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'status') $cssforfield .= ($cssforfield ? ' ' : '').'right';
478  if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100';
479 
480  if (!empty($arrayfields['t.'.$key]['checked']))
481  {
482  print '<td'.($cssforfield ? ' class="'.$cssforfield.'"' : '').'>';
483  if ($key == 'status') print $object->getLibStatut(5);
484  else print $object->showOutputField($val, $key, $object->$key, '');
485  print '</td>';
486  if (!$i) $totalarray['nbfield']++;
487  if (!empty($val['isameasure']))
488  {
489  if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key;
490  $totalarray['val']['t.'.$key] += $object->$key;
491  }
492  }
493  }
494  // Extra fields
495  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
496  // Fields from hook
497  $parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
498  $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook
499  print $hookmanager->resPrint;
500  // Action column
501  print '<td class="nowrap center">';
502  if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
503  {
504  $selected = 0;
505  if (in_array($object->id, $arrayofselected)) $selected = 1;
506  print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
507  }
508  print '</td>';
509  if (!$i) $totalarray['nbfield']++;
510 
511  print '</tr>'."\n";
512 
513  $i++;
514 }
515 
516 // Show total line
517 include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
518 
519 
520 // If no record found
521 if ($num == 0)
522 {
523  $colspan = 1;
524  foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; }
525  print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
526 }
527 
528 
529 $db->free($resql);
530 
531 $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
532 $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook
533 print $hookmanager->resPrint;
534 
535 print '</table>'."\n";
536 print '</div>'."\n";
537 
538 print '</form>'."\n";
539 
540 if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords))
541 {
542  $hidegeneratedfilelistifempty = 1;
543  if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0;
544 
545  require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
546  $formfile = new FormFile($db);
547 
548  // Show list of available documents
549  $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
550  $urlsource .= str_replace('&amp;', '&', $param);
551 
552  $filedir = $diroutputmassaction;
553  $genallowed = $permissiontoread;
554  $delallowed = $permissiontoadd;
555 
556  print $formfile->showdocuments('massfilesarea_mrp', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
557 }
558 
559 // End of page
560 llxFooter();
561 $db->close();
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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.
foreach($object->fields as $key=> $val) if(is_array($extrafields->attributes[$object->table_element]['label'])&&count($extrafields->attributes[$object->table_element]['label']) > 0) $object fields
dol_now($mode= 'auto')
Return date for now.
Class for Mo.
Definition: mo.class.php:34
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition: repair.php:108
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
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...
llxHeader()
Empty header.
Definition: wrapper.php:45
Class to manage standard extra fields.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
print_barre_liste($titre, $page, $file, $options= '', $sortfield= '', $sortorder= '', $morehtmlcenter= '', $num=-1, $totalnboflines= '', $picto= 'generic', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow= '')
Print a title with navigation controls for pagination.
Class to manage generation of HTML components Only common components must be here.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
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 ...
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...
Class to offer components to list and upload files.
print $_SERVER["PHP_SELF"]
Edit parameters.
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...
print
Draft customers invoices.
Definition: index.php:89
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1232
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
print $_SERVER["PHP_SELF"] n
Edit parameters.
Definition: categories.php:101
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip= '', $forcenowrapcolumntitle=0)
Get title line of an array.
llxFooter()
Empty footer.
Definition: wrapper.php:59
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
Definition: repair.php:105
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $keepmoretags= '', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...