/**
  * Browse all custom data groups.
  *
  *
  * @return void
  * @access public
  * @static
  */
 function browse()
 {
     // get all custom groups sorted by weight
     $contributionType = array();
     $dao = new CRM_Financial_DAO_FinancialAccount();
     $dao->orderBy('financial_account_type_id, name');
     $dao->find();
     $financialAccountType = CRM_Core_PseudoConstant::get('CRM_Financial_DAO_FinancialAccount', 'financial_account_type_id');
     while ($dao->fetch()) {
         $contributionType[$dao->id] = array();
         CRM_Core_DAO::storeValues($dao, $contributionType[$dao->id]);
         $contributionType[$dao->id]['financial_account_type_id'] = $financialAccountType[$dao->financial_account_type_id];
         // form all action links
         $action = array_sum(array_keys($this->links()));
         // update enable/disable links depending on if it is is_reserved or is_active
         if ($dao->is_reserved) {
             continue;
         } else {
             if ($dao->is_active) {
                 $action -= CRM_Core_Action::ENABLE;
             } else {
                 $action -= CRM_Core_Action::DISABLE;
             }
         }
         $contributionType[$dao->id]['action'] = CRM_Core_Action::formLink(self::links(), $action, array('id' => $dao->id), ts('more'), FALSE, 'financialAccount.manage.action', 'FinancialAccount', $dao->id);
     }
     $this->assign('rows', $contributionType);
 }
Пример #2
0
 /**
  * @return array
  */
 public static function &exportableFields()
 {
     if (!self::$_exportableFields) {
         if (!self::$_exportableFields) {
             self::$_exportableFields = array();
         }
         $impFields = CRM_Contribute_DAO_Contribution::export();
         $expFieldProduct = CRM_Contribute_DAO_Product::export();
         $expFieldsContrib = CRM_Contribute_DAO_ContributionProduct::export();
         $typeField = CRM_Financial_DAO_FinancialType::export();
         $financialAccount = CRM_Financial_DAO_FinancialAccount::export();
         $optionField = CRM_Core_OptionValue::getFields($mode = 'contribute');
         $contributionStatus = array('contribution_status' => array('title' => ts('Contribution Status'), 'name' => 'contribution_status', 'data_type' => CRM_Utils_Type::T_STRING));
         $contributionPage = array('contribution_page' => array('title' => ts('Contribution Page'), 'name' => 'contribution_page', 'where' => 'civicrm_contribution_page.title', 'data_type' => CRM_Utils_Type::T_STRING));
         $contributionNote = array('contribution_note' => array('title' => ts('Contribution Note'), 'name' => 'contribution_note', 'data_type' => CRM_Utils_Type::T_TEXT));
         $contributionRecurId = array('contribution_recur_id' => array('title' => ts('Recurring Contributions ID'), 'name' => 'contribution_recur_id', 'where' => 'civicrm_contribution.contribution_recur_id', 'data_type' => CRM_Utils_Type::T_INT));
         $extraFields = array('contribution_batch' => array('title' => ts('Batch Name')));
         $softCreditFields = array('contribution_soft_credit_name' => array('name' => 'contribution_soft_credit_name', 'title' => 'Soft Credit For', 'where' => 'civicrm_contact_d.display_name', 'data_type' => CRM_Utils_Type::T_STRING), 'contribution_soft_credit_amount' => array('name' => 'contribution_soft_credit_amount', 'title' => 'Soft Credit Amount', 'where' => 'civicrm_contribution_soft.amount', 'data_type' => CRM_Utils_Type::T_MONEY), 'contribution_soft_credit_type' => array('name' => 'contribution_soft_credit_type', 'title' => 'Soft Credit Type', 'where' => 'contribution_softcredit_type.label', 'data_type' => CRM_Utils_Type::T_STRING), 'contribution_soft_credit_contribution_id' => array('name' => 'contribution_soft_credit_contribution_id', 'title' => 'Soft Credit For Contribution ID', 'where' => 'civicrm_contribution_soft.contribution_id', 'data_type' => CRM_Utils_Type::T_INT));
         // CRM-16713 - contribution search by Premiums on 'Find Contribution' form.
         $premiums = array('contribution_product_id' => array('title' => ts('Premium'), 'name' => 'contribution_product_id', 'where' => 'civicrm_product.id', 'data_type' => CRM_Utils_Type::T_INT));
         $fields = array_merge($impFields, $typeField, $contributionStatus, $contributionPage, $optionField, $expFieldProduct, $expFieldsContrib, $contributionNote, $contributionRecurId, $extraFields, $softCreditFields, $financialAccount, $premiums, CRM_Core_BAO_CustomField::getFieldsForImport('Contribution'));
         self::$_exportableFields = $fields;
     }
     return self::$_exportableFields;
 }
Пример #3
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();
     }
 }
 static function &exportableFields()
 {
     if (!self::$_exportableFields) {
         if (!self::$_exportableFields) {
             self::$_exportableFields = array();
         }
         $impFields = CRM_Contribute_DAO_Contribution::export();
         $expFieldProduct = CRM_Contribute_DAO_Product::export();
         $expFieldsContrib = CRM_Contribute_DAO_ContributionProduct::export();
         $typeField = CRM_Financial_DAO_FinancialType::export();
         $financialAccount = CRM_Financial_DAO_FinancialAccount::export();
         $optionField = CRM_Core_OptionValue::getFields($mode = 'contribute');
         $contributionStatus = array('contribution_status' => array('title' => ts('Contribution Status'), 'name' => 'contribution_status', 'data_type' => CRM_Utils_Type::T_STRING));
         $contributionNote = array('contribution_note' => array('title' => ts('Contribution Note'), 'name' => 'contribution_note', 'data_type' => CRM_Utils_Type::T_TEXT));
         $contributionRecurId = array('contribution_recur_id' => array('title' => ts('Recurring Contributions ID'), 'name' => 'contribution_recur_id', 'where' => 'civicrm_contribution.contribution_recur_id', 'data_type' => CRM_Utils_Type::T_INT));
         $extraFields = array('contribution_batch' => array('title' => ts('Batch Name')));
         $fields = array_merge($impFields, $typeField, $contributionStatus, $optionField, $expFieldProduct, $expFieldsContrib, $contributionNote, $contributionRecurId, $extraFields, $financialAccount, CRM_Core_BAO_CustomField::getFieldsForImport('Contribution'));
         self::$_exportableFields = $fields;
     }
     return self::$_exportableFields;
 }
Пример #5
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();
 }
Пример #6
0
 /**
  * Returns the list of fields that can be exported
  *
  * @param bool $prefix
  *
  * @return array
  */
 static function &export($prefix = false)
 {
     if (!self::$_export) {
         self::$_export = array();
         $fields = self::fields();
         foreach ($fields as $name => $field) {
             if (CRM_Utils_Array::value('export', $field)) {
                 if ($prefix) {
                     self::$_export['financial_account'] =& $fields[$name];
                 } else {
                     self::$_export[$name] =& $fields[$name];
                 }
             }
         }
     }
     return self::$_export;
 }