dolibarr 21.0.0-beta
subaccount.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2013-2016 Olivier Geffroy <jeff@jeffinfo.com>
3 * Copyright (C) 2013-2024 Alexandre Spangaro <aspangaro@easya.solutions>
4 * Copyright (C) 2016-2018 Laurent Destailleur <eldy@users.sourceforge.net>
5 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
27// Load Dolibarr environment
28require '../../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
30require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
31
40// Load translation files required by the page
41$langs->loadLangs(array("accountancy", "admin", "bills", "compta", "errors", "hrm", "salaries"));
42
43$mesg = '';
44$action = GETPOST('action', 'aZ09');
45$cancel = GETPOST('cancel', 'alpha');
46$id = GETPOSTINT('id');
47$rowid = GETPOSTINT('rowid');
48$massaction = GETPOST('massaction', 'aZ09');
49$optioncss = GETPOST('optioncss', 'alpha');
50$mode = GETPOST('mode', 'aZ'); // The output mode ('list', 'kanban', 'hierarchy', 'calendar', ...)
51$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'accountingsubaccountlist'; // To manage different context of search
52
53$search_subaccount = GETPOST('search_subaccount', 'alpha');
54$search_label = GETPOST('search_label', 'alpha');
55$search_type = GETPOST('search_type', 'intcomma');
56
57// Load variable for pagination
58$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
59$sortfield = GETPOST('sortfield', 'aZ09comma');
60$sortorder = GETPOST('sortorder', 'aZ09comma');
61$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT('page');
62if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
63 // If $page is not defined, or '' or -1 or if we click on clear filters
64 $page = 0;
65}
66$offset = $limit * $page;
67$pageprev = $page - 1;
68$pagenext = $page + 1;
69if (!$sortfield) {
70 $sortfield = "label";
71}
72if (!$sortorder) {
73 $sortorder = "ASC";
74}
75
76$arrayfields = array(
77 'subaccount'=>array('label'=>$langs->trans("AccountNumber"), 'checked'=>1),
78 'label'=>array('label'=>$langs->trans("Label"), 'checked'=>1),
79 'type'=>array('label'=>$langs->trans("Type"), 'checked'=>1),
80 'reconcilable'=>array('label'=>$langs->trans("Reconcilable"), 'checked'=>1)
81);
82
83if (getDolGlobalInt('MAIN_FEATURES_LEVEL') < 2) {
84 unset($arrayfields['reconcilable']);
85}
86
87// Security check
88if ($user->socid > 0) {
90}
91if (!$user->hasRight('accounting', 'chartofaccount')) { // after this test, $user->hasRight('accounting', 'chartofaccount') is always valid
93}
94
95
96/*
97 * Actions
98 */
99
100if (GETPOST('cancel', 'alpha')) {
101 $action = 'list';
102 $massaction = '';
103}
104if (!GETPOST('confirmmassaction', 'alpha')) {
105 $massaction = '';
106}
107
108$parameters = array();
109$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
110if ($reshook < 0) {
111 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
112}
113
114if (empty($reshook)) {
115 if (!empty($cancel)) {
116 $action = '';
117 }
118
119 include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
120
121 if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All test are required to be compatible with all browsers
122 $search_subaccount = "";
123 $search_label = "";
124 $search_type = "";
125 $search_array_options = array();
126 }
127
128 if ($action == 'enable' /* && $user->hasRight('accounting', 'chartofaccount') */) { // test useless
129 setEventMessages($langs->trans("FeatureNotYetAvailable"), null, 'errors');
130 }
131 if ($action == 'disable' /* && $user->hasRight('accounting', 'chartofaccount') */) {
132 setEventMessages($langs->trans("FeatureNotYetAvailable"), null, 'errors');
133 }
134}
135
136
137/*
138 * View
139 */
140
141$form = new Form($db);
142
143
144// Page Header
145$help_url = 'EN:Module_Double_Entry_Accounting#Setup|FR:Module_Comptabilit&eacute;_en_Partie_Double#Configuration';
146$title = $langs->trans('ChartOfIndividualAccountsOfSubsidiaryLedger');
147
148llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-accountancy page-admin_subaccount');
149
150
151// Customer
152$sql = "SELECT sa.rowid, sa.nom as label, sa.code_compta as subaccount, '1' as type, sa.entity, sa.client as nature, sa.fournisseur as nature2";
153$sql .= " FROM ".MAIN_DB_PREFIX."societe sa";
154$sql .= " WHERE sa.entity IN (".getEntity('societe').")";
155$sql .= " AND sa.code_compta <> ''";
156//print $sql;
157if (strlen(trim($search_subaccount))) {
158 $lengthpaddingaccount = 0;
159 if (getDolGlobalInt('ACCOUNTING_LENGTH_AACCOUNT')) {
160 $lengthpaddingaccount = getDolGlobalInt('ACCOUNTING_LENGTH_AACCOUNT');
161 }
162 $search_subaccount_tmp = $search_subaccount;
163 $weremovedsomezero = 0;
164 if (strlen($search_subaccount_tmp) <= $lengthpaddingaccount) {
165 for ($i = 0; $i < $lengthpaddingaccount; $i++) {
166 if (preg_match('/0$/', $search_subaccount_tmp)) {
167 $weremovedsomezero++;
168 $search_subaccount_tmp = preg_replace('/0$/', '', $search_subaccount_tmp);
169 }
170 }
171 }
172
173 if ($search_subaccount_tmp) {
174 if ($weremovedsomezero) {
175 $search_subaccount_tmp_clean = $search_subaccount_tmp;
176 $search_subaccount_clean = $search_subaccount;
177 $startchar = '%';
178 if (strpos($search_subaccount_tmp, '^') === 0) {
179 $startchar = '';
180 $search_subaccount_tmp_clean = preg_replace('/^\^/', '', $search_subaccount_tmp);
181 $search_subaccount_clean = preg_replace('/^\^/', '', $search_subaccount);
182 }
183 $sql .= " AND (sa.code_compta LIKE '".$db->escape($startchar.$search_subaccount_tmp_clean)."'";
184 $sql .= " OR sa.code_compta LIKE '".$db->escape($startchar.$search_subaccount_clean)."%')";
185 } else {
186 $sql .= natural_search("sa.code_compta", $search_subaccount_tmp);
187 }
188 }
189}
190if (strlen(trim($search_label))) {
191 $sql .= natural_search("sa.nom", $search_label);
192}
193if (!empty($search_type) && $search_type >= 0) {
194 $sql .= " HAVING type LIKE '".$db->escape($search_type)."'";
195}
196
197// Supplier
198$sql .= " UNION ";
199$sql .= " SELECT sa.rowid, sa.nom as label, sa.code_compta_fournisseur as subaccount, '2' as type, sa.entity, sa.client as nature, sa.fournisseur as nature2";
200$sql .= " FROM ".MAIN_DB_PREFIX."societe sa";
201$sql .= " WHERE sa.entity IN (".getEntity('societe').")";
202$sql .= " AND sa.code_compta_fournisseur <> ''";
203//print $sql;
204if (strlen(trim($search_subaccount))) {
205 $lengthpaddingaccount = 0;
206 if (getDolGlobalInt('ACCOUNTING_LENGTH_AACCOUNT')) {
207 $lengthpaddingaccount = getDolGlobalInt('ACCOUNTING_LENGTH_AACCOUNT');
208 }
209 $search_subaccount_tmp = $search_subaccount;
210 $weremovedsomezero = 0;
211 if (strlen($search_subaccount_tmp) <= $lengthpaddingaccount) {
212 for ($i = 0; $i < $lengthpaddingaccount; $i++) {
213 if (preg_match('/0$/', $search_subaccount_tmp)) {
214 $weremovedsomezero++;
215 $search_subaccount_tmp = preg_replace('/0$/', '', $search_subaccount_tmp);
216 }
217 }
218 }
219
220 //var_dump($search_subaccount); exit;
221 if ($search_subaccount_tmp) {
222 if ($weremovedsomezero) {
223 $search_subaccount_tmp_clean = $search_subaccount_tmp;
224 $search_subaccount_clean = $search_subaccount;
225 $startchar = '%';
226 if (strpos($search_subaccount_tmp, '^') === 0) {
227 $startchar = '';
228 $search_subaccount_tmp_clean = preg_replace('/^\^/', '', $search_subaccount_tmp);
229 $search_subaccount_clean = preg_replace('/^\^/', '', $search_subaccount);
230 }
231 $sql .= " AND (sa.code_compta_fournisseur LIKE '".$db->escape($startchar.$search_subaccount_tmp_clean)."'";
232 $sql .= " OR sa.code_compta_fournisseur LIKE '".$db->escape($startchar.$search_subaccount_clean)."%')";
233 } else {
234 $sql .= natural_search("sa.code_compta_fournisseur", $search_subaccount_tmp);
235 }
236 }
237}
238if (strlen(trim($search_label))) {
239 $sql .= natural_search("sa.nom", $search_label);
240}
241if (!empty($search_type) && $search_type >= 0) {
242 $sql .= " HAVING type LIKE '".$db->escape($search_type)."'";
243}
244
245// User - Employee
246$sql .= " UNION ";
247$sql .= " SELECT u.rowid, u.lastname as label, u.accountancy_code as subaccount, '3' as type, u.entity, '0' as nature, '0' as nature2";
248$sql .= " FROM ".MAIN_DB_PREFIX."user u";
249$sql .= " WHERE u.entity IN (".getEntity('user').")";
250$sql .= " AND u.accountancy_code <> ''";
251//print $sql;
252if (strlen(trim($search_subaccount))) {
253 $lengthpaddingaccount = 0;
254 if (getDolGlobalInt('ACCOUNTING_LENGTH_AACCOUNT')) {
255 $lengthpaddingaccount = getDolGlobalInt('ACCOUNTING_LENGTH_AACCOUNT');
256 }
257 $search_subaccount_tmp = $search_subaccount;
258 $weremovedsomezero = 0;
259 if (strlen($search_subaccount_tmp) <= $lengthpaddingaccount) {
260 for ($i = 0; $i < $lengthpaddingaccount; $i++) {
261 if (preg_match('/0$/', $search_subaccount_tmp)) {
262 $weremovedsomezero++;
263 $search_subaccount_tmp = preg_replace('/0$/', '', $search_subaccount_tmp);
264 }
265 }
266 }
267
268 //var_dump($search_subaccount); exit;
269 if ($search_subaccount_tmp) {
270 if ($weremovedsomezero) {
271 $search_subaccount_tmp_clean = $search_subaccount_tmp;
272 $search_subaccount_clean = $search_subaccount;
273 $startchar = '%';
274 if (strpos($search_subaccount_tmp, '^') === 0) {
275 $startchar = '';
276 $search_subaccount_tmp_clean = preg_replace('/^\^/', '', $search_subaccount_tmp);
277 $search_subaccount_clean = preg_replace('/^\^/', '', $search_subaccount);
278 }
279 $sql .= " AND (u.accountancy_code LIKE '".$db->escape($startchar.$search_subaccount_tmp_clean)."'";
280 $sql .= " OR u.accountancy_code LIKE '".$db->escape($startchar.$search_subaccount_clean)."%')";
281 } else {
282 $sql .= natural_search("u.accountancy_code", $search_subaccount_tmp);
283 }
284 }
285}
286if (strlen(trim($search_label))) {
287 $sql .= natural_search("u.lastname", $search_label);
288}
289if (!empty($search_type) && $search_type >= 0) {
290 $sql .= " HAVING type LIKE '".$db->escape($search_type)."'";
291}
292
293$sql .= $db->order($sortfield, $sortorder);
294
295// Count total nb of records
296$nbtotalofrecords = '';
297if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
298 $resql = $db->query($sql);
299 $nbtotalofrecords = $db->num_rows($resql);
300 if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
301 $page = 0;
302 $offset = 0;
303 }
304}
305
306$sql .= $db->plimit($limit + 1, $offset);
307
308dol_syslog("accountancy/admin/subaccount.php:: sql=".$sql);
309$resql = $db->query($sql);
310
311if ($resql) {
312 $num = $db->num_rows($resql);
313
314 $param = '';
315 if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
316 $param .= '&contextpage='.urlencode($contextpage);
317 }
318 if ($limit > 0 && $limit != $conf->liste_limit) {
319 $param .= '&limit='.((int) $limit);
320 }
321 if ($optioncss != '') {
322 $param .= '&optioncss='.urlencode($optioncss);
323 }
324 if ($search_subaccount) {
325 $param .= '&search_subaccount='.urlencode($search_subaccount);
326 }
327 if ($search_label) {
328 $param .= '&search_label='.urlencode($search_label);
329 }
330 if ($search_type) {
331 $param .= '&search_type='.urlencode($search_type);
332 }
333
334 // List of mass actions available
335 $arrayofmassactions = array();
336
337 print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
338 if ($optioncss != '') {
339 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
340 }
341 print '<input type="hidden" name="token" value="'.newToken().'">';
342 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
343 print '<input type="hidden" name="action" value="list">';
344 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
345 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
346 print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
347
348 print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit, 0, 0, 1);
349
350 print '<div class="info">'.$langs->trans("WarningCreateSubAccounts").'</div>';
351
352 $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
353 $htmlofselectarray = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')); // This also change content of $arrayfields with user setup
354 $selectedfields = ($mode != 'kanban' ? $htmlofselectarray : '');
355 $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
356
357 $moreforfilter = '';
358 $massactionbutton = '';
359
360 print '<div class="div-table-responsive">';
361 print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
362
363 // Line for search fields
364 print '<tr class="liste_titre_filter">';
365 // Action column
366 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
367 print '<td class="liste_titre center maxwidthsearch">';
368 $searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0, 'checkforselect', 1);
369 print $searchpicto;
370 print '</td>';
371 }
372 if (!empty($arrayfields['subaccount']['checked'])) {
373 print '<td class="liste_titre"><input type="text" class="flat" size="10" name="search_subaccount" value="'.$search_subaccount.'"></td>';
374 }
375 if (!empty($arrayfields['label']['checked'])) {
376 print '<td class="liste_titre"><input type="text" class="flat" size="20" name="search_label" value="'.$search_label.'"></td>';
377 }
378 if (!empty($arrayfields['type']['checked'])) {
379 print '<td class="liste_titre center">'.$form->selectarray('search_type', array('1'=>$langs->trans('Customer').' / '.$langs->trans("Prospect"), '2'=>$langs->trans('Supplier'), '3'=>$langs->trans('Employee')), $search_type, 1).'</td>';
380 }
381 if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) {
382 if (!empty($arrayfields['reconcilable']['checked'])) {
383 print '<td class="liste_titre">&nbsp;</td>';
384 }
385 }
386 // Action column
387 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
388 print '<td class="liste_titre maxwidthsearch">';
389 $searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0, 'checkforselect', 1);
390 print $searchpicto;
391 print '</td>';
392 }
393 print '</tr>';
394
395 print '<tr class="liste_titre">';
396 // Action column
397 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
398 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'center maxwidthsearch ');
399 }
400 if (!empty($arrayfields['subaccount']['checked'])) {
401 print_liste_field_titre($arrayfields['subaccount']['label'], $_SERVER["PHP_SELF"], "subaccount", "", $param, '', $sortfield, $sortorder);
402 }
403 if (!empty($arrayfields['label']['checked'])) {
404 print_liste_field_titre($arrayfields['label']['label'], $_SERVER["PHP_SELF"], "label", "", $param, '', $sortfield, $sortorder);
405 }
406 if (!empty($arrayfields['type']['checked'])) {
407 print_liste_field_titre($arrayfields['type']['label'], $_SERVER["PHP_SELF"], "type", "", $param, '', $sortfield, $sortorder, 'center ');
408 }
409 if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) {
410 if (!empty($arrayfields['reconcilable']['checked'])) {
411 print_liste_field_titre($arrayfields['reconcilable']['label'], $_SERVER["PHP_SELF"], 'reconcilable', '', $param, '', $sortfield, $sortorder, 'center ');
412 }
413 }
414 // Action column
415 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
416 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'center maxwidthsearch ');
417 }
418 print "</tr>\n";
419
420 $companystatic = new Societe($db);
421
422 $totalarray = array();
423 $totalarray['nbfield'] = 0;
424 $i = 0;
425 while ($i < min($num, $limit)) {
426 $obj = $db->fetch_object($resql);
427
428 if ($obj->type == 1) {
429 $companystatic->id = $obj->id;
430 $companystatic->client = $obj->nature;
431 $companystatic->fournisseur = 0;
432 }
433 if ($obj->type == 2) {
434 $companystatic->id = $obj->id;
435 $companystatic->client = 0;
436 $companystatic->fournisseur = $obj->nature2;
437 }
438
439 print '<tr class="oddeven">';
440
441 // Action column
442 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
443 print '<td class="center">';
444 $e = '';
445
446 // Customer
447 if ($obj->type == 1) {
448 $e .= '<a class="editfielda" title="'.$langs->trans("Customer").'" href="'.DOL_URL_ROOT.'/societe/card.php?action=edit&token='.newToken().'&socid='.$obj->rowid.'&backtopage='.urlencode($_SERVER["PHP_SELF"]).'">'.img_edit().'</a>';
449 } elseif ($obj->type == 2) {
450 // Supplier
451 $e .= '<a class="editfielda" title="'.$langs->trans("Supplier").'" href="'.DOL_URL_ROOT.'/societe/card.php?action=edit&token='.newToken().'&socid='.$obj->rowid.'&backtopage='.urlencode($_SERVER["PHP_SELF"]).'">'.img_edit().'</a>';
452 } elseif ($obj->type == 3) {
453 // User - Employee
454 $e .= '<a class="editfielda" title="'.$langs->trans("Employee").'" href="'.DOL_URL_ROOT.'/user/card.php?action=edit&token='.newToken().'&id='.$obj->rowid.'&backtopage='.urlencode($_SERVER["PHP_SELF"]).'">'.img_edit().'</a>';
455 }
456 print $e;
457 print '</td>'."\n";
458 if (!$i) {
459 $totalarray['nbfield']++;
460 }
461 }
462
463 // Account number
464 if (!empty($arrayfields['subaccount']['checked'])) {
465 print "<td>";
466 print length_accounta($obj->subaccount);
467 print "</td>\n";
468 if (!$i) {
469 $totalarray['nbfield']++;
470 }
471 }
472
473 // Subaccount label
474 if (!empty($arrayfields['label']['checked'])) {
475 print "<td>";
476 print dol_escape_htmltag($obj->label);
477 print "</td>\n";
478 if (!$i) {
479 $totalarray['nbfield']++;
480 }
481 }
482
483 // Type
484 if (!empty($arrayfields['type']['checked'])) {
485 print '<td class="center">';
486 $s = '';
487
488 // Customer
489 if ($obj->type == 1) {
490 $s .= '<a class="customer-back" style="padding-left: 6px; padding-right: 6px" title="'.$langs->trans("Customer").'" href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$obj->rowid.'">';
491 $s .= $langs->trans("Customer");
492 $s .= '</a>';
493 if ($obj->nature == 2) {
494 $s .= ' <span class="warning">('.$langs->trans("Prospect").')</span>';
495 }
496 } elseif ($obj->type == 2) {
497 // Supplier
498 $s .= '<a class="vendor-back" style="padding-left: 6px; padding-right: 6px" title="'.$langs->trans("Supplier").'" href="'.DOL_URL_ROOT.'/fourn/card.php?socid='.$obj->rowid.'">'.$langs->trans("Supplier").'</a>';
499 } elseif ($obj->type == 3) {
500 // User - Employee
501 $s .= '<a class="user-back" style="padding-left: 6px; padding-right: 6px" title="'.$langs->trans("Employee").'" href="'.DOL_URL_ROOT.'/user/card.php?id='.$obj->rowid.'">'.$langs->trans("Employee").'</a>';
502 }
503 print $s;
504 print '</td>';
505 if (!$i) {
506 $totalarray['nbfield']++;
507 }
508 }
509
510 if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) {
511 // Activated or not reconciliation on accounting account
512 if (!empty($arrayfields['reconcilable']['checked'])) {
513 print '<td class="center">';
514 if (empty($obj->reconcilable)) {
515 print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$obj->rowid.'&action=enable&mode=1&page='.$page.'&token='.newToken().'">';
516 print img_picto($langs->trans("Disabled"), 'switch_off');
517 print '</a>';
518 } else {
519 print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$obj->rowid.'&action=disable&mode=1&page='.$page.'&token='.newToken().'">';
520 print img_picto($langs->trans("Activated"), 'switch_on');
521 print '</a>';
522 }
523 print '</td>';
524 if (!$i) {
525 $totalarray['nbfield']++;
526 }
527 }
528 }
529
530 // Action column
531 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
532 print '<td class="center">';
533 $e = '';
534
535 // Customer
536 if ($obj->type == 1) {
537 $e .= '<a class="editfielda" title="'.$langs->trans("Customer").'" href="'.DOL_URL_ROOT.'/societe/card.php?action=edit&token='.newToken().'&socid='.$obj->rowid.'&backtopage='.urlencode($_SERVER["PHP_SELF"]).'">'.img_edit().'</a>';
538 } elseif ($obj->type == 2) {
539 // Supplier
540 $e .= '<a class="editfielda" title="'.$langs->trans("Supplier").'" href="'.DOL_URL_ROOT.'/societe/card.php?action=edit&token='.newToken().'&socid='.$obj->rowid.'&backtopage='.urlencode($_SERVER["PHP_SELF"]).'">'.img_edit().'</a>';
541 } elseif ($obj->type == 3) {
542 // User - Employee
543 $e .= '<a class="editfielda" title="'.$langs->trans("Employee").'" href="'.DOL_URL_ROOT.'/user/card.php?action=edit&token='.newToken().'&id='.$obj->rowid.'&backtopage='.urlencode($_SERVER["PHP_SELF"]).'">'.img_edit().'</a>';
544 }
545 print $e;
546 print '</td>'."\n";
547 if (!$i) {
548 $totalarray['nbfield']++;
549 }
550 }
551
552 print '</tr>'."\n";
553 $i++;
554 }
555
556 // If no record found
557 if ($num == 0) {
558 $colspan = 1;
559 foreach ($arrayfields as $key => $val) {
560 if (!empty($val['checked'])) {
561 $colspan++;
562 }
563 }
564 print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
565 }
566
567 $db->free($resql);
568
569 $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
570 $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook
571 print $hookmanager->resPrint;
572
573 print "</table>";
574 print "</div>";
575
576 print '</form>';
577} else {
578 dol_print_error($db);
579}
580
581// End of page
582llxFooter();
583$db->close();
$id
Definition account.php:48
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:66
length_accounta($accounta)
Return Auxiliary accounting account of thirdparties with defined length.
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 generation of HTML components Only common components must be here.
Class to manage third parties objects (customers, suppliers, prospects...)
llxFooter()
Footer empty.
Definition document.php:107
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show 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.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
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
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.