/** * Function to delete financial Types * * @param int $contributionTypeId * @static */ static function del($financialTypeId) { $financialType = new CRM_Financial_DAO_FinancialType(); $financialType->id = $financialTypeId; $financialType->find(true); // tables to ingore checks for financial_type_id $ignoreTables = array('CRM_Financial_DAO_EntityFinancialAccount'); //TODO: if (!$financialType->find(true)) { // ensure that we have no objects that have an FK to this financial type id TODO: that cannot be null $occurrences = $financialType->findReferences(); if ($occurrences) { $tables = array(); foreach ($occurrences as $occurence) { $className = get_class($occurence); if (!in_array($className, $ignoreTables)) { $tables[] = $className; } } if (!empty($tables)) { $message = ts('The following tables have an entry for this financial type: %1', array('%1' => implode(', ', $tables))); $errors = array(); $errors['is_error'] = 1; $errors['error_message'] = $message; return $errors; } } //delete from financial Type table $financialType->delete(); $entityFinancialType = new CRM_Financial_DAO_EntityFinancialAccount(); $entityFinancialType->entity_id = $financialTypeId; $entityFinancialType->entity_table = 'civicrm_financial_type'; $entityFinancialType->delete(); return FALSE; }