Layout fixes
[fa-stable.git] / gl / gl_journal.php
index b5a2c1cc287a05f0b400a9abb63df99ba6b0844e..1e820f5f393c336f1baf4455587cc3fb77f85b47 100644 (file)
@@ -13,14 +13,13 @@ include_once($path_to_root . "/gl/includes/ui/gl_journal_ui.inc");
 include_once($path_to_root . "/gl/includes/gl_db.inc");
 include_once($path_to_root . "/gl/includes/gl_ui.inc");
 
-$js = get_js_form_entry("CodeID2", "code_id", "AmountDebit");
+$js = '';
 if ($use_popup_windows)
        $js .= get_js_open_window(800, 500);
 if ($use_date_picker)
        $js .= get_js_date_picker();
-$js .= get_js_set_focus('CodeID2');
 
-page(_("Journal Entry"), false, false, "setFocus()", $js);
+page(_("Journal Entry"), false, false,'', $js);
 
 //-----------------------------------------------------------------------------------------------
 
@@ -86,21 +85,25 @@ if (isset($_POST['Process']))
        if (!is_date($_POST['date_'])) 
        {
                display_error(_("The entered date is invalid."));
+               set_focus('date_');
                $input_error = 1;
        } 
        elseif (!is_date_in_fiscalyear($_POST['date_'])) 
        {
                display_error(_("The entered date is not in fiscal year."));
+               set_focus('date_');
                $input_error = 1;
        } 
        elseif (!references::is_valid($_POST['ref'])) 
        {
                display_error( _("You must enter a reference."));
+               set_focus('ref');
                $input_error = 1;
        } 
        elseif (references::exists(systypes::journal_entry(), $_POST['ref'])) 
        {
                display_error( _("The entered reference is already in use."));
+               set_focus('ref');
                $input_error = 1;
        }
 
@@ -127,28 +130,33 @@ function check_item_data()
        if (isset($_POST['dimension_id']) && $_POST['dimension_id'] != 0 && dimension_is_closed($_POST['dimension_id'])) 
        {
                display_error(_("Dimension is closed."));
-                       return false;
+               set_focus('dimension_id');
+               return false;
        }
 
        if (isset($_POST['dimension2_id']) && $_POST['dimension2_id'] != 0 && dimension_is_closed($_POST['dimension2_id'])) 
        {
                display_error(_("Dimension is closed."));
-                       return false;
+               set_focus('dimension2_id');
+               return false;
        }
 
-       if (!(!strlen($_POST['AmountDebit']) ^ !strlen($_POST['AmountCredit'])))
+       if (!(input_num('AmountDebit')!=0 ^ input_num('AmountCredit')!=0) )
        {
                display_error(_("You must enter either a debit amount or a credit amount."));
+               set_focus('AmountDebit');
                return false;
        }
 
        if (strlen($_POST['AmountDebit']) && !check_num('AmountDebit', 0)) 
        {
                display_error(_("The debit amount entered is not a valid number or is less than zero."));
+               set_focus('AmountDebit');
                return false;
        } elseif (strlen($_POST['AmountCredit']) && !check_num('AmountCredit', 0))
        {
                display_error(_("The credit amount entered is not a valid number or is less than zero."));
+               set_focus('AmountCredit');
                return false;
        }
 
@@ -156,6 +164,7 @@ function check_item_data()
        if ($_SESSION["wa_current_user"]->access != 2 && is_bank_account($_POST['code_id'])) 
        {
                display_error(_("You cannot make a journal entry for a bank account. Please use one of the banking functions for bank transactions."));
+               set_focus('code_id');
                return false;
        }
 
@@ -202,21 +211,30 @@ function handle_new_item()
 }
 
 //-----------------------------------------------------------------------------------------------
-
-if (isset($_GET['Delete']) || isset($_GET['Edit']))
+if (isset($_GET['Edit'])) {
+       copy_from_je();
+       set_focus('dimension_id');
+}
+if (isset($_GET['Delete'])) {
        copy_from_je();
-
-if (isset($_GET['Delete']))
        handle_delete_item();
-
-if (isset($_POST['AddItem']) || isset($_POST['UpdateItem']))
+       set_focus('_code_id_edit');
+}
+if (isset($_POST['AddItem'])) {
        copy_to_je();
-
-if (isset($_POST['AddItem']))
        handle_new_item();
-
-if (isset($_POST['UpdateItem']))
+       set_focus('_code_id_edit');
+}
+if (isset($_POST['UpdateItem'])) {
+       copy_to_je();
        handle_update_item();
+       set_focus('_code_id_edit');
+}
+if (isset($_POST['CancelItemChanges']))
+       set_focus('_code_id_edit');
+
+if (isset($_POST['EditItem']))
+       set_focus('dimension_id');
 
 //-----------------------------------------------------------------------------------------------