Four minor bug fixes
[fa-stable.git] / inventory / adjustments.php
index 9a114e41c6ab5ef217ab6c481a3a6c8c550015eb..a70d2d543ea2889780403bbb0c884ce7eb7055b9 100644 (file)
@@ -14,6 +14,8 @@ include_once($path_to_root . "/inventory/includes/inventory_db.inc");
 $js = "";
 if ($use_popup_windows)
        $js .= get_js_open_window(800, 500);
+if ($use_date_picker)
+       $js .= get_js_date_picker();
 page(_("Item Adjustments Note"), false, false, "", $js);
 
 //-----------------------------------------------------------------------------------------------
@@ -134,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;
@@ -161,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'));
     }
 }
 
@@ -179,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'));
 }
 
 //-----------------------------------------------------------------------------------------------