+ $stock_qty = $qoh_stock[$stock_id];
+ if ($stock_qty == NULL) $stock_qty = 0;
+ if ($qty <= $stock_qty) return $demand;
+ $bom = $bom_list[$stock_id];
+ if ($bom == NULL) {
+ $sql = "SELECT parent, component, quantity FROM "
+ .TB_PREF."bom WHERE parent = ".db_escape($stock_id);
+ if ($location != "") $sql .= " AND loc_code = ".db_escape($location);
+ $result = db_query($sql, "Could not search bom");
+ $bom = array();
+ // Even if we get no results, remember that fact
+ $bom[] = array($stock_id, '', 0);
+ while ($row = db_fetch_row($result)) {
+ $bom[] = array($row[0], $row[1], $row[2]);
+ }
+ db_free_result($result);
+ $bom_list[$stock_id] = $bom;
+ }