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