当前位置: 首页>>代码示例>>PHP>>正文


PHP CRM_Financial_BAO_FinancialTypeAccount::retrieve方法代码示例

本文整理汇总了PHP中CRM_Financial_BAO_FinancialTypeAccount::retrieve方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Financial_BAO_FinancialTypeAccount::retrieve方法的具体用法?PHP CRM_Financial_BAO_FinancialTypeAccount::retrieve怎么用?PHP CRM_Financial_BAO_FinancialTypeAccount::retrieve使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CRM_Financial_BAO_FinancialTypeAccount的用法示例。


在下文中一共展示了CRM_Financial_BAO_FinancialTypeAccount::retrieve方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testRetrieve

 /**
  * Check method getFinancialAccount()
  */
 public function testRetrieve()
 {
     list($financialAccount, $financialType, $financialAccountType) = $this->createFinancialAccount('Asset', 'Asset Account is');
     $relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Asset Account is' "));
     $financialParams = array('entity_table' => 'civicrm_financial_type', 'entity_id' => $financialType->id, 'account_relationship' => $relationTypeId, 'financial_account_id' => $financialAccount->id);
     $defaults = array();
     $financialAccountType = CRM_Financial_BAO_FinancialTypeAccount::retrieve($financialParams, $defaults);
     $this->assertEquals($financialAccountType['entity_id'], $financialType->id, 'Verify Entity Id.');
     $this->assertEquals($financialAccountType['financial_account_id'], $financialAccount->id, 'Verify Financial Account Id.');
 }
开发者ID:nielosz,项目名称:civicrm-core,代码行数:13,代码来源:FinancialTypeAccountTest.php

示例2: browse

 /**
  * Browse all financial types
  *
  *
  * @return void
  * @access public
  * @static
  */
 function browse()
 {
     // get all financial types sorted by weight
     $financialType = array();
     $dao = new CRM_Financial_DAO_FinancialType();
     $dao->orderBy('name');
     $dao->find();
     while ($dao->fetch()) {
         $financialType[$dao->id] = array();
         CRM_Core_DAO::storeValues($dao, $financialType[$dao->id]);
         $defaults = $financialAccountId = array();
         $financialAccounts = CRM_Contribute_PseudoConstant::financialAccount();
         $financialAccountIds = array();
         $params['entity_id'] = $dao->id;
         $params['entity_table'] = 'civicrm_financial_type';
         CRM_Financial_BAO_FinancialTypeAccount::retrieve($params, CRM_Core_DAO::$_nullArray, $financialAccountIds);
         foreach ($financialAccountIds as $key => $values) {
             if (CRM_Utils_Array::value($values['financial_account_id'], $financialAccounts)) {
                 $financialAccountId[$values['financial_account_id']] = CRM_Utils_Array::value($values['financial_account_id'], $financialAccounts);
             }
         }
         if (!empty($financialAccountId)) {
             $financialType[$dao->id]['financial_account'] = implode(',', $financialAccountId);
         }
         // 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) {
             $action -= CRM_Core_Action::ENABLE;
             $action -= CRM_Core_Action::DISABLE;
             $action -= CRM_Core_Action::DELETE;
             //continue;
         } else {
             if ($dao->is_active) {
                 $action -= CRM_Core_Action::ENABLE;
             } else {
                 $action -= CRM_Core_Action::DISABLE;
             }
         }
         $financialType[$dao->id]['action'] = CRM_Core_Action::formLink(self::links(), $action, array('id' => $dao->id));
     }
     $this->assign('rows', $financialType);
 }
开发者ID:hguru,项目名称:224Civi,代码行数:51,代码来源:FinancialType.php

示例3: getFinancialAccountId

 /**
  * Get financial account id has 'Sales Tax Account is'
  * account relationship with financial type
  *
  * @param int $financialTypeId
  *
  * @return FinancialAccountId
  */
 public static function getFinancialAccountId($financialTypeId)
 {
     $accountRel = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Sales Tax Account is' "));
     $searchParams = array('entity_table' => 'civicrm_financial_type', 'entity_id' => $financialTypeId, 'account_relationship' => $accountRel);
     $result = array();
     CRM_Financial_BAO_FinancialTypeAccount::retrieve($searchParams, $result);
     return CRM_Utils_Array::value('financial_account_id', $result);
 }
开发者ID:nganivet,项目名称:civicrm-core,代码行数:16,代码来源:Contribution.php

示例4: formRule

 /**
  * Global validation rules for the form.
  *
  * @param array $values
  *   posted values of the form
  * @param $files
  * @param $self
  *
  * @return array
  *   list of errors to be posted back to the form
  */
 public static function formRule($values, $files, $self)
 {
     $errorMsg = array();
     $financialAccountTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('financial_account_type', NULL, " AND v.name LIKE 'Liability' "));
     if (isset($values['is_tax'])) {
         if ($values['financial_account_type_id'] != $financialAccountTypeId) {
             $errorMsg['financial_account_type_id'] = ts('Taxable accounts should have Financial Account Type set to Liability.');
         }
         if (CRM_Utils_Array::value('tax_rate', $values) == NULL) {
             $errorMsg['tax_rate'] = ts('Please enter value for tax rate');
         }
     }
     if (CRM_Utils_Array::value('tax_rate', $values) != NULL) {
         if ($values['tax_rate'] < 0 || $values['tax_rate'] >= 100) {
             $errorMsg['tax_rate'] = ts('Tax Rate Should be between 0 - 100');
         }
     }
     if ($self->_action & CRM_Core_Action::UPDATE) {
         if (!isset($values['is_tax'])) {
             $relationshipId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Sales Tax Account is' "));
             $params = array('financial_account_id' => $self->_id, 'account_relationship' => $relationshipId);
             $result = CRM_Financial_BAO_FinancialTypeAccount::retrieve($params, $defaults);
             if ($result) {
                 $errorMsg['is_tax'] = ts('Is Tax? must be set for this financial account');
             }
         }
     }
     return CRM_Utils_Array::crmIsEmptyArray($errorMsg) ? TRUE : $errorMsg;
 }
开发者ID:nganivet,项目名称:civicrm-core,代码行数:40,代码来源:FinancialAccount.php

示例5: add

 /**
  * Add the financial items and financial trxn.
  *
  * @param object $lineItem
  *   Line item object.
  * @param object $contribution
  *   Contribution object.
  * @param bool $taxTrxnID
  *
  * @return void
  */
 public static function add($lineItem, $contribution, $taxTrxnID = FALSE, $trxnId = NULL)
 {
     $contributionStatuses = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
     $financialItemStatus = CRM_Core_PseudoConstant::get('CRM_Financial_DAO_FinancialItem', 'status_id');
     $itemStatus = NULL;
     if ($contribution->contribution_status_id == array_search('Completed', $contributionStatuses) || $contribution->contribution_status_id == array_search('Pending refund', $contributionStatuses)) {
         $itemStatus = array_search('Paid', $financialItemStatus);
     } elseif ($contribution->contribution_status_id == array_search('Pending', $contributionStatuses) || $contribution->contribution_status_id == array_search('In Progress', $contributionStatuses)) {
         $itemStatus = array_search('Unpaid', $financialItemStatus);
     } elseif ($contribution->contribution_status_id == array_search('Partially paid', $contributionStatuses)) {
         $itemStatus = array_search('Partially paid', $financialItemStatus);
     }
     $params = array('transaction_date' => CRM_Utils_Date::isoToMysql($contribution->receive_date), 'contact_id' => $contribution->contact_id, 'amount' => $lineItem->line_total, 'currency' => $contribution->currency, 'entity_table' => 'civicrm_line_item', 'entity_id' => $lineItem->id, 'description' => ($lineItem->qty != 1 ? $lineItem->qty . ' of ' : '') . ' ' . $lineItem->label, 'status_id' => $itemStatus);
     if ($taxTrxnID) {
         $invoiceSettings = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME, 'contribution_invoice_settings');
         $taxTerm = CRM_Utils_Array::value('tax_term', $invoiceSettings);
         $params['amount'] = $lineItem->tax_amount;
         $params['description'] = $taxTerm;
         $accountRel = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Sales Tax Account is' "));
     } else {
         $accountRel = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Income Account is' "));
     }
     if ($lineItem->financial_type_id) {
         $searchParams = array('entity_table' => 'civicrm_financial_type', 'entity_id' => $lineItem->financial_type_id, 'account_relationship' => $accountRel);
         $result = array();
         CRM_Financial_BAO_FinancialTypeAccount::retrieve($searchParams, $result);
         $params['financial_account_id'] = CRM_Utils_Array::value('financial_account_id', $result);
     }
     if (empty($trxnId)) {
         $trxn = CRM_Core_BAO_FinancialTrxn::getFinancialTrxnId($contribution->id, 'ASC', TRUE);
         $trxnId['id'] = $trxn['financialTrxnId'];
     }
     return self::create($params, NULL, $trxnId);
 }
开发者ID:kidaa30,项目名称:yes,代码行数:45,代码来源:FinancialItem.php

示例6: testRetrieve

 /**
  * check method getFinancialAccount()
  */
 function testRetrieve()
 {
     $params = array('name' => 'TestFinancialAccount_3', 'is_deductible' => 0, 'is_active' => 1, 'is_reserved' => 0);
     $ids = array();
     $financialAccount = CRM_Financial_BAO_FinancialAccount::add($params, $ids);
     $params['name'] = 'test_financialType3';
     $financialType = CRM_Financial_BAO_FinancialType::add($params, $ids);
     $relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Asset Account is' "));
     $financialParams = array('entity_table' => 'civicrm_financial_type', 'entity_id' => $financialType->id, 'account_relationship' => $relationTypeId, 'financial_account_id' => $financialAccount->id);
     CRM_Financial_BAO_FinancialTypeAccount::add($financialParams, $ids);
     $defaults = array();
     $financialAccountType = CRM_Financial_BAO_FinancialTypeAccount::retrieve($financialParams, $defaults);
     $this->assertEquals($financialAccountType['entity_id'], $financialType->id, 'Verify Entity Id.');
     $this->assertEquals($financialAccountType['financial_account_id'], $financialAccount->id, 'Verify Financial Account Id.');
 }
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:18,代码来源:FinancialTypeAccountTest.php

示例7: formRule

 /**
  * global validation rules for the form
  *
  * @param array $fields posted values of the form
  *
  * @return array list of errors to be posted back to the form
  * @static
  * @access public
  */
 static function formRule($values, $files, $self)
 {
     $errorMsg = array();
     $errorFlag = FALSE;
     if ($self->_action == CRM_Core_Action::DELETE) {
         $relationValues = CRM_Core_PseudoConstant::get('CRM_Financial_DAO_EntityFinancialAccount', 'account_relationship');
         if (CRM_Utils_Array::value('financial_account_id', $values) != 'select') {
             if ($relationValues[$values['account_relationship']] == 'Premiums Inventory Account is' || $relationValues[$values['account_relationship']] == 'Cost of Sales Account is') {
                 $premiumsProduct = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_PremiumsProduct', $values['financial_type_id'], 'product_id', 'financial_type_id');
                 $product = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Product', $values['financial_type_id'], 'name', 'financial_type_id');
                 if (!empty($premiumsProduct) || !empty($product)) {
                     $errorMsg['account_relationship'] = 'You cannot remove ' . $relationValues[$values['account_relationship']] . ' relationship while the Financial Type is used for a Premium.';
                 }
             }
         }
     }
     if (CRM_Utils_Array::value('account_relationship', $values) == 'select') {
         $errorMsg['account_relationship'] = 'Financial Account relationship is a required field.';
     }
     if (CRM_Utils_Array::value('financial_account_id', $values) == 'select') {
         $errorMsg['financial_account_id'] = 'Financial Account is a required field.';
     }
     if (!empty($values['account_relationship']) && !empty($values['financial_account_id'])) {
         $params = array('account_relationship' => $values['account_relationship'], 'entity_id' => $self->_aid);
         $defaults = array();
         if ($self->_action == CRM_Core_Action::ADD) {
             $result = CRM_Financial_BAO_FinancialTypeAccount::retrieve($params, $defaults);
             if ($result) {
                 $errorFlag = TRUE;
             }
         }
         if ($self->_action == CRM_Core_Action::UPDATE) {
             if ($values['account_relationship'] == $self->_defaultValues['account_relationship'] && $values['financial_account_id'] == $self->_defaultValues['financial_account_id']) {
                 $errorFlag = FALSE;
             } else {
                 $params['financial_account_id'] = $values['financial_account_id'];
                 $result = CRM_Financial_BAO_FinancialTypeAccount::retrieve($params, $defaults);
                 if ($result) {
                     $errorFlag = TRUE;
                 }
             }
         }
         if ($errorFlag) {
             $errorMsg['account_relationship'] = ts('This account relationship already exits');
         }
     }
     return CRM_Utils_Array::crmIsEmptyArray($errorMsg) ? TRUE : $errorMsg;
 }
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:57,代码来源:FinancialTypeAccount.php

示例8: add

 /**
  * function to add the financial items and financial trxn
  *
  * @param object $lineItem     line item object
  * @param object $contribution contribution object
  *
  * @access public
  * @static
  * @return void
  */
 static function add($lineItem, $contribution)
 {
     $contributionStatuses = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
     $financialItemStatus = CRM_Core_PseudoConstant::get('CRM_Financial_DAO_FinancialItem', 'status_id');
     $itemStatus = NULL;
     if ($contribution->contribution_status_id == array_search('Completed', $contributionStatuses)) {
         $itemStatus = array_search('Paid', $financialItemStatus);
     } elseif ($contribution->contribution_status_id == array_search('Pending', $contributionStatuses) || $contribution->contribution_status_id == array_search('In Progress', $contributionStatuses)) {
         $itemStatus = array_search('Unpaid', $financialItemStatus);
     } elseif ($contribution->contribution_status_id == array_search('Partially paid', $contributionStatuses)) {
         $itemStatus = array_search('Partially paid', $financialItemStatus);
     }
     $params = array('transaction_date' => CRM_Utils_Date::isoToMysql($contribution->receive_date), 'contact_id' => $contribution->contact_id, 'amount' => $lineItem->line_total, 'currency' => $contribution->currency, 'entity_table' => 'civicrm_line_item', 'entity_id' => $lineItem->id, 'description' => ($lineItem->qty != 1 ? $lineItem->qty . ' of ' : '') . ' ' . $lineItem->label, 'status_id' => $itemStatus);
     if ($lineItem->financial_type_id) {
         $searchParams = array('entity_table' => 'civicrm_financial_type', 'entity_id' => $lineItem->financial_type_id, 'account_relationship' => 1);
         $result = array();
         CRM_Financial_BAO_FinancialTypeAccount::retrieve($searchParams, $result);
         $params['financial_account_id'] = CRM_Utils_Array::value('financial_account_id', $result);
     }
     $trxn = CRM_Core_BAO_FinancialTrxn::getFinancialTrxnId($contribution->id, 'ASC', TRUE);
     $trxnId['id'] = $trxn['financialTrxnId'];
     return self::create($params, NULL, $trxnId);
 }
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:33,代码来源:FinancialItem.php

示例9: browse

 /**
  * Browse all financial types.
  */
 public function browse()
 {
     // Check permission for Financial Type when ACL-FT is enabled
     if (CRM_Financial_BAO_FinancialType::isACLFinancialTypeStatus() && !CRM_Core_Permission::check('administer CiviCRM Financial Types')) {
         CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
     }
     // get all financial types sorted by weight
     $financialType = array();
     $dao = new CRM_Financial_DAO_FinancialType();
     $dao->orderBy('name');
     $dao->find();
     while ($dao->fetch()) {
         $financialType[$dao->id] = array();
         CRM_Core_DAO::storeValues($dao, $financialType[$dao->id]);
         $defaults = $financialAccountId = array();
         $financialAccounts = CRM_Contribute_PseudoConstant::financialAccount();
         $financialAccountIds = array();
         $params['entity_id'] = $dao->id;
         $params['entity_table'] = 'civicrm_financial_type';
         CRM_Financial_BAO_FinancialTypeAccount::retrieve($params, CRM_Core_DAO::$_nullArray, $financialAccountIds);
         foreach ($financialAccountIds as $key => $values) {
             if (!empty($financialAccounts[$values['financial_account_id']])) {
                 $financialAccountId[$values['financial_account_id']] = CRM_Utils_Array::value($values['financial_account_id'], $financialAccounts);
             }
         }
         if (!empty($financialAccountId)) {
             $financialType[$dao->id]['financial_account'] = implode(',', $financialAccountId);
         }
         // 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) {
             $action -= CRM_Core_Action::ENABLE;
             $action -= CRM_Core_Action::DISABLE;
             $action -= CRM_Core_Action::DELETE;
         } else {
             if ($dao->is_active) {
                 $action -= CRM_Core_Action::ENABLE;
             } else {
                 $action -= CRM_Core_Action::DISABLE;
             }
         }
         $financialType[$dao->id]['action'] = CRM_Core_Action::formLink(self::links(), $action, array('id' => $dao->id), ts('more'), FALSE, 'financialType.manage.action', 'FinancialType', $dao->id);
     }
     $this->assign('rows', $financialType);
 }
开发者ID:nielosz,项目名称:civicrm-core,代码行数:49,代码来源:FinancialType.php


注:本文中的CRM_Financial_BAO_FinancialTypeAccount::retrieve方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。