2 /**********************************************************************
3 Copyright (C) FrontAccounting, LLC.
4 Released under the terms of the GNU General Public License, GPL,
5 as published by the Free Software Foundation, either version 3
6 of the License, or (at your option) any later version.
7 This program is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
11 ***********************************************************************/
13 $page_security = 'SA_GLCLOSE';
14 $path_to_root = "../..";
15 include_once($path_to_root . "/includes/session.inc");
17 include_once($path_to_root . "/includes/date_functions.inc");
18 include_once($path_to_root . "/includes/ui.inc");
19 include_once($path_to_root . "/includes/banking.inc");
20 include_once($path_to_root . "/admin/db/fiscalyears_db.inc");
23 if (user_use_date_picker())
24 $js .= get_js_date_picker();
25 page(_($help_context = "Closing GL Transactions"), false, false, "", $js);
27 //---------------------------------------------------------------------------------------------
32 if (!is_date($_POST['date']) || date1_greater_date2($_POST['date'], Today()))
34 display_error( _("The entered date is invalid."));
38 if (!is_date_in_fiscalyears($_POST['date'], false))
40 display_error(_("Selected date is not in fiscal year or the year is closed."));
44 if (date1_greater_date2(sql2date(get_company_pref('gl_closing_date')), $_POST['date']))
46 if (!$SysPrefs->allow_gl_reopen) {
47 display_error(_("The entered date is earlier than date already selected as closing date."));
50 } elseif (!user_check_access('SA_GLREOPEN')) {
51 display_error(_("You are not allowed to reopen already closed transactions."));
59 //---------------------------------------------------------------------------------------------
61 function handle_submit()
66 if (!close_transactions($_POST['date']))
69 sprintf( _("All transactions resulting in GL accounts changes up to %s has been closed for further edition."),
70 sql2date(get_company_pref('gl_closing_date'))) );
76 //---------------------------------------------------------------------------------------------
80 unset($_POST['date_']);
83 //---------------------------------------------------------------------------------------------
85 if (get_post('submit'))
88 display_note(_("Using this feature you can prevent entering new transactions <br>
89 and disable edition of already entered transactions up to specified date.<br>
90 Only transactions which can generate GL postings are subject to the constraint."));
92 //---------------------------------------------------------------------------------------------
96 start_table(TABLESTYLE2);
97 if (!isset($_POST['date'])) {
98 $cdate = sql2date(get_company_pref('gl_closing_date'));
99 $_POST['date'] = $cdate ;// ? end_month(add_months($cdate, 1)) : Today();
101 date_row(_("End date of closing period:"), 'date');
104 submit_center('submit', _("Close Transactions"), true, false);