[0000227] Fixed sessio cookie naming to support multiply FA instances on same server.
[fa-stable.git] / purchasing / po_entry_items.php
index 988c90faf3a1b15af98e82d0c8eb5af3af9484cb..df67182db583834ef6bc98c5663c9932db7a3384 100644 (file)
@@ -66,22 +66,22 @@ if (isset($_GET['AddedID']))
 
 function copy_from_cart()
 {
-       $_POST['supplier_id'] = $_SESSION['PO']->supplier_id;   
-       $_POST['OrderDate'] = $_SESSION['PO']->orig_order_date; 
+       $_POST['supplier_id'] = $_SESSION['PO']->supplier_id;
+       $_POST['OrderDate'] = $_SESSION['PO']->orig_order_date;
     $_POST['Requisition'] = $_SESSION['PO']->requisition_no;
     $_POST['ref'] = $_SESSION['PO']->reference;
        $_POST['Comments'] = $_SESSION['PO']->Comments;
     $_POST['StkLocation'] = $_SESSION['PO']->Location;
-    $_POST['delivery_address'] = $_SESSION['PO']->delivery_address;    
+    $_POST['delivery_address'] = $_SESSION['PO']->delivery_address;
 }
 
 function copy_to_cart()
 {
-       $_SESSION['PO']->supplier_id = $_POST['supplier_id'];   
+       $_SESSION['PO']->supplier_id = $_POST['supplier_id'];
        $_SESSION['PO']->orig_order_date = $_POST['OrderDate'];
        $_SESSION['PO']->reference = $_POST['ref'];
        $_SESSION['PO']->requisition_no = $_POST['Requisition'];
-       $_SESSION['PO']->Comments = $_POST['Comments']; 
+       $_SESSION['PO']->Comments = $_POST['Comments'];
        $_SESSION['PO']->Location = $_POST['StkLocation'];
        $_SESSION['PO']->delivery_address = $_POST['delivery_address'];
 }
@@ -157,9 +157,12 @@ function handle_cancel_po()
 
 function check_data()
 {
-    if (!check_num('qty',0))
+       $dec = get_qty_dec($_POST['stock_id']);
+       $min = 1 / pow(10, $dec);
+    if (!check_num('qty',$min))
     {
-               display_error(_("The quantity of the order item must be numeric and not less than zero."));
+       $min = number_format2($min, $dec);
+               display_error(_("The quantity of the order item must be numeric and not less than ").$min);
                set_focus('qty');
                return false;
     }
@@ -185,19 +188,21 @@ function handle_update_item()
 {
        $allow_update = check_data(); 
 
-       if ($allow_update && 
-               ($_SESSION['PO']->line_items[$_POST['line_no']]->qty_inv > input_num('qty') ||
-               $_SESSION['PO']->line_items[$_POST['line_no']]->qty_received > input_num('qty')))
+       if ($allow_update)
        {
-               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."));
-               set_focus('qty');
-               return;
-       }
+               if ($_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."));
+                       set_focus('qty');
+                       return;
+               }
        
-       $_SESSION['PO']->update_order_item($_POST['line_no'], input_num('qty'), input_num('price'),
-               $_POST['req_del_date']);
-       unset_form_variables();
+               $_SESSION['PO']->update_order_item($_POST['line_no'], input_num('qty'), input_num('price'),
+                       $_POST['req_del_date']);
+               unset_form_variables();
+       }       
     line_start_focus();
 }
 
@@ -263,6 +268,13 @@ function can_commit()
 {
        global $Refs;
 
+       if (!get_post('supplier_id')) 
+       {
+               display_error(_("There is no supplier selected."));
+               set_focus('supplier_id');
+               return false;
+       } 
+       
        if (!is_date($_POST['OrderDate'])) 
        {
                display_error(_("The entered order date is invalid."));