From ed12c6b38e84077b5183de344c3a204162bd4e87 Mon Sep 17 00:00:00 2001 From: Janusz Dobrowolski Date: Sun, 29 Jun 2008 21:18:25 +0000 Subject: [PATCH] Rewritten bank deposit/payment related files, added ajax. --- applications/generalledger.php | 4 +- gl/{gl_payment.php => gl_bank.php} | 135 +++++---- gl/gl_deposit.php | 274 ------------------ gl/gl_journal.php | 2 +- gl/includes/db/gl_db_banking.inc | 19 -- .../ui/{gl_payment_ui.inc => gl_bank_ui.inc} | 104 ++++--- manufacturing/search_work_orders.php | 2 +- 7 files changed, 146 insertions(+), 394 deletions(-) rename gl/{gl_payment.php => gl_bank.php} (65%) delete mode 100644 gl/gl_deposit.php rename gl/includes/ui/{gl_payment_ui.inc => gl_bank_ui.inc} (69%) diff --git a/applications/generalledger.php b/applications/generalledger.php index 3a715824..b610f841 100644 --- a/applications/generalledger.php +++ b/applications/generalledger.php @@ -9,8 +9,8 @@ $this->application("GL",_("Banking and General Ledger")); $this->add_module(_("Transactions")); - $this->add_lapp_function(0, _("Payments"),"gl/gl_payment.php?NewPayment=Yes"); - $this->add_lapp_function(0, _("Deposits"),"gl/gl_deposit.php?NewDeposit=Yes"); + $this->add_lapp_function(0, _("Payments"),"gl/gl_bank.php?NewPayment=Yes"); + $this->add_lapp_function(0, _("Deposits"),"gl/gl_bank.php?NewDeposit=Yes"); $this->add_lapp_function(0, _("Bank Account Transfers"),"gl/bank_transfer.php?"); $this->add_rapp_function(0, _("Journal Entry"),"gl/gl_journal.php?NewJournal=Yes"); $this->add_rapp_function(0, _("Budget Entry"),"gl/gl_budget.php?"); diff --git a/gl/gl_payment.php b/gl/gl_bank.php similarity index 65% rename from gl/gl_payment.php rename to gl/gl_bank.php index 60efb8ae..b035587b 100644 --- a/gl/gl_payment.php +++ b/gl/gl_bank.php @@ -8,7 +8,7 @@ include_once($path_to_root . "/includes/session.inc"); include_once($path_to_root . "/includes/date_functions.inc"); include_once($path_to_root . "/includes/data_checks.inc"); -include_once($path_to_root . "/gl/includes/ui/gl_payment_ui.inc"); +include_once($path_to_root . "/gl/includes/ui/gl_bank_ui.inc"); include_once($path_to_root . "/gl/includes/gl_db.inc"); include_once($path_to_root . "/gl/includes/gl_ui.inc"); @@ -18,14 +18,29 @@ if ($use_popup_windows) if ($use_date_picker) $js .= get_js_date_picker(); -page(_("Bank Account Payment Entry"), false, false, '', $js); +if (isset($_GET['NewPayment'])) { + $_SESSION['page_title'] = _("Bank Account Payment Entry"); + handle_new_order(systypes::bank_payment()); -//----------------------------------------------------------------------------------------------- +} else if(isset($_GET['NewDeposit'])) { + $_SESSION['page_title'] = _("Bank Account Deposit Entry"); + handle_new_order(systypes::bank_deposit()); +} +page($_SESSION['page_title'], false, false, '', $js); +//----------------------------------------------------------------------------------------------- check_db_has_bank_accounts(_("There are no bank accounts defined in the system.")); check_db_has_bank_trans_types(_("There are no bank payment types defined in the system.")); +//-------------------------------------------------------------------------------------------------- +function line_start_focus() { + global $Ajax; + + $Ajax->activate('items_table'); + set_focus('_code_id_edit'); +} + //----------------------------------------------------------------------------------------------- if (isset($_GET['AddedID'])) @@ -42,6 +57,20 @@ if (isset($_GET['AddedID'])) display_footer_exit(); } +if (isset($_GET['AddedDep'])) +{ + $trans_no = $_GET['AddedDep']; + $trans_type = systypes::bank_deposit(); + + display_notification_centered(_("Deposit has been entered")); + + display_note(get_gl_view_str($trans_type, $trans_no, _("View the GL Postings for this Deposit"))); + + hyperlink_no_params($_SERVER['PHP_SELF'], _("Enter Another Deposit")); + + display_footer_exit(); +} + //-------------------------------------------------------------------------------------------------- function copy_to_py() @@ -74,7 +103,7 @@ function copy_from_py() //----------------------------------------------------------------------------------------------- -function handle_new_order() +function handle_new_order($type) { if (isset($_SESSION['pay_items'])) { @@ -84,7 +113,7 @@ function handle_new_order() session_register("pay_items"); - $_SESSION['pay_items'] = new items_cart; + $_SESSION['pay_items'] = new items_cart($type); $_POST['date_'] = Today(); if (!is_date_in_fiscalyear($_POST['date_'])) @@ -99,19 +128,25 @@ if (isset($_POST['Process'])) $input_error = 0; + if ($_SESSION['pay_items']->count_gl_items() < 1) { + display_error(_("You must enter at least one payment line.")); + set_focus('code_id'); + $input_error = 1; + } + if (!references::is_valid($_POST['ref'])) { display_error( _("You must enter a reference.")); set_focus('ref'); $input_error = 1; } - elseif (!is_new_reference($_POST['ref'], systypes::bank_payment())) + elseif (!is_new_reference($_POST['ref'], $_SESSION['pay_items']->trans_type)) { display_error( _("The entered reference is already in use.")); set_focus('ref'); $input_error = 1; } - elseif (!is_date($_POST['date_'])) + if (!is_date($_POST['date_'])) { display_error(_("The entered date for the payment is invalid.")); set_focus('date_'); @@ -130,10 +165,11 @@ if (isset($_POST['Process'])) if (isset($_POST['Process'])) { - - $trans = add_bank_payment($_POST['bank_account'], + + $trans = add_bank_transaction( + $_SESSION['pay_items']->trans_type, $_POST['bank_account'], $_SESSION['pay_items'], $_POST['date_'], - $_POST['PayType'], $_POST['person_id'], $_POST['PersonDetailID'], + $_POST['PayType'], $_POST['person_id'], get_post('PersonDetailID'), $_POST['type'], $_POST['ref'], $_POST['memo_']); $trans_type = $trans[0]; @@ -142,7 +178,8 @@ if (isset($_POST['Process'])) $_SESSION['pay_items']->clear_items(); unset($_SESSION['pay_items']); - meta_forward($_SERVER['PHP_SELF'], "AddedID=$trans_no"); + meta_forward($_SERVER['PHP_SELF'], $trans_type==systypes::bank_payment() ? + "AddedID=$trans_no" : "AddedDep=$trans_no"); } /*end of process credit note */ @@ -166,7 +203,10 @@ function check_item_data() if (is_bank_account($_POST['code_id'])) { - display_error( _("You cannot make a payment to a bank account. Please use the transfer funds facility for this.")); + if ($_SESSION['pay_items']->trans_type == systypes::bank_payment()) + display_error( _("You cannot make a payment to a bank account. Please use the transfer funds facility for this.")); + else + display_error( _("You cannot make a deposit from a bank account. Please use the transfer funds facility for this.")); set_focus('code_id'); return false; } @@ -178,19 +218,21 @@ function check_item_data() function handle_update_item() { + $amount = ($_SESSION['pay_items']->trans_type==systypes::bank_payment() ? 1:-1) * input_num('amount'); if($_POST['UpdateItem'] != "" && check_item_data()) { $_SESSION['pay_items']->update_gl_item($_POST['Index'], $_POST['dimension_id'], - $_POST['dimension2_id'], input_num('amount'), $_POST['LineMemo']); + $_POST['dimension2_id'], $amount , $_POST['LineMemo']); } - set_focus('_code_id_edit'); + line_start_focus(); } //----------------------------------------------------------------------------------------------- -function handle_delete_item() +function handle_delete_item($id) { - $_SESSION['pay_items']->remove_gl_item($_GET['Delete']); + $_SESSION['pay_items']->remove_gl_item($id); + line_start_focus(); } //----------------------------------------------------------------------------------------------- @@ -199,70 +241,53 @@ function handle_new_item() { if (!check_item_data()) return; - + $amount = ($_SESSION['pay_items']->trans_type==systypes::bank_payment() ? 1:-1) * input_num('amount'); + $_SESSION['pay_items']->add_gl_item($_POST['code_id'], $_POST['dimension_id'], - $_POST['dimension2_id'], input_num('amount'), $_POST['LineMemo']); + $_POST['dimension2_id'], $amount, $_POST['LineMemo']); + line_start_focus(); } //----------------------------------------------------------------------------------------------- - -if (isset($_GET['Edit'])) { +$id = find_submit('Delete'); +if ($id != -1) { copy_from_py(); - set_focus('dimension_id'); + handle_delete_item($id); } -if (isset($_GET['Delete'])) { - copy_from_py(); - handle_delete_item(); - set_focus('_code_id_edit'); -} -if (isset($_POST['AddItem'])) { - copy_to_py(); - handle_new_item(); - set_focus('_code_id_edit'); -} -if (isset($_POST['UpdateItem'])) { - copy_to_py(); - handle_update_item(); - set_focus('_code_id_edit'); +if (isset($_POST['AddItem']) || isset($_POST['UpdateItem'])) { + copy_to_py(); + line_start_focus(); } -if (isset($_POST['CancelItemChanges'])) - set_focus('_code_id_edit'); -if (isset($_POST['EditItem'])) - set_focus('dimension_id'); +if (isset($_POST['AddItem'])) + handle_new_item(); -//----------------------------------------------------------------------------------------------- +if (isset($_POST['UpdateItem'])) + handle_update_item(); -if (isset($_GET['NewPayment']) || !isset($_SESSION['pay_items'])) -{ - handle_new_order(); +if (isset($_POST['CancelItemChanges'])) { + line_start_focus(); } //----------------------------------------------------------------------------------------------- start_form(false, true); -display_order_header($_SESSION['pay_items']); +display_bank_header($_SESSION['pay_items']); start_table("$table_style2 width=90%", 10); start_row(); echo ""; -display_gl_items(_("Payment Items"), $_SESSION['pay_items']); +display_gl_items($_SESSION['pay_items']->trans_type==systypes::bank_payment() ? + _("Payment Items"):_("Deposit Items"), $_SESSION['pay_items']); gl_options_controls(); echo ""; end_row(); end_table(1); -if (!isset($_POST['Process'])) -{ - if ($_SESSION['pay_items']->count_gl_items() >= 1) - { - submit_center_first('Update', _("Update")); - submit_center_last('Process', _("Process Payment")); - } - else - submit_center('Update', _("Update")); -} +submit_center_first('Update', _("Update"), '', null); +submit_center_last('Process', $_SESSION['pay_items']->trans_type==systypes::bank_payment() ? + _("Process Payment"):_("Process Deposit"), '', true); end_form(); diff --git a/gl/gl_deposit.php b/gl/gl_deposit.php deleted file mode 100644 index cdc4910b..00000000 --- a/gl/gl_deposit.php +++ /dev/null @@ -1,274 +0,0 @@ -from_loc = $_POST['bank_account']; - $_SESSION['deposit_items']->tran_date = $_POST['date_']; - $_SESSION['deposit_items']->transfer_type = $_POST['type']; - $_SESSION['deposit_items']->increase = $_POST['PayType']; - if (!isset($_POST['person_id'])) - $_POST['person_id'] = ""; - $_SESSION['deposit_items']->person_id = $_POST['person_id']; - if (!isset($_POST['PersonDetailID'])) - $_POST['PersonDetailID'] = ""; - $_SESSION['deposit_items']->branch_id = $_POST['PersonDetailID']; - $_SESSION['deposit_items']->memo_ = $_POST['memo_']; -} - -//-------------------------------------------------------------------------------------------------- - -function copy_from_py() -{ - $_POST['bank_account'] = $_SESSION['deposit_items']->from_loc; - $_POST['date_'] = $_SESSION['deposit_items']->tran_date; - $_POST['type'] = $_SESSION['deposit_items']->transfer_type; - $_POST['PayType'] = $_SESSION['deposit_items']->increase; - $_POST['person_id'] = $_SESSION['deposit_items']->person_id; - $_POST['PersonDetailID'] = $_SESSION['deposit_items']->branch_id; - $_POST['memo_'] = $_SESSION['deposit_items']->memo_; -} - -//----------------------------------------------------------------------------------------------- - -function handle_new_order() -{ - if (isset($_SESSION['deposit_items'])) - { - $_SESSION['deposit_items']->clear_items(); - unset ($_SESSION['deposit_items']); - } - - session_register("deposit_items"); - - $_SESSION['deposit_items'] = new items_cart; - $_POST['date_'] = Today(); - if (!is_date_in_fiscalyear($_POST['date_'])) - $_POST['date_'] = end_fiscalyear(); - $_SESSION['deposit_items']->tran_date = $_POST['date_']; -} - -//----------------------------------------------------------------------------------------------- - -if (isset($_POST['Process'])) -{ - - $input_error = 0; - - if (!references::is_valid($_POST['ref'])) - { - display_error( _("You must enter a reference.")); - set_focus('ref'); - $input_error = 1; - } - elseif (!is_new_reference($_POST['ref'], systypes::bank_deposit())) - { - display_error( _("The entered reference is already in use.")); - set_focus('ref'); - $input_error = 1; - } - - if (!is_date($_POST['date_'])) - { - display_error(_("The entered date for the deposit is invalid.")); - set_focus('date_'); - $input_error = 1; - } - - if (!is_date_in_fiscalyear($_POST['date_'])) - { - display_error(_("The entered date is not in fiscal year.")); - set_focus('date_'); - $input_error = 1; - } - - if ($input_error == 1) - unset($_POST['Process']); -} - -//----------------------------------------------------------------------------------------------- - -if (isset($_POST['Process'])) -{ - - $trans = add_bank_deposit($_POST['bank_account'], - $_SESSION['deposit_items'], $_POST['date_'], - $_POST['PayType'], $_POST['person_id'], $_POST['PersonDetailID'], - $_POST['type'], $_POST['ref'], $_POST['memo_']); - - $trans_type = $trans[0]; - $trans_no = $trans[1]; - - $_SESSION['deposit_items']->clear_items(); - unset($_SESSION['deposit_items']); - - meta_forward($_SERVER['PHP_SELF'], "AddedID=$trans_no"); - -} /*end of process credit note */ - -//----------------------------------------------------------------------------------------------- - -function check_item_data() -{ - if (!check_num('amount', 0)) - { - display_error( _("The amount entered is not a valid number or is less than zero.")); - set_focus('amount'); - return false; - } - - if ($_POST['code_id'] == $_POST['bank_account']) - { - display_error( _("The source and destination accouts cannot be the same.")); - set_focus('code_id'); - return false; - } - - if (is_bank_account($_POST['code_id'])) - { - display_error( _("You cannot make a deposit from a bank account. Please use the transfer funds facility for this.")); - set_focus('code_id'); - return false; - } - - return true; -} - -//----------------------------------------------------------------------------------------------- - -function handle_update_item() -{ - if($_POST['UpdateItem'] != "" && check_item_data()) - { - $_SESSION['deposit_items']->update_gl_item($_POST['Index'], $_POST['dimension_id'], - $_POST['dimension2_id'], -input_num('amount'), $_POST['LineMemo']); - } -} - -//----------------------------------------------------------------------------------------------- - -function handle_delete_item() -{ - $_SESSION['deposit_items']->remove_gl_item($_GET['Delete']); -} - -//----------------------------------------------------------------------------------------------- - -function handle_new_item() -{ - if (!check_item_data()) - return; - - $_SESSION['deposit_items']->add_gl_item($_POST['code_id'], $_POST['dimension_id'], - $_POST['dimension2_id'], -input_num('amount'), $_POST['LineMemo']); -} - -//----------------------------------------------------------------------------------------------- -if (isset($_GET['Edit'])) { - copy_from_py(); - set_focus('dimension_id'); -} -if (isset($_GET['Delete'])) { - copy_from_py(); - handle_delete_item(); - set_focus('_code_id_edit'); -} -if (isset($_POST['AddItem'])) { - copy_to_py(); - handle_new_item(); - set_focus('_code_id_edit'); -} -if (isset($_POST['UpdateItem'])) { - copy_to_py(); - 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'); - -//----------------------------------------------------------------------------------------------- - -if (isset($_GET['NewDeposit']) || !isset($_SESSION['deposit_items'])) -{ - handle_new_order(); -} - -//----------------------------------------------------------------------------------------------- - -start_form(false, true); - -display_order_header($_SESSION['deposit_items']); - -start_table("$table_style width=90%", 10); -start_row(); -echo ""; -display_gl_items(_("Deposit Items"), $_SESSION['deposit_items']); -gl_options_controls(); -echo ""; -end_row(); -end_table(1); - -if (!isset($_POST['Process'])) -{ - if ($_SESSION['deposit_items']->count_gl_items() >= 1) - { - submit_center_first('Update', _("Update")); - submit_center_last('Process', _("Process Deposit")); - } - else - submit_center('Update', _("Update")); -} - -end_form(); - -//------------------------------------------------------------------------------------------------ - -end_page(); - -?> diff --git a/gl/gl_journal.php b/gl/gl_journal.php index 1e820f5f..9d42cdad 100644 --- a/gl/gl_journal.php +++ b/gl/gl_journal.php @@ -67,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_'])) diff --git a/gl/includes/db/gl_db_banking.inc b/gl/includes/db/gl_db_banking.inc index 4711baba..a5fe71ad 100644 --- a/gl/includes/db/gl_db_banking.inc +++ b/gl/includes/db/gl_db_banking.inc @@ -137,23 +137,4 @@ function add_bank_transaction($trans_type, $from_account, $items, $date_, //---------------------------------------------------------------------------------------- -function add_bank_payment($from_account, $items, $date_, - $person_type_id, $person_id, $person_detail_id, $type, $ref, $memo_) -{ - return add_bank_transaction(systypes::bank_payment(), $from_account, $items, $date_, - $person_type_id, $person_id, $person_detail_id, $type, $ref, $memo_); -} - -//--------------------------------------------------------------------------------------------- - -function add_bank_deposit($from_account, $items, $date_, - $person_type_id, $person_id, $person_detail_id, $type, $ref, $memo_) -{ - return add_bank_transaction(systypes::bank_deposit(), $from_account, $items, $date_, - $person_type_id, $person_id, $person_detail_id, $type, $ref, $memo_); -} - -//--------------------------------------------------------------------------------------------- - - ?> \ No newline at end of file diff --git a/gl/includes/ui/gl_payment_ui.inc b/gl/includes/ui/gl_bank_ui.inc similarity index 69% rename from gl/includes/ui/gl_payment_ui.inc rename to gl/includes/ui/gl_bank_ui.inc index 0f3b0aa4..7e8c9375 100644 --- a/gl/includes/ui/gl_payment_ui.inc +++ b/gl/includes/ui/gl_bank_ui.inc @@ -1,19 +1,17 @@ trans_type == systypes::bank_payment(); + + div_start('pmt_header'); start_table("width=90% $table_style2"); // outer table echo ""; echo ""; // inner table - bank_accounts_list_row(_("From:"), 'bank_account', null, true); + bank_accounts_list_row( $payment ? _("From:") : _("To:"), 'bank_account', null, true); date_row(_("Date:"), 'date_'); @@ -37,12 +35,18 @@ function display_order_header(&$order) else $_POST['person_id'] = ""; } - payment_person_types_list_row(_("Pay To:"), 'PayType', $_POST['PayType'], 'person_id'); - + if (isset($_POST['_PayType_update'])) { + $_POST['person_id'] = ''; + $Ajax->activate('pmt_header'); + $Ajax->activate('code_id'); + } + payment_person_types_list_row( $payment ? _("Pay To:"):_("From:"), + 'PayType', $_POST['PayType'], true); switch ($_POST['PayType']) { case payment_person_types::misc() : - text_row_ex(_("To the Order of:"), 'person_id', 40, 50); + text_row_ex($payment ?_("To the Order of:"):_("Name:"), + 'person_id', 40, 50); break; case payment_person_types::WorkOrder() : workorders_list_row(_("Work Order:"), 'person_id', null); @@ -59,7 +63,8 @@ function display_order_header(&$order) } else { - hidden('BranchID', reserved_words::get_any_numeric()); + $_POST['PersonDetailID'] = reserved_words::get_any_numeric(); + hidden('PersonDetailID'); } break; //case payment_person_types::Project() : @@ -75,14 +80,14 @@ function display_order_header(&$order) { exchange_rate_display($bank_currency, $person_currency, $_POST['date_']); } - + echo "
"; // inner table echo ""; echo ""; // inner table - bank_trans_types_list_row(_("Payment Type:"), 'type', null); + bank_trans_types_list_row(_("Type:"), 'type', null); ref_row(_("Reference:"), 'ref', '', references::get_next(systypes::bank_payment())); @@ -91,8 +96,8 @@ function display_order_header(&$order) echo ""; end_table(1); // outer table + div_end(); } - //--------------------------------------------------------------------------------- function display_gl_items($title, &$order) @@ -103,6 +108,7 @@ function display_gl_items($title, &$order) $colspan = ($dim == 2 ? 4 : ($dim == 1 ? 3 : 2)); display_heading($title); + div_start('items_table'); start_table("$table_style colspan=7 width=95%"); if ($dim == 2) @@ -120,9 +126,10 @@ function display_gl_items($title, &$order) table_header($th); $k = 0; //row colour counter + $id = find_submit('Edit'); foreach ($order->gl_items as $item) { - if (!isset($_GET['Edit']) || $_GET['Edit'] != $item->index) + if ($id != $item->index) { alt_table_row_color($k); @@ -132,11 +139,13 @@ function display_gl_items($title, &$order) label_cell(get_dimension_string($item->dimension_id, true)); if ($dim > 1) label_cell(get_dimension_string($item->dimension2_id, true)); - amount_cell($item->amount); + amount_cell(abs($item->amount)); label_cell($item->reference); - edit_link_cell("Edit=$item->index"); - delete_link_cell("Delete=$item->index"); + edit_button_cell("Edit$item->index", _("Edit"), + _('Edit document line')); + edit_button_cell("Delete$item->index", _("Delete"), + _('Remove line from document')); end_row(); } else @@ -145,44 +154,44 @@ function display_gl_items($title, &$order) } } - if (!isset($_GET['Edit'])) + if ($id == -1) gl_edit_item_controls($order, $dim); if ($order->count_gl_items()) label_row(_("Total"), number_format2(abs($order->gl_items_total()), user_price_dec()),"colspan=" . $colspan . " align=right", "align=right"); end_table(); + div_end(); } //--------------------------------------------------------------------------------- function gl_edit_item_controls(&$order, $dim, $Index=null) { - start_row(); + global $Ajax; + $payment = $order->trans_type == systypes::bank_payment(); - if (isset($_GET['Edit']) && $Index != null) + start_row(); + $id = find_submit('Edit'); + if ($Index != -1 && $Index == $id) { - if (!isset($_POST['code_id'])) - $_POST['code_id'] = $order->gl_items[$Index]->code_id; - if (!isset($_POST['dimension_id'])) - $_POST['dimension_id'] = $order->gl_items[$Index]->dimension_id; - if (!isset($_POST['dimension2_id'])) - $_POST['dimension2_id'] = $order->gl_items[$Index]->dimension2_id; - if (!isset($_POST['amount']) || ($_POST['amount'] == "")) - $_POST['amount'] = price_format($order->gl_items[$Index]->amount); - if (!isset($_POST['description']) || ($_POST['description'] == "")) - $_POST['description'] = $order->gl_items[$Index]->description; - if (!isset($_POST['LineMemo']) || ($_POST['LineMemo'] == "")) - $_POST['LineMemo'] = $order->gl_items[$Index]->reference; + $_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); label_cell($_POST['code_id']); label_cell($order->gl_items[$Index]->description); if ($dim >= 1) - dimensions_list_cells(null, 'dimension_id', $_POST['dimension_id'], true, " ", false, 1); + dimensions_list_cells(null, 'dimension_id', null, true, " ", false, 1); if ($dim > 1) - dimensions_list_cells(null, 'dimension2_id', $_POST['dimension2_id'], true, " ", false, 2); + dimensions_list_cells(null, 'dimension2_id', null, true, " ", false, 2); + $Ajax->activate('items_table'); } else { @@ -190,6 +199,9 @@ function gl_edit_item_controls(&$order, $dim, $Index=null) $_POST['dimension_id'] = 0; $_POST['dimension2_id'] = 0; $_POST['LineMemo'] = ""; + if(isset($_POST['_code_id_update'])) { + $Ajax->activate('code_id'); + } if ($_POST['PayType'] == payment_person_types::customer()) { @@ -203,8 +215,10 @@ function gl_edit_item_controls(&$order, $dim, $Index=null) } elseif ($_POST['PayType'] == payment_person_types::WorkOrder()) $_POST['code_id'] = get_company_pref('default_assembly_act'); - else - $_POST['code_id'] = get_company_pref('default_cogs_act'); + else { + $_POST['code_id'] = + get_company_pref($payment ? 'default_cogs_act':'default_inv_sales_act'); + } gl_all_accounts_list('code_id', null, true, false, true); if ($dim >= 1) dimensions_list_cells(null, 'dimension_id', null, true, " ", false, 1); @@ -219,13 +233,19 @@ function gl_edit_item_controls(&$order, $dim, $Index=null) amount_cells(null, 'amount'); text_cells_ex(null, 'LineMemo', 35, 50); - if (isset($_GET['Edit'])) + if ($id != -1) { - submit_cells('UpdateItem', _("Update")); - submit_cells('CancelItemChanges', _("Cancel")); + edit_button_cell('UpdateItem', _("Update"), + _('Confirm changes')); + edit_button_cell('CancelItemChanges', _("Cancel"), + _('Cancel changes')); + set_focus('amount'); } else - submit_cells('AddItem', _("Add Item"), "colspan=2"); + { + submit_cells('AddItem', _("Add Item"), "colspan=2", + _('Add new item to document'), true); + } end_row(); } diff --git a/manufacturing/search_work_orders.php b/manufacturing/search_work_orders.php index dd181343..11ebd0c7 100644 --- a/manufacturing/search_work_orders.php +++ b/manufacturing/search_work_orders.php @@ -156,7 +156,7 @@ while ($myrow = db_fetch($result)) { $issue = $path_to_root . "/manufacturing/work_order_issue.php?" . SID . "trans_no=" .$myrow["id"]; $add_finished = $path_to_root . "/manufacturing/work_order_add_finished.php?" . SID . "trans_no=" .$myrow["id"]; - $costs = $path_to_root . "/gl/gl_payment.php?NewPayment=1&PayType=" . payment_person_types::WorkOrder(). "&PayPerson=" .$myrow["id"]; + $costs = $path_to_root . "/gl/gl_bank.php?NewPayment=1&PayType=" . payment_person_types::WorkOrder(). "&PayPerson=" .$myrow["id"]; $l2 = "" . _("Issue") . ""; $l3 = "" . _("Produce") . ""; $l4 = "" . _("Costs") . ""; -- 2.30.2