/**
* Set variables up before form is built.
+ *
+ * @throws \CRM_Core_Exception
+ * @throws \CiviCRM_API3_Exception
*/
public function preProcess() {
// Check permission for action.
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);
$this->_lineItems = [];
if ($this->_id) {
- if (!empty($this->_compId) && $this->_compContext == 'participant') {
+ if (!empty($this->_compId) && $this->_compContext === 'participant') {
$this->assign('compId', $this->_compId);
$lineItem = CRM_Price_BAO_LineItem::getLineItems($this->_compId);
}
* Set default values.
*
* @return array
+ *
+ * @throws \CRM_Core_Exception
*/
public function setDefaultValues() {
$defaults = $this->_values;
// 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;
}
// For Premium section.
if ($this->_premiumID) {
$this->assign('showOption', FALSE);
- $options = isset($this->_options[$this->_productDAO->product_id]) ? $this->_options[$this->_productDAO->product_id] : "";
+ $options = $this->_options[$this->_productDAO->product_id] ?? "";
if (!$options) {
$this->assign('showOption', TRUE);
}
$defaults['refund_trxn_id'] = CRM_Core_BAO_FinancialTrxn::getRefundTransactionTrxnID($this->_id);
}
else {
- $defaults['refund_trxn_id'] = isset($defaults['trxn_id']) ? $defaults['trxn_id'] : NULL;
+ $defaults['refund_trxn_id'] = $defaults['trxn_id'] ?? NULL;
}
if (!$this->_id && empty($defaults['receive_date'])) {
$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);
/**
* Build the form object.
+ *
+ * @throws \CiviCRM_API3_Exception
+ * @throws \CRM_Core_Exception
*/
public function buildQuickForm() {
if ($this->_id) {
$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);
$this->set('is_deductible', TRUE);
}
$contributionParams = [
- 'id' => CRM_Utils_Array::value('contribution_id', $this->_params),
+ 'id' => $this->_params['contribution_id'] ?? NULL,
'contact_id' => $contactID,
'line_item' => $lineItem,
'is_test' => $isTest,
- 'campaign_id' => CRM_Utils_Array::value('campaign_id', $this->_params),
- 'contribution_page_id' => CRM_Utils_Array::value('contribution_page_id', $this->_params),
+ 'campaign_id' => $this->_params['campaign_id'] ?? NULL,
+ 'contribution_page_id' => $this->_params['contribution_page_id'] ?? NULL,
'source' => CRM_Utils_Array::value('source', $paymentParams, CRM_Utils_Array::value('description', $paymentParams)),
- 'thankyou_date' => CRM_Utils_Array::value('thankyou_date', $this->_params),
+ 'thankyou_date' => $this->_params['thankyou_date'] ?? NULL,
];
$contributionParams['payment_instrument_id'] = $this->_paymentProcessor['payment_instrument_id'];
'trxn_id' => $result['trxn_id'],
'payment_processor_id' => $this->_paymentProcessor['id'],
'is_transactional' => FALSE,
- 'fee_amount' => CRM_Utils_Array::value('fee_amount', $result),
- 'card_type_id' => CRM_Utils_Array::value('card_type_id', $paymentParams),
- 'pan_truncation' => CRM_Utils_Array::value('pan_truncation', $paymentParams),
+ 'fee_amount' => $result['fee_amount'] ?? NULL,
+ 'card_type_id' => $paymentParams['card_type_id'] ?? NULL,
+ 'pan_truncation' => $paymentParams['pan_truncation'] ?? NULL,
'is_email_receipt' => FALSE,
]);
// This has now been set to 1 in the DB - declare it here also
// 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)) {
]);
$this->_id = $params['id'];
$this->_values = $existingContribution;
- if (CRM_Contribute_BAO_Contribution::checkContributeSettings('invoicing')) {
+ if (CRM_Invoicing_Utils::isInvoicingEnabled()) {
$this->_values['tax_amount'] = civicrm_api3('contribution', 'getvalue', [
'id' => $params['id'],
'return' => 'tax_amount',
// 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 (!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.');
}
}
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']);