Fixed maximum nam length.
[fa-stable.git] / admin / fiscalyears.php
index bae4e4bbc4226e7b095ccb313a39ad43e710e47a..1926d48e1719c6c0a6bec73b5ac605f4f8f2b5e8 100644 (file)
@@ -29,7 +29,7 @@ simple_page_mode(true);
 
 function check_data()
 {
-       if (!is_date($_POST['from_date']) || is_date_in_fiscalyears($_POST['from_date']) || is_bad_begin_date($_POST['from_date']))
+       if (!is_date($_POST['from_date']) || is_date_in_fiscalyears($_POST['from_date']) || !check_begin_date($_POST['from_date']))
        {
                display_error( _("Invalid BEGIN date in fiscal year."));
                set_focus('from_date');
@@ -120,16 +120,14 @@ function handle_delete()
 
 function display_fiscalyears()
 {
-       global $table_style;
-
        $company_year = get_company_pref('f_year');
 
        $result = get_all_fiscalyears();
        start_form();
        display_note(_("Warning: Deleting a fiscal year all transactions 
                are removed and converted into relevant balances. This process is irreversible!"), 
-               0, 0, "class='currentfg'");
-       start_table($table_style);
+               0, 1, "class='currentfg'");
+       start_table(TABLESTYLE);
 
        $th = array(_("Fiscal Year Begin"), _("Fiscal Year End"), _("Closed"), "", "");
        table_header($th);
@@ -176,10 +174,10 @@ function display_fiscalyears()
 
 function display_fiscalyear_edit($selected_id)
 {
-       global $table_style2, $Mode;
+       global $Mode;
 
        start_form();
-       start_table($table_style2);
+       start_table(TABLESTYLE2);
 
        if ($selected_id != -1)
        {
@@ -198,7 +196,16 @@ function display_fiscalyear_edit($selected_id)
        }
        else
        {
-               date_row(_("Fiscal Year Begin:"), 'from_date', '', null, 0, 0, 1001);
+               $begin = check_begin_date("", false);
+               if ($begin)
+               {
+                       $_POST['from_date'] = $begin;
+                       hidden('from_date', $begin);
+                       $_POST['to_date'] = end_month(add_months($begin, 11));
+                       label_row(_("Fiscal Year Begin:"), $_POST['from_date']);
+               }
+               else
+                       date_row(_("Fiscal Year Begin:"), 'from_date', '', null, 0, 0, 1001);
                date_row(_("Fiscal Year End:"), 'to_date', '', null, 0, 0, 1001);
        }
        hidden('selected_id', $selected_id);