public function preProcess() {
// Check permission for action.
if (!CRM_Core_Permission::checkActionPermission('CiviContribute', $this->_action)) {
+ // @todo replace with throw new CRM_Core_Exception().
CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
}
else {
$lineItem = CRM_Price_BAO_LineItem::getLineItems($this->_id, 'contribution', 1, TRUE, TRUE);
}
+ // wtf?
empty($lineItem) ? NULL : $this->_lineItems[] = $lineItem;
}
- $this->assign('lineItem', empty($this->_lineItems) ? FALSE : $this->_lineItems);
+ $this->assign('lineItem', empty($lineItem) ? FALSE : array($lineItem));
// Set title
if ($this->_mode && $this->_id) {
$defaults['fee_amount'] = CRM_Utils_Money::format($defaults['fee_amount'], NULL, '%a');
}
- if (isset($defaults['net_amount'])) {
- $defaults['net_amount'] = CRM_Contribute_BAO_Contribution::calculateNetAmount($defaults['net_amount'], CRM_Utils_Array::value('tax_amount', $defaults));
- }
-
if ($this->_contributionType) {
$defaults['financial_type_id'] = $this->_contributionType;
}
$paymentInstrument = FALSE;
if (!$this->_mode) {
+ $checkPaymentID = array_search('Check', CRM_Contribute_PseudoConstant::paymentInstrument('name'));
$paymentInstrument = $this->add('select', 'payment_instrument_id',
ts('Payment Method'),
array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::paymentInstrument(),
- TRUE, array('onChange' => "return showHideByValue('payment_instrument_id','4','checkNumber','table-row','select',false);")
+ TRUE, array('onChange' => "return showHideByValue('payment_instrument_id','{$checkPaymentID}','checkNumber','table-row','select',false);")
);
}
if ($this->_online) {
$this->assign('hideCalender', TRUE);
}
- $checkNumber = $this->add('text', 'check_number', ts('Check Number'), $attributes['check_number']);
+ $checkNumber = $this->add('text', 'check_number', ts('Check Number'), $attributes['contribution_check_number']);
$this->addDateTime('receipt_date', ts('Receipt Date'), FALSE, array('formatType' => 'activityDateTime'));
$this->addDateTime('cancel_date', ts('Cancelled / Refunded Date'), FALSE, array('formatType' => 'activityDateTime'));
* @throws \Exception
*/
protected function submit($submittedValues, $action, $pledgePaymentID) {
- $softIDs = array();
+
$pId = $contribution = $isRelatedId = FALSE;
$this->_params = $submittedValues;
$this->beginPostProcess();
}
if (!isset($submittedValues['total_amount'])) {
- $submittedValues['total_amount'] = CRM_Utils_Array::value('total_amount', $this->_values);
+ $submittedValues['total_amount'] = CRM_Utils_Array::value('total_amount', $this->_values) - CRM_Utils_Array::value('tax_amount', $this->_values);
}
$this->assign('lineItem', !empty($lineItem) && !$isQuickConfig ? $lineItem : FALSE);
}
$taxRate = array();
$getTaxDetails = FALSE;
- if ($action & CRM_Core_Action::ADD) {
- $line = $lineItem;
- }
- elseif ($action & CRM_Core_Action::UPDATE) {
- $line = $this->_lineItems;
- }
- foreach ($line as $key => $value) {
+
+ foreach ($lineItem as $key => $value) {
foreach ($value as $v) {
if (isset($taxRate[(string) CRM_Utils_Array::value('tax_rate', $v)])) {
$taxRate[(string) $v['tax_rate']] = $taxRate[(string) $v['tax_rate']] + CRM_Utils_Array::value('tax_amount', $v);