dolibarr  19.0.0-dev
website.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2005 Brice Davoleau <brice.davoleau@gmail.com>
4  * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
5  * Copyright (C) 2006-2015 Laurent Destailleur <eldy@users.sourceforge.net>
6  * Copyright (C) 2007 Patrick Raguin <patrick.raguin@gmail.com>
7  * Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
8  * Copyright (C) 2015 Marcos GarcĂ­a <marcosgdf@gmail.com>
9  * Copyright (C) 2018 Ferran Marcet <fmarcet@2byte.es>
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 3 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program. If not, see <https://www.gnu.org/licenses/>.
23  */
24 
32 // Load Dolibarr environment
33 require '../main.inc.php';
34 require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
35 require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
36 require_once DOL_DOCUMENT_ROOT.'/societe/class/societeaccount.class.php';
37 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
38 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
39 
40 
41 // Load translation files required by the page
42 $langs->loadLangs(array("companies", "website"));
43 
44 
45 // Get parameters
46 $action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ...
47 $show_files = GETPOST('show_files', 'int');
48 $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'websitelist'; // To manage different context of search
49 $backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
50 $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
51 
52 // Security check
53 $id = GETPOST('id', 'int') ?GETPOST('id', 'int') : GETPOST('socid', 'int');
54 if ($user->socid) {
55  $socid = $user->socid;
56 }
57 $result = restrictedArea($user, 'societe', $socid, '&societe');
58 
59 $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
60 $sortfield = GETPOST('sortfield', 'aZ09comma');
61 $sortorder = GETPOST('sortorder', 'aZ09comma');
62 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
63 if (empty($page) || $page == -1) {
64  $page = 0;
65 } // If $page is not defined, or '' or -1
66 $offset = $limit * $page;
67 $pageprev = $page - 1;
68 $pagenext = $page + 1;
69 if (!$sortfield) {
70  $sortfield = 't.login';
71 }
72 if (!$sortorder) {
73  $sortorder = 'ASC';
74 }
75 
76 // Initialize technical objects
77 $object = new Societe($db);
78 $objectwebsiteaccount = new SocieteAccount($db);
79 $extrafields = new ExtraFields($db);
80 $diroutputmassaction = $conf->website->dir_output.'/temp/massgeneration/'.$user->id;
81 $hookmanager->initHooks(array('websitethirdpartylist')); // Note that conf->hooks_modules contains array
82 
83 // Fetch optionals attributes and labels
84 $extrafields->fetch_name_optionals_label($objectwebsiteaccount->table_element);
85 
86 $search_array_options = $extrafields->getOptionalsFromPost($objectwebsiteaccount->table_element, '', 'search_');
87 
88 unset($objectwebsiteaccount->fields['fk_soc']); // Remove this field, we are already on the thirdparty
89 
90 // Initialize array of search criterias
91 $search_all = GETPOST("search_all", 'alpha');
92 $search = array();
93 foreach ($objectwebsiteaccount->fields as $key => $val) {
94  if (GETPOST('search_'.$key, 'alpha')) {
95  $search[$key] = GETPOST('search_'.$key, 'alpha');
96  }
97 }
98 
99 // List of fields to search into when doing a "search in all"
100 $fieldstosearchall = array();
101 foreach ($objectwebsiteaccount->fields as $key => $val) {
102  if (!empty($val['searchall'])) {
103  $fieldstosearchall['t.'.$key] = $val['label'];
104  }
105 }
106 
107 // Definition of fields for list
108 $arrayfields = array();
109 foreach ($objectwebsiteaccount->fields as $key => $val) {
110  // If $val['visible']==0, then we never show the field
111  if (!empty($val['visible'])) {
112  $arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>$val['enabled']);
113  }
114 }
115 
116 // Extra fields
117 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
118 
119 $object->fields = dol_sort_array($object->fields, 'position');
120 $arrayfields = dol_sort_array($arrayfields, 'position');
121 
122 
123 if ($id > 0) {
124  $result = $object->fetch($id);
125 }
126 
127 
128 /*
129  * Actions
130  */
131 
132 $parameters = array('id'=>$socid);
133 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
134 if ($reshook < 0) {
135  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
136 }
137 
138 if (empty($reshook)) {
139  // Cancel
140  if (GETPOST('cancel', 'alpha') && !empty($backtopage)) {
141  header("Location: ".$backtopage);
142  exit;
143  }
144 
145  // Selection of new fields
146  include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
147 
148  // Purge search criteria
149  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
150  foreach ($objectwebsiteaccount->fields as $key => $val) {
151  $search[$key] = '';
152  }
153  $toselect = array();
154  $search_array_options = array();
155  }
156  if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
157  || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) {
158  $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
159  }
160 
161  // Mass actions
162  $objectclass = 'WebsiteAccount';
163  $objectlabel = 'WebsiteAccount';
164  $permissiontoread = $user->hasRight('societe', 'lire');
165  $permissiontodelete = $user->hasRight('societe', 'supprimer');
166  $uploaddir = $conf->societe->multidir_output[$object->entity];
167  include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
168 }
169 
170 
171 
172 /*
173  * View
174  */
175 
176 $contactstatic = new Contact($db);
177 
178 $form = new Form($db);
179 
180 $langs->load("companies");
181 
182 $title = $langs->trans("WebsiteAccounts");
183 llxHeader('', $title);
184 
185 $param = '';
186 if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
187  $param .= '&contextpage='.urlencode($contextpage);
188 }
189 if ($id > 0) {
190  $param .= '&id='.urlencode($id);
191 }
192 if ($limit > 0 && $limit != $conf->liste_limit) {
193  $param .= '&limit='.((int) $limit);
194 }
195 foreach ($search as $key => $val) {
196  $param .= '&search_'.$key.'='.urlencode($search[$key]);
197 }
198 if ($optioncss != '') {
199  $param .= '&optioncss='.urlencode($optioncss);
200 }
201 // Add $param from extra fields
202 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
203 
204 $head = societe_prepare_head($object);
205 
206 print dol_get_fiche_head($head, 'website', $langs->trans("ThirdParty"), - 1, 'company');
207 
208 $linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
209 
210 dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom');
211 
212 print '<div class="fichecenter">';
213 
214 print '<div class="underbanner clearboth"></div>';
215 
216 print '<table class="border centpercent">';
217 
218 // Prefix
219 if (!empty($conf->global->SOCIETE_USEPREFIX)) { // Old not used prefix field
220  print '<tr><td class="titlefield">'.$langs->trans('Prefix').'</td><td colspan="3">'.$object->prefix_comm.'</td></tr>';
221 }
222 
223 if ($object->client) {
224  print '<tr><td class="titlefield">';
225  print $langs->trans('CustomerCode').'</td><td colspan="3">';
226  print $object->code_client;
227  $tmpcheck = $object->check_codeclient();
228  if ($tmpcheck != 0 && $tmpcheck != -5) {
229  print ' <span class="error">('.$langs->trans("WrongCustomerCode").')</span>';
230  }
231  print '</td></tr>';
232 }
233 
234 if ($object->fournisseur) {
235  print '<tr><td class="titlefield">';
236  print $langs->trans('SupplierCode').'</td><td colspan="3">';
237  print $object->code_fournisseur;
238  $tmpcheck = $object->check_codefournisseur();
239  if ($tmpcheck != 0 && $tmpcheck != -5) {
240  print ' <span class="error">('.$langs->trans("WrongSupplierCode").')</span>';
241  }
242  print '</td></tr>';
243 }
244 
245 print '</table>';
246 
247 print '</div>';
248 
249 print dol_get_fiche_end();
250 
251 $newcardbutton = '';
252 if (isModEnabled('website')) {
253  if ($user->hasRight('societe', 'lire')) {
254  $newcardbutton .= dolGetButtonTitle($langs->trans("AddWebsiteAccount"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/website/websiteaccount_card.php?action=create&fk_soc='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id));
255  } else {
256  $newcardbutton .= dolGetButtonTitle($langs->trans("AddAction"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/website/websiteaccount_card.php?action=create&fk_soc='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id), '', 0);
257  }
258 }
259 
260 print '<br>';
261 
262 
263 
264 // Build and execute select
265 // --------------------------------------------------------------------
266 $sql = 'SELECT ';
267 foreach ($objectwebsiteaccount->fields as $key => $val) {
268  $sql .= "t.".$key.", ";
269 }
270 // Add fields from extrafields
271 if (!empty($extrafields->attributes[$object->table_element]['label'])) {
272  foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
273  $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key." as options_".$key.', ' : '');
274  }
275 }
276 // Add fields from hooks
277 $parameters = array();
278 $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $objectwebsiteaccount); // Note that $action and $object may have been modified by hook
279 $sql .= $hookmanager->resPrint;
280 $sql = preg_replace('/, $/', '', $sql);
281 $sql .= " FROM ".MAIN_DB_PREFIX."societe_account as t";
282 if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
283  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)";
284 }
285 if ($objectwebsiteaccount->ismultientitymanaged == 1) {
286  $sql .= " WHERE t.entity IN (".getEntity('societeaccount').")";
287 } else {
288  $sql .= " WHERE 1 = 1";
289 }
290 $sql .= " AND fk_soc = ".((int) $object->id);
291 foreach ($search as $key => $val) {
292  $mode_search = (($objectwebsiteaccount->isInt($objectwebsiteaccount->fields[$key]) || $objectwebsiteaccount->isFloat($objectwebsiteaccount->fields[$key])) ? 1 : 0);
293  if ($search[$key] != '') {
294  $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search));
295  }
296 }
297 if ($search_all) {
298  $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
299 }
300 // Add where from extra fields
301 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
302 // Add where from hooks
303 $parameters = array();
304 $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $objectwebsiteaccount); // Note that $action and $objectwebsiteaccount may have been modified by hook
305 $sql .= $hookmanager->resPrint;
306 
307 /* If a group by is required
308 $sql.= " GROUP BY "
309 foreach($objectwebsiteaccount->fields as $key => $val)
310 {
311  $sql .= "t.".$key.", ";
312 }
313 // Add fields from extrafields
314 if (!empty($extrafields->attributes[$object->table_element]['label'])) {
315  foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.', ' : '');
316 // Add where from hooks
317 $parameters=array();
318 $reshook=$hookmanager->executeHooks('printFieldListGroupBy',$parameters); // Note that $action and $objectwebsiteaccount may have been modified by hook
319 $sql.=$hookmanager->resPrint;
320 */
321 
322 $sql .= $db->order($sortfield, $sortorder);
323 
324 // Count total nb of records
325 $nbtotalofrecords = '';
326 if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
327  $result = $db->query($sql);
328  $nbtotalofrecords = $db->num_rows($result);
329  if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
330  $page = 0;
331  $offset = 0;
332  }
333 }
334 
335 $sql .= $db->plimit($limit + 1, $offset);
336 
337 $resql = $db->query($sql);
338 if (!$resql) {
339  dol_print_error($db);
340  exit;
341 }
342 
343 $num = $db->num_rows($resql);
344 
345 $arrayofselected = is_array($toselect) ? $toselect : array();
346 
347 // List of mass actions available
348 $arrayofmassactions = array(
349 //'presend'=>$langs->trans("SendByMail"),
350 //'builddoc'=>$langs->trans("PDFMerge"),
351 );
352 if ($user->hasRight('mymodule', 'delete')) {
353  $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
354 }
355 if (in_array($massaction, array('presend', 'predelete'))) {
356  $arrayofmassactions = array();
357 }
358 $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
359 
360 print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
361 if ($optioncss != '') {
362  print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
363 }
364 print '<input type="hidden" name="token" value="'.newToken().'">';
365 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
366 print '<input type="hidden" name="action" value="list">';
367 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
368 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
369 print '<input type="hidden" name="page" value="'.$page.'">';
370 print '<input type="hidden" name="id" value="'.$id.'">';
371 print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
372 
373 print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, '', 0, $newcardbutton, '', $limit);
374 
375 $topicmail = "Information";
376 $modelmail = "societeaccount";
377 $objecttmp = new SocieteAccount($db);
378 $trackid = 'thi'.$object->id;
379 include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
380 
381 /*if ($sall)
382 {
383  foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val);
384  print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall) . join(', ', $fieldstosearchall).'</div>';
385 }*/
386 
387 $moreforfilter = '';
388 /*$moreforfilter.='<div class="divsearchfield">';
389 $moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escape_htmltag($search_myfield).'">';
390 $moreforfilter.= '</div>';*/
391 
392 $parameters = array();
393 $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $objectwebsiteaccount); // Note that $action and $objectwebsiteaccount may have been modified by hook
394 if (empty($reshook)) {
395  $moreforfilter .= $hookmanager->resPrint;
396 } else {
397  $moreforfilter = $hookmanager->resPrint;
398 }
399 
400 if (!empty($moreforfilter)) {
401  print '<div class="liste_titre liste_titre_bydiv centpercent">';
402  print $moreforfilter;
403  print '</div>';
404 }
405 
406 $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
407 $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
408 $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
409 
410 print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
411 print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
412 
413 
414 // Fields title search
415 // --------------------------------------------------------------------
416 print '<tr class="liste_titre">';
417 foreach ($objectwebsiteaccount->fields as $key => $val) {
418  $align = '';
419  if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
420  $align = 'center';
421  }
422  if (in_array($val['type'], array('timestamp'))) {
423  $align .= ' nowrap';
424  }
425  if ($key == 'status') {
426  $align .= ($align ? ' ' : '').'center';
427  }
428  if (!empty($arrayfields['t.'.$key]['checked'])) {
429  print '<td class="liste_titre'.($align ? ' '.$align : '').'"><input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'"></td>';
430  }
431 }
432 // Extra fields
433 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
434 // Fields from hook
435 $parameters = array('arrayfields'=>$arrayfields);
436 $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $objectwebsiteaccount); // Note that $action and $object may have been modified by hook
437 print $hookmanager->resPrint;
438 // Action column
439 print '<td class="liste_titre maxwidthsearch">';
440 $searchpicto = $form->showFilterButtons();
441 print $searchpicto;
442 print '</td>';
443 print '</tr>'."\n";
444 
445 
446 // Fields title label
447 // --------------------------------------------------------------------
448 print '<tr class="liste_titre">';
449 foreach ($objectwebsiteaccount->fields as $key => $val) {
450  $align = '';
451  if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
452  $align = 'center';
453  }
454  if (in_array($val['type'], array('timestamp'))) {
455  $align .= 'nowrap';
456  }
457  if ($key == 'status') {
458  $align .= ($align ? ' ' : '').'center';
459  }
460  if (!empty($arrayfields['t.'.$key]['checked'])) {
461  print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($align ? 'class="'.$align.'"' : ''), $sortfield, $sortorder, $align.' ')."\n";
462  }
463 }
464 // Extra fields
465 // Extra fields
466 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
467 // Hook fields
468 $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
469 $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $objectwebsiteaccount); // Note that $action and $object may have been modified by hook
470 print $hookmanager->resPrint;
471 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'maxwidthsearch center ')."\n";
472 print '</tr>'."\n";
473 
474 
475 // Detect if we need a fetch on each output line
476 $needToFetchEachLine = 0;
477 if (isset($extrafields->attributes[$object->table_element]['computed']) && is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) {
478  foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) {
479  if (!is_null($val) && preg_match('/\$object/', $val)) {
480  $needToFetchEachLine++; // There is at least one compute field that use $object
481  }
482  }
483 }
484 
485 // Loop on record
486 // --------------------------------------------------------------------
487 $i = 0;
488 $totalarray = array();
489 while ($i < min($num, $limit)) {
490  $obj = $db->fetch_object($resql);
491  if (empty($obj)) {
492  break; // Should not happen
493  }
494 
495  // Store properties in $object
496  $objectwebsiteaccount->id = $obj->rowid;
497  $objectwebsiteaccount->login = $obj->login;
498  $objectwebsiteaccount->ref = $obj->login;
499  foreach ($objectwebsiteaccount->fields as $key => $val) {
500  if (property_exists($objectwebsiteaccount, $key)) {
501  $objectwebsiteaccount->$key = $obj->$key;
502  }
503  }
504 
505  // Show here line of result
506  print '<tr class="oddeven">';
507  foreach ($objectwebsiteaccount->fields as $key => $val) {
508  $align = '';
509  if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
510  $align = 'center';
511  }
512  if (in_array($val['type'], array('timestamp'))) {
513  $align .= 'nowrap';
514  }
515  if ($key == 'status') {
516  $align .= ($align ? ' ' : '').'center';
517  }
518  if (!empty($arrayfields['t.'.$key]['checked'])) {
519  print '<td';
520  if ($align) {
521  print ' class="'.$align.'"';
522  }
523  print '>';
524  if ($key == 'login') {
525  print $objectwebsiteaccount->getNomUrl(1, '', 0, '', 1);
526  } else {
527  print $objectwebsiteaccount->showOutputField($val, $key, $obj->$key, '');
528  }
529  print '</td>';
530  if (!$i) {
531  $totalarray['nbfield']++;
532  }
533  if (!empty($val['isameasure']) && $val['isameasure'] == 1) {
534  if (!$i) {
535  $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key;
536  }
537  if (!isset($totalarray['val'])) {
538  $totalarray['val'] = array();
539  }
540  if (!isset($totalarray['val']['t.'.$key])) {
541  $totalarray['val']['t.'.$key] = 0;
542  }
543  $totalarray['val']['t.'.$key] += $objectwebsiteaccount->$key;
544  }
545  }
546  }
547  // Extra fields
548  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
549  // Fields from hook
550  $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
551  $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $objectwebsiteaccount); // Note that $action and $object may have been modified by hook
552  print $hookmanager->resPrint;
553  // Action column
554  print '<td class="nowrap center">';
555  if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
556  $selected = 0;
557  if (in_array($obj->rowid, $arrayofselected)) {
558  $selected = 1;
559  }
560  print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
561  }
562  print '</td>';
563  if (!$i) {
564  $totalarray['nbfield']++;
565  }
566 
567  print '</tr>';
568 
569  $i++;
570 }
571 
572 // Show total line
573 include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
574 
575 
576 // If no record found
577 if ($num == 0) {
578  $colspan = 1;
579  foreach ($arrayfields as $key => $val) {
580  if (!empty($val['checked'])) {
581  $colspan++;
582  }
583  }
584  print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
585 }
586 
587 
588 $db->free($resql);
589 
590 $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
591 $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $objectwebsiteaccount); // Note that $action and $object may have been modified by hook
592 print $hookmanager->resPrint;
593 
594 print '</table>'."\n";
595 print '</div>'."\n";
596 
597 print '</form>'."\n";
598 
599 if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) {
600  $hidegeneratedfilelistifempty = 1;
601  if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
602  $hidegeneratedfilelistifempty = 0;
603  }
604 
605  require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
606  $formfile = new FormFile($db);
607 
608  // Show list of available documents
609  $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
610  $urlsource .= str_replace('&amp;', '&', $param);
611 
612  $filedir = $diroutputmassaction;
613  $genallowed = $user->rights->mymodule->read;
614  $delallowed = $user->rights->mymodule->create;
615 
616  print $formfile->showdocuments('massfilesarea_mymodule', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
617 }
618 
619 // End of page
620 llxFooter();
621 $db->close();
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:56
llxFooter()
Empty footer.
Definition: wrapper.php:70
Class to manage contact/addresses.
Class to manage standard extra fields.
Class to offer components to list and upload files.
Class to manage generation of HTML components Only common components must be here.
Class for SocieteAccount.
Class to manage third parties objects (customers, suppliers, prospects...)
societe_prepare_head(Societe $object)
Return array of tabs to used on pages for third parties cards.
Definition: company.lib.php:42
if(isModEnabled('facture') && $user->hasRight('facture', 'lire')) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') && $user->hasRight('don', 'lire')) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $sql
Social contributions to pay.
Definition: index.php:746
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='')
Show tab footer of a card.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
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...
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by second index function, which produces ascending (default) or descending output...
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get title line of an array.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
isModEnabled($module)
Is Dolibarr module enabled.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.