dolibarr 21.0.0-beta
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
46if (!$user->admin) {
48}
49
50$action = GETPOST('action', 'aZ09');
51
52// Other parameters ACCOUNTING_*
53$list = array(
54 'ACCOUNTING_PRODUCT_BUY_ACCOUNT',
55 'ACCOUNTING_PRODUCT_SOLD_ACCOUNT',
56 'ACCOUNTING_SERVICE_BUY_ACCOUNT',
57 'ACCOUNTING_SERVICE_SOLD_ACCOUNT',
58 'ACCOUNTING_VAT_SOLD_ACCOUNT',
59 'ACCOUNTING_VAT_BUY_ACCOUNT',
60 'ACCOUNTING_ACCOUNT_CUSTOMER',
61 'ACCOUNTING_ACCOUNT_SUPPLIER'
62);
63
64/*
65 * Actions
66 */
67
68$accounting_mode = getDolGlobalString('ACCOUNTING_MODE', 'RECETTES-DEPENSES');
69
70if ($action == 'update') {
71 $error = 0;
72
73 $accounting_modes = array(
74 'RECETTES-DEPENSES',
75 'CREANCES-DETTES'
76 );
77
78 $accounting_mode = GETPOST('accounting_mode', 'alpha');
79
80
81 if (in_array($accounting_mode, $accounting_modes)) {
82 if (!dolibarr_set_const($db, 'ACCOUNTING_MODE', $accounting_mode, 'chaine', 0, '', $conf->entity)) {
83 $error++;
84 }
85 } else {
86 $error++;
87 }
88
89 foreach ($list as $constname) {
90 $constvalue = GETPOST($constname, 'alpha');
91
92 if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
93 $error++;
94 }
95 }
96
97 $report_include_varpay = GETPOST('ACCOUNTING_REPORTS_INCLUDE_VARPAY', 'alpha');
98 if (!empty($report_include_varpay)) {
99 if ($report_include_varpay == 'yes') {
100 if (!dolibarr_set_const($db, 'ACCOUNTING_REPORTS_INCLUDE_VARPAY', 1, 'chaine', 0, '', $conf->entity)) {
101 $error++;
102 }
103 }
104 }
105 if ($report_include_varpay == 'no') {
106 if (!dolibarr_del_const($db, 'ACCOUNTING_REPORTS_INCLUDE_VARPAY', $conf->entity)) {
107 $error++;
108 }
109 }
110
111 $report_include_loan = GETPOST('ACCOUNTING_REPORTS_INCLUDE_LOAN', 'alpha');
112 if (!empty($report_include_loan)) {
113 if ($report_include_loan == 'yes') {
114 if (!dolibarr_set_const($db, 'ACCOUNTING_REPORTS_INCLUDE_LOAN', 1, 'chaine', 0, '', $conf->entity)) {
115 $error++;
116 }
117 }
118 }
119 if ($report_include_loan == 'no') {
120 if (!dolibarr_del_const($db, 'ACCOUNTING_REPORTS_INCLUDE_LOAN', $conf->entity)) {
121 $error++;
122 }
123 }
124
125 if (!$error) {
126 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
127 } else {
128 setEventMessages($langs->trans("Error"), null, 'errors');
129 }
130}
131
132/*
133 * View
134 */
135
136llxHeader('', '', '', '', 0, 0, '', '', '', 'mod-admin page-compta');
137
138$form = new Form($db);
139
140$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
141print load_fiche_titre($langs->trans('ComptaSetup'), $linkback, 'title_setup');
142
143print '<br>';
144
145print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
146print '<input type="hidden" name="token" value="'.newToken().'">';
147print '<input type="hidden" name="action" value="update">';
148
149print '<table class="noborder centpercent">';
150
151// case of the parameter ACCOUNTING_MODE
152
153print '<tr class="liste_titre">';
154print '<td>'.$langs->trans('OptionMode').'</td><td>'.$langs->trans('Description').'</td>';
155print "</tr>\n";
156print '<tr class="oddeven"><td width="200"><input type="radio" name="accounting_mode" value="RECETTES-DEPENSES"'.($accounting_mode != 'CREANCES-DETTES' ? ' checked' : '').'> '.$langs->trans('OptionModeTrue').'</td>';
157print '<td colspan="2">'.nl2br($langs->trans('OptionModeTrueDesc'));
158print "</td></tr>\n";
159print '<tr class="oddeven"><td width="200"><input type="radio" name="accounting_mode" value="CREANCES-DETTES"'.($accounting_mode == 'CREANCES-DETTES' ? ' checked' : '').'> '.$langs->trans('OptionModeVirtual').'</td>';
160print '<td colspan="2">'.nl2br($langs->trans('OptionModeVirtualDesc'))."</td></tr>\n";
161
162print "</table>\n";
163
164print "<br>\n";
165
166print '<table class="noborder centpercent">';
167print '<tr class="liste_titre">';
168print '<td colspan="3">'.$langs->trans('OtherOptions').'</td>';
169print "</tr>\n";
170
171
172foreach ($list as $key) {
173 print '<tr class="oddeven value">';
174
175 // Param
176 $libelle = $langs->trans($key);
177 print '<td><label for="'.$key.'">'.$libelle.'</label></td>';
178
179 // Value
180 print '<td>';
181 print '<input type="text" size="20" id="'.$key.'" name="'.$key.'" value="'.getDolGlobalString($key).'">';
182 print '</td></tr>';
183}
184
185// Option to include various payment in results
186print '<tr class="oddeven value">'."\n";
187print '<td><label for="ACCOUNTING_REPORTS_INCLUDE_VARPAY">'.$langs->trans('IncludeVarpaysInResults').'</label></td>'."\n";
188print '<td class="center">'."\n";
189print $form->selectyesno('ACCOUNTING_REPORTS_INCLUDE_VARPAY', (getDolGlobalString('ACCOUNTING_REPORTS_INCLUDE_VARPAY')));
190print '</td></tr>';
191
192// Option to include loan in results
193print '<tr class="oddeven value">'."\n";
194print '<td><label for="ACCOUNTING_REPORTS_INCLUDE_LOAN">'.$langs->trans('IncludeLoansInResults').'</label></td>'."\n";
195print '<td class="center">'."\n";
196print $form->selectyesno('ACCOUNTING_REPORTS_INCLUDE_LOAN', (getDolGlobalString('ACCOUNTING_REPORTS_INCLUDE_LOAN')));
197print '</td></tr>';
198
199print "</table>\n";
200
201print '<br><br><div style="text-align:center"><input type="submit" class="button button-edit" name="button" value="'.$langs->trans('Modify').'"></div>';
202print '</form>';
203
204// End of page
205llxFooter();
206$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.
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:71
Class to manage generation of HTML components Only common components must be here.
llxFooter()
Footer empty.
Definition document.php:107
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.