dolibarr  13.0.2
index.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
3  * Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
4  * Copyright (C) 2013-2019 Alexandre Spangaro <aspangaro@open-dsi.fr>
5  * Copyright (C) 2014-2015 Ari Elbaz (elarifr) <github@accedinfo.com>
6  * Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
7  * Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
8  * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
9  * Copyright (C) 2017 Laurent Destailleur <eldy@destailleur.fr>
10  * Copyright (C) 2021 Ferran Marcet <fmarcet@2byte.es>
11  *
12  * This program is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation; either version 3 of the License, or
15  * (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program. If not, see <https://www.gnu.org/licenses/>.
24  */
25 
32 require '../../main.inc.php';
33 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
34 require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
35 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
36 
37 // Load translation files required by the page
38 $langs->loadLangs(array("compta", "bills", "admin", "accountancy", "other"));
39 
40 // Security access
41 if (empty($user->rights->accounting->chartofaccount))
42 {
44 }
45 
46 $action = GETPOST('action', 'aZ09');
47 
48 // Parameters ACCOUNTING_* and others
49 $list = array(
50  'ACCOUNTING_LENGTH_GACCOUNT',
51  'ACCOUNTING_LENGTH_AACCOUNT',
52 // 'ACCOUNTING_LENGTH_DESCRIPTION', // adjust size displayed for lines description for dol_trunc
53 // 'ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT', // adjust size displayed for select account description for dol_trunc
54 );
55 
56 $list_binding = array(
57  'ACCOUNTING_DATE_START_BINDING',
58  'ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER'
59 );
60 
61 /*
62  * Actions
63  */
64 
65 if ($action == 'update') {
66  $error = 0;
67 
68  if (!$error)
69  {
70  foreach ($list as $constname)
71  {
72  $constvalue = GETPOST($constname, 'alpha');
73 
74  if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
75  $error++;
76  }
77  }
78  if ($error) {
79  setEventMessages($langs->trans("Error"), null, 'errors');
80  }
81 
82  foreach ($list_binding as $constname)
83  {
84  $constvalue = GETPOST($constname, 'alpha');
85 
86  if ($constname == 'ACCOUNTING_DATE_START_BINDING') {
87  $constvalue = dol_mktime(12, 0, 0, GETPOST($constname.'month', 'int'), GETPOST($constname.'day', 'int'), GETPOST($constname.'year', 'int'));
88  }
89 
90  if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
91  $error++;
92  }
93  }
94  if ($error) {
95  setEventMessages($langs->trans("Error"), null, 'errors');
96  }
97  }
98 
99  if (!$error) {
100  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
101  }
102 }
103 
104 if ($action == 'setlistsorttodo') {
105  $setlistsorttodo = GETPOST('value', 'int');
106  $res = dolibarr_set_const($db, "ACCOUNTING_LIST_SORT_VENTILATION_TODO", $setlistsorttodo, 'yesno', 0, '', $conf->entity);
107  if (!($res > 0)) {
108  $error++;
109  }
110 
111  if (!$error) {
112  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
113  } else {
114  setEventMessages($langs->trans("Error"), null, 'mesgs');
115  }
116 }
117 
118 if ($action == 'setlistsortdone') {
119  $setlistsortdone = GETPOST('value', 'int');
120  $res = dolibarr_set_const($db, "ACCOUNTING_LIST_SORT_VENTILATION_DONE", $setlistsortdone, 'yesno', 0, '', $conf->entity);
121  if (!($res > 0)) {
122  $error++;
123  }
124 
125  if (!$error) {
126  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
127  } else {
128  setEventMessages($langs->trans("Error"), null, 'mesgs');
129  }
130 }
131 
132 if ($action == 'setmanagezero') {
133  $setmanagezero = GETPOST('value', 'int');
134  $res = dolibarr_set_const($db, "ACCOUNTING_MANAGE_ZERO", $setmanagezero, 'yesno', 0, '', $conf->entity);
135  if (!($res > 0)) {
136  $error++;
137  }
138 
139  if (!$error) {
140  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
141  } else {
142  setEventMessages($langs->trans("Error"), null, 'mesgs');
143  }
144 }
145 
146 if ($action == 'setdisabledirectinput') {
147  $setdisabledirectinput = GETPOST('value', 'int');
148  $res = dolibarr_set_const($db, "BANK_DISABLE_DIRECT_INPUT", $setdisabledirectinput, 'yesno', 0, '', $conf->entity);
149  if (!($res > 0)) {
150  $error++;
151  }
152 
153  if (!$error) {
154  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
155  } else {
156  setEventMessages($langs->trans("Error"), null, 'mesgs');
157  }
158 }
159 
160 if ($action == 'setenabledraftexport') {
161  $setenabledraftexport = GETPOST('value', 'int');
162  $res = dolibarr_set_const($db, "ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL", $setenabledraftexport, 'yesno', 0, '', $conf->entity);
163  if (!($res > 0)) {
164  $error++;
165  }
166 
167  if (!$error) {
168  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
169  } else {
170  setEventMessages($langs->trans("Error"), null, 'mesgs');
171  }
172 }
173 
174 if ($action == 'setenablesubsidiarylist') {
175  $setenablesubsidiarylist = GETPOST('value', 'int');
176  $res = dolibarr_set_const($db, "ACCOUNTANCY_COMBO_FOR_AUX", $setenablesubsidiarylist, 'yesno', 0, '', $conf->entity);
177  if (!($res > 0)) {
178  $error++;
179  }
180 
181  if (!$error) {
182  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
183  } else {
184  setEventMessages($langs->trans("Error"), null, 'mesgs');
185  }
186 }
187 
188 if ($action == 'setdisablebindingonsales') {
189  $setdisablebindingonsales = GETPOST('value', 'int');
190  $res = dolibarr_set_const($db, "ACCOUNTING_DISABLE_BINDING_ON_SALES", $setdisablebindingonsales, 'yesno', 0, '', $conf->entity);
191  if (!($res > 0)) {
192  $error++;
193  }
194 
195  if (!$error) {
196  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
197  } else {
198  setEventMessages($langs->trans("Error"), null, 'mesgs');
199  }
200 }
201 
202 if ($action == 'setdisablebindingonpurchases') {
203  $setdisablebindingonpurchases = GETPOST('value', 'int');
204  $res = dolibarr_set_const($db, "ACCOUNTING_DISABLE_BINDING_ON_PURCHASES", $setdisablebindingonpurchases, 'yesno', 0, '', $conf->entity);
205  if (!($res > 0)) {
206  $error++;
207  }
208 
209  if (!$error) {
210  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
211  } else {
212  setEventMessages($langs->trans("Error"), null, 'mesgs');
213  }
214 }
215 
216 if ($action == 'setdisablebindingonexpensereports') {
217  $setdisablebindingonexpensereports = GETPOST('value', 'int');
218  $res = dolibarr_set_const($db, "ACCOUNTING_DISABLE_BINDING_ON_EXPENSEREPORTS", $setdisablebindingonexpensereports, 'yesno', 0, '', $conf->entity);
219  if (!($res > 0)) {
220  $error++;
221  }
222 
223  if (!$error) {
224  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
225  } else {
226  setEventMessages($langs->trans("Error"), null, 'mesgs');
227  }
228 }
229 
230 
231 /*
232  * View
233  */
234 
235 $form = new Form($db);
236 
237 $title = $langs->trans('ConfigAccountingExpert');
238 llxHeader('', $title);
239 
240 $linkback = '';
241 //$linkback = '<a href="' . DOL_URL_ROOT . '/admin/modules.php?restore_lastsearch_values=1">' . $langs->trans("BackToModuleList") . '</a>';
242 print load_fiche_titre($langs->trans('ConfigAccountingExpert'), $linkback, 'accountancy');
243 
244 print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
245 print '<input type="hidden" name="token" value="'.newToken().'">';
246 print '<input type="hidden" name="action" value="update">';
247 
248 // Params
249 print '<table class="noborder centpercent">';
250 print '<tr class="liste_titre">';
251 print '<td colspan="2">'.$langs->trans('Options').'</td>';
252 print "</tr>\n";
253 
254 // TO DO Mutualize code for yes/no constants
255 
256 /* Set this option as a hidden option but keep it for some needs.
257 print '<tr>';
258 print '<td>'.$langs->trans("ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL").'</td>';
259 if (!empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL)) {
260  print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&enabledraftexport&value=0">';
261  print img_picto($langs->trans("Activated"), 'switch_on');
262  print '</a></td>';
263 } else {
264  print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&enabledraftexport&value=1">';
265  print img_picto($langs->trans("Disabled"), 'switch_off');
266  print '</a></td>';
267 }
268 print '</tr>';
269 */
270 
271 print '<tr class="oddeven">';
272 print '<td>'.$langs->trans("BANK_DISABLE_DIRECT_INPUT").'</td>';
273 if (!empty($conf->global->BANK_DISABLE_DIRECT_INPUT)) {
274  print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&disabledirectinput&value=0">';
275  print img_picto($langs->trans("Activated"), 'switch_on');
276  print '</a></td>';
277 } else {
278  print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&disabledirectinput&value=1">';
279  print img_picto($langs->trans("Disabled"), 'switch_off');
280  print '</a></td>';
281 }
282 print '</tr>';
283 
284 print '<tr class="oddeven">';
285 print '<td>'.$langs->trans("ACCOUNTANCY_COMBO_FOR_AUX").'</td>';
286 if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) {
287  print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&enablesubsidiarylist&value=0">';
288  print img_picto($langs->trans("Activated"), 'switch_on');
289  print '</a></td>';
290 } else {
291  print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&enablesubsidiarylist&value=1">';
292  print img_picto($langs->trans("Disabled"), 'switch_off');
293  print '</a></td>';
294 }
295 print '</tr>';
296 
297 print '<tr class="oddeven">';
298 print '<td>'.$langs->trans("ACCOUNTING_MANAGE_ZERO").'</td>';
299 if (!empty($conf->global->ACCOUNTING_MANAGE_ZERO)) {
300  print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&managezero&value=0">';
301  print img_picto($langs->trans("Activated"), 'switch_on');
302  print '</a></td>';
303 } else {
304  print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&managezero&value=1">';
305  print img_picto($langs->trans("Disabled"), 'switch_off');
306  print '</a></td>';
307 }
308 print '</tr>';
309 
310 // Param a user $user->rights->accounting->chartofaccount can access
311 foreach ($list as $key)
312 {
313  print '<tr class="oddeven value">';
314 
315  if (!empty($conf->global->ACCOUNTING_MANAGE_ZERO) && ($key == 'ACCOUNTING_LENGTH_GACCOUNT' || $key == 'ACCOUNTING_LENGTH_AACCOUNT')) continue;
316 
317  // Param
318  $label = $langs->trans($key);
319  print '<td>'.$label.'</td>';
320  // Value
321  print '<td class="right">';
322  print '<input type="text" class="maxwidth100" id="'.$key.'" name="'.$key.'" value="'.$conf->global->$key.'">';
323 
324  print '</td>';
325  print '</tr>';
326 }
327 print '</table>';
328 print '<br>';
329 
330 // Binding params
331 print '<table class="noborder centpercent">';
332 print '<tr class="liste_titre">';
333 print '<td colspan="2">'.$langs->trans('BindingOptions').'</td>';
334 print "</tr>\n";
335 
336 // TO DO Mutualize code for yes/no constants
337 print '<tr class="oddeven">';
338 print '<td>'.$langs->trans("ACCOUNTING_LIST_SORT_VENTILATION_TODO").'</td>';
339 if (!empty($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_TODO)) {
340  print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&listsorttodo&value=0">';
341  print img_picto($langs->trans("Activated"), 'switch_on');
342  print '</a></td>';
343 } else {
344  print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&listsorttodo&value=1">';
345  print img_picto($langs->trans("Disabled"), 'switch_off');
346  print '</a></td>';
347 }
348 print '</tr>';
349 
350 print '<tr class="oddeven">';
351 print '<td>'.$langs->trans("ACCOUNTING_LIST_SORT_VENTILATION_DONE").'</td>';
352 if (!empty($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_DONE)) {
353  print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&listsortdone&value=0">';
354  print img_picto($langs->trans("Activated"), 'switch_on');
355  print '</a></td>';
356 } else {
357  print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&listsortdone&value=1">';
358  print img_picto($langs->trans("Disabled"), 'switch_off');
359  print '</a></td>';
360 }
361 print '</tr>';
362 
363 // Param a user $user->rights->accounting->chartofaccount can access
364 foreach ($list_binding as $key)
365 {
366  print '<tr class="oddeven value">';
367 
368  // Param
369  $label = $langs->trans($key);
370  print '<td>'.$label.'</td>';
371  // Value
372  print '<td class="right">';
373  if ($key == 'ACCOUNTING_DATE_START_BINDING') {
374  print $form->selectDate(($conf->global->$key ? $db->idate($conf->global->$key) : -1), $key, 0, 0, 1);
375  } elseif ($key == 'ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER') {
376  $array = array(0=>$langs->trans("PreviousMonth"), 1=>$langs->trans("CurrentMonth"), 2=>$langs->trans("Fiscalyear"));
377  print $form->selectarray($key, $array, (isset($conf->global->ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER) ? $conf->global->ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER : 0));
378  } else {
379  print '<input type="text" class="maxwidth100" id="'.$key.'" name="'.$key.'" value="'.$conf->global->$key.'">';
380  }
381 
382  print '</td>';
383  print '</tr>';
384 }
385 
386 print '<tr class="oddeven">';
387 print '<td>'.$langs->trans("ACCOUNTING_DISABLE_BINDING_ON_SALES").'</td>';
388 if (!empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_SALES)) {
389  print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&action=setdisablebindingonsales&value=0">';
390  print img_picto($langs->trans("Activated"), 'switch_on');
391  print '</a></td>';
392 } else {
393  print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&action=setdisablebindingonsales&value=1">';
394  print img_picto($langs->trans("Disabled"), 'switch_off');
395  print '</a></td>';
396 }
397 print '</tr>';
398 
399 print '<tr class="oddeven">';
400 print '<td>'.$langs->trans("ACCOUNTING_DISABLE_BINDING_ON_PURCHASES").'</td>';
401 if (!empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_PURCHASES)) {
402  print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&action=setdisablebindingonpurchases&value=0">';
403  print img_picto($langs->trans("Activated"), 'switch_on');
404  print '</a></td>';
405 } else {
406  print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&action=setdisablebindingonpurchases&value=1">';
407  print img_picto($langs->trans("Disabled"), 'switch_off');
408  print '</a></td>';
409 }
410 print '</tr>';
411 
412 print '<tr class="oddeven">';
413 print '<td>'.$langs->trans("ACCOUNTING_DISABLE_BINDING_ON_EXPENSEREPORTS").'</td>';
414 if (!empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_EXPENSEREPORTS)) {
415  print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&action=setdisablebindingonexpensereports&value=0">';
416  print img_picto($langs->trans("Activated"), 'switch_on');
417  print '</a></td>';
418 } else {
419  print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&action=setdisablebindingonexpensereports&value=1">';
420  print img_picto($langs->trans("Disabled"), 'switch_off');
421  print '</a></td>';
422 }
423 print '</tr>';
424 
425 print '</table>';
426 
427 print '<div class="center"><input type="submit" class="button" value="'.$langs->trans('Modify').'" name="button"></div>';
428 
429 print '</form>';
430 
431 // End of page
432 llxFooter();
433 $db->close();
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm= 'auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
dolibarr_set_const($db, $name, $value, $type= 'chaine', $visible=0, $note= '', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
Definition: admin.lib.php:575
llxHeader()
Empty header.
Definition: wrapper.php:45
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
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_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it&#39;s its name (generic function)
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
print
Draft customers invoices.
Definition: index.php:89
newToken()
Return the value of token currently saved into session with name &#39;newtoken&#39;.
llxFooter()
Empty footer.
Definition: wrapper.php:59