dolibarr  7.0.0-beta
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@capnetworks.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 $langs->load('admin');
33 $langs->load('compta');
34 $langs->load('accountancy');
35 
36 if (!$user->admin)
38 
39 $action = GETPOST('action','alpha');
40 
41 // Other parameters ACCOUNTING_*
42 $list = array(
43  'ACCOUNTING_PRODUCT_BUY_ACCOUNT',
44  'ACCOUNTING_PRODUCT_SOLD_ACCOUNT',
45  'ACCOUNTING_SERVICE_BUY_ACCOUNT',
46  'ACCOUNTING_SERVICE_SOLD_ACCOUNT',
47  'ACCOUNTING_VAT_SOLD_ACCOUNT',
48  'ACCOUNTING_VAT_BUY_ACCOUNT',
49  'ACCOUNTING_ACCOUNT_CUSTOMER',
50  'ACCOUNTING_ACCOUNT_SUPPLIER'
51 );
52 
53 /*
54  * Actions
55  */
56 
57 $accounting_mode = empty($conf->global->ACCOUNTING_MODE) ? 'RECETTES-DEPENSES' : $conf->global->ACCOUNTING_MODE;
58 
59 if ($action == 'update')
60 {
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 
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  if (! $error)
89  {
90  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
91  }
92  else
93  {
94  setEventMessages($langs->trans("Error"), null, 'errors');
95  }
96 }
97 
98 /*
99  * View
100  */
101 
102 llxHeader();
103 
104 $form=new Form($db);
105 
106 $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
107 print load_fiche_titre($langs->trans('ComptaSetup'),$linkback,'title_setup');
108 
109 print '<br>';
110 
111 print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
112 print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
113 print '<input type="hidden" name="action" value="update">';
114 
115 print '<table class="noborder" width="100%">';
116 
117 // case of the parameter ACCOUNTING_MODE
118 
119 print '<tr class="liste_titre">';
120 print '<td>'.$langs->trans('OptionMode').'</td><td>'.$langs->trans('Description').'</td>';
121 print "</tr>\n";
122 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>';
123 print '<td colspan="2">'.nl2br($langs->trans('OptionModeTrueDesc'));
124 // Write info on way to count VAT
125 //if (! empty($conf->global->MAIN_MODULE_COMPTABILITE))
126 //{
127 // // print "<br>\n";
128 // // print nl2br($langs->trans('OptionModeTrueInfoModuleComptabilite'));
129 //}
130 //else
131 //{
132 // // print "<br>\n";
133 // // print nl2br($langs->trans('OptionModeTrueInfoExpert'));
134 //}
135 print "</td></tr>\n";
136 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>';
137 print '<td colspan="2">'.nl2br($langs->trans('OptionModeVirtualDesc'))."</td></tr>\n";
138 
139 print "</table>\n";
140 
141 print "<br>\n";
142 
143 print '<table class="noborder" width="100%">';
144 print '<tr class="liste_titre">';
145 print '<td colspan="3">'.$langs->trans('OtherOptions').'</td>';
146 print "</tr>\n";
147 
148 
149 foreach ($list as $key)
150 {
151  print '<tr class="oddeven value">';
152 
153  // Param
154  $libelle = $langs->trans($key);
155  print '<td><label for="'.$key.'">'.$libelle.'</label></td>';
156 
157  // Value
158  print '<td>';
159  print '<input type="text" size="20" id="'.$key.'" name="'.$key.'" value="'.$conf->global->$key.'">';
160  print '</td></tr>';
161 }
162 
163 print "</table>\n";
164 
165 print '<br><br><div style="text-align:center"><input type="submit" class="button" value="'.$langs->trans('Modify').'" name="button"></div>';
166 print '</form>';
167 
168 llxFooter();
169 $db->close();
llxFooter()
Empty footer.
Definition: wrapper.php:58
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.
load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png', $pictoisfullpath=0, $id=0, $morecssontable='', $morehtmlcenter='')
Load a title with picto.
llxHeader()
Empty header.
Definition: wrapper.php:46
print
Draft customers invoices.
Definition: index.php:91