diff --git a/CRM/Event/Form/Participant.php b/CRM/Event/Form/Participant.php index f79e29d43f7a1f57cfac84888cfe27f8f7a1d8da..ba3d0875eef1628c226be4155de4e924fbe67b99 100644 --- a/CRM/Event/Form/Participant.php +++ b/CRM/Event/Form/Participant.php @@ -887,6 +887,20 @@ loadCampaign( {$this->_eID}, {$eventCampaigns} ); $confirmJS = array('onclick' => "return confirmStatus( {$participantStatusId}, {$contributionStatusId} );"); } + // get the participant status names to build special status array which is used to show notification + // checkbox below participant status select + $participantStatusName = CRM_Event_PseudoConstant::participantStatus(); + $notificationStatuses = array( + 'Cancelled', + 'Pending from waitlist', + 'Pending from approval', + 'Expired', + ); + + // get the required status and then implode only ids + $notificationStatusIds = implode(',', array_keys(array_intersect($participantStatusName, $notificationStatuses))); + $this->assign('notificationStatusIds', $notificationStatusIds); + $this->_participantStatuses = CRM_Event_PseudoConstant::participantStatus(NULL, NULL, 'label'); $this->add('select', 'status_id', ts('Participant Status'), array( diff --git a/templates/CRM/Event/Form/Participant.tpl b/templates/CRM/Event/Form/Participant.tpl index 603b019f3b6edf7cc6a468a0596c0887b8afb495..1f77e35f77204a06778028cb523aee09aee5e452 100644 --- a/templates/CRM/Event/Form/Participant.tpl +++ b/templates/CRM/Event/Form/Participant.tpl @@ -571,27 +571,20 @@ {* include jscript to warn if unsaved form field changes *} {include file="CRM/common/formNavigate.tpl"} -{/if} {* end of eventshow condition*} - <script type="text/javascript"> {literal} -if(cj("#priceset").length == 0) { -cj('.initial-payment').hide(); -}else { -cj('.initial-payment').show(); -} + sendNotification(); - cj("#notify").hide(); - function sendNotification( ) { - var status = cj("select#status_id option:selected").text(); - cj("#notify").hide(); - - if ( status == 'Cancelled' || - status == 'Pending from waitlist' || - status == 'Pending from approval' || - status == 'Expired' ) { + function sendNotification() { + var notificationStatusIds = {/literal}"{$notificationStatusIds}"{literal}; + notificationStatusIds = notificationStatusIds.split(','); + if (cj.inArray(cj('select#status_id option:selected').val(), notificationStatusIds) > -1) { cj("#notify").show(); - cj("#is_notify").attr('checked',true); + cj("#is_notify").attr('checked', true); + } + else { + cj("#notify").hide(); + cj("#is_notify").removeAttr('checked'); } } @@ -623,3 +616,5 @@ cj('.initial-payment').show(); </script> {/literal} +{/if} {* end of main event block*} +