From 59e44db1a8785975bd7f0b55faa28b805d6b8ed0 Mon Sep 17 00:00:00 2001 From: Pratik Joshi Date: Fri, 20 Dec 2013 18:00:36 +0530 Subject: [PATCH] CRM-13964 : JQUERY part and new status creation --- CRM/Event/Form/Participant.php | 4 +++ .../Incremental/sql/4.5.alpha1.mysql.tpl | 19 +++++++++- templates/CRM/Event/Form/Participant.tpl | 35 +++++++++++++++++++ xml/templates/civicrm_data.tpl | 5 ++- 4 files changed, 61 insertions(+), 2 deletions(-) diff --git a/CRM/Event/Form/Participant.php b/CRM/Event/Form/Participant.php index 51b2359f66..4b9eb2184f 100644 --- a/CRM/Event/Form/Participant.php +++ b/CRM/Event/Form/Participant.php @@ -255,6 +255,10 @@ class CRM_Event_Form_Participant extends CRM_Contact_Form_Task { $this->assign('eventNameCustomDataTypeID', $this->_eventNameCustomDataTypeID); $this->assign('eventTypeCustomDataTypeID', $this->_eventTypeCustomDataTypeID); + $partiallyPaidStatusId = CRM_Event_PseudoConstant::participantStatus(); + $partiallyPaidStatusId = array_search('Partially paid', $partiallyPaidStatusId); + $this->assign('partiallyPaidStatusId', $partiallyPaidStatusId); + if ($this->_mode) { $this->assign('participantMode', $this->_mode); diff --git a/CRM/Upgrade/Incremental/sql/4.5.alpha1.mysql.tpl b/CRM/Upgrade/Incremental/sql/4.5.alpha1.mysql.tpl index 1faa6c9955..db9fe0acfd 100644 --- a/CRM/Upgrade/Incremental/sql/4.5.alpha1.mysql.tpl +++ b/CRM/Upgrade/Incremental/sql/4.5.alpha1.mysql.tpl @@ -97,4 +97,21 @@ SELECT @caseCompId := id FROM `civicrm_component` where `name` like 'CiviCase'; UPDATE `civicrm_option_value` SET is_reserved = 1 -WHERE is_reserved = 0 AND option_group_id = @option_group_id_activity_type AND component_id = @caseCompId; \ No newline at end of file +WHERE is_reserved = 0 AND option_group_id = @option_group_id_activity_type AND component_id = @caseCompId; + +-- CRM-13964 +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, '{ts escape="sql"}Partially paid{/ts}', @option_val_id_cs_val+1, 'Partially paid', NULL, 0, NULL, @option_val_id_cs_wt+1, 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 (id, name, {localize field='label'}label{/localize}, class, is_reserved, is_active, is_counted, weight, visibility_id) +VALUES + (1, 'Partially paid', '{ts escape="sql"}Partially paid{/ts}', 'Positive', 1, 1, 1, @participant_status_wt+1, 2); \ No newline at end of file diff --git a/templates/CRM/Event/Form/Participant.tpl b/templates/CRM/Event/Form/Participant.tpl index 5a37446fda..2f5973dd64 100644 --- a/templates/CRM/Event/Form/Participant.tpl +++ b/templates/CRM/Event/Form/Participant.tpl @@ -127,6 +127,41 @@ } } } + + // 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(); + } + } + } + ); {/literal} {/if} diff --git a/xml/templates/civicrm_data.tpl b/xml/templates/civicrm_data.tpl index 560ac86814..80a775945d 100644 --- a/xml/templates/civicrm_data.tpl +++ b/xml/templates/civicrm_data.tpl @@ -413,6 +413,7 @@ VALUES (@option_group_id_cs, '{ts escape="sql"}In Progress{/ts}', 5, 'In Progress', NULL, 0, NULL, 5, NULL, 0, 1, 1, NULL, NULL), (@option_group_id_cs, '{ts escape="sql"}Overdue{/ts}' , 6, 'Overdue' , NULL, 0, NULL, 6, NULL, 0, 1, 1, NULL, NULL), (@option_group_id_cs, '{ts escape="sql"}Refunded{/ts}' , 7, 'Refunded' , NULL, 0, NULL, 7, NULL, 0, 1, 1, NULL, NULL), + (@option_group_id_cs, '{ts escape="sql"}Partially paid{/ts}', 8, 'Partially paid', NULL, 0, NULL, 8, NULL, 0, 1, 1, NULL, NULL), (@option_group_id_pcp, '{ts escape="sql"}Waiting Review{/ts}', 1, 'Waiting Review', NULL, 0, NULL, 1, NULL, 0, 1, 1, NULL, NULL), (@option_group_id_pcp, '{ts escape="sql"}Approved{/ts}' , 2, 'Approved' , NULL, 0, NULL, 2, NULL, 0, 1, 1, NULL, NULL), @@ -1446,7 +1447,9 @@ INSERT INTO civicrm_participant_status_type (10, 'Pending from approval', '{ts escape="sql"}Pending from approval{/ts}', 'Pending', 1, 0, 1, 10, 2 ), (11, 'Rejected', '{ts escape="sql"}Rejected{/ts}', 'Negative', 1, 0, 0, 11, 2 ), (12, 'Expired', '{ts escape="sql"}Expired{/ts}', 'Negative', 1, 1, 0, 12, 2 ), - (13, 'Pending in cart', '{ts escape="sql"}Pending in cart{/ts}', 'Pending', 1, 1, 0, 13, 2 ); + (13, 'Pending in cart', '{ts escape="sql"}Pending in cart{/ts}', 'Pending', 1, 1, 0, 13, 2 ), + (14, 'Partially paid', '{ts escape="sql"}Partially paid{/ts}', 'Positive', 1, 1, 1, 14, 2 ); + -- CRM-8150 -- 2.25.1