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