Add and Manage Customers, Suppliers: contact persons where not removed when deleting...
[fa-stable.git] / purchasing / includes / db / suppliers_db.inc
index 602b86bf60049a52f50d3c385785510480909acb..c3a16d21488a9ac516eb55379e87a39b3f18f517 100644 (file)
@@ -73,8 +73,12 @@ function update_supplier($supplier_id, $supp_name, $supp_ref, $address, $supp_ad
 
 function delete_supplier($supplier_id)
 {
+       begin_transaction();
+       delete_entity_contacts('supplier', $supplier_id);
        $sql="DELETE FROM ".TB_PREF."suppliers WHERE supplier_id=".db_escape($supplier_id);
+
        db_query($sql,"check failed");
+       commit_transaction();
 }
 
 function get_supplier_details($supplier_id, $to=null, $all=true)
@@ -144,7 +148,7 @@ function get_supplier_name($supplier_id)
 
        $row = db_fetch_row($result);
 
-       return $row[0];
+       return is_array($row) ? $row[0] : false;
 }
 
 function get_supplier_accounts($supplier_id)