-$sql = "SELECT type, trans_no, tran_date, person_id, qty, reference
- FROM ".TB_PREF."stock_moves
- WHERE loc_code='" . $_POST['StockLocation'] . "'
- AND tran_date >= '". $after_date . "'
- AND tran_date <= '" . $before_date . "'
- AND stock_id = '" . $_POST['stock_id'] . "' ORDER BY tran_date,trans_id";
-$result = db_query($sql, "could not query stock moves");
-
-check_db_error("The stock movements for the selected criteria could not be retrieved",$sql);
+$result = get_stock_movements($_POST['stock_id'], $_POST['StockLocation'],
+ $_POST['BeforeDate'], $_POST['AfterDate']);