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