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