本文整理汇总了PHP中CRM_Price_BAO_PriceSet类的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Price_BAO_PriceSet类的具体用法?PHP CRM_Price_BAO_PriceSet怎么用?PHP CRM_Price_BAO_PriceSet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CRM_Price_BAO_PriceSet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addParticipantWithPayment
/**
* Helper function to record participant with paid contribution.
*
* @param int $feeTotal
* @param int $actualPaidAmt
*
* @return array
* @throws Exception
*/
protected function addParticipantWithPayment($feeTotal, $actualPaidAmt)
{
$priceSetId = $this->eventPriceSetCreate($feeTotal);
CRM_Price_BAO_PriceSet::addTo('civicrm_event', $this->_eventId, $priceSetId);
// create participant record
$eventId = $this->_eventId;
$participantParams = array('send_receipt' => 1, 'is_test' => 0, 'is_pay_later' => 0, 'event_id' => $eventId, 'register_date' => date('Y-m-d') . " 00:00:00", 'role_id' => 1, 'status_id' => 14, 'source' => 'Event_' . $eventId, 'contact_id' => $this->_contactId, 'note' => 'Note added for Event_' . $eventId, 'fee_level' => 'Price_Field - 55');
$participant = $this->callAPISuccess('participant', 'create', $participantParams);
$this->callAPISuccessGetSingle('participant', array('id' => $participant['id']));
// create participant contribution with partial payment
$contributionParams = array('total_amount' => $actualPaidAmt, 'source' => 'Fall Fundraiser Dinner: Offline registration', 'currency' => 'USD', 'non_deductible_amount' => 'null', 'receipt_date' => date('Y-m-d') . " 00:00:00", 'contact_id' => $this->_contactId, 'financial_type_id' => 4, 'payment_instrument_id' => 4, 'contribution_status_id' => 1, 'receive_date' => date('Y-m-d') . " 00:00:00", 'skipLineItem' => 1, 'partial_payment_total' => $feeTotal, 'partial_amount_pay' => $actualPaidAmt);
$contribution = CRM_Contribute_BAO_Contribution::create($contributionParams);
$contributionId = $contribution->id;
$participant = $this->callAPISuccessGetSingle('participant', array('id' => $participant['id']));
// add participant payment entry
$this->callAPISuccess('participant_payment', 'create', array('participant_id' => $participant['id'], 'contribution_id' => $contributionId));
// -- processing priceSet using the BAO
$lineItem = array();
$priceSet = CRM_Price_BAO_PriceSet::getSetDetail($priceSetId, TRUE, FALSE);
$priceSet = CRM_Utils_Array::value($priceSetId, $priceSet);
$feeBlock = CRM_Utils_Array::value('fields', $priceSet);
$params['price_2'] = $feeTotal;
CRM_Price_BAO_PriceSet::processAmount($feeBlock, $params, $lineItem);
$lineItemVal[$priceSetId] = $lineItem;
CRM_Price_BAO_LineItem::processPriceSet($participant['id'], $lineItemVal, $contribution, 'civicrm_participant');
return array($participant, $contribution);
}
示例2: postProcess
/**
* Process the form when submitted
*
* @return void
* @access public
*/
public function postProcess()
{
if (CRM_Price_BAO_PriceSet::deleteSet($this->_sid)) {
CRM_Core_Session::setStatus(ts('The Price Set \'%1\' has been deleted.', array(1 => $this->_title), ts('Deleted'), 'success'));
} else {
CRM_Core_Session::setStatus(ts('The Price Set \'%1\' has not been deleted! You must delete all price fields in this set prior to deleting the set.', array(1 => $this->_title)), 'Unable to Delete', 'error');
}
}
示例3: testGetAmountLevelTextAmount
/**
* Test the correct amount level is returned for an event which is not presented as a price set event.
*
* (these are denoted as 'quickConfig' in the code - but quickConfig is only supposed to refer to the
* configuration interface - there should be no different post process.
*/
public function testGetAmountLevelTextAmount()
{
$priceSetID = $this->eventPriceSetCreate(9);
$priceSet = CRM_Price_BAO_PriceSet::getCachedPriceSetDetail($priceSetID);
$field = reset($priceSet['fields']);
$params = array('priceSetId' => $priceSetID, 'price_' . $field['id'] => 1);
$amountLevel = CRM_Price_BAO_PriceSet::getAmountLevelText($params);
$this->assertEquals(CRM_Core_DAO::VALUE_SEPARATOR . 'Price Field - 1' . CRM_Core_DAO::VALUE_SEPARATOR, $amountLevel);
}
示例4: preProcess
/**
* Pre processing work done here.
*
* gets session variables for group or field id
*
* @return void
*/
public function preProcess()
{
// get the controller vars
$groupId = $this->get('groupId');
$fieldId = $this->get('fieldId');
if ($fieldId) {
$groupTree = CRM_Price_BAO_PriceSet::getSetDetail($groupId);
$this->_groupTree[$groupId]['fields'][$fieldId] = $groupTree[$groupId]['fields'][$fieldId];
$this->assign('preview_type', 'field');
$url = CRM_Utils_System::url('civicrm/admin/price/field', "reset=1&action=browse&sid={$groupId}");
$breadCrumb = array(array('title' => ts('Price Set Fields'), 'url' => $url));
} else {
// group preview
$this->_groupTree = CRM_Price_BAO_PriceSet::getSetDetail($groupId);
$this->assign('preview_type', 'group');
$this->assign('setTitle', CRM_Price_BAO_PriceSet::getTitle($groupId));
$url = CRM_Utils_System::url('civicrm/admin/price', 'reset=1');
$breadCrumb = array(array('title' => ts('Price Sets'), 'url' => $url));
}
CRM_Utils_System::appendBreadCrumb($breadCrumb);
}
示例5: _addParticipantWithPayment
function _addParticipantWithPayment($feeTotal, $actualPaidAmt)
{
// creating price set, price field
$paramsSet['title'] = 'Price Set';
$paramsSet['name'] = CRM_Utils_String::titleToVar('Price Set');
$paramsSet['is_active'] = FALSE;
$paramsSet['extends'] = 1;
$priceset = CRM_Price_BAO_PriceSet::create($paramsSet);
CRM_Price_BAO_PriceSet::addTo('civicrm_event', $this->_eventId, $priceset->id);
$priceSetId = $priceset->id;
//Checking for priceset added in the table.
$this->assertDBCompareValue('CRM_Price_BAO_PriceSet', $priceSetId, 'title', 'id', $paramsSet['title'], 'Check DB for created priceset');
$paramsField = array('label' => 'Price Field', 'name' => CRM_Utils_String::titleToVar('Price Field'), 'html_type' => 'Text', 'price' => $feeTotal, 'option_label' => array('1' => 'Price Field'), 'option_value' => array('1' => $feeTotal), 'option_name' => array('1' => $feeTotal), 'option_weight' => array('1' => 1), 'option_amount' => array('1' => 1), 'is_display_amounts' => 1, 'weight' => 1, 'options_per_line' => 1, 'is_active' => array('1' => 1), 'price_set_id' => $priceset->id, 'is_enter_qty' => 1);
$ids = array();
$pricefield = CRM_Price_BAO_PriceField::create($paramsField, $ids);
//Checking for priceset added in the table.
$this->assertDBCompareValue('CRM_Price_BAO_PriceField', $pricefield->id, 'label', 'id', $paramsField['label'], 'Check DB for created pricefield');
// create participant record
$eventId = $this->_eventId;
$participantParams = array('send_receipt' => 1, 'is_test' => 0, 'is_pay_later' => 0, 'event_id' => $eventId, 'register_date' => date('Y-m-d') . " 00:00:00", 'role_id' => 1, 'status_id' => 14, 'source' => 'Event_' . $eventId, 'contact_id' => $this->_contactId, 'note' => 'Note added for Event_' . $eventId, 'fee_level' => 'Price_Field - 55');
$participant = CRM_Event_BAO_Participant::add($participantParams);
// create participant contribution with partial payment
$contributionParams = array('total_amount' => $actualPaidAmt, 'source' => 'Fall Fundraiser Dinner: Offline registration', 'currency' => 'USD', 'non_deductible_amount' => 'null', 'receipt_date' => date('Y-m-d') . " 00:00:00", 'contact_id' => $this->_contactId, 'financial_type_id' => 4, 'payment_instrument_id' => 4, 'contribution_status_id' => 1, 'receive_date' => date('Y-m-d') . " 00:00:00", 'skipLineItem' => 1, 'partial_payment_total' => $feeTotal, 'partial_amount_pay' => $actualPaidAmt);
$contribution = CRM_Contribute_BAO_Contribution::create($contributionParams, CRM_Core_DAO::$_nullArray);
$contributionId = $contribution->id;
// add participant payment entry
$this->participantPaymentCreate($participant->id, $contributionId);
// -- processing priceSet using the BAO
$lineItem = array();
$priceSet = CRM_Price_BAO_PriceSet::getSetDetail($priceSetId, TRUE, FALSE);
$priceSet = CRM_Utils_Array::value($priceSetId, $priceSet);
$feeBlock = CRM_Utils_Array::value('fields', $priceSet);
$params['price_2'] = $feeTotal;
CRM_Price_BAO_PriceSet::processAmount($feeBlock, $params, $lineItem);
$lineItemVal[$priceSetId] = $lineItem;
CRM_Price_BAO_LineItem::processPriceSet($participant->id, $lineItemVal, $contribution, 'civicrm_participant');
return array($participant, $contribution);
}
示例6: postProcess
//.........这里部分代码省略.........
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);
}
} else {
//check if discount is selected
if (!empty($params['discount_id'])) {
$discountId = $params['discount_id'];
} else {
$discountId = $params['discount_id'] = 'null';
}
//lets carry currency, CRM-4453
$params['fee_currency'] = $config->defaultCurrency;
CRM_Price_BAO_PriceSet::processAmount($this->_values['fee'], $params, $lineItem[0]);
//CRM-11529 for quick config backoffice transactions
//when financial_type_id is passed in form, update the
//lineitems with the financial type selected in form
$submittedFinancialType = CRM_Utils_Array::value('financial_type_id', $params);
$isPaymentRecorded = CRM_Utils_Array::value('record_contribution', $params);
if ($isPaymentRecorded && $this->_quickConfig && $submittedFinancialType) {
foreach ($lineItem[0] as &$values) {
$values['financial_type_id'] = $submittedFinancialType;
}
}
$params['fee_level'] = $params['amount_level'];
$contributionParams['total_amount'] = $params['amount'];
if ($this->_quickConfig && !empty($params['total_amount']) && $params['status_id'] != array_search('Partially paid', $participantStatus)) {
$params['fee_amount'] = $params['total_amount'];
} else {
//fix for CRM-3086
$params['fee_amount'] = $params['amount'];
}
}
if (isset($params['priceSetId'])) {
if (!empty($lineItem[0])) {
$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'];
}
}
}
示例7: getPriceSetDetails
/**
* Get the details for the selected price set.
*
* @param array $params
* Parameters submitted to the form.
*
* @return array
*/
protected static function getPriceSetDetails($params)
{
$priceSetID = CRM_Utils_Array::value('price_set_id', $params);
if ($priceSetID) {
return CRM_Price_BAO_PriceSet::getSetDetail($priceSetID);
} else {
$priceSet = CRM_Price_BAO_PriceSet::getDefaultPriceSet('membership');
$priceSet = reset($priceSet);
return CRM_Price_BAO_PriceSet::getSetDetail($priceSet['setID']);
}
}
示例8: submit
//.........这里部分代码省略.........
} elseif ($fieldVal['name'] == 'contribution_amount' && $this->_submitValues['price_' . $fieldId] > 0) {
$proceFieldAmount += $fieldVal['options'][$this->_submitValues['price_' . $fieldId]]['amount'];
}
unset($params['price_' . $fieldId]);
break;
}
}
}
}
}
if (!isset($params['amount_other'])) {
$this->set('amount_level', CRM_Utils_Array::value('amount_level', $params));
}
if (!empty($this->_ccid)) {
$this->set('lineItem', $this->_lineItem);
} elseif ($priceSetId = CRM_Utils_Array::value('priceSetId', $params)) {
$lineItem = array();
$is_quick_config = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $priceSetId, 'is_quick_config');
if ($is_quick_config) {
foreach ($this->_values['fee'] as $key => &$val) {
if ($val['name'] == 'other_amount' && $val['html_type'] == 'Text' && !empty($params['price_' . $key])) {
// Clean out any currency symbols.
$params['price_' . $key] = CRM_Utils_Rule::cleanMoney($params['price_' . $key]);
if ($params['price_' . $key] != 0) {
foreach ($val['options'] as $optionKey => &$options) {
$options['amount'] = CRM_Utils_Array::value('price_' . $key, $params);
break;
}
}
$params['price_' . $key] = 1;
break;
}
}
}
$component = '';
if ($this->_membershipBlock) {
$component = 'membership';
}
CRM_Price_BAO_PriceSet::processAmount($this->_values['fee'], $params, $lineItem[$priceSetId], $component);
if ($params['tax_amount']) {
$this->set('tax_amount', $params['tax_amount']);
}
if ($proceFieldAmount) {
$lineItem[$params['priceSetId']][$fieldOption]['unit_price'] = $proceFieldAmount;
$lineItem[$params['priceSetId']][$fieldOption]['line_total'] = $proceFieldAmount;
if (isset($lineItem[$params['priceSetId']][$fieldOption]['tax_amount'])) {
$proceFieldAmount += $lineItem[$params['priceSetId']][$fieldOption]['tax_amount'];
}
if (!$this->_membershipBlock['is_separate_payment']) {
//require when separate membership not used
$params['amount'] = $proceFieldAmount;
}
}
$this->set('lineItem', $lineItem);
}
if ($params['amount'] != 0 && ($this->_values['is_pay_later'] && empty($this->_paymentProcessor) && !array_key_exists('hidden_processor', $params) || CRM_Utils_Array::value('payment_processor_id', $params) == 0)) {
$params['is_pay_later'] = 1;
} else {
$params['is_pay_later'] = 0;
}
// Would be nice to someday understand the point of this set.
$this->set('is_pay_later', $params['is_pay_later']);
// assign pay later stuff
$this->_params['is_pay_later'] = CRM_Utils_Array::value('is_pay_later', $params, FALSE);
$this->assign('is_pay_later', $params['is_pay_later']);
if ($params['is_pay_later']) {
$this->assign('pay_later_text', $this->_values['pay_later_text']);
$this->assign('pay_later_receipt', $this->_values['pay_later_receipt']);
}
if ($this->_membershipBlock['is_separate_payment'] && !empty($params['separate_amount'])) {
$this->set('amount', $params['separate_amount']);
} else {
$this->set('amount', $params['amount']);
}
// generate and set an invoiceID for this transaction
$invoiceID = md5(uniqid(rand(), TRUE));
$this->set('invoiceID', $invoiceID);
$params['invoiceID'] = $invoiceID;
$params['description'] = ts('Online Contribution') . ': ' . (!empty($this->_pcpInfo['title']) ? $this->_pcpInfo['title'] : $this->_values['title']);
$params['button'] = $this->controller->getButtonName();
// required only if is_monetary and valid positive amount
// @todo it seems impossible for $memFee to be greater than 0 & $params['amount'] not to
// be & by requiring $memFee down here we make it harder to do a sensible refactoring of the function
// above (ie. extract the amount in a small function).
if ($this->_values['is_monetary'] && !empty($this->_paymentProcessor) && ((double) $params['amount'] > 0.0 || $memFee > 0.0)) {
// The concept of contributeMode is deprecated - as should be the 'is_monetary' setting.
$this->setContributeMode();
// Really this setting of $this->_params & params within it should be done earlier on in the function
// probably the values determined here should be reused in confirm postProcess as there is no opportunity to alter anything
// on the confirm page. However as we are dealing with a stable release we go as close to where it is used
// as possible.
// In general the form has a lack of clarity of the logic of why things are set on the form in some cases &
// the logic around when $this->_params is used compared to other params arrays.
$this->_params = array_merge($params, $this->_params);
$this->setRecurringMembershipParams();
if ($this->_paymentProcessor && $this->_paymentProcessor['object']->supports('preApproval')) {
$this->handlePreApproval($this->_params);
}
}
}
示例9: setDefaultPriceSet
/**
* This function sets the default values for price set.
*
*
* @param int $participantID
* @param int $eventID
* @param bool $includeQtyZero
*
* @return void
*/
public static function setDefaultPriceSet($participantID, $eventID = NULL, $includeQtyZero = TRUE)
{
$defaults = array();
if (!$eventID && $participantID) {
$eventID = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', $participantID, 'event_id');
}
if (!$participantID || !$eventID) {
return $defaults;
}
// get price set ID.
$priceSetID = CRM_Price_BAO_PriceSet::getFor('civicrm_event', $eventID);
if (!$priceSetID) {
return $defaults;
}
// use line items for setdefault price set fields, CRM-4090
$lineItems[$participantID] = CRM_Price_BAO_LineItem::getLineItems($participantID, 'participant', NULL, $includeQtyZero);
if (is_array($lineItems[$participantID]) && !CRM_Utils_System::isNull($lineItems[$participantID])) {
$priceFields = $htmlTypes = $optionValues = array();
foreach ($lineItems[$participantID] as $lineId => $items) {
$priceFieldId = CRM_Utils_Array::value('price_field_id', $items);
$priceOptionId = CRM_Utils_Array::value('price_field_value_id', $items);
if ($priceFieldId && $priceOptionId) {
$priceFields[$priceFieldId][] = $priceOptionId;
}
}
if (empty($priceFields)) {
return $defaults;
}
// get all price set field html types.
$sql = '
SELECT id, html_type
FROM civicrm_price_field
WHERE id IN (' . implode(',', array_keys($priceFields)) . ')';
$fieldDAO = CRM_Core_DAO::executeQuery($sql);
while ($fieldDAO->fetch()) {
$htmlTypes[$fieldDAO->id] = $fieldDAO->html_type;
}
foreach ($lineItems[$participantID] as $lineId => $items) {
$fieldId = $items['price_field_id'];
$htmlType = CRM_Utils_Array::value($fieldId, $htmlTypes);
if (!$htmlType) {
continue;
}
if ($htmlType == 'Text') {
$defaults["price_{$fieldId}"] = $items['qty'];
} else {
$fieldOptValues = CRM_Utils_Array::value($fieldId, $priceFields);
if (!is_array($fieldOptValues)) {
continue;
}
foreach ($fieldOptValues as $optionId) {
if ($htmlType == 'CheckBox') {
$defaults["price_{$fieldId}"][$optionId] = TRUE;
} else {
$defaults["price_{$fieldId}"] = $optionId;
break;
}
}
}
}
}
return $defaults;
}
示例10: setQuickConfigMembershipParameters
/**
* Get line items representing the default price set.
*
* @param int $membershipOrg
* @param int $membershipTypeID
* @param float $total_amount
* @param int $priceSetId
*
* @return array
*/
public static function setQuickConfigMembershipParameters($membershipOrg, $membershipTypeID, $total_amount, $priceSetId)
{
$priceSets = current(CRM_Price_BAO_PriceSet::getSetDetail($priceSetId));
// The name of the price field corresponds to the membership_type organization contact.
$params = array('price_set_id' => $priceSetId, 'name' => $membershipOrg);
$results = array();
CRM_Price_BAO_PriceField::retrieve($params, $results);
if (!empty($results)) {
$fields[$results['id']] = $priceSets['fields'][$results['id']];
$fid = $results['id'];
$editedFieldParams = array('price_field_id' => $results['id'], 'membership_type_id' => $membershipTypeID);
$results = array();
CRM_Price_BAO_PriceFieldValue::retrieve($editedFieldParams, $results);
$fields[$fid]['options'][$results['id']] = $priceSets['fields'][$fid]['options'][$results['id']];
if (!empty($total_amount)) {
$fields[$fid]['options'][$results['id']]['amount'] = $total_amount;
}
}
$fieldID = key($fields);
$returnParams = array('price_set_id' => $priceSetId, 'price_sets' => $priceSets, 'fields' => $fields, 'price_fields' => array('price_' . $fieldID => CRM_Utils_Array::value('id', $results)));
return $returnParams;
}
示例11: createPriceSetWithPage
/**
* Create price set with contribution test for test setup.
*
* This could be merged with 4.5 function setup in api_v3_ContributionPageTest::setUpContributionPage
* on parent class at some point (fn is not in 4.4).
*
* @param $entity
* @param array $params
*/
public function createPriceSetWithPage($entity, $params = array())
{
$membershipTypeID = $this->membershipTypeCreate();
$contributionPageResult = $this->callAPISuccess('contribution_page', 'create', array('title' => "Test Contribution Page", 'financial_type_id' => 1, 'currency' => 'NZD', 'goal_amount' => 50, 'is_pay_later' => 1, 'is_monetary' => TRUE, 'is_email_receipt' => FALSE));
$priceSet = $this->callAPISuccess('price_set', 'create', array('is_quick_config' => 0, 'extends' => 'CiviMember', 'financial_type_id' => 1, 'title' => 'my Page'));
$priceSetID = $priceSet['id'];
CRM_Price_BAO_PriceSet::addTo('civicrm_contribution_page', $contributionPageResult['id'], $priceSetID);
$priceField = $this->callAPISuccess('price_field', 'create', array('price_set_id' => $priceSetID, 'label' => 'Goat Breed', 'html_type' => 'Radio'));
$priceFieldValue = $this->callAPISuccess('price_field_value', 'create', array('price_set_id' => $priceSetID, 'price_field_id' => $priceField['id'], 'label' => 'Long Haired Goat', 'amount' => 20, 'financial_type_id' => 'Donation', 'membership_type_id' => $membershipTypeID, 'membership_num_terms' => 1));
$this->_ids['price_field_value'] = array($priceFieldValue['id']);
$priceFieldValue = $this->callAPISuccess('price_field_value', 'create', array('price_set_id' => $priceSetID, 'price_field_id' => $priceField['id'], 'label' => 'Shoe-eating Goat', 'amount' => 10, 'financial_type_id' => 'Donation', 'membership_type_id' => $membershipTypeID, 'membership_num_terms' => 2));
$this->_ids['price_field_value'][] = $priceFieldValue['id'];
$this->_ids['price_set'] = $priceSetID;
$this->_ids['contribution_page'] = $contributionPageResult['id'];
$this->_ids['price_field'] = array($priceField['id']);
$this->_ids['membership_type'] = $membershipTypeID;
}
示例12: processMembership
/**
* process membership records
*
* @param array $params associated array of submitted values
*
* @access public
*
* @return bool
*/
private function processMembership(&$params)
{
$dateTypes = array('join_date' => 'joinDate', 'membership_start_date' => 'startDate', 'membership_end_date' => 'endDate');
$dates = array('join_date', 'start_date', 'end_date', 'reminder_date');
// get the price set associated with offline memebership
$priceSetId = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', 'default_membership_type_amount', 'id', 'name');
$this->_priceSet = $priceSets = current(CRM_Price_BAO_PriceSet::getSetDetail($priceSetId));
if (isset($params['field'])) {
$customFields = array();
foreach ($params['field'] as $key => $value) {
// if contact is not selected we should skip the row
if (empty($params['primary_contact_id'][$key])) {
continue;
}
$value['contact_id'] = CRM_Utils_Array::value($key, $params['primary_contact_id']);
// update contact information
$this->updateContactInfo($value);
$membershipTypeId = $value['membership_type_id'] = $value['membership_type'][1];
foreach ($dateTypes as $dateField => $dateVariable) {
${$dateVariable} = CRM_Utils_Date::processDate($value[$dateField]);
}
$calcDates = array();
$calcDates[$membershipTypeId] = CRM_Member_BAO_MembershipType::getDatesForMembershipType($membershipTypeId, $joinDate, $startDate, $endDate);
foreach ($calcDates as $memType => $calcDate) {
foreach ($dates as $d) {
//first give priority to form values then calDates.
$date = CRM_Utils_Array::value($d, $value);
if (!$date) {
$date = CRM_Utils_Array::value($d, $calcDate);
}
$value[$d] = CRM_Utils_Date::processDate($date);
}
}
if (!empty($value['send_receipt'])) {
$value['receipt_date'] = date('Y-m-d His');
}
if (!empty($value['membership_source'])) {
$value['source'] = $value['membership_source'];
}
unset($value['membership_source']);
//Get the membership status
if (!empty($value['membership_status'])) {
$value['status_id'] = $value['membership_status'];
unset($value['membership_status']);
}
if (empty($customFields)) {
// membership type custom data
$customFields = CRM_Core_BAO_CustomField::getFields('Membership', FALSE, FALSE, $membershipTypeId);
$customFields = CRM_Utils_Array::crmArrayMerge($customFields, CRM_Core_BAO_CustomField::getFields('Membership', FALSE, FALSE, NULL, NULL, TRUE));
}
//check for custom data
$value['custom'] = CRM_Core_BAO_CustomField::postProcess($params['field'][$key], $customFields, $key, 'Membership', $membershipTypeId);
if (!empty($value['financial_type'])) {
$value['financial_type_id'] = $value['financial_type'];
}
if (!empty($value['payment_instrument'])) {
$value['payment_instrument_id'] = $value['payment_instrument'];
}
// handle soft credit
if (is_array(CRM_Utils_Array::value('soft_credit_contact_id', $params)) && !empty($params['soft_credit_contact_id'][$key]) && CRM_Utils_Array::value($key, $params['soft_credit_amount'])) {
$value['soft_credit'][$key]['contact_id'] = $params['soft_credit_contact_id'][$key];
$value['soft_credit'][$key]['amount'] = CRM_Utils_Rule::cleanMoney($params['soft_credit_amount'][$key]);
}
if (!empty($value['receive_date'])) {
$value['receive_date'] = CRM_Utils_Date::processDate($value['receive_date'], $value['receive_date_time'], TRUE);
}
$params['actualBatchTotal'] += $value['total_amount'];
unset($value['financial_type']);
unset($value['payment_instrument']);
$value['batch_id'] = $this->_batchId;
$value['skipRecentView'] = TRUE;
// make entry in line item for contribution
$editedFieldParams = array('price_set_id' => $priceSetId, 'name' => $value['membership_type'][0]);
$editedResults = array();
CRM_Price_BAO_PriceField::retrieve($editedFieldParams, $editedResults);
if (!empty($editedResults)) {
unset($this->_priceSet['fields']);
$this->_priceSet['fields'][$editedResults['id']] = $priceSets['fields'][$editedResults['id']];
unset($this->_priceSet['fields'][$editedResults['id']]['options']);
$fid = $editedResults['id'];
$editedFieldParams = array('price_field_id' => $editedResults['id'], 'membership_type_id' => $value['membership_type_id']);
$editedResults = array();
CRM_Price_BAO_PriceFieldValue::retrieve($editedFieldParams, $editedResults);
$this->_priceSet['fields'][$fid]['options'][$editedResults['id']] = $priceSets['fields'][$fid]['options'][$editedResults['id']];
if (!empty($value['total_amount'])) {
$this->_priceSet['fields'][$fid]['options'][$editedResults['id']]['amount'] = $value['total_amount'];
}
$fieldID = key($this->_priceSet['fields']);
$value['price_' . $fieldID] = $editedResults['id'];
$lineItem = array();
CRM_Price_BAO_PriceSet::processAmount($this->_priceSet['fields'], $value, $lineItem[$priceSetId]);
//.........这里部分代码省略.........
示例13: usesPriceSet
/**
* This is sometimes called in a loop (during event search)
* hence we cache the values to prevent repeated calls to the db
*/
static function usesPriceSet($id)
{
static $usesPriceSet = array();
if (!array_key_exists($id, $usesPriceSet)) {
$usesPriceSet[$id] = CRM_Price_BAO_PriceSet::getFor('civicrm_event', $id);
}
return $usesPriceSet[$id];
}
示例14: postProcess
/**
* Process the form submission.
*
*
* @return void
*/
public function postProcess()
{
//get the button name.
$button = substr($this->controller->getButtonName(), -4);
//take the participant instance.
$addParticipantNum = substr($this->_name, 12);
//user submitted params.
$params = $this->controller->exportValues($this->_name);
if (!$this->_allowConfirmation) {
// check if the participant is already registered
$params['contact_id'] = CRM_Event_Form_Registration_Register::checkRegistration($params, $this, TRUE, TRUE);
}
//carry campaign to partcipants.
if (array_key_exists('participant_campaign_id', $params)) {
$params['campaign_id'] = $params['participant_campaign_id'];
} else {
$params['campaign_id'] = CRM_Utils_Array::value('campaign_id', $this->_values['event']);
}
// if waiting is enabled
if (!$this->_allowConfirmation && is_numeric($this->_availableRegistrations)) {
$this->_allowWaitlist = FALSE;
//get the current page count.
$currentCount = self::getParticipantCount($this, $params);
if ($button == 'skip') {
$currentCount = 'skip';
}
//get the total count.
$previousCount = self::getParticipantCount($this, $this->_params, TRUE);
$totalParticipants = $previousCount;
if (is_numeric($currentCount)) {
$totalParticipants += $currentCount;
}
if (!empty($this->_values['event']['has_waitlist']) && $totalParticipants > $this->_availableRegistrations) {
$this->_allowWaitlist = TRUE;
}
$this->set('allowWaitlist', $this->_allowWaitlist);
$this->_lineItemParticipantsCount[$addParticipantNum] = $currentCount;
}
if ($button == 'skip') {
//hack for free/zero amount event.
if ($this->_resetAllowWaitlist) {
$this->_allowWaitlist = FALSE;
$this->set('allowWaitlist', FALSE);
if ($this->_requireApproval) {
$status = ts("You have skipped last participant and which result into event having enough spaces, but your registration require approval, Once your registration has been reviewed, you will receive an email with a link to a web page where you can complete the registration process.");
} else {
$status = ts("You have skipped last participant and which result into event having enough spaces, hence your group become as register participants though you selected on wait list.");
}
CRM_Core_Session::setStatus($status);
}
$this->_params[$addParticipantNum] = 'skip';
if (isset($this->_lineItem)) {
$this->_lineItem[$addParticipantNum] = 'skip';
$this->_lineItemParticipantsCount[$addParticipantNum] = 'skip';
}
} else {
$config = CRM_Core_Config::singleton();
$params['currencyID'] = $config->defaultCurrency;
if ($this->_values['event']['is_monetary']) {
//added for discount
$discountId = CRM_Core_BAO_Discount::findSet($this->_eventId, 'civicrm_event');
if (!empty($this->_values['discount'][$discountId])) {
$params['discount_id'] = $discountId;
$params['amount_level'] = $this->_values['discount'][$discountId][$params['amount']]['label'];
$params['amount'] = $this->_values['discount'][$discountId][$params['amount']]['value'];
} elseif (empty($params['priceSetId'])) {
$params['amount_level'] = $this->_values['fee'][$params['amount']]['label'];
$params['amount'] = $this->_values['fee'][$params['amount']]['value'];
} else {
$lineItem = array();
CRM_Price_BAO_PriceSet::processAmount($this->_values['fee'], $params, $lineItem);
//build line item array..
//if requireApproval/waitlist is enabled we hide fees for primary participant
// (and not for additional participant which might be is a bug)
//lineItem are not correctly build for primary participant
//this results in redundancy since now lineItems for additional participant will be build against primary participantNum
//therefore lineItems must always be build against current participant No
$this->_lineItem[$addParticipantNum] = $lineItem;
}
}
if (array_key_exists('participant_role', $params)) {
$params['participant_role_id'] = $params['participant_role'];
}
if (empty($params['participant_role_id']) && $this->_values['event']['default_role_id']) {
$params['participant_role_id'] = $this->_values['event']['default_role_id'];
}
if (!empty($this->_params[0]['is_pay_later'])) {
$params['is_pay_later'] = 1;
}
//carry additional participant id, contact id if pre-registered.
if ($this->_allowConfirmation && $this->_additionalParticipantId) {
$params['contact_id'] = $this->_contactId;
$params['participant_id'] = $this->_additionalParticipantId;
}
//.........这里部分代码省略.........
示例15: preProcess
//.........这里部分代码省略.........
$ppIds = explode(CRM_Core_DAO::VALUE_SEPARATOR, $ppID);
$this->_paymentProcessors = CRM_Financial_BAO_PaymentProcessor::getPayments($ppIds, $this->_mode);
$this->set('paymentProcessors', $this->_paymentProcessors);
//set default payment processor
if (!empty($this->_paymentProcessors) && empty($this->_paymentProcessor)) {
foreach ($this->_paymentProcessors as $ppId => $values) {
if ($values['is_default'] == 1 || count($this->_paymentProcessors) == 1) {
$defaultProcessorId = $ppId;
break;
}
}
}
if (isset($defaultProcessorId)) {
$this->_paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getPayment($defaultProcessorId, $this->_mode);
$this->assign_by_ref('paymentProcessor', $this->_paymentProcessor);
}
if (!CRM_Utils_System::isNull($this->_paymentProcessors)) {
foreach ($this->_paymentProcessors as $eachPaymentProcessor) {
// check selected payment processor is active
if (empty($eachPaymentProcessor)) {
CRM_Core_Error::fatal(ts('A payment processor configured for this page might be disabled (contact the site administrator for assistance).'));
}
// ensure that processor has a valid config
$this->_paymentObject =& CRM_Core_Payment::singleton($this->_mode, $eachPaymentProcessor, $this);
$error = $this->_paymentObject->checkConfig();
if (!empty($error)) {
CRM_Core_Error::fatal($error);
}
}
}
}
// get price info
// CRM-5095
CRM_Price_BAO_PriceSet::initSet($this, $this->_id, 'civicrm_contribution_page');
// this avoids getting E_NOTICE errors in php
$setNullFields = array('amount_block_is_active', 'honor_block_is_active', 'is_allow_other_amount', 'footer_text');
foreach ($setNullFields as $f) {
if (!isset($this->_values[$f])) {
$this->_values[$f] = NULL;
}
}
//check if Membership Block is enabled, if Membership Fields are included in profile
//get membership section for this contribution page
$this->_membershipBlock = CRM_Member_BAO_Membership::getMembershipBlock($this->_id);
$this->set('membershipBlock', $this->_membershipBlock);
if ($this->_values['custom_pre_id']) {
$preProfileType = CRM_Core_BAO_UFField::getProfileType($this->_values['custom_pre_id']);
}
if ($this->_values['custom_post_id']) {
$postProfileType = CRM_Core_BAO_UFField::getProfileType($this->_values['custom_post_id']);
}
if ((isset($postProfileType) && $postProfileType == 'Membership' || isset($preProfileType) && $preProfileType == 'Membership') && !$this->_membershipBlock['is_active']) {
CRM_Core_Error::fatal(ts('This page includes a Profile with Membership fields - but the Membership Block is NOT enabled. Please notify the site administrator.'));
}
$pledgeBlock = CRM_Pledge_BAO_PledgeBlock::getPledgeBlock($this->_id);
if ($pledgeBlock) {
$this->_values['pledge_block_id'] = CRM_Utils_Array::value('id', $pledgeBlock);
$this->_values['max_reminders'] = CRM_Utils_Array::value('max_reminders', $pledgeBlock);
$this->_values['initial_reminder_day'] = CRM_Utils_Array::value('initial_reminder_day', $pledgeBlock);
$this->_values['additional_reminder_day'] = CRM_Utils_Array::value('additional_reminder_day', $pledgeBlock);
//set pledge id in values
$pledgeId = CRM_Utils_Request::retrieve('pledgeId', 'Positive', $this);
//authenticate pledge user for pledge payment.
if ($pledgeId) {
$this->_values['pledge_id'] = $pledgeId;
//lets override w/ pledge campaign.