dolibarr 24.0.0-beta
accountmodel.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004-2019 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
5 * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
6 * Copyright (C) 2010-2016 Juanjo Menent <jmenent@2byte.es>
7 * Copyright (C) 2011-2019 Philippe Grand <philippe.grand@atoo-net.com>
8 * Copyright (C) 2011 Remy Younes <ryounes@gmail.com>
9 * Copyright (C) 2012-2015 Marcos García <marcosgdf@gmail.com>
10 * Copyright (C) 2012 Christophe Battarel <christophe.battarel@ltairis.fr>
11 * Copyright (C) 2011-2026 Alexandre Spangaro <alexandre@inovea-conseil.com>
12 * Copyright (C) 2015 Ferran Marcet <fmarcet@2byte.es>
13 * Copyright (C) 2016 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
14 * Copyright (C) 2024-2026 Frédéric France <frederic.france@free.fr>
15 * Copyright (C) 2024-2026 MDW <mdeweerd@users.noreply.github.com>
16 *
17 * This program is free software; you can redistribute it and/or modify
18 * it under the terms of the GNU General Public License as published by
19 * the Free Software Foundation; either version 3 of the License, or
20 * (at your option) any later version.
21 *
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 *
27 * You should have received a copy of the GNU General Public License
28 * along with this program. If not, see <https://www.gnu.org/licenses/>.
29 */
30
37// Load Dolibarr environment
38require '../../main.inc.php';
39require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
40require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
41require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
42require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
43require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
44require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
45if (isModEnabled('accounting')) {
46 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
47}
48
57// Load translation files required by the page
58$langs->loadLangs(array('accountancy', 'admin', 'companies', 'compta', 'errors', 'holiday', 'hrm', 'resource'));
59
60$action = GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view';
61$confirm = GETPOST('confirm', 'alpha');
62$id = 31;
63$rowid = GETPOST('rowid', 'alpha');
64$code = GETPOST('code', 'alpha');
65
66$acts = array();
67$actl = array();
68$acts[0] = "activate";
69$acts[1] = "disable";
70$actl[0] = img_picto($langs->trans("Disabled"), 'switch_off', 'class="size15x"');
71$actl[1] = img_picto($langs->trans("Activated"), 'switch_on', 'class="size15x"');
72
73$listoffset = GETPOST('listoffset', 'alpha');
74$listlimit = GETPOSTINT('listlimit') > 0 ? GETPOSTINT('listlimit') : 1000;
75$active = 1;
76
77$sortfield = GETPOST("sortfield", 'aZ09comma');
78$sortorder = GETPOST("sortorder", 'aZ09comma');
79$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT('page');
80if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
81 // If $page is not defined, or '' or -1 or if we click on clear filters
82 $page = 0;
83}
84$offset = $listlimit * $page;
85$pageprev = $page - 1;
86$pagenext = $page + 1;
87
88$search_country_id = GETPOST('search_country_id', 'int');
89
90
91// Security check
92if ($user->socid > 0) {
94}
95
96$permissiontoeditchart = $user->hasRight('accounting', 'chartofaccount');
97if (!$user->hasRight('accounting', 'chartofaccount')) {
99}
100
101
102// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
103$hookmanager->initHooks(array('admin'));
104
105// This page is a generic page to edit dictionaries
106// Put here declaration of dictionaries properties
107
108// Name of SQL tables of dictionaries
109$tabname = array();
110
111$tabname[31] = MAIN_DB_PREFIX."accounting_system";
112
113// Dictionary labels
114$tablib = array();
115$tablib[31] = "Pcg_version";
116
117// Requests to extract data
118$tabsql = array();
119$tabsql[31] = "SELECT s.rowid as rowid, pcg_version, s.label, s.fk_country as country_id, c.code as country_code, c.label as country, s.active FROM ".MAIN_DB_PREFIX."accounting_system as s, ".MAIN_DB_PREFIX."c_country as c WHERE s.fk_country=c.rowid and c.active=1";
120
121// Criteria to sort dictionaries
122$tabsqlsort = array();
123$tabsqlsort[31] = "pcg_version ASC";
124
125// Nom des champs en resultat de select pour affichage du dictionnaire
126$tabfield = array();
127$tabfield[31] = "pcg_version,label,country_id,country";
128
129// Nom des champs d'edition pour modification d'un enregistrement
130$tabfieldvalue = array();
131$tabfieldvalue[31] = "pcg_version,label,country";
132
133// Nom des champs dans la table pour insertion d'un enregistrement
134$tabfieldinsert = array();
135$tabfieldinsert[31] = "pcg_version,label,fk_country";
136
137// Nom du rowid si le champ n'est pas de type autoincrement
138// Example: "" if id field is "rowid" and has autoincrement on
139// "nameoffield" if id field is not "rowid" or has not autoincrement on
140$tabrowid = array();
141$tabrowid[31] = "";
142
143// List of help for fields
144$tabhelp = array();
145$tabhelp[31] = array('pcg_version' => $langs->trans("EnterAnyCode"));
146
147
148/*
149 * Actions
150 */
151
152if (GETPOST('button_removefilter', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter_x', 'alpha')) {
153 $search_country_id = '';
154}
155
156// Actions add or modify an entry into a dictionary
157if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) {
158 $listfield = explode(',', str_replace(' ', '', $tabfield[$id]));
159 $listfieldinsert = explode(',', $tabfieldinsert[$id]);
160 $listfieldmodify = explode(',', $tabfieldinsert[$id]);
161 $listfieldvalue = explode(',', $tabfieldvalue[$id]);
162
163 // Check that all fields are filled
164 $ok = 1;
165 foreach ($listfield as $f => $value) {
166 if ($value == 'country_id' && in_array($tablib[$id], array('Pcg_version'))) {
167 continue; // For some pages, country is not mandatory
168 }
169 if ((!GETPOSTISSET($value)) || GETPOST($value) == '') {
170 $ok = 0;
171 $fieldnamekey = $listfield[$f];
172 // We take translate key of field
173
174 if ($fieldnamekey == 'pcg_version') {
175 $fieldnamekey = 'Pcg_version';
176 }
177 if ($fieldnamekey == 'label') {
178 $fieldnamekey = 'Label';
179 }
180 if ($fieldnamekey == 'country') {
181 $fieldnamekey = "Country";
182 }
183
184 setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities($fieldnamekey)), null, 'errors');
185 }
186 }
187 // Other checks
188 if (GETPOSTISSET("pcg_version")) {
189 if (GETPOST("pcg_version") == '0') {
190 $ok = 0;
191 setEventMessages($langs->transnoentities('ErrorCodeCantContainZero'), null, 'errors');
192 }
193 }
194 if (GETPOSTISSET("country") && GETPOST("country") == '0') {
195 $ok = 0;
196 setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities("Country")), null, 'errors');
197 }
198
199 // In case of 'actionadd' and with valid parameters, add the line
200 if ($ok && GETPOST('actionadd', 'alpha')) {
201 $newid = 0;
202
203 // Add new entry
204 $sql = "INSERT INTO ".$db->sanitize($tabname[$id])." (";
205 // List of fields
206 $sql .= $db->sanitize($tabfieldinsert[$id]);
207 $sql .= ",active)";
208 $sql .= " VALUES(";
209
210 // List of values
211 $i = 0;
212 foreach ($listfieldinsert as $f => $value) {
213 if ($value == 'price' || preg_match('/^amount/i', $value) || $value == 'taux') {
214 $_POST[$listfieldvalue[$i]] = price2num(GETPOST($listfieldvalue[$i]), 'MU');
215 } elseif ($value == 'entity') {
216 $_POST[$listfieldvalue[$i]] = $conf->entity;
217 }
218 if ($i) {
219 $sql .= ",";
220 }
221 if (GETPOST($listfieldvalue[$i]) == '') {
222 $sql .= "null";
223 } else {
224 $sql .= "'".$db->escape(GETPOST($listfieldvalue[$i]))."'";
225 }
226 $i++;
227 }
228 $sql .= ",1)";
229
230 dol_syslog("actionadd", LOG_DEBUG);
231 $result = $db->query($sql);
232 if ($result) { // Add is ok
233 setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs');
234 $_POST = array('id' => $id); // Clean $_POST array, we keep only
235 } else {
236 if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
237 setEventMessages($langs->transnoentities("ErrorRecordAlreadyExists"), null, 'errors');
238 } else {
240 }
241 }
242 }
243
244 // In case of 'actionmodify' and with valid parameters, modify the line
245 if ($ok && GETPOST('actionmodify', 'alpha')) {
246 // Modify entry
247 $sql = "UPDATE ".$db->sanitize($tabname[$id])." SET ";
248 // Change field's value
249
250 $i = 0;
251 foreach ($listfieldmodify as $field) {
252 if ($field == 'price' || preg_match('/^amount/i', $field) || $field == 'taux') {
253 $_POST[$listfieldvalue[$i]] = price2num(GETPOST($listfieldvalue[$i]), 'MU');
254 } elseif ($field == 'entity') {
255 $_POST[$listfieldvalue[$i]] = $conf->entity;
256 }
257 if ($i) {
258 $sql .= ",";
259 }
260 $sql .= $field."=";
261 if (GETPOST($listfieldvalue[$i]) == '') {
262 $sql .= "null";
263 } else {
264 $sql .= "'".$db->escape(GETPOST($listfieldvalue[$i]))."'";
265 }
266 $i++;
267 }
268 $sql .= " WHERE rowid = ".((int) $rowid);
269
270 dol_syslog("actionmodify", LOG_DEBUG);
271 $resql = $db->query($sql);
272 if (!$resql) {
273 setEventMessages($db->error(), null, 'errors');
274 }
275 }
276}
277
278// delete
279if ($action == 'confirm_delete' && $confirm == 'yes' && $permissiontoeditchart) {
280 $sql = "DELETE from ".$db->sanitize($tabname[$id])." WHERE rowid = ".((int) $rowid);
281
282 dol_syslog("delete", LOG_DEBUG);
283 $result = $db->query($sql);
284 if (!$result) {
285 if ($db->errno() == 'DB_ERROR_CHILD_EXISTS') {
286 setEventMessages($langs->transnoentities("ErrorRecordIsUsedByChild"), null, 'errors');
287 } else {
289 }
290 }
291}
292
293// activate
294if ($action == 'activate' && $permissiontoeditchart) {
295 $sql = "UPDATE ".$db->sanitize($tabname[$id])." SET active = 1 WHERE rowid = ".((int) $rowid);
296 $result = $db->query($sql);
297 if (!$result) {
299 }
300}
301
302// disable
303if ($action == $acts[1] && $permissiontoeditchart) {
304 $sql = "UPDATE ".$db->sanitize($tabname[$id])." SET active = 0 WHERE rowid = ".((int) $rowid);
305 $result = $db->query($sql);
306 if (!$result) {
308 }
309}
310
311
312/*
313 * View
314 */
315
316$form = new Form($db);
317$formadmin = new FormAdmin($db);
318
319$help_url = 'EN:Module_Double_Entry_Accounting#Setup|FR:Module_Comptabilit&eacute;_en_Partie_Double#Configuration';
320
321llxHeader('', $langs->trans("Pcg_version"), $help_url, '', 0, 0, '', '', '', 'mod-accountancy page-admin_accountmodel');
322
323$titre = $langs->trans($tablib[$id]);
324$linkback = '';
325
326print load_fiche_titre($titre, $linkback, 'title_accountancy');
327
328
329// Confirmation of line deletion
330if ($action == 'delete') {
331 print $form->formconfirm(dolBuildUrl($_SERVER["PHP_SELF"], ['page'=> $page, 'sortfield' => $sortfield, 'sortorder' => $sortorder, 'rowid' => $rowid, 'code' => $code, 'id' => $id]), $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete', '', 0, 1);
332}
333
334
335// Complete the values search query with the sort order
336$sql = $tabsql[$id];
337
338if ($search_country_id > 0) {
339 if (preg_match('/ WHERE /', $sql)) {
340 $sql .= " AND ";
341 } else {
342 $sql .= " WHERE ";
343 }
344 $sql .= " c.rowid = ".((int) $search_country_id);
345}
346
347// If sort order is "country", we use country_code instead
348if ($sortfield == 'country') {
349 $sortfield = 'country_code';
350}
351$sql .= $db->order($sortfield, $sortorder);
352$sql .= $db->plimit($listlimit + 1, $offset);
353
354$fieldlist = explode(',', $tabfield[$id]);
355
356print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$id.'" method="POST">';
357print '<input type="hidden" name="token" value="'.newToken().'">';
358
359print '<div class="div-table-responsive">';
360print '<table class="noborder centpercent">';
361
362// Form to add a new line
363
364$fieldlist = explode(',', $tabfield[$id]);
365
366// Line for title
367print '<tr class="liste_titre">';
368foreach ($fieldlist as $field => $value) {
369 // Determine the field name based on the possible names
370 // in the data dictionaries
371 $valuetoshow = ucfirst($fieldlist[$field]); // By default
372 $valuetoshow = $langs->trans($valuetoshow); // try to translate
373 $class = "left";
374 if ($fieldlist[$field] == 'code') {
375 $valuetoshow = $langs->trans("Code");
376 }
377 if ($fieldlist[$field] == 'label') {
378 $valuetoshow = $langs->trans("Label");
379 $class = 'minwidth300';
380 }
381 if ($fieldlist[$field] == 'country') {
382 if (in_array('region_id', $fieldlist)) {
383 print '<td>&nbsp;</td>';
384 continue;
385 } // For region page, we do not show the country input
386 $valuetoshow = $langs->trans("Country");
387 }
388 if ($fieldlist[$field] == 'country_id') {
389 $valuetoshow = '';
390 }
391 if ($fieldlist[$field] == 'pcg_version' || $fieldlist[$field] == 'fk_pcg_version') {
392 $valuetoshow = $langs->trans("Pcg_version");
393 }
394
395 if ($valuetoshow != '') {
396 print '<td class="'.$class.'">';
397 if (!empty($tabhelp[$id][$value]) && preg_match('/^http(s*):/i', $tabhelp[$id][$value])) {
398 print '<a href="'.$tabhelp[$id][$value].'">'.$valuetoshow.' '.img_help(1, $valuetoshow).'</a>';
399 } elseif (!empty($tabhelp[$id][$value])) {
400 print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value]);
401 } else {
402 print $valuetoshow;
403 }
404 print '</td>';
405 }
406}
407
408print '<td>';
409print '<input type="hidden" name="id" value="'.$id.'">';
410print '</td>';
411print '<td></td>';
412print '<td></td>';
413print '</tr>';
414
415// Line to enter new values
416print '<tr class="oddeven">';
417
418$obj = new stdClass();
419// If data was already input, we define them in obj to populate input fields.
420if (GETPOST('actionadd', 'alpha')) {
421 foreach ($fieldlist as $key => $val) {
422 if (GETPOST($val)) {
423 $obj->$val = GETPOST($val);
424 }
425 }
426}
427
428$tmpaction = 'create';
429$parameters = array('fieldlist' => $fieldlist, 'tabname' => $tabname[$id]);
430$reshook = $hookmanager->executeHooks('createDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
431$error = $hookmanager->error;
432$errors = $hookmanager->errors;
433
434if (empty($reshook)) {
435 fieldListAccountModel($fieldlist, $obj, $tabname[$id], 'add');
436}
437
438print '<td colspan="3" class="right">';
439print '<input type="submit" class="button button-add" name="actionadd" value="'.$langs->trans("Add").'">';
440print '</td>';
441print "</tr>";
442
443$colspan = count($fieldlist) + 3;
444
445print '<tr><td colspan="'.$colspan.'">&nbsp;</td></tr>'; // Keep &nbsp; to have a line with enough height
446
447
448
449// List of available values in database
450dol_syslog("htdocs/admin/dict", LOG_DEBUG);
451$resql = $db->query($sql);
452if ($resql) {
453 $num = $db->num_rows($resql);
454 $i = 0;
455
456 $param = '&id='.urlencode((string) ($id));
457 if ($search_country_id > 0) {
458 $param .= '&search_country_id='.urlencode((string) ($search_country_id));
459 }
460 $paramwithsearch = $param;
461 if ($sortorder) {
462 $paramwithsearch .= '&sortorder='.urlencode($sortorder);
463 }
464 if ($sortfield) {
465 $paramwithsearch .= '&sortfield='.urlencode($sortfield);
466 }
467
468 // There is several pages
469 if ($num > $listlimit) {
470 print '<tr class="none"><td class="right" colspan="'.(3 + count($fieldlist)).'">';
471 print_fleche_navigation($page, $_SERVER["PHP_SELF"], $paramwithsearch, ($num > $listlimit ? 1 : 0), '<li class="pagination"><span>'.$langs->trans("Page").' '.($page + 1).'</span></li>');
472 print '</td></tr>';
473 }
474
475 // Title line with search boxes
476 print '<tr class="liste_titre liste_titre_add">';
477 foreach ($fieldlist as $field => $value) {
478 $showfield = 1; // By default
479
480 if ($fieldlist[$field] == 'region_id' || $fieldlist[$field] == 'country_id') {
481 $showfield = 0;
482 }
483
484 if ($showfield) {
485 if ($value == 'country') {
486 print '<td class="liste_titre">';
487 print $form->select_country($search_country_id, 'search_country_id', '', 28, 'maxwidth200 maxwidthonsmartphone');
488 print '</td>';
489 } else {
490 print '<td class="liste_titre"></td>';
491 }
492 }
493 }
494 print '<td class="liste_titre"></td>';
495 print '<td class="liste_titre right" colspan="2">';
496 $searchpicto = $form->showFilterAndCheckAddButtons(0);
497 print $searchpicto;
498 print '</td>';
499 print '</tr>';
500
501 // Title of lines
502 print '<tr class="liste_titre">';
503 print getTitleFieldOfList($langs->trans("Pcg_version"), 0, $_SERVER["PHP_SELF"], "pcg_version", ($page ? 'page='.$page.'&' : ''), $param, '', $sortfield, $sortorder, '');
504 print getTitleFieldOfList($langs->trans("Label"), 0, $_SERVER["PHP_SELF"], "label", ($page ? 'page='.$page.'&' : ''), $param, '', $sortfield, $sortorder, '');
505 print getTitleFieldOfList($langs->trans("Country"), 0, $_SERVER["PHP_SELF"], "country_code", ($page ? 'page='.$page.'&' : ''), $param, '', $sortfield, $sortorder, '');
506 print getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], "active", ($page ? 'page='.$page.'&' : ''), $param, '', $sortfield, $sortorder, 'center ');
507 print getTitleFieldOfList('');
508 print getTitleFieldOfList('');
509 print '</tr>';
510
511 if ($num) {
512 $i = 0;
513 // Lines with values
514 while ($i < $num) {
515 $obj = $db->fetch_object($resql);
516 //print_r($obj);
517
518 print '<tr class="oddeven" id="rowid-'.$obj->rowid.'">';
519 if ($action == 'edit' && ($rowid == (!empty($obj->rowid) ? $obj->rowid : $obj->code))) {
520 print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$id.'" method="POST">';
521 print '<input type="hidden" name="token" value="'.newToken().'">';
522 print '<input type="hidden" name="page" value="'.$page.'">';
523 print '<input type="hidden" name="rowid" value="'.$rowid.'">';
524
525 $tmpaction = 'edit';
526 $parameters = array('fieldlist' => $fieldlist, 'tabname' => $tabname[$id]);
527 $reshook = $hookmanager->executeHooks('editDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
528 $error = $hookmanager->error;
529 $errors = $hookmanager->errors;
530
531 if (empty($reshook)) {
532 fieldListAccountModel($fieldlist, $obj, $tabname[$id], 'edit');
533 }
534
535 print '<td colspan="3" class="right">';
536 print '<a name="'.(!empty($obj->rowid) ? $obj->rowid : $obj->code).'">&nbsp;</a><input type="submit" class="button button-edit smallpaddingimp" name="actionmodify" value="'.$langs->trans("Modify").'">';
537 print '&nbsp;<input type="submit" class="button button-cancel smallpaddingimp" name="actioncancel" value="'.$langs->trans("Cancel").'">';
538 print '</td>';
539 } else {
540 $tmpaction = 'view';
541 $parameters = array('fieldlist' => $fieldlist, 'tabname' => $tabname[$id]);
542 $reshook = $hookmanager->executeHooks('viewDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
543
544 $error = $hookmanager->error;
545 $errors = $hookmanager->errors;
546
547 if (empty($reshook)) {
548 foreach ($fieldlist as $field => $value) {
549 $showfield = 1;
550 $class = "left";
551 $tmpvar = $fieldlist[$field];
552 $valuetoshow = $obj->$tmpvar;
553 if ($valuetoshow == 'all') {
554 $valuetoshow = $langs->trans('All');
555 } elseif ($fieldlist[$field] == 'country') {
556 if (empty($obj->country_code)) {
557 $valuetoshow = '-';
558 } else {
559 $key = $langs->trans("Country".strtoupper($obj->country_code));
560 $valuetoshow = ($key != "Country".strtoupper($obj->country_code) ? $obj->country_code." - ".$key : $obj->country);
561 }
562 } elseif ($fieldlist[$field] == 'country_id') {
563 $showfield = 0;
564 }
565
566 $class = 'tddict';
567 if ($fieldlist[$field] == 'tracking') {
568 $class .= ' tdoverflowauto';
569 }
570 // Show value for field
571 if ($showfield) {
572 print '<!-- '.$fieldlist[$field].' --><td class="'.$class.'">'.$valuetoshow.'</td>';
573 }
574 }
575 }
576
577 // $url = $_SERVER["PHP_SELF"].'?token='.newToken().($page ? '&page='.$page : '').'&sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(!empty($obj->rowid) ? $obj->rowid : (!empty($obj->code) ? $obj->code : '')).'&code='.(!empty($obj->code) ? urlencode($obj->code) : '');
578 // $url .= '&'.$param.'&';
579
580 $query = [];
581 // decode and add param to query
582 parse_str($param, $query);
583 $query = array_merge($query, [
584 'action' => '',
585 'page' => $page,
586 'sortfield' => $sortfield,
587 'sortorder' => $sortorder,
588 'rowid' => (!empty($obj->rowid) ? $obj->rowid : '')
589 ]);
590
591 // Active
592 print '<td class="center nowrap">';
593 $query['action'] = $acts[$obj->active];
594 print '<a href="'.dolBuildUrl($_SERVER["PHP_SELF"], $query, true).'">'.$actl[$obj->active].'</a>';
595 print "</td>";
596
597 // Modify link
598 $query['action'] = 'edit';
599 print '<td class="center"><a class="reposition editfielda" href="'.dolBuildUrl($_SERVER["PHP_SELF"], $query, true).'">'.img_edit().'</a></td>';
600
601 // Delete link
602 $query['action'] = 'delete';
603 print '<td class="center"><a href="'.dolBuildUrl($_SERVER["PHP_SELF"], $query, true).'">'.img_delete().'</a></td>';
604
605 print "</tr>\n";
606 }
607
608 $i++;
609 }
610 } else {
611 print '<tr><td colspan="6"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
612 }
613} else {
615}
616
617print '</table>';
618print '</div>';
619
620print '</form>';
621
622print '<br>';
623
624// End of page
625llxFooter();
626$db->close();
627
628
638function fieldListAccountModel($fieldlist, $obj = null, $tabname = '', $context = '')
639{
640 global $langs, $db;
641 global $form;
642
643 $formadmin = new FormAdmin($db);
644 $formcompany = new FormCompany($db);
645 $formaccounting = new FormAccounting($db);
646
647 foreach ($fieldlist as $field => $value) {
648 if ($fieldlist[$field] == 'country') {
649 if (in_array('region_id', $fieldlist)) {
650 print '<td>';
651 //print join(',',$fieldlist);
652 print '</td>';
653 continue;
654 } // For state page, we do not show the country input (we link to region, not country)
655 print '<td>';
656 $fieldname = 'country';
657 print $form->select_country((!empty($obj->country_code) ? $obj->country_code : (!empty($obj->country) ? $obj->country : '')), $fieldname, '', 28, 'maxwidth200 maxwidthonsmartphone');
658 print '</td>';
659 } elseif ($fieldlist[$field] == 'country_id') {
660 if (!in_array('country', $fieldlist)) { // If there is already a field country, we don't show country_id (avoid duplicate)
661 $country_id = (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]} : 0);
662 print '<td>';
663 print '<input type="hidden" name="'.$fieldlist[$field].'" value="'.$country_id.'">';
664 print '</td>';
665 }
666 } elseif ($fieldlist[$field] == 'type_cdr') {
667 print '<td class="center">';
668 print $form->selectarray($fieldlist[$field], array(0 => $langs->trans('None'), 1 => $langs->trans('AtEndOfMonth'), 2 => $langs->trans('CurrentNext')), (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]} : ''));
669 print '</td>';
670 } elseif ($fieldlist[$field] == 'code' && isset($obj->{$fieldlist[$field]})) {
671 print '<td><input type="text" class="flat" value="'.(!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]} : '').'" size="10" name="'.$fieldlist[$field].'"></td>';
672 } else {
673 print '<td>';
674 $class = '';
675 if ($fieldlist[$field] == 'pcg_version') {
676 $class = 'width150';
677 }
678 if ($fieldlist[$field] == 'label') {
679 $class = 'width300';
680 }
681 print '<input type="text" class="flat'.($class ? ' '.$class : '').'" value="'.(isset($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]} : '').'" name="'.$fieldlist[$field].'">';
682 print '</td>';
683 }
684 }
685}
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:47
fieldListAccountModel($fieldlist, $obj=null, $tabname='', $context='')
Show fields in insert/edit mode.
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 for accounting management.
Class to generate html code for admin pages.
Class to build HTML component for third parties management Only common components are here.
Class to manage generation of HTML components Only common components must be here.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_help($usehelpcursor=1, $usealttitle=1)
Show help logo with cursor "?".
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)
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dolBuildUrl($url, $params=[], $addtoken=false, $anchor='')
Return path of url.
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get 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...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
print_fleche_navigation($page, $file, $options='', $nextpage=0, $betweenarrows='', $afterarrows='', $limit=-1, $totalnboflines=0, $selectlimitsuffix='', $beforearrows='', $hidenavigation=0)
Function to show navigation arrows into lists.
isModEnabled($module)
Is Dolibarr module enabled.
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.
$context
@method int call_trigger(string $triggerName, ?User $user)
Definition logout.php:42
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.