Added Quick Entries in GL Journal Entry and changed some needed fixes.
[fa-stable.git] / gl / gl_bank.php
index b3f1c1b7766f0f5871371ecf47d4f817346734a7..0df087b2a2baf5e102fe1983d1cfcab1be55aac5 100644 (file)
@@ -246,21 +246,7 @@ function handle_new_item()
        line_start_focus();
 }
 
-//-----------------------------------------------------------------------------------------------
-$id = find_submit('Delete');
-if ($id != -1)
-       handle_delete_item($id);
-
-if (isset($_POST['AddItem']))
-       handle_new_item();
-
-if (isset($_POST['UpdateItem']))
-       handle_update_item();
-
-if (isset($_POST['CancelItemChanges']))
-       line_start_focus();
-
-if (isset($_POST['go']))
+function display_quick_entries(&$cart)
 {
        if (!check_num('totamount', 0))
        {
@@ -269,7 +255,7 @@ if (isset($_POST['go']))
        }
        elseif (!get_post('person_id'))
        {
-               if ($_SESSION['pay_items']->trans_type==systypes::bank_payment())       
+               if ($cart->trans_type==systypes::bank_payment())        
                        display_error( _("No Quick Entries are defined for Payment."));
                else    
                        display_error( _("No Quick Entries are defined for Deposit."));
@@ -279,7 +265,7 @@ if (isset($_POST['go']))
        {
                $rate = 0;
                $totamount = input_num('totamount');
-               $totamount = ($_SESSION['pay_items']->trans_type==systypes::bank_payment() ? 1:-1) * $totamount;
+               $totamount = ($cart->trans_type==systypes::bank_payment() ? 1:-1) * $totamount;
                $qe = get_quick_entry($_POST['person_id']);
                $qe_lines = get_quick_entry_lines($_POST['person_id']);
                while ($qe_line = db_fetch($qe_lines))
@@ -293,9 +279,9 @@ if (isset($_POST['go']))
                                        $rate += $item['rate'];
                                if ($rate != 0)
                                        $totamount = $totamount * 100 / ($rate + 100);
-                               $_SESSION['pay_items']->clear_items();
+                               $cart->clear_items();
 
-                               $_SESSION['pay_items']->add_gl_item($qe_line['account'], $qe_line['dimension_id'], $qe_line['dimension2_id'], 
+                               $cart->add_gl_item($qe_line['account'], $qe_line['dimension_id'], $qe_line['dimension2_id'], 
                                        $totamount, $qe['description']);
                                $items = get_tax_group_items($tax_group);
                                while ($item = db_fetch($items))
@@ -303,9 +289,9 @@ if (isset($_POST['go']))
                                        if ($item['rate'] != 0)
                                        {
                                                $amount = $totamount * $item['rate'] / 100;
-                                               $code = ($_SESSION['pay_items']->trans_type==systypes::bank_payment() ? $item['purchasing_gl_code'] : 
+                                               $code = ($cart->trans_type==systypes::bank_payment() ? $item['purchasing_gl_code'] : 
                                                        $item['sales_gl_code']);
-                                               $_SESSION['pay_items']->add_gl_item($code, 0, 0, $amount, $qe['description']);
+                                               $cart->add_gl_item($code, 0, 0, $amount, $qe['description']);
                                        }
                                }
                        }
@@ -315,13 +301,29 @@ if (isset($_POST['go']))
                                        $amount = $totamount * $qe_line['amount'] / 100;
                                else
                                        $amount = $qe_line['amount'];
-                               $_SESSION['pay_items']->add_gl_item($qe_line['account'], $qe_line['dimension_id'], $qe_line['dimension2_id'], 
+                               $cart->add_gl_item($qe_line['account'], $qe_line['dimension_id'], $qe_line['dimension2_id'], 
                                        $amount, $qe['description']);
                        }               
                }
                line_start_focus();
        }       
-}      
+}
+//-----------------------------------------------------------------------------------------------
+$id = find_submit('Delete');
+if ($id != -1)
+       handle_delete_item($id);
+
+if (isset($_POST['AddItem']))
+       handle_new_item();
+
+if (isset($_POST['UpdateItem']))
+       handle_update_item();
+
+if (isset($_POST['CancelItemChanges']))
+       line_start_focus();
+
+if (isset($_POST['go']))
+       display_quick_entries($_SESSION['pay_items']);
 
 //-----------------------------------------------------------------------------------------------