本文整理汇总了PHP中CRM_Price_BAO_PriceSet::setDefaultPriceSet方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Price_BAO_PriceSet::setDefaultPriceSet方法的具体用法?PHP CRM_Price_BAO_PriceSet::setDefaultPriceSet怎么用?PHP CRM_Price_BAO_PriceSet::setDefaultPriceSet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Price_BAO_PriceSet
的用法示例。
在下文中一共展示了CRM_Price_BAO_PriceSet::setDefaultPriceSet方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setDefaultValues
//.........这里部分代码省略.........
$paymentAmount = 0;
$duePayment = FALSE;
foreach ($pledgePayments as $payId => $value) {
if ($value['status'] == 'Overdue') {
$this->_defaults['pledge_amount'][$payId] = 1;
$paymentAmount += $value['scheduled_amount'];
} elseif (!$duePayment && $value['status'] == 'Pending') {
$this->_defaults['pledge_amount'][$payId] = 1;
$paymentAmount += $value['scheduled_amount'];
$duePayment = TRUE;
} elseif ($value['status'] == 'Completed' && $value['contribution_id']) {
$completedContributionIds[] = $value['contribution_id'];
}
}
$this->_defaults['price_' . $this->_priceSetId] = $paymentAmount;
if (count($completedContributionIds)) {
$softCredit = array();
foreach ($completedContributionIds as $id) {
$softCredit = CRM_Contribute_BAO_ContributionSoft::getSoftContribution($id);
}
if (isset($softCredit['soft_credit'])) {
$this->_defaults['soft_credit_type_id'] = $softCredit['soft_credit'][1]['soft_credit_type'];
//since honoree profile fieldname of fields are prefixed with 'honor'
//we need to reformat the fieldname to append prefix during setting default values
CRM_Core_BAO_UFGroup::setProfileDefaults($softCredit['soft_credit'][1]['contact_id'], CRM_Core_BAO_UFGroup::getFields($this->_honoreeProfileId), $defaults);
foreach ($defaults as $fieldName => $value) {
$this->_defaults['honor[' . $fieldName . ']'] = $value;
}
}
}
} elseif (!empty($this->_values['pledge_block_id'])) {
//set default to one time contribution.
$this->_defaults['is_pledge'] = 0;
}
// to process Custom data that are appended to URL
$getDefaults = CRM_Core_BAO_CustomGroup::extractGetParams($this, "'Contact', 'Individual', 'Contribution'");
$this->_defaults = array_merge($this->_defaults, $getDefaults);
$config = CRM_Core_Config::singleton();
// set default country from config if no country set
if (empty($this->_defaults["billing_country_id-{$this->_bltID}"])) {
$this->_defaults["billing_country_id-{$this->_bltID}"] = $config->defaultContactCountry;
}
// set default state/province from config if no state/province set
if (empty($this->_defaults["billing_state_province_id-{$this->_bltID}"])) {
$this->_defaults["billing_state_province_id-{$this->_bltID}"] = $config->defaultContactStateProvince;
}
$entityId = $memtypeID = NULL;
if ($this->_priceSetId) {
if ($this->_useForMember && !empty($this->_currentMemberships) || $this->_defaultMemTypeId) {
$selectedCurrentMemTypes = array();
foreach ($this->_priceSet['fields'] as $key => $val) {
foreach ($val['options'] as $keys => $values) {
$opMemTypeId = CRM_Utils_Array::value('membership_type_id', $values);
$priceFieldName = 'price_' . $values['price_field_id'];
$priceFieldValue = CRM_Price_BAO_PriceSet::getPriceFieldValueFromURL($this, $priceFieldName);
if (!empty($priceFieldValue)) {
CRM_Price_BAO_PriceSet::setDefaultPriceSetField($priceFieldName, $priceFieldValue, $val['html_type'], $this->_defaults);
// break here to prevent overwriting of default due to 'is_default'
// option configuration or setting of current membership or
// membership for related organization.
// The value sent via URL get's higher priority.
break;
} elseif ($opMemTypeId && in_array($opMemTypeId, $this->_currentMemberships) && !in_array($opMemTypeId, $selectedCurrentMemTypes)) {
CRM_Price_BAO_PriceSet::setDefaultPriceSetField($priceFieldName, $keys, $val['html_type'], $this->_defaults);
$memtypeID = $selectedCurrentMemTypes[] = $values['membership_type_id'];
} elseif (!empty($values['is_default']) && !$opMemTypeId && (!isset($this->_defaults[$priceFieldName]) || $val['html_type'] == 'CheckBox' && !isset($this->_defaults[$priceFieldName][$keys]))) {
CRM_Price_BAO_PriceSet::setDefaultPriceSetField($priceFieldName, $keys, $val['html_type'], $this->_defaults);
$memtypeID = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceFieldValue', $this->_defaults[$priceFieldName], 'membership_type_id');
}
}
}
$entityId = CRM_Utils_Array::value('id', CRM_Member_BAO_Membership::getContactMembership($contactID, $memtypeID, NULL));
} else {
CRM_Price_BAO_PriceSet::setDefaultPriceSet($this, $this->_defaults);
}
}
//set custom field defaults set by admin if value is not set
if (!empty($this->_fields)) {
//load default campaign from page.
if (array_key_exists('contribution_campaign_id', $this->_fields)) {
$this->_defaults['contribution_campaign_id'] = CRM_Utils_Array::value('campaign_id', $this->_values);
}
//set custom field defaults
foreach ($this->_fields as $name => $field) {
if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($name)) {
if (!isset($this->_defaults[$name])) {
CRM_Core_BAO_CustomField::setProfileDefaults($customFieldID, $name, $this->_defaults, $entityId, CRM_Profile_Form::MODE_REGISTER);
}
}
}
}
if (!empty($this->_paymentProcessors)) {
foreach ($this->_paymentProcessors as $pid => $value) {
if (!empty($value['is_default'])) {
$this->_defaults['payment_processor_id'] = $pid;
}
}
}
return $this->_defaults;
}
示例2: setDefaultValues
/**
* Set default values for the form. MobileProvider that in edit/view mode
* the default values are retrieved from the database
*
*
* @return void
*/
public function setDefaultValues()
{
if ($this->_cdType) {
return CRM_Custom_Form_CustomData::setDefaultValues($this);
}
if ($this->_priceSetId) {
return CRM_Price_BAO_PriceSet::setDefaultPriceSet($this, $defaults);
}
$defaults = parent::setDefaultValues();
//setting default join date and receive date
list($now, $currentTime) = CRM_Utils_Date::setDateDefaults();
if ($this->_action == CRM_Core_Action::ADD) {
$defaults['receive_date'] = $now;
$defaults['receive_date_time'] = $currentTime;
}
if (is_numeric($this->_memType)) {
$defaults['membership_type_id'] = array();
$defaults['membership_type_id'][0] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $this->_memType, 'member_of_contact_id', 'id');
$defaults['membership_type_id'][1] = $this->_memType;
} else {
$defaults['membership_type_id'] = $this->_memType;
}
$defaults['num_terms'] = 1;
if (!empty($defaults['id'])) {
if ($this->_onlinePendingContributionId) {
$defaults['record_contribution'] = $this->_onlinePendingContributionId;
} else {
$contributionId = CRM_Core_DAO::singleValueQuery("\n SELECT contribution_id\n FROM civicrm_membership_payment\n WHERE membership_id = {$this->_id}\n ORDER BY contribution_id\n DESC limit 1");
if ($contributionId) {
$defaults['record_contribution'] = $contributionId;
}
}
}
//set Soft Credit Type to Gift by default
$scTypes = CRM_Core_OptionGroup::values("soft_credit_type");
$defaults['soft_credit_type_id'] = CRM_Utils_Array::value(ts('Gift'), array_flip($scTypes));
if (!empty($defaults['record_contribution']) && !$this->_mode) {
$contributionParams = array('id' => $defaults['record_contribution']);
$contributionIds = array();
//keep main object campaign in hand.
$memberCampaignId = CRM_Utils_Array::value('campaign_id', $defaults);
CRM_Contribute_BAO_Contribution::getValues($contributionParams, $defaults, $contributionIds);
//get back original object campaign id.
$defaults['campaign_id'] = $memberCampaignId;
if (!empty($defaults['receive_date'])) {
list($defaults['receive_date']) = CRM_Utils_Date::setDateDefaults($defaults['receive_date']);
}
// Contribution::getValues() over-writes the membership record's source field value - so we need to restore it.
if (!empty($defaults['membership_source'])) {
$defaults['source'] = $defaults['membership_source'];
}
}
//CRM-13420
if (empty($defaults['payment_instrument_id'])) {
$defaults['payment_instrument_id'] = key(CRM_Core_OptionGroup::values('payment_instrument', FALSE, FALSE, FALSE, 'AND is_default = 1'));
}
// User must explicitly choose to send a receipt in both add and update mode.
$defaults['send_receipt'] = 0;
if ($this->_action & CRM_Core_Action::UPDATE) {
// in this mode by default uncheck this checkbox
unset($defaults['record_contribution']);
}
if (!empty($defaults['id'])) {
$subscriptionCancelled = CRM_Member_BAO_Membership::isSubscriptionCancelled($this->_id);
}
$alreadyAutoRenew = FALSE;
if (!empty($defaults['contribution_recur_id']) && !$subscriptionCancelled) {
$defaults['auto_renew'] = 1;
$alreadyAutoRenew = TRUE;
}
$this->assign('alreadyAutoRenew', $alreadyAutoRenew);
$this->assign('member_is_test', CRM_Utils_Array::value('member_is_test', $defaults));
$this->assign('membership_status_id', CRM_Utils_Array::value('status_id', $defaults));
if (!empty($defaults['is_pay_later'])) {
$this->assign('is_pay_later', TRUE);
}
if ($this->_mode) {
// set default country from config if no country set
$config = CRM_Core_Config::singleton();
if (empty($defaults["billing_country_id-{$this->_bltID}"])) {
$defaults["billing_country_id-{$this->_bltID}"] = $config->defaultContactCountry;
}
if (empty($defaults["billing_state_province_id-{$this->_bltID}"])) {
$defaults["billing_state_province_id-{$this->_bltID}"] = $config->defaultContactStateProvince;
}
$billingDefaults = $this->getProfileDefaults('Billing', $this->_contactID);
$defaults = array_merge($defaults, $billingDefaults);
// // hack to simplify credit card entry for testing
// $defaults['credit_card_type'] = 'Visa';
// $defaults['credit_card_number'] = '4807731747657838';
// $defaults['cvv2'] = '000';
// $defaults['credit_card_exp_date'] = array( 'Y' => '2012', 'M' => '05' );
}
//.........这里部分代码省略.........
示例3: setDefaultValues
//.........这里部分代码省略.........
$billingDefaults = $this->getProfileDefaults('Billing', $contactID);
$this->_defaults = array_merge($this->_defaults, $billingDefaults);
}
//set custom field defaults set by admin if value is not set
if (!empty($this->_fields)) {
//load default campaign from page.
if (array_key_exists('contribution_campaign_id', $this->_fields)) {
$this->_defaults['contribution_campaign_id'] = CRM_Utils_Array::value('campaign_id', $this->_values);
}
//set custom field defaults
foreach ($this->_fields as $name => $field) {
if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($name)) {
if (!isset($this->_defaults[$name])) {
CRM_Core_BAO_CustomField::setProfileDefaults($customFieldID, $name, $this->_defaults, NULL, CRM_Profile_Form::MODE_REGISTER);
}
}
}
}
// // hack to simplify credit card entry for testing
// $this->_defaults['credit_card_type'] = 'Visa';
// $this->_defaults['amount'] = 168;
// $this->_defaults['credit_card_number'] = '4111111111111111';
// $this->_defaults['cvv2'] = '000';
// $this->_defaults['credit_card_exp_date'] = array('Y' => '2014', 'M' => '05');
// // hack to simplify direct debit entry for testing
// $this->_defaults['account_holder'] = 'Max Müller';
// $this->_defaults['bank_account_number'] = '12345678';
// $this->_defaults['bank_identification_number'] = '12030000';
// $this->_defaults['bank_name'] = 'Bankname';
//build set default for pledge overdue payment.
if (CRM_Utils_Array::value('pledge_id', $this->_values)) {
//get all payment statuses.
$statuses = array();
$returnProperties = array('status_id');
CRM_Core_DAO::commonRetrieveAll('CRM_Pledge_DAO_PledgePayment', 'pledge_id', $this->_values['pledge_id'], $statuses, $returnProperties);
$paymentStatusTypes = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
$duePayment = FALSE;
foreach ($statuses as $payId => $value) {
if ($paymentStatusTypes[$value['status_id']] == 'Overdue') {
$this->_defaults['pledge_amount'][$payId] = 1;
} elseif (!$duePayment && $paymentStatusTypes[$value['status_id']] == 'Pending') {
$this->_defaults['pledge_amount'][$payId] = 1;
$duePayment = TRUE;
}
}
} elseif (CRM_Utils_Array::value('pledge_block_id', $this->_values)) {
//set default to one time contribution.
$this->_defaults['is_pledge'] = 0;
}
// to process Custom data that are appended to URL
$getDefaults = CRM_Core_BAO_CustomGroup::extractGetParams($this, "'Contact', 'Individual', 'Contribution'");
if (!empty($getDefaults)) {
$this->_defaults = array_merge($this->_defaults, $getDefaults);
}
$config = CRM_Core_Config::singleton();
// set default country from config if no country set
if (!CRM_Utils_Array::value("billing_country_id-{$this->_bltID}", $this->_defaults)) {
$this->_defaults["billing_country_id-{$this->_bltID}"] = $config->defaultContactCountry;
}
// set default state/province from config if no state/province set
if (!CRM_Utils_Array::value("billing_state_province_id-{$this->_bltID}", $this->_defaults)) {
$this->_defaults["billing_state_province_id-{$this->_bltID}"] = $config->defaultContactStateProvince;
}
// now fix all state country selectors
CRM_Core_BAO_Address::fixAllStateSelects($this, $this->_defaults);
if ($this->_priceSetId) {
if ($this->_useForMember && !empty($this->_currentMemberships) || $this->_defaultMemTypeId) {
$selectedCurrentMemTypes = array();
foreach ($this->_priceSet['fields'] as $key => $val) {
foreach ($val['options'] as $keys => $values) {
$opMemTypeId = CRM_Utils_Array::value('membership_type_id', $values);
if ($opMemTypeId && in_array($opMemTypeId, $this->_currentMemberships) && !in_array($opMemTypeId, $selectedCurrentMemTypes)) {
if ($val['html_type'] == 'CheckBox') {
$this->_defaults["price_{$key}"][$keys] = 1;
} else {
$this->_defaults["price_{$key}"] = $keys;
}
$selectedCurrentMemTypes[] = $values['membership_type_id'];
} elseif (CRM_Utils_Array::value('is_default', $values) && !$opMemTypeId && (!isset($this->_defaults["price_{$key}"]) || $val['html_type'] == 'CheckBox' && !isset($this->_defaults["price_{$key}"][$keys]))) {
if ($val['html_type'] == 'CheckBox') {
$this->_defaults["price_{$key}"][$keys] = 1;
} else {
$this->_defaults["price_{$key}"] = $keys;
}
}
}
}
} else {
CRM_Price_BAO_PriceSet::setDefaultPriceSet($this, $this->_defaults);
}
}
if (!empty($this->_paymentProcessors)) {
foreach ($this->_paymentProcessors as $pid => $value) {
if (CRM_Utils_Array::value('is_default', $value)) {
$this->_defaults['payment_processor'] = $pid;
}
}
}
return $this->_defaults;
}