本文整理汇总了PHP中CRM_Price_BAO_Set::getSetDetail方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Price_BAO_Set::getSetDetail方法的具体用法?PHP CRM_Price_BAO_Set::getSetDetail怎么用?PHP CRM_Price_BAO_Set::getSetDetail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Price_BAO_Set
的用法示例。
在下文中一共展示了CRM_Price_BAO_Set::getSetDetail方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: preProcess
/**
* pre processing work done here.
*
* gets session variables for group or field id
*
* @param null
*
* @return void
* @access public
*/
function preProcess()
{
// get the controller vars
$groupId = $this->get('groupId');
$fieldId = $this->get('fieldId');
if ($fieldId) {
require_once 'CRM/Price/BAO/Set.php';
$groupTree = CRM_Price_BAO_Set::getSetDetail($groupId);
$this->_groupTree[$groupId]['fields'][$fieldId] = $groupTree[$groupId]['fields'][$fieldId];
$this->assign('preview_type', 'field');
} else {
// group preview
require_once 'CRM/Price/BAO/Set.php';
$this->_groupTree = CRM_Price_BAO_Set::getSetDetail($groupId);
$this->assign('preview_type', 'group');
}
}
示例2: build_price_options
function build_price_options($event)
{
$price_fields_for_event = array();
$base_field_name = "event_{$event->id}_amount";
$price_set_id = CRM_Price_BAO_Set::getFor('civicrm_event', $event->id);
if ($price_set_id) {
$price_sets = CRM_Price_BAO_Set::getSetDetail($price_set_id, TRUE, TRUE);
$price_set = $price_sets[$price_set_id];
$index = -1;
foreach ($price_set['fields'] as $field) {
$index++;
$field_name = "event_{$event->id}_price_{$field['id']}";
CRM_Price_BAO_Field::addQuickFormElement($this, $field_name, $field['id'], FALSE);
$price_fields_for_event[] = $field_name;
}
}
return $price_fields_for_event;
}
示例3: preProcess
/**
* pre processing work done here.
*
* gets session variables for group or field id
*
* @param null
*
* @return void
* @access public
*/
function preProcess()
{
// get the controller vars
$groupId = $this->get('groupId');
$fieldId = $this->get('fieldId');
if ($fieldId) {
$groupTree = CRM_Price_BAO_Set::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_Set::getSetDetail($groupId);
$this->assign('preview_type', 'group');
$this->assign('setTitle', CRM_Price_BAO_Set::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);
}
示例4: processMembership
/**
* process membership records
*
* @param array $params associated array of submitted values
*
* @access public
*
* @return None
*/
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_Set', 'default_membership_type_amount', 'id', 'name');
$this->_priceSet = $priceSets = current(CRM_Price_BAO_Set::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 (!CRM_Utils_Array::value($key, $params['primary_contact_select_id'])) {
continue;
}
$value['contact_id'] = CRM_Utils_Array::value($key, $params['primary_contact_select_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 (CRM_Utils_Array::value('send_receipt', $value)) {
$value['receipt_date'] = date('Y-m-d His');
}
if (CRM_Utils_Array::value('membership_source', $value)) {
$value['source'] = $value['membership_source'];
}
unset($value['membership_source']);
//Get the membership status
if (CRM_Utils_Array::value('membership_status', $value)) {
$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 (CRM_Utils_Array::value('contribution_type', $value)) {
$value['contribution_type_id'] = $value['contribution_type'];
}
if (CRM_Utils_Array::value('payment_instrument', $value)) {
$value['payment_instrument_id'] = $value['payment_instrument'];
}
// handle soft credit
if (CRM_Utils_Array::value('soft_credit_contact_select_id', $params) && CRM_Utils_Array::value($key, $params['soft_credit_contact_select_id'])) {
$value['soft_credit_to'] = $params['soft_credit_contact_select_id'][$key];
}
if (CRM_Utils_Array::value('receive_date', $value)) {
$value['receive_date'] = CRM_Utils_Date::processDate($value['receive_date'], $value['receive_date_time'], TRUE);
}
$params['actualBatchTotal'] += $value['total_amount'];
unset($value['contribution_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_Field::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_FieldValue::retrieve($editedFieldParams, $editedResults);
$this->_priceSet['fields'][$fid]['options'][$editedResults['id']] = $priceSets['fields'][$fid]['options'][$editedResults['id']];
if (CRM_Utils_Array::value('total_amount', $value)) {
$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_Set::processAmount($this->_priceSet['fields'], $value, $lineItem[$priceSetId]);
$value['lineItems'] = $lineItem;
//.........这里部分代码省略.........
示例5: run
/**
* Run the page.
*
* This method is called after the page is created. It checks for the
* type of action and executes that action.
* Finally it calls the parent's run method.
*
* @return void
* @access public
*
*/
function run()
{
//get the event id.
$this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this, true);
$config =& CRM_Core_Config::singleton();
require_once 'CRM/Event/BAO/Event.php';
// ensure that the user has permission to see this page
if (!CRM_Core_Permission::event(CRM_Core_Permission::VIEW, $this->_id)) {
CRM_Core_Error::fatal(ts('You do not have permission to view this event'));
}
$action = CRM_Utils_Request::retrieve('action', 'String', $this, false);
$context = CRM_Utils_Request::retrieve('context', 'String', $this, false, 'register');
$this->assign('context', $context);
// Sometimes we want to suppress the Event Full msg
$noFullMsg = CRM_Utils_Request::retrieve('noFullMsg', 'String', $this, false, 'false');
// set breadcrumb to append to 2nd layer pages
$breadCrumbPath = CRM_Utils_System::url("civicrm/event/info", "id={$this->_id}&reset=1");
$additionalBreadCrumb = "<a href=\"{$breadCrumbPath}\">" . ts('Events') . '</a>';
//retrieve event information
$params = array('id' => $this->_id);
CRM_Event_BAO_Event::retrieve($params, $values['event']);
if (!$values['event']['is_active']) {
// form is inactive, die a fatal death
CRM_Core_Error::fatal(ts('The page you requested is currently unavailable.'));
}
$this->assign('isShowLocation', CRM_Utils_Array::value('is_show_location', $values['event']));
// show event fees.
require_once 'CRM/Price/BAO/Set.php';
if ($this->_id && CRM_Utils_Array::value('is_monetary', $values['event'])) {
// get price set options, - CRM-5209
if ($priceSetId = CRM_Price_BAO_Set::getFor('civicrm_event', $this->_id)) {
$setDetails = CRM_Price_BAO_Set::getSetDetail($priceSetId);
eval("\$priceSetFields = \$setDetails[{$priceSetId}][fields];");
if (is_array($priceSetFields)) {
$fieldCnt = 1;
foreach ($priceSetFields as $fid => $fieldValues) {
if (!is_array($fieldValues['options']) || empty($fieldValues['options'])) {
continue;
}
foreach ($fieldValues['options'] as $optionId => $optionVal) {
$values['feeBlock']['value'][$fieldCnt] = $optionVal['value'];
$values['feeBlock']['label'][$fieldCnt] = $optionVal['description'];
$fieldCnt++;
}
}
}
} else {
//retrieve event fee block.
require_once 'CRM/Core/OptionGroup.php';
require_once 'CRM/Core/BAO/Discount.php';
$discountId = CRM_Core_BAO_Discount::findSet($this->_id, 'civicrm_event');
if ($discountId) {
CRM_Core_OptionGroup::getAssoc(CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Discount', $discountId, 'option_group_id'), $values['feeBlock'], false, 'id');
} else {
CRM_Core_OptionGroup::getAssoc("civicrm_event.amount.{$this->_id}", $values['feeBlock']);
}
}
}
$params = array('entity_id' => $this->_id, 'entity_table' => 'civicrm_event');
require_once 'CRM/Core/BAO/Location.php';
$values['location'] = CRM_Core_BAO_Location::getValues($params, true);
//retrieve custom field information
require_once 'CRM/Core/BAO/CustomGroup.php';
$groupTree =& CRM_Core_BAO_CustomGroup::getTree("Event", $this, $this->_id, 0, $values['event']['event_type_id']);
CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree);
$this->assign('action', CRM_Core_Action::VIEW);
//To show the event location on maps directly on event info page
$locations =& CRM_Event_BAO_Event::getMapInfo($this->_id);
if (!empty($locations) && CRM_Utils_Array::value('is_map', $values['event'])) {
$this->assign('locations', $locations);
$this->assign('mapProvider', $config->mapProvider);
$this->assign('mapKey', $config->mapAPIKey);
$sumLat = $sumLng = 0;
$maxLat = $maxLng = -400;
$minLat = $minLng = +400;
foreach ($locations as $location) {
$sumLat += $location['lat'];
$sumLng += $location['lng'];
if ($location['lat'] > $maxLat) {
$maxLat = $location['lat'];
}
if ($location['lat'] < $minLat) {
$minLat = $location['lat'];
}
if ($location['lng'] > $maxLng) {
$maxLng = $location['lng'];
}
if ($location['lng'] < $minLng) {
$minLng = $location['lng'];
//.........这里部分代码省略.........
示例6: run
/**
* Run the page.
*
* This method is called after the page is created. It checks for the
* type of action and executes that action.
* Finally it calls the parent's run method.
*
* @return void
* @access public
*
*/
function run()
{
//get the event id.
$this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE);
$config = CRM_Core_Config::singleton();
// ensure that the user has permission to see this page
if (!CRM_Core_Permission::event(CRM_Core_Permission::VIEW, $this->_id)) {
CRM_Utils_System::setUFMessage(ts('You do not have permission to view this event'));
return CRM_Utils_System::permissionDenied();
}
$action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE);
$context = CRM_Utils_Request::retrieve('context', 'String', $this, FALSE, 'register');
$this->assign('context', $context);
// Sometimes we want to suppress the Event Full msg
$noFullMsg = CRM_Utils_Request::retrieve('noFullMsg', 'String', $this, FALSE, 'false');
// set breadcrumb to append to 2nd layer pages
$breadCrumbPath = CRM_Utils_System::url('civicrm/event/info', "id={$this->_id}&reset=1");
$additionalBreadCrumb = "<a href=\"{$breadCrumbPath}\">" . ts('Events') . '</a>';
//retrieve event information
$params = array('id' => $this->_id);
CRM_Event_BAO_Event::retrieve($params, $values['event']);
if (!$values['event']['is_active']) {
// form is inactive, die a fatal death
CRM_Core_Error::fatal(ts('The page you requested is currently unavailable.'));
}
if (!empty($values['event']['is_template'])) {
// form is an Event Template
CRM_Core_Error::fatal(ts('The page you requested is currently unavailable.'));
}
$this->assign('isShowLocation', CRM_Utils_Array::value('is_show_location', $values['event']));
// show event fees.
if ($this->_id && CRM_Utils_Array::value('is_monetary', $values['event'])) {
//CRM-6907
$config = CRM_Core_Config::singleton();
$config->defaultCurrency = CRM_Utils_Array::value('currency', $values['event'], $config->defaultCurrency);
//CRM-10434
$discountId = CRM_Core_BAO_Discount::findSet($this->_id, 'civicrm_event');
if ($discountId) {
$priceSetId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Discount', $discountId, 'option_group_id');
} else {
$priceSetId = CRM_Price_BAO_Set::getFor('civicrm_event', $this->_id);
}
// get price set options, - CRM-5209
if ($priceSetId) {
$setDetails = CRM_Price_BAO_Set::getSetDetail($priceSetId, TRUE, TRUE);
$priceSetFields = $setDetails[$priceSetId]['fields'];
if (is_array($priceSetFields)) {
$fieldCnt = 1;
$visibility = CRM_Core_PseudoConstant::visibility('name');
foreach ($priceSetFields as $fid => $fieldValues) {
if (!is_array($fieldValues['options']) || empty($fieldValues['options']) || CRM_Utils_Array::value('visibility_id', $fieldValues) != array_search('public', $visibility)) {
continue;
}
if (count($fieldValues['options']) > 1) {
$values['feeBlock']['value'][$fieldCnt] = '';
$values['feeBlock']['label'][$fieldCnt] = $fieldValues['label'];
$values['feeBlock']['lClass'][$fieldCnt] = 'price_set_option_group-label';
$values['feeBlock']['isDisplayAmount'][$fieldCnt] = CRM_Utils_Array::value('is_display_amounts', $fieldValues);
$fieldCnt++;
$labelClass = 'price_set_option-label';
} else {
$labelClass = 'price_set_field-label';
}
foreach ($fieldValues['options'] as $optionId => $optionVal) {
$values['feeBlock']['isDisplayAmount'][$fieldCnt] = CRM_Utils_Array::value('is_display_amounts', $fieldValues);
$values['feeBlock']['value'][$fieldCnt] = $optionVal['amount'];
$values['feeBlock']['label'][$fieldCnt] = $optionVal['label'];
$values['feeBlock']['lClass'][$fieldCnt] = $labelClass;
$fieldCnt++;
}
}
}
// Tell tpl we have price set fee data and whether it's a quick_config price set
$this->assign('isPriceSet', 1);
$this->assign('isQuickConfig', $setDetails[$priceSetId]['is_quick_config']);
}
}
$params = array('entity_id' => $this->_id, 'entity_table' => 'civicrm_event');
$values['location'] = CRM_Core_BAO_Location::getValues($params, TRUE);
//retrieve custom field information
$groupTree = CRM_Core_BAO_CustomGroup::getTree('Event', $this, $this->_id, 0, $values['event']['event_type_id']);
CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree);
$this->assign('action', CRM_Core_Action::VIEW);
//To show the event location on maps directly on event info page
$locations = CRM_Event_BAO_Event::getMapInfo($this->_id);
if (!empty($locations) && CRM_Utils_Array::value('is_map', $values['event'])) {
$this->assign('locations', $locations);
$this->assign('mapProvider', $config->mapProvider);
$this->assign('mapKey', $config->mapAPIKey);
//.........这里部分代码省略.........
示例7: setColumns
function setColumns()
{
$this->_columns = array(ts('Contact Id') => 'contact_id', ts('Participant Id') => 'participant_id', ts('Name') => 'display_name');
if (!$this->_eventID) {
return;
}
// for the selected event, find the price set and all the columns associated with it.
// create a column for each field and option group within it
$dao = $this->priceSetDAO($this->_formValues['event_id']);
if ($dao->fetch() && !$dao->price_set_id) {
CRM_Core_Error::fatal(ts('There are no events with Price Sets'));
}
// get all the fields and all the option values associated with it
$priceSet = CRM_Price_BAO_Set::getSetDetail($dao->price_set_id);
if (is_array($priceSet[$dao->price_set_id])) {
foreach ($priceSet[$dao->price_set_id]['fields'] as $key => $value) {
if (is_array($value['options'])) {
foreach ($value['options'] as $oKey => $oValue) {
$columnHeader = CRM_Utils_Array::value('label', $value);
if (CRM_Utils_Array::value('html_type', $value) != 'Text') {
$columnHeader .= ' - ' . $oValue['label'];
}
$this->_columns[$columnHeader] = "price_field_{$oValue['id']}";
}
}
}
}
}
示例8: setColumns
function setColumns()
{
$this->_columns = array(ts('Contact Id') => 'contact_id', ts('Participant Id') => 'participant_id', ts('Name') => 'display_name');
if (!$this->_eventID) {
return;
}
// for the selected event, find the price set and all the columns associated with it.
// create a column for each field and option group within it
$dao = $this->priceSetDAO($this->_formValues['event_id']);
if ($dao->fetch() && !$dao->price_set_id) {
CRM_Core_Error::fatal(ts('There are no events with Price Sets'));
}
// get all the fields and all the option values associated with it
require_once 'CRM/Price/BAO/Set.php';
$priceSet = CRM_Price_BAO_Set::getSetDetail($dao->price_set_id);
if (is_array($priceSet[$dao->price_set_id])) {
foreach ($priceSet[$dao->price_set_id]['fields'] as $key => $value) {
if (is_array($value['options'])) {
foreach ($value['options'] as $oKey => $oValue) {
$this->_columns[$oValue['description']] = "price_field_{$oValue['id']}";
}
}
}
}
}
示例9: setDefaultValues
/**
* This function sets the default values for the form. For edit/view mode
* the default values are retrieved from the database
*
* @access public
*
* @return None
*/
function setDefaultValues()
{
$parentDefaults = parent::setDefaultValues();
$eventId = $this->_id;
$params = array();
$defaults = array();
if (isset($eventId)) {
$params = array('id' => $eventId);
}
CRM_Event_BAO_Event::retrieve($params, $defaults);
if (isset($eventId)) {
$price_set_id = CRM_Price_BAO_Set::getFor('civicrm_event', $eventId, NULL, 1);
if ($price_set_id) {
$defaults['price_set_id'] = $price_set_id;
} else {
$priceSetId = CRM_Price_BAO_Set::getFor('civicrm_event', $eventId, NULL);
if ($priceSetId) {
if ($isQuick = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_Set', $priceSetId, 'is_quick_config')) {
$this->assign('isQuick', $isQuick);
$priceField = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_Field', $priceSetId, 'id', 'price_set_id');
$options = array();
$priceFieldOptions = CRM_Price_BAO_FieldValue::getValues($priceField, $options, 'weight', true);
$defaults['price_field_id'] = $priceField;
$countRow = 0;
foreach ($options as $optionId => $optionValue) {
$countRow++;
$defaults['value'][$countRow] = $optionValue['amount'];
$defaults['label'][$countRow] = $optionValue['label'];
$defaults['name'][$countRow] = $optionValue['name'];
$defaults['weight'][$countRow] = $optionValue['weight'];
$defaults["price_field_value"][$countRow] = $optionValue['id'];
if ($optionValue['is_default']) {
$defaults['default'] = $countRow;
}
}
}
}
}
}
//check if discounted
$discountedEvent = CRM_Core_BAO_Discount::getOptionGroup($this->_id, "civicrm_event");
if (!empty($discountedEvent)) {
$defaults['is_discount'] = $i = 1;
$totalLables = $maxSize = $defaultDiscounts = array();
foreach ($discountedEvent as $optionGroupId) {
$defaults["discount_price_set"][] = $optionGroupId;
$name = $defaults["discount_name[{$i}]"] = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_Set', $optionGroupId, 'title');
list($defaults["discount_start_date[{$i}]"]) = CRM_Utils_Date::setDateDefaults(CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Discount', $optionGroupId, 'start_date', 'option_group_id'));
list($defaults["discount_end_date[{$i}]"]) = CRM_Utils_Date::setDateDefaults(CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Discount', $optionGroupId, 'end_date', 'option_group_id'));
$defaultDiscounts[] = CRM_Price_BAO_Set::getSetDetail($optionGroupId);
$i++;
}
//avoid moving up value of lable when some labels don't
//have a value ,fixed for CRM-3088
$rowCount = 1;
foreach ($defaultDiscounts as $val) {
$discountFields = current($val);
$discountFields = current($discountFields['fields']);
foreach ($discountFields['options'] as $discountFieldsval) {
$defaults["discounted_label"][$discountFieldsval['weight']] = $discountFieldsval['label'];
$defaults["discounted_value"][$discountFieldsval['weight']][$rowCount] = $discountFieldsval['amount'];
$defaults['discount_option_id'][$rowCount][] = $discountFieldsval['id'];
if (CRM_Utils_Array::value('is_default', $discountFieldsval)) {
$defaults['discounted_default'] = $discountFieldsval['weight'];
}
}
$rowCount++;
}
$this->set('discountSection', 1);
$this->buildQuickForm();
} elseif (!empty($defaults['label'])) {
//if Regular Fees are present in DB and event fee page is in update mode
$defaults["discounted_label"] = $defaults['label'];
} elseif (CRM_Utils_Array::value('label', $this->_submitValues)) {
//if event is newly created, use submitted values for
//discount labels
if (is_array($this->_submitValues['label'])) {
$k = 1;
foreach ($this->_submitValues['label'] as $value) {
if ($value) {
$defaults["discounted_label"][$k] = $value;
$k++;
}
}
}
}
$defaults['id'] = $eventId;
if (!empty($totalLables)) {
$maxKey = count($totalLables) - 1;
if (isset($maxKey) && CRM_Utils_Array::value('value', $totalLables[$maxKey])) {
foreach ($totalLables[$maxKey]['value'] as $i => $v) {
if ($totalLables[$maxKey]['amount_id'][$i] == CRM_Utils_Array::value('default_discount_fee_id', $defaults)) {
//.........这里部分代码省略.........
示例10: postProcess
/**
* Function to process the form
*
* @access public
*
* @return None
*/
public function postProcess()
{
$session = CRM_Core_Session::singleton();
if ($this->_action & CRM_Core_Action::DELETE) {
CRM_Contribute_BAO_Contribution::deleteContribution($this->_id);
$session->replaceUserContext(CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$this->_contactID}&selectedChild=contribute"));
return;
}
// get the submitted form values.
$submittedValues = $this->controller->exportValues($this->_name);
if (CRM_Utils_Array::value('price_set_id', $submittedValues) && $this->_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_Field', CRM_Utils_Array::value('price_field_id', $line[$lineID]), 'price_set_id');
$quickConfig = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_Set', $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 = $pId = NULL;
$priceSetId = CRM_Utils_Array::value('price_set_id', $submittedValues);
if (empty($priceSetId) && !$this->_id) {
$this->_priceSetId = $priceSetId = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_Set', 'default_contribution_amount', 'id', 'name');
$this->_priceSet = current(CRM_Price_BAO_Set::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_Set::processAmount($this->_priceSet['fields'], $submittedValues, $lineItem[$priceSetId]);
$submittedValues['total_amount'] = CRM_Utils_Array::value('amount', $submittedValues);
}
if (!$priceSetId && CRM_Utils_Array::value('total_amount', $submittedValues) && $this->_id) {
// 10117 update th line items for participants
$pId = $this->_compId && $this->_context == 'participant' ? $this->_compId : CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $this->_id, 'participant_id', 'contribution_id');
//CRM-10964
if ($pId) {
$entityTable = 'participant';
$entityID = $pId;
$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);
$itemId = key($lineItems);
$fieldType = NULL;
if ($itemId && CRM_Utils_Array::value('price_field_id', $lineItems[$itemId])) {
$fieldType = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_Field', $lineItems[$itemId]['price_field_id'], 'html_type');
}
$lineItems[$itemId]['unit_price'] = $lineItems[$itemId]['line_total'] = CRM_Utils_Rule::cleanMoney(CRM_Utils_Array::value('total_amount', $submittedValues));
$lineItems[$itemId]['id'] = $itemId;
// 10117 update th line items for participants
$this->_priceSetId = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_Field', $lineItems[$itemId]['price_field_id'], 'price_set_id');
$lineItem[$this->_priceSetId] = $lineItems;
}
$isQuickConfig = 0;
if ($this->_priceSetId && CRM_Core_DAO::getFieldValue('CRM_Price_DAO_Set', $this->_priceSetId, 'is_quick_config')) {
$isQuickConfig = 1;
}
if (!CRM_Utils_Array::value('total_amount', $submittedValues)) {
$submittedValues['total_amount'] = CRM_Utils_Array::value('total_amount', $this->_values);
}
$this->assign('lineItem', !empty($lineItem) && !$isQuickConfig ? $lineItem : FALSE);
if (CRM_Utils_Array::value('soft_credit_to', $submittedValues)) {
$submittedValues['soft_credit_to'] = $submittedValues['soft_contact_id'];
}
// set the contact, when contact is selected
if (CRM_Utils_Array::value('contact_select_id', $submittedValues)) {
$this->_contactID = $submittedValues['contact_select_id'][1];
}
$config = CRM_Core_Config::singleton();
//Credit Card Contribution.
if ($this->_mode) {
$unsetParams = array('trxn_id', 'payment_instrument_id', 'contribution_status_id', 'cancel_date', 'cancel_reason');
foreach ($unsetParams as $key) {
if (isset($submittedValues[$key])) {
unset($submittedValues[$key]);
}
}
//Get the rquire fields value only.
$params = $this->_params = $submittedValues;
$this->_paymentProcessor = CRM_Core_BAO_PaymentProcessor::getPayment($this->_params['payment_processor_id'], $this->_mode);
//get the payment processor id as per mode.
$params['payment_processor_id'] = $this->_params['payment_processor_id'] = $submittedValues['payment_processor_id'] = $this->_paymentProcessor['id'];
$now = date('YmdHis');
//.........这里部分代码省略.........
示例11: task_4_2_alpha1_convertParticipants
/**
* (Queue Task Callback)
*
* Find any participant records and create corresponding line-item
* records.
*
* @param $startId int, the first/lowest participant ID to convert
* @param $endId int, the last/highest participant ID to convert
*/
static function task_4_2_alpha1_convertParticipants(CRM_Queue_TaskContext $ctx, $startId, $endId)
{
$upgrade = new CRM_Upgrade_Form();
//create lineitems for participant in edge cases using default price set for contribution.
$query = "\nSELECT cp.id as participant_id, cp.fee_amount, cp.fee_level,ce.is_monetary,\n cpse.price_set_id, cpf.id as price_field_id, cpfv.id as price_field_value_id\nFROM civicrm_participant cp\nLEFT JOIN civicrm_line_item cli ON cli.entity_id=cp.id and cli.entity_table = 'civicrm_participant'\nLEFT JOIN civicrm_event ce ON ce.id=cp.event_id\nLEFT JOIN civicrm_price_set_entity cpse ON cp.event_id = cpse.entity_id and cpse.entity_table = 'civicrm_event'\nLEFT JOIN civicrm_price_field cpf ON cpf.price_set_id = cpse.price_set_id\nLEFT JOIN civicrm_price_field_value cpfv ON cpfv.price_field_id = cpf.id AND cpfv.label = cp.fee_level\nWHERE (cp.id BETWEEN %1 AND %2)\nAND cli.entity_id IS NULL AND cp.fee_amount IS NOT NULL";
$sqlParams = array(1 => array($startId, 'Integer'), 2 => array($endId, 'Integer'));
$dao = CRM_Core_DAO::executeQuery($query, $sqlParams);
if ($dao->N) {
$defaultPriceSetId = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_Set', 'default_contribution_amount', 'id', 'name');
$priceSets = current(CRM_Price_BAO_Set::getSetDetail($defaultPriceSetId));
$fieldID = key($priceSets['fields']);
}
while ($dao->fetch()) {
$lineParams = array('entity_table' => 'civicrm_participant', 'entity_id' => $dao->participant_id, 'label' => $dao->fee_level ? $dao->fee_level : ts('Default'), 'qty' => 1, 'unit_price' => $dao->fee_amount, 'line_total' => $dao->fee_amount, 'participant_count' => 1);
if ($dao->is_monetary && $dao->price_field_id) {
$lineParams += array('price_field_id' => $dao->price_field_id, 'price_field_value_id' => $dao->price_field_value_id);
$priceSetId = $dao->price_set_id;
} else {
$lineParams['price_field_id'] = $fieldID;
$priceSetId = $defaultPriceSetId;
}
CRM_Price_BAO_LineItem::create($lineParams);
}
return TRUE;
}
示例12: process_event_line_item
function process_event_line_item(&$event_in_cart, $class = NULL)
{
$cost = 0;
$price_set_id = CRM_Price_BAO_Set::getFor("civicrm_event", $event_in_cart->event_id);
$amount_level = NULL;
if ($price_set_id) {
$event_price_values = array();
foreach ($this->_price_values as $key => $value) {
if (preg_match("/event_{$event_in_cart->event_id}_(price.*)/", $key, $matches)) {
$event_price_values[$matches[1]] = $value;
}
}
$price_sets = CRM_Price_BAO_Set::getSetDetail($price_set_id, TRUE);
$price_set = $price_sets[$price_set_id];
$price_set_amount = array();
CRM_Price_BAO_Set::processAmount($price_set['fields'], $event_price_values, $price_set_amount);
$price_set_index = end(array_keys($event_price_values['amount_priceset_level_radio']));
$cost = $event_price_values['amount'];
$amount_level = $event_price_values['amount_level'];
}
// iterate over each participant in event
foreach ($event_in_cart->participants as &$participant) {
$participant->cost = $cost;
$participant->fee_level = $amount_level;
}
$this->add_line_item($event_in_cart, $class);
}
示例13: createLineItems
/**
* Function to record line items for default membership
*
* @param $qf object
*
* @param $membershipType array with membership type and organization
*
* @param$ priceSetId priceset id
* @access public
* @static
*/
static function createLineItems(&$qf, $membershipType, &$priceSetId)
{
$qf->_priceSetId = $priceSetId = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_Set', 'default_membership_type_amount', 'id', 'name');
if ($priceSetId) {
$qf->_priceSet = $priceSets = current(CRM_Price_BAO_Set::getSetDetail($priceSetId));
}
$editedFieldParams = array('price_set_id' => $priceSetId, 'name' => $membershipType[0]);
$editedResults = array();
CRM_Price_BAO_Field::retrieve($editedFieldParams, $editedResults);
if (!empty($editedResults)) {
unset($qf->_priceSet['fields']);
$qf->_priceSet['fields'][$editedResults['id']] = $priceSets['fields'][$editedResults['id']];
unset($qf->_priceSet['fields'][$editedResults['id']]['options']);
$fid = $editedResults['id'];
$editedFieldParams = array('price_field_id' => $editedResults['id'], 'membership_type_id' => $membershipType[1]);
$editedResults = array();
CRM_Price_BAO_FieldValue::retrieve($editedFieldParams, $editedResults);
$qf->_priceSet['fields'][$fid]['options'][$editedResults['id']] = $priceSets['fields'][$fid]['options'][$editedResults['id']];
if (CRM_Utils_Array::value('total_amount', $qf->_params)) {
$qf->_priceSet['fields'][$fid]['options'][$editedResults['id']]['amount'] = $qf->_params['total_amount'];
}
}
$fieldID = key($qf->_priceSet['fields']);
$qf->_params['price_' . $fieldID] = $editedResults['id'];
}