return;
}
$allPanes = array();
+ $recurJs = NULL;
//tax rate from financialType
$this->assign('taxRates', json_encode(CRM_Core_PseudoConstant::getTaxRates()));
$this->assign('currencies', json_encode(CRM_Core_OptionGroup::values('currencies_enabled')));
// use to build form during form rule.
$this->assign('buildPriceSet', $buildPriceSet);
- $showAdditionalInfo = FALSE;
-
$defaults = $this->_values;
$additionalDetailFields = array(
'note',
$billingPanes = array();
if ($this->_mode) {
if (CRM_Core_Payment_Form::buildPaymentForm($this, $this->_paymentProcessor, FALSE) == TRUE) {
- $buildRecurBlock = TRUE;
foreach ($this->billingPane as $name => $label) {
if (!empty($this->billingFieldSets[$name]['fields'])) {
// @todo reduce variation so we don't have to convert 'credit_card' to 'CreditCard'
$billingPanes[$label] = $this->generatePane(CRM_Utils_String::convertStringToCamel($name), $defaults);
}
}
+ if (!empty($this->_recurPaymentProcessors)) {
+ CRM_Contribute_Form_Contribution_Main::buildRecur($this);
+ $this->setDefaults(array('is_recur' => 0));
+ $this->assign('buildRecurBlock', TRUE);
+ $recurJs = array('onChange' => "buildRecurBlock( this.value ); return false;");
+ }
}
}
foreach ($paneNames as $name => $type) {
$allPanes[$name] = $this->generatePane($type, $defaults);
}
- if (empty($this->_recurPaymentProcessors)) {
- $buildRecurBlock = FALSE;
- }
- if ($buildRecurBlock) {
- CRM_Contribute_Form_Contribution_Main::buildRecur($this);
- $this->setDefaults(array('is_recur' => 0));
- }
- $this->assign('buildRecurBlock', $buildRecurBlock);
+
$qfKey = $this->controller->_key;
$this->assign('qfKey', $qfKey);
$this->assign('billingPanes', $billingPanes);
$this->add('textarea', 'cancel_reason', ts('Cancellation / Refund Reason'), $attributes['cancel_reason']);
- $recurJs = NULL;
- if ($buildRecurBlock) {
- $recurJs = array('onChange' => "buildRecurBlock( this.value ); return false;");
- }
$element = $this->add('select',
'payment_processor_id',
ts('Payment Processor'),
* @return bool|array
* true if no errors, else array of errors
*/
- public static function formRule($fields, $files, $self) {
+ public static function formRule($fields, /** @noinspection PhpUnusedParameterInspection */
+ $files, $self) {
$errors = array();
// Check for Credit Card Contribution.
*
* @param array $submittedValues
* @param array $lineItem
- *
- * @throws CRM_Core_Exception
- */
- protected function processCreditCard($submittedValues, $lineItem, $pledgePaymentID) {
+ */
+ protected function processCreditCard($submittedValues, $lineItem) {
$sendReceipt = $contribution = FALSE;
$unsetParams = array(
CRM_Contribute_Form_AdditionalInfo::processPremium($params, $contribution->id, NULL, $this->_options);
}
- //update pledge payment status.
- if ($this->_ppID && $contribution->id) {
- // Store contribution id in payment record.
- CRM_Core_DAO::setFieldValue('CRM_Pledge_DAO_PledgePayment', $this->_ppID, 'contribution_id', $contribution->id);
-
- CRM_Pledge_BAO_PledgePayment::updatePledgePaymentStatus($pledgeID,
- array($this->_ppID),
- $contribution->contribution_status_id,
- NULL,
- $contribution->total_amount
- );
- }
-
if ($contribution->id) {
$statusMsg = ts('The contribution record has been processed.');
if (!empty($this->_params['is_email_receipt']) && $sendReceipt) {
}
CRM_Core_Session::setStatus($statusMsg, ts('Complete'), 'success');
}
+ return $contribution;
}
/**
* (If we expose through api we can get default additions 'for free').
*
* @param array $params
+ * @param int $action
*/
public function testSubmit($params, $action) {
$defaults = array(
'cancel_date' => '',
'cancel_date_time' => '',
);
+ if (!empty($params['id'])) {
+ $existingContribution = civicrm_api3('contribution', 'getsingle', array(
+ 'id' => $params['id'],
+ ));
+ }
+ else {
+ $existingContribution = array();
+ }
+
+ $this->_defaults['contribution_status_id'] = CRM_Utils_Array::value('contribution_status_id',
+ $existingContribution
+ );
+
+ $this->_defaults['total_amount'] = CRM_Utils_Array::value('total_amount',
+ $existingContribution
+ );
$this->submit(array_merge($defaults, $params), $action, CRM_Utils_Array::value('pledge_payment_id', $params));
}
* Action constant
* - CRM_Core_Action::UPDATE
*
+ * @param $pledgePaymentID
+ *
* @return array
* @throws \Exception
*/
// Credit Card Contribution.
if ($this->_mode) {
- $this->processCreditCard($submittedValues, $lineItem, $pledgePaymentID);
- return FALSE;
+ $contribution = $this->processCreditCard($submittedValues, $lineItem);
}
else {
// Offline Contribution.
$this->_premiumID, $this->_options
);
}
+ $statusMsg = ts('The contribution record has been saved.');
// assign tax calculation for contribution receipts
$taxRate = array();
// to get 'from email id' for send receipt
$this->fromEmailId = $formValues['from_email_address'];
- $sendReceipt = CRM_Contribute_Form_AdditionalInfo::emailReceipt($this, $formValues);
- }
-
- CRM_Contribute_BAO_Contribution::updateRelatedPledge(
- $action,
- $pledgePaymentID,
- $contribution->id,
- (CRM_Utils_Array::value('option_type', $formValues) == 2) ? TRUE : FALSE,
- $formValues['total_amount'],
- $this->_defaults['total_amount'],
- $formValues['contribution_status_id'],
- $this->_defaults['contribution_status_id']
- );
-
- $statusMsg = ts('The contribution record has been saved.');
- if (!empty($formValues['is_email_receipt']) && $sendReceipt) {
- $statusMsg .= ' ' . ts('A receipt has been emailed to the contributor.');
+ if (CRM_Contribute_Form_AdditionalInfo::emailReceipt($this, $formValues)) {
+ $statusMsg .= ' ' . ts('A receipt has been emailed to the contributor.');
+ }
}
if ($relatedComponentStatusMsg) {
}
CRM_Core_Session::setStatus($statusMsg, ts('Saved'), 'success');
- return $contribution;
//Offline Contribution ends.
}
+
+ CRM_Contribute_BAO_Contribution::updateRelatedPledge(
+ $action,
+ $pledgePaymentID,
+ $contribution->id,
+ (CRM_Utils_Array::value('option_type', $formValues) == 2) ? TRUE : FALSE,
+ $formValues['total_amount'],
+ $this->_defaults['total_amount'],
+ $formValues['contribution_status_id'],
+ $this->_defaults['contribution_status_id']
+ );
+ return $contribution;
}
}
'receive_date_time' => '11:27PM',
'contact_id' => $this->_individualId,
'payment_instrument_id' => array_search('Check', $this->paymentInstruments),
+ 'contribution_status_id' => 1,
),
CRM_Core_Action::ADD);
$this->callAPISuccessGetCount('Contribution', array('contact_id' => $this->_individualId), 1);
'receive_date_time' => '11:27PM',
'contact_id' => $this->_individualId,
'payment_instrument_id' => array_search('Credit Card', $this->paymentInstruments),
+ 'contribution_status_id' => 1,
), CRM_Core_Action::ADD);
$this->callAPISuccessGetCount('Contribution', array('contact_id' => $this->_individualId), 1);
}
'contact_id' => $this->_individualId,
'is_email_receipt' => TRUE,
'from_email_address' => 'test@test.com',
+ 'contribution_status_id' => 1,
), CRM_Core_Action::ADD);
$this->callAPISuccessGetCount('Contribution', array('contact_id' => $this->_individualId), 1);
$mut->checkMailLog(array(
'contact_id' => $this->_individualId,
'payment_instrument_id' => array_search('Check', $this->paymentInstruments),
'pledge_payment_id' => $pledgePaymentID,
+ 'contribution_status_id' => 1,
), CRM_Core_Action::ADD);
$pledgePayment = $this->callAPISuccess('pledge_payment', 'getsingle', array('id' => $pledgePaymentID));
$this->assertNotEmpty($pledgePayment['contribution_id']);