- display_notification('Row0 - '.$row[0].' Row1- '.$row[1]);
-
- //return $row;
-
- // Get Std cost of previsous transaction before the cut-over delivery
- // This is useful to get inventory valuation
- //Chaitanya : Corrected
- /*$sql = "SELECT max( `trans_id` )
- FROM ".TB_PREF."stock_moves
- WHERE stock_id = ".db_escape($stock_id)."
- AND trans_id<'$from'";
- $result = db_query($sql, "The deliveries could not be updated");
- $trans = db_fetch_row($result);
- $prev_trans = $trans[0];*/
-
- display_notification('From - '.$from);
- $sql = "SELECT standard_cost FROM ".TB_PREF."stock_moves
- WHERE stock_id=".db_escape($stock_id)
- ." AND trans_id ='$from'";
- $result = db_query($sql, "The deliveries could not be updated");
- $cost = db_fetch_row($result);
-
- display_notification('Last Delivery Cost - '.$cost[0]);
-
+ $sql = "SELECT IF(type=".ST_SUPPRECEIVE." OR type=".ST_SUPPCREDIT.", price, standard_cost)
+ FROM ".TB_PREF."stock_moves
+ WHERE stock_id=".db_escape($stock_id)
+ ." AND trans_id ='$from'";
+ $result = db_query($sql, "The deliveries could not be updated");
+ $cost = db_fetch_row($result);
+