dolibarr 18.0.6
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 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 3 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22 */
23
30// Load Dolibarr environment
31require '../main.inc.php';
32require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
33
34// Load translation files required by the page
35$langs->loadLangs(array('admin', 'compta', 'accountancy'));
36
37if (!$user->admin) {
39}
40
41$action = GETPOST('action', 'aZ09');
42
43// Other parameters ACCOUNTING_*
44$list = array(
45 'ACCOUNTING_PRODUCT_BUY_ACCOUNT',
46 'ACCOUNTING_PRODUCT_SOLD_ACCOUNT',
47 'ACCOUNTING_SERVICE_BUY_ACCOUNT',
48 'ACCOUNTING_SERVICE_SOLD_ACCOUNT',
49 'ACCOUNTING_VAT_SOLD_ACCOUNT',
50 'ACCOUNTING_VAT_BUY_ACCOUNT',
51 'ACCOUNTING_ACCOUNT_CUSTOMER',
52 'ACCOUNTING_ACCOUNT_SUPPLIER'
53);
54
55/*
56 * Actions
57 */
58
59$accounting_mode = empty($conf->global->ACCOUNTING_MODE) ? 'RECETTES-DEPENSES' : $conf->global->ACCOUNTING_MODE;
60
61if ($action == 'update') {
62 $error = 0;
63
64 $accounting_modes = array(
65 'RECETTES-DEPENSES',
66 'CREANCES-DETTES'
67 );
68
69 $accounting_mode = GETPOST('accounting_mode', 'alpha');
70
71
72 if (in_array($accounting_mode, $accounting_modes)) {
73 if (!dolibarr_set_const($db, 'ACCOUNTING_MODE', $accounting_mode, 'chaine', 0, '', $conf->entity)) {
74 $error++;
75 }
76 } else {
77 $error++;
78 }
79
80 foreach ($list as $constname) {
81 $constvalue = GETPOST($constname, 'alpha');
82
83 if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
84 $error++;
85 }
86 }
87
88 $report_include_varpay = GETPOST('ACCOUNTING_REPORTS_INCLUDE_VARPAY', 'alpha');
89 if (!empty($report_include_varpay)) {
90 if ($report_include_varpay == 'yes') {
91 if (!dolibarr_set_const($db, 'ACCOUNTING_REPORTS_INCLUDE_VARPAY', 1, 'chaine', 0, '', $conf->entity)) {
92 $error++;
93 }
94 }
95 }
96 if ($report_include_varpay == 'no') {
97 if (!dolibarr_del_const($db, 'ACCOUNTING_REPORTS_INCLUDE_VARPAY', $conf->entity)) {
98 $error++;
99 }
100 }
101
102 $report_include_loan = GETPOST('ACCOUNTING_REPORTS_INCLUDE_LOAN', 'alpha');
103 if (!empty($report_include_loan)) {
104 if ($report_include_loan == 'yes') {
105 if (!dolibarr_set_const($db, 'ACCOUNTING_REPORTS_INCLUDE_LOAN', 1, 'chaine', 0, '', $conf->entity)) {
106 $error++;
107 }
108 }
109 }
110 if ($report_include_loan == 'no') {
111 if (!dolibarr_del_const($db, 'ACCOUNTING_REPORTS_INCLUDE_LOAN', $conf->entity)) {
112 $error++;
113 }
114 }
115
116 if (!$error) {
117 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
118 } else {
119 setEventMessages($langs->trans("Error"), null, 'errors');
120 }
121}
122
123/*
124 * View
125 */
126
127llxHeader();
128
129$form = new Form($db);
130
131$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
132print load_fiche_titre($langs->trans('ComptaSetup'), $linkback, 'title_setup');
133
134print '<br>';
135
136print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
137print '<input type="hidden" name="token" value="'.newToken().'">';
138print '<input type="hidden" name="action" value="update">';
139
140print '<table class="noborder centpercent">';
141
142// case of the parameter ACCOUNTING_MODE
143
144print '<tr class="liste_titre">';
145print '<td>'.$langs->trans('OptionMode').'</td><td>'.$langs->trans('Description').'</td>';
146print "</tr>\n";
147print '<tr class="oddeven"><td width="200"><input type="radio" name="accounting_mode" value="RECETTES-DEPENSES"'.($accounting_mode != 'CREANCES-DETTES' ? ' checked' : '').'> '.$langs->trans('OptionModeTrue').'</td>';
148print '<td colspan="2">'.nl2br($langs->trans('OptionModeTrueDesc'));
149// Write info on way to count VAT
150//if (!empty($conf->global->MAIN_MODULE_COMPTABILITE))
151//{
152// // print "<br>\n";
153// // print nl2br($langs->trans('OptionModeTrueInfoModuleComptabilite'));
154//}
155//else
156//{
157// // print "<br>\n";
158// // print nl2br($langs->trans('OptionModeTrueInfoExpert'));
159//}
160print "</td></tr>\n";
161print '<tr class="oddeven"><td width="200"><input type="radio" name="accounting_mode" value="CREANCES-DETTES"'.($accounting_mode == 'CREANCES-DETTES' ? ' checked' : '').'> '.$langs->trans('OptionModeVirtual').'</td>';
162print '<td colspan="2">'.nl2br($langs->trans('OptionModeVirtualDesc'))."</td></tr>\n";
163
164print "</table>\n";
165
166print "<br>\n";
167
168print '<table class="noborder centpercent">';
169print '<tr class="liste_titre">';
170print '<td colspan="3">'.$langs->trans('OtherOptions').'</td>';
171print "</tr>\n";
172
173
174foreach ($list as $key) {
175 print '<tr class="oddeven value">';
176
177 // Param
178 $libelle = $langs->trans($key);
179 print '<td><label for="'.$key.'">'.$libelle.'</label></td>';
180
181 // Value
182 print '<td>';
183 print '<input type="text" size="20" id="'.$key.'" name="'.$key.'" value="'.getDolGlobalString($key).'">';
184 print '</td></tr>';
185}
186
187// Option to include various payment in results
188print '<tr class="oddeven value">'."\n";
189print '<td><label for="ACCOUNTING_REPORTS_INCLUDE_VARPAY">'.$langs->trans('IncludeVarpaysInResults').'</label></td>'."\n";
190print '<td class="center">'."\n";
191print $form->selectyesno('ACCOUNTING_REPORTS_INCLUDE_VARPAY', (!empty($conf->global->ACCOUNTING_REPORTS_INCLUDE_VARPAY)));
192print '</td></tr>';
193
194// Option to include loan in results
195print '<tr class="oddeven value">'."\n";
196print '<td><label for="ACCOUNTING_REPORTS_INCLUDE_LOAN">'.$langs->trans('IncludeLoansInResults').'</label></td>'."\n";
197print '<td class="center">'."\n";
198print $form->selectyesno('ACCOUNTING_REPORTS_INCLUDE_LOAN', (!empty($conf->global->ACCOUNTING_REPORTS_INCLUDE_LOAN)));
199print '</td></tr>';
200
201print "</table>\n";
202
203print '<br><br><div style="text-align:center"><input type="submit" class="button button-edit" name="button" value="'.$langs->trans('Modify').'"></div>';
204print '</form>';
205
206// End of page
207llxFooter();
208$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()
Empty header.
Definition wrapper.php:56
llxFooter()
Empty footer.
Definition wrapper.php:70
Class to manage generation of HTML components Only common components must be here.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
getDolGlobalString($key, $default='')
Return 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.