dolibarr  17.0.3
journals_list.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2017-2022 Alexandre Spangaro <aspangaro@open-dsi.fr>
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 
25 if (!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
30 require '../../main.inc.php';
31 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
32 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
33 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
34 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
35 require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
36 require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
37 require_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
49 if (!$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');
65 if (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;
71 if (empty($sortfield)) {
72  $sortfield = 'code';
73 }
74 if (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
138 complete_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 
158 if (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
163 if (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  // Recupere id libre pour insertion
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  //$_GET["id"]=GETPOST('id', 'int'); // Force affichage dictionnaire en cours d'edition
276 }
277 
278 //if (GETPOST('actioncancel', 'alpha'))
279 //{
280 // $_GET["id"]=GETPOST('id', 'int'); // Force affichage dictionnaire en cours d'edition
281 //}
282 
283 if ($action == 'confirm_delete' && $confirm == 'yes') { // delete
284  if ($tabrowid[$id]) {
285  $rowidcol = $tabrowid[$id];
286  } else {
287  $rowidcol = "rowid";
288  }
289 
290  $sql = "DELETE from ".$tabname[$id]." WHERE ".$rowidcol." = ".((int) $rowid);
291  $sql .= " AND entity = ".((int) $conf->entity);
292 
293  dol_syslog("delete", LOG_DEBUG);
294  $result = $db->query($sql);
295  if (!$result) {
296  if ($db->errno() == 'DB_ERROR_CHILD_EXISTS') {
297  setEventMessages($langs->transnoentities("ErrorRecordIsUsedByChild"), null, 'errors');
298  } else {
299  dol_print_error($db);
300  }
301  }
302 }
303 
304 // activate
305 if ($action == $acts[0]) {
306  if ($tabrowid[$id]) {
307  $rowidcol = $tabrowid[$id];
308  } else {
309  $rowidcol = "rowid";
310  }
311 
312  if ($rowid) {
313  $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol." = ".((int) $rowid);
314  } elseif ($code) {
315  $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE code='".$db->escape($code)."'";
316  }
317  $sql .= " AND entity = ".$conf->entity;
318 
319  $result = $db->query($sql);
320  if (!$result) {
321  dol_print_error($db);
322  }
323 }
324 
325 // disable
326 if ($action == $acts[1]) {
327  if ($tabrowid[$id]) {
328  $rowidcol = $tabrowid[$id];
329  } else {
330  $rowidcol = "rowid";
331  }
332 
333  if ($rowid) {
334  $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol." = ".((int) $rowid);
335  } elseif ($code) {
336  $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE code='".$db->escape($code)."'";
337  }
338  $sql .= " AND entity = ".$conf->entity;
339 
340  $result = $db->query($sql);
341  if (!$result) {
342  dol_print_error($db);
343  }
344 }
345 
346 
347 /*
348  * View
349  */
350 
351 $form = new Form($db);
352 $formadmin = new FormAdmin($db);
353 
354 llxHeader();
355 
356 $titre = $langs->trans("DictionarySetup");
357 $linkback = '';
358 if ($id) {
359  $titre .= ' - '.$langs->trans($tablib[$id]);
360  $titlepicto = 'title_accountancy';
361 }
362 
363 print load_fiche_titre($titre, $linkback, $titlepicto);
364 
365 
366 // Confirmation de la suppression de la ligne
367 if ($action == 'delete') {
368  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);
369 }
370 //var_dump($elementList);
371 
372 /*
373  * Show a dictionary
374  */
375 if ($id) {
376  // Complete requete recherche valeurs avec critere de tri
377  $sql = $tabsql[$id];
378  $sql .= " WHERE a.entity = ".((int) $conf->entity);
379 
380  // If sort order is "country", we use country_code instead
381  if ($sortfield == 'country') {
382  $sortfield = 'country_code';
383  }
384  $sql .= $db->order($sortfield, $sortorder);
385  $sql .= $db->plimit($listlimit + 1, $offset);
386 
387  $fieldlist = explode(',', $tabfield[$id]);
388 
389  print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$id.'" method="POST">';
390  print '<input type="hidden" name="token" value="'.newToken().'">';
391  print '<input type="hidden" name="from" value="'.dol_escape_htmltag(GETPOST('from', 'alpha')).'">';
392 
393  print '<div class="div-table-responsive">';
394  print '<table class="noborder centpercent">';
395 
396  // Form to add a new line
397  if ($tabname[$id]) {
398  $fieldlist = explode(',', $tabfield[$id]);
399 
400  // Line for title
401  print '<tr class="liste_titre">';
402  foreach ($fieldlist as $field => $value) {
403  // Determine le nom du champ par rapport aux noms possibles
404  // dans les dictionnaires de donnees
405  $valuetoshow = ucfirst($fieldlist[$field]); // Par defaut
406  $valuetoshow = $langs->trans($valuetoshow); // try to translate
407  $class = "left";
408  if ($fieldlist[$field] == 'code') {
409  $valuetoshow = $langs->trans("Code");
410  }
411  if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') {
412  $valuetoshow = $langs->trans("Label");
413  }
414  if ($fieldlist[$field] == 'nature') {
415  $valuetoshow = $langs->trans("NatureOfJournal");
416  }
417 
418  if ($valuetoshow != '') {
419  print '<td class="'.$class.'">';
420  if (!empty($tabhelp[$id][$value]) && preg_match('/^http(s*):/i', $tabhelp[$id][$value])) {
421  print '<a href="'.$tabhelp[$id][$value].'">'.$valuetoshow.' '.img_help(1, $valuetoshow).'</a>';
422  } elseif (!empty($tabhelp[$id][$value])) {
423  print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value]);
424  } else {
425  print $valuetoshow;
426  }
427  print '</td>';
428  }
429  }
430 
431  print '<td>';
432  print '<input type="hidden" name="id" value="'.$id.'">';
433  print '</td>';
434  print '<td style="min-width: 26px;"></td>';
435  print '<td style="min-width: 26px;"></td>';
436  print '<td style="min-width: 26px;"></td>';
437  print '</tr>';
438 
439  // Line to enter new values
440  print '<tr class="oddeven nodrag nodrap nohover">';
441 
442  $obj = new stdClass();
443  // If data was already input, we define them in obj to populate input fields.
444  if (GETPOST('actionadd', 'alpha')) {
445  foreach ($fieldlist as $key => $val) {
446  if (GETPOST($val) != '') {
447  $obj->$val = GETPOST($val);
448  }
449  }
450  }
451 
452  $tmpaction = 'create';
453  $parameters = array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
454  $reshook = $hookmanager->executeHooks('createDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
455  $error = $hookmanager->error; $errors = $hookmanager->errors;
456 
457  if (empty($reshook)) {
458  fieldListJournal($fieldlist, $obj, $tabname[$id], 'add');
459  }
460 
461  print '<td colspan="4" class="right">';
462  print '<input type="submit" class="button button-add" name="actionadd" value="'.$langs->trans("Add").'">';
463  print '</td>';
464  print "</tr>";
465 
466  print '<tr><td colspan="7">&nbsp;</td></tr>'; // Keep &nbsp; to have a line with enough height
467  }
468 
469 
470 
471  // List of available record in database
472  dol_syslog("htdocs/admin/dict", LOG_DEBUG);
473  $resql = $db->query($sql);
474  if ($resql) {
475  $num = $db->num_rows($resql);
476  $i = 0;
477 
478  $param = '&id='.((int) $id);
479  if ($search_country_id > 0) {
480  $param .= '&search_country_id='.urlencode($search_country_id);
481  }
482  $paramwithsearch = $param;
483  if ($sortorder) {
484  $paramwithsearch .= '&sortorder='.$sortorder;
485  }
486  if ($sortfield) {
487  $paramwithsearch .= '&sortfield='.$sortfield;
488  }
489  if (GETPOST('from', 'alpha')) {
490  $paramwithsearch .= '&from='.GETPOST('from', 'alpha');
491  }
492 
493  // There is several pages
494  if ($num > $listlimit) {
495  print '<tr class="none"><td class="right" colspan="'.(3 + count($fieldlist)).'">';
496  print_fleche_navigation($page, $_SERVER["PHP_SELF"], $paramwithsearch, ($num > $listlimit), '<li class="pagination"><span>'.$langs->trans("Page").' '.($page + 1).'</span></li>');
497  print '</td></tr>';
498  }
499 
500  // Title line with search boxes
501  /*print '<tr class="liste_titre_filter liste_titre_add">';
502  print '<td class="liste_titre"></td>';
503  print '<td class="liste_titre"></td>';
504  print '<td class="liste_titre"></td>';
505  print '<td class="liste_titre"></td>';
506  print '<td class="liste_titre"></td>';
507  print '<td class="liste_titre"></td>';
508  print '<td class="liste_titre center">';
509  $searchpicto=$form->showFilterButtons();
510  print $searchpicto;
511  print '</td>';
512  print '</tr>';
513  */
514 
515  // Title of lines
516  print '<tr class="liste_titre liste_titre_add">';
517  foreach ($fieldlist as $field => $value) {
518  // Determine le nom du champ par rapport aux noms possibles
519  // dans les dictionnaires de donnees
520  $showfield = 1; // By defaut
521  $class = "left";
522  $sortable = 1;
523  $valuetoshow = '';
524  /*
525  $tmparray=getLabelOfField($fieldlist[$field]);
526  $showfield=$tmp['showfield'];
527  $valuetoshow=$tmp['valuetoshow'];
528  $align=$tmp['align'];
529  $sortable=$tmp['sortable'];
530  */
531  $valuetoshow = ucfirst($fieldlist[$field]); // By defaut
532  $valuetoshow = $langs->trans($valuetoshow); // try to translate
533  if ($fieldlist[$field] == 'code') {
534  $valuetoshow = $langs->trans("Code");
535  }
536  if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') {
537  $valuetoshow = $langs->trans("Label");
538  }
539  if ($fieldlist[$field] == 'nature') {
540  $valuetoshow = $langs->trans("NatureOfJournal");
541  }
542 
543  // Affiche nom du champ
544  if ($showfield) {
545  print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], ($sortable ? $fieldlist[$field] : ''), ($page ? 'page='.$page.'&' : ''), $param, "", $sortfield, $sortorder, $class.' ');
546  }
547  }
548  print getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], "active", ($page ? 'page='.$page.'&' : ''), $param, '', $sortfield, $sortorder, 'center ');
549  print getTitleFieldOfList('');
550  print getTitleFieldOfList('');
551  print getTitleFieldOfList('');
552  print '</tr>';
553 
554  if ($num) {
555  // Lines with values
556  while ($i < $num) {
557  $obj = $db->fetch_object($resql);
558  //print_r($obj);
559  print '<tr class="oddeven" id="rowid-'.$obj->rowid.'">';
560  if ($action == 'edit' && ($rowid == (!empty($obj->rowid) ? $obj->rowid : $obj->code))) {
561  $tmpaction = 'edit';
562  $parameters = array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
563  $reshook = $hookmanager->executeHooks('editDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
564  $error = $hookmanager->error; $errors = $hookmanager->errors;
565 
566  // Show fields
567  if (empty($reshook)) {
568  fieldListJournal($fieldlist, $obj, $tabname[$id], 'edit');
569  }
570 
571  print '<td class="center" colspan="4">';
572  print '<input type="hidden" name="page" value="'.$page.'">';
573  print '<input type="hidden" name="rowid" value="'.$rowid.'">';
574  print '<input type="submit" class="button button-edit" name="actionmodify" value="'.$langs->trans("Modify").'">';
575  print '<input type="submit" class="button button-cancel" name="actioncancel" value="'.$langs->trans("Cancel").'">';
576  print '<div name="'.(!empty($obj->rowid) ? $obj->rowid : $obj->code).'"></div>';
577  print '</td>';
578  } else {
579  $tmpaction = 'view';
580  $parameters = array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
581  $reshook = $hookmanager->executeHooks('viewDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
582 
583  $error = $hookmanager->error; $errors = $hookmanager->errors;
584 
585  if (empty($reshook)) {
586  $langs->load("accountancy");
587  foreach ($fieldlist as $field => $value) {
588  $showfield = 1;
589  $class = "left";
590  $valuetoshow = $obj->{$fieldlist[$field]};
591  if ($valuetoshow == 'all') {
592  $valuetoshow = $langs->trans('All');
593  } elseif ($fieldlist[$field] == 'nature' && $tabname[$id] == MAIN_DB_PREFIX.'accounting_journal') {
594  $key = $langs->trans("AccountingJournalType".strtoupper($obj->nature));
595  $valuetoshow = ($obj->nature && $key != "AccountingJournalType".strtoupper($langs->trans($obj->nature)) ? $key : $obj->{$fieldlist[$field]});
596  } elseif ($fieldlist[$field] == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'accounting_journal') {
597  $valuetoshow = $langs->trans($obj->label);
598  }
599 
600  $class = 'tddict';
601  // Show value for field
602  if ($showfield) {
603  print '<!-- '.$fieldlist[$field].' --><td class="'.$class.'">'.dol_escape_htmltag($valuetoshow).'</td>';
604  }
605  }
606  }
607 
608  // Can an entry be erased or disabled ?
609  $iserasable = 1; $canbedisabled = 1; $canbemodified = 1; // true by default
610  if (isset($obj->code) && $id != 10) {
611  if (($obj->code == '0' || $obj->code == '' || preg_match('/unknown/i', $obj->code))) {
612  $iserasable = 0;
613  $canbedisabled = 0;
614  }
615  }
616 
617  $canbemodified = $iserasable;
618 
619  $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) : '');
620  if ($param) {
621  $url .= '&'.$param;
622  }
623  $url .= '&';
624 
625  // Active
626  print '<td class="nowrap center">';
627  if ($canbedisabled) {
628  print '<a href="'.$url.'action='.$acts[$obj->active].'&token='.newToken().'">'.$actl[$obj->active].'</a>';
629  } else {
630  print $langs->trans("AlwaysActive");
631  }
632  print "</td>";
633 
634  // Modify link
635  if ($canbemodified) {
636  print '<td class="center"><a class="reposition editfielda" href="'.$url.'action=edit&token='.newToken().'">'.img_edit().'</a></td>';
637  } else {
638  print '<td>&nbsp;</td>';
639  }
640 
641  // Delete link
642  if ($iserasable) {
643  print '<td class="center">';
644  if ($user->admin) {
645  print '<a href="'.$url.'action=delete&token='.newToken().'">'.img_delete().'</a>';
646  }
647  //else print '<a href="#">'.img_delete().'</a>'; // Some dictionary can be edited by other profile than admin
648  print '</td>';
649  } else {
650  print '<td>&nbsp;</td>';
651  }
652 
653  print '<td></td>';
654 
655  print '</td>';
656  }
657 
658  print "</tr>\n";
659  $i++;
660  }
661  }
662  } else {
663  dol_print_error($db);
664  }
665 
666  print '</table>';
667  print '</div>';
668 
669  print '</form>';
670 }
671 
672 print '<br>';
673 
674 // End of page
675 llxFooter();
676 $db->close();
677 
678 
688 function fieldListJournal($fieldlist, $obj = '', $tabname = '', $context = '')
689 {
690  global $conf, $langs, $db;
691  global $form, $mysoc;
692  global $region_id;
693  global $elementList, $sourceList, $localtax_typeList;
694  global $bc;
695 
696  $formadmin = new FormAdmin($db);
697  $formcompany = new FormCompany($db);
698 
699  foreach ($fieldlist as $field => $value) {
700  if ($fieldlist[$field] == 'nature') {
701  print '<td>';
702  print $form->selectarray('nature', $sourceList, (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:''));
703  print '</td>';
704  } elseif ($fieldlist[$field] == 'code' && isset($obj->{$fieldlist[$field]})) {
705  print '<td><input type="text" class="flat minwidth100" value="'.(!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:'').'" name="'.$fieldlist[$field].'"></td>';
706  } else {
707  print '<td>';
708  $size = ''; $class = '';
709  if ($fieldlist[$field] == 'code') {
710  $class = 'maxwidth100';
711  }
712  if ($fieldlist[$field] == 'label') {
713  $class = 'quatrevingtpercent';
714  }
715  if ($fieldlist[$field] == 'sortorder' || $fieldlist[$field] == 'sens' || $fieldlist[$field] == 'category_type') {
716  $size = 'size="2" ';
717  }
718  print '<input type="text" '.$size.'class="flat'.($class ? ' '.$class : '').'" value="'.(isset($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:'').'" name="'.$fieldlist[$field].'">';
719  print '</td>';
720  }
721  }
722 }
dol_escape_htmltag
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
Definition: functions.lib.php:1493
fieldListJournal
fieldListJournal($fieldlist, $obj='', $tabname='', $context='')
Show fields in insert/edit mode.
Definition: journals_list.php:688
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:70
getTitleFieldOfList
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get title line of an array.
Definition: functions.lib.php:5201
load_fiche_titre
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
Definition: functions.lib.php:5360
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:520
dol_print_error
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
Definition: functions.lib.php:4993
complete_dictionary_with_modules
complete_dictionary_with_modules(&$taborder, &$tabname, &$tablib, &$tabsql, &$tabsqlsort, &$tabfield, &$tabfieldvalue, &$tabfieldinsert, &$tabrowid, &$tabcond, &$tabhelp, &$tabcomplete)
Add external modules to list of dictionaries.
Definition: admin.lib.php:1297
img_help
img_help($usehelpcursor=1, $usealttitle=1)
Show help logo with cursor "?".
Definition: functions.lib.php:4630
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
FormAdmin
Class to generate html code for admin pages.
Definition: html.formadmin.class.php:30
img_edit
img_edit($titlealt='default', $float=0, $other='')
Show logo editer/modifier fiche.
Definition: functions.lib.php:4538
FormCompany
Class to build HTML component for third parties management Only common components are here.
Definition: html.formcompany.class.php:40
img_picto
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
Definition: functions.lib.php:4024
llxHeader
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:56
img_delete
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
Definition: functions.lib.php:4578
$resql
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
Definition: index.php:745
dol_syslog
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
Definition: functions.lib.php:1628
newToken
newToken()
Return the value of token currently saved into session with name 'newtoken'.
Definition: functions.lib.php:11290
isModEnabled
isModEnabled($module)
Is Dolibarr module enabled.
Definition: functions.lib.php:137
GETPOSTISSET
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
Definition: functions.lib.php:421
Form
Class to manage generation of HTML components Only common components must be here.
Definition: html.form.class.php:53
print_fleche_navigation
print_fleche_navigation($page, $file, $options='', $nextpage=0, $betweenarrows='', $afterarrows='', $limit=-1, $totalnboflines=0, $hideselectlimit=0, $beforearrows='')
Function to show navigation arrows into lists.
Definition: functions.lib.php:5559
setEventMessages
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
Definition: functions.lib.php:8465
accessforbidden
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.
Definition: security.lib.php:1120