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