X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=inventory%2Ftransfers.php;h=d0db3b0bac03575c52082acab91735a4288e657a;hb=7d4687a00e3ee61cd628d5c74ceb7251fc11a7ac;hp=4b0339b2c585d9ed4a54f547c91ff12734ef8c12;hpb=431531eebf3ba494002cfbf7ea36f9e82d4975c0;p=fa-stable.git diff --git a/inventory/transfers.php b/inventory/transfers.php index 4b0339b2..d0db3b0b 100644 --- a/inventory/transfers.php +++ b/inventory/transfers.php @@ -1,7 +1,16 @@ . +***********************************************************************/ +$page_security = 'SA_LOCATIONTRANSFER'; +$path_to_root = ".."; include_once($path_to_root . "/includes/ui/items_cart.inc"); include_once($path_to_root . "/includes/session.inc"); @@ -16,8 +25,7 @@ if ($use_popup_windows) $js .= get_js_open_window(800, 500); if ($use_date_picker) $js .= get_js_date_picker(); -page(_("Inventory Location Transfers"), false, false, "", $js); - +page(_($help_context = "Inventory Location Transfers"), false, false, "", $js); //----------------------------------------------------------------------------------------------- @@ -30,38 +38,23 @@ check_db_has_movement_types(_("There are no inventory movement types defined in if (isset($_GET['AddedID'])) { $trans_no = $_GET['AddedID']; - $trans_type = systypes::location_transfer(); + $trans_type = ST_LOCTRANSFER; display_notification_centered(_("Inventory transfer has been processed")); - display_note(get_trans_view_str($trans_type, $trans_no, _("View this transfer"))); + display_note(get_trans_view_str($trans_type, $trans_no, _("&View this transfer"))); - hyperlink_no_params($_SERVER['PHP_SELF'], _("Enter Another Inventory Transfer")); + hyperlink_no_params($_SERVER['PHP_SELF'], _("Enter &Another Inventory Transfer")); display_footer_exit(); } - //-------------------------------------------------------------------------------------------------- -function copy_to_st() -{ - $_SESSION['transfer_items']->from_loc = $_POST['FromStockLocation']; - $_SESSION['transfer_items']->to_loc = $_POST['ToStockLocation']; - $_SESSION['transfer_items']->tran_date = $_POST['AdjDate']; - $_SESSION['transfer_items']->transfer_type = $_POST['type']; - $_SESSION['transfer_items']->memo_ = $_POST['memo_']; -} - -//-------------------------------------------------------------------------------------------------- +function line_start_focus() { + global $Ajax; -function copy_from_st() -{ - $_POST['FromStockLocation'] = $_SESSION['transfer_items']->from_loc; - $_POST['ToStockLocation'] = $_SESSION['transfer_items']->to_loc; - $_POST['AdjDate'] = $_SESSION['transfer_items']->tran_date; - $_POST['type'] = $_SESSION['transfer_items']->transfer_type; - $_POST['memo_'] = $_SESSION['transfer_items']->memo_; + $Ajax->activate('items_table'); + set_focus('_stock_id_edit'); } - //----------------------------------------------------------------------------------------------- function handle_new_order() @@ -72,10 +65,8 @@ function handle_new_order() unset ($_SESSION['transfer_items']); } - session_register("transfer_items"); - - $_SESSION['transfer_items'] = new items_cart; - $_POST['AdjDate'] = Today(); + $_SESSION['transfer_items'] = new items_cart(ST_LOCTRANSFER); + $_POST['AdjDate'] = new_doc_date(); if (!is_date_in_fiscalyear($_POST['AdjDate'])) $_POST['AdjDate'] = end_fiscalyear(); $_SESSION['transfer_items']->tran_date = $_POST['AdjDate']; @@ -85,42 +76,56 @@ function handle_new_order() if (isset($_POST['Process'])) { + global $Refs; + $tr = &$_SESSION['transfer_items']; $input_error = 0; - if (!references::is_valid($_POST['ref'])) + if (count($tr->line_items) == 0) { + display_error(_("You must enter at least one non empty item line.")); + set_focus('stock_id'); + return false; + } + if (!$Refs->is_valid($_POST['ref'])) { display_error(_("You must enter a reference.")); + set_focus('ref'); $input_error = 1; } - elseif (!is_new_reference($_POST['ref'], systypes::location_transfer())) + elseif (!is_new_reference($_POST['ref'], ST_LOCTRANSFER)) { display_error(_("The entered reference is already in use.")); + set_focus('ref'); $input_error = 1; } elseif (!is_date($_POST['AdjDate'])) { display_error(_("The entered date for the adjustment 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.")); + set_focus('AdjDate'); $input_error = 1; } elseif ($_POST['FromStockLocation'] == $_POST['ToStockLocation']) { display_error(_("The locations to transfer from and to must be different.")); + set_focus('FromStockLocation'); $input_error = 1; } else { - $failed_item = $_SESSION['transfer_items']->check_qoh($_POST['FromStockLocation'], $_POST['AdjDate'], true); - if ($failed_item != null) + $failed_item = $tr->check_qoh($_POST['FromStockLocation'], $_POST['AdjDate'], true); + if ($failed_item >= 0) { + $line = $tr->line_items[$failed_item]; display_error(_("The quantity entered is greater than the available quantity for this item at the source location :") . - " " . $failed_item->stock_id . " - " . $failed_item->item_description); + " " . $line->stock_id . " - " . $line->item_description); echo "
"; + $_POST['Edit'.$failed_item] = 1; // enter edit mode $input_error = 1; } } @@ -137,7 +142,7 @@ if (isset($_POST['Process'])) $trans_no = add_stock_transfer($_SESSION['transfer_items']->line_items, $_POST['FromStockLocation'], $_POST['ToStockLocation'], $_POST['AdjDate'], $_POST['type'], $_POST['ref'], $_POST['memo_']); - + new_doc_date($_POST['AdjDate']); $_SESSION['transfer_items']->clear_items(); unset($_SESSION['transfer_items']); @@ -148,18 +153,12 @@ if (isset($_POST['Process'])) function check_item_data() { - if (!is_numeric($_POST['qty']) || ($_POST['qty'] == 0)) - { - 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.")); + set_focus('qty'); return false; } - return true; } @@ -169,17 +168,20 @@ function handle_update_item() { if($_POST['UpdateItem'] != "" && check_item_data()) { + $id = $_POST['LineNo']; 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']); + $_POST['std_cost'] = $_SESSION['transfer_items']->line_items[$id]->standard_cost; + $_SESSION['transfer_items']->update_cart_item($id, input_num('qty'), $_POST['std_cost']); } + line_start_focus(); } //----------------------------------------------------------------------------------------------- -function handle_delete_item() +function handle_delete_item($id) { - $_SESSION['transfer_items']->remove_from_cart($_GET['Delete']); + $_SESSION['transfer_items']->remove_from_cart($id); + line_start_focus(); } //----------------------------------------------------------------------------------------------- @@ -190,19 +192,14 @@ 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']); + line_start_focus(); } //----------------------------------------------------------------------------------------------- - -if (isset($_GET['Delete']) || isset($_GET['Edit'])) - copy_from_st(); - -if (isset($_GET['Delete'])) - handle_delete_item(); - -if (isset($_POST['AddItem']) || isset($_POST['UpdateItem'])) - copy_to_st(); +$id = find_submit('Delete'); +if ($id != -1) + handle_delete_item($id); if (isset($_POST['AddItem'])) handle_new_item(); @@ -210,6 +207,9 @@ if (isset($_POST['AddItem'])) if (isset($_POST['UpdateItem'])) handle_update_item(); +if (isset($_POST['CancelItemChanges'])) { + line_start_focus(); +} //----------------------------------------------------------------------------------------------- if (isset($_GET['NewTransfer']) || !isset($_SESSION['transfer_items'])) @@ -218,12 +218,11 @@ if (isset($_GET['NewTransfer']) || !isset($_SESSION['transfer_items'])) } //----------------------------------------------------------------------------------------------- - -start_form(false, true); +start_form(); display_order_header($_SESSION['transfer_items']); -start_table("$table_style width=70%", 10); +start_table(TABLESTYLE, "width=70%", 10); start_row(); echo ""; display_transfer_items(_("Items"), $_SESSION['transfer_items']); @@ -232,16 +231,9 @@ echo ""; end_row(); end_table(1); -if (!isset($_POST['Process'])) -{ - if ($_SESSION['transfer_items']->count_items() >= 1) - { - submit_center_first('Update', _("Update")); - submit_center_last('Process', _("Process Transfer")); - } - else - submit_center('Update', _("Update")); -} +submit_center_first('Update', _("Update"), '', null); +submit_center_last('Process', _("Process Transfer"), '', 'default'); + end_form(); end_page();