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


PHP CRM_Contribute_BAO_Contribution::transitionComponents方法代码示例

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


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

示例1: postProcess


//.........这里部分代码省略.........
         $this->assign('trxn_id', CRM_Utils_Array::value('trxn_id', $result));
         $this->assign('receive_date', CRM_Utils_Date::mysqlToIso($params['receive_date']));
         // required for creating membership for related contacts
         $params['action'] = $this->_action;
         //create membership record.
         $count = 0;
         foreach ($this->_memTypeSelected as $memType) {
             if ($count && ($relateContribution = CRM_Member_BAO_Membership::getMembershipContributionId($membership->id))) {
                 $membershipTypeValues[$memType]['relate_contribution_id'] = $relateContribution;
             }
             $membershipParams = array_merge($membershipTypeValues[$memType], $params);
             //CRM-15366
             if (!empty($softParams) && empty($paymentParams['is_recur'])) {
                 $membershipParams['soft_credit'] = $softParams;
             }
             if (!empty($paymentParams['is_recur']) && CRM_Utils_Array::value('payment_status_id', $result) == 1) {
                 // CRM-16993 we have a situation where line items have already been created.
                 unset($membershipParams['lineItems']);
             }
             $membership = CRM_Member_BAO_Membership::create($membershipParams, $ids);
             $params['contribution'] = CRM_Utils_Array::value('contribution', $membershipParams);
             unset($params['lineItems']);
             $this->_membershipIDs[] = $membership->id;
             $createdMemberships[$memType] = $membership;
             $count++;
         }
     } else {
         $params['action'] = $this->_action;
         if ($this->_onlinePendingContributionId && !empty($formValues['record_contribution'])) {
             // update membership as well as contribution object, CRM-4395
             $params['contribution_id'] = $this->_onlinePendingContributionId;
             $params['componentId'] = $params['id'];
             $params['componentName'] = 'contribute';
             $result = CRM_Contribute_BAO_Contribution::transitionComponents($params, TRUE);
             if (!empty($result) && !empty($params['contribution_id'])) {
                 $lineItem = array();
                 $lineItems = CRM_Price_BAO_LineItem::getLineItems($params['contribution_id'], 'contribution', NULL, TRUE, TRUE);
                 $itemId = key($lineItems);
                 $priceSetId = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceField', $lineItems[$itemId]['price_field_id'], 'price_set_id');
                 $fieldType = NULL;
                 if ($itemId && !empty($lineItems[$itemId]['price_field_id'])) {
                     $fieldType = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceField', $lineItems[$itemId]['price_field_id'], 'html_type');
                 }
                 $lineItems[$itemId]['unit_price'] = $params['total_amount'];
                 $lineItems[$itemId]['line_total'] = $params['total_amount'];
                 $lineItems[$itemId]['id'] = $itemId;
                 $lineItem[$priceSetId] = $lineItems;
                 $contributionBAO = new CRM_Contribute_BAO_Contribution();
                 $contributionBAO->id = $params['contribution_id'];
                 $contributionBAO->contact_id = $params['contact_id'];
                 $contributionBAO->find();
                 CRM_Price_BAO_LineItem::processPriceSet($params['contribution_id'], $lineItem, $contributionBAO, 'civicrm_membership');
                 //create new soft-credit record, CRM-13981
                 if ($softParams) {
                     $softParams['contribution_id'] = $params['contribution_id'];
                     while ($contributionBAO->fetch()) {
                         $softParams['currency'] = $contributionBAO->currency;
                         $softParams['amount'] = $contributionBAO->total_amount;
                     }
                     CRM_Contribute_BAO_ContributionSoft::add($softParams);
                 }
             }
             //carry updated membership object.
             $membership = new CRM_Member_DAO_Membership();
             $membership->id = $this->_id;
             $membership->find(TRUE);
开发者ID:indydas,项目名称:civi-demo,代码行数:67,代码来源:Membership.php

示例2: updateRelatedComponent

 /**
  * This function process contribution related objects.
  *
  * @param int $contributionId
  * @param int $statusId
  * @param int|null $previousStatusId
  *
  * @return null|string
  */
 protected function updateRelatedComponent($contributionId, $statusId, $previousStatusId = NULL, $receiveDate = NULL)
 {
     $statusMsg = NULL;
     if (!$contributionId || !$statusId) {
         return $statusMsg;
     }
     $params = array('contribution_id' => $contributionId, 'contribution_status_id' => $statusId, 'previous_contribution_status_id' => $previousStatusId, 'receive_date' => $receiveDate);
     $updateResult = CRM_Contribute_BAO_Contribution::transitionComponents($params);
     if (!is_array($updateResult) || !($updatedComponents = CRM_Utils_Array::value('updatedComponents', $updateResult)) || !is_array($updatedComponents) || empty($updatedComponents)) {
         return $statusMsg;
     }
     // get the user display name.
     $sql = "\n   SELECT  display_name as displayName\n     FROM  civicrm_contact\nLEFT JOIN  civicrm_contribution on (civicrm_contribution.contact_id = civicrm_contact.id )\n    WHERE  civicrm_contribution.id = {$contributionId}";
     $userDisplayName = CRM_Core_DAO::singleValueQuery($sql);
     // get the status message for user.
     foreach ($updatedComponents as $componentName => $updatedStatusId) {
         if ($componentName == 'CiviMember') {
             $updatedStatusName = CRM_Utils_Array::value($updatedStatusId, CRM_Member_PseudoConstant::membershipStatus());
             if ($updatedStatusName == 'Cancelled') {
                 $statusMsg .= "<br />" . ts("Membership for %1 has been Cancelled.", array(1 => $userDisplayName));
             } elseif ($updatedStatusName == 'Expired') {
                 $statusMsg .= "<br />" . ts("Membership for %1 has been Expired.", array(1 => $userDisplayName));
             } else {
                 $endDate = CRM_Utils_Array::value('membership_end_date', $updateResult);
                 if ($endDate) {
                     $statusMsg .= "<br />" . ts("Membership for %1 has been updated. The membership End Date is %2.", array(1 => $userDisplayName, 2 => $endDate));
                 }
             }
         }
         if ($componentName == 'CiviEvent') {
             $updatedStatusName = CRM_Utils_Array::value($updatedStatusId, CRM_Event_PseudoConstant::participantStatus());
             if ($updatedStatusName == 'Cancelled') {
                 $statusMsg .= "<br />" . ts("Event Registration for %1 has been Cancelled.", array(1 => $userDisplayName));
             } elseif ($updatedStatusName == 'Registered') {
                 $statusMsg .= "<br />" . ts("Event Registration for %1 has been updated.", array(1 => $userDisplayName));
             }
         }
         if ($componentName == 'CiviPledge') {
             $updatedStatusName = CRM_Utils_Array::value($updatedStatusId, CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name'));
             if ($updatedStatusName == 'Cancelled') {
                 $statusMsg .= "<br />" . ts("Pledge Payment for %1 has been Cancelled.", array(1 => $userDisplayName));
             } elseif ($updatedStatusName == 'Failed') {
                 $statusMsg .= "<br />" . ts("Pledge Payment for %1 has been Failed.", array(1 => $userDisplayName));
             } elseif ($updatedStatusName == 'Completed') {
                 $statusMsg .= "<br />" . ts("Pledge Payment for %1 has been updated.", array(1 => $userDisplayName));
             }
         }
     }
     return $statusMsg;
 }
开发者ID:riyadennis,项目名称:my_civicrm,代码行数:59,代码来源:AbstractEditPayment.php

示例3: submit


//.........这里部分代码省略.........
                 $membershipTypeValues[$memType]['relate_contribution_id'] = $relateContribution;
             }
             $membershipParams = array_merge($membershipTypeValues[$memType], $params);
             //CRM-15366
             if (!empty($softParams) && empty($paymentParams['is_recur'])) {
                 $membershipParams['soft_credit'] = $softParams;
             }
             // This is required to trigger the recording of the membership contribution in the
             // CRM_Member_BAO_Membership::Create function.
             // @todo stop setting this & 'teach' the create function to respond to something
             // appropriate as part of our 2-step always create the pending contribution & then finally add the payment
             // process -
             // @see http://wiki.civicrm.org/confluence/pages/viewpage.action?pageId=261062657#Payments&AccountsRoadmap-Movetowardsalwaysusinga2-steppaymentprocess
             $membershipParams['contribution_status_id'] = CRM_Utils_Array::value('payment_status_id', $result);
             if (!empty($paymentParams['is_recur'])) {
                 // The earlier process created the line items (although we want to get rid of the earlier one in favour
                 // of a single path!
                 unset($membershipParams['lineItems']);
             }
             $membership = CRM_Member_BAO_Membership::create($membershipParams, $ids);
             $params['contribution'] = CRM_Utils_Array::value('contribution', $membershipParams);
             unset($params['lineItems']);
             $this->_membershipIDs[] = $membership->id;
             $createdMemberships[$memType] = $membership;
             $count++;
         }
     } else {
         $params['action'] = $this->_action;
         if ($this->_onlinePendingContributionId && !empty($formValues['record_contribution'])) {
             // update membership as well as contribution object, CRM-4395
             $params['contribution_id'] = $this->_onlinePendingContributionId;
             $params['componentId'] = $params['id'];
             $params['componentName'] = 'contribute';
             $result = CRM_Contribute_BAO_Contribution::transitionComponents($params, TRUE);
             if (!empty($result) && !empty($params['contribution_id'])) {
                 $lineItem = array();
                 $lineItems = CRM_Price_BAO_LineItem::getLineItems($params['contribution_id'], 'contribution', NULL, TRUE, TRUE);
                 $itemId = key($lineItems);
                 $priceSetId = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceField', $lineItems[$itemId]['price_field_id'], 'price_set_id');
                 $lineItems[$itemId]['unit_price'] = $params['total_amount'];
                 $lineItems[$itemId]['line_total'] = $params['total_amount'];
                 $lineItems[$itemId]['id'] = $itemId;
                 $lineItem[$priceSetId] = $lineItems;
                 $contributionBAO = new CRM_Contribute_BAO_Contribution();
                 $contributionBAO->id = $params['contribution_id'];
                 $contributionBAO->contact_id = $params['contact_id'];
                 $contributionBAO->find();
                 CRM_Price_BAO_LineItem::processPriceSet($params['contribution_id'], $lineItem, $contributionBAO, 'civicrm_membership');
                 //create new soft-credit record, CRM-13981
                 if ($softParams) {
                     $softParams['contribution_id'] = $params['contribution_id'];
                     while ($contributionBAO->fetch()) {
                         $softParams['currency'] = $contributionBAO->currency;
                         $softParams['amount'] = $contributionBAO->total_amount;
                     }
                     CRM_Contribute_BAO_ContributionSoft::add($softParams);
                 }
             }
             //carry updated membership object.
             $membership = new CRM_Member_DAO_Membership();
             $membership->id = $this->_id;
             $membership->find(TRUE);
             $cancelled = TRUE;
             if ($membership->end_date) {
                 //display end date w/ status message.
                 $endDate = $membership->end_date;
开发者ID:utkarshsharma,项目名称:civicrm-core,代码行数:67,代码来源:Membership.php

示例4: civicrm_api3_order_cancel

/**
 * Cancel an Order.
 *
 * @param array $params
 *   Input parameters.
 *
 * @return array
 */
function civicrm_api3_order_cancel($params)
{
    $contributionStatuses = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
    $params['contribution_status_id'] = array_search('Cancelled', $contributionStatuses);
    $result = civicrm_api3('Contribution', 'create', $params);
    CRM_Contribute_BAO_Contribution::transitionComponents($params);
    return civicrm_api3_create_success($result['values'], $params, 'Order', 'cancel');
}
开发者ID:nielosz,项目名称:civicrm-core,代码行数:16,代码来源:Order.php

示例5: postProcess


//.........这里部分代码省略.........
         $params['invoice_id'] = $this->_params['invoiceID'];
         $params['contribution_source'] = ts('Online Membership: Admin Interface');
         $params['source'] = $formValues['source'] ? $formValues['source'] : $params['contribution_source'];
         $params['trxn_id'] = $result['trxn_id'];
         $params['payment_instrument_id'] = 1;
         $params['is_test'] = $this->_mode == 'live' ? 0 : 1;
         if (CRM_Utils_Array::value('send_receipt', $this->_params)) {
             $params['receipt_date'] = $now;
         } else {
             $params['receipt_date'] = null;
         }
         $this->set('params', $this->_params);
         $this->assign('trxn_id', $result['trxn_id']);
         $this->assign('receive_date', CRM_Utils_Date::mysqlToIso($params['receive_date']));
         // required for creating membership for related contacts
         $params['action'] = $this->_action;
         $membership =& CRM_Member_BAO_Membership::create($params, $ids);
         $contribution = new CRM_Contribute_BAO_Contribution();
         $contribution->trxn_id = $result['trxn_id'];
         if ($contribution->find(true)) {
             // next create the transaction record
             $trxnParams = array('contribution_id' => $contribution->id, 'trxn_date' => $now, 'trxn_type' => 'Debit', 'total_amount' => $params['total_amount'], 'fee_amount' => CRM_Utils_Array::value('fee_amount', $result), 'net_amount' => CRM_Utils_Array::value('net_amount', $result, $params['total_amount']), 'currency' => $config->defaultCurrency, 'payment_processor' => $this->_paymentProcessor['payment_processor_type'], 'trxn_id' => $result['trxn_id']);
             require_once 'CRM/Contribute/BAO/FinancialTrxn.php';
             $trxn =& CRM_Contribute_BAO_FinancialTrxn::create($trxnParams);
         }
     } else {
         $params['action'] = $this->_action;
         if ($this->_onlinePendingContributionId && CRM_Utils_Array::value('record_contribution', $formValues)) {
             // update membership as well as contribution object, CRM-4395
             require_once 'CRM/Contribute/Form/Contribution.php';
             $params['contribution_id'] = $this->_onlinePendingContributionId;
             $params['componentId'] = $params['id'];
             $params['componentName'] = 'contribute';
             $result = CRM_Contribute_BAO_Contribution::transitionComponents($params, true);
             //carry updated membership object.
             $membership =& new CRM_Member_DAO_Membership();
             $membership->id = $this->_id;
             $membership->find(true);
             $cancelled = true;
             if ($membership->end_date) {
                 //display end date w/ status message.
                 $endDate = $membership->end_date;
                 require_once 'CRM/Member/PseudoConstant.php';
                 $membershipStatues = CRM_Member_PseudoConstant::membershipStatus();
                 if (!in_array($membership->status_id, array(array_search('Cancelled', $membershipStatues), array_search('Expired', $membershipStatues)))) {
                     $cancelled = false;
                 }
             }
             // suppress form values in template.
             $this->assign('cancelled', $cancelled);
         } else {
             $membership =& CRM_Member_BAO_Membership::create($params, $ids);
         }
     }
     if (CRM_Utils_Array::value('send_receipt', $formValues)) {
         require_once 'CRM/Core/DAO.php';
         CRM_Core_DAO::setFieldValue('CRM_Member_DAO_MembershipType', $params['membership_type_id'], 'receipt_text_signup', $formValues['receipt_text_signup']);
     }
     $receiptSend = false;
     if (CRM_Utils_Array::value('send_receipt', $formValues)) {
         $receiptSend = true;
         $receiptFrom = "{$userName} <{$userEmail}>";
         if (CRM_Utils_Array::value('payment_instrument_id', $formValues)) {
             $paymentInstrument = CRM_Contribute_PseudoConstant::paymentInstrument();
             $formValues['paidBy'] = $paymentInstrument[$formValues['payment_instrument_id']];
         }
开发者ID:ksecor,项目名称:civicrm,代码行数:67,代码来源:Membership.php


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