dolibarr  13.0.2
hook_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) 2019 Frédéric France <frederic.france@netlogic.fr>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
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.'/zapier/class/hook.class.php';
32 
33 // Load translation files required by the page
34 $langs->loadLangs(array("zapier", "other"));
35 
36 // The action 'add', 'create', 'edit', 'update', 'view', ...
37 $action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view';
38 // The bulk action (combo box choice into lists)
39 $massaction = GETPOST('massaction', 'alpha');
40 $show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ?
41 $confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation
42 $cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button
43 $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list
44 $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'zapierlist'; // To manage different context of search
45 $backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
46 $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
47 
48 $id = GETPOST('id', 'int');
49 
50 // Load variable for pagination
51 $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
52 $sortfield = GETPOST('sortfield', 'aZ09comma');
53 $sortorder = GETPOST('sortorder', 'aZ09comma');
54 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : (int) GETPOST("page", 'int');
55 if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) {
56  // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action
57  $page = 0;
58 }
59 $offset = $limit * $page;
60 $pageprev = $page - 1;
61 $pagenext = $page + 1;
62 //if (! $sortfield) $sortfield="p.date_fin";
63 //if (! $sortorder) $sortorder="DESC";
64 
65 // Initialize technical objects
66 $object = new Hook($db);
67 $extrafields = new ExtraFields($db);
68 $diroutputmassaction = $conf->zapier->dir_output.'/temp/massgeneration/'.$user->id;
69 // Note that conf->hooks_modules contains array
70 $hookmanager->initHooks(array('zapierhooklist'));
71 
72 // Fetch optionals attributes and labels
73 $extrafields->fetch_name_optionals_label($object->table_element);
74 
75 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
76 
77 // Default sort order (if not yet defined by previous GETPOST)
78 if (!$sortfield) {
79  // Set here default search field. By default 1st field in definition.
80  $sortfield = "t.".key($object->fields);
81 }
82 if (!$sortorder) {
83  $sortorder = "ASC";
84 }
85 
86 // Security check
87 $socid = 0;
88 if ($user->socid > 0) {
89  // Protection if external user
90  //$socid = $user->socid;
92 }
93 //$result = restrictedArea($user, 'zapier', $id, '');
94 
95 // Initialize array of search criterias
96 $search_all = GETPOST("search_all", 'alpha');
97 $search = array();
98 foreach ($object->fields as $key => $val) {
99  if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha');
100 }
101 
102 // List of fields to search into when doing a "search in all"
103 $fieldstosearchall = array();
104 foreach ($object->fields as $key => $val) {
105  if ($val['searchall']) $fieldstosearchall['t.'.$key] = $val['label'];
106 }
107 
108 // Definition of fields for list
109 $arrayfields = array();
110 foreach ($object->fields as $key => $val) {
111  // If $val['visible']==0, then we never show the field
112  if (!empty($val['visible'])) $arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>$val['enabled'], 'position'=>$val['position']);
113 }
114 // Extra fields
115 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
116 
117 $object->fields = dol_sort_array($object->fields, 'position');
118 $arrayfields = dol_sort_array($arrayfields, 'position');
119 
120 
121 
122 /*
123  * Actions
124  */
125 
126 if (GETPOST('cancel', 'alpha')) {
127  $action = 'list';
128  $massaction = '';
129 }
130 if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
131  $massaction = '';
132 }
133 
134 $parameters = array();
135 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
136 if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
137 
138 if (empty($reshook)) {
139  // Selection of new fields
140  include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
141 
142  // Purge search criteria
143  if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
144  // 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 = 'Hook';
158  $objectlabel = 'Hook';
159  $permissiontoread = $user->rights->zapier->read;
160  $permissiontodelete = $user->rights->zapier->delete;
161  $uploaddir = $conf->zapier->dir_output;
162  include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
163 }
164 
165 
166 
167 /*
168  * View
169  */
170 
171 $form = new Form($db);
172 
173 $now = dol_now();
174 
175 //$help_url="EN:Module_Hook|FR:Module_Hook_FR|ES:Módulo_Hook";
176 $help_url = '';
177 $title = $langs->trans('ListOf', $langs->transnoentitiesnoconv("Hooks"));
178 
179 
180 // Build and execute select
181 // --------------------------------------------------------------------
182 $sql = 'SELECT ';
183 foreach ($object->fields as $key => $val) {
184  $sql .= 't.'.$key.', ';
185 }
186 // Add fields from extrafields
187 if (!empty($extrafields->attributes[$object->table_element]['label'])) {
188  foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
189  $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : '');
190  }
191 }
192 // Add fields from hooks
193 $parameters = array();
194 $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook
195 $sql .= $hookmanager->resPrint;
196 $sql = preg_replace('/, $/', '', $sql);
197 $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t";
198 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)";
199 if ($object->ismultientitymanaged == 1) {
200  $sql .= " WHERE t.entity IN (".getEntity($object->element).")";
201 } else {
202  $sql .= " WHERE 1 = 1";
203 }
204 foreach ($search as $key => $val) {
205  if ($key == 'status' && $search[$key] == -1) {
206  continue;
207  }
208  $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0);
209  if ($search[$key] != '') {
210  $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search));
211  }
212 }
213 if ($search_all) {
214  $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
215 }
216 // Add where from extra fields
217 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
218 // Add where from hooks
219 $parameters = array();
220 $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook
221 $sql .= $hookmanager->resPrint;
222 
223 /* If a group by is required
224 $sql.= " GROUP BY "
225 foreach($object->fields as $key => $val)
226 {
227  $sql.='t.'.$key.', ';
228 }
229 // Add fields from extrafields
230 if (! empty($extrafields->attributes[$object->table_element]['label'])) {
231  foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.', ' : '');
232 // Add where from hooks
233 $parameters=array();
234 $reshook=$hookmanager->executeHooks('printFieldListGroupBy',$parameters); // Note that $action and $object may have been modified by hook
235 $sql.=$hookmanager->resPrint;
236 $sql=preg_replace('/, $/','', $sql);
237 */
238 
239 $sql .= $db->order($sortfield, $sortorder);
240 
241 // Count total nb of records
242 $nbtotalofrecords = '';
243 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
244  $resql = $db->query($sql);
245  $nbtotalofrecords = $db->num_rows($resql);
246  if (($page * $limit) > $nbtotalofrecords) {
247  // if total of record found is smaller than page * limit, goto and load page 0
248  $page = 0;
249  $offset = 0;
250  }
251 }
252 // if total of record found is smaller than limit, no need to do paging and to restart another select with limits set.
253 if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) {
254  $num = $nbtotalofrecords;
255 } else {
256  $sql .= $db->plimit($limit + 1, $offset);
257 
258  $resql = $db->query($sql);
259  if (!$resql) {
260  dol_print_error($db);
261  exit;
262  }
263 
264  $num = $db->num_rows($resql);
265 }
266 
267 // Direct jump if only one record found
268 if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) {
269  $obj = $db->fetch_object($resql);
270  $id = $obj->rowid;
271  header("Location: ".dol_buildpath('/zapierfordolibarr/hook_card.php', 1).'?id='.$id);
272  exit;
273 }
274 
275 
276 // Output page
277 // --------------------------------------------------------------------
278 
279 llxHeader('', $title, $help_url);
280 
281 // Example : Adding jquery code
282 // print '<script type="text/javascript" language="javascript">
283 // jQuery(document).ready(function() {
284 // function init_myfunc()
285 // {
286 // jQuery("#myid").removeAttr(\'disabled\');
287 // jQuery("#myid").attr(\'disabled\',\'disabled\');
288 // }
289 // init_myfunc();
290 // jQuery("#mybutton").click(function() {
291 // init_myfunc();
292 // });
293 // });
294 // </script>';
295 
296 $arrayofselected = is_array($toselect) ? $toselect : array();
297 
298 $param = '';
299 if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
300 if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
301 foreach ($search as $key => $val) {
302  if (is_array($search[$key]) && count($search[$key])) {
303  foreach ($search[$key] as $skey) {
304  $param .= '&search_'.$key.'[]='.urlencode($skey);
305  }
306  } else {
307  $param .= '&search_'.$key.'='.urlencode($search[$key]);
308  }
309 }
310 if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
311 // Add $param from extra fields
312 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
313 
314 // List of mass actions available
315 $arrayofmassactions = array(
316  //'presend'=>$langs->trans("SendByMail"),
317  //'builddoc'=>$langs->trans("PDFMerge"),
318 );
319 if ($user->rights->zapier->delete) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
320 if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array();
321 $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
322 
323 print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
324 if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
325 print '<input type="hidden" name="token" value="'.newToken().'">';
326 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
327 print '<input type="hidden" name="action" value="list">';
328 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
329 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
330 print '<input type="hidden" name="page" value="'.$page.'">';
331 print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
332 
333 $newcardbutton = '';
334 //if ($user->rights->zapier->creer)
335 //{
336  $newcardbutton = '<a class="butActionNew" href="hook_card.php?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']).'"><span class="valignmiddle text-plus-circle">'.$langs->trans('New').'</span>';
337  $newcardbutton .= '<span class="fa fa-plus-circle valignmiddle"></span>';
338  $newcardbutton .= '</a>';
339 //}
340 //else
341 //{
342 // $newcardbutton='<a class="butActionNewRefused" href="#"><span class="valignmiddle text-plus-circle">'.$langs->trans('New').'</span>;
343 // $newcardbutton.= '<span class="fa fa-plus-circle valignmiddle"></span>';
344 // $newcardbutton.= '</a>';
345 //}
346 
347 print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_companies', 0, $newcardbutton, '', $limit);
348 
349 // Add code for pre mass action (confirmation or email presend form)
350 $topicmail = "SendHookRef";
351 $modelmail = "hook";
352 $objecttmp = new Hook($db);
353 $trackid = 'zapier'.$object->id;
354 include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
355 
356 if ($sall) {
357  foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val);
358  print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>';
359 }
360 
361 $moreforfilter = '';
362 /*$moreforfilter.='<div class="divsearchfield">';
363 $moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escape_htmltag($search_myfield).'">';
364 $moreforfilter.= '</div>';*/
365 
366 $parameters = array();
367 $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
368 if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint;
369 else $moreforfilter = $hookmanager->resPrint;
370 
371 if (!empty($moreforfilter)) {
372  print '<div class="liste_titre liste_titre_bydiv centpercent">';
373  print $moreforfilter;
374  print '</div>';
375 }
376 
377 $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
378 $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
379 $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
380 
381 print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
382 print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
383 
384 
385 // Fields title search
386 // --------------------------------------------------------------------
387 print '<tr class="liste_titre">';
388 foreach ($object->fields as $key => $val) {
389  $cssforfield = '';
390  if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
391  $cssforfield .= ($cssforfield ? ' ' : '').'center';
392  }
393  if (in_array($val['type'], array('timestamp'))) {
394  $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
395  }
396  if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real'))) {
397  $cssforfield .= ($cssforfield ? ' ' : '').'right';
398  }
399  if ($key == 'status') {
400  $cssforfield .= ($cssforfield ? ' ' : '').'center';
401  }
402  if (!empty($arrayfields['t.'.$key]['checked'])) {
403  print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').'"><input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'"></td>';
404  }
405 }
406 // Extra fields
407 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
408 
409 // Fields from hook
410 $parameters = array('arrayfields'=>$arrayfields);
411 $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook
412 print $hookmanager->resPrint;
413 // Action column
414 print '<td class="liste_titre right">';
415 $searchpicto = $form->showFilterButtons();
416 print $searchpicto;
417 print '</td>';
418 print '</tr>'."\n";
419 
420 
421 // Fields title label
422 // --------------------------------------------------------------------
423 print '<tr class="liste_titre">';
424 foreach ($object->fields as $key => $val) {
425  $cssforfield = '';
426  if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center';
427  if (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
428  if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real'))) $cssforfield .= ($cssforfield ? ' ' : '').'right';
429  if ($key == 'status') {
430  $cssforfield .= ($cssforfield ? ' ' : '').'center';
431  }
432  if (!empty($arrayfields['t.'.$key]['checked'])) {
433  print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n";
434  }
435 }
436 // Extra fields
437 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
438 // Hook fields
439 $parameters = array(
440  'arrayfields' => $arrayfields,
441  'param' => $param,
442  'sortfield' => $sortfield,
443  'sortorder' => $sortorder,
444 );
445 $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
446 print $hookmanager->resPrint;
447 // Action column
448 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
449 print '</tr>'."\n";
450 
451 
452 // Detect if we need a fetch on each output line
453 $needToFetchEachLine = 0;
454 if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) {
455  foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) {
456  if (preg_match('/\$object/', $val)) {
457  // There is at least one compute field that use $object
458  $needToFetchEachLine++;
459  }
460  }
461 }
462 
463 
464 // Loop on record
465 // --------------------------------------------------------------------
466 $i = 0;
467 $totalarray = array();
468 while ($i < min($num, $limit)) {
469  $obj = $db->fetch_object($resql);
470  if (empty($obj)) {
471  break; // Should not happen
472  }
473 
474  // Store properties in $object
475  $object->id = $obj->rowid;
476  foreach ($object->fields as $key => $val) {
477  if (isset($obj->$key)) $object->$key = $obj->$key;
478  }
479 
480  // Show here line of result
481  print '<tr class="oddeven">';
482  foreach ($object->fields as $key => $val) {
483  $cssforfield = '';
484  if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
485  $cssforfield .= ($cssforfield ? ' ' : '').'center';
486  } elseif ($key == 'status') {
487  $cssforfield .= ($cssforfield ? ' ' : '').'center';
488  }
489 
490  if (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
491  elseif ($key == 'ref') $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
492 
493  if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real'))) $cssforfield .= ($cssforfield ? ' ' : '').'right';
494 
495  if (!empty($arrayfields['t.'.$key]['checked'])) {
496  print '<td';
497  if ($cssforfield || $val['css']) print ' class="';
498  print $cssforfield;
499  if ($cssforfield && $val['css']) print ' ';
500  print $val['css'];
501  if ($cssforfield || $val['css']) print '"';
502  print '>';
503  if ($key == 'status') print $object->getLibStatut(5);
504  elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) print $object->showOutputField($val, $key, $db->jdate($obj->$key), '');
505  else print $object->showOutputField($val, $key, $obj->$key, '');
506  print '</td>';
507  if (!$i) $totalarray['nbfield']++;
508  if (!empty($val['isameasure'])) {
509  if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key;
510  $totalarray['val']['t.'.$key] += $obj->$key;
511  }
512  }
513  }
514  // Extra fields
515  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
516  // Fields from hook
517  $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
518  $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook
519  print $hookmanager->resPrint;
520  // Action column
521  print '<td class="nowrap center">';
522  if ($massactionbutton || $massaction) {
523  // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
524  $selected = 0;
525  if (in_array($obj->rowid, $arrayofselected)) $selected = 1;
526  print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
527  }
528  print '</td>';
529  if (!$i) $totalarray['nbfield']++;
530 
531  print '</tr>';
532 
533  $i++;
534 }
535 
536 // Show total line
537 include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
538 
539 
540 // If no record found
541 if ($num == 0) {
542  $colspan = 1;
543  foreach ($arrayfields as $key => $val) {
544  if (!empty($val['checked'])) {
545  $colspan++;
546  }
547  }
548  print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
549 }
550 
551 
552 $db->free($resql);
553 
554 $parameters = array(
555  'arrayfields' => $arrayfields,
556  'sql' => $sql,
557 );
558 $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook
559 print $hookmanager->resPrint;
560 
561 print '</table>'."\n";
562 print '</div>'."\n";
563 
564 print '</form>'."\n";
565 
566 if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) {
567  $hidegeneratedfilelistifempty = 1;
568  if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
569  $hidegeneratedfilelistifempty = 0;
570  }
571 
572  require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
573  $formfile = new FormFile($db);
574 
575  // Show list of available documents
576  $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
577  $urlsource .= str_replace('&amp;', '&', $param);
578 
579  $filedir = $diroutputmassaction;
580  $genallowed = $user->rights->zapier->read;
581  $delallowed = $user->rights->zapier->create;
582 
583  print $formfile->showdocuments('massfilesarea_zapier', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
584 }
585 
586 // End of page
587 llxFooter();
588 $db->close();
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_now($mode= 'auto')
Return date for now.
Class for Hook.
Definition: hook.class.php:29
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
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.
if(!GETPOST('transkey', 'alphanohtml')&&!GETPOST('transphrase', 'alphanohtml')) else
View.
Definition: notice.php:44
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...
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...