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


PHP CRM_Pledge_BAO_PledgePayment::calculatePledgeStatus方法代码示例

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


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

示例1: array

 /**
  * takes an associative array and creates a pledge object
  *
  * @param array $params (reference ) an assoc array of name/value pairs
  *
  * @return object CRM_Pledge_BAO_Pledge object
  * @access public
  * @static
  */
 static function &create(&$params)
 {
     //FIXME: a cludgy hack to fix the dates to MySQL format
     $dateFields = array('start_date', 'create_date', 'acknowledge_date', 'modified_date', 'cancel_date', 'end_date');
     foreach ($dateFields as $df) {
         if (isset($params[$df])) {
             $params[$df] = CRM_Utils_Date::isoToMysql($params[$df]);
         }
     }
     $transaction = new CRM_Core_Transaction();
     $paymentParams = array();
     $paymentParams['status_id'] = CRM_Utils_Array::value('status_id', $params);
     if (CRM_Utils_Array::value('installment_amount', $params)) {
         $params['amount'] = $params['installment_amount'] * $params['installments'];
     }
     //get All Payments status types.
     $paymentStatusTypes = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
     //update the pledge status only if it does NOT come from form
     if (!isset($params['pledge_status_id'])) {
         if (isset($params['contribution_id'])) {
             if ($params['installments'] > 1) {
                 $params['status_id'] = array_search('In Progress', $paymentStatusTypes);
             }
         } else {
             if (!empty($params['id'])) {
                 $params['status_id'] = CRM_Pledge_BAO_PledgePayment::calculatePledgeStatus($params['id']);
             } else {
                 $params['status_id'] = array_search('Pending', $paymentStatusTypes);
             }
         }
     }
     $pledge = self::add($params);
     if (is_a($pledge, 'CRM_Core_Error')) {
         $pledge->rollback();
         return $pledge;
     }
     //handle custom data.
     if (CRM_Utils_Array::value('custom', $params) && is_array($params['custom'])) {
         CRM_Core_BAO_CustomValueTable::store($params['custom'], 'civicrm_pledge', $pledge->id);
     }
     // skip payment stuff inedit mode
     if (!isset($params['id']) || CRM_Utils_Array::value('is_pledge_pending', $params)) {
         //if pledge is pending delete all payments and recreate.
         if (CRM_Utils_Array::value('is_pledge_pending', $params)) {
             CRM_Pledge_BAO_PledgePayment::deletePayments($pledge->id);
         }
         //building payment params
         $paymentParams['pledge_id'] = $pledge->id;
         $paymentKeys = array('amount', 'installments', 'scheduled_date', 'frequency_unit', 'currency', 'frequency_day', 'frequency_interval', 'contribution_id', 'installment_amount', 'actual_amount');
         foreach ($paymentKeys as $key) {
             $paymentParams[$key] = CRM_Utils_Array::value($key, $params, NULL);
         }
         CRM_Pledge_BAO_PledgePayment::create($paymentParams);
     }
     $transaction->commit();
     $url = CRM_Utils_System::url('civicrm/contact/view/pledge', "action=view&reset=1&id={$pledge->id}&cid={$pledge->contact_id}&context=home");
     $recentOther = array();
     if (CRM_Core_Permission::checkActionPermission('CiviPledge', CRM_Core_Action::UPDATE)) {
         $recentOther['editUrl'] = CRM_Utils_System::url('civicrm/contact/view/pledge', "action=update&reset=1&id={$pledge->id}&cid={$pledge->contact_id}&context=home");
     }
     if (CRM_Core_Permission::checkActionPermission('CiviPledge', CRM_Core_Action::DELETE)) {
         $recentOther['deleteUrl'] = CRM_Utils_System::url('civicrm/contact/view/pledge', "action=delete&reset=1&id={$pledge->id}&cid={$pledge->contact_id}&context=home");
     }
     $contributionTypes = CRM_Contribute_PseudoConstant::financialType();
     $title = CRM_Contact_BAO_Contact::displayName($pledge->contact_id) . ' - (' . ts('Pledged') . ' ' . CRM_Utils_Money::format($pledge->amount, $pledge->currency) . ' - ' . CRM_Utils_Array::value($pledge->financial_type_id, $contributionTypes) . ')';
     // add the recently created Pledge
     CRM_Utils_Recent::add($title, $url, $pledge->id, 'Pledge', $pledge->contact_id, NULL, $recentOther);
     return $pledge;
 }
开发者ID:hguru,项目名称:224Civi,代码行数:78,代码来源:Pledge.php


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