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