dolibarr 22.0.5
compta.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
5 * Copyright (C) 2011-2013 Juanjo Menent <jmenent@2byte.es>
6 * Copyright (C) 2013-2017 Philippe Grand <philippe.grand@atoo-net.com>
7 * Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
8 * Copyright (C) 2020 Maxime DEMAREST <maxime@indelog.fr>
9 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 3 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program. If not, see <https://www.gnu.org/licenses/>.
23 */
24
31// Load Dolibarr environment
32require '../main.inc.php';
33require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
34
43// Load translation files required by the page
44$langs->loadLangs(array('admin', 'compta', 'accountancy'));
45
46$action = GETPOST('action', 'aZ09');
47
48// Other parameters ACCOUNTING_*
49$list = array(
50 'ACCOUNTING_PRODUCT_BUY_ACCOUNT',
51 'ACCOUNTING_PRODUCT_SOLD_ACCOUNT',
52 'ACCOUNTING_SERVICE_BUY_ACCOUNT',
53 'ACCOUNTING_SERVICE_SOLD_ACCOUNT',
54 'ACCOUNTING_VAT_SOLD_ACCOUNT',
55 'ACCOUNTING_VAT_BUY_ACCOUNT',
56 'ACCOUNTING_ACCOUNT_CUSTOMER',
57 'ACCOUNTING_ACCOUNT_SUPPLIER'
58);
59
60if (!$user->admin) {
62}
63
64if (!isModEnabled('comptabilite')) {
65 accessforbidden('Module not enabled');
66}
67
68
69/*
70 * Actions
71 */
72
73$accounting_mode = getDolGlobalString('ACCOUNTING_MODE', 'CREANCES-DETTES');
74
75if ($action == 'update') {
76 $error = 0;
77
78 $accounting_modes = array(
79 'RECETTES-DEPENSES',
80 'CREANCES-DETTES'
81 );
82
83 $accounting_mode = GETPOST('accounting_mode', 'alpha');
84
85
86 if (in_array($accounting_mode, $accounting_modes)) {
87 if (!dolibarr_set_const($db, 'ACCOUNTING_MODE', $accounting_mode, 'chaine', 0, '', $conf->entity)) {
88 $error++;
89 }
90 } else {
91 $error++;
92 }
93
94 foreach ($list as $constname) {
95 $constvalue = GETPOST($constname, 'alpha');
96
97 if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
98 $error++;
99 }
100 }
101
102 $report_include_varpay = GETPOST('ACCOUNTING_REPORTS_INCLUDE_VARPAY', 'alpha');
103 if (!empty($report_include_varpay)) {
104 if ($report_include_varpay == 'yes') {
105 if (!dolibarr_set_const($db, 'ACCOUNTING_REPORTS_INCLUDE_VARPAY', 1, 'chaine', 0, '', $conf->entity)) {
106 $error++;
107 }
108 }
109 }
110 if ($report_include_varpay == 'no') {
111 if (!dolibarr_del_const($db, 'ACCOUNTING_REPORTS_INCLUDE_VARPAY', $conf->entity)) {
112 $error++;
113 }
114 }
115
116 $report_include_loan = GETPOST('ACCOUNTING_REPORTS_INCLUDE_LOAN', 'alpha');
117 if (!empty($report_include_loan)) {
118 if ($report_include_loan == 'yes') {
119 if (!dolibarr_set_const($db, 'ACCOUNTING_REPORTS_INCLUDE_LOAN', 1, 'chaine', 0, '', $conf->entity)) {
120 $error++;
121 }
122 }
123 }
124 if ($report_include_loan == 'no') {
125 if (!dolibarr_del_const($db, 'ACCOUNTING_REPORTS_INCLUDE_LOAN', $conf->entity)) {
126 $error++;
127 }
128 }
129
130 if (!$error) {
131 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
132 } else {
133 setEventMessages($langs->trans("Error"), null, 'errors');
134 }
135}
136
137
138/*
139 * View
140 */
141
142llxHeader('', '', '', '', 0, 0, '', '', '', 'mod-admin page-compta');
143
144$form = new Form($db);
145
146$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
147print load_fiche_titre($langs->trans('ComptaSetup'), $linkback, 'title_setup');
148
149print '<br>';
150
151print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
152print '<input type="hidden" name="token" value="'.newToken().'">';
153print '<input type="hidden" name="action" value="update">';
154
155print '<table class="noborder centpercent">';
156
157// case of the parameter ACCOUNTING_MODE
158
159print '<tr class="liste_titre">';
160print '<td colspan="2">'.$langs->trans('OptionMode').'</td>';
161print "</tr>\n";
162print '<tr class="oddeven"><td class="nowraponall"><input type="radio" id="accounting_mode_2" name="accounting_mode" value="CREANCES-DETTES"'.($accounting_mode != 'RECETTES-DEPENSES' ? ' checked' : '').'><label for="accounting_mode_2"> '.$langs->trans('OptionModeVirtual').'</label></td>';
163print '<td class="opacitymedium">'.nl2br($langs->trans('OptionModeVirtualDesc'))."</td></tr>\n";
164print '<tr class="oddeven"><td class="nowraponall"><input type="radio" id="accounting_mode_1" name="accounting_mode" value="RECETTES-DEPENSES"'.($accounting_mode == 'RECETTES-DEPENSES' ? ' checked' : '').'><label for="accounting_mode_1"> '.$langs->trans('OptionModeTrue').'</label></td>';
165print '<td class="opacitymedium">'.nl2br($langs->trans('OptionModeTrueDesc'));
166print "</td></tr>\n";
167
168print "</table>\n";
169
170print "<br>\n";
171
172print '<table class="noborder centpercent">';
173print '<tr class="liste_titre">';
174print '<td colspan="3">'.$langs->trans('OtherOptions').'</td>';
175print "</tr>\n";
176
177/*
178foreach ($list as $key) {
179 print '<tr class="oddeven value">';
180
181 // Param
182 $libelle = $langs->trans($key);
183 print '<td><label for="'.$key.'">'.$libelle.'</label></td>';
184
185 // Value
186 print '<td>';
187 print '<input type="text" size="20" id="'.$key.'" name="'.$key.'" value="'.getDolGlobalString($key).'">';
188 print '</td></tr>';
189}
190*/
191
192// Option to include various payment in results
193print '<tr class="oddeven value">'."\n";
194print '<td><label for="ACCOUNTING_REPORTS_INCLUDE_VARPAY">'.$langs->trans('IncludeVarpaysInResults').'</label></td>'."\n";
195print '<td class="center">'."\n";
196print $form->selectyesno('ACCOUNTING_REPORTS_INCLUDE_VARPAY', (getDolGlobalString('ACCOUNTING_REPORTS_INCLUDE_VARPAY')));
197print '</td></tr>';
198
199// Option to include loan in results
200print '<tr class="oddeven value">'."\n";
201print '<td><label for="ACCOUNTING_REPORTS_INCLUDE_LOAN">'.$langs->trans('IncludeLoansInResults').'</label></td>'."\n";
202print '<td class="center">'."\n";
203print $form->selectyesno('ACCOUNTING_REPORTS_INCLUDE_LOAN', (getDolGlobalString('ACCOUNTING_REPORTS_INCLUDE_LOAN')));
204print '</td></tr>';
205
206print "</table>\n";
207
208print '<br><br><div class="center"><input type="submit" class="button button-edit" name="button" value="'.$langs->trans('Save').'"></div>';
209print '</form>';
210
211// End of page
212llxFooter();
213$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).
dolibarr_del_const($db, $name, $entity=1)
Delete a constant.
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
Class to manage generation of HTML components Only common components must be here.
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.
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.
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.