Fixed numeric fields to accept user native number format.
authorJanusz Dobrowolski <janusz@frontaccounting.eu>
Fri, 14 Mar 2008 20:17:56 +0000 (20:17 +0000)
committerJanusz Dobrowolski <janusz@frontaccounting.eu>
Fri, 14 Mar 2008 20:17:56 +0000 (20:17 +0000)
51 files changed:
admin/gl_setup.php
gl/bank_transfer.php
gl/gl_budget.php
gl/gl_deposit.php
gl/gl_journal.php
gl/gl_payment.php
gl/includes/db/gl_db_banking.inc
gl/includes/ui/gl_deposit_ui.inc
gl/includes/ui/gl_journal_ui.inc
gl/includes/ui/gl_payment_ui.inc
gl/manage/exchange_rates.php
inventory/adjustments.php
inventory/cost_update.php
inventory/includes/item_adjustments_ui.inc
inventory/includes/stock_transfers_ui.inc
inventory/manage/item_units.php
inventory/prices.php
inventory/purchasing_data.php
inventory/reorder_level.php
inventory/transfers.php
manufacturing/inquiry/where_used_inquiry.php
manufacturing/manage/bom_edit.php
manufacturing/work_order_entry.php
purchasing/allocations/supplier_allocate.php
purchasing/includes/ui/po_ui.inc
purchasing/inquiry/po_search.php
purchasing/po_entry_items.php
purchasing/po_receive_items.php
purchasing/supplier_credit_grns.php
purchasing/supplier_invoice_grns.php
purchasing/supplier_payment.php
purchasing/supplier_trans_gl.php
sales/allocations/customer_allocate.php
sales/credit_note_entry.php
sales/customer_credit_invoice.php
sales/customer_delivery.php
sales/customer_invoice.php
sales/customer_payments.php
sales/includes/ui/sales_credit_ui.inc
sales/includes/ui/sales_order_ui.inc
sales/manage/customers.php
sales/manage/sales_people.php
sales/sales_order_entry.php
sales/view/view_credit.php
sales/view/view_dispatch.php
sales/view/view_invoice.php
sales/view/view_receipt.php
sales/view/view_sales_order.php
taxes/item_tax_types.php
taxes/tax_groups.php
taxes/tax_types.php

index 161888547bdcb8c072563ac40258a940badf1a9b..3af347c8eb0586dc292ba9a268d6be719b9ce5df 100644 (file)
@@ -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'];
index 2f5b1f1ae4265186679708f2147a309757c62c45..5f5a783b98ca16f9b8ee9b6d459cc5c5d3814c4a 100644 (file)
@@ -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");
index 988e6026cb36c5c0f3ba86ba7ed8cd72a3304e2f..cda847c2e29a1487b8e1028a4422692bc882057f 100644 (file)
@@ -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("<b>"._("Total")."</b>");
-       label_cell("<b>".number_format2($total, 0)."</b>");
+       label_cell("<b>".number_format2($total, 0)."</b>", 'align=right');
        if ($showdims)
                label_cell("<b>".number_format2($btotal, 0)."</b>", "nowrap align=right");
        label_cell("<b>".number_format2($ltotal, 0)."</b>", "nowrap align=right");
index fd4f98e567a28e5228a03d7e2276bae285c341b6..a4b5f1734f38cf97f0234b11f83a6d7123459376 100644 (file)
@@ -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']);
 }
 
 //-----------------------------------------------------------------------------------------------
index 2a027399891d5c70ce593bca6883d5df5ef6f0ba..b5a2c1cc287a05f0b400a9abb63df99ba6b0844e 100644 (file)
@@ -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 "</td>";
 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();
index c1771cdf6ec5fecf1d191e8e89a17422779f1930..696506820f84fc88939acc867b4fa4773f3f886a 100644 (file)
@@ -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']);
 }
 
 //-----------------------------------------------------------------------------------------------
index dc86c0a4f2a0c410413159798edc29d521f32a3b..46c81faf3dde2f955802cdaec2a880a905602a16 100644 (file)
@@ -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);
 
     }
index 3f65b68c531c47ff3dfa9ddc89c970abf040f07b..e1dece6bcaf9e8549b26ea284a2bd3678ba8add4 100644 (file)
@@ -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'] = "";
index 1b3c232fb03a3c25709f46f7c0e037cc07a335a8..046430caac1516f92eeb5a49fab5922beb53221d 100644 (file)
@@ -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'])) 
index 13fc5c6b701e52b9c2c6d9fca02eb206699e079f..c355b92f400ccfa41167ebf509c10338cbde0b98 100644 (file)
@@ -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'] = "";
index 52798c8877f00fd460b02cd77b7fc13b10d29d21..deeb49b384a6a47e4719cc79890b86298a745339 100644 (file)
@@ -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);
 
index e2a793843208bc676b69404e26d11852cb8cc952..a70d2d543ea2889780403bbb0c884ce7eb7055b9 100644 (file)
@@ -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'));
 }
 
 //-----------------------------------------------------------------------------------------------
index 6b6c5950434280ae0f5608d13263711471685411..392160392290e1f027b4d0fa34ec4ee1adc9df9e 100644 (file)
@@ -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
 {
index ce8762f1151b55d9853d2436a753afc688672a9f..bf88c7dae5f7c41690e6997666a0a7a1d81d4337 100644 (file)
@@ -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("&nbsp;");
 
        if (isset($_GET['Edit'])) 
index 05b7304f228ef113dfee1396afc05a2b17d77e76..c0395af47b3ad1ae95709e9b6618446066776d53 100644 (file)
@@ -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'])) 
index 0df22f8e903b5922f53706a852064ac51fff66f0..76af07d90aa20c64f1c3a057a0d95d7dc38fea27 100644 (file)
@@ -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);
 
index 073289c65b3610cb742be9d097111e145835ff0e..06fab6d144a711424413a7d70ff9a9a5c9aefcd2 100644 (file)
@@ -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);
 
index 8e2cb59d0e9a94e166e640506089ef62868a2b16..51cd7fce0602ad839a6acc6b65235affc5e86894 100644 (file)
@@ -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 "<br>";
@@ -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);
index 980d04cfb60ed09e393a45875b8a19c32e79e470..3d92cebfb108e652d6cb9fb324153ab020cfe119 100644 (file)
@@ -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)
index 4b0339b2c585d9ed4a54f547c91ff12734ef8c12..78f86a7d5d2b1cced4d688d835fd3b2652a16848 100644 (file)
@@ -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']);
 }
 
 //-----------------------------------------------------------------------------------------------
index 9304c197a7ea2ab4bd5c4f2c4b7c94f63ee50c3d..a31adc8dfe8d8effb2c2d265d98ebb862ca92101 100644 (file)
@@ -56,7 +56,7 @@ if (isset($_POST['stock_id']))
                label_cell("<a href='$select_item'>" . $myrow["parent"]. " - " . $myrow["description"]. "</a>");
                label_cell($myrow["WorkCentreName"]);
                label_cell($myrow["location_name"]);
-               label_cell($myrow["quantity"]);
+               label_cell(qty_format($myrow["quantity"]));
                        end_row();
                        
                $j++;
index 6e30c49727643940275799cc479114eecf244afb..cfb15ad15acfd5044b7b4e0e97c669f5f8d80c2d 100644 (file)
@@ -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"));
index 39fd25bfe20c3bbe5ea0f85674482bed26dbbdc9..4da03e6e0095d2ec8475a36d76dd385466401d07 100644 (file)
@@ -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');
 }
index 7ef2b2aa79147c47f115d91a597d21cd011b694c..e749e0fea4e6a1446af95f6a077b121b793b6f25 100644 (file)
@@ -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:") . " <b>" . $_SESSION['alloc']->date_ . "</b>");
-    display_heading2(_("Total:") . " <b>" . number_format2(-$_SESSION['alloc']->amount,user_price_dec()) . "</b>");
+    display_heading2(_("Total:") . " <b>" . price_format(-$_SESSION['alloc']->amount) . "</b>");
 
     echo "<br>";
 
@@ -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("<a href='#' name=Alloc$counter onclick='allocate_all(this.name.substr(5));return true;'>"
+                                        . _("All") . "</a>");
+                       label_cell("<a href='#' name=DeAll$counter onclick='allocate_none(this.name.substr(5));return true;'>"
+                                        . _("None") . "</a>");
 
-                       label_cell("<a href='#' onclick='forms[0].amount$counter.value=forms[0].un_allocated$counter.value; return true;'>" . _("All") . "</a>");
-                       label_cell("<a href='#' onclick='forms[0].amount$counter.value=0; return true;'>" . _("None") . "</a>");
+//                     label_cell("<a href='#' onclick='forms[0].amount$counter.value=forms[0].un_allocated$counter.value; return true;'>" . _("All") . "</a>");
+//                     label_cell("<a href='#' onclick='forms[0].amount$counter.value=0; return true;'>" . _("None") . "</a>");
                        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 "<br><center>";
                submit('UpdateDisplay', _("Update"));
                echo "&nbsp;";
index 240012538af61f25f0ff4c104300df29bc7fd8c8..b2322f99c2d0535c9f806fa67e0ef48b4e3f8053 100644 (file)
@@ -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']))
index e460d53e121ef31745ffd4cdb1d0942e5867cf41..7b2e867cc7008a838cb17f77f256abe97e22d6e9 100644 (file)
@@ -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);
 
index be2393ae774eaa8285b4a44803bf08bd07f6e022..7a89b20bfa2ded3eac02c24a7edee325410c17c5 100644 (file)
@@ -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.") .
                        "<br>" . _("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();
index e12b6a4203277fc86eba319c0afcdf4749bf9ff9..59791f468dbb3edbc22753cf148aeb47c842e5b8 100644 (file)
@@ -28,7 +28,7 @@ if (isset($_GET['AddedID']))
        //echo "<BR>";
        //echo get_gl_view_str(25, $grn, _("View the GL Journal Entries for this Delivery"));
 
-       echo "<br>";
+//     echo "<br>";
        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) 
                {
index f195d788545982b955e6ea5d5398730c31078f55..ab14148be3c95bd03d0f342d08696ae11f76d813 100644 (file)
@@ -29,19 +29,13 @@ echo "<br>";
 
 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);
 
index 04aaaea7526dfce88f108eb2ed6cb05410dadd2e..8cea6d8ec1564765d7bb64480665805522762fe6 100644 (file)
@@ -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);;
 
index d92973570efb4a39f2b44095f321d2f2c930af36..6cf626691dc8ad6fa124d212c47b25dd49b19d75 100644 (file)
@@ -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 "<center><br>";
     hyperlink_params($path_to_root . "/purchasing/allocations/supplier_allocate.php", _("Allocate this Payment"), "trans_no=$payment_id&trans_type=22");
 
-       echo "<br><br>";
        hyperlink_params($_SERVER['PHP_SELF'], _("Enter another supplier payment"), "supplier_id=" . $_POST['supplier_id']);
 
-       echo "</center><br><br>";
-
-       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']);
index cc78626998f5f2d480ec7707bdd2ab4565050bd7..1e120b45587c19d0e1693519b5f7adf8f139c7b3 100644 (file)
@@ -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();
        }
 }
index 46daa72dde799c47617f19c419c9c139fb357e48..f8b96d5ca14872965092358f82241cd4818e89f1 100644 (file)
@@ -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:") . " <b>" . $_SESSION['alloc']->date_ . "</b>");
-    display_heading2(_("Total:") . " <b>" . number_format2($_SESSION['alloc']->amount,user_price_dec()) . "</b>");
+    display_heading2(_("Total:") . " <b>" . price_format($_SESSION['alloc']->amount) . "</b>");
 
     echo "<br>";
 
@@ -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") . "</a>");
                        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);
index 9258863992f46e5a8612a8876f8817743f24aaef..5de3dfb9d11332e39dc29748257186ad60ab71a8 100644 (file)
@@ -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']))
index 0a1e103c136310233b23e5a3b003e2e032014562..b084a7d1bf0cd332a54f826c4cb14a9efc89d1ee 100644 (file)
@@ -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");
 
index ba7016ef78d9610e8dd4dc1480d0c114e0207dc9..eca3446868a64aa6cda2b774f445016d6a117204 100644 (file)
@@ -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");
 
index 8b3102ac5973bdb90a79dab340f7a0139977fea9..c2ffcfe0382d3808e2072d01ae21d72de7e6f9f4 100644 (file)
@@ -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 '<td nowrap align=right>';
                hidden('Line' . $line, $ln_itm->qty_dispatched );
-               echo number_format2($ln_itm->qty_dispatched, user_qty_dec()).'</td>';
+               echo qty_format($ln_itm->qty_dispatched).'</td>';
        } 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);
 
index cd48b65805823dd7e8ea64af78d564572616a742..212b96e0c93a1d2b0e5dbe4cd990b31f111f4fbd 100644 (file)
@@ -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 "</table></table>";
                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');
 
index 811167d603aa9103d82f1401c88eb3ee79d71a1c..6fa90b12658ca7491a1016bb78706417df2fd1a6 100644 (file)
@@ -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));
 
index 5494ae00f83a6b7e27d5af9f41f93487f4505fee..152724e14671576c0de8dc69c7bd954ef3a91522 100644 (file)
@@ -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 "<table>";
 
        $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 "</table>";
@@ -246,34 +247,35 @@ function display_order_header(&$order, $editable, $date_text, $display_tax_group
        {
                echo "<table height='5'>";
                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 "</table>";
                echo "</td><td>"; // 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 "<table height='5'>";
        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 "</table>";
 
@@ -281,28 +283,28 @@ function display_order_header(&$order, $editable, $date_text, $display_tax_group
 
        echo "<table height='5'>";
 
-       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 "</table>";
 
        echo "</td></tr>";
-       
+
        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 "<td colspan=2>\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 "<br>";
-    start_table("$table_style2 width=90%");
-    echo "<tr valign=top><td>"; // outer table
+       echo "<br>";
+       start_table("$table_style2 width=90%");
+       echo "<tr valign=top><td>"; // outer table
 
-    echo "<table>";
+       echo "<table>";
 
 //     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 "</table>";
+       echo "</table>";
 
-    echo "</td><td>"; // outer table
+       echo "</td><td>"; // outer table
 
-    echo "<table>";
+       echo "<table>";
 
-    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 "</table>";
+       echo "</table>";
 
-    echo "</td></tr>";
-    end_table(1); // outer table
+       echo "</td></tr>";
+       end_table(1); // outer table
 }
 
 ?>
\ No newline at end of file
index 5a57732f8328ef12f6b182717b07021c39a5d873..bba429660282b90b88c392efd39cda1b4df3a34f 100644 (file)
@@ -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']); 
index b8bc94bc8ac1e19300a5f31d653dee291c57c682..e2c4ed4398307aca8796849b480216d29c70afeb 100644 (file)
@@ -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);
 }
index 780f26cf08c7386abfea9a351d3b653cfc98c4b3..39a90fe5d808c4fc6d3408ad96afcac9d95e1726 100644 (file)
@@ -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();
 
index e1e7326cbfd52352655830c60b30ed280f1c4e36..0ba000898ee19fd0bf02ee549352e2f8e1e85bce 100644 (file)
@@ -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)
index 84bf2288eea8b603431e46e64927cd78edd8adcc..8a4460c0ee154029c03b07cd6027225d478fa32f 100644 (file)
@@ -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");
index 90820a79b2fa16125bab8ddcd49d98a463fbbf1d..b6da97d4373497a03fede71d1e11a848eefc1891 100644 (file)
@@ -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");
index 16a8c5806f944dccffef68f2f21ab8c2c1c9028b..13797b0a671ebd4d0f5b4b3dfd108ed6af1cd548 100644 (file)
@@ -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'");
index 32cd1b7440c28f33820f0bd93a05df4d80eefda8..76c58b45a4fd828722ee2c577f134bbe53d6fcd6 100644 (file)
@@ -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 "</td><td valign='top'>";
@@ -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, "<font color=red>" . number_format2(-$credits_total,user_price_dec()) . "</font>",
+label_row(null, "<font color=red>" . price_format(-$credits_total) . "</font>",
        "", "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");
index 55175b709e41effa6cf9906304a8f970a8bb30aa..d398e6c9b2f7e239d5a2d85958174be367078ee4 100644 (file)
@@ -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();
     }
index af19925d3678f0ee8163ab1d26460bd99615c87c..fdc065101a2b68ec224448d996128647102921b9 100644 (file)
@@ -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();
 }
index d70493c847080d206d2442149a834f9f5bd1dd01..1ab9f95576a3fc6c2abd82099a546854c26af6d1 100644 (file)
@@ -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"] . "&nbsp;" . $myrow["SalesAccountName"]);
        label_cell($myrow["purchasing_gl_code"] . "&nbsp;" . $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);