dolibarr  7.0.0-beta
index.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
3  * Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
4  * Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro@zendsi.com>
5  * Copyright (C) 2014-2015 Ari Elbaz (elarifr) <github@accedinfo.com>
6  * Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
7  * Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
8  * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
9  * Copyright (C) 2017 Laurent Destailleur <eldy@destailleur.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 <http://www.gnu.org/licenses/>.
23  */
24 
30 require '../../main.inc.php';
31 
32 // Class
33 require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php';
34 require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
35 
36 $langs->load("compta");
37 $langs->load("bills");
38 $langs->load("admin");
39 $langs->load("accountancy");
40 
41 // Security access
42 if (empty($user->rights->accounting->chartofaccount))
43 {
45 }
46 
47 $action = GETPOST('action', 'alpha');
48 
49 // Parameters ACCOUNTING_* and others
50 $list = array (
51  'ACCOUNTING_LENGTH_GACCOUNT',
52  'ACCOUNTING_LENGTH_AACCOUNT' ,
53 // 'ACCOUNTING_LENGTH_DESCRIPTION', // adjust size displayed for lines description for dol_trunc
54 // 'ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT', // adjust size displayed for select account description for dol_trunc
55 );
56 
57 
58 
59 /*
60  * Actions
61  */
62 
63 $accounting_mode = empty($conf->global->ACCOUNTING_MODE) ? 'RECETTES-DEPENSES' : $conf->global->ACCOUNTING_MODE;
64 
65 if ($action == 'update') {
66  $error = 0;
67 
68  $accounting_modes = array (
69  'RECETTES-DEPENSES',
70  'CREANCES-DETTES'
71  );
72 
73  $accounting_mode = GETPOST('accounting_mode', 'alpha');
74 
75  if (in_array($accounting_mode, $accounting_modes)) {
76 
77  if (! dolibarr_set_const($db, 'ACCOUNTING_MODE', $accounting_mode, 'chaine', 0, '', $conf->entity)) {
78  $error ++;
79  }
80  } else {
81  $error ++;
82  }
83 
84  if ($error) {
85  setEventMessages($langs->trans("Error"), null, 'errors');
86  }
87 
88  foreach ($list as $constname)
89  {
90  $constvalue = GETPOST($constname, 'alpha');
91 
92  if (! dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
93  $error ++;
94  }
95  }
96 
97  if (! $error) {
98  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
99  } else {
100  setEventMessages($langs->trans("Error"), null, 'errors');
101  }
102 }
103 
104 // TO DO Mutualize code for yes/no constants
105 if ($action == 'setlistsorttodo') {
106  $setlistsorttodo = GETPOST('value', 'int');
107  $res = dolibarr_set_const($db, "ACCOUNTING_LIST_SORT_VENTILATION_TODO", $setlistsorttodo, 'yesno', 0, '', $conf->entity);
108  if (! $res > 0)
109  $error ++;
110 
111  if (! $error) {
112  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
113  } else {
114  setEventMessages($langs->trans("Error"), null, 'mesgs');
115  }
116 }
117 
118 if ($action == 'setlistsortdone') {
119  $setlistsortdone = GETPOST('value', 'int');
120  $res = dolibarr_set_const($db, "ACCOUNTING_LIST_SORT_VENTILATION_DONE", $setlistsortdone, 'yesno', 0, '', $conf->entity);
121  if (! $res > 0)
122  $error ++;
123  if (! $error) {
124  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
125  } else {
126  setEventMessages($langs->trans("Error"), null, 'mesgs');
127  }
128 }
129 
130 if ($action == 'setmanagezero') {
131  $setmanagezero = GETPOST('value', 'int');
132  $res = dolibarr_set_const($db, "ACCOUNTING_MANAGE_ZERO", $setmanagezero, 'yesno', 0, '', $conf->entity);
133  if (! $res > 0)
134  $error ++;
135  if (! $error) {
136  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
137  } else {
138  setEventMessages($langs->trans("Error"), null, 'mesgs');
139  }
140 }
141 
142 if ($action == 'setdisabledirectinput') {
143  $setdisabledirectinput = GETPOST('value', 'int');
144  $res = dolibarr_set_const($db, "BANK_DISABLE_DIRECT_INPUT", $setdisabledirectinput, 'yesno', 0, '', $conf->entity);
145  if (! $res > 0)
146  $error ++;
147  if (! $error) {
148  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
149  } else {
150  setEventMessages($langs->trans("Error"), null, 'mesgs');
151  }
152 }
153 
154 /*
155  * View
156  */
157 
158 llxHeader();
159 
160 $form = new Form($db);
161 
162 //$linkback = '<a href="' . DOL_URL_ROOT . '/admin/modules.php">' . $langs->trans("BackToModuleList") . '</a>';
163 print load_fiche_titre($langs->trans('ConfigAccountingExpert'), $linkback, 'title_setup');
164 
165 print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">';
166 print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
167 print '<input type="hidden" name="action" value="update">';
168 
169 // Default mode for calculating turnover (parameter ACCOUNTING_MODE)
170 /*
171 print '<table class="noborder" width="100%">';
172 
173 print '<tr class="liste_titre">';
174 print '<td>' . $langs->trans('OptionMode') . '</td><td>' . $langs->trans('Description') . '</td>';
175 print "</tr>\n";
176 print '<tr ' . $bc[false] . '><td width="200"><input type="radio" name="accounting_mode" value="RECETTES-DEPENSES"' . ($accounting_mode != 'CREANCES-DETTES' ? ' checked' : '') . '> ' . $langs->trans('OptionModeTrue') . '</td>';
177 print '<td colspan="2">' . nl2br($langs->trans('OptionModeTrueDesc'));
178 // Write info on way to count VAT
179 // if (! empty($conf->global->MAIN_MODULE_COMPTABILITE))
180 // {
181 // // print "<br>\n";
182 // // print nl2br($langs->trans('OptionModeTrueInfoModuleComptabilite'));
183 // }
184 // else
185 // {
186 // // print "<br>\n";
187 // // print nl2br($langs->trans('OptionModeTrueInfoExpert'));
188 // }
189 print "</td></tr>\n";
190 print '<tr ' . $bc[true] . '><td width="200"><input type="radio" name="accounting_mode" value="CREANCES-DETTES"' . ($accounting_mode == 'CREANCES-DETTES' ? ' checked' : '') . '> ' . $langs->trans('OptionModeVirtual') . '</td>';
191 print '<td colspan="2">' . nl2br($langs->trans('OptionModeVirtualDesc')) . "</td></tr>\n";
192 
193 print "</table>\n";
194 
195 
196 print '<br>';
197 */
198 
199 // Others params
200 
201 print '<table class="noborder" width="100%">';
202 print '<tr class="liste_titre">';
203 print '<td colspan="2">' . $langs->trans('OtherOptions') . '</td>';
204 print "</tr>\n";
205 
206 if (! empty($user->admin))
207 {
208  // TO DO Mutualize code for yes/no constants
209  print '<tr class="oddeven">';
210  print '<td>' . $langs->trans("ACCOUNTING_LIST_SORT_VENTILATION_TODO") . '</td>';
211  if (! empty($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_TODO)) {
212  print '<td align="right"><a href="' . $_SERVER['PHP_SELF'] . '?action=setlistsorttodo&value=0">';
213  print img_picto($langs->trans("Activated"), 'switch_on');
214  print '</a></td>';
215  } else {
216  print '<td align="right"><a href="' . $_SERVER['PHP_SELF'] . '?action=setlistsorttodo&value=1">';
217  print img_picto($langs->trans("Disabled"), 'switch_off');
218  print '</a></td>';
219  }
220  print '</tr>';
221 
222  print '<tr class="oddeven">';
223  print '<td>' . $langs->trans("ACCOUNTING_LIST_SORT_VENTILATION_DONE") . '</td>';
224  if (! empty($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_DONE)) {
225  print '<td align="right"><a href="' . $_SERVER['PHP_SELF'] . '?action=setlistsortdone&value=0">';
226  print img_picto($langs->trans("Activated"), 'switch_on');
227  print '</a></td>';
228  } else {
229  print '<td align="right"><a href="' . $_SERVER['PHP_SELF'] . '?action=setlistsortdone&value=1">';
230  print img_picto($langs->trans("Disabled"), 'switch_off');
231  print '</a></td>';
232  }
233  print '</tr>';
234 
235  print '<tr class="oddeven">';
236  print '<td>' . $langs->trans("BANK_DISABLE_DIRECT_INPUT") . '</td>';
237  if (! empty($conf->global->BANK_DISABLE_DIRECT_INPUT)) {
238  print '<td align="right"><a href="' . $_SERVER['PHP_SELF'] . '?action=setdisabledirectinput&value=0">';
239  print img_picto($langs->trans("Activated"), 'switch_on');
240  print '</a></td>';
241  } else {
242  print '<td align="right"><a href="' . $_SERVER['PHP_SELF'] . '?action=setdisabledirectinput&value=1">';
243  print img_picto($langs->trans("Disabled"), 'switch_off');
244  print '</a></td>';
245  }
246  print '</tr>';
247 
248  print '<tr class="oddeven">';
249  print '<td>' . $langs->trans("ACCOUNTING_MANAGE_ZERO") . '</td>';
250  if (! empty($conf->global->ACCOUNTING_MANAGE_ZERO)) {
251  print '<td align="right"><a href="' . $_SERVER['PHP_SELF'] . '?action=setmanagezero&value=0">';
252  print img_picto($langs->trans("Activated"), 'switch_on');
253  print '</a></td>';
254  } else {
255  print '<td align="right"><a href="' . $_SERVER['PHP_SELF'] . '?action=setmanagezero&value=1">';
256  print img_picto($langs->trans("Disabled"), 'switch_off');
257  print '</a></td>';
258  }
259  print '</tr>';
260 }
261 
262 
263 // Param a user $user->rights->accounting->chartofaccount can access
264 foreach ($list as $key)
265 {
266  print '<tr class="oddeven value">';
267 
268  if (! empty($conf->global->ACCOUNTING_MANAGE_ZERO) && ($key == 'ACCOUNTING_LENGTH_GACCOUNT' || $key == 'ACCOUNTING_LENGTH_AACCOUNT')) continue;
269 
270  // Param
271  $label = $langs->trans($key);
272  print '<td>'.$label.'</td>';
273  // Value
274  print '<td align="right">';
275  print '<input type="text" class="maxwidth100" id="' . $key . '" name="' . $key . '" value="' . $conf->global->$key . '">';
276  print '</td>';
277 
278  print '</tr>';
279 }
280 
281 
282 print '</table>';
283 
284 print '<div class="center"><input type="submit" class="button" value="' . $langs->trans('Modify') . '" name="button"></div>';
285 
286 print '<br>';
287 print '<br>';
288 
289 print '<br>';
290 print '</form>';
291 
292 llxFooter();
293 $db->close();
llxFooter()
Footer empty.
Definition: index.php:43
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='')
Show picto whatever it's its name (generic function)
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:485
if(empty($reshook)) $form
View.
Definition: perms.php:103
GETPOST($paramname, $check='none', $method=0, $filter=NULL, $options=NULL, $noreplace=0)
Return value of a param into GET or POST supervariable.
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()
Header empty.
Definition: index.php:37
load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png', $pictoisfullpath=0, $id=0, $morecssontable='', $morehtmlcenter='')
Load a title with picto.
print
Draft customers invoices.
Definition: index.php:91