本文整理汇总了PHP中CRM_Core_BAO_Discount类的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_BAO_Discount类的具体用法?PHP CRM_Core_BAO_Discount怎么用?PHP CRM_Core_BAO_Discount使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CRM_Core_BAO_Discount类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: createDiscountTrxn
/**
* create trxn entry if an event has discount.
*
* @param int $eventID
* Event id.
* @param array $contributionParams
* Contribution params.
*
* @param $feeLevel
*
*/
public static function createDiscountTrxn($eventID, $contributionParams, $feeLevel)
{
// CRM-11124
$checkDiscount = CRM_Core_BAO_Discount::findSet($eventID, 'civicrm_event');
if (!empty($checkDiscount)) {
$feeLevel = current($feeLevel);
$priceSetId = CRM_Price_BAO_PriceSet::getFor('civicrm_event', $eventID, NULL);
$query = "SELECT cpfv.amount FROM `civicrm_price_field_value` cpfv\nLEFT JOIN civicrm_price_field cpf ON cpfv.price_field_id = cpf.id\nWHERE cpf.price_set_id = %1 AND cpfv.label LIKE %2";
$params = array(1 => array($priceSetId, 'Integer'), 2 => array($feeLevel, 'String'));
$mainAmount = CRM_Core_DAO::singleValueQuery($query, $params);
$relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Discounts Account is' "));
$contributionParams['trxnParams']['from_financial_account_id'] = CRM_Contribute_PseudoConstant::financialAccountType($contributionParams['contribution']->financial_type_id, $relationTypeId);
if (!empty($contributionParams['trxnParams']['from_financial_account_id'])) {
$contributionParams['trxnParams']['total_amount'] = $mainAmount - $contributionParams['total_amount'];
$contributionParams['trxnParams']['payment_processor_id'] = NULL;
$contributionParams['trxnParams']['payment_instrument_id'] = NULL;
$contributionParams['trxnParams']['check_number'] = NULL;
$contributionParams['trxnParams']['trxn_id'] = NULL;
$contributionParams['trxnParams']['net_amount'] = NULL;
$contributionParams['trxnParams']['fee_amount'] = NULL;
CRM_Core_BAO_FinancialTrxn::create($contributionParams['trxnParams']);
}
}
}
开发者ID:BorislavZlatanov,项目名称:civicrm-core,代码行数:35,代码来源:Participant.php
示例2: 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;
}
//.........这里部分代码省略.........
开发者ID:utkarshsharma,项目名称:civicrm-core,代码行数:101,代码来源:AdditionalParticipant.php
示例3: copy
/**
* This function is to make a copy of a Event, including
* all the fields in the event Wizard
*
* @param int $id the event id to copy
*
* @return void
* @access public
*/
static function copy($id)
{
$defaults = $eventValues = array();
//get the require event values.
$eventParams = array('id' => $id);
$returnProperties = array('loc_block_id', 'is_show_location', 'default_fee_id', 'default_discount_fee_id');
CRM_Core_DAO::commonRetrieve('CRM_Event_DAO_Event', $eventParams, $eventValues, $returnProperties);
// since the location is sharable, lets use the same loc_block_id.
$locBlockId = CRM_Utils_Array::value('loc_block_id', $eventValues);
$fieldsFix = array('prefix' => array('title' => ts('Copy of') . ' '));
if (!CRM_Utils_Array::value('is_show_location', $eventValues)) {
$fieldsFix['prefix']['is_show_location'] = 0;
}
$copyEvent =& CRM_Core_DAO::copyGeneric('CRM_Event_DAO_Event', array('id' => $id), array('loc_block_id' => $locBlockId ? $locBlockId : null), $fieldsFix);
$copyPriceSet =& CRM_Core_DAO::copyGeneric('CRM_Price_DAO_SetEntity', array('entity_id' => $id, 'entity_table' => 'civicrm_event'), array('entity_id' => $copyEvent->id));
$copyUF =& CRM_Core_DAO::copyGeneric('CRM_Core_DAO_UFJoin', array('entity_id' => $id, 'entity_table' => 'civicrm_event'), array('entity_id' => $copyEvent->id));
$copyTellFriend =& CRM_Core_DAO::copyGeneric('CRM_Friend_DAO_Friend', array('entity_id' => $id, 'entity_table' => 'civicrm_event'), array('entity_id' => $copyEvent->id));
require_once "CRM/Core/BAO/OptionGroup.php";
//copy option Group and values
$copyEvent->default_fee_id = CRM_Core_BAO_OptionGroup::copyValue('event', $id, $copyEvent->id, CRM_Utils_Array::value('default_fee_id', $eventValues));
//copy discounted fee levels
require_once 'CRM/Core/BAO/Discount.php';
$discount = CRM_Core_BAO_Discount::getOptionGroup($id, 'civicrm_event');
if (!empty($discount)) {
foreach ($discount as $discountOptionGroup) {
$name = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', $discountOptionGroup);
$length = substr_compare($name, "civicrm_event.amount." . $id, 0);
$discountSuffix = substr($name, $length * -1);
$copyEvent->default_discount_fee_id = CRM_Core_BAO_OptionGroup::copyValue('event', $id, $copyEvent->id, CRM_Utils_Array::value('default_discount_fee_id', $eventValues), $discountSuffix);
}
}
//copy custom data
require_once 'CRM/Core/BAO/CustomGroup.php';
$extends = array('event');
$groupTree = CRM_Core_BAO_CustomGroup::getGroupDetail(null, null, $extends);
if ($groupTree) {
foreach ($groupTree as $groupID => $group) {
$table[$groupTree[$groupID]['table_name']] = array('entity_id');
foreach ($group['fields'] as $fieldID => $field) {
$table[$groupTree[$groupID]['table_name']][] = $groupTree[$groupID]['fields'][$fieldID]['column_name'];
}
}
foreach ($table as $tableName => $tableColumns) {
$insert = 'INSERT INTO ' . $tableName . ' (' . implode(', ', $tableColumns) . ') ';
$tableColumns[0] = $copyEvent->id;
$select = 'SELECT ' . implode(', ', $tableColumns);
$from = ' FROM ' . $tableName;
$where = " WHERE {$tableName}.entity_id = {$id}";
$query = $insert . $select . $from . $where;
$dao = CRM_Core_DAO::executeQuery($query, CRM_Core_DAO::$_nullArray);
}
}
$copyEvent->save();
require_once 'CRM/Utils/Hook.php';
CRM_Utils_Hook::copy('Event', $copyEvent);
return $copyEvent;
}
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:66,代码来源:Event.php
示例4: postProcess
/**
* Function to process the form
*
* @access public
* @return None
*/
public function postProcess()
{
$params = $this->controller->exportValues($this->_name);
//format params
$params['start_date'] = CRM_Utils_Date::processDate($params['start_date'], $params['start_date_time']);
$params['end_date'] = CRM_Utils_Date::processDate($params['end_date'], $params['end_date_time'], true);
$params['has_waitlist'] = CRM_Utils_Array::value('has_waitlist', $params, false);
$params['is_map'] = CRM_Utils_Array::value('is_map', $params, false);
$params['is_active'] = CRM_Utils_Array::value('is_active', $params, false);
$params['is_public'] = CRM_Utils_Array::value('is_public', $params, false);
$params['default_role_id'] = CRM_Utils_Array::value('default_role_id', $params, false);
$params['id'] = $this->_id;
//new event, so lets set the created_id
if ($this->_action & CRM_Core_Action::ADD) {
$session =& CRM_Core_Session::singleton();
$params['created_id'] = $session->get('userID');
$params['created_date'] = date('YmdHis');
}
$customFields = CRM_Core_BAO_CustomField::getFields('Event', false, false, CRM_Utils_Array::value('event_type_id', $params));
$params['custom'] = CRM_Core_BAO_CustomField::postProcess($params, $customFields, $this->_id, 'Event');
require_once 'CRM/Event/BAO/Event.php';
// copy all not explicitely set $params keys from the template (if it should be sourced)
if (CRM_Utils_Array::value('template_id', $params)) {
$defaults = array();
$templateParams = array('id' => $params['template_id']);
CRM_Event_BAO_Event::retrieve($templateParams, $defaults);
unset($defaults['id']);
unset($defaults['default_fee_id']);
unset($defaults['default_discount_fee_id']);
foreach ($defaults as $key => $value) {
if (!isset($params[$key])) {
$params[$key] = $value;
}
}
}
$event = CRM_Event_BAO_Event::create($params);
// now that we have the event’s id, do some more template-based stuff
if (CRM_Utils_Array::value('template_id', $params)) {
// copy event fees
$ogParams = array('name' => "civicrm_event.amount.{$event->id}");
$defaults = array();
require_once 'CRM/Core/BAO/OptionGroup.php';
if (is_null(CRM_Core_BAO_OptionGroup::retrieve($ogParams, $defaults))) {
// Copy the Main Event Fees
CRM_Core_BAO_OptionGroup::copyValue('event', $params['template_id'], $event->id);
// Copy the Discount option Group and Values
require_once 'CRM/Core/BAO/Discount.php';
$optionGroupIds = CRM_Core_BAO_Discount::getOptionGroup($params['template_id'], "civicrm_event");
foreach ($optionGroupIds as $id) {
$discountSuffix = '.discount.' . CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', $id, 'label');
CRM_Core_BAO_OptionGroup::copyValue('event', $params['template_id'], $event->id, false, $discountSuffix);
}
}
// copy price sets if any
require_once 'CRM/Price/BAO/Set.php';
$priceSetId = CRM_Price_BAO_Set::getFor('civicrm_event', $params['template_id']);
if ($priceSetId) {
CRM_Price_BAO_Set::addTo('civicrm_event', $event->id, $priceSetId);
}
// link profiles if none linked
$ufParams = array('entity_table' => 'civicrm_event', 'entity_id' => $event->id);
require_once 'CRM/Core/BAO/UFJoin.php';
if (!CRM_Core_BAO_UFJoin::findUFGroupId($ufParams)) {
CRM_Core_DAO::copyGeneric('CRM_Core_DAO_UFJoin', array('entity_id' => $params['template_id'], 'entity_table' => 'civicrm_event'), array('entity_id' => $event->id));
}
// if no Tell-a-Friend defined, check whether there’s one for template and copy if so
$tafParams = array('entity_table' => 'civicrm_event', 'entity_id' => $event->id);
require_once 'CRM/Friend/BAO/Friend.php';
if (!CRM_Friend_BAO_Friend::getValues($tafParams)) {
$tafParams['entity_id'] = $params['template_id'];
if (CRM_Friend_BAO_Friend::getValues($tafParams)) {
$tafParams['entity_id'] = $event->id;
CRM_Friend_BAO_Friend::addTellAFriend($tafParams);
}
}
}
$this->set('id', $event->id);
if ($this->_action & CRM_Core_Action::ADD) {
$urlParam = "action=update&reset=1&subPage=Location&id={$event->id}";
// special case for 'Save and Done' consistency.
if ($this->controller->getButtonName('submit') == "_qf_EventInfo_upload_done") {
$urlParam = "action=update&reset=1&id={$event->id}";
CRM_Core_Session::setStatus(ts("'%1' information has been saved.", array(1 => $this->getTitle())));
}
CRM_Utils_System::redirect(CRM_Utils_System::url(CRM_Utils_System::currentPath(), $urlParam));
}
parent::endPostProcess();
}
开发者ID:bhirsch,项目名称:voipdev,代码行数:94,代码来源:EventInfo.php
示例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'];
//.........这里部分代码省略.........
开发者ID:ksecor,项目名称:civicrm,代码行数:101,代码来源:EventInfo.php
示例6: postProcess
/**
* Process the form.
*/
public function postProcess()
{
$eventTitle = '';
$params = $this->exportValues();
$this->set('discountSection', 0);
if (!empty($_POST['_qf_Fee_submit'])) {
$this->buildAmountLabel();
$this->set('discountSection', 2);
return;
}
if (!empty($params['payment_processor'])) {
$params['payment_processor'] = str_replace(',', CRM_Core_DAO::VALUE_SEPARATOR, $params['payment_processor']);
} else {
$params['payment_processor'] = 'null';
}
$params['is_pay_later'] = CRM_Utils_Array::value('is_pay_later', $params, 0);
$params['is_billing_required'] = CRM_Utils_Array::value('is_billing_required', $params, 0);
if ($this->_id) {
// delete all the prior label values or discounts in the custom options table
// and delete a price set if one exists
//@todo note that this removes the reference from existing participants -
// even where there is not change - redress?
// note that a more tentative form of this is invoked by passing price_set_id as an array
// to event.create see CRM-14069
// @todo get all of this logic out of form layer (currently partially in BAO/api layer)
if (CRM_Price_BAO_PriceSet::removeFrom('civicrm_event', $this->_id)) {
CRM_Core_BAO_Discount::del($this->_id, 'civicrm_event');
}
}
if ($params['is_monetary']) {
if (!empty($params['price_set_id'])) {
//@todo this is now being done in the event BAO if passed price_set_id as an array
// per notes on that fn - looking at the api converting to an array
// so calling via the api may cause this to be done in the api
CRM_Price_BAO_PriceSet::addTo('civicrm_event', $this->_id, $params['price_set_id']);
if (!empty($params['price_field_id'])) {
$priceSetID = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceField', $params['price_field_id'], 'price_set_id');
CRM_Price_BAO_PriceSet::setIsQuickConfig($priceSetID, 0);
}
} else {
// if there are label / values, create custom options for them
$labels = CRM_Utils_Array::value('label', $params);
$values = CRM_Utils_Array::value('value', $params);
$default = CRM_Utils_Array::value('default', $params);
$options = array();
if (!CRM_Utils_System::isNull($labels) && !CRM_Utils_System::isNull($values)) {
for ($i = 1; $i < self::NUM_OPTION; $i++) {
if (!empty($labels[$i]) && !CRM_Utils_System::isNull($values[$i])) {
$options[] = array('label' => trim($labels[$i]), 'value' => CRM_Utils_Rule::cleanMoney(trim($values[$i])), 'weight' => $i, 'is_active' => 1, 'is_default' => $default == $i);
}
}
if (!empty($options)) {
$params['default_fee_id'] = NULL;
if (empty($params['price_set_id'])) {
if (empty($params['price_field_id'])) {
$setParams['title'] = $eventTitle = $this->_isTemplate ? $this->_defaultValues['template_title'] : $this->_defaultValues['title'];
$eventTitle = strtolower(CRM_Utils_String::munge($eventTitle, '_', 245));
if (!CRM_Core_DAO::getFieldValue('CRM_Price_BAO_PriceSet', $eventTitle, 'id', 'name')) {
$setParams['name'] = $eventTitle;
} elseif (!CRM_Core_DAO::getFieldValue('CRM_Price_BAO_PriceSet', $eventTitle . '_' . $this->_id, 'id', 'name')) {
$setParams['name'] = $eventTitle . '_' . $this->_id;
} else {
$timeSec = explode('.', microtime(TRUE));
$setParams['name'] = $eventTitle . '_' . date('is', $timeSec[0]) . $timeSec[1];
}
$setParams['is_quick_config'] = 1;
$setParams['financial_type_id'] = $params['financial_type_id'];
$setParams['extends'] = CRM_Core_Component::getComponentID('CiviEvent');
$priceSet = CRM_Price_BAO_PriceSet::create($setParams);
$fieldParams['name'] = strtolower(CRM_Utils_String::munge($params['fee_label'], '_', 245));
$fieldParams['price_set_id'] = $priceSet->id;
} else {
foreach ($params['price_field_value'] as $arrayID => $fieldValueID) {
if (empty($params['label'][$arrayID]) && empty($params['value'][$arrayID]) && !empty($fieldValueID)) {
CRM_Price_BAO_PriceFieldValue::setIsActive($fieldValueID, '0');
unset($params['price_field_value'][$arrayID]);
}
}
$fieldParams['id'] = CRM_Utils_Array::value('price_field_id', $params);
$fieldParams['option_id'] = $params['price_field_value'];
$priceSet = new CRM_Price_BAO_PriceSet();
$priceSet->id = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceField', CRM_Utils_Array::value('price_field_id', $params), 'price_set_id');
if ($this->_defaultValues['financial_type_id'] != $params['financial_type_id']) {
CRM_Core_DAO::setFieldValue('CRM_Price_DAO_PriceSet', $priceSet->id, 'financial_type_id', $params['financial_type_id']);
}
}
$fieldParams['label'] = $params['fee_label'];
$fieldParams['html_type'] = 'Radio';
CRM_Price_BAO_PriceSet::addTo('civicrm_event', $this->_id, $priceSet->id);
$fieldParams['option_label'] = $params['label'];
$fieldParams['option_amount'] = $params['value'];
$fieldParams['financial_type_id'] = $params['financial_type_id'];
foreach ($options as $value) {
$fieldParams['option_weight'][$value['weight']] = $value['weight'];
}
$fieldParams['default_option'] = $params['default'];
$priceField = CRM_Price_BAO_PriceField::create($fieldParams);
//.........这里部分代码省略.........
开发者ID:saurabhbatra96,项目名称:civicrm-core,代码行数:101,代码来源:Fee.php
示例7: setDefaultValues
//.........这里部分代码省略.........
foreach ($val['options'] as $keys => $values) {
if ($values['is_default']) {
if (get_class($form) != 'CRM_Event_Form_Participant' && CRM_Utils_Array::value('is_full', $values)) {
continue;
}
if ($val['html_type'] == 'CheckBox') {
$defaults[$form->_pId]["price_{$key}"][$keys] = 1;
} else {
$defaults[$form->_pId]["price_{$key}"] = $keys;
}
}
}
}
}
$form->assign('totalAmount', CRM_Utils_Array::value('fee_amount', $defaults[$form->_pId]));
if ($form->_action == CRM_Core_Action::UPDATE) {
$fee_level = $defaults[$form->_pId]['fee_level'];
CRM_Event_BAO_Participant::fixEventLevel($fee_level);
$form->assign('fee_level', $fee_level);
$form->assign('fee_amount', CRM_Utils_Array::value('fee_amount', $defaults[$form->_pId]));
}
} else {
$optionGroupId = NULL;
// if user has selected discount use that to set default
if (isset($form->_discountId)) {
$defaults[$form->_pId]['discount_id'] = $form->_discountId;
//hack to set defaults for already selected discount value
if ($form->_action == CRM_Core_Action::UPDATE && !$form->_originalDiscountId) {
$form->_originalDiscountId = $defaults[$form->_pId]['discount_id'];
if ($form->_originalDiscountId) {
$optionGroupId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Discount', $form->_originalDiscountId, 'option_group_id');
$defaults[$form->_pId]['discount_id'] = $form->_originalDiscountId;
}
}
}
if ($form->_action == CRM_Core_Action::ADD) {
// this case is for add mode, where we show discount automatically
if (!isset($form->_discountId)) {
$discountId = CRM_Core_BAO_Discount::findSet($form->_eventId, 'civicrm_event');
} else {
$discountId = $form->_discountId;
}
if ($form->_eventId && $discountId) {
$defaultDiscountId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $form->_eventId, 'default_discount_fee_id');
if ($defaultDiscountId) {
$discountKey = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionValue', $defaultDiscountId, 'weight');
}
$defaults[$form->_pId]['discount_id'] = $discountId;
$defaults[$form->_pId]['amount'] = key(array_slice($form->_values['discount'][$discountId], $discountKey - 1, $discountKey, TRUE));
$optionGroupId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Discount', $discountId, 'option_group_id');
} else {
if ($form->_eventId) {
$defaults[$form->_pId]['amount'] = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $form->_eventId, 'default_fee_id');
}
}
}
if (CRM_Utils_Array::value('event_id', $defaults[$form->_pId]) && ($form->_action == CRM_Core_Action::UPDATE || $form->_allowConfirmation)) {
if (!empty($form->_feeBlock)) {
$feeLevel = CRM_Utils_Array::value('fee_level', $defaults[$form->_pId]);
$feeAmount = CRM_Utils_Array::value('fee_amount', $defaults[$form->_pId]);
foreach ($form->_feeBlock as $amountId => $amountInfo) {
if ($amountInfo['label'] == $feeLevel && $amountInfo['value'] == $feeAmount) {
$defaults[$form->_pId]['amount'] = $amountInfo['amount_id'];
}
// if amount is not set do fuzzy matching
if (!isset($defaults[$form->_pId]['amount'])) {
// if only level use that
if ($amountInfo['label'] == $feeLevel) {
$defaults[$form->_pId]['amount'] = $amountInfo['amount_id'];
} elseif (strpos($feeLevel, $amountInfo['label']) !== FALSE) {
$defaults[$form->_pId]['amount'] = $amountInfo['amount_id'];
} elseif ($amountInfo['value'] == $feeAmount) {
// if amount matches use that
$defaults[$form->_pId]['amount'] = $amountInfo['amount_id'];
}
}
}
}
}
$form->assign('amountId', CRM_Utils_Array::value('amount', $defaults[$form->_pId]));
}
//CRM-4453
if (CRM_Utils_Array::value('participant_fee_currency', $defaults[$form->_pId])) {
$form->assign('fee_currency', $defaults[$form->_pId]['participant_fee_currency']);
}
// CRM-4395
if ($contriId = $form->get('onlinePendingContributionId')) {
$contribution = new CRM_Contribute_DAO_Contribution();
$contribution->id = $contriId;
$contribution->find(TRUE);
foreach (array('contribution_type_id', 'payment_instrument_id', 'contribution_status_id', 'receive_date', 'total_amount') as $f) {
if ($f == 'receive_date') {
list($defaults[$form->_pId]['receive_date']) = CRM_Utils_Date::setDateDefaults($contribution->{$f});
} else {
$defaults[$form->_pId][$f] = $contribution->{$f};
}
}
}
return $defaults[$form->_pId];
}
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:101,代码来源:EventFees.php
示例8: postProcess
/**
* Process the form submission.
*/
public function postProcess()
{
// get the submitted form values.
$params = $this->controller->exportValues($this->_name);
//set as Primary participant
$params['is_primary'] = 1;
if ($this->_values['event']['is_pay_later'] && (!array_key_exists('hidden_processor', $params) || $params['payment_processor_id'] == 0)) {
$params['is_pay_later'] = 1;
} else {
$params['is_pay_later'] = 0;
}
$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['event']['pay_later_text']);
$this->assign('pay_later_receipt', $this->_values['event']['pay_later_receipt']);
}
if (!$this->_allowConfirmation) {
// check if the participant is already registered
if (!$this->_skipDupeRegistrationCheck) {
$params['contact_id'] = self::checkRegistration($params, $this, FALSE, TRUE, TRUE);
}
}
if (!empty($params['image_URL'])) {
CRM_Contact_BAO_Contact::processImageParams($params);
}
//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']);
}
//hack to allow group to register w/ waiting
$primaryParticipantCount = self::getParticipantCount($this, $params);
$totalParticipants = $primaryParticipantCount;
if (!empty($params['additional_participants'])) {
$totalParticipants += $params['additional_participants'];
}
if (!$this->_allowConfirmation && !empty($params['bypass_payment']) && is_numeric($this->_availableRegistrations) && $totalParticipants > $this->_availableRegistrations) {
$this->_allowWaitlist = TRUE;
$this->set('allowWaitlist', TRUE);
}
//carry participant id if pre-registered.
if ($this->_allowConfirmation && $this->_participantId) {
$params['participant_id'] = $this->_participantId;
}
$params['defaultRole'] = 1;
if (array_key_exists('participant_role', $params)) {
$params['participant_role_id'] = $params['participant_role'];
}
if (array_key_exists('participant_role_id', $params)) {
$params['defaultRole'] = 0;
}
if (empty($params['participant_role_id']) && $this->_values['event']['default_role_id']) {
$params['participant_role_id'] = $this->_values['event']['default_role_id'];
}
$config = CRM_Core_Config::singleton();
$params['currencyID'] = $config->defaultCurrency;
if ($this->_values['event']['is_monetary']) {
// we first reset the confirm page so it accepts new values
$this->controller->resetPage('Confirm');
//added for discount
$discountId = CRM_Core_BAO_Discount::findSet($this->_eventId, 'civicrm_event');
$params['amount_level'] = $this->getAmountLevel($params, $discountId);
if (!empty($this->_values['discount'][$discountId])) {
$params['discount_id'] = $discountId;
$params['amount'] = $this->_values['discount'][$discountId][$params['amount']]['value'];
} elseif (empty($params['priceSetId'])) {
if (!empty($params['amount'])) {
$params['amount'] = $this->_values['fee'][$params['amount']]['value'];
} else {
$params['amount'] = '';
}
} else {
$lineItem = array();
CRM_Price_BAO_PriceSet::processAmount($this->_values['fee'], $params, $lineItem);
if ($params['tax_amount']) {
$this->set('tax_amount', $params['tax_amount']);
}
$submittedLineItems = $this->get('lineItem');
if (!empty($submittedLineItems) && is_array($submittedLineItems)) {
$submittedLineItems[0] = $lineItem;
} else {
$submittedLineItems = array($lineItem);
}
$this->set('lineItem', $submittedLineItems);
$this->set('lineItemParticipantsCount', array($primaryParticipantCount));
}
$this->set('amount', $params['amount']);
$this->set('amount_level', $params['amount_level']);
// generate and set an invoiceID for this transaction
$invoiceID = md5(uniqid(rand(), TRUE));
$this->set('invoiceID', $invoiceID);
if ($this->_paymentProcessor) {
$payment = $this->_paymentProcessor['object'];
//.........这里部分代码省略.........
开发者ID:konadave,项目名称:civicrm-core,代码行数:101,代码来源:Register.php
示例9: postProcess
/**
* Function to process the form
*
* @access public
*
* @return None
*/
public function postProcess()
{
// get the submitted form values.
$params = $this->controller->exportValues($this->_name);
//set as Primary participant
$params['is_primary'] = 1;
if ($this->_values['event']['is_pay_later'] && !array_key_exists('hidden_processor', $params)) {
$params['is_pay_later'] = 1;
} else {
$params['is_pay_later'] = 0;
}
$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['event']['pay_later_text']);
$this->assign('pay_later_receipt', $this->_values['event']['pay_later_receipt']);
}
if (!$this->_allowConfirmation) {
// check if the participant is already registered
if (!$this->_skipDupeRegistrationCheck) {
$params['contact_id'] = self::checkRegistration($params, $this, FALSE, TRUE, TRUE);
}
}
if (CRM_Utils_Array::value('image_URL', $params)) {
CRM_Contact_BAO_Contact::processImageParams($params);
}
//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']);
}
//hack to allow group to register w/ waiting
$primaryParticipantCount = self::getParticipantCount($this, $params);
$totalParticipants = $primaryParticipantCount;
if (CRM_Utils_Array::value('additional_participants', $params)) {
$totalParticipants += $params['additional_participants'];
}
if (!$this->_allowConfirmation && CRM_Utils_Array::value('bypass_payment', $params) && is_numeric($this->_availableRegistrations) && $totalParticipants > $this->_availableRegistrations) {
$this->_allowWaitlist = TRUE;
$this->set('allowWaitlist', TRUE);
}
//carry participant id if pre-registered.
if ($this->_allowConfirmation && $this->_participantId) {
$params['participant_id'] = $this->_participantId;
}
$params['defaultRole'] = 1;
if (array_key_exists('participant_role', $params)) {
$params['participant_role_id'] = $params['participant_role'];
}
if (array_key_exists('participant_role_id', $params)) {
$params['defaultRole'] = 0;
}
if (!CRM_Utils_Array::value('participant_role_id', $params) && $this->_values['event']['default_role_id']) {
$params['participant_role_id'] = $this->_values['event']['default_role_id'];
}
$config = CRM_Core_Config::singleton();
$params['currencyID'] = $config->defaultCurrency;
if ($this->_values['event']['is_monetary']) {
// we first reset the confirm page so it accepts new values
$this->controller->resetPage('Confirm');
//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'])) {
if (!empty($params['amount'])) {
$params['amount_level'] = $this->_values['fee'][$params['amount']]['label'];
$params['amount'] = $this->_values['fee'][$params['amount']]['value'];
} else {
$params['amount_level'] = $params['amount'] = '';
}
} else {
$lineItem = array();
CRM_Price_BAO_PriceSet::processAmount($this->_values['fee'], $params, $lineItem);
$this->set('lineItem', array($lineItem));
$this->set('lineItemParticipantsCount', array($primaryParticipantCount));
}
$this->set('amount', $params['amount']);
$this->set('amount_level', $params['amount_level']);
// generate and set an invoiceID for this transaction
$invoiceID = md5(uniqid(rand(), TRUE));
$this->set('invoiceID', $invoiceID);
if (is_array($this->_paymentProcessor)) {
$payment = CRM_Core_Payment::singleton($this->_mode, $this->_paymentProcessor, $this);
}
// default mode is direct
$this->set('contributeMode', 'direct');
if (isset($params["state_province_id-{$this->_bltID}"]) && $params["state_province_id-{$this->_bltID}"]) {
//.........这里部分代码省略.........
开发者ID:TheCraftyCanvas,项目名称:aegir-platforms,代码行数:101,代码来源:Register.php
示例10: setIsQuickConfig
/**
* Change is_quick_config priceSet to complex.
*
*/
public static function setIsQuickConfig()
{
$id = $context = NULL;
if (!empty($_REQUEST['id'])) {
$id = CRM_Utils_Type::escape($_REQUEST['id'], 'Integer');
}
if (!empty($_REQUEST['context'])) {
$context = CRM_Utils_Type::escape($_REQUEST['context'], 'String');
}
// return false if $id is null and
// $context is not civicrm_event or civicrm_contribution_page
if (!$id || !in_array($context, array('civicrm_event', 'civicrm_contribution_page'))) {
return FALSE;
}
$priceSetId = CRM_Price_BAO_PriceSet::getFor($context, $id, NULL);
if ($priceSetId) {
$result = CRM_Price_BAO_PriceSet::setIsQuickConfig($priceSetId, 0);
if ($context == 'civicrm_event') {
$sql = "UPDATE\n civicrm_price_set cps\n INNER JOIN civicrm_discount cd ON cd.price_set_id = cps.id\n SET cps.is_quick_config = 0\n WHERE cd.entity_id = (%1) AND cd.entity_table = 'civicrm_event' ";
$params = array(1 => array($id, 'Integer'));
CRM_Core_DAO::executeQuery($sql, $params);
CRM_Core_BAO_Discount::del($id, $context);
}
}
if (!$result) {
$priceSetId = NULL;
}
CRM_Utils_JSON::output($priceSetId);
}
开发者ID:utkarshsharma,项目名称:civicrm-core,代码行数:33,代码来源:AJAX.php
示例11: postProcess
/**
* Function to process the form
*
* @access public
* @return None
*/
public function postProcess()
{
//get the button name.
$button = substr($this->controller->getButtonName(), -4);
//take the participant instance.
$addParticipantNum = substr($this->_name, 12);
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';
}
} else {
$params = $this->controller->exportValues($this->_name);
if ($this->_values['event']['is_monetary']) {
//added for discount
require_once 'CRM/Core/BAO/Discount.php';
$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'];
} else {
if (empty($params['priceSetId'])) {
|
请发表评论