User side percent/qty/amount/exrate input formatting via onblur handler.
authorJanusz Dobrowolski <janusz@frontaccounting.eu>
Sun, 16 Mar 2008 17:37:57 +0000 (17:37 +0000)
committerJanusz Dobrowolski <janusz@frontaccounting.eu>
Sun, 16 Mar 2008 17:37:57 +0000 (17:37 +0000)
23 files changed:
admin/gl_setup.php
includes/ui/ui_input.inc
inventory/includes/item_adjustments_ui.inc
inventory/includes/stock_transfers_ui.inc
inventory/purchasing_data.php
inventory/reorder_level.php
manufacturing/manage/bom_edit.php
manufacturing/work_order_entry.php
purchasing/allocations/supplier_allocate.php
purchasing/includes/ui/po_ui.inc
purchasing/po_entry_items.php
purchasing/po_receive_items.php
purchasing/supplier_credit.php
purchasing/supplier_credit_grns.php
purchasing/supplier_invoice_grns.php
purchasing/supplier_trans_gl.php
sales/allocations/customer_allocate.php
sales/customer_delivery.php
sales/customer_invoice.php
sales/includes/ui/sales_credit_ui.inc
sales/includes/ui/sales_order_ui.inc
taxes/tax_groups.php
taxes/tax_types.php

index 3af347c8eb0586dc292ba9a268d6be719b9ce5df..a0c99433fb3871de91470d9318c5699d7f3b30b9 100644 (file)
@@ -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");
 
index aab5fd18c5d3873ea564282878d5de6060f26b41..0831e6103df0fd66369deac64cc2bbc30bfc66d1 100644 (file)
@@ -164,25 +164,25 @@ function label_cell($label, $params="")
 function amount_cell($label, $bold=false)
 {
        if ($bold)
-               label_cell("<b>".number_format2($label,user_price_dec())."</b>", "nowrap align=right");
+               label_cell("<b>".price_format($label)."</b>", "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("<b>".number_format2($label,user_percent_dec())."</b>", "nowrap align=right");
+               label_cell("<b>".percent_format($label)."</b>", "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("<b>".number_format2($label,user_qty_dec())."</b>", "nowrap align=right");
+               label_cell("<b>".qty_format($label, $dec)."</b>", "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 "<td>";
 
-       echo "<input class='amount' type=\"text\" name=\"$name\" size=\"$size\" maxlength=\"$max\" value=\"" . $_POST[$name]. "\">";
+       echo "<input class='amount' type=\"text\" name=\"$name\" size=\"$size\" maxlength=\"$max\" dec=\"$dec\" value=\"" . $_POST[$name]. "\">";
 
        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 "<tr>";
-       amount_cells($label, $name, $init, $params, $post_label);
+       amount_cells($label, $name, $init, $params, $post_label, $dec);
        echo "</tr>\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 "<tr>";
-       small_amount_cells($label, $name, $init, $params, $post_label);
+       small_amount_cells($label, $name, $init, $params, $post_label, $dec);
        echo "</tr>\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 "<tr>";
+       amount_cells($label, $name, $init, $params, $post_label, $dec);
+       echo "</tr>\n";
+}
+
+function small_qty_row($label, $name, $init=null, $params=null, $post_label=null, $dec=null)
+{
+       if(!isset($dec))
+         $dec = user_qty_dec();
+
+       echo "<tr>";
+       small_amount_cells($label, $name, $init, $params, $post_label, $dec);
+       echo "</tr>\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);
 }
 
 //-----------------------------------------------------------------------------------
index bf88c7dae5f7c41690e6997666a0a7a1d81d4337..8a530b7db97bf254689aa047b24cd3fc1ea77a09 100644 (file)
@@ -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']);
index c0395af47b3ad1ae95709e9b6618446066776d53..9d3bbfa65180c8882c2c56b5ddc1ecc6457da54e 100644 (file)
@@ -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'])) 
index 51cd7fce0602ad839a6acc6b65235affc5e86894..4d03d6feb1db2fecdce8323f8bfe31796ba5ee14 100644 (file)
@@ -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);
index 3d92cebfb108e652d6cb9fb324153ab020cfe119..cfe3303cb64b08b3da9f653f90a94f822555fc50 100644 (file)
@@ -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)
index cfb15ad15acfd5044b7b4e0e97c669f5f8d80c2d..94cc504c746759a850cbc263774972678b3c93b2 100644 (file)
@@ -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"));
index 4da03e6e0095d2ec8475a36d76dd385466401d07..9abac4df3f9dc4dc2ab9a08f3ae3bbf4046a8d71 100644 (file)
@@ -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', '');
 
index e749e0fea4e6a1446af95f6a077b121b793b6f25..a0e3b86fb187249097e1705797e2c2edfc6a12e6 100644 (file)
@@ -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);
 
index b2322f99c2d0535c9f806fa67e0ef48b4e3f8053..893de6b4a25cbf33d9e83eef1d296d63c9394035 100644 (file)
@@ -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);
index 7a89b20bfa2ded3eac02c24a7edee325410c17c5..7e30f39ec65313f6b6a676008dad891a76c5ae56 100644 (file)
@@ -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");
 
index 59791f468dbb3edbc22753cf148aeb47c842e5b8..836a05483ffc5874ecb9223d07501943efdf3509 100644 (file)
@@ -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);
index ff4c07249a78e311a8b525c3c2ccf297a5df2818..680c988b1f5195ce532c7f8ee2741f2f5f7b5756 100644 (file)
@@ -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");
 
index ab14148be3c95bd03d0f342d08696ae11f76d813..15ea083045bad55fd36608e2bfdfdc5e4efa0d57 100644 (file)
@@ -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();
index 8cea6d8ec1564765d7bb64480665805522762fe6..ecbfe1684bffefefa9a63e87a3e745d792f24de4 100644 (file)
@@ -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();
index 1e120b45587c19d0e1693519b5f7adf8f139c7b3..fdec05f83f6120e926de3eb23d8d735f5fe538aa 100644 (file)
@@ -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();
index f8b96d5ca14872965092358f82241cd4818e89f1..6d09d7665aa0a2cd6656b649c04657f16e2a76e7 100644 (file)
@@ -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);
 
index eca3446868a64aa6cda2b774f445016d6a117204..2c0991ab4f68a5a8bc401c4a8d55d34a0838441d 100644 (file)
@@ -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) . "%";
 
index c2ffcfe0382d3808e2072d01ae21d72de7e6f9f4..e8dadd9aeb81b9ccd9e4b485c8f18256510cdce9 100644 (file)
@@ -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).'</td>';
        } 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) . " %";
 
index 6fa90b12658ca7491a1016bb78706417df2fd1a6..3eb1a39921c2febae5e8c9060f1ad0122426c561 100644 (file)
@@ -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));
 
index 152724e14671576c0de8dc69c7bd954ef3a91522..23a2fc1878bd338dd0bd613298bf4ea0d2cd4f90 100644 (file)
@@ -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);
index fdc065101a2b68ec224448d996128647102921b9..f04e0bfa3ecb13a8a16b75c3ec27b3f4ab194670 100644 (file)
@@ -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();
 }
index 1ab9f95576a3fc6c2abd82099a546854c26af6d1..f0cf4c8140bd89bd763b2f445ab130d7856a98ba 100644 (file)
@@ -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);