dolibarr 19.0.4
journals_list.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2017-2024 Alexandre Spangaro <aspangaro@easya.solutions>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 *
17 */
18
25if (!defined('CSRFCHECK_WITH_TOKEN')) {
26 define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET
27}
28
29// Load Dolibarr environment
30require '../../main.inc.php';
31require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
32require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
33require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
34require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
35require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
36require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
37require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
38
39// Load translation files required by the page
40$langs->loadLangs(array("admin", "compta", "accountancy"));
41
42$action = GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view';
43$confirm = GETPOST('confirm', 'alpha');
44$id = 35;
45$rowid = GETPOST('rowid', 'alpha');
46$code = GETPOST('code', 'alpha');
47
48// Security access
49if (!$user->hasRight('accounting', 'chartofaccount')) {
51}
52
53$acts[0] = "activate";
54$acts[1] = "disable";
55$actl[0] = img_picto($langs->trans("Disabled"), 'switch_off', 'class="size15x"');
56$actl[1] = img_picto($langs->trans("Activated"), 'switch_on', 'class="size15x"');
57
58$listoffset = GETPOST('listoffset', 'alpha');
59$listlimit = GETPOST('listlimit', 'int') > 0 ? GETPOST('listlimit', 'int') : 1000;
60$active = 1;
61
62$sortfield = GETPOST('sortfield', 'aZ09comma');
63$sortorder = GETPOST('sortorder', 'aZ09comma');
64$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
65if (empty($page) || $page == -1) {
66 $page = 0;
67} // If $page is not defined, or '' or -1
68$offset = $listlimit * $page;
69$pageprev = $page - 1;
70$pagenext = $page + 1;
71if (empty($sortfield)) {
72 $sortfield = 'code';
73}
74if (empty($sortorder)) {
75 $sortorder = 'ASC';
76}
77
78$error = 0;
79
80$search_country_id = GETPOST('search_country_id', 'int');
81
82// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
83$hookmanager->initHooks(array('admin'));
84
85// This page is a generic page to edit dictionaries
86// Put here declaration of dictionaries properties
87
88// Sort order to show dictionary (0 is space). All other dictionaries (added by modules) will be at end of this.
89$taborder = array(35);
90
91// Name of SQL tables of dictionaries
92$tabname = array();
93$tabname[35] = MAIN_DB_PREFIX."accounting_journal";
94
95// Dictionary labels
96$tablib = array();
97$tablib[35] = "DictionaryAccountancyJournal";
98
99// Requests to extract data
100$tabsql = array();
101$tabsql[35] = "SELECT a.rowid as rowid, a.code as code, a.label, a.nature, a.active FROM ".MAIN_DB_PREFIX."accounting_journal as a";
102
103// Criteria to sort dictionaries
104$tabsqlsort = array();
105$tabsqlsort[35] = "code ASC";
106
107// Nom des champs en resultat de select pour affichage du dictionnaire
108$tabfield = array();
109$tabfield[35] = "code,label,nature";
110
111// Nom des champs d'edition pour modification d'un enregistrement
112$tabfieldvalue = array();
113$tabfieldvalue[35] = "code,label,nature";
114
115// Nom des champs dans la table pour insertion d'un enregistrement
116$tabfieldinsert = array();
117$tabfieldinsert[35] = "code,label,nature";
118
119// Nom du rowid si le champ n'est pas de type autoincrement
120// Example: "" if id field is "rowid" and has autoincrement on
121// "nameoffield" if id field is not "rowid" or has not autoincrement on
122$tabrowid = array();
123$tabrowid[35] = "";
124
125// Condition to show dictionary in setup page
126$tabcond = array();
127$tabcond[35] = isModEnabled('accounting');
128
129// List of help for fields
130$tabhelp = array();
131$tabhelp[35] = array('code'=>$langs->trans("EnterAnyCode"));
132
133// List of check for fields (NOT USED YET)
134$tabfieldcheck = array();
135$tabfieldcheck[35] = array();
136
137// Complete all arrays with entries found into modules
138complete_dictionary_with_modules($taborder, $tabname, $tablib, $tabsql, $tabsqlsort, $tabfield, $tabfieldvalue, $tabfieldinsert, $tabrowid, $tabcond, $tabhelp, $tabfieldcheck);
139
140
141// Define elementList and sourceList (used for dictionary type of contacts "llx_c_type_contact")
142$elementList = array();
143// Must match ids defined into eldy.lib.php
144$sourceList = array(
145 '1' => $langs->trans('AccountingJournalType1'),
146 '2' => $langs->trans('AccountingJournalType2'),
147 '3' => $langs->trans('AccountingJournalType3'),
148 '4' => $langs->trans('AccountingJournalType4'),
149 '5' => $langs->trans('AccountingJournalType5'),
150 '8' => $langs->trans('AccountingJournalType8'),
151 '9' => $langs->trans('AccountingJournalType9'),
152);
153
154/*
155 * Actions
156 */
157
158if (GETPOST('button_removefilter', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter_x', 'alpha')) {
159 $search_country_id = '';
160}
161
162// Actions add or modify an entry into a dictionary
163if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) {
164 $listfield = explode(',', str_replace(' ', '', $tabfield[$id]));
165 $listfieldinsert = explode(',', $tabfieldinsert[$id]);
166 $listfieldmodify = explode(',', $tabfieldinsert[$id]);
167 $listfieldvalue = explode(',', $tabfieldvalue[$id]);
168
169 // Check that all fields are filled
170 $ok = 1;
171
172 // Other checks
173 if (GETPOSTISSET("code")) {
174 if (GETPOST("code") == '0') {
175 $ok = 0;
176 setEventMessages($langs->transnoentities('ErrorCodeCantContainZero'), null, 'errors');
177 }
178 }
179 if (!GETPOST('label', 'alpha')) {
180 setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors');
181 $ok = 0;
182 }
183
184 // Si verif ok et action add, on ajoute la ligne
185 if ($ok && GETPOST('actionadd', 'alpha')) {
186 if ($tabrowid[$id]) {
187 // Get free id for insert
188 $newid = 0;
189 $sql = "SELECT MAX(".$tabrowid[$id].") newid from ".$tabname[$id];
190 $result = $db->query($sql);
191 if ($result) {
192 $obj = $db->fetch_object($result);
193 $newid = ($obj->newid + 1);
194 } else {
195 dol_print_error($db);
196 }
197 }
198
199 // Add new entry
200 $sql = "INSERT INTO ".$tabname[$id]." (";
201 // List of fields
202 if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert)) {
203 $sql .= $tabrowid[$id].",";
204 }
205 $sql .= $tabfieldinsert[$id];
206 $sql .= ",active,entity)";
207 $sql .= " VALUES(";
208
209 // List of values
210 if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert)) {
211 $sql .= $newid.",";
212 }
213 $i = 0;
214 foreach ($listfieldinsert as $f => $value) {
215 if ($i) {
216 $sql .= ",";
217 }
218 if (GETPOST($listfieldvalue[$i]) == '') {
219 $sql .= "null"; // For vat, we want/accept code = ''
220 } else {
221 $sql .= "'".$db->escape(GETPOST($listfieldvalue[$i]))."'";
222 }
223 $i++;
224 }
225 $sql .= ",1,".$conf->entity.")";
226
227 dol_syslog("actionadd", LOG_DEBUG);
228 $result = $db->query($sql);
229 if ($result) { // Add is ok
230 setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs');
231 $_POST = array('id'=>$id); // Clean $_POST array, we keep only id
232 } else {
233 if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
234 setEventMessages($langs->transnoentities("ErrorRecordAlreadyExists"), null, 'errors');
235 } else {
236 dol_print_error($db);
237 }
238 }
239 }
240
241 // Si verif ok et action modify, on modifie la ligne
242 if ($ok && GETPOST('actionmodify', 'alpha')) {
243 if ($tabrowid[$id]) {
244 $rowidcol = $tabrowid[$id];
245 } else {
246 $rowidcol = "rowid";
247 }
248
249 // Modify entry
250 $sql = "UPDATE ".$tabname[$id]." SET ";
251 // Modifie valeur des champs
252 if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldmodify)) {
253 $sql .= $tabrowid[$id]."=";
254 $sql .= "'".$db->escape($rowid)."', ";
255 }
256 $i = 0;
257 foreach ($listfieldmodify as $field) {
258 if ($i) {
259 $sql .= ",";
260 }
261 $sql .= $field." = ";
262 $sql .= "'".$db->escape(GETPOST($listfieldvalue[$i]))."'";
263 $i++;
264 }
265 $sql .= " WHERE ".$rowidcol." = ".((int) $rowid);
266 $sql .= " AND entity = ".((int) $conf->entity);
267
268 dol_syslog("actionmodify", LOG_DEBUG);
269 //print $sql;
270 $resql = $db->query($sql);
271 if (!$resql) {
272 setEventMessages($db->error(), null, 'errors');
273 }
274 }
275}
276
277if ($action == 'confirm_delete' && $confirm == 'yes') { // delete
278 if ($tabrowid[$id]) {
279 $rowidcol = $tabrowid[$id];
280 } else {
281 $rowidcol = "rowid";
282 }
283
284 $sql = "DELETE from ".$tabname[$id]." WHERE ".$rowidcol." = ".((int) $rowid);
285 $sql .= " AND entity = ".((int) $conf->entity);
286
287 dol_syslog("delete", LOG_DEBUG);
288 $result = $db->query($sql);
289 if (!$result) {
290 if ($db->errno() == 'DB_ERROR_CHILD_EXISTS') {
291 setEventMessages($langs->transnoentities("ErrorRecordIsUsedByChild"), null, 'errors');
292 } else {
293 dol_print_error($db);
294 }
295 }
296}
297
298// activate
299if ($action == $acts[0]) {
300 if ($tabrowid[$id]) {
301 $rowidcol = $tabrowid[$id];
302 } else {
303 $rowidcol = "rowid";
304 }
305
306 if ($rowid) {
307 $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol." = ".((int) $rowid);
308 } elseif ($code) {
309 $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE code='".$db->escape($code)."'";
310 }
311 $sql .= " AND entity = ".$conf->entity;
312
313 $result = $db->query($sql);
314 if (!$result) {
315 dol_print_error($db);
316 }
317}
318
319// disable
320if ($action == $acts[1]) {
321 if ($tabrowid[$id]) {
322 $rowidcol = $tabrowid[$id];
323 } else {
324 $rowidcol = "rowid";
325 }
326
327 if ($rowid) {
328 $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol." = ".((int) $rowid);
329 } elseif ($code) {
330 $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE code='".$db->escape($code)."'";
331 }
332 $sql .= " AND entity = ".$conf->entity;
333
334 $result = $db->query($sql);
335 if (!$result) {
336 dol_print_error($db);
337 }
338}
339
340
341/*
342 * View
343 */
344
345$form = new Form($db);
346$formadmin = new FormAdmin($db);
347
348$title = $langs->trans('AccountingJournals');
349$help_url = 'EN:Module_Double_Entry_Accounting#Setup|FR:Module_Comptabilit&eacute;_en_Partie_Double#Configuration';
350llxHeader('', $title, $help_url);
351
352$titre = $langs->trans("DictionarySetup");
353$linkback = '';
354if ($id) {
355 $titre .= ' - '.$langs->trans($tablib[$id]);
356 $titlepicto = 'title_accountancy';
357}
358
359print load_fiche_titre($titre, $linkback, $titlepicto);
360
361
362// Confirmation de la suppression de la ligne
363if ($action == 'delete') {
364 print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.$rowid.'&code='.$code.'&id='.$id, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete', '', 0, 1);
365}
366
367/*
368 * Show a dictionary
369 */
370if ($id) {
371 // Complete requete recherche valeurs avec critere de tri
372 $sql = $tabsql[$id];
373 $sql .= " WHERE a.entity = ".((int) $conf->entity);
374
375 // If sort order is "country", we use country_code instead
376 if ($sortfield == 'country') {
377 $sortfield = 'country_code';
378 }
379 $sql .= $db->order($sortfield, $sortorder);
380 $sql .= $db->plimit($listlimit + 1, $offset);
381
382 $fieldlist = explode(',', $tabfield[$id]);
383
384 print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$id.'" method="POST">';
385 print '<input type="hidden" name="token" value="'.newToken().'">';
386 print '<input type="hidden" name="from" value="'.dol_escape_htmltag(GETPOST('from', 'alpha')).'">';
387
388 print '<div class="div-table-responsive">';
389 print '<table class="noborder centpercent">';
390
391 // Form to add a new line
392 if ($tabname[$id]) {
393 $fieldlist = explode(',', $tabfield[$id]);
394
395 // Line for title
396 print '<tr class="liste_titre">';
397 foreach ($fieldlist as $field => $value) {
398 // Determine le nom du champ par rapport aux noms possibles
399 // dans les dictionnaires de donnees
400 $valuetoshow = ucfirst($fieldlist[$field]); // Par defaut
401 $valuetoshow = $langs->trans($valuetoshow); // try to translate
402 $class = "left";
403 if ($fieldlist[$field] == 'code') {
404 $valuetoshow = $langs->trans("Code");
405 }
406 if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') {
407 $valuetoshow = $langs->trans("Label");
408 }
409 if ($fieldlist[$field] == 'nature') {
410 $valuetoshow = $langs->trans("NatureOfJournal");
411 }
412
413 if ($valuetoshow != '') {
414 print '<td class="'.$class.'">';
415 if (!empty($tabhelp[$id][$value]) && preg_match('/^http(s*):/i', $tabhelp[$id][$value])) {
416 print '<a href="'.$tabhelp[$id][$value].'">'.$valuetoshow.' '.img_help(1, $valuetoshow).'</a>';
417 } elseif (!empty($tabhelp[$id][$value])) {
418 print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value]);
419 } else {
420 print $valuetoshow;
421 }
422 print '</td>';
423 }
424 }
425
426 print '<td>';
427 print '<input type="hidden" name="id" value="'.$id.'">';
428 print '</td>';
429 print '<td></td>';
430 print '<td></td>';
431 print '<td></td>';
432 print '</tr>';
433
434 // Line to enter new values
435 print '<tr class="oddeven nodrag nodrap nohover">';
436
437 $obj = new stdClass();
438 // If data was already input, we define them in obj to populate input fields.
439 if (GETPOST('actionadd', 'alpha')) {
440 foreach ($fieldlist as $key => $val) {
441 if (GETPOST($val) != '') {
442 $obj->$val = GETPOST($val);
443 }
444 }
445 }
446
447 $tmpaction = 'create';
448 $parameters = array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
449 $reshook = $hookmanager->executeHooks('createDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
450 $error = $hookmanager->error;
451 $errors = $hookmanager->errors;
452
453 if (empty($reshook)) {
454 fieldListJournal($fieldlist, $obj, $tabname[$id], 'add');
455 }
456
457 print '<td colspan="4" class="right">';
458 print '<input type="submit" class="button button-add" name="actionadd" value="'.$langs->trans("Add").'">';
459 print '</td>';
460 print "</tr>";
461
462 print '<tr><td colspan="7">&nbsp;</td></tr>'; // Keep &nbsp; to have a line with enough height
463 }
464
465
466
467 // List of available record in database
468 dol_syslog("htdocs/admin/dict", LOG_DEBUG);
469 $resql = $db->query($sql);
470 if ($resql) {
471 $num = $db->num_rows($resql);
472 $i = 0;
473
474 $param = '&id='.((int) $id);
475 if ($search_country_id > 0) {
476 $param .= '&search_country_id='.urlencode($search_country_id);
477 }
478 $paramwithsearch = $param;
479 if ($sortorder) {
480 $paramwithsearch .= '&sortorder='.$sortorder;
481 }
482 if ($sortfield) {
483 $paramwithsearch .= '&sortfield='.$sortfield;
484 }
485 if (GETPOST('from', 'alpha')) {
486 $paramwithsearch .= '&from='.GETPOST('from', 'alpha');
487 }
488
489 // There is several pages
490 if ($num > $listlimit) {
491 print '<tr class="none"><td class="right" colspan="'.(3 + count($fieldlist)).'">';
492 print_fleche_navigation($page, $_SERVER["PHP_SELF"], $paramwithsearch, ($num > $listlimit), '<li class="pagination"><span>'.$langs->trans("Page").' '.($page + 1).'</span></li>');
493 print '</td></tr>';
494 }
495
496 // Title line with search boxes
497 /*print '<tr class="liste_titre_filter liste_titre_add">';
498 print '<td class="liste_titre"></td>';
499 print '<td class="liste_titre"></td>';
500 print '<td class="liste_titre"></td>';
501 print '<td class="liste_titre"></td>';
502 print '<td class="liste_titre"></td>';
503 print '<td class="liste_titre"></td>';
504 print '<td class="liste_titre center">';
505 $searchpicto=$form->showFilterButtons();
506 print $searchpicto;
507 print '</td>';
508 print '</tr>';
509 */
510
511 // Title of lines
512 print '<tr class="liste_titre liste_titre_add">';
513 foreach ($fieldlist as $field => $value) {
514 // Determine le nom du champ par rapport aux noms possibles
515 // dans les dictionnaires de donnees
516 $showfield = 1; // By defaut
517 $class = "left";
518 $sortable = 1;
519 $valuetoshow = '';
520 /*
521 $tmparray=getLabelOfField($fieldlist[$field]);
522 $showfield=$tmp['showfield'];
523 $valuetoshow=$tmp['valuetoshow'];
524 $align=$tmp['align'];
525 $sortable=$tmp['sortable'];
526 */
527 $valuetoshow = ucfirst($fieldlist[$field]); // By defaut
528 $valuetoshow = $langs->trans($valuetoshow); // try to translate
529 if ($fieldlist[$field] == 'code') {
530 $valuetoshow = $langs->trans("Code");
531 }
532 if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') {
533 $valuetoshow = $langs->trans("Label");
534 }
535 if ($fieldlist[$field] == 'nature') {
536 $valuetoshow = $langs->trans("NatureOfJournal");
537 }
538
539 // Affiche nom du champ
540 if ($showfield) {
541 print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], ($sortable ? $fieldlist[$field] : ''), ($page ? 'page='.$page.'&' : ''), $param, "", $sortfield, $sortorder, $class.' ');
542 }
543 }
544 print getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], "active", ($page ? 'page='.$page.'&' : ''), $param, '', $sortfield, $sortorder, 'center ');
545 print getTitleFieldOfList('');
546 print getTitleFieldOfList('');
547 print getTitleFieldOfList('');
548 print '</tr>';
549
550 if ($num) {
551 // Lines with values
552 while ($i < $num) {
553 $obj = $db->fetch_object($resql);
554 //print_r($obj);
555 print '<tr class="oddeven" id="rowid-'.$obj->rowid.'">';
556 if ($action == 'edit' && ($rowid == (!empty($obj->rowid) ? $obj->rowid : $obj->code))) {
557 $tmpaction = 'edit';
558 $parameters = array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
559 $reshook = $hookmanager->executeHooks('editDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
560 $error = $hookmanager->error;
561 $errors = $hookmanager->errors;
562
563 // Show fields
564 if (empty($reshook)) {
565 fieldListJournal($fieldlist, $obj, $tabname[$id], 'edit');
566 }
567
568 print '<td class="center" colspan="4">';
569 print '<input type="hidden" name="page" value="'.$page.'">';
570 print '<input type="hidden" name="rowid" value="'.$rowid.'">';
571 print '<input type="submit" class="button button-edit" name="actionmodify" value="'.$langs->trans("Modify").'">';
572 print '<input type="submit" class="button button-cancel" name="actioncancel" value="'.$langs->trans("Cancel").'">';
573 print '<div name="'.(!empty($obj->rowid) ? $obj->rowid : $obj->code).'"></div>';
574 print '</td>';
575 } else {
576 $tmpaction = 'view';
577 $parameters = array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
578 $reshook = $hookmanager->executeHooks('viewDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
579
580 $error = $hookmanager->error;
581 $errors = $hookmanager->errors;
582
583 if (empty($reshook)) {
584 $langs->load("accountancy");
585 foreach ($fieldlist as $field => $value) {
586 $showfield = 1;
587 $class = "left";
588 $tmpvar = $fieldlist[$field];
589 $valuetoshow = $obj->$tmpvar;
590 if ($valuetoshow == 'all') {
591 $valuetoshow = $langs->trans('All');
592 } elseif ($fieldlist[$field] == 'nature' && $tabname[$id] == MAIN_DB_PREFIX.'accounting_journal') {
593 $key = $langs->trans("AccountingJournalType".strtoupper($obj->nature));
594 $valuetoshow = ($obj->nature && $key != "AccountingJournalType".strtoupper($langs->trans($obj->nature)) ? $key : $obj->{$fieldlist[$field]});
595 } elseif ($fieldlist[$field] == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'accounting_journal') {
596 $valuetoshow = $langs->trans($obj->label);
597 }
598
599 $class = 'tddict';
600 // Show value for field
601 if ($showfield) {
602 print '<!-- '.$fieldlist[$field].' --><td class="'.$class.'">'.dol_escape_htmltag($valuetoshow).'</td>';
603 }
604 }
605 }
606
607 // Can an entry be erased or disabled ?
608 $iserasable = 1;
609 $canbedisabled = 1;
610 $canbemodified = 1; // true by default
611 if (isset($obj->code) && $id != 10) {
612 if (($obj->code == '0' || $obj->code == '' || preg_match('/unknown/i', $obj->code))) {
613 $iserasable = 0;
614 $canbedisabled = 0;
615 }
616 }
617
618 $canbemodified = $iserasable;
619
620 $url = $_SERVER["PHP_SELF"].'?'.($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) : '');
621 if ($param) {
622 $url .= '&'.$param;
623 }
624 $url .= '&';
625
626 // Active
627 print '<td class="nowrap center">';
628 if ($canbedisabled) {
629 print '<a href="'.$url.'action='.$acts[$obj->active].'&token='.newToken().'">'.$actl[$obj->active].'</a>';
630 } else {
631 print $langs->trans("AlwaysActive");
632 }
633 print "</td>";
634
635 // Modify link
636 if ($canbemodified) {
637 print '<td class="center"><a class="reposition editfielda" href="'.$url.'action=edit&token='.newToken().'">'.img_edit().'</a></td>';
638 } else {
639 print '<td>&nbsp;</td>';
640 }
641
642 // Delete link
643 if ($iserasable) {
644 print '<td class="center">';
645 if ($user->admin) {
646 print '<a href="'.$url.'action=delete&token='.newToken().'">'.img_delete().'</a>';
647 }
648 //else print '<a href="#">'.img_delete().'</a>'; // Some dictionary can be edited by other profile than admin
649 print '</td>';
650 } else {
651 print '<td>&nbsp;</td>';
652 }
653
654 print '<td></td>';
655
656 print '</td>';
657 }
658
659 print "</tr>\n";
660 $i++;
661 }
662 }
663 } else {
664 dol_print_error($db);
665 }
666
667 print '</table>';
668 print '</div>';
669
670 print '</form>';
671}
672
673print '<br>';
674
675// End of page
676llxFooter();
677$db->close();
678
679
689function fieldListJournal($fieldlist, $obj = null, $tabname = '', $context = '')
690{
691 global $conf, $langs, $db;
692 global $form, $mysoc;
693 global $region_id;
694 global $elementList, $sourceList, $localtax_typeList;
695 global $bc;
696
697 $formadmin = new FormAdmin($db);
698 $formcompany = new FormCompany($db);
699
700 foreach ($fieldlist as $field => $value) {
701 if ($fieldlist[$field] == 'nature') {
702 print '<td>';
703 print $form->selectarray('nature', $sourceList, (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]} : ''));
704 print '</td>';
705 } elseif ($fieldlist[$field] == 'code' && isset($obj->{$fieldlist[$field]})) {
706 print '<td><input type="text" class="flat minwidth100" value="'.(!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]} : '').'" name="'.$fieldlist[$field].'"></td>';
707 } else {
708 print '<td>';
709 $size = '';
710 $class = '';
711 if ($fieldlist[$field] == 'code') {
712 $class = 'maxwidth100';
713 }
714 if ($fieldlist[$field] == 'label') {
715 $class = 'quatrevingtpercent';
716 }
717 if ($fieldlist[$field] == 'sortorder' || $fieldlist[$field] == 'sens' || $fieldlist[$field] == 'category_type') {
718 $size = 'size="2" ';
719 }
720 print '<input type="text" '.$size.'class="flat'.($class ? ' '.$class : '').'" value="'.(isset($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]} : '').'" name="'.$fieldlist[$field].'">';
721 print '</td>';
722 }
723 }
724}
complete_dictionary_with_modules(&$taborder, &$tabname, &$tablib, &$tabsql, &$tabsqlsort, &$tabfield, &$tabfieldvalue, &$tabfieldinsert, &$tabrowid, &$tabcond, &$tabhelp, &$tabcomplete)
Add external modules to list of dictionaries.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Definition wrapper.php:55
llxFooter()
Empty footer.
Definition wrapper.php:69
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.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_help($usehelpcursor=1, $usealttitle=1)
Show help logo with cursor "?".
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
print_fleche_navigation($page, $file, $options='', $nextpage=0, $betweenarrows='', $afterarrows='', $limit=-1, $totalnboflines=0, $hideselectlimit=0, $beforearrows='', $hidenavigation=0)
Function to show navigation arrows into lists.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
img_edit($titlealt='default', $float=0, $other='')
Show logo editer/modifier 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...
fieldListJournal($fieldlist, $obj=null, $tabname='', $context='')
Show fields in insert/edit mode.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.