X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=includes%2Fdb%2Finventory_db.inc;h=4fcc7a411d1e87a0434a9c3f8929c1fe9669df71;hb=8864b1ec0fd3321e510511ef22614bc36845540e;hp=562c8d1b1d866c970dc552026b5ec0cca685e4da;hpb=c55119ade6f4c6bd4acdfa55c46870187f408978;p=fa-stable.git diff --git a/includes/db/inventory_db.inc b/includes/db/inventory_db.inc index 562c8d1b..4fcc7a41 100644 --- a/includes/db/inventory_db.inc +++ b/includes/db/inventory_db.inc @@ -1,6 +1,15 @@ . +***********************************************************************/ +function get_qoh_on_date($stock_id, $location=null, $date_=null, $exclude=0) { if ($date_ == null) $date_ = Today(); @@ -17,6 +26,18 @@ function get_qoh_on_date($stock_id, $location=null, $date_=null) $result = db_query($sql, "QOH calulcation failed"); $myrow = db_fetch_row($result); + if ($exclude > 0) + { + $sql = "SELECT SUM(qty) FROM ".TB_PREF."stock_moves + WHERE stock_id='$stock_id' + AND type=$exclude + AND tran_date = '$date'"; + + $result = db_query($sql, "QOH calulcation failed"); + $myrow2 = db_fetch_row($result); + if ($myrow2 !== false) + $myrow[0] -= $myrow2[0]; + } return $myrow[0]; } @@ -25,8 +46,10 @@ function get_qoh_on_date($stock_id, $location=null, $date_=null) function get_item_edit_info($stock_id) { - $sql = "SELECT material_cost + labour_cost + overhead_cost AS standard_cost, units - FROM ".TB_PREF."stock_master WHERE stock_id='$stock_id'"; + $sql = "SELECT material_cost + labour_cost + overhead_cost AS standard_cost, units, decimals + FROM ".TB_PREF."stock_master,".TB_PREF."item_units + WHERE stock_id='$stock_id' + AND ".TB_PREF."stock_master.units=".TB_PREF."item_units.abbr"; $result = db_query($sql, "The standard cost cannot be retrieved"); return db_fetch($result); @@ -78,7 +101,7 @@ Function get_stock_gl_code($stock_id) // $price - in $person_id's currency function add_stock_move($type, $stock_id, $trans_no, $location, - $date_, $reference, $quantity, $std_cost, $person_id=null, $show_or_hide=1, + $date_, $reference, $quantity, $std_cost, $person_id=0, $show_or_hide=1, $price=0, $discount_percent=0, $error_msg="") { // do not add a stock move if it's a non-inventory item @@ -101,6 +124,15 @@ function add_stock_move($type, $stock_id, $trans_no, $location, return db_insert_id(); } +function update_stock_move_pid($type, $stock_id, $from, $to, $pid, $cost) +{ + $from = date2sql($from); + $to = date2sql($to); + $sql = "UPDATE ".TB_PREF."stock_moves SET standard_cost=$cost WHERE type=$type + AND stock_id='$stock_id' AND tran_date>='$from' AND tran_date<='$to' AND person_id = $pid"; + db_query($sql, "The stock movement standard_cost cannot be updated"); +} + //-------------------------------------------------------------------------------------------------- function get_stock_moves($type, $type_no, $visible=false)