X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=inventory%2Fincludes%2Fdb%2Fitems_transfer_db.inc;h=dc587e3d2c52c4ecd5f0635895aa2f956bec06a3;hb=34c15f2f88c2b4d8a18ca40f76df3b9748e463e1;hp=4d4a438b62cd0bc181e07108c49840f3ec66cb29;hpb=da8311619dd73feae101d246a1957b972e00cbd2;p=fa-stable.git diff --git a/inventory/includes/db/items_transfer_db.inc b/inventory/includes/db/items_transfer_db.inc index 4d4a438b..dc587e3d 100644 --- a/inventory/includes/db/items_transfer_db.inc +++ b/inventory/includes/db/items_transfer_db.inc @@ -1,28 +1,35 @@ . +***********************************************************************/ //------------------------------------------------------------------------------------------------------------- function add_stock_transfer($Items, $location_from, $location_to, $date_, $type, $reference, $memo_) { begin_transaction(); - + $transfer_id = get_next_trans_no(systypes::location_transfer()); - - foreach ($Items as $line_item) + + foreach ($Items as $line_item) { - add_stock_transfer_item($transfer_id, $line_item->stock_id, $location_from, + add_stock_transfer_item($transfer_id, $line_item->stock_id, $location_from, $location_to, $date_, $type, $reference, $line_item->quantity); } - - add_comments(systypes::location_transfer(), $transfer_id, $date_, $memo_); - - add_forms_for_sys_type(systypes::location_transfer(), $transfer_id, $location_from, $location_to); - - references::save_last($reference, systypes::location_transfer()); - + + add_comments(systypes::location_transfer(), $transfer_id, $date_, $memo_); + + references::save_last($reference, systypes::location_transfer()); + commit_transaction(); - return $transfer_id; + return $transfer_id; } //------------------------------------------------------------------------------------------------------------- @@ -32,15 +39,15 @@ function add_stock_transfer($Items, $location_from, $location_to, $date_, $type, // std_cost is in HOME currency // it seems the standard_cost field is not used at all -function add_stock_transfer_item($transfer_id, $stock_id, $location_from, $location_to, +function add_stock_transfer_item($transfer_id, $stock_id, $location_from, $location_to, $date_, $type, $reference, $quantity) { add_stock_move(systypes::location_transfer(), $stock_id, $transfer_id, $location_from, - $date_, $reference, -$quantity, 0, $type); - + $date_, $reference, -$quantity, 0, $type); + add_stock_move(systypes::location_transfer(), $stock_id, $transfer_id, $location_to, - $date_, $reference, $quantity, 0, $type); - + $date_, $reference, $quantity, 0, $type); + } //------------------------------------------------------------------------------------------------------------- @@ -48,17 +55,17 @@ function add_stock_transfer_item($transfer_id, $stock_id, $location_from, $locat function get_stock_transfer($trans_no) { $result = get_stock_transfer_items($trans_no); - if (db_num_rows($result) < 2) + if (db_num_rows($result) < 2) { - display_db_error("transfer with less than 2 items : $trans_no", ""); + display_db_error("transfer with less than 2 items : $trans_no", ""); } - + // this function is very bad that it assumes that 1st record and 2nd record contain the // from and to locations - if get_stock_moves uses a different ordering than trans_no then // it will bomb $move1 = db_fetch($result); $move2 = db_fetch($result); - + // return an array of (From, To) if ($move1['qty'] < 0) return array($move1, $move2); @@ -71,12 +78,12 @@ function get_stock_transfer($trans_no) function get_stock_transfer_items($trans_no) { $result = get_stock_moves(systypes::location_transfer(), $trans_no); - - if (db_num_rows($result) == 0) + + if (db_num_rows($result) == 0) { - return null; + return null; } - + return $result; }