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