dolibarr 24.0.0-beta
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 * Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
11 * Copyright (C) 2025-2026 MDW <mdeweerd@users.noreply.github.com>
12 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 3 of the License, or
16 * (at your option) any later version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program. If not, see <https://www.gnu.org/licenses/>.
25 */
26
34// Load Dolibarr environment
35require '../main.inc.php';
43require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
44require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
45require_once DOL_DOCUMENT_ROOT.'/societe/class/societeaccount.class.php';
46require_once DOL_DOCUMENT_ROOT.'/website/class/website.class.php';
47require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
48require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
49
50// Load translation files required by the page
51$langs->loadLangs(array("companies", "website"));
52
53// Get parameters
54$action = GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ...
55$show_files = GETPOSTINT('show_files');
56$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'websitelist'; // To manage different context of search
57$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
58$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
59$toselect = GETPOST('toselect', 'array:int'); // Array of ids of elements selected into a list
60$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
61$mode = GETPOST('mode', 'aZ'); // The output mode ('list', 'kanban', 'hierarchy', 'calendar', ...)
62
63$id = GETPOSTINT('id') ? GETPOSTINT('id') : GETPOSTINT('socid');
64
65$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
66$sortfield = GETPOST('sortfield', 'aZ09comma');
67$sortorder = GETPOST('sortorder', 'aZ09comma');
68$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
69if (empty($page) || $page == -1) {
70 $page = 0;
71} // If $page is not defined, or '' or -1
72$offset = $limit * $page;
73$pageprev = $page - 1;
74$pagenext = $page + 1;
75if (!$sortfield) {
76 $sortfield = 't.login';
77}
78if (!$sortorder) {
79 $sortorder = 'ASC';
80}
81if (!isset($massaction)) {
82 $massaction = '';
83}
84
85
86// Initialize a technical objects
87$object = new Societe($db);
88$objectwebsiteaccount = new SocieteAccount($db);
89$extrafields = new ExtraFields($db);
90$diroutputmassaction = isModEnabled('website') ? $conf->website->dir_output.'/temp/massgeneration/'.$user->id : '';
91$hookmanager->initHooks(array('thirdpartywebsite', 'websitethirdpartylist')); // Note that conf->hooks_modules contains array
92
93// Fetch optionals attributes and labels
94$extrafields->fetch_name_optionals_label($objectwebsiteaccount->table_element);
95
96$search_array_options = $extrafields->getOptionalsFromPost($objectwebsiteaccount->table_element, '', 'search_');
97
98unset($objectwebsiteaccount->fields['fk_soc']); // Remove this field, we are already on the thirdparty
99
100// Initialize array of search criteria
101$search_all = GETPOST("search_all", 'alpha');
103$search = array();
104foreach ($objectwebsiteaccount->fields as $key => $val) {
105 $value = GETPOST('search_'.$key, 'alpha');
106 if ($value) {
107 $search[$key] = $value;
108 }
109}
110
111// List of fields to search into when doing a "search in all"
112$fieldstosearchall = array();
113foreach ($objectwebsiteaccount->fields as $key => $val) {
114 if (!empty($val['searchall'])) {
115 $fieldstosearchall['t.'.$key] = $val['label'];
116 }
117}
118
119// Definition of array of fields for columns
120$arrayfields = array();
121foreach ($objectwebsiteaccount->fields as $key => $val) {
122 // If $val['visible']==0, then we never show the field
123 if (!empty($val['visible'])) {
124 $arrayfields['t.'.$key] = array('label' => $val['label'], 'checked' => (($val['visible'] < 0) ? 0 : 1), 'enabled' => $val['enabled']);
125 }
126}
127
128// Extra fields
129include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
130
131$object->fields = dol_sort_array($object->fields, 'position');
132$arrayfields = dol_sort_array($arrayfields, 'position');
133
134if ($id > 0) {
135 $result = $object->fetch($id);
136}
137
138if (!($object->id > 0) && $action == 'view') {
139 recordNotFound();
140}
141
142// Security check
143$id = GETPOSTINT('id') ? GETPOSTINT('id') : GETPOSTINT('socid');
144if ($user->socid) {
145 $id = $user->socid;
146}
147$result = restrictedArea($user, 'societe', $object->id, '&societe');
148
149$permissiontoread = $user->hasRight('societe', 'lire');
150$permissiontoadd = $user->hasRight('societe', 'create');
151$permissiontodelete = $user->hasRight('societe', 'supprimer');
152
153
154/*
155 * Actions
156 */
157
158$parameters = array('id' => $id);
159$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
160if ($reshook < 0) {
161 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
162}
163
164if (empty($reshook)) {
165 // Cancel
166 if (GETPOST('cancel', 'alpha') && !empty($backtopage)) {
167 header("Location: ".$backtopage);
168 exit;
169 }
170
171 // Selection of new fields
172 include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
173
174 // Purge search criteria
175 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
176 foreach ($objectwebsiteaccount->fields as $key => $val) {
177 $search[$key] = '';
178 if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
179 $search[$key.'_dtstart'] = '';
180 $search[$key.'_dtend'] = '';
181 }
182 }
183 $search_all = '';
184 $toselect = array();
185 $search_array_options = array();
186 }
187 if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
188 || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) {
189 $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
190 }
191
192 // Mass actions
193 $objectclass = 'WebsiteAccount';
194 $objectlabel = 'WebsiteAccount';
195 $uploaddir = empty($conf->societe->multidir_output[$object->entity ?? $conf->entity]) ? $conf->societe->dir_output : $conf->societe->multidir_output[$object->entity ?? $conf->entity];
196
197 include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
198}
199
200
201
202/*
203 * View
204 */
205
206$form = new Form($db);
207
208$langs->load("companies");
209
210$title = $langs->trans("WebsiteAccounts");
211if ($id > 0) {
212 $title = $object->name.' - '.$langs->trans("WebsiteAccounts");
213}
214$help_url = '';
215
216
217// Build and execute select
218// --------------------------------------------------------------------
219$site_filter_list = array();
220if (isModEnabled('website')) {
221 $site_filter_list[] = 'dolibarr_website';
222}
223if (isModEnabled('webportal')) {
224 $site_filter_list[] = 'dolibarr_portal';
225}
226$sql = 'SELECT ';
227$sql .= $objectwebsiteaccount->getFieldList('t');
228// Add fields from extrafields
229if (!empty($extrafields->attributes[$object->table_element]['label'])) {
230 foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
231 $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
232 }
233}
234// Add fields from hooks
235$parameters = array();
236$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $objectwebsiteaccount, $action); // Note that $action and $object may have been modified by hook
237$sql .= $hookmanager->resPrint;
238$sql = preg_replace('/,\s*$/', '', $sql);
239
240$sqlfields = $sql; // $sql fields to remove for count total
241
242$sql .= " FROM ".MAIN_DB_PREFIX."societe_account as t";
243if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
244 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)";
245}
246// Add table from hooks
247$parameters = array();
248$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
249$sql .= $hookmanager->resPrint;
250if ($objectwebsiteaccount->ismultientitymanaged == 1) {
251 $sql .= " WHERE t.entity IN (".getEntity('thirdpartyaccount').")";
252} else {
253 $sql .= " WHERE 1 = 1";
254}
255$sql .= " AND fk_soc = ".((int) $object->id);
256if (!empty($site_filter_list)) {
257 $sql .= " AND t.site IN (".$db->sanitize("'".implode("','", $site_filter_list)."'", 1).")";
258}
259foreach ($search as $key => $val) {
260 if (array_key_exists($key, $objectwebsiteaccount->fields)) {
261 if ($key == 'status' && $search[$key] == -1) {
262 continue;
263 }
264 $mode_search = (($objectwebsiteaccount->isInt($objectwebsiteaccount->fields[$key]) || $objectwebsiteaccount->isFloat($objectwebsiteaccount->fields[$key])) ? 1 : 0);
265 if ((strpos($objectwebsiteaccount->fields[$key]['type'], 'integer:') === 0) || (strpos($objectwebsiteaccount->fields[$key]['type'], 'sellist:') === 0) || !empty($objectwebsiteaccount->fields[$key]['arrayofkeyval'])) {
266 if ($search[$key] == '-1' || ($search[$key] === '0' && (empty($objectwebsiteaccount->fields[$key]['arrayofkeyval']) || !array_key_exists('0', $objectwebsiteaccount->fields[$key]['arrayofkeyval'])))) {
267 $search[$key] = '';
268 }
269 $mode_search = 2;
270 }
271 if ($search[$key] != '') {
272 $sql .= natural_search("t.".$db->sanitize($key), $search[$key], (($key == 'status') ? 2 : $mode_search));
273 }
274 } else {
275 if (preg_match('/(_dtstart|_dtend)$/', $key) && $search[$key] != '') {
276 $columnName = preg_replace('/(_dtstart|_dtend)$/', '', $key);
277 if (preg_match('/^(date|timestamp|datetime)/', $objectwebsiteaccount->fields[$columnName]['type'])) {
278 if (preg_match('/_dtstart$/', $key)) {
279 $sql .= " AND t.".$db->sanitize($columnName)." >= '".$db->idate((int) $search[$key])."'";
280 }
281 if (preg_match('/_dtend$/', $key)) {
282 $sql .= " AND t.".$db->sanitize($columnName)." <= '".$db->idate((int) $search[$key])."'";
283 }
284 }
285 }
286 }
287 /*if ($search[$key] != '') {
288 $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search));
289 }*/
290}
291if ($search_all) {
292 $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
293}
294// Add where from extra fields
295include 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, $action); // 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 $sql .= "t.".$db->sanitize($key).", ";
305 }
306 // Add fields from extrafields
307 if (!empty($extrafields->attributes[$object->table_element]['label'])) {
308 foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.', ' : '');
309 // Add groupby from hooks
310 $parameters=array();
311 $reshook = $hookmanager->executeHooks('printFieldListGroupBy',$parameters); // Note that $action and $objectwebsiteaccount may have been modified by hook
312 $sql.=$hookmanager->resPrint;
313 */
314
315// Count total nb of records
316$nbtotalofrecords = '';
317if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
318 $resql = $db->query($sql);
319 $nbtotalofrecords = $db->num_rows($resql);
320 if (($page * $limit) > (int) $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
321 $page = 0;
322 $offset = 0;
323 }
324 $db->free($resql);
325}
326
327// Complete request and execute it with limit
328$sql .= $db->order($sortfield, $sortorder);
329if ($limit) {
330 $sql .= $db->plimit($limit + 1, $offset);
331}
332
333$resql = $db->query($sql);
334if (!$resql) {
336 exit;
337}
338
339$num = $db->num_rows($resql);
340
341
342// Output page
343// --------------------------------------------------------------------
344
345llxHeader('', $title, $help_url);
346
347$arrayofselected = is_array($toselect) ? $toselect : array();
348
349$param = 'id='.$object->id;
350if (!empty($mode)) {
351 $param .= '&mode='.urlencode($mode);
352}
353if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
354 $param .= '&contextpage='.urlencode($contextpage);
355}
356if ($limit > 0 && $limit != $conf->liste_limit) {
357 $param .= '&limit='.((int) $limit);
358}
359if ($optioncss != '') {
360 $param .= '&optioncss='.urlencode($optioncss);
361}
362foreach ($search as $key => $val) {
363 if (is_array($search[$key])) {
364 foreach ($search[$key] as $skey) {
365 if ($skey != '') {
366 $param .= '&search_'.$key.'[]='.urlencode($skey);
367 }
368 }
369 } elseif (preg_match('/(_dtstart|_dtend)$/', $key) && !empty($val)) {
370 $param .= '&search_'.$key.'month='.((int) GETPOST('search_'.$key.'month', 'int'));
371 $param .= '&search_'.$key.'day='.((int) GETPOST('search_'.$key.'day', 'int'));
372 $param .= '&search_'.$key.'year='.((int) GETPOST('search_'.$key.'year', 'int'));
373 } elseif ($search[$key] != '') {
374 $param .= '&search_'.$key.'='.urlencode($search[$key]);
375 }
376}
377// Add $param from extra fields
378include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
379
380$head = societe_prepare_head($object);
381
382print dol_get_fiche_head($head, 'website', $langs->trans("ThirdParty"), - 1, 'company');
383
384$linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
385
386dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom');
387
388print '<div class="fichecenter">';
389
390print '<div class="underbanner clearboth"></div>';
391print '<table class="border centpercent tableforfield">';
392
393$socstat = $object;
394
395// Type Prospect/Customer/Supplier
396print '<tr><td class="titlefield">'.$langs->trans('NatureOfThirdParty').'</td><td>';
397print $socstat->getTypeUrl(1);
398print '</td></tr>';
399
400// Customer code
401if ($socstat->client && !empty($socstat->code_client)) {
402 print '<tr><td class="titlefield">';
403 print $langs->trans('CustomerCode').'</td><td>';
404 print showValueWithClipboardCPButton(dol_escape_htmltag($socstat->code_client));
405 $tmpcheck = $socstat->check_codeclient();
406 if ($tmpcheck != 0 && $tmpcheck != -5) {
407 print ' <span class="error">('.$langs->trans("WrongCustomerCode").')</span>';
408 }
409 print '</td>';
410 print '</tr>';
411}
412// Supplier code
413if ($socstat->fournisseur && !empty($socstat->code_fournisseur)) {
414 print '<tr><td class="titlefield">';
415 print $langs->trans('SupplierCode').'</td><td>';
416 print showValueWithClipboardCPButton(dol_escape_htmltag($socstat->code_fournisseur));
417 $tmpcheck = $socstat->check_codefournisseur();
418 if ($tmpcheck != 0 && $tmpcheck != -5) {
419 print ' <span class="error">('.$langs->trans("WrongSupplierCode").')</span>';
420 }
421 print '</td>';
422 print '</tr>';
423}
424
425print '</table>';
426
427print '</div>';
428
429print dol_get_fiche_end();
430
431$newcardbutton = '';
432if (isModEnabled('website') || isModEnabled('webportal')) {
433 if ($user->hasRight('societe', 'lire')) {
434 $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));
435 } else {
436 $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);
437 }
438}
439
440print '<br>';
441
442
443
444// List of mass actions available
445$arrayofmassactions = array(
446//'presend'=>$langs->trans("SendByMail"),
447//'builddoc'=>$langs->trans("PDFMerge"),
448);
449if ($user->hasRight('mymodule', 'delete')) {
450 $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
451}
452if (GETPOSTINT('nomassaction') || in_array($massaction, array('presend', 'predelete'))) {
453 $arrayofmassactions = array();
454}
455$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
456
457print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
458if ($optioncss != '') {
459 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
460}
461print '<input type="hidden" name="token" value="'.newToken().'">';
462print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
463print '<input type="hidden" name="action" value="list">';
464print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
465print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
466print '<input type="hidden" name="page" value="'.$page.'">';
467print '<input type="hidden" name="id" value="'.$id.'">';
468print '<input type="hidden" name="page_y" value="">';
469print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
470
471print_barre_liste($langs->trans("WebsiteAccounts"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'website', 0, $newcardbutton, '', $limit); // @phan-suppress-current-line PhanPluginSuspiciousParamOrder
472
473$topicmail = "Information";
474$modelmail = "societeaccount";
475$objecttmp = new SocieteAccount($db);
476$trackid = 'thi'.$object->id;
477include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
478
479/*if ($search_all)
480{
481 foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val);
482 print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all) . join(', ', $fieldstosearchall).'</div>';
483}*/
484
485$moreforfilter = '';
486/*$moreforfilter.='<div class="divsearchfield">';
487$moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escape_htmltag($search_myfield).'">';
488$moreforfilter.= '</div>';*/
489
490$parameters = array();
491$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $objectwebsiteaccount, $action); // Note that $action and $objectwebsiteaccount may have been modified by hook
492if (empty($reshook)) {
493 $moreforfilter .= $hookmanager->resPrint;
494} else {
495 $moreforfilter = $hookmanager->resPrint;
496}
497
498if (!empty($moreforfilter)) {
499 print '<div class="liste_titre liste_titre_bydiv centpercent">';
500 print $moreforfilter;
501 print '</div>';
502}
503
504$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
505$htmlofselectarray = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, $conf->main_checkbox_left_column); // This also change content of $arrayfields with user setup
506$selectedfields = ($mode != 'kanban' ? $htmlofselectarray : '');
507$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
508
509print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you don't need reserved height for your table
510print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
511
512
513// Fields title search
514// --------------------------------------------------------------------
515print '<tr class="liste_titre_filter">';
516// Action column
517if ($conf->main_checkbox_left_column) {
518 print '<td class="liste_titre center maxwidthsearch">';
519 $searchpicto = $form->showFilterButtons('left');
520 print $searchpicto;
521 print '</td>';
522}
523foreach ($objectwebsiteaccount->fields as $key => $val) {
524 //$searchkey = empty($search[$key]) ? '' : $search[$key];
525 $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
526 if ($key == 'status') {
527 $cssforfield .= ($cssforfield ? ' ' : '').'center';
528 } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
529 $cssforfield .= ($cssforfield ? ' ' : '').'center';
530 } elseif (in_array($val['type'], array('timestamp'))) {
531 $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
532 } 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'])) {
533 $cssforfield .= ($cssforfield ? ' ' : '').'right';
534 }
535 if (!empty($arrayfields['t.'.$key]['checked'])) {
536 print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').($key == 'status' ? ' parentonrightofpage' : '').'">';
537 if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) {
538 print $form->selectarray('search_'.$key, $val['arrayofkeyval'], (isset($search[$key]) ? $search[$key] : ''), 1, 0, 0, '', 1, 0, 0, '', 'maxwidth100'.($key == 'status' ? ' search_status width100 onrightofpage' : ''), 1);
539 } elseif ((strpos($val['type'], 'integer:') === 0) || (strpos($val['type'], 'sellist:') === 0)) {
540 //print $object->showInputField($val, $key, (isset($search[$key]) ? $search[$key] : ''), '', '', 'search_', $cssforfield.' maxwidth250', 1);
541 print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag(empty($search[$key]) ? '' : $search[$key]).'">';
542 } elseif (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
543 print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag(empty($search[$key]) ? '' : $search[$key]).'">';
544 /*print '<div class="nowrap">';
545 print $form->selectDate($search[$key.'_dtstart'] ? $search[$key.'_dtstart'] : '', "search_".$key."_dtstart", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
546 print '</div>';
547 print '<div class="nowrap">';
548 print $form->selectDate($search[$key.'_dtend'] ? $search[$key.'_dtend'] : '', "search_".$key."_dtend", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
549 print '</div>';
550 */
551 } elseif ($key == 'lang') {
552 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
553 $formadmin = new FormAdmin($db);
554 print $formadmin->select_language((isset($search[$key]) ? $search[$key] : ''), 'search_lang', 0, array(), 1, 0, 0, 'minwidth100imp maxwidth125', 2);
555 } else {
556 print '<input type="text" class="flat maxwidth'.($val['type'] == 'integer' ? '50' : '75').'" name="search_'.$key.'" value="'.dol_escape_htmltag(isset($search[$key]) ? $search[$key] : '').'">';
557 }
558 print '</td>';
559 }
560}
561// Extra fields
562include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
563// Fields from hook
564$parameters = array('arrayfields' => $arrayfields);
565$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $objectwebsiteaccount, $action); // Note that $action and $object may have been modified by hook
566print $hookmanager->resPrint;
567// Action column
568if (!$conf->main_checkbox_left_column) {
569 print '<td class="liste_titre center maxwidthsearch">';
570 $searchpicto = $form->showFilterButtons();
571 print $searchpicto;
572 print '</td>';
573}
574print '</tr>'."\n";
575
576
577$totalarray = array();
578$totalarray['nbfield'] = 0;
579
580// Fields title label
581// --------------------------------------------------------------------
582print '<tr class="liste_titre">';
583// Action column
584if ($conf->main_checkbox_left_column) {
585 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
586 $totalarray['nbfield']++;
587}
588foreach ($objectwebsiteaccount->fields as $key => $val) {
589 $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
590 if ($key == 'status') {
591 $cssforfield .= ($cssforfield ? ' ' : '').'center';
592 } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
593 $cssforfield .= ($cssforfield ? ' ' : '').'center';
594 } elseif (in_array($val['type'], array('timestamp'))) {
595 $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
596 } 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'])) {
597 $cssforfield .= ($cssforfield ? ' ' : '').'right';
598 }
599 $cssforfield = preg_replace('/small\s*/', '', $cssforfield); // the 'small' css must not be used for the title label
600 if (!empty($arrayfields['t.'.$key]['checked'])) {
601 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";
602 $totalarray['nbfield']++;
603 }
604}
605// Extra fields
606include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
607// Hook fields
608$parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder, 'totalarray' => &$totalarray);
609$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $objectwebsiteaccount, $action); // Note that $action and $object may have been modified by hook
610print $hookmanager->resPrint;
611// Action column
612if (!$conf->main_checkbox_left_column) {
613 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
614 $totalarray['nbfield']++;
615}
616print '</tr>'."\n";
617
618
619// Detect if we need a fetch on each output line
620$needToFetchEachLine = 0;
621if (isset($extrafields->attributes[$object->table_element]['computed']) && is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) {
622 foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) {
623 if (!is_null($val) && preg_match('/\$object/', $val)) {
624 $needToFetchEachLine++; // There is at least one compute field that use $object
625 }
626 }
627}
628
629// Loop on record
630// --------------------------------------------------------------------
631$i = 0;
632$savnbfield = $totalarray['nbfield'];
633$totalarray = array();
634$totalarray['nbfield'] = 0;
635$imaxinloop = ($limit ? min($num, $limit) : $num);
636while ($i < $imaxinloop) {
637 $obj = $db->fetch_object($resql);
638 if (empty($obj)) {
639 break; // Should not happen
640 }
641
642 // Store properties in $object
643 $objectwebsiteaccount->id = $obj->rowid;
644 $objectwebsiteaccount->login = $obj->login;
645 $objectwebsiteaccount->ref = $obj->login;
646 foreach ($objectwebsiteaccount->fields as $key => $val) {
647 if (property_exists($objectwebsiteaccount, $key)) {
648 $objectwebsiteaccount->$key = $obj->$key;
649 }
650 }
651
652 // Show line of result
653 print '<tr data-rowid="'.$objectwebsiteaccount->id.'" class="oddeven">';
654 // Action column
655 if ($conf->main_checkbox_left_column) {
656 print '<td class="nowrap center">';
657 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
658 $selected = 0;
659 if (in_array($obj->rowid, $arrayofselected)) {
660 $selected = 1;
661 }
662 print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
663 }
664 print '</td>';
665 if (!$i) {
666 $totalarray['nbfield']++;
667 }
668 }
669 foreach ($objectwebsiteaccount->fields as $key => $val) {
670 $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
671 if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
672 $cssforfield .= ($cssforfield ? ' ' : '').'center';
673 } elseif ($key == 'status') {
674 $cssforfield .= ($cssforfield ? ' ' : '').'center';
675 }
676 if (in_array($val['type'], array('timestamp'))) {
677 $cssforfield .= ($cssforfield ? ' ' : '').'nowraponall';
678 } elseif ($key == 'ref') {
679 $cssforfield .= ($cssforfield ? ' ' : '').'nowraponall';
680 }
681
682 if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('id', 'rowid', 'ref', 'status')) && empty($val['arrayofkeyval'])) {
683 $cssforfield .= ($cssforfield ? ' ' : '').'right';
684 }
685
686 if (!empty($arrayfields['t.'.$key]['checked'])) {
687 print '<td'.($cssforfield ? ' class="'.$cssforfield.((preg_match('/tdoverflow/', $cssforfield) && !in_array($val['type'], array('ip', 'url')) && !is_numeric($object->$key)) ? ' classfortooltip' : '').'"' : '');
688 if (preg_match('/tdoverflow/', $cssforfield) && !in_array($val['type'], array('ip', 'url')) && !is_numeric($object->$key)) {
689 print ' title="'.dol_escape_htmltag((string) $object->$key).'"';
690 }
691 print '>';
692 if ($key == 'login') {
693 print $objectwebsiteaccount->getNomUrl(1, '', 0, '', 1);
694 } elseif ($key == 'fk_website') {
695 if ($obj->$key > 0) {
696 $tmpwebsite = new Website($db);
697 $tmpwebsite->fetch($obj->$key);
698 print $tmpwebsite->getNomUrl(1);
699 }
700 } else {
701 print $objectwebsiteaccount->showOutputField($val, $key, $obj->$key, '');
702 }
703 print '</td>';
704 if (!$i) {
705 $totalarray['nbfield']++;
706 }
707 if (!empty($val['isameasure']) && $val['isameasure'] == 1) {
708 if (!$i) {
709 $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key;
710 }
711 if (!isset($totalarray['val'])) {
712 $totalarray['val'] = array();
713 }
714 if (!isset($totalarray['val']['t.'.$key])) {
715 $totalarray['val']['t.'.$key] = 0;
716 }
717 $totalarray['val']['t.'.$key] += $objectwebsiteaccount->$key;
718 }
719 }
720 }
721 // Extra fields
722 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
723 // Fields from hook
724 $parameters = array('arrayfields' => $arrayfields, 'object' => $objectwebsiteaccount, 'obj' => $obj, 'i' => $i, 'totalarray' => &$totalarray);
725 $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $objectwebsiteaccount, $action); // Note that $action and $object may have been modified by hook
726 print $hookmanager->resPrint;
727 // Action column
728 if (!$conf->main_checkbox_left_column) {
729 print '<td class="nowrap center">';
730 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
731 $selected = 0;
732 if (in_array($obj->rowid, $arrayofselected)) {
733 $selected = 1;
734 }
735 print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
736 }
737 print '</td>';
738 if (!$i) {
739 $totalarray['nbfield']++;
740 }
741 }
742 print '</tr>'."\n";
743
744 $i++;
745}
746
747// Show total line
748include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
749
750
751// If no record found
752if ($num == 0) {
753 $colspan = 1;
754 foreach ($arrayfields as $key => $val) {
755 if (!empty($val['checked'])) {
756 $colspan++;
757 }
758 }
759 print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
760}
761
762
763$db->free($resql);
764
765$parameters = array('arrayfields' => $arrayfields, 'sql' => $sql);
766$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $objectwebsiteaccount, $action); // Note that $action and $object may have been modified by hook
767print $hookmanager->resPrint;
768
769print '</table>'."\n";
770print '</div>'."\n";
771
772print '</form>'."\n";
773
774if (in_array('builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords === '' || $nbtotalofrecords)) {
775 $hidegeneratedfilelistifempty = 1;
776 if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
777 $hidegeneratedfilelistifempty = 0;
778 }
779
780 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
781 $formfile = new FormFile($db);
782
783 // Show list of available documents
784 $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
785 $urlsource .= str_replace('&amp;', '&', $param);
786
787 $filedir = $diroutputmassaction;
788 $genallowed = $permissiontoread;
789 $delallowed = $permissiontoadd;
790
791 print $formfile->showdocuments('massfilesarea_mymodule', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
792}
793
794// End of page
795llxFooter();
796$db->close();
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:47
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
$totalarray
Definition list.php:497
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:73
Class to manage standard extra fields.
Class to generate html code for admin pages.
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...)
Class Website.
societe_prepare_head(Societe $object, $subtabs='')
Return array of tabs to used on pages for third parties cards.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
natural_search($fields, $value, $mode=0, $nofirstand=0, $sqltoadd='')
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 the value of a given key, which produces ascending (default) or descending out...
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.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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.