Code cleanup
authorJanusz Dobrowolski <janusz@frontaccounting.eu>
Tue, 1 Jul 2008 21:23:47 +0000 (21:23 +0000)
committerJanusz Dobrowolski <janusz@frontaccounting.eu>
Tue, 1 Jul 2008 21:23:47 +0000 (21:23 +0000)
gl/gl_bank.php
gl/includes/ui/gl_bank_ui.inc
inventory/adjustments.php
inventory/transfers.php
purchasing/po_entry_items.php
sales/credit_note_entry.php
sales/sales_order_entry.php

index b035587bff5ba46fb077204fa2ae990391295ce9..99a0dc335c5eab4831ccc1081d5178156689c9be 100644 (file)
@@ -70,39 +70,8 @@ if (isset($_GET['AddedDep']))
 
        display_footer_exit();
 }
-
 //--------------------------------------------------------------------------------------------------
 
-function copy_to_py()
-{
-       $_SESSION['pay_items']->from_loc = $_POST['bank_account'];
-       $_SESSION['pay_items']->tran_date = $_POST['date_'];
-       $_SESSION['pay_items']->transfer_type = $_POST['type'];
-       $_SESSION['pay_items']->increase = $_POST['PayType'];
-       if (!isset($_POST['person_id']))
-               $_POST['person_id'] = "";
-       $_SESSION['pay_items']->person_id = $_POST['person_id'];
-       if (!isset($_POST['PersonDetailID']))
-               $_POST['PersonDetailID'] = "";
-       $_SESSION['pay_items']->branch_id = $_POST['PersonDetailID'];
-       $_SESSION['pay_items']->memo_ = $_POST['memo_'];
-}
-
-//--------------------------------------------------------------------------------------------------
-
-function copy_from_py()
-{
-       $_POST['bank_account'] = $_SESSION['pay_items']->from_loc;
-       $_POST['date_'] = $_SESSION['pay_items']->tran_date;
-       $_POST['type'] = $_SESSION['pay_items']->transfer_type;
-       $_POST['PayType'] = $_SESSION['pay_items']->increase;
-       $_POST['person_id'] = $_SESSION['pay_items']->person_id;
-       $_POST['PersonDetailID'] = $_SESSION['pay_items']->branch_id;
-       $_POST['memo_'] = $_SESSION['pay_items']->memo_;
-}
-
-//-----------------------------------------------------------------------------------------------
-
 function handle_new_order($type)
 {
        if (isset($_SESSION['pay_items']))
@@ -250,14 +219,8 @@ function handle_new_item()
 
 //-----------------------------------------------------------------------------------------------
 $id = find_submit('Delete');
-if ($id != -1) {
-       copy_from_py();
+if ($id != -1)
        handle_delete_item($id);
-}
-if (isset($_POST['AddItem']) || isset($_POST['UpdateItem'])) {
-       copy_to_py();
-       line_start_focus();
-}
 
 if (isset($_POST['AddItem']))
        handle_new_item();
@@ -265,9 +228,9 @@ if (isset($_POST['AddItem']))
 if (isset($_POST['UpdateItem']))
        handle_update_item();
 
-if (isset($_POST['CancelItemChanges'])) {
+if (isset($_POST['CancelItemChanges'])) 
        line_start_focus();
-}
+
 
 //-----------------------------------------------------------------------------------------------
 
index 7e8c9375390852600b8541a8a6ef92182e9885ae..d55d7e2f24932b36e8a28f1ccd5fb47870f4da2f 100644 (file)
@@ -72,15 +72,11 @@ function display_bank_header(&$order)
        //      break;
     }
 
-       //$homeCurrency = get_company_currency();
        $person_currency = payment_person_types::person_currency($_POST['PayType'], $_POST['person_id']);
        $bank_currency = get_bank_account_currency($_POST['bank_account']);
 
-       if ($bank_currency != "" && $bank_currency != $person_currency)
-       {
-               exchange_rate_display($bank_currency, $person_currency, $_POST['date_']);
-       }
-       
+       exchange_rate_display($bank_currency, $person_currency, $_POST['date_']);
+
        echo "</table>"; // inner table
 
        echo "</td><td>";
@@ -175,18 +171,18 @@ function gl_edit_item_controls(&$order, $dim, $Index=null)
        $id = find_submit('Edit');
        if ($Index != -1 && $Index == $id)
        {
-               $_POST['code_id'] = $order->gl_items[$Index]->code_id;
-               $_POST['dimension_id'] = $order->gl_items[$Index]->dimension_id;
-               $_POST['dimension2_id'] = $order->gl_items[$Index]->dimension2_id;
-               $_POST['amount'] = 
-                       price_format(($payment ? 1 : -1) * $order->gl_items[$Index]->amount);
-               $_POST['description'] = $order->gl_items[$Index]->description;
-               $_POST['LineMemo'] = $order->gl_items[$Index]->reference;
-
-               hidden('Index', $order->gl_items[$Index]->index);
-               hidden('code_id', $order->gl_items[$Index]->code_id);
+               $item = $order->gl_items[$Index];
+               $_POST['code_id'] = $item->code_id;
+               $_POST['dimension_id'] = $item->dimension_id;
+               $_POST['dimension2_id'] = $item->dimension2_id;
+               $_POST['amount'] = price_format(abs($item->amount));
+               $_POST['description'] = $item->description;
+               $_POST['LineMemo'] = $item->reference;
+
+               hidden('Index', $item->index);
+               hidden('code_id', $item->code_id);
                label_cell($_POST['code_id']);
-               label_cell($order->gl_items[$Index]->description);
+               label_cell($item->description);
                if ($dim >= 1)
                        dimensions_list_cells(null, 'dimension_id', null, true, " ", false, 1);
                if ($dim > 1)
index dda848d7da92f306fab1d9c4683255e9e0cdcb59..7eac496c1d26bc54960a8d90056bb7417f47b723 100644 (file)
@@ -48,27 +48,6 @@ function line_start_focus() {
   $Ajax->activate('items_table');
   set_focus('_stock_id_edit');
 }
-//--------------------------------------------------------------------------------------------------
-
-function copy_to_st()
-{
-       $_SESSION['adj_items']->from_loc = $_POST['StockLocation'];
-       $_SESSION['adj_items']->tran_date = $_POST['AdjDate'];
-       $_SESSION['adj_items']->transfer_type = $_POST['type'];
-       $_SESSION['adj_items']->increase = $_POST['Increase'];
-       $_SESSION['adj_items']->memo_ = $_POST['memo_'];
-}
-//--------------------------------------------------------------------------------------------------
-
-function copy_from_st()
-{
-       $_POST['StockLocation'] = $_SESSION['adj_items']->from_loc;
-       $_POST['AdjDate'] = $_SESSION['adj_items']->tran_date;
-       $_POST['type'] = $_SESSION['adj_items']->transfer_type;
-       $_POST['Increase'] = $_SESSION['adj_items']->increase;
-       $_POST['memo_'] = $_SESSION['adj_items']->memo_;
-}
-
 //-----------------------------------------------------------------------------------------------
 
 function handle_new_order()
@@ -212,11 +191,6 @@ $id = find_submit('Delete');
 if ($id != -1)
        handle_delete_item($id);
 
-if (isset($_POST['AddItem']) || isset($_POST['UpdateItem'])) {
-       copy_to_st();
-       line_start_focus();
-}
-
 if (isset($_POST['AddItem']))
        handle_new_item();
 
index a17253d50bb1e7b95bfac6b47c97687c133b9533..13f4c109303a5de4a66ed45df17ef6b6a991ae27 100644 (file)
@@ -46,27 +46,6 @@ function line_start_focus() {
   $Ajax->activate('items_table');
   set_focus('_stock_id_edit');
 }
-//--------------------------------------------------------------------------------------------------
-
-function copy_to_st()
-{
-       $_SESSION['transfer_items']->from_loc = $_POST['FromStockLocation'];
-       $_SESSION['transfer_items']->to_loc = $_POST['ToStockLocation'];
-       $_SESSION['transfer_items']->tran_date = $_POST['AdjDate'];
-       $_SESSION['transfer_items']->transfer_type = $_POST['type'];
-       $_SESSION['transfer_items']->memo_ = $_POST['memo_'];
-}
-//--------------------------------------------------------------------------------------------------
-
-function copy_from_st()
-{
-       $_POST['FromStockLocation'] = $_SESSION['transfer_items']->from_loc;
-       $_POST['ToStockLocation'] = $_SESSION['transfer_items']->to_loc;
-       $_POST['AdjDate'] = $_SESSION['transfer_items']->tran_date;
-       $_POST['type'] = $_SESSION['transfer_items']->transfer_type;
-       $_POST['memo_'] = $_SESSION['transfer_items']->memo_;
-}
-
 //-----------------------------------------------------------------------------------------------
 
 function handle_new_order()
@@ -213,11 +192,6 @@ function handle_new_item()
 $id = find_submit('Delete');
 if ($id != -1)
        handle_delete_item($id);
-
-if (isset($_POST['AddItem']) || isset($_POST['UpdateItem'])) {
-       copy_to_st();
-       line_start_focus();
-}
        
 if (isset($_POST['AddItem']))
        handle_new_item();
index 6d950dbbf26ed04d54a7c89a600d869d67a4d363..be9dc188684e6b72fffbb90aebfcba76a766ecf7 100644 (file)
@@ -61,32 +61,6 @@ function line_start_focus() {
 }
 //--------------------------------------------------------------------------------------------------
 
-function copy_to_po()
-{
-       $_SESSION['PO']->supplier_id = $_POST['supplier_id'];   
-       $_SESSION['PO']->orig_order_date = $_POST['OrderDate'];
-       $_SESSION['PO']->reference = $_POST['ref'];
-       $_SESSION['PO']->requisition_no = $_POST['Requisition'];
-       $_SESSION['PO']->Comments = $_POST['Comments']; 
-       $_SESSION['PO']->Location = $_POST['StkLocation'];
-       $_SESSION['PO']->delivery_address = $_POST['delivery_address'];
-}
-
-//--------------------------------------------------------------------------------------------------
-
-function copy_from_po()
-{
-       $_POST['supplier_id'] = $_SESSION['PO']->supplier_id;   
-       $_POST['OrderDate'] = $_SESSION['PO']->orig_order_date; 
-    $_POST['Requisition'] = $_SESSION['PO']->requisition_no;
-    $_POST['ref'] = $_SESSION['PO']->reference;
-       $_POST['Comments'] = $_SESSION['PO']->Comments;
-    $_POST['StkLocation'] = $_SESSION['PO']->Location;
-    $_POST['delivery_address'] = $_SESSION['PO']->delivery_address;    
-}
-
-//--------------------------------------------------------------------------------------------------
-
 function unset_form_variables() {
        unset($_POST['stock_id']);
     unset($_POST['qty']);
@@ -259,14 +233,14 @@ function can_commit()
        
        if (!$_SESSION['PO']->order_no) 
        {
-       if (!references::is_valid($_SESSION['PO']->reference)) 
+       if (!references::is_valid(get_post('ref'))) 
        {
                display_error(_("There is no reference entered for this purchase order."));
                        set_focus('ref');
                return false;
        } 
        
-       if (!is_new_reference($_SESSION['PO']->reference, systypes::po())) 
+       if (!is_new_reference(get_post('ref'), systypes::po())) 
        {
                display_error(_("The entered reference is already in use."));
                        set_focus('ref');
@@ -274,14 +248,14 @@ function can_commit()
        }
        }
        
-       if ($_SESSION['PO']->delivery_address == "")
+       if (get_post('delivery_address') == '')
        {
                display_error(_("There is no delivery address specified."));
                set_focus('delivery_address');
                return false;
        } 
        
-       if (!isset($_SESSION['PO']->Location) || $_SESSION['PO']->Location == "")
+       if (get_post('StkLocation') == '')
        {
                display_error(_("There is no location specified to move any items into."));
                set_focus('StkLocation');
@@ -301,10 +275,16 @@ function can_commit()
 
 function handle_commit_order()
 {
-       copy_to_po();
 
        if (can_commit())
        {
+               $_SESSION['PO']->supplier_id = $_POST['supplier_id'];   
+               $_SESSION['PO']->orig_order_date = $_POST['OrderDate'];
+               $_SESSION['PO']->reference = $_POST['ref'];
+               $_SESSION['PO']->requisition_no = $_POST['Requisition'];
+               $_SESSION['PO']->Comments = $_POST['Comments']; 
+               $_SESSION['PO']->Location = $_POST['StkLocation'];
+               $_SESSION['PO']->delivery_address = $_POST['delivery_address'];
 
                if ($_SESSION['PO']->order_no == 0)
                { 
@@ -334,34 +314,22 @@ $id = find_submit('Delete');
 if ($id != -1)
        handle_delete_item($id);
 
-if (isset($_POST['Delete']) || isset($_POST['Edit']))
-{
-       copy_from_po();
-}
-       
 if (isset($_POST['Commit']))
 {
        handle_commit_order();
 }
 if (isset($_POST['UpdateLine']))
-{
-       copy_to_po();
        handle_update_item();
-}
+
 if (isset($_POST['EnterLine']))
-{
-       copy_to_po();
        handle_add_new_item();
-} 
+
 if (isset($_POST['CancelOrder'])) 
-{
        handle_cancel_po();
-}
+
 if (isset($_POST['CancelUpdate']))
-{
-       copy_to_po();
        unset_form_variables();
-}
+
 if (isset($_GET['ModifyOrderNumber']) && $_GET['ModifyOrderNumber'] != "")
 {
        create_new_po();
@@ -370,29 +338,22 @@ if (isset($_GET['ModifyOrderNumber']) && $_GET['ModifyOrderNumber'] != "")
 
        /*read in all the selected order into the Items cart  */
        read_po($_SESSION['PO']->order_no, $_SESSION['PO']);
-       copy_from_po();
+
+       $_POST['supplier_id'] = $_SESSION['PO']->supplier_id;   
+       $_POST['OrderDate'] = $_SESSION['PO']->orig_order_date; 
+    $_POST['Requisition'] = $_SESSION['PO']->requisition_no;
+    $_POST['ref'] = $_SESSION['PO']->reference;
+       $_POST['Comments'] = $_SESSION['PO']->Comments;
+    $_POST['StkLocation'] = $_SESSION['PO']->Location;
+    $_POST['delivery_address'] = $_SESSION['PO']->delivery_address;    
 }
+
 if (isset($_POST['CancelUpdate']) || isset($_POST['UpdateLine'])) {
        line_start_focus();
 }
 
-//--------------------------------------------------------------------------------
-
 if (isset($_GET['NewOrder']))
-{
        create_new_po();
-} 
-else 
-{
-       if (!isset($_POST['supplier_id']))
-               $_POST['supplier_id'] = $_SESSION['PO']->supplier_id;
-       if (!isset($_POST['OrderDate']))                
-               $_POST['OrderDate'] = $_SESSION['PO']->orig_order_date;
-       if (!isset($_POST['Requisition']))              
-               $_POST['Requisition'] = $_SESSION['PO']->requisition_no;
-       if (!isset($_POST['Comments']))         
-               $_POST['Comments'] = $_SESSION['PO']->Comments;
-}
 
 //---------------------------------------------------------------------------------------------------
 
index bc8a9e98f422091f50bfea779eb9def4fc547f77..9a73d7c25c8c71ad715280e9030a1924c23bfa32 100644 (file)
@@ -208,27 +208,19 @@ $id = find_submit('Delete');
 if ($id!=-1)
        handle_delete_item($id);
 
-if (isset($_POST['AddItem']) || isset($_POST['UpdateItem']))
-       copy_to_cn();
-
 if (isset($_POST['AddItem']))
        handle_new_item();
 
 if (isset($_POST['UpdateItem']))
        handle_update_item();
 
-if (isset($_POST['CancelItemChanges']) || isset($_POST['UpdateItem']))
+if (isset($_POST['CancelItemChanges']))
        line_start_focus();
 
 //-----------------------------------------------------------------------------
 
 if (!processing_active()) {
        handle_new_credit();
-} else {
-       if (!isset($_POST['customer_id']))
-               $_POST['customer_id'] = $_SESSION['Items']->customer_id;
-       if (!isset($_POST['branch_id']))
-               $_POST['branch_id'] = $_SESSION['Items']->Branch;
 }
 
 //-----------------------------------------------------------------------------
index aaad352b018adcbdc5ae4fa5f8c72b1ffc99db3e..dfeb153279eccdc426ca84180ecf0f610f08942e 100644 (file)
@@ -303,7 +303,6 @@ function handle_update_item()
                 input_num('qty'), input_num('price'),
                 input_num('Disc') / 100 );
        }
-  copy_from_cart();
   line_start_focus();
 }
 
@@ -412,7 +411,7 @@ if (isset($_POST['UpdateItem']))
 if (isset($_POST['AddItem']))
        handle_new_item();
 
-if (isset($_POST['CancelItemChanges']) || isset($_POST['UpdateItem'])) {
+if (isset($_POST['CancelItemChanges'])) {
        line_start_focus();
 }