本文整理汇总了PHP中CRM_Price_BAO_Set::processAmount方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Price_BAO_Set::processAmount方法的具体用法?PHP CRM_Price_BAO_Set::processAmount怎么用?PHP CRM_Price_BAO_Set::processAmount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Price_BAO_Set
的用法示例。
在下文中一共展示了CRM_Price_BAO_Set::processAmount方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
//.........这里部分代码省略.........
示例2: postProcess
/**
* Function to process the form
*
* @access public
*
* @return None
*/
public function postProcess()
{
if ($this->_action & CRM_Core_Action::DELETE) {
CRM_Member_BAO_Membership::deleteRelatedMemberships($this->_id);
CRM_Member_BAO_Membership::deleteMembership($this->_id);
return;
}
$config = CRM_Core_Config::singleton();
// get the submitted form values.
$this->_params = $formValues = $this->controller->exportValues($this->_name);
$params = $ids = array();
$membershipTypeValues = array();
foreach ($this->_memTypeSelected as $memType) {
$membershipTypeValues[$memType]['membership_type_id'] = $memType;
}
//take the required membership recur values.
if ($this->_mode && CRM_Utils_Array::value('auto_renew', $this->_params)) {
$params['is_recur'] = $this->_params['is_recur'] = $formValues['is_recur'] = TRUE;
$mapping = array('frequency_interval' => 'duration_interval', 'frequency_unit' => 'duration_unit');
$count = 0;
foreach ($this->_memTypeSelected as $memType) {
$recurMembershipTypeValues = CRM_Utils_Array::value($memType, $this->_recurMembershipTypes, array());
foreach ($mapping as $mapVal => $mapParam) {
$membershipTypeValues[$memType][$mapVal] = CRM_Utils_Array::value($mapParam, $recurMembershipTypeValues);
if (!$count) {
$this->_params[$mapVal] = $formValues[$mapVal] = CRM_Utils_Array::value($mapParam, $recurMembershipTypeValues);
}
}
$count++;
}
// unset send-receipt option, since receipt will be sent when ipn is received.
unset($this->_params['send_receipt'], $formValues['send_receipt']);
}
// process price set and get total amount and line items.
$lineItem = array();
$priceSetId = NULL;
if (!($priceSetId = CRM_Utils_Array::value('price_set_id', $formValues))) {
CRM_Member_BAO_Membership::createLineItems($this, $formValues['membership_type_id'], $priceSetId);
}
if ($priceSetId) {
CRM_Price_BAO_Set::processAmount($this->_priceSet['fields'], $this->_params, $lineItem[$priceSetId]);
$params['total_amount'] = CRM_Utils_Array::value('amount', $this->_params);
}
$this->storeContactFields($formValues);
$params['contact_id'] = $this->_contactID;
$fields = array('status_id', 'source', 'is_override', 'campaign_id');
foreach ($fields as $f) {
$params[$f] = CRM_Utils_Array::value($f, $formValues);
}
// fix for CRM-3724
// when is_override false ignore is_admin statuses during membership
// status calculation. similarly we did fix for import in CRM-3570.
if (!CRM_Utils_Array::value('is_override', $params)) {
$params['exclude_is_admin'] = TRUE;
}
// process date params to mysql date format.
$dateTypes = array('join_date' => 'joinDate', 'start_date' => 'startDate', 'end_date' => 'endDate');
foreach ($dateTypes as $dateField => $dateVariable) {
${$dateVariable} = CRM_Utils_Date::processDate($formValues[$dateField]);
}
$dates = array('join_date', 'start_date', 'end_date', 'reminder_date');
$calcDates = array();
foreach ($this->_memTypeSelected as $memType) {
$calcDates[$memType] = CRM_Member_BAO_MembershipType::getDatesForMembershipType($memType, $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, $formValues);
if (!$date) {
$date = CRM_Utils_Array::value($d, $calcDate);
}
$membershipTypeValues[$memType][$d] = CRM_Utils_Date::processDate($date);
//$params[$d] = CRM_Utils_Date::processDate( $date );
}
}
if ($this->_id) {
$ids['membership'] = $params['id'] = $this->_id;
}
$session = CRM_Core_Session::singleton();
$ids['userId'] = $session->get('userID');
// membership type custom data
foreach ($this->_memTypeSelected as $memType) {
$customFields = CRM_Core_BAO_CustomField::getFields('Membership', FALSE, FALSE, $memType);
$customFields = CRM_Utils_Array::crmArrayMerge($customFields, CRM_Core_BAO_CustomField::getFields('Membership', FALSE, FALSE, NULL, NULL, TRUE));
$membershipTypeValues[$memType]['custom'] = CRM_Core_BAO_CustomField::postProcess($formValues, $customFields, $this->_id, 'Membership');
}
foreach ($this->_memTypeSelected as $memType) {
$membershipTypes[$memType] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $memType);
}
$membershipType = implode(', ', $membershipTypes);
// Retrieve the name and email of the current user - this will be the FROM for the receipt email
list($userName, $userEmail) = CRM_Contact_BAO_Contact_Location::getEmailDetails($ids['userId']);
//.........这里部分代码省略.........
示例3: postProcess
/**
* Function to process the form
*
* @access public
*/
public function postProcess()
{
if ($this->_action & CRM_Core_Action::DELETE) {
require_once "CRM/Event/BAO/Participant.php";
CRM_Event_BAO_Participant::deleteParticipant($this->_participantId);
return;
}
// get the submitted form values.
$params = $this->controller->exportValues($this->_name);
// set the contact, when contact is selected
if (CRM_Utils_Array::value('contact_select_id', $params)) {
$this->_contactID = CRM_Utils_Array::value('contact_select_id', $params);
}
$config =& CRM_Core_Config::singleton();
//check if discount is selected
if (CRM_Utils_Array::value('discount_id', $params)) {
$discountId = $params['discount_id'];
} else {
$params['discount_id'] = 'null';
$discountId = null;
}
if ($this->_isPaidEvent) {
//lets carry currency, CRM-4453
$params['fee_currency'] = $config->defaultCurrency;
// fix for CRM-3088
if ($discountId && !empty($this->_values['discount'][$discountId])) {
$params['amount_level'] = $this->_values['discount'][$discountId][$params['amount']]['label'];
$params['amount'] = $this->_values['discount'][$discountId][$params['amount']]['value'];
$this->assign('amount_level', $params['amount_level']);
} else {
if (!isset($params['priceSetId'])) {
$params['amount_level'] = $this->_values['fee'][$params['amount']]['label'];
$params['amount'] = $this->_values['fee'][$params['amount']]['value'];
$this->assign('amount_level', $params['amount_level']);
} else {
if (!$this->_online) {
$lineItem = array();
CRM_Price_BAO_Set::processAmount($this->_values['fee']['fields'], $params, $lineItem[0]);
$this->set('lineItem', $lineItem);
$this->assign('lineItem', $lineItem);
$this->_lineItem = $lineItem;
}
}
}
$params['fee_level'] = $params['amount_level'];
$contributionParams = array();
$contributionParams['total_amount'] = $params['amount'];
}
//fix for CRM-3086
$params['fee_amount'] = $params['amount'];
$this->_params = $params;
unset($params['amount']);
$params['register_date'] = CRM_Utils_Date::processDate($params['register_date'], $params['register_date_time']);
$params['receive_date'] = CRM_Utils_Date::processDate(CRM_Utils_Array::value('receive_date', $params));
$params['contact_id'] = $this->_contactID;
if ($this->_participantId) {
$params['id'] = $this->_participantId;
}
$status = null;
if ($this->_action & CRM_Core_Action::UPDATE) {
$participantBAO =& new CRM_Event_BAO_Participant();
$participantBAO->id = $this->_participantId;
$participantBAO->find();
while ($participantBAO->fetch()) {
$status = $participantBAO->status_id;
$contributionParams['total_amount'] = $participantBAO->fee_amount;
}
$params['discount_id'] = null;
//re-enter the values for UPDATE mode
$params['fee_level'] = $params['amount_level'] = $participantBAO->fee_level;
$params['fee_amount'] = $participantBAO->fee_amount;
}
require_once 'CRM/Contact/BAO/Contact.php';
// Retrieve the name and email of the current user - this will be the FROM for the receipt email
$session =& CRM_Core_Session::singleton();
$userID = $session->get('userID');
list($userName, $userEmail) = CRM_Contact_BAO_Contact_Location::getEmailDetails($userID);
require_once "CRM/Event/BAO/Participant.php";
if ($this->_mode) {
if (!$this->_isPaidEvent) {
CRM_Core_Error::fatal(ts('Selected Event is not Paid Event '));
}
//modify params according to parameter used in create
//participant method (addParticipant)
$params['participant_status_id'] = $params['status_id'];
$params['participant_role_id'] = $params['role_id'];
$params['participant_register_date'] = $params['register_date'];
$params['participant_source'] = $params['source'];
require_once 'CRM/Core/BAO/PaymentProcessor.php';
$this->_paymentProcessor = CRM_Core_BAO_PaymentProcessor::getPayment($this->_params['payment_processor_id'], $this->_mode);
require_once "CRM/Contact/BAO/Contact.php";
$now = date('YmdHis');
$fields = array();
// set email for primary location.
$fields["email-Primary"] = 1;
//.........这里部分代码省略.........
示例4: 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'])) {
$params['amount_level'] = $this->_values['fee'][$params['amount']]['label'];
$params['amount'] = $this->_values['fee'][$params['amount']]['value'];
} else {
$lineItem = array();
CRM_Price_BAO_Set::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}"]) {
$params["state_province-{$this->_bltID}"] = CRM_Core_PseudoConstant::stateProvinceAbbreviation($params["state_province_id-{$this->_bltID}"]);
}
if (isset($params["country_id-{$this->_bltID}"]) && $params["country_id-{$this->_bltID}"]) {
$params["country-{$this->_bltID}"] = CRM_Core_PseudoConstant::countryIsoCode($params["country_id-{$this->_bltID}"]);
//.........这里部分代码省略.........
示例5: 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'])) {
$params['amount_level'] = $this->_values['fee'][$params['amount']]['label'];
$params['amount'] = $this->_values['fee'][$params['amount']]['value'];
} else {
$lineItem = array();
require_once 'CRM/Price/BAO/Set.php';
CRM_Price_BAO_Set::processAmount($this->_values['fee']['fields'], $params, $lineItem);
//build the line item..
if (array_key_exists($addParticipantNum, $this->_lineItem)) {
$this->_lineItem[$addParticipantNum] = $lineItem;
} else {
$this->_lineItem[] = $lineItem;
}
}
}
}
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'];
}
if (CRM_Utils_Array::value('is_pay_later', $this->_params[0])) {
$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;
}
//build the params array.
if (array_key_exists($addParticipantNum, $this->_params)) {
$this->_params[$addParticipantNum] = $params;
} else {
$this->_params[] = $params;
}
}
//finally set the params.
$this->set('params', $this->_params);
//set the line item.
if ($this->_lineItem) {
$this->set('lineItem', $this->_lineItem);
}
$participantNo = count($this->_params);
if ($button != 'skip') {
require_once "CRM/Core/Session.php";
$statusMsg = ts('Registration information for participant %1 has been saved.', array(1 => $participantNo));
CRM_Core_Session::setStatus("{$statusMsg}");
}
//to check whether call processRegistration()
if (!$this->_values['event']['is_monetary'] && CRM_Utils_Array::value('additional_participants', $this->_params[0]) && $this->isLastParticipant()) {
require_once 'CRM/Event/Form/Registration/Register.php';
CRM_Event_Form_Registration_Register::processRegistration($this->_params, null);
}
}
示例6: 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;
//hack to allow group to register w/ waiting
if (!$this->_allowConfirmation && CRM_Utils_Array::value('bypass_payment', $params) && is_numeric($this->_availableRegistrations) && CRM_Utils_Array::value('additional_participants', $params) >= $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_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'];
}
if ($this->_values['event']['is_monetary']) {
$config =& CRM_Core_Config::singleton();
// we first reset the confirm page so it accepts new values
$this->controller->resetPage('Confirm');
// get the submitted form values.
$params['currencyID'] = $config->defaultCurrency;
//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'])) {
$params['amount_level'] = $this->_values['fee'][$params['amount']]['label'];
$params['amount'] = $this->_values['fee'][$params['amount']]['value'];
} else {
$lineItem = array();
require_once "CRM/Price/BAO/Set.php";
CRM_Price_BAO_Set::processAmount($this->_values['fee']['fields'], $params, $lineItem);
$priceSet = array();
$priceSet[] = $lineItem;
$this->set('lineItem', $priceSet);
}
}
$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, 'Event', $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}"]) {
$params["state_province-{$this->_bltID}"] = CRM_Core_PseudoConstant::stateProvinceAbbreviation($params["state_province_id-{$this->_bltID}"]);
}
if (isset($params["country_id-{$this->_bltID}"]) && $params["country_id-{$this->_bltID}"]) {
$params["country-{$this->_bltID}"] = CRM_Core_PseudoConstant::countryIsoCode($params["country_id-{$this->_bltID}"]);
}
if (isset($params['credit_card_exp_date'])) {
$params['year'] = $params['credit_card_exp_date']['Y'];
$params['month'] = $params['credit_card_exp_date']['M'];
}
if ($this->_values['event']['is_monetary']) {
$params['ip_address'] = CRM_Utils_System::ipAddress();
$params['currencyID'] = $config->defaultCurrency;
$params['payment_action'] = 'Sale';
$params['invoiceID'] = $invoiceID;
}
$this->_params = array();
$this->_params[] = $params;
$this->set('params', $this->_params);
if ($this->_paymentProcessor['billing_mode'] & CRM_Core_Payment::BILLING_MODE_BUTTON) {
//get the button name
$buttonName = $this->controller->getButtonName();
if (in_array($buttonName, array($this->_expressButtonName, $this->_expressButtonName . '_x', $this->_expressButtonName . '_y')) && !isset($params['is_pay_later']) && !$this->_allowWaitlist && !$this->_requireApproval) {
$this->set('contributeMode', 'express');
// Send Event Name & Id in Params
$params['eventName'] = $this->_values['event']['title'];
$params['eventId'] = $this->_values['event']['id'];
$params['cancelURL'] = CRM_Utils_System::url('civicrm/event/register', '_qf_Register_display=1', true, null, false);
if (CRM_Utils_Array::value('additional_participants', $params, false)) {
$urlArgs = "_qf_Participant_1_display=1&rfp=1&qfKey={$this->controller->_key}";
} else {
$urlArgs = '_qf_Confirm_display=1&rfp=1';
}
$params['returnURL'] = CRM_Utils_System::url('civicrm/event/register', $urlArgs, true, null, false);
$params['invoiceID'] = $invoiceID;
//default action is Sale
//.........这里部分代码省略.........
示例7: postProcess
//.........这里部分代码省略.........
$fieldId = $fieldVal['id'];
$fieldOption = $params['price_' . $fieldId];
$memPresent = TRUE;
} else {
if (CRM_Utils_Array::value('price_' . $fieldKey, $params) && $memPresent && ($fieldVal['name'] == 'other_amount' || $fieldVal['name'] == 'contribution_amount')) {
$fieldId = $fieldVal['id'];
if ($fieldVal['name'] == 'other_amount') {
$proceFieldAmount = $this->_submitValues['price_' . $fieldId];
} else {
$proceFieldAmount = $fieldVal['options'][$this->_submitValues['price_' . $fieldId]]['amount'];
}
unset($params['price_' . $fieldId]);
break;
}
}
}
}
}
if (!isset($params['amount_other'])) {
$this->set('amount_level', CRM_Utils_Array::value('amount_level', $params));
}
if ($priceSetId = CRM_Utils_Array::value('priceSetId', $params)) {
$lineItem = array();
$is_quick_config = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_Set', $priceSetId, 'is_quick_config');
if ($is_quick_config) {
foreach ($this->_values['fee'] as $key => &$val) {
if ($val['name'] == 'other_amount' && $val['html_type'] == 'Text' && array_key_exists('price_' . $key, $params) && $params['price_' . $key] != 0) {
foreach ($val['options'] as $optionKey => &$options) {
$options['amount'] = CRM_Utils_Array::value('price_' . $key, $params);
break;
}
$params['price_' . $key] = 1;
break;
}
}
}
CRM_Price_BAO_Set::processAmount($this->_values['fee'], $params, $lineItem[$priceSetId]);
if ($proceFieldAmount) {
$lineItem[$params['priceSetId']][$fieldOption]['line_total'] = $proceFieldAmount;
$lineItem[$params['priceSetId']][$fieldOption]['unit_price'] = $proceFieldAmount;
if (!$this->_membershipBlock['is_separate_payment']) {
$params['amount'] = $proceFieldAmount;
//require when separate membership not used
}
}
$this->set('lineItem', $lineItem);
}
if ($this->_membershipBlock['is_separate_payment'] && CRM_Utils_Array::value('separate_amount', $params)) {
$this->set('amount', $params['separate_amount']);
} else {
$this->set('amount', $params['amount']);
}
// generate and set an invoiceID for this transaction
$invoiceID = md5(uniqid(rand(), TRUE));
$this->set('invoiceID', $invoiceID);
// required only if is_monetary and valid postive amount
if ($this->_values['is_monetary'] && is_array($this->_paymentProcessor) && ((double) $params['amount'] > 0.0 || $memFee > 0.0)) {
// default mode is direct
$this->set('contributeMode', 'direct');
if ($this->_paymentProcessor['billing_mode'] & CRM_Core_Payment::BILLING_MODE_BUTTON) {
//get the button name
$buttonName = $this->controller->getButtonName();
if (in_array($buttonName, array($this->_expressButtonName, $this->_expressButtonName . '_x', $this->_expressButtonName . '_y')) && !CRM_Utils_Array::value('is_pay_later', $params)) {
$this->set('contributeMode', 'express');
$donateURL = CRM_Utils_System::url('civicrm/contribute', '_qf_Contribute_display=1');
$params['cancelURL'] = CRM_Utils_System::url('civicrm/contribute/transact', "_qf_Main_display=1&qfKey={$params['qfKey']}", TRUE, NULL, FALSE);
$params['returnURL'] = CRM_Utils_System::url('civicrm/contribute/transact', "_qf_Confirm_display=1&rfp=1&qfKey={$params['qfKey']}", TRUE, NULL, FALSE);
$params['invoiceID'] = $invoiceID;
//default action is Sale
$params['payment_action'] = 'Sale';
$payment = CRM_Core_Payment::singleton($this->_mode, $this->_paymentProcessor, $this);
$token = $payment->setExpressCheckout($params);
if (is_a($token, 'CRM_Core_Error')) {
CRM_Core_Error::displaySessionError($token);
CRM_Utils_System::redirect($params['cancelURL']);
}
$this->set('token', $token);
$paymentURL = $this->_paymentProcessor['url_site'] . "/cgi-bin/webscr?cmd=_express-checkout&token={$token}";
CRM_Utils_System::redirect($paymentURL);
}
} elseif ($this->_paymentProcessor['billing_mode'] & CRM_Core_Payment::BILLING_MODE_NOTIFY) {
$this->set('contributeMode', 'notify');
}
}
// should we skip the confirm page?
if (!CRM_Utils_Array::value('is_confirm_enabled', $this->_values)) {
// build the confirm page
$confirmForm =& $this->controller->_pages['Confirm'];
$confirmForm->preProcess();
$confirmForm->buildQuickForm();
// the confirmation page is valid
$data =& $this->controller->container();
$data['valid']['Confirm'] = 1;
// confirm the contribution
$confirmForm->postProcess();
$qfKey = $this->controller->_key;
// redirect to thank you page
CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/contribute/transact', "_qf_ThankYou_display=1&qfKey={$qfKey}", TRUE, NULL, FALSE));
}
}
示例8: postProcess
/**
* Function to process the form
*
* @access public
* @return None
*/
public function postProcess()
{
if ($this->_action & CRM_Core_Action::DELETE) {
require_once 'CRM/Contribute/BAO/Contribution.php';
CRM_Contribute_BAO_Contribution::deleteContribution($this->_id);
return;
}
// get the submitted form values.
$submittedValues = $this->controller->exportValues($this->_name);
// process price set and get total amount and line items.
$lineItem = array();
$priceSetId = null;
if ($priceSetId = CRM_Utils_Array::value('price_set_id', $submittedValues)) {
require_once 'CRM/Price/BAO/Set.php';
CRM_Price_BAO_Set::processAmount($this->_priceSet['fields'], $submittedValues, $lineItem[$priceSetId]);
$submittedValues['total_amount'] = $submittedValues['amount'];
}
if (!CRM_Utils_Array::value('total_amount', $submittedValues)) {
$submittedValues['total_amount'] = $this->_values['total_amount'];
}
$this->assign('lineItem', !empty($lineItem) ? $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 = CRM_Utils_Array::value('contact_select_id', $submittedValues);
}
$config =& CRM_Core_Config::singleton();
$session =& CRM_Core_Session::singleton();
//Credit Card Contribution.
if ($this->_mode) {
$unsetParams = array('trxn_id', 'payment_instrument_id', 'contribution_status_id', 'receive_date', '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;
require_once 'CRM/Core/BAO/PaymentProcessor.php';
$this->_paymentProcessor = CRM_Core_BAO_PaymentProcessor::getPayment($this->_params['payment_processor_id'], $this->_mode);
require_once "CRM/Contact/BAO/Contact.php";
$now = date('YmdHis');
$fields = array();
// we need to retrieve email address
if ($this->_context == 'standalone' && CRM_Utils_Array::value('is_email_receipt', $submittedValues)) {
require_once 'CRM/Contact/BAO/Contact/Location.php';
list($this->userDisplayName, $this->userEmail) = CRM_Contact_BAO_Contact_Location::getEmailDetails($this->_contactID);
$this->assign('displayName', $this->userDisplayName);
}
//set email for primary location.
$fields["email-Primary"] = 1;
$params["email-Primary"] = $this->userEmail;
// now set the values for the billing location.
foreach ($this->_fields as $name => $dontCare) {
$fields[$name] = 1;
}
// also add location name to the array
$params["address_name-{$this->_bltID}"] = CRM_Utils_Array::value('billing_first_name', $params) . ' ' . CRM_Utils_Array::value('billing_middle_name', $params) . ' ' . CRM_Utils_Array::value('billing_last_name', $params);
$params["address_name-{$this->_bltID}"] = trim($params["address_name-{$this->_bltID}"]);
$fields["address_name-{$this->_bltID}"] = 1;
$ctype = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $this->_contactID, 'contact_type');
$nameFields = array('first_name', 'middle_name', 'last_name');
foreach ($nameFields as $name) {
$fields[$name] = 1;
if (array_key_exists("billing_{$name}", $params)) {
$params[$name] = $params["billing_{$name}"];
$params['preserveDBName'] = true;
}
}
if (CRM_Utils_Array::value('source', $params)) {
unset($params['source']);
}
$contactID = CRM_Contact_BAO_Contact::createProfileContact($params, $fields, $this->_contactID, null, null, $ctype);
// add all the additioanl payment params we need
$this->_params["state_province-{$this->_bltID}"] = CRM_Core_PseudoConstant::stateProvinceAbbreviation($this->_params["billing_state_province_id-{$this->_bltID}"]);
$this->_params["country-{$this->_bltID}"] = CRM_Core_PseudoConstant::countryIsoCode($this->_params["billing_country_id-{$this->_bltID}"]);
if ($this->_paymentProcessor['payment_type'] & CRM_Core_Payment::PAYMENT_TYPE_CREDIT_CARD) {
$this->_params['year'] = $this->_params['credit_card_exp_date']['Y'];
$this->_params['month'] = $this->_params['credit_card_exp_date']['M'];
}
$this->_params['ip_address'] = CRM_Utils_System::ipAddress();
$this->_params['amount'] = $this->_params['total_amount'];
$this->_params['amount_level'] = 0;
$this->_params['currencyID'] = $config->defaultCurrency;
$this->_params['payment_action'] = 'Sale';
if (CRM_Utils_Array::value('soft_credit_to', $params)) {
$this->_params['soft_credit_to'] = $params['soft_credit_to'];
$this->_params['pcp_made_through_id'] = $params['pcp_made_through_id'];
}
$this->_params['pcp_display_in_roll'] = $params['pcp_display_in_roll'];
$this->_params['pcp_roll_nickname'] = $params['pcp_roll_nickname'];
$this->_params['pcp_personal_note'] = $params['pcp_personal_note'];
//.........这里部分代码省略.........
示例9: 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);
//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 (CRM_Utils_Array::value('has_waitlist', $this->_values['event']) && $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_Set::processAmount($this->_values['fee'], $params, $lineItem);
//build the line item..
if (array_key_exists($addParticipantNum, $this->_lineItem)) {
$this->_lineItem[$addParticipantNum] = $lineItem;
} else {
$this->_lineItem[] = $lineItem;
}
}
}
if (array_key_exists('participant_role', $params)) {
$params['participant_role_id'] = $params['participant_role'];
}
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'];
}
if (CRM_Utils_Array::value('is_pay_later', $this->_params[0])) {
$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;
}
//.........这里部分代码省略.........
示例10: postProcess
/**
* Function to process the form
*
* @access public
* @return None
*/
public function postProcess()
{
$config = CRM_Core_Config::singleton();
// we first reset the confirm page so it accepts new values
$this->controller->resetPage('Confirm');
// get the submitted form values.
$params = $this->controller->exportValues($this->_name);
//carry campaign from profile.
if (array_key_exists('contribution_campaign_id', $params)) {
$params['campaign_id'] = $params['contribution_campaign_id'];
}
if (CRM_Utils_Array::value('onbehalfof_id', $params)) {
$params['organization_id'] = $params['onbehalfof_id'];
}
$params['currencyID'] = $config->defaultCurrency;
$params['amount'] = self::computeAmount($params, $this);
$memFee = null;
if (CRM_Utils_Array::value('selectMembership', $params)) {
if (!empty($this->_membershipTypeValues)) {
$membershipTypeValues = $this->_membershipTypeValues[$params['selectMembership']];
} else {
$membershipTypeValues = CRM_Member_BAO_Membership::buildMembershipTypeValues($this, $params['selectMembership']);
}
$memFee = $membershipTypeValues['minimum_fee'];
if (!$params['amount'] && !$this->_separateMembershipPayment) {
$params['amount'] = $memFee ? $memFee : 0;
}
}
if (!isset($params['amount_other'])) {
$this->set('amount_level', CRM_Utils_Array::value('amount_level', $params));
}
if ($priceSetId = CRM_Utils_Array::value('priceSetId', $params)) {
$lineItem = array();
require_once 'CRM/Price/BAO/Set.php';
CRM_Price_BAO_Set::processAmount($this->_values['fee'], $params, $lineItem[$priceSetId]);
$this->set('lineItem', $lineItem);
}
$this->set('amount', $params['amount']);
// generate and set an invoiceID for this transaction
$invoiceID = md5(uniqid(rand(), true));
$this->set('invoiceID', $invoiceID);
// required only if is_monetary and valid postive amount
if ($this->_values['is_monetary'] && is_array($this->_paymentProcessor) && ((double) $params['amount'] > 0.0 || $memFee > 0.0)) {
// default mode is direct
$this->set('contributeMode', 'direct');
if ($this->_paymentProcessor['billing_mode'] & CRM_Core_Payment::BILLING_MODE_BUTTON) {
//get the button name
$buttonName = $this->controller->getButtonName();
if (in_array($buttonName, array($this->_expressButtonName, $this->_expressButtonName . '_x', $this->_expressButtonName . '_y')) && !isset($params['is_pay_later'])) {
$this->set('contributeMode', 'express');
$donateURL = CRM_Utils_System::url('civicrm/contribute', '_qf_Contribute_display=1');
$params['cancelURL'] = CRM_Utils_System::url('civicrm/contribute/transact', "_qf_Main_display=1&qfKey={$params['qfKey']}", true, null, false);
$params['returnURL'] = CRM_Utils_System::url('civicrm/contribute/transact', "_qf_Confirm_display=1&rfp=1&qfKey={$params['qfKey']}", true, null, false);
$params['invoiceID'] = $invoiceID;
//default action is Sale
$params['payment_action'] = 'Sale';
$payment =& CRM_Core_Payment::singleton($this->_mode, $this->_paymentProcessor, $this);
$token = $payment->setExpressCheckout($params);
if (is_a($token, 'CRM_Core_Error')) {
CRM_Core_Error::displaySessionError($token);
CRM_Utils_System::redirect($params['cancelURL']);
}
$this->set('token', $token);
$paymentURL = $this->_paymentProcessor['url_site'] . "/cgi-bin/webscr?cmd=_express-checkout&token={$token}";
CRM_Utils_System::redirect($paymentURL);
}
} else {
if ($this->_paymentProcessor['billing_mode'] & CRM_Core_Payment::BILLING_MODE_NOTIFY) {
$this->set('contributeMode', 'notify');
}
}
}
}
示例11: 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');
//.........这里部分代码省略.........
示例12: postProcess
//.........这里部分代码省略.........
if ($formValues['renewal_date']) {
$this->set('renewalDate', CRM_Utils_Date::processDate($formValues['renewal_date']));
}
$this->_membershipId = $this->_id;
// membership type custom data
$customFields = CRM_Core_BAO_CustomField::getFields('Membership', FALSE, FALSE, $formValues['membership_type_id'][1]);
$customFields = CRM_Utils_Array::crmArrayMerge($customFields, CRM_Core_BAO_CustomField::getFields('Membership', FALSE, FALSE, NULL, NULL, TRUE));
$customFieldsFormatted = CRM_Core_BAO_CustomField::postProcess($formValues, $customFields, $this->_id, 'Membership');
// check for test membership.
$isTestMembership = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_Membership', $this->_membershipId, 'is_test');
// chk for renewal for multiple terms CRM-8750
$numRenewTerms = 1;
if (is_numeric(CRM_Utils_Array::value('num_terms', $formValues))) {
$numRenewTerms = $formValues['num_terms'];
}
//if contribution status is pending then set pay later
if ($formValues["contribution_status_id"] == array_search('Pending', CRM_Contribute_PseudoConstant::contributionStatus())) {
$this->_params['is_pay_later'] = 1;
}
$renewMembership = CRM_Member_BAO_Membership::renewMembership($this->_contactID, $formValues['membership_type_id'][1], $isTestMembership, $this, NULL, NULL, $customFieldsFormatted, $numRenewTerms);
$endDate = CRM_Utils_Date::processDate($renewMembership->end_date);
// Retrieve the name and email of the current user - this will be the FROM for the receipt email
$session = CRM_Core_Session::singleton();
$userID = $session->get('userID');
list($userName, $userEmail) = CRM_Contact_BAO_Contact_Location::getEmailDetails($userID);
$memType = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $renewMembership->membership_type_id, 'name');
if (CRM_Utils_Array::value('record_contribution', $formValues) || $this->_mode) {
// set the source
$formValues['contribution_source'] = "{$memType} Membership: Offline membership renewal (by {$userName})";
//create line items
$lineItem = array();
$priceSetId = null;
CRM_Member_BAO_Membership::createLineItems($this, $formValues['membership_type_id'], $priceSetId);
CRM_Price_BAO_Set::processAmount($this->_priceSet['fields'], $this->_params, $lineItem[$priceSetId]);
$formValues['total_amount'] = CRM_Utils_Array::value('amount', $this->_params);
if (!empty($lineItem)) {
$formValues['lineItems'] = $lineItem;
$formValues['processPriceSet'] = TRUE;
}
//assign contribution contact id to the field expected by recordMembershipContribution
if ($this->_contributorContactID != $this->_contactID) {
$formValues['contribution_contact_id'] = $this->_contributorContactID;
if (CRM_Utils_Array::value('honor_type_id', $this->_params)) {
$formValues['honor_contact_id'] = $this->_contactID;
}
}
$formValues['contact_id'] = $this->_contactID;
CRM_Member_BAO_Membership::recordMembershipContribution($formValues, CRM_Core_DAO::$_nullArray, $renewMembership->id);
if ($this->_mode) {
$trxnParams = array('contribution_id' => CRM_Utils_Array::value('contribution_id', $formValues), 'trxn_date' => $now, 'trxn_type' => 'Debit', 'total_amount' => $formValues['total_amount'], 'fee_amount' => CRM_Utils_Array::value('fee_amount', $result), 'net_amount' => CRM_Utils_Array::value('net_amount', $result, $formValues['total_amount']), 'currency' => $config->defaultCurrency, 'payment_processor' => $this->_paymentProcessor['payment_processor_type'], 'trxn_id' => $result['trxn_id']);
$trxn = CRM_Core_BAO_FinancialTrxn::create($trxnParams);
}
}
if (CRM_Utils_Array::value('send_receipt', $formValues)) {
CRM_Core_DAO::setFieldValue('CRM_Member_DAO_MembershipType', $formValues['membership_type_id'][1], 'receipt_text_renewal', $formValues['receipt_text_renewal']);
}
$receiptSend = FALSE;
if (CRM_Utils_Array::value('send_receipt', $formValues)) {
$receiptSend = TRUE;
$receiptFrom = $formValues['from_email_address'];
if (CRM_Utils_Array::value('payment_instrument_id', $formValues)) {
$paymentInstrument = CRM_Contribute_PseudoConstant::paymentInstrument();
$formValues['paidBy'] = $paymentInstrument[$formValues['payment_instrument_id']];
}
//get the group Tree
$this->_groupTree = CRM_Core_BAO_CustomGroup::getTree('Membership', $this, $this->_id, FALSE, $this->_memType);
示例13: 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);
}
示例14: validate
function validate()
{
parent::validate();
if ($this->_errors) {
return FALSE;
}
$this->cart->load_associations();
$fields = $this->_submitValues;
foreach ($this->cart->get_main_events_in_carts() as $event_in_cart) {
$price_set_id = CRM_Event_BAO_Event::usesPriceSet($event_in_cart->event_id);
if ($price_set_id) {
$priceField = new CRM_Price_DAO_Field();
$priceField->price_set_id = $price_set_id;
$priceField->find();
$check = array();
while ($priceField->fetch()) {
if (!empty($fields["event_{$event_in_cart->event_id}_price_{$priceField->id}"])) {
$check[] = $priceField->id;
}
}
//XXX
if (empty($check)) {
$this->_errors['_qf_default'] = ts("Select at least one option from Price Levels.");
}
$lineItem = array();
if (is_array($this->_values['fee']['fields'])) {
CRM_Price_BAO_Set::processAmount($this->_values['fee']['fields'], $fields, $lineItem);
//XXX total...
if ($fields['amount'] < 0) {
$this->_errors['_qf_default'] = ts("Price Levels can not be less than zero. Please select the options accordingly");
}
}
}
foreach ($event_in_cart->participants as $mer_participant) {
$participant_fields = $fields['event'][$event_in_cart->event_id]['participant'][$mer_participant->id];
//TODO what to do when profile responses differ for the same contact?
$contact_id = self::find_contact($participant_fields);
if ($contact_id) {
$participant = new CRM_Event_BAO_Participant();
$participant->event_id = $event_in_cart->event_id;
$participant->contact_id = $contact_id;
$statusTypes = CRM_Event_PseudoConstant::participantStatus(NULL, 'is_counted = 1');
$participant->find();
while ($participant->fetch()) {
if (array_key_exists($participant->status_id, $statusTypes)) {
$form = $mer_participant->get_form();
$this->_errors[$form->html_field_name('email')] = ts("The participant %1 is already registered for %2 (%3).", array(1 => $participant_fields['email'], 2 => $event_in_cart->event->title, 3 => $event_in_cart->event->start_date));
}
}
}
}
}
return empty($this->_errors);
}