*
* @var int
*/
- protected $_priceSetID = NULL;
+ protected $_priceSetID;
protected $_values;
* Set variables up before form is built.
*/
public function preProcess() {
- // current contribution page id
- $this->_id = CRM_Utils_Request::retrieve('id', 'Positive',
- $this, FALSE, NULL, 'REQUEST'
- );
- $this->assign('contributionPageID', $this->_id);
+ $this->assign('contributionPageID', $this->getContributionPageID());
// get the requested action
$this->_action = CRM_Utils_Request::retrieve('action', 'String',
// get price set of type contributions
//this is the value for stored in db if price set extends contribution
- $usedFor = 2;
- $this->_priceSetID = CRM_Price_BAO_PriceSet::getFor('civicrm_contribution_page', $this->_id, $usedFor, 1);
- if ($this->_priceSetID) {
- $defaults['price_set_id'] = $this->_priceSetID;
+ if ($this->getPriceSetID()) {
+ $defaults['price_set_id'] = $this->getPriceSetID();
}
}
else {
}
}
+ /**
+ * Get the price set ID for the event.
+ *
+ * @return int|null
+ *
+ * @api This function will not change in a minor release and is supported for
+ * use outside of core. This annotation / external support for properties
+ * is only given where there is specific test cover.
+ */
+ public function getContributionPageID(): ?int {
+ if (!$this->_id) {
+ $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
+ }
+ return $this->_id ? (int) $this->_id : NULL;
+ }
+
+ /**
+ * Get the price set ID for the contribution page.
+ *
+ * @return int|null
+ *
+ * @api This function will not change in a minor release and is supported for
+ * use outside of core. This annotation / external support for properties
+ * is only given where there is specific test cover.
+ */
+ public function getPriceSetID(): ?int {
+ if (!$this->_priceSetID && $this->getContributionPageID()) {
+ $this->_priceSetID = CRM_Price_BAO_PriceSet::getFor('civicrm_contribution_page', $this->getContributionPageID());
+ }
+ return $this->_priceSetID ? (int) $this->_priceSetID : NULL;
+ }
+
}
if (count($recurringPaymentProcessor)) {
$this->assign('recurringPaymentProcessor', $recurringPaymentProcessor);
}
- if (count($futurePaymentProcessor)) {
- $this->assign('futurePaymentProcessor', $futurePaymentProcessor);
- }
+ $this->assign('futurePaymentProcessor', json_encode($futurePaymentProcessor ?? [], TRUE));
if (count($paymentProcessor)) {
$this->assign('paymentProcessor', $paymentProcessor);
}
else {
$this->assign('price', TRUE);
}
-
+ $this->assign('isQuick', $this->isQuickConfig());
$this->addSelect('price_set_id', [
'entity' => 'PriceSet',
'option_url' => 'civicrm/admin/price',
if (empty($defaults['pay_later_text'])) {
$defaults['pay_later_text'] = ts('I will send payment by check');
}
-
if (!empty($defaults['amount_block_is_active'])) {
if ($priceSetId = CRM_Price_BAO_PriceSet::getFor('civicrm_contribution_page', $this->_id, NULL)) {
- if ($isQuick = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $priceSetId, 'is_quick_config')) {
- $this->assign('isQuick', $isQuick);
+ if ($this->isQuickConfig()) {
//$priceField = CRM_Core_DAO::getFieldValue( 'CRM_Price_DAO_PriceField', $priceSetId, 'id', 'price_set_id' );
$options = $pFIDs = [];
$priceFieldParams = ['price_set_id' => $priceSetId];
parent::endPostProcess();
}
+ /**
+ * Is the price set quick config.
+ *
+ * @return bool
+ */
+ private function isQuickConfig(): bool {
+ return $this->getPriceSetID() && CRM_Price_BAO_PriceSet::isQuickConfig($this->getPriceSetID());
+ }
+
/**
* Return a descriptive name for the page, used in wizard header
*
{literal}
<script type="text/javascript">
- var futurePaymentProcessorMapper = [];
- {/literal}{if $futurePaymentProcessor}
- {foreach from=$futurePaymentProcessor item="futurePaymentProcessor" key="index"}{literal}
- futurePaymentProcessorMapper[{/literal}{$index}{literal}] = '{/literal}{$futurePaymentProcessor}{literal}';
- {/literal}{/foreach}
- {literal}
+ {/literal}{if $futurePaymentProcessor}{literal}
CRM.$(function($) {
var defId = $('input[name="pledge_default_toggle"][value="contribution_date"]').attr('id');
var calId = $('input[name="pledge_default_toggle"][value="calendar_date"]').attr('id');
function showAdjustRecurring( paymentProcessorIds ) {
var display = true;
cj.each(paymentProcessorIds, function(k, id){
- if( cj.inArray(id, futurePaymentProcessorMapper) == -1 ) {
- display = false;
- }
+ if( cj.inArray(parseInt(id), {/literal}{$futurePaymentProcessor}{literal}) == -1 ) {
+ display = false;
+ }
});
if(display) {
- cj( '#adjustRecurringFields' ).show( );
+ cj('#adjustRecurringFields').show();
} else {
if ( cj( '#adjust_recur_start_date' ).prop('checked' ) ) {
cj( '#adjust_recur_start_date' ).prop('checked', false);