Add and Manage Customers, Suppliers: contact persons where not removed when deleting...
[fa-stable.git] / includes / db / crm_contacts_db.inc
index e5a91fb1be4561bbca0c811b37074ab15ef63402..b9a7eda8776492023eb8bd444e3efd7caa5303a3 100644 (file)
@@ -175,9 +175,9 @@ function update_person_contacts($id, $cat_ids, $entity_id=null, $type=null)
 
 function delete_entity_contacts($class, $entity)
 {
-       delete_crm_contacts(null, $class, $entity);
        // cleanup
        $res = get_crm_persons($class, null, $entity, null, true);
+       delete_crm_contacts(null, $class, $entity);
        while($person = db_fetch($res)) {
                $rels = get_person_contacts($person['id']);
                if (count($rels) == 0) {
@@ -242,7 +242,7 @@ function get_crm_category_name($id)
        $result = db_query($sql, "could not get sales type");
 
        $row = db_fetch_row($result);
-       return $row[0];
+       return is_array($row) ? $row[0] : false;
 }
 
 //----------------------------------------------------------------------------------------