dolibarr 21.0.0-alpha
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-2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
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 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
12 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 3 of the License, or
16 * (at your option) any later version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program. If not, see <https://www.gnu.org/licenses/>.
25 */
26
33// Load Dolibarr environment
34require '../../main.inc.php';
35require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
36require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
37require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
38require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountancyexport.class.php';
39
40// Load translation files required by the page
41$langs->loadLangs(array("compta", "bills", "admin", "accountancy", "other"));
42
43// Security access
44if (!$user->hasRight('accounting', 'chartofaccount')) {
46}
47
48$action = GETPOST('action', 'aZ09');
49
50$nbletter = GETPOSTINT('ACCOUNTING_LETTERING_NBLETTERS');
51
52// Parameters ACCOUNTING_* and others
53$list = array(
54 'ACCOUNTING_LENGTH_GACCOUNT',
55 'ACCOUNTING_LENGTH_AACCOUNT',
56);
57
58$list_binding = array(
59 'ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER',
60 'ACCOUNTING_DATE_START_BINDING',
61 'ACCOUNTING_LABEL_OPERATION_ON_TRANSFER'
62);
63
64// Parameters for export options
65$main_option = array(
66 'ACCOUNTING_EXPORT_PREFIX_SPEC',
67);
68
69$accountancyexport = new AccountancyExport($db);
70$configuration = $accountancyexport->getTypeConfig();
71
72$listparam = $configuration['param'];
73$listformat = $configuration['format'];
74$listcr = $configuration['cr'];
75
76$model_option = array(
77 '1' => array(
78 'label' => 'ACCOUNTING_EXPORT_FORMAT',
79 'param' => $listformat,
80 ),
81 '2' => array(
82 'label' => 'ACCOUNTING_EXPORT_SEPARATORCSV',
83 'param' => '',
84 ),
85 '3' => array(
86 'label' => 'ACCOUNTING_EXPORT_ENDLINE',
87 'param' => $listcr,
88 ),
89 '4' => array(
90 'label' => 'ACCOUNTING_EXPORT_DATE',
91 'param' => '',
92 ),
93);
94
95$error = 0;
96
97
98/*
99 * Actions
100 */
101
102if (in_array($action, array('setBANK_DISABLE_DIRECT_INPUT', 'setACCOUNTANCY_ER_DATE_RECORD', 'setACCOUNTANCY_COMBO_FOR_AUX', 'setACCOUNTING_MANAGE_ZERO', 'setACCOUNTING_BANK_CONCILIATED'))) {
103 $constname = preg_replace('/^set/', '', $action);
104 $constvalue = GETPOSTINT('value');
105 $res = dolibarr_set_const($db, $constname, $constvalue, 'yesno', 0, '', $conf->entity);
106 if (!($res > 0)) {
107 $error++;
108 }
109
110 if (!$error) {
111 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
112 } else {
113 setEventMessages($langs->trans("Error"), null, 'mesgs');
114 }
115}
116
117if ($action == 'update') {
118 $error = 0;
119
120 if (!$error) {
121 foreach ($list as $constname) {
122 $constvalue = GETPOST($constname, 'alpha');
123 if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
124 $error++;
125 }
126 }
127 if ($error) {
128 setEventMessages($langs->trans("Error"), null, 'errors');
129 }
130
131 // option in section binding
132 foreach ($list_binding as $constname) {
133 $constvalue = GETPOST($constname, 'alpha');
134
135 if ($constname == 'ACCOUNTING_DATE_START_BINDING') {
136 $constvalue = dol_mktime(0, 0, 0, GETPOSTINT($constname.'month'), GETPOSTINT($constname.'day'), GETPOSTINT($constname.'year'));
137 }
138
139 if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
140 $error++;
141 }
142 }
143
144 // options in section other
145 if (GETPOSTISSET('ACCOUNTING_LETTERING_NBLETTERS')) {
146 if (!dolibarr_set_const($db, 'ACCOUNTING_LETTERING_NBLETTERS', GETPOST('ACCOUNTING_LETTERING_NBLETTERS'), 'chaine', 0, '', $conf->entity)) {
147 $error++;
148 }
149 }
150
151 // Export options
152 $modelcsv = GETPOSTINT('ACCOUNTING_EXPORT_MODELCSV');
153
154 if (!empty($modelcsv)) {
155 if (!dolibarr_set_const($db, 'ACCOUNTING_EXPORT_MODELCSV', $modelcsv, 'chaine', 0, '', $conf->entity)) {
156 $error++;
157 }
158 //if ($modelcsv==AccountancyExport::$EXPORT_TYPE_QUADRATUS || $modelcsv==AccountancyExport::$EXPORT_TYPE_CIEL) {
159 // dolibarr_set_const($db, 'ACCOUNTING_EXPORT_FORMAT', 'txt', 'chaine', 0, '', $conf->entity);
160 //}
161 } else {
162 $error++;
163 }
164
165 foreach ($main_option as $constname) {
166 $constvalue = GETPOST($constname, 'alpha');
167
168 if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
169 $error++;
170 }
171 }
172
173 foreach ($listparam[$modelcsv] as $key => $value) {
174 $constante = $key;
175
176 if (strpos($constante, 'ACCOUNTING') !== false) {
177 $constvalue = GETPOST($key, 'alpha');
178 if (!dolibarr_set_const($db, $constante, $constvalue, 'chaine', 0, '', $conf->entity)) {
179 $error++;
180 }
181 }
182 }
183
184 if (!$error) {
185 // reload
186 $configuration = $accountancyexport->getTypeConfig();
187 $listparam = $configuration['param'];
188 }
189 }
190
191 if (!$error) {
192 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
193 } else {
194 setEventMessages($langs->trans("Error"), null, 'errors');
195 }
196}
197
198if ($action == 'setmanagezero') {
199 $setmanagezero = GETPOSTINT('value');
200 $res = dolibarr_set_const($db, "ACCOUNTING_MANAGE_ZERO", $setmanagezero, 'yesno', 0, '', $conf->entity);
201 if (!($res > 0)) {
202 $error++;
203 }
204
205 if (!$error) {
206 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
207 } else {
208 setEventMessages($langs->trans("Error"), null, 'mesgs');
209 }
210}
211
212if ($action == 'setenabledraftexport') {
213 $setenabledraftexport = GETPOSTINT('value');
214 $res = dolibarr_set_const($db, "ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL", $setenabledraftexport, 'yesno', 0, '', $conf->entity);
215 if (!($res > 0)) {
216 $error++;
217 }
218
219 if (!$error) {
220 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
221 } else {
222 setEventMessages($langs->trans("Error"), null, 'mesgs');
223 }
224}
225
226if ($action == 'setenablesubsidiarylist') {
227 $setenablesubsidiarylist = GETPOSTINT('value');
228 $res = dolibarr_set_const($db, "ACCOUNTANCY_COMBO_FOR_AUX", $setenablesubsidiarylist, 'yesno', 0, '', $conf->entity);
229 if (!($res > 0)) {
230 $error++;
231 }
232
233 if (!$error) {
234 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
235 } else {
236 setEventMessages($langs->trans("Error"), null, 'mesgs');
237 }
238}
239
240if ($action == 'setdisablebindingonsales') {
241 $setdisablebindingonsales = GETPOSTINT('value');
242 $res = dolibarr_set_const($db, "ACCOUNTING_DISABLE_BINDING_ON_SALES", $setdisablebindingonsales, 'yesno', 0, '', $conf->entity);
243 if (!($res > 0)) {
244 $error++;
245 }
246
247 if (!$error) {
248 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
249 } else {
250 setEventMessages($langs->trans("Error"), null, 'mesgs');
251 }
252}
253
254if ($action == 'setdisablebindingonpurchases') {
255 $setdisablebindingonpurchases = GETPOSTINT('value');
256 $res = dolibarr_set_const($db, "ACCOUNTING_DISABLE_BINDING_ON_PURCHASES", $setdisablebindingonpurchases, 'yesno', 0, '', $conf->entity);
257 if (!($res > 0)) {
258 $error++;
259 }
260
261 if (!$error) {
262 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
263 } else {
264 setEventMessages($langs->trans("Error"), null, 'mesgs');
265 }
266}
267
268if ($action == 'setdisablebindingonexpensereports') {
269 $setdisablebindingonexpensereports = GETPOSTINT('value');
270 $res = dolibarr_set_const($db, "ACCOUNTING_DISABLE_BINDING_ON_EXPENSEREPORTS", $setdisablebindingonexpensereports, 'yesno', 0, '', $conf->entity);
271 if (!($res > 0)) {
272 $error++;
273 }
274
275 if (!$error) {
276 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
277 } else {
278 setEventMessages($langs->trans("Error"), null, 'mesgs');
279 }
280}
281
282if ($action == 'setenablelettering') {
283 $setenablelettering = GETPOSTINT('value');
284 $res = dolibarr_set_const($db, "ACCOUNTING_ENABLE_LETTERING", $setenablelettering, 'yesno', 0, '', $conf->entity);
285 if (!($res > 0)) {
286 $error++;
287 }
288
289 if (!$error) {
290 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
291 } else {
292 setEventMessages($langs->trans("Error"), null, 'mesgs');
293 }
294}
295
296if ($action == 'setenableautolettering') {
297 $setenableautolettering = GETPOSTINT('value');
298 $res = dolibarr_set_const($db, "ACCOUNTING_ENABLE_AUTOLETTERING", $setenableautolettering, 'yesno', 0, '', $conf->entity);
299 if (!($res > 0)) {
300 $error++;
301 }
302
303 if (!$error) {
304 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
305 } else {
306 setEventMessages($langs->trans("Error"), null, 'mesgs');
307 }
308}
309
310if ($action == 'setenablevatreversecharge') {
311 $setenablevatreversecharge = GETPOSTINT('value');
312 $res = dolibarr_set_const($db, "ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE", $setenablevatreversecharge, 'yesno', 0, '', $conf->entity);
313 if (!($res > 0)) {
314 $error++;
315 }
316
317 if (!$error) {
318 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
319 } else {
320 setEventMessages($langs->trans("Error"), null, 'mesgs');
321 }
322}
323
324
325/*
326 * View
327 */
328
329$form = new Form($db);
330
331$title = $langs->trans('ConfigAccountingExpert');
332$help_url = 'EN:Module_Double_Entry_Accounting#Setup|FR:Module_Comptabilit&eacute;_en_Partie_Double#Configuration';
333llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-accountancy page-admin_index');
334
335
336$linkback = '';
337//$linkback = '<a href="' . DOL_URL_ROOT . '/admin/modules.php?restore_lastsearch_values=1">' . $langs->trans("BackToModuleList") . '</a>';
338print load_fiche_titre($title, $linkback, 'accountancy');
339
340
341// Show message if accountancy hidden options are activated to help to resolve some problems
342if (!$user->admin) {
343 if (getDolGlobalString('FACTURE_DEPOSITS_ARE_JUST_PAYMENTS')) {
344 print '<div class="info">' . $langs->trans("ConstantIsOn", "FACTURE_DEPOSITS_ARE_JUST_PAYMENTS") . '</div>';
345 }
346 if (getDolGlobalString('FACTURE_SUPPLIER_DEPOSITS_ARE_JUST_PAYMENTS')) {
347 print '<div class="info">' . $langs->trans("ConstantIsOn", "FACTURE_SUPPLIER_DEPOSITS_ARE_JUST_PAYMENTS") . '</div>';
348 }
349 if (getDolGlobalString('ACCOUNTANCY_USE_PRODUCT_ACCOUNT_ON_THIRDPARTY')) {
350 print '<div class="info">' . $langs->trans("ConstantIsOn", "ACCOUNTANCY_USE_PRODUCT_ACCOUNT_ON_THIRDPARTY") . '</div>';
351 }
352 if (getDolGlobalString('MAIN_COMPANY_PERENTITY_SHARED')) {
353 print '<div class="info">' . $langs->trans("ConstantIsOn", "MAIN_COMPANY_PERENTITY_SHARED") . '</div>';
354 }
355 if (getDolGlobalString('MAIN_PRODUCT_PERENTITY_SHARED')) {
356 print '<div class="info">' . $langs->trans("ConstantIsOn", "MAIN_PRODUCT_PERENTITY_SHARED") . '</div>';
357 }
358}
359
360print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
361print '<input type="hidden" name="token" value="'.newToken().'">';
362print '<input type="hidden" name="action" value="update">';
363print '<input type="hidden" name="page_y" value="">';
364
365// Params
366print '<div class="div-table-responsive-no-min">';
367print '<table class="noborder centpercent">';
368print '<tr class="liste_titre">';
369print '<td colspan="2">'.$langs->trans('Options').'</td>';
370print "</tr>\n";
371
372// TO DO Mutualize code for yes/no constants
373
374/* Set this option as a hidden option but keep it for some needs.
375print '<tr>';
376print '<td>'.$langs->trans("ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL").'</td>';
377if (getDolGlobalString('ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL')) {
378 print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&enabledraftexport&value=0">';
379 print img_picto($langs->trans("Activated"), 'switch_on');
380 print '</a></td>';
381} else {
382 print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&enabledraftexport&value=1">';
383 print img_picto($langs->trans("Disabled"), 'switch_off');
384 print '</a></td>';
385}
386print '</tr>';
387*/
388
389print '<tr class="oddeven">';
390print '<td>'.$langs->trans("BANK_DISABLE_DIRECT_INPUT").'</td>';
391if (getDolGlobalString('BANK_DISABLE_DIRECT_INPUT')) {
392 print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&action=setBANK_DISABLE_DIRECT_INPUT&value=0">';
393 print img_picto($langs->trans("Activated"), 'switch_on');
394 print '</a></td>';
395} else {
396 print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&action=setBANK_DISABLE_DIRECT_INPUT&value=1">';
397 print img_picto($langs->trans("Disabled"), 'switch_off');
398 print '</a></td>';
399}
400print '</tr>';
401
402print '<tr class="oddeven">';
403print '<td>'.$langs->trans("ACCOUNTANCY_COMBO_FOR_AUX");
404print ' - <span class="opacitymedium">'.$langs->trans("NotRecommended").'</span>';
405print '</td>';
406
407if (getDolGlobalString('ACCOUNTANCY_COMBO_FOR_AUX')) {
408 print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&action=setACCOUNTANCY_COMBO_FOR_AUX&value=0">';
409 print img_picto($langs->trans("Activated").' - '.$langs->trans("NotRecommended"), 'switch_on', 'class="warning"');
410 print '</a></td>';
411} else {
412 print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&action=setACCOUNTANCY_COMBO_FOR_AUX&value=1">';
413 print img_picto($langs->trans("Disabled"), 'switch_off');
414 print '</a></td>';
415}
416print '</tr>';
417
418print '<tr class="oddeven">';
419print '<td>'.$langs->trans("ACCOUNTING_MANAGE_ZERO").'</td>';
420if (getDolGlobalInt('ACCOUNTING_MANAGE_ZERO')) {
421 print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&action=setACCOUNTING_MANAGE_ZERO&value=0">';
422 print img_picto($langs->trans("Activated"), 'switch_on');
423 print '</a></td>';
424} else {
425 print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&action=setACCOUNTING_MANAGE_ZERO&value=1">';
426 print img_picto($langs->trans("Disabled"), 'switch_off');
427 print '</a></td>';
428}
429print '</tr>';
430
431// Param a user $user->hasRight('accounting', 'chartofaccount') can access
432foreach ($list as $key) {
433 print '<tr class="oddeven value">';
434
435 if (getDolGlobalInt('ACCOUNTING_MANAGE_ZERO') && ($key == 'ACCOUNTING_LENGTH_GACCOUNT' || $key == 'ACCOUNTING_LENGTH_AACCOUNT')) {
436 continue;
437 }
438
439 // Param
440 $label = $langs->trans($key);
441 print '<td>'.$label.'</td>';
442 // Value
443 print '<td class="right">';
444 print '<input type="number" class="maxwidth50 right" id="'.$key.'" name="'.$key.'" value="'.getDolGlobalString($key).'">';
445
446 print '</td>';
447 print '</tr>';
448}
449
450print '</table>';
451
452print '<div class="center"><input type="submit" class="button reposition" value="'.dol_escape_htmltag($langs->trans('Save')).'" name="button"></div>';
453
454print '</div>';
455
456print '<br><br>';
457
458// Binding params
459print '<div class="div-table-responsive-no-min">';
460print '<table class="noborder centpercent">';
461print '<tr class="liste_titre">';
462print '<td colspan="2">'.$langs->trans('BindingOptions').'</td>';
463print "</tr>\n";
464
465// Param a user $user->hasRight('accounting', 'chartofaccount') can access
466foreach ($list_binding as $key) {
467 print '<tr class="oddeven value">';
468
469 // Param
470 $label = $langs->trans($key);
471 print '<td>'.$label.'</td>';
472 // Value
473 print '<td class="right minwidth75imp parentonrightofpage">';
474 if ($key == 'ACCOUNTING_DATE_START_BINDING') {
475 print $form->selectDate((getDolGlobalInt($key) ? (int) getDolGlobalInt($key) : -1), $key, 0, 0, 1);
476 } elseif ($key == 'ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER') {
477 $array = array(0=>$langs->trans("PreviousMonth"), 1=>$langs->trans("CurrentMonth"), 2=>$langs->trans("Fiscalyear"));
478 print $form->selectarray($key, $array, getDolGlobalInt('ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER', 0), 0, 0, 0, '', 0, 0, 0, '', 'onrightofpage width200');
479 } elseif ($key == 'ACCOUNTING_LABEL_OPERATION_ON_TRANSFER') {
480 $array = array(
481 0=>$langs->trans("ThirdPartyName") . ' - ' . $langs->trans("NumPiece") . ' - ' . $langs->trans("LabelAccount"),
482 1=>$langs->trans("ThirdPartyName") . ' - ' . $langs->trans("NumPiece"),
483 2=>$langs->trans("ThirdPartyName")
484 );
485 print $form->selectarray($key, $array, getDolGlobalInt('ACCOUNTING_LABEL_OPERATION_ON_TRANSFER', 0), 0, 0, 0, '', 0, 0, 0, '', 'onrightofpage width200');
486 } else {
487 print '<input type="text" class="maxwidth100" id="'.$key.'" name="'.$key.'" value="'.getDolGlobalString($key).'">';
488 }
489
490 print '</td>';
491 print '</tr>';
492}
493
494print '<tr class="oddeven">';
495print '<td>'.$langs->trans("ACCOUNTING_DISABLE_BINDING_ON_SALES").'</td>';
496if (getDolGlobalString('ACCOUNTING_DISABLE_BINDING_ON_SALES')) {
497 print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&action=setdisablebindingonsales&value=0">';
498 print img_picto($langs->trans("Activated"), 'switch_on', '', 0, 0, 0, '', 'warning');
499 print '</a></td>';
500} else {
501 print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&action=setdisablebindingonsales&value=1">';
502 print img_picto($langs->trans("Disabled"), 'switch_off');
503 print '</a></td>';
504}
505print '</tr>';
506
507print '<tr class="oddeven">';
508print '<td>'.$langs->trans("ACCOUNTING_DISABLE_BINDING_ON_PURCHASES").'</td>';
509if (getDolGlobalString('ACCOUNTING_DISABLE_BINDING_ON_PURCHASES')) {
510 print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&action=setdisablebindingonpurchases&value=0">';
511 print img_picto($langs->trans("Activated"), 'switch_on', '', 0, 0, 0, '', 'warning');
512 print '</a></td>';
513} else {
514 print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&action=setdisablebindingonpurchases&value=1">';
515 print img_picto($langs->trans("Disabled"), 'switch_off');
516 print '</a></td>';
517}
518print '</tr>';
519
520print '<tr class="oddeven">';
521print '<td>'.$langs->trans("ACCOUNTING_DISABLE_BINDING_ON_EXPENSEREPORTS").'</td>';
522if (getDolGlobalString('ACCOUNTING_DISABLE_BINDING_ON_EXPENSEREPORTS')) {
523 print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&action=setdisablebindingonexpensereports&value=0">';
524 print img_picto($langs->trans("Activated"), 'switch_on', '', 0, 0, 0, '', 'warning');
525 print '</a></td>';
526} else {
527 print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&action=setdisablebindingonexpensereports&value=1">';
528 print img_picto($langs->trans("Disabled"), 'switch_off');
529 print '</a></td>';
530}
531print '</tr>';
532
533if (!getDolGlobalString('ACCOUNTING_DISABLE_BINDING_ON_EXPENSEREPORTS')) {
534 print '<tr class="oddeven">';
535 print '<td>'.$langs->trans("ACCOUNTANCY_ER_DATE_RECORD").'</td>';
536 if (getDolGlobalInt('ACCOUNTANCY_ER_DATE_RECORD')) {
537 print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&action=setACCOUNTANCY_ER_DATE_RECORD&value=0">';
538 print img_picto($langs->trans("Activated"), 'switch_on');
539 print '</a></td>';
540 } else {
541 print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&action=setACCOUNTANCY_ER_DATE_RECORD&value=1">';
542 print img_picto($langs->trans("Disabled"), 'switch_off');
543 print '</a></td>';
544 }
545 print '</tr>';
546}
547
548print '<tr class="oddeven">';
549print '<td>'.$langs->trans("ACCOUNTING_BANK_CONCILIATED").'</td>';
550if (getDolGlobalInt('ACCOUNTING_BANK_CONCILIATED') == 2) {
551 print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&action=setACCOUNTING_BANK_CONCILIATED&value=1">';
552 print img_picto($langs->trans("Activated"), 'switch_on');
553 print '</a></td>';
554} else {
555 print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&action=setACCOUNTING_BANK_CONCILIATED&value=2">';
556 print img_picto($langs->trans("Disabled"), 'switch_off');
557 print '</a></td>';
558}
559print '</tr>';
560
561print '</table>';
562print '</div>';
563
564print '<div class="center"><input type="submit" class="button reposition" value="'.dol_escape_htmltag($langs->trans('Save')).'" name="button"></div>';
565
566
567
568// Show advanced options
569print '<br><br>';
570
571
572// Advanced params
573print '<div class="div-table-responsive-no-min">';
574print '<table class="noborder centpercent">';
575print '<tr class="liste_titre">';
576print '<td colspan="2">' . $langs->trans('OptionsAdvanced') . '</td>';
577print "</tr>\n";
578
579print '<tr class="oddeven">';
580print '<td>';
581print $form->textwithpicto($langs->trans("ACCOUNTING_ENABLE_LETTERING"), $langs->trans("ACCOUNTING_ENABLE_LETTERING_DESC", $langs->transnoentitiesnoconv("NumMvts")).'<br>'.$langs->trans("EnablingThisFeatureIsNotNecessary")).'</td>';
582if (getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING')) {
583 print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&action=setenablelettering&value=0">';
584 print img_picto($langs->trans("Activated"), 'switch_on');
585 print '</a></td>';
586} else {
587 print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&action=setenablelettering&value=1">';
588 print img_picto($langs->trans("Disabled"), 'switch_off');
589 print '</a></td>';
590}
591print '</tr>';
592
593if (getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING')) {
594 // Number of letters for lettering (3 by default (AAA), min 2 (AA))
595 print '<tr class="oddeven">';
596 print '<td>';
597 print $form->textwithpicto($langs->trans("ACCOUNTING_LETTERING_NBLETTERS"), $langs->trans("ACCOUNTING_LETTERING_NBLETTERS_DESC")) . '</td>';
598 print '<td class="right">';
599
600 if (empty($letter)) {
601 if (getDolGlobalInt('ACCOUNTING_LETTERING_NBLETTERS')) {
602 $nbletter = getDolGlobalInt('ACCOUNTING_LETTERING_NBLETTERS');
603 } else {
604 $nbletter = 3;
605 }
606 }
607
608 print '<input class="flat right" name="ACCOUNTING_LETTERING_NBLETTERS" id="ACCOUNTING_LETTERING_NBLETTERS" value="' . $nbletter . '" type="number" step="1" min="2" max="3" >' . "\n";
609 print '</tr>';
610
611 // Auto Lettering when transfer in accountancy is realized
612 print '<tr class="oddeven">';
613 print '<td>';
614 print $form->textwithpicto($langs->trans("ACCOUNTING_ENABLE_AUTOLETTERING"), $langs->trans("ACCOUNTING_ENABLE_AUTOLETTERING_DESC")) . '</td>';
615 if (getDolGlobalInt('ACCOUNTING_ENABLE_AUTOLETTERING')) {
616 print '<td class="right"><a class="reposition" href="' . $_SERVER['PHP_SELF'] . '?token=' . newToken() . '&action=setenableautolettering&value=0">';
617 print img_picto($langs->trans("Activated"), 'switch_on');
618 print '</a></td>';
619 } else {
620 print '<td class="right"><a class="reposition" href="' . $_SERVER['PHP_SELF'] . '?token=' . newToken() . '&action=setenableautolettering&value=1">';
621 print img_picto($langs->trans("Disabled"), 'switch_off');
622 print '</a></td>';
623 }
624 print '</tr>';
625}
626
627print '<tr class="oddeven">';
628print '<td>';
629print $form->textwithpicto($langs->trans("ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE"), $langs->trans("ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE_DESC", $langs->transnoentities("MenuDefaultAccounts"))).'</td>';
630if (getDolGlobalString('ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE')) {
631 print '<td class="right"><a class="reposition" href="' . $_SERVER['PHP_SELF'] . '?token=' . newToken() . '&action=setenablevatreversecharge&value=0">';
632 print img_picto($langs->trans("Activated"), 'switch_on');
633 print '</a></td>';
634} else {
635 print '<td class="right"><a class="reposition" href="' . $_SERVER['PHP_SELF'] . '?token=' . newToken() . '&action=setenablevatreversecharge&value=1">';
636 print img_picto($langs->trans("Disabled"), 'switch_off');
637 print '</a></td>';
638}
639print '</tr>';
640
641print '</table>';
642print '</div>';
643
644
645print '<div class="center"><input type="submit" class="button button-edit reposition" name="button" value="'.$langs->trans('Save').'"></div>';
646
647print '<br><br>';
648
649
650// Export options
651
652print "\n".'<script type="text/javascript">'."\n";
653print 'jQuery(document).ready(function () {'."\n";
654print ' function initfields()'."\n";
655print ' {'."\n";
656foreach ($listparam as $key => $param) {
657 print ' if (jQuery("#ACCOUNTING_EXPORT_MODELCSV").val()=="'.$key.'")'."\n";
658 print ' {'."\n";
659 print ' //console.log("'.$param['label'].'");'."\n";
660 if (empty($param['ACCOUNTING_EXPORT_FORMAT'])) {
661 print ' jQuery("#ACCOUNTING_EXPORT_FORMAT").val("'.getDolGlobalString('ACCOUNTING_EXPORT_FORMAT').'");'."\n";
662 print ' jQuery("#ACCOUNTING_EXPORT_FORMAT").prop("disabled", true);'."\n";
663 } else {
664 print ' jQuery("#ACCOUNTING_EXPORT_FORMAT").val("'.$param['ACCOUNTING_EXPORT_FORMAT'].'");'."\n";
665 print ' jQuery("#ACCOUNTING_EXPORT_FORMAT").removeAttr("disabled");'."\n";
666 }
667 if (empty($param['ACCOUNTING_EXPORT_SEPARATORCSV'])) {
668 print ' jQuery("#ACCOUNTING_EXPORT_SEPARATORCSV").val("");'."\n";
669 print ' jQuery("#ACCOUNTING_EXPORT_SEPARATORCSV").prop("disabled", true);'."\n";
670 } else {
671 print ' jQuery("#ACCOUNTING_EXPORT_SEPARATORCSV").val("'.getDolGlobalString('ACCOUNTING_EXPORT_SEPARATORCSV').'");'."\n";
672 print ' jQuery("#ACCOUNTING_EXPORT_SEPARATORCSV").removeAttr("disabled");'."\n";
673 }
674 if (empty($param['ACCOUNTING_EXPORT_ENDLINE'])) {
675 print ' jQuery("#ACCOUNTING_EXPORT_ENDLINE").prop("disabled", true);'."\n";
676 } else {
677 print ' jQuery("#ACCOUNTING_EXPORT_ENDLINE").removeAttr("disabled");'."\n";
678 }
679 if (empty($param['ACCOUNTING_EXPORT_DATE'])) {
680 print ' jQuery("#ACCOUNTING_EXPORT_DATE").val("");'."\n";
681 print ' jQuery("#ACCOUNTING_EXPORT_DATE").prop("disabled", true);'."\n";
682 } else {
683 print ' jQuery("#ACCOUNTING_EXPORT_DATE").val("'.getDolGlobalString('ACCOUNTING_EXPORT_DATE').'");'."\n";
684 print ' jQuery("#ACCOUNTING_EXPORT_DATE").removeAttr("disabled");'."\n";
685 }
686 print ' }'."\n";
687}
688print ' }'."\n";
689print ' initfields();'."\n";
690print ' jQuery("#ACCOUNTING_EXPORT_MODELCSV").change(function() {'."\n";
691print ' initfields();'."\n";
692print ' });'."\n";
693print '})'."\n";
694print '</script>'."\n";
695
696// Main Options
697
698print '<table class="noborder centpercent">';
699print '<tr class="liste_titre">';
700print '<td colspan="2">'.$langs->trans('ExportOptions').'</td>';
701print "</tr>\n";
702
703$num = count($main_option);
704if ($num) {
705 foreach ($main_option as $key) {
706 print '<tr class="oddeven value">';
707
708 // Param
709 $label = $langs->trans($key);
710 print '<td>'.dol_escape_htmltag($label).'</td>';
711
712 // Value
713 print '<td>';
714 print '<input type="text" size="20" id="'.$key.'" name="'.$key.'" value="'.getDolGlobalString($key).'">';
715 print '</td></tr>';
716 }
717}
718
719print '<tr class="oddeven">';
720print '<td>'.$langs->trans("Selectmodelcsv").'</td>';
721if (!$conf->use_javascript_ajax) {
722 print '<td class="nowrap">';
723 print $langs->trans("NotAvailableWhenAjaxDisabled");
724 print "</td>";
725} else {
726 print '<td>';
727 $listofexporttemplates = $accountancyexport->getType(1);
728 print $form->selectarray("ACCOUNTING_EXPORT_MODELCSV", $listofexporttemplates, getDolGlobalString('ACCOUNTING_EXPORT_MODELCSV'), 0, 0, 0, '', 0, 0, 0, '', '', 1);
729 print '</td>';
730}
731print "</tr>";
732
733
734$num2 = count($model_option);
735if ($num2) {
736 foreach ($model_option as $key) {
737 print '<tr class="oddeven value">';
738
739 // Param
740 $label = $key['label'];
741 print '<td>'.$langs->trans($label).'</td>';
742
743 // Value
744 print '<td>';
745 if (is_array($key['param'])) {
746 print $form->selectarray($label, $key['param'], getDolGlobalString($label), 0);
747 } else {
748 print '<input type="text" size="20" id="'.$label.'" name="'.$key['label'].'" value="'.getDolGlobalString($label).'">';
749 }
750
751 print '</td></tr>';
752 }
753
754 print "</table>\n";
755}
756
757print '<div class="center"><input type="submit" class="button reposition" value="'.dol_escape_htmltag($langs->trans('Save')).'" name="button"></div>';
758
759
760print '</form>';
761
762// End of page
763llxFooter();
764$db->close();
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).
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:70
Manage the different format accountancy export.
Class to manage generation of HTML components Only common components must be here.
llxFooter()
Footer empty.
Definition document.php:107
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.