/**
* Id of the component entity
+ * @var int
*/
public $_id = NULL;
protected $_refund = NULL;
/**
- * @deprecated - use parent $this->contactID
- *
* @var int
+ * @deprecated - use parent $this->contactID
*/
protected $_contactId = NULL;
* @return array
* reference to the array of default values
*/
+
/**
* @return array
*/
if ($this->_view == 'transaction' && ($this->_action & CRM_Core_Action::BROWSE)) {
return NULL;
}
- $defaults = array();
+ $defaults = [];
if ($this->_mode) {
CRM_Core_Payment_Form::setDefaultValues($this, $this->_contactId);
$defaults = array_merge($defaults, $this->_defaults);
*/
public function buildQuickForm() {
if ($this->_view == 'transaction' && ($this->_action & CRM_Core_Action::BROWSE)) {
- $this->addButtons(array(
- array(
- 'type' => 'cancel',
- 'name' => ts('Done'),
- 'spacing' => ' ',
- 'isDefault' => TRUE,
- ),
- )
- );
+ $this->addButtons([
+ [
+ 'type' => 'cancel',
+ 'name' => ts('Done'),
+ 'spacing' => ' ',
+ 'isDefault' => TRUE,
+ ],
+ ]);
return;
}
$this->add('textarea', 'receipt_text', ts('Confirmation Message'));
$dateLabel = ($this->_refund) ? ts('Refund Date') : ts('Date Received');
- $this->addField('trxn_date', array('entity' => 'FinancialTrxn', 'label' => $dateLabel, 'context' => 'Contribution'), FALSE, FALSE);
+ $this->addField('trxn_date', ['entity' => 'FinancialTrxn', 'label' => $dateLabel, 'context' => 'Contribution'], FALSE, FALSE);
if ($this->_contactId && $this->_id) {
if ($this->_component == 'event') {
$js = NULL;
// render backoffice payment fields only on offline mode
if (!$this->_mode) {
- $js = array('onclick' => "return verify( );");
+ $js = ['onclick' => "return verify( );"];
$this->add('select', 'payment_instrument_id',
ts('Payment Method'),
- array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::paymentInstrument(),
+ ['' => ts('- select -')] + CRM_Contribute_PseudoConstant::paymentInstrument(),
TRUE,
- array('onChange' => "return showHideByValue('payment_instrument_id','4','checkNumber','table-row','select',false);")
+ ['onChange' => "return showHideByValue('payment_instrument_id','4','checkNumber','table-row','select',false);"]
);
$this->add('text', 'check_number', ts('Check Number'), $attributes['financial_trxn_check_number']);
- $this->add('text', 'trxn_id', ts('Transaction ID'), array('class' => 'twelve') + $attributes['trxn_id']);
+ $this->add('text', 'trxn_id', ts('Transaction ID'), ['class' => 'twelve'] + $attributes['trxn_id']);
$this->add('text', 'fee_amount', ts('Fee Amount'),
$attributes['fee_amount']
}
$buttonName = $this->_refund ? 'Record Refund' : 'Record Payment';
- $this->addButtons(array(
- array(
- 'type' => 'upload',
- 'name' => ts('%1', array(1 => $buttonName)),
- 'js' => $js,
- 'isDefault' => TRUE,
- ),
- array(
- 'type' => 'cancel',
- 'name' => ts('Cancel'),
- ),
- )
- );
+ $this->addButtons([
+ [
+ 'type' => 'upload',
+ 'name' => ts('%1', [1 => $buttonName]),
+ 'js' => $js,
+ 'isDefault' => TRUE,
+ ],
+ [
+ 'type' => 'cancel',
+ 'name' => ts('Cancel'),
+ ],
+ ]);
$mailingInfo = Civi::settings()->get('mailing_backend');
$this->assign('outBound_option', $mailingInfo['outBound_option']);
- $this->addFormRule(array('CRM_Contribute_Form_AdditionalPayment', 'formRule'), $this);
+ $this->addFormRule(['CRM_Contribute_Form_AdditionalPayment', 'formRule'], $this);
}
/**
* @return array
*/
public static function formRule($fields, $files, $self) {
- $errors = array();
+ $errors = [];
if ($self->_paymentType == 'owed' && $fields['total_amount'] > $self->_owed) {
$errors['total_amount'] = ts('Payment amount cannot be greater than owed amount');
}
}
$contributionStatuses = CRM_Core_PseudoConstant::get('CRM_Contribute_DAO_Contribution',
'contribution_status_id',
- array('labelColumn' => 'name')
+ ['labelColumn' => 'name']
);
$contributionStatusID = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Contribution', $this->_contributionId, 'contribution_status_id');
if ($contributionStatuses[$contributionStatusID] == 'Pending') {
civicrm_api3('Contribution', 'create',
- array(
+ [
'id' => $this->_contributionId,
'contribution_status_id' => array_search('Partially paid', $contributionStatuses),
'is_pay_later' => 0,
- )
+ ]
);
}
$this->processCreditCard();
}
- $defaults = array();
- $contribution = civicrm_api3('Contribution', 'getsingle', array(
- 'return' => array("contribution_status_id"),
+ $defaults = [];
+ $contribution = civicrm_api3('Contribution', 'getsingle', [
+ 'return' => ["contribution_status_id"],
'id' => $this->_contributionId,
- ));
+ ]);
$contributionStatusId = CRM_Utils_Array::value('contribution_status_id', $contribution);
$result = CRM_Contribute_BAO_Contribution::recordAdditionalPayment($this->_contributionId, $this->_params, $this->_paymentType, $participantId);
// Fetch the contribution & do proportional line item assignment
- $params = array('id' => $this->_contributionId);
+ $params = ['id' => $this->_contributionId];
$contribution = CRM_Contribute_BAO_Contribution::retrieve($params, $defaults, $params);
- CRM_Contribute_BAO_Contribution::addPayments(array($contribution), $contributionStatusId);
+ CRM_Contribute_BAO_Contribution::addPayments([$contribution], $contributionStatusId);
if ($this->_contributionId && CRM_Core_Permission::access('CiviMember')) {
- $membershipPaymentCount = civicrm_api3('MembershipPayment', 'getCount', array('contribution_id' => $this->_contributionId));
+ $membershipPaymentCount = civicrm_api3('MembershipPayment', 'getCount', ['contribution_id' => $this->_contributionId]);
if ($membershipPaymentCount) {
$this->ajaxResponse['updateTabs']['#tab_member'] = CRM_Contact_BAO_Contact::getCountComponent('membership', $this->_contactID);
}
}
if ($this->_contributionId && CRM_Core_Permission::access('CiviEvent')) {
- $participantPaymentCount = civicrm_api3('ParticipantPayment', 'getCount', array('contribution_id' => $this->_contributionId));
+ $participantPaymentCount = civicrm_api3('ParticipantPayment', 'getCount', ['contribution_id' => $this->_contributionId]);
if ($participantPaymentCount) {
$this->ajaxResponse['updateTabs']['#tab_participant'] = CRM_Contact_BAO_Contact::getCountComponent('participant', $this->_contactID);
}
$statusMsg = ts('The payment record has been processed.');
// send email
if (!empty($result) && !empty($this->_params['is_email_receipt'])) {
- $this->_params['contact_id'] = $this->_contactId;
- $this->_params['contribution_id'] = $this->_contributionId;
-
- $sendReceipt = $this->emailReceipt($this->_params);
- if ($sendReceipt) {
+ $sendResult = civicrm_api3('Payment', 'sendconfirmation', ['id' => $result->id])['values'][$result->id];
+ if ($sendResult['is_sent']) {
$statusMsg .= ' ' . ts('A receipt has been emailed to the contributor.');
}
}
$session = CRM_Core_Session::singleton();
$now = date('YmdHis');
- $fields = array();
+ $fields = [];
// we need to retrieve email address
if ($this->_context == 'standalone' && !empty($this->_params['is_email_receipt'])) {
$userSortName = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $userID,
'sort_name'
);
- $this->_params['source'] = ts('Submit Credit Card Payment by: %1', array(1 => $userSortName));
- }
- }
-
- /**
- * Function to send email receipt.
- *
- * @param array $params
- *
- * @return bool
- */
- public function emailReceipt(&$params) {
- $templateEngine = CRM_Core_Smarty::singleton();
- // email receipt sending
- list($contributorDisplayName, $contributorEmail, $doNotMail) = CRM_Contact_BAO_Contact::getContactDetails($params['contact_id']);
- if (!$contributorEmail || $doNotMail) {
- return FALSE;
- }
- $templateEngine->assign('contactDisplayName', $contributorDisplayName);
- // send message template
- if ($this->_component == 'event') {
-
- // fetch event information from participant ID using API
- $eventId = civicrm_api3('Participant', 'getvalue', array(
- 'return' => "event_id",
- 'id' => $this->_id,
- ));
- $event = civicrm_api3('Event', 'getsingle', array('id' => $eventId));
-
- $templateEngine->assign('event', $event);
- $templateEngine->assign('isShowLocation', $event['is_show_location']);
- if (CRM_Utils_Array::value('is_show_location', $event) == 1) {
- $locationParams = array(
- 'entity_id' => $eventId,
- 'entity_table' => 'civicrm_event',
- );
- $location = CRM_Core_BAO_Location::getValues($locationParams, TRUE);
- $templateEngine->assign('location', $location);
- }
+ $this->_params['source'] = ts('Submit Credit Card Payment by: %1', [1 => $userSortName]);
}
-
- // assign payment info here
- $paymentConfig['confirm_email_text'] = CRM_Utils_Array::value('confirm_email_text', $params);
- $templateEngine->assign('paymentConfig', $paymentConfig);
-
- $templateEngine->assign('totalAmount', $this->_amtTotal);
-
- $isRefund = ($this->_paymentType == 'refund') ? TRUE : FALSE;
- $templateEngine->assign('isRefund', $isRefund);
- if ($isRefund) {
- $templateEngine->assign('totalPaid', $this->_amtPaid);
- $templateEngine->assign('refundAmount', $params['total_amount']);
- }
- else {
- $balance = $this->_amtTotal - ($this->_amtPaid + $params['total_amount']);
- $paymentsComplete = ($balance == 0) ? 1 : 0;
- $templateEngine->assign('amountOwed', $balance);
- $templateEngine->assign('paymentAmount', $params['total_amount']);
- $templateEngine->assign('paymentsComplete', $paymentsComplete);
- }
-
- // assign trxn details
- $templateEngine->assign('trxn_id', CRM_Utils_Array::value('trxn_id', $params));
- $templateEngine->assign('receive_date', CRM_Utils_Array::value('trxn_date', $params));
- $templateEngine->assign('paidBy', CRM_Core_PseudoConstant::getLabel(
- 'CRM_Contribute_BAO_Contribution',
- 'payment_instrument_id',
- $params['payment_instrument_id']
- ));
- $templateEngine->assign('checkNumber', CRM_Utils_Array::value('check_number', $params));
-
- $sendTemplateParams = array(
- 'groupName' => 'msg_tpl_workflow_contribution',
- 'valueName' => 'payment_or_refund_notification',
- 'contactId' => $params['contact_id'],
- 'PDFFilename' => ts('notification') . '.pdf',
- );
-
- $sendTemplateParams['from'] = $params['from_email_address'];
- $sendTemplateParams['toName'] = $contributorDisplayName;
- $sendTemplateParams['toEmail'] = $contributorEmail;
-
- list($mailSent) = CRM_Core_BAO_MessageTemplate::sendTemplate($sendTemplateParams);
- return $mailSent;
}
/**
$this->_mode = $creditCardMode;
}
- $this->_fields = array();
+ $this->_fields = [];
$this->set('cid', $this->_contactId);
parent::preProcess();
$this->submit($params);