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