- // clear the requirements units received
- void_wo_requirements($woid);
- }
- else
- {
- // void everything inside the work order : issues, productions, payments
- $date = sql2date($work_order['date_']);
-
- $result = get_work_order_productions($woid); // check the produced quantity
- while ($row = db_fetch($result))
- {
- void_work_order_produce($row['id']);
-
- //Post voided entry if not prevoided explicitly
- $void_entry = get_voided_entry(ST_MANURECEIVE, $row['id']);
- if ($void_entry)
- continue;
- $memo_ = _("Voiding Work Order Trans # ").$woid;
- add_audit_trail(ST_MANURECEIVE, $row['id'], today(), _("Voided.")."\n".$memo_);
- add_voided_entry(ST_MANURECEIVE, $row['id'], today(), $memo_);
- }
-
- $result = get_work_order_issues($woid);
- $cost = 0;
- while ($row = db_fetch($result))
- {
- void_work_order_issue($row['issue_no']);
-
- //Post voided entry if not prevoided explicitly
- $void_entry = get_voided_entry(ST_MANUISSUE, $row['issue_no']);
- if ($void_entry)
- continue;
- $memo_ = _("Voiding Work Order Trans # ").$woid;
- add_audit_trail(ST_MANUISSUE, $row['issue_no'], today(), _("Voided.")."\n".$memo_);
- add_voided_entry(ST_MANUISSUE, $row['issue_no'], today(), $memo_);
- }
-
- //Adust avg labour cost
- $cost = get_gl_wo_cost($woid, WO_LABOUR);
- if ($cost != 0)
- add_labour_cost($work_order['stock_id'], 1, $date, -$cost, true);
-
- //Adust avg overhead cost
- $cost = get_gl_wo_cost($woid, WO_OVERHEAD);
- if ($cost != 0)
- add_overhead_cost($work_order['stock_id'], 1, $date, -$cost, true);
-
- $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");