本文整理汇总了PHP中CRM_Member_BAO_Membership::renewMembershipFormWrapper方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Member_BAO_Membership::renewMembershipFormWrapper方法的具体用法?PHP CRM_Member_BAO_Membership::renewMembershipFormWrapper怎么用?PHP CRM_Member_BAO_Membership::renewMembershipFormWrapper使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Member_BAO_Membership
的用法示例。
在下文中一共展示了CRM_Member_BAO_Membership::renewMembershipFormWrapper方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postProcess
//.........这里部分代码省略.........
CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/contact/view/membership', "reset=1&action=renew&cid={$this->_contactID}&id={$this->_id}&context=membership&mode={$this->_mode}"));
}
if ($result) {
$this->_params = array_merge($this->_params, $result);
}
$formValues['contribution_status_id'] = 1;
$formValues['invoice_id'] = $this->_params['invoiceID'];
$formValues['trxn_id'] = $result['trxn_id'];
$formValues['payment_instrument_id'] = 1;
$formValues['is_test'] = $this->_mode == 'live' ? 0 : 1;
$this->set('params', $this->_params);
$this->assign('trxn_id', $result['trxn_id']);
}
$renewalDate = NULL;
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::renewMembershipFormWrapper($this->_contactID, $formValues['membership_type_id'][1], $isTestMembership, $this, NULL, NULL, $customFieldsFormatted, $numRenewTerms, $this->_membershipId);
$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 (!empty($formValues['record_contribution']) || $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_PriceSet::processAmount($this->_priceSet['fields'], $this->_params, $lineItem[$priceSetId]);
//CRM-11529 for quick config backoffice transactions
//when financial_type_id is passed in form, update the
//line items with the financial type selected in form
if ($submittedFinancialType = CRM_Utils_Array::value('financial_type_id', $formValues)) {
foreach ($lineItem[$priceSetId] as &$li) {
$li['financial_type_id'] = $submittedFinancialType;
}
}
$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 (!empty($this->_params['soft_credit_type_id'])) {
$formValues['soft_credit'] = array('soft_credit_type_id' => $this->_params['soft_credit_type_id'], 'contact_id' => $this->_contactID);
示例2: processMembership
//.........这里部分代码省略.........
//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]);
//CRM-11529 for backoffice transactions
//when financial_type_id is passed in form, update the
//lineitems with the financial type selected in form
if (!empty($value['financial_type_id']) && !empty($lineItem[$priceSetId])) {
foreach ($lineItem[$priceSetId] as &$values) {
$values['financial_type_id'] = $value['financial_type_id'];
}
}
$value['lineItems'] = $lineItem;
$value['processPriceSet'] = TRUE;
}
// end of contribution related section
unset($value['membership_type']);
unset($value['membership_start_date']);
unset($value['membership_end_date']);
$value['is_renew'] = false;
if (!empty($params['member_option']) && CRM_Utils_Array::value($key, $params['member_option']) == 2) {
$this->_params = $params;
$value['is_renew'] = true;
$membership = CRM_Member_BAO_Membership::renewMembershipFormWrapper($value['contact_id'], $value['membership_type_id'], FALSE, $this, NULL, NULL, $value['custom']);
// make contribution entry
CRM_Member_BAO_Membership::recordMembershipContribution(array_merge($value, array('membership_id' => $membership->id)));
} else {
$membership = CRM_Member_BAO_Membership::create($value, CRM_Core_DAO::$_nullArray);
}
//process premiums
if (!empty($value['product_name'])) {
if ($value['product_name'][0] > 0) {
list($products, $options) = CRM_Contribute_BAO_Premium::getPremiumProductInfo();
$value['hidden_Premium'] = 1;
$value['product_option'] = CRM_Utils_Array::value($value['product_name'][1], $options[$value['product_name'][0]]);
$premiumParams = array('product_id' => $value['product_name'][0], 'contribution_id' => $value['contribution_id'], 'product_option' => $value['product_option'], 'quantity' => 1);
CRM_Contribute_BAO_Contribution::addPremium($premiumParams);
}
}
// end of premium
//send receipt mail.
if ($membership->id && !empty($value['send_receipt'])) {
// add the domain email id
$domainEmail = CRM_Core_BAO_Domain::getNameAndEmail();
$domainEmail = "{$domainEmail['0']} <{$domainEmail['1']}>";
$value['from_email_address'] = $domainEmail;
$value['membership_id'] = $membership->id;
CRM_Member_Form_Membership::emailReceipt($this, $value, $membership);
}
}
}
return TRUE;
}
示例3: testStaleMembership
/**
* Renew stale membership.
*/
public function testStaleMembership()
{
$statusId = 3;
$contactId = Contact::createIndividual();
$joinDate = $startDate = date("Ymd", strtotime(date("Ymd") . " -1 year -15 days"));
$endDate = date("Ymd", strtotime($joinDate . " +1 year -1 day"));
$params = array('contact_id' => $contactId, 'membership_type_id' => $this->_membershipTypeID, 'join_date' => $joinDate, 'start_date' => $startDate, 'end_date' => $endDate, 'source' => 'Payment', 'status_id' => $statusId);
$ids = array();
$membership = CRM_Member_BAO_Membership::create($params, $ids);
$membershipId = $this->assertDBNotNull('CRM_Member_BAO_Membership', $contactId, 'id', 'contact_id', 'Database check for created membership.');
$this->assertEquals($membership->status_id, $statusId, 'Verify correct status id is calculated.');
$this->assertEquals($membership->membership_type_id, $this->_membershipTypeID, 'Verify correct membership type id.');
//verify all dates.
$dates = array('startDate' => 'start_date', 'joinDate' => 'join_date', 'endDate' => 'end_date');
foreach ($dates as $date => $dbDate) {
$this->assertEquals($membership->{$dbDate}, ${$date}, "Verify correct {$date} is present.");
}
$this->assertDBNotNull('CRM_Member_BAO_MembershipLog', $membership->id, 'id', 'membership_id', 'Database checked on membershiplog record.');
// this is a test and we dont want qfKey generation / validation
// easier to suppress it, than change core code
$config = CRM_Core_Config::singleton();
$config->keyDisable = TRUE;
$membershipRenewal = new CRM_Core_Form();
$membershipRenewal->controller = new CRM_Core_Controller();
$MembershipRenew = CRM_Member_BAO_Membership::renewMembershipFormWrapper($contactId, $this->_membershipTypeID, $isTestMembership = 0, $membershipRenewal, NULL, NULL, NULL, 1, NULL, FALSE);
$this->assertDBNotNull('CRM_Member_BAO_MembershipLog', $MembershipRenew->id, 'id', 'membership_id', 'Database checked on membershiplog record.');
$this->membershipDelete($membershipId);
Contact::delete($contactId);
}