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


PHP CRM_Contribute_DAO_Contribution::toArray方法代码示例

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


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

示例1: match

 /** 
  * Generate a set of suggestions for the given bank transaction
  * 
  * @return array(match structures)
  */
 public function match(CRM_Banking_BAO_BankTransaction $btx, CRM_Banking_Matcher_Context $context)
 {
     $config = $this->_plugin_config;
     $threshold = $this->getThreshold();
     $penalty = $this->getPenalty($btx);
     $data_parsed = $btx->getDataParsed();
     // first see if all the required values are there
     if (!$this->requiredValuesPresent($btx)) {
         return null;
     }
     // resolve accepted states
     $accepted_status_ids = $this->getAcceptedContributionStatusIDs();
     $contributions = array();
     $contribution2contact = array();
     $contribution2totalamount = array();
     $contributions_identified = array();
     // check if this is actually enabled
     if ($config->contribution_search) {
         // find contacts
         $contacts_found = $context->findContacts($threshold, $data_parsed['name'], $config->lookup_contact_by_name);
         // with the identified contacts, look up contributions
         foreach ($contacts_found as $contact_id => $contact_probabiliy) {
             if ($contact_probabiliy < $threshold) {
                 continue;
             }
             $potential_contributions = $this->getPotentialContributionsForContact($contact_id, $context);
             foreach ($potential_contributions as $contribution) {
                 // check for expected status
                 if (!in_array($contribution['contribution_status_id'], $accepted_status_ids)) {
                     continue;
                 }
                 $contribution_probability = $this->rateContribution($contribution, $context);
                 // apply penalty
                 $contribution_probability -= $penalty;
                 if ($contribution_probability > $threshold) {
                     $contributions[$contribution['id']] = $contribution_probability;
                     $contribution2contact[$contribution['id']] = $contact_id;
                     $contribution2totalamount[$contribution['id']] = $contribution['total_amount'];
                 }
             }
         }
     }
     // add the contributions coming in from a list (if any)
     if (!empty($config->contribution_list)) {
         if (!empty($data_parsed[$config->contribution_list])) {
             $id_list = explode(',', $data_parsed[$config->contribution_list]);
             foreach ($id_list as $contribution_id_string) {
                 $contribution_id = (int) $contribution_id_string;
                 if ($contribution_id) {
                     $contribution_bao = new CRM_Contribute_DAO_Contribution();
                     if ($contribution_bao->get('id', $contribution_id)) {
                         $contribution = $contribution_bao->toArray();
                         // check for expected status
                         if (!in_array($contribution['contribution_status_id'], $accepted_status_ids)) {
                             continue;
                         }
                         $contribution_probability = $this->rateContribution($contribution, $context);
                         // apply penalty
                         $contribution_probability -= $penalty;
                         if ($contribution_probability > $threshold) {
                             $contributions[$contribution['id']] = $contribution_probability;
                             $contribution2contact[$contribution['id']] = $contribution['contact_id'];
                             $contribution2totalamount[$contribution['id']] = $contribution['total_amount'];
                             $contacts_found[$contribution['contact_id']] = 1.0;
                             $contributions_identified[] = $contribution['id'];
                         }
                     }
                 }
             }
         }
     }
     // transform all of the contributions found into suggestions
     foreach ($contributions as $contribution_id => $contribution_probability) {
         $contact_id = $contribution2contact[$contribution_id];
         $suggestion = new CRM_Banking_Matcher_Suggestion($this, $btx);
         if (!in_array($contribution_id, $contributions_identified)) {
             if ($contacts_found[$contact_id] >= 1.0) {
                 $suggestion->addEvidence(1.0, ts("Contact was positively identified."));
             } else {
                 $suggestion->addEvidence($contacts_found[$contact_id], ts("Contact was likely identified."));
             }
         }
         if ($contribution_probability >= 1.0) {
             $suggestion->setTitle(ts("Matching contribution found"));
             if ($config->mode != "cancellation") {
                 $suggestion->addEvidence(1.0, ts("A pending contribution matching the transaction was found."));
             } else {
                 $suggestion->addEvidence(1.0, ts("This transaction is the <b>cancellation</b> of the below contribution."));
             }
         } else {
             $suggestion->setTitle(ts("Possible matching contribution found"));
             if ($config->mode != "cancellation") {
                 $suggestion->addEvidence($contacts_found[$contact_id], ts("A pending contribution partially matching the transaction was found."));
             } else {
                 $suggestion->addEvidence($contacts_found[$contact_id], ts("This transaction could be the <b>cancellation</b> of the below contribution."));
//.........这里部分代码省略.........
开发者ID:VangelisP,项目名称:org.project60.banking,代码行数:101,代码来源:ExistingContribution.php


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