dolibarr  16.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  *
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 require '../main.inc.php';
31 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
32 
33 // Load translation files required by the page
34 $langs->loadLangs(array('admin', 'compta', 'accountancy'));
35 
36 if (!$user->admin) {
38 }
39 
40 $action = GETPOST('action', 'aZ09');
41 
42 // Other parameters ACCOUNTING_*
43 $list = array(
44  'ACCOUNTING_PRODUCT_BUY_ACCOUNT',
45  'ACCOUNTING_PRODUCT_SOLD_ACCOUNT',
46  'ACCOUNTING_SERVICE_BUY_ACCOUNT',
47  'ACCOUNTING_SERVICE_SOLD_ACCOUNT',
48  'ACCOUNTING_VAT_SOLD_ACCOUNT',
49  'ACCOUNTING_VAT_BUY_ACCOUNT',
50  'ACCOUNTING_ACCOUNT_CUSTOMER',
51  'ACCOUNTING_ACCOUNT_SUPPLIER'
52 );
53 
54 /*
55  * Actions
56  */
57 
58 $accounting_mode = empty($conf->global->ACCOUNTING_MODE) ? 'RECETTES-DEPENSES' : $conf->global->ACCOUNTING_MODE;
59 
60 if ($action == 'update') {
61  $error = 0;
62 
63  $accounting_modes = array(
64  'RECETTES-DEPENSES',
65  'CREANCES-DETTES'
66  );
67 
68  $accounting_mode = GETPOST('accounting_mode', 'alpha');
69 
70 
71  if (in_array($accounting_mode, $accounting_modes)) {
72  if (!dolibarr_set_const($db, 'ACCOUNTING_MODE', $accounting_mode, 'chaine', 0, '', $conf->entity)) {
73  $error++;
74  }
75  } else {
76  $error++;
77  }
78 
79  foreach ($list as $constname) {
80  $constvalue = GETPOST($constname, 'alpha');
81 
82  if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
83  $error++;
84  }
85  }
86 
87  $report_include_varpay = GETPOST('ACCOUNTING_REPORTS_INCLUDE_VARPAY', 'alpha');
88  if (!empty($report_include_varpay)) {
89  if ($report_include_varpay == 'yes') {
90  if (!dolibarr_set_const($db, 'ACCOUNTING_REPORTS_INCLUDE_VARPAY', 1, 'chaine', 0, '', $conf->entity)) {
91  $error++;
92  }
93  }
94  }
95  if ($report_include_varpay == 'no') {
96  if (!dolibarr_del_const($db, 'ACCOUNTING_REPORTS_INCLUDE_VARPAY', $conf->entity)) {
97  $error++;
98  }
99  }
100 
101  $report_include_loan = GETPOST('ACCOUNTING_REPORTS_INCLUDE_LOAN', 'alpha');
102  if (!empty($report_include_loan)) {
103  if ($report_include_loan == 'yes') {
104  if (!dolibarr_set_const($db, 'ACCOUNTING_REPORTS_INCLUDE_LOAN', 1, 'chaine', 0, '', $conf->entity)) {
105  $error++;
106  }
107  }
108  }
109  if ($report_include_loan == 'no') {
110  if (!dolibarr_del_const($db, 'ACCOUNTING_REPORTS_INCLUDE_LOAN', $conf->entity)) {
111  $error++;
112  }
113  }
114 
115  if (!$error) {
116  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
117  } else {
118  setEventMessages($langs->trans("Error"), null, 'errors');
119  }
120 }
121 
122 /*
123  * View
124  */
125 
126 llxHeader();
127 
128 $form = new Form($db);
129 
130 $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
131 print load_fiche_titre($langs->trans('ComptaSetup'), $linkback, 'title_setup');
132 
133 print '<br>';
134 
135 print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
136 print '<input type="hidden" name="token" value="'.newToken().'">';
137 print '<input type="hidden" name="action" value="update">';
138 
139 print '<table class="noborder centpercent">';
140 
141 // case of the parameter ACCOUNTING_MODE
142 
143 print '<tr class="liste_titre">';
144 print '<td>'.$langs->trans('OptionMode').'</td><td>'.$langs->trans('Description').'</td>';
145 print "</tr>\n";
146 print '<tr class="oddeven"><td width="200"><input type="radio" name="accounting_mode" value="RECETTES-DEPENSES"'.($accounting_mode != 'CREANCES-DETTES' ? ' checked' : '').'> '.$langs->trans('OptionModeTrue').'</td>';
147 print '<td colspan="2">'.nl2br($langs->trans('OptionModeTrueDesc'));
148 // Write info on way to count VAT
149 //if (! empty($conf->global->MAIN_MODULE_COMPTABILITE))
150 //{
151 // // print "<br>\n";
152 // // print nl2br($langs->trans('OptionModeTrueInfoModuleComptabilite'));
153 //}
154 //else
155 //{
156 // // print "<br>\n";
157 // // print nl2br($langs->trans('OptionModeTrueInfoExpert'));
158 //}
159 print "</td></tr>\n";
160 print '<tr class="oddeven"><td width="200"><input type="radio" name="accounting_mode" value="CREANCES-DETTES"'.($accounting_mode == 'CREANCES-DETTES' ? ' checked' : '').'> '.$langs->trans('OptionModeVirtual').'</td>';
161 print '<td colspan="2">'.nl2br($langs->trans('OptionModeVirtualDesc'))."</td></tr>\n";
162 
163 print "</table>\n";
164 
165 print "<br>\n";
166 
167 print '<table class="noborder centpercent">';
168 print '<tr class="liste_titre">';
169 print '<td colspan="3">'.$langs->trans('OtherOptions').'</td>';
170 print "</tr>\n";
171 
172 
173 foreach ($list as $key) {
174  print '<tr class="oddeven value">';
175 
176  // Param
177  $libelle = $langs->trans($key);
178  print '<td><label for="'.$key.'">'.$libelle.'</label></td>';
179 
180  // Value
181  print '<td>';
182  print '<input type="text" size="20" id="'.$key.'" name="'.$key.'" value="'.getDolGlobalString($key).'">';
183  print '</td></tr>';
184 }
185 
186 // Option to include various payment in results
187 print '<tr class="oddeven value">'."\n";
188 print '<td><label for="ACCOUNTING_REPORTS_INCLUDE_VARPAY">'.$langs->trans('IncludeVarpaysInResults').'</label></td>'."\n";
189 print '<td class="center">'."\n";
190 print $form->selectyesno('ACCOUNTING_REPORTS_INCLUDE_VARPAY', (!empty($conf->global->ACCOUNTING_REPORTS_INCLUDE_VARPAY)));
191 print '</td></tr>';
192 
193 // Option to include loan in results
194 print '<tr class="oddeven value">'."\n";
195 print '<td><label for="ACCOUNTING_REPORTS_INCLUDE_LOAN">'.$langs->trans('IncludeLoansInResults').'</label></td>'."\n";
196 print '<td class="center">'."\n";
197 print $form->selectyesno('ACCOUNTING_REPORTS_INCLUDE_LOAN', (!empty($conf->global->ACCOUNTING_REPORTS_INCLUDE_LOAN)));
198 print '</td></tr>';
199 
200 print "</table>\n";
201 
202 print '<br><br><div style="text-align:center"><input type="submit" class="button button-edit" name="button" value="'.$langs->trans('Modify').'"></div>';
203 print '</form>';
204 
205 // End of page
206 llxFooter();
207 $db->close();
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:73
dolibarr_del_const
dolibarr_del_const($db, $name, $entity=1)
Delete a constant.
Definition: admin.lib.php:552
load_fiche_titre
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
Definition: functions.lib.php:5204
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:484
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:142
getDolGlobalString
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
Definition: functions.lib.php:80
dolibarr_set_const
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).
Definition: admin.lib.php:627
Form
Class to manage generation of HTML components Only common components must be here.
Definition: html.form.class.php:52
setEventMessages
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
Definition: functions.lib.php:8137
accessforbidden
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
Definition: security.lib.php:933
llxHeader
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:59