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