CRM-12752, check ids instead of label for showing notification checkbox, also code...
authorKurund Jalmi <kurund@civicrm.org>
Mon, 3 Jun 2013 13:05:19 +0000 (18:35 +0530)
committerKurund Jalmi <kurund@civicrm.org>
Mon, 3 Jun 2013 13:05:19 +0000 (18:35 +0530)
CRM/Event/Form/Participant.php
templates/CRM/Event/Form/Participant.tpl

index f79e29d43f7a1f57cfac84888cfe27f8f7a1d8da..ba3d0875eef1628c226be4155de4e924fbe67b99 100644 (file)
@@ -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(
index d9d6c3992c634c2e9c6527432be897c8b4eda210..1f77e35f77204a06778028cb523aee09aee5e452 100644 (file)
   {* 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}
+
   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');
     }
   }
 
 </script>
 {/literal}
 
+{/if} {* end of main event block*}
+