Fixed default POST assigning [fixes 0000009]
[fa-stable.git] / gl / gl_journal.php
index 5c974d29d61f86a48afc600134c1825c1dbc96c4..9d42cdad89f2537a5c8de63d9386b743b4d4304a 100644 (file)
@@ -19,8 +19,6 @@ if ($use_popup_windows)
 if ($use_date_picker)
        $js .= get_js_date_picker();
 
-set_focus('CodeID2');
-
 page(_("Journal Entry"), false, false,'', $js);
 
 //-----------------------------------------------------------------------------------------------
@@ -69,7 +67,7 @@ function handle_new_order()
 
     session_register("journal_items");
 
-    $_SESSION['journal_items'] = new items_cart;
+    $_SESSION['journal_items'] = new items_cart(systypes::journal_entry());
 
        $_POST['date_'] = Today();
        if (!is_date_in_fiscalyear($_POST['date_']))
@@ -146,7 +144,7 @@ function check_item_data()
        if (!(input_num('AmountDebit')!=0 ^ input_num('AmountCredit')!=0) )
        {
                display_error(_("You must enter either a debit amount or a credit amount."));
-               set_focus('Amount_Debit');
+               set_focus('AmountDebit');
                return false;
        }
 
@@ -213,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');
 
 //-----------------------------------------------------------------------------------------------