Add and Manage Customers, Suppliers: contact persons where not removed when deleting...
[fa-stable.git] / includes / db / crm_contacts_db.inc
index a226e496c81f3a583a0eb8c786228dd84e3bdd39..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;
 }
 
 //----------------------------------------------------------------------------------------
@@ -313,4 +313,3 @@ function is_crm_category_used($id)
 }
 
 
-?>
\ No newline at end of file