+ $date = sql2date($work_order['date_']);
+
+ $result = get_work_order_productions($woid); // check the produced quantity
+ $qty = 0;
+ 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_);\r
+ }
+\r
+ $result = get_work_order_issues($woid);
+ $cost = 0;
+ $issue_no = 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\r
+ $cost = get_gl_wo_cost($woid, WO_LABOUR); \r
+ if ($cost != 0)
+ add_labour_cost($work_order['stock_id'], 1, $date, -$cost, true);
+ \r
+ //Adust avg overhead cost\r
+ $cost = get_gl_wo_cost($woid, WO_OVERHEAD); \r
+ 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");
+
+ // void all related stock moves
+ void_stock_move(ST_WORKORDER, $woid);
+
+ // void any related bank/gl trans
+ void_bank_trans(ST_WORKORDER, $woid, true);
+
+ // clear the requirements units received
+ void_wo_requirements($woid);