Some typos
[fa-stable.git] / inventory / prices.php
index 073289c65b3610cb742be9d097111e145835ff0e..7a8e53e1121bc67e53dff882284339644386120c 100644 (file)
@@ -44,10 +44,10 @@ if (!isset($_POST['stock_id']))
 
 echo "<center>" . _("Item:"). "&nbsp;";
 stock_items_list('stock_id', $_POST['stock_id'], false, true);
-echo "<hr>";
+echo "<hr></center>";
 
 // if stock sel has changed, clear the form
-if ($_POST['stock_id'] != get_global_stock_item()) 
+if ($_POST['stock_id'] != get_global_stock_item())
 {
        clear_data();
 }
@@ -64,29 +64,32 @@ function clear_data()
 
 //----------------------------------------------------------------------------------------------------
 
-if (isset($_POST['updatePrice'])) 
+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."));
+               set_focus('price');
        }
 
        if ($input_error != 1)
        {
 
-               if (isset($_POST['PriceID'])) 
+               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) 
+               }
+               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."));
                }
@@ -97,7 +100,7 @@ if (isset($_POST['updatePrice']))
 
 //------------------------------------------------------------------------------------------------------
 
-if (isset($_GET['delete'])) 
+if (isset($_GET['delete']))
 {
 
        //the link to delete a selected record was clicked
@@ -105,20 +108,22 @@ if (isset($_GET['delete']))
        echo _("The selected price has been deleted.");
 
 }
-
+if (isset($_POST['_stock_id_update']))
+       $Ajax->activate('price_table');
 //---------------------------------------------------------------------------------------------------
 
 $mb_flag = get_mb_flag($_POST['stock_id']);
 
 $prices_list = get_prices($_POST['stock_id']);
 
+div_start('price_table');
 start_table("$table_style width=30%");
 
 $th = array(_("Currency"), _("Sales Type"), _("Price"), "", "");
 table_header($th);
 $k = 0; //row colour counter
 
-while ($myrow = db_fetch($prices_list)) 
+while ($myrow = db_fetch($prices_list))
 {
 
        alt_table_row_color($k);
@@ -132,10 +137,10 @@ while ($myrow = db_fetch($prices_list))
 
 }
 end_table();
-
+div_end();
 //------------------------------------------------------------------------------------------------
 
-if (db_num_rows($prices_list) == 0) 
+if (db_num_rows($prices_list) == 0)
 {
        display_note(_("There are no prices set up for this part."));
 }
@@ -148,7 +153,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 +162,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);