Skip to content
Snippets Groups Projects
Commit 2cfd4a61 authored by Kurund Jalmi's avatar Kurund Jalmi
Browse files

Merge pull request #2385 from kurund/CRM-13964

CRM-13964 CRM-13965 CRM-13973
parents 850eea21 5ce9cbe9
No related branches found
No related tags found
No related merge requests found
Showing
with 1946 additions and 49 deletions
...@@ -144,13 +144,22 @@ class CRM_Contribute_BAO_Contribution extends CRM_Contribute_DAO_Contribution { ...@@ -144,13 +144,22 @@ class CRM_Contribute_BAO_Contribution extends CRM_Contribute_DAO_Contribution {
$params['contribution_status_id'] = CRM_Core_OptionGroup::getValue('contribution_status', 'Completed', 'name'); $params['contribution_status_id'] = CRM_Core_OptionGroup::getValue('contribution_status', 'Completed', 'name');
} }
// CRM-13964 partial payment
if (empty($contributionID)) {
if (!empty($params['partial_payment_total']) && !empty($params['partial_amount_pay'])) {
$partialAmtTotal = $params['partial_payment_total'];
$partialAmtPay = $params['partial_amount_pay'];
$params['total_amount'] = $partialAmtTotal;
$params['contribution_status_id'] = CRM_Core_OptionGroup::getValue('contribution_status', 'Partially paid', 'name');
}
}
if ($contributionID) { if ($contributionID) {
CRM_Utils_Hook::pre('edit', 'Contribution', $contributionID, $params); CRM_Utils_Hook::pre('edit', 'Contribution', $contributionID, $params);
} }
else { else {
CRM_Utils_Hook::pre('create', 'Contribution', NULL, $params); CRM_Utils_Hook::pre('create', 'Contribution', NULL, $params);
} }
$contribution = new CRM_Contribute_BAO_Contribution(); $contribution = new CRM_Contribute_BAO_Contribution();
$contribution->copyValues($params); $contribution->copyValues($params);
...@@ -2440,7 +2449,7 @@ WHERE contribution_id = %1 "; ...@@ -2440,7 +2449,7 @@ WHERE contribution_id = %1 ";
* @access public * @access public
* @static * @static
*/ */
static function recordFinancialAccounts(&$params) { static function recordFinancialAccounts(&$params, $financialTrxnVals = NULL) {
$skipRecords = $update = FALSE; $skipRecords = $update = FALSE;
$additionalParticipantId = array(); $additionalParticipantId = array();
$contributionStatuses = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name'); $contributionStatuses = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
...@@ -2467,6 +2476,42 @@ WHERE contribution_id = %1 "; ...@@ -2467,6 +2476,42 @@ WHERE contribution_id = %1 ";
$update = TRUE; $update = TRUE;
} }
$statusId = $params['contribution']->contribution_status_id;
// CRM-13964 partial payment
if (CRM_Utils_Array::value('contribution_status_id', $params) == array_search('Partially paid', $contributionStatuses)
&& !empty($params['partial_payment_total']) && !empty($params['partial_amount_pay'])) {
$partialAmtPay = $params['partial_amount_pay'];
$partialAmtTotal = $params['partial_payment_total'];
$relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Accounts Receivable Account is' "));
$fromFinancialAccountId = CRM_Contribute_PseudoConstant::financialAccountType($params['financial_type_id'], $relationTypeId);
$statusId = CRM_Core_OptionGroup::getValue('contribution_status', 'Completed', 'name');
$params['total_amount'] = $partialAmtPay;
$balanceTrxnInfo = CRM_Core_BAO_FinancialTrxn::getBalanceTrxnAmt($params['contribution']->id, $params['financial_type_id']);
if (empty($balanceTrxnInfo['trxn_id'])) {
// create new balance transaction record
$relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Accounts Receivable Account is' "));
$toFinancialAccount = CRM_Contribute_PseudoConstant::financialAccountType($params['financial_type_id'], $relationTypeId);
$balanceTrxnParams['total_amount'] = $partialAmtTotal;
$balanceTrxnParams['to_financial_account_id'] = $toFinancialAccount;
$balanceTrxnParams['contribution_id'] = $params['contribution']->id;
$balanceTrxnParams['trxn_date'] = date('YmdHis');
$balanceTrxnParams['fee_amount'] = CRM_Utils_Array::value('fee_amount', $params);
$balanceTrxnParams['net_amount'] = CRM_Utils_Array::value('net_amount', $params);
$balanceTrxnParams['currency'] = $params['contribution']->currency;
$balanceTrxnParams['trxn_id'] = $params['contribution']->trxn_id;
$balanceTrxnParams['status_id'] = $statusId;
$balanceTrxnParams['payment_instrument_id'] = $params['contribution']->payment_instrument_id;
$balanceTrxnParams['check_number'] = CRM_Utils_Array::value('check_number', $params);
if (CRM_Utils_Array::value('payment_processor', $params)) {
$balanceTrxnParams['payment_processor_id'] = $params['payment_processor'];
}
CRM_Core_BAO_FinancialTrxn::create($balanceTrxnParams);
}
}
// build line item array if its not set in $params // build line item array if its not set in $params
if (!CRM_Utils_Array::value('line_item', $params) || $additionalParticipantId) { if (!CRM_Utils_Array::value('line_item', $params) || $additionalParticipantId) {
CRM_Price_BAO_LineItem::getLineItemArray($params, $entityID, str_replace('civicrm_', '', $entityTable)); CRM_Price_BAO_LineItem::getLineItemArray($params, $entityID, str_replace('civicrm_', '', $entityTable));
...@@ -2495,6 +2540,7 @@ WHERE contribution_id = %1 "; ...@@ -2495,6 +2540,7 @@ WHERE contribution_id = %1 ";
if (!isset($totalAmount) && CRM_Utils_Array::value('prevContribution', $params)) { if (!isset($totalAmount) && CRM_Utils_Array::value('prevContribution', $params)) {
$totalAmount = $params['total_amount'] = $params['prevContribution']->total_amount; $totalAmount = $params['total_amount'] = $params['prevContribution']->total_amount;
} }
//build financial transaction params //build financial transaction params
$trxnParams = array( $trxnParams = array(
'contribution_id' => $params['contribution']->id, 'contribution_id' => $params['contribution']->id,
...@@ -2505,7 +2551,7 @@ WHERE contribution_id = %1 "; ...@@ -2505,7 +2551,7 @@ WHERE contribution_id = %1 ";
'net_amount' => CRM_Utils_Array::value('net_amount', $params), 'net_amount' => CRM_Utils_Array::value('net_amount', $params),
'currency' => $params['contribution']->currency, 'currency' => $params['contribution']->currency,
'trxn_id' => $params['contribution']->trxn_id, 'trxn_id' => $params['contribution']->trxn_id,
'status_id' => $params['contribution']->contribution_status_id, 'status_id' => $statusId,
'payment_instrument_id' => $params['contribution']->payment_instrument_id, 'payment_instrument_id' => $params['contribution']->payment_instrument_id,
'check_number' => CRM_Utils_Array::value('check_number', $params), 'check_number' => CRM_Utils_Array::value('check_number', $params),
); );
...@@ -2513,6 +2559,16 @@ WHERE contribution_id = %1 "; ...@@ -2513,6 +2559,16 @@ WHERE contribution_id = %1 ";
if (CRM_Utils_Array::value('payment_processor', $params)) { if (CRM_Utils_Array::value('payment_processor', $params)) {
$trxnParams['payment_processor_id'] = $params['payment_processor']; $trxnParams['payment_processor_id'] = $params['payment_processor'];
} }
if (isset($fromFinancialAccountId)) {
$trxnParams['from_financial_account_id'] = $fromFinancialAccountId;
}
// consider external values passed for recording transaction entry
if (!empty($financialTrxnVals)) {
$trxnParams = array_merge($trxnParams, $financialTrxnVals);
}
$params['trxnParams'] = $trxnParams; $params['trxnParams'] = $trxnParams;
if (CRM_Utils_Array::value('prevContribution', $params)) { if (CRM_Utils_Array::value('prevContribution', $params)) {
...@@ -2646,6 +2702,10 @@ WHERE contribution_id = %1 "; ...@@ -2646,6 +2702,10 @@ WHERE contribution_id = %1 ";
CRM_Event_BAO_Participant::createDiscountTrxn($eventID, $params, $feeLevel); CRM_Event_BAO_Participant::createDiscountTrxn($eventID, $params, $feeLevel);
} }
unset($params['line_item']); unset($params['line_item']);
if (!$update) {
return $financialTxn;
}
} }
/** /**
...@@ -2891,6 +2951,187 @@ WHERE contribution_id = %1 "; ...@@ -2891,6 +2951,187 @@ WHERE contribution_id = %1 ";
} }
return FALSE; return FALSE;
} }
}
static function recordAdditionPayment($contributionId, $trxnsData, $paymentType, $participantId = NULL) {
// FIXME : needs handling of partial payment validness checking, if its valid then only record new entries
$params = $ids = $defaults = array();
$getInfoOf['id'] = $contributionId;
// build params for recording financial trxn entry
$contributionDAO = CRM_Contribute_BAO_Contribution::retrieve($getInfoOf, $defaults, $ids);
$params['contribution'] = $contributionDAO;
$params = array_merge($defaults, $params);
$params['skipLineItem'] = TRUE;
$params['partial_payment_total'] = $contributionDAO->total_amount;
$params['partial_amount_pay'] = $trxnsData['total_amount'];
$trxnsData['trxn_date'] = !empty($trxnsData['trxn_date']) ? $trxnsData['trxn_date'] : date('YmdHis');
// record the entry
$financialTrxn = CRM_Contribute_BAO_Contribution::recordFinancialAccounts($params, $trxnsData);
$statusId = CRM_Core_OptionGroup::getValue('contribution_status', 'Completed', 'name');
$relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Accounts Receivable Account is' "));
$toFinancialAccount = CRM_Contribute_PseudoConstant::financialAccountType($contributionDAO->financial_type_id, $relationTypeId);
$trxnId = CRM_Core_BAO_FinancialTrxn::getBalanceTrxnAmt($contributionId, $contributionDAO->financial_type_id);
$trxnId = $trxnId['trxn_id'];
// update statuses
// criteria for updates contribution total_amount == financial_trxns of partial_payments
$sql = "SELECT SUM(ft.total_amount) as sum_of_payments
FROM civicrm_financial_trxn ft
LEFT JOIN civicrm_entity_financial_trxn eft
ON (ft.id = eft.financial_trxn_id)
WHERE eft.entity_table = 'civicrm_contribution'
AND eft.entity_id = {$contributionId}
AND ft.to_financial_account_id != {$toFinancialAccount}
AND ft.status_id = {$statusId}
";
$sumOfPayments = CRM_Core_DAO::singleValueQuery($sql);
// update statuses
if ($contributionDAO->total_amount == $sumOfPayments) {
// update contribution status
$contributionUpdate['id'] = $contributionId;
$contributionUpdate['contribution_status_id'] = $statusId;
$contributionUpdate['skipLineItem'] = TRUE;
// note : not using the self::add method,
// the reason because it performs 'status change' related code execution for financial records
// which in 'Partial Paid' => 'Completed' is not useful, instead specific financial record updates
// are coded below i.e. just updating financial_item status to 'Paid'
$contributionDetails = CRM_Core_DAO::setFieldValue('CRM_Contribute_BAO_Contribution', $contributionId, 'contribution_status_id', $statusId);
if ($participantId) {
// update participant status
$participantUpdate['id'] = $participantId;
$participantStatuses = CRM_Event_PseudoConstant::participantStatus();
$participantUpdate['status_id'] = array_search('Registered', $participantStatuses);
CRM_Event_BAO_Participant::add($participantUpdate);
}
// update financial item statuses
$financialItemStatus = CRM_Core_PseudoConstant::get('CRM_Financial_DAO_FinancialItem', 'status_id');
$paidStatus = array_search('Paid', $financialItemStatus);
$sqlFinancialItemUpdate = "
UPDATE civicrm_financial_item fi
LEFT JOIN civicrm_entity_financial_trxn eft
ON (eft.entity_id = fi.id AND eft.entity_table = 'civicrm_financial_item')
SET status_id = {$paidStatus}
WHERE eft.financial_trxn_id = {$trxnId}
";
CRM_Core_DAO::executeQuery($sqlFinancialItemUpdate);
}
if (!empty($financialTrxn)) {
if ($participantId) {
$inputParams['id'] = $participantId;
$values = array();
$ids = array();
$component = 'event';
$entityObj = CRM_Event_BAO_Participant::getValues($inputParams, $values, $ids);
$entityObj = $entityObj[$participantId];
}
$activityType = ($paymentType == 'refund') ? 'Refund' : 'Payment';
// creation of activity
$activity = new CRM_Activity_DAO_Activity();
$activity->source_record_id = $financialTrxn->id;
$activity->activity_type_id = CRM_Core_OptionGroup::getValue('activity_type',
$activityType,
'name'
);
if (!$activity->find(TRUE)) {
self::addActivityForPayment($entityObj, $financialTrxn, $activityType, $component);
}
}
return $financialTrxn;
}
static function addActivityForPayment($entityObj, $trxnObj, $activityType, $component) {
if ($component == 'event') {
$date = CRM_Utils_Date::isoToMysql($trxnObj->trxn_date);
$paymentAmount = CRM_Utils_Money::format($trxnObj->total_amount, $trxnObj->currency);
$eventTitle = CRM_Core_DAO::getFieldValue('CRM_Event_BAO_Event', $entityObj->event_id, 'title');
$subject = "{$paymentAmount} - Offline {$activityType} for {$eventTitle}";
$targetCid = $entityObj->contact_id;
$srcRecId = $trxnObj->id;
}
// activity params
$activityParams = array(
'source_contact_id' => $targetCid,
'source_record_id' => $srcRecId,
'activity_type_id' => CRM_Core_OptionGroup::getValue('activity_type',
$activityType,
'name'
),
'subject' => $subject,
'activity_date_time' => $date,
'status_id' => CRM_Core_OptionGroup::getValue('activity_status',
'Completed',
'name'
),
'skipRecentView' => TRUE,
);
// create activity with target contacts
$session = CRM_Core_Session::singleton();
$id = $session->get('userID');
if ($id) {
$activityParams['source_contact_id'] = $id;
$activityParams['target_contact_id'][] = $targetCid;
}
CRM_Activity_BAO_Activity::create($activityParams);
}
function getPaymentInfo($id, $component, $getTrxnInfo = FALSE) {
if ($component == 'event') {
$entity = 'participant';
$contributionId = CRM_Core_DAO::getFieldValue('CRM_Event_BAO_ParticipantPayment', $id, 'contribution_id', 'participant_id');
}
$total = CRM_Core_BAO_FinancialTrxn::getBalanceTrxnAmt($contributionId);
$baseTrxnId = NULL;
if (empty($total)) {
$total = CRM_Price_BAO_LineItem::getLineTotal($id, 'civicrm_participant');
}
else {
$baseTrxnId = $total['trxn_id'];
$total = $total['total_amount'];
}
$paymentBalance = CRM_Core_BAO_FinancialTrxn::getPartialPaymentWithType($id, $entity, FALSE, $total);
$info['total'] = $total;
$info['paid'] = $total - $paymentBalance;
$info['balance'] = $paymentBalance;
$info['id'] = $id;
$info['component'] = $component;
$rows = array();
if ($getTrxnInfo && $baseTrxnId) {
$sql = "
SELECT ft.total_amount, con.financial_type_id, ft.payment_instrument_id, ft.trxn_date, ft.trxn_id, ft.status_id
FROM civicrm_contribution con
LEFT JOIN civicrm_entity_financial_trxn eft ON (eft.entity_id = con.id AND eft.entity_table = 'civicrm_contribution')
LEFT JOIN civicrm_financial_trxn ft ON ft.id = eft.financial_trxn_id
WHERE ft.id != {$baseTrxnId} AND con.id = {$contributionId}
";
$resultDAO = CRM_Core_DAO::executeQuery($sql);
while($resultDAO->fetch()) {
$paymentInstrument = CRM_Contribute_PseudoConstant::paymentInstrument();
$statuses = CRM_Contribute_PseudoConstant::contributionStatus();
$financialTypes = CRM_Contribute_PseudoConstant::financialType();
$rows[] = array(
'total_amount' => $resultDAO->total_amount,
'financial_type' => $financialTypes[$resultDAO->financial_type_id],
'payment_instrument' => $paymentInstrument[$resultDAO->payment_instrument_id],
'receive_date' => $resultDAO->trxn_date,
'trxn_id' => $resultDAO->trxn_id,
'status' => $statuses[$resultDAO->status_id],
);
}
$info['transaction'] = $rows;
}
return $info;
}
}
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.4 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2013 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
| under the terms of the GNU Affero General Public License |
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
| |
| CiviCRM is distributed in the hope that it will be usefusul, but |
| WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| See the GNU Affero General Public License for more details. |
| |
| You should have received a copy of the GNU Affero General Public |
| License and the CiviCRM Licensing Exception along |
| with this program; if not, contact CiviCRM LLC |
| at info[AT]civicrm[DOT]org. If you have questions about the |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
/**
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2013
* $Id$
*
*/
/**
* This form records additional payments needed when
* event/contribution is partially paid
*
*/
class CRM_Contribute_Form_AdditionalPayment extends CRM_Contribute_Form_AbstractEditPayment {
public $_contributeMode = 'direct';
/**
* related component whose financial payment is being processed
*
* @var string
* @public
*/
protected $_component = NULL;
/**
* id of the component entity
*/
public $_id = NULL;
protected $_owed = NULL;
protected $_refund = NULL;
protected $_contactId = NULL;
protected $_contributorDisplayName = NULL;
protected $_contributorEmail = NULL;
protected $_toDoNotEmail = NULL;
protected $_paymentType = NULL;
protected $_contributionId = NULL;
protected $fromEmailId = NULL;
public function preProcess() {
$this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE);
$this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE);
$this->_component = CRM_Utils_Request::retrieve('component', 'String', $this, TRUE);
$this->_fromEmails = CRM_Core_BAO_Email::getFromEmail();
$this->_formType = CRM_Utils_Array::value('formType', $_GET);
$enitityType = NULL;
if ($this->_component == 'event') {
$enitityType = 'participant';
$this->_contributionId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $this->_id, 'contribution_id', 'participant_id');
}
$paymentInfo = CRM_Core_BAO_FinancialTrxn::getPartialPaymentWithType($this->_id, $enitityType);
if (!empty($paymentInfo['refund_due'])) {
$paymentAmt = $this->_refund = $paymentInfo['refund_due'];
$this->_paymentType = 'refund';
}
elseif (!empty($paymentInfo['amount_owed'])) {
$paymentAmt = $this->_owed = $paymentInfo['amount_owed'];
$this->_paymentType = 'owed';
}
else {
CRM_Core_Error::fatal(ts('No payment information found for this record'));
}
list($this->_contributorDisplayName, $this->_contributorEmail) = CRM_Contact_BAO_Contact_Location::getEmailDetails($this->_contactId);
//set the payment mode - _mode property is defined in parent class
$this->_mode = CRM_Utils_Request::retrieve('mode', 'String', $this);
$this->assignProcessors();
// also check for billing information
// get the billing location type
$this->assignBillingType();
$this->assign('contributionMode', $this->_mode);
$this->assign('contactId', $this->_contactId);
$this->assign('component', $this->_component);
$this->assign('id', $this->_id);
$this->assign('paymentType', $this->_paymentType);
$this->assign('paymentAmt', $paymentAmt);
$this->_paymentProcessor = array('billing_mode' => 1);
$title = ($this->_refund) ? "Refund for {$this->_contributorDisplayName}" : "Payment from {$this->_contributorDisplayName}";
if ($title) {
CRM_Utils_System::setTitle(ts('%1', array(1 => $title)));
}
}
public function setDefaultValues() {
if ($this->_mode) {
$defaults = $this->_values;
$config = CRM_Core_Config::singleton();
// set default country from config if no country set
if (!CRM_Utils_Array::value("billing_country_id-{$this->_bltID}", $defaults)) {
$defaults["billing_country_id-{$this->_bltID}"] = $config->defaultContactCountry;
}
if (!CRM_Utils_Array::value("billing_state_province_id-{$this->_bltID}", $defaults)) {
$defaults["billing_state_province_id-{$this->_bltID}"] = $config->defaultContactStateProvince;
}
$billingDefaults = $this->getProfileDefaults('Billing', $this->_contactId);
$defaults = array_merge($defaults, $billingDefaults);
// now fix all state country selectors, set correct state based on country
CRM_Core_BAO_Address::fixAllStateSelects($this, $defaults);
}
// Set $newCredit variable in template to control whether link to credit card mode is included
CRM_Core_Payment::allowBackofficeCreditCard($this);
}
public function buildQuickForm() {
$ccPane = NULL;
if ($this->_mode) {
if (CRM_Utils_Array::value('payment_type', $this->_processors) & CRM_Core_Payment::PAYMENT_TYPE_DIRECT_DEBIT
) {
$ccPane = array(ts('Direct Debit Information') => 'DirectDebit');
}
else {
$ccPane = array(ts('Credit Card Information') => 'CreditCard');
}
$defaults = $this->_values;
$showAdditionalInfo = FALSE;
foreach ($ccPane as $name => $type) {
if ($this->_formType == $type ||
CRM_Utils_Array::value("hidden_{$type}", $_POST) ||
CRM_Utils_Array::value("hidden_{$type}", $defaults)
) {
$showAdditionalInfo = TRUE;
$allPanes[$name]['open'] = 'true';
}
$urlParams = "snippet=4&formType={$type}";
if ($this->_mode) {
$urlParams .= "&mode={$this->_mode}";
}
$open = 'false';
if ($type == 'CreditCard' ||
$type == 'DirectDebit'
) {
$open = 'true';
}
$allPanes[$name] = array(
'url' => CRM_Utils_System::url('civicrm/payment/add', $urlParams),
'open' => $open,
'id' => $type
);
if ($type == 'CreditCard') {
$this->add('hidden', 'hidden_CreditCard', 1);
CRM_Core_Payment_Form::buildCreditCard($this, TRUE);
}
elseif ($type == 'DirectDebit') {
$this->add('hidden', 'hidden_DirectDebit', 1);
CRM_Core_Payment_Form::buildDirectDebit($this, TRUE);
}
$qfKey = $this->controller->_key;
$this->assign('qfKey', $qfKey);
$this->assign('allPanes', $allPanes);
$this->assign('showAdditionalInfo', $showAdditionalInfo);
if ($this->_formType) {
$this->assign('formType', $this->_formType);
return;
}
}
}
$attributes = CRM_Core_DAO::getAttribute('CRM_Financial_DAO_FinancialTrxn');
$this->add('select', 'payment_processor_id', ts('Payment Processor'), $this->_processors, NULL);
$this->add('select', 'financial_type_id',
ts('Financial Type'),
array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::financialType(),
TRUE
);
$label = ($this->_refund) ? 'Refund Amount' : 'Payment Amount';
$this->addMoney('total_amount',
ts('%1', array(1 => $label)),
FALSE,
$attributes['total_amount'],
TRUE, 'currency', NULL
);
if (!$this->_mode) {
$this->add('select', 'payment_instrument_id',
ts('Paid By'),
array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::paymentInstrument(),
TRUE, array('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']);
$trxnId = $this->add('text', 'trxn_id', ts('Transaction ID'), $attributes['trxn_id']);
//add receipt for offline contribution
$this->addElement('checkbox', 'is_email_receipt', ts('Send Receipt?'));
$this->add('select', 'from_email_address', ts('Receipt From'), $this->_fromEmails);
// add various dates
$this->addDateTime('trxn_date', ts('Received'), FALSE, array('formatType' => 'activityDateTime'));
if ($this->_contactId && $this->_id) {
if ($this->_component == 'event') {
$eventId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', $this->_id, 'event_id', 'id');
$event = CRM_Event_BAO_Event::getEvents(0, $eventId);
$this->assign('eventName', $event[$eventId]);
}
}
$this->assign('displayName', $this->_contributorDisplayName);
$this->assign('component', $this->_component);
$this->assign('email', $this->_contributorEmail);
$this->add('text', 'fee_amount', ts('Fee Amount'),
$attributes['fee_amount']
);
$this->addRule('fee_amount', ts('Please enter a valid monetary value for Fee Amount.'), 'money');
$this->add('text', 'net_amount', ts('Net Amount'),
$attributes['net_amount']
);
$this->addRule('net_amount', ts('Please enter a valid monetary value for Net Amount.'), 'money');
$js = NULL;
if (!$this->_mode) {
$js = array('onclick' => "return verify( );");
}
$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')
),
)
);
$mailingInfo = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME,
'mailing_backend'
);
$this->assign('outBound_option', $mailingInfo['outBound_option']);
$this->addFormRule(array('CRM_Contribute_Form_AdditionalPayment', 'formRule'), $this);
}
static function formRule($fields, $files, $self) {
$errors = array();
if ($self->_paymentType == 'owed' && $fields['total_amount'] > $self->_owed) {
$errors['total_amount'] = ts('Payment amount cannot be greater than owed amount');
}
if ($self->_paymentType == 'refund' && $fields['total_amount'] != $self->_refund) {
$errors['total_amount'] = ts('Refund amount should not differ');
}
$netAmt = $fields['total_amount'] - $fields['fee_amount'];
if (!empty($fields['net_amount']) && $netAmt != $fields['net_amount']) {
$errors['net_amount'] = ts('Net amount should be difference of payment amount and fee amount');
}
return $errors;
}
public function postProcess() {
$participantId = NULL;
if ($this->_component == 'event') {
$participantId = $this->_id;
}
$submittedValues = $this->controller->exportValues($this->_name);
$submittedValues['trxn_date'] = CRM_Utils_Date::processDate($submittedValues['trxn_date'], $submittedValues['trxn_date_time']);
if ($this->_mode) {
// process credit card
$this->processCreditCard($submittedValues);
}
else {
$result = CRM_Contribute_BAO_Contribution::recordAdditionPayment($this->_contributionId, $submittedValues, $this->_paymentType, $participantId);
// email sending
if (!empty($result) && CRM_Utils_Array::value('is_email_receipt', $submittedValues)) {
$submittedValues['contact_id'] = $this->_contactId;
$submittedValues['contribution_id'] = $this->_contributionId;
// to get 'from email id' for send receipt
$this->fromEmailId = $submittedValues['from_email_address'];
$sendReceipt = self::emailReceipt($this, $submittedValues);
}
$statusMsg = ts('The payment record has been processed.');
if (CRM_Utils_Array::value('is_email_receipt', $submittedValues) && $sendReceipt) {
$statusMsg .= ' ' . ts('A receipt has been emailed to the contributor.');
}
CRM_Core_Session::setStatus($statusMsg, ts('Saved'), 'success');
$session = CRM_Core_Session::singleton();
$session->replaceUserContext(CRM_Utils_System::url('civicrm/contact/view',
"reset=1&cid={$this->_contactId}&selectedChild=participant"
));
}
}
public function processCreditCard($submittedValues) {
$config = CRM_Core_Config::singleton();
$session = CRM_Core_Session::singleton();
$unsetParams = array(
'trxn_id',
'payment_instrument_id',
'contribution_status_id',
);
foreach ($unsetParams as $key) {
if (isset($submittedValues[$key])) {
unset($submittedValues[$key]);
}
}
//Get the rquire fields value only.
$params = $this->_params = $submittedValues;
$this->_paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getPayment($this->_params['payment_processor_id'],
$this->_mode
);
//get the payment processor id as per mode.
$this->_params['payment_processor'] = $params['payment_processor_id'] =
$this->_params['payment_processor_id'] = $submittedValues['payment_processor_id'] = $this->_paymentProcessor['id'];
$now = date('YmdHis');
$fields = array();
// we need to retrieve email address
if ($this->_context == 'standalone' && CRM_Utils_Array::value('is_email_receipt', $submittedValues)) {
list($this->userDisplayName,
$this->userEmail
) = CRM_Contact_BAO_Contact_Location::getEmailDetails($this->_contactId);
$this->assign('displayName', $this->userDisplayName);
}
//set email for primary location.
$fields['email-Primary'] = 1;
$params['email-Primary'] = $this->_contributorEmail;
// now set the values for the billing location.
foreach ($this->_fields as $name => $dontCare) {
$fields[$name] = 1;
}
// also add location name to the array
$params["address_name-{$this->_bltID}"] = CRM_Utils_Array::value('billing_first_name', $params) . ' ' . CRM_Utils_Array::value('billing_middle_name', $params) . ' ' . CRM_Utils_Array::value('billing_last_name', $params);
$params["address_name-{$this->_bltID}"] = trim($params["address_name-{$this->_bltID}"]);
$fields["address_name-{$this->_bltID}"] = 1;
$ctype = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact',
$this->_contactId,
'contact_type'
);
$nameFields = array('first_name', 'middle_name', 'last_name');
foreach ($nameFields as $name) {
$fields[$name] = 1;
if (array_key_exists("billing_$name", $params)) {
$params[$name] = $params["billing_{$name}"];
$params['preserveDBName'] = TRUE;
}
}
if (CRM_Utils_Array::value('source', $params)) {
unset($params['source']);
}
$contactID = CRM_Contact_BAO_Contact::createProfileContact($params, $fields,
$this->_contactId,
NULL, NULL,
$ctype
);
// add all the additioanl payment params we need
$this->_params["state_province-{$this->_bltID}"] = $this->_params["billing_state_province-{$this->_bltID}"] = CRM_Core_PseudoConstant::stateProvinceAbbreviation($this->_params["billing_state_province_id-{$this->_bltID}"]);
$this->_params["country-{$this->_bltID}"] = $this->_params["billing_country-{$this->_bltID}"] = CRM_Core_PseudoConstant::countryIsoCode($this->_params["billing_country_id-{$this->_bltID}"]);
if ($this->_paymentProcessor['payment_type'] & CRM_Core_Payment::PAYMENT_TYPE_CREDIT_CARD) {
$this->_params['year'] = CRM_Core_Payment_Form::getCreditCardExpirationYear($this->_params);
$this->_params['month'] = CRM_Core_Payment_Form::getCreditCardExpirationMonth($this->_params);
}
$this->_params['ip_address'] = CRM_Utils_System::ipAddress();
$this->_params['amount'] = $this->_params['total_amount'];
$this->_params['amount_level'] = 0;
$this->_params['currencyID'] = CRM_Utils_Array::value('currency',
$this->_params,
$config->defaultCurrency
);
$this->_params['payment_action'] = 'Sale';
if (CRM_Utils_Array::value('trxn_date', $this->_params)) {
$this->_params['receive_date'] = CRM_Utils_Date::processDate($this->_params['trxn_date'], $this->_params['receive_date_time']);
}
if (empty($this->_params['invoice_id'])) {
$this->_params['invoiceID'] = md5(uniqid(rand(), TRUE));
}
else {
$this->_params['invoiceID'] = $this->_params['invoice_id'];
}
//Add common data to formatted params
CRM_Contribute_Form_AdditionalInfo::postProcessCommon($params, $this->_params, $this);
// at this point we've created a contact and stored its address etc
// all the payment processors expect the name and address to be in the
// so we copy stuff over to first_name etc.
$paymentParams = $this->_params;
$paymentParams['contactID'] = $this->_contactId;
CRM_Core_Payment_Form::mapParams($this->_bltID, $this->_params, $paymentParams, TRUE);
$contributionType = new CRM_Financial_DAO_FinancialType();
$contributionType->id = $params['financial_type_id'];
if (!$contributionType->find(TRUE)) {
CRM_Core_Error::fatal('Could not find a system table');
}
// add some financial type details to the params list
// if folks need to use it
$paymentParams['contributionType_name'] = $this->_params['contributionType_name'] = $contributionType->name;
$paymentParams['contributionPageID'] = NULL;
if (CRM_Utils_Array::value('is_email_receipt', $this->_params)) {
$paymentParams['email'] = $this->_contributorEmail;
$paymentParams['is_email_receipt'] = 1;
}
else {
$paymentParams['is_email_receipt'] = 0;
$this->_params['is_email_receipt'] = 0;
}
if (CRM_Utils_Array::value('receive_date', $this->_params)) {
$paymentParams['receive_date'] = $this->_params['receive_date'];
}
if (CRM_Utils_Array::value('receive_date', $this->_params)) {
$paymentParams['receive_date'] = $this->_params['receive_date'];
}
$result = NULL;
if ($paymentParams['amount'] > 0.0) {
// force a reget of the payment processor in case the form changed it, CRM-7179
$payment = CRM_Core_Payment::singleton($this->_mode, $this->_paymentProcessor, $this, TRUE);
$result = $payment->doDirectPayment($paymentParams);
}
if (is_a($result, 'CRM_Core_Error')) {
//set the contribution mode.
$urlParams = "action=add&cid={$this->_contactId}&id={$this->_id}&component={$this->_component}";
if ($this->_mode) {
$urlParams .= "&mode={$this->_mode}";
}
CRM_Core_Error::displaySessionError($result);
CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/payment/add', $urlParams));
}
if ($result) {
$this->_params = array_merge($this->_params, $result);
}
$this->_params['receive_date'] = $now;
$this->set('params', $this->_params);
$this->assign('trxn_id', $result['trxn_id']);
$this->assign('receive_date', $this->_params['receive_date']);
// set source if not set
if (empty($this->_params['source'])) {
$userID = $session->get('userID');
$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));
}
// process the additional payment
$trxnRecord = CRM_Contribute_BAO_Contribution::recordAdditionPayment($this->_contributionId, $submittedValues, $this->_paymentType, $participantId);
if ($trxnRecord->id &&
CRM_Utils_Array::value('is_email_receipt', $this->_params)
) {
$sendReceipt = self::emailReceipt($this, $this->_params);
}
if ($trxnRecord->id) {
$statusMsg = ts('The payment record has been processed.');
if (CRM_Utils_Array::value('is_email_receipt', $this->_params) && $sendReceipt) {
$statusMsg .= ' ' . ts('A receipt has been emailed to the contributor.');
}
CRM_Core_Session::setStatus($statusMsg, ts('Complete'), 'success');
$session->replaceUserContext(CRM_Utils_System::url('civicrm/contact/view',
"reset=1&cid={$this->_contactId}&selectedChild=participant"
));
}
}
static function emailReceipt(&$form, &$params) {
// email receipt sending
}
}
\ No newline at end of file
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.4 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2013 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
| under the terms of the GNU Affero General Public License |
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
| |
| CiviCRM is distributed in the hope that it will be useful, but |
| WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| See the GNU Affero General Public License for more details. |
| |
| You should have received a copy of the GNU Affero General Public |
| License and the CiviCRM Licensing Exception along |
| with this program; if not, contact CiviCRM LLC |
| at info[AT]civicrm[DOT]org. If you have questions about the |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
/**
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2013
* $Id$
*
*/
class CRM_Contribute_Page_PaymentInfo extends CRM_Core_Page {
function preProcess() {
$this->_component = CRM_Utils_Request::retrieve('component', 'String', $this, TRUE);
$this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'browse');
$this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE);
$this->_context = CRM_Utils_Request::retrieve('context', 'String', $this, TRUE);
$this->_cid = CRM_Utils_Request::retrieve('cid', 'String', $this, TRUE);
$this->assign('cid', $this->_cid);
$this->assign('id', $this->_id);
$this->assign('context', $this->_context);
$this->assign('component', $this->_component);
}
function browse() {
$getTrxnInfo = $this->_context == 'transaction' ? TRUE : FALSE;
$paymentInfo = CRM_Contribute_BAO_Contribution::getPaymentInfo($this->_id, $this->_component, $getTrxnInfo);
if ($this->_context == 'payment_info') {
$this->assign('paymentInfo', $paymentInfo);
}
else {
$rows = CRM_Utils_Array::value('transaction', $paymentInfo);
$this->assign('rows', $rows);
}
}
function run() {
$this->preProcess();
if ($this->_action) {
$this->browse();
}
return parent::run();
}
}
\ No newline at end of file
...@@ -121,6 +121,15 @@ ...@@ -121,6 +121,15 @@
<adminGroup>CiviContribute</adminGroup> <adminGroup>CiviContribute</adminGroup>
<weight>580</weight> <weight>580</weight>
</item> </item>
<item>
<path>civicrm/payment/add</path>
<title>New Payment</title>
<page_callback>CRM_Contribute_Form_AdditionalPayment</page_callback>
<path_arguments>action=add</path_arguments>
<access_arguments>access CiviContribute</access_arguments>
<page_type>1</page_type>
<component>CiviContribute</component>
</item>
<item> <item>
<path>civicrm/admin/financial/financialAccount</path> <path>civicrm/admin/financial/financialAccount</path>
<title>Financial Accounts</title> <title>Financial Accounts</title>
...@@ -282,4 +291,13 @@ ...@@ -282,4 +291,13 @@
<page_callback>CRM_Financial_Form_Export</page_callback> <page_callback>CRM_Financial_Form_Export</page_callback>
<weight>610</weight> <weight>610</weight>
</item> </item>
</menu> <item>
<path>civicrm/payment/view</path>
<title>View Payment</title>
<page_callback>CRM_Contribute_Page_PaymentInfo</page_callback>
<path_arguments>action=view</path_arguments>
<access_arguments>access CiviContribute</access_arguments>
<page_type>1</page_type>
<component>CiviContribute</component>
</item>
</menu>
\ No newline at end of file
...@@ -83,6 +83,25 @@ class CRM_Core_BAO_FinancialTrxn extends CRM_Financial_DAO_FinancialTrxn { ...@@ -83,6 +83,25 @@ class CRM_Core_BAO_FinancialTrxn extends CRM_Financial_DAO_FinancialTrxn {
return $trxn; return $trxn;
} }
static function getBalanceTrxnAmt($contributionId, $contributionFinancialTypeId = NULL) {
if (!$contributionFinancialTypeId) {
$contributionFinancialTypeId = CRM_Core_DAO::getFieldValue('CRM_Contribute_BAO_Contribution', $contributionId, 'financial_type_id');
}
$relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Accounts Receivable Account is' "));
$toFinancialAccount = CRM_Contribute_PseudoConstant::financialAccountType($contributionFinancialTypeId, $relationTypeId);
$q = "SELECT ft.id, ft.total_amount FROM civicrm_financial_trxn ft INNER JOIN civicrm_entity_financial_trxn eft ON (eft.financial_trxn_id = ft.id AND eft.entity_table = 'civicrm_contribution') WHERE eft.entity_id = %1 AND ft.to_financial_account_id = %2";
$p[1] = array($contributionId, 'Integer');
$p[2] = array($toFinancialAccount, 'Integer');
$balanceAmtDAO = CRM_Core_DAO::executeQuery($q, $p);
$ret = array();
while($balanceAmtDAO->fetch()) {
$ret['trxn_id'] = $balanceAmtDAO->id;
$ret['total_amount'] = $balanceAmtDAO->total_amount;
}
return $ret;
}
/** /**
* Takes a bunch of params that are needed to match certain criteria and * Takes a bunch of params that are needed to match certain criteria and
* retrieves the relevant objects. Typically the valid params are only * retrieves the relevant objects. Typically the valid params are only
...@@ -373,5 +392,58 @@ WHERE ceft.entity_id = %1"; ...@@ -373,5 +392,58 @@ WHERE ceft.entity_id = %1";
$trxnIDS['id'] = $trxn->id; $trxnIDS['id'] = $trxn->id;
$financialItem = CRM_Financial_BAO_FinancialItem::create($fItemParams, NULL, $trxnIDS); $financialItem = CRM_Financial_BAO_FinancialItem::create($fItemParams, NULL, $trxnIDS);
} }
}
/*
* function to get partial payment amount and type of it
* return @array : payment type => amount
* payment type : 'amount_owed' or 'refund_due'
*/
static function getPartialPaymentWithType($entityId, $entityName = 'participant', $returnType = TRUE, $lineItemTotal = NULL) {
$value = NULL;
if (empty($entityName)) {
return $value;
}
if ($entityName == 'participant') {
$contributionId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $entityId, 'contribution_id', 'participant_id');
$financialTypeId = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Contribution', $entityId, 'financial_type_id');
if ($contributionId && $financialTypeId) {
$statusId = CRM_Core_OptionGroup::getValue('contribution_status', 'Completed', 'name');
$relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Accounts Receivable Account is' "));
$toFinancialAccount = CRM_Contribute_PseudoConstant::financialAccountType($financialTypeId, $relationTypeId);
if (empty($lineItemTotal)) {
$lineItemTotal = CRM_Price_BAO_LineItem::getLineTotal($entityId, 'civicrm_participant');
}
$sqlFtTotalAmt = "
SELECT SUM(ft.total_amount)
FROM civicrm_financial_trxn ft
LEFT JOIN civicrm_entity_financial_trxn eft ON (ft.id = eft.financial_trxn_id AND eft.entity_table = 'civicrm_contribution')
LEFT JOIN civicrm_contribution c ON (eft.entity_id = c.id)
LEFT JOIN civicrm_participant_payment pp ON (pp.contribution_id = c.id)
WHERE pp.participant_id = {$entityId} AND ft.to_financial_account_id != {$toFinancialAccount}
AND ft.from_financial_account_id = {$toFinancialAccount} AND ft.status_id = {$statusId}
";
$ftTotalAmt = CRM_Core_DAO::singleValueQuery($sqlFtTotalAmt);
$value = 0;
if ($ftTotalAmt) {
$value = $paymentVal = $lineItemTotal - $ftTotalAmt;
}
if ($returnType) {
$value = array();
if ($paymentVal < 0) {
$value['refund_due'] = $paymentVal;
}
elseif ($paymentVal > 0) {
$value['amount_owed'] = $paymentVal;
}
elseif ($lineItemTotal == $ftTotalAmt) {
$value['full_paid'] = $ftTotalAmt;
}
}
}
}
return $value;
}
}
\ No newline at end of file
...@@ -228,8 +228,12 @@ class CRM_Event_Form_Participant extends CRM_Contact_Form_Task { ...@@ -228,8 +228,12 @@ class CRM_Event_Form_Participant extends CRM_Contact_Form_Task {
else { else {
$this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this); $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
} }
$participantStatuses = CRM_Event_PseudoConstant::participantStatus();
if ($this->_id) { if ($this->_id) {
$this->assign('participantId', $this->_id);
$statusId = CRM_Core_DAO::getFieldValue('CRM_Event_BAO_Participant', $this->_id, 'status_id', 'id');
$this->_paymentId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $this->_paymentId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment',
$this->_id, 'id', 'participant_id' $this->_id, 'id', 'participant_id'
); );
...@@ -255,6 +259,9 @@ class CRM_Event_Form_Participant extends CRM_Contact_Form_Task { ...@@ -255,6 +259,9 @@ class CRM_Event_Form_Participant extends CRM_Contact_Form_Task {
$this->assign('eventNameCustomDataTypeID', $this->_eventNameCustomDataTypeID); $this->assign('eventNameCustomDataTypeID', $this->_eventNameCustomDataTypeID);
$this->assign('eventTypeCustomDataTypeID', $this->_eventTypeCustomDataTypeID); $this->assign('eventTypeCustomDataTypeID', $this->_eventTypeCustomDataTypeID);
$partiallyPaidStatusId = array_search('Partially paid', $participantStatuses);
$this->assign('partiallyPaidStatusId', $partiallyPaidStatusId);
if ($this->_mode) { if ($this->_mode) {
$this->assign('participantMode', $this->_mode); $this->assign('participantMode', $this->_mode);
...@@ -665,6 +672,7 @@ SELECT civicrm_custom_group.name as name, ...@@ -665,6 +672,7 @@ SELECT civicrm_custom_group.name as name,
* @access public * @access public
*/ */
public function buildQuickForm() { public function buildQuickForm() {
CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js');
if ($this->_showFeeBlock) { if ($this->_showFeeBlock) {
return CRM_Event_Form_EventFees::buildQuickForm($this); return CRM_Event_Form_EventFees::buildQuickForm($this);
} }
...@@ -1054,6 +1062,7 @@ loadCampaign( {$this->_eID}, {$eventCampaigns} ); ...@@ -1054,6 +1062,7 @@ loadCampaign( {$this->_eID}, {$eventCampaigns} );
return; return;
} }
$participantStatus = CRM_Event_PseudoConstant::participantStatus();
// set the contact, when contact is selected // set the contact, when contact is selected
if (CRM_Utils_Array::value('contact_select_id', $params)) { if (CRM_Utils_Array::value('contact_select_id', $params)) {
$this->_contactId = $params['contact_select_id'][1]; $this->_contactId = $params['contact_select_id'][1];
...@@ -1122,7 +1131,8 @@ loadCampaign( {$this->_eID}, {$eventCampaigns} ); ...@@ -1122,7 +1131,8 @@ loadCampaign( {$this->_eID}, {$eventCampaigns} );
$params['fee_level'] = $params['amount_level']; $params['fee_level'] = $params['amount_level'];
$contributionParams['total_amount'] = $params['amount']; $contributionParams['total_amount'] = $params['amount'];
if ($this->_quickConfig && CRM_Utils_Array::value('total_amount', $params)) { if ($this->_quickConfig && CRM_Utils_Array::value('total_amount', $params)
&& $params['status_id'] != array_search('Partially paid', $participantStatus)) {
$params['fee_amount'] = $params['total_amount']; $params['fee_amount'] = $params['total_amount'];
} else { } else {
//fix for CRM-3086 //fix for CRM-3086
...@@ -1157,7 +1167,11 @@ loadCampaign( {$this->_eID}, {$eventCampaigns} ); ...@@ -1157,7 +1167,11 @@ loadCampaign( {$this->_eID}, {$eventCampaigns} );
} }
$this->_params = $params; $this->_params = $params;
unset($params['amount']); $amountOwed = NULL;
if (isset($params['amount'])) {
$amountOwed = $params['amount'];
unset($params['amount']);
}
$params['register_date'] = CRM_Utils_Date::processDate($params['register_date'], $params['register_date_time']); $params['register_date'] = CRM_Utils_Date::processDate($params['register_date'], $params['register_date_time']);
$params['receive_date'] = CRM_Utils_Date::processDate(CRM_Utils_Array::value('receive_date', $params)); $params['receive_date'] = CRM_Utils_Date::processDate(CRM_Utils_Array::value('receive_date', $params));
$params['contact_id'] = $this->_contactId; $params['contact_id'] = $this->_contactId;
...@@ -1461,6 +1475,16 @@ loadCampaign( {$this->_eID}, {$eventCampaigns} ); ...@@ -1461,6 +1475,16 @@ loadCampaign( {$this->_eID}, {$eventCampaigns} );
if ($contributionParams['contribution_status_id'] == CRM_Core_OptionGroup::getValue('contribution_status', 'Pending', 'name')) { if ($contributionParams['contribution_status_id'] == CRM_Core_OptionGroup::getValue('contribution_status', 'Pending', 'name')) {
$contributionParams['is_pay_later'] = 1; $contributionParams['is_pay_later'] = 1;
} }
if ($params['status_id'] == array_search('Partially paid', $participantStatus)) {
// CRM-13964 partial_payment_total
if ($amountOwed > $params['total_amount']) {
// the owed amount
$contributionParams['partial_payment_total'] = $amountOwed;
// the actual amount paid
$contributionParams['partial_amount_pay'] = $params['total_amount'];
}
}
if ($this->_single) { if ($this->_single) {
if (empty($ids)) { if (empty($ids)) {
$ids = array(); $ids = array();
...@@ -1510,7 +1534,9 @@ loadCampaign( {$this->_eID}, {$eventCampaigns} ); ...@@ -1510,7 +1534,9 @@ loadCampaign( {$this->_eID}, {$eventCampaigns} );
if (is_array($value) && $value != 'skip') { if (is_array($value) && $value != 'skip') {
foreach ($value as $lineKey => $line) { foreach ($value as $lineKey => $line) {
//10117 update the line items for participants if contribution amount is recorded //10117 update the line items for participants if contribution amount is recorded
if ($this->_quickConfig && CRM_Utils_Array::value('total_amount', $params )) { if ($this->_quickConfig && CRM_Utils_Array::value('total_amount', $params )
&& $params['status_id'] != array_search('Partially paid', $participantStatus)
) {
$line['unit_price'] = $line['line_total'] = $params['total_amount']; $line['unit_price'] = $line['line_total'] = $params['total_amount'];
} }
$lineItem[$this->_priceSetId][$lineKey] = $line; $lineItem[$this->_priceSetId][$lineKey] = $line;
......
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.4 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2013 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
| under the terms of the GNU Affero General Public License |
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
| |
| CiviCRM is distributed in the hope that it will be usefusul, but |
| WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| See the GNU Affero General Public License for more details. |
| |
| You should have received a copy of the GNU Affero General Public |
| License and the CiviCRM Licensing Exception along |
| with this program; if not, contact CiviCRM LLC |
| at info[AT]civicrm[DOT]org. If you have questions about the |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
/**
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2013
* $Id$
*
*/
/**
* This form used for changing / updating fee selections for the events
* event/contribution is partially paid
*
*/
class CRM_Event_Form_ParticipantFeeSelection extends CRM_Core_Form {
protected $_contactId = NULL;
protected $_contributorDisplayName = NULL;
protected $_contributorEmail = NULL;
protected $_toDoNotEmail = NULL;
protected $_contributionId = NULL;
protected $fromEmailId = NULL;
protected $_eventId = NULL;
public $_action = NULL;
public $_values = NULL;
public $_participantId = NULL;
protected $_participantStatus = NULL;
public function preProcess() {
$this->_participantId = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE);
$this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE);
$this->_eventId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', $this->_participantId, 'event_id');
$this->_fromEmails = CRM_Event_BAO_Event::getFromEmailIds($this->_eventId);
$this->_contributionId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $this->_participantId, 'contribution_id', 'participant_id');
if ($this->_contributionId) {
$this->_isPaidEvent = TRUE;
}
$this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, TRUE);
list($this->_contributorDisplayName, $this->_contributorEmail) = CRM_Contact_BAO_Contact_Location::getEmailDetails($this->_contactId);
$this->assign('displayName', $this->_contributorDisplayName);
$this->assign('email', $this->_contributorEmail);
$this->_participantStatus = CRM_Core_DAO::getFieldValue('CRM_Event_BAO_Participant', $this->_participantId, 'status_id');
//set the payment mode - _mode property is defined in parent class
$this->_mode = CRM_Utils_Request::retrieve('mode', 'String', $this);
$this->assign('contactId', $this->_contactId);
$this->assign('id', $this->_participantId);
$paymentInfo = CRM_Contribute_BAO_Contribution::getPaymentInfo($this->_participantId, 'event');
$this->assign('paymentInfo', $paymentInfo);
CRM_Core_Resources::singleton()->addSetting(array('feePaid' => $paymentInfo['paid']));
$title = "Change selections for {$this->_contributorDisplayName}";
if ($title) {
CRM_Utils_System::setTitle(ts('%1', array(1 => $title)));
}
}
public function setDefaultValues() {
$params = array('id' => $this->_participantId);
CRM_Event_BAO_Participant::getValues($params, $defaults, $ids);
$priceSetId = CRM_Price_BAO_PriceSet::getFor('civicrm_event', $this->_eventId);
$priceSetValues = CRM_Event_Form_EventFees::setDefaultPriceSet($this->_participantId, $this->_eventId);
if (!empty($priceSetValues)) {
$defaults[$this->_participantId] = array_merge($defaults[$this->_participantId], $priceSetValues);
}
$this->assign('totalAmount', CRM_Utils_Array::value('fee_amount', $defaults[$this->_participantId]));
if ($this->_action == CRM_Core_Action::UPDATE) {
$fee_level = $defaults[$this->_participantId]['fee_level'];
CRM_Event_BAO_Participant::fixEventLevel($fee_level);
$this->assign('fee_level', $fee_level);
$this->assign('fee_amount', CRM_Utils_Array::value('fee_amount', $defaults[$this->_participantId]));
}
$defaults = $defaults[$this->_participantId];
return $defaults;
}
public function buildQuickForm() {
CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js');
$statuses = CRM_Event_PseudoConstant::participantStatus();
CRM_Core_Resources::singleton()->addSetting(array(
'partiallyPaid' => array_search('Partially paid', $statuses),
'pendingRefund' => array_search('Pending refund', $statuses),
'participantStatus' => $this->_participantStatus
));
$config = CRM_Core_Config::singleton();
$this->assign('currencySymbol', $config->defaultCurrencySymbol);
// line items block
$lineItem = $event = array();
$params = array('id' => $this->_eventId);
CRM_Event_BAO_Event::retrieve($params, $event);
//retrieve custom information
$this->_values = array();
CRM_Event_Form_Registration::initEventFee($this, $event['id']);
CRM_Event_Form_Registration_Register::buildAmount($this, TRUE);
if (!CRM_Utils_System::isNull(CRM_Utils_Array::value('line_items', $this->_values))) {
$lineItem[] = $this->_values['line_items'];
}
$this->assign('lineItem', empty($lineItem) ? FALSE : $lineItem);
$event = CRM_Event_BAO_Event::getEvents(0, $this->_eventId);
$this->assign('eventName', $event[$this->_eventId]);
$statusOptions = CRM_Event_PseudoConstant::participantStatus(NULL, NULL, 'label');
$this->add('select', 'status_id', ts('Participant Status'),
array(
'' => ts('- select -')) + $statusOptions,
TRUE
);
$this->addElement('checkbox',
'send_receipt',
ts('Send Confirmation?'), NULL,
array('onclick' => "showHideByValue('send_receipt','','notice','table-row','radio',false); showHideByValue('send_receipt','','from-email','table-row','radio',false);")
);
$this->add('select', 'from_email_address', ts('Receipt From'), $this->_fromEmails['from_email_id']);
$this->add('textarea', 'receipt_text', ts('Confirmation Message'));
$noteAttributes = CRM_Core_DAO::getAttribute('CRM_Core_DAO_Note');
$this->add('textarea', 'note', ts('Notes'), $noteAttributes['note']);
$buttons[] = array(
'type' => 'upload',
'name' => ts('Save'),
'isDefault' => TRUE,
);
$buttons[] = array(
'type' => 'upload',
'name' => ts('Save and Record Payment'),
'subName' => 'new'
);
$buttons[] = array(
'type' => 'cancel',
'name' => ts('Cancel'),
);
$this->addButtons($buttons);
$this->addFormRule(array('CRM_Event_Form_ParticipantFeeSelection', 'formRule'), $this);
}
static function formRule($fields, $files, $self) {
$errors = array();
return $errors;
}
public function postProcess() {
$params = $this->controller->exportValues($this->_name);
$session = CRM_Core_Session::singleton();
$buttonName = $this->controller->getButtonName();
if ($buttonName == $this->getButtonName('upload', 'new')) {
$session->replaceUserContext(CRM_Utils_System::url('civicrm/payment/add',
"reset=1&action=add&component=event&id={$this->_participantId}&cid={$this->_contactId}"
));
}
}
static function emailReceipt(&$form, &$params) {
// email receipt sending
}
}
\ No newline at end of file
...@@ -66,6 +66,11 @@ class CRM_Event_Form_ParticipantView extends CRM_Core_Form { ...@@ -66,6 +66,11 @@ class CRM_Event_Form_ParticipantView extends CRM_Core_Form {
CRM_Event_BAO_Participant::fixEventLevel($values[$participantID]['fee_level']); CRM_Event_BAO_Participant::fixEventLevel($values[$participantID]['fee_level']);
} }
$this->assign('contactId', $contactID);
$this->assign('participantId', $participantID);
$statusId = CRM_Core_DAO::getFieldValue('CRM_Event_BAO_Participant', $participantID, 'status_id', 'id');
$participantStatuses = CRM_Event_PseudoConstant::participantStatus();
if ($values[$participantID]['is_test']) { if ($values[$participantID]['is_test']) {
$values[$participantID]['status'] .= ' (test) '; $values[$participantID]['status'] .= ' (test) ';
} }
...@@ -197,6 +202,7 @@ class CRM_Event_Form_ParticipantView extends CRM_Core_Form { ...@@ -197,6 +202,7 @@ class CRM_Event_Form_ParticipantView extends CRM_Core_Form {
* @access public * @access public
*/ */
public function buildQuickForm() { public function buildQuickForm() {
CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js');
$this->addButtons(array( $this->addButtons(array(
array( array(
'type' => 'cancel', 'type' => 'cancel',
......
...@@ -360,8 +360,18 @@ class CRM_Event_Selector_Search extends CRM_Core_Selector_Base implements CRM_Co ...@@ -360,8 +360,18 @@ class CRM_Event_Selector_Search extends CRM_Core_Selector_Base implements CRM_Co
} }
$row['checkbox'] = CRM_Core_Form::CB_PREFIX . $result->participant_id; $row['checkbox'] = CRM_Core_Form::CB_PREFIX . $result->participant_id;
$links = self::links($this->_key, $this->_context, $this->_compContext);
if ($statusTypes[$row['participant_status_id']] == 'Partially paid') {
$links[CRM_Core_Action::ADD] = array(
'name' => ts('Record Payment'),
'url' => 'civicrm/payment/add',
'qs' => 'reset=1&id=%%id%%&cid=%%cid%%&action=add&component=event',
'title' => ts('Record Payment'),
);
}
$row['action'] = CRM_Core_Action::formLink(self::links($this->_key, $this->_context, $this->_compContext), $row['action'] = CRM_Core_Action::formLink($links,
$mask, $mask,
array( array(
'id' => $result->participant_id, 'id' => $result->participant_id,
......
...@@ -330,4 +330,10 @@ ...@@ -330,4 +330,10 @@
<is_public>true</is_public> <is_public>true</is_public>
<is_ssl>false</is_ssl> <is_ssl>false</is_ssl>
</item> </item>
<item>
<path>civicrm/event/participant/feeselection</path>
<title>Change Registration Selections</title>
<page_callback>CRM_Event_Form_ParticipantFeeSelection</page_callback>
<access_arguments>access CiviEvent</access_arguments>
</item>
</menu> </menu>
...@@ -85,6 +85,9 @@ class CRM_Financial_BAO_FinancialItem extends CRM_Financial_DAO_FinancialItem { ...@@ -85,6 +85,9 @@ class CRM_Financial_BAO_FinancialItem extends CRM_Financial_DAO_FinancialItem {
elseif ($contribution->contribution_status_id == array_search('Pending', $contributionStatuses)) { elseif ($contribution->contribution_status_id == array_search('Pending', $contributionStatuses)) {
$itemStatus = array_search('Unpaid', $financialItemStatus); $itemStatus = array_search('Unpaid', $financialItemStatus);
} }
elseif ($contribution->contribution_status_id == array_search('Partially paid', $contributionStatuses)) {
$itemStatus = array_search('Partially paid', $financialItemStatus);
}
$params = array( $params = array(
'transaction_date' => CRM_Utils_Date::isoToMysql($contribution->receive_date), 'transaction_date' => CRM_Utils_Date::isoToMysql($contribution->receive_date),
'contact_id' => $contribution->contact_id, 'contact_id' => $contribution->contact_id,
......
...@@ -92,6 +92,16 @@ class CRM_Price_BAO_LineItem extends CRM_Price_DAO_LineItem { ...@@ -92,6 +92,16 @@ class CRM_Price_BAO_LineItem extends CRM_Price_DAO_LineItem {
return NULL; return NULL;
} }
static function getLineTotal($entityId, $entityTable) {
$sqlLineItemTotal = "SELECT SUM(li.line_total)
FROM civicrm_line_item li
INNER JOIN civicrm_participant_payment pp ON ( li.entity_id = pp.participant_id
AND li.entity_table = '{$entityTable}'
AND li.entity_id = {$entityId})";
$lineItemTotal = CRM_Core_DAO::singleValueQuery($sqlLineItemTotal);
return $lineItemTotal;
}
/** /**
* Given a participant id/contribution id, * Given a participant id/contribution id,
* return contribution/fee line items * return contribution/fee line items
......
...@@ -131,9 +131,9 @@ SELECT @uf_group_id_honoree_individual := max(id) from civicrm_uf_group where na ...@@ -131,9 +131,9 @@ SELECT @uf_group_id_honoree_individual := max(id) from civicrm_uf_group where na
INSERT INTO `civicrm_uf_field` INSERT INTO `civicrm_uf_field`
(`uf_group_id`, `field_name`, `is_required`, `is_reserved`, `weight`, `visibility`, `in_selector`, `is_searchable`, {localize field='label'}`label`{/localize}, field_type) (`uf_group_id`, `field_name`, `is_required`, `is_reserved`, `weight`, `visibility`, `in_selector`, `is_searchable`, {localize field='label'}`label`{/localize}, field_type)
VALUES VALUES
(@uf_group_id_honoree_individual, 'honor_prefix_id', 0, 1, 1, 'User and User Admin Only', 0, 1, '{ts escape="sql"}Individual Prefix{/ts}', 'Individual'), (@uf_group_id_honoree_individual, 'prefix_id', 0, 1, 1, 'User and User Admin Only', 0, 1, '{ts escape="sql"}Individual Prefix{/ts}', 'Individual'),
(@uf_group_id_honoree_individual, 'honor_first_name', 0, 1, 2, 'User and User Admin Only', 0, 1, '{ts escape="sql"}First Name{/ts}', 'Individual'), (@uf_group_id_honoree_individual, 'first_name', 0, 1, 2, 'User and User Admin Only', 0, 1, '{ts escape="sql"}First Name{/ts}', 'Individual'),
(@uf_group_id_honoree_individual, 'honor_last_name', 0, 1, 3, 'User and User Admin Only', 0, 1, '{ts escape="sql"}Last Name{/ts}', 'Individual'); (@uf_group_id_honoree_individual, 'last_name', 0, 1, 3, 'User and User Admin Only', 0, 1, '{ts escape="sql"}Last Name{/ts}', 'Individual');
ALTER TABLE `civicrm_uf_join` ALTER TABLE `civicrm_uf_join`
ADD COLUMN `module_data` varchar(255) COMMENT 'Json serialized array of data used by the ufjoin.module'; ADD COLUMN `module_data` varchar(255) COMMENT 'Json serialized array of data used by the ufjoin.module';
...@@ -153,3 +153,36 @@ ALTER TABLE civicrm_contribution DROP honor_type_id; ...@@ -153,3 +153,36 @@ ALTER TABLE civicrm_contribution DROP honor_type_id;
ALTER TABLE civicrm_pledge DROP honor_contact_id; ALTER TABLE civicrm_pledge DROP honor_contact_id;
ALTER TABLE civicrm_pledge DROP honor_type_id; ALTER TABLE civicrm_pledge DROP honor_type_id;
-- CRM-13964 and CRM-13965
SELECT @option_group_id_cs := max(id) from civicrm_option_group where name = 'contribution_status';
SELECT @option_val_id_cs_wt := MAX(weight) FROM civicrm_option_value WHERE option_group_id = @option_group_id_cs;
SELECT @option_val_id_cs_val := MAX(value) FROM civicrm_option_value WHERE option_group_id = @option_group_id_cs;
INSERT INTO
`civicrm_option_value` (`option_group_id`, {localize field='label'}label{/localize}, `value`, `name`, `grouping`, `filter`, `is_default`, `weight`, `is_optgroup`, `is_reserved`, `is_active`, `component_id`, `visibility_id`)
VALUES
(@option_group_id_cs, {localize}'{ts escape="sql"}Partially paid{/ts}'{/localize}, @option_val_id_cs_val+1, 'Partially paid', NULL, 0, NULL, @option_val_id_cs_wt+1, 0, 1, 1, NULL, NULL),
(@option_group_id_cs, {localize}'{ts escape="sql"}Pending refund{/ts}'{/localize}, @option_val_id_cs_val+2, 'Pending refund', NULL, 0, NULL, @option_val_id_cs_wt+2, 0, 1, 1, NULL, NULL);
-- participant status adding
SELECT @participant_status_wt := max(id) from civicrm_participant_status_type;
INSERT INTO civicrm_participant_status_type (name, {localize field='label'}label{/localize}, class, is_reserved, is_active, is_counted, weight, visibility_id)
VALUES
('Partially paid', {localize}'{ts escape="sql"}Partially paid{/ts}'{/localize}, 'Positive', 1, 1, 1, @participant_status_wt+1, 2),
('Pending refund', {localize}'{ts escape="sql"}Pending refund{/ts}'{/localize}, 'Positive', 1, 1, 1, @participant_status_wt+2, 2);
-- new activity types required for partial payments
SELECT @option_group_id_act := max(id) from civicrm_option_group where name = 'activity_type';
SELECT @option_group_id_act_wt := MAX(weight) FROM civicrm_option_value WHERE option_group_id = @option_group_id_act;
SELECT @option_group_id_act_val := MAX(value) FROM civicrm_option_value WHERE option_group_id = @option_group_id_act;
SELECT @contributeCompId := max(id) FROM civicrm_component where name = 'CiviContribute';
INSERT INTO
`civicrm_option_value` (`option_group_id`, {localize field='label'}`label`{/localize}, `value`, `name`, `grouping`, `filter`, `is_default`, `weight`, {localize field='description'}`description`{/localize}, `is_optgroup`, `is_reserved`, `is_active`, `component_id`, `visibility_id`)
VALUES
(@option_group_id_act, {localize}'{ts escape="sql"}Payment{/ts}'{/localize}, @option_group_id_act_val+1, 'Payment', NULL, 1, NULL, @option_group_id_act_wt+1, {localize}'{ts escape="sql"}Additional payment recorded for event or membership fee.{/ts}'{/localize}, 0, 1, 1, @contributeCompId, NULL),
(@option_group_id_act, {localize}'{ts escape="sql"}Refund{/ts}'{/localize}, @option_group_id_act_val+2, 'Refund', NULL, 1, NULL, @option_group_id_act_wt+2, {localize}'{ts escape="sql"}Refund recorded for event or membership fee.{/ts}'{/localize}, 0, 1, 1, @contributeCompId, NULL),
(@option_group_id_act, {localize}'{ts escape="sql"}Change Registration{/ts}'{/localize}, @option_group_id_act_val+3, 'Change Registration', NULL, 1, NULL, @option_group_id_act_wt+3, {localize}'{ts escape="sql"}Changes to an existing event registration.{/ts}'{/localize}, 0, 1, 1, @eventCompId, NULL);
Source diff could not be displayed: it is too large. Options to address this: view the blob.
{*
+--------------------------------------------------------------------+
| CiviCRM version 4.4 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2013 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
| under the terms of the GNU Affero General Public License |
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
| |
| CiviCRM is distributed in the hope that it will be useful, but |
| WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| See the GNU Affero General Public License for more details. |
| |
| You should have received a copy of the GNU Affero General Public |
| License and the CiviCRM Licensing Exception along |
| with this program; if not, contact CiviCRM LLC |
| at info[AT]civicrm[DOT]org. If you have questions about the |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*}
{htxt id="id-trans_id"}
{ts}Unique payment ID for this transaction. The Payment Processor's transaction ID will be automatically stored here on online contributions.{/ts} {ts}For offline contributions you can record a bank transfer ID or other identifier if applicable.{/ts}
{/htxt}
{htxt id="payment_instrument_id"}
<p>
{ts}Choose the method by which this transaction was paid.{/ts}
</p><p>
{ts}Note: if the correct payment instrument is not listed here (e.g. for in-kind donations) ask your administrator to add a new option to this list.{/ts}
</p>
{/htxt}
{*
+--------------------------------------------------------------------+
| CiviCRM version 4.4 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2013 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
| under the terms of the GNU Affero General Public License |
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
| |
| CiviCRM is distributed in the hope that it will be useful, but |
| WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| See the GNU Affero General Public License for more details. |
| |
| You should have received a copy of the GNU Affero General Public |
| License and the CiviCRM Licensing Exception along |
| with this program; if not, contact CiviCRM LLC |
| at info[AT]civicrm[DOT]org. If you have questions about the |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*}
{if $formType}
{include file="CRM/Contribute/Form/AdditionalInfo/$formType.tpl"}
{else}
<h3>{if $component eq 'event'}{if $contributionMode}{ts}Credit Card Event Payment{/ts}{else}{ts}New Event Payement{/ts}{/if}{/if}</h3>
<div class="crm-block crm-form-block crm-payment-form-block">
{if $contributionMode == 'test'}
{assign var=contribMode value="TEST"}
{elseif $contributionMode == 'live'}
{assign var=contribMode value="LIVE"}
{/if}
{if !$email}
<div class="messages status no-popup">
<div class="icon inform-icon"></div>&nbsp;{ts}You will not be able to send an automatic email receipt for this payment because there is no email address recorded for this contact. If you want a receipt to be sent when this payment is recorded, click Cancel and then click Edit from the Summary tab to add an email address before recording the payment.{/ts}
</div>
{/if}
<div class="crm-submit-buttons">
{include file="CRM/common/formButtons.tpl"}
{if $newCredit AND $contributionMode EQ null}
{if $contactId}
{capture assign=ccModeLink}{crmURL p='civicrm/payment/add' q="reset=1&action=add&cid=`$contactId`&id=`$id`&component=`$component`&mode=live"}{/capture}
{/if}
<span class="action-link crm-link-credit-card-mode">&nbsp;<a href="{$ccModeLink}">&raquo; {ts}submit credit card payment{/ts}</a>
{/if}
</div>
<table class="form-layout-compressed">
<tr>
<td class="font-size12pt label"><strong>{ts}Participant{/ts}</strong></td><td class="font-size12pt"><strong>{$displayName}</strong></td>
</tr>
{if $contributionMode}
<tr class="crm-payment-form-block-payment_processor_id"><td class="label nowrap">{$form.payment_processor_id.label}<span class="marker"> * </span></td><td>{$form.payment_processor_id.html}</td></tr>
{/if}
<tr>
<td class='label'>{ts}Event{/ts}</td><td>{$eventName}</td>
</tr>
<tr class="crm-payment-form-block-contribution_type_id crm-payment-form-block-financial_type_id">
<td class="label">{$form.financial_type_id.label}</td><td{$valueStyle}>{$form.financial_type_id.html}&nbsp;
</td>
</tr>
<tr class="crm-payment-form-block-total_amount">
<td class="label">{$form.total_amount.label}</td>
<td>
<span id='totalAmount'>{$form.currency.html|crmAddClass:eight}&nbsp;{$form.total_amount.html|crmAddClass:eight}</span> {$paymentAmt}
</td>
</tr>
</table>
<div class="crm-accordion-wrapper crm-accordion_title-accordion crm-accordion-processed" id="paymentDetails_Information">
<div class="crm-accordion-header">
{ts}Payment Details{/ts}
</div>
<div class="crm-accordion-body">
<table class="form-layout-compressed" >
<tr class="crm-payment-form-block-trxn_date">
<td class="label">{$form.trxn_date.label}</td>
<td {$valueStyle}>{include file="CRM/common/jcalendar.tpl" elementName=trxn_date}<br />
<span class="description">{ts}The date this payment was received.{/ts}</span>
</td>
</tr>
<tr class="crm-payment-form-block-payment_instrument_id">
<td class="label">{$form.payment_instrument_id.label}</td>
<td {$valueStyle}>{$form.payment_instrument_id.html} {help id="payment_instrument_id"}</td>
</td>
</tr>
{if $showCheckNumber || !$isOnline}
<tr id="checkNumber" class="crm-payment-form-block-check_number">
<td class="label">{$form.check_number.label}</td>
<td>{$form.check_number.html|crmReplace:class:six}</td>
</tr>
{/if}
<tr class="crm-payment-form-block-trxn_id">
<td class="label">{$form.trxn_id.label}</td>
<td {$valueStyle}>{$form.trxn_id.html|crmReplace:class:twelve} {help id="id-trans_id"}</td>
</tr>
{if $email and $outBound_option != 2}
<tr class="crm-payment-form-block-is_email_receipt">
<td class="label">
{$form.is_email_receipt.label}</td><td>{$form.is_email_receipt.html}&nbsp;
<span class="description">{ts 1=$email}Automatically email a receipt for this payment to %1?{/ts}</span>
</td>
</tr>
{elseif $context eq 'standalone' and $outBound_option != 2 }
<tr id="email-receipt" style="display:none;" class="crm-payment-form-block-is_email_receipt">
<td class="label">{$form.is_email_receipt.label}</td>
<td>{$form.is_email_receipt.html} <span class="description">{ts}Automatically email a receipt for this payment to {/ts}<span id="email-address"></span>?</span>
</td>
</tr>
{/if}
<tr id="fromEmail" class="crm-payment-form-block-receipt_date" style="display:none;">
<td class="label">{$form.from_email_address.label}</td>
<td>{$form.from_email_address.html}</td>
</tr>
<tr class="crm-payment-form-block-fee_amount"><td class="label">{$form.fee_amount.label}</td><td{$valueStyle}>{$form.fee_amount.html|crmMoney:$currency:'XXX':'YYY'}<br />
<span class="description">{ts}Processing fee for this transaction (if applicable).{/ts}</span></td></tr>
<tr class="crm-payment-form-block-net_amount"><td class="label">{$form.net_amount.label}</td><td{$valueStyle}>{$form.net_amount.html|crmMoney:$currency:'':1}<br />
<span class="description">{ts}Net value of the payment (Total Amount minus Fee).{/ts}</span></td></tr>
</table>
</div>
</div>
<div class="accordion ui-accordion ui-widget ui-helper-reset">
{* Additional Detail / Honoree Information / Premium Information *}
{foreach from=$allPanes key=paneName item=paneValue}
<div class="crm-accordion-wrapper crm-ajax-accordion crm-{$paneValue.id}-accordion {if $paneValue.open neq 'true'}collapsed{/if}">
<div class="crm-accordion-header" id="{$paneValue.id}">
{$paneName}
</div><!-- /.crm-accordion-header -->
<div class="crm-accordion-body">
<div class="{$paneValue.id}"></div>
</div><!-- /.crm-accordion-body -->
</div><!-- /.crm-accordion-wrapper -->
{/foreach}
</div>
{literal}
<script type="text/javascript">
var url = "{/literal}{$dataUrl}{literal}";
cj( function( ) {
showHideByValue( 'is_email_receipt', '', 'fromEmail', 'table-row', 'radio', false );
});
{/literal}
</script>
<br />
<div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div>
</div>
{literal}
<script type="text/javascript">
function verify( ) {
if (cj('#is_email_receipt').attr( 'checked' )) {
var ok = confirm( '{/literal}{ts escape='js'}Click OK to save this payment record AND send a receipt to the contributor now{/ts}{literal}.' );
if (!ok) {
return false;
}
}
}
</script>
{/literal}
{literal}
<script type="text/javascript">
cj( function( ) {
checkEmailDependancies( );
cj('#is_email_receipt').click( function( ) {
checkEmailDependancies( );
});
});
function checkEmailDependancies( ) {
if (cj('#is_email_receipt').attr( 'checked' )) {
cj('#fromEmail').show( );
cj('#receiptDate').hide( );
}
else {
cj('#fromEmail').hide( );
cj('#receiptDate').show( );
}
}
// bind first click of accordion header to load crm-accordion-body with snippet
// everything else taken care of by cj().crm-accordions()
cj(function() {
cj('#adjust-option-type').hide();
cj('.crm-ajax-accordion .crm-accordion-header').one('click', function() {
loadPanes(cj(this).attr('id'));
});
cj('.crm-ajax-accordion:not(.collapsed) .crm-accordion-header').each(function(index) {
loadPanes(cj(this).attr('id'));
});
});
// load panes function call for snippet based on id of crm-accordion-header
function loadPanes( id ) {
var url = "{/literal}{crmURL p='civicrm/payment/add' q='snippet=4&formType=' h=0}{literal}" + id;
{/literal}
{if $contributionMode}
url = url + "&mode={$contributionMode}";
{/if}
{if $qfKey}
url = url + "&qfKey={$qfKey}";
{/if}
{literal}
if (! cj('div.'+id).html()) {
var loading = '<img src="{/literal}{$config->resourceBase}i/loading.gif{literal}" alt="{/literal}{ts escape='js'}loading{/ts}{literal}" />&nbsp;{/literal}{ts escape='js'}Loading{/ts}{literal}...';
cj('div.'+id).html(loading);
cj.ajax({
url : url,
success: function(data) { cj('div.'+id).html(data); }
});
}
}
cj('#fee_amount').change( function() {
var totalAmount = cj('#total_amount').val();
var feeAmount = cj('#fee_amount').val();
var netAmount = totalAmount.replace(/,/g, '') - feeAmount.replace(/,/g, '');
if (!cj('#net_amount').val()) {
cj('#net_amount').val(netAmount);
}
});
</script>
{/literal}
{if !$contributionMode}
{include file="CRM/common/showHideByFieldValue.tpl"
trigger_field_id ="payment_instrument_id"
trigger_value = '4'
target_element_id ="checkNumber"
target_element_type ="table-row"
field_type ="select"
invert = 0
}
{/if}
{* include jscript to warn if unsaved form field changes *}
{include file="CRM/common/formNavigate.tpl"}
{/if}
{literal}
<script type="text/javascript">
cj(function() {
cj().crmAccordions();
});
</script>
{/literal}
{*
+--------------------------------------------------------------------+
| CiviCRM version 4.4 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2013 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
| under the terms of the GNU Affero General Public License |
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
| |
| CiviCRM is distributed in the hope that it will be useful, but |
| WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| See the GNU Affero General Public License for more details. |
| |
| You should have received a copy of the GNU Affero General Public |
| License and the CiviCRM Licensing Exception along |
| with this program; if not, contact CiviCRM LLC |
| at info[AT]civicrm[DOT]org. If you have questions about the |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*}
{if $show eq 'event-payment'}
{literal}
<script type='text/javascript'>
cj(function($){
var dataUrl = {/literal}'{crmURL p="civicrm/payment/view" h=0 q="action=browse&id=$participantId&cid=`$contactId`&component=event&context=payment_info&snippet=4"}'{literal};
cj.ajax({
url: dataUrl,
async: false,
success: function(html) {
cj("#payment-info").html(html);
}
});
cj('.total_amount-section').remove();
});
</script>
{/literal}
{/if}
{if $context eq 'payment_info'}
<table id='info'>
<tr class="columnheader">
{if $component eq "event"}
<th>{ts}Total Fee(s){/ts}</th>
{/if}
<th class="right">{ts}Total Paid{/ts}</th>
<th class="right">{ts}Balance{/ts}</th>
</tr>
<tr>
<td>{$paymentInfo.total|crmMoney}</td>
<td class='right'>
{if $paymentInfo.paid > 0}
<a class='action-item' href='{crmURL p="civicrm/payment/view" q="action=browse&cid=`$cid`&id=`$paymentInfo.id`&component=`$paymentInfo.component`&context=transaction"}'>{$paymentInfo.paid|crmMoney}<br/>>> view payments</a>
{/if}
</td>
<td class='right'>{$paymentInfo.balance|crmMoney}</td>
</tr>
</table>
{if $paymentInfo.balance > 0}
<a class="button" href='{crmURL p="civicrm/payment/add" q="reset=1&component=`$component`&id=`$id`&cid=`$cid`"}' title="{ts}Record Payment{/ts}"><span><div class="icon add-icon"></div> {ts}Record Payment{/ts}</span></a>
{/if}
{elseif $context eq 'transaction'}
{if !empty($rows)}
<table id='info'>
<tr class="columnheader">
<th>{ts}Amount{/ts}</th>
<th>{ts}Type{/ts}</th>
<th>{ts}Paid By{/ts}</th>
<th>{ts}Received{/ts}</th>
<th>{ts}Transaction ID{/ts}</th>
<th>{ts}Status{/ts}</th>
</tr>
{foreach from=$rows item=row}
<tr>
<td>{$row.total_amount|crmMoney}</td>
<td>{$row.financial_type}</td>
<td>{$row.payment_instrument}</td>
<td>{$row.receive_date|crmDate}</td>
<td>{$row.trxn_id}</td>
<td>{$row.status}</td>
</tr>
{/foreach}
<table>
{else}
{if $component eq 'event'}
{assign var='entity' value='participant'}
{else}
{assign var='entity' value=$component}
{/if}
{ts 1=$entity}No additional payments found for this %1 record{/ts}
{/if}
{/if}
\ No newline at end of file
...@@ -35,9 +35,15 @@ ...@@ -35,9 +35,15 @@
{if $action eq 2 and $hasPayment} {* Updating *} {if $action eq 2 and $hasPayment} {* Updating *}
{if $lineItem} {if $lineItem}
<tr class="crm-event-eventfees-form-block-line_items"> <tr class="crm-event-eventfees-form-block-line_items">
<td class="label">{ts}Event Fees{/ts}</td> <td class="label">{ts}Selections{/ts}</td>
<td>{include file="CRM/Price/Page/LineItem.tpl" context="Event"}</td> <td>{include file="CRM/Price/Page/LineItem.tpl" context="Event"}</td>
</tr> </tr>
<tr>
<td></td>
<td>
<a class="button" href='{crmURL p="civicrm/event/participant/feeselection" q="reset=1&id=`$participantId`&cid=`$contactId`&action=update"}' title="{ts}Change Selections{/ts}"><span><div class="icon edit-icon"></div> {ts}Change Selections{/ts}</span></a>
</td>
</tr>
{else} {else}
<tr class="crm-event-eventfees-form-block-event_level"> <tr class="crm-event-eventfees-form-block-event_level">
<td class="label">{ts}Event Level{/ts}</td> <td class="label">{ts}Event Level{/ts}</td>
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
+--------------------------------------------------------------------+ +--------------------------------------------------------------------+
*} *}
{* This template is used for adding/editing/deleting offline Event Registrations *} {* This template is used for adding/editing/deleting offline Event Registrations *}
{if $showFeeBlock } {if $showFeeBlock}
{if $priceSet} {if $priceSet}
<div id='validate_pricefield' class='messages crm-error hiddenElement'></div> <div id='validate_pricefield' class='messages crm-error hiddenElement'></div>
{literal} {literal}
...@@ -127,12 +127,49 @@ ...@@ -127,12 +127,49 @@
} }
} }
} }
// change the status to default 'partially paid' for partial payments
var feeAmount;
var userModifiedAmount;
var partiallyPaidStatusId = {/literal}{$partiallyPaidStatusId}{literal};
cj('#total_amount')
.focus(
function() {
feeAmount = cj(this).val();
feeAmount = parseInt(feeAmount);
}
)
.change(
function() {
userModifiedAmount = cj(this).val();
userModifiedAmount = parseInt(userModifiedAmount);
if (userModifiedAmount < feeAmount) {
cj('#status_id').val(partiallyPaidStatusId);
}
}
);
cj('#Participant').submit(
function(e) {
var userSubmittedStatus = cj('#status_id').val();
var statusLabel = cj('#status_id option:selected').text();
if (userModifiedAmount < feeAmount && userSubmittedStatus != partiallyPaidStatusId) {
var result = confirm('Payment amount is less than the amount owed. Expected participant status is \'Partially paid\'. Are you sure you want to set the participant status to ' + statusLabel + '? Click OK to continue, Cancel to change your entries.');
if (result == false) {
e.preventDefault();
}
}
}
);
</script> </script>
{/literal} {/literal}
{/if} {/if}
{if $participantId}
{include file="CRM/Contribute/Page/PaymentInfo.tpl" show='event-payment'}
{/if}
{include file="CRM/Event/Form/EventFees.tpl"} {include file="CRM/Event/Form/EventFees.tpl"}
{elseif $cdType}
{elseif $cdType }
{include file="CRM/Custom/Form/CustomData.tpl"} {include file="CRM/Custom/Form/CustomData.tpl"}
{else} {else}
{if $participantMode == 'test' } {if $participantMode == 'test' }
...@@ -254,7 +291,15 @@ ...@@ -254,7 +291,15 @@
<span class="description">{ts}Source for this registration (if applicable).{/ts}</span></td> <span class="description">{ts}Source for this registration (if applicable).{/ts}</span></td>
</tr> </tr>
</table> </table>
{if $participantId}
<table class='form-layout'>
<tr>
<td class='label'>{ts}Fees{/ts}</td>
{* this is where the payment info is shown using CRM/Contribute/Page/PaymentInfo.tpl tpl*}
<td id='payment-info'></td>
</tr>
</table>
{/if}
{* Fee block (EventFees.tpl) is injected here when an event is selected. *} {* Fee block (EventFees.tpl) is injected here when an event is selected. *}
<div id="feeBlock"></div> <div id="feeBlock"></div>
<fieldset> <fieldset>
......
{*
+--------------------------------------------------------------------+
| CiviCRM version 4.4 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2013 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
| under the terms of the GNU Affero General Public License |
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
| |
| CiviCRM is distributed in the hope that it will be useful, but |
| WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| See the GNU Affero General Public License for more details. |
| |
| You should have received a copy of the GNU Affero General Public |
| License and the CiviCRM Licensing Exception along |
| with this program; if not, contact CiviCRM LLC |
| at info[AT]civicrm[DOT]org. If you have questions about the |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*}
{* This template is used to change selections of fees for a participant *}
{literal}
<script type='text/javascript'>
function display(totalfee) {
// totalfee is monetary, round it to 2 decimal points so it can
// go as a float - CRM-13491
totalfee = Math.round(totalfee*100)/100;
// note : some variables used used here are global variables defined inside Calculate.tpl
var totalEventFee = formatMoney( totalfee, 2, seperator, thousandMarker);
cj('#pricevalue').html("<b>"+symbol+"</b> "+totalEventFee);
scriptfee = totalfee;
scriptarray = price;
cj('#total_amount').val(totalfee);
( totalfee < 0 ) ? cj('table#pricelabel').addClass('disabled') : cj('table#pricelabel').removeClass('disabled');
// populate the balance amount div
// change the status selections according to updated selections
populatebalanceFee(totalEventFee);
}
function populatebalanceFee(updatedAmt) {
// calculate the balance amount using total paid and updated amount
var balanceAmt = updatedAmt - CRM.feePaid;
// change the status selections according to updated selections
if (balanceAmt > 0) {
cj('#status_id').val(CRM.partiallyPaid);
}
else if(balanceAmt < 0) {
cj('#status_id').val(CRM.pendingRefund);
}
else if(balanceAmt == 0) {
cj('#status_id').val(CRM.participantStatus);
}
balanceAmt = formatMoney(balanceAmt, 2, seperator, thousandMarker);
cj('#balance-fee').text(symbol+" "+balanceAmt);
}
cj(function(){
var updatedFeeUnFormatted = cj('#pricevalue').text();
var updatedAmt = parseFloat(updatedFeeUnFormatted.replace(/[^0-9-.]/g, ''));
var balanceAmt = updatedAmt - CRM.feePaid;
// change the status selections according to updated selections
if (balanceAmt > 0) {
cj('#status_id').val(CRM.partiallyPaid);
}
else if(balanceAmt < 0) {
cj('#status_id').val(CRM.pendingRefund);
}
});
{/literal}
</script>
<h3>Change Registration Selections</h3>
<div class="crm-block crm-form-block crm-payment-form-block">
<div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div>
{if !$email}
<div class="messages status no-popup">
<div class="icon inform-icon"></div>&nbsp;{ts}You will not be able to send an automatic email receipt for this payment because there is no email address recorded for this contact. If you want a receipt to be sent when this payment is recorded, click Cancel and then click Edit from the Summary tab to add an email address before recording the payment.{/ts}
</div>
{/if}
<table class="form-layout">
<tr>
<td class="font-size12pt label"><strong>{ts}Participant{/ts}</strong></td><td class="font-size12pt"><strong>{$displayName}</strong></td>
</tr>
<tr>
<td class='label'>{ts}Event{/ts}</td><td>{$eventName}</td>
</tr>
<tr class="crm-participant-form-block-status_id">
<td class="label">{$form.status_id.label}</td>
<td>{$form.status_id.html}</td>
</tr>
{if $lineItem}
<tr class="crm-event-eventfees-form-block-line_items">
<td class="label">{ts}Current Selections{/ts}</td>
<td>{include file="CRM/Price/Page/LineItem.tpl" context="Event"}</td>
</tr>
{/if}
</table>
{if $priceSet.fields}
<fieldset id="priceset" class="crm-group priceset-group">
<table class='form-layout'>
<tr class="crm-event-eventfees-form-block-price_set_amount">
<td class="label" style="padding-top: 10px;">{$form.amount.label}</td>
<td class="view-value"><table class="form-layout">{include file="CRM/Price/Form/PriceSet.tpl" extends="Event" dontInclCal="true"}</table></td>
</tr>
{if $paymentInfo}
<tr><td></td><td>
<div class='crm-section'>
<div class='label'>{ts}Updated Fee(s){/ts}</div><div id="pricevalue" class='content updated-fee'></div>
<div class='label'>{ts}Total Paid{/ts}</div>
<div class='content'><a class='action-item' href='{crmURL p="civicrm/payment/view" q="action=browse&cid=`$contactId`&id=`$paymentInfo.id`&component=`$paymentInfo.component`&context=transaction"}'>{$paymentInfo.paid|crmMoney}<br/>>> view payments</a>
</div>
<div class='label'><strong>{ts}Balance Owed{/ts}</strong></div><div class='content'><strong id='balance-fee'></strong></div>
</div>
{include file='CRM/Price/Form/Calculate.tpl' currencySymbol=$currencySymbol noCalcValueDisplay='false' displayOveride='true'}
{/if}
</table>
</fieldset>
{/if}
{if $email}
<fieldset id="email-receipt"><legend>{ts}Participant Confirmation{/ts}</legend>
<table class="form-layout" style="width:auto;">
<tr class="crm-event-eventfees-form-block-send_receipt">
<td class="label">{ts}Send Confirmation{/ts}</td>
<td>{$form.send_receipt.html}<br>
<span class="description">{ts 1=$email'}Automatically email a confirmation to %1?{/ts}</span>
</td>
</tr>
<tr id="from-email" class="crm-event-eventfees-form-block-from_email_address">
<td class="label">{$form.from_email_address.label}</td>
<td>{$form.from_email_address.html} {help id ="id-from_email" file="CRM/Contact/Form/Task/Email.hlp"}</td>
</tr>
<tr id='notice' class="crm-event-eventfees-form-block-receipt_text">
<td class="label">{$form.receipt_text.label}</td>
<td><span class="description">
{ts}Enter a message you want included at the beginning of the confirmation email. EXAMPLE: 'We have made the changes you requested to your registration.'{/ts}
</span><br />
{$form.receipt_text.html|crmAddClass:huge}
</td>
</tr>
</table>
</fieldset>
{/if}
<fieldset>
<table class="form-layout">
<tr class="crm-participant-form-block-note">
<td class="label">{$form.note.label}</td><td>{$form.note.html}</td>
</tr>
</table>
</fieldset>
<div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div>
</div>
{if $email}
{include file="CRM/common/showHideByFieldValue.tpl"
trigger_field_id ="send_receipt"
trigger_value =""
target_element_id ="notice"
target_element_type ="table-row"
field_type ="radio"
invert = 0
}
{include file="CRM/common/showHideByFieldValue.tpl"
trigger_field_id ="send_receipt"
trigger_value =""
target_element_id ="from-email"
target_element_type ="table-row"
field_type ="radio"
invert = 0
}
{/if}
{literal}
<script type='text/javascript'>
cj(function($){
cj('.total_amount-section').remove();
cj('#ParticipantFeeSelection').submit(function(e) {
var statusId = cj('#status_id').val();
var statusLabel = cj('#status_id option:selected').text();
var balanceFee = cj('#balance-fee').text();
balanceFee = parseFloat(balanceFee.replace(/[^0-9-.]/g, ''));
if (balanceFee > 0 && statusId != CRM.partiallyPaid) {
var result = confirm('Balance is owing for the updated selections. Expected participant status is \'Partially paid\'. Are you sure you want to set the participant status to ' + statusLabel + ' ? Click OK to continue, Cancel to change your entries.');
if (result == false) {
e.preventDefault();
}
}
else if (balanceFee < 0 && statusId != CRM.pendingRefund) {
var result = confirm('Balance is overpaid for the updated selections. Expected participant status is \'Pending refund\'. Are you sure you want to set the participant status to ' + statusLabel + ' ? Click OK to continue, Cancel to change your entries');
if (result == false) {
e.preventDefault();
}
}
});
});
</script>
{/literal}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment