Exemplo n.º 1
0
 /**
  * @param string $name
  */
 public function financialAccountDelete($name)
 {
     $financialAccount = new CRM_Financial_DAO_FinancialAccount();
     $financialAccount->name = $name;
     if ($financialAccount->find(TRUE)) {
         $entityFinancialType = new CRM_Financial_DAO_EntityFinancialAccount();
         $entityFinancialType->financial_account_id = $financialAccount->id;
         $entityFinancialType->delete();
         $financialAccount->delete();
     }
 }
Exemplo n.º 2
0
 /**
  * Delete financial Types.
  *
  * @param int $financialAccountId
  */
 public static function del($financialAccountId)
 {
     // checking if financial type is present
     $check = FALSE;
     //check dependencies
     $dependency = array(array('Core', 'FinancialTrxn', 'to_financial_account_id'), array('Financial', 'FinancialTypeAccount', 'financial_account_id'));
     foreach ($dependency as $name) {
         require_once str_replace('_', DIRECTORY_SEPARATOR, "CRM_" . $name[0] . "_BAO_" . $name[1]) . ".php";
         $className = "CRM_{$name[0]}_BAO_{$name[1]}";
         $bao = new $className();
         $bao->{$name}[2] = $financialAccountId;
         if ($bao->find(TRUE)) {
             $check = TRUE;
         }
     }
     if ($check) {
         CRM_Core_Session::setStatus(ts('This financial account cannot be deleted since it is being used as a header account. Please remove it from being a header account before trying to delete it again.'));
         return CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/admin/financial/financialAccount', "reset=1&action=browse"));
     }
     // delete from financial Type table
     $financialAccount = new CRM_Financial_DAO_FinancialAccount();
     $financialAccount->id = $financialAccountId;
     $financialAccount->delete();
 }