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