dolibarr 22.0.5
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-2025 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';
39require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php';
40require_once DOL_DOCUMENT_ROOT.'/core/class/html.formsetup.class.php';
41
51// Load translation files required by the page
52$langs->loadLangs(array("compta", "bills", "admin", "accountancy", "other"));
53
54// Security access
55if (!$user->hasRight('accounting', 'chartofaccount')) {
57}
58
59$action = GETPOST('action', 'aZ09');
60if (empty($action)) {
61 $action = 'edit';
62}
63
64$nbletter = GETPOSTINT('ACCOUNTING_LETTERING_NBLETTERS');
65
66// New form setup options
67$formSetup = new FormSetup($db);
68
69// Main options
70$formSetup->newItem('BANK_DISABLE_DIRECT_INPUT')->setAsYesNo();
71
72$formSetup->newItem('ACCOUNTANCY_COMBO_FOR_AUX')->setAsYesNo();
73
74$item = $formSetup->newItem('ACCOUNTING_MANAGE_ZERO')->setAsYesNo();
75$item->helpText = $langs->trans('ACCOUNTING_MANAGE_ZERO2');
76$item->fieldParams['helpText'] = 'noclick';
77
78
79if (!getDolGlobalInt('ACCOUNTING_MANAGE_ZERO')) {
80 $item = $formSetup->newItem('ACCOUNTING_LENGTH_GACCOUNT')->setAsString();
81 $item->fieldAttr['type'] = 'number';
82 $item->fieldAttr['class'] = 'maxwidth50 right';
83
84 $item = $formSetup->newItem('ACCOUNTING_LENGTH_AACCOUNT')->setAsString();
85 $item->fieldAttr['type'] = 'number';
86 $item->fieldAttr['class'] = 'maxwidth50 right';
87}
88
89// Parameters ACCOUNTING_* and others
90$list = array(
91 'ACCOUNTING_LENGTH_GACCOUNT',
92 'ACCOUNTING_LENGTH_AACCOUNT',
93);
94
95$list_binding = array(
96 'ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER',
97 'ACCOUNTING_DATE_START_BINDING',
98 'ACCOUNTING_LABEL_OPERATION_ON_TRANSFER'
99);
100
101// Parameters for export options
102$main_option = array(
103 'ACCOUNTING_EXPORT_PREFIX_SPEC',
104);
105
106$accountancyexport = new AccountancyExport($db);
107$configuration = $accountancyexport->getTypeConfig();
108
109$listparam = $configuration['param'];
110$listformat = $configuration['format'];
111$listcr = $configuration['cr'];
112
113$model_option = array(
114 '1' => array(
115 'label' => 'ACCOUNTING_EXPORT_FORMAT',
116 'param' => $listformat,
117 ),
118 '2' => array(
119 'label' => 'ACCOUNTING_EXPORT_SEPARATORCSV',
120 'param' => '',
121 ),
122 '3' => array(
123 'label' => 'ACCOUNTING_EXPORT_ENDLINE',
124 'param' => $listcr,
125 ),
126 '4' => array(
127 'label' => 'ACCOUNTING_EXPORT_DATE',
128 'param' => '',
129 ),
130);
131
132$error = 0;
133
134$accounting_mode = getDolGlobalString('ACCOUNTING_MODE', 'CREANCES-DETTES');
135
136
137/*
138 * Actions
139 */
140
141include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
142
143if (in_array($action, array('setACCOUNTANCY_ER_DATE_RECORD', 'setACCOUNTING_BANK_CONCILIATED'))) {
144 $constname = preg_replace('/^set/', '', $action);
145 $constvalue = GETPOSTINT('value');
146 $res = dolibarr_set_const($db, $constname, $constvalue, 'yesno', 0, '', $conf->entity);
147 if (!($res > 0)) {
148 $error++;
149 }
150
151 if (!$error) {
152 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
153 } else {
154 setEventMessages($langs->trans("Error"), null, 'mesgs');
155 }
156}
157
158if ($action == 'updatemode') {
159 $error = 0;
160
161 $accounting_modes = array(
162 'CREANCES-DETTES',
163 'RECETTES-DEPENSES'
164 );
165
166 $accounting_mode = GETPOST('accounting_mode', 'alpha');
167
168 if (in_array($accounting_mode, $accounting_modes)) {
169 if (dolibarr_set_const($db, 'ACCOUNTING_MODE', $accounting_mode, 'chaine', 0, '', $conf->entity)) {
170 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
171 } else {
172 $error++;
173 }
174 } else {
175 $error++;
176 }
177}
178
179if ($action == 'update') {
180 $error = 0;
181
182 foreach ($list as $constname) {
183 $constvalue = GETPOST($constname, 'alpha');
184
185 if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
186 $error++;
187 }
188 }
189
190 if (!$error) {
191 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
192 } else {
193 setEventMessages($langs->trans("Error"), null, 'errors');
194 }
195}
196
197if ($action == 'update_binding') {
198 $error = 0;
199
200 foreach ($list_binding as $constname) {
201 $constvalue = GETPOST($constname, 'alpha');
202
203 if ($constname == 'ACCOUNTING_DATE_START_BINDING') {
204 $constvalue = dol_mktime(0, 0, 0, GETPOSTINT($constname.'month'), GETPOSTINT($constname.'day'), GETPOSTINT($constname.'year'));
205 }
206
207 if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
208 $error++;
209 }
210 }
211
212 if (!$error) {
213 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
214 } else {
215 setEventMessages($langs->trans("Error"), null, 'errors');
216 }
217}
218
219if ($action == 'update_advanced') {
220 $error = 0;
221
222 if (GETPOSTISSET('ACCOUNTING_LETTERING_NBLETTERS')) {
223 if (!dolibarr_set_const($db, 'ACCOUNTING_LETTERING_NBLETTERS', GETPOST('ACCOUNTING_LETTERING_NBLETTERS'), 'chaine', 0, '', $conf->entity)) {
224 $error++;
225 }
226 }
227
228 if (!$error) {
229 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
230 } else {
231 setEventMessages($langs->trans("Error"), null, 'errors');
232 }
233}
234
235if ($action == 'update_export') {
236 $error = 0;
237
238 // Export options
239 $modelcsv = GETPOSTINT('ACCOUNTING_EXPORT_MODELCSV');
240
241 if (!$error) {
242 // reload
243 $configuration = $accountancyexport->getTypeConfig();
244 $listparam = $configuration['param'];
245 }
246
247 if (!empty($modelcsv)) {
248 if (!dolibarr_set_const($db, 'ACCOUNTING_EXPORT_MODELCSV', $modelcsv, 'chaine', 0, '', $conf->entity)) {
249 $error++;
250 }
251 //if ($modelcsv==AccountancyExport::$EXPORT_TYPE_QUADRATUS || $modelcsv==AccountancyExport::$EXPORT_TYPE_CIEL) {
252 // dolibarr_set_const($db, 'ACCOUNTING_EXPORT_FORMAT', 'txt', 'chaine', 0, '', $conf->entity);
253 //}
254 } else {
255 $error++;
256 }
257
258 foreach ($main_option as $constname) {
259 $constvalue = GETPOST($constname, 'alpha');
260
261 if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
262 $error++;
263 }
264 }
265
266 foreach ($listparam[$modelcsv] as $key => $value) {
267 $constante = $key;
268
269 if (strpos($constante, 'ACCOUNTING') !== false) {
270 $constvalue = GETPOST($key, 'alpha');
271 if (!dolibarr_set_const($db, $constante, $constvalue, 'chaine', 0, '', $conf->entity)) {
272 $error++;
273 }
274 }
275 }
276
277 if (!$error) {
278 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
279 } else {
280 setEventMessages($langs->trans("Error"), null, 'errors');
281 }
282}
283
284if ($action == 'setenabledraftexport') {
285 $setenabledraftexport = GETPOSTINT('value');
286 $res = dolibarr_set_const($db, "ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL", $setenabledraftexport, 'yesno', 0, '', $conf->entity);
287 if (!($res > 0)) {
288 $error++;
289 }
290
291 if (!$error) {
292 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
293 } else {
294 setEventMessages($langs->trans("Error"), null, 'mesgs');
295 }
296}
297
298if ($action == 'setdisablebindingonsales') {
299 $setdisablebindingonsales = GETPOSTINT('value');
300 $res = dolibarr_set_const($db, "ACCOUNTING_DISABLE_BINDING_ON_SALES", $setdisablebindingonsales, 'yesno', 0, '', $conf->entity);
301 if (!($res > 0)) {
302 $error++;
303 }
304
305 if (!$error) {
306 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
307 } else {
308 setEventMessages($langs->trans("Error"), null, 'mesgs');
309 }
310}
311
312if ($action == 'setdisablebindingonpurchases') {
313 $setdisablebindingonpurchases = GETPOSTINT('value');
314 $res = dolibarr_set_const($db, "ACCOUNTING_DISABLE_BINDING_ON_PURCHASES", $setdisablebindingonpurchases, 'yesno', 0, '', $conf->entity);
315 if (!($res > 0)) {
316 $error++;
317 }
318
319 if (!$error) {
320 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
321 } else {
322 setEventMessages($langs->trans("Error"), null, 'mesgs');
323 }
324}
325
326if ($action == 'setdisablebindingonexpensereports') {
327 $setdisablebindingonexpensereports = GETPOSTINT('value');
328 $res = dolibarr_set_const($db, "ACCOUNTING_DISABLE_BINDING_ON_EXPENSEREPORTS", $setdisablebindingonexpensereports, 'yesno', 0, '', $conf->entity);
329 if (!($res > 0)) {
330 $error++;
331 }
332
333 if (!$error) {
334 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
335 } else {
336 setEventMessages($langs->trans("Error"), null, 'mesgs');
337 }
338}
339
340if ($action == 'setenablelettering') {
341 $setenablelettering = GETPOSTINT('value');
342 $res = dolibarr_set_const($db, "ACCOUNTING_ENABLE_LETTERING", $setenablelettering, 'yesno', 0, '', $conf->entity);
343 if (!($res > 0)) {
344 $error++;
345 }
346
347 if (!$error) {
348 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
349 } else {
350 setEventMessages($langs->trans("Error"), null, 'mesgs');
351 }
352}
353
354if ($action == 'setenableautolettering') {
355 $setenableautolettering = GETPOSTINT('value');
356 $res = dolibarr_set_const($db, "ACCOUNTING_ENABLE_AUTOLETTERING", $setenableautolettering, 'yesno', 0, '', $conf->entity);
357 if (!($res > 0)) {
358 $error++;
359 }
360
361 if (!$error) {
362 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
363 } else {
364 setEventMessages($langs->trans("Error"), null, 'mesgs');
365 }
366}
367
368if ($action == 'setenablevatreversecharge') {
369 $setenablevatreversecharge = GETPOSTINT('value');
370 $res = dolibarr_set_const($db, "ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE", $setenablevatreversecharge, 'yesno', 0, '', $conf->entity);
371 if (!($res > 0)) {
372 $error++;
373 }
374
375 if (!$error) {
376 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
377 } else {
378 setEventMessages($langs->trans("Error"), null, 'mesgs');
379 }
380}
381
382if ($action == 'setenabletabonthirdparty') {
383 $setenabletabonthirdparty = GETPOSTINT('value');
384 $res = dolibarr_set_const($db, "ACCOUNTING_ENABLE_TABONTHIRDPARTY", $setenabletabonthirdparty, 'yesno', 0, '', $conf->entity);
385 if (!($res > 0)) {
386 $error++;
387 }
388
389 if (!$error) {
390 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
391 } else {
392 setEventMessages($langs->trans("Error"), null, 'mesgs');
393 }
394}
395
396if ($action == 'updateMask') {
397 $maskconstbookkeeping = GETPOST('maskconstbookkeeping', 'aZ09');
398 $maskbookkeeping = GETPOST('maskbookkeeping', 'alpha');
399
400 $res = 0;
401
402 if ($maskconstbookkeeping && preg_match('/_MASK$/', $maskconstbookkeeping)) {
403 $res = dolibarr_set_const($db, $maskconstbookkeeping, $maskbookkeeping, 'chaine', 0, '', $conf->entity);
404 }
405
406 if (!($res > 0)) {
407 $error++;
408 }
409
410 if (!$error) {
411 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
412 } else {
413 setEventMessages($langs->trans("Error"), null, 'errors');
414 }
415}
416
417if ($action == 'setmod') {
418 $value = GETPOST('value', 'alpha');
419 dolibarr_set_const($db, "BOOKKEEPING_ADDON", $value, 'chaine', 0, '', $conf->entity);
420}
421
422/*
423 * View
424 */
425
426$form = new Form($db);
427
428$title = $langs->trans('ConfigAccountingExpert');
429$help_url = 'EN:Module_Double_Entry_Accounting#Setup|FR:Module_Comptabilit&eacute;_en_Partie_Double#Configuration';
430llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-accountancy page-admin_index');
431
432
433$linkback = '';
434//$linkback = '<a href="' . DOL_URL_ROOT . '/admin/modules.php?restore_lastsearch_values=1">' . $langs->trans("BackToModuleList") . '</a>';
435print load_fiche_titre($title, $linkback, 'accountancy');
436
437
438// Show message if accountancy hidden options are activated to help to resolve some problems
439if (getDolGlobalString('FACTURE_DEPOSITS_ARE_JUST_PAYMENTS')) {
440 print '<div class="info">' . $langs->trans("ConstantIsOn", "FACTURE_DEPOSITS_ARE_JUST_PAYMENTS") . '</div>';
441}
442if (getDolGlobalString('FACTURE_SUPPLIER_DEPOSITS_ARE_JUST_PAYMENTS')) {
443 print '<div class="info">' . $langs->trans("ConstantIsOn", "FACTURE_SUPPLIER_DEPOSITS_ARE_JUST_PAYMENTS") . '</div>';
444}
445if (getDolGlobalString('ACCOUNTANCY_USE_PRODUCT_ACCOUNT_ON_THIRDPARTY')) {
446 print '<div class="info">' . $langs->trans("ConstantIsOn", "ACCOUNTANCY_USE_PRODUCT_ACCOUNT_ON_THIRDPARTY") . '</div>';
447}
448if (getDolGlobalString('MAIN_COMPANY_PERENTITY_SHARED')) {
449 print '<div class="info">' . $langs->trans("ConstantIsOn", "MAIN_COMPANY_PERENTITY_SHARED") . '</div>';
450}
451if (getDolGlobalString('MAIN_PRODUCT_PERENTITY_SHARED')) {
452 print '<div class="info">' . $langs->trans("ConstantIsOn", "MAIN_PRODUCT_PERENTITY_SHARED") . '</div>';
453}
454
455print '<br>';
456
457
458// Case of the parameter ACCOUNTING_MODE
459
460if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 1) {
461 print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
462 print '<input type="hidden" name="token" value="'.newToken().'">';
463 print '<input type="hidden" name="action" value="updatemode">';
464
465 print '<table class="noborder centpercent">';
466
467 print '<tr class="liste_titre">';
468 print '<td colspan="2">'.$langs->trans('OptionMode').'</td>';
469 print "</tr>\n";
470 print '<tr class="oddeven"><td class="nowraponall"><input type="radio" id="accounting_mode_1" name="accounting_mode" value="CREANCES-DETTES"'.($accounting_mode != 'RECETTES-DEPENSES' ? ' checked' : '').'><label for="accounting_mode_1"> '.$langs->trans('OptionModeVirtual').'</label> ('.$langs->trans('Default').')</td>';
471 print '<td><span class="opacitymedium">'.nl2br($langs->trans('ACCOUNTING_USE_NON_TREASURY_Desc')).'</span>';
472 print "</td></tr>\n";
473 print '<tr class="oddeven"><td class="nowraponall"><input type="radio" id="accounting_mode_2" name="accounting_mode" value="RECETTES-DEPENSES"'.($accounting_mode == 'RECETTES-DEPENSES' ? ' checked' : '').'><label for="accounting_mode_2"> '.$langs->trans('OptionModeTrue').'</label></td>';
474 print '<td><span class="opacitymedium">'.nl2br($langs->trans('ACCOUNTING_USE_TREASURY_Desc'))."</span>";
475 print "</td></tr>\n";
476
477 print "</table>\n";
478
479 print '<div class="center"><input type="submit" class="button button-edit" name="button" value="'.$langs->trans('Save').'"></div>';
480 print '</form>';
481
482
483 print '<br><br>';
484}
485
486
487// Show form main options
488print $formSetup->generateOutput(true);
489
490print '<br><br>';
491
492
493print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
494print '<input type="hidden" name="token" value="'.newToken().'">';
495print '<input type="hidden" name="action" value="update_binding">';
496print '<input type="hidden" name="page_y" value="">';
497
498// Binding params
499print '<div class="div-table-responsive-no-min">';
500print '<table class="noborder centpercent">';
501print '<tr class="liste_titre">';
502print '<td colspan="2">'.$langs->trans('BindingOptions').'</td>';
503print "</tr>\n";
504
505// Param a user $user->hasRight('accounting', 'chartofaccount') can access
506foreach ($list_binding as $key) {
507 print '<tr class="oddeven value">';
508
509 // Param
510 $label = $langs->trans($key);
511 print '<td>'.$label.'</td>';
512 // Value
513 print '<td class="right minwidth75imp parentonrightofpage">';
514 if ($key == 'ACCOUNTING_DATE_START_BINDING') {
515 print $form->selectDate((getDolGlobalInt($key) ? (int) getDolGlobalInt($key) : -1), $key, 0, 0, 1);
516 } elseif ($key == 'ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER') {
517 $array = array(0=>$langs->trans("PreviousMonth"), 1=>$langs->trans("CurrentMonth"), 2=>$langs->trans("Fiscalyear"));
518 print $form->selectarray($key, $array, getDolGlobalInt('ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER', 0), 0, 0, 0, '', 0, 0, 0, '', 'onrightofpage width200');
519 } elseif ($key == 'ACCOUNTING_LABEL_OPERATION_ON_TRANSFER') {
520 $array = array(
521 0=>$langs->trans("ThirdPartyName") . ' - ' . $langs->trans("NumPiece") . ' - ' . $langs->trans("LabelAccount"),
522 1=>$langs->trans("ThirdPartyName") . ' - ' . $langs->trans("NumPiece"),
523 2=>$langs->trans("ThirdPartyName")
524 );
525 print $form->selectarray($key, $array, getDolGlobalInt('ACCOUNTING_LABEL_OPERATION_ON_TRANSFER', 0), 0, 0, 0, '', 0, 0, 0, '', 'onrightofpage width200');
526 } else {
527 print '<input type="text" class="maxwidth100" id="'.$key.'" name="'.$key.'" value="'.getDolGlobalString($key).'">';
528 }
529
530 print '</td>';
531 print '</tr>';
532}
533
534print '<tr class="oddeven">';
535print '<td>'.$langs->trans("ACCOUNTING_DISABLE_BINDING_ON_SALES").'</td>';
536if (getDolGlobalString('ACCOUNTING_DISABLE_BINDING_ON_SALES')) {
537 print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&action=setdisablebindingonsales&value=0">';
538 print img_picto($langs->trans("Activated"), 'switch_on', '', 0, 0, 0, '', 'warning');
539 print '</a></td>';
540} else {
541 print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&action=setdisablebindingonsales&value=1">';
542 print img_picto($langs->trans("Disabled"), 'switch_off');
543 print '</a></td>';
544}
545print '</tr>';
546
547print '<tr class="oddeven">';
548print '<td>'.$langs->trans("ACCOUNTING_DISABLE_BINDING_ON_PURCHASES").'</td>';
549if (getDolGlobalString('ACCOUNTING_DISABLE_BINDING_ON_PURCHASES')) {
550 print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&action=setdisablebindingonpurchases&value=0">';
551 print img_picto($langs->trans("Activated"), 'switch_on', '', 0, 0, 0, '', 'warning');
552 print '</a></td>';
553} else {
554 print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&action=setdisablebindingonpurchases&value=1">';
555 print img_picto($langs->trans("Disabled"), 'switch_off');
556 print '</a></td>';
557}
558print '</tr>';
559
560print '<tr class="oddeven">';
561print '<td>'.$langs->trans("ACCOUNTING_DISABLE_BINDING_ON_EXPENSEREPORTS").'</td>';
562if (getDolGlobalString('ACCOUNTING_DISABLE_BINDING_ON_EXPENSEREPORTS')) {
563 print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&action=setdisablebindingonexpensereports&value=0">';
564 print img_picto($langs->trans("Activated"), 'switch_on', '', 0, 0, 0, '', 'warning');
565 print '</a></td>';
566} else {
567 print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&action=setdisablebindingonexpensereports&value=1">';
568 print img_picto($langs->trans("Disabled"), 'switch_off');
569 print '</a></td>';
570}
571print '</tr>';
572
573if (!getDolGlobalString('ACCOUNTING_DISABLE_BINDING_ON_EXPENSEREPORTS')) {
574 print '<tr class="oddeven">';
575 print '<td>'.$langs->trans("ACCOUNTANCY_ER_DATE_RECORD").'</td>';
576 if (getDolGlobalInt('ACCOUNTANCY_ER_DATE_RECORD')) {
577 print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&action=setACCOUNTANCY_ER_DATE_RECORD&value=0">';
578 print img_picto($langs->trans("Activated"), 'switch_on');
579 print '</a></td>';
580 } else {
581 print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&action=setACCOUNTANCY_ER_DATE_RECORD&value=1">';
582 print img_picto($langs->trans("Disabled"), 'switch_off');
583 print '</a></td>';
584 }
585 print '</tr>';
586}
587
588print '<tr class="oddeven">';
589print '<td>'.$langs->trans("ACCOUNTING_BANK_CONCILIATED").'</td>';
590if (getDolGlobalInt('ACCOUNTING_BANK_CONCILIATED') == 2) {
591 print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&action=setACCOUNTING_BANK_CONCILIATED&value=1">';
592 print img_picto($langs->trans("Activated"), 'switch_on');
593 print '</a></td>';
594} else {
595 print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&action=setACCOUNTING_BANK_CONCILIATED&value=2">';
596 print img_picto($langs->trans("Disabled"), 'switch_off');
597 print '</a></td>';
598}
599print '</tr>';
600
601print '</table>';
602print '</div>';
603
604print '<div class="center"><input type="submit" class="button button-edit reposition" name="button" value="'.dol_escape_htmltag($langs->trans('Save')).'"></div>';
605print '</form>';
606
607// Show numbering options
608print '<br><br>';
609
610// Accountancy Numbering model
611$dirmodels = array_merge(array('/'), $conf->modules_parts['models']);
612
613print '<div class="div-table-responsive-no-min">';
614print '<table class="noborder centpercent">';
615print '<tr class="liste_titre">';
616print '<td colspan="2">'.$langs->trans("BookkeepingNumberingModules").'</td>';
617print '<td class="nowrap">'.$langs->trans("Example").'</td>';
618print '<td class="center" width="60">'.$langs->trans("Status").'</td>';
619print '<td class="center" width="16">'.$langs->trans("ShortInfo").'</td>';
620print '</tr>'."\n";
621
622clearstatcache();
623
624$arrayofmodules = array();
625
626foreach ($dirmodels as $reldir) {
627 $dir = dol_buildpath($reldir."core/modules/accountancy/");
628
629 if (is_dir($dir)) {
630 $handle = opendir($dir);
631 if (is_resource($handle)) {
632 while (($file = readdir($handle)) !== false) {
633 if (strpos($file, 'mod_bookkeeping_') === 0 && substr($file, dol_strlen($file) - 3, 3) == 'php') {
634 $file = substr($file, 0, dol_strlen($file) - 4);
635
636 require_once $dir.$file.'.php';
637
638 $module = new $file($db);
639
641 '@phan-var-force ModeleNumRefBookkeeping $module';
642
643 $arrayofmodules[] = $module;
644 }
645 }
646 closedir($handle);
647 }
648 }
649}
650
651$arrayofmodules = dol_sort_array($arrayofmodules, 'position');
652
653foreach ($arrayofmodules as $module) {
654 $file = 'mod_bookkeeping_'.strtolower($module->getName($langs));
655
656 // Show modules according to features level
657 if ($module->version == 'development' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 2) {
658 continue;
659 }
660 if ($module->version == 'experimental' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 1) {
661 continue;
662 }
663
664 if ($module->isEnabled()) {
665 print '<tr class="oddeven"><td class="width100">'.$module->name."</td><td>\n";
666 print $module->info($langs);
667 print '</td>';
668
669 // Show example of the numbering model
670 print '<td class="nowrap">';
671 $tmp = $module->getExample();
672 if (preg_match('/^Error/', $tmp)) {
673 $langs->load("errors");
674 print '<div class="error">'.$langs->trans($tmp).'</div>';
675 } elseif ($tmp == 'NotConfigured') {
676 print '<span class="opacitymedium">'.$langs->trans($tmp).'</span>';
677 } else {
678 print $tmp;
679 }
680 print '</td>'."\n";
681
682 print '<td class="center">';
683 if (getDolGlobalString('BOOKKEEPING_ADDON') == $file) {
684 print img_picto($langs->trans("Activated"), 'switch_on');
685 } else {
686 print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setmod&token='.newToken().'&value='.urlencode($file).'">';
687 print img_picto($langs->trans("Disabled"), 'switch_off');
688 print '</a>';
689 }
690 print '</td>';
691
692 $bookkeeping = new BookKeeping($db);
693 $bookkeeping->initAsSpecimen();
694
695 // Info
696 $htmltooltip = ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
697
698 $nextval = $module->getNextValue($bookkeeping);
699 if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
700 $htmltooltip .= ''.$langs->trans("NextValue").': ';
701 if ($nextval) {
702 if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') {
703 $nextval = $langs->trans($nextval);
704 }
705 $htmltooltip .= $nextval.'<br>';
706 } else {
707 $htmltooltip .= $langs->trans($module->error).'<br>';
708 }
709 }
710
711 print '<td class="center">';
712 print $form->textwithpicto('', $htmltooltip, 1, 'info');
713 print '</td>';
714
715 print "</tr>\n";
716 }
717}
718print '</table>';
719print '</div>';
720print '</form>';
721
722// Show advanced options
723print '<br><br>';
724
725// Advanced params
726print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
727print '<input type="hidden" name="token" value="'.newToken().'">';
728print '<input type="hidden" name="action" value="update_advanced">';
729print '<input type="hidden" name="page_y" value="">';
730
731print '<div class="div-table-responsive-no-min">';
732print '<table class="noborder centpercent">';
733print '<tr class="liste_titre">';
734print '<td colspan="2">' . $langs->trans('OptionsAdvanced') . '</td>';
735print "</tr>\n";
736
737print '<tr class="oddeven">';
738print '<td>';
739print $form->textwithpicto($langs->trans("ACCOUNTING_ENABLE_LETTERING"), $langs->trans("ACCOUNTING_ENABLE_LETTERING_DESC", $langs->transnoentitiesnoconv("NumMvts")).'<br>'.$langs->trans("EnablingThisFeatureIsNotNecessary")).'</td>';
740if (getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING')) {
741 print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&action=setenablelettering&value=0">';
742 print img_picto($langs->trans("Activated"), 'switch_on');
743 print '</a></td>';
744} else {
745 print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&action=setenablelettering&value=1">';
746 print img_picto($langs->trans("Disabled"), 'switch_off');
747 print '</a></td>';
748}
749print '</tr>';
750
751if (getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING')) {
752 // Number of letters for lettering (3 by default (AAA), min 2 (AA))
753 print '<tr class="oddeven">';
754 print '<td>';
755 print $form->textwithpicto($langs->trans("ACCOUNTING_LETTERING_NBLETTERS"), $langs->trans("ACCOUNTING_LETTERING_NBLETTERS_DESC")) . '</td>';
756 print '<td class="right">';
757
758 if (empty($letter)) {
759 if (getDolGlobalInt('ACCOUNTING_LETTERING_NBLETTERS')) {
760 $nbletter = getDolGlobalInt('ACCOUNTING_LETTERING_NBLETTERS');
761 } else {
762 $nbletter = 3;
763 }
764 }
765
766 print '<input class="flat right" name="ACCOUNTING_LETTERING_NBLETTERS" id="ACCOUNTING_LETTERING_NBLETTERS" value="' . $nbletter . '" type="number" step="1" min="2" max="3" >' . "\n";
767 print '</tr>';
768
769 // Auto Lettering when transfer in accountancy is realized
770 print '<tr class="oddeven">';
771 print '<td>';
772 print $form->textwithpicto($langs->trans("ACCOUNTING_ENABLE_AUTOLETTERING"), $langs->trans("ACCOUNTING_ENABLE_AUTOLETTERING_DESC")) . '</td>';
773 if (getDolGlobalInt('ACCOUNTING_ENABLE_AUTOLETTERING')) {
774 print '<td class="right"><a class="reposition" href="' . $_SERVER['PHP_SELF'] . '?token=' . newToken() . '&action=setenableautolettering&value=0">';
775 print img_picto($langs->trans("Activated"), 'switch_on');
776 print '</a></td>';
777 } else {
778 print '<td class="right"><a class="reposition" href="' . $_SERVER['PHP_SELF'] . '?token=' . newToken() . '&action=setenableautolettering&value=1">';
779 print img_picto($langs->trans("Disabled"), 'switch_off');
780 print '</a></td>';
781 }
782 print '</tr>';
783}
784
785print '<tr class="oddeven">';
786print '<td>';
787print $form->textwithpicto($langs->trans("ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE"), $langs->trans("ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE_DESC", $langs->transnoentities("MenuDefaultAccounts"))).'</td>';
788if (getDolGlobalString('ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE')) {
789 print '<td class="right"><a class="reposition" href="' . $_SERVER['PHP_SELF'] . '?token=' . newToken() . '&action=setenablevatreversecharge&value=0">';
790 print img_picto($langs->trans("Activated"), 'switch_on');
791 print '</a></td>';
792} else {
793 print '<td class="right"><a class="reposition" href="' . $_SERVER['PHP_SELF'] . '?token=' . newToken() . '&action=setenablevatreversecharge&value=1">';
794 print img_picto($langs->trans("Disabled"), 'switch_off');
795 print '</a></td>';
796}
797print '</tr>';
798
799print '<tr class="oddeven">';
800print '<td>';
801print $form->textwithpicto($langs->trans("ACCOUNTING_ENABLE_TABONTHIRDPARTY"), $langs->trans("ACCOUNTING_ENABLE_TABONTHIRDPARTY_DESC")).'</td>';
802if (getDolGlobalString('ACCOUNTING_ENABLE_TABONTHIRDPARTY')) {
803 print '<td class="right"><a class="reposition" href="' . $_SERVER['PHP_SELF'] . '?token=' . newToken() . '&action=setenabletabonthirdparty&value=0">';
804 print img_picto($langs->trans("Activated"), 'switch_on');
805 print '</a></td>';
806} else {
807 print '<td class="right"><a class="reposition" href="' . $_SERVER['PHP_SELF'] . '?token=' . newToken() . '&action=setenabletabonthirdparty&value=1">';
808 print img_picto($langs->trans("Disabled"), 'switch_off');
809 print '</a></td>';
810}
811print '</tr>';
812
813print '</table>';
814print '</div>';
815
816
817print '<div class="center"><input type="submit" class="button button-edit reposition" name="button" value="'.$langs->trans('Save').'"></div>';
818print '</form>';
819
820print '<br><br>';
821
822
823// Export options
824print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
825print '<input type="hidden" name="token" value="'.newToken().'">';
826print '<input type="hidden" name="action" value="update_export">';
827print '<input type="hidden" name="page_y" value="">';
828
829print "\n".'<script type="text/javascript">'."\n";
830print 'jQuery(document).ready(function () {'."\n";
831print ' function initfields()'."\n";
832print ' {'."\n";
833foreach ($listparam as $key => $param) {
834 print ' if (jQuery("#ACCOUNTING_EXPORT_MODELCSV").val()=="'.$key.'")'."\n";
835 print ' {'."\n";
836 print ' //console.log("'.$param['label'].'");'."\n";
837 if (empty($param['ACCOUNTING_EXPORT_FORMAT'])) {
838 print ' jQuery("#ACCOUNTING_EXPORT_FORMAT").val("'.getDolGlobalString('ACCOUNTING_EXPORT_FORMAT').'");'."\n";
839 print ' jQuery("#ACCOUNTING_EXPORT_FORMAT").prop("disabled", true);'."\n";
840 } else {
841 print ' jQuery("#ACCOUNTING_EXPORT_FORMAT").val("'.$param['ACCOUNTING_EXPORT_FORMAT'].'");'."\n";
842 print ' jQuery("#ACCOUNTING_EXPORT_FORMAT").removeAttr("disabled");'."\n";
843 }
844 if (empty($param['ACCOUNTING_EXPORT_SEPARATORCSV'])) {
845 print ' jQuery("#ACCOUNTING_EXPORT_SEPARATORCSV").val("");'."\n";
846 print ' jQuery("#ACCOUNTING_EXPORT_SEPARATORCSV").prop("disabled", true);'."\n";
847 } else {
848 print ' jQuery("#ACCOUNTING_EXPORT_SEPARATORCSV").val("'.getDolGlobalString('ACCOUNTING_EXPORT_SEPARATORCSV').'");'."\n";
849 print ' jQuery("#ACCOUNTING_EXPORT_SEPARATORCSV").removeAttr("disabled");'."\n";
850 }
851 if (empty($param['ACCOUNTING_EXPORT_ENDLINE'])) {
852 print ' jQuery("#ACCOUNTING_EXPORT_ENDLINE").prop("disabled", true);'."\n";
853 } else {
854 print ' jQuery("#ACCOUNTING_EXPORT_ENDLINE").removeAttr("disabled");'."\n";
855 }
856 if (empty($param['ACCOUNTING_EXPORT_DATE'])) {
857 print ' jQuery("#ACCOUNTING_EXPORT_DATE").val("");'."\n";
858 print ' jQuery("#ACCOUNTING_EXPORT_DATE").prop("disabled", true);'."\n";
859 } else {
860 print ' jQuery("#ACCOUNTING_EXPORT_DATE").val("'.getDolGlobalString('ACCOUNTING_EXPORT_DATE').'");'."\n";
861 print ' jQuery("#ACCOUNTING_EXPORT_DATE").removeAttr("disabled");'."\n";
862 }
863 print ' }'."\n";
864}
865print ' }'."\n";
866print ' initfields();'."\n";
867print ' jQuery("#ACCOUNTING_EXPORT_MODELCSV").change(function() {'."\n";
868print ' initfields();'."\n";
869print ' });'."\n";
870print '})'."\n";
871print '</script>'."\n";
872
873print '<table class="noborder centpercent">';
874print '<tr class="liste_titre">';
875print '<td colspan="2">'.$langs->trans('ExportOptions').'</td>';
876print "</tr>\n";
877
878$num = count($main_option);
879if ($num) {
880 foreach ($main_option as $key) {
881 print '<tr class="oddeven value">';
882
883 // Param
884 $label = $langs->trans($key);
885 print '<td>'.dol_escape_htmltag($label).'</td>';
886
887 // Value
888 print '<td>';
889 print '<input type="text" size="20" id="'.$key.'" name="'.$key.'" value="'.getDolGlobalString($key).'">';
890 print '</td></tr>';
891 }
892}
893
894print '<tr class="oddeven">';
895print '<td>'.$langs->trans("Selectmodelcsv").'</td>';
896if (!$conf->use_javascript_ajax) {
897 print '<td class="nowrap">';
898 print $langs->trans("NotAvailableWhenAjaxDisabled");
899 print "</td>";
900} else {
901 print '<td>';
902 $listofexporttemplates = $accountancyexport->getType(1);
903 print $form->selectarray("ACCOUNTING_EXPORT_MODELCSV", $listofexporttemplates, getDolGlobalString('ACCOUNTING_EXPORT_MODELCSV'), 0, 0, 0, '', 0, 0, 0, '', '', 1);
904 print '</td>';
905}
906print "</tr>";
907
908
909$num2 = count($model_option);
910if ($num2) {
911 foreach ($model_option as $key) {
912 print '<tr class="oddeven value">';
913
914 // Param
915 $label = $key['label'];
916 print '<td>'.$langs->trans($label).'</td>';
917
918 // Value
919 print '<td>';
920 if (is_array($key['param'])) {
921 print $form->selectarray($label, $key['param'], getDolGlobalString($label), 0);
922 } else {
923 print '<input type="text" size="20" id="'.$label.'" name="'.$key['label'].'" value="'.getDolGlobalString($label).'">';
924 }
925
926 print '</td></tr>';
927 }
928
929 print "</table>\n";
930}
931
932print '<div class="center"><input type="submit" class="button reposition" value="'.dol_escape_htmltag($langs->trans('Save')).'" name="button"></div>';
933
934print '</form>';
935
936// End of page
937llxFooter();
938$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).
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:73
Manage the different format accountancy export.
Class to manage Ledger (General Ledger and Subledger)
Class to manage generation of HTML components Only common components must be here.
This class help you create setup render.
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, $allowothertags=array())
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.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
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.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.