本文整理汇总了PHP中CRM_Contribute_BAO_Premium::getPremiumProductInfo方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Contribute_BAO_Premium::getPremiumProductInfo方法的具体用法?PHP CRM_Contribute_BAO_Premium::getPremiumProductInfo怎么用?PHP CRM_Contribute_BAO_Premium::getPremiumProductInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Contribute_BAO_Premium
的用法示例。
在下文中一共展示了CRM_Contribute_BAO_Premium::getPremiumProductInfo方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: processMembership
//.........这里部分代码省略.........
$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);
$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) {
// The following parameter setting may be obsolete.
$this->_params = $params;
$value['is_renew'] = TRUE;
$isPayLater = CRM_Utils_Array::value('is_pay_later', $params);
$campaignId = NULL;
if (isset($this->_values) && is_array($this->_values) && !empty($this->_values)) {
$campaignId = CRM_Utils_Array::value('campaign_id', $this->_params);
if (!array_key_exists('campaign_id', $this->_params)) {
$campaignId = CRM_Utils_Array::value('campaign_id', $this->_values);
}
}
foreach (array('join_date', 'start_date', 'end_date') as $dateType) {
//CRM-18000 - ignore $dateType if its not explicitly passed
if (!empty($fDate[$dateType]) || !empty($fDate['membership_' . $dateType])) {
$formDates[$dateType] = CRM_Utils_Array::value($dateType, $value);
}
}
$membershipSource = CRM_Utils_Array::value('source', $value);
list($membership) = CRM_Member_BAO_Membership::renewMembership($value['contact_id'], $value['membership_type_id'], FALSE, NULL, NULL, $value['custom'], 1, NULL, FALSE, NULL, $membershipSource, $isPayLater, $campaignId, $formDates);
// make contribution entry
$contrbutionParams = array_merge($value, array('membership_id' => $membership->id));
// @todo - calling this from here is pretty hacky since it is called from membership.create anyway
// This form should set the correct params & not call this fn directly.
CRM_Member_BAO_Membership::recordMembershipContribution($contrbutionParams);
} 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' => CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipPayment', $membership->id, 'contribution_id', 'membership_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;
$value['contribution_id'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipPayment', $membership->id, 'contribution_id', 'membership_id');
CRM_Member_Form_Membership::emailReceipt($this, $value, $membership);
}
}
}
return TRUE;
}
示例3: buildProfile
//.........这里部分代码省略.........
$contID = $contactId;
if (!$contID) {
$contID = $form->get('id');
}
$form->addRule($name, ts('External ID already exists in Database.'), 'objectExists', array('CRM_Contact_DAO_Contact', $contID, 'external_identifier'));
} elseif ($fieldName === 'group') {
CRM_Contact_Form_Edit_TagsAndGroups::buildQuickForm($form, $contactId, CRM_Contact_Form_Edit_TagsAndGroups::GROUP, TRUE, $required, $title, NULL, $name);
} elseif ($fieldName === 'tag') {
CRM_Contact_Form_Edit_TagsAndGroups::buildQuickForm($form, $contactId, CRM_Contact_Form_Edit_TagsAndGroups::TAG, FALSE, $required, NULL, $title, $name);
} elseif (substr($fieldName, 0, 4) === 'url-') {
$form->add('text', $name, $title, CRM_Core_DAO::getAttribute('CRM_Core_DAO_Website', 'url'), $required);
$form->addRule($name, ts('Enter a valid web address beginning with \'http://\' or \'https://\'.'), 'url');
} elseif (substr($fieldName, -4) == 'note') {
$form->add('textarea', $name, $title, $attributes, $required);
} elseif (substr($fieldName, 0, 6) === 'custom') {
$customFieldID = CRM_Core_BAO_CustomField::getKeyID($fieldName);
if ($customFieldID) {
CRM_Core_BAO_CustomField::addQuickFormElement($form, $name, $customFieldID, FALSE, $required, $search, $title);
}
} elseif (substr($fieldName, 0, 14) === 'address_custom') {
list($fName, $locTypeId) = CRM_Utils_System::explode('-', $fieldName, 2);
$customFieldID = CRM_Core_BAO_CustomField::getKeyID(substr($fName, 8));
if ($customFieldID) {
CRM_Core_BAO_CustomField::addQuickFormElement($form, $name, $customFieldID, FALSE, $required, $search, $title);
}
} elseif (in_array($fieldName, array('receive_date', 'receipt_date', 'thankyou_date', 'cancel_date'))) {
$form->addDateTime($name, $title, $required, array('formatType' => 'activityDateTime'));
} elseif ($fieldName == 'send_receipt') {
$form->addElement('checkbox', $name, $title);
} elseif ($fieldName == 'soft_credit') {
$form->addEntityRef("soft_credit_contact_id[{$rowNumber}]", ts('Soft Credit To'), array('create' => TRUE));
$form->addMoney("soft_credit_amount[{$rowNumber}]", ts('Amount'), FALSE, NULL, FALSE);
} elseif ($fieldName == 'product_name') {
list($products, $options) = CRM_Contribute_BAO_Premium::getPremiumProductInfo();
$sel =& $form->addElement('hierselect', $name, $title);
$products = array('0' => ts('- select -')) + $products;
$sel->setOptions(array($products, $options));
} elseif ($fieldName == 'payment_instrument') {
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::paymentInstrument(), $required);
} elseif ($fieldName == 'financial_type') {
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::financialType(), $required);
} elseif ($fieldName == 'contribution_status_id') {
$contributionStatuses = CRM_Contribute_PseudoConstant::contributionStatus();
$statusName = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
foreach (array('In Progress', 'Overdue', 'Refunded') as $suppress) {
unset($contributionStatuses[CRM_Utils_Array::key($suppress, $statusName)]);
}
$form->add('select', $name, $title, array('' => ts('- select -')) + $contributionStatuses, $required);
} elseif ($fieldName == 'soft_credit_type') {
$name = "soft_credit_type[{$rowNumber}]";
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Core_OptionGroup::values("soft_credit_type"));
//CRM-15350: choose SCT field default value as 'Gift' for membership use
//else (for contribution), use configured SCT default value
$SCTDefaultValue = CRM_Core_OptionGroup::getDefaultValue("soft_credit_type");
if ($field['field_type'] == 'Membership') {
$SCTDefaultValue = CRM_Core_OptionGroup::getValue('soft_credit_type', 'Gift', 'name');
}
$form->addElement('hidden', 'sct_default_id', $SCTDefaultValue, array('id' => 'sct_default_id'));
} elseif ($fieldName == 'currency') {
$form->addCurrency($name, $title, $required);
} elseif ($fieldName == 'contribution_page_id') {
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::contributionPage(), $required, 'class="big"');
} elseif ($fieldName == 'participant_register_date') {
$form->addDateTime($name, $title, $required, array('formatType' => 'activityDateTime'));
} elseif ($fieldName == 'activity_status_id') {
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Core_PseudoConstant::activityStatus(), $required);
示例4: buildProfile
//.........这里部分代码省略.........
} elseif (substr($fieldName, 0, 4) === 'url-') {
$form->addElement('text', $name, $title, array_merge(CRM_Core_DAO::getAttribute('CRM_Core_DAO_Website', 'url'), array('onfocus' => "if (!this.value) { this.value='http://';} else return false", 'onblur' => "if ( this.value == 'http://') { this.value='';} else return false")));
$form->addRule($name, ts('Enter a valid Website.'), 'url');
//Website type select
if ($onBehalf) {
if (substr($name, -1) == ']') {
$websiteTypeName = substr($name, 0, -1) . '-website_type_id]';
}
$form->addElement('select', $websiteTypeName, NULL, CRM_Core_PseudoConstant::websiteType());
} else {
$form->addElement('select', $name . '-website_type_id', NULL, CRM_Core_PseudoConstant::websiteType());
}
// added because note appeared as a standard text input
} elseif ($fieldName == 'note') {
$form->add('textarea', $name, $title, $attributes, $required);
} elseif (substr($fieldName, 0, 6) === 'custom') {
$customFieldID = CRM_Core_BAO_CustomField::getKeyID($fieldName);
if ($customFieldID) {
CRM_Core_BAO_CustomField::addQuickFormElement($form, $name, $customFieldID, FALSE, $required, $search, $title);
}
} elseif (substr($fieldName, 0, 14) === 'address_custom') {
list($fName, $locTypeId) = CRM_Utils_System::explode('-', $fieldName, 2);
$customFieldID = CRM_Core_BAO_CustomField::getKeyID(substr($fName, 8));
if ($customFieldID) {
CRM_Core_BAO_CustomField::addQuickFormElement($form, $name, $customFieldID, FALSE, $required, $search, $title);
}
} elseif (in_array($fieldName, array('receive_date', 'receipt_date', 'thankyou_date', 'cancel_date'))) {
$form->addDateTime($name, $title, $required, array('formatType' => 'activityDateTime'));
} elseif ($fieldName == 'send_receipt') {
$form->addElement('checkbox', $name, $title);
} elseif ($fieldName == 'soft_credit') {
CRM_Contact_Form_NewContact::buildQuickForm($form, $rowNumber, NULL, FALSE, 'soft_credit_');
} elseif ($fieldName == 'product_name') {
list($products, $options) = CRM_Contribute_BAO_Premium::getPremiumProductInfo();
$sel =& $form->addElement('hierselect', $name, $title);
$products = array('0' => ts('- select -')) + $products;
$sel->setOptions(array($products, $options));
} elseif ($fieldName == 'payment_instrument') {
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::paymentInstrument(), $required);
} elseif ($fieldName == 'contribution_type') {
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::contributionType(), $required);
} elseif ($fieldName == 'contribution_status_id') {
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::contributionStatus(), $required);
} elseif ($fieldName == 'currency') {
$form->addCurrency($name, $title, $required);
} elseif ($fieldName == 'contribution_page_id') {
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::contributionPage(), $required, 'class="big"');
} elseif ($fieldName == 'participant_register_date') {
$form->addDateTime($name, $title, $required, array('formatType' => 'activityDateTime'));
} elseif ($fieldName == 'activity_status_id') {
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Core_PseudoConstant::activityStatus(), $required);
} elseif ($fieldName == 'activity_engagement_level') {
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Campaign_PseudoConstant::engagementLevel(), $required);
} elseif ($fieldName == 'activity_date_time') {
$form->addDateTime($name, $title, $required, array('formatType' => 'activityDateTime'));
} elseif ($fieldName == 'participant_status') {
$cond = NULL;
if ($online == TRUE) {
$cond = 'visibility_id = 1';
}
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Event_PseudoConstant::participantStatus(NULL, $cond, 'label'), $required);
} elseif ($fieldName == 'participant_role') {
if (CRM_Utils_Array::value('is_multiple', $field)) {
$form->addCheckBox($name, $title, CRM_Event_PseudoConstant::participantRole(), NULL, NULL, NULL, NULL, ' ', TRUE);
} else {
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Event_PseudoConstant::participantRole(), $required);