From: Janusz Dobrowolski Date: Tue, 1 Jul 2008 21:23:47 +0000 (+0000) Subject: Code cleanup X-Git-Tag: v2.4.2~19^2~1946 X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=commitdiff_plain;h=e8623dd6746abb8eec4eb3ddd583d208e531b8e7;p=fa-stable.git Code cleanup --- diff --git a/gl/gl_bank.php b/gl/gl_bank.php index b035587b..99a0dc33 100644 --- a/gl/gl_bank.php +++ b/gl/gl_bank.php @@ -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(); -} + //----------------------------------------------------------------------------------------------- diff --git a/gl/includes/ui/gl_bank_ui.inc b/gl/includes/ui/gl_bank_ui.inc index 7e8c9375..d55d7e2f 100644 --- a/gl/includes/ui/gl_bank_ui.inc +++ b/gl/includes/ui/gl_bank_ui.inc @@ -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 ""; // inner table echo ""; @@ -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) diff --git a/inventory/adjustments.php b/inventory/adjustments.php index dda848d7..7eac496c 100644 --- a/inventory/adjustments.php +++ b/inventory/adjustments.php @@ -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(); diff --git a/inventory/transfers.php b/inventory/transfers.php index a17253d5..13f4c109 100644 --- a/inventory/transfers.php +++ b/inventory/transfers.php @@ -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(); diff --git a/purchasing/po_entry_items.php b/purchasing/po_entry_items.php index 6d950dbb..be9dc188 100644 --- a/purchasing/po_entry_items.php +++ b/purchasing/po_entry_items.php @@ -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; -} //--------------------------------------------------------------------------------------------------- diff --git a/sales/credit_note_entry.php b/sales/credit_note_entry.php index bc8a9e98..9a73d7c2 100644 --- a/sales/credit_note_entry.php +++ b/sales/credit_note_entry.php @@ -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; } //----------------------------------------------------------------------------- diff --git a/sales/sales_order_entry.php b/sales/sales_order_entry.php index aaad352b..dfeb1532 100644 --- a/sales/sales_order_entry.php +++ b/sales/sales_order_entry.php @@ -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(); }