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");
23 $js .= get_js_date_picker();
24 page(_($help_context = "Closing GL Transactions"), false, false, "", $js);
26 //---------------------------------------------------------------------------------------------
29 global $Refs, $allow_gl_reopen;
31 if (!is_date($_POST['date']) || date1_greater_date2($_POST['date'], Today()))
33 display_error( _("The entered date is invalid."));
37 if (!is_date_in_fiscalyears($date, false))
39 display_error(_("Selected date is not in fiscal year or the year is closed."));
43 if (date1_greater_date2(sql2date(get_company_pref('gl_closing_date')), $_POST['date']))
45 if (!$allow_gl_reopen) {
46 display_error(_("The entered date is earlier than date already selected as closing date."));
49 } elseif (!user_check_access('SA_GLREOPEN')) {
50 display_error(_("You are not allowed to reopen already closed transactions."));
58 //---------------------------------------------------------------------------------------------
60 function handle_submit()
65 if (!close_transactions($_POST['date']))
68 sprintf( _("All transactions resulting in GL accounts changes up to %s has been closed for further edition."),
69 sql2date(get_company_pref('gl_closing_date'))) );
75 //---------------------------------------------------------------------------------------------
79 unset($_POST['date_']);
82 //---------------------------------------------------------------------------------------------
84 if (get_post('submit'))
87 display_note(_("Using this feature you can prevent entering new transactions <br>
88 and disable edition of already entered transactions up to specified date.<br>
89 Only transactions which can generate GL postings are subject to the constraint."));
91 //---------------------------------------------------------------------------------------------
95 start_table(TABLESTYLE2);
96 if (!isset($_POST['date'])) {
97 $cdate = sql2date(get_company_pref('gl_closing_date'));
98 $_POST['date'] = $cdate ;// ? end_month(add_months($cdate, 1)) : Today();
100 date_row(_("End date of closing period:"), 'date');
103 submit_center('submit', _("Close Transactions"), true, false);