dolibarr  9.0.0
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-2018 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 
31 require '../../main.inc.php';
32 require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php';
33 require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
34 
35 // Load translation files required by the page
36 $langs->loadLangs(array("compta","bills","admin","accountancy"));
37 
38 // Security access
39 if (empty($user->rights->accounting->chartofaccount))
40 {
42 }
43 
44 $action = GETPOST('action', 'aZ09');
45 
46 // Parameters ACCOUNTING_* and others
47 $list = array (
48  'ACCOUNTING_LENGTH_GACCOUNT',
49  'ACCOUNTING_LENGTH_AACCOUNT' ,
50 // 'ACCOUNTING_LENGTH_DESCRIPTION', // adjust size displayed for lines description for dol_trunc
51 // 'ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT', // adjust size displayed for select account description for dol_trunc
52 );
53 
54 
55 
56 /*
57  * Actions
58  */
59 
60 $accounting_mode = empty($conf->global->ACCOUNTING_MODE) ? 'RECETTES-DEPENSES' : $conf->global->ACCOUNTING_MODE;
61 
62 if ($action == 'update') {
63  $error = 0;
64 
65  if (! $error)
66  {
67  foreach ($list as $constname)
68  {
69  $constvalue = GETPOST($constname, 'alpha');
70 
71  if (! dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
72  $error++;
73  }
74  }
75  if ($error) {
76  setEventMessages($langs->trans("Error"), null, 'errors');
77  }
78  }
79 
80  if (! $error) {
81  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
82  }
83 }
84 
85 // TO DO Mutualize code for yes/no constants
86 if ($action == 'setlistsorttodo') {
87  $setlistsorttodo = GETPOST('value', 'int');
88  $res = dolibarr_set_const($db, "ACCOUNTING_LIST_SORT_VENTILATION_TODO", $setlistsorttodo, 'yesno', 0, '', $conf->entity);
89  if (! $res > 0)
90  $error ++;
91 
92  if (! $error) {
93  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
94  } else {
95  setEventMessages($langs->trans("Error"), null, 'mesgs');
96  }
97 }
98 
99 if ($action == 'setlistsortdone') {
100  $setlistsortdone = GETPOST('value', 'int');
101  $res = dolibarr_set_const($db, "ACCOUNTING_LIST_SORT_VENTILATION_DONE", $setlistsortdone, 'yesno', 0, '', $conf->entity);
102  if (! $res > 0)
103  $error ++;
104  if (! $error) {
105  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
106  } else {
107  setEventMessages($langs->trans("Error"), null, 'mesgs');
108  }
109 }
110 
111 if ($action == 'setmanagezero') {
112  $setmanagezero = GETPOST('value', 'int');
113  $res = dolibarr_set_const($db, "ACCOUNTING_MANAGE_ZERO", $setmanagezero, 'yesno', 0, '', $conf->entity);
114  if (! $res > 0)
115  $error ++;
116  if (! $error) {
117  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
118  } else {
119  setEventMessages($langs->trans("Error"), null, 'mesgs');
120  }
121 }
122 
123 if ($action == 'setdisabledirectinput') {
124  $setdisabledirectinput = GETPOST('value', 'int');
125  $res = dolibarr_set_const($db, "BANK_DISABLE_DIRECT_INPUT", $setdisabledirectinput, 'yesno', 0, '', $conf->entity);
126  if (! $res > 0)
127  $error ++;
128  if (! $error) {
129  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
130  } else {
131  setEventMessages($langs->trans("Error"), null, 'mesgs');
132  }
133 }
134 
135 if ($action == 'setenabledraftexport') {
136  $setenabledraftexport = GETPOST('value', 'int');
137  $res = dolibarr_set_const($db, "ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL", $setenabledraftexport, 'yesno', 0, '', $conf->entity);
138  if (! $res > 0)
139  $error ++;
140  if (! $error) {
141  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
142  } else {
143  setEventMessages($langs->trans("Error"), null, 'mesgs');
144  }
145 }
146 
147 /*
148  * View
149  */
150 
151 llxHeader();
152 
153 $form = new Form($db);
154 
155 //$linkback = '<a href="' . DOL_URL_ROOT . '/admin/modules.php?restore_lastsearch_values=1">' . $langs->trans("BackToModuleList") . '</a>';
156 print load_fiche_titre($langs->trans('ConfigAccountingExpert'), $linkback, 'title_setup');
157 
158 print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">';
159 print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
160 print '<input type="hidden" name="action" value="update">';
161 
162 // Default mode for calculating turnover (parameter ACCOUNTING_MODE)
163 /*
164 print '<table class="noborder" width="100%">';
165 
166 print '<tr class="liste_titre">';
167 print '<td>' . $langs->trans('OptionMode') . '</td><td>' . $langs->trans('Description') . '</td>';
168 print "</tr>\n";
169 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>';
170 print '<td colspan="2">' . nl2br($langs->trans('OptionModeTrueDesc'));
171 // Write info on way to count VAT
172 // if (! empty($conf->global->MAIN_MODULE_COMPTABILITE))
173 // {
174 // // print "<br>\n";
175 // // print nl2br($langs->trans('OptionModeTrueInfoModuleComptabilite'));
176 // }
177 // else
178 // {
179 // // print "<br>\n";
180 // // print nl2br($langs->trans('OptionModeTrueInfoExpert'));
181 // }
182 print "</td></tr>\n";
183 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>';
184 print '<td colspan="2">' . nl2br($langs->trans('OptionModeVirtualDesc')) . "</td></tr>\n";
185 
186 print "</table>\n";
187 
188 
189 print '<br>';
190 */
191 
192 // Others params
193 
194 print '<table class="noborder" width="100%">';
195 print '<tr class="liste_titre">';
196 print '<td colspan="2">' . $langs->trans('OtherOptions') . '</td>';
197 print "</tr>\n";
198 
199 if (! empty($user->admin))
200 {
201  // TO DO Mutualize code for yes/no constants
202  print '<tr class="oddeven">';
203  print '<td>' . $langs->trans("ACCOUNTING_LIST_SORT_VENTILATION_TODO") . '</td>';
204  if (! empty($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_TODO)) {
205  print '<td align="right"><a href="' . $_SERVER['PHP_SELF'] . '?action=setlistsorttodo&value=0">';
206  print img_picto($langs->trans("Activated"), 'switch_on');
207  print '</a></td>';
208  } else {
209  print '<td align="right"><a href="' . $_SERVER['PHP_SELF'] . '?action=setlistsorttodo&value=1">';
210  print img_picto($langs->trans("Disabled"), 'switch_off');
211  print '</a></td>';
212  }
213  print '</tr>';
214 
215  print '<tr class="oddeven">';
216  print '<td>' . $langs->trans("ACCOUNTING_LIST_SORT_VENTILATION_DONE") . '</td>';
217  if (! empty($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_DONE)) {
218  print '<td align="right"><a href="' . $_SERVER['PHP_SELF'] . '?action=setlistsortdone&value=0">';
219  print img_picto($langs->trans("Activated"), 'switch_on');
220  print '</a></td>';
221  } else {
222  print '<td align="right"><a href="' . $_SERVER['PHP_SELF'] . '?action=setlistsortdone&value=1">';
223  print img_picto($langs->trans("Disabled"), 'switch_off');
224  print '</a></td>';
225  }
226  print '</tr>';
227 
228  print '<tr class="oddeven">';
229  print '<td>' . $langs->trans("ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL") . '</td>';
230  if (! empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL)) {
231  print '<td align="right"><a href="' . $_SERVER['PHP_SELF'] . '?action=setenabledraftexport&value=0">';
232  print img_picto($langs->trans("Activated"), 'switch_on');
233  print '</a></td>';
234  } else {
235  print '<td align="right"><a href="' . $_SERVER['PHP_SELF'] . '?action=setenabledraftexport&value=1">';
236  print img_picto($langs->trans("Disabled"), 'switch_off');
237  print '</a></td>';
238  }
239  print '</tr>';
240 
241  print '<tr class="oddeven">';
242  print '<td>' . $langs->trans("BANK_DISABLE_DIRECT_INPUT") . '</td>';
243  if (! empty($conf->global->BANK_DISABLE_DIRECT_INPUT)) {
244  print '<td align="right"><a href="' . $_SERVER['PHP_SELF'] . '?action=setdisabledirectinput&value=0">';
245  print img_picto($langs->trans("Activated"), 'switch_on');
246  print '</a></td>';
247  } else {
248  print '<td align="right"><a href="' . $_SERVER['PHP_SELF'] . '?action=setdisabledirectinput&value=1">';
249  print img_picto($langs->trans("Disabled"), 'switch_off');
250  print '</a></td>';
251  }
252  print '</tr>';
253 
254  print '<tr class="oddeven">';
255  print '<td>' . $langs->trans("ACCOUNTING_MANAGE_ZERO") . '</td>';
256  if (! empty($conf->global->ACCOUNTING_MANAGE_ZERO)) {
257  print '<td align="right"><a href="' . $_SERVER['PHP_SELF'] . '?action=setmanagezero&value=0">';
258  print img_picto($langs->trans("Activated"), 'switch_on');
259  print '</a></td>';
260  } else {
261  print '<td align="right"><a href="' . $_SERVER['PHP_SELF'] . '?action=setmanagezero&value=1">';
262  print img_picto($langs->trans("Disabled"), 'switch_off');
263  print '</a></td>';
264  }
265  print '</tr>';
266 }
267 
268 
269 // Param a user $user->rights->accounting->chartofaccount can access
270 foreach ($list as $key)
271 {
272  print '<tr class="oddeven value">';
273 
274  if (! empty($conf->global->ACCOUNTING_MANAGE_ZERO) && ($key == 'ACCOUNTING_LENGTH_GACCOUNT' || $key == 'ACCOUNTING_LENGTH_AACCOUNT')) continue;
275 
276  // Param
277  $label = $langs->trans($key);
278  print '<td>'.$label.'</td>';
279  // Value
280  print '<td align="right">';
281  print '<input type="text" class="maxwidth100" id="' . $key . '" name="' . $key . '" value="' . $conf->global->$key . '">';
282  print '</td>';
283 
284  print '</tr>';
285 }
286 
287 
288 print '</table>';
289 
290 print '<div class="center"><input type="submit" class="button" value="' . $langs->trans('Modify') . '" name="button"></div>';
291 
292 print '<br>';
293 print '<br>';
294 
295 print '<br>';
296 print '</form>';
297 
298 // End of page
299 llxFooter();
300 $db->close();
llxFooter()
Footer empty.
Definition: index.php:44
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()
Header empty.
Definition: index.php:36
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='')
Show picto whatever it&#39;s its name (generic function)