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


PHP CRM_Event_BAO_Participant::getParticipantIds方法代码示例

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


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

示例1: preProcess

 public function preProcess()
 {
     $this->_participantId = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE);
     $this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE);
     $this->_eventId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', $this->_participantId, 'event_id');
     $this->_fromEmails = CRM_Event_BAO_Event::getFromEmailIds($this->_eventId);
     $this->_contributionId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $this->_participantId, 'contribution_id', 'participant_id');
     if (!$this->_contributionId) {
         if ($primaryParticipantId = CRM_Core_DAO::getFieldValue('CRM_Event_BAO_Participant', $this->_participantId, 'registered_by_id')) {
             $this->_contributionId = CRM_Core_DAO::getFieldValue('CRM_Event_BAO_ParticipantPayment', $primaryParticipantId, 'contribution_id', 'participant_id');
         }
     }
     if ($this->_contributionId) {
         $this->_isPaidEvent = TRUE;
     }
     $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, TRUE);
     list($this->_contributorDisplayName, $this->_contributorEmail) = CRM_Contact_BAO_Contact_Location::getEmailDetails($this->_contactId);
     $this->assign('displayName', $this->_contributorDisplayName);
     $this->assign('email', $this->_contributorEmail);
     $this->_participantStatus = CRM_Core_DAO::getFieldValue('CRM_Event_BAO_Participant', $this->_participantId, 'status_id');
     //set the payment mode - _mode property is defined in parent class
     $this->_mode = CRM_Utils_Request::retrieve('mode', 'String', $this);
     $this->assign('contactId', $this->_contactId);
     $this->assign('id', $this->_participantId);
     $paymentInfo = CRM_Contribute_BAO_Contribution::getPaymentInfo($this->_participantId, 'event');
     $this->_paidAmount = $paymentInfo['paid'];
     $this->assign('paymentInfo', $paymentInfo);
     $this->assign('feePaid', $this->_paidAmount);
     $ids = CRM_Event_BAO_Participant::getParticipantIds($this->_contributionId);
     if (count($ids) > 1) {
         $total = 0;
         foreach ($ids as $val) {
             $total += CRM_Price_BAO_LineItem::getLineTotal($val, 'civicrm_participant');
         }
         $this->assign('totalLineTotal', $total);
         $lineItemTotal = CRM_Price_BAO_LineItem::getLineTotal($this->_participantId, 'civicrm_participant');
         $this->assign('lineItemTotal', $lineItemTotal);
     }
     $title = "Change selections for {$this->_contributorDisplayName}";
     if ($title) {
         CRM_Utils_System::setTitle(ts('%1', array(1 => $title)));
     }
 }
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:43,代码来源:ParticipantFeeSelection.php

示例2: changeFeeSelections


//.........这里部分代码省略.........
     } elseif (empty($submittedFields) && empty($submittedFieldValues)) {
         $updateLineItem = "UPDATE civicrm_line_item li\n        INNER JOIN civicrm_financial_item fi\n        ON (li.id = fi.entity_id AND fi.entity_table = 'civicrm_line_item')\n        SET li.qty = 0,\n        li.line_total = 0.00,\n        li.tax_amount = NULL\n        WHERE (li.entity_table = 'civicrm_participant' AND li.entity_id = {$participantId})";
         CRM_Core_DAO::executeQuery($updateLineItem);
     }
     $amountLevel = array();
     $totalParticipant = $participantCount = 0;
     if (!empty($updateLines)) {
         foreach ($updateLines as $valueId => $vals) {
             $taxAmount = "NULL";
             if (isset($vals['tax_amount'])) {
                 $taxAmount = $vals['tax_amount'];
             }
             $amountLevel[] = $vals['label'] . ' - ' . (double) $vals['qty'];
             if (isset($vals['participant_count'])) {
                 $participantCount = $vals['participant_count'];
                 $totalParticipant += $vals['participant_count'];
             }
             $updateLineItem = "\nUPDATE civicrm_line_item li\nSET li.qty = {$vals['qty']},\n    li.line_total = {$vals['line_total']},\n    li.tax_amount = {$taxAmount},\n    li.unit_price = {$vals['unit_price']},\n    li.participant_count = {$participantCount},\n    li.label = %1\nWHERE (li.entity_table = 'civicrm_participant' AND li.entity_id = {$participantId}) AND\n      (price_field_value_id = {$valueId})\n";
             CRM_Core_DAO::executeQuery($updateLineItem, array(1 => array($vals['label'], 'String')));
         }
     }
     // insert new 'adjusted amount' transaction entry and update contribution entry.
     // ensure entity_financial_trxn table has a linking of it.
     // insert new line items
     if (!empty($insertLines)) {
         foreach ($insertLines as $valueId => $lineParams) {
             $lineParams['entity_table'] = 'civicrm_participant';
             $lineParams['entity_id'] = $participantId;
             $lineParams['contribution_id'] = $contributionId;
             $lineObj = CRM_Price_BAO_LineItem::create($lineParams);
         }
     }
     // the recordAdjustedAmt code would execute over here
     $ids = CRM_Event_BAO_Participant::getParticipantIds($contributionId);
     if (count($ids) > 1) {
         $total = 0;
         foreach ($ids as $val) {
             $total += CRM_Price_BAO_LineItem::getLineTotal($val, 'civicrm_participant');
         }
         $updatedAmount = $total;
     } else {
         $updatedAmount = $params['amount'];
     }
     if (strlen($params['tax_amount']) != 0) {
         $taxAmount = $params['tax_amount'];
     } else {
         $taxAmount = "NULL";
     }
     $displayParticipantCount = '';
     if ($totalParticipant > 0) {
         $displayParticipantCount = ' Participant Count -' . $totalParticipant;
     }
     $updateAmountLevel = NULL;
     if (!empty($amountLevel)) {
         $updateAmountLevel = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR, $amountLevel) . $displayParticipantCount . CRM_Core_DAO::VALUE_SEPARATOR;
     }
     $trxn = self::recordAdjustedAmt($updatedAmount, $paidAmount, $contributionId, $taxAmount, $updateAmountLevel);
     $trxnId = array();
     if ($trxn) {
         $trxnId['id'] = $trxn->id;
         foreach ($financialItemsArray as $updateFinancialItemInfoValues) {
             CRM_Financial_BAO_FinancialItem::create($updateFinancialItemInfoValues, NULL, $trxnId);
             if (!empty($updateFinancialItemInfoValues['tax'])) {
                 $updateFinancialItemInfoValues['tax']['amount'] = $updateFinancialItemInfoValues['amount'];
                 $updateFinancialItemInfoValues['tax']['description'] = $updateFinancialItemInfoValues['description'];
                 if (!empty($updateFinancialItemInfoValues['financial_account_id'])) {
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:67,代码来源:Participant.php

示例3: getPaymentInfo

 /**
  * Get list of payments displayed by Contribute_Page_PaymentInfo.
  *
  * @param int $id
  * @param $component
  * @param bool $getTrxnInfo
  * @param bool $usingLineTotal
  *
  * @return mixed
  */
 public static function getPaymentInfo($id, $component, $getTrxnInfo = FALSE, $usingLineTotal = FALSE)
 {
     if ($component == 'event') {
         $entity = 'participant';
         $entityTable = 'civicrm_participant';
         $contributionId = CRM_Core_DAO::getFieldValue('CRM_Event_BAO_ParticipantPayment', $id, 'contribution_id', 'participant_id');
         if (!$contributionId) {
             if ($primaryParticipantId = CRM_Core_DAO::getFieldValue('CRM_Event_BAO_Participant', $id, 'registered_by_id')) {
                 $contributionId = CRM_Core_DAO::getFieldValue('CRM_Event_BAO_ParticipantPayment', $primaryParticipantId, 'contribution_id', 'participant_id');
                 $id = $primaryParticipantId;
             }
             if (!$contributionId) {
                 return;
             }
         }
     }
     $total = CRM_Core_BAO_FinancialTrxn::getBalanceTrxnAmt($contributionId);
     $baseTrxnId = !empty($total['trxn_id']) ? $total['trxn_id'] : NULL;
     $isBalance = NULL;
     if ($baseTrxnId) {
         $isBalance = TRUE;
     } else {
         $baseTrxnId = CRM_Core_BAO_FinancialTrxn::getFinancialTrxnId($contributionId);
         $baseTrxnId = $baseTrxnId['financialTrxnId'];
         $isBalance = FALSE;
     }
     if (!CRM_Utils_Array::value('total_amount', $total) || $usingLineTotal) {
         // for additional participants
         if ($entityTable == 'civicrm_participant') {
             $ids = CRM_Event_BAO_Participant::getParticipantIds($contributionId);
             $total = 0;
             foreach ($ids as $val) {
                 $total += CRM_Price_BAO_LineItem::getLineTotal($val, $entityTable);
             }
         } else {
             $total = CRM_Price_BAO_LineItem::getLineTotal($id, $entityTable);
         }
     } else {
         $baseTrxnId = $total['trxn_id'];
         $total = $total['total_amount'];
     }
     $paymentBalance = CRM_Core_BAO_FinancialTrxn::getPartialPaymentWithType($id, $entity, FALSE, $total);
     $contributionIsPayLater = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Contribution', $contributionId, 'is_pay_later');
     $feeRelationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Expense Account is' "));
     $financialTypeId = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Contribution', $contributionId, 'financial_type_id');
     $feeFinancialAccount = CRM_Contribute_PseudoConstant::financialAccountType($financialTypeId, $feeRelationTypeId);
     if ($paymentBalance == 0 && $contributionIsPayLater) {
         $paymentBalance = $total;
     }
     $info['total'] = $total;
     $info['paid'] = $total - $paymentBalance;
     $info['balance'] = $paymentBalance;
     $info['id'] = $id;
     $info['component'] = $component;
     $info['payLater'] = $contributionIsPayLater;
     $rows = array();
     if ($getTrxnInfo && $baseTrxnId) {
         // Need to exclude fee trxn rows so filter out rows where TO FINANCIAL ACCOUNT is expense account
         $sql = "\nSELECT ft.total_amount, con.financial_type_id, ft.payment_instrument_id, ft.trxn_date, ft.trxn_id, ft.status_id, ft.check_number\nFROM civicrm_contribution con\n  LEFT JOIN civicrm_entity_financial_trxn eft ON (eft.entity_id = con.id AND eft.entity_table = 'civicrm_contribution')\n  INNER JOIN civicrm_financial_trxn ft ON ft.id = eft.financial_trxn_id AND ft.to_financial_account_id != {$feeFinancialAccount}\nWHERE con.id = {$contributionId}\n";
         // conditioned WHERE clause
         if ($isBalance) {
             // if balance trxn exists don't include details of it in transaction info
             $sql .= " AND ft.id != {$baseTrxnId} ";
         }
         $resultDAO = CRM_Core_DAO::executeQuery($sql);
         $statuses = CRM_Contribute_PseudoConstant::contributionStatus();
         $financialTypes = CRM_Contribute_PseudoConstant::financialType();
         while ($resultDAO->fetch()) {
             $paidByLabel = CRM_Core_PseudoConstant::getLabel('CRM_Core_BAO_FinancialTrxn', 'payment_instrument_id', $resultDAO->payment_instrument_id);
             $paidByName = CRM_Core_PseudoConstant::getName('CRM_Core_BAO_FinancialTrxn', 'payment_instrument_id', $resultDAO->payment_instrument_id);
             $val = array('total_amount' => $resultDAO->total_amount, 'financial_type' => $financialTypes[$resultDAO->financial_type_id], 'payment_instrument' => $paidByLabel, 'receive_date' => $resultDAO->trxn_date, 'trxn_id' => $resultDAO->trxn_id, 'status' => $statuses[$resultDAO->status_id]);
             if ($paidByName == 'Check') {
                 $val['check_number'] = $resultDAO->check_number;
             }
             $rows[] = $val;
         }
         $info['transaction'] = $rows;
     }
     return $info;
 }
开发者ID:nganivet,项目名称:civicrm-core,代码行数:90,代码来源:Contribution.php

示例4: _gatherMessageValues

 function _gatherMessageValues($input, &$values, $ids = array())
 {
     // set display address of contributor
     if ($this->address_id) {
         $addressParams = array('id' => $this->address_id);
         $addressDetails = CRM_Core_BAO_Address::getValues($addressParams, FALSE, 'id');
         $addressDetails = array_values($addressDetails);
         $values['address'] = $addressDetails[0]['display'];
     }
     if ($this->_component == 'contribute') {
         if (isset($this->contribution_page_id)) {
             CRM_Contribute_BAO_ContributionPage::setValues($this->contribution_page_id, $values);
             if ($this->contribution_page_id) {
                 // CRM-8254 - override default currency if applicable
                 $config = CRM_Core_Config::singleton();
                 $config->defaultCurrency = CRM_Utils_Array::value('currency', $values, $config->defaultCurrency);
             }
         } else {
             // Handle re-print receipt for offline contributions (call from PDF.php - no contribution_page_id)
             $values['is_email_receipt'] = 1;
             $values['title'] = 'Contribution';
         }
         // set lineItem for contribution
         if ($this->id) {
             $lineItem = CRM_Price_BAO_LineItem::getLineItems($this->id, 'contribution', 1);
             if (!empty($lineItem)) {
                 $itemId = key($lineItem);
                 foreach ($lineItem as &$eachItem) {
                     if (array_key_exists($eachItem['membership_type_id'], $this->_relatedObjects['membership'])) {
                         $eachItem['join_date'] = CRM_Utils_Date::customFormat($this->_relatedObjects['membership'][$eachItem['membership_type_id']]->join_date);
                         $eachItem['start_date'] = CRM_Utils_Date::customFormat($this->_relatedObjects['membership'][$eachItem['membership_type_id']]->start_date);
                         $eachItem['end_date'] = CRM_Utils_Date::customFormat($this->_relatedObjects['membership'][$eachItem['membership_type_id']]->end_date);
                     }
                 }
                 $values['lineItem'][0] = $lineItem;
                 $values['priceSetID'] = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceField', $lineItem[$itemId]['price_field_id'], 'price_set_id');
             }
         }
         $relatedContact = CRM_Contribute_BAO_Contribution::getOnbehalfIds($this->id, $this->contact_id);
         // if this is onbehalf of contribution then set related contact
         if (CRM_Utils_Array::value('individual_id', $relatedContact)) {
             $values['related_contact'] = $ids['related_contact'] = $relatedContact['individual_id'];
         }
     } else {
         // event
         $eventParams = array('id' => $this->_relatedObjects['event']->id);
         $values['event'] = array();
         CRM_Event_BAO_Event::retrieve($eventParams, $values['event']);
         //get location details
         $locationParams = array('entity_id' => $this->_relatedObjects['event']->id, 'entity_table' => 'civicrm_event');
         $values['location'] = CRM_Core_BAO_Location::getValues($locationParams);
         $ufJoinParams = array('entity_table' => 'civicrm_event', 'entity_id' => $ids['event'], 'module' => 'CiviEvent');
         list($custom_pre_id, $custom_post_ids) = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinParams);
         $values['custom_pre_id'] = $custom_pre_id;
         $values['custom_post_id'] = $custom_post_ids;
         // set lineItem for event contribution
         if ($this->id) {
             $participantIds = CRM_Event_BAO_Participant::getParticipantIds($this->id);
             if (!empty($participantIds)) {
                 foreach ($participantIds as $pIDs) {
                     $lineItem = CRM_Price_BAO_LineItem::getLineItems($pIDs);
                     if (!CRM_Utils_System::isNull($lineItem)) {
                         $values['lineItem'][] = $lineItem;
                     }
                 }
             }
         }
     }
     return $values;
 }
开发者ID:TheCraftyCanvas,项目名称:aegir-platforms,代码行数:70,代码来源:Contribution.php

示例5: getPartialPaymentWithType

 /**
  * get partial payment amount and type of it.
  *
  * @param int $entityId
  * @param string $entityName
  * @param bool $returnType
  * @param int $lineItemTotal
  *
  * @return array|int|NULL|string
  *   [payment type => amount]
  *   payment type: 'amount_owed' or 'refund_due'
  */
 public static function getPartialPaymentWithType($entityId, $entityName = 'participant', $returnType = TRUE, $lineItemTotal = NULL)
 {
     $value = NULL;
     if (empty($entityName)) {
         return $value;
     }
     if ($entityName == 'participant') {
         $contributionId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $entityId, 'contribution_id', 'participant_id');
         $financialTypeId = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Contribution', $contributionId, 'financial_type_id');
         if ($contributionId && $financialTypeId) {
             $statusId = CRM_Core_OptionGroup::getValue('contribution_status', 'Completed', 'name');
             $refundStatusId = CRM_Core_OptionGroup::getValue('contribution_status', 'Refunded', 'name');
             $relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Accounts Receivable Account is' "));
             $toFinancialAccount = CRM_Contribute_PseudoConstant::financialAccountType($financialTypeId, $relationTypeId);
             $feeRelationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Expense Account is' "));
             $feeFinancialAccount = CRM_Contribute_PseudoConstant::financialAccountType($financialTypeId, $feeRelationTypeId);
             if (empty($lineItemTotal)) {
                 $ids = CRM_Event_BAO_Participant::getParticipantIds($contributionId);
                 if (count($ids) > 1) {
                     $total = 0;
                     foreach ($ids as $val) {
                         $total += CRM_Price_BAO_LineItem::getLineTotal($val, 'civicrm_participant');
                     }
                     $lineItemTotal = $total;
                 } else {
                     $lineItemTotal = CRM_Price_BAO_LineItem::getLineTotal($entityId, 'civicrm_participant');
                 }
             }
             $sqlFtTotalAmt = "\nSELECT SUM(ft.total_amount)\nFROM civicrm_financial_trxn ft\n  LEFT JOIN civicrm_entity_financial_trxn eft ON (ft.id = eft.financial_trxn_id AND eft.entity_table = 'civicrm_contribution')\n  LEFT JOIN civicrm_contribution c ON (eft.entity_id = c.id)\n  LEFT JOIN civicrm_participant_payment pp ON (pp.contribution_id = c.id)\nWHERE pp.participant_id = {$entityId} AND ft.to_financial_account_id != {$toFinancialAccount} AND ft.to_financial_account_id != {$feeFinancialAccount}\n  AND ft.status_id IN ({$statusId}, {$refundStatusId})\n";
             $ftTotalAmt = CRM_Core_DAO::singleValueQuery($sqlFtTotalAmt);
             $value = 0;
             if ($ftTotalAmt) {
                 $value = $paymentVal = $lineItemTotal - $ftTotalAmt;
             }
             if ($returnType) {
                 $value = array();
                 if ($paymentVal < 0) {
                     $value['refund_due'] = $paymentVal;
                 } elseif ($paymentVal > 0) {
                     $value['amount_owed'] = $paymentVal;
                 } elseif ($lineItemTotal == $ftTotalAmt) {
                     $value['full_paid'] = $ftTotalAmt;
                 }
             }
         }
     }
     return $value;
 }
开发者ID:vincent1892,项目名称:civicrm-core,代码行数:60,代码来源:FinancialTrxn.php

示例6: changeFeeSelections

 /**
  * @param $params
  * @param $participantId
  * @param $contributionId
  * @param $feeBlock
  * @param $lineItems
  * @param $paidAmount
  * @param $priceSetId
  */
 static function changeFeeSelections($params, $participantId, $contributionId, $feeBlock, $lineItems, $paidAmount, $priceSetId)
 {
     $contributionStatuses = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
     $partiallyPaidStatusId = array_search('Partially paid', $contributionStatuses);
     $pendngRefundStatusId = array_search('Pending refund', $contributionStatuses);
     $previousLineItems = CRM_Price_BAO_LineItem::getLineItems($participantId, 'participant');
     CRM_Price_BAO_PriceSet::processAmount($feeBlock, $params, $lineItems);
     // get the submitted
     foreach ($feeBlock as $id => $values) {
         CRM_Price_BAO_LineItem::format($id, $params, $values, $submittedLineItems);
         $submittedFieldId[] = CRM_Utils_Array::retrieveValueRecursive($submittedLineItems, 'price_field_id');
     }
     $insertLines = $submittedLineItems;
     $submittedFieldValueIds = array_keys($submittedLineItems);
     $updateLines = array();
     foreach ($previousLineItems as $id => $previousLineItem) {
         // check through the submitted items if the previousItem exists,
         // if found in submitted items, do not use it for new item creations
         if (in_array($previousLineItem['price_field_value_id'], $submittedFieldValueIds)) {
             // if submitted line items are existing don't fire INSERT query
             unset($insertLines[$previousLineItem['price_field_value_id']]);
             // for updating the line items i.e. use-case - once deselect-option selecting again
             if ($previousLineItem['line_total'] != $submittedLineItems[$previousLineItem['price_field_value_id']]['line_total']) {
                 $updateLines[$previousLineItem['price_field_value_id']]['qty'] = $submittedLineItems[$previousLineItem['price_field_value_id']]['qty'];
                 $updateLines[$previousLineItem['price_field_value_id']]['line_total'] = $submittedLineItems[$previousLineItem['price_field_value_id']]['line_total'];
             }
         }
     }
     $submittedFields = implode(', ', $submittedFieldId);
     $submittedFieldValues = implode(', ', $submittedFieldValueIds);
     if (!empty($submittedFields) && !empty($submittedFieldValues)) {
         $updateLineItem = "UPDATE civicrm_line_item li\nINNER JOIN civicrm_financial_item fi\n   ON (li.id = fi.entity_id AND fi.entity_table = 'civicrm_line_item')\nSET li.qty = 0,\n    li.line_total = 0.00\nWHERE (li.entity_table = 'civicrm_participant' AND li.entity_id = {$participantId}) AND\n       (price_field_value_id NOT IN ({$submittedFieldValues}))\n";
         CRM_Core_DAO::executeQuery($updateLineItem);
         // gathering necessary info to record negative (deselected) financial_item
         $updateFinancialItem = "\n  SELECT fi.*, SUM(fi.amount) as differenceAmt, price_field_value_id\n    FROM civicrm_financial_item fi LEFT JOIN civicrm_line_item li ON (li.id = fi.entity_id AND fi.entity_table = 'civicrm_line_item')\nWHERE (li.entity_table = 'civicrm_participant' AND li.entity_id = {$participantId})\nGROUP BY li.entity_table, li.entity_id, price_field_value_id\n";
         $updateFinancialItemInfoDAO = CRM_Core_DAO::executeQuery($updateFinancialItem);
         $trxn = CRM_Core_BAO_FinancialTrxn::getFinancialTrxnId($contributionId, 'ASC', TRUE);
         $trxnId['id'] = $trxn['financialTrxnId'];
         $updateFinancialItemInfoValues = array();
         while ($updateFinancialItemInfoDAO->fetch()) {
             $updateFinancialItemInfoValues = (array) $updateFinancialItemInfoDAO;
             $updateFinancialItemInfoValues['transaction_date'] = date('YmdHis');
             // the below params are not needed
             unset($updateFinancialItemInfoValues['id']);
             unset($updateFinancialItemInfoValues['created_date']);
             // if not submitted and difference is not 0 make it negative
             if (!in_array($updateFinancialItemInfoValues['price_field_value_id'], $submittedFieldValueIds) && $updateFinancialItemInfoValues['differenceAmt'] != 0) {
                 // INSERT negative financial_items
                 $updateFinancialItemInfoValues['amount'] = -$updateFinancialItemInfoValues['amount'];
                 CRM_Financial_BAO_FinancialItem::create($updateFinancialItemInfoValues, NULL, $trxnId);
             } elseif (in_array($updateFinancialItemInfoValues['price_field_value_id'], $submittedFieldValueIds) && $updateFinancialItemInfoValues['differenceAmt'] == 0) {
                 $updateFinancialItemInfoValues['amount'] = $updateFinancialItemInfoValues['amount'];
                 CRM_Financial_BAO_FinancialItem::create($updateFinancialItemInfoValues, NULL, $trxnId);
             }
         }
     }
     if (!empty($updateLines)) {
         foreach ($updateLines as $valueId => $vals) {
             $updateLineItem = "\nUPDATE civicrm_line_item li\nSET li.qty = {$vals['qty']},\n    li.line_total = {$vals['line_total']}\nWHERE (li.entity_table = 'civicrm_participant' AND li.entity_id = {$participantId}) AND\n      (price_field_value_id = {$valueId})\n";
             CRM_Core_DAO::executeQuery($updateLineItem);
         }
     }
     // insert new 'adjusted amount' transaction entry and update contribution entry.
     // ensure entity_financial_trxn table has a linking of it.
     // insert new line items
     foreach ($insertLines as $valueId => $lineParams) {
         $lineParams['entity_table'] = 'civicrm_participant';
         $lineParams['entity_id'] = $participantId;
         $lineObj = CRM_Price_BAO_LineItem::create($lineParams);
     }
     // the recordAdjustedAmt code would execute over here
     $ids = CRM_Event_BAO_Participant::getParticipantIds($contributionId);
     if (count($ids) > 1) {
         $total = 0;
         foreach ($ids as $val) {
             $total += CRM_Price_BAO_LineItem::getLineTotal($val, 'civicrm_participant');
         }
         $updatedAmount = $total;
     } else {
         $updatedAmount = $params['amount'];
     }
     self::recordAdjustedAmt($updatedAmount, $paidAmount, $contributionId);
     $fetchCon = array('id' => $contributionId);
     $updatedContribution = CRM_Contribute_BAO_Contribution::retrieve($fetchCon, CRM_Core_DAO::$_nullArray, CRM_Core_DAO::$_nullArray);
     // insert financial items
     foreach ($insertLines as $valueId => $lineParams) {
         $lineParams['entity_table'] = 'civicrm_participant';
         $lineParams['entity_id'] = $participantId;
         $lineObj = CRM_Price_BAO_LineItem::retrieve($lineParams, CRM_Core_DAO::$_nullArray);
         // insert financial items
         // ensure entity_financial_trxn table has a linking of it.
//.........这里部分代码省略.........
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:101,代码来源:Participant.php

示例7: sendMail

 function sendMail(&$input, &$ids, &$objects, &$values, $recur = false, $returnMessageText = false)
 {
     $contribution =& $objects['contribution'];
     $membership =& $objects['membership'];
     $participant =& $objects['participant'];
     $event =& $objects['event'];
     if (empty($values)) {
         $values = array();
         $contribID = $ids['contribution'];
         if ($input['component'] == 'contribute') {
             require_once 'CRM/Contribute/BAO/ContributionPage.php';
             if (isset($contribution->contribution_page_id)) {
                 CRM_Contribute_BAO_ContributionPage::setValues($contribution->contribution_page_id, $values);
             } else {
                 // Handle re-print receipt for offline contributions (call from PDF.php - no contribution_page_id)
                 $values['is_email_receipt'] = 1;
                 $values['title'] = 'Contribution';
             }
             // set lineItem for contribution
             require_once 'CRM/Price/BAO/Set.php';
             if ($contribID && ($pId = CRM_Price_BAO_Set::getFor('civicrm_contribution', $contribID))) {
                 require_once 'CRM/Price/BAO/LineItem.php';
                 $values['lineItem'][0] = CRM_Price_BAO_LineItem::getLineItems($contribID, 'contribution');
                 $values['priceSetID'] = $pId;
             }
             require_once 'CRM/Contribute/BAO/Contribution.php';
             $relatedContact = CRM_Contribute_BAO_Contribution::getOnbehalfIds($contribID, $contribution->contact_id);
             // if this is onbehalf of contribution then set related contact
             if ($relatedContactId = $relatedContact['individual_id']) {
                 $values['related_contact'] = $ids['related_contact'] = $relatedContactId;
             }
         } else {
             // event
             $eventParams = array('id' => $objects['event']->id);
             $values['event'] = array();
             require_once 'CRM/Event/BAO/Event.php';
             CRM_Event_BAO_Event::retrieve($eventParams, $values['event']);
             //get location details
             $locationParams = array('entity_id' => $objects['event']->id, 'entity_table' => 'civicrm_event');
             require_once 'CRM/Core/BAO/Location.php';
             require_once 'CRM/Event/Form/ManageEvent/Location.php';
             $values['location'] = CRM_Core_BAO_Location::getValues($locationParams);
             require_once 'CRM/Core/BAO/UFJoin.php';
             $ufJoinParams = array('entity_table' => 'civicrm_event', 'entity_id' => $ids['event'], 'weight' => 1);
             $values['custom_pre_id'] = CRM_Core_BAO_UFJoin::findUFGroupId($ufJoinParams);
             $ufJoinParams['weight'] = 2;
             $values['custom_post_id'] = CRM_Core_BAO_UFJoin::findUFGroupId($ufJoinParams);
             // set lineItem for event contribution
             if ($contribID) {
                 require_once 'CRM/Event/BAO/Participant.php';
                 $participantIds = CRM_Event_BAO_Participant::getParticipantIds($contribID);
                 require_once 'CRM/Price/BAO/LineItem.php';
                 if (!empty($participantIds)) {
                     foreach ($participantIds as $pIDs) {
                         $lineItem = CRM_Price_BAO_LineItem::getLineItems($pIDs);
                         if (!CRM_Utils_System::isNull($lineItem)) {
                             $values['lineItem'][] = $lineItem;
                         }
                     }
                 }
             }
         }
         // set receipt from e-mail and name in value
         if (!$returnMessageText) {
             require_once 'CRM/Contact/BAO/Contact/Location.php';
             $session = CRM_Core_Session::singleton();
             $userID = $session->get('userID');
             list($userName, $userEmail) = CRM_Contact_BAO_Contact_Location::getEmailDetails($userID);
             $values['receipt_from_email'] = $userEmail;
             $values['receipt_from_name'] = $userName;
         }
         // set display address of contributor
         if ($contribution->address_id) {
             require_once 'CRM/Core/BAO/Address.php';
             $addressParams = array('id' => $contribution->address_id);
             $addressDetails = CRM_Core_BAO_Address::getValues($addressParams, false, 'id');
             $addressDetails = array_values($addressDetails);
             $values['address'] = $addressDetails[0]['display'];
         }
     }
     $template =& CRM_Core_Smarty::singleton();
     // CRM_Core_Error::debug('tpl',$template);
     //assign honor infomation to receiptmessage
     if ($honarID = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Contribution', $contribution->id, 'honor_contact_id')) {
         $honorDefault = array();
         $honorIds = array();
         $honorIds['contribution'] = $contribution->id;
         $idParams = array('id' => $honarID, 'contact_id' => $honarID);
         require_once "CRM/Contact/BAO/Contact.php";
         CRM_Contact_BAO_Contact::retrieve($idParams, $honorDefault, $honorIds);
         require_once "CRM/Core/PseudoConstant.php";
         $honorType = CRM_Core_PseudoConstant::honor();
         $prefix = CRM_Core_PseudoConstant::individualPrefix();
         $template->assign('honor_block_is_active', 1);
         $template->assign('honor_prefix', $prefix[$honorDefault["prefix_id"]]);
         $template->assign('honor_first_name', CRM_Utils_Array::value("first_name", $honorDefault));
         $template->assign('honor_last_name', CRM_Utils_Array::value("last_name", $honorDefault));
         $template->assign('honor_email', CRM_Utils_Array::value("email", $honorDefault["email"][1]));
         $template->assign('honor_type', $honorType[$contribution->honor_type_id]);
     }
//.........这里部分代码省略.........
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:101,代码来源:BaseIPN.php

示例8: updateAmountAndFeeLevel

 /**
  * Update price option label in line_item, civicrm_contribution and civicrm_participant.
  *
  * @param int $id - id of the price_field_value
  * @param string $prevLabel
  * @param string $newLabel
  *
  */
 public static function updateAmountAndFeeLevel($id, $prevLabel, $newLabel)
 {
     // update price field label in line item.
     $lineItem = new CRM_Price_DAO_LineItem();
     $lineItem->price_field_value_id = $id;
     $lineItem->label = $prevLabel;
     $lineItem->find();
     while ($lineItem->fetch()) {
         $lineItem->label = $newLabel;
         $lineItem->save();
         // update amount and fee level in civicrm_contribution and civicrm_participant
         $params = array(1 => array(CRM_Core_DAO::VALUE_SEPARATOR . $prevLabel . ' -', 'String'), 2 => array(CRM_Core_DAO::VALUE_SEPARATOR . $newLabel . ' -', 'String'));
         if (!empty($lineItem->contribution_id)) {
             CRM_Core_DAO::executeQuery("UPDATE `civicrm_contribution` SET `amount_level` = REPLACE(amount_level, %1, %2) WHERE id = {$lineItem->contribution_id}", $params);
             $participantIds = CRM_Event_BAO_Participant::getParticipantIds($lineItem->contribution_id);
             foreach ($participantIds as $key => $id) {
                 if (!empty($id)) {
                     CRM_Core_DAO::executeQuery("UPDATE `civicrm_participant` SET `fee_level` = REPLACE(fee_level, %1, %2) WHERE id = {$id}", $params);
                 }
             }
         }
     }
 }
开发者ID:hyebahi,项目名称:civicrm-core,代码行数:31,代码来源:PriceFieldValue.php


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