本文整理汇总了PHP中CRM_Price_BAO_LineItem::getLineItems方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Price_BAO_LineItem::getLineItems方法的具体用法?PHP CRM_Price_BAO_LineItem::getLineItems怎么用?PHP CRM_Price_BAO_LineItem::getLineItems使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Price_BAO_LineItem
的用法示例。
在下文中一共展示了CRM_Price_BAO_LineItem::getLineItems方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: preProcess
/**
* Function to set variables up before form is built
*
* @return void
* @access public
*/
public function preProcess()
{
require_once 'CRM/Event/BAO/Participant.php';
$values = $ids = array();
$participantID = CRM_Utils_Request::retrieve('id', 'Positive', $this, true);
$contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this, true);
$params = array('id' => $participantID);
CRM_Event_BAO_Participant::getValues($params, $values, $ids);
if (empty($values)) {
require_once 'CRM/Core/Error.php';
CRM_Core_Error::statusBounce(ts('The requested participant record does not exist (possibly the record was deleted).'));
}
CRM_Event_BAO_Participant::resolveDefaults($values[$participantID]);
if (CRM_Utils_Array::value('fee_level', $values[$participantID])) {
CRM_Event_BAO_Participant::fixEventLevel($values[$participantID]['fee_level']);
}
if ($values[$participantID]['is_test']) {
$values[$participantID]['status'] .= ' (test) ';
}
// Get Note
$noteValue = CRM_Core_BAO_Note::getNote($participantID, 'civicrm_participant');
$values[$participantID]['note'] = array_values($noteValue);
require_once 'CRM/Price/BAO/LineItem.php';
// Get Line Items
$lineItem = CRM_Price_BAO_LineItem::getLineItems($participantID);
if (!CRM_Utils_System::isNull($lineItem)) {
$values[$participantID]['lineItem'][] = $lineItem;
}
$values[$participantID]['totalAmount'] = $values[$participantID]['fee_amount'];
// get the option value for custom data type
$roleCustomDataTypeID = CRM_Core_OptionGroup::getValue('custom_data_type', 'ParticipantRole', 'name');
$eventNameCustomDataTypeID = CRM_Core_OptionGroup::getValue('custom_data_type', 'ParticipantEventName', 'name');
$eventTypeCustomDataTypeID = CRM_Core_OptionGroup::getValue('custom_data_type', 'ParticipantEventType', 'name');
$roleGroupTree =& CRM_Core_BAO_CustomGroup::getTree('Participant', $this, $participantID, null, $values[$participantID]['role_id'], $roleCustomDataTypeID);
$eventGroupTree =& CRM_Core_BAO_CustomGroup::getTree('Participant', $this, $participantID, null, $values[$participantID]['event_id'], $eventNameCustomDataTypeID);
$eventTypeID = CRM_Core_DAO::getFieldValue("CRM_Event_DAO_Event", $values[$participantID]['event_id'], 'event_type_id', 'id');
$eventTypeGroupTree =& CRM_Core_BAO_CustomGroup::getTree('Participant', $this, $participantID, null, $eventTypeID, $eventTypeCustomDataTypeID);
$groupTree = CRM_Utils_Array::crmArrayMerge($roleGroupTree, $eventGroupTree);
$groupTree = CRM_Utils_Array::crmArrayMerge($groupTree, $eventTypeGroupTree);
$groupTree = CRM_Utils_Array::crmArrayMerge($groupTree, CRM_Core_BAO_CustomGroup::getTree('Participant', $this, $participantID));
CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree);
$this->assign($values[$participantID]);
// add viewed participant to recent items list
require_once 'CRM/Utils/Recent.php';
require_once 'CRM/Contact/BAO/Contact.php';
$url = CRM_Utils_System::url('civicrm/contact/view/participant', "action=view&reset=1&id={$values[$participantID]['id']}&cid={$values[$participantID]['contact_id']}&context=home");
$participantRoles = CRM_Event_PseudoConstant::participantRole();
$eventTitle = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $values[$participantID]['event_id'], 'title');
$displayName = CRM_Contact_BAO_Contact::displayName($contactID);
$this->assign('displayName', $displayName);
$title = $displayName . ' (' . $participantRoles[$values[$participantID]['role_id']] . ' - ' . $eventTitle . ')';
// add Participant to Recent Items
CRM_Utils_Recent::add($title, $url, $values[$participantID]['id'], 'Participant', $values[$participantID]['contact_id'], null);
}
示例2: preProcess
/**
* Function to set variables up before form is built
*
* @return void
* @access public
*/
public function preProcess()
{
$id = $this->get('id');
$values = $ids = array();
$params = array('id' => $id);
$context = CRM_Utils_Request::retrieve('context', 'String', $this);
$this->assign('context', $context);
CRM_Contribute_BAO_Contribution::getValues($params, $values, $ids);
$softParams = array('contribution_id' => $values['contribution_id']);
if ($softContribution = CRM_Contribute_BAO_Contribution::getSoftContribution($softParams, TRUE)) {
$values = array_merge($values, $softContribution);
}
CRM_Contribute_BAO_Contribution::resolveDefaults($values);
if (CRM_Utils_Array::value('contribution_page_id', $values)) {
$contribPages = CRM_Contribute_PseudoConstant::contributionPage(NULL, TRUE);
$values['contribution_page_title'] = CRM_Utils_Array::value(CRM_Utils_Array::value('contribution_page_id', $values), $contribPages);
}
if (CRM_Utils_Array::value('honor_contact_id', $values)) {
$sql = "SELECT display_name FROM civicrm_contact WHERE id = %1";
$params = array(1 => array($values['honor_contact_id'], 'Integer'));
$dao = CRM_Core_DAO::executeQuery($sql, $params);
if ($dao->fetch()) {
$url = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$values['honor_contact_id']}");
$values['honor_display'] = "<A href = {$url}>" . $dao->display_name . "</A>";
}
$honor = CRM_Core_PseudoConstant::honor();
$values['honor_type'] = CRM_Utils_Array::value(CRM_Utils_Array::value('honor_type_id', $values), $honor);
}
if (CRM_Utils_Array::value('contribution_recur_id', $values)) {
$sql = "SELECT installments, frequency_interval, frequency_unit FROM civicrm_contribution_recur WHERE id = %1";
$params = array(1 => array($values['contribution_recur_id'], 'Integer'));
$dao = CRM_Core_DAO::executeQuery($sql, $params);
if ($dao->fetch()) {
$values['recur_installments'] = $dao->installments;
$values['recur_frequency_unit'] = $dao->frequency_unit;
$values['recur_frequency_interval'] = $dao->frequency_interval;
}
}
$groupTree = CRM_Core_BAO_CustomGroup::getTree('Contribution', $this, $id, 0, $values['contribution_type_id']);
CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree);
$premiumId = NULL;
if ($id) {
$dao = new CRM_Contribute_DAO_ContributionProduct();
$dao->contribution_id = $id;
if ($dao->find(TRUE)) {
$premiumId = $dao->id;
$productID = $dao->product_id;
}
}
if ($premiumId) {
$productDAO = new CRM_Contribute_DAO_Product();
$productDAO->id = $productID;
$productDAO->find(TRUE);
$this->assign('premium', $productDAO->name);
$this->assign('option', $dao->product_option);
$this->assign('fulfilled', $dao->fulfilled_date);
}
// Get Note
$noteValue = CRM_Core_BAO_Note::getNote($values['id'], 'civicrm_contribution');
$values['note'] = array_values($noteValue);
// show billing address location details, if exists
if (CRM_Utils_Array::value('address_id', $values)) {
$addressParams = array('id' => CRM_Utils_Array::value('address_id', $values));
$addressDetails = CRM_Core_BAO_Address::getValues($addressParams, FALSE, 'id');
$addressDetails = array_values($addressDetails);
$values['billing_address'] = $addressDetails[0]['display'];
}
//get soft credit record if exists.
if ($softContribution = CRM_Contribute_BAO_Contribution::getSoftContribution($softParams)) {
$softContribution['softCreditToName'] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $softContribution['soft_credit_to'], 'display_name');
//hack to avoid dispalyName conflict
//for viewing softcredit record.
$softContribution['displayName'] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $values['contact_id'], 'display_name');
$values = array_merge($values, $softContribution);
}
$lineItems = array();
if ($id) {
$lineItem = CRM_Price_BAO_LineItem::getLineItems($id, 'contribution', 1);
empty($lineItem) ? null : ($lineItems[] = $lineItem);
}
$this->assign('lineItem', empty($lineItems) ? FALSE : $lineItems);
$values['totalAmount'] = $values['total_amount'];
//do check for campaigns
if ($campaignId = CRM_Utils_Array::value('campaign_id', $values)) {
$campaigns = CRM_Campaign_BAO_Campaign::getCampaigns($campaignId);
$values['campaign'] = $campaigns[$campaignId];
}
// assign values to the template
$this->assign($values);
// add viewed contribution to recent items list
$url = CRM_Utils_System::url('civicrm/contact/view/contribution', "action=view&reset=1&id={$values['id']}&cid={$values['contact_id']}&context=home");
$displayName = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $values['contact_id'], 'display_name');
$this->assign('displayName', $displayName);
$title = $displayName . ' - (' . CRM_Utils_Money::format($values['total_amount']) . ' ' . ' - ' . $values['contribution_type'] . ')';
//.........这里部分代码省略.........
示例3: preProcess
/**
* Set variables up before form is built.
*
* @return void
*/
public function preProcess()
{
$values = $ids = array();
$participantID = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE);
$contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE);
$params = array('id' => $participantID);
CRM_Event_BAO_Participant::getValues($params, $values, $ids);
if (empty($values)) {
CRM_Core_Error::statusBounce(ts('The requested participant record does not exist (possibly the record was deleted).'));
}
CRM_Event_BAO_Participant::resolveDefaults($values[$participantID]);
if (!empty($values[$participantID]['fee_level'])) {
CRM_Event_BAO_Participant::fixEventLevel($values[$participantID]['fee_level']);
}
$this->assign('contactId', $contactID);
$this->assign('participantId', $participantID);
$paymentId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $participantID, 'id', 'participant_id');
$this->assign('hasPayment', $paymentId);
if ($parentParticipantId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', $participantID, 'registered_by_id')) {
$parentHasPayment = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $parentParticipantId, 'id', 'participant_id');
$this->assign('parentHasPayment', $parentHasPayment);
}
$statusId = CRM_Core_DAO::getFieldValue('CRM_Event_BAO_Participant', $participantID, 'status_id', 'id');
$status = CRM_Core_DAO::getFieldValue('CRM_Event_BAO_ParticipantStatusType', $statusId, 'name', 'id');
$status = CRM_Core_DAO::getFieldValue('CRM_Event_BAO_ParticipantStatusType', $statusId, 'name', 'id');
if ($status == 'Transferred') {
$transferId = CRM_Core_DAO::getFieldValue('CRM_Event_BAO_Participant', $participantID, 'transferred_to_contact_id', 'id');
$pid = CRM_Core_DAO::getFieldValue('CRM_Event_BAO_Participant', $transferId, 'id', 'contact_id');
$transferName = current(CRM_Contact_BAO_Contact::getContactDetails($transferId));
$this->assign('pid', $pid);
$this->assign('transferId', $transferId);
$this->assign('transferName', $transferName);
}
$participantStatuses = CRM_Event_PseudoConstant::participantStatus();
if ($values[$participantID]['is_test']) {
$values[$participantID]['status'] .= ' (test) ';
}
// Get Note
$noteValue = CRM_Core_BAO_Note::getNote($participantID, 'civicrm_participant');
$values[$participantID]['note'] = array_values($noteValue);
// Get Line Items
$lineItem = CRM_Price_BAO_LineItem::getLineItems($participantID);
if (!CRM_Utils_System::isNull($lineItem)) {
$values[$participantID]['lineItem'][] = $lineItem;
}
$values[$participantID]['totalAmount'] = CRM_Utils_Array::value('fee_amount', $values[$participantID]);
// Get registered_by contact ID and display_name if participant was registered by someone else (CRM-4859)
if (!empty($values[$participantID]['participant_registered_by_id'])) {
$values[$participantID]['registered_by_contact_id'] = CRM_Core_DAO::getFieldValue("CRM_Event_DAO_Participant", $values[$participantID]['participant_registered_by_id'], 'contact_id', 'id');
$values[$participantID]['registered_by_display_name'] = CRM_Contact_BAO_Contact::displayName($values[$participantID]['registered_by_contact_id']);
}
// Check if this is a primaryParticipant (registered for others) and retrieve additional participants if true (CRM-4859)
if (CRM_Event_BAO_Participant::isPrimaryParticipant($participantID)) {
$values[$participantID]['additionalParticipants'] = CRM_Event_BAO_Participant::getAdditionalParticipants($participantID);
}
// get the option value for custom data type
$roleCustomDataTypeID = CRM_Core_OptionGroup::getValue('custom_data_type', 'ParticipantRole', 'name');
$eventNameCustomDataTypeID = CRM_Core_OptionGroup::getValue('custom_data_type', 'ParticipantEventName', 'name');
$eventTypeCustomDataTypeID = CRM_Core_OptionGroup::getValue('custom_data_type', 'ParticipantEventType', 'name');
$allRoleIDs = explode(CRM_Core_DAO::VALUE_SEPARATOR, $values[$participantID]['role_id']);
$groupTree = array();
$finalTree = array();
foreach ($allRoleIDs as $k => $v) {
$roleGroupTree = CRM_Core_BAO_CustomGroup::getTree('Participant', $this, $participantID, NULL, $v, $roleCustomDataTypeID);
$eventGroupTree = CRM_Core_BAO_CustomGroup::getTree('Participant', $this, $participantID, NULL, $values[$participantID]['event_id'], $eventNameCustomDataTypeID);
$eventTypeID = CRM_Core_DAO::getFieldValue("CRM_Event_DAO_Event", $values[$participantID]['event_id'], 'event_type_id', 'id');
$eventTypeGroupTree = CRM_Core_BAO_CustomGroup::getTree('Participant', $this, $participantID, NULL, $eventTypeID, $eventTypeCustomDataTypeID);
$groupTree = CRM_Utils_Array::crmArrayMerge($roleGroupTree, $eventGroupTree);
$groupTree = CRM_Utils_Array::crmArrayMerge($groupTree, $eventTypeGroupTree);
$groupTree = CRM_Utils_Array::crmArrayMerge($groupTree, CRM_Core_BAO_CustomGroup::getTree('Participant', $this, $participantID));
foreach ($groupTree as $treeId => $trees) {
$finalTree[$treeId] = $trees;
}
}
CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $finalTree, FALSE, NULL, NULL, NULL, $participantID);
$eventTitle = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $values[$participantID]['event_id'], 'title');
//CRM-7150, show event name on participant view even if the event is disabled
if (empty($values[$participantID]['event'])) {
$values[$participantID]['event'] = $eventTitle;
}
//do check for campaigns
if ($campaignId = CRM_Utils_Array::value('campaign_id', $values[$participantID])) {
$campaigns = CRM_Campaign_BAO_Campaign::getCampaigns($campaignId);
$values[$participantID]['campaign'] = $campaigns[$campaignId];
}
$this->assign($values[$participantID]);
// add viewed participant to recent items list
$url = CRM_Utils_System::url('civicrm/contact/view/participant', "action=view&reset=1&id={$values[$participantID]['id']}&cid={$values[$participantID]['contact_id']}&context=home");
$recentOther = array();
if (CRM_Core_Permission::check('edit event participants')) {
$recentOther['editUrl'] = CRM_Utils_System::url('civicrm/contact/view/participant', "action=update&reset=1&id={$values[$participantID]['id']}&cid={$values[$participantID]['contact_id']}&context=home");
}
if (CRM_Core_Permission::check('delete in CiviEvent')) {
$recentOther['deleteUrl'] = CRM_Utils_System::url('civicrm/contact/view/participant', "action=delete&reset=1&id={$values[$participantID]['id']}&cid={$values[$participantID]['contact_id']}&context=home");
}
//.........这里部分代码省略.........
示例4: postProcess
//.........这里部分代码省略.........
$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);
$cancelled = TRUE;
if ($membership->end_date) {
//display end date w/ status message.
示例5: postProcess
/**
* Process the form submission.
*/
public function postProcess()
{
// get the submitted form values.
$params = $this->controller->exportValues($this->_name);
if ($this->_action & CRM_Core_Action::DELETE) {
if (CRM_Utils_Array::value('delete_participant', $params) == 2) {
$additionalId = CRM_Event_BAO_Participant::getAdditionalParticipantIds($this->_id);
$participantLinks = CRM_Event_BAO_Participant::getAdditionalParticipantUrl($additionalId);
}
if (CRM_Utils_Array::value('delete_participant', $params) == 1) {
$additionalIds = CRM_Event_BAO_Participant::getAdditionalParticipantIds($this->_id);
foreach ($additionalIds as $value) {
CRM_Event_BAO_Participant::deleteParticipant($value);
}
}
CRM_Event_BAO_Participant::deleteParticipant($this->_id);
CRM_Core_Session::setStatus(ts('Selected participant was deleted successfully.'), ts('Record Deleted'), 'success');
if (!empty($participantLinks)) {
$status = ts('The following participants no longer have an event fee recorded. You can edit their registration and record a replacement contribution by clicking the links below:') . '<br/>' . $participantLinks;
CRM_Core_Session::setStatus($status, ts('Group Payment Deleted'));
}
return;
}
// When adding a single contact, the formRule prevents you from adding duplicates
// (See above in formRule()). When adding more than one contact, the duplicates are
// removed automatically and the user receives one notification.
if ($this->_action & CRM_Core_Action::ADD) {
$event_id = $this->_eventId;
if (empty($event_id) && !empty($params['event_id'])) {
$event_id = $params['event_id'];
}
if (!$this->_single && !empty($event_id)) {
$duplicateContacts = 0;
while (list($k, $dupeCheckContactId) = each($this->_contactIds)) {
// Eliminate contacts that have already been assigned to this event.
$dupeCheck = new CRM_Event_BAO_Participant();
$dupeCheck->contact_id = $dupeCheckContactId;
$dupeCheck->event_id = $event_id;
$dupeCheck->find(TRUE);
if (!empty($dupeCheck->id)) {
$duplicateContacts++;
unset($this->_contactIds[$k]);
}
}
if ($duplicateContacts > 0) {
$msg = ts("%1 contacts have already been assigned to this event. They were not added a second time.", array(1 => $duplicateContacts));
CRM_Core_Session::setStatus($msg);
}
if (count($this->_contactIds) == 0) {
CRM_Core_Session::setStatus(ts("No participants were added."));
return;
}
// We have to re-key $this->_contactIds so each contact has the same
// key as their corresponding record in the $participants array that
// will be created below.
$this->_contactIds = array_values($this->_contactIds);
}
}
$participantStatus = CRM_Event_PseudoConstant::participantStatus();
// set the contact, when contact is selected
if (!empty($params['contact_id'])) {
$this->_contactId = $params['contact_id'];
}
if ($this->_priceSetId && ($isQuickConfig = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $this->_priceSetId, 'is_quick_config'))) {
$this->_quickConfig = $isQuickConfig;
}
if ($this->_id) {
$params['id'] = $this->_id;
}
$config = CRM_Core_Config::singleton();
if ($this->_isPaidEvent) {
$contributionParams = array();
$lineItem = array();
$additionalParticipantDetails = array();
if (CRM_Contribute_BAO_Contribution::checkContributeSettings('deferred_revenue_enabled')) {
$eventStartDate = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $this->_eventId, 'start_date');
if ($eventStartDate) {
$contributionParams['revenue_recognition_date'] = date('Ymd', strtotime($eventStartDate));
}
}
if ($this->_id && $this->_action & CRM_Core_Action::UPDATE && $this->_paymentId) {
$participantBAO = new CRM_Event_BAO_Participant();
$participantBAO->id = $this->_id;
$participantBAO->find(TRUE);
$contributionParams['total_amount'] = $participantBAO->fee_amount;
$params['discount_id'] = NULL;
//re-enter the values for UPDATE mode
$params['fee_level'] = $params['amount_level'] = $participantBAO->fee_level;
$params['fee_amount'] = $participantBAO->fee_amount;
if (isset($params['priceSetId'])) {
$lineItem[0] = CRM_Price_BAO_LineItem::getLineItems($this->_id);
}
//also add additional participant's fee level/priceset
if (CRM_Event_BAO_Participant::isPrimaryParticipant($this->_id)) {
$additionalIds = CRM_Event_BAO_Participant::getAdditionalParticipantIds($this->_id);
$hasLineItems = CRM_Utils_Array::value('priceSetId', $params, FALSE);
$additionalParticipantDetails = CRM_Event_BAO_Participant::getFeeDetails($additionalIds, $hasLineItems);
//.........这里部分代码省略.........
示例6: submit
/**
* @param array $submittedValues
*
* @param int $action
* Action constant
* - CRM_Core_Action::UPDATE
*
* @param $pledgePaymentID
*
* @return array
* @throws \Exception
*/
protected function submit($submittedValues, $action, $pledgePaymentID)
{
$softParams = $softIDs = array();
$pId = $contribution = $isRelatedId = FALSE;
$this->_params = $submittedValues;
$this->beginPostProcess();
if (!empty($submittedValues['price_set_id']) && $action & CRM_Core_Action::UPDATE) {
$line = CRM_Price_BAO_LineItem::getLineItems($this->_id, 'contribution');
$lineID = key($line);
$priceSetId = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceField', CRM_Utils_Array::value('price_field_id', $line[$lineID]), 'price_set_id');
$quickConfig = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $priceSetId, 'is_quick_config');
// Why do we do this? Seems like a like a wrapper for old functionality - but single line price sets & quick
// config should be treated the same.
if ($quickConfig) {
CRM_Price_BAO_LineItem::deleteLineItems($this->_id, 'civicrm_contribution');
}
}
// Process price set and get total amount and line items.
$lineItem = array();
$priceSetId = CRM_Utils_Array::value('price_set_id', $submittedValues);
if (empty($priceSetId) && !$this->_id) {
$this->_priceSetId = $priceSetId = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', 'default_contribution_amount', 'id', 'name');
$this->_priceSet = current(CRM_Price_BAO_PriceSet::getSetDetail($priceSetId));
$fieldID = key($this->_priceSet['fields']);
$fieldValueId = key($this->_priceSet['fields'][$fieldID]['options']);
$this->_priceSet['fields'][$fieldID]['options'][$fieldValueId]['amount'] = $submittedValues['total_amount'];
$submittedValues['price_' . $fieldID] = 1;
}
// Every contribution has a price-set - the only reason it shouldn't be set is if we are dealing with
// quick config (very very arguably) & yet we see that this could still be quick config so this should be understood
// as a point of fragility rather than a logical 'if' clause.
if ($priceSetId) {
CRM_Price_BAO_PriceSet::processAmount($this->_priceSet['fields'], $submittedValues, $lineItem[$priceSetId]);
// Unset tax amount for offline 'is_quick_config' contribution.
// @todo WHY - quick config was conceived as a quick way to configure contribution forms.
// this is an example of 'other' functionality being hung off it.
if ($this->_priceSet['is_quick_config'] && !array_key_exists($submittedValues['financial_type_id'], CRM_Core_PseudoConstant::getTaxRates())) {
unset($submittedValues['tax_amount']);
}
$submittedValues['total_amount'] = CRM_Utils_Array::value('amount', $submittedValues);
}
if ($this->_id) {
if ($this->_compId) {
if ($this->_context == 'participant') {
$pId = $this->_compId;
} elseif ($this->_context == 'membership') {
$isRelatedId = TRUE;
} else {
$pId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $this->_id, 'participant_id', 'contribution_id');
}
} else {
$contributionDetails = CRM_Contribute_BAO_Contribution::getComponentDetails($this->_id);
if (array_key_exists('membership', $contributionDetails)) {
$isRelatedId = TRUE;
} elseif (array_key_exists('participant', $contributionDetails)) {
$pId = $contributionDetails['participant'];
}
}
}
if (!$priceSetId && !empty($submittedValues['total_amount']) && $this->_id) {
// CRM-10117 update the line items for participants.
// @todo - if we are completing a contribution then the api call
// civicrm_api3('Contribution', 'completetransaction') should take care of
// all associated updates rather than replicating them on the form layer.
if ($pId) {
$entityTable = 'participant';
$entityID = $pId;
$isRelatedId = FALSE;
$participantParams = array('fee_amount' => $submittedValues['total_amount'], 'id' => $entityID);
CRM_Event_BAO_Participant::add($participantParams);
if (empty($this->_lineItems)) {
$this->_lineItems[] = CRM_Price_BAO_LineItem::getLineItems($entityID, 'participant', 1);
}
} else {
$entityTable = 'contribution';
$entityID = $this->_id;
}
$lineItems = CRM_Price_BAO_LineItem::getLineItems($entityID, $entityTable, NULL, TRUE, $isRelatedId);
foreach (array_keys($lineItems) as $id) {
$lineItems[$id]['id'] = $id;
}
$itemId = key($lineItems);
if ($itemId && !empty($lineItems[$itemId]['price_field_id'])) {
$this->_priceSetId = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceField', $lineItems[$itemId]['price_field_id'], 'price_set_id');
}
// @todo see above - new functionality has been inappropriately added to the quick config concept
// and new functionality has been added onto the form layer rather than the BAO :-(
if ($this->_priceSetId && CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $this->_priceSetId, 'is_quick_config')) {
//.........这里部分代码省略.........
示例7: _checkFinancialItem
/**
* @param int $contId
* @param $context
*/
public function _checkFinancialItem($contId, $context)
{
if ($context != 'paylater') {
$params = array('entity_id' => $contId, 'entity_table' => 'civicrm_contribution');
$trxn = current(CRM_Financial_BAO_FinancialItem::retrieveEntityFinancialTrxn($params, TRUE));
$entityParams = array('financial_trxn_id' => $trxn['financial_trxn_id'], 'entity_table' => 'civicrm_financial_item');
$entityTrxn = current(CRM_Financial_BAO_FinancialItem::retrieveEntityFinancialTrxn($entityParams));
$params = array('id' => $entityTrxn['entity_id']);
}
if ($context == 'paylater') {
$lineItems = CRM_Price_BAO_LineItem::getLineItems($contId, 'contribution');
foreach ($lineItems as $key => $item) {
$params = array('entity_id' => $key, 'entity_table' => 'civicrm_line_item');
$compareParams = array('status_id' => 1);
$this->assertDBCompareValues('CRM_Financial_DAO_FinancialItem', $params, $compareParams);
}
} elseif ($context == 'refund') {
$compareParams = array('status_id' => 1, 'financial_account_id' => 1, 'amount' => -100);
} elseif ($context == 'cancelPending') {
$compareParams = array('status_id' => 3, 'financial_account_id' => 1, 'amount' => -100);
} elseif ($context == 'changeFinancial') {
$lineKey = key(CRM_Price_BAO_LineItem::getLineItems($contId, 'contribution'));
$params = array('entity_id' => $lineKey, 'amount' => -100);
$compareParams = array('financial_account_id' => 1);
$this->assertDBCompareValues('CRM_Financial_DAO_FinancialItem', $params, $compareParams);
$params = array('financial_account_id' => 3, 'entity_id' => $lineKey);
$compareParams = array('amount' => 100);
}
if ($context != 'paylater') {
$this->assertDBCompareValues('CRM_Financial_DAO_FinancialItem', $params, $compareParams);
}
}
示例8: getLineItemArray
/**
* Build line items array.
* @param array $params
* Form values.
*
* @param string $entityId
* Entity id.
*
* @param string $entityTable
* Entity Table.
*
* @return void
*/
public static function getLineItemArray(&$params, $entityId = NULL, $entityTable = 'contribution', $isRelatedID = FALSE)
{
if (!$entityId) {
$priceSetDetails = CRM_Price_BAO_PriceSet::getDefaultPriceSet($entityTable);
$totalAmount = CRM_Utils_Array::value('total_amount', $params);
$financialType = CRM_Utils_Array::value('financial_type_id', $params);
foreach ($priceSetDetails as $values) {
if ($entityTable == 'membership') {
if ($isRelatedID != $values['membership_type_id']) {
continue;
}
if (!$totalAmount) {
$totalAmount = $values['amount'];
}
$financialType = $values['financial_type_id'];
}
$params['line_item'][$values['setID']][$values['priceFieldID']] = array('price_field_id' => $values['priceFieldID'], 'price_field_value_id' => $values['priceFieldValueID'], 'label' => $values['label'], 'qty' => 1, 'unit_price' => $totalAmount, 'line_total' => $totalAmount, 'financial_type_id' => $financialType, 'membership_type_id' => $values['membership_type_id']);
break;
}
} else {
$setID = NULL;
$totalEntityId = count($entityId);
foreach ($entityId as $id) {
$lineItems = CRM_Price_BAO_LineItem::getLineItems($id, $entityTable, NULL, TRUE, $isRelatedID);
foreach ($lineItems as $key => $values) {
if (!$setID && $values['price_field_id']) {
$setID = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceField', $values['price_field_id'], 'price_set_id');
$params['is_quick_config'] = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $setID, 'is_quick_config');
}
if (!empty($params['is_quick_config']) && array_key_exists('total_amount', $params) && $totalEntityId == 1) {
$values['line_total'] = $values['unit_price'] = $params['total_amount'];
}
$values['id'] = $key;
$params['line_item'][$setID][$key] = $values;
}
}
}
}
示例9: initSet
/**
* Initiate price set such that various non-BAO things are set on the form.
*
* This function is not really a BAO function so the location is misleading.
*
* @param CRM_Core_Form $form
* @param int $id
* Form entity id.
* @param string $entityTable
* @param bool $validOnly
* @param int $priceSetId
* Price Set ID
*
* @return bool|false|int|null
*/
public static function initSet(&$form, $id, $entityTable = 'civicrm_event', $validOnly = FALSE, $priceSetId = NULL)
{
if (!$priceSetId) {
$priceSetId = self::getFor($entityTable, $id);
}
//check if priceset is is_config
if (is_numeric($priceSetId)) {
if (CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $priceSetId, 'is_quick_config') && $form->getVar('_name') != 'Participant') {
$form->assign('quickConfig', 1);
}
}
// get price info
if ($priceSetId) {
if ($form->_action & CRM_Core_Action::UPDATE) {
$entityId = $entity = NULL;
switch ($entityTable) {
case 'civicrm_event':
$entity = 'participant';
if (CRM_Utils_System::getClassName($form) == 'CRM_Event_Form_Participant') {
$entityId = $form->_id;
} else {
$entityId = $form->_participantId;
}
break;
case 'civicrm_contribution_page':
case 'civicrm_contribution':
$entity = 'contribution';
$entityId = $form->_id;
break;
}
if ($entityId && $entity) {
$form->_values['line_items'] = CRM_Price_BAO_LineItem::getLineItems($entityId, $entity);
}
$required = FALSE;
} else {
$required = TRUE;
}
$form->_priceSetId = $priceSetId;
$priceSet = self::getSetDetail($priceSetId, $required, $validOnly);
$form->_priceSet = CRM_Utils_Array::value($priceSetId, $priceSet);
$form->_values['fee'] = CRM_Utils_Array::value('fields', $form->_priceSet);
//get the price set fields participant count.
if ($entityTable == 'civicrm_event') {
//get option count info.
$form->_priceSet['optionsCountTotal'] = self::getPricesetCount($priceSetId);
if ($form->_priceSet['optionsCountTotal']) {
$optionsCountDeails = array();
if (!empty($form->_priceSet['fields'])) {
foreach ($form->_priceSet['fields'] as $field) {
foreach ($field['options'] as $option) {
$count = CRM_Utils_Array::value('count', $option, 0);
$optionsCountDeails['fields'][$field['id']]['options'][$option['id']] = $count;
}
}
}
$form->_priceSet['optionsCountDetails'] = $optionsCountDeails;
}
//get option max value info.
$optionsMaxValueTotal = 0;
$optionsMaxValueDetails = array();
if (!empty($form->_priceSet['fields'])) {
foreach ($form->_priceSet['fields'] as $field) {
foreach ($field['options'] as $option) {
$maxVal = CRM_Utils_Array::value('max_value', $option, 0);
$optionsMaxValueDetails['fields'][$field['id']]['options'][$option['id']] = $maxVal;
$optionsMaxValueTotal += $maxVal;
}
}
}
$form->_priceSet['optionsMaxValueTotal'] = $optionsMaxValueTotal;
if ($optionsMaxValueTotal) {
$form->_priceSet['optionsMaxValueDetails'] = $optionsMaxValueDetails;
}
}
$form->set('priceSetId', $form->_priceSetId);
$form->set('priceSet', $form->_priceSet);
return $priceSetId;
}
return FALSE;
}
示例10: buildQuickForm
/**
* Build the form
*
* @access public
* @return void
*/
function buildQuickForm()
{
$this->addElement('text', 'sort_name', ts('Participant Name or Email'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));
require_once 'CRM/Event/BAO/Query.php';
CRM_Event_BAO_Query::buildSearchForm($this);
/*
* add form checkboxes for each row. This is needed out here to conform to QF protocol
* of all elements being declared in builQuickForm
*/
$rows = $this->get('rows');
if (is_array($rows)) {
$lineItems = array();
require_once 'CRM/Event/BAO/Event.php';
if (!$this->_single) {
$this->addElement('checkbox', 'toggleSelect', null, null, array('onclick' => "toggleTaskAction( true ); return toggleCheckboxVals('mark_x_',this);"));
}
foreach ($rows as $row) {
if (!$this->_single) {
$this->addElement('checkbox', $row['checkbox'], null, null, array('onclick' => "toggleTaskAction( true ); return checkSelectedBox('" . $row['checkbox'] . "', '" . $this->getName() . "');"));
}
if (CRM_Event_BAO_Event::usesPriceSet($row['event_id'])) {
// add line item details if applicable
require_once 'CRM/Price/BAO/LineItem.php';
$lineItems[$row['participant_id']] = CRM_Price_BAO_LineItem::getLineItems($row['participant_id']);
}
}
$this->assign('lineItems', $lineItems);
$total = $cancel = 0;
require_once "CRM/Core/Permission.php";
$permission = CRM_Core_Permission::getPermission();
require_once 'CRM/Event/Task.php';
$tasks = array('' => ts('- more actions -')) + CRM_Event_Task::permissionedTaskTitles($permission);
if (isset($this->_ssID)) {
if ($permission == CRM_Core_Permission::EDIT) {
require_once "CRM/Contact/Task.php";
$tasks = $tasks + CRM_Event_Task::optionalTaskTitle();
}
$savedSearchValues = array('id' => $this->_ssID, 'name' => CRM_Contact_BAO_SavedSearch::getName($this->_ssID, 'title'));
$this->assign_by_ref('savedSearch', $savedSearchValues);
$this->assign('ssID', $this->_ssID);
}
$this->add('select', 'task', ts('Actions:') . ' ', $tasks);
$this->add('submit', $this->_actionButtonName, ts('Go'), array('class' => 'form-submit', 'id' => 'Go', 'onclick' => "return checkPerformAction('mark_x', '" . $this->getName() . "', 0);"));
$this->add('submit', $this->_printButtonName, ts('Print'), array('class' => 'form-submit', 'onclick' => "return checkPerformAction('mark_x', '" . $this->getName() . "', 1);"));
// need to perform tasks on all or selected items ? using radio_ts(task selection) for it
$this->addElement('radio', 'radio_ts', null, '', 'ts_sel', array('checked' => 'checked'));
$this->addElement('radio', 'radio_ts', null, '', 'ts_all', array('onclick' => $this->getName() . ".toggleSelect.checked = false; toggleCheckboxVals('mark_x_',this); toggleTaskAction( true );"));
}
// add buttons
$this->addButtons(array(array('type' => 'refresh', 'name' => ts('Search'), 'isDefault' => true)));
}
示例11: emailReceipt
/**
* @param $params
*
* @return mixed
*/
function emailReceipt(&$params)
{
$updatedLineItem = CRM_Price_BAO_LineItem::getLineItems($this->_participantId, 'participant', NULL, FALSE);
$lineItem = array();
if ($updatedLineItem) {
$lineItem[] = $updatedLineItem;
}
$this->assign('lineItem', empty($lineItem) ? FALSE : $lineItem);
// offline receipt sending
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 (array_keys($participantRoles) as $roleId) {
$selectedRoles[] = $role[$roleId];
}
$event['participant_role'] = implode(', ', $selectedRoles);
} else {
$event['participant_role'] = CRM_Utils_Array::value($participantRoles, $role);
}
$event['is_monetary'] = $this->_isPaidEvent;
if ($params['receipt_text']) {
$event['confirm_email_text'] = $params['receipt_text'];
}
$this->assign('isAmountzero', 1);
$this->assign('event', $event);
$this->assign('isShowLocation', $event['is_show_location']);
if (CRM_Utils_Array::value('is_show_location', $event) == 1) {
$locationParams = array('entity_id' => $params['event_id'], 'entity_table' => 'civicrm_event');
$location = CRM_Core_BAO_Location::getValues($locationParams, TRUE);
$this->assign('location', $location);
}
$status = CRM_Event_PseudoConstant::participantStatus();
if ($this->_isPaidEvent) {
$paymentInstrument = CRM_Contribute_PseudoConstant::paymentInstrument();
if (!$this->_mode) {
if (isset($params['payment_instrument_id'])) {
$this->assign('paidBy', CRM_Utils_Array::value($params['payment_instrument_id'], $paymentInstrument));
}
}
$this->assign('totalAmount', $this->contributionAmt);
$this->assign('isPrimary', 1);
$this->assign('checkNumber', CRM_Utils_Array::value('check_number', $params));
}
$this->assign('register_date', $params['register_date']);
$template = CRM_Core_Smarty::singleton();
// Retrieve the name and email of the contact - this will be the TO for receipt email
list($this->_contributorDisplayName, $this->_contributorEmail, $this->_toDoNotEmail) = CRM_Contact_BAO_Contact::getContactDetails($this->_contactId);
$this->_contributorDisplayName = $this->_contributorDisplayName == ' ' ? $this->_contributorEmail : $this->_contributorDisplayName;
$waitStatus = CRM_Event_PseudoConstant::participantStatus(NULL, "class = 'Waiting'");
if ($waitingStatus = CRM_Utils_Array::value($params['status_id'], $waitStatus)) {
$this->assign('isOnWaitlist', TRUE);
}
$this->assign('contactID', $this->_contactId);
$this->assign('participantID', $this->_participantId);
$sendTemplateParams = array('groupName' => 'msg_tpl_workflow_event', 'valueName' => 'event_offline_receipt', 'contactId' => $this->_contactId, 'isTest' => FALSE, 'PDFFilename' => ts('confirmation') . '.pdf');
// try to send emails only if email id is present
// and the do-not-email option is not checked for that contact
if ($this->_contributorEmail && !$this->_toDoNotEmail) {
$sendTemplateParams['from'] = $receiptFrom;
$sendTemplateParams['toName'] = $this->_contributorDisplayName;
$sendTemplateParams['toEmail'] = $this->_contributorEmail;
$sendTemplateParams['cc'] = CRM_Utils_Array::value('cc', $this->_fromEmails);
$sendTemplateParams['bcc'] = CRM_Utils_Array::value('bcc', $this->_fromEmails);
}
list($mailSent, $subject, $message, $html) = CRM_Core_BAO_MessageTemplate::sendTemplate($sendTemplateParams);
return $mailSent;
}
示例12: submit
/**
* @param array $submittedValues
*
* @param int $action
* Action constant
* - CRM_Core_Action::UPDATE
*
* @param $pledgePaymentID
*
* @return array
* @throws \Exception
*/
protected function submit($submittedValues, $action, $pledgePaymentID)
{
$softParams = $softIDs = array();
$pId = $contribution = $isRelatedId = FALSE;
if (!empty($submittedValues['price_set_id']) && $action & CRM_Core_Action::UPDATE) {
$line = CRM_Price_BAO_LineItem::getLineItems($this->_id, 'contribution');
$lineID = key($line);
$priceSetId = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceField', CRM_Utils_Array::value('price_field_id', $line[$lineID]), 'price_set_id');
$quickConfig = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $priceSetId, 'is_quick_config');
if ($quickConfig) {
CRM_Price_BAO_LineItem::deleteLineItems($this->_id, 'civicrm_contribution');
}
}
// Process price set and get total amount and line items.
$lineItem = array();
$priceSetId = CRM_Utils_Array::value('price_set_id', $submittedValues);
if (empty($priceSetId) && !$this->_id) {
$this->_priceSetId = $priceSetId = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', 'default_contribution_amount', 'id', 'name');
$this->_priceSet = current(CRM_Price_BAO_PriceSet::getSetDetail($priceSetId));
$fieldID = key($this->_priceSet['fields']);
$fieldValueId = key($this->_priceSet['fields'][$fieldID]['options']);
$this->_priceSet['fields'][$fieldID]['options'][$fieldValueId]['amount'] = $submittedValues['total_amount'];
$submittedValues['price_' . $fieldID] = 1;
}
if ($priceSetId) {
CRM_Price_BAO_PriceSet::processAmount($this->_priceSet['fields'], $submittedValues, $lineItem[$priceSetId]);
// Unset tax amount for offline 'is_quick_config' contribution.
if ($this->_priceSet['is_quick_config'] && !array_key_exists($submittedValues['financial_type_id'], CRM_Core_PseudoConstant::getTaxRates())) {
unset($submittedValues['tax_amount']);
}
$submittedValues['total_amount'] = CRM_Utils_Array::value('amount', $submittedValues);
}
if ($this->_id) {
if ($this->_compId) {
if ($this->_context == 'participant') {
$pId = $this->_compId;
} elseif ($this->_context == 'membership') {
$isRelatedId = TRUE;
} else {
$pId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $this->_id, 'participant_id', 'contribution_id');
}
} else {
$contributionDetails = CRM_Contribute_BAO_Contribution::getComponentDetails($this->_id);
if (array_key_exists('membership', $contributionDetails)) {
$isRelatedId = TRUE;
} elseif (array_key_exists('participant', $contributionDetails)) {
$pId = $contributionDetails['participant'];
}
}
}
if (!$priceSetId && !empty($submittedValues['total_amount']) && $this->_id) {
// CRM-10117 update the line items for participants.
if ($pId) {
$entityTable = 'participant';
$entityID = $pId;
$isRelatedId = FALSE;
$participantParams = array('fee_amount' => $submittedValues['total_amount'], 'id' => $entityID);
CRM_Event_BAO_Participant::add($participantParams);
if (empty($this->_lineItems)) {
$this->_lineItems[] = CRM_Price_BAO_LineItem::getLineItems($entityID, 'participant', 1);
}
} else {
$entityTable = 'contribution';
$entityID = $this->_id;
}
$lineItems = CRM_Price_BAO_LineItem::getLineItems($entityID, $entityTable, NULL, TRUE, $isRelatedId);
foreach (array_keys($lineItems) as $id) {
$lineItems[$id]['id'] = $id;
}
$itemId = key($lineItems);
if ($itemId && !empty($lineItems[$itemId]['price_field_id'])) {
$this->_priceSetId = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceField', $lineItems[$itemId]['price_field_id'], 'price_set_id');
}
if ($this->_priceSetId && CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $this->_priceSetId, 'is_quick_config')) {
$lineItems[$itemId]['unit_price'] = $lineItems[$itemId]['line_total'] = CRM_Utils_Rule::cleanMoney(CRM_Utils_Array::value('total_amount', $submittedValues));
// Update line total and total amount with tax on edit.
$financialItemsId = CRM_Core_PseudoConstant::getTaxRates();
if (array_key_exists($submittedValues['financial_type_id'], $financialItemsId)) {
$lineItems[$itemId]['tax_rate'] = $financialItemsId[$submittedValues['financial_type_id']];
} else {
$lineItems[$itemId]['tax_rate'] = $lineItems[$itemId]['tax_amount'] = "";
$submittedValues['tax_amount'] = 'null';
}
if ($lineItems[$itemId]['tax_rate']) {
$lineItems[$itemId]['tax_amount'] = $lineItems[$itemId]['tax_rate'] / 100 * $lineItems[$itemId]['line_total'];
$submittedValues['total_amount'] = $lineItems[$itemId]['line_total'] + $lineItems[$itemId]['tax_amount'];
$submittedValues['tax_amount'] = $lineItems[$itemId]['tax_amount'];
}
//.........这里部分代码省略.........
示例13: setStatusMessage
/**
* @param $membership
* @param $endDate
* @param $receiptSend
* @param $membershipTypes
* @param $createdMemberships
* @param $isRecur
* @param $calcDates
* @param $mailSend
*/
protected function setStatusMessage($membership, $endDate, $receiptSend, $membershipTypes, $createdMemberships, $isRecur, $calcDates, $mailSend)
{
$statusMsg = '';
if ($this->_action & CRM_Core_Action::UPDATE) {
$statusMsg = $this->getStatusMessageForUpdate($membership, $endDate, $receiptSend);
} elseif ($this->_action & CRM_Core_Action::ADD) {
$statusMsg = $this->getStatusMessageForCreate($endDate, $receiptSend, $membershipTypes, $createdMemberships, $isRecur, $calcDates, $mailSend);
}
CRM_Core_Session::setStatus($statusMsg, ts('Complete'), 'success');
//CRM-15187
// display message when membership type is changed
if ($this->_action & CRM_Core_Action::UPDATE && $this->_id && !in_array($this->_memType, $this->_memTypeSelected)) {
$lineItem = CRM_Price_BAO_LineItem::getLineItems($this->_id, 'membership');
$maxID = max(array_keys($lineItem));
$lineItem = $lineItem[$maxID];
$membershipTypeDetails = $this->allMembershipTypeDetails[$membership->membership_type_id];
if ($membershipTypeDetails['financial_type_id'] != $lineItem['financial_type_id']) {
CRM_Core_Session::setStatus(ts('The financial types associated with the old and new membership types are different. You may want to edit the contribution associated with this membership to adjust its financial type.'), ts('Warning'));
}
if ($membershipTypeDetails['minimum_fee'] != $lineItem['line_total']) {
CRM_Core_Session::setStatus(ts('The cost of the old and new membership types are different. You may want to edit the contribution associated with this membership to adjust its amount.'), ts('Warning'));
}
}
}
示例14: initSet
static function initSet(&$form, $id, $entityTable = 'civicrm_event')
{
// get price info
if ($priceSetId = self::getFor($entityTable, $id)) {
if ($form->_action & CRM_Core_Action::UPDATE) {
$entityId = $entity = null;
switch ($entityTable) {
case 'civicrm_event':
$entity = 'participant';
$entityId = $form->_participantId;
break;
case 'civicrm_contribution_page':
case 'civicrm_contribution':
$entity = 'contribution';
$entityId = $form->_id;
break;
}
if ($entityId && $entity) {
require_once 'CRM/Price/BAO/LineItem.php';
$form->_values['line_items'] = CRM_Price_BAO_LineItem::getLineItems($entityId, $entity);
}
$required = false;
} else {
$required = true;
}
$form->_priceSetId = $priceSetId;
$priceSet = self::getSetDetail($priceSetId, $required);
$form->_priceSet = CRM_Utils_Array::value($priceSetId, $priceSet);
$form->_values['fee'] = CRM_Utils_Array::value($priceSetId, $priceSet);
$form->set('priceSetId', $form->_priceSetId);
$form->set('priceSet', $form->_priceSet);
return $priceSetId;
}
return false;
}
示例15: postProcess
/**
* Function to process the form
*
* @access public
*/
public function postProcess()
{
// get the submitted form values.
$params = $this->controller->exportValues($this->_name);
if ($this->_action & CRM_Core_Action::DELETE) {
require_once "CRM/Event/BAO/Participant.php";
if (CRM_Utils_Array::value('delete_participant', $params) == 2) {
$additionalId = CRM_Event_BAO_Participant::getAdditionalParticipantIds($this->_id);
$participantLinks = CRM_Event_BAO_Participant::getAdditionalParticipantUrl($additionalId);
}
if (CRM_Utils_Array::value('delete_participant', $params) == 1) {
$additionalIds = CRM_Event_BAO_Participant::getAdditionalParticipantIds($this->_id);
foreach ($additionalIds as $value) {
CRM_Event_BAO_Participant::deleteParticipant($value);
}
}
CRM_Event_BAO_Participant::deleteParticipant($this->_id);
if (!empty($participantLinks)) {
$status = ts('The following participants no longer have an event fee recorded. You can edit their registration and record a replacement contribution by clicking the links below:') . '<br>' . $participantLinks;
} else {
$status = "Selected Participants was deleted sucessfully.";
}
CRM_Core_Session::setStatus($status);
return;
}
// set the contact, when contact is selected
if (CRM_Utils_Array::value('contact_select_id', $params)) {
$this->_contactId = $params['contact_select_id'][1];
}
if ($this->_id) {
$params['id'] = $this->_id;
}
$config = CRM_Core_Config::singleton();
if ($this->_isPaidEvent) {
$contributionParams = array();
$lineItem = array();
$additionalParticipantDetails = array();
if ($this->_id && $this->_action & CRM_Core_Action::UPDATE && $this->_paymentId) {
$participantBAO = new CRM_Event_BAO_Participant();
$participantBAO->id = $this->_id;
$participantBAO->find(true);
$contributionParams['total_amount'] = $participantBAO->fee_amount;
$params['discount_id'] = null;
//re-enter the values for UPDATE mode
$params['fee_level'] = $params['amount_level'] = $participantBAO->fee_level;
$params['fee_amount'] = $participantBAO->fee_amount;
if (isset($params['priceSetId'])) {
require_once 'CRM/Price/BAO/LineItem.php';
$lineItem[0] = CRM_Price_BAO_LineItem::getLineItems($this->_id);
}
//also add additional participant's fee level/priceset
if (CRM_Event_BAO_Participant::isPrimaryParticipant($this->_id)) {
$additionalIds = CRM_Event_BAO_Participant::getAdditionalParticipantIds($this->_id);
$hasLineItems = CRM_Utils_Array::value('priceSetId', $params, false);
$additionalParticipantDetails = CRM_Event_BAO_Participant::getFeeDetails($additionalIds, $hasLineItems);
}
} else {
//check if discount is selected
if (CRM_Utils_Array::value('discount_id', $params)) {
$discountId = $params['discount_id'];
} else {
$discountId = $params['discount_id'] = 'null';
}
//lets carry currency, CRM-4453
$params['fee_currency'] = $config->defaultCurrency;
// fix for CRM-3088
if ($discountId && !empty($this->_values['discount'][$discountId])) {
$params['amount_level'] = $this->_values['discount'][$discountId][$params['amount']]['label'];
$params['amount'] = $this->_values['discount'][$discountId][$params['amount']]['value'];
} else {
if (!isset($params['priceSetId']) && CRM_Utils_Array::value('amount', $params)) {
$params['amount_level'] = $this->_values['fee'][$params['amount']]['label'];
$params['amount'] = $this->_values['fee'][$params['amount']]['value'];
} else {
CRM_Price_BAO_Set::processAmount($this->_values['fee'], $params, $lineItem[0]);
}
}
$params['fee_level'] = $params['amount_level'];
$contributionParams['total_amount'] = $params['amount'];
//fix for CRM-3086
$params['fee_amount'] = $params['amount'];
}
if (isset($params['priceSetId'])) {
$this->set('lineItem', $lineItem);
$this->_lineItem = $lineItem;
$lineItem = array_merge($lineItem, $additionalParticipantDetails);
$participantCount = array();
foreach ($lineItem as $k) {
foreach ($k as $v) {
if (CRM_Utils_Array::value('participant_count', $v) > 0) {
$participantCount[] = $v['participant_count'];
}
}
}
if ($participantCount) {
//.........这里部分代码省略.........