parent::preProcess();
- $this->_formType = CRM_Utils_Array::value('formType', $_GET);
+ $this->_formType = $_GET['formType'] ?? NULL;
// Get price set id.
- $this->_priceSetId = CRM_Utils_Array::value('priceSetId', $_GET);
+ $this->_priceSetId = $_GET['priceSetId'] ?? NULL;
$this->set('priceSetId', $this->_priceSetId);
$this->assign('priceSetId', $this->_priceSetId);
// Set defaults for pledge payment.
if ($this->_ppID) {
- $defaults['total_amount'] = CRM_Utils_Array::value('scheduled_amount', $this->_pledgeValues['pledgePayment']);
- $defaults['financial_type_id'] = CRM_Utils_Array::value('financial_type_id', $this->_pledgeValues);
- $defaults['currency'] = CRM_Utils_Array::value('currency', $this->_pledgeValues);
+ $defaults['total_amount'] = $this->_pledgeValues['pledgePayment']['scheduled_amount'] ?? NULL;
+ $defaults['financial_type_id'] = $this->_pledgeValues['financial_type_id'] ?? NULL;
+ $defaults['currency'] = $this->_pledgeValues['currency'] ?? NULL;
$defaults['option_type'] = 1;
}
$defaults['total_amount'] = CRM_Utils_Money::format($total_value, NULL, '%a');
if (!empty($defaults['tax_amount'])) {
$componentDetails = CRM_Contribute_BAO_Contribution::getComponentDetails($this->_id);
- if (!(CRM_Utils_Array::value('membership', $componentDetails) || CRM_Utils_Array::value('participant', $componentDetails))) {
+ if (empty($componentDetails['membership']) && empty($componentDetails['participant'])) {
$defaults['total_amount'] = CRM_Utils_Money::format($total_value - $defaults['tax_amount'], NULL, '%a');
}
}
$defaults['receive_date'] = date('Y-m-d H:i:s');
}
- $currency = CRM_Utils_Array::value('currency', $defaults);
+ $currency = $defaults['currency'] ?? NULL;
$this->assign('currency', $currency);
// Hack to get currency info to the js layer. CRM-11440.
CRM_Utils_Money::format(1);
// FIXME: This probably needs to be done in preprocess
if (CRM_Financial_BAO_FinancialType::isACLFinancialTypeStatus()
&& $this->_action & CRM_Core_Action::UPDATE
- && CRM_Utils_Array::value('financial_type_id', $this->_values)
+ && !empty($this->_values['financial_type_id'])
) {
$financialTypeID = CRM_Contribute_PseudoConstant::financialType($this->_values['financial_type_id']);
CRM_Financial_BAO_FinancialType::checkPermissionedLineItems($this->_id, 'edit');
$paymentInstrument = FALSE;
if (!$this->_mode) {
// payment_instrument isn't required in edit and will not be present when payment block is enabled.
- $required = $this->_id ? FALSE : TRUE;
+ $required = !$this->_id;
$checkPaymentID = array_search('Check', CRM_Contribute_PseudoConstant::paymentInstrument('name'));
$paymentInstrument = $this->add('select', 'payment_instrument_id',
ts('Payment Method'),
$totalAmount = $this->addMoney('total_amount',
ts('Total Amount'),
- ($hasPriceSets) ? FALSE : TRUE,
+ !$hasPriceSets,
$attributes['total_amount'],
TRUE, 'currency', NULL, $currencyFreeze
);
CRM_Core_Config::singleton()->defaultCurrency
);
- $this->_params['pcp_display_in_roll'] = CRM_Utils_Array::value('pcp_display_in_roll', $params);
- $this->_params['pcp_roll_nickname'] = CRM_Utils_Array::value('pcp_roll_nickname', $params);
- $this->_params['pcp_personal_note'] = CRM_Utils_Array::value('pcp_personal_note', $params);
+ $this->_params['pcp_display_in_roll'] = $params['pcp_display_in_roll'] ?? NULL;
+ $this->_params['pcp_roll_nickname'] = $params['pcp_roll_nickname'] ?? NULL;
+ $this->_params['pcp_personal_note'] = $params['pcp_personal_note'] ?? NULL;
//Add common data to formatted params
CRM_Contribute_Form_AdditionalInfo::postProcessCommon($params, $this->_params, $this);
// Send receipt mail.
array_unshift($this->statusMessage, ts('The contribution record has been saved.'));
if ($contribution->id && !empty($this->_params['is_email_receipt'])) {
- $this->_params['trxn_id'] = CRM_Utils_Array::value('trxn_id', $result);
+ $this->_params['trxn_id'] = $result['trxn_id'] ?? NULL;
$this->_params['contact_id'] = $contactID;
$this->_params['contribution_id'] = $contribution->id;
if (CRM_Contribute_Form_AdditionalInfo::emailReceipt($this, $this->_params, TRUE)) {
// See if we need to include this paneName in the current form.
if ($this->_formType == $type || !empty($_POST["hidden_{$type}"]) ||
- CRM_Utils_Array::value("hidden_{$type}", $defaults)
+ !empty($defaults["hidden_{$type}"])
) {
$this->assign('showAdditionalInfo', TRUE);
$pane['open'] = 'true';
// Process price set and get total amount and line items.
$lineItem = [];
- $priceSetId = CRM_Utils_Array::value('price_set_id', $submittedValues);
+ $priceSetId = $submittedValues['price_set_id'] ?? NULL;
if (empty($priceSetId) && !$this->_id) {
$this->_priceSetId = $priceSetId = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', 'default_contribution_amount', 'id', 'name');
$this->_priceSet = current(CRM_Price_BAO_PriceSet::getSetDetail($priceSetId));
) {
unset($submittedValues['tax_amount']);
}
- $submittedValues['total_amount'] = CRM_Utils_Array::value('amount', $submittedValues);
+ $submittedValues['total_amount'] = $submittedValues['amount'] ?? NULL;
}
if ($this->_id) {
if ($this->_priceSetId && CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $this->_priceSetId, 'is_quick_config')) {
//CRM-16833: Ensure tax is applied only once for membership conribution, when status changed.(e.g Pending to Completed).
$componentDetails = CRM_Contribute_BAO_Contribution::getComponentDetails($this->_id);
- if (!(CRM_Utils_Array::value('membership', $componentDetails) || CRM_Utils_Array::value('participant', $componentDetails))) {
+ if (empty($componentDetails['membership']) && empty($componentDetails['participant'])) {
if (!($this->_action & CRM_Core_Action::UPDATE && (($this->_defaults['contribution_status_id'] != $submittedValues['contribution_status_id'])))) {
$lineItems[$itemId]['unit_price'] = $lineItems[$itemId]['line_total'] = CRM_Utils_Rule::cleanMoney(CRM_Utils_Array::value('total_amount', $submittedValues));
}
// NOTE that this IS still a legitimate use of 'quick-config' for contributions under the current DB but
// we should look at having a price field per contribution type & then there would be little reason
// for the back-office contribution form postProcess to know if it is a quick-config form.
- if ($isQuickConfig && !empty($submittedValues['financial_type_id']) && CRM_Utils_Array::value($this->_priceSetId, $lineItem)
+ if ($isQuickConfig && !empty($submittedValues['financial_type_id']) && !empty($lineItem[$this->_priceSetId])
) {
foreach ($lineItem[$this->_priceSetId] as &$values) {
$values['financial_type_id'] = $submittedValues['financial_type_id'];
}
if (!isset($submittedValues['total_amount'])) {
- $submittedValues['total_amount'] = CRM_Utils_Array::value('total_amount', $this->_values);
+ $submittedValues['total_amount'] = $this->_values['total_amount'] ?? NULL;
// Avoid tax amount deduction on edit form and keep it original, because this will lead to error described in CRM-20676
if (!$this->_id) {
$submittedValues['total_amount'] -= CRM_Utils_Array::value('tax_amount', $this->_values, 0);
'pan_truncation',
];
foreach ($fields as $f) {
- $params[$f] = CRM_Utils_Array::value($f, $formValues);
+ $params[$f] = $formValues[$f] ?? NULL;
}
$params['revenue_recognition_date'] = NULL;
$params['contribution_mode'] = 'membership';
}
$params['line_item'] = $lineItem;
- $params['payment_processor_id'] = $params['payment_processor'] = CRM_Utils_Array::value('id', $this->_paymentProcessor);
+ $params['payment_processor_id'] = $params['payment_processor'] = $this->_paymentProcessor['id'] ?? NULL;
$params['tax_amount'] = CRM_Utils_Array::value('tax_amount', $submittedValues, CRM_Utils_Array::value('tax_amount', $this->_values));
//create contribution.
if ($isQuickConfig) {
$formValues += CRM_Contribute_BAO_ContributionSoft::getSoftContribution($contribution->id);
// to get 'from email id' for send receipt
- $this->fromEmailId = CRM_Utils_Array::value('from_email_address', $formValues);
+ $this->fromEmailId = $formValues['from_email_address'] ?? NULL;
if (CRM_Contribute_Form_AdditionalInfo::emailReceipt($this, $formValues)) {
$this->statusMessage[] = ts('A receipt has been emailed to the contributor.');
}
$action,
$pledgePaymentID,
$contribution->id,
- (CRM_Utils_Array::value('option_type', $formValues) == 2) ? TRUE : FALSE,
+ ($formValues['option_type'] ?? 0) == 2,
$formValues['total_amount'],
CRM_Utils_Array::value('total_amount', $this->_defaults),
$formValues['contribution_status_id'],
}
else {
if (isset($v['tax_rate'])) {
- $taxRate[(string) $v['tax_rate']] = CRM_Utils_Array::value('tax_amount', $v);
+ $taxRate[(string) $v['tax_rate']] = $v['tax_amount'] ?? NULL;
$getTaxDetails = TRUE;
}
}
return $params['non_deductible_amount'];
}
- $priceSetId = CRM_Utils_Array::value('price_set_id', $params);
+ $priceSetId = $params['price_set_id'] ?? NULL;
// return non-deductible amount if it is set at the price field option level
if ($priceSetId && !empty($params['line_item'])) {
$nonDeductibleAmount = CRM_Price_BAO_PriceSet::getNonDeductibleAmountFromPriceSet($priceSetId, $params['line_item']);