- $result = get_work_order_productions($woid); // check the produced quantity
- $qty = 0;
- while ($row = db_fetch($result))
- {
- $qty += $row['quantity'];
- // clear the production record
- $sql = "UPDATE ".TB_PREF."wo_manufacture SET quantity=0 WHERE id=".$row['id'];
- db_query($sql, "Cannot void a wo production");
-
- void_stock_move(ST_MANURECEIVE, $row['id']); // and void the stock moves;
- }
- $result = get_additional_issues($woid); // check the issued quantities
- $cost = 0;
- $issue_no = 0;
- while ($row = db_fetch($result))
- {
- $unit_cost = get_unit_cost($row['stock_id']);
- $icost = $unit_cost * $row['qty_issued'];
- $cost += $icost;
- if ($issue_no == 0)
- $issue_no = $row['issue_no'];
- // void the actual issue items and their quantities
- $sql = "UPDATE ".TB_PREF."wo_issue_items SET qty_issued = 0 WHERE issue_id="
- .db_escape($row['id']);
- db_query($sql,"A work order issue item could not be voided");
- }
- if ($issue_no != 0)
- void_stock_move(ST_MANUISSUE, $issue_no); // and void the stock moves
-
- if ($cost != 0)
- add_issue_cost($work_order['stock_id'], -$qty, $date, $cost);
-
- $sql = "UPDATE ".TB_PREF."workorders SET closed=1,units_reqd=0,units_issued=0 WHERE id = "
- .db_escape($woid);
- db_query($sql, "The work order couldn't be voided");