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