dolibarr 21.0.0-beta
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 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 *
19 */
20
27// Load Dolibarr environment
28require '../../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
30require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
31require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
32
41// Load translation files required by the page
42$langs->loadLangs(array("compta", "admin", "accountancy"));
43
44// Security check
45if (!$user->hasRight('accounting', 'chartofaccount')) {
47}
48
49$action = GETPOST('action', 'aZ09');
50
51
52$list_account_main = array(
53 'ACCOUNTING_RESULT_PROFIT',
54 'ACCOUNTING_RESULT_LOSS'
55);
56
57/*
58 * Actions
59 */
60
61if ($action == 'update') {
62 $error = 0;
63
64 $defaultjournal = GETPOST('ACCOUNTING_CLOSURE_DEFAULT_JOURNAL', 'alpha');
65
66 if (!empty($defaultjournal)) {
67 if (!dolibarr_set_const($db, 'ACCOUNTING_CLOSURE_DEFAULT_JOURNAL', $defaultjournal, 'chaine', 0, '', $conf->entity)) {
68 $error++;
69 }
70 } else {
71 $error++;
72 }
73
74 $accountinggroupsusedforbalancesheetaccount = GETPOST('ACCOUNTING_CLOSURE_ACCOUNTING_GROUPS_USED_FOR_BALANCE_SHEET_ACCOUNT', 'alphanohtml');
75 if (!empty($accountinggroupsusedforbalancesheetaccount)) {
76 if (!dolibarr_set_const($db, 'ACCOUNTING_CLOSURE_ACCOUNTING_GROUPS_USED_FOR_BALANCE_SHEET_ACCOUNT', $accountinggroupsusedforbalancesheetaccount, 'chaine', 0, '', $conf->entity)) {
77 $error++;
78 }
79 } else {
80 $error++;
81 }
82
83 $accountinggroupsusedforincomestatement = GETPOST('ACCOUNTING_CLOSURE_ACCOUNTING_GROUPS_USED_FOR_INCOME_STATEMENT', 'alpha');
84 if (!empty($accountinggroupsusedforincomestatement)) {
85 if (!dolibarr_set_const($db, 'ACCOUNTING_CLOSURE_ACCOUNTING_GROUPS_USED_FOR_INCOME_STATEMENT', $accountinggroupsusedforincomestatement, 'chaine', 0, '', $conf->entity)) {
86 $error++;
87 }
88 } else {
89 $error++;
90 }
91
92 foreach ($list_account_main as $constname) {
93 $constvalue = GETPOST($constname, 'alpha');
94 if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
95 $error++;
96 }
97 }
98
99 if (!$error) {
100 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
101 } else {
102 setEventMessages($langs->trans("Error"), null, 'errors');
103 }
104}
105
106
107/*
108 * View
109 */
110
111$form = new Form($db);
112$formaccounting = new FormAccounting($db);
113
114$title = $langs->trans('Closure');
115
116$help_url = 'EN:Module_Double_Entry_Accounting#Setup|FR:Module_Comptabilit&eacute;_en_Partie_Double#Configuration';
117
118llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-accountancy page-admin_closure');
119
120$linkback = '';
121print load_fiche_titre($langs->trans('MenuClosureAccounts'), $linkback, 'title_accountancy');
122
123print '<span class="opacitymedium">'.$langs->trans("DefaultClosureDesc").'</span><br>';
124print '<br>';
125
126print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
127print '<input type="hidden" name="token" value="'.newToken().'">';
128print '<input type="hidden" name="action" value="update">';
129
130// Define main accounts for closure
131print '<table class="noborder centpercent">';
132
133print '<tr class="liste_titre">';
134print '<th>'.$langs->trans("Parameter").'</th>';
135print '<th>';
136print '</th></tr>';
137
138foreach ($list_account_main as $key) {
139 print '<tr class="oddeven value">';
140 // Param
141 $label = $langs->trans($key);
142 $keydesc = $key.'_Desc';
143
144 $htmltext = $langs->trans($keydesc);
145 print '<td class="fieldrequired" width="50%">';
146 print $form->textwithpicto($label, $htmltext);
147 print '</td>';
148 // Value
149 print '<td>'; // Do not force class=right, or it align also the content of the select box
150 print $formaccounting->select_account(getDolGlobalString($key), $key, 1, array(), 1, 1);
151 print '</td>';
152 print '</tr>';
153}
154
155// Journal
156print '<tr class="oddeven">';
157print '<td class="fieldrequired">'.$langs->trans("ACCOUNTING_CLOSURE_DEFAULT_JOURNAL").'</td>';
158print '<td>';
159$defaultjournal = getDolGlobalString('ACCOUNTING_CLOSURE_DEFAULT_JOURNAL');
160print $formaccounting->select_journal($defaultjournal, "ACCOUNTING_CLOSURE_DEFAULT_JOURNAL", 9, 1, 0, 0);
161print '</td></tr>';
162
163// Accounting groups used for the balance sheet account
164print '<tr class="oddeven">';
165print '<td class="fieldrequired">';
166print $form->textwithpicto($langs->trans("ACCOUNTING_CLOSURE_ACCOUNTING_GROUPS_USED_FOR_BALANCE_SHEET_ACCOUNT"), $langs->trans("ACCOUNTING_CLOSURE_ACCOUNTING_GROUPS_USED_FOR_BALANCE_SHEET_ACCOUNTHelp"));
167print '</td>';
168print '<td>';
169print '<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')). '">';
170print '</td></tr>';
171
172// Accounting groups used for the income statement
173print '<tr class="oddeven">';
174print '<td class="fieldrequired">';
175print $form->textwithpicto($langs->trans("ACCOUNTING_CLOSURE_ACCOUNTING_GROUPS_USED_FOR_INCOME_STATEMENT"), $langs->trans("ACCOUNTING_CLOSURE_ACCOUNTING_GROUPS_USED_FOR_INCOME_STATEMENTHelp"));
176print '</td>';
177print '<td>';
178print '<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')). '">';
179print '</td></tr>';
180
181print "</table>\n";
182
183print '<div class="center"><input type="submit" class="button button-edit" name="button" value="'.$langs->trans('Save').'"></div>';
184
185print '</form>';
186
187// End of page
188llxFooter();
189$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:71
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...
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.