當前位置: 首頁>>代碼示例>>PHP>>正文


PHP CRM_Contribute_BAO_Contribution::addPayments方法代碼示例

本文整理匯總了PHP中CRM_Contribute_BAO_Contribution::addPayments方法的典型用法代碼示例。如果您正苦於以下問題:PHP CRM_Contribute_BAO_Contribution::addPayments方法的具體用法?PHP CRM_Contribute_BAO_Contribution::addPayments怎麽用?PHP CRM_Contribute_BAO_Contribution::addPayments使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在CRM_Contribute_BAO_Contribution的用法示例。


在下文中一共展示了CRM_Contribute_BAO_Contribution::addPayments方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: postProcess


//.........這裏部分代碼省略.........
                 foreach ($this->_contactIds as $num => $contactID) {
                     $ppDAO = new CRM_Event_DAO_ParticipantPayment();
                     $ppDAO->participant_id = $participants[$num]->id;
                     $ppDAO->contribution_id = $contributions[$num]->id;
                     $ppDAO->save();
                 }
             }
             // next create the transaction record
             $transaction = new CRM_Core_Transaction();
             // CRM-11124
             if ($this->_params['discount_id']) {
                 CRM_Event_BAO_Participant::createDiscountTrxn($this->_eventId, $contributionParams, NULL, CRM_Price_BAO_PriceSet::parseFirstPriceSetValueIDFromParams($this->_params));
             }
             $transaction->commit();
         }
     }
     // also store lineitem stuff here
     if ($this->_lineItem & $this->_action & CRM_Core_Action::ADD || $this->_lineItem && CRM_Core_Action::UPDATE && !$this->_paymentId) {
         foreach ($this->_contactIds as $num => $contactID) {
             foreach ($this->_lineItem as $key => $value) {
                 if (is_array($value) && $value != 'skip') {
                     foreach ($value as $lineKey => $line) {
                         //10117 update the line items for participants if contribution amount is recorded
                         if ($this->_quickConfig && !empty($params['total_amount']) && $params['status_id'] != array_search('Partially paid', $participantStatus)) {
                             $line['unit_price'] = $line['line_total'] = $params['total_amount'];
                             if (!empty($params['tax_amount'])) {
                                 $line['unit_price'] = $line['unit_price'] - $params['tax_amount'];
                                 $line['line_total'] = $line['line_total'] - $params['tax_amount'];
                             }
                         }
                         $lineItem[$this->_priceSetId][$lineKey] = $line;
                     }
                     CRM_Price_BAO_LineItem::processPriceSet($participants[$num]->id, $lineItem, CRM_Utils_Array::value($num, $contributions, NULL), 'civicrm_participant');
                     CRM_Contribute_BAO_Contribution::addPayments($value, $contributions);
                 }
             }
         }
     }
     $updateStatusMsg = NULL;
     //send mail when participant status changed, CRM-4326
     if ($this->_id && $this->_statusId && $this->_statusId != CRM_Utils_Array::value('status_id', $params) && !empty($params['is_notify'])) {
         $updateStatusMsg = CRM_Event_BAO_Participant::updateStatusMessage($this->_id, $params['status_id'], $this->_statusId);
     }
     $sent = array();
     $notSent = array();
     if (!empty($params['send_receipt'])) {
         if (array_key_exists($params['from_email_address'], $this->_fromEmails['from_email_id'])) {
             $receiptFrom = $params['from_email_address'];
         }
         $this->assign('module', 'Event Registration');
         //use of the message template below requires variables in different format
         $event = $events = array();
         $returnProperties = array('fee_label', 'start_date', 'end_date', 'is_show_location', 'title');
         //get all event details.
         CRM_Core_DAO::commonRetrieveAll('CRM_Event_DAO_Event', 'id', $params['event_id'], $events, $returnProperties);
         $event = $events[$params['event_id']];
         unset($event['start_date']);
         unset($event['end_date']);
         $role = CRM_Event_PseudoConstant::participantRole();
         $participantRoles = CRM_Utils_Array::value('role_id', $params);
         if (is_array($participantRoles)) {
             $selectedRoles = array();
             foreach ($participantRoles as $roleId) {
                 $selectedRoles[] = $role[$roleId];
             }
             $event['participant_role'] = implode(', ', $selectedRoles);
開發者ID:kcristiano,項目名稱:civicrm-core,代碼行數:67,代碼來源:Participant.php

示例2: postProcess

 public function postProcess()
 {
     $participantId = NULL;
     if ($this->_component == 'event') {
         $participantId = $this->_id;
     }
     $submittedValues = $this->controller->exportValues($this->_name);
     $submittedValues['confirm_email_text'] = CRM_Utils_Array::value('receipt_text', $submittedValues);
     $submittedValues['trxn_date'] = CRM_Utils_Date::processDate($submittedValues['trxn_date'], $submittedValues['trxn_date_time']);
     if ($this->_mode) {
         // process credit card
         $this->assign('contributeMode', 'direct');
         $this->processCreditCard($submittedValues);
     } else {
         $defaults = array();
         $contribution = civicrm_api3('Contribution', 'getsingle', array('return' => array("contribution_status_id"), 'id' => $this->_contributionId));
         $contributionStatusId = CRM_Utils_Array::value('contribution_status_id', $contribution);
         $result = CRM_Contribute_BAO_Contribution::recordAdditionalPayment($this->_contributionId, $submittedValues, $this->_paymentType, $participantId);
         // Fetch the contribution & do proportional line item assignment
         $params = array('id' => $this->_contributionId);
         $contribution = CRM_Contribute_BAO_Contribution::retrieve($params, $defaults, $params);
         $lineItems = CRM_Price_BAO_LineItem::getLineItemsByContributionID($this->_contributionId);
         if (!empty($lineItems)) {
             CRM_Contribute_BAO_Contribution::addPayments($lineItems, array($contribution), $contributionStatusId);
         }
         // email sending
         if (!empty($result) && !empty($submittedValues['is_email_receipt'])) {
             $submittedValues['contact_id'] = $this->_contactId;
             $submittedValues['contribution_id'] = $this->_contributionId;
             // to get 'from email id' for send receipt
             $this->fromEmailId = $submittedValues['from_email_address'];
             $sendReceipt = $this->emailReceipt($submittedValues);
         }
         $statusMsg = ts('The payment record has been processed.');
         if (!empty($submittedValues['is_email_receipt']) && $sendReceipt) {
             $statusMsg .= ' ' . ts('A receipt has been emailed to the contributor.');
         }
         CRM_Core_Session::setStatus($statusMsg, ts('Saved'), 'success');
         $session = CRM_Core_Session::singleton();
         $session->replaceUserContext(CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$this->_contactId}&selectedChild=participant"));
     }
 }
開發者ID:nielosz,項目名稱:civicrm-core,代碼行數:42,代碼來源:AdditionalPayment.php

示例3: testAddPayments

 /**
  * addPayments() method (add and edit modes of participant)
  */
 public function testAddPayments()
 {
     list($lineItems, $contribution) = $this->addParticipantWithContribution();
     foreach ($lineItems as $value) {
         CRM_Contribute_BAO_Contribution::addPayments($value, array($contribution));
     }
     $this->checkItemValues($contribution);
 }
開發者ID:konadave,項目名稱:civicrm-core,代碼行數:11,代碼來源:ContributionTest.php

示例4: testAddPayments

 /**
  * Add() method (add and edit modes of participant)
  */
 public function testAddPayments()
 {
     list($lineItems, $contribution) = $this->addParticipantWithContribution();
     foreach ($lineItems as $value) {
         CRM_Contribute_BAO_Contribution::addPayments($value, array($contribution));
     }
     $relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Accounts Receivable Account is' "));
     $toFinancialAccount = CRM_Contribute_PseudoConstant::financialAccountType(4, $relationTypeId);
     $query = "SELECT eft1.entity_id, ft.total_amount, eft1.amount FROM civicrm_financial_trxn ft INNER JOIN civicrm_entity_financial_trxn eft ON (eft.financial_trxn_id = ft.id AND eft.entity_table = 'civicrm_contribution') \nINNER JOIN civicrm_entity_financial_trxn eft1 ON (eft1.financial_trxn_id = eft.financial_trxn_id AND eft1.entity_table = 'civicrm_financial_item')\nWHERE eft.entity_id = %1 AND ft.to_financial_account_id <> %2";
     $queryParams[1] = array($contribution->id, 'Integer');
     $queryParams[2] = array($toFinancialAccount, 'Integer');
     $dao = CRM_Core_DAO::executeQuery($query, $queryParams);
     $amounts = array(1 => 50.0, 2 => 100.0);
     while ($dao->fetch()) {
         $this->assertEquals(150.0, $dao->total_amount, 'Mismatch of total amount paid.');
         $this->assertEquals($dao->amount, $amounts[$dao->entity_id], 'Mismatch of amount proportionally assigned to financial item');
     }
     Contact::delete($this->_contactId);
     Event::delete($this->_eventId);
 }
開發者ID:Prem-Patel,項目名稱:civicrm-core,代碼行數:23,代碼來源:ContributionTest.php


注:本文中的CRM_Contribute_BAO_Contribution::addPayments方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。