dolibarr 24.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';
40require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
41
42// Load translation files required by the page
43$langs->loadLangs(array('admin', 'compta', 'accountancy'));
44
45$action = GETPOST('action', 'aZ09');
46
47// Other parameters ACCOUNTING_*
48$list = array(
49 'ACCOUNTING_PRODUCT_BUY_ACCOUNT',
50 'ACCOUNTING_PRODUCT_SOLD_ACCOUNT',
51 'ACCOUNTING_SERVICE_BUY_ACCOUNT',
52 'ACCOUNTING_SERVICE_SOLD_ACCOUNT',
53 'ACCOUNTING_VAT_SOLD_ACCOUNT',
54 'ACCOUNTING_VAT_BUY_ACCOUNT',
55 'ACCOUNTING_ACCOUNT_CUSTOMER',
56 'ACCOUNTING_ACCOUNT_SUPPLIER'
57);
58
59if (!$user->admin) {
61}
62
63if (!isModEnabled('comptabilite')) {
64 accessforbidden('Module not enabled');
65}
66
67
68/*
69 * Actions
70 */
71
72$accounting_mode = getDolGlobalString('ACCOUNTING_MODE', 'CREANCES-DETTES');
73
74if ($action == 'update') {
75 $error = 0;
76
77 $accounting_modes = array(
78 'RECETTES-DEPENSES',
79 'CREANCES-DETTES'
80 );
81
82 $accounting_mode = GETPOST('accounting_mode', 'alpha');
83
84
85 if (in_array($accounting_mode, $accounting_modes)) {
86 if (!dolibarr_set_const($db, 'ACCOUNTING_MODE', $accounting_mode, 'chaine', 0, '', $conf->entity)) {
87 $error++;
88 }
89 } else {
90 $error++;
91 }
92
93 foreach ($list as $constname) {
94 $constvalue = GETPOST($constname, 'alpha');
95
96 if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
97 $error++;
98 }
99 }
100
101 $report_include_varpay = GETPOST('ACCOUNTING_REPORTS_INCLUDE_VARPAY', 'alpha');
102 if (!empty($report_include_varpay)) {
103 if ($report_include_varpay == 'yes') {
104 if (!dolibarr_set_const($db, 'ACCOUNTING_REPORTS_INCLUDE_VARPAY', 1, 'chaine', 0, '', $conf->entity)) {
105 $error++;
106 }
107 }
108 }
109 if ($report_include_varpay == 'no') {
110 if (!dolibarr_del_const($db, 'ACCOUNTING_REPORTS_INCLUDE_VARPAY', $conf->entity)) {
111 $error++;
112 }
113 }
114
115 $report_include_loan = GETPOST('ACCOUNTING_REPORTS_INCLUDE_LOAN', 'alpha');
116 if (!empty($report_include_loan)) {
117 if ($report_include_loan == 'yes') {
118 if (!dolibarr_set_const($db, 'ACCOUNTING_REPORTS_INCLUDE_LOAN', 1, 'chaine', 0, '', $conf->entity)) {
119 $error++;
120 }
121 }
122 }
123 if ($report_include_loan == 'no') {
124 if (!dolibarr_del_const($db, 'ACCOUNTING_REPORTS_INCLUDE_LOAN', $conf->entity)) {
125 $error++;
126 }
127 }
128
129 if (!$error) {
130 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
131 } else {
132 setEventMessages($langs->trans("Error"), null, 'errors');
133 }
134}
135
136
137/*
138 * View
139 */
140
141llxHeader('', '', '', '', 0, 0, '', '', '', 'mod-admin page-compta');
142
143$form = new Form($db);
144
145$linkback = '<a href="'.dolBuildUrl(DOL_URL_ROOT.'/admin/modules.php', ['restore_lastsearch_values' => 1]).'">'.img_picto($langs->trans("BackToModuleList"), 'back', 'class="pictofixedwidth"').'<span class="hideonsmartphone">'.$langs->trans("BackToModuleList").'</span></a>';
146
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.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
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)
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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.
isModEnabled($module)
Is Dolibarr module enabled.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.