dolibarr 19.0.3
closure.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2019-2024 Alexandre Spangaro <aspangaro@easya.solutions>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 *
17 */
18
25// Load Dolibarr environment
26require '../../main.inc.php';
27require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
28require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
29require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
30
31// Load translation files required by the page
32$langs->loadLangs(array("compta", "admin", "accountancy"));
33
34// Security check
35if (!$user->hasRight('accounting', 'chartofaccount')) {
37}
38
39$action = GETPOST('action', 'aZ09');
40
41
42$list_account_main = array(
43 'ACCOUNTING_RESULT_PROFIT',
44 'ACCOUNTING_RESULT_LOSS'
45);
46
47/*
48 * Actions
49 */
50
51if ($action == 'update') {
52 $error = 0;
53
54 $defaultjournal = GETPOST('ACCOUNTING_CLOSURE_DEFAULT_JOURNAL', 'alpha');
55
56 if (!empty($defaultjournal)) {
57 if (!dolibarr_set_const($db, 'ACCOUNTING_CLOSURE_DEFAULT_JOURNAL', $defaultjournal, 'chaine', 0, '', $conf->entity)) {
58 $error++;
59 }
60 } else {
61 $error++;
62 }
63
64 $accountinggroupsusedforbalancesheetaccount = GETPOST('ACCOUNTING_CLOSURE_ACCOUNTING_GROUPS_USED_FOR_BALANCE_SHEET_ACCOUNT', 'alphanohtml');
65 if (!empty($accountinggroupsusedforbalancesheetaccount)) {
66 if (!dolibarr_set_const($db, 'ACCOUNTING_CLOSURE_ACCOUNTING_GROUPS_USED_FOR_BALANCE_SHEET_ACCOUNT', $accountinggroupsusedforbalancesheetaccount, 'chaine', 0, '', $conf->entity)) {
67 $error++;
68 }
69 } else {
70 $error++;
71 }
72
73 $accountinggroupsusedforincomestatement = GETPOST('ACCOUNTING_CLOSURE_ACCOUNTING_GROUPS_USED_FOR_INCOME_STATEMENT', 'alpha');
74 if (!empty($accountinggroupsusedforincomestatement)) {
75 if (!dolibarr_set_const($db, 'ACCOUNTING_CLOSURE_ACCOUNTING_GROUPS_USED_FOR_INCOME_STATEMENT', $accountinggroupsusedforincomestatement, 'chaine', 0, '', $conf->entity)) {
76 $error++;
77 }
78 } else {
79 $error++;
80 }
81
82 foreach ($list_account_main as $constname) {
83 $constvalue = GETPOST($constname, 'alpha');
84 if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
85 $error++;
86 }
87 }
88
89 if (!$error) {
90 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
91 } else {
92 setEventMessages($langs->trans("Error"), null, 'errors');
93 }
94}
95
96
97/*
98 * View
99 */
100
101$form = new Form($db);
102$formaccounting = new FormAccounting($db);
103
104$title = $langs->trans('Closure');
105
106$help_url = 'EN:Module_Double_Entry_Accounting#Setup|FR:Module_Comptabilit&eacute;_en_Partie_Double#Configuration';
107
108llxHeader('', $title, $help_url);
109
110$linkback = '';
111print load_fiche_titre($langs->trans('MenuClosureAccounts'), $linkback, 'title_accountancy');
112
113print '<span class="opacitymedium">'.$langs->trans("DefaultClosureDesc").'</span><br>';
114print '<br>';
115
116print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
117print '<input type="hidden" name="token" value="'.newToken().'">';
118print '<input type="hidden" name="action" value="update">';
119
120// Define main accounts for closure
121print '<table class="noborder centpercent">';
122
123foreach ($list_account_main as $key) {
124 print '<tr class="oddeven value">';
125 // Param
126 $label = $langs->trans($key);
127 $keydesc = $key.'_Desc';
128
129 $htmltext = $langs->trans($keydesc);
130 print '<td class="fieldrequired" width="50%">';
131 print $form->textwithpicto($label, $htmltext);
132 print '</td>';
133 // Value
134 print '<td>'; // Do not force class=right, or it align also the content of the select box
135 print $formaccounting->select_account(getDolGlobalString($key), $key, 1, '', 1, 1);
136 print '</td>';
137 print '</tr>';
138}
139
140// Journal
141print '<tr class="oddeven">';
142print '<td class="fieldrequired">'.$langs->trans("ACCOUNTING_CLOSURE_DEFAULT_JOURNAL").'</td>';
143print '<td>';
144$defaultjournal = getDolGlobalString('ACCOUNTING_CLOSURE_DEFAULT_JOURNAL');
145print $formaccounting->select_journal($defaultjournal, "ACCOUNTING_CLOSURE_DEFAULT_JOURNAL", 9, 1, 0, 0);
146print '</td></tr>';
147
148// Accounting groups used for the balance sheet account
149print '<tr class="oddeven">';
150print '<td class="fieldrequired">'.$langs->trans("ACCOUNTING_CLOSURE_ACCOUNTING_GROUPS_USED_FOR_BALANCE_SHEET_ACCOUNT").'</td>';
151print '<td>';
152print '<input type="text" size="100" id="ACCOUNTING_CLOSURE_ACCOUNTING_GROUPS_USED_FOR_BALANCE_SHEET_ACCOUNT" name="ACCOUNTING_CLOSURE_ACCOUNTING_GROUPS_USED_FOR_BALANCE_SHEET_ACCOUNT" value="' . dol_escape_htmltag(getDolGlobalString('ACCOUNTING_CLOSURE_ACCOUNTING_GROUPS_USED_FOR_BALANCE_SHEET_ACCOUNT')). '">';
153print '</td></tr>';
154
155// Accounting groups used for the income statement
156print '<tr class="oddeven">';
157print '<td class="fieldrequired">'.$langs->trans("ACCOUNTING_CLOSURE_ACCOUNTING_GROUPS_USED_FOR_INCOME_STATEMENT").'</td>';
158print '<td>';
159print '<input type="text" size="100" id="ACCOUNTING_CLOSURE_ACCOUNTING_GROUPS_USED_FOR_INCOME_STATEMENT" name="ACCOUNTING_CLOSURE_ACCOUNTING_GROUPS_USED_FOR_INCOME_STATEMENT" value="' . dol_escape_htmltag(getDolGlobalString('ACCOUNTING_CLOSURE_ACCOUNTING_GROUPS_USED_FOR_INCOME_STATEMENT')). '">';
160print '</td></tr>';
161
162print "</table>\n";
163
164print '<div class="center"><input type="submit" class="button button-edit" name="button" value="'.$langs->trans('Modify').'"></div>';
165
166print '</form>';
167
168// End of page
169llxFooter();
170$db->close();
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).
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Definition wrapper.php:55
llxFooter()
Empty footer.
Definition wrapper.php:69
Class to manage generation of HTML components for accounting management.
Class to manage generation of HTML components Only common components must be here.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.