From 0ad7b92c6cf2e4e65ca0fa94ba31f30f7b292ba8 Mon Sep 17 00:00:00 2001 From: Janusz Dobrowolski Date: Fri, 14 Mar 2008 20:17:56 +0000 Subject: [PATCH] Fixed numeric fields to accept user native number format. --- admin/gl_setup.php | 17 +- gl/bank_transfer.php | 11 +- gl/gl_budget.php | 12 +- gl/gl_deposit.php | 16 +- gl/gl_journal.php | 73 ++-- gl/gl_payment.php | 14 +- gl/includes/db/gl_db_banking.inc | 2 +- gl/includes/ui/gl_deposit_ui.inc | 4 +- gl/includes/ui/gl_journal_ui.inc | 15 +- gl/includes/ui/gl_payment_ui.inc | 7 +- gl/manage/exchange_rates.php | 22 +- inventory/adjustments.php | 18 +- inventory/cost_update.php | 29 +- inventory/includes/item_adjustments_ui.inc | 14 +- inventory/includes/stock_transfers_ui.inc | 10 +- inventory/manage/item_units.php | 2 +- inventory/prices.php | 12 +- inventory/purchasing_data.php | 23 +- inventory/reorder_level.php | 13 +- inventory/transfers.php | 8 +- manufacturing/inquiry/where_used_inquiry.php | 2 +- manufacturing/manage/bom_edit.php | 39 ++- manufacturing/work_order_entry.php | 48 +-- purchasing/allocations/supplier_allocate.php | 44 +-- purchasing/includes/ui/po_ui.inc | 18 +- purchasing/inquiry/po_search.php | 4 +- purchasing/po_entry_items.php | 24 +- purchasing/po_receive_items.php | 14 +- purchasing/supplier_credit_grns.php | 20 +- purchasing/supplier_invoice_grns.php | 31 +- purchasing/supplier_payment.php | 17 +- purchasing/supplier_trans_gl.php | 5 +- sales/allocations/customer_allocate.php | 27 +- sales/credit_note_entry.php | 31 +- sales/customer_credit_invoice.php | 35 +- sales/customer_delivery.php | 49 +-- sales/customer_invoice.php | 42 +-- sales/customer_payments.php | 14 +- sales/includes/ui/sales_credit_ui.inc | 33 +- sales/includes/ui/sales_order_ui.inc | 339 ++++++++++--------- sales/manage/customers.php | 59 ++-- sales/manage/sales_people.php | 20 +- sales/sales_order_entry.php | 32 +- sales/view/view_credit.php | 8 +- sales/view/view_dispatch.php | 8 +- sales/view/view_invoice.php | 8 +- sales/view/view_receipt.php | 4 +- sales/view/view_sales_order.php | 10 +- taxes/item_tax_types.php | 2 +- taxes/tax_groups.php | 12 +- taxes/tax_types.php | 19 +- 51 files changed, 626 insertions(+), 714 deletions(-) diff --git a/admin/gl_setup.php b/admin/gl_setup.php index 16188854..3af347c8 100644 --- a/admin/gl_setup.php +++ b/admin/gl_setup.php @@ -15,22 +15,19 @@ include_once($path_to_root . "/admin/db/company_db.inc"); function can_process() { - if (!is_numeric($_POST['po_over_receive']) || ($_POST['po_over_receive'] < 0) - || ($_POST['po_over_receive'] > 100)) + if (!check_num('po_over_receive', 0, 100)) { display_error(_("The delivery over-receive allowance must be between 0 and 100.")); return false; } - if (!is_numeric($_POST['po_over_charge']) || ($_POST['po_over_charge'] < 0) - || ($_POST['po_over_charge'] > 100)) + if (!check_num('po_over_charge', 0, 100)) { display_error(_("The invoice over-charge allowance must be between 0 and 100.")); return false; } - if (!is_numeric($_POST['past_due_days']) || ($_POST['past_due_days'] < 0) - || ($_POST['past_due_days'] > 100)) + if (!check_num('past_due_days', 0, 100)) { display_error(_("The past due days interval allowance must be between 0 and 100.")); return false; @@ -55,8 +52,8 @@ if (isset($_POST['submit']) && can_process()) $_POST['default_inv_sales_act'], $_POST['default_assembly_act'], $_POST['payroll_act'], check_value('allow_negative_stock'), - $_POST['po_over_receive'], - $_POST['po_over_charge'], + input_num('po_over_receive'), + input_num('po_over_charge'), $_POST['past_due_days'], $_POST['default_credit_limit'], $_POST['default_workorder_required'], @@ -96,8 +93,8 @@ $_POST['payroll_act'] = $myrow['payroll_act']; $_POST['allow_negative_stock'] = $myrow['allow_negative_stock']; -$_POST['po_over_receive'] = $myrow['po_over_receive']; -$_POST['po_over_charge'] = $myrow['po_over_charge']; +$_POST['po_over_receive'] = percent_format($myrow['po_over_receive']); +$_POST['po_over_charge'] = percent_format($myrow['po_over_charge']); $_POST['past_due_days'] = $myrow['past_due_days']; $_POST['default_credit_limit'] = $myrow['default_credit_limit']; diff --git a/gl/bank_transfer.php b/gl/bank_transfer.php index 2f5b1f1a..5f5a783b 100644 --- a/gl/bank_transfer.php +++ b/gl/bank_transfer.php @@ -104,14 +104,9 @@ function check_valid_entries() return false; } - if (!is_numeric($_POST['amount'])) + if (!check_num('amount', 0)) { - display_error(_("The entered amount is invalid.")); - return false; - } - if ($_POST['amount'] <= 0) - { - display_error(_("The entered amount must be a positive number.")); + display_error(_("The entered amount is invalid or less than zero.")); return false; } @@ -143,7 +138,7 @@ function handle_add_deposit() global $path_to_root; $trans_no = add_bank_transfer($_POST['FromBankAccount'], $_POST['ToBankAccount'], - $_POST['DatePaid'], $_POST['amount'], + $_POST['DatePaid'], input_num('amount'), $_POST['TransferType'], $_POST['ref'], $_POST['memo_']); meta_forward($_SERVER['PHP_SELF'], "AddedID=$trans_no"); diff --git a/gl/gl_budget.php b/gl/gl_budget.php index 988e6026..cda847c2 100644 --- a/gl/gl_budget.php +++ b/gl/gl_budget.php @@ -71,7 +71,7 @@ if (isset($_POST['add']) || isset($_POST['delete'])) for ($i = 0, $da = $_POST['begin']; date1_greater_date2($_POST['end'], $da); $i++) { if (isset($_POST['add'])) - add_update_gl_budget_trans($da, $_POST['account'], $_POST['dim1'], $_POST['dim2'], $_POST['amount'.$i]); + add_update_gl_budget_trans($da, $_POST['account'], $_POST['dim1'], $_POST['dim2'], input_num('amount'.$i)); else delete_gl_budget_trans($da, $_POST['account'], $_POST['dim1'], $_POST['dim2']); $da = add_months($da, 1); @@ -139,12 +139,12 @@ if (db_has_gl_accounts()) for ($i = 0, $date_ = $begin; date1_greater_date2($end, $date_); $i++) { start_row(); - $_POST['amount'.$i] = get_only_budget_trans_from_to($date_, $date_, $_POST['account'], $_POST['dim1'], $_POST['dim2']); + $_POST['amount'.$i] = number_format2(get_only_budget_trans_from_to($date_, $date_, $_POST['account'], $_POST['dim1'], $_POST['dim2']), 0); label_cell($date_); if (!isset($_POST['amount'.$i])) - $_POST['amount'.$i] = "0"; - text_cells(null, 'amount'.$i, null, 15); + $_POST['amount'.$i] = '0'; + amount_cells(null, 'amount'.$i, null, 15); if ($showdims) { $d = get_budget_trans_from_to($date_, $date_, $_POST['account'], $_POST['dim1'], $_POST['dim2']); @@ -152,7 +152,7 @@ if (db_has_gl_accounts()) $btotal += $d; } $lamount = get_gl_trans_from_to(add_years($date_, -1), add_years(end_month($date_), -1), $_POST['account'], $_POST['dim1'], $_POST['dim2']); - $total += $_POST['amount'.$i]; + $total += input_num('amount'.$i); $ltotal += $lamount; label_cell(number_format2($lamount, 0), "nowrap align=right"); $date_ = add_months($date_, 1); @@ -160,7 +160,7 @@ if (db_has_gl_accounts()) } start_row(); label_cell(""._("Total").""); - label_cell("".number_format2($total, 0).""); + label_cell("".number_format2($total, 0)."", 'align=right'); if ($showdims) label_cell("".number_format2($btotal, 0)."", "nowrap align=right"); label_cell("".number_format2($ltotal, 0)."", "nowrap align=right"); diff --git a/gl/gl_deposit.php b/gl/gl_deposit.php index fd4f98e5..a4b5f173 100644 --- a/gl/gl_deposit.php +++ b/gl/gl_deposit.php @@ -149,15 +149,9 @@ if (isset($_POST['Process'])) function check_item_data() { - if (!is_numeric($_POST['amount'])) + if (!check_num('amount', 0)) { - display_error( _("The amount entered is not a valid number.")); - return false; - } - - if ($_POST['amount'] <= 0) - { - display_error( _("The amount entered must be a postitive number.")); + display_error( _("The amount entered is not a valid number or is less than zero.")); return false; } @@ -182,7 +176,8 @@ function handle_update_item() { if($_POST['UpdateItem'] != "" && check_item_data()) { - $_SESSION['deposit_items']->update_gl_item($_POST['Index'], $_POST['dimension_id'], $_POST['dimension2_id'], -$_POST['amount'], $_POST['LineMemo']); + $_SESSION['deposit_items']->update_gl_item($_POST['Index'], $_POST['dimension_id'], + $_POST['dimension2_id'], -input_num('amount'), $_POST['LineMemo']); } } @@ -200,7 +195,8 @@ function handle_new_item() if (!check_item_data()) return; - $_SESSION['deposit_items']->add_gl_item($_POST['code_id'], $_POST['dimension_id'], $_POST['dimension2_id'], -$_POST['amount'], $_POST['LineMemo']); + $_SESSION['deposit_items']->add_gl_item($_POST['code_id'], $_POST['dimension_id'], + $_POST['dimension2_id'], -input_num('amount'), $_POST['LineMemo']); } //----------------------------------------------------------------------------------------------- diff --git a/gl/gl_journal.php b/gl/gl_journal.php index 2a027399..b5a2c1cc 100644 --- a/gl/gl_journal.php +++ b/gl/gl_journal.php @@ -136,50 +136,22 @@ function check_item_data() return false; } - if (strlen($_POST['AmountDebit']) && strlen($_POST['AmountCredit'])) - { - display_error(_("You cannot enter both a debit amount and a credit amount.")); - return false; - } - - if ((!isset($_POST['AmountDebit']) && !isset($_POST['AmountCredit'])) - || ($_POST['AmountDebit'] == "" && $_POST['AmountCredit'] == "")) + if (!(!strlen($_POST['AmountDebit']) ^ !strlen($_POST['AmountCredit']))) { display_error(_("You must enter either a debit amount or a credit amount.")); - return false; - } - - if (isset($_POST['AmountDebit']) && $_POST['AmountDebit'] != "") - { - - if (!is_numeric($_POST['AmountDebit'])) - { - display_error(_("The debit amount entered is not a valid number.")); return false; - } + } - if ($_POST['AmountDebit'] <= 0) - { - display_error(_("The debit amount entered cannot be zero or negative.")); + if (strlen($_POST['AmountDebit']) && !check_num('AmountDebit', 0)) + { + display_error(_("The debit amount entered is not a valid number or is less than zero.")); return false; - } - } - - if (isset($_POST['AmountCredit']) && $_POST['AmountCredit'] != "") + } elseif (strlen($_POST['AmountCredit']) && !check_num('AmountCredit', 0)) { - - if (!is_numeric($_POST['AmountCredit'])) - { - display_error(_("The credit amount entered is not a valid number.")); + display_error(_("The credit amount entered is not a valid number or is less than zero.")); return false; - } + } - if ($_POST['AmountCredit'] <= 0) - { - display_error(_("The credit amount entered cannot be zero or negative.")); - return false; - } - } if ($_SESSION["wa_current_user"]->access != 2 && is_bank_account($_POST['code_id'])) { @@ -196,10 +168,10 @@ function handle_update_item() { if($_POST['UpdateItem'] != "" && check_item_data()) { - if ($_POST['AmountDebit'] > 0) - $amount = $_POST['AmountDebit']; + if (input_num('AmountDebit') > 0) + $amount = input_num('AmountDebit'); else - $amount = -$_POST['AmountCredit']; + $amount = -input_num('AmountCredit'); $_SESSION['journal_items']->update_gl_item($_POST['Index'], $_POST['dimension_id'], $_POST['dimension2_id'], $amount, $_POST['LineMemo']); @@ -220,10 +192,10 @@ function handle_new_item() if (!check_item_data()) return; - if ($_POST['AmountDebit'] > 0) - $amount = $_POST['AmountDebit']; + if (input_num('AmountDebit') > 0) + $amount = input_num('AmountDebit'); else - $amount = -$_POST['AmountCredit']; + $amount = -input_num('AmountCredit'); $_SESSION['journal_items']->add_gl_item($_POST['code_id'], $_POST['dimension_id'], $_POST['dimension2_id'], $amount, $_POST['LineMemo']); @@ -268,17 +240,14 @@ echo ""; end_row(); end_table(1); -if (!isset($_POST['Process'])) +if ($_SESSION['journal_items']->count_gl_items() >= 1 && + abs($_SESSION['journal_items']->gl_items_total()) < 0.0001) { - if ($_SESSION['journal_items']->count_gl_items() >= 1 && - abs($_SESSION['journal_items']->gl_items_total()) < 0.0001) - { - submit_center('Process', _("Process Journal Entry")); - } - else - { - display_note(_("The journal must balance (debits equal to credits) before it can be processed."), 0, 1); - } + submit_center('Process', _("Process Journal Entry")); +} +else +{ + display_note(_("The journal must balance (debits equal to credits) before it can be processed."), 0, 1); } end_form(); diff --git a/gl/gl_payment.php b/gl/gl_payment.php index c1771cdf..69650682 100644 --- a/gl/gl_payment.php +++ b/gl/gl_payment.php @@ -146,15 +146,9 @@ if (isset($_POST['Process'])) function check_item_data() { - if (!is_numeric($_POST['amount'])) + if (!check_num('amount', 0)) { - display_error( _("The amount entered is not a valid number.")); - return false; - } - - if ($_POST['amount'] <= 0) - { - display_error( _("The amount entered must be a postitive number.")); + display_error( _("The amount entered is not a valid number or is less than zero.")); return false; } @@ -180,7 +174,7 @@ function handle_update_item() if($_POST['UpdateItem'] != "" && check_item_data()) { $_SESSION['pay_items']->update_gl_item($_POST['Index'], $_POST['dimension_id'], - $_POST['dimension2_id'], $_POST['amount'], $_POST['LineMemo']); + $_POST['dimension2_id'], input_num('amount'), $_POST['LineMemo']); } } @@ -199,7 +193,7 @@ function handle_new_item() return; $_SESSION['pay_items']->add_gl_item($_POST['code_id'], $_POST['dimension_id'], - $_POST['dimension2_id'], $_POST['amount'], $_POST['LineMemo']); + $_POST['dimension2_id'], input_num('amount'), $_POST['LineMemo']); } //----------------------------------------------------------------------------------------------- diff --git a/gl/includes/db/gl_db_banking.inc b/gl/includes/db/gl_db_banking.inc index dc86c0a4..46c81faf 100644 --- a/gl/includes/db/gl_db_banking.inc +++ b/gl/includes/db/gl_db_banking.inc @@ -68,7 +68,7 @@ function add_bank_transaction($trans_type, $from_account, $items, $date_, // convert to customer currency $cust_amount = exchange_from_to($total_amount, $currency, get_customer_currency($person_id), $date_); - $trans_no = add_customer_trans($trans_type, $person_id, $person_detail_id, $date_, + $trans_no = write_customer_trans($trans_type, 0, $person_id, $person_detail_id, $date_, $ref, $cust_amount); } diff --git a/gl/includes/ui/gl_deposit_ui.inc b/gl/includes/ui/gl_deposit_ui.inc index 3f65b68c..e1dece6b 100644 --- a/gl/includes/ui/gl_deposit_ui.inc +++ b/gl/includes/ui/gl_deposit_ui.inc @@ -166,7 +166,7 @@ function gl_edit_item_controls(&$order, $dim, $Index=null) if (!isset($_POST['dimension2_id'])) $_POST['dimension2_id'] = $order->gl_items[$Index]->dimension2_id; if (!isset($_POST['amount']) || ($_POST['amount'] == "")) - $_POST['amount'] = -$order->gl_items[$Index]->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'] == "")) @@ -184,7 +184,7 @@ function gl_edit_item_controls(&$order, $dim, $Index=null) } else { - $_POST['amount'] = 0; + $_POST['amount'] = price_format(0); $_POST['dimension_id'] = 0; $_POST['dimension2_id'] = 0; $_POST['LineMemo'] = ""; diff --git a/gl/includes/ui/gl_journal_ui.inc b/gl/includes/ui/gl_journal_ui.inc index 1b3c232f..046430ca 100644 --- a/gl/includes/ui/gl_journal_ui.inc +++ b/gl/includes/ui/gl_journal_ui.inc @@ -52,6 +52,9 @@ function display_gl_items($title, &$order) else $th = array(_("Account Code"), _("Account Description"), _("Debit"), _("Credit"), _("Memo")); + + if (count($order->gl_items)) $th[] = ''; + table_header($th); $k = 0; @@ -121,10 +124,10 @@ function gl_edit_item_controls(&$order, $dim, $Index=null) $_POST['dimension2_id'] = $item->dimension2_id; if ((!isset($_POST['AmountDebit']) || ($_POST['AmountDebit']=="")) && $item->amount > 0) - $_POST['AmountDebit'] = $item->amount; + $_POST['AmountDebit'] = price_format($item->amount); if ((!isset($_POST['AmountCredit']) || ($_POST['AmountCredit']=="")) && $item->amount <= 0) - $_POST['AmountCredit'] = abs($item->amount); + $_POST['AmountCredit'] = price_format(abs($item->amount)); if (!isset($_POST['description']) || ($_POST['description'] == "")) $_POST['description'] = $item->description; @@ -142,8 +145,8 @@ function gl_edit_item_controls(&$order, $dim, $Index=null) } else { - $_POST['AmountDebit'] = 0; - $_POST['AmountCredit'] = 0; + $_POST['AmountDebit'] = ''; //price_format(0); + $_POST['AmountCredit'] = ''; //price_format(0); $_POST['dimension_id'] = 0; $_POST['dimension2_id'] = 0; $_POST['LineMemo'] = ""; @@ -163,8 +166,8 @@ function gl_edit_item_controls(&$order, $dim, $Index=null) if ($dim < 2) hidden('dimension2_id', 0); - amount_cells(null, 'AmountDebit'); - amount_cells(null, 'AmountCredit'); + small_amount_cells(null, 'AmountDebit'); + small_amount_cells(null, 'AmountCredit'); text_cells_ex(null, 'LineMemo', 35, 50); if (isset($_GET['Edit'])) diff --git a/gl/includes/ui/gl_payment_ui.inc b/gl/includes/ui/gl_payment_ui.inc index 13fc5c6b..c355b92f 100644 --- a/gl/includes/ui/gl_payment_ui.inc +++ b/gl/includes/ui/gl_payment_ui.inc @@ -114,6 +114,9 @@ function display_gl_items($title, &$order) else $th = array(_("Account Code"), _("Account Description"), _("Amount"), _("Memo")); + + if (count($order->gl_items)) $th[] = ''; + table_header($th); $k = 0; //row colour counter @@ -166,7 +169,7 @@ function gl_edit_item_controls(&$order, $dim, $Index=null) if (!isset($_POST['dimension2_id'])) $_POST['dimension2_id'] = $order->gl_items[$Index]->dimension2_id; if (!isset($_POST['amount']) || ($_POST['amount'] == "")) - $_POST['amount'] = $order->gl_items[$Index]->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'] == "")) @@ -183,7 +186,7 @@ function gl_edit_item_controls(&$order, $dim, $Index=null) } else { - $_POST['amount'] = 0; + $_POST['amount'] = price_format(0); $_POST['dimension_id'] = 0; $_POST['dimension2_id'] = 0; $_POST['LineMemo'] = ""; diff --git a/gl/manage/exchange_rates.php b/gl/manage/exchange_rates.php index 52798c88..deeb49b3 100644 --- a/gl/manage/exchange_rates.php +++ b/gl/manage/exchange_rates.php @@ -26,7 +26,6 @@ elseif (isset($_POST['selected_id'])) else $selected_id = ""; //--------------------------------------------------------------------------------------------- - function check_data() { if (!is_date($_POST['date_'])) @@ -34,9 +33,9 @@ function check_data() display_error( _("The entered date is invalid.")); return false; } - if (!is_numeric($_POST['BuyRate'])) + if (!check_num('BuyRate', 0)) { - display_error( _("The exchange rate must be numeric.")); + display_error( _("The exchange rate must be numeric and greater than zero.")); return false; } if ($_POST['BuyRate'] <= 0) @@ -60,14 +59,14 @@ function handle_submit() if ($selected_id != "") { - update_exchange_rate($_POST['curr_abrev'], $_POST['date_'], $_POST['BuyRate'], - $_POST['BuyRate']); + update_exchange_rate($_POST['curr_abrev'], $_POST['date_'], + input_num('BuyRate'), input_num('BuyRate')); } else { - add_exchange_rate($_POST['curr_abrev'], $_POST['date_'], $_POST['BuyRate'], - $_POST['BuyRate']); + add_exchange_rate($_POST['curr_abrev'], $_POST['date_'], + input_num('BuyRate'), input_num('BuyRate')); } return true; @@ -128,17 +127,16 @@ function display_rate_edit() if (isset($_POST['get_rate'])) { - $_POST['BuyRate'] = get_ecb_rate($_POST['curr_abrev']); - $_POST['BuyRate'] = number_format($_POST['BuyRate'], user_exrate_dec()); + $_POST['BuyRate'] = exrate_format(get_ecb_rate($_POST['curr_abrev'])); } if ($selected_id != "") { - //editing an existing payment terms + //editing an existing exchange rate $myrow = get_exchange_rate($selected_id); $_POST['date_'] = sql2date($myrow["date_"]); - $_POST['BuyRate'] = $myrow["rate_buy"]; + $_POST['BuyRate'] = exrate_format($myrow["rate_buy"]); hidden('selected_id', $selected_id); hidden('date_', $_POST['date_']); @@ -150,7 +148,7 @@ function display_rate_edit() { date_row(_("Date to Use From:"), 'date_'); } - text_row(_("Exchange Rate:"), 'BuyRate', null, 15, 12, "", submit('get_rate',_("Get"), false)); + small_amount_row(_("Exchange Rate:"), 'BuyRate', null, '', submit('get_rate',_("Get"), false)); end_table(1); diff --git a/inventory/adjustments.php b/inventory/adjustments.php index e2a79384..a70d2d54 100644 --- a/inventory/adjustments.php +++ b/inventory/adjustments.php @@ -136,19 +136,13 @@ if (isset($_POST['Process']) && can_process()){ function check_item_data() { - if (!is_numeric($_POST['qty'])) + if (!check_num('qty',0)) { - display_error(_("The quantity entered is not a valid number.")); + display_error(_("The quantity entered is negative or invalid.")); return false; } - if ($_POST['qty'] <= 0) - { - display_error(_("The quantity entered must be greater than zero.")); - return false; - } - - if (!is_numeric($_POST['std_cost']) || $_POST['std_cost'] < 0) + if (!check_num('std_cost', 0)) { display_error(_("The entered standard cost is negative or invalid.")); return false; @@ -163,7 +157,8 @@ function handle_update_item() { if($_POST['UpdateItem'] != "" && check_item_data()) { - $_SESSION['adj_items']->update_cart_item($_POST['stock_id'], $_POST['qty'], $_POST['std_cost']); + $_SESSION['adj_items']->update_cart_item($_POST['stock_id'], + input_num('qty'), input_num('std_cost')); } } @@ -181,7 +176,8 @@ function handle_new_item() if (!check_item_data()) return; - add_to_order($_SESSION['adj_items'], $_POST['stock_id'], $_POST['qty'], $_POST['std_cost']); + add_to_order($_SESSION['adj_items'], $_POST['stock_id'], + input_num('qty'), input_num('std_cost')); } //----------------------------------------------------------------------------------------------- diff --git a/inventory/cost_update.php b/inventory/cost_update.php index 6b6c5950..39216039 100644 --- a/inventory/cost_update.php +++ b/inventory/cost_update.php @@ -30,13 +30,15 @@ if (isset($_GET['stock_id'])) if (isset($_POST['UpdateData'])) { - $old_cost = $_POST['OldMaterialCost'] + $_POST['OldLabourCost'] + $_POST['OldOverheadCost']; - $new_cost = $_POST['material_cost'] + $_POST['labour_cost'] + $_POST['overhead_cost']; + $old_cost = input_num('OldMaterialCost') + input_num('OldLabourCost') + + input_num('OldOverheadCost'); + $new_cost = input_num('material_cost') + input_num('labour_cost') + + input_num('overhead_cost'); $should_update = true; - if (!is_numeric($_POST['material_cost']) || !is_numeric($_POST['labour_cost']) || - !is_numeric($_POST['overhead_cost'])) + if (!check_num('material_cost') || !check_num('labour_cost') || + !check_num('overhead_cost')) { display_error( _("The entered cost is not numeric.")); $should_update = false; @@ -49,8 +51,9 @@ if (isset($_POST['UpdateData'])) if ($should_update) { - $update_no = stock_cost_update($_POST['stock_id'], $_POST['material_cost'], - $_POST['labour_cost'], $_POST['overhead_cost'], $old_cost); + $update_no = stock_cost_update($_POST['stock_id'], + input_num('material_cost'), input_num('labour_cost'), + input_num('overhead_cost'), $old_cost); display_note(_("Cost has been updated.")); @@ -89,18 +92,18 @@ hidden("OldLabourCost", $myrow["labour_cost"]); hidden("OldOverheadCost", $myrow["overhead_cost"]); start_table($table_style2); -label_row(_("Last Cost"), number_format2($myrow["last_cost"],user_price_dec()), +label_row(_("Last Cost"), price_format($myrow["last_cost"]), "class='tableheader2'", "nowrap align=right"); -text_row(_("Standard Material Cost Per Unit"), "material_cost", - number_format($myrow["material_cost"],user_price_dec()), "", "", "class='tableheader2'"); +amount_row(_("Standard Material Cost Per Unit"), "material_cost", + price_format($myrow["material_cost"]), "", "", "class='tableheader2'"); if ($myrow["mb_flag"]=='M') { - text_row(_("Standard Labour Cost Per Unit"), "labour_cost", - number_format($myrow["labour_cost"],user_price_dec()), "", "", "class='tableheader2'"); - text_row(_("Standard Overhead Cost Per Unit"), "overhead_cost", - number_format($myrow["overhead_cost"],user_price_dec()), "", "", "class='tableheader2'"); + amount_row(_("Standard Labour Cost Per Unit"), "labour_cost", + price_format($myrow["labour_cost"]), '', "", "class='tableheader2'"); + amount_row(_("Standard Overhead Cost Per Unit"), "overhead_cost", + price_format($myrow["overhead_cost"]), "", "", "class='tableheader2'"); } else { diff --git a/inventory/includes/item_adjustments_ui.inc b/inventory/includes/item_adjustments_ui.inc index ce8762f1..bf88c7da 100644 --- a/inventory/includes/item_adjustments_ui.inc +++ b/inventory/includes/item_adjustments_ui.inc @@ -73,6 +73,8 @@ function display_adjustment_items($title, &$order) start_table("$table_style width=80%"); $th = array(_("Item Code"), _("Item Description"), _("Quantity"), _("Unit"), _("Unit Cost"), _("Total")); + if ( count($order->line_items)) $th[] = ''; + table_header($th); $total = 0; $k = 0; //row colour counter @@ -124,9 +126,9 @@ function adjustment_edit_item_controls(&$order, $stock_id=null) if (!isset($_POST['stock_id'])) $_POST['stock_id'] = $order->line_items[$stock_id]->stock_id; if (!isset($_POST['qty']) OR ($_POST['qty']=="")) - $_POST['qty'] = $order->line_items[$stock_id]->quantity; + $_POST['qty'] = qty_format($order->line_items[$stock_id]->quantity); if (!isset($_POST['std_cost']) OR ($_POST['std_cost']=="")) - $_POST['std_cost'] = $order->line_items[$stock_id]->standard_cost; + $_POST['std_cost'] = price_format($order->line_items[$stock_id]->standard_cost); $_POST['units'] = $order->line_items[$stock_id]->units; @@ -142,15 +144,15 @@ function adjustment_edit_item_controls(&$order, $stock_id=null) $item_info = get_item_edit_info($_POST['stock_id']); - $_POST['qty'] = 0; - $_POST['std_cost'] = $item_info["standard_cost"]; + $_POST['qty'] = qty_format(0); + $_POST['std_cost'] = price_format($item_info["standard_cost"]); $_POST['units'] = $item_info["units"]; } - text_cells(null, 'qty', $_POST['qty'], 13, 15); + amount_cells(null, 'qty', $_POST['qty']); label_cell($_POST['units']); - text_cells(null, 'std_cost', $_POST['std_cost'], 15, 14); + amount_cells(null, 'std_cost', $_POST['std_cost']); label_cell(" "); if (isset($_GET['Edit'])) diff --git a/inventory/includes/stock_transfers_ui.inc b/inventory/includes/stock_transfers_ui.inc index 05b7304f..c0395af4 100644 --- a/inventory/includes/stock_transfers_ui.inc +++ b/inventory/includes/stock_transfers_ui.inc @@ -67,7 +67,7 @@ function display_transfer_items($title, &$order) display_heading($title); start_table("$table_style width=80%"); - $th = array(_("Item Code"), _("Item Description"), _("Quantity"), _("Unit")); + $th = array(_("Item Code"), _("Item Description"), _("Quantity"), _("Unit"),''); table_header($th); $subtotal = 0; $k = 0; //row colour counter @@ -112,8 +112,8 @@ function transfer_edit_item_controls(&$order, $stock_id=null) { if (!isset($_POST['stock_id'])) $_POST['stock_id'] = $order->line_items[$stock_id]->stock_id; - if (!isset($_POST['qty']) || ($_POST['qty']=="")) - $_POST['qty'] = $order->line_items[$stock_id]->quantity; + if (!isset($_POST['qty']) || $_POST['qty'] == '') + $_POST['qty'] = qty_format($order->line_items[$stock_id]->quantity); $_POST['units'] = $order->line_items[$stock_id]->units; @@ -129,12 +129,12 @@ function transfer_edit_item_controls(&$order, $stock_id=null) $item_info = get_item_edit_info($_POST['stock_id']); - $_POST['qty'] = 0; + $_POST['qty'] = qty_format(0); $_POST['units'] = $item_info["units"]; } - text_cells(null, 'qty', $_POST['qty'], 13, 15); + small_amount_cells(null, 'qty', $_POST['qty']); label_cell($_POST['units']); if (isset($_GET['Edit'])) diff --git a/inventory/manage/item_units.php b/inventory/manage/item_units.php index 0df22f8e..76af07d9 100644 --- a/inventory/manage/item_units.php +++ b/inventory/manage/item_units.php @@ -121,7 +121,7 @@ if (isset($selected_id) && item_unit_used($selected_id)) { } else text_row(_("Unit Abbreviation:"), 'abbr', null, 20, 20); text_row(_("Descriptive Name:"), 'description', null, 40, 40); -text_row(_("Decimal Places:"), 'decimals', null, 40, 40); +text_row(_("Decimal Places:"), 'decimals', null, 3, 3); end_table(1); diff --git a/inventory/prices.php b/inventory/prices.php index 073289c6..06fab6d1 100644 --- a/inventory/prices.php +++ b/inventory/prices.php @@ -67,7 +67,7 @@ function clear_data() if (isset($_POST['updatePrice'])) { - if (!is_numeric($_POST['price']) || $_POST['price'] == "") + if (!check_num('price', 0)) { $input_error = 1; display_error( _("The price entered must be numeric.")); @@ -79,14 +79,16 @@ if (isset($_POST['updatePrice'])) if (isset($_POST['PriceID'])) { //editing an existing price - update_item_price($_POST['PriceID'], $_POST['sales_type_id'], $_POST['curr_abrev'], $_POST['price']); + update_item_price($_POST['PriceID'], $_POST['sales_type_id'], + $_POST['curr_abrev'], input_num('price')); $msg = _("This price has been updated."); } elseif ($input_error !=1) { - add_item_price($_POST['stock_id'], $_POST['sales_type_id'], $_POST['curr_abrev'], $_POST['price']); + add_item_price($_POST['stock_id'], $_POST['sales_type_id'], + $_POST['curr_abrev'], input_num('price')); display_note(_("The new price has been added.")); } @@ -148,7 +150,7 @@ if (isset($_GET['Edit'])) hidden('PriceID', $_GET['PriceID']); $_POST['curr_abrev'] = $myrow["curr_abrev"]; $_POST['sales_type_id'] = $myrow["sales_type_id"]; - $_POST['price'] = $myrow["price"]; + $_POST['price'] = price_format($myrow["price"]); } start_table($table_style2); @@ -157,7 +159,7 @@ currencies_list_row(_("Currency:"), 'curr_abrev', null); sales_types_list_row(_("Sales Type:"), 'sales_type_id', null); -text_row(_("Price:"), 'price', null, 10, 10); +small_amount_row(_("Price:"), 'price', null); end_table(1); diff --git a/inventory/purchasing_data.php b/inventory/purchasing_data.php index 8e2cb59d..51cd7fce 100644 --- a/inventory/purchasing_data.php +++ b/inventory/purchasing_data.php @@ -40,12 +40,12 @@ if ((isset($_POST['AddRecord']) || isset($_POST['UpdateRecord'])) && isset($supp $input_error = 1; display_error( _("There is no item selected.")); } - elseif (!is_numeric($_POST['price']) || $_POST['price']==0) + elseif (!check_num('price', 0)) { $input_error = 1; display_error( _("The price entered was not numeric.")); } - elseif (!is_numeric($_POST['conversion_factor'])) + elseif (!check_num('conversion_factor')) { $input_error = 1; display_error( _("The conversion factor entered was not numeric. The conversion factor is the number by which the price must be divided by to get the unit price in our unit of measure.")); @@ -58,8 +58,9 @@ if ((isset($_POST['AddRecord']) || isset($_POST['UpdateRecord'])) && isset($supp $sql = "INSERT INTO ".TB_PREF."purch_data (supplier_id, stock_id, price, suppliers_uom, conversion_factor, supplier_description) VALUES ("; - $sql .= "'$supplier_id', '" . $_POST['stock_id'] . "', " . $_POST['price'] . ", '" . $_POST['suppliers_uom'] . "', " . - $_POST['conversion_factor'] . ", '" . $_POST['supplier_description'] . "')"; + $sql .= "'$supplier_id', '" . $_POST['stock_id'] . "', " . + input_num('price') . ", '" . $_POST['suppliers_uom'] . "', " . + input_num('conversion_factor') . ", '" . $_POST['supplier_description'] . "')"; db_query($sql,"The supplier purchasing details could not be added"); display_notification(_("This supplier purchasing data has been added.")); @@ -67,9 +68,9 @@ if ((isset($_POST['AddRecord']) || isset($_POST['UpdateRecord'])) && isset($supp if (isset($_POST['UpdateRecord'])) { - $sql = "UPDATE ".TB_PREF."purch_data SET price=" . $_POST['price'] . ", + $sql = "UPDATE ".TB_PREF."purch_data SET price=" . input_num('price') . ", suppliers_uom='" . $_POST['suppliers_uom'] . "', - conversion_factor=" . $_POST['conversion_factor'] . ", + conversion_factor=" . input_num('conversion_factor') . ", supplier_description='" . $_POST['supplier_description'] . "' WHERE stock_id='" . $_POST['stock_id'] . "' AND supplier_id='$supplier_id'"; @@ -188,10 +189,10 @@ if (isset($_GET['Edit'])) $myrow = db_fetch($result); $supp_name = $myrow["supp_name"]; - $_POST['price'] = $myrow["price"]; + $_POST['price'] = price_format($myrow["price"]); $_POST['suppliers_uom'] = $myrow["suppliers_uom"]; $_POST['supplier_description'] = $myrow["supplier_description"]; - $_POST['conversion_factor'] = $myrow["conversion_factor"]; + $_POST['conversion_factor'] = exrate_format($myrow["conversion_factor"]); } echo "
"; @@ -207,14 +208,14 @@ else supplier_list_row(_("Supplier:"), 'supplier_id', null, false, true); $supplier_id = $_POST['supplier_id']; } -text_row(_("Price:"), 'price', null, 12, 12, "", get_supplier_currency($supplier_id)); +amount_row(_("Price:"), 'price', null,'', get_supplier_currency($supplier_id)); text_row(_("Suppliers Unit of Measure:"), 'suppliers_uom', null, 50, 51); if (!isset($_POST['conversion_factor']) || $_POST['conversion_factor'] == "") { - $_POST['conversion_factor'] = 1; + $_POST['conversion_factor'] = exrate_format(1); } -text_row(_("Conversion Factor (to our UOM):"), 'conversion_factor', $_POST['conversion_factor'], 12, 12); +amount_row(_("Conversion Factor (to our UOM):"), 'conversion_factor', exrate_format($_POST['conversion_factor'])); text_row(_("Supplier's Code or Description:"), 'supplier_description', null, 50, 51); end_table(1); diff --git a/inventory/reorder_level.php b/inventory/reorder_level.php index 980d04cf..3d92cebf 100644 --- a/inventory/reorder_level.php +++ b/inventory/reorder_level.php @@ -52,18 +52,21 @@ while ($myrow = db_fetch($result)) alt_table_row_color($k); - if (isset($_POST['UpdateData']) && is_numeric($_POST[$myrow["loc_code"]])) + if (isset($_POST['UpdateData']) && check_num($myrow["loc_code"])) { - $myrow["reorder_level"] = $_POST[$myrow["loc_code"]]; - set_reorder_level($_POST['stock_id'], $myrow["loc_code"], $_POST[$myrow["loc_code"]]); + $myrow["reorder_level"] = input_num($myrow["loc_code"]); + set_reorder_level($_POST['stock_id'], $myrow["loc_code"], input_num($myrow["loc_code"])); } $qoh = get_qoh_on_date($_POST['stock_id'], $myrow["loc_code"]); - + label_cell($myrow["location_name"]); + + $_POST[$myrow["loc_code"]] = qty_format($myrow["reorder_level"]); + label_cell(number_format2($qoh,user_qty_dec()), "nowrap align='right'"); - text_cells(null, $myrow["loc_code"], $myrow["reorder_level"], 10, 10); + amount_cells(null, $myrow["loc_code"]); end_row(); $j++; If ($j == 12) diff --git a/inventory/transfers.php b/inventory/transfers.php index 4b0339b2..78f86a7d 100644 --- a/inventory/transfers.php +++ b/inventory/transfers.php @@ -148,13 +148,13 @@ if (isset($_POST['Process'])) function check_item_data() { - if (!is_numeric($_POST['qty']) || ($_POST['qty'] == 0)) + if (!check_num('qty')) { display_error( _("The quantity entered is not a valid number.")); return false; } - if ($_POST['qty'] <= 0) + if (!check_num('qty', 0)) { display_error(_("The quantity entered must be a positive number.")); return false; @@ -171,7 +171,7 @@ function handle_update_item() { if (!isset($_POST['std_cost'])) $_POST['std_cost'] = $_SESSION['transfer_items']->line_items[$_POST['stock_id']]->standard_cost; - $_SESSION['transfer_items']->update_cart_item($_POST['stock_id'], $_POST['qty'], $_POST['std_cost']); + $_SESSION['transfer_items']->update_cart_item($_POST['stock_id'], input_num('qty'), $_POST['std_cost']); } } @@ -190,7 +190,7 @@ function handle_new_item() return; if (!isset($_POST['std_cost'])) $_POST['std_cost'] = 0; - add_to_order($_SESSION['transfer_items'], $_POST['stock_id'], $_POST['qty'], $_POST['std_cost']); + add_to_order($_SESSION['transfer_items'], $_POST['stock_id'], input_num('qty'), $_POST['std_cost']); } //----------------------------------------------------------------------------------------------- diff --git a/manufacturing/inquiry/where_used_inquiry.php b/manufacturing/inquiry/where_used_inquiry.php index 9304c197..a31adc8d 100644 --- a/manufacturing/inquiry/where_used_inquiry.php +++ b/manufacturing/inquiry/where_used_inquiry.php @@ -56,7 +56,7 @@ if (isset($_POST['stock_id'])) label_cell("" . $myrow["parent"]. " - " . $myrow["description"]. ""); label_cell($myrow["WorkCentreName"]); label_cell($myrow["location_name"]); - label_cell($myrow["quantity"]); + label_cell(qty_format($myrow["quantity"])); end_row(); $j++; diff --git a/manufacturing/manage/bom_edit.php b/manufacturing/manage/bom_edit.php index 6e30c497..cfb15ad1 100644 --- a/manufacturing/manage/bom_edit.php +++ b/manufacturing/manage/bom_edit.php @@ -102,7 +102,7 @@ function display_bom_items($selected_parent) label_cell($myrow["description"]); label_cell($myrow["location_name"]); label_cell($myrow["WorkCentreDescription"]); - label_cell($myrow["quantity"]); + label_cell(qty_format($myrow["quantity"])); label_cell($myrow["units"]); edit_link_cell(SID . "NewItem=$selected_parent&selected_component=" . $myrow["id"]); delete_link_cell(SID . "delete=" . $myrow["id"]. "&stock_id=" . $_POST['stock_id']); @@ -114,27 +114,20 @@ function display_bom_items($selected_parent) //-------------------------------------------------------------------------------------------------- -function on_submit($selected_parent, $selected_component) +function on_submit($selected_parent, $selected_component=null) { - if (!is_numeric($_POST['quantity'])) + if (!check_num('quantity', 0)) { - display_error(_("The quantity entered must be numeric.")); + display_error(_("The quantity entered must be numeric and greater than zero.")); return; } - if ($_POST['quantity'] <= 0) - { - display_error(_("The quantity entered must be greater than zero.")); - return; - } - - if (isset($selected_parent) && isset($selected_component)) { $sql = "UPDATE ".TB_PREF."bom SET workcentre_added='" . $_POST['workcentre_added'] . "', loc_code='" . $_POST['loc_code'] . "', - quantity= " . $_POST['quantity'] . " + quantity= " . input_num('quantity') . " WHERE parent='" . $selected_parent . "' AND id='" . $selected_component . "'"; check_db_error("Could not update this bom component", $sql); @@ -145,7 +138,9 @@ function on_submit($selected_parent, $selected_component) elseif (!isset($selected_component) && isset($selected_parent)) { - /*Selected component is null cos no item selected on first time round so must be adding a record must be Submitting new entries in the new component form */ + /*Selected component is null cos no item selected on first time round + so must be adding a record must be Submitting new entries in the new + component form */ //need to check not recursive bom component of itself! If (!check_for_recursive_bom($selected_parent, $_POST['component'])) @@ -162,7 +157,9 @@ function on_submit($selected_parent, $selected_component) if (db_num_rows($result) == 0) { $sql = "INSERT INTO ".TB_PREF."bom (parent, component, workcentre_added, loc_code, quantity) - VALUES ('$selected_parent', '" . $_POST['component'] . "', '" . $_POST['workcentre_added'] . "', '" . $_POST['loc_code'] . "', " . $_POST['quantity'] . ")"; + VALUES ('$selected_parent', '" . $_POST['component'] . "', '" + . $_POST['workcentre_added'] . "', '" . $_POST['loc_code'] . "', " + . input_num('quantity') . ")"; db_query($sql,"check failed"); @@ -210,10 +207,12 @@ end_form(); if (isset($_POST['stock_id'])) { //Parent Item selected so display bom or edit component $selected_parent = $_POST['stock_id']; - - if (isset($selected_parent) && isset($_POST['Submit'])) + if (isset($selected_parent) && isset($_POST['Submit'])) { + if(isset($selected_component)) on_submit($selected_parent, $selected_component); - + else + on_submit($selected_parent); + } //-------------------------------------------------------------------------------------- display_bom_items($selected_parent); @@ -241,7 +240,7 @@ if (isset($_POST['stock_id'])) $_POST['loc_code'] = $myrow["loc_code"]; $_POST['workcentre_added'] = $myrow["workcentre_added"]; - $_POST['quantity'] = $myrow["quantity"]; + $_POST['quantity'] = qty_format($myrow["quantity"]); hidden('selected_parent', $selected_parent); hidden('selected_component', $selected_component); @@ -267,9 +266,9 @@ if (isset($_POST['stock_id'])) if (!isset($_POST['quantity'])) { - $_POST['quantity'] = 1; + $_POST['quantity'] = qty_format(1); } - text_row(_("Quantity:"), 'quantity', $_POST['quantity'], 10, 18); + amount_row(_("Quantity:"), 'quantity', $_POST['quantity']); end_table(1); submit_center('Submit', _("Add/Update")); diff --git a/manufacturing/work_order_entry.php b/manufacturing/work_order_entry.php index 39fd25bf..4da03e6e 100644 --- a/manufacturing/work_order_entry.php +++ b/manufacturing/work_order_entry.php @@ -115,15 +115,9 @@ function can_process() } } - if (!is_numeric($_POST['quantity'])) + if (!check_num('quantity', 0)) { - display_error( _("The quantity entered must be numeric.")); - return false; - } - - if ($_POST['quantity'] <= 0) - { - display_error( _("The quantity entered must be a positive number greater than zero.")); + display_error( _("The quantity entered is invalid or less than zero.")); return false; } @@ -147,16 +141,10 @@ function can_process() } if ($_POST['Costs'] == "") - $_POST['Costs'] = 0; - if (!is_numeric($_POST['Costs'])) - { - display_error( _("The cost entered must be numeric.")); - return false; - } - - if ($_POST['Costs'] < 0) + $_POST['Costs'] = price_format(0); + if (!check_num('Costs', 0)) { - display_error( _("The cost entered cannot be negative.")); + display_error( _("The cost entered is invalid or less than zero.")); return false; } @@ -173,7 +161,7 @@ function can_process() if (has_stock_holding($bom_item["ResourceType"])) { - $quantity = $bom_item["quantity"] * $_POST['quantity']; + $quantity = $bom_item["quantity"] * input_num('quantity'); $qoh = get_qoh_on_date($bom_item["component"], $bom_item["loc_code"], $_POST['date_']); if (-$quantity + $qoh < 0) @@ -189,7 +177,7 @@ function can_process() { // if unassembling, check item to unassemble $qoh = get_qoh_on_date($_POST['stock_id'], $_POST['StockLocation'], $_POST['date_']); - if (-$_POST['quantity'] + $qoh < 0) + if (-input_num('quantity') + $qoh < 0) { display_error(_("The selected item cannot be unassembled because there is insufficient stock.")); return false; @@ -213,7 +201,7 @@ function can_process() { $myrow = get_work_order($selected_id, true); - if ($_POST['units_issued'] > $_POST['quantity']) + if ($_POST['units_issued'] > input_num('quantity')) { display_error(_("The quantity cannot be changed to be less than the quantity already manufactured for this order.")); return false; @@ -229,9 +217,9 @@ function can_process() if (isset($_POST['ADD_ITEM']) && can_process()) { - $id = add_work_order($_POST['wo_ref'], $_POST['StockLocation'], $_POST['quantity'], + $id = add_work_order($_POST['wo_ref'], $_POST['StockLocation'], input_num('quantity'), $_POST['stock_id'], $_POST['type'], $_POST['date_'], - $_POST['RequDate'], $_POST['Costs'], $_POST['memo_']); + $_POST['RequDate'], input_num('Costs'), $_POST['memo_']); meta_forward($_SERVER['PHP_SELF'], "AddedID=$id"); } @@ -241,7 +229,7 @@ if (isset($_POST['ADD_ITEM']) && can_process()) if (isset($_POST['UPDATE_ITEM']) && can_process()) { - update_work_order($selected_id, $_POST['StockLocation'], $_POST['quantity'], + update_work_order($selected_id, $_POST['StockLocation'], input_num('quantity'), $_POST['stock_id'], $_POST['date_'], $_POST['RequDate'], $_POST['memo_']); meta_forward($_SERVER['PHP_SELF'], "UpdatedID=$selected_id"); @@ -310,7 +298,7 @@ if (isset($selected_id)) } $_POST['wo_ref'] = $myrow["wo_ref"]; - $_POST['quantity'] = $myrow["units_reqd"]; + $_POST['quantity'] = qty_format($myrow["units_reqd"]); $_POST['StockLocation'] = $myrow["loc_code"]; $_POST['released'] = $myrow["released"]; $_POST['closed'] = $myrow["closed"]; @@ -321,7 +309,7 @@ if (isset($selected_id)) $_POST['released_date'] = sql2date($myrow["released_date"]); $_POST['memo_'] = ""; $_POST['units_issued'] = $myrow["units_issued"]; - $_POST['Costs'] = $myrow["Costs"]; + $_POST['Costs'] = price_format($myrow["Costs"]); $_POST['memo_'] = get_comments_string(systypes::work_order(), $selected_id); @@ -361,24 +349,24 @@ else } if (!isset($_POST['quantity'])) - $_POST['quantity'] = 1; + $_POST['quantity'] = qty_format(1); if ($_POST['type'] == wo_types::advanced()) { - text_row_ex(_("Quantity Required:"), 'quantity', 12); + amount_row(_("Quantity Required:"), 'quantity', 12); if ($_POST['released']) - label_row(_("Quantity Manufactured:"), $_POST['units_issued']); + label_row(_("Quantity Manufactured:"), qty_format($_POST['units_issued'])); date_row(_("Date") . ":", 'date_'); date_row(_("Date Required By") . ":", 'RequDate', null, sys_prefs::default_wo_required_by()); } else { - text_row_ex(_("Quantity:"), 'quantity', 12); + amount_row(_("Quantity:"), 'quantity', 12); date_row(_("Date") . ":", 'date_'); hidden('RequDate', ''); if (!isset($_POST['Costs'])) - $_POST['Costs'] = 0; + $_POST['Costs'] = price_format(0); amount_row(_("Total Additional Costs:"), 'Costs'); } diff --git a/purchasing/allocations/supplier_allocate.php b/purchasing/allocations/supplier_allocate.php index 7ef2b2aa..e749e0fe 100644 --- a/purchasing/allocations/supplier_allocate.php +++ b/purchasing/allocations/supplier_allocate.php @@ -15,6 +15,9 @@ include_once($path_to_root . "/sales/includes/sales_db.inc"); $js = ""; if ($use_popup_windows) $js .= get_js_open_window(900, 500); + +$js .= get_js_allocate(); + page(_("Allocate Supplier Payment or Credit Note"), false, false, "", $js); @@ -40,28 +43,22 @@ function check_data() for ($counter=0; $counter < $_POST["TotalNumberOfAllocs"]; $counter++) { - if (!is_numeric($_POST['amount' . $counter])) + if (!check_num('amount' . $counter, 0)) { - display_error(_("The entry for one or more amounts is invalid.")); - return false; - } - - if ($_POST['amount' . $counter] < 0) - { - display_error(_("The entry for an amount to allocate was negative. A positive allocation amount is expected.")); + display_error(_("The entry for one or more amounts is invalid or negative.")); return false; } /*Now check to see that the AllocAmt is no greater than the amount left to be allocated against the transaction under review */ - if ($_POST['amount' . $counter] > $_POST['un_allocated' . $counter]) + if (input_num('amount' . $counter) > $_POST['un_allocated' . $counter]) { //$_POST['amount' . $counter] = $_POST['un_allocated' . $counter]; } - $_SESSION['alloc']->allocs[$counter]->current_allocated = $_POST['amount' . $counter]; + $_SESSION['alloc']->allocs[$counter]->current_allocated = input_num('amount' . $counter); - $total_allocated += $_POST['amount' . $counter]; + $total_allocated += input_num('amount' . $counter); } if ($total_allocated + $_SESSION['alloc']->amount > sys_prefs::allocation_settled_allowance()) @@ -185,7 +182,7 @@ function edit_allocations_for_transaction($type, $trans_no) display_heading($_SESSION['alloc']->person_name); display_heading2(_("Date:") . " " . $_SESSION['alloc']->date_ . ""); - display_heading2(_("Total:") . " " . number_format2(-$_SESSION['alloc']->amount,user_price_dec()) . ""); + display_heading2(_("Total:") . " " . price_format(-$_SESSION['alloc']->amount) . ""); echo "
"; @@ -193,7 +190,7 @@ function edit_allocations_for_transaction($type, $trans_no) { start_table($table_style); $th = array(_("Transaction Type"), _("#"), _("Date"), _("Due Date"), _("Amount"), - _("Other Allocations"), _("This Allocation"), _("Left to Allocate")); + _("Other Allocations"), _("This Allocation"), _("Left to Allocate"),''); table_header($th); $k = $counter = $total_allocated = 0; @@ -207,21 +204,25 @@ function edit_allocations_for_transaction($type, $trans_no) label_cell($alloc_item->date_, "align=right"); label_cell($alloc_item->due_date, "align=right"); amount_cell($alloc_item->amount); - amount_cell($alloc_item->amount_allocated); + amount_cell($alloc_item->amount_allocated); if (!isset($_POST['amount' . $counter]) || $_POST['amount' . $counter] == "") - $_POST['amount' . $counter] = $alloc_item->current_allocated; - text_cells(null, "amount" . $counter, $_POST['amount' . $counter], 13, 12); + $_POST['amount' . $counter] = price_format($alloc_item->current_allocated); + amount_cells(null, "amount" . $counter, price_format('amount' . $counter)); $un_allocated = round($alloc_item->amount - $alloc_item->amount_allocated, 6); hidden("un_allocated" . $counter, $un_allocated); amount_cell($un_allocated); + label_cell("" + . _("All") . ""); + label_cell("" + . _("None") . ""); - label_cell("" . _("All") . ""); - label_cell("" . _("None") . ""); +// label_cell("" . _("All") . ""); +// label_cell("" . _("None") . ""); end_row(); - $total_allocated += $_POST['amount' . $counter]; + $total_allocated += input_num('amount' . $counter); $counter++; } @@ -234,12 +235,13 @@ function edit_allocations_for_transaction($type, $trans_no) } else $font1 = $font2 = ""; - label_row(_("Left to Allocate"), $font1 . number_format2(-$_SESSION['alloc']->amount - - $total_allocated,user_price_dec()) . $font2, "colspan=6 align=right", + $left_to_allocate = price_format(-$_SESSION['alloc']->amount - $total_allocated); + label_row(_("Left to Allocate"), $font1 . $left_to_allocate . $font2, "colspan=6 align=right", "nowrap align=right"); end_table(); hidden('TotalNumberOfAllocs', $counter); + hidden('left_to_allocate', $left_to_allocate); echo "
"; submit('UpdateDisplay', _("Update")); echo " "; diff --git a/purchasing/includes/ui/po_ui.inc b/purchasing/includes/ui/po_ui.inc index 24001253..b2322f99 100644 --- a/purchasing/includes/ui/po_ui.inc +++ b/purchasing/includes/ui/po_ui.inc @@ -166,6 +166,8 @@ function display_po_items(&$order, $editable=true) $th = array(_("Item Code"), _("Item Description"), _("Quantity"), _("Unit"), _("Required Delivery Date"), _("Price"), _("Line Total")); + + if (count($order->line_items)) $th[] = ''; table_header($th); $total = 0; @@ -205,7 +207,7 @@ function display_po_items(&$order, $editable=true) if (!isset($_GET['Edit']) && $editable) po_item_controls($order); - $display_total = number_format2($total,user_price_dec()); + $display_total = price_format($total); label_row(_("Total Excluding Shipping/Tax"), $display_total, "colspan=6 align=right", "nowrap align=right"); @@ -276,9 +278,9 @@ function po_item_controls(&$order, $stock_id=null) if (!isset($_POST['stock_id'])) $_POST['stock_id'] = $order->line_items[$_GET['Edit']]->stock_id; if (!isset($_POST['qty']) || ($_POST['qty'] == "")) - $_POST['qty'] = $order->line_items[$_GET['Edit']]->quantity; + $_POST['qty'] = qty_format($order->line_items[$_GET['Edit']]->quantity); if (!isset($_POST['price']) || ($_POST['price'] == "")) - $_POST['price'] = $order->line_items[$_GET['Edit']]->price; + $_POST['price'] = price_format($order->line_items[$_GET['Edit']]->price); if (!isset($_POST['req_del_date']) || ($_POST['req_del_date'] == "")) $_POST['req_del_date'] = $order->line_items[$_GET['Edit']]->req_del_date; @@ -307,19 +309,19 @@ function po_item_controls(&$order, $stock_id=null) $item_info = get_item_edit_info($_POST['stock_id']); $_POST['units'] = $item_info["units"]; - $_POST['qty'] = 1; - $_POST['price'] = get_purchase_price ($order->supplier_id, $_POST['stock_id']); + $_POST['qty'] = qty_format(1); + $_POST['price'] = price_format(get_purchase_price ($order->supplier_id, $_POST['stock_id'])); $_POST['req_del_date'] = add_days(Today(), 10); } - text_cells(null, 'qty', null, 13, 15); + amount_cells(null, 'qty', null); label_cell($_POST['units']); date_cells(null, 'req_del_date', null, 0, 0, 0); - text_cells(null, 'price', null, 15, 14); + amount_cells(null, 'price', null); //$line_total = $_POST['qty'] * $_POST['price'] * (1 - $_POST['Disc'] / 100); - $line_total = $_POST['qty'] * $_POST['price']; + $line_total = input_num('qty') * input_num('price'); amount_cell($line_total); if (isset($_GET['Edit'])) diff --git a/purchasing/inquiry/po_search.php b/purchasing/inquiry/po_search.php index e460d53e..7b2e867c 100644 --- a/purchasing/inquiry/po_search.php +++ b/purchasing/inquiry/po_search.php @@ -105,10 +105,10 @@ start_table("$table_style colspan=7 width=80%"); if (isset($_POST['StockLocation']) && $_POST['StockLocation'] == $all_items) $th = array(_("#"), _("Reference"), _("Supplier"), _("Location"), - _("Supplier's Reference"), _("Order Date"), _("Currency"), _("Order Total")); + _("Supplier's Reference"), _("Order Date"), _("Currency"), _("Order Total"),''); else $th = array(_("#"), _("Reference"), _("Supplier"), - _("Supplier's Reference"), _("Order Date"), _("Currency"), _("Order Total")); + _("Supplier's Reference"), _("Order Date"), _("Currency"), _("Order Total"),''); table_header($th); diff --git a/purchasing/po_entry_items.php b/purchasing/po_entry_items.php index be2393ae..7a89b20b 100644 --- a/purchasing/po_entry_items.php +++ b/purchasing/po_entry_items.php @@ -153,19 +153,15 @@ if (isset($_GET['Delete'])) function check_data() { - if (!is_numeric($_POST['qty'])) + if (!check_num('qty',0)) { - display_error(_("The quantity of the order item must be numeric.")); + display_error(_("The quantity of the order item must be numeric and not less than zero.")); return false; } - if ($_POST['qty'] <= 0) - { - display_error(_("The quantity of the ordered item entered must be a positive amount.")); - return false; - } - if (!is_numeric($_POST['price'])) + + if (!check_num('price', 0)) { - display_error(_("The price entered must be numeric.")); + display_error(_("The price entered must be numeric and not less than zero.")); return false; } if (!is_date($_POST['req_del_date'])){ @@ -183,15 +179,15 @@ function handle_update_item() $allow_update = check_data(); if ($allow_update && - ($_SESSION['PO']->line_items[$_POST['line_no']]->qty_inv > $_POST['qty'] || - $_SESSION['PO']->line_items[$_POST['line_no']]->qty_received > $_POST['qty'])) + ($_SESSION['PO']->line_items[$_POST['line_no']]->qty_inv > input_num('qty') || + $_SESSION['PO']->line_items[$_POST['line_no']]->qty_received > input_num('qty'))) { display_error(_("You are attempting to make the quantity ordered a quantity less than has already been invoiced or received. This is prohibited.") . "
" . _("The quantity received can only be modified by entering a negative receipt and the quantity invoiced can only be reduced by entering a credit note against this item.")); return; } - $_SESSION['PO']->update_order_item($_POST['line_no'], $_POST['qty'], $_POST['price'], + $_SESSION['PO']->update_order_item($_POST['line_no'], input_num('qty'), input_num('price'), $_POST['req_del_date']); unset_form_variables(); } @@ -235,8 +231,8 @@ function handle_add_new_item() if ($allow_update) { $myrow = db_fetch($result); - $_SESSION['PO']->add_to_order ($_POST['line_no'], $_POST['stock_id'], $_POST['qty'], - $myrow["description"], $_POST['price'], $myrow["units"], + $_SESSION['PO']->add_to_order ($_POST['line_no'], $_POST['stock_id'], input_num('qty'), + $myrow["description"], input_num('price'), $myrow["units"], $_POST['req_del_date'], 0, 0); unset_form_variables(); diff --git a/purchasing/po_receive_items.php b/purchasing/po_receive_items.php index e12b6a42..59791f46 100644 --- a/purchasing/po_receive_items.php +++ b/purchasing/po_receive_items.php @@ -28,7 +28,7 @@ if (isset($_GET['AddedID'])) //echo "
"; //echo get_gl_view_str(25, $grn, _("View the GL Journal Entries for this Delivery")); - echo "
"; +// echo "
"; hyperlink_no_params("$path_to_root/purchasing/inquiry/po_search.php", _("Select a different purchase order for receiving items against")); display_footer_exit(); @@ -85,10 +85,10 @@ function display_po_receive_items() qty_cell($qty_outstanding); if ($qty_outstanding > 0) - text_cells(null, $ln_itm->line_no, $ln_itm->receive_qty, 10, 10, "align=right"); + amount_cells(null, $ln_itm->line_no, qty_format($ln_itm->receive_qty), "align=right"); else - text_cells(null, $ln_itm->line_no, $ln_itm->receive_qty, 10, 10, "align=right", - "", "disabled"); + amount_cells(null, $ln_itm->line_no, qty_format($ln_itm->receive_qty), "align=right", + "disabled"); amount_cell($ln_itm->price); amount_cell($line_total); @@ -259,13 +259,13 @@ if (isset($_POST['Update']) || isset($_POST['ProcessGoodsReceived'])) { $_POST[$line->line_no] = max($_POST[$line->line_no], 0); - if (!is_numeric($_POST[$line->line_no])) - $_POST[$line->line_no] = 0; + if (!check_num($line->line_no)) + $_POST[$line->line_no] = qty_format(0); if (!isset($_POST['DefaultReceivedDate']) || $_POST['DefaultReceivedDate'] == "") $_POST['DefaultReceivedDate'] = Today(); - $_SESSION['PO']->line_items[$line->line_no]->receive_qty = $_POST[$line->line_no]; + $_SESSION['PO']->line_items[$line->line_no]->receive_qty = input_num($line->line_no); if (isset($_POST[$line->stock_id . "Desc"]) && strlen($_POST[$line->stock_id . "Desc"]) > 0) { diff --git a/purchasing/supplier_credit_grns.php b/purchasing/supplier_credit_grns.php index f195d788..ab14148b 100644 --- a/purchasing/supplier_credit_grns.php +++ b/purchasing/supplier_credit_grns.php @@ -29,19 +29,13 @@ echo "
"; function check_data() { - if (!is_numeric($_POST['This_QuantityCredited'])) + if (!check_num('This_QuantityCredited', 0)) { - display_error(_("The quantity to credit must be numeric.")); + display_error(_("The quantity to credit must be numeric and greater than zero.")); return false; } - if ($_POST['This_QuantityCredited'] <= 0) - { - display_error(_("The quantity to credit must be greater than zero.")); - return false; - } - - if (!is_numeric($_POST['ChgPrice']) || $_POST['ChgPrice'] < 0) + if (!check_num('ChgPrice', 0)) { display_error(_("The price is either not numeric or negative.")); return false; @@ -68,8 +62,8 @@ if (isset($_POST['AddGRNToTrans'])) $_SESSION['supp_trans']->add_grn_to_trans($_POST['GRNNumber'], $_POST['po_detail_item'], $_POST['item_code'], $_POST['item_description'], $_POST['qty_recd'], - $_POST['prev_quantity_inv'], $_POST['This_QuantityCredited'], - $_POST['order_price'], $_POST['ChgPrice'], $complete, + $_POST['prev_quantity_inv'], input_num('This_QuantityCredited'), + $_POST['order_price'], input_num('ChgPrice'), $complete, $_POST['std_cost_unit'], ""); } } @@ -172,9 +166,9 @@ if (isset($_POST['grn_item_id']) && $_POST['grn_item_id'] != "") label_cell($_POST['grn_item_id']); label_cell($myrow['item_code'] . " " . $myrow['description']); qty_cell($myrow["quantity_inv"]); - text_cells(null, 'This_QuantityCredited', max($myrow['quantity_inv'], 0), 13, 15); + amount_cells(null, 'This_QuantityCredited', qty_format(max($myrow['quantity_inv'],0))); amount_cell($myrow['unit_price']); - text_cells(null, 'ChgPrice', $myrow['unit_price'], 13, 15); + amount_cells(null, 'ChgPrice', price_format($myrow['unit_price'])); end_row(); end_table(1); diff --git a/purchasing/supplier_invoice_grns.php b/purchasing/supplier_invoice_grns.php index 04aaaea7..8cea6d8e 100644 --- a/purchasing/supplier_invoice_grns.php +++ b/purchasing/supplier_invoice_grns.php @@ -33,19 +33,13 @@ function check_data() { global $check_price_charged_vs_order_price, $check_qty_charged_vs_del_qty; - if (!is_numeric($_POST['this_quantity_inv'])) + if (!check_num('this_quantity_inv', 0) || input_num('this_quantity_inv')==0) { - display_error( _("The quantity to invoice must be numeric.")); + display_error( _("The quantity to invoice must be numeric and greater than zero.")); return false; } - if ($_POST['this_quantity_inv'] <= 0) - { - display_error( _("The quantity to invoice must be greater than zero.")); - return false; - } - - if (!is_numeric($_POST['ChgPrice'])) + if (!check_num('ChgPrice')) { display_error( _("The price is not numeric.")); return false; @@ -53,7 +47,7 @@ function check_data() if ($check_price_charged_vs_order_price == True) { - if ($_POST['ChgPrice']/$_POST['order_price'] > + if (input_num('ChgPrice')/$_POST['order_price'] > (1 + (sys_prefs::over_charge_allowance() / 100))) { display_error(_("The price being invoiced is more than the purchase order price by more than the allowed over-charge percentage. The system is set up to prohibit this. See the system administrator to modify the set up parameters if necessary.") . @@ -64,7 +58,7 @@ function check_data() if ($check_qty_charged_vs_del_qty == True) { - if ($_POST['this_quantity_inv'] / ($_POST['qty_recd'] - $_POST['prev_quantity_inv']) > + if (input_num('this_quantity_inv') / ($_POST['qty_recd'] - $_POST['prev_quantity_inv']) > (1+ (sys_prefs::over_charge_allowance() / 100))) { display_error( _("The quantity being invoiced is more than the outstanding quantity by more than the allowed over-charge percentage. The system is set up to prohibit this. See the system administrator to modify the set up parameters if necessary.") @@ -83,7 +77,7 @@ if (isset($_POST['AddGRNToTrans'])) if (check_data()) { - if ($_POST['this_quantity_inv'] >= ($_POST['qty_recd'] - $_POST['prev_quantity_inv'])) + if (input_num('this_quantity_inv') >= ($_POST['qty_recd'] - $_POST['prev_quantity_inv'])) { $complete = True; } @@ -92,15 +86,10 @@ if (isset($_POST['AddGRNToTrans'])) $complete = False; } - //$_SESSION['supp_trans']->add_grn_to_trans($_POST['GRNNumber'], $_POST['po_detail_item'], - // $_POST['item_code'], $_POST['item_description'], $_POST['qty_recd'], - // $_POST['prev_quantity_inv'], $_POST['this_quantity_inv'], - // $_POST['order_price'], $_POST['ChgPrice'], $complete, - // $_POST['std_cost_unit'], $_POST['gl_code']); $_SESSION['supp_trans']->add_grn_to_trans($_POST['GRNNumber'], $_POST['po_detail_item'], $_POST['item_code'], $_POST['item_description'], $_POST['qty_recd'], - $_POST['prev_quantity_inv'], $_POST['this_quantity_inv'], - $_POST['order_price'], $_POST['ChgPrice'], $complete, + $_POST['prev_quantity_inv'], input_num('this_quantity_inv'), + $_POST['order_price'], input_num('ChgPrice'), $complete, $_POST['std_cost_unit'], ""); } } @@ -213,9 +202,9 @@ if (isset($_POST['grn_item_id']) && $_POST['grn_item_id'] != "") label_cell($myrow['item_code']); label_cell($myrow['description']); qty_cell($myrow['QtyOstdg']); - text_cells(null, 'this_quantity_inv', $myrow['QtyOstdg'], 13, 15); + amount_cells(null, 'this_quantity_inv', qty_format($myrow['QtyOstdg'])); amount_cell($myrow['unit_price']); - text_cells(null, 'ChgPrice', $myrow['unit_price'], 13, 15); + small_amount_cells(null, 'ChgPrice', price_format($myrow['unit_price'])); end_row(); end_table(1);; diff --git a/purchasing/supplier_payment.php b/purchasing/supplier_payment.php index d9297357..6cf62669 100644 --- a/purchasing/supplier_payment.php +++ b/purchasing/supplier_payment.php @@ -41,16 +41,11 @@ if (isset($_GET['AddedID'])) display_note(get_gl_view_str(22, $payment_id, _("View the GL Journal Entries for this Payment"))); - echo "

"; hyperlink_params($path_to_root . "/purchasing/allocations/supplier_allocate.php", _("Allocate this Payment"), "trans_no=$payment_id&trans_type=22"); - echo "

"; hyperlink_params($_SERVER['PHP_SELF'], _("Enter another supplier payment"), "supplier_id=" . $_POST['supplier_id']); - echo "


"; - - end_page(); - exit; + display_footer_exit(); } //---------------------------------------------------------------------------------------- @@ -122,10 +117,10 @@ function check_inputs() { if ($_POST['amount'] == "") { - $_POST['amount'] = 0; + $_POST['amount'] = price_format(0); } - if (!is_numeric($_POST['amount']) || $_POST['amount'] < 0) + if (!check_num('amount', 0)) { display_error(_("The entered amount is invalid or less than zero.")); return false; @@ -136,13 +131,13 @@ function check_inputs() $_POST['discount'] = 0; } - if (!is_numeric($_POST['discount']) OR $_POST['discount'] < 0) + if (!check_num('discount', 0)) { display_error(_("The entered discount is invalid or less than zero.")); return false; } - if ($_POST['amount'] - $_POST['discount'] <= 0) + if (input_num('amount') - input_num('discount') <= 0) { display_error(_("The total of the amount and the discount negative. Please enter positive values.")); return false; @@ -179,7 +174,7 @@ function handle_add_payment() { $payment_id = add_supp_payment($_POST['supplier_id'], $_POST['DatePaid'], $_POST['PaymentType'], $_POST['bank_account'], - $_POST['amount'], $_POST['discount'], $_POST['ref'], $_POST['memo_']); + input_num('amount'), input_num('discount'), $_POST['ref'], $_POST['memo_']); //unset($_POST['supplier_id']); unset($_POST['bank_account']); diff --git a/purchasing/supplier_trans_gl.php b/purchasing/supplier_trans_gl.php index cc786269..1e120b45 100644 --- a/purchasing/supplier_trans_gl.php +++ b/purchasing/supplier_trans_gl.php @@ -54,7 +54,7 @@ if (isset($_POST['AddGLCodeToTrans'])){ { $myrow = db_fetch_row($result); $gl_act_name = $myrow[1]; - if (!is_numeric($_POST['amount'])) + if (!check_num('amount')) { display_error(_("The amount entered is not numeric. This line cannot be added to the transaction.")); $input_error = true; @@ -64,7 +64,8 @@ if (isset($_POST['AddGLCodeToTrans'])){ if ($input_error == false) { $_SESSION['supp_trans']->add_gl_codes_to_trans($_POST['gl_code'], $gl_act_name, - $_POST['dimension_id'], $_POST['dimension2_id'], $_POST['amount'], $_POST['memo_']); + $_POST['dimension_id'], $_POST['dimension2_id'], + input_num('amount'), $_POST['memo_']); clear_fields(); } } diff --git a/sales/allocations/customer_allocate.php b/sales/allocations/customer_allocate.php index 46daa72d..f8b96d5c 100644 --- a/sales/allocations/customer_allocate.php +++ b/sales/allocations/customer_allocate.php @@ -37,13 +37,13 @@ function check_data() for ($counter = 0; $counter < $_POST["TotalNumberOfAllocs"]; $counter++) { - if (!is_numeric($_POST['amount' . $counter])) + if (!check_num('amount' . $counter)) { display_error(_("The entry for one or more amounts is invalid.")); return false; } - if ($_POST['amount' . $counter] < 0) + if (!check_num('amount' . $counter,0)) { display_error(_("The entry for an amount to allocate was negative. A positive allocation amount is expected.")); return false; @@ -51,14 +51,14 @@ function check_data() /*Now check to see that the AllocAmt is no greater than the amount left to be allocated against the transaction under review */ - if ($_POST['amount' . $counter] > $_POST['un_allocated' . $counter]) + if (input_num('amount' . $counter) > $_POST['un_allocated' . $counter]) { //$_POST['amount' . $counter] = $_POST['un_allocated' . $counter]; } - $_SESSION['alloc']->allocs[$counter]->current_allocated = $_POST['amount' . $counter]; + $_SESSION['alloc']->allocs[$counter]->current_allocated = input_num('amount' . $counter); - $total_allocated += $_POST['amount' . $counter]; + $total_allocated += input_num('amount' . $counter); } if ($total_allocated - $_SESSION['alloc']->amount > sys_prefs::allocation_settled_allowance()) @@ -94,6 +94,7 @@ function handle_process() update_debtor_trans_allocation($allocn_item->type, $allocn_item->type_no, $allocn_item->current_allocated); $total_allocated += $allocn_item->current_allocated; + } } /*end of the loop through the array of allocations made */ @@ -179,7 +180,7 @@ function edit_allocations_for_transaction($type, $trans_no) display_heading($_SESSION['alloc']->person_name); display_heading2(_("Date:") . " " . $_SESSION['alloc']->date_ . ""); - display_heading2(_("Total:") . " " . number_format2($_SESSION['alloc']->amount,user_price_dec()) . ""); + display_heading2(_("Total:") . " " . price_format($_SESSION['alloc']->amount) . ""); echo "
"; @@ -205,9 +206,9 @@ function edit_allocations_for_transaction($type, $trans_no) amount_cell($allocn_item->amount); amount_cell($allocn_item->amount_allocated); - if (!isset($_POST['amount' . $counter]) || $_POST['amount' . $counter] == "") - $_POST['amount' . $counter] = $allocn_item->current_allocated; - text_cells(null, "amount" . $counter, $_POST['amount' . $counter], 13, 12); + if (!check_num('amount' . $counter)) + $_POST['amount' . $counter] = price_format($allocn_item->current_allocated); + amount_cells(null, 'amount' . $counter, $_POST['amount' . $counter]); $un_allocated = round($allocn_item->amount - $allocn_item->amount_allocated, 6); hidden("un_allocated" . $counter, $un_allocated); @@ -219,11 +220,11 @@ function edit_allocations_for_transaction($type, $trans_no) . _("None") . ""); end_row(); - $total_allocated += $_POST['amount' . $counter]; + $total_allocated += input_num('amount' . $counter); $counter++; } - label_row(_("Total Allocated"), number_format2($total_allocated,user_price_dec()), + label_row(_("Total Allocated"), price_format($total_allocated), "colspan=6 align=right", "nowrap align=right"); if ($_SESSION['alloc']->amount - $total_allocated < 0) { @@ -233,9 +234,9 @@ function edit_allocations_for_transaction($type, $trans_no) else $font1 = $font2 = ""; $left_to_allocate = $_SESSION['alloc']->amount - $total_allocated; - $left_to_allocate = number_format2($left_to_allocate, user_price_dec()); + $left_to_allocate = price_format($left_to_allocate); label_row(_("Left to Allocate"), $font1 . $left_to_allocate . $font2, - "colspan=6 align=right", "nowrap align=right"); + "colspan=6 align=right ", "nowrap align=right"); end_table(1); hidden('TotalNumberOfAllocs', $counter); diff --git a/sales/credit_note_entry.php b/sales/credit_note_entry.php index 92588639..5de3dfb9 100644 --- a/sales/credit_note_entry.php +++ b/sales/credit_note_entry.php @@ -61,7 +61,7 @@ function copy_to_cn() { $_SESSION['Items']->Comments = $_POST['CreditText']; $_SESSION['Items']->document_date = $_POST['OrderDate']; - $_SESSION['Items']->freight_cost = $_POST['ChargeFreightCost']; + $_SESSION['Items']->freight_cost = input_num('ChargeFreightCost'); $_SESSION['Items']->Location = $_POST["Location"]; $_SESSION['Items']->sales_type = $_POST['sales_type_id']; $_SESSION['Items']->reference = $_POST['ref']; @@ -74,7 +74,7 @@ function copy_from_cn() { $_POST['CreditText'] = $_SESSION['Items']->Comments; $_POST['OrderDate'] = $_SESSION['Items']->document_date; - $_POST['ChargeFreightCost'] = $_SESSION['Items']->freight_cost; + $_POST['ChargeFreightCost'] = price_format($_SESSION['Items']->freight_cost); $_POST['Location'] = $_SESSION['Items']->Location; $_POST['sales_type_id'] = $_SESSION['Items']->sales_type; $_POST['ref'] = $_SESSION['Items']->reference; @@ -97,17 +97,18 @@ function can_process() $input_error = 0; - if ($_SESSION['Items']->count_items() == 0 - && (!isset($_POST['ChargeFreightCost']) || $_POST['ChargeFreightCost'] <= 0)) + if ($_SESSION['Items']->count_items() == 0 && (!check_num('ChargeFreightCost',0))) return false; - - if (!references::is_valid($_POST['ref'])) { + if($_SESSION['Items']->trans_no == 0) { + if (!references::is_valid($_POST['ref'])) { display_error( _("You must enter a reference.")); $input_error = 1; - } elseif (!is_new_reference($_POST['ref'], 11)) { + } elseif (!is_new_reference($_POST['ref'], 11)) { display_error( _("The entered reference is already in use.")); $input_error = 1; - } elseif (!is_date($_POST['OrderDate'])) { + } + } + if (!is_date($_POST['OrderDate'])) { display_error(_("The entered date for the credit note is invalid.")); $input_error = 1; } elseif (!is_date_in_fiscalyear($_POST['OrderDate'])) { @@ -139,15 +140,15 @@ if (isset($_POST['ProcessCredit']) && can_process()) { function check_item_data() { - if ($_POST['qty'] <= 0) { + if (!check_num('qty',0)) { display_error(_("The quantity must be greater than zero.")); return false; } - if (!is_numeric($_POST['price']) || $_POST['price'] < 0) { + if (!check_num('price',0)) { display_error(_("The entered price is negative or invalid.")); return false; } - if (!is_numeric($_POST['Disc']) || $_POST['Disc'] > 100 || $_POST['Disc'] < 0) { + if (!check_num('Disc', 0, 100)) { display_error(_("The entered discount percent is negative, greater than 100 or invalid.")); return false; } @@ -159,8 +160,8 @@ function check_item_data() function handle_update_item() { if ($_POST['UpdateItem'] != "" && check_item_data()) { - $_SESSION['Items']->update_cart_item($_POST['line_no'], $_POST['qty'], - $_POST['price'], ($_POST['Disc'] / 100)); + $_SESSION['Items']->update_cart_item($_POST['line_no'], input_num('qty'), + input_num('price'), input_num('Disc') / 100); } } @@ -179,8 +180,8 @@ function handle_new_item() if (!check_item_data()) return; - add_to_order($_SESSION['Items'], $_POST['stock_id'], $_POST['qty'], - $_POST['price'], $_POST['Disc'] / 100); + add_to_order($_SESSION['Items'], $_POST['stock_id'], input_num('qty'), + input_num('price'), input_num('Disc') / 100); } //----------------------------------------------------------------------------- if (isset($_GET['Delete']) || isset($_GET['Edit'])) diff --git a/sales/customer_credit_invoice.php b/sales/customer_credit_invoice.php index 0a1e103c..b084a7d1 100644 --- a/sales/customer_credit_invoice.php +++ b/sales/customer_credit_invoice.php @@ -90,7 +90,7 @@ function can_process() return false; } } - if (!is_numeric($_POST['ChargeFreightCost']) || $_POST['ChargeFreightCost'] < 0) { + if (!check_num('ChargeFreightCost', 0)) { display_error(_("The entered shipping cost is invalid or less than zero."));; return false; } @@ -138,9 +138,9 @@ if (isset($_GET['InvoiceNumber']) && $_GET['InvoiceNumber'] > 0) { } else { foreach ($_SESSION['Items']->line_items as $line_no=>$itm) { if (isset($_POST['Line'.$line_no])) { - $line_qty = $_POST['Line'.$line_no]; - if (is_numeric($line_qty) && $_POST['Line'.$line_no] <= ($itm->quantity - $itm->qty_done)) { - $_SESSION['Items']->line_items[$line_no]->qty_dispatched = $line_qty; + if (check_num('Line'.$line_no, ($itm->quantity - $itm->qty_done))) { + $_SESSION['Items']->line_items[$line_no]->qty_dispatched = + input_num('Line'.$line_no); } } @@ -158,7 +158,7 @@ function copy_to_cart() { $cart = &$_SESSION['Items']; $cart->ship_via = $_POST['ShipperID']; - $cart->freight_cost = $_POST['ChargeFreightCost']; + $cart->freight_cost = input_num('ChargeFreightCost'); $cart->document_date = $_POST['CreditDate']; $cart->Location = $_POST['Location']; $cart->Comments = $_POST['CreditText']; @@ -169,7 +169,7 @@ function copy_from_cart() { $cart = &$_SESSION['Items']; $_POST['ShipperID'] = $cart->ship_via; - $_POST['ChargeFreightCost'] = $cart->freight_cost; + $_POST['ChargeFreightCost'] = price_format($cart->freight_cost); $_POST['CreditDate']= $cart->document_date; $_POST['Location']= $cart->Location; $_POST['CreditText']= $cart->Comments; @@ -274,43 +274,40 @@ function display_credit_items() // view_stock_status_cell($ln_itm->stock_id); alternative view label_cell($ln_itm->stock_id); - text_cells(null, 'Line'.$line_no.'Desc', $ln_itm->item_description, 30, 50); + text_cells(null, 'Line'.$line_no.'Desc', $ln_itm->item_description, 30, 50); qty_cell($ln_itm->quantity); label_cell($ln_itm->units); - text_cells(null, 'Line'.$line_no, $ln_itm->qty_dispatched, 13, 15); + + amount_cells(null, 'Line'.$line_no, qty_format($ln_itm->qty_dispatched)); $line_total =($ln_itm->qty_dispatched * $ln_itm->price * (1 - $ln_itm->discount_percent)); amount_cell($ln_itm->price); - amount_cell($ln_itm->discount_percent*100); + percent_cell($ln_itm->discount_percent*100); amount_cell($line_total); end_row(); } - if (!isset($_POST['ChargeFreightCost']) || ($_POST['ChargeFreightCost'] == "")) { - $_POST['ChargeFreightCost'] = $_SESSION['Items']->freight_cost; + if (!check_num('ChargeFreightCost')) { + $_POST['ChargeFreightCost'] = price_format($_SESSION['Items']->freight_cost); } - if (!is_numeric($_POST['ChargeFreightCost'])) - { - $_POST['ChargeFreightCost'] = 0; - } start_row(); label_cell(_("Credit Shipping Cost"), "colspan=7 align=right"); - text_cells(null, "ChargeFreightCost", $_POST['ChargeFreightCost'], 6, 6); + amount_cells(null, "ChargeFreightCost", $_POST['ChargeFreightCost'], 6, 6); end_row(); $inv_items_total = $_SESSION['Items']->get_items_total_dispatch(); - $display_sub_total = number_format2($inv_items_total + $_POST['ChargeFreightCost'],user_price_dec()); + $display_sub_total = price_format($inv_items_total + input_num($_POST['ChargeFreightCost'])); label_row(_("Sub-total"), $display_sub_total, "colspan=7 align=right", "align=right"); - $taxes = $_SESSION['Items']->get_taxes($_POST['ChargeFreightCost']); + $taxes = $_SESSION['Items']->get_taxes(input_num($_POST['ChargeFreightCost'])); $tax_total = display_edit_tax_items($taxes, 7, $_SESSION['Items']->tax_included); - $display_total = number_format2(($inv_items_total + $_POST['ChargeFreightCost'] + $tax_total), user_price_dec()); + $display_total = price_format(($inv_items_total + input_num('ChargeFreightCost') + $tax_total)); label_row(_("Credit Note Total"), $display_total, "colspan=7 align=right", "align=right"); diff --git a/sales/customer_delivery.php b/sales/customer_delivery.php index ba7016ef..eca34468 100644 --- a/sales/customer_delivery.php +++ b/sales/customer_delivery.php @@ -116,9 +116,13 @@ if (isset($_GET['OrderNumber']) && $_GET['OrderNumber'] > 0) { exit; } elseif (!check_quantities()) { - display_error(_("Selected quantity cannot be less then quantity invoiced nor more then quantity + display_error(_("Selected quantity cannot be less than quantity invoiced nor more than quantity not dispatched on sales order.")); -} + +} elseif(!check_num('ChargeFreightCost', 0)) + display_error(_("Freight cost cannot be less than zero")); + + //----------------------------------------------------------------------------- function check_data() @@ -150,21 +154,21 @@ function check_data() } } if ($_POST['ChargeFreightCost'] == "") { - $_POST['ChargeFreightCost'] = 0; + $_POST['ChargeFreightCost'] = price_format(0); } - if (!is_numeric($_POST['ChargeFreightCost']) || $_POST['ChargeFreightCost'] < 0) { + if (!check_num('ChargeFreightCost',0)) { display_error(_("The entered shipping value is not numeric.")); return false; } - if ($_SESSION['Items']->has_items_dispatch() == 0 && $_POST['ChargeFreightCost'] == 0) { + if ($_SESSION['Items']->has_items_dispatch() == 0 && input_num('ChargeFreightCost') == 0) { display_error(_("There are no item quantities on this delivery note.")); return false; } if (!check_quantities()) { - display_error(_("Selected quantity cannot be less then quantity invoiced nor more then quantity + display_error(_("Selected quantity cannot be less than quantity invoiced nor more than quantity not dispatched on sales order.")); return false; } @@ -176,7 +180,7 @@ function copy_to_cart() { $cart = &$_SESSION['Items']; $cart->ship_via = $_POST['ship_via']; - $cart->freight_cost = $_POST['ChargeFreightCost']; + $cart->freight_cost = input_num('ChargeFreightCost'); $cart->document_date = $_POST['DispatchDate']; $cart->due_date = $_POST['due_date']; $cart->Location = $_POST['Location']; @@ -191,7 +195,7 @@ function copy_from_cart() { $cart = &$_SESSION['Items']; $_POST['ship_via'] = $cart->ship_via; - $_POST['ChargeFreightCost'] = $cart->freight_cost; + $_POST['ChargeFreightCost'] = price_format($cart->freight_cost); $_POST['DispatchDate']= $cart->document_date; $_POST['due_date'] = $cart->due_date; $_POST['Location']= $cart->Location; @@ -205,11 +209,9 @@ function check_quantities() // Update cart delivery quantities/descriptions foreach ($_SESSION['Items']->line_items as $line=>$itm) { if (isset($_POST['Line'.$line])) { - $line_qty = $_POST['Line'.$line]; - if (is_numeric($line_qty) && ($_POST['Line'.$line] <= $itm->quantity) && - ($_POST['Line'.$line] >= $itm->qty_done)) { - - $_SESSION['Items']->line_items[$line]->qty_dispatched = $line_qty; + if (!check_num('Line'.$line, $itm->qty_done, $itm->quantity) == 0) { + $_SESSION['Items']->line_items[$line]->qty_dispatched = + input_num('Line'.$line); } else { $ok = 0; } @@ -223,8 +225,9 @@ function check_quantities() } } } - $_SESSION['Items']->freight_cost = $_POST['ChargeFreightCost']; - +// ... +// else +// $_SESSION['Items']->freight_cost = input_num('ChargeFreightCost'); return $ok; } //------------------------------------------------------------------------------ @@ -375,9 +378,9 @@ foreach ($_SESSION['Items']->line_items as $line=>$ln_itm) { label_cell($ln_itm->units); qty_cell($ln_itm->qty_done); - text_cells(null, 'Line'.$line, $ln_itm->qty_dispatched, 10, 10); + small_amount_cells(null, 'Line'.$line, qty_format($ln_itm->qty_dispatched)); - $display_discount_percent = number_format2($ln_itm->discount_percent*100,user_percent_dec()) . "%"; + $display_discount_percent = percent_format($ln_itm->discount_percent*100) . "%"; $line_total = ($ln_itm->qty_dispatched * $ln_itm->price * (1 - $ln_itm->discount_percent)); @@ -389,10 +392,10 @@ foreach ($_SESSION['Items']->line_items as $line=>$ln_itm) { end_row(); } -$_POST['ChargeFreightCost'] = $_SESSION['Items']->freight_cost; +$_POST['ChargeFreightCost'] = price_format($_SESSION['Items']->freight_cost); -if (!is_numeric($_POST['ChargeFreightCost'])) { - $_POST['ChargeFreightCost'] = 0; +if (!check_num('ChargeFreightCost')) { + $_POST['ChargeFreightCost'] = price_format(0); } start_row(); @@ -401,14 +404,14 @@ small_amount_cells(_("Shipping Cost"), 'ChargeFreightCost', $_SESSION['Items']-> $inv_items_total = $_SESSION['Items']->get_items_total_dispatch(); -$display_sub_total = number_format2($inv_items_total + $_POST['ChargeFreightCost'],user_price_dec()); +$display_sub_total = price_format($inv_items_total + input_num('ChargeFreightCost')); label_row(_("Sub-total"), $display_sub_total, "colspan=9 align=right","align=right"); -$taxes = $_SESSION['Items']->get_taxes($_POST['ChargeFreightCost']); +$taxes = $_SESSION['Items']->get_taxes(input_num('ChargeFreightCost')); $tax_total = display_edit_tax_items($taxes, 9, $_SESSION['Items']->tax_included); -$display_total = number_format2(($inv_items_total + $_POST['ChargeFreightCost'] + $tax_total), user_price_dec()); +$display_total = price_format(($inv_items_total + input_num('ChargeFreightCost') + $tax_total)); label_row(_("Amount Total"), $display_total, "colspan=9 align=right","align=right"); diff --git a/sales/customer_invoice.php b/sales/customer_invoice.php index 8b3102ac..c2ffcfe0 100644 --- a/sales/customer_invoice.php +++ b/sales/customer_invoice.php @@ -133,9 +133,9 @@ if ( (isset($_GET['DeliveryNumber']) && ($_GET['DeliveryNumber'] > 0) ) } else { foreach ($_SESSION['Items']->line_items as $line_no=>$itm) { if (isset($_POST['Line'.$line_no])) { - $line_qty = $_POST['Line'.$line_no]; - if (is_numeric($line_qty) && $_POST['Line'.$line_no] <= ($itm->quantity - $itm->qty_done)) { - $_SESSION['Items']->line_items[$line_no]->qty_dispatched = $line_qty; + if (!check_num('Line'.$line_no, 0, ($itm->quantity - $itm->qty_done))) { + $_SESSION['Items']->line_items[$line_no]->qty_dispatched = + input_num('Line'.$line_no); } } @@ -153,7 +153,7 @@ function copy_to_cart() { $cart = &$_SESSION['Items']; $cart->ship_via = $_POST['ship_via']; - $cart->freight_cost = $_POST['ChargeFreightCost']; + $cart->freight_cost = input_num('ChargeFreightCost'); $cart->document_date = $_POST['InvoiceDate']; $cart->due_date = $_POST['due_date']; $cart->Comments = $_POST['Comments']; @@ -164,7 +164,7 @@ function copy_from_cart() { $cart = &$_SESSION['Items']; $_POST['ship_via'] = $cart->ship_via; - $_POST['ChargeFreightCost'] = $cart->freight_cost; + $_POST['ChargeFreightCost'] = price_format($cart->freight_cost); $_POST['InvoiceDate']= $cart->document_date; $_POST['due_date'] = $cart->due_date; $_POST['Comments']= $cart->Comments; @@ -202,15 +202,15 @@ function check_data() } if ($_POST['ChargeFreightCost'] == "") { - $_POST['ChargeFreightCost'] = 0; + $_POST['ChargeFreightCost'] = price_format(0); } - if (!is_numeric($_POST['ChargeFreightCost']) || $_POST['ChargeFreightCost'] < 0) { + if (!check_num('ChargeFreightCost', 0)) { display_error(_("The entered shipping value is not numeric.")); return false; } - if ($_SESSION['Items']->has_items_dispatch() == 0 && $_POST['ChargeFreightCost'] == 0) { + if ($_SESSION['Items']->has_items_dispatch() == 0 && input_num('ChargeFreightCost') == 0) { display_error(_("There are no item quantities on this invoice.")); return false; } @@ -314,12 +314,12 @@ $th = array(_("Item Code"), _("Item Description"), _("Delivered"), _("Units"), _ _("This Invoice"), _("Price"), _("Tax Type"), _("Discount"), _("Total")); if ($is_batch_invoice) { -$th[] = _("DN"); -$th[] = ""; + $th[] = _("DN"); + $th[] = ""; } if ($is_edition) { -$th[4] = _("Credited"); + $th[4] = _("Credited"); } table_header($th); @@ -345,11 +345,11 @@ foreach ($_SESSION['Items']->line_items as $line=>$ln_itm) { // for batch invoices we can only remove whole deliveries echo ''; hidden('Line' . $line, $ln_itm->qty_dispatched ); - echo number_format2($ln_itm->qty_dispatched, user_qty_dec()).''; + echo qty_format($ln_itm->qty_dispatched).''; } else { - text_cells(null, 'Line'.$line, $ln_itm->qty_dispatched, 10, 10); + small_amount_cells(null, 'Line'.$line, qty_format($ln_itm->qty_dispatched)); } - $display_discount_percent = number_format2($ln_itm->discount_percent*100, user_percent_dec()) . "%"; + $display_discount_percent = percent_format($ln_itm->discount_percent*100) . " %"; $line_total = ($ln_itm->qty_dispatched * $ln_itm->price * (1 - $ln_itm->discount_percent)); @@ -378,13 +378,13 @@ was not fully delivered the first time ?? */ if (!isset($_POST['ChargeFreightCost']) || $_POST['ChargeFreightCost'] == "") { if ($_SESSION['Items']->any_already_delivered() == 1) { - $_POST['ChargeFreightCost'] = 0; + $_POST['ChargeFreightCost'] = price_format(0); } else { - $_POST['ChargeFreightCost'] = $_SESSION['Items']->freight_cost; + $_POST['ChargeFreightCost'] = price_format($_SESSION['Items']->freight_cost); } - if (!is_numeric($_POST['ChargeFreightCost'])) { - $_POST['ChargeFreightCost'] = 0; + if (!check_num('ChargeFreightCost')) { + $_POST['ChargeFreightCost'] = price_format(0); } } @@ -398,14 +398,14 @@ label_cell('', 'colspan=2'); end_row(); $inv_items_total = $_SESSION['Items']->get_items_total_dispatch(); -$display_sub_total = number_format2($inv_items_total + $_POST['ChargeFreightCost'],user_price_dec()); +$display_sub_total = price_format($inv_items_total + input_num('ChargeFreightCost')); label_row(_("Sub-total"), $display_sub_total, "colspan=9 align=right","align=right", $is_batch_invoice ? 2 : 0); -$taxes = $_SESSION['Items']->get_taxes($_POST['ChargeFreightCost']); +$taxes = $_SESSION['Items']->get_taxes(input_num('ChargeFreightCost')); $tax_total = display_edit_tax_items($taxes, 9, $_SESSION['Items']->tax_included, $is_batch_invoice ? 2:0); -$display_total = number_format2(($inv_items_total + $_POST['ChargeFreightCost'] + $tax_total), user_price_dec()); +$display_total = price_format(($inv_items_total + input_num('ChargeFreightCost') + $tax_total)); label_row(_("Invoice Total"), $display_total, "colspan=9 align=right","align=right", $is_batch_invoice ? 2 : 0); diff --git a/sales/customer_payments.php b/sales/customer_payments.php index cd48b658..212b96e0 100644 --- a/sales/customer_payments.php +++ b/sales/customer_payments.php @@ -65,21 +65,17 @@ function can_process() return false; } - if ((!is_numeric($_POST['amount']) || $_POST['amount'] < 0)) { + if (!check_num('amount', 0)) { display_error(_("The entered amount is invalid or negative and cannot be processed.")); return false; } - if (!isset($_POST['discount']) || ($_POST['discount'] == "")) { - $_POST['discount'] = 0; - } - - if (!is_numeric($_POST['discount'])) { + if (!check_num('discount')) { display_error(_("The entered discount is not a valid number.")); return false; } - if (($_POST['amount'] - $_POST['discount'] <= 0)) { + if ((input_num('amount') - input_num('discount') <= 0)) { display_error(_("The balance of the amount and discout is zero or negative. Please enter valid amounts.")); return false; } @@ -102,7 +98,7 @@ if (isset($_POST['AddPaymentItem'])) { if (isset($_POST['AddPaymentItem'])) { $payment_no = write_customer_payment(0, $_POST['customer_id'], $_POST['BranchID'], $_POST['bank_account'], $_POST['DateBanked'], $_POST['ReceiptType'], $_POST['ref'], - $_POST['amount'], $_POST['discount'], $_POST['memo_']); + input_num('amount'), input_num('discount'), $_POST['memo_']); meta_forward($_SERVER['PHP_SELF'], "AddedID=$payment_no"); } @@ -160,7 +156,7 @@ function display_item_form() echo ""; display_note(_("This customer account is on hold."), 0, 0, "class='redfb'"); } else { - $display_discount_percent = number_format2($_POST['pymt_discount']*100,user_price_dec()) . "%"; + $display_discount_percent = percent_format($_POST['pymt_discount']*100) . "%"; amount_row(_("Amount:"), 'amount'); diff --git a/sales/includes/ui/sales_credit_ui.inc b/sales/includes/ui/sales_credit_ui.inc index 811167d6..6fa90b12 100644 --- a/sales/includes/ui/sales_credit_ui.inc +++ b/sales/includes/ui/sales_credit_ui.inc @@ -45,9 +45,9 @@ function display_credit_header(&$order) if (!isset($_POST['ref'])) $_POST['ref'] = references::get_next(11); if ($_SESSION['Items']->trans_no==0) - ref_row(_("Reference:"), 'ref'); + ref_row(_("Reference").':', 'ref'); else - label_row(_("Reference"), $_POST['ref'], "class='tableheader2'"); + label_row(_("Reference").':', $_POST['ref'] ); @@ -155,20 +155,21 @@ function display_credit_items($title, &$order) if (!isset($_GET['Edit'])) credit_edit_item_controls($order); - $display_sub_total = number_format2($subtotal,user_price_dec()); + $display_sub_total = price_format($subtotal); label_row(_("Sub-total"), $display_sub_total, "colspan=6 align=right", "align=right"); if (!isset($_POST['ChargeFreightCost']) OR ($_POST['ChargeFreightCost'] == "")) - $_POST['ChargeFreightCost'] = 0; + $_POST['ChargeFreightCost'] = price_format(0); - text_row(_("Shipping"), 'ChargeFreightCost', $_POST['ChargeFreightCost'], 8, 8, "colspan=6 align=right"); + amount_cells_ex(_("Shipping"), 'ChargeFreightCost', 8, 8, $_POST['ChargeFreightCost'], "colspan=6 align=right"); $taxes = $order->get_taxes($_POST['ChargeFreightCost']); $tax_total = display_edit_tax_items($taxes, 6, $_SESSION['Items']->tax_included); - $display_total = number_format2(($subtotal + $_POST['ChargeFreightCost'] + $tax_total), user_price_dec()); - label_row(_("Credit Note Total"), $display_total, "colspan=6 align=right","align=right"); + $display_total = price_format(($subtotal + $_POST['ChargeFreightCost'] + $tax_total)); + + label_row(_("Credit Note Total"), $display_total, "colspan=6 align=right","class='amount'"); end_table(); } @@ -184,11 +185,11 @@ function credit_edit_item_controls(&$order, $line_no=-1) if (!isset($_POST['stock_id'])) $_POST['stock_id'] = $order->line_items[$_GET['Edit']]->stock_id; if (!isset($_POST['qty']) || ($_POST['qty']=="")) - $_POST['qty'] = $order->line_items[$_GET['Edit']]->qty_dispatched; + $_POST['qty'] = qty_format($order->line_items[$_GET['Edit']]->qty_dispatched); if (!isset($_POST['price']) || ($_POST['price']=="")) - $_POST['price'] = $order->line_items[$_GET['Edit']]->price; + $_POST['price'] = price_format($order->line_items[$_GET['Edit']]->price); if (!isset($_POST['Disc']) || ($_POST['Disc']=="")) - $_POST['Disc'] = ($order->line_items[$_GET['Edit']]->discount_percent)*100; + $_POST['Disc'] = percent_format(($order->line_items[$_GET['Edit']]->discount_percent)*100); $_POST['units'] = $order->line_items[$_GET['Edit']]->units; @@ -210,25 +211,25 @@ function credit_edit_item_controls(&$order, $line_no=-1) text_cells(null, "StockID2", "", 12, 10, "", "", "onkeyup='recalcAccounts();' onKeyDown='if (event.keyCode==13) event.keyCode=9;' onblur='return setAccount(0, true);'"); stock_items_list_cells(null, 'stock_id', null, false, false, "onchange='return setAccount(1, true)'"); } - $item_info = get_item_edit_info($_POST['stock_id']); + $item_info = get_item_edit_info($_POST['stock_id']); $_POST['units'] = $item_info["units"]; - $_POST['qty'] = 0; + $_POST['qty'] = qty_format(0); $_POST['price'] = get_price($_POST['stock_id'], $order->customer_currency, $order->sales_type); // default to the customer's discount % - $_POST['Disc'] = $order->default_discount * 100; + $_POST['Disc'] = percent_format($order->default_discount * 100); } - text_cells(null, 'qty', $_POST['qty'], 13, 15); + amount_cells(null, 'qty', $_POST['qty']); // if ($order->trans_no!=0) { // amount_cell($line_no==-1 ? 0 :$order->line_items[$line_no]->qty_done); // } label_cell($_POST['units']); - text_cells(null, 'price', null, 13, 15); - text_cells(null, 'Disc', $_POST['Disc'], 7, 5); + amount_cells(null, 'price', null); + small_amount_cells(null, 'Disc', percent_format(0)); amount_cell($_POST['qty'] * $_POST['price'] * (1 - $_POST['Disc']/100)); diff --git a/sales/includes/ui/sales_order_ui.inc b/sales/includes/ui/sales_order_ui.inc index 5494ae00..152724e1 100644 --- a/sales/includes/ui/sales_order_ui.inc +++ b/sales/includes/ui/sales_order_ui.inc @@ -8,15 +8,15 @@ include_once($path_to_root . "/includes/manufacturing.inc"); function add_to_order(&$order, $new_item, $new_item_qty, $price, $discount) { - foreach ($order->line_items AS $order_item) + foreach ($order->line_items AS $order_item) { - if (strcasecmp($order_item->stock_id, $new_item) == 0) - { - display_notification(_("For Part :") . $new_item . " " . _("This item is already on this order. You have been warned.")); - break; + if (strcasecmp($order_item->stock_id, $new_item) == 0) + { + display_notification(_("For Part :") . $new_item . " " . _("This item is already on this order. You have been warned.")); + break; } } - + $order->add_to_cart (count($order->line_items),$new_item, $new_item_qty, $price, $discount); } @@ -27,13 +27,13 @@ function get_customer_details_to_order(&$order, $customer_id, $branch_id) $ret_error = ""; $myrow = get_customer_to_order($customer_id); - + $name = $myrow['name']; if ($myrow['dissallow_invoices'] == 1) $ret_error = _("The selected customer account is currently on hold. Please contact the credit control personnel to discuss."); -/* if (!isset($_POST['branch_id']) || $_POST['branch_id'] == "") +/* if (!isset($_POST['branch_id']) || $_POST['branch_id'] == "") { $ret_error = _("The selected customer does not have any branches. Please create at least one branch."); unset($_POST['branch_id']); @@ -45,30 +45,30 @@ function get_customer_details_to_order(&$order, $customer_id, $branch_id) $order->set_customer($customer_id, $name, $myrow['curr_code'], $myrow['discount']); // the sales type determines the price list to be used by default - $order->set_sales_type($myrow['salestype'], $myrow['sales_type'], $myrow['tax_included']); + $order->set_sales_type($myrow['salestype'], $myrow['sales_type'], $myrow['tax_included']); // if ($order->Branch != 0) { $result = get_branch_to_order($customer_id, $branch_id); - if (db_num_rows($result) == 0) - { - return _("The selected customer and branch are not valid, or the customer does not have any branches."); - } + if (db_num_rows($result) == 0) + { + return _("The selected customer and branch are not valid, or the customer does not have any branches."); + } - $myrow = db_fetch($result); + $myrow = db_fetch($result); $order->set_branch($branch_id, $myrow["tax_group_id"], - $myrow["tax_group_name"], $myrow["phone"], $myrow["email"]); + $myrow["tax_group_name"], $myrow["phone"], $myrow["email"]); - $address = $myrow["br_post_address"]; + $address = $myrow["br_post_address"]; - if (strlen($address) <= 1) // if branch has no address - $address = $deliver; // set sales order address + if (strlen($address) <= 1) // if branch has no address + $address = $deliver; // set sales order address $order->set_location($myrow["default_location"], $myrow["location_name"]); - $order->set_delivery($myrow["default_ship_via"], $myrow["br_name"], - $address); + $order->set_delivery($myrow["default_ship_via"], $myrow["br_name"], + $address); } return $ret_error; @@ -83,25 +83,25 @@ function display_order_summary($title, &$order, $editable_items=false) display_heading($title); start_table("$table_style colspan=7 width=90%"); $th = array(_("Item Code"), _("Item Description"), _("Quantity"), - _("Delivered"), + _("Delivered"), _("Unit"), _("Price"), _("Discount %"), _("Total"), ""); if ($order->trans_no==0) { - unset( $th[3] ); + unset( $th[3] ); } if (count($order->line_items)) $th[]= ''; - table_header($th); + table_header($th); $total = 0; $k = 0; //row colour counter - foreach ($order->line_items as $line_no=>$stock_item) + foreach ($order->line_items as $line_no=>$stock_item) { $line_total = $stock_item->qty_dispatched * $stock_item->price * (1 - $stock_item->discount_percent); - + if (!isset($_GET['Edit'])) $id = -1; else @@ -109,30 +109,30 @@ function display_order_summary($title, &$order, $editable_items=false) if (!$editable_items || $id != $line_no) { - alt_table_row_color($k); + alt_table_row_color($k); view_stock_status_cell($stock_item->stock_id); - - label_cell($stock_item->item_description); - qty_cell($stock_item->qty_dispatched); - - if ($order->trans_no!=0) - amount_cell($stock_item->qty_done); - - label_cell($stock_item->units); - amount_cell($stock_item->price); - - amount_cell($stock_item->discount_percent * 100); - amount_cell($line_total); - - if ($editable_items) - { - edit_link_cell(SID . "Edit=$line_no"); - delete_link_cell(SID . "Delete=$line_no"); - } - end_row(); - } - else + + label_cell($stock_item->item_description); + qty_cell($stock_item->qty_dispatched); + + if ($order->trans_no!=0) + amount_cell($stock_item->qty_done); + + label_cell($stock_item->units); + amount_cell($stock_item->price); + + percent_cell($stock_item->discount_percent * 100); + amount_cell($line_total); + + if ($editable_items) + { + edit_link_cell(SID . "Edit=$line_no"); + delete_link_cell(SID . "Delete=$line_no"); + } + end_row(); + } + else { sales_order_item_controls($order, $line_no); } @@ -143,7 +143,7 @@ function display_order_summary($title, &$order, $editable_items=false) if (!isset($_GET['Edit']) && $editable_items) sales_order_item_controls($order); - $display_total = number_format2($total,user_price_dec()); + $display_total = price_format($total); label_row(_("Total Excluding Shipping"), $display_total, "colspan=6 align=right", "nowrap align=right"); @@ -160,82 +160,83 @@ function display_order_header(&$order, $editable, $date_text, $display_tax_group echo ""; $customer_error = ""; - $change_prices = 0; + $change_prices = 0; if (isset($order) && !$editable) { // can't change the customer/branch if items already received on this order echo $order->customer_name . " - " . $order->deliver_to; - hidden('customer_id', $order->customer_id); - hidden('branch_id', $order->Branch); - } - else + hidden('customer_id', $order->customer_id); + hidden('branch_id', $order->Branch); + hidden('sales_type', $order->sales_type); + } + else { - if (!isset($_POST['customer_id']) && (get_global_customer() != reserved_words::get_all())) - $_POST['customer_id'] = get_global_customer(); + if (!isset($_POST['customer_id']) && (get_global_customer() != reserved_words::get_all())) + $_POST['customer_id'] = get_global_customer(); - customer_list_row(_("Customer:"), 'customer_id', null, false, true); + customer_list_row(_("Customer:"), 'customer_id', null, false, true); - if (!isset($_POST['delivery_date'])) - { + if (!isset($_POST['delivery_date'])) + { if ($order->trans_type==10) - $_POST['delivery_date'] = $_SESSION['Items']->due_date = + $_POST['delivery_date'] = $_SESSION['Items']->due_date = get_invoice_duedate($_POST['customer_id'], $_POST['OrderDate']); - else - $_POST['delivery_date'] = $_SESSION['Items']->due_date = + else + $_POST['delivery_date'] = $_SESSION['Items']->due_date = add_days($_POST['OrderDate'], 10); // FIX this should be in company prefs - } - if ($order->customer_id != $_POST['customer_id']) - { + } + if ($order->customer_id != $_POST['customer_id']) + { // customer has changed // delete all the order items - drastic but necessary because of // change of currency, sales type, etc - // $order->clear_items(); + // $order->clear_items(); // clear the branch selection unset($_POST['branch_id']); - } - if (!isset($_POST['branch_id'])) + } + if (!isset($_POST['branch_id'])) $_POST['branch_id'] = ""; customer_branches_list_row(_("Branch:"), $_POST['customer_id'], 'branch_id', null, false, true, true); - if (!isset($_POST['branch_id']) || $_POST['branch_id'] == "") - { - $customer_error = _("The selected customer does not have any branches. Please create at least one branch."); - unset($_POST['branch_id']); - $order->Branch = 0; - } else - { - //set_global_customer($_POST['customer_id']); - if (($order->customer_id != $_POST['customer_id']) || - ($order->Branch != $_POST['branch_id'])) { - - $old_order = (PHP_VERSION<5) ? $order : clone( $order ); - $customer_error = get_customer_details_to_order($order, $_POST['customer_id'], $_POST['branch_id']); - $_POST['Location'] = $order->Location; - $_POST['deliver_to'] = $order->deliver_to; - $_POST['delivery_address'] = $order->delivery_address; - $_POST['phone'] = $order->phone; - $_POST['sales_type'] = $order->sales_type; - - // change prices if necessary - // what about discount in template case? - if ( $old_order->customer_currency!=$order->customer_currency - || $old_order->sales_type!=$order->sales_type - // || $old_order->default_discount!=$order->default_discount - ) { - $change_prices = 1; - } - - } - } // changed branch - set_global_customer($_POST['customer_id']); + if (!isset($_POST['branch_id']) || $_POST['branch_id'] == "") + { + $customer_error = _("The selected customer does not have any branches. Please create at least one branch."); + unset($_POST['branch_id']); + $order->Branch = 0; + } else + { + //set_global_customer($_POST['customer_id']); + if (($order->customer_id != $_POST['customer_id']) || + ($order->Branch != $_POST['branch_id'])) { + + $old_order = (PHP_VERSION<5) ? $order : clone( $order ); + $customer_error = get_customer_details_to_order($order, $_POST['customer_id'], $_POST['branch_id']); + $_POST['Location'] = $order->Location; + $_POST['deliver_to'] = $order->deliver_to; + $_POST['delivery_address'] = $order->delivery_address; + $_POST['phone'] = $order->phone; + $_POST['sales_type'] = $order->sales_type; + + // change prices if necessary + // what about discount in template case? + if ( $old_order->customer_currency!=$order->customer_currency + || $old_order->sales_type!=$order->sales_type + // || $old_order->default_discount!=$order->default_discount + ) { + $change_prices = 1; + } + + } + } // changed branch + set_global_customer($_POST['customer_id']); } if ($_SESSION['Items']->trans_type!=30) { - ref_cells(_("Reference").':', 'ref', null, ""); + ref_cells(_("Reference").':', 'ref', null, ''); } echo "
"; @@ -246,34 +247,35 @@ function display_order_header(&$order, $editable, $date_text, $display_tax_group { echo ""; label_row(_("Customer Currency:"), $order->customer_currency); - exchange_rate_display($order->customer_currency, get_company_currency(), - ($editable?$_POST['OrderDate']:$order->document_date), $editable); + exchange_rate_display($order->customer_currency, get_company_currency(), + ($editable ? $_POST['OrderDate'] : $order->document_date), $editable); echo "
"; echo ""; // outer table } - if( $order->sales_type != $_POST['sales_type']) { - $myrow = get_sales_type($_POST['sales_type']); - $order->set_sales_type($myrow['id'], $myrow['sales_type'], + if( $order->sales_type != $_POST['sales_type']) { + $myrow = get_sales_type($_POST['sales_type']); + $order->set_sales_type($myrow['id'], $myrow['sales_type'], $myrow['tax_included']); - $change_prices = 1; + $change_prices = 1; } - if($change_prices!=0) - { - foreach ($order->line_items as $line_no=>$item) { + if($change_prices!=0) + { + foreach ($order->line_items as $line_no=>$item) { $line = &$order->line_items[$line_no]; $line->price = get_price($line->stock_id, $order->customer_currency, - $order->sales_type); + $order->sales_type); // $line->discount_percent = $order->default_discount; - } + } } echo ""; if($editable) - sales_types_list_row(_("Price List"), 'sales_type', $_POST['sales_type'], true); - else - label_row(_("Price List:"), $order->sales_type_name); + sales_types_list_row(_("Price List"), 'sales_type', $_POST['sales_type'], true); + else { + label_row(_("Price List:"), $order->sales_type_name); + } label_row(_("Customer Discount:"), ($order->default_discount * 100) . "%"); echo "
"; @@ -281,28 +283,28 @@ function display_order_header(&$order, $editable, $date_text, $display_tax_group echo ""; - if ($editable) + if ($editable) { - if (!isset($_POST['OrderDate']) || $_POST['OrderDate'] == "") - $_POST['OrderDate'] = $order->document_date; + if (!isset($_POST['OrderDate']) || $_POST['OrderDate'] == "") + $_POST['OrderDate'] = $order->document_date; date_row($date_text, 'OrderDate'); } - else + else { label_row($date_text, $order->document_date); hidden('OrderDate', $order->document_date); } - if ($display_tax_group) + if ($display_tax_group) { -/* if ($editable) +/* if ($editable) { - if (!isset($_POST['tax_group_id'])) - $_POST['tax_group_id'] = $_SESSION['Items']->tax_group_id; - tax_groups_list_row(_("Tax Group:"), 'tax_group_id', $_POST['tax_group_id'], true); - } - else + if (!isset($_POST['tax_group_id'])) + $_POST['tax_group_id'] = $_SESSION['Items']->tax_group_id; + tax_groups_list_row(_("Tax Group:"), 'tax_group_id', $_POST['tax_group_id'], true); + } + else */ { label_row(_("Tax Group:"), $order->tax_group_name); hidden('tax_group_id', $_SESSION['Items']->tax_group_id); @@ -311,7 +313,7 @@ function display_order_header(&$order, $editable, $date_text, $display_tax_group echo "
"; echo ""; - + end_table(1); // outer table return $customer_error; @@ -327,20 +329,20 @@ function sales_order_item_controls(&$order, $line_no=-1) if (!isset($_POST['stock_id'])) $_POST['stock_id'] = $order->line_items[$_GET['Edit']]->stock_id; if (!isset($_POST['qty']) || ($_POST['qty'] == "")) - $_POST['qty'] = $order->line_items[$_GET['Edit']]->qty_dispatched; + $_POST['qty'] = qty_format($order->line_items[$_GET['Edit']]->qty_dispatched); if (!isset($_POST['price']) || ($_POST['price'] == "")) - $_POST['price'] = $order->line_items[$_GET['Edit']]->price; + $_POST['price'] = price_format($order->line_items[$_GET['Edit']]->price); if (!isset($_POST['Disc']) || ($_POST['Disc'] == "")) - $_POST['Disc'] = ($order->line_items[$_GET['Edit']]->discount_percent)*100; + $_POST['Disc'] = percent_format($order->line_items[$_GET['Edit']]->discount_percent*100); $_POST['units'] = $order->line_items[$_GET['Edit']]->units; hidden('stock_id', $_POST['stock_id']); label_cell($_POST['stock_id']); label_cell($order->line_items[$line_no]->item_description); - } - else + } + else { - global $no_item_list; + global $no_item_list; if ($no_item_list) { echo "\n"; @@ -349,39 +351,39 @@ function sales_order_item_controls(&$order, $line_no=-1) } else { - text_cells(null, "StockID2", "", 12, 10, "", "", "onkeyup='recalcAccounts();' onKeyDown='if (event.keyCode==13) event.keyCode=9;' onblur='return setAccount(0, true);'"); + text_cells(null, "StockID2", "", 12, 10, "", "", "onkeyup='recalcAccounts();' onKeyDown='if (event.keyCode==13) event.keyCode=9;' onblur='return setAccount(0, true);'"); stock_items_list_cells(null, 'stock_id', null, false, false, "onchange='return setAccount(1, true)'"); } $item_info = get_item_edit_info($_POST['stock_id']); $_POST['units'] = $item_info["units"]; - $_POST['qty'] = 1; - $_POST['price'] = get_price ($_POST['stock_id'], - $order->customer_currency, $order->sales_type); + $_POST['qty'] = qty_format(1); + $_POST['price'] = price_format(get_price ($_POST['stock_id'], + $order->customer_currency, $order->sales_type)); // default to the customer's discount % - $_POST['Disc'] = $order->default_discount * 100; + $_POST['Disc'] = percent_format($order->default_discount * 100); } - text_cells(null, 'qty', $_POST['qty'], 12, 15); + amount_cells(null, 'qty', qty_format($_POST['qty'])); if ($order->trans_no!=0) { - amount_cell($line_no==-1 ? 0 :$order->line_items[$line_no]->qty_done); + amount_cell($line_no==-1 ? 0 :$order->line_items[$line_no]->qty_done); } label_cell($_POST['units']); amount_cells(null, 'price'); - text_cells(null, 'Disc', $_POST['Disc'], 7, 5); + small_amount_cells(null, 'Disc', percent_format($_POST['Disc'])); $line_total = $_POST['qty'] * $_POST['price'] * (1 - $_POST['Disc'] / 100); amount_cell($line_total); - if (isset($_GET['Edit'])) + if (isset($_GET['Edit'])) { - submit_cells('UpdateItem', _("Update")); - submit_cells('CancelItemChanges', _("Cancel")); + submit_cells('UpdateItem', _("Update")); + submit_cells('CancelItemChanges', _("Cancel")); hidden('LineNo', $line_no); - } - else + } + else { submit_cells('AddItem', _("Add Item"), "colspan=2"); } @@ -394,56 +396,57 @@ function sales_order_item_controls(&$order, $line_no=-1) function display_delivery_details(&$order) { global $table_style2; - if ($order->trans_type==10) + if ($order->trans_type==10) { $title = _("Delivery Details"); $delname = _("Due Date").':'; - } - elseif ($order->trans_type==13) + } + elseif ($order->trans_type==13) { $title = _("Invoice Delivery Details"); $delname = _("Invoice before").':'; - } - else + } + else { $title = _("Order Delivery Details"); $delname = _("Required Delivery Date").':'; } display_heading($title); - echo "
"; - start_table("$table_style2 width=90%"); - echo ""; // outer table + echo "
"; + start_table("$table_style2 width=90%"); + echo ""; // outer table - echo ""; + echo "
"; // echo $order->Location, $_POST['Location']; - locations_list_row(_("Deliver from Location:"), 'Location', $_POST['Location']); + locations_list_row(_("Deliver from Location:"), 'Location', $_POST['Location']); - date_row($delname, 'delivery_date', $order->due_date, 0, 0, 0); + date_row($delname, 'delivery_date', $order->due_date, 0, 0, 0); - text_row(_("Deliver To:"), 'deliver_to', $order->deliver_to, 40, 40); + text_row(_("Deliver To:"), 'deliver_to', $order->deliver_to, 40, 40); - textarea_row(_("Address:"), 'delivery_address', $order->delivery_address, 35, 5); - text_row(_("Contact Phone Number:"), 'phone', $order->phone, 25, 25); + textarea_row(_("Address:"), 'delivery_address', $order->delivery_address, 35, 5); + text_row(_("Contact Phone Number:"), 'phone', $order->phone, 25, 25); - echo "
"; + echo ""; - echo ""; // outer table + echo ""; // outer table - echo ""; + echo "
"; - text_row(_("Customer Reference:"), 'cust_ref', $order->cust_ref, 25, 25); - textarea_row(_("Comments:"), "Comments", $order->Comments, 31, 5); + text_row(_("Customer Reference:"), 'cust_ref', $order->cust_ref, 25, 25); + textarea_row(_("Comments:"), "Comments", $order->Comments, 31, 5); - text_row(_("Shipping Charge:"), 'freight_cost', $order->freight_cost, 10, 10); + small_amount_row(_("Shipping Charge:"), 'freight_cost', + price_format($_POST['freight_cost'])); - shippers_list_row(_("Shipping Company:"), 'ship_via', $order->ship_via); + shippers_list_row(_("Shipping Company:"), 'ship_via', $order->ship_via); - echo "
"; + echo ""; - echo ""; - end_table(1); // outer table + echo ""; + end_table(1); // outer table } ?> \ No newline at end of file diff --git a/sales/manage/customers.php b/sales/manage/customers.php index 5a57732f..bba42966 100644 --- a/sales/manage/customers.php +++ b/sales/manage/customers.php @@ -31,42 +31,24 @@ function can_process() return false; } - if (!is_numeric( $_POST['credit_limit'])) + if (!check_num('credit_limit', 0)) { - display_error(_("The credit limit must be numeric.")); + display_error(_("The credit limit must be numeric and not less than zero.")); return false; } - if (!is_numeric( $_POST['pymt_discount'])) + if (!check_num('pymt_discount', 0, 100)) { - display_error(_("The payment discount must be numeric.")); + display_error(_("The payment discount must be numeric and is expected to be less than 100% and greater than or equal to 0.")); return false; } - if (!is_numeric( $_POST['discount'])) + if (!check_num('discount', 0, 100)) { - display_error(_("The discount percentage must be numeric.")); + display_error(_("The discount percentage must be numeric and is expected to be less than 100% and greater than or equal to 0.")); return false; } - - if ($_POST['credit_limit'] < 0) - { - display_error(_("The credit limit must be a positive number.")); - return false; - } - - if (($_POST['pymt_discount'] >= 100) || ($_POST['pymt_discount'] < 0)) - { - display_error(_("The payment discount is expected to be less than 100% and greater than or equal to 0.")); - return false; - } - - if (($_POST['discount'] >= 100) || ($_POST['discount'] < 0)) - { - display_error(_("The discount percent is expected to be less than 100 and greater than or equal to 0.")); - return false; - } - + return true; } @@ -81,7 +63,6 @@ function handle_submit() if (!isset($_POST['New'])) { - // Sherifoz 22.06.03 convert percent to fraction $sql = "UPDATE ".TB_PREF."debtors_master SET name='" . $_POST['CustName'] . "', address='" . $_POST['address'] . "', tax_id='" . $_POST['tax_id'] . "', @@ -91,9 +72,9 @@ function handle_submit() dimension2_id=" . $_POST['dimension2_id'] . ", credit_status='" . $_POST['credit_status'] . "', payment_terms='" . $_POST['payment_terms'] . "', - discount=" . ($_POST['discount']) / 100 . ", - pymt_discount=" . ($_POST['pymt_discount']) / 100 . ", - credit_limit=" . $_POST['credit_limit'] . ", + discount=" . input_num('discount') / 100 . ", + pymt_discount=" . input_num('pymt_discount') / 100 . ", + credit_limit=" . input_num('credit_limit') . ", sales_type = '" . $_POST['sales_type'] . "' WHERE debtor_no = '" . $_POST['customer_id'] . "'"; @@ -111,8 +92,8 @@ function handle_submit() curr_code, credit_status, payment_terms, discount, pymt_discount,credit_limit, sales_type) VALUES ('" . $_POST['CustName'] ."', '" . $_POST['address'] . "', '" . $_POST['tax_id'] . "', '" . $_POST['email'] . "', " . $_POST['dimension_id'] . ", " . $_POST['dimension2_id'] . ", '" . $_POST['curr_code'] . "', - " . $_POST['credit_status'] . ", '" . $_POST['payment_terms'] . "', " . ($_POST['discount'])/100 . ", - " . ($_POST['pymt_discount'])/100 . ", " . $_POST['credit_limit'] . ", '" . $_POST['sales_type'] . "')"; + " . $_POST['credit_status'] . ", '" . $_POST['payment_terms'] . "', " . input_num('discount')/100 . ", + " . input_num('pymt_discount')/100 . ", " . $_POST['credit_limit'] . ", '" . $_POST['sales_type'] . "')"; db_query($sql,"The customer could not be added"); @@ -244,8 +225,8 @@ if (isset($_POST['New'])) $_POST['curr_code'] = get_company_currency(); $_POST['credit_status'] = -1; $_POST['payment_terms'] = ''; - $_POST['discount'] = $_POST['pymt_discount'] = 0; - $_POST['credit_limit'] = sys_prefs::default_credit_limit(); + $_POST['discount'] = $_POST['pymt_discount'] = percent_format(0); + $_POST['credit_limit'] = price_format(sys_prefs::default_credit_limit()); } else { @@ -265,9 +246,9 @@ else $_POST['curr_code'] = $myrow["curr_code"]; $_POST['credit_status'] = $myrow["credit_status"]; $_POST['payment_terms'] = $myrow["payment_terms"]; - $_POST['discount'] = $myrow["discount"] * 100; // Sherifoz 21.6.03 convert to displayable percentage - $_POST['pymt_discount'] = $myrow["pymt_discount"] * 100; // Sherifoz 21.6.03 convert to displayable percentage - $_POST['credit_limit'] = $myrow["credit_limit"]; + $_POST['discount'] = percent_format($myrow["discount"] * 100); + $_POST['pymt_discount'] = percent_format($myrow["pymt_discount"] * 100); + $_POST['credit_limit'] = price_format($myrow["credit_limit"]); } text_row(_("Customer Name:"), 'CustName', $_POST['CustName'], 40, 40); @@ -304,9 +285,9 @@ if ($dim < 1) if ($dim < 2) hidden('dimension2_id', 0); -text_row(_("Discount Percent:"), 'discount', $_POST['discount'], 5, 4); -text_row(_("Prompt Payment Discount Percent:"), 'pymt_discount', $_POST['pymt_discount'], 5, 4); -text_row(_("Credit Limit:"), 'credit_limit', $_POST['credit_limit'], 16, 14); +percent_row(_("Discount Percent:"), 'discount', $_POST['discount']); +percent_row(_("Prompt Payment Discount Percent:"), 'pymt_discount', $_POST['pymt_discount']); +amount_row(_("Credit Limit:"), 'credit_limit', $_POST['credit_limit']); payment_terms_list_row(_("Payment Terms:"), 'payment_terms', $_POST['payment_terms']); credit_status_list_row(_("Credit Status:"), 'credit_status', $_POST['credit_status']); diff --git a/sales/manage/sales_people.php b/sales/manage/sales_people.php index b8bc94bc..e2c4ed43 100644 --- a/sales/manage/sales_people.php +++ b/sales/manage/sales_people.php @@ -41,9 +41,9 @@ if (isset($_POST['ADD_ITEM']) || isset($_POST['UPDATE_ITEM'])) salesman_phone='" . $_POST['salesman_phone'] . "', salesman_fax='" . $_POST['salesman_fax'] . "', salesman_email='" . $_POST['salesman_email'] . "', - provision=".$_POST['provision'].", - break_pt=".$_POST['break_pt'].", - provision2=".$_POST['provision2']." + provision=".input_num('provision').", + break_pt=".input_num('break_pt').", + provision2=".input_num('provision2')." WHERE salesman_code = '$selected_id'"; } else @@ -51,8 +51,8 @@ if (isset($_POST['ADD_ITEM']) || isset($_POST['UPDATE_ITEM'])) /*Selected group is null cos no item selected on first time round so must be adding a record must be submitting new entries in the new Sales-person form */ $sql = "INSERT INTO ".TB_PREF."salesman (salesman_name, salesman_phone, salesman_fax, salesman_email, provision, break_pt, provision2) - VALUES ('" . $_POST['salesman_name'] . "', '" . $_POST['salesman_phone'] . "', '" . $_POST['salesman_fax'] . "', '" . $_POST['salesman_email'] . "', ". - $_POST['provision'].", ".$_POST['break_pt'].", ".$_POST['provision2'].")"; + VALUES ('" . $_POST['salesman_name'] . "', '" .$_POST['salesman_phone'] . "', '" . $_POST['salesman_fax'] . "', '" . $_POST['salesman_email'] . "', ". + input_num('provision').", ".input_num('break_pt').", ".input_num('provision2').")"; } //run the sql from either of the above possibilites @@ -103,9 +103,9 @@ while ($myrow = db_fetch($result)) label_cell($myrow["salesman_phone"]); label_cell($myrow["salesman_fax"]); label_cell($myrow["salesman_email"]); - percent_cell($myrow["provision"]); + label_cell(percent_format($myrow["provision"])." %", "nowrap align=right"); amount_cell($myrow["break_pt"]); - percent_cell($myrow["provision2"]); + label_cell(percent_format($myrow["provision2"])." %", "nowrap align=right"); edit_link_cell(SID . "selected_id=" . $myrow["salesman_code"]); delete_link_cell(SID . "selected_id=" . $myrow["salesman_code"]. "&delete=1"); end_row(); @@ -134,9 +134,9 @@ if (isset($selected_id)) $_POST['salesman_phone'] = $myrow["salesman_phone"]; $_POST['salesman_fax'] = $myrow["salesman_fax"]; $_POST['salesman_email'] = $myrow["salesman_email"]; - $_POST['provision'] = $myrow["provision"]; - $_POST['break_pt'] = $myrow["break_pt"]; - $_POST['provision2'] = $myrow["provision2"]; + $_POST['provision'] = percent_format($myrow["provision"]); + $_POST['break_pt'] = price_format($myrow["break_pt"]); + $_POST['provision2'] = percent_format($myrow["provision2"]); hidden('selected_id', $selected_id); } diff --git a/sales/sales_order_entry.php b/sales/sales_order_entry.php index 780f26cf..39a90fe5 100644 --- a/sales/sales_order_entry.php +++ b/sales/sales_order_entry.php @@ -141,7 +141,7 @@ function copy_to_cart() $cart->document_date = $_POST['OrderDate']; $cart->due_date = $_POST['delivery_date']; $cart->cust_ref = $_POST['cust_ref']; - $cart->freight_cost = $_POST['freight_cost']; + $cart->freight_cost = input_num('freight_cost'); $cart->deliver_to = $_POST['deliver_to']; $cart->delivery_address = $_POST['delivery_address']; $cart->phone = $_POST['phone']; @@ -170,7 +170,7 @@ function copy_from_cart() $_POST['OrderDate'] = $cart->document_date; $_POST['delivery_date'] = $cart->due_date; $_POST['cust_ref'] = $cart->cust_ref; - $_POST['freight_cost'] = $cart->freight_cost; + $_POST['freight_cost'] = price_format($cart->freight_cost); $_POST['deliver_to'] = $cart->deliver_to; $_POST['delivery_address'] = $cart->delivery_address; @@ -208,9 +208,9 @@ function can_process() { } if ($_POST['freight_cost'] == "") - $_POST['freight_cost'] = 0; + $_POST['freight_cost'] = price_format(0); - if (!is_numeric($_POST['freight_cost'])) { + if (!check_num('freight_cost',0)) { display_error(_("The shipping cost entered is expected to be numeric.")); return false; } @@ -259,15 +259,15 @@ if (isset($_POST['ProcessOrder']) && can_process()) { function check_item_data() { - if (!is_numeric($_POST['qty']) || $_POST['qty'] < 0 || $_POST['Disc'] > 100 || $_POST['Disc'] < 0) { + + if (!check_num('qty', 0) || !check_num('Disc', 0, 100)) { display_error( _("The item could not be updated because you are attempting to set the quantity ordered to less than 0, or the discount percent to more than 100.")); return false; - } elseif (!is_numeric($_POST['price']) || $_POST['price'] < 0) { - - display_error( _("Price for item must be entered and can not be less then 0")); + } elseif (!check_num('price', 0)) { + display_error( _("Price for item must be entered and can not be less than 0")); return false; } elseif (isset($_POST['LineNo']) && isset($_SESSION['Items']->line_items[$_POST['LineNo']]) - && $_SESSION['Items']->line_items[$_POST['LineNo']]->qty_done > $_POST['qty']) { + && !check_num('qty', $_SESSION['Items']->line_items[$_POST['LineNo']]->qty_done)) { display_error(_("You attempting to make the quantity ordered a quantity less than has already been delivered. The quantity delivered cannot be modified retrospectively.")); return false; @@ -280,9 +280,11 @@ function check_item_data() function handle_update_item() { if ($_POST['UpdateItem'] != '' && check_item_data()) { - $_SESSION['Items']->update_cart_item($_POST['LineNo'], $_POST['qty'], - $_POST['price'], ($_POST['Disc'] / 100)); + $_SESSION['Items']->update_cart_item($_POST['LineNo'], + input_num('qty'), input_num('price'), + input_num('Disc') / 100 ); } + copy_from_cart(); } //-------------------------------------------------------------------------------- @@ -306,8 +308,8 @@ function handle_new_item() if (!check_item_data()) { return; } - add_to_order($_SESSION['Items'], $_POST['stock_id'], $_POST['qty'], - $_POST['price'], $_POST['Disc'] / 100); + add_to_order($_SESSION['Items'], $_POST['stock_id'], input_num('qty'), + input_num('price'), input_num('Disc') / 100); $_POST['StockID2'] = $_POST['stock_id'] = ""; } @@ -378,6 +380,10 @@ function create_cart($type, $trans_no) //-------------------------------------------------------------------------------- + +if (isset($_GET['Delete']) || isset($_GET['Edit'])) + copy_from_cart(); // GET method need form restore + if (isset($_POST['CancelOrder'])) handle_cancel_order(); diff --git a/sales/view/view_credit.php b/sales/view/view_credit.php index e1e7326c..0ba00089 100644 --- a/sales/view/view_credit.php +++ b/sales/view/view_credit.php @@ -99,7 +99,7 @@ if (db_num_rows($result) > 0) } else { - $display_discount = number_format2($myrow2["discount_percent"]*100,user_percent_dec()) . "%"; + $display_discount = percent_format($myrow2["discount_percent"]*100) . "%"; } label_cell($myrow2["stock_id"]); @@ -115,11 +115,11 @@ if (db_num_rows($result) > 0) else display_note(_("There are no line items on this credit note."), 1, 2); -$display_sub_tot = number_format2($sub_total,user_price_dec()); -$display_freight = number_format2($myrow["ov_freight"],user_price_dec()); +$display_sub_tot = price_format($sub_total); +$display_freight = price_format($myrow["ov_freight"]); $credit_total = $myrow["ov_freight"]+$myrow["ov_gst"]+$myrow["ov_amount"]+$myrow["ov_freight_tax"]; -$display_total = number_format2($credit_total,user_price_dec()); +$display_total = price_format($credit_total); /*Print out the invoice text entered */ if ($sub_total != 0) diff --git a/sales/view/view_dispatch.php b/sales/view/view_dispatch.php index 84bf2288..8a4460c0 100644 --- a/sales/view/view_dispatch.php +++ b/sales/view/view_dispatch.php @@ -120,7 +120,7 @@ if (db_num_rows($result) > 0) } else { - $display_discount = number_format2($myrow2["discount_percent"]*100,user_percent_dec()) . "%"; + $display_discount = percent_format($myrow2["discount_percent"]*100) . "%"; } label_cell($myrow2["stock_id"]); @@ -137,8 +137,8 @@ if (db_num_rows($result) > 0) else display_note(_("There are no line items on this dispatch."), 1, 2); -$display_sub_tot = number_format2($sub_total,user_price_dec()); -$display_freight = number_format2($myrow["ov_freight"],user_price_dec()); +$display_sub_tot = price_format($sub_total); +$display_freight = price_format($myrow["ov_freight"]); /*Print out the delivery note text entered */ label_row(_("Sub-total"), $display_sub_tot, "colspan=6 align=right", @@ -148,7 +148,7 @@ label_row(_("Shipping"), $display_freight, "colspan=6 align=right", "nowrap alig $tax_items = get_customer_trans_tax_details(13, $trans_id); display_customer_trans_tax_details($tax_items, 6); -$display_total = number_format2($myrow["ov_freight"]+$myrow["ov_amount"]+$myrow["ov_freight_tax"]+$myrow["ov_gst"],user_price_dec()); +$display_total = price_format($myrow["ov_freight"]+$myrow["ov_amount"]+$myrow["ov_freight_tax"]+$myrow["ov_gst"]); label_row(_("TOTAL VALUE"), $display_total, "colspan=6 align=right", "nowrap align=right"); diff --git a/sales/view/view_invoice.php b/sales/view/view_invoice.php index 90820a79..b6da97d4 100644 --- a/sales/view/view_invoice.php +++ b/sales/view/view_invoice.php @@ -120,7 +120,7 @@ if (db_num_rows($result) > 0) } else { - $display_discount = number_format2($myrow2["discount_percent"]*100,user_percent_dec()) . "%"; + $display_discount = percent_format2($myrow2["discount_percent"]*100) . "%"; } label_cell($myrow2["stock_id"]); @@ -137,8 +137,8 @@ if (db_num_rows($result) > 0) else display_note(_("There are no line items on this invoice."), 1, 2); -$display_sub_tot = number_format2($sub_total,user_price_dec()); -$display_freight = number_format2($myrow["ov_freight"],user_price_dec()); +$display_sub_tot = price_format($sub_total); +$display_freight = price_format($myrow["ov_freight"]); /*Print out the invoice text entered */ label_row(_("Sub-total"), $display_sub_tot, "colspan=6 align=right", @@ -148,7 +148,7 @@ label_row(_("Shipping"), $display_freight, "colspan=6 align=right", "nowrap alig $tax_items = get_customer_trans_tax_details(10, $trans_id); display_customer_trans_tax_details($tax_items, 6); -$display_total = number_format2($myrow["ov_freight"]+$myrow["ov_gst"]+$myrow["ov_amount"]+$myrow["ov_freight_tax"],user_price_dec()); +$display_total = price_format($myrow["ov_freight"]+$myrow["ov_gst"]+$myrow["ov_amount"]+$myrow["ov_freight_tax"]); label_row(_("TOTAL INVOICE"), $display_total, "colspan=6 align=right", "nowrap align=right"); diff --git a/sales/view/view_receipt.php b/sales/view/view_receipt.php index 16a8c580..13797b0a 100644 --- a/sales/view/view_receipt.php +++ b/sales/view/view_receipt.php @@ -28,8 +28,8 @@ label_cells(_("Date of Deposit"), sql2date($receipt['tran_date']), "class='table end_row(); start_row(); label_cells(_("Payment Currency"), $receipt['curr_code'], "class='tableheader2'"); -label_cells(_("Amount"), number_format2(-$receipt['ov_amount'], user_price_dec()), "class='tableheader2'"); -label_cells(_("Discount"), number_format2(-$receipt['ov_discount'], user_price_dec()), "class='tableheader2'"); +label_cells(_("Amount"), price_format($receipt['ov_amount']), "class='tableheader2'"); +label_cells(_("Discount"), price_format($receipt['ov_discount']), "class='tableheader2'"); end_row(); start_row(); label_cells(_("Payment Type"), $receipt['BankTransType'], "class='tableheader2'"); diff --git a/sales/view/view_sales_order.php b/sales/view/view_sales_order.php index 32cd1b74..76c58b45 100644 --- a/sales/view/view_sales_order.php +++ b/sales/view/view_sales_order.php @@ -90,7 +90,7 @@ while ($del_row = db_fetch($result)) } -label_row(null, number_format2($delivery_total,user_price_dec()), "", "colspan=4 align=right"); +label_row(null, price_format($delivery_total), "", "colspan=4 align=right"); end_table(); echo ""; @@ -123,7 +123,7 @@ while ($inv_row = db_fetch($result)) } -label_row(null, number_format2($invoices_total,user_price_dec()), "", "colspan=4 align=right"); +label_row(null, price_format($invoices_total), "", "colspan=4 align=right"); end_table(); @@ -155,7 +155,7 @@ while ($credits_row = db_fetch($result)) } -label_row(null, "" . number_format2(-$credits_total,user_price_dec()) . "", +label_row(null, "" . price_format(-$credits_total) . "", "", "colspan=4 align=right"); @@ -195,9 +195,9 @@ foreach ($_SESSION['Items']->line_items as $stock_item) { $items_total = $_SESSION['Items']->get_items_total(); -$display_total = number_format2($items_total + $_SESSION['Items']->freight_cost,user_price_dec()); +$display_total = price_format($items_total + $_SESSION['Items']->freight_cost); -label_row(_("Shipping"), number_format2($_SESSION['Items']->freight_cost,user_price_dec()), +label_row(_("Shipping"), price_format($_SESSION['Items']->freight_cost), "align=right colspan=6", "nowrap align=right"); label_row(_("Total Order Value"), $display_total, "align=right colspan=6", "nowrap align=right"); diff --git a/taxes/item_tax_types.php b/taxes/item_tax_types.php index 55175b70..d398e6c9 100644 --- a/taxes/item_tax_types.php +++ b/taxes/item_tax_types.php @@ -184,7 +184,7 @@ if (!isset($_POST['exempt']) || $_POST['exempt'] == 0) alt_table_row_color($k); label_cell($myrow["name"]); - percent_cell($myrow["rate"]); + label_cell(percent_format($myrow["rate"])." %", "nowrap align=right"); check_cells("", 'ExemptTax' . $myrow["id"], null); end_row(); } diff --git a/taxes/tax_groups.php b/taxes/tax_groups.php index af19925d..fdc06510 100644 --- a/taxes/tax_groups.php +++ b/taxes/tax_groups.php @@ -46,7 +46,7 @@ if (isset($_POST['ADD_ITEM']) || isset($_POST['UPDATE_ITEM'])) { if (isset($_POST['tax_type_id' . $i]) && $_POST['tax_type_id' . $i] != reserved_words::get_all_numeric() && - (!is_numeric($_POST['rate' . $i]) || $_POST['rate' . $i] < 0)) + !check_num('rate' . $i, 0)) { display_error( _("An entered tax rate is invalid or less than zero.")); $input_error = 1; @@ -68,7 +68,7 @@ if (isset($_POST['ADD_ITEM']) || isset($_POST['UPDATE_ITEM'])) $_POST['tax_type_id' . $i] != reserved_words::get_any_numeric()) { $taxes[] = $_POST['tax_type_id' . $i]; - $rates[] = $_POST['rate' . $i]; + $rates[] = input_num('rate' . $i); } } @@ -186,7 +186,7 @@ if ($selected_id != -1) while ($tax_item = db_fetch($items)) { $_POST['tax_type_id' . $i] = $tax_item["tax_type_id"]; - $_POST['rate' . $i] = $tax_item["rate"]; + $_POST['rate' . $i] = percent_format($tax_item["rate"]); $i ++; } } @@ -214,11 +214,11 @@ for ($i = 0; $i < 5; $i++) { $default_rate = get_tax_type_default_rate($_POST['tax_type_id' . $i]); - label_cell(number_format2($default_rate, user_percent_dec()), "nowrap align=right"); + label_cell(percent_format($default_rate), "nowrap align=right"); if (!isset($_POST['rate' . $i]) || $_POST['rate' . $i] == "") - $_POST['rate' . $i] = $default_rate; - text_cells(null, 'rate' . $i, $_POST['rate' . $i], 10, 10); + $_POST['rate' . $i] = percent_format($default_rate); + small_amount_cells(null, 'rate' . $i, $_POST['rate' . $i]); } end_row(); } diff --git a/taxes/tax_types.php b/taxes/tax_types.php index d70493c8..1ab9f955 100644 --- a/taxes/tax_types.php +++ b/taxes/tax_types.php @@ -25,14 +25,9 @@ function can_process() display_error(_("The tax type name cannot be empty.")); return false; } - elseif (!is_numeric($_POST['rate'])) + elseif (!check_num('rate', 0)) { - display_error( _("The default tax rate must be numeric.")); - return false; - } - elseif ($_POST['rate'] < 0) - { - display_error( _("The default tax rate cannot be less than zero.")); + display_error( _("The default tax rate must be numeric and not less than zero.")); return false; } @@ -45,7 +40,7 @@ if (isset($_POST['ADD_ITEM']) && can_process()) { add_tax_type($_POST['name'], $_POST['sales_gl_code'], - $_POST['purchasing_gl_code'], $_POST['rate']); + $_POST['purchasing_gl_code'], imput_num('rate')); meta_forward($_SERVER['PHP_SELF']); } @@ -55,7 +50,7 @@ if (isset($_POST['UPDATE_ITEM']) && can_process()) { update_tax_type($selected_id, $_POST['name'], - $_POST['sales_gl_code'], $_POST['purchasing_gl_code'], $_POST['rate']); + $_POST['sales_gl_code'], $_POST['purchasing_gl_code'], input_num('rate')); meta_forward($_SERVER['PHP_SELF']); } @@ -105,7 +100,7 @@ while ($myrow = db_fetch($result)) alt_table_row_color($k); label_cell($myrow["name"]); - label_cell(number_format2($myrow["rate"],user_percent_dec()), "align=right"); + label_cell(percent_format($myrow["rate"]), "align=right"); label_cell($myrow["sales_gl_code"] . " " . $myrow["SalesAccountName"]); label_cell($myrow["purchasing_gl_code"] . " " . $myrow["PurchasingAccountName"]); @@ -134,14 +129,14 @@ if (isset($selected_id)) $myrow = get_tax_type($selected_id); $_POST['name'] = $myrow["name"]; - $_POST['rate'] = $myrow["rate"]; + $_POST['rate'] = percent_format($myrow["rate"]); $_POST['sales_gl_code'] = $myrow["sales_gl_code"]; $_POST['purchasing_gl_code'] = $myrow["purchasing_gl_code"]; hidden('selected_id', $selected_id); } text_row_ex(_("Description:"), 'name', 50); -text_row_ex(_("Default Rate:"), 'rate', 10, 10, "", "%"); +small_amount_row(_("Default Rate:"), 'rate', '', "", "%"); gl_all_accounts_list_row(_("Sales GL Account:"), 'sales_gl_code', null); gl_all_accounts_list_row(_("Purchasing GL Account:"), 'purchasing_gl_code', null); -- 2.30.2