From: Janusz Dobrowolski Date: Sun, 16 Mar 2008 17:37:57 +0000 (+0000) Subject: User side percent/qty/amount/exrate input formatting via onblur handler. X-Git-Tag: v2.4.2~19^2~2173 X-Git-Url: https://delta.frontaccounting.com/gitweb/?p=fa-stable.git;a=commitdiff_plain;h=de3a75773afa86df1739d14f24399d6f7a46f809 User side percent/qty/amount/exrate input formatting via onblur handler. --- diff --git a/admin/gl_setup.php b/admin/gl_setup.php index 3af347c8..a0c99433 100644 --- a/admin/gl_setup.php +++ b/admin/gl_setup.php @@ -8,6 +8,7 @@ page(_("System and General GL Setup")); include_once($path_to_root . "/includes/date_functions.inc"); include_once($path_to_root . "/includes/ui.inc"); +include_once($path_to_root . "/includes/data_checks.inc"); include_once($path_to_root . "/admin/db/company_db.inc"); diff --git a/includes/ui/ui_input.inc b/includes/ui/ui_input.inc index aab5fd18..0831e610 100644 --- a/includes/ui/ui_input.inc +++ b/includes/ui/ui_input.inc @@ -164,25 +164,25 @@ function label_cell($label, $params="") function amount_cell($label, $bold=false) { if ($bold) - label_cell("".number_format2($label,user_price_dec())."", "nowrap align=right"); + label_cell("".price_format($label)."", "nowrap align=right"); else - label_cell(number_format2($label,user_price_dec()), "nowrap align=right"); + label_cell(price_format($label), "nowrap align=right"); } function percent_cell($label, $bold=false) { if ($bold) - label_cell("".number_format2($label,user_percent_dec())."", "nowrap align=right"); + label_cell("".percent_format($label)."", "nowrap align=right"); else - label_cell(number_format2($label,user_percent_dec()), "nowrap align=right"); + label_cell(percent_format($label), "nowrap align=right"); } -function qty_cell($label, $bold=false) +function qty_cell($label, $bold=false, $dec=null) { if ($bold) - label_cell("".number_format2($label,user_qty_dec())."", "nowrap align=right"); + label_cell("".qty_format($label, $dec)."", "nowrap align=right"); else - label_cell(number_format2($label,user_qty_dec()), "nowrap align=right"); + label_cell(qty_format($label, $dec), "nowrap align=right"); } function label_cells($label, $value, $params="", $params2="") @@ -331,11 +331,13 @@ function percent_row($label, $name, $init=null) $_POST[$name] = $init== null ? '' : $init; } - small_amount_row($label, $name, $_POST[$name], null, "%"); + small_amount_row($label, $name, $_POST[$name], null, "%", user_percent_dec()); } -function amount_cells_ex($label, $name, $size, $max=null, $init=null, $params=null, $post_label=null) +function amount_cells_ex($label, $name, $size, $max=null, $init=null, $params=null, $post_label=null, $dec=null) { + if (!isset($dec)) + $dec = user_price_dec(); if (!isset($_POST[$name]) || $_POST[$name] == "") { if ($init) @@ -351,7 +353,7 @@ function amount_cells_ex($label, $name, $size, $max=null, $init=null, $params=nu echo ""; - echo ""; + echo ""; if ($post_label) echo " " . $post_label; @@ -362,30 +364,69 @@ function amount_cells_ex($label, $name, $size, $max=null, $init=null, $params=nu //----------------------------------------------------------------------------------- -function amount_cells($label, $name, $init=null, $params=null, $post_label=null) +function amount_cells($label, $name, $init=null, $params=null, $post_label=null, $dec=null) { - amount_cells_ex($label, $name, 15, 15, $init, $params, $post_label); + amount_cells_ex($label, $name, 15, 15, $init, $params, $post_label, $dec); } -function amount_row($label, $name, $init=null, $params=null, $post_label=null) +function amount_row($label, $name, $init=null, $params=null, $post_label=null, $dec=null) { echo ""; - amount_cells($label, $name, $init, $params, $post_label); + amount_cells($label, $name, $init, $params, $post_label, $dec); echo "\n"; } -function small_amount_row($label, $name, $init=null, $params=null, $post_label=null) +function small_amount_row($label, $name, $init=null, $params=null, $post_label=null, $dec=null) { echo ""; - small_amount_cells($label, $name, $init, $params, $post_label); + small_amount_cells($label, $name, $init, $params, $post_label, $dec); echo "\n"; } //----------------------------------------------------------------------------------- -function small_amount_cells($label, $name, $init=null, $params=null, $post_label=null) +function qty_cells($label, $name, $init=null, $params=null, $post_label=null, $dec=null) { - amount_cells_ex($label, $name, 7, 12, $init, $params, $post_label); + if(!isset($dec)) + $dec = user_qty_dec(); + + amount_cells_ex($label, $name, 15, 15, $init, $params, $post_label, $dec); +} + +function qty_row($label, $name, $init=null, $params=null, $post_label=null, $dec=null) +{ + if(!isset($dec)) + $dec = user_qty_dec(); + + echo ""; + amount_cells($label, $name, $init, $params, $post_label, $dec); + echo "\n"; +} + +function small_qty_row($label, $name, $init=null, $params=null, $post_label=null, $dec=null) +{ + if(!isset($dec)) + $dec = user_qty_dec(); + + echo ""; + small_amount_cells($label, $name, $init, $params, $post_label, $dec); + echo "\n"; +} + +//----------------------------------------------------------------------------------- + +function small_amount_cells($label, $name, $init=null, $params=null, $post_label=null, $dec=null) +{ + amount_cells_ex($label, $name, 7, 12, $init, $params, $post_label, $dec); +} + +//----------------------------------------------------------------------------------- + +function small_qty_cells($label, $name, $init=null, $params=null, $post_label=null, $dec=null) +{ + if (!isset($dec)) + $dec = user_qty_dec(); + amount_cells_ex($label, $name, 7, 12, $init, $params, $post_label, $dec); } //----------------------------------------------------------------------------------- diff --git a/inventory/includes/item_adjustments_ui.inc b/inventory/includes/item_adjustments_ui.inc index bf88c7da..8a530b7d 100644 --- a/inventory/includes/item_adjustments_ui.inc +++ b/inventory/includes/item_adjustments_ui.inc @@ -149,7 +149,7 @@ function adjustment_edit_item_controls(&$order, $stock_id=null) $_POST['units'] = $item_info["units"]; } - amount_cells(null, 'qty', $_POST['qty']); + qty_cells(null, 'qty', $_POST['qty']); label_cell($_POST['units']); amount_cells(null, 'std_cost', $_POST['std_cost']); diff --git a/inventory/includes/stock_transfers_ui.inc b/inventory/includes/stock_transfers_ui.inc index c0395af4..9d3bbfa6 100644 --- a/inventory/includes/stock_transfers_ui.inc +++ b/inventory/includes/stock_transfers_ui.inc @@ -134,7 +134,7 @@ function transfer_edit_item_controls(&$order, $stock_id=null) } - small_amount_cells(null, 'qty', $_POST['qty']); + small_qty_cells(null, 'qty', $_POST['qty']); label_cell($_POST['units']); if (isset($_GET['Edit'])) diff --git a/inventory/purchasing_data.php b/inventory/purchasing_data.php index 51cd7fce..4d03d6fe 100644 --- a/inventory/purchasing_data.php +++ b/inventory/purchasing_data.php @@ -215,7 +215,8 @@ if (!isset($_POST['conversion_factor']) || $_POST['conversion_factor'] == "") { $_POST['conversion_factor'] = exrate_format(1); } -amount_row(_("Conversion Factor (to our UOM):"), 'conversion_factor', exrate_format($_POST['conversion_factor'])); +amount_row(_("Conversion Factor (to our UOM):"), 'conversion_factor', + exrate_format($_POST['conversion_factor']), null, null, user_exrate_dec() ); 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 3d92cebf..cfe3303c 100644 --- a/inventory/reorder_level.php +++ b/inventory/reorder_level.php @@ -66,7 +66,7 @@ while ($myrow = db_fetch($result)) $_POST[$myrow["loc_code"]] = qty_format($myrow["reorder_level"]); label_cell(number_format2($qoh,user_qty_dec()), "nowrap align='right'"); - amount_cells(null, $myrow["loc_code"]); + qty_cells(null, $myrow["loc_code"]); end_row(); $j++; If ($j == 12) diff --git a/manufacturing/manage/bom_edit.php b/manufacturing/manage/bom_edit.php index cfb15ad1..94cc504c 100644 --- a/manufacturing/manage/bom_edit.php +++ b/manufacturing/manage/bom_edit.php @@ -268,7 +268,7 @@ if (isset($_POST['stock_id'])) { $_POST['quantity'] = qty_format(1); } - amount_row(_("Quantity:"), 'quantity', $_POST['quantity']); + qty_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 4da03e6e..9abac4df 100644 --- a/manufacturing/work_order_entry.php +++ b/manufacturing/work_order_entry.php @@ -353,7 +353,7 @@ if (!isset($_POST['quantity'])) if ($_POST['type'] == wo_types::advanced()) { - amount_row(_("Quantity Required:"), 'quantity', 12); + qty_row(_("Quantity Required:"), 'quantity', 12); if ($_POST['released']) label_row(_("Quantity Manufactured:"), qty_format($_POST['units_issued'])); date_row(_("Date") . ":", 'date_'); @@ -361,7 +361,7 @@ if ($_POST['type'] == wo_types::advanced()) } else { - amount_row(_("Quantity:"), 'quantity', 12); + qty_row(_("Quantity:"), 'quantity', 12); date_row(_("Date") . ":", 'date_'); hidden('RequDate', ''); diff --git a/purchasing/allocations/supplier_allocate.php b/purchasing/allocations/supplier_allocate.php index e749e0fe..a0e3b86f 100644 --- a/purchasing/allocations/supplier_allocate.php +++ b/purchasing/allocations/supplier_allocate.php @@ -16,7 +16,7 @@ $js = ""; if ($use_popup_windows) $js .= get_js_open_window(900, 500); -$js .= get_js_allocate(); +add_js_allocate(); page(_("Allocate Supplier Payment or Credit Note"), false, false, "", $js); diff --git a/purchasing/includes/ui/po_ui.inc b/purchasing/includes/ui/po_ui.inc index b2322f99..893de6b4 100644 --- a/purchasing/includes/ui/po_ui.inc +++ b/purchasing/includes/ui/po_ui.inc @@ -314,7 +314,7 @@ function po_item_controls(&$order, $stock_id=null) $_POST['req_del_date'] = add_days(Today(), 10); } - amount_cells(null, 'qty', null); + qty_cells(null, 'qty', null); label_cell($_POST['units']); date_cells(null, 'req_del_date', null, 0, 0, 0); diff --git a/purchasing/po_entry_items.php b/purchasing/po_entry_items.php index 7a89b20b..7e30f39e 100644 --- a/purchasing/po_entry_items.php +++ b/purchasing/po_entry_items.php @@ -3,12 +3,12 @@ $page_security = 4; $path_to_root=".."; -include($path_to_root . "/purchasing/includes/po_class.inc"); +include_once($path_to_root . "/purchasing/includes/po_class.inc"); -include($path_to_root . "/includes/session.inc"); +include_once($path_to_root . "/includes/session.inc"); -include($path_to_root . "/includes/data_checks.inc"); -include($path_to_root . "/includes/manufacturing.inc"); +//include($path_to_root . "/includes/data_checks.inc"); +//include($path_to_root . "/includes/manufacturing.inc"); include_once($path_to_root . "/purchasing/includes/purchasing_ui.inc"); diff --git a/purchasing/po_receive_items.php b/purchasing/po_receive_items.php index 59791f46..836a0548 100644 --- a/purchasing/po_receive_items.php +++ b/purchasing/po_receive_items.php @@ -85,9 +85,9 @@ function display_po_receive_items() qty_cell($qty_outstanding); if ($qty_outstanding > 0) - amount_cells(null, $ln_itm->line_no, qty_format($ln_itm->receive_qty), "align=right"); + qty_cells(null, $ln_itm->line_no, qty_format($ln_itm->receive_qty), "align=right"); else - amount_cells(null, $ln_itm->line_no, qty_format($ln_itm->receive_qty), "align=right", + qty_cells(null, $ln_itm->line_no, qty_format($ln_itm->receive_qty), "align=right", "disabled"); amount_cell($ln_itm->price); diff --git a/purchasing/supplier_credit.php b/purchasing/supplier_credit.php index ff4c0724..680c988b 100644 --- a/purchasing/supplier_credit.php +++ b/purchasing/supplier_credit.php @@ -2,11 +2,11 @@ $path_to_root=".."; -include($path_to_root . "/purchasing/includes/supp_trans_class.inc"); +include_once($path_to_root . "/purchasing/includes/supp_trans_class.inc"); $page_security=5; -include($path_to_root . "/includes/session.inc"); +include_once($path_to_root . "/includes/session.inc"); include_once($path_to_root . "/includes/data_checks.inc"); diff --git a/purchasing/supplier_credit_grns.php b/purchasing/supplier_credit_grns.php index ab14148b..15ea0830 100644 --- a/purchasing/supplier_credit_grns.php +++ b/purchasing/supplier_credit_grns.php @@ -166,7 +166,7 @@ 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"]); - amount_cells(null, 'This_QuantityCredited', qty_format(max($myrow['quantity_inv'],0))); + qty_cells(null, 'This_QuantityCredited', qty_format(max($myrow['quantity_inv'],0))); amount_cell($myrow['unit_price']); amount_cells(null, 'ChgPrice', price_format($myrow['unit_price'])); end_row(); diff --git a/purchasing/supplier_invoice_grns.php b/purchasing/supplier_invoice_grns.php index 8cea6d8e..ecbfe168 100644 --- a/purchasing/supplier_invoice_grns.php +++ b/purchasing/supplier_invoice_grns.php @@ -202,7 +202,7 @@ if (isset($_POST['grn_item_id']) && $_POST['grn_item_id'] != "") label_cell($myrow['item_code']); label_cell($myrow['description']); qty_cell($myrow['QtyOstdg']); - amount_cells(null, 'this_quantity_inv', qty_format($myrow['QtyOstdg'])); + qty_cells(null, 'this_quantity_inv', qty_format($myrow['QtyOstdg'])); amount_cell($myrow['unit_price']); small_amount_cells(null, 'ChgPrice', price_format($myrow['unit_price'])); end_row(); diff --git a/purchasing/supplier_trans_gl.php b/purchasing/supplier_trans_gl.php index 1e120b45..fdec05f8 100644 --- a/purchasing/supplier_trans_gl.php +++ b/purchasing/supplier_trans_gl.php @@ -3,10 +3,10 @@ $page_security=5; $path_to_root=".."; -include($path_to_root . "/purchasing/includes/supp_trans_class.inc"); -include($path_to_root . "/includes/session.inc"); +include_once($path_to_root . "/purchasing/includes/supp_trans_class.inc"); +include_once($path_to_root . "/includes/session.inc"); -include($path_to_root . "/purchasing/includes/purchasing_ui.inc"); +include_once($path_to_root . "/purchasing/includes/purchasing_ui.inc"); $js = ""; if ($use_date_picker) $js .= get_js_date_picker(); diff --git a/sales/allocations/customer_allocate.php b/sales/allocations/customer_allocate.php index f8b96d5c..6d09d766 100644 --- a/sales/allocations/customer_allocate.php +++ b/sales/allocations/customer_allocate.php @@ -5,6 +5,7 @@ $page_security = 3; include($path_to_root . "/includes/ui/allocation_cart.inc"); include_once($path_to_root . "/includes/session.inc"); +include_once($path_to_root . "/includes/data_checks.inc"); include_once($path_to_root . "/sales/includes/sales_ui.inc"); include_once($path_to_root . "/sales/includes/sales_db.inc"); @@ -12,7 +13,7 @@ $js = ""; if ($use_popup_windows) $js .= get_js_open_window(900, 500); -$js .= get_js_allocate(); +add_js_allocate(); page(_("Allocate Customer Payment or Credit Note"), false, false, "", $js); diff --git a/sales/customer_delivery.php b/sales/customer_delivery.php index eca34468..2c0991ab 100644 --- a/sales/customer_delivery.php +++ b/sales/customer_delivery.php @@ -378,7 +378,7 @@ foreach ($_SESSION['Items']->line_items as $line=>$ln_itm) { label_cell($ln_itm->units); qty_cell($ln_itm->qty_done); - small_amount_cells(null, 'Line'.$line, qty_format($ln_itm->qty_dispatched)); + small_qty_cells(null, 'Line'.$line, qty_format($ln_itm->qty_dispatched)); $display_discount_percent = percent_format($ln_itm->discount_percent*100) . "%"; diff --git a/sales/customer_invoice.php b/sales/customer_invoice.php index c2ffcfe0..e8dadd9a 100644 --- a/sales/customer_invoice.php +++ b/sales/customer_invoice.php @@ -347,7 +347,7 @@ foreach ($_SESSION['Items']->line_items as $line=>$ln_itm) { hidden('Line' . $line, $ln_itm->qty_dispatched ); echo qty_format($ln_itm->qty_dispatched).''; } else { - small_amount_cells(null, 'Line'.$line, qty_format($ln_itm->qty_dispatched)); + small_qty_cells(null, 'Line'.$line, qty_format($ln_itm->qty_dispatched)); } $display_discount_percent = percent_format($ln_itm->discount_percent*100) . " %"; diff --git a/sales/includes/ui/sales_credit_ui.inc b/sales/includes/ui/sales_credit_ui.inc index 6fa90b12..3eb1a399 100644 --- a/sales/includes/ui/sales_credit_ui.inc +++ b/sales/includes/ui/sales_credit_ui.inc @@ -223,13 +223,13 @@ function credit_edit_item_controls(&$order, $line_no=-1) } - amount_cells(null, 'qty', $_POST['qty']); + qty_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']); amount_cells(null, 'price', null); - small_amount_cells(null, 'Disc', percent_format(0)); + small_amount_cells(null, 'Disc', percent_format(0), null, null, user_percent_dec()); 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 152724e1..23a2fc18 100644 --- a/sales/includes/ui/sales_order_ui.inc +++ b/sales/includes/ui/sales_order_ui.inc @@ -364,7 +364,7 @@ function sales_order_item_controls(&$order, $line_no=-1) $_POST['Disc'] = percent_format($order->default_discount * 100); } - amount_cells(null, 'qty', qty_format($_POST['qty'])); + qty_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); @@ -372,7 +372,7 @@ function sales_order_item_controls(&$order, $line_no=-1) label_cell($_POST['units']); amount_cells(null, 'price'); - small_amount_cells(null, 'Disc', percent_format($_POST['Disc'])); + small_amount_cells(null, 'Disc', percent_format($_POST['Disc']), null, null, user_percent_dec()); $line_total = $_POST['qty'] * $_POST['price'] * (1 - $_POST['Disc'] / 100); amount_cell($line_total); diff --git a/taxes/tax_groups.php b/taxes/tax_groups.php index fdc06510..f04e0bfa 100644 --- a/taxes/tax_groups.php +++ b/taxes/tax_groups.php @@ -218,7 +218,8 @@ for ($i = 0; $i < 5; $i++) if (!isset($_POST['rate' . $i]) || $_POST['rate' . $i] == "") $_POST['rate' . $i] = percent_format($default_rate); - small_amount_cells(null, 'rate' . $i, $_POST['rate' . $i]); + small_amount_cells(null, 'rate' . $i, $_POST['rate' . $i], null, null, + user_percent_dec()); } end_row(); } diff --git a/taxes/tax_types.php b/taxes/tax_types.php index 1ab9f955..f0cf4c81 100644 --- a/taxes/tax_types.php +++ b/taxes/tax_types.php @@ -136,7 +136,7 @@ if (isset($selected_id)) hidden('selected_id', $selected_id); } text_row_ex(_("Description:"), 'name', 50); -small_amount_row(_("Default Rate:"), 'rate', '', "", "%"); +small_amount_row(_("Default Rate:"), 'rate', '', "", "%", user_percent_dec()); gl_all_accounts_list_row(_("Sales GL Account:"), 'sales_gl_code', null); gl_all_accounts_list_row(_("Purchasing GL Account:"), 'purchasing_gl_code', null);