CRM-15932 - Repeat tab must refresh page when switching repeat mode so js & vars...
authorColeman Watts <coleman@civicrm.org>
Sun, 8 Mar 2015 14:10:55 +0000 (10:10 -0400)
committerColeman Watts <coleman@civicrm.org>
Sun, 8 Mar 2015 14:10:55 +0000 (10:10 -0400)
CRM/Core/Form/RecurringEntity.php
CRM/Event/Form/ManageEvent.php
CRM/Event/Form/ManageEvent/Repeat.php
CRM/Event/Form/ManageEvent/TabHeader.php

index 7f73df3ec9444d4090f62e83cc1b5f08ec658d71..32bcaf4107cd5c7836613304cbf4dd5cc404dbdb 100644 (file)
@@ -333,7 +333,7 @@ class CRM_Core_Form_RecurringEntity {
     }
     //Process this function only when you get this variable
     if ($params['allowRepeatConfigToSubmit'] == 1) {
-      if (CRM_Utils_Array::value('entity_table', $params) && CRM_Utils_Array::value('entity_id', $params) && $type) {
+      if (!empty($params['entity_table']) && !empty($params['entity_id']) && $type) {
         $params['used_for'] = $type;
         if (empty($params['parent_entity_id'])) {
           $params['parent_entity_id'] = self::$_parentEntityId;
index 035b0b488dc239e47ad22ce6ca5adc8f31c96f4e..ae92d3a3633835bd47065b1f01cbd9f35599a0eb 100644 (file)
@@ -85,7 +85,7 @@ class CRM_Event_Form_ManageEvent extends CRM_Core_Form {
   /**
    * Check if repeating event.
    */
-  protected $_isRepeatingEvent;
+  public $_isRepeatingEvent;
 
   /**
    * Set variables up before form is built.
index 2d9919092b358a154571c7d51f61313f040fe393..02c79fbcdfef180ae7ec9c0be70f52d82cf8ed45 100644 (file)
@@ -101,6 +101,7 @@ class CRM_Event_Form_ManageEvent_Repeat extends CRM_Event_Form_ManageEvent {
       $params['dateColumns'] = array('start_date');
       $params['excludeDateRangeColumns'] = array('start_date', 'end_date');
       $params['entity_table'] = 'civicrm_event';
+      $params['entity_id'] = $this->_id;
       //Unset event id
       unset($params['id']);
 
@@ -164,6 +165,7 @@ class CRM_Event_Form_ManageEvent_Repeat extends CRM_Event_Form_ManageEvent {
    * @return array
    */
   static public function getParticipantCountforEvent($listOfRelatedEntities = array()) {
+    $participantDetails = array();
     if (!empty($listOfRelatedEntities)) {
       $implodeRelatedEntities = implode(',', array_map(function ($entity) {
         return $entity['id'];
@@ -176,7 +178,6 @@ class CRM_Event_Form_ManageEvent_Repeat extends CRM_Event_Form_ManageEvent {
           WHERE p.event_id = e.id AND p.event_id IN ({$implodeRelatedEntities})
           GROUP BY p.event_id";
         $dao = CRM_Core_DAO::executeQuery($query);
-        $participantDetails = array();
         while ($dao->fetch()) {
           $participantDetails['countByID'][$dao->event_id] = $dao->participant_count;
           $participantDetails['countByName'][$dao->event_id][$dao->event_data] = $dao->participant_count;
index c4d3578d0e85dcbe423bfd99a9f79a52d8eb0b91..ebacc9bf46803fd8a3b1b23457a5b8491de1d4e1 100644 (file)
@@ -39,7 +39,7 @@
 class CRM_Event_Form_ManageEvent_TabHeader {
 
   /**
-   * @param CRM_Core_Form $form
+   * @param CRM_Event_Form_ManageEvent $form
    *
    * @return array
    */
@@ -62,7 +62,7 @@ class CRM_Event_Form_ManageEvent_TabHeader {
   }
 
   /**
-   * @param CRM_Core_Form $form
+   * @param CRM_Event_Form_ManageEvent $form
    *
    * @return array
    * @throws Exception
@@ -93,6 +93,11 @@ class CRM_Event_Form_ManageEvent_TabHeader {
     $tabs['pcp'] = array('title' => ts('Personal Campaigns')) + $default;
     $tabs['repeat'] = array('title' => ts('Repeat')) + $default;
 
+    // Repeat tab must refresh page when switching repeat mode so js & vars will get set-up
+    if (!$form->_isRepeatingEvent) {
+      unset($tabs['repeat']['class']);
+    }
+
     // check if we're in shopping cart mode for events
     $enableCart = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::EVENT_PREFERENCES_NAME,
       'enable_cart'
@@ -204,7 +209,7 @@ WHERE      e.id = %1
   }
 
   /**
-   * @param $form
+   * @param CRM_Event_Form_ManageEvent $form
    */
   public static function reset(&$form) {
     $tabs = self::process($form);