Merged changes from stable branch up to 2.3.23.
[fa-stable.git] / inventory / transfers.php
index 9e6cbd8534afac56308cb2e4efc164b8dc829ba9..7d4a34845cb06a56853ad30842fb07b6fd840a19 100644 (file)
@@ -21,9 +21,9 @@ include_once($path_to_root . "/includes/data_checks.inc");
 include_once($path_to_root . "/inventory/includes/stock_transfers_ui.inc");
 include_once($path_to_root . "/inventory/includes/inventory_db.inc");
 $js = "";
-if ($use_popup_windows)
+if ($SysPrefs->use_popup_windows)
        $js .= get_js_open_window(800, 500);
-if ($use_date_picker)
+if (user_use_date_picker())
        $js .= get_js_date_picker();
 page(_($help_context = "Inventory Location Transfers"), false, false, "", $js);
 
@@ -65,8 +65,6 @@ function handle_new_order()
                unset ($_SESSION['transfer_items']);
        }
 
-    //session_register("transfer_items");
-
        $_SESSION['transfer_items'] = new items_cart(ST_LOCTRANSFER);
        $_POST['AdjDate'] = new_doc_date();
        if (!is_date_in_fiscalyear($_POST['AdjDate']))
@@ -78,7 +76,6 @@ function handle_new_order()
 
 if (isset($_POST['Process']))
 {
-       global $Refs;
 
        $tr = &$_SESSION['transfer_items'];
        $input_error = 0;
@@ -86,7 +83,7 @@ if (isset($_POST['Process']))
        if (count($tr->line_items) == 0)        {
                display_error(_("You must enter at least one non empty item line."));
                set_focus('stock_id');
-               return false;
+               $input_error = 1;
        }
        if (!$Refs->is_valid($_POST['ref'])) 
        {
@@ -102,13 +99,13 @@ if (isset($_POST['Process']))
        } 
        elseif (!is_date($_POST['AdjDate'])) 
        {
-               display_error(_("The entered date for the adjustment is invalid."));
+               display_error(_("The entered transfer date is invalid."));
                set_focus('AdjDate');
                $input_error = 1;
        } 
        elseif (!is_date_in_fiscalyear($_POST['AdjDate'])) 
        {
-               display_error(_("The entered date is not in fiscal year."));
+               display_error(_("The entered date is out of fiscal year or is closed for further data entry."));
                set_focus('AdjDate');
                $input_error = 1;
        } 
@@ -117,17 +114,14 @@ if (isset($_POST['Process']))
                display_error(_("The locations to transfer from and to must be different."));
                set_focus('FromStockLocation');
                $input_error = 1;
-       } 
-       else 
+       }
+       elseif (!$SysPrefs->allow_negative_stock())
        {
-               $failed_item = $tr->check_qoh($_POST['FromStockLocation'], $_POST['AdjDate'], true);
-               if ($failed_item >= 0) 
+               $low_stock = $tr->check_qoh($_POST['FromStockLocation'], $_POST['AdjDate'], true);
+
+               if ($low_stock)
                {
-                       $line = $tr->line_items[$failed_item];
-               display_error(_("The quantity entered is greater than the available quantity for this item at the source location :") .
-                       " " . $line->stock_id . " - " .  $line->item_description);
-               echo "<br>";
-                       $_POST['Edit'.$failed_item] = 1; // enter edit mode
+               display_error(_("The transfer cannot be processed because it would cause negative inventory balance in source location for marked items as of document date or later."));
                        $input_error = 1;
                }
        }
@@ -224,7 +218,7 @@ start_form();
 
 display_order_header($_SESSION['transfer_items']);
 
-start_table("$table_style width=70%", 10);
+start_table(TABLESTYLE, "width='70%'", 10);
 start_row();
 echo "<td>";
 display_transfer_items(_("Items"), $_SESSION['transfer_items']);
@@ -239,4 +233,3 @@ submit_center_last('Process', _("Process Transfer"), '',  'default');
 end_form();
 end_page();
 
-?>