Merge pull request #5288 from colemanw/CRM-15932
authorDave Greenberg <dave@civicrm.org>
Wed, 4 Mar 2015 00:44:39 +0000 (16:44 -0800)
committerDave Greenberg <dave@civicrm.org>
Wed, 4 Mar 2015 00:44:39 +0000 (16:44 -0800)
CRM-15932 - Recurring entity QA fixes

39 files changed:
CRM/Activity/BAO/Activity.php
CRM/Activity/Form/Activity.php
CRM/Activity/Page/AJAX.php
CRM/Admin/Form/ScheduleReminders.php
CRM/Badge/BAO/Badge.php
CRM/Campaign/Page/DashBoard.php
CRM/Contact/Form/Search/Criteria.php
CRM/Contact/Form/Search/Custom/ActivitySearch.php
CRM/Contact/Form/Search/Custom/Basic.php
CRM/Contribute/Form/Contribution.php
CRM/Contribute/Form/ContributionPage/Settings.php
CRM/Core/BAO/Dashboard.php
CRM/Core/BAO/RecurringEntity.php
CRM/Core/Block.php
CRM/Core/Form/RecurringEntity.php
CRM/Core/Page/AJAX/RecurringEntity.php
CRM/Core/Page/RecurringEntityPreview.php [new file with mode: 0644]
CRM/Core/SelectValues.php
CRM/Core/Smarty/plugins/function.help.php
CRM/Core/xml/Menu/Misc.xml
CRM/Dedupe/BAO/RuleGroup.php
CRM/Event/Form/ManageEvent.php
CRM/Event/Form/ManageEvent/Repeat.php
CRM/Event/Form/ParticipantFeeSelection.php
CRM/Grant/BAO/Query.php
CRM/Price/BAO/PriceSet.php
CRM/Report/BAO/ReportInstance.php
CRM/Upgrade/Form.php
css/civicrm.css
js/Common.js
js/crm.ajax.js
templates/CRM/Activity/Form/Activity.tpl
templates/CRM/Core/Form/RecurringEntity.hlp
templates/CRM/Core/Form/RecurringEntity.tpl
templates/CRM/Core/Page/RecurringEntityPreview.tpl [new file with mode: 0644]
templates/CRM/Event/Form/ManageEvent/ConfirmRepeatMode.tpl
templates/CRM/Event/Form/ManageEvent/Repeat.tpl
tools/extensions/org.civicrm.search.activity/ActivitySearch.php
tools/extensions/org.civicrm.search.basic/Basic.php

index 61fdb3c53f3c5fe6300a6a26b40eb3acb39ed375..446e661f248bd6de9b2a54437beb453a5a4be081 100644 (file)
@@ -2697,7 +2697,7 @@ INNER JOIN  civicrm_option_group grp ON ( grp.id = val.option_group_id AND grp.n
    * @param array $params
    */
   public function setApiFilter(&$params) {
-    if (CRM_Utils_Array::value('target_contact_id', $params)) {
+    if (!empty($params['target_contact_id'])) {
       $this->selectAdd();
       $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name');
       $targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts);
index e382c65c7b017978f875894579d407e83b34213e..facd92491db6b9ef7a9efb5ecea087b889ba0170 100644 (file)
@@ -524,7 +524,7 @@ class CRM_Activity_Form_Activity extends CRM_Contact_Form_Task {
       return CRM_Custom_Form_CustomData::setDefaultValues($this);
     }
 
-    $defaults = $this->_values;
+    $defaults = $this->_values + CRM_Core_Form_RecurringEntity::setDefaultValues();
     // if we're editing...
     if (isset($this->_activityId)) {
       if (empty($defaults['activity_date_time'])) {
@@ -536,9 +536,6 @@ class CRM_Activity_Form_Activity extends CRM_Contact_Form_Task {
           $defaults['activity_date_time_time']
           ) = CRM_Utils_Date::setDateDefaults($defaults['activity_date_time'], 'activityDateTime');
         list($defaults['repetition_start_date'], $defaults['repetition_start_date_time']) = CRM_Utils_Date::setDateDefaults($defaults['activity_date_time'], 'activityDateTime');
-        $recurringEntityDefaults = array();
-        $recurringEntityDefaults = CRM_Core_Form_RecurringEntity::setDefaultValues();
-        $defaults = array_merge($defaults, $recurringEntityDefaults);
       }
 
       if ($this->_context != 'standalone') {
@@ -638,10 +635,10 @@ class CRM_Activity_Form_Activity extends CRM_Contact_Form_Task {
     $this->assign('suppressForm', FALSE);
 
     $element = &$this->add('select', 'activity_type_id', ts('Activity Type'),
-      $this->_fields['followup_activity_type_id']['attributes'],
+      array('' => '- ' . ts('select') . ' -') + $this->_fields['followup_activity_type_id']['attributes'],
       FALSE, array(
         'onchange' => "CRM.buildCustomData( 'Activity', this.value );",
-        'class' => 'crm-select2',
+        'class' => 'crm-select2 required',
       )
     );
 
@@ -836,15 +833,10 @@ class CRM_Activity_Form_Activity extends CRM_Contact_Form_Task {
       return TRUE;
     }
     $errors = array();
-    if (!$self->_single && !$fields['activity_type_id']) {
+    if ((array_key_exists('activity_type_id', $fields) || !$self->_single) && empty($fields['activity_type_id'])) {
       $errors['activity_type_id'] = ts('Activity Type is a required field');
     }
 
-    //Activity type is mandatory if creating new activity, CRM-4515
-    if (array_key_exists('activity_type_id', $fields) && empty($fields['activity_type_id'])) {
-      $errors['activity_type_id'] = ts('Activity Type is required field.');
-    }
-
     if (CRM_Utils_Array::value('activity_type_id', $fields) == 3 &&
       CRM_Utils_Array::value('status_id', $fields) == 1
     ) {
@@ -969,7 +961,6 @@ class CRM_Activity_Form_Activity extends CRM_Contact_Form_Task {
       // set params for repeat configuration in create mode
       $params['entity_id'] = $activityId;
       $params['entity_table'] = 'civicrm_activity';
-      $scheduleReminderDetails = array();
       if (!empty($params['entity_id']) && !empty($params['entity_table'])) {
         $checkParentExistsForThisId = CRM_Core_BAO_RecurringEntity::getParentFor($params['entity_id'], $params['entity_table']);
         if ($checkParentExistsForThisId) {
@@ -986,6 +977,11 @@ class CRM_Activity_Form_Activity extends CRM_Contact_Form_Task {
       }
       $params['dateColumns'] = array('activity_date_time');
 
+      // Set default repetition start if it was not provided.
+      if (empty($params['repetition_start_date'])) {
+        $params['repetition_start_date'] = $params['activity_date_time'];
+      }
+
       // unset activity id
       unset($params['id']);
       $linkedEntities = array(
index 6f657edeeeb7a1f7ef77ff1d77328d528bddf2be..dc6b5323ba1e0d57a6fc2c2d565c3e0636e98f8c 100644 (file)
@@ -486,7 +486,7 @@ class CRM_Activity_Page_AJAX {
 
     foreach ($activities as $key => $value) {
       //Check if recurring activity
-      if (CRM_Utils_Array::value('is_recurring_activity', $value)) {
+      if (!empty($value['is_recurring_activity'])) {
         if ($key == $value['is_recurring_activity']) {
           $activities[$key]['activity_type'] = $activities[$key]['activity_type'] . '<br/><span class="bold">Recurring Activity - (Parent)</span>';
         }
index 0cba27518f24de0bd7d62c0e8a632d41bb722c0b..fc6f7dce2ddbb5e8e2c2b2e4745c44f136f6e3e2 100644 (file)
@@ -145,7 +145,7 @@ class CRM_Admin_Form_ScheduleReminders extends CRM_Admin_Form {
     }
 
     //get the frequency units.
-    $this->_freqUnits = CRM_Core_SelectValues::getScheduleReminderFrequencyUnits();
+    $this->_freqUnits = CRM_Core_SelectValues::getRecurringFrequencyUnits();
 
     //pass the mapping ID in UPDATE mode
     $mappings = CRM_Core_BAO_ActionSchedule::getMapping($mappingID);
index 1576e347281c5eb172b5ba8fcf9374d77380d9c9..21972d54938408c97f8f8c52e0c1b2a594982401 100644 (file)
@@ -208,7 +208,7 @@ class CRM_Badge_BAO_Badge {
       $startOffset = CRM_Utils_Array::value('height_image_2', $formattedRow);
     }
 
-    if (CRM_Utils_Array::value('participant_image', $formattedRow)) {
+    if (!empty($formattedRow['participant_image'])) {
       $imageAlign = 0;
       switch (CRM_Utils_Array::value('alignment_participant_image', $formattedRow)) {
         case 'R':
index 73a7c852f5d05abba9dd8f4d1ec8135bf8145635..f51bdfc4e0667fcdfc3fbb06fb931bf51d31345e 100644 (file)
@@ -314,7 +314,7 @@ class CRM_Campaign_Page_DashBoard extends CRM_Core_Page {
         $surveysData[$sid]['campaign'] = CRM_Utils_Array::value($campaignId, $campaigns);
         $surveysData[$sid]['activity_type'] = $surveyType[$survey['activity_type_id']];
         if (!empty($survey['release_frequency'])) {
-          $surveysData[$sid]['release_frequency'] = $survey['release_frequency'] . ' Day(s)';
+          $surveysData[$sid]['release_frequency'] = $survey['release_frequency'] . ' ' . ts('Day(s)');
         }
 
         $action = array_sum(array_keys(self::surveyActionLinks($surveysData[$sid]['activity_type'])));
index 8578b763af8fdf6ac3ed44f6978354e7ac21d59d..74d449c9bc4f01cb0551f0a858c3e10a6b632ff7 100644 (file)
@@ -255,7 +255,7 @@ class CRM_Contact_Form_Search_Criteria {
       $commPreff[] = $form->createElement('advcheckbox', $k, NULL, $v);
     }
 
-    $onHold[] = $form->createElement('advcheckbox', 'on_hold', NULL, ts(''));
+    $onHold[] = $form->createElement('advcheckbox', 'on_hold', NULL, '');
     $form->addGroup($onHold, 'email_on_hold', ts('Email On Hold'));
 
     $form->addGroup($commPreff, 'preferred_communication_method', ts('Preferred Communication Method'));
index d8578e2510f2296736358f5ff0ea617222a412bc..a81f092395777a205a6e2a2ed7e8f33578970c1c 100644 (file)
@@ -55,9 +55,9 @@ class CRM_Contact_Form_Search_Custom_ActivitySearch extends CRM_Contact_Form_Sea
       ts('Activity Subject') => 'activity_subject',
       ts('Scheduled By') => 'source_contact',
       ts('Scheduled Date') => 'activity_date',
-      ts(' ') => 'activity_id',
-      ts('  ') => 'activity_type_id',
-      ts('   ') => 'case_id',
+      ' ' => 'activity_id',
+      '  ' => 'activity_type_id',
+      '   ' => 'case_id',
       ts('Location') => 'location',
       ts('Duration') => 'duration',
       ts('Details') => 'details',
index 0823a8ba0ee79d3f40be675d83b87bffbfba9521..5a71382d5b7938bfa1b9f1d95a0e5102b680f78e 100644 (file)
@@ -47,7 +47,7 @@ class CRM_Contact_Form_Search_Custom_Basic extends CRM_Contact_Form_Search_Custo
 
     $this->normalize();
     $this->_columns = array(
-      ts('') => 'contact_type',
+      '' => 'contact_type',
       ts('Name') => 'sort_name',
       ts('Address') => 'street_address',
       ts('City') => 'city',
index 8dbf4882610cb82446b1ec569e1110e6f2c88ff8..1abeefd2f97c389967263f6470b303ddc62482e6 100644 (file)
@@ -1357,7 +1357,7 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP
           $this->assign('dataArray', $taxRate);
         }
         else {
-          if (CRM_Utils_Array::value('price_set_id', $submittedValues)) {
+          if (!empty($submittedValues['price_set_id'])) {
             $this->assign('totalTaxAmount', $submittedValues['tax_amount']);
             $this->assign('getTaxDetails', $getTaxDetails);
             $this->assign('dataArray', $taxRate);
index eaade9d0a1e749f1b90d72b05b67899441c27680..8719d6652c928573f82b2b6a3bc41f1f640c325f 100644 (file)
@@ -164,7 +164,7 @@ class CRM_Contribute_Form_ContributionPage_Settings extends CRM_Contribute_Form_
     $options = array();
     $options[] = $this->createElement('radio', NULL, NULL, ts('Optional'), 1);
     $options[] = $this->createElement('radio', NULL, NULL, ts('Required'), 2);
-    $this->addGroup($options, 'is_for_organization', ts(''));
+    $this->addGroup($options, 'is_for_organization', '');
     $this->add('textarea', 'for_organization', ts('On behalf of Label'), $attributes['for_organization']);
 
     // collect goal amount
index 9d589d8988ece41b3d7eee7648b939024ac0c4ba..c65fa536dcbc332634c7a5a3610a83168277ca2b 100644 (file)
@@ -164,7 +164,7 @@ class CRM_Core_BAO_Dashboard extends CRM_Core_DAO_Dashboard {
     $contactID = CRM_Core_Session::singleton()->get('userID');
     $allDashlets = CRM_Utils_Array::index(array('name'), $getDashlets['values']);
     $defaultDashlets = array();
-    if (CRM_Utils_Array::value('blog', $allDashlets)) {
+    if (!empty($allDashlets['blog'])) {
       $defaultDashlets['blog'] = array(
         'dashboard_id' => $allDashlets['blog']['id'],
         'is_active' => 1,
index ae2ef35b836cad687deedc294217c9ae12f47766..31853c88450d03ce9e0669de493bf04eddd95c51 100644 (file)
@@ -155,7 +155,7 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity {
    * @return object
    */
   public static function add(&$params) {
-    if (CRM_Utils_Array::value('id', $params)) {
+    if (!empty($params['id'])) {
       CRM_Utils_Hook::pre('edit', 'RecurringEntity', $params['id'], $params);
     }
     else {
@@ -167,7 +167,7 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity {
     $daoRecurringEntity->find(TRUE);
     $result = $daoRecurringEntity->save();
 
-    if (CRM_Utils_Array::value('id', $params)) {
+    if (!empty($params['id'])) {
       CRM_Utils_Hook::post('edit', 'RecurringEntity', $daoRecurringEntity->id, $daoRecurringEntity);
     }
     else {
@@ -361,8 +361,8 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity {
           $recursionDates[$count][$col] = CRM_Utils_Date::processDate($newDate->format('Y-m-d H:i:s'));
         }
         if ($exRangeStart) {
-          $exRangeStartDate = CRM_Utils_Date::processDate($recursionDates[$count][$exRangeStart], NULL, FALSE, 'Ymd');
-          $exRangeEndDate = CRM_Utils_Date::processDate($recursionDates[$count][$exRangeEnd], NULL, FALSE, 'Ymd');
+          $exRangeStartDate = CRM_Utils_Date::processDate(CRM_Utils_Array::value($exRangeStart, $recursionDates[$count]), NULL, FALSE, 'Ymd');
+          $exRangeEndDate = CRM_Utils_Date::processDate(CRM_Utils_Array::value($exRangeEnd, $recursionDates[$count]), NULL, FALSE, 'Ymd');
         }
 
         foreach ($this->excludeDates as $exDate) {
@@ -843,39 +843,39 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity {
    */
   public function mapFormValuesToDB($formParams = array()) {
     $dbParams = array();
-    if (CRM_Utils_Array::value('used_for', $formParams)) {
+    if (!empty($formParams['used_for'])) {
       $dbParams['used_for'] = $formParams['used_for'];
     }
 
-    if (CRM_Utils_Array::value('entity_id', $formParams)) {
+    if (!empty($formParams['entity_id'])) {
       $dbParams['entity_value'] = $formParams['entity_id'];
     }
 
-    if (CRM_Utils_Array::value('repetition_start_date', $formParams)) {
-      if (CRM_Utils_Array::value('repetition_start_date_display', $formParams)) {
+    if (!empty($formParams['repetition_start_date'])) {
+      if (!empty($formParams['repetition_start_date_display'])) {
         $repetitionStartDate = $formParams['repetition_start_date_display'];
       }
       else {
         $repetitionStartDate = $formParams['repetition_start_date'];
       }
-      if (CRM_Utils_Array::value('repetition_start_date_time', $formParams)) {
+      if (!empty($formParams['repetition_start_date_time'])) {
         $repetitionStartDate = $repetitionStartDate . " " . $formParams['repetition_start_date_time'];
       }
       $repetition_start_date = new DateTime($repetitionStartDate);
       $dbParams['start_action_date'] = CRM_Utils_Date::processDate($repetition_start_date->format('Y-m-d H:i:s'));
     }
 
-    if (CRM_Utils_Array::value('repetition_frequency_unit', $formParams)) {
+    if (!empty($formParams['repetition_frequency_unit'])) {
       $dbParams['repetition_frequency_unit'] = $formParams['repetition_frequency_unit'];
     }
 
-    if (CRM_Utils_Array::value('repetition_frequency_interval', $formParams)) {
+    if (!empty($formParams['repetition_frequency_interval'])) {
       $dbParams['repetition_frequency_interval'] = $formParams['repetition_frequency_interval'];
     }
 
     //For Repeats on:(weekly case)
     if ($formParams['repetition_frequency_unit'] == 'week') {
-      if (CRM_Utils_Array::value('start_action_condition', $formParams)) {
+      if (!empty($formParams['start_action_condition'])) {
         $repeats_on = CRM_Utils_Array::value('start_action_condition', $formParams);
         $dbParams['start_action_condition'] = implode(",", array_keys($repeats_on));
       }
@@ -884,7 +884,7 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity {
     //For Repeats By:(monthly case)
     if ($formParams['repetition_frequency_unit'] == 'month') {
       if ($formParams['repeats_by'] == 1) {
-        if (CRM_Utils_Array::value('limit_to', $formParams)) {
+        if (!empty($formParams['limit_to'])) {
           $dbParams['limit_to'] = $formParams['limit_to'];
         }
       }
@@ -897,14 +897,14 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity {
 
     //For "Ends" - After:
     if ($formParams['ends'] == 1) {
-      if (CRM_Utils_Array::value('start_action_offset', $formParams)) {
+      if (!empty($formParams['start_action_offset'])) {
         $dbParams['start_action_offset'] = $formParams['start_action_offset'];
       }
     }
 
     //For "Ends" - On:
     if ($formParams['ends'] == 2) {
-      if (CRM_Utils_Array::value('repeat_absolute_date', $formParams)) {
+      if (!empty($formParams['repeat_absolute_date'])) {
         $dbParams['absolute_date'] = CRM_Utils_Date::processDate($formParams['repeat_absolute_date']);
       }
     }
@@ -1046,7 +1046,7 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity {
         $r->count($scheduleReminderDetails['start_action_offset']);
       }
 
-      if (CRM_Utils_Array::value('absolute_date', $scheduleReminderDetails)) {
+      if (!empty($scheduleReminderDetails['absolute_date'])) {
         $absoluteDate = CRM_Utils_Date::setDateDefaults($scheduleReminderDetails['absolute_date']);
         $endDate = new DateTime($absoluteDate[0] . ' ' . $absoluteDate[1]);
         $endDate->modify('+1 day');
@@ -1140,7 +1140,7 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity {
       );
       $defaults = array();
       CRM_Core_DAO::commonRetrieve($dao, $params, $defaults);
-      if (CRM_Utils_Array::value('id', $defaults)) {
+      if (!empty($defaults['id'])) {
         $result['entityId'] = $defaults['id'];
         $result['entityTable'] = $entityTable;
       }
index 569f0552129c9759cef64f2ea8b89bb476b469ca..662e756b9e18768870cdb33652a15195457d6891 100644 (file)
@@ -90,7 +90,7 @@ class CRM_Core_Block {
         self::CREATE_NEW => array(
           'template' => 'CreateNew.tpl',
           'info' => ts('CiviCRM Create New Record'),
-          'subject' => ts(''),
+          'subject' => '',
           'active' => TRUE,
           'cache' => BLOCK_CACHE_GLOBAL,
           'visibility' => 1,
index 17242eb01e4aab81a626948babb3117a86f58954..f3247fe26916d4b27d373aa13bc843785c28de63 100644 (file)
@@ -96,16 +96,23 @@ class CRM_Core_Form_RecurringEntity {
         self::$_scheduleReminderID = self::$_scheduleReminderDetails->id;
       }
     }
-    if ($entityTable) {
-      CRM_Core_OptionValue::getValues(array('name' => $entityTable . '_repeat_exclude_dates_' . self::$_parentEntityId), $optionValue);
-      $excludeOptionValues = array();
-      if (!empty($optionValue)) {
-        foreach ($optionValue as $key => $val) {
-          $excludeOptionValues[$val['value']] = date('m/d/Y', strtotime($val['value']));
-        }
-        self::$_excludeDateInfo = $excludeOptionValues;
+    CRM_Core_OptionValue::getValues(array('name' => $entityTable . '_repeat_exclude_dates_' . self::$_parentEntityId), $optionValue);
+    $excludeOptionValues = array();
+    if (!empty($optionValue)) {
+      foreach ($optionValue as $key => $val) {
+        $excludeOptionValues[$val['value']] = CRM_Utils_Date::customFormat($val['value']);
       }
+      self::$_excludeDateInfo = $excludeOptionValues;
     }
+
+    // Assign variables
+    $entityType = CRM_Core_DAO_AllCoreTables::getBriefName(CRM_Core_DAO_AllCoreTables::getClassForTable($entityTable));
+    $tpl = CRM_Core_Smarty::singleton();
+    $tpl->assign('recurringEntityType', ts($entityType));
+    $tpl->assign('currentEntityId', self::$_entityId);
+    $tpl->assign('entityTable', self::$_entityTable);
+    $tpl->assign('scheduleReminderId', self::$_scheduleReminderID);
+    $tpl->assign('hasParent', self::$_hasParent);
   }
 
   /**
@@ -116,7 +123,12 @@ class CRM_Core_Form_RecurringEntity {
    * @return array
    */
   public static function setDefaultValues() {
-    $defaults = array();
+    // Defaults for new entity
+    $defaults = array(
+      'repetition_frequency_unit' => 'week',
+    );
+
+    // Default for existing entity
     if (self::$_scheduleReminderID) {
       $defaults['repetition_frequency_unit'] = self::$_scheduleReminderDetails->repetition_frequency_unit;
       $defaults['repetition_frequency_interval'] = self::$_scheduleReminderDetails->repetition_frequency_interval;
@@ -137,7 +149,6 @@ class CRM_Core_Form_RecurringEntity {
       if (self::$_scheduleReminderDetails->limit_to) {
         $defaults['repeats_by'] = 1;
       }
-      $explodeStartActionCondition = array();
       if (self::$_scheduleReminderDetails->entity_status) {
         $explodeStartActionCondition = explode(" ", self::$_scheduleReminderDetails->entity_status);
         $defaults['entity_status_1'] = $explodeStartActionCondition[0];
@@ -146,6 +157,9 @@ class CRM_Core_Form_RecurringEntity {
       if (self::$_scheduleReminderDetails->entity_status) {
         $defaults['repeats_by'] = 2;
       }
+      if (self::$_excludeDateInfo) {
+        $defaults['exclude_date_list'] = implode(',', self::$_excludeDateInfo);
+      }
     }
     return $defaults;
   }
@@ -153,78 +167,54 @@ class CRM_Core_Form_RecurringEntity {
   /**
    * Build form.
    *
-   * @param $form
+   * @param CRM_Core_Form $form
    */
   public static function buildQuickForm(&$form) {
-    if (self::$_entityTable) {
-      $entityType = explode("_", self::$_entityTable);
-      if ($entityType[1]) {
-        $form->assign('entityType', ucwords($entityType[1]));
-      }
-    }
-    $form->assign('currentEntityId', self::$_entityId);
-    $form->assign('entityTable', self::$_entityTable);
-    $form->assign('scheduleReminderId', self::$_scheduleReminderID);
-    $form->assign('hasParent', self::$_hasParent);
-
-    $form->_freqUnits = array('hour' => 'hour') + CRM_Core_OptionGroup::values('recur_frequency_units');
-    foreach ($form->_freqUnits as $val => $label) {
-      if ($label == "day") {
-        $label = "dai";
-      }
-      $freqUnitsDisplay[$val] = ts('%1ly', array(1 => $label));
-    }
-    // echo "<pre>";print_r($freqUnitsDisplay);
+    // For some reason this is using the following as keys rather than the standard numeric keys returned by CRM_Utils_Date
     $dayOfTheWeek = array(
-      'monday' => 'Monday',
-      'tuesday' => 'Tuesday',
-      'wednesday' => 'Wednesday',
-      'thursday' => 'Thursday',
-      'friday' => 'Friday',
-      'saturday' => 'Saturday',
-      'sunday' => 'Sunday',
+      'sunday',
+      'monday',
+      'tuesday',
+      'wednesday',
+      'thursday',
+      'friday',
+      'saturday',
     );
-    $form->add('select', 'repetition_frequency_unit', ts('Repeats:'), $freqUnitsDisplay);
+    $dayOfTheWeek = array_combine($dayOfTheWeek, CRM_Utils_Date::getAbbrWeekdayNames());
+    $form->add('select', 'repetition_frequency_unit', ts('Repeats every'), CRM_Core_SelectValues::getRecurringFrequencyUnits(), FALSE, array('class' => 'required'));
     $numericOptions = CRM_Core_SelectValues::getNumericOptions(1, 30);
-    $form->add('select', 'repetition_frequency_interval', ts('Repeats every:'), $numericOptions, '', array('style' => 'width:55px;'));
+    $form->add('select', 'repetition_frequency_interval', NULL, $numericOptions, FALSE, array('class' => 'required'));
     $form->addDateTime('repetition_start_date', ts('Repetition Start Date'), FALSE, array('formatType' => 'activityDateTime'));
     foreach ($dayOfTheWeek as $key => $val) {
-      $startActionCondition[] = $form->createElement('checkbox', $key, NULL, substr($val . "&nbsp;", 0, 3));
+      $startActionCondition[] = $form->createElement('checkbox', $key, NULL, $val);
     }
     $form->addGroup($startActionCondition, 'start_action_condition', ts('Repeats on'));
     $roptionTypes = array(
       '1' => ts('day of the month'),
       '2' => ts('day of the week'),
     );
-    $form->addRadio('repeats_by', ts("Repeats By:"), $roptionTypes, array(), NULL);
-    $getMonths = CRM_Core_SelectValues::getNumericOptions(1, 31);
-    $form->add('select', 'limit_to', '', $getMonths, FALSE, array('style' => 'width:55px;'));
+    $form->addRadio('repeats_by', ts("Repeats by"), $roptionTypes, array('required' => TRUE), NULL);
+    $form->add('select', 'limit_to', '', CRM_Core_SelectValues::getNumericOptions(1, 31));
     $dayOfTheWeekNo = array(
-      'first' => 'First',
-      'second' => 'Second',
-      'third' => 'Third',
-      'fourth' => 'Fourth',
-      'last' => 'Last',
+      'first' => ts('First'),
+      'second' => ts('Second'),
+      'third' => ts('Third'),
+      'fourth' => ts('Fourth'),
+      'last' => ts('Last'),
     );
-    $form->add('select', 'entity_status_1', ts(''), $dayOfTheWeekNo);
-    $form->add('select', 'entity_status_2', ts(''), $dayOfTheWeek);
+    $form->add('select', 'entity_status_1', '', $dayOfTheWeekNo);
+    $form->add('select', 'entity_status_2', '', $dayOfTheWeek);
     $eoptionTypes = array(
       '1' => ts('After'),
       '2' => ts('On'),
     );
-    $form->addRadio('ends', ts("Ends:"), $eoptionTypes, array(), NULL);
-    $form->add('text', 'start_action_offset', ts(''), array('size' => 3, 'maxlength' => 2));
+    $form->addRadio('ends', ts("Ends"), $eoptionTypes, array('class' => 'required'), NULL);
+    $form->add('select', 'start_action_offset', NULL, CRM_Core_SelectValues::getNumericOptions(1, 30), FALSE);
     $form->addFormRule(array('CRM_Core_Form_RecurringEntity', 'formRule'));
     $form->addDate('repeat_absolute_date', ts('On'), FALSE, array('formatType' => 'mailing'));
-    $form->addDate('exclude_date', ts('Exclude Date(s)'), FALSE);
-    $select = $form->add('select', 'exclude_date_list', ts(''), self::$_excludeDateInfo, FALSE, array(
-        'style' => 'width:150px;',
-        'size' => 4,
+    $form->add('text', 'exclude_date_list', ts('Exclude Dates'), array(
+        'class' => 'twenty',
       ));
-    $select->setMultiple(TRUE);
-    $form->addElement('button', 'add_to_exclude_list', '>>', 'onClick="addToExcludeList(document.getElementById(\'exclude_date\').value);"');
-    $form->addElement('button', 'remove_from_exclude_list', '<<', 'onClick="removeFromExcludeList(\'exclude_date_list\')"');
-    $form->addElement('hidden', 'copyExcludeDates', '', array('id' => 'copyExcludeDates'));
     $form->addElement('hidden', 'allowRepeatConfigToSubmit', '', array('id' => 'allowRepeatConfigToSubmit'));
     $form->addButtons(array(
         array(
@@ -238,6 +228,11 @@ class CRM_Core_Form_RecurringEntity {
         ),
       )
     );
+    // For client-side pluralization
+    $form->assign('recurringFrequencyOptions', array(
+      'single' => CRM_Utils_Array::makeNonAssociative(CRM_Core_SelectValues::getRecurringFrequencyUnits()),
+      'plural' => CRM_Utils_Array::makeNonAssociative(CRM_Core_SelectValues::getRecurringFrequencyUnits(2)),
+    ));
   }
 
   /**
@@ -255,15 +250,15 @@ class CRM_Core_Form_RecurringEntity {
     if ($values['allowRepeatConfigToSubmit'] == 1) {
       $dayOfTheWeek = array('monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday');
       //Repeats
-      if (!CRM_Utils_Array::value('repetition_frequency_unit', $values)) {
+      if (empty($values['repetition_frequency_unit'])) {
         $errors['repetition_frequency_unit'] = ts('This is a required field');
       }
       //Repeats every
-      if (!CRM_Utils_Array::value('repetition_frequency_interval', $values)) {
+      if (empty($values['repetition_frequency_interval'])) {
         $errors['repetition_frequency_interval'] = ts('This is a required field');
       }
       //Ends
-      if (CRM_Utils_Array::value('ends', $values)) {
+      if (!empty($values['ends'])) {
         if ($values['ends'] == 1) {
           if (empty($values['start_action_offset'])) {
             $errors['start_action_offset'] = ts('This is a required field');
@@ -273,7 +268,7 @@ class CRM_Core_Form_RecurringEntity {
           }
         }
         if ($values['ends'] == 2) {
-          if (CRM_Utils_Array::value('repeat_absolute_date', $values)) {
+          if (!empty($values['repeat_absolute_date'])) {
             $entityStartDate = CRM_Utils_Date::processDate($values['repetition_start_date']);
             $end = CRM_Utils_Date::processDate($values['repeat_absolute_date']);
             if (($end < $entityStartDate) && ($end != 0)) {
@@ -290,9 +285,9 @@ class CRM_Core_Form_RecurringEntity {
       }
 
       //Repeats BY
-      if (CRM_Utils_Array::value('repeats_by', $values)) {
+      if (!empty($values['repeats_by'])) {
         if ($values['repeats_by'] == 1) {
-          if (CRM_Utils_Array::value('limit_to', $values)) {
+          if (!empty($values['limit_to'])) {
             if ($values['limit_to'] < 1 && $values['limit_to'] > 31) {
               $errors['limit_to'] = ts('Invalid day of the month');
             }
@@ -302,7 +297,7 @@ class CRM_Core_Form_RecurringEntity {
           }
         }
         if ($values['repeats_by'] == 2) {
-          if (CRM_Utils_Array::value('entity_status_1', $values)) {
+          if (!empty($values['entity_status_1'])) {
             $dayOfTheWeekNo = array('first', 'second', 'third', 'fourth', 'last');
             if (!in_array($values['entity_status_1'], $dayOfTheWeekNo)) {
               $errors['entity_status_1'] = ts('Invalid option');
@@ -311,7 +306,7 @@ class CRM_Core_Form_RecurringEntity {
           else {
             $errors['entity_status_1'] = ts('Invalid option');
           }
-          if (CRM_Utils_Array::value('entity_status_2', $values)) {
+          if (!empty($values['entity_status_2'])) {
             if (!in_array($values['entity_status_2'], $dayOfTheWeek)) {
               $errors['entity_status_2'] = ts('Invalid day name');
             }
@@ -333,17 +328,17 @@ class CRM_Core_Form_RecurringEntity {
    */
   public static function postProcess($params = array(), $type, $linkedEntities = array()) {
     //Check entity_id not present in params take it from class variable
-    if (!CRM_Utils_Array::value('entity_id', $params)) {
+    if (empty($params['entity_id'])) {
       $params['entity_id'] = self::$_entityId;
     }
     //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) {
         $params['used_for'] = $type;
-        if (!CRM_Utils_Array::value('parent_entity_id', $params)) {
+        if (empty($params['parent_entity_id'])) {
           $params['parent_entity_id'] = self::$_parentEntityId;
         }
-        if (CRM_Utils_Array::value('schedule_reminder_id', $params)) {
+        if (!empty($params['schedule_reminder_id'])) {
           $params['id'] = $params['schedule_reminder_id'];
         }
         else {
@@ -355,7 +350,7 @@ class CRM_Core_Form_RecurringEntity {
         $dbParams = $recurobj->mapFormValuesToDB($params);
 
         //Delete repeat configuration and rebuild
-        if (CRM_Utils_Array::value('id', $params)) {
+        if (!empty($params['id'])) {
           CRM_Core_BAO_ActionSchedule::del($params['id']);
           unset($params['id']);
         }
@@ -363,10 +358,9 @@ class CRM_Core_Form_RecurringEntity {
 
         //exclude dates
         $excludeDateList = array();
-        if (CRM_Utils_Array::value('copyExcludeDates', $params) && CRM_Utils_Array::value('parent_entity_id', $params) && $actionScheduleObj->entity_value) {
+        if (CRM_Utils_Array::value('exclude_date_list', $params) && CRM_Utils_Array::value('parent_entity_id', $params) && $actionScheduleObj->entity_value) {
           //Since we get comma separated values lets get them in array
-          $excludeDates = array();
-          $excludeDates = explode(",", $params['copyExcludeDates']);
+          $excludeDates = explode(",", $params['exclude_date_list']);
 
           //Check if there exists any values for this option group
           $optionGroupIdExists = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup',
@@ -398,13 +392,12 @@ class CRM_Core_Form_RecurringEntity {
                 'is_active' => 1,
               );
               $excludeDateList[] = $optionGroupValue['value'];
-              CRM_Core_BAO_OptionValue::add($optionGroupValue);
+              CRM_Core_BAO_OptionValue::create($optionGroupValue);
             }
           }
         }
 
         //Set type for API
-        $apiEntityType = array();
         $apiEntityType = explode("_", $type);
         if (!empty($apiEntityType[1])) {
           $apiType = $apiEntityType[1];
@@ -475,7 +468,7 @@ class CRM_Core_Form_RecurringEntity {
           $recursion->excludeDates = $excludeDateList;
           $recursion->excludeDateRangeColumns = $params['excludeDateRangeColumns'];
         }
-        if (CRM_Utils_Array::value('intervalDateColumns', $params)) {
+        if (!empty($params['intervalDateColumns'])) {
           $recursion->intervalDateColumns = $params['intervalDateColumns'];
         }
         $recursion->entity_id = $params['entity_id'];
@@ -484,7 +477,7 @@ class CRM_Core_Form_RecurringEntity {
           $recursion->linkedEntities = $linkedEntities;
         }
 
-        $recurResult = $recursion->generate();
+        $recursion->generate();
 
         $status = ts('Repeat Configuration has been saved');
         CRM_Core_Session::setStatus($status, ts('Saved'), 'success');
index f4fb03dfc926652ef21d0cd11b6760cd98d5c154..7265eeda26c6f08f0411fcab863d0be281bce36d 100644 (file)
 class CRM_Core_Page_AJAX_RecurringEntity {
 
   public static function updateMode() {
+    $finalResult = array();
     if (CRM_Utils_Array::value('mode', $_REQUEST) && CRM_Utils_Array::value('entityId', $_REQUEST) && CRM_Utils_Array::value('entityTable', $_REQUEST)) {
 
-      $finalResult = array();
       $mode = CRM_Utils_Type::escape($_REQUEST['mode'], 'Integer');
       $entityId = CRM_Utils_Type::escape($_REQUEST['entityId'], 'Integer');
       $entityTable = CRM_Utils_Type::escape($_REQUEST['entityTable'], 'String');
 
-      if (CRM_Utils_Array::value('linkedEntityTable', $_REQUEST)) {
-        $result = array();
+      if (!empty($_REQUEST['linkedEntityTable'])) {
         $result = CRM_Core_BAO_RecurringEntity::updateModeLinkedEntity($entityId, $_REQUEST['linkedEntityTable'], $entityTable);
       }
 
@@ -44,74 +43,7 @@ class CRM_Core_Page_AJAX_RecurringEntity {
         $finalResult['status'] = 'Error';
       }
     }
-    echo json_encode($finalResult);
-    CRM_Utils_System::civiExit();
-  }
-
-  public static function generatePreview() {
-    $params = $formValues = $genericResult = array();
-    $formValues = $_REQUEST;
-    if (!empty($formValues) &&
-      CRM_Utils_Array::value('entity_table', $formValues)
-    ) {
-      $startDateColumnName = CRM_Core_BAO_RecurringEntity::$_dateColumns[$formValues['entity_table']]['dateColumns'][0];
-      $endDateColumnName = CRM_Core_BAO_RecurringEntity::$_dateColumns[$formValues['entity_table']]['intervalDateColumns'][0];
-
-      $recursion = new CRM_Core_BAO_RecurringEntity();
-      if (CRM_Utils_Array::value('dateColumns', CRM_Core_BAO_RecurringEntity::$_dateColumns[$formValues['entity_table']])) {
-        $recursion->dateColumns = CRM_Core_BAO_RecurringEntity::$_dateColumns[$formValues['entity_table']]['dateColumns'];
-      }
-      $recursion->scheduleFormValues = $formValues;
-      if (!empty($formValues['exclude_date_list'])) {
-        $recursion->excludeDates = $formValues['exclude_date_list'];
-      }
-      if (CRM_Utils_Array::value('excludeDateRangeColumns', CRM_Core_BAO_RecurringEntity::$_dateColumns[$formValues['entity_table']])) {
-        $recursion->excludeDateRangeColumns = CRM_Core_BAO_RecurringEntity::$_dateColumns[$formValues['entity_table']]['excludeDateRangeColumns'];
-      }
-
-      if (CRM_Utils_Array::value('entity_id', $formValues)) {
-        $parentEventId = CRM_Core_BAO_RecurringEntity::getParentFor($formValues['entity_id'], $formValues['entity_table']);
-      }
-
-      //Check if there is any enddate column defined to find out the interval between the two range
-      if (CRM_Utils_Array::value('intervalDateColumns', CRM_Core_BAO_RecurringEntity::$_dateColumns[$formValues['entity_table']])) {
-        $daoName = CRM_Core_BAO_RecurringEntity::$_tableDAOMapper[$formValues['entity_table']];
-        if ($parentEventId) {
-          $startDate = CRM_Core_DAO::getFieldValue($daoName, $parentEventId, $startDateColumnName);
-          $endDate = CRM_Core_DAO::getFieldValue($daoName, $parentEventId, $endDateColumnName);
-        }
-        if ($endDate) {
-          $interval = $recursion->getInterval($startDate, $endDate);
-          $recursion->intervalDateColumns = array($endDateColumnName => $interval);
-        }
-      }
-
-      $result = $recursion->generateRecursiveDates();
-
-      foreach ($result as $key => $value) {
-        if ($startDateColumnName) {
-          $result[$key]['start_date'] = date('M d, Y h:i:s A \o\n l', strtotime($value[$startDateColumnName]));
-        }
-        if ($value[$endDateColumnName]) {
-          if ($endDateColumnName) {
-            $result[$key]['end_date'] = date('M d, Y h:i:s A \o\n l', strtotime($value[$endDateColumnName]));
-          }
-        }
-      }
-
-      //Show the list of participants registered for the events if any
-      if ($formValues['entity_table'] == "civicrm_event" && !empty($parentEventId)) {
-        $getConnectedEntities = CRM_Core_BAO_RecurringEntity::getEntitiesForParent($parentEventId, 'civicrm_event', TRUE);
-        if ($getConnectedEntities) {
-          $participantDetails = CRM_Event_Form_ManageEvent_Repeat::getParticipantCountforEvent($getConnectedEntities);
-          if (!empty($participantDetails['countByName'])) {
-            $result['participantData'] = $participantDetails['countByName'];
-          }
-        }
-      }
-    }
-    echo json_encode($result);
-    CRM_Utils_System::civiExit();
+    CRM_Utils_JSON::output($finalResult);
   }
 
 }
diff --git a/CRM/Core/Page/RecurringEntityPreview.php b/CRM/Core/Page/RecurringEntityPreview.php
new file mode 100644 (file)
index 0000000..7c6c4b5
--- /dev/null
@@ -0,0 +1,108 @@
+<?php
+/*
+ +--------------------------------------------------------------------+
+ | CiviCRM version 4.6                                                |
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC (c) 2004-2014                                |
+ +--------------------------------------------------------------------+
+ | This file is a part of CiviCRM.                                    |
+ |                                                                    |
+ | CiviCRM is free software; you can copy, modify, and distribute it  |
+ | under the terms of the GNU Affero General Public License           |
+ | Version 3, 19 November 2007 and the CiviCRM Licensing Exception.   |
+ |                                                                    |
+ | CiviCRM is distributed in the hope that it will be useful, but     |
+ | WITHOUT ANY WARRANTY; without even the implied warranty of         |
+ | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.               |
+ | See the GNU Affero General Public License for more details.        |
+ |                                                                    |
+ | You should have received a copy of the GNU Affero General Public   |
+ | License and the CiviCRM Licensing Exception along                  |
+ | with this program; if not, contact CiviCRM LLC                     |
+ | at info[AT]civicrm[DOT]org. If you have questions about the        |
+ | GNU Affero General Public License or the licensing of CiviCRM,     |
+ | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
+ +--------------------------------------------------------------------+
+ */
+
+/**
+ *
+ * @package CRM
+ * @copyright CiviCRM LLC (c) 2004-2014
+ * $Id$
+ *
+ */
+class CRM_Core_Page_RecurringEntityPreview extends CRM_Core_Page {
+
+  /**
+   * Run the basic page (run essentially starts execution for that page).
+   *
+   * @return void
+   */
+  public function run() {
+    $parentEventId = $startDate = $endDate = NULL;
+    $dates = array();
+    $formValues = $_REQUEST;
+    if (!empty($formValues['entity_table'])) {
+      $startDateColumnName = CRM_Core_BAO_RecurringEntity::$_dateColumns[$formValues['entity_table']]['dateColumns'][0];
+      $endDateColumnName = CRM_Core_BAO_RecurringEntity::$_dateColumns[$formValues['entity_table']]['intervalDateColumns'][0];
+
+      $recursion = new CRM_Core_BAO_RecurringEntity();
+      if (CRM_Utils_Array::value('dateColumns', CRM_Core_BAO_RecurringEntity::$_dateColumns[$formValues['entity_table']])) {
+        $recursion->dateColumns = CRM_Core_BAO_RecurringEntity::$_dateColumns[$formValues['entity_table']]['dateColumns'];
+      }
+      $recursion->scheduleFormValues = $formValues;
+      if (!empty($formValues['exclude_date_list'])) {
+        $recursion->excludeDates = explode(',', $formValues['exclude_date_list']);
+      }
+      if (CRM_Utils_Array::value('excludeDateRangeColumns', CRM_Core_BAO_RecurringEntity::$_dateColumns[$formValues['entity_table']])) {
+        $recursion->excludeDateRangeColumns = CRM_Core_BAO_RecurringEntity::$_dateColumns[$formValues['entity_table']]['excludeDateRangeColumns'];
+      }
+
+      if (!empty($formValues['entity_id'])) {
+        $parentEventId = CRM_Core_BAO_RecurringEntity::getParentFor($formValues['entity_id'], $formValues['entity_table']);
+      }
+
+      //Check if there is any enddate column defined to find out the interval between the two range
+      if (CRM_Utils_Array::value('intervalDateColumns', CRM_Core_BAO_RecurringEntity::$_dateColumns[$formValues['entity_table']])) {
+        $daoName = CRM_Core_BAO_RecurringEntity::$_tableDAOMapper[$formValues['entity_table']];
+        if ($parentEventId) {
+          $startDate = CRM_Core_DAO::getFieldValue($daoName, $parentEventId, $startDateColumnName);
+          $endDate = CRM_Core_DAO::getFieldValue($daoName, $parentEventId, $endDateColumnName);
+        }
+        if ($endDate) {
+          $interval = $recursion->getInterval($startDate, $endDate);
+          $recursion->intervalDateColumns = array($endDateColumnName => $interval);
+        }
+      }
+
+      $dates = $recursion->generateRecursiveDates();
+
+      foreach ($dates as $key => &$value) {
+        if ($startDateColumnName) {
+          $value['start_date'] = CRM_Utils_Date::customFormat($value[$startDateColumnName]);
+        }
+        if ($endDateColumnName && !empty($value[$endDateColumnName])) {
+          $value['end_date'] = CRM_Utils_Date::customFormat($value[$endDateColumnName]);
+          $endDates = TRUE;
+        }
+      }
+
+      //Show the list of participants registered for the events if any
+      if ($formValues['entity_table'] == "civicrm_event" && !empty($parentEventId)) {
+        $getConnectedEntities = CRM_Core_BAO_RecurringEntity::getEntitiesForParent($parentEventId, 'civicrm_event', TRUE);
+        if ($getConnectedEntities) {
+          $participantDetails = CRM_Event_Form_ManageEvent_Repeat::getParticipantCountforEvent($getConnectedEntities);
+          if (!empty($participantDetails['countByName'])) {
+            $this->assign('participantData', $participantDetails['countByName']);
+          }
+        }
+      }
+    }
+    $this->assign('dates', $dates);
+    $this->assign('endDates', !empty($endDates));
+
+    return parent::run();
+  }
+
+}
index b7273e435030d82b4649f2e8cfa72124451ba41a..fff91f827426df8df3bfd5a068047dd102920ab6 100644 (file)
@@ -968,18 +968,21 @@ class CRM_Core_SelectValues {
   /**
    * Frequency unit for schedule reminders.
    *
+   * @param int $count
+   *   For pluralization
    * @return array
    */
-  public static function getScheduleReminderFrequencyUnits() {
-    //@todo update schema to refer to option group direct & remove this
-    static $scheduleReminderFrequencyUnits = NULL;
-    if (!$scheduleReminderFrequencyUnits) {
-      $scheduleReminderFrequencyUnits = array(
-        'hour' => ts('hour'),
-      ) + CRM_Core_OptionGroup::values('recur_frequency_units');
-    }
-
-    return $scheduleReminderFrequencyUnits;
+  public static function getRecurringFrequencyUnits($count = 1) {
+    // @todo this used to refer to the 'recur_frequency_unit' option_values which
+    // is for recurring payments and probably not good to re-use for recurring entities.
+    // If something other than a hard-coded list is desired, add a new option_group.
+    return array(
+      'hour' => ts('hour', array('plural' => 'hours', 'count' => $count)),
+      'day' => ts('day', array('plural' => 'days', 'count' => $count)),
+      'week' => ts('week', array('plural' => 'weeks', 'count' => $count)),
+      'month' => ts('month', array('plural' => 'months', 'count' => $count)),
+      'year' => ts('year', array('plural' => 'years', 'count' => $count)),
+    );
   }
 
 }
index d070f3e939f10c1e58dc418bef5916f11e3e08d4..ec044bcaa93ff1dd57c665ba4cb58c24514fab0b 100644 (file)
@@ -59,15 +59,19 @@ function smarty_function_help($params, &$smarty) {
   $params['file'] = str_replace(array('.tpl', '.hlp'), '', $params['file']);
 
   if (empty($params['title'])) {
-    // Avod overwriting existing vars CRM-11900
-    $oldID = $smarty->get_template_vars('id');
+    $vars = $smarty->get_template_vars();
     $smarty->assign('id', $params['id'] . '-title');
     $name = trim($smarty->fetch($params['file'] . '.hlp'));
     $additionalTPLFile = $params['file'] . '.extra.hlp';
     if ($smarty->template_exists($additionalTPLFile)) {
       $name .= trim($smarty->fetch($additionalTPLFile));
     }
-    $smarty->assign('id', $oldID);
+    // Ensure we didn't change any existing vars CRM-11900
+    foreach ($vars as $key => $value) {
+      if ($smarty->get_template_vars($key) !== $value) {
+        $smarty->assign($key, $value);
+      }
+    }
   }
   else {
     $name = trim(strip_tags($params['title']));
index 8de633f0808a93a3775001c2398a22a0bd648fbf..f6703f958f58c10c889a73614591b78a7157ce1f 100644 (file)
      <access_arguments>access CiviCRM,access CiviEvent</access_arguments>
   </item>
   <item>
-     <path>civicrm/ajax/recurringentity/generate-preview</path>
-     <page_callback>CRM_Core_Page_AJAX_RecurringEntity::generatePreview</page_callback>
+     <path>civicrm/recurringentity/preview</path>
+     <page_callback>CRM_Core_Page_RecurringEntityPreview</page_callback>
      <access_arguments>access CiviCRM,access CiviEvent</access_arguments>
+     <title>Confirm dates</title>
   </item>
   <item>
     <path>civicrm/ajax/l10n-js</path>
index f8dca07695b542eb85c1cdf74789157a911f5fd0..32befd8c0ab9ffd19084411b117acbed304e229e 100644 (file)
@@ -390,7 +390,7 @@ class CRM_Dedupe_BAO_RuleGroup extends CRM_Dedupe_DAO_RuleGroup {
   public static function dedupeRuleFieldsWeight($params) {
     $rgBao = new CRM_Dedupe_BAO_RuleGroup();
     $rgBao->contact_type = $params['contact_type'];
-    if (CRM_Utils_Array::value('id', $params)) {
+    if (!empty($params['id'])) {
       // accept an ID if provided
       $rgBao->id = $params['id'];
     }
index 71e00a39815cd57bc0f677d2a47799e9e70aa248..035b0b488dc239e47ad22ce6ca5adc8f31c96f4e 100644 (file)
@@ -97,6 +97,7 @@ class CRM_Event_Form_ManageEvent extends CRM_Core_Form {
     if (in_array('CiviEvent', $config->enableComponents)) {
       $this->assign('CiviEvent', TRUE);
     }
+    CRM_Core_Form_RecurringEntity::preProcess('civicrm_event');
 
     $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'add', 'REQUEST');
 
index c5da44b37cd1db6a396fa3e32b67120e07529a8c..2d9919092b358a154571c7d51f61313f040fe393 100644 (file)
@@ -25,7 +25,6 @@ class CRM_Event_Form_ManageEvent_Repeat extends CRM_Event_Form_ManageEvent {
 
   public function preProcess() {
     parent::preProcess();
-    CRM_Core_Form_RecurringEntity::preProcess('civicrm_event');
     $this->assign('currentEventId', $this->_id);
 
     $checkParentExistsForThisId = CRM_Core_BAO_RecurringEntity::getParentFor($this->_id, 'civicrm_event');
@@ -76,7 +75,7 @@ class CRM_Event_Form_ManageEvent_Repeat extends CRM_Event_Form_ManageEvent {
    * the default values are retrieved from the database
    *
    *
-   * @return void
+   * @return array
    */
   public function setDefaultValues() {
     $defaults = array();
@@ -84,11 +83,8 @@ class CRM_Event_Form_ManageEvent_Repeat extends CRM_Event_Form_ManageEvent {
     //Always pass current event's start date by default
     $currentEventStartDate = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $this->_id, 'start_date', 'id');
     list($defaults['repetition_start_date'], $defaults['repetition_start_date_time']) = CRM_Utils_Date::setDateDefaults($currentEventStartDate, 'activityDateTime');
-    $defaults['allowRepeatConfigToSubmit'] = 1;
-    $recurringEntityDefaults = array();
     $recurringEntityDefaults = CRM_Core_Form_RecurringEntity::setDefaultValues();
-    $defaults = array_merge($defaults, $recurringEntityDefaults);
-    return $defaults;
+    return array_merge($defaults, $recurringEntityDefaults);
   }
 
   public function buildQuickForm() {
index 178fbea43e5df92d80077b95ecc0389cb685d750..7aa096163b290102e87732674b499d7284884e8e 100644 (file)
@@ -241,7 +241,7 @@ class CRM_Event_Form_ParticipantFeeSelection extends CRM_Core_Form {
     CRM_Event_BAO_Participant::changeFeeSelections($params, $this->_participantId, $this->_contributionId, $feeBlock, $lineItems, $this->_paidAmount, $params['priceSetId']);
     $this->contributionAmt = CRM_Core_DAO::getFieldValue('CRM_Contribute_BAO_Contribution', $this->_contributionId, 'total_amount');
     // email sending
-    if (CRM_Utils_Array::value('send_receipt', $params)) {
+    if (!empty($params['send_receipt'])) {
       $fetchParticipantVals = array('id' => $this->_participantId);
       CRM_Event_BAO_Participant::getValues($fetchParticipantVals, $participantDetails, CRM_Core_DAO::$_nullArray);
       $participantParams = array_merge($params, $participantDetails[$this->_participantId]);
index f10860f4767f2000d4bf2576f44184cc066709df..db3abfba0ebde5c512b987f473ebc60c520c738f 100644 (file)
@@ -378,22 +378,22 @@ class CRM_Grant_BAO_Query {
     $form->addDate('grant_application_received_date_low', ts('App. Received Date - From'), FALSE, array('formatType' => 'searchDate'));
     $form->addDate('grant_application_received_date_high', ts('To'), FALSE, array('formatType' => 'searchDate'));
 
-    $form->addElement('checkbox', 'grant_application_received_notset', ts(''), NULL);
+    $form->addElement('checkbox', 'grant_application_received_notset', '', NULL);
 
     $form->addDate('grant_money_transfer_date_low', ts('Money Sent Date - From'), FALSE, array('formatType' => 'searchDate'));
     $form->addDate('grant_money_transfer_date_high', ts('To'), FALSE, array('formatType' => 'searchDate'));
 
-    $form->addElement('checkbox', 'grant_money_transfer_date_notset', ts(''), NULL);
+    $form->addElement('checkbox', 'grant_money_transfer_date_notset', '', NULL);
 
     $form->addDate('grant_due_date_low', ts('Report Due Date - From'), FALSE, array('formatType' => 'searchDate'));
     $form->addDate('grant_due_date_high', ts('To'), FALSE, array('formatType' => 'searchDate'));
 
-    $form->addElement('checkbox', 'grant_due_date_notset', ts(''), NULL);
+    $form->addElement('checkbox', 'grant_due_date_notset', '', NULL);
 
     $form->addDate('grant_decision_date_low', ts('Grant Decision Date - From'), FALSE, array('formatType' => 'searchDate'));
     $form->addDate('grant_decision_date_high', ts('To'), FALSE, array('formatType' => 'searchDate'));
 
-    $form->addElement('checkbox', 'grant_decision_date_notset', ts(''), NULL);
+    $form->addElement('checkbox', 'grant_decision_date_notset', '', NULL);
 
     $form->addYesNo('grant_report_received', ts('Grant report received?'), TRUE);
 
index 577105ed32e3e6981291f20d868573e95c1d960c..e0a6e90f064af65f86a58555644a4b15bd6c91c7 100644 (file)
@@ -1068,7 +1068,7 @@ WHERE  id = %1";
     foreach ($params['price_set_id'] as $priceSetID) {
       CRM_Price_BAO_PriceSet::addTo('civicrm_' . $entityName, $entity->id, $priceSetID);
       //@todo - how should we do this - copied from form
-      //if (CRM_Utils_Array::value('price_field_id', $params)) {
+      //if (!empty($params['price_field_id'])) {
       //  $priceSetID = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceField', $params['price_field_id'], 'price_set_id');
       //  CRM_Price_BAO_PriceSet::setIsQuickConfig($priceSetID, 0);
       //}
index 3e184f5945f6b5c9d9702c6b2b2b20b8132493c2..dbd180330e64d1f23dae8cd6cc6c7db36caa88d7 100644 (file)
@@ -209,7 +209,7 @@ class CRM_Report_BAO_ReportInstance extends CRM_Report_DAO_ReportInstance {
         $chart = "&charts=" . $params['charts'];
       }
       $limitResult = NULL;
-      if (CRM_Utils_Array::value('row_count', $params)) {
+      if (!empty($params['row_count'])) {
         $limitResult = '&rowCount=' . $params['row_count'];
       }
       $dashletParams['name'] = "report/{$instance->id}";
index e6d27cbe1dc9195f7548086bbf16c67fa833204d..aeda5995555c404fd85b50f8fcf82945fa6269ed 100644 (file)
@@ -232,7 +232,7 @@ class CRM_Upgrade_Form extends CRM_Core_Form {
    * @return string
    */
   public function getFieldsetTitle() {
-    return ts('');
+    return '';
   }
 
   /**
index 7b0c581dd790dad273549fe9c6ca2b9294358974..c67998883243029181c923eaf29aa187f845ced1 100644 (file)
@@ -282,6 +282,8 @@ input.crm-form-entityref {
 }
 
 .crm-container input.crm-form-text[disabled],
+.crm-container input.dateplugin[disabled],
+.crm-container select.crm-form-select[disabled],
 .crm-container input.crm-form-text[readonly] {
   background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(1%, #ddd), color-stop(15%, #f2f2f2));
   background-image: -webkit-linear-gradient(top, #ddd 1%, #f2f2f2 15%);
@@ -289,6 +291,12 @@ input.crm-form-entityref {
   background-image: linear-gradient(top, #ddd 1%, #f2f2f2 15%);
 }
 
+.crm-container input.crm-form-text[disabled],
+.crm-container input.dateplugin[disabled],
+.crm-container select.crm-form-select[disabled] {
+  color: #a9a9a9;
+}
+
 .crm-container .crm-form-submit {
   margin: .25em 0.5em 0.25em 0;
 }
@@ -4010,29 +4018,6 @@ span.crm-status-icon {
   background: url("../i/loading-overlay.gif") center center no-repeat white !important;
 }
 
-/* Recurring Dialog */
-.crm-container .recurring-dialog-inner-wrapper {
-  display: inline-block;
-  width: 100%;
-}
-.crm-container .recurring-dialog-inner-left{
-  width: 30%;
-  float: left;
-}
-.crm-container .recurring-dialog-inner-right{
-  width: 70%;
-  float: left;
-}
-.crm-container .recurring-dialog-button{
-  background: #f5f5f5;
-  background-image: -webkit-linear-gradient(top,#f5f5f5,#f1f1f1);
-  border: 1px solid rgba(0,0,0,0.1);
-  padding: 5px 8px;
-  text-align: center;
-  border-radius: 2px;
-  cursor: pointer;
-  font-size: 11px !important;
-}
 .crm-container table.mergecontact thead th {
   width:30%;
 }
index a03074f495e498d6f06a6f265fe671b52515f46d..737bc89fa0523114b3d1b43c9f70c329dc743716 100644 (file)
@@ -1008,7 +1008,7 @@ CRM.strings = CRM.strings || {};
       message: ts('Are you sure you want to continue?'),
       url: null,
       width: 'auto',
-      modal: true,
+      height: 'auto',
       resizable: false,
       dialogClass: 'crm-container crm-confirm',
       close: function () {
@@ -1019,7 +1019,12 @@ CRM.strings = CRM.strings || {};
         yes: ts('Continue')
       }
     };
+    if (options && options.url) {
+      settings.resizable = true;
+      settings.height = '50%';
+    }
     $.extend(settings, ($.isFunction(options) ? arguments[1] : options) || {});
+    settings = CRM.utils.adjustDialogDefaults(settings);
     if (!settings.buttons && $.isPlainObject(settings.options)) {
       $.each(settings.options, function(op, label) {
         buttons.push({
index 8a8e74cc49e60a72bbb73228a208c57f74369386..7c22c3ddd97a8e9abdef8bc4df6b9a501cf3ead3 100644 (file)
     // Create new dialog
     if (settings.dialog) {
       settings.dialog = CRM.utils.adjustDialogDefaults(settings.dialog);
-      $('<div id="'+ settings.target.substring(1) +'"><div class="crm-loading-element">' + ts('Loading') + '...</div></div>').dialog(settings.dialog);
+      $('<div id="' + settings.target.substring(1) + '"></div>').dialog(settings.dialog);
+    }
+    if ($(settings.target).data('uiDialog')) {
       $(settings.target)
         .on('dialogclose', function() {
-          if ($(this).attr('data-unsaved-changes') !== 'true') {
+          if (settings.dialog && $(this).attr('data-unsaved-changes') !== 'true') {
             $(this).crmSnippet('destroy').dialog('destroy').remove();
           }
         })
index 096e6aa537f3741cd5d62cddfa4917aea5f9db73..77e8a3e7d45fbeac5439ab731fb660fe52559060 100644 (file)
   {if $action eq 2 OR $action eq 1}
     <tr class="crm-activity-form-block-recurring_activity">
       <td colspan="2">
-        {include file="CRM/Core/Form/RecurringEntity.tpl"}
-        {literal}
-          <script type="text/javascript">
-            CRM.$(function($) {
-              if ($('#activity_date_time').val() !== "" && $('#activity_date_time_time').val() !== "") {
-                $('#repetition_start_date, input[id^="repetition_start_date_display_"]').val($('#activity_date_time').val());
-                $('#repetition_start_date_time').val($('#activity_date_time_time').val());
-              }
-
-              $('input[id^="activity_date_time_display_"]').change(function() {
-                $('#repetition_start_date, input[id^="repetition_start_date_display_"]').val($('#activity_date_time').val());
-              });
-
-              $('#activity_date_time_time').change(function() {
-                $('#repetition_start_date_time').val($('#activity_date_time_time').val());
-              });
-
-              if ($('#start_action_offset').val() == "" && $('input[id^="repeat_absolute_date_display_"]').val() == "") {
-                $('#recurring-entity-block').addClass('collapsed');
-              }
-            });
-          </script>
-        {/literal}
-        {if $action eq 1}
-          {literal}
-            <script type="text/javascript">
-              CRM.$(function($) {
-                $('#recurring-entity-block div.crm-submit-buttons').css('display', 'none');
-              });
-            </script>
-          {/literal}
-        {/if}
+        {include file="CRM/Core/Form/RecurringEntity.tpl" recurringFormIsEmbedded=true}
       </td>
     </tr>
   {/if}
index dd1e55571b29afba74ca0ef1ed77f3cfc8b00b7c..476c65946b678136a315bef22be2595b84aff0bd 100644 (file)
   {ts}Repeats{/ts}
 {/htxt}
 {htxt id="id-repeats"}
-  {ts 1=$entityType}Access the drop-down menu here to select how frequently your %1 occurs. Options are:{/ts}
-  <ul>
-    <li>{ts}Hourly: repeats hourly or after every few hours{/ts}</li>
-    <li>{ts 1=$entityType}Daily: repeats daily or after every few days{/ts}</li>
-    <li>{ts 1=$entityType}Weekly: repeats on one or more days every week{/ts}</li>
-    <li>{ts 1=$entityType}Monthly: repeats on one or more days every month{/ts}</li>
-    <li>{ts 1=$entityType}Yearly: repeats yearly or after every few years{/ts}</li>
-  </ul>
-  {ts 1=$entityType}Example: You would select option "monthly", if your %1 occurs every month.{/ts}
-{/htxt}
-
-{htxt id="id-repeats-every-title"}
-  {ts}Repeats every{/ts}
-{/htxt}
-{htxt id="id-repeats-every"}
-  {ts}This option decides the repetition interval.{/ts}<br/>
-  {ts 1=$entityType}Example: If your %1 repeats every 5 months, then you would select option 5.{/ts}
+  {ts 1=$entityType}Access the drop-down menus here to select how frequently your %1 occurs.{/ts}
+  {ts 1=$entityType}Example: You would select options "1 month", if your %1 occurs every month.{/ts}
 {/htxt}
 
 {htxt id="id-repeats-on-title"}
@@ -76,7 +61,7 @@
 {/htxt}
 {htxt id="id-ends-after"}
   {ts 1=$entityType}Use this field to limit/end the repetition of the %1.{/ts}<br/>
-  {ts 1=$entityType}Example: If you want to repeat an %1 for six months (i.e it repeats 6 times), then set 6 as a value for this field.{/ts}
+  {ts 1=$entityType}Example: If you want to repeat an %1 6 times, then set 6 as a value for this field.{/ts}
 {/htxt}
 
 {htxt id="id-ends-on-title"}
index 2c1e36692287330651803e4dd50256cb57e896fb..c25626516ababb7c8158c3f921199770adcee19b 100644 (file)
  +--------------------------------------------------------------------+\r
 *}\r
 \r
-<div class="crm-core-form-recurringentity-block crm-accordion-wrapper" id="recurring-entity-block">\r
-    <div class="crm-accordion-header">\r
-      Repeat {if $entityType}{$entityType}{/if}\r
-    </div>\r
-    <div class="crm-accordion-body">\r
-        <div class="crm-submit-buttons">\r
-            {include file="CRM/common/formButtons.tpl" location="top"}\r
-        </div>\r
-        <table class="form-layout-compressed">\r
-          <tr class="crm-core-form-recurringentity-block-repetition_start_date" id="tr-repetition_start_date">\r
-            <td class="label">{$form.repetition_start_date.label}</td>\r
-            <td>{include file="CRM/common/jcalendar.tpl" elementName=repetition_start_date}</td>\r
-          </tr>\r
-          <tr class="crm-core-form-recurringentity-block-repetition_frequency_unit">\r
-            <td class="label">{$form.repetition_frequency_unit.label}&nbsp;<span class="crm-marker" title="This field is required.">*</span></td>\r
-            <td>{$form.repetition_frequency_unit.html} {help id="id-repeats" entityType=$entityType file="CRM/Core/Form/RecurringEntity.hlp"}</td>\r
-          </tr>\r
-          <tr class="crm-core-form-recurringentity-block-repetition_frequency_interval">\r
-            <td class="label">{$form.repetition_frequency_interval.label}&nbsp;<span class="crm-marker" title="This field is required.">*</span></td>\r
-            <td>{$form.repetition_frequency_interval.html} &nbsp;<span id="repeats-every-text">hour(s)</span> {help id="id-repeats-every" entityType=$entityType file="CRM/Core/Form/RecurringEntity.hlp"}</td>\r
-            </td>\r
-          </tr>\r
-          <tr class="crm-core-form-recurringentity-block-start_action_condition">\r
-            <td class="label">\r
-                <label for="repeats_on">{$form.start_action_condition.label}: </label>\r
-            </td>\r
-            <td>\r
-                {$form.start_action_condition.html} {help id="id-repeats-on" entityType=$entityType file="CRM/Core/Form/RecurringEntity.hlp"}</td>\r
-            </td>\r
-          </tr>\r
-          <tr class="crm-core-form-recurringentity-block-repeats_by">\r
-            <td class="label">{$form.repeats_by.label}</td>\r
-            <td>{$form.repeats_by.1.html}&nbsp;&nbsp;{$form.limit_to.html} {help id="id-repeats-by-month" entityType=$entityType file="CRM/Core/Form/RecurringEntity.hlp"}\r
-            </td>\r
-          </tr>\r
-          <tr class="crm-core-form-recurringentity-block-repeats_by">\r
-            <td class="label"></td>\r
-            <td>{$form.repeats_by.2.html}&nbsp;&nbsp;{$form.entity_status_1.html}&nbsp;&nbsp;{$form.entity_status_2.html} {help id="id-repeats-by-week" entityType=$entityType file="CRM/Core/Form/RecurringEntity.hlp"}\r
-            </td>\r
-          </tr>\r
-          <tr class="crm-core-form-recurringentity-block-ends">\r
-            <td class="label">{$form.ends.label}&nbsp;<span class="crm-marker" title="This field is required.">*</span></td>\r
-            <td>{$form.ends.1.html}&nbsp;{$form.start_action_offset.html}&nbsp;occurrences&nbsp;{help id="id-ends-after" entityType=$entityType file="CRM/Core/Form/RecurringEntity.hlp"}</td>\r
-          </tr>\r
-          <tr class="crm-core-form-recurringentity-block-absolute_date">\r
-              <td class="label"></td>\r
-              <td>{$form.ends.2.html}&nbsp;{include file="CRM/common/jcalendar.tpl" elementName=repeat_absolute_date} {help id="id-ends-on" entityType=$entityType file="CRM/Core/Form/RecurringEntity.hlp"}\r
-              </td>\r
-          </tr>\r
-          <tr class="crm-core-form-recurringentity-block-exclude_date">\r
-              <td class="label">{$form.exclude_date.label}</td>\r
-              <td>&nbsp;{include file="CRM/common/jcalendar.tpl" elementName=exclude_date}\r
-                  &nbsp;{$form.add_to_exclude_list.html}&nbsp;{$form.remove_from_exclude_list.html}\r
-                  {$form.exclude_date_list.html} {help id="id-exclude-date" entityType=$entityType file="CRM/Core/Form/RecurringEntity.hlp"}\r
-              </td>\r
-          </tr>\r
-          <tr>\r
-            <td class="label bold">{ts}Summary:{/ts}</td>\r
-            <td><span id="rec-summary"></span></td>\r
-          </tr>\r
-        </table>\r
+<div class="crm-core-form-recurringentity-block crm-accordion-wrapper{if $recurringFormIsEmbedded && !$scheduleReminderId} collapsed{/if}" id="recurring-entity-block">\r
+  <div class="crm-accordion-header">\r
+    {ts 1=$recurringEntityType}Repeat %1{/ts}\r
+  </div>\r
+  <div class="crm-accordion-body">\r
+    {if !$recurringFormIsEmbedded}\r
+      <div class="crm-submit-buttons">\r
+        {include file="CRM/common/formButtons.tpl" location="top"}\r
+      </div>\r
+    {/if}\r
+    <table class="form-layout-compressed">\r
+      <tr class="crm-core-form-recurringentity-block-repetition_start_date" id="tr-repetition_start_date">\r
+        <td class="label">{$form.repetition_start_date.label}</td>\r
+        <td>{include file="CRM/common/jcalendar.tpl" elementName=repetition_start_date}</td>\r
+      </tr>\r
+      <tr class="crm-core-form-recurringentity-block-repetition_frequency">\r
+        <td class="label">{$form.repetition_frequency_unit.label}&nbsp;<span class="crm-marker">*</span>  {help id="id-repeats" entityType=$recurringEntityType file="CRM/Core/Form/RecurringEntity.hlp"}</td>\r
+        <td>{$form.repetition_frequency_interval.html} {$form.repetition_frequency_unit.html}</td>\r
+      </tr>\r
+      <tr class="crm-core-form-recurringentity-block-start_action_condition">\r
+        <td class="label">\r
+          <label for="repeats_on">{$form.start_action_condition.label} {help id="id-repeats-on" entityType=$recurringEntityType file="CRM/Core/Form/RecurringEntity.hlp"}</label>\r
+        </td>\r
+        <td>\r
+          {$form.start_action_condition.html}\r
+        </td>\r
+      </tr>\r
+      <tr class="crm-core-form-recurringentity-block-repeats_by">\r
+        <td class="label">{$form.repeats_by.label} {help id="id-repeats-by-month" entityType=$recurringEntityType file="CRM/Core/Form/RecurringEntity.hlp"}</td>\r
+        <td>{$form.repeats_by.1.html}&nbsp;&nbsp;{$form.limit_to.html}\r
+        </td>\r
+      </tr>\r
+      <tr class="crm-core-form-recurringentity-block-repeats_by">\r
+        <td class="label">{help id="id-repeats-by-week" entityType=$recurringEntityType file="CRM/Core/Form/RecurringEntity.hlp"}</td>\r
+        <td>{$form.repeats_by.2.html}&nbsp;&nbsp;{$form.entity_status_1.html}&nbsp;&nbsp;{$form.entity_status_2.html}\r
+        </td>\r
+      </tr>\r
+      <tr class="crm-core-form-recurringentity-block-ends">\r
+        <td class="label">{$form.ends.label}&nbsp;<span class="crm-marker">*</span> {help id="id-ends-after" entityType=$recurringEntityType file="CRM/Core/Form/RecurringEntity.hlp"}</td>\r
+        <td>{$form.ends.1.html}&nbsp;{$form.start_action_offset.html} {ts}occurrences{/ts}</td>\r
+      </tr>\r
+      <tr class="crm-core-form-recurringentity-block-absolute_date">\r
+        <td class="label"> {help id="id-ends-on" entityType=$recurringEntityType file="CRM/Core/Form/RecurringEntity.hlp"}</td>\r
+        <td>{$form.ends.2.html}&nbsp;{include file="CRM/common/jcalendar.tpl" elementName=repeat_absolute_date}\r
+        </td>\r
+      </tr>\r
+      <tr class="crm-core-form-recurringentity-block-exclude_date">\r
+        <td class="label">{$form.exclude_date_list.label} {help id="id-exclude-date" entityType=$recurringEntityType file="CRM/Core/Form/RecurringEntity.hlp"}</td>\r
+        <td>{$form.exclude_date_list.html}</td>\r
+      </tr>\r
+    </table>\r
+    {if !$recurringFormIsEmbedded}\r
       <div class="crm-submit-buttons">\r
         {include file="CRM/common/formButtons.tpl" location="bottom"}\r
       </div>\r
-    </div>\r
-</div>\r
-<div id="preview-dialog" class="hiddenElement">\r
-    <div id="generated_dates" class="show-block"></div>\r
+    {/if}\r
+  </div>\r
 </div>\r
 {literal}\r
 <script type="text/javascript">\r
-  cj(document).ready(function() {\r
-    cj('#repetition_start_date_display').closest("tr").hide();\r
-    /****** On load "Repeats By" and "Repeats On" blocks should be hidden if dropdown value is not week or month****** (Edit Mode)***/\r
-    if (cj('#repetition_frequency_unit').val() == "week") {\r
-      cj('.crm-core-form-recurringentity-block-start_action_condition').show();\r
-      cj('.crm-core-form-recurringentity-block-repeats_by td').hide();\r
-    } else if (cj('#repetition_frequency_unit').val() == "month") {\r
-      cj('.crm-core-form-recurringentity-block-repeats_by td').show();\r
-      cj('.crm-core-form-recurringentity-block-start_action_condition').hide();\r
-    } else {\r
-      cj('.crm-core-form-recurringentity-block-start_action_condition').hide();\r
-      cj('.crm-core-form-recurringentity-block-repeats_by td').hide();\r
-    }\r
-    cj("#repeats-every-text").html(cj('#repetition_frequency_unit').val()+'(s)');\r
-\r
-    /***********On Load Set Ends Value (Edit Mode) **********/\r
-    if (cj('input:radio[name=ends]:checked').val() == 1) {\r
-      cj('#start_action_offset').removeAttr('disabled').attr('enabled','enabled');\r
-      cj('#repeat_absolute_date_display').removeAttr("enabled").attr('disabled','disabled');\r
-      cj('#repeat_absolute_date_display').val('');\r
-    } else if (cj('input:radio[name=ends]:checked').val() == 2) {\r
-      cj('#repeat_absolute_date_display').removeAttr("disabled").attr('enabled','enabled');\r
-      cj('#start_action_offset').removeAttr('enabled').attr('disabled','disabled');\r
-      cj('#start_action_offset').val('');\r
-    } else {\r
-      cj('#start_action_offset').removeAttr('enabled').attr('disabled','disabled');\r
-      cj('#repeat_absolute_date_display').removeAttr('enabled').attr('disabled','disabled');\r
+  CRM.$(function($) {\r
+    var $form = $('form.{/literal}{$form.formClass}{literal}');\r
+\r
+    // Prevent html5 errors\r
+    $form.attr('novalidate', 'novalidate');\r
+\r
+    function changeFrequencyUnit() {\r
+      switch ($(this).val()) {\r
+        case 'week':\r
+          //Show "Repeats On" block when week is selected\r
+          $('.crm-core-form-recurringentity-block-start_action_condition', $form).show();\r
+          $('.crm-core-form-recurringentity-block-repeats_by td', $form).hide();\r
+          break;\r
+        case 'month':\r
+          //Show "Repeats By" block when month is selected\r
+          $('.crm-core-form-recurringentity-block-start_action_condition', $form).hide();\r
+          $('.crm-core-form-recurringentity-block-repeats_by td', $form).show();\r
+          break;\r
+        default:\r
+          $('.crm-core-form-recurringentity-block-start_action_condition', $form).hide();\r
+          $('.crm-core-form-recurringentity-block-repeats_by td', $form).hide();\r
+      }\r
     }\r
+    $('#repetition_frequency_unit', $form).each(changeFrequencyUnit).change(changeFrequencyUnit);\r
 \r
-    /******On Load set Repeats by section******************/\r
-    if (cj('input:radio[name=repeats_by]:checked').val() == 1) {\r
-      cj('#limit_to').removeAttr('disabled').attr('enabled','enabled');\r
-      cj('#entity_status_1, #entity_status_2').removeAttr("enabled").attr('disabled','disabled');\r
-    } else if (cj('input:radio[name=repeats_by]:checked').val() == 2) {\r
-      cj('#entity_status_1, #entity_status_2').removeAttr("disabled").attr('enabled','enabled');\r
-      cj('#limit_to').removeAttr('enabled').attr('disabled','disabled');\r
-    } else {\r
-      //Just in-case block shows up, disable it\r
-      cj('#limit_to, #entity_status_1, #entity_status_2').removeAttr('enabled').attr('disabled','disabled');\r
+    function disableUnselected() {\r
+      $('input:radio[name=ends], input[name=repeats_by]', $form).not(':checked').siblings(':input').prop('disabled', true);\r
     }\r
+    disableUnselected();\r
 \r
-    cj('#repetition_frequency_unit').change(function () {\r
-      if (cj(this).val()==='hour') {\r
-        cj('#repeats-every-text').html(cj(this).val()+'(s)');\r
-        cj('.crm-core-form-recurringentity-block-start_action_condition').hide();\r
-        cj('.crm-core-form-recurringentity-block-repeats_by td').hide();\r
-      } else if (cj(this).val()==='day') {\r
-        cj('#repeats-every-text').html(cj(this).val()+'(s)');\r
-        cj('.crm-core-form-recurringentity-block-start_action_condition').hide();\r
-        cj('.crm-core-form-recurringentity-block-repeats_by td').hide();\r
-      } else if (cj(this).val()==='week') {\r
-        cj('#repeats-every-text').html(cj(this).val()+'(s)');\r
-        //Show "Repeats On" block when week is selected\r
-        cj('.crm-core-form-recurringentity-block-start_action_condition').show();\r
-        cj('.crm-core-form-recurringentity-block-repeats_by td').hide();\r
-      } else if (cj(this).val()==='month') {\r
-        cj('#repeats-every-text').html(cj(this).val()+'(s)');\r
-        cj('.crm-core-form-recurringentity-block-start_action_condition').hide();\r
-        //Show "Repeats By" block when month is selected\r
-        cj('.crm-core-form-recurringentity-block-repeats_by td').show();\r
-      } else if (cj(this).val()==='year') {\r
-        cj('#repeats-every-text').html(cj(this).val()+'(s)');\r
-        cj('.crm-core-form-recurringentity-block-start_action_condition').hide();\r
-        cj('.crm-core-form-recurringentity-block-repeats_by td').hide();\r
-      }\r
-    });\r
-\r
-    // For "Ends" block\r
-    cj('input:radio[name=ends]').click(function() {\r
-      if (cj(this).val() == 1) {\r
-        cj('#start_action_offset').removeAttr('disabled').attr('enabled','enabled');\r
-        cj('#repeat_absolute_date_display').val('');\r
-      } else if (cj(this).val() == 2) {\r
-        cj('#repeat_absolute_date_display').removeAttr('disabled').attr('enabled','enabled');\r
-        cj('#start_action_offset').val('');\r
-      } else {\r
-        cj('#repeat_absolute_date_display').removeAttr('enabled').attr('disabled','disabled');\r
-      }\r
-    });\r
-\r
-    //For "Repeats By" block\r
-    cj('input:radio[name=repeats_by]').click(function() {\r
-      if (cj(this).val() == 1) {\r
-        cj('#limit_to').removeAttr('disabled').attr('enabled','enabled');\r
-      } else {\r
-        cj('#limit_to').removeAttr('enabled').attr('disabled','disabled');\r
-      }\r
-      if (cj(this).val() == 2) {\r
-        cj('#entity_status_1').removeAttr('disabled').attr('enabled','enabled');\r
-        cj('#entity_status_2').removeAttr('disabled').attr('enabled','enabled');\r
-      } else {\r
-        cj('#entity_status_1').removeAttr('enabled').attr('disabled','disabled');\r
-        cj('#entity_status_2').removeAttr('enabled').attr('disabled','disabled');\r
-      }\r
+    $('input:radio[name=ends], input[name=repeats_by]', $form).click(function() {\r
+      $(this).siblings(':input').prop('disabled', false).filter(':visible').addClass('required').focus();\r
+      disableUnselected();\r
     });\r
 \r
-    //Select all options in selectbox before submitting\r
-    cj(this).submit(function() {\r
-      cj('#exclude_date_list option').attr('selected',true);\r
-\r
-      //Check form for values submitted\r
-      if (cj('input[name=ends]:checked').val() == 1) {\r
-        if (cj('#start_action_offset').val() == "") {\r
-          if (!cj('span#start_action_offset-error').length) {\r
-              cj('#start_action_offset').after('<span id ="start_action_offset-error" class="crm-error"> This is a required field.</span>');\r
-              //Check if other message already present, hide it\r
-              cj('span#repeat_absolute_date_display-error').toggle();\r
-          }\r
-          return false;\r
-        }\r
-      } else if (cj('input[name=ends]:checked').val() == 2) {\r
-        if (cj('#repeat_absolute_date_display').val() == "") {\r
-          if (!cj('span#repeat_absolute_date_display-error').length) {\r
-            cj('#repeat_absolute_date_display').after('<span id="repeat_absolute_date_display-error" class="crm-error"> This is a required field.</span>');\r
-            //Check if other message already present, hide it\r
-            cj('span#start_action_offset-error').toggle();\r
-          }\r
-          return false;\r
-        }\r
-      }\r
-\r
-    });\r
+    function validate() {\r
+      var valid = $(':input', '#recurring-entity-block').valid(),\r
+        modified = CRM.utils.initialValueChanged('#recurring-entity-block');\r
+      $('#allowRepeatConfigToSubmit', $form).val(valid && modified ? '1' : '0');\r
+      return valid;\r
+    }\r
 \r
-    //Detect changes in Repeat configuration field\r
-    var unsavedChanges = false;\r
-    cj('div.crm-core-form-recurringentity-block').on('change', function() {\r
-      unsavedChanges = true;\r
-    });\r
+    function getDisplayDate(date) {\r
+      return $.datepicker.formatDate(CRM.config.dateInputFormat, $.datepicker.parseDate('yy-mm-dd', date));\r
+    }\r
 \r
-    //If there are changes in repeat configuration, enable save button\r
-    //Dialog for preview repeat Configuration dates\r
-    cj('#preview-dialog').dialog({ autoOpen: false });\r
-    function previewDialog() {\r
-        cj('#exclude_date_list option').attr('selected',true);\r
-        //Copy exclude dates\r
-        var dateTxt=[];\r
-        cj('#exclude_date_list option:selected').each(function() {\r
-            dateTxt.push(cj(this).text());\r
+    // Combine select2 and datepicker into a multi-select-date widget\r
+    $('#exclude_date_list', $form).crmSelect2({\r
+      multiple: true,\r
+      data: [],\r
+      initSelection: function(element, callback) {\r
+        var values = [];\r
+        $.each($(element).val().split(','), function(k, v) {\r
+          values.push({\r
+            text: getDisplayDate(v),\r
+            id: v\r
+          });\r
         });\r
-        var completeDateText = dateTxt.join(',');\r
-        cj('#copyExcludeDates').val(completeDateText);\r
-\r
-        cj('#generated_dates').html('').html('<div class="crm-loading-element"><span class="loading-text">{/literal}{ts escape='js'}Just a moment, generating dates{/ts}{literal}...</span></div>');\r
-        cj('#preview-dialog').dialog('open');\r
-        cj('#preview-dialog').dialog({\r
-          title: 'Confirm dates',\r
-          width: '650',\r
-          position: 'center',\r
-          //draggable: false,\r
-          buttons: {\r
-            Ok: function() {\r
-                cj(this).dialog( "close" );\r
-                cj('form#Repeat, form#Activity').submit();\r
-            },\r
-            Cancel: function() { //cancel\r
-                cj(this).dialog( "close" );\r
+        callback(values);\r
+      }\r
+    })\r
+      .on('select2-opening', function(e) {\r
+        var $el = $(this);\r
+        // Prevent select2 from opening and show a datepicker instead\r
+        e.preventDefault();\r
+        $('.select2-search-field input', $el.select2('container'))\r
+          .datepicker()\r
+          .datepicker('show')\r
+          .off('.crmDate')\r
+          .on('change.crmDate', function() {\r
+            if ($(this).val()) {\r
+              var date = $(this).datepicker('getDate'),\r
+                data = $el.select2('data') || [];\r
+              data.push({\r
+                text: $.datepicker.formatDate(CRM.config.dateInputFormat, date),\r
+                id: $.datepicker.formatDate('yy-mm-dd', date)\r
+              });\r
+              $el.select2('data', data);\r
             }\r
-          }\r
-        });\r
-        var ajaxurl = CRM.url("civicrm/ajax/recurringentity/generate-preview");\r
-        var entityID = parseInt('{/literal}{$currentEntityId}{literal}');\r
-        var entityTable = '{/literal}{$entityTable}{literal}';\r
-        if (entityTable != "") {\r
-          ajaxurl += "?entity_table="+entityTable;\r
-        }\r
-        if (entityID != "") {\r
-          ajaxurl += "&entity_id="+entityID;\r
-        }\r
-        var formData = cj('form').serializeArray();\r
-        cj.ajax({\r
-          dataType: "json",\r
-          type: "POST",\r
-          data: formData,\r
-          url:  ajaxurl,\r
-          success: function (result) {\r
-            if (Object.keys(result).length > 0) {\r
-              var errors = [];\r
-              var participantData = [];\r
-              var html = 'Based on your repeat configuration, here is the list of dates. Do you wish to create a recurring set with these dates?<br/><table id="options" class="display"><thead><tr><th></th><th>Start date</th><th id="th-end-date">End date</th></tr><thead>';\r
-              var count = 1;\r
-              for(var i in result) {\r
-                if (i != 'errors') {\r
-                  if (i == 'participantData') {\r
-                    participantData = result.participantData;\r
-                    break;\r
-                  }\r
-                  var start_date = result[i].start_date;\r
-                  var end_date = result[i].end_date;\r
+          });\r
+      });\r
 \r
-                  var end_date_text = '';\r
-                  if (end_date !== undefined) {\r
-                    end_date_text = '<td>'+end_date+'</td>';\r
-                  }\r
-                  html += '<tr><td>'+count+'</td><td>'+start_date+'</td>'+end_date_text+'</tr>';\r
-                  count = count + 1;\r
-                } else {\r
-                  errors = result.errors;\r
-                }\r
-              }\r
-              html += '</table>';\r
-              var warningHtml = '';\r
-              if (Object.keys(participantData).length > 0) {\r
-                warningHtml += '<div class="messages status no-popup"><div class="icon inform-icon"></div>&nbsp;There are registrations for the repeating events already present in the set, continuing with the process would unlink them and repeating events without registration would be trashed. </div><table id="options" class="display"><thead><tr><th>Event ID</th><th>Event</th><th>Participant Count</th></tr><thead>';\r
-                for (var id in participantData) {\r
-                  for(var data in participantData[id]) {\r
-                  warningHtml += '<tr><td>'+id+'</td><td> <a href="{/literal}{crmURL p="civicrm/event/manage/settings" q="reset=1&action=update&id="}{literal}'+id+'{/literal}{literal}">'+data+'</a></td><td><a href="{/literal}{crmURL p='civicrm/event/search' q="reset=1&force=1&status=true&event="}{literal}'+id+'{/literal}{literal}">'+participantData[id][data]+'</a></td></tr>';\r
-                  }\r
-                }\r
-                warningHtml += '</table><br/>';\r
-              }\r
-              if (errors.length > 0) {\r
-                html = '';\r
-                for (var j = 0; j < errors.length; j++) {\r
-                  html += '<span class="crm-error">*&nbsp;' + errors[j] + '</span><br/>';\r
-                }\r
-              }\r
-              if (warningHtml != "") {\r
-                cj('#generated_dates').append(warningHtml).append(html);\r
-              } else {\r
-                cj('#generated_dates').html(html);\r
-              }\r
-              if (end_date_text == "") {\r
-                cj('#th-end-date').hide();\r
-              }\r
-              if (cj("#preview-dialog").height() >= 300) {\r
-                cj('#preview-dialog').css('height', '300');\r
-                cj('#preview-dialog').css('overflow-y', 'auto');\r
-              }\r
-            } else {\r
-              cj('div.ui-dialog-buttonset button span:contains(Ok)').hide();\r
-              cj('#generated_dates').append("<span class='crm-error'>Sorry, no dates could be generated for the given criteria!</span>");\r
-            }\r
-          },\r
-          complete: function() {\r
-            cj('div.crm-loading-element').hide();\r
-          }\r
+    // Dialog for preview repeat Configuration dates\r
+    function previewDialog() {\r
+      // Set default value for start date on activity forms before generating preview\r
+      if (!$('#repetition_start_date', $form).val() && $('#activity_date_time', $form).val()) {\r
+        $('#repetition_start_date', $form)\r
+          .val($('#activity_date_time', $form).val())\r
+          .next().val($('#activity_date_time', $form).next().val())\r
+          .siblings('.hasTimeEntry').val($('#activity_date_time', $form).siblings('.hasTimeEntry').val());\r
+      }\r
+      var payload = $form.serialize() + '{/literal}&entity_table={$entityTable}&entity_id={$currentEntityId}{literal}';\r
+      CRM.confirm({\r
+        width: '50%',\r
+        url: CRM.url("civicrm/recurringentity/preview", payload)\r
+      }).on('crmConfirm:yes', function() {\r
+          $form.submit();\r
         });\r
-        return false;\r
     }\r
 \r
-    cj('#_qf_Repeat_submit-top, #_qf_Repeat_submit-bottom').click( function () {\r
-      return previewDialog();\r
+    $('#_qf_Repeat_submit-top, #_qf_Repeat_submit-bottom').click(function (e) {\r
+      if (validate()) {\r
+        previewDialog();\r
+      }\r
+      e.preventDefault();\r
     });\r
 \r
-    cj('#_qf_Activity_upload-top, #_qf_Activity_upload-bottom').click( function () {\r
-      //Process this only when repeat is configured. We need to do this test here as there is a common save for activity.\r
-      var isRepeatConfigured = '{/literal}{$scheduleReminderId}{literal}';\r
-      if (isRepeatConfigured) {\r
-         if (unsavedChanges) {\r
-          cj('#allowRepeatConfigToSubmit').val('1');\r
-          //Set this variable to decide which dialog box to show\r
-          cj.data( document.body, "preview-dialog", true );\r
-          return previewDialog();\r
-        }\r
-        else {\r
-          cj.data( document.body, "preview-dialog", false );\r
-          return false;\r
-        }\r
-      }\r
-      else {\r
-        if (unsavedChanges) {\r
-          cj('#allowRepeatConfigToSubmit').val('1');\r
-          return previewDialog();\r
+    $('#_qf_Activity_upload-top, #_qf_Activity_upload-bottom').click(function (e) {\r
+      if (CRM.utils.initialValueChanged('#recurring-entity-block')) {\r
+        e.preventDefault();\r
+        if (validate()) {\r
+          previewDialog();\r
         }\r
       }\r
     });\r
 \r
-    //Build Summary\r
-    var finalSummary = '';\r
-    var numberText = '';\r
-    var interval = cj('#repetition_frequency_interval').val() + ' ';\r
-    if (cj('#repetition_frequency_interval').val() == 1) {\r
-      interval = '';\r
-    } else {\r
-      numberText = 's';\r
-    }\r
-    finalSummary = "Every " + interval + cj('#repetition_frequency_unit option:selected').val() + numberText;\r
-\r
-    //Case Week\r
-    var dayOfWeek = new Array();\r
-    if (cj('#repetition_frequency_unit option:selected').val() == "week") {\r
-      cj("input[name^='start_action_condition']:checked").each(function() {\r
-        var tempArray = new Array();\r
-        var thisID = cj(this).attr('id');\r
-        tempArray = thisID.split('_');\r
-        dayOfWeek.push(tempArray[3].substr(0, 1).toUpperCase() + tempArray[3].substr(1).toLowerCase());\r
-      });\r
-      finalSummary += ' on ' + dayOfWeek.join();\r
-    }\r
-\r
-    //Case Monthly\r
-    if (cj('#repetition_frequency_unit option:selected').val() == "month") {\r
-      if (cj('input:radio[name=repeats_by]:checked').val() == 1) {\r
-        finalSummary += ' on day ' + cj('#limit_to').val();\r
-      }\r
-      if (cj('input:radio[name=repeats_by]:checked').val() == 2) {\r
-        finalSummary += ' on ' + cj('#entity_status_1').val().substr(0, 1).toUpperCase() + cj('#entity_status_1').val().substr(1).toLowerCase() + ' ' + cj('#entity_status_2').val().substr(0, 1).toUpperCase() + cj('#entity_status_2').val().substr(1).toLowerCase();\r
-      }\r
-    }\r
+    // Enable/disable form buttons when not embedded in another form\r
+    $form.on('change', function() {\r
+      $('#_qf_Repeat_submit-top, #_qf_Repeat_submit-bottom').prop('disabled', !CRM.utils.initialValueChanged('#recurring-entity-block'));\r
+    });\r
 \r
-    //Case Ends\r
-    if (cj('input:radio[name=ends]:checked').val() == 1) {\r
-      var timeText = ''\r
-      if (cj('#start_action_offset').val() != 1) {\r
-        timeText = cj('#start_action_offset').val() + ' times';\r
-      } else {\r
-        timeText = ' once';\r
-      }\r
-      finalSummary += ', ' + timeText;\r
-    }\r
-    if (cj('input:radio[name=ends]:checked').val() == 2) {\r
-      var monthNames = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");\r
-      var date = new Date(cj('#repeat_absolute_date_display').val());\r
-      function addOrdinal(d) {\r
-        if (d>3 && d<21) return 'th';\r
-        switch (d % 10) {\r
-          case 1:  return "st";\r
-          case 2:  return "nd";\r
-          case 3:  return "rd";\r
-          default: return "th";\r
-        }\r
-      }\r
-      var newDate = monthNames[(date.getMonth())] + ' ' + date.getDate()+ addOrdinal() + ' ' +  date.getFullYear();\r
-      finalSummary += ', untill '+ newDate;\r
+    // Pluralize frequency options\r
+    var recurringFrequencyOptions = {/literal}{$recurringFrequencyOptions|@json_encode}{literal};\r
+    function pluralizeUnits() {\r
+      CRM.utils.setOptions($('[name=repetition_frequency_unit]', $form),\r
+        $(this).val() === '1' ? recurringFrequencyOptions.single : recurringFrequencyOptions.plural);\r
     }\r
+    $('[name=repetition_frequency_interval]', $form).each(pluralizeUnits).change(pluralizeUnits);\r
 \r
-    //Build/Attach final Summary\r
-    cj('#rec-summary').html(finalSummary);\r
-\r
-});\r
-\r
-  //Exclude list function\r
-  function addToExcludeList(val) {\r
-    if (val !== "") {\r
-      var exists = false;\r
-      for(var i = 0, opts = document.getElementById('exclude_date_list').options; i < opts.length; ++i) {\r
-        if (opts[i].text == val) {\r
-          exists = true;\r
-          break;\r
-        }\r
-      }\r
-      if (exists == false) {\r
-        cj('#exclude_date_list').append('<option>'+val+'</option>');\r
-      }\r
-    }\r
-  }\r
+  });\r
 \r
-  function removeFromExcludeList(sourceID) {\r
-    var src = document.getElementById(sourceID);\r
-    for(var count= src.options.length-1; count >= 0; count--) {\r
-      if (src.options[count].selected == true) {\r
-        try{\r
-          src.remove(count, null);\r
-        }catch(error) {\r
-          src.remove(count);\r
-        }\r
-      }\r
-    }\r
-  }\r
 </script>\r
 {/literal}\r
-{*Hide Summary*}\r
-{if empty($scheduleReminderId)}\r
-    {literal}\r
-        <script type="text/javascript">\r
-        cj(document).ready(function() {\r
-            if (cj('#rec-summary').length) {\r
-                cj('#rec-summary').parent().parent().hide();\r
-            }\r
-        });\r
-        </script>\r
-    {/literal}\r
-{/if}\r
diff --git a/templates/CRM/Core/Page/RecurringEntityPreview.tpl b/templates/CRM/Core/Page/RecurringEntityPreview.tpl
new file mode 100644 (file)
index 0000000..7451cff
--- /dev/null
@@ -0,0 +1,68 @@
+{*
+ +--------------------------------------------------------------------+
+ | CiviCRM version 4.6                                                |
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC (c) 2004-2014                                |
+ +--------------------------------------------------------------------+
+ | This file is a part of CiviCRM.                                    |
+ |                                                                    |
+ | CiviCRM is free software; you can copy, modify, and distribute it  |
+ | under the terms of the GNU Affero General Public License           |
+ | Version 3, 19 November 2007 and the CiviCRM Licensing Exception.   |
+ |                                                                    |
+ | CiviCRM is distributed in the hope that it will be useful, but     |
+ | WITHOUT ANY WARRANTY; without even the implied warranty of         |
+ | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.               |
+ | See the GNU Affero General Public License for more details.        |
+ |                                                                    |
+ | You should have received a copy of the GNU Affero General Public   |
+ | License and the CiviCRM Licensing Exception along                  |
+ | with this program; if not, contact CiviCRM LLC                     |
+ | at info[AT]civicrm[DOT]org. If you have questions about the        |
+ | GNU Affero General Public License or the licensing of CiviCRM,     |
+ | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
+ +--------------------------------------------------------------------+
+*}
+{if !empty($participantData)}
+  <div class="messages status no-popup">
+    <div class="icon ui-icon-alert"></div>
+    {ts}There are participants registered for repeating events being removed from the set. Those with participants will be converted to standalone events, and those without registration will be deleted.{/ts}
+  </div>
+  <table class="display">
+    <thead><tr>
+      <th>{ts}Event ID{/ts}</th>
+      <th>{ts}Event{/ts}</th>
+      <th>{ts}Participant Count{/ts}</th>
+    </tr><thead>
+    <tbody>
+      {foreach from=$participantData item="row" key="id"}
+        {foreach from=$row item="count" key="data"}
+          <tr class="{cycle values="odd-row,even-row"}">
+            <td>{$id}</td>
+            <td><a href="{crmURL p="civicrm/event/manage/settings" q="reset=1&action=update&id=$id"}">{$data}</a></td>
+            <td><a href="{crmURL p='civicrm/event/search' q="reset=1&force=1&status=true&event=$id"}">{$count}</a></td>
+          </tr>
+        {/foreach}
+      {/foreach}
+    </tbody>
+{/if}
+
+<h3>
+  {ts}A recurring set will be created with the following dates.{/ts}
+</h3>
+<table class="display row-highlight">
+  <thead><tr>
+    <th>#</th>
+    <th>{ts}Start date{/ts}</th>
+    {if $endDates}<th>{ts}End date{/ts}</th>{/if}
+  </tr><thead>
+  <tbody>
+    {foreach from=$dates item="row" key="count"}
+      <tr class="{cycle values="odd-row,even-row"}">
+        <td>{$count + 1}</td>
+        <td>{$row.start_date}</td>
+        {if $endDates}<td>{$row.end_date}</td>{/if}
+      </tr>
+    {/foreach}
+  </tbody>
+</table>
\ No newline at end of file
index d92c99a48bde59dbc8e95e3315f763505f498188..aeeedba5bdcc14dd5ac1b00f1a9e8f45b621d7bc 100644 (file)
  | see the CiviCRM license FAQ at http://civicrm.org/licensing        |\r
  +--------------------------------------------------------------------+\r
 *}\r
+{if $hasParent || $isRepeatingEntity || $scheduleReminderId}\r
+  {capture assign='entity_type'}{$recurringEntityType|lower}{/capture}\r
+  <script type="text/template" id="recurring-dialog-tpl">\r
+    <div class="recurring-dialog">\r
+      <h4>{ts}How should this change affect others in the series?{/ts}</h4>\r
+      <div>\r
+        <input type="radio" id="recur-only-this-entity" name="recur_mode" value="1">\r
+        <label for="recur-only-this-entity">{ts 1=$entity_type}Only this %1{/ts}</label>\r
+        <div class="description">{ts}All others in the series will remain unchanged.{/ts}</div>\r
 \r
-<div id="recurring-dialog" class="hiddenElement">\r
-    {ts}How would you like this change to affect other entities in the repetition set?{/ts}<br/><br/>\r
-    <div class="show-block">\r
-        <div class="recurring-dialog-inner-wrapper">\r
-            <div class="recurring-dialog-inner-left">\r
-                <button class="recurring-dialog-button only-this-event">{ts}Only this entity{/ts}</button>\r
-            </div>\r
-          <div class="recurring-dialog-inner-right">{ts}All other entities in the series will remain same.{/ts}</div>\r
-        </div>\r
-        <div class="recurring-dialog-inner-wrapper">\r
-            <div class="recurring-dialog-inner-left">\r
-                <button class="recurring-dialog-button this-and-all-following-event">{ts}This and Following entities{/ts}</button>\r
-            </div>\r
-            <div class="recurring-dialog-inner-right">{ts}Change applies to this and all the following entities.{/ts}</div>\r
-        </div>\r
-        <div class="recurring-dialog-inner-wrapper">\r
-            <div class="recurring-dialog-inner-left">\r
-                <button class="recurring-dialog-button all-events">{ts}All the entities{/ts}</button>\r
-            </div>\r
-            <div class="recurring-dialog-inner-right">{ts}Change applies to all the entities in the series.{/ts}</div>\r
-        </div>\r
+        <input type="radio" id="recur-this-and-all-following-entity" name="recur_mode" value="2">\r
+        <label for="recur-this-and-all-following-entity">{ts 1=$entity_type}This %1 onwards{/ts}</label>\r
+        <div class="description">{ts 1=$entity_type}Change applies to this %1 and all that come after it.{/ts}</div>\r
+\r
+        <input type="radio" id="recur-all-entity" name="recur_mode" value="3">\r
+        <label for="recur-all-entity">{ts 1=$entity_type}Every %1{/ts}</label>\r
+        <div class="description">{ts 1=$entity_type}Change applies to every %1 in the series.{/ts}</div>\r
+      </div>\r
+      <div class="status help"><div class="icon ui-icon-lightbulb"></div>{ts}Changes to date or time will <em>not</em> be applied to others in the series.{/ts}</div>\r
     </div>\r
-    <div class="status"><div class="icon ui-icon-lightbulb"></div> Changes to date or time will NOT be applied to other entities in the series.</div>\r
-</div>\r
-{if $hasParent || $isRepeatingEntity}\r
+  </script>\r
 {literal}\r
   <script type="text/javascript">\r
     CRM.$(function($) {\r
-      var $dialog;\r
-      /** Add your linked entity mapper here **/\r
-      var mapper = {'CRM_Event_Form_ManageEvent_EventInfo': '',\r
-                'CRM_Event_Form_ManageEvent_Location': '',\r
-                'CRM_Event_Form_ManageEvent_Fee': '',\r
-                'CRM_Event_Form_ManageEvent_Registration': '',\r
-                'CRM_Friend_Form_Event': 'civicrm_tell_friend',\r
-                'CRM_PCP_Form_Event': 'civicrm_pcp_block',\r
-                'CRM_Activity_Form_Activity': ''\r
-                };\r
+      var $form, formClass,\r
+        /** Add your linked entity mapper here **/\r
+        mapper = {\r
+          'CRM_Event_Form_ManageEvent_EventInfo': '',\r
+          'CRM_Event_Form_ManageEvent_Location': '',\r
+          'CRM_Event_Form_ManageEvent_Fee': '',\r
+          'CRM_Event_Form_ManageEvent_Registration': '',\r
+          'CRM_Friend_Form_Event': 'civicrm_tell_friend',\r
+          'CRM_PCP_Form_Event': 'civicrm_pcp_block',\r
+          'CRM_Activity_Form_Activity': ''\r
+        };\r
+\r
       function cascadeChangesDialog() {\r
-        $dialog =  $("#recurring-dialog").dialog({\r
-          title: 'How does this change affect other repeating entities in the set?',\r
-          modal: true,\r
-          width: '650',\r
-          buttons: {\r
-            Cancel: function() { //cancel\r
-              $( this ).dialog( "close" );\r
-            }\r
-          }\r
-        }).dialog('open');\r
+        CRM.confirm({\r
+          title: "{/literal}{ts escape='js' 1=$entity_type}Update recurring %1{/ts}{literal}",\r
+          message: $('#recurring-dialog-tpl').html()\r
+        })\r
+          .on('crmConfirm:yes', updateMode)\r
+          .on('click change', 'input[name=recur_mode]', function() {\r
+            $('button[data-op=yes]').prop('disabled', false);\r
+          })\r
+          .parent().find('button[data-op=yes]').prop('disabled', true)\r
       }\r
-      var form = '';\r
-      $('#crm-main-content-wrapper').on('click', 'div.crm-submit-buttons span.crm-button input[value="Save"], div.crm-submit-buttons span.crm-button input[value="Save and Done"]', function() {\r
-          form = $(this).parents('form:first').attr('class');\r
-          if( form != "" && mapper.hasOwnProperty(form) ){\r
-            cascadeChangesDialog();\r
-            return false;\r
-          }\r
-      });\r
-\r
-      $("#_qf_Activity_upload-top, #_qf_Activity_upload-bottom").click(function() {\r
-          form = $(this).parents('form:first').attr('class');\r
-          if( form != "" && mapper.hasOwnProperty(form) ){\r
-            var showPreviewDialog = $.data( document.body, "preview-dialog");\r
-            if (showPreviewDialog == false) {\r
-              cascadeChangesDialog();\r
-            }\r
-            return false;\r
-          }\r
-      });\r
 \r
-      $(".only-this-event").click(function() {\r
-        updateMode(1);\r
-      });\r
-\r
-      $(".this-and-all-following-event").click(function() {\r
-        updateMode(2);\r
-      });\r
-\r
-      $(".all-events").click(function() {\r
-        updateMode(3);\r
+      // Intercept form submissions and check if they will impact the recurring entity\r
+      // This ought to attach the handler to the the dialog if we're in a popup, or the page wrapper if we're not\r
+      $('#recurring-dialog-tpl').closest('.crm-container').on('click', '.crm-form-submit.validate', function(e) {\r
+        $form = $(this).closest('form');\r
+        var className = ($form.attr('class') || '').match(/CRM_\S*/);\r
+        formClass = className && className[0];\r
+        if (formClass && mapper.hasOwnProperty(formClass) &&\r
+            // For activities, only show this if the changes were not made to the recurring settings\r
+          (formClass !== 'CRM_Activity_Form_Activity' || !CRM.utils.initialValueChanged('.crm-core-form-recurringentity-block'))\r
+        ) {\r
+          cascadeChangesDialog();\r
+          e.preventDefault();\r
+        }\r
       });\r
 \r
-      function updateMode(mode) {\r
-        var entityID = parseInt('{/literal}{$entityID}{literal}');\r
-        var entityTable = '{/literal}{$entityTable}{literal}';\r
-        if (entityID != "" && mode && mapper.hasOwnProperty(form) && entityTable !="") {\r
-          var ajaxurl = CRM.url("civicrm/ajax/recurringentity/update-mode");\r
-          var data    = {mode: mode, entityId: entityID, entityTable: entityTable, linkedEntityTable: mapper[form]};\r
-          $.ajax({\r
-            dataType: "json",\r
-            data: data,\r
-            url:  ajaxurl,\r
-            success: function (result) {\r
+      function updateMode() {\r
+        var mode = $('input[name=recur_mode]:checked', this).val(),\r
+          entityID = parseInt('{/literal}{$entityID}{literal}'),\r
+          entityTable = '{/literal}{$entityTable}{literal}';\r
+        if (entityID != "" && mode && mapper.hasOwnProperty(formClass) && entityTable !="") {\r
+          $.getJSON(CRM.url("civicrm/ajax/recurringentity/update-mode",\r
+              {mode: mode, entityId: entityID, entityTable: entityTable, linkedEntityTable: mapper[formClass]})\r
+          ).done(function (result) {\r
               if (result.status != "" && result.status == 'Done') {\r
-                $('#mainTabContainer div:visible Form, form.'+form).submit();\r
-                $dialog.dialog('close');\r
+                $form.submit();\r
               } else if (result.status != "" && result.status == 'Error') {\r
-                var errorBox = confirm(ts("Mode could not be updated, save only this event?"));\r
-                if (errorBox == true) {\r
-                  $('#mainTabContainer div:visible Form, form.'+form).submit();\r
-                  $dialog.dialog('close');\r
-                } else {\r
-                  $dialog.dialog('close');\r
-                  return false;\r
+                if (confirm("{/literal}{ts escape='js' 1=$entity_type}Mode could not be updated, save only this %1?{/ts}{literal}")) {\r
+                  $form.submit();\r
                 }\r
               }\r
-            }\r
-          });\r
+            });\r
         }\r
       }\r
     });\r
index 572528dd2294fd4e9ce6a03214ccce3e7b7db73d..e5187ca670a0b586cb5034150a26b1d3e1085f9e 100644 (file)
@@ -24,9 +24,9 @@
  +--------------------------------------------------------------------+
 *}
 <div class="crm-block crm-form-block crm-event-manage-repeat-form-block">
-{include file="CRM/Core/Form/RecurringEntity.tpl"}
+{include file="CRM/Core/Form/RecurringEntity.tpl" recurringFormIsEmbedded=false}
 {if $rows}
-<div id="event_status_id" class="crm-block crm-manage-events crm-accordion-wrapper">
+<div class="crm-block crm-manage-events crm-accordion-wrapper">
   <div class="crm-accordion-header">{ts}Connected Repeating Events{/ts}</div>
   <div class="crm-accordion-body">
   {strip}
@@ -51,7 +51,7 @@
           {else}
               {assign var="highlight" value=""}
           {/if}
-          <tr id="row_{$row.id}" class="{if NOT $row.is_active} disabled{/if}">
+          <tr class="row_{$row.id}{if NOT $row.is_active} disabled{/if}">
           <td class="crm-event_{$row.id}{$highlight}">
             <a href="{crmURL p='civicrm/event/info' q="id=`$row.id`&reset=1"}"
                title="{ts}View event info page{/ts}" class="bold">{$row.title}</a>&nbsp;&nbsp;({ts}ID:{/ts} {$row.id})
@@ -63,7 +63,7 @@
             {if $row.is_active eq 1}{ts}Yes{/ts} {else} {ts}No{/ts} {/if}
           </td>
           <td class="{$highlight}">
-            <a href="{crmURL p="civicrm/event/manage/settings" q="reset=1&action=update&id=`$row.id`"}">Manage Event</a>
+            <a class="action-item no-popup crm-hover-button" href="{crmURL p="civicrm/event/manage/settings" q="reset=1&action=update&id=`$row.id`"}">{ts}Settings{/ts}</a>
           </td>
           <td class="crm-event-start_date hiddenElement">{$row.start_date|crmDate}</td>
           <td class="crm-event-end_date hiddenElement">{$row.end_date|crmDate}</td>
@@ -71,7 +71,6 @@
         {/if}
       {/foreach}
     </table>
-  {include file="CRM/common/pager.tpl" location="bottom"}
   {/strip}
   </div>
 </div>
index 08b85cec1d01f59f8f78e140640d69a45bc33600..8b7faed798e091a3380f08055976355e578670b6 100644 (file)
@@ -58,9 +58,9 @@ class org_civicrm_search_activityimplementsCRM_Contact_Form_Search_Interface {
       ts('Activity Subject') => 'activity_subject',
       ts('Scheduled By') => 'source_contact',
       ts('Scheduled Date') => 'activity_date',
-      ts(' ') => 'activity_id',
-      ts('  ') => 'activity_type_id',
-      ts('   ') => 'case_id',
+      ' ' => 'activity_id',
+      '  ' => 'activity_type_id',
+      '   ' => 'case_id',
       ts('Location') => 'location',
       ts('Duration') => 'duration',
       ts('Details') => 'details',
index aab47c09a3d6178d8397bf51502ffb81a03ca090..03752b157bc691c2e0461856ce7bfe5ccb1c401d 100644 (file)
@@ -49,8 +49,9 @@ class org_civicrm_search_basic extends CRM_Contact_Form_Search_Custom_Baseimplem
     parent::__construct($formValues);
 
     $this->normalize();
-    $this->_columns = array(ts('') => 'contact_type',
-      ts('') => 'contact_sub_type',
+    $this->_columns = array(
+      '' => 'contact_type',
+      '' => 'contact_sub_type',
       ts('Name') => 'sort_name',
       ts('Address') => 'street_address',
       ts('City') => 'city',