dolibarr  9.0.0
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  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program. If not, see <http://www.gnu.org/licenses/>.
21  */
22 
29 require '../main.inc.php';
30 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
31 
32 // Load translation files required by the page
33 $langs->loadLangs(array('admin', 'compta', 'accountancy'));
34 
35 if (!$user->admin)
37 
38 $action = GETPOST('action','alpha');
39 
40 // Other parameters ACCOUNTING_*
41 $list = array(
42  'ACCOUNTING_PRODUCT_BUY_ACCOUNT',
43  'ACCOUNTING_PRODUCT_SOLD_ACCOUNT',
44  'ACCOUNTING_SERVICE_BUY_ACCOUNT',
45  'ACCOUNTING_SERVICE_SOLD_ACCOUNT',
46  'ACCOUNTING_VAT_SOLD_ACCOUNT',
47  'ACCOUNTING_VAT_BUY_ACCOUNT',
48  'ACCOUNTING_ACCOUNT_CUSTOMER',
49  'ACCOUNTING_ACCOUNT_SUPPLIER'
50 );
51 
52 /*
53  * Actions
54  */
55 
56 $accounting_mode = empty($conf->global->ACCOUNTING_MODE) ? 'RECETTES-DEPENSES' : $conf->global->ACCOUNTING_MODE;
57 
58 if ($action == 'update')
59 {
60  $error = 0;
61 
62  $accounting_modes = array(
63  'RECETTES-DEPENSES',
64  'CREANCES-DETTES'
65  );
66 
67  $accounting_mode = GETPOST('accounting_mode','alpha');
68 
69 
70  if (in_array($accounting_mode,$accounting_modes)) {
71 
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  if (! $error)
88  {
89  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
90  }
91  else
92  {
93  setEventMessages($langs->trans("Error"), null, 'errors');
94  }
95 }
96 
97 /*
98  * View
99  */
100 
101 llxHeader();
102 
103 $form=new Form($db);
104 
105 $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
106 print load_fiche_titre($langs->trans('ComptaSetup'),$linkback,'title_setup');
107 
108 print '<br>';
109 
110 print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
111 print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
112 print '<input type="hidden" name="action" value="update">';
113 
114 print '<table class="noborder" width="100%">';
115 
116 // case of the parameter ACCOUNTING_MODE
117 
118 print '<tr class="liste_titre">';
119 print '<td>'.$langs->trans('OptionMode').'</td><td>'.$langs->trans('Description').'</td>';
120 print "</tr>\n";
121 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>';
122 print '<td colspan="2">'.nl2br($langs->trans('OptionModeTrueDesc'));
123 // Write info on way to count VAT
124 //if (! empty($conf->global->MAIN_MODULE_COMPTABILITE))
125 //{
126 // // print "<br>\n";
127 // // print nl2br($langs->trans('OptionModeTrueInfoModuleComptabilite'));
128 //}
129 //else
130 //{
131 // // print "<br>\n";
132 // // print nl2br($langs->trans('OptionModeTrueInfoExpert'));
133 //}
134 print "</td></tr>\n";
135 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>';
136 print '<td colspan="2">'.nl2br($langs->trans('OptionModeVirtualDesc'))."</td></tr>\n";
137 
138 print "</table>\n";
139 
140 print "<br>\n";
141 
142 print '<table class="noborder" width="100%">';
143 print '<tr class="liste_titre">';
144 print '<td colspan="3">'.$langs->trans('OtherOptions').'</td>';
145 print "</tr>\n";
146 
147 
148 foreach ($list as $key)
149 {
150  print '<tr class="oddeven value">';
151 
152  // Param
153  $libelle = $langs->trans($key);
154  print '<td><label for="'.$key.'">'.$libelle.'</label></td>';
155 
156  // Value
157  print '<td>';
158  print '<input type="text" size="20" id="'.$key.'" name="'.$key.'" value="'.$conf->global->$key.'">';
159  print '</td></tr>';
160 }
161 
162 print "</table>\n";
163 
164 print '<br><br><div style="text-align:center"><input type="submit" class="button" value="'.$langs->trans('Modify').'" name="button"></div>';
165 print '</form>';
166 
167 // End of page
168 llxFooter();
169 $db->close();
llxFooter()
Empty footer.
Definition: wrapper.php:56
load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
GETPOST($paramname, $check='none', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
print
Draft customers invoices.
Definition: index.php:91
setEventMessages($mesg, $mesgs, $style='mesgs')
Set event messages in dol_events session object.
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:510
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
Class to manage generation of HTML components Only common components must be here.
llxHeader()
Empty header.
Definition: wrapper.php:44