Passing error message parameter err_msg to low level db functions from caller does...
[fa-stable.git] / manufacturing / includes / db / work_orders_db.inc
index 05ddbb6b4075247e1c7cee399f015ec0c8aac3d3..2cd0ced36f3da48546b330fd0ce43de06d5dbe24 100644 (file)
@@ -122,10 +122,12 @@ function get_work_order($woid, $allow_null=false)
 {
     $sql = "SELECT wo.*,st.description As StockItemName,l.location_name,
                l.delivery_address,l.email, l.contact, st.inventory_account, st.wip_account
-               FROM ".TB_PREF."workorders wo, "
+                       FROM ".TB_PREF."workorders wo
+                       LEFT JOIN ".TB_PREF."voided v ON v.id=wo.id and v.type=".ST_WORKORDER.","
                        .TB_PREF."stock_master st, "
                        .TB_PREF."locations l
-               WHERE st.stock_id=wo.stock_id
+               WHERE ISNULL(v.id)
+               AND st.stock_id=wo.stock_id
                AND     l.loc_code=wo.loc_code
                AND wo.id=".db_escape($woid)."
                GROUP BY wo.id";
@@ -287,8 +289,7 @@ function void_work_order($woid)
        void_wo_requirements($woid);
 
        // close workorder
-       // FIXME: due to bug in 2.4 db scheme (conflicting wo_ref unique key) we have to fix wo_ref here:
-       $sql = "UPDATE ".TB_PREF."workorders SET closed=1,units_reqd=0,units_issued=0, wo_ref=CONCAT(wo_ref, ' ', '".uniqid()."') WHERE id = "
+       $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");