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