*/
/**
- * This form records additional payments needed when
+ * 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 {
- /**
- * related component whose financial payment is being processed
- *
- * @var string
- * @public
- */
- protected $_component = NULL;
protected $_contactId = NULL;
public $_values = NULL;
- public $_isPaidEvent = NULL;
-
public $_participantId = 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->_fromEmails = CRM_Core_BAO_Email::getFromEmail();
$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;
list($this->_contributorDisplayName, $this->_contributorEmail) = CRM_Contact_BAO_Contact_Location::getEmailDetails($this->_contactId);
$this->assign('displayName', $this->_contributorDisplayName);
+ $this->assign('email', $this->_contributorEmail);
+
//set the payment mode - _mode property is defined in parent class
$this->_mode = CRM_Utils_Request::retrieve('mode', 'String', $this);
}
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),
+ ));
+
$config = CRM_Core_Config::singleton();
$this->assign('currencySymbol', $config->defaultCurrencySymbol);
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'),
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
`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);
\ No newline at end of file
+ (@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);
\ No newline at end of file
<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> {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>
<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 id='balance-fee' class='content'></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('.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
(@option_group_id_act, '{ts escape="sql"}Payment{/ts}', 46, 'Payment', NULL, 1, NULL, 46, '{ts escape="sql"}Additional payment recorded for event or membership fee.{/ts}', 0, 1, 1, @contributeCompId, NULL),
(@option_group_id_act, '{ts escape="sql"}Refund{/ts}', 47, 'Refund', NULL, 1, NULL, 47, '{ts escape="sql"}Refund recorded for event or membership fee.{/ts}', 0, 1, 1, @contributeCompId, NULL),
+ -- for selection changes
+ (@option_group_id_act, '{ts escape="sql"}Change Registration{/ts}', 48, 'Change Registration', NULL, 1, NULL, 48, '{ts escape="sql"}Changes to an existing event registration.{/ts}', 0, 1, 1, @eventCompId, NULL),
+
(@option_group_id_gender, '{ts escape="sql"}Female{/ts}', 1, 'Female', NULL, 0, NULL, 1, NULL, 0, 0, 1, NULL, NULL),
(@option_group_id_gender, '{ts escape="sql"}Male{/ts}', 2, 'Male', NULL, 0, NULL, 2, NULL, 0, 0, 1, NULL, NULL),
(@option_group_id_gender, '{ts escape="sql"}Transgender{/ts}', 3, 'Transgender', NULL, 0, NULL, 3, NULL, 0, 0, 1, NULL, NULL),