dolibarr  16.0.5
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 
31 require '../main.inc.php';
32 require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
33 require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
34 require_once DOL_DOCUMENT_ROOT.'/societe/class/societeaccount.class.php';
35 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
36 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
37 
38 $langs->loadLangs(array("companies", "website"));
39 
40 $action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ...
41 $show_files = GETPOST('show_files', 'int');
42 $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'websitelist'; // To manage different context of search
43 $backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
44 $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
45 
46 // Security check
47 $id = GETPOST('id', 'int') ?GETPOST('id', 'int') : GETPOST('socid', 'int');
48 if ($user->socid) {
49  $socid = $user->socid;
50 }
51 $result = restrictedArea($user, 'societe', $socid, '&societe');
52 
53 $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
54 $sortfield = GETPOST('sortfield', 'aZ09comma');
55 $sortorder = GETPOST('sortorder', 'aZ09comma');
56 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
57 if (empty($page) || $page == -1) {
58  $page = 0;
59 } // If $page is not defined, or '' or -1
60 $offset = $limit * $page;
61 $pageprev = $page - 1;
62 $pagenext = $page + 1;
63 if (!$sortfield) {
64  $sortfield = 't.login';
65 }
66 if (!$sortorder) {
67  $sortorder = 'ASC';
68 }
69 
70 // Initialize technical objects
71 $object = new Societe($db);
72 $objectwebsiteaccount = new SocieteAccount($db);
73 $extrafields = new ExtraFields($db);
74 $diroutputmassaction = $conf->website->dir_output.'/temp/massgeneration/'.$user->id;
75 $hookmanager->initHooks(array('websitethirdpartylist')); // Note that conf->hooks_modules contains array
76 
77 // Fetch optionals attributes and labels
78 $extrafields->fetch_name_optionals_label($objectwebsiteaccount->table_element);
79 
80 $search_array_options = $extrafields->getOptionalsFromPost($objectwebsiteaccount->table_element, '', 'search_');
81 
82 unset($objectwebsiteaccount->fields['fk_soc']); // Remove this field, we are already on the thirdparty
83 
84 // Initialize array of search criterias
85 $search_all = GETPOST("search_all", 'alpha');
86 $search = array();
87 foreach ($objectwebsiteaccount->fields as $key => $val) {
88  if (GETPOST('search_'.$key, 'alpha')) {
89  $search[$key] = GETPOST('search_'.$key, 'alpha');
90  }
91 }
92 
93 // List of fields to search into when doing a "search in all"
94 $fieldstosearchall = array();
95 foreach ($objectwebsiteaccount->fields as $key => $val) {
96  if (!empty($val['searchall'])) {
97  $fieldstosearchall['t.'.$key] = $val['label'];
98  }
99 }
100 
101 // Definition of fields for list
102 $arrayfields = array();
103 foreach ($objectwebsiteaccount->fields as $key => $val) {
104  // If $val['visible']==0, then we never show the field
105  if (!empty($val['visible'])) {
106  $arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>$val['enabled']);
107  }
108 }
109 
110 // Extra fields
111 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
112 
113 $object->fields = dol_sort_array($object->fields, 'position');
114 $arrayfields = dol_sort_array($arrayfields, 'position');
115 
116 
117 if ($id > 0) {
118  $result = $object->fetch($id);
119 }
120 
121 
122 /*
123  * Actions
124  */
125 
126 $parameters = array('id'=>$socid);
127 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
128 if ($reshook < 0) {
129  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
130 }
131 
132 if (empty($reshook)) {
133  // Cancel
134  if (GETPOST('cancel', 'alpha') && !empty($backtopage)) {
135  header("Location: ".$backtopage);
136  exit;
137  }
138 
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')) { // All tests are required to be compatible with all browsers
144  foreach ($objectwebsiteaccount->fields as $key => $val) {
145  $search[$key] = '';
146  }
147  $toselect = array();
148  $search_array_options = array();
149  }
150  if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
151  || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) {
152  $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
153  }
154 
155  // Mass actions
156  $objectclass = 'WebsiteAccount';
157  $objectlabel = 'WebsiteAccount';
158  $permissiontoread = $user->rights->societe->lire;
159  $permissiontodelete = $user->rights->societe->supprimer;
160  $uploaddir = $conf->societe->multidir_output[$object->entity];
161  include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
162 }
163 
164 
165 
166 /*
167  * View
168  */
169 
170 $contactstatic = new Contact($db);
171 
172 $form = new Form($db);
173 
174 $langs->load("companies");
175 
176 $title = $langs->trans("WebsiteAccounts");
177 llxHeader('', $title);
178 
179 $param = '';
180 if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
181  $param .= '&contextpage='.urlencode($contextpage);
182 }
183 if ($id > 0) {
184  $param .= '&id='.urlencode($id);
185 }
186 if ($limit > 0 && $limit != $conf->liste_limit) {
187  $param .= '&limit='.urlencode($limit);
188 }
189 foreach ($search as $key => $val) {
190  $param .= '&search_'.$key.'='.urlencode($search[$key]);
191 }
192 if ($optioncss != '') {
193  $param .= '&optioncss='.urlencode($optioncss);
194 }
195 // Add $param from extra fields
196 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
197 
198 $head = societe_prepare_head($object);
199 
200 print dol_get_fiche_head($head, 'website', $langs->trans("ThirdParty"), - 1, 'company');
201 
202 $linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
203 
204 dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom');
205 
206 print '<div class="fichecenter">';
207 
208 print '<div class="underbanner clearboth"></div>';
209 
210 print '<table class="border centpercent">';
211 
212 // Prefix
213 if (!empty($conf->global->SOCIETE_USEPREFIX)) { // Old not used prefix field
214  print '<tr><td class="titlefield">'.$langs->trans('Prefix').'</td><td colspan="3">'.$object->prefix_comm.'</td></tr>';
215 }
216 
217 if ($object->client) {
218  print '<tr><td class="titlefield">';
219  print $langs->trans('CustomerCode').'</td><td colspan="3">';
220  print $object->code_client;
221  $tmpcheck = $object->check_codeclient();
222  if ($tmpcheck != 0 && $tmpcheck != -5) {
223  print ' <span class="error">('.$langs->trans("WrongCustomerCode").')</span>';
224  }
225  print '</td></tr>';
226 }
227 
228 if ($object->fournisseur) {
229  print '<tr><td class="titlefield">';
230  print $langs->trans('SupplierCode').'</td><td colspan="3">';
231  print $object->code_fournisseur;
232  $tmpcheck = $object->check_codefournisseur();
233  if ($tmpcheck != 0 && $tmpcheck != -5) {
234  print ' <span class="error">('.$langs->trans("WrongSupplierCode").')</span>';
235  }
236  print '</td></tr>';
237 }
238 
239 print '</table>';
240 
241 print '</div>';
242 
243 print dol_get_fiche_end();
244 
245 $newcardbutton = '';
246 if (!empty($conf->website->enabled)) {
247  if (!empty($user->rights->societe->lire)) {
248  $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));
249  } else {
250  $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);
251  }
252 }
253 
254 print '<br>';
255 
256 
257 
258 // Build and execute select
259 // --------------------------------------------------------------------
260 $sql = 'SELECT ';
261 foreach ($objectwebsiteaccount->fields as $key => $val) {
262  $sql .= "t.".$key.", ";
263 }
264 // Add fields from extrafields
265 if (!empty($extrafields->attributes[$object->table_element]['label'])) {
266  foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
267  $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key." as options_".$key.', ' : '');
268  }
269 }
270 // Add fields from hooks
271 $parameters = array();
272 $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $objectwebsiteaccount); // Note that $action and $object may have been modified by hook
273 $sql .= $hookmanager->resPrint;
274 $sql = preg_replace('/, $/', '', $sql);
275 $sql .= " FROM ".MAIN_DB_PREFIX."societe_account as t";
276 if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
277  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)";
278 }
279 if ($objectwebsiteaccount->ismultientitymanaged == 1) {
280  $sql .= " WHERE t.entity IN (".getEntity('societeaccount').")";
281 } else {
282  $sql .= " WHERE 1 = 1";
283 }
284 $sql .= " AND fk_soc = ".((int) $object->id);
285 foreach ($search as $key => $val) {
286  $mode_search = (($objectwebsiteaccount->isInt($objectwebsiteaccount->fields[$key]) || $objectwebsiteaccount->isFloat($objectwebsiteaccount->fields[$key])) ? 1 : 0);
287  if ($search[$key] != '') {
288  $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search));
289  }
290 }
291 if ($search_all) {
292  $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
293 }
294 // Add where from extra fields
295 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
296 // Add where from hooks
297 $parameters = array();
298 $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $objectwebsiteaccount); // Note that $action and $objectwebsiteaccount may have been modified by hook
299 $sql .= $hookmanager->resPrint;
300 
301 /* If a group by is required
302 $sql.= " GROUP BY "
303 foreach($objectwebsiteaccount->fields as $key => $val)
304 {
305  $sql .= "t.".$key.", ";
306 }
307 // Add fields from extrafields
308 if (! empty($extrafields->attributes[$object->table_element]['label'])) {
309  foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.', ' : '');
310 // Add where from hooks
311 $parameters=array();
312 $reshook=$hookmanager->executeHooks('printFieldListGroupBy',$parameters); // Note that $action and $objectwebsiteaccount may have been modified by hook
313 $sql.=$hookmanager->resPrint;
314 */
315 
316 $sql .= $db->order($sortfield, $sortorder);
317 
318 // Count total nb of records
319 $nbtotalofrecords = '';
320 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
321  $result = $db->query($sql);
322  $nbtotalofrecords = $db->num_rows($result);
323  if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
324  $page = 0;
325  $offset = 0;
326  }
327 }
328 
329 $sql .= $db->plimit($limit + 1, $offset);
330 
331 $resql = $db->query($sql);
332 if (!$resql) {
333  dol_print_error($db);
334  exit;
335 }
336 
337 $num = $db->num_rows($resql);
338 
339 $arrayofselected = is_array($toselect) ? $toselect : array();
340 
341 // List of mass actions available
342 $arrayofmassactions = array(
343 //'presend'=>$langs->trans("SendByMail"),
344 //'builddoc'=>$langs->trans("PDFMerge"),
345 );
346 if ($user->rights->mymodule->delete) {
347  $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
348 }
349 if (in_array($massaction, array('presend', 'predelete'))) {
350  $arrayofmassactions = array();
351 }
352 $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
353 
354 print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
355 if ($optioncss != '') {
356  print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
357 }
358 print '<input type="hidden" name="token" value="'.newToken().'">';
359 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
360 print '<input type="hidden" name="action" value="list">';
361 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
362 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
363 print '<input type="hidden" name="page" value="'.$page.'">';
364 print '<input type="hidden" name="id" value="'.$id.'">';
365 print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
366 
367 print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, '', 0, $newcardbutton, '', $limit);
368 
369 $topicmail = "Information";
370 $modelmail = "societeaccount";
371 $objecttmp = new SocieteAccount($db);
372 $trackid = 'thi'.$object->id;
373 include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
374 
375 /*if ($sall)
376 {
377  foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val);
378  print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall) . join(', ', $fieldstosearchall).'</div>';
379 }*/
380 
381 $moreforfilter = '';
382 /*$moreforfilter.='<div class="divsearchfield">';
383 $moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escape_htmltag($search_myfield).'">';
384 $moreforfilter.= '</div>';*/
385 
386 $parameters = array();
387 $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $objectwebsiteaccount); // Note that $action and $objectwebsiteaccount may have been modified by hook
388 if (empty($reshook)) {
389  $moreforfilter .= $hookmanager->resPrint;
390 } else {
391  $moreforfilter = $hookmanager->resPrint;
392 }
393 
394 if (!empty($moreforfilter)) {
395  print '<div class="liste_titre liste_titre_bydiv centpercent">';
396  print $moreforfilter;
397  print '</div>';
398 }
399 
400 $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
401 $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
402 $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
403 
404 print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
405 print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
406 
407 
408 // Fields title search
409 // --------------------------------------------------------------------
410 print '<tr class="liste_titre">';
411 foreach ($objectwebsiteaccount->fields as $key => $val) {
412  $align = '';
413  if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
414  $align = 'center';
415  }
416  if (in_array($val['type'], array('timestamp'))) {
417  $align .= ' nowrap';
418  }
419  if ($key == 'status') {
420  $align .= ($align ? ' ' : '').'center';
421  }
422  if (!empty($arrayfields['t.'.$key]['checked'])) {
423  print '<td class="liste_titre'.($align ? ' '.$align : '').'"><input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'"></td>';
424  }
425 }
426 // Extra fields
427 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
428 // Fields from hook
429 $parameters = array('arrayfields'=>$arrayfields);
430 $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $objectwebsiteaccount); // Note that $action and $object may have been modified by hook
431 print $hookmanager->resPrint;
432 // Action column
433 print '<td class="liste_titre maxwidthsearch">';
434 $searchpicto = $form->showFilterButtons();
435 print $searchpicto;
436 print '</td>';
437 print '</tr>'."\n";
438 
439 
440 // Fields title label
441 // --------------------------------------------------------------------
442 print '<tr class="liste_titre">';
443 foreach ($objectwebsiteaccount->fields as $key => $val) {
444  $align = '';
445  if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
446  $align = 'center';
447  }
448  if (in_array($val['type'], array('timestamp'))) {
449  $align .= 'nowrap';
450  }
451  if ($key == 'status') {
452  $align .= ($align ? ' ' : '').'center';
453  }
454  if (!empty($arrayfields['t.'.$key]['checked'])) {
455  print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($align ? 'class="'.$align.'"' : ''), $sortfield, $sortorder, $align.' ')."\n";
456  }
457 }
458 // Extra fields
459 // Extra fields
460 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
461 // Hook fields
462 $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
463 $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $objectwebsiteaccount); // Note that $action and $object may have been modified by hook
464 print $hookmanager->resPrint;
465 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'maxwidthsearch center ')."\n";
466 print '</tr>'."\n";
467 
468 
469 // Detect if we need a fetch on each output line
470 $needToFetchEachLine = 0;
471 if (isset($extrafields->attributes[$object->table_element]['computed']) && is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) {
472  foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) {
473  if (preg_match('/\$object/', $val)) {
474  $needToFetchEachLine++; // There is at least one compute field that use $object
475  }
476  }
477 }
478 
479 // Loop on record
480 // --------------------------------------------------------------------
481 $i = 0;
482 $totalarray = array();
483 while ($i < min($num, $limit)) {
484  $obj = $db->fetch_object($resql);
485  if (empty($obj)) {
486  break; // Should not happen
487  }
488 
489  // Store properties in $object
490  $objectwebsiteaccount->id = $obj->rowid;
491  $objectwebsiteaccount->login = $obj->login;
492  $objectwebsiteaccount->ref = $obj->login;
493  foreach ($objectwebsiteaccount->fields as $key => $val) {
494  if (property_exists($objectwebsiteaccount, $key)) {
495  $objectwebsiteaccount->$key = $obj->$key;
496  }
497  }
498 
499  // Show here line of result
500  print '<tr class="oddeven">';
501  foreach ($objectwebsiteaccount->fields as $key => $val) {
502  $align = '';
503  if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
504  $align = 'center';
505  }
506  if (in_array($val['type'], array('timestamp'))) {
507  $align .= 'nowrap';
508  }
509  if ($key == 'status') {
510  $align .= ($align ? ' ' : '').'center';
511  }
512  if (!empty($arrayfields['t.'.$key]['checked'])) {
513  print '<td';
514  if ($align) {
515  print ' class="'.$align.'"';
516  }
517  print '>';
518  if ($key == 'login') {
519  print $objectwebsiteaccount->getNomUrl(1, '', 0, '', 1);
520  } else {
521  print $objectwebsiteaccount->showOutputField($val, $key, $obj->$key, '');
522  }
523  print '</td>';
524  if (!$i) {
525  $totalarray['nbfield']++;
526  }
527  if (!empty($val['isameasure']) && $val['isameasure'] == 1) {
528  if (!$i) {
529  $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key;
530  }
531  if (!isset($totalarray['val'])) {
532  $totalarray['val'] = array();
533  }
534  if (!isset($totalarray['val']['t.'.$key])) {
535  $totalarray['val']['t.'.$key] = 0;
536  }
537  $totalarray['val']['t.'.$key] += $objectwebsiteaccount->$key;
538  }
539  }
540  }
541  // Extra fields
542  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
543  // Fields from hook
544  $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
545  $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $objectwebsiteaccount); // Note that $action and $object may have been modified by hook
546  print $hookmanager->resPrint;
547  // Action column
548  print '<td class="nowrap center">';
549  if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
550  $selected = 0;
551  if (in_array($obj->rowid, $arrayofselected)) {
552  $selected = 1;
553  }
554  print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
555  }
556  print '</td>';
557  if (!$i) {
558  $totalarray['nbfield']++;
559  }
560 
561  print '</tr>';
562 
563  $i++;
564 }
565 
566 // Show total line
567 include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
568 
569 
570 // If no record found
571 if ($num == 0) {
572  $colspan = 1;
573  foreach ($arrayfields as $key => $val) {
574  if (!empty($val['checked'])) {
575  $colspan++;
576  }
577  }
578  print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
579 }
580 
581 
582 $db->free($resql);
583 
584 $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
585 $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $objectwebsiteaccount); // Note that $action and $object may have been modified by hook
586 print $hookmanager->resPrint;
587 
588 print '</table>'."\n";
589 print '</div>'."\n";
590 
591 print '</form>'."\n";
592 
593 if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) {
594  $hidegeneratedfilelistifempty = 1;
595  if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
596  $hidegeneratedfilelistifempty = 0;
597  }
598 
599  require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
600  $formfile = new FormFile($db);
601 
602  // Show list of available documents
603  $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
604  $urlsource .= str_replace('&amp;', '&', $param);
605 
606  $filedir = $diroutputmassaction;
607  $genallowed = $user->rights->mymodule->read;
608  $delallowed = $user->rights->mymodule->create;
609 
610  print $formfile->showdocuments('massfilesarea_mymodule', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
611 }
612 
613 // End of page
614 llxFooter();
615 $db->close();
Societe
Class to manage third parties objects (customers, suppliers, prospects...)
Definition: societe.class.php:48
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
restrictedArea
restrictedArea($user, $features, $objectid=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.
Definition: security.lib.php:234
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
SocieteAccount
Class for SocieteAccount.
Definition: societeaccount.class.php:35
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:142
dol_banner_tab
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.
Definition: functions.lib.php:2046
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
Contact
Class to manage contact/addresses.
Definition: contact.class.php:40
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
dol_get_fiche_head
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
Definition: functions.lib.php:1822
societe_prepare_head
societe_prepare_head(Societe $object)
Return array of tabs to used on pages for third parties cards.
Definition: company.lib.php:42
dol_get_fiche_end
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Definition: functions.lib.php:2018
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
$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
setEventMessages
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
Definition: functions.lib.php:8137
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