本文整理汇总了PHP中CRM_Price_BAO_PriceSet::getSetDetail方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Price_BAO_PriceSet::getSetDetail方法的具体用法?PHP CRM_Price_BAO_PriceSet::getSetDetail怎么用?PHP CRM_Price_BAO_PriceSet::getSetDetail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Price_BAO_PriceSet
的用法示例。
在下文中一共展示了CRM_Price_BAO_PriceSet::getSetDetail方法的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: 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_PriceSet::getFor('civicrm_event', $event->id);
if ($price_set_id) {
$price_sets = CRM_Price_BAO_PriceSet::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_PriceField::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
*
* @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);
}
示例4: _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);
}
示例5: createLineItems
/**
* Record line items for default membership.
* @deprecated
*
* Use getQuickConfigMembershipLineItems
*
* @param CRM_Core_Form $qf
* @param array $membershipType
* Array with membership type and organization.
*
* @return int $priceSetId
*/
public static function createLineItems(&$qf, $membershipType)
{
$qf->_priceSetId = $priceSetId = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', 'default_membership_type_amount', 'id', 'name');
$qf->_priceSet = $priceSets = current(CRM_Price_BAO_PriceSet::getSetDetail($priceSetId));
// The name of the price field corresponds to the membership_type organization contact.
$editedFieldParams = array('price_set_id' => $priceSetId, 'name' => $membershipType[0]);
$editedResults = array();
CRM_Price_BAO_PriceField::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_PriceFieldValue::retrieve($editedFieldParams, $editedResults);
$qf->_priceSet['fields'][$fid]['options'][$editedResults['id']] = $priceSets['fields'][$fid]['options'][$editedResults['id']];
if (!empty($qf->_params['total_amount'])) {
$qf->_priceSet['fields'][$fid]['options'][$editedResults['id']]['amount'] = $qf->_params['total_amount'];
}
}
$fieldID = key($qf->_priceSet['fields']);
$qf->_params['price_' . $fieldID] = CRM_Utils_Array::value('id', $editedResults);
return $priceSetId;
}
示例6: processMembership
/**
* Process membership records.
*
* @param array $params
* Associated array of submitted values.
*
*
* @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 membership
$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]);
$fDate[$dateField] = CRM_Utils_Array::value($dateField, $value);
}
$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], $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 (!empty($params['soft_credit_contact_id'][$key]) && !empty($params['soft_credit_amount'][$key])) {
$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]);
//CRM-15350: if soft-credit-type profile field is disabled or removed then
//we choose Gift as default value as per Gift Membership rule
if (!empty($params['soft_credit_type'][$key])) {
$value['soft_credit'][$key]['soft_credit_type_id'] = $params['soft_credit_type'][$key];
} else {
$value['soft_credit'][$key]['soft_credit_type_id'] = CRM_Core_OptionGroup::getValue('soft_credit_type', 'Gift', 'name');
}
}
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);
//.........这里部分代码省略.........
示例7: 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;
}
示例8: 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]);
//.........这里部分代码省略.........
示例9: submit
/**
* @param array $submittedValues
*
* @param int $action
* Action constant
* - CRM_Core_Action::UPDATE
*
* @param $pledgePaymentID
*
* @return array
* @throws \Exception
*/
protected function submit($submittedValues, $action, $pledgePaymentID)
{
$softParams = $softIDs = array();
$pId = $contribution = $isRelatedId = FALSE;
$this->_params = $submittedValues;
$this->beginPostProcess();
if (!empty($submittedValues['price_set_id']) && $action & CRM_Core_Action::UPDATE) {
$line = CRM_Price_BAO_LineItem::getLineItems($this->_id, 'contribution');
$lineID = key($line);
$priceSetId = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceField', CRM_Utils_Array::value('price_field_id', $line[$lineID]), 'price_set_id');
$quickConfig = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $priceSetId, 'is_quick_config');
// Why do we do this? Seems like a like a wrapper for old functionality - but single line price sets & quick
// config should be treated the same.
if ($quickConfig) {
CRM_Price_BAO_LineItem::deleteLineItems($this->_id, 'civicrm_contribution');
}
}
// Process price set and get total amount and line items.
$lineItem = array();
$priceSetId = CRM_Utils_Array::value('price_set_id', $submittedValues);
if (empty($priceSetId) && !$this->_id) {
$this->_priceSetId = $priceSetId = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', 'default_contribution_amount', 'id', 'name');
$this->_priceSet = current(CRM_Price_BAO_PriceSet::getSetDetail($priceSetId));
$fieldID = key($this->_priceSet['fields']);
$fieldValueId = key($this->_priceSet['fields'][$fieldID]['options']);
$this->_priceSet['fields'][$fieldID]['options'][$fieldValueId]['amount'] = $submittedValues['total_amount'];
$submittedValues['price_' . $fieldID] = 1;
}
// Every contribution has a price-set - the only reason it shouldn't be set is if we are dealing with
// quick config (very very arguably) & yet we see that this could still be quick config so this should be understood
// as a point of fragility rather than a logical 'if' clause.
if ($priceSetId) {
CRM_Price_BAO_PriceSet::processAmount($this->_priceSet['fields'], $submittedValues, $lineItem[$priceSetId]);
// Unset tax amount for offline 'is_quick_config' contribution.
// @todo WHY - quick config was conceived as a quick way to configure contribution forms.
// this is an example of 'other' functionality being hung off it.
if ($this->_priceSet['is_quick_config'] && !array_key_exists($submittedValues['financial_type_id'], CRM_Core_PseudoConstant::getTaxRates())) {
unset($submittedValues['tax_amount']);
}
$submittedValues['total_amount'] = CRM_Utils_Array::value('amount', $submittedValues);
}
if ($this->_id) {
if ($this->_compId) {
if ($this->_context == 'participant') {
$pId = $this->_compId;
} elseif ($this->_context == 'membership') {
$isRelatedId = TRUE;
} else {
$pId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $this->_id, 'participant_id', 'contribution_id');
}
} else {
$contributionDetails = CRM_Contribute_BAO_Contribution::getComponentDetails($this->_id);
if (array_key_exists('membership', $contributionDetails)) {
$isRelatedId = TRUE;
} elseif (array_key_exists('participant', $contributionDetails)) {
$pId = $contributionDetails['participant'];
}
}
}
if (!$priceSetId && !empty($submittedValues['total_amount']) && $this->_id) {
// CRM-10117 update the line items for participants.
// @todo - if we are completing a contribution then the api call
// civicrm_api3('Contribution', 'completetransaction') should take care of
// all associated updates rather than replicating them on the form layer.
if ($pId) {
$entityTable = 'participant';
$entityID = $pId;
$isRelatedId = FALSE;
$participantParams = array('fee_amount' => $submittedValues['total_amount'], 'id' => $entityID);
CRM_Event_BAO_Participant::add($participantParams);
if (empty($this->_lineItems)) {
$this->_lineItems[] = CRM_Price_BAO_LineItem::getLineItems($entityID, 'participant', 1);
}
} else {
$entityTable = 'contribution';
$entityID = $this->_id;
}
$lineItems = CRM_Price_BAO_LineItem::getLineItems($entityID, $entityTable, NULL, TRUE, $isRelatedId);
foreach (array_keys($lineItems) as $id) {
$lineItems[$id]['id'] = $id;
}
$itemId = key($lineItems);
if ($itemId && !empty($lineItems[$itemId]['price_field_id'])) {
$this->_priceSetId = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceField', $lineItems[$itemId]['price_field_id'], 'price_set_id');
}
// @todo see above - new functionality has been inappropriately added to the quick config concept
// and new functionality has been added onto the form layer rather than the BAO :-(
if ($this->_priceSetId && CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $this->_priceSetId, 'is_quick_config')) {
//.........这里部分代码省略.........
示例10: submit
/**
* @param array $submittedValues
*
* @param int $action
* Action constant
* - CRM_Core_Action::UPDATE
*
* @param $pledgePaymentID
*
* @return array
* @throws \Exception
*/
protected function submit($submittedValues, $action, $pledgePaymentID)
{
$softParams = $softIDs = array();
$pId = $contribution = $isRelatedId = FALSE;
if (!empty($submittedValues['price_set_id']) && $action & CRM_Core_Action::UPDATE) {
$line = CRM_Price_BAO_LineItem::getLineItems($this->_id, 'contribution');
$lineID = key($line);
$priceSetId = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceField', CRM_Utils_Array::value('price_field_id', $line[$lineID]), 'price_set_id');
$quickConfig = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $priceSetId, 'is_quick_config');
if ($quickConfig) {
CRM_Price_BAO_LineItem::deleteLineItems($this->_id, 'civicrm_contribution');
}
}
// Process price set and get total amount and line items.
$lineItem = array();
$priceSetId = CRM_Utils_Array::value('price_set_id', $submittedValues);
if (empty($priceSetId) && !$this->_id) {
$this->_priceSetId = $priceSetId = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', 'default_contribution_amount', 'id', 'name');
$this->_priceSet = current(CRM_Price_BAO_PriceSet::getSetDetail($priceSetId));
$fieldID = key($this->_priceSet['fields']);
$fieldValueId = key($this->_priceSet['fields'][$fieldID]['options']);
$this->_priceSet['fields'][$fieldID]['options'][$fieldValueId]['amount'] = $submittedValues['total_amount'];
$submittedValues['price_' . $fieldID] = 1;
}
if ($priceSetId) {
CRM_Price_BAO_PriceSet::processAmount($this->_priceSet['fields'], $submittedValues, $lineItem[$priceSetId]);
// Unset tax amount for offline 'is_quick_config' contribution.
if ($this->_priceSet['is_quick_config'] && !array_key_exists($submittedValues['financial_type_id'], CRM_Core_PseudoConstant::getTaxRates())) {
unset($submittedValues['tax_amount']);
}
$submittedValues['total_amount'] = CRM_Utils_Array::value('amount', $submittedValues);
}
if ($this->_id) {
if ($this->_compId) {
if ($this->_context == 'participant') {
$pId = $this->_compId;
} elseif ($this->_context == 'membership') {
$isRelatedId = TRUE;
} else {
$pId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $this->_id, 'participant_id', 'contribution_id');
}
} else {
$contributionDetails = CRM_Contribute_BAO_Contribution::getComponentDetails($this->_id);
if (array_key_exists('membership', $contributionDetails)) {
$isRelatedId = TRUE;
} elseif (array_key_exists('participant', $contributionDetails)) {
$pId = $contributionDetails['participant'];
}
}
}
if (!$priceSetId && !empty($submittedValues['total_amount']) && $this->_id) {
// CRM-10117 update the line items for participants.
if ($pId) {
$entityTable = 'participant';
$entityID = $pId;
$isRelatedId = FALSE;
$participantParams = array('fee_amount' => $submittedValues['total_amount'], 'id' => $entityID);
CRM_Event_BAO_Participant::add($participantParams);
if (empty($this->_lineItems)) {
$this->_lineItems[] = CRM_Price_BAO_LineItem::getLineItems($entityID, 'participant', 1);
}
} else {
$entityTable = 'contribution';
$entityID = $this->_id;
}
$lineItems = CRM_Price_BAO_LineItem::getLineItems($entityID, $entityTable, NULL, TRUE, $isRelatedId);
foreach (array_keys($lineItems) as $id) {
$lineItems[$id]['id'] = $id;
}
$itemId = key($lineItems);
if ($itemId && !empty($lineItems[$itemId]['price_field_id'])) {
$this->_priceSetId = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceField', $lineItems[$itemId]['price_field_id'], 'price_set_id');
}
if ($this->_priceSetId && CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $this->_priceSetId, 'is_quick_config')) {
$lineItems[$itemId]['unit_price'] = $lineItems[$itemId]['line_total'] = CRM_Utils_Rule::cleanMoney(CRM_Utils_Array::value('total_amount', $submittedValues));
// Update line total and total amount with tax on edit.
$financialItemsId = CRM_Core_PseudoConstant::getTaxRates();
if (array_key_exists($submittedValues['financial_type_id'], $financialItemsId)) {
$lineItems[$itemId]['tax_rate'] = $financialItemsId[$submittedValues['financial_type_id']];
} else {
$lineItems[$itemId]['tax_rate'] = $lineItems[$itemId]['tax_amount'] = "";
$submittedValues['tax_amount'] = 'null';
}
if ($lineItems[$itemId]['tax_rate']) {
$lineItems[$itemId]['tax_amount'] = $lineItems[$itemId]['tax_rate'] / 100 * $lineItems[$itemId]['line_total'];
$submittedValues['total_amount'] = $lineItems[$itemId]['line_total'] + $lineItems[$itemId]['tax_amount'];
$submittedValues['tax_amount'] = $lineItems[$itemId]['tax_amount'];
}
//.........这里部分代码省略.........
示例11: 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_PriceSet::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']}";
}
}
}
}
}
示例12: initEventFee
/**
* @param $form
* @param $eventID
*
* @throws Exception
*/
static function initEventFee(&$form, $eventID)
{
// get price info
// retrive all active price set fields.
$discountId = CRM_Core_BAO_Discount::findSet($eventID, 'civicrm_event');
if (property_exists($form, '_discountId') && $form->_discountId) {
$discountId = $form->_discountId;
}
if ($discountId) {
$priceSetId = CRM_Core_DAO::getFieldValue('CRM_Core_BAO_Discount', $discountId, 'price_set_id');
$price = CRM_Price_BAO_PriceSet::initSet($form, $eventID, 'civicrm_event', TRUE, $priceSetId);
} else {
$price = CRM_Price_BAO_PriceSet::initSet($form, $eventID, 'civicrm_event', TRUE);
}
if (property_exists($form, '_context') && ($form->_context == 'standalone' || $form->_context == 'participant')) {
$discountedEvent = CRM_Core_BAO_Discount::getOptionGroup($eventID, 'civicrm_event');
if (is_array($discountedEvent)) {
foreach ($discountedEvent as $key => $priceSetId) {
$priceSet = CRM_Price_BAO_PriceSet::getSetDetail($priceSetId);
$priceSet = CRM_Utils_Array::value($priceSetId, $priceSet);
$form->_values['discount'][$key] = CRM_Utils_Array::value('fields', $priceSet);
$fieldID = key($form->_values['discount'][$key]);
$form->_values['discount'][$key][$fieldID]['name'] = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $priceSetId, 'title');
}
}
}
$eventFee = CRM_Utils_Array::value('fee', $form->_values);
if (!is_array($eventFee) || empty($eventFee)) {
$form->_values['fee'] = array();
}
//fix for non-upgraded price sets.CRM-4256.
if (isset($form->_isPaidEvent)) {
$isPaidEvent = $form->_isPaidEvent;
} else {
$isPaidEvent = CRM_Utils_Array::value('is_monetary', $form->_values['event']);
}
if ($isPaidEvent && empty($form->_values['fee'])) {
if (CRM_Utils_System::getClassName($form) != 'CRM_Event_Form_Participant') {
CRM_Core_Error::fatal(ts('No Fee Level(s) or Price Set is configured for this event.<br />Click <a href=\'%1\'>CiviEvent >> Manage Event >> Configure >> Event Fees</a> to configure the Fee Level(s) or Price Set for this event.', array(1 => CRM_Utils_System::url('civicrm/event/manage/fee', 'reset=1&action=update&id=' . $form->_eventId))));
}
}
}
示例13: submit
/**
* Static submit function allowing tests (& api access although this is being built slowly)
* @param $params
*/
static function submit($params)
{
$form = new CRM_Contribute_Form_Contribution_Confirm();
$form->_id = $params['id'];
CRM_Contribute_BAO_ContributionPage::setValues($form->_id, $form->_values);
$form->_separateMembershipPayment = CRM_Contribute_BAO_ContributionPage::getIsMembershipPayment($form->_id);
//this way the mocked up controller ignores the session stuff
$_SERVER['REQUEST_METHOD'] = 'GET';
$form->controller = new CRM_Contribute_Controller_Contribution();
$params['invoiceID'] = md5(uniqid(rand(), TRUE));
$paramsProcessedForForm = $form->_params = self::getFormParams($params['id'], $params);
$form->_amount = $params['amount'];
$priceSetID = $form->_params['priceSetId'] = $paramsProcessedForForm['price_set_id'];
$priceFields = CRM_Price_BAO_PriceSet::getSetDetail($priceSetID);
$priceSetFields = reset($priceFields);
$form->_values['fee'] = $priceSetFields['fields'];
$form->_priceSetId = $priceSetID;
$form->setFormAmountFields($priceSetID);
if (!empty($params['payment_processor'])) {
$form->_paymentProcessor = civicrm_api3('payment_processor', 'getsingle', array('id' => $params['payment_processor']));
}
$priceFields = $priceFields[$priceSetID]['fields'];
CRM_Price_BAO_PriceSet::processAmount($priceFields, $paramsProcessedForForm, $lineItems, 'civicrm_contribution');
$form->_lineItem = array($priceSetID => $lineItems);
$form->postProcess();
}
示例14: process_event_line_item
/**
* Process line item for event.
*
* @param bool $event_in_cart
* @param string $class
*/
public function process_event_line_item(&$event_in_cart, $class = NULL)
{
$cost = 0;
$price_set_id = CRM_Price_BAO_PriceSet::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_PriceSet::getSetDetail($price_set_id, TRUE);
$price_set = $price_sets[$price_set_id];
$price_set_amount = array();
CRM_Price_BAO_PriceSet::processAmount($price_set['fields'], $event_price_values, $price_set_amount);
$discountCode = $this->_price_values['discountcode'];
if (!empty($discountCode)) {
$ret = $this->apply_discount($discountCode, $price_set_amount, $cost, $event_in_cart->event_id);
if ($ret == FALSE) {
$cost = $event_price_values['amount'];
}
} else {
$cost = $event_price_values['amount'];
}
// @todo - stop setting amount level in this function & call the CRM_Price_BAO_PriceSet::getAmountLevel
// function to get correct amount level consistently. Remove setting of the amount level in
// CRM_Price_BAO_PriceSet::processAmount. Extend the unit tests in CRM_Price_BAO_PriceSetTest
// to cover all variants.
$amount_level = $event_price_values['amount_level'];
$price_details[$price_set_id] = $price_set_amount;
}
// iterate over each participant in event
foreach ($event_in_cart->participants as &$participant) {
$participant->cost = $cost;
$participant->fee_level = $amount_level;
$participant->price_details = $price_details;
}
$this->add_line_item($event_in_cart, $class);
}
示例15: postProcess
/**
* Process the form submission.
*/
public function postProcess()
{
$sendReceipt = $pId = $contribution = $isRelatedId = FALSE;
$softParams = $softIDs = array();
if ($this->_action & CRM_Core_Action::DELETE) {
CRM_Contribute_BAO_Contribution::deleteContribution($this->_id);
CRM_Core_Session::singleton()->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 (!empty($submittedValues['price_set_id']) && $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_PriceField', CRM_Utils_Array::value('price_field_id', $line[$lineID]), 'price_set_id');
$quickConfig = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $priceSetId, 'is_quick_config');
if ($quickConfig) {
CRM_Price_BAO_LineItem::deleteLineItems($this->_id, 'civicrm_contribution');
}
}
// Process price set and get total amount and line items.
$lineItem = array();
$priceSetId = CRM_Utils_Array::value('price_set_id', $submittedValues);
if (empty($priceSetId) && !$this->_id) {
$this->_priceSetId = $priceSetId = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', 'default_contribution_amount', 'id', 'name');
$this->_priceSet = current(CRM_Price_BAO_PriceSet::getSetDetail($priceSetId));
$fieldID = key($this->_priceSet['fields']);
$fieldValueId = key($this->_priceSet['fields'][$fieldID]['options']);
$this->_priceSet['fields'][$fieldID]['options'][$fieldValueId]['amount'] = $submittedValues['total_amount'];
$submittedValues['price_' . $fieldID] = 1;
}
if ($priceSetId) {
CRM_Price_BAO_PriceSet::processAmount($this->_priceSet['fields'], $submittedValues, $lineItem[$priceSetId]);
// Unset tax amount for offline 'is_quick_config' contribution.
if ($this->_priceSet['is_quick_config'] && !array_key_exists($submittedValues['financial_type_id'], CRM_Core_PseudoConstant::getTaxRates())) {
unset($submittedValues['tax_amount']);
}
$submittedValues['total_amount'] = CRM_Utils_Array::value('amount', $submittedValues);
}
if ($this->_id) {
if ($this->_compId) {
if ($this->_context == 'participant') {
$pId = $this->_compId;
} elseif ($this->_context == 'membership') {
$isRelatedId = TRUE;
} else {
$pId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $this->_id, 'participant_id', 'contribution_id');
}
} else {
$contributionDetails = CRM_Contribute_BAO_Contribution::getComponentDetails($this->_id);
if (array_key_exists('membership', $contributionDetails)) {
$isRelatedId = TRUE;
} elseif (array_key_exists('participant', $contributionDetails)) {
$pId = $contributionDetails['participant'];
}
}
}
if (!$priceSetId && !empty($submittedValues['total_amount']) && $this->_id) {
// CRM-10117 update the line items for participants.
if ($pId) {
$entityTable = 'participant';
$entityID = $pId;
$isRelatedId = FALSE;
$participantParams = array('fee_amount' => $submittedValues['total_amount'], 'id' => $entityID);
CRM_Event_BAO_Participant::add($participantParams);
if (empty($this->_lineItems)) {
$this->_lineItems[] = CRM_Price_BAO_LineItem::getLineItems($entityID, 'participant', 1);
}
} else {
$entityTable = 'contribution';
$entityID = $this->_id;
}
$lineItems = CRM_Price_BAO_LineItem::getLineItems($entityID, $entityTable, NULL, TRUE, $isRelatedId);
foreach (array_keys($lineItems) as $id) {
$lineItems[$id]['id'] = $id;
}
$itemId = key($lineItems);
if ($itemId && !empty($lineItems[$itemId]['price_field_id'])) {
$this->_priceSetId = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceField', $lineItems[$itemId]['price_field_id'], 'price_set_id');
}
if ($this->_priceSetId && CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $this->_priceSetId, 'is_quick_config')) {
$lineItems[$itemId]['unit_price'] = $lineItems[$itemId]['line_total'] = CRM_Utils_Rule::cleanMoney(CRM_Utils_Array::value('total_amount', $submittedValues));
// Update line total and total amount with tax on edit.
$financialItemsId = CRM_Core_PseudoConstant::getTaxRates();
if (array_key_exists($submittedValues['financial_type_id'], $financialItemsId)) {
$lineItems[$itemId]['tax_rate'] = $financialItemsId[$submittedValues['financial_type_id']];
} else {
$lineItems[$itemId]['tax_rate'] = $lineItems[$itemId]['tax_amount'] = "";
$submittedValues['tax_amount'] = 'null';
}
if ($lineItems[$itemId]['tax_rate']) {
$lineItems[$itemId]['tax_amount'] = $lineItems[$itemId]['tax_rate'] / 100 * $lineItems[$itemId]['line_total'];
$submittedValues['total_amount'] = $lineItems[$itemId]['line_total'] + $lineItems[$itemId]['tax_amount'];
$submittedValues['tax_amount'] = $lineItems[$itemId]['tax_amount'];
}
}
// CRM-10117 update the line items for participants.
//.........这里部分代码省略.........