Merged changes from stable branch up to 2.3.23.
[fa-stable.git] / purchasing / includes / db / po_db.inc
index 510851429058f523a0de2b677e4f9f2cc6661c79..9f5a0cc299ad550ec072d3dafe1972d671fb9f7c 100644 (file)
@@ -45,12 +45,18 @@ function get_supplier_details_to_order(&$order, $supplier_id)
 
 function delete_po($po)
 {
+       global $Refs;
+
+       begin_transaction();
        hook_db_prevoid($po, ST_PURCHORDER);
        $sql = "DELETE FROM ".TB_PREF."purch_orders WHERE order_no=".db_escape($po);
        db_query($sql, "The order header could not be deleted");
 
        $sql = "DELETE FROM ".TB_PREF."purch_order_details WHERE order_no =".db_escape($po);
        db_query($sql, "The order detail lines could not be deleted");
+
+       $Refs->restore_last(ST_PURCHORDER, $po);
+       commit_transaction();
 }
 
 //----------------------------------------------------------------------------------------