+ // if production we need to check the qoh of the wo requirements
+ if (($_POST['ProductionType'] == 1) && !$SysPrefs->allow_negative_stock())
+ {
+ $err = false;
+ $result = get_wo_requirements($_POST['selected_id']);
+ while ($row = db_fetch($result))
+ {
+ if ($row['mb_flag'] == 'D') // service, non stock
+ continue;
+ $qoh = get_qoh_on_date($row["stock_id"], $row["loc_code"], $_POST['date_']);
+ if ($qoh - $row['units_req'] * input_num('quantity') < 0)
+ {
+ display_error( _("The production cannot be processed because a required item would cause a negative inventory balance :") .
+ " " . $row['stock_id'] . " - " . $row['description']);
+ $err = true;
+ }
+ }
+ if ($err)
+ {
+ set_focus('quantity');
+ return false;
+ }
+ }