+include_once($path_to_root . "/fixed_assets/includes/fa_classes_db.inc");
+
+function find_last_location($stock_id, $end_date)
+{
+ $end_date = date2sql($end_date);
+ $sql = "SELECT loc_code FROM ".TB_PREF."stock_moves WHERE stock_id = ".db_escape($stock_id)." AND
+ tran_date <= '$end_date' ORDER BY tran_date DESC LIMIT 1";
+ $res = db_query($sql,"No stock moves were returned");
+ $row = db_fetch_row($res);
+ return is_array($row) ? $row[0] : false;
+}