event recurring patch for v4.6
authorpriyankakaran26 <priyanka.karan26@gmail.com>
Wed, 3 Sep 2014 21:13:51 +0000 (22:13 +0100)
committerdeepak-srivastava <deepak.srivastava.0303@gmail.com>
Fri, 3 Oct 2014 08:55:14 +0000 (09:55 +0100)
25 files changed:
CRM/Core/BAO/ActionSchedule.php
CRM/Core/BAO/RecurringEntity.php [new file with mode: 0644]
CRM/Core/DAO.php
CRM/Core/DAO/RecurringEntity.php [new file with mode: 0644]
CRM/Core/Form/RecurringEntity.php [new file with mode: 0644]
CRM/Core/Page/AJAX/RecurringEntity.php [new file with mode: 0644]
CRM/Event/BAO/Query.php
CRM/Event/Form/ManageEvent.php
CRM/Event/Form/ManageEvent/Repeat.php [new file with mode: 0644]
CRM/Event/Form/ManageEvent/TabHeader.php
CRM/Event/Page/ManageEvent.php
CRM/Event/xml/Menu/Event.xml
templates/CRM/Event/Form/ConfirmSubmit.tpl [new file with mode: 0644]
templates/CRM/Event/Form/ManageEvent/EventInfo.tpl
templates/CRM/Event/Form/ManageEvent/Fee.tpl
templates/CRM/Event/Form/ManageEvent/Location.tpl
templates/CRM/Event/Form/ManageEvent/Registration.tpl
templates/CRM/Event/Form/ManageEvent/Repeat.hlp [new file with mode: 0644]
templates/CRM/Event/Form/ManageEvent/Repeat.tpl [new file with mode: 0644]
templates/CRM/Event/Form/ManageEvent/ScheduleReminders.tpl
templates/CRM/Friend/Form/Friend.tpl
templates/CRM/PCP/Form/PCP.tpl
xml/schema/Core/ActionSchedule.xml
xml/schema/Core/RecurringEntity.xml [new file with mode: 0644]
xml/schema/Core/files.xml

index b2f93dfede01d77c4d285dc5824a04e1fbadfd99..c5f6eeafc51b3bb3c8545d98ffadf37301d0d1c1 100755 (executable)
@@ -367,20 +367,19 @@ FROM civicrm_action_schedule cas
 LEFT JOIN civicrm_action_mapping cam ON (cam.id = cas.mapping_id)
 ";
     $params = CRM_Core_DAO::$_nullArray;
-
+    $where = " WHERE 1 ";
     if ($entityValue and $id) {
-      $where = "
-WHERE   cas.entity_value = $id AND
+      $where .= "
+AND   cas.entity_value = $id AND
         cam.entity_value = '$entityValue'";
 
-      $query .= $where;
-
       $params = array(
         1 => array($id, 'Integer'),
         2 => array($entityValue, 'String'),
       );
     }
-
+    $where .= " AND cas.used_for IS NULL";
+    $query .= $where;
     $dao = CRM_Core_DAO::executeQuery($query);
     while ($dao->fetch()) {
       $list[$dao->id]['id'] = $dao->id;
diff --git a/CRM/Core/BAO/RecurringEntity.php b/CRM/Core/BAO/RecurringEntity.php
new file mode 100644 (file)
index 0000000..144cfd5
--- /dev/null
@@ -0,0 +1,353 @@
+<?php
+/*
+ +--------------------------------------------------------------------+
+ | CiviCRM version 4.4                                                |
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC (c) 2004-2013                                |
+ +--------------------------------------------------------------------+
+ | 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-2013
+ * $Id$
+ *
+ */
+
+require_once 'packages/When/When.php'; 
+
+class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity {
+
+  static $_tableDAOMapper = 
+    array(
+      'civicrm_event' => 'CRM_Event_DAO_Event',
+      'civicrm_price_set_entity' => 'CRM_Price_DAO_PriceSetEntity',
+      'civicrm_uf_join'     => 'CRM_Core_DAO_UFJoin',
+      'civicrm_tell_friend' => 'CRM_Friend_DAO_Friend',
+      'civicrm_pcp_block'   => 'CRM_PCP_DAO_PCPBlock',
+    );
+
+  static function add(&$params) {
+    if (CRM_Utils_Array::value('id', $params)) {
+      CRM_Utils_Hook::pre('edit', 'RecurringEntity', $params['id'], $params);
+    }
+    else {
+      CRM_Utils_Hook::pre('create', 'RecurringEntity', NULL, $params);
+    }
+
+    $daoRecurringEntity = new CRM_Core_DAO_RecurringEntity();
+    $daoRecurringEntity->copyValues($params);
+    $result = $daoRecurringEntity->save();
+
+    if (CRM_Utils_Array::value('id', $params)) {
+      CRM_Utils_Hook::post('edit', 'RecurringEntity', $daoRecurringEntity->id, $daoRecurringEntity);
+    }
+    else {
+      CRM_Utils_Hook::post('create', 'RecurringEntity', $daoRecurringEntity->id, $daoRecurringEntity);
+    }
+    return $result;
+  }
+
+  static function quickAdd($parentId, $entityId, $entityTable) {
+    $params = 
+      array(
+        'parent_id'    => $parentId,
+        'entity_id'    => $entityId,
+        'entity_table' => $entityTable
+      );
+    return self::add($params);
+  }
+
+  static public function getEntitiesForParent($parentId, $entityTable, $includeParent = TRUE) {
+    $entities = array();
+
+    $query = "SELECT *
+      FROM civicrm_recurring_entity
+      WHERE parent_id = %1 AND entity_table = %2";
+    if (!$includeParent) {
+      $query .= " AND entity_id != %1";
+    }
+    $dao = CRM_Core_DAO::executeQuery($query, 
+      array(
+        1 => array($parentId, 'Integer'),
+        2 => array($entityTable, 'String'),
+      )
+    );
+
+    while ($dao->fetch()) {
+      $entities["{$dao->entity_table}_{$dao->entity_id}"]['table'] = $dao->entity_table;
+      $entities["{$dao->entity_table}_{$dao->entity_id}"]['id'] = $dao->entity_id;
+    }
+    return $entities;
+  }
+
+  static public function getEntitiesFor($entityId, $entityTable, $includeParent = TRUE) {
+    $parentId = self::getParentFor($entityId, $entityTable);
+    if ($parentId) {
+      return self::getEntitiesForParent($parentId, $entityTable, $includeParent);
+    }
+    return array();
+  }
+
+  static public function getParentFor($entityId, $entityTable, $includeParent = TRUE) {
+    $query = "
+      SELECT parent_id 
+      FROM civicrm_recurring_entity
+      WHERE entity_id = %1 AND entity_table = %2";
+    if (!$includeParent) {
+      $query .= " AND parent_id != %1";
+    }
+    $parentId = 
+      CRM_Core_DAO::singleValueQuery($query,
+        array(
+          1 => array($entityId, 'Integer'),
+          2 => array($entityTable, 'String'),
+        )
+      );
+    return $parentId;
+  }
+
+  //static public function copyCreateEntity('civicrm_event', array('id' => $params['parent_event_id'], $newParams) {
+  static public function copyCreateEntity($entityTable, $fromCriteria, $newParams, $createRecurringEntity = TRUE) {
+    $daoName = self::$_tableDAOMapper[$entityTable];
+    $newObject = CRM_Core_DAO::copyGeneric($daoName, $fromCriteria, $newParams);
+
+    if ($newObject->id && $createRecurringEntity) {
+      $object = new $daoName( );
+      foreach ($fromCriteria as $key => $value) {
+        $object->$key = $value;
+      }
+      $object->find(TRUE);
+
+      CRM_Core_BAO_RecurringEntity::quickAdd($object->id, $newObject->id, $entityTable);
+    }
+    return $newObject;
+  }
+
+  static public function triggerUpdate($obj) {
+    static $processedEntities = array();
+    if (empty($obj->id) || empty($obj->__table)) {
+      return FALSE;
+    }
+    $key = "{$obj->__table}_{$obj->id}";
+
+    if (array_key_exists($key, $processedEntities)) {
+      // already processed
+      return NULL;
+    }
+
+    // get related entities
+    $repeatingEntities = self::getEntitiesFor($obj->id, $obj->__table, FALSE);
+    if (empty($repeatingEntities)) {
+      // return if its not a recurring entity parent
+      return NULL;
+    }
+    // mark processed
+    $processedEntities[$key] = 1;
+
+    foreach ($repeatingEntities as $key => $val) {
+      $entityID = $val['id'];
+      $entityTable = $val['table'];
+
+      $processedEntities[$key] = 1;
+
+      if (array_key_exists($entityTable, self::$_tableDAOMapper)) {
+        $daoName = self::$_tableDAOMapper[$entityTable];
+
+        $fromId  = self::getParentFor($entityID, $entityTable);
+
+        // FIXME: generalize me
+        $skipData = array('start_date' => NULL, 
+          'end_date' => NULL,
+        );
+
+        $updateDAO = CRM_Core_DAO::cascadeUpdate($daoName, $fromId, $entityID, $skipData);
+      }
+    }
+    // done with processing. lets unset static var.
+    unset($processedEntities);
+  }
+
+  static function mapFormValuesToDB($formParams = array()){   
+    $dbParams = array();
+    if(CRM_Utils_Array::value('used_for', $formParams)){
+      $dbParams['used_for'] = $formParams['used_for'];
+    }
+       
+    if(CRM_Utils_Array::value('parent_event_id', $formParams)){
+        $dbParams['entity_value'] = $formParams['parent_event_id'];
+      }
+
+    if(CRM_Utils_Array::value('repetition_frequency_unit', $formParams)){
+        $dbParams['repetition_frequency_unit'] = $formParams['repetition_frequency_unit'];
+      }
+
+    if(CRM_Utils_Array::value('repetition_frequency_interval', $formParams)){
+        $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)){
+          $repeats_on = CRM_Utils_Array::value('start_action_condition', $formParams);
+          $dbParams['start_action_condition'] = implode(",", array_keys($repeats_on));
+        }
+      }
+
+    //For Repeats By:(monthly case)
+      if($formParams['repetition_frequency_unit'] == 'month'){
+        if($formParams['repeats_by'] == 1){
+          if(CRM_Utils_Array::value('limit_to', $formParams)){
+            $dbParams['limit_to'] = $formParams['limit_to'];
+          }
+        }
+        if($formParams['repeats_by'] == 2){
+          if(CRM_Utils_Array::value('start_action_date_1', $formParams) && CRM_Utils_Array::value('start_action_date_2', $formParams)){
+            $dbParams['start_action_date'] = $formParams['start_action_date_1']." ".$formParams['start_action_date_2'];
+          }
+        }
+      }
+
+    //For "Ends" - After: 
+      if($formParams['ends'] == 1){
+        if(CRM_Utils_Array::value('start_action_offset', $formParams)){
+          $dbParams['start_action_offset'] = $formParams['start_action_offset'];
+        }
+      }
+
+      //For "Ends" - On: 
+      if($formParams['ends'] == 2){
+        if(CRM_Utils_Array::value('repeat_absolute_date', $formParams)){
+          $dbParams['absolute_date'] = CRM_Utils_Date::processDate($formParams['repeat_absolute_date']);
+        }
+      }
+      return $dbParams;
+    }
+
+    static public function getScheduleReminderDetailsById($scheduleReminderId){
+      $query = "SELECT *
+                FROM civicrm_action_schedule WHERE 1";
+      if($scheduleReminderId){
+        $query .= "
+        AND id = %1";
+      }
+      $dao = CRM_Core_DAO::executeQuery($query,
+            array(
+              1 => array($scheduleReminderId, 'Integer')
+            )
+          );
+      $dao->fetch();
+      return $dao;
+    }
+    
+    static function getRecursionFromReminder($scheduleReminderId){
+      if($scheduleReminderId){
+        //Get all the details from schedule reminder table
+        $scheduleReminderDetails = self::getScheduleReminderDetailsById($scheduleReminderId);
+        $scheduleReminderDetails = (array) $scheduleReminderDetails;
+        $recursionDetails = self::getRecursionFromReminderByDBParams($scheduleReminderDetails);
+      }
+      return $recursionDetails;
+    }
+    
+    static function getRecursionFromReminderByDBParams($scheduleReminderDetails = array()){
+      $r = new When();
+      //If there is some data for this id
+      if($scheduleReminderDetails['repetition_frequency_unit']){
+        $currDate = date("Y-m-d H:i:s");
+        $start = new DateTime($currDate);
+        if($scheduleReminderDetails['repetition_frequency_unit']){
+          $repetition_frequency_unit = $scheduleReminderDetails['repetition_frequency_unit'];
+          if($repetition_frequency_unit == "day"){
+            $repetition_frequency_unit = "dai";
+          }
+          $repetition_frequency_unit = $repetition_frequency_unit.'ly';
+          $r->recur($start, $repetition_frequency_unit);
+        }
+
+        if($scheduleReminderDetails['repetition_frequency_interval']){
+          $r->interval($scheduleReminderDetails['repetition_frequency_interval']);
+        }
+
+        //week
+        if($scheduleReminderDetails['repetition_frequency_unit'] == 'week'){
+          if($scheduleReminderDetails['start_action_condition']){
+            $startActionCondition = $scheduleReminderDetails['start_action_condition'];
+            $explodeStartActionCondition = explode(',', $startActionCondition);
+            $buildRuleArray = array();
+            foreach($explodeStartActionCondition as $key => $val){
+              $buildRuleArray[] = strtoupper(substr($val, 0, 2));
+            }
+//              CRM_Core_Error::debug('$buildRuleArray', $buildRuleArray);exit;
+            $r->wkst('MO')->byday($buildRuleArray);
+          }
+        }
+
+        //month 
+        if($scheduleReminderDetails['repetition_frequency_unit'] == 'month'){
+          if($scheduleReminderDetails['limit_to']){
+            $r->bymonthday(array($scheduleReminderDetails['limit_to']));
+          }
+          if($scheduleReminderDetails['start_action_date']){
+            $startActionDate = explode(" ", $scheduleReminderDetails['start_action_date']);
+            switch ($startActionDate[0]) {
+              case 'first':
+                  $startActionDate1 = 1;
+                  break;
+              case 'second':
+                  $startActionDate1 = 2;
+                  break;
+              case 'third':
+                  $startActionDate1 = 3;
+                  break;
+              case 'fourth':
+                  $startActionDate1 = 4;
+                  break;
+              case 'last':
+                  $startActionDate1 = -1;
+                  break;
+            }
+            $concatStartActionDateBits = $startActionDate1.strtoupper(substr($startActionDate[1], 0, 2));
+            $r->byday(array($concatStartActionDateBits));
+          }
+        }
+
+        //Ends
+        if($scheduleReminderDetails['start_action_offset']){
+          $r->count($scheduleReminderDetails['start_action_offset']);
+        }
+
+        if($scheduleReminderDetails['absolute_date']){
+          $absoluteDate = CRM_Utils_Date::setDateDefaults($scheduleReminderDetails['absolute_date']);
+          $endDate = new DateTime($absoluteDate[0].' '.$absoluteDate[1]);
+          $r->until($endDate);
+        }
+
+        if(!$scheduleReminderDetails['start_action_offset'] && !$scheduleReminderDetails['absolute_date']){
+          CRM_Core_Error::fatal("Could not find end limit for repeat configuration");
+        }
+     }
+      return $r;
+    }
+    
+    
+  }
index 0399e88fb1be649ccdfd12863b147127033a02c7..445576fa5f56fe7436a90a17e417854ab3bdc3ea 100644 (file)
@@ -450,6 +450,7 @@ class CRM_Core_DAO extends DB_DataObject {
   function save() {
     if (!empty($this->id)) {
       $this->update();
+      CRM_Core_BAO_RecurringEntity::triggerUpdate($this);
     }
     else {
       $this->insert();
@@ -1348,6 +1349,41 @@ FROM   civicrm_domain
     return $newObject;
   }
 
+  static function cascadeUpdate($daoName, $fromId, $toId, $newData = array()) {
+    $object = new $daoName( );
+    $object->id = $fromId;
+
+    if ($object->find(TRUE)) {
+      $newObject = new $daoName( );
+      $newObject->id = $toId;
+
+      if ($newObject->find(TRUE)) {
+        $fields = &$object->fields();
+        foreach ($fields as $name => $value) {
+          if ($name == 'id' || $value['name'] == 'id') {
+            // copy everything but the id!
+            continue;
+          }
+
+          $colName = $value['name'];
+          $newObject->$colName = $object->$colName;
+
+          if (substr($name, -5) == '_date' ||
+            substr($name, -10) == '_date_time'
+          ) {
+            $newObject->$colName = CRM_Utils_Date::isoToMysql($newObject->$colName);
+          }
+        }
+        foreach ($newData as $k => $v) {
+          $newObject->$k = $v;
+        }
+        $newObject->save();
+        return $newObject;
+      }
+    }
+    return CRM_Core_DAO::$_nullObject;
+  }
+
   /**
    * Given the component id, compute the contact id
    * since its used for things like send email
diff --git a/CRM/Core/DAO/RecurringEntity.php b/CRM/Core/DAO/RecurringEntity.php
new file mode 100644 (file)
index 0000000..a371ef2
--- /dev/null
@@ -0,0 +1,248 @@
+<?php
+/*
++--------------------------------------------------------------------+
+| CiviCRM version 4.4                                                |
++--------------------------------------------------------------------+
+| Copyright CiviCRM LLC (c) 2004-2013                                |
++--------------------------------------------------------------------+
+| 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-2013
+ *
+ * Generated from xml/schema/CRM/Core/RecurringEntity.xml
+ * DO NOT EDIT.  Generated by GenCode.php
+ */
+require_once 'CRM/Core/DAO.php';
+require_once 'CRM/Utils/Type.php';
+class CRM_Core_DAO_RecurringEntity extends CRM_Core_DAO
+{
+  /**
+   * static instance to hold the table name
+   *
+   * @var string
+   * @static
+   */
+  static $_tableName = 'civicrm_recurring_entity';
+  /**
+   * static instance to hold the field values
+   *
+   * @var array
+   * @static
+   */
+  static $_fields = null;
+  /**
+   * static instance to hold the keys used in $_fields for each field.
+   *
+   * @var array
+   * @static
+   */
+  static $_fieldKeys = null;
+  /**
+   * static instance to hold the FK relationships
+   *
+   * @var string
+   * @static
+   */
+  static $_links = null;
+  /**
+   * static instance to hold the values that can
+   * be imported
+   *
+   * @var array
+   * @static
+   */
+  static $_import = null;
+  /**
+   * static instance to hold the values that can
+   * be exported
+   *
+   * @var array
+   * @static
+   */
+  static $_export = null;
+  /**
+   * static value to see if we should log any modifications to
+   * this table in the civicrm_log table
+   *
+   * @var boolean
+   * @static
+   */
+  static $_log = true;
+  /**
+   *
+   * @var int unsigned
+   */
+  public $id;
+  /**
+   *
+   * @var int unsigned
+   */
+  public $parent_id;
+  /**
+   *
+   * @var int unsigned
+   */
+  public $entity_id;
+  /**
+   *
+   * @var string
+   */
+  public $entity_table;
+  /**
+   * class constructor
+   *
+   * @access public
+   * @return civicrm_recurring_entity
+   */
+  function __construct()
+  {
+    $this->__table = 'civicrm_recurring_entity';
+    parent::__construct();
+  }
+  /**
+   * returns all the column names of this table
+   *
+   * @access public
+   * @return array
+   */
+  static function &fields()
+  {
+    if (!(self::$_fields)) {
+      self::$_fields = array(
+        'id' => array(
+          'name' => 'id',
+          'type' => CRM_Utils_Type::T_INT,
+          'title' => ts('ID') ,
+          'required' => true,
+        ) ,
+        'parent_id' => array(
+          'name' => 'parent_id',
+          'type' => CRM_Utils_Type::T_INT,
+          'title' => ts('Parent ID') ,
+          'required' => true,
+        ) ,
+        'entity_id' => array(
+          'name' => 'entity_id',
+          'type' => CRM_Utils_Type::T_INT,
+          'title' => ts('Entity ID') ,
+        ) ,
+        'entity_table' => array(
+          'name' => 'entity_table',
+          'type' => CRM_Utils_Type::T_STRING,
+          'title' => ts('Entity Table') ,
+          'required' => true,
+          'size' => CRM_Utils_Type::TWO,
+        ) ,
+      );
+    }
+    return self::$_fields;
+  }
+  /**
+   * Returns an array containing, for each field, the arary key used for that
+   * field in self::$_fields.
+   *
+   * @access public
+   * @return array
+   */
+  static function &fieldKeys()
+  {
+    if (!(self::$_fieldKeys)) {
+      self::$_fieldKeys = array(
+        'id' => 'id',
+        'parent_id' => 'parent_id',
+        'entity_id' => 'entity_id',
+        'entity_table' => 'entity_table',
+      );
+    }
+    return self::$_fieldKeys;
+  }
+  /**
+   * returns the names of this table
+   *
+   * @access public
+   * @static
+   * @return string
+   */
+  static function getTableName()
+  {
+    return self::$_tableName;
+  }
+  /**
+   * returns if this table needs to be logged
+   *
+   * @access public
+   * @return boolean
+   */
+  function getLog()
+  {
+    return self::$_log;
+  }
+  /**
+   * returns the list of fields that can be imported
+   *
+   * @access public
+   * return array
+   * @static
+   */
+  static function &import($prefix = false)
+  {
+    if (!(self::$_import)) {
+      self::$_import = array();
+      $fields = self::fields();
+      foreach($fields as $name => $field) {
+        if (CRM_Utils_Array::value('import', $field)) {
+          if ($prefix) {
+            self::$_import['recurring_entity'] = & $fields[$name];
+          } else {
+            self::$_import[$name] = & $fields[$name];
+          }
+        }
+      }
+    }
+    return self::$_import;
+  }
+  /**
+   * returns the list of fields that can be exported
+   *
+   * @access public
+   * return array
+   * @static
+   */
+  static function &export($prefix = false)
+  {
+    if (!(self::$_export)) {
+      self::$_export = array();
+      $fields = self::fields();
+      foreach($fields as $name => $field) {
+        if (CRM_Utils_Array::value('export', $field)) {
+          if ($prefix) {
+            self::$_export['recurring_entity'] = & $fields[$name];
+          } else {
+            self::$_export[$name] = & $fields[$name];
+          }
+        }
+      }
+    }
+    return self::$_export;
+  }
+}
diff --git a/CRM/Core/Form/RecurringEntity.php b/CRM/Core/Form/RecurringEntity.php
new file mode 100644 (file)
index 0000000..db74623
--- /dev/null
@@ -0,0 +1,432 @@
+<?php
+/*
+ +--------------------------------------------------------------------+
+ | CiviCRM version 4.4                                                |
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC (c) 2004-2013                                |
+ +--------------------------------------------------------------------+
+ | 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-2013
+ * $Id$
+ *
+ */
+/**
+ * This class generates form components for processing Event
+ *
+ */
+class CRM_Core_Form_RecurringEntity {
+  /**
+   *  Current entity id
+   */
+  protected static $_entityId = NULL;
+  
+  static function buildQuickForm(&$form) {
+    //$attributes_schedule = CRM_Core_DAO::getAttribute('CRM_Core_DAO_ActionMapping');
+    self::$_entityId = CRM_Utils_Array::value('id', $_GET);
+    $form->assign('currentEntityId', self::$_entityId);
+    
+    $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);
+    $dayOfTheWeek = array('monday'   => 'Monday',
+                          'tuesday'   => 'Tuesday',
+                          'wednesday' => 'Wednesday',
+                          'thursday'  => 'Thursday',
+                          'friday'    => 'Friday',
+                          'saturday'  => 'Saturday',
+                          'sunday'    => 'Sunday'
+                         );
+    $form->add('select', 'repetition_frequency_unit', ts('Repeats:'), $freqUnitsDisplay, TRUE);
+    $numericOptions = CRM_Core_SelectValues::getNumericOptions(1, 30);
+    $form->add('select', 'repetition_frequency_interval', ts('Repeats every:'), $numericOptions, TRUE, array('style' => 'width:49px;'));
+    foreach($dayOfTheWeek as $key => $val){
+        $startActionCondition[] = $form->createElement('checkbox', $key, NULL, substr($val."&nbsp;", 0, 3));
+    }
+    $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:49px;'));
+    $dayOfTheWeekNo = array('first'  => 'First',
+                            'second'=> 'Second',
+                            'third' => 'Third',
+                            'fourth'=> 'Fourth',
+                            'last'  => 'Last'
+                         );
+    $form->add('select', 'start_action_date_1', ts(''), $dayOfTheWeekNo);
+    $form->add('select', 'start_action_date_2', ts(''), $dayOfTheWeek);
+    $eoptionTypes = array('1' => ts('After'),
+        '2' => ts('On'),
+      );
+    $form->addRadio('ends', ts("Ends:"), $eoptionTypes, array(), NULL, TRUE);
+    $form->add('text', 'start_action_offset', ts(''), array('maxlength' => 2));
+    $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(''), $form->_excludeDateInfo, FALSE, array('style' => 'width:200px;', 'size' => 4));
+    $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', 'isChangeInRepeatConfiguration', '', array('id' => 'isChangeInRepeatConfiguration'));
+    $form->addElement('hidden', 'copyExcludeDates', '', array('id' => 'copyExcludeDates'));
+    $form->addButtons(array(
+        array(
+          'type' => 'submit',
+          'name' => ts('Save'),
+          'isDefault' => TRUE,
+        ),
+        array(
+          'type' => 'cancel',
+          'name' => ts('Cancel')
+        ),
+      )
+    );
+  }
+
+  /**
+   * global validation rules for the form
+   *
+   * @param array $fields posted values of the form
+   *
+   * @return array list of errors to be posted back to the form
+   * @static
+   * @access public
+   */
+  static function formRule($values) {
+    $errors = array();
+    $dayOfTheWeek = array(monday,tuesday,wednesday,thursday,friday,saturday,sunday);
+//    CRM_Core_Error::debug('$values', $values);
+    
+    //Repeats
+    if(!CRM_Utils_Array::value('repetition_frequency_unit', $values)){
+      $errors['repetition_frequency_unit'] = ts('This is a required field');
+    }
+    //Repeats every
+    if(!CRM_Utils_Array::value('repetition_frequency_interval', $values)){
+      $errors['repetition_frequency_interval'] = ts('This is a required field');
+    }
+    //Ends
+    if(CRM_Utils_Array::value('ends', $values)){
+      if($values['ends'] == 1){
+        if ($values['start_action_offset'] == "") {
+          $errors['start_action_offset'] = ts('This is a required field');
+        }else if($values['start_action_offset'] > 30){
+          $errors['start_action_offset'] = ts('Occurrences should be less than or equal to 30');
+        }
+      }
+      if($values['ends'] == 2){
+        if ($values['repeat_absolute_date'] != "") {
+          $today = date("Y-m-d H:i:s"); 
+          $today = CRM_Utils_Date::processDate($today);
+          $end = CRM_Utils_Date::processDate($values['repeat_absolute_date']);
+          if (($end <= $today) && ($end != 0)) {
+            $errors['repeat_absolute_date'] = ts('End date should be after today\'s date');
+          }
+        }else{
+          $errors['repeat_absolute_date'] = ts('This is a required field');
+        }
+      }
+    }else{
+      $errors['ends'] = ts('This is a required field');
+    }
+    
+    //Repeats BY
+    if(CRM_Utils_Array::value('repeats_by', $values)){
+      if($values['repeats_by'] == 1){
+        if($values['limit_to'] != ""){
+          if($values['limit_to'] < 1 && $values['limit_to'] > 31){
+            $errors['limit_to'] = ts('Invalid day of the month');
+          }
+        }else{
+          $errors['limit_to'] = ts('Invalid day of the month');
+        }
+      }
+      if($values['repeats_by'] == 2){
+        if($values['start_action_date_1'] != "" ) {
+          $dayOfTheWeekNo = array(first, second, third, fourth, last);
+          if(!in_array($values['start_action_date_1'], $dayOfTheWeekNo)){
+             $errors['start_action_date_1'] = ts('Invalid option');
+          }
+        }else{
+          $errors['start_action_date_1'] = ts('Invalid option');
+        }
+        if($values['start_action_date_2'] != "" ) {
+          if(!in_array($values['start_action_date_2'], $dayOfTheWeek)){
+             $errors['start_action_date_2'] = ts('Invalid day name');
+          }
+        }else{
+          $errors['start_action_date_2'] = ts('Invalid day name');
+        }
+      }
+    }
+    return $errors;
+  }
+
+  /**
+   * Function to process the form
+   *
+   * @access public
+   *
+   * @return None
+   */
+  static function postProcess($params=array(), $type) {
+    if(!empty($type)){
+      $params['used_for'] = $type;
+    }
+    
+    if(CRM_Utils_Array::value('id', $params)){
+      CRM_Core_BAO_ActionSchedule::del($params['id']);
+      unset($params['id']);
+    }
+    //Save post params to the schedule reminder table
+    $dbParams = CRM_Core_BAO_RecurringEntity::mapFormValuesToDB($params);
+    $actionScheduleObj = CRM_Core_BAO_ActionSchedule::add($dbParams);
+    
+    //Build Recursion Object
+    if($actionScheduleObj->id){
+      $recursionObject = CRM_Core_BAO_RecurringEntity::getRecursionFromReminder($actionScheduleObj->id);
+    }
+    
+    
+    //TO DO - Exclude date functionality
+    if(CRM_Utils_Array::value('copyExcludeDates', $params) && CRM_Utils_Array::value('parent_event_id', $params)){   
+      //Since we get comma separated values lets get them in array
+      $exclude_date_list = array();
+      $exclude_date_list = explode(",", $params['copyExcludeDates']);
+
+      //Check if there exists any values for this option group
+      $optionGroupIdExists = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup',
+          'event_repeat_exclude_dates_'.$params['parent_event_id'],
+          'id',
+          'name'
+        );
+      if($optionGroupIdExists){
+        CRM_Core_BAO_OptionGroup::del($optionGroupIdExists);
+      }
+      $optionGroupParams = 
+          array(
+            'name'        => 'event_repeat_exclude_dates_'.$params['parent_event_id'],
+            'title'       => 'Event Recursion',
+            'is_reserved' => 0,
+            'is_active'   => 1
+          );
+      $opGroup = CRM_Core_BAO_OptionGroup::add($optionGroupParams);
+      if($opGroup->id){
+        $oldWeight= 0;
+        $fieldValues = array('option_group_id' => $opGroup->id);
+        foreach($exclude_date_list as $val){
+          $optionGroupValue = 
+              array(
+                'option_group_id' =>  $opGroup->id,
+                'label'           =>  CRM_Utils_Date::processDate($val),
+                'value'           =>  CRM_Utils_Date::processDate($val),
+                'name'            =>  $opGroup->name,
+                'description'     =>  'Used for event recursion',
+                'weight'          =>  CRM_Utils_Weight::updateOtherWeights('CRM_Core_DAO_OptionValue', $oldWeight, CRM_Utils_Array::value('weight', $params), $fieldValues),
+                'is_active'       =>  1
+              );
+          CRM_Core_BAO_OptionValue::add($optionGroupValue);
+        }
+      }
+    }
+    
+    //Give call to create recursions
+    $recurResult = self::generateRecursions($recursionObject, $params);
+    if(!empty($recurResult)){
+      self::addEntityThroughRecursion($recurResult, $params['parent_event_id']);
+    }
+    $status = ts('Repeat Configuration Saved');
+    CRM_Core_Session::setStatus($status, ts('Saved'), 'success');
+  }
+  //end of function
+
+  /**
+   * Return a descriptive name for the page, used in wizard header
+   *
+   * @return string
+   * @access public
+   */
+  public function getTitle() {
+    return ts('Repeat Event');
+  }
+
+  static public function generateRecursions($recursionObj, $params=array()){ 
+    $newParams = $recursionResult = array();
+    if($recursionObj && !empty($params)){ 
+      //Proceed only if these keys are found in array
+      if(CRM_Utils_Array::value('parent_event_start_date', $params) && CRM_Utils_Array::value('parent_event_id', $params)){
+        $count = 1;
+        while($result = $recursionObj->next()){
+          //$result->format('YmdHis'). '<br />';
+          $newParams['start_date'] = CRM_Utils_Date::processDate($result->format('Y-m-d H:i:s'));
+          $parentStartDate = new DateTime($params['parent_event_start_date']);
+          //If open ended event
+          if(CRM_Utils_Array::value('parent_event_end_date', $params)){
+            $parentEndDate = new DateTime($params['parent_event_end_date']);
+            $interval = $parentStartDate->diff($parentEndDate);
+            $end_date = new DateTime($newParams['start_date']);
+            $end_date->add($interval);
+            $newParams['end_date'] = CRM_Utils_Date::processDate($end_date->format('Y-m-d H:i:s'));
+            $recursionResult[$count]['end_date'] = $newParams['end_date'];
+          }
+          $recursionResult[$count]['start_date'] = $newParams['start_date'];
+          $count++;
+        }
+      }
+    }
+    return $recursionResult;
+  }
+  
+  static public function addEntityThroughRecursion($recursionResult = array(), $currEntityID){
+    if(!empty($recursionResult) && $currEntityID){
+      $parent_event_id = CRM_Core_BAO_RecurringEntity::getParentFor($currEntityID, 'civicrm_event');
+      if(!$parent_event_id){
+        $parent_event_id = $currEntityID;
+      }
+
+      foreach ($recursionResult as $key => $value) {
+        $newEventObj = CRM_Core_BAO_RecurringEntity::copyCreateEntity('civicrm_event', 
+        array('id' => $parent_event_id), 
+        $value);
+
+        CRM_Core_BAO_RecurringEntity::copyCreateEntity('civicrm_price_set_entity', 
+          array(
+            'entity_id' => $parent_event_id, 
+            'entity_table' => 'civicrm_event'
+          ), 
+          array(
+            'entity_id' => $newEventObj->id
+          ),
+          FALSE
+        );
+
+        CRM_Core_BAO_RecurringEntity::copyCreateEntity('civicrm_uf_join', 
+          array(
+            'entity_id' => $parent_event_id, 
+            'entity_table' => 'civicrm_event'
+          ), 
+          array(
+            'entity_id' => $newEventObj->id
+          ),
+          FALSE
+        );
+
+        CRM_Core_BAO_RecurringEntity::copyCreateEntity('civicrm_tell_friend', 
+          array(
+            'entity_id' => $parent_event_id, 
+            'entity_table' => 'civicrm_event'
+          ), 
+          array(
+            'entity_id' => $newEventObj->id
+          )
+        );
+
+        CRM_Core_BAO_RecurringEntity::copyCreateEntity('civicrm_pcp_block', 
+          array(
+            'entity_id' => $parent_event_id, 
+            'entity_table' => 'civicrm_event'
+          ), 
+          array(
+            'entity_id' => $newEventObj->id
+          )
+        );
+      }
+      CRM_Core_BAO_RecurringEntity::quickAdd($parent_event_id, $parent_event_id, 'civicrm_event');
+    }
+  }
+  
+  /*
+   * Get Reminder id based on event id
+   */
+  static public function getReminderDetailsByEventId($eventId=''){
+    if(!empty($eventId)){
+      $query = "
+        SELECT *
+        FROM   civicrm_action_schedule 
+        WHERE  entity_value = '".$eventId."'";
+      $dao = CRM_Core_DAO::executeQuery($query);
+      $dao->fetch();
+    }
+    return $dao;
+  }
+  
+  //It is a repeating event if, there exists a parent for an event
+  static public function checkParentExistsForThisId($currentEventId){
+    if(!empty($currentEventId)){
+      $query = "
+        SELECT parent_id 
+        FROM civicrm_recurring_entity
+        WHERE entity_id = ".$currentEventId;
+      $dao = CRM_Core_DAO::executeQuery($query);
+      $dao->fetch();
+    }
+    return $dao;
+  }
+  
+  static public function getAllConnectedEvents($parentId=''){
+    if(!empty($parentId)){
+      $query = "
+        SELECT GROUP_CONCAT(entity_id) as entity_id
+        FROM civicrm_recurring_entity
+        WHERE parent_id = ".$parentId;
+      $dao = CRM_Core_DAO::executeQuery($query);
+      $dao->fetch();
+    }
+    return $dao;
+  }
+  
+  static function getListOfCurrentAndFutureEvents($ids=''){
+    if(isset($ids) and !empty($ids)){
+      $curDate = date('YmdHis');
+      $query = "SELECT group_concat(id) as ids FROM civicrm_event 
+                WHERE id IN ({$ids}) 
+                AND ( end_date >= {$curDate} OR
+                (
+                  ( end_date IS NULL OR end_date = '' ) AND start_date >= {$curDate}
+                ))";
+      $dao = CRM_Core_DAO::executeQuery($query);
+      $dao->fetch();
+    }
+    return $dao;
+  }
+  
+  static function deleleRelationsForEventsInPast($ids=''){
+    if(isset($ids) and !empty($ids)){
+      $query = "DELETE FROM civicrm_recurring_entity
+                WHERE entity_id IN ({$ids})";
+      $dao = CRM_Core_DAO::executeQuery($query);
+    }
+    return; 
+  }
+   
+}
diff --git a/CRM/Core/Page/AJAX/RecurringEntity.php b/CRM/Core/Page/AJAX/RecurringEntity.php
new file mode 100644 (file)
index 0000000..4ab193c
--- /dev/null
@@ -0,0 +1,81 @@
+<?php
+
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+/**
+ * Description of EntityApplyChangesTo
+ *
+ * @author Priyanka
+ */
+
+class CRM_Core_Page_Ajax_RecurringEntity {
+  
+  public static function updateCascadeType(){
+    if(CRM_Utils_Array::value('cascadeType', $_REQUEST) && CRM_Utils_Array::value('entityId', $_REQUEST)){
+      $finalResult = array();
+      $cascadeType = CRM_Utils_Type::escape($_REQUEST['cascadeType'], 'Integer');
+      $entityId = CRM_Utils_Type::escape($_REQUEST['entityId'], 'Integer');
+      
+      $sql = "UPDATE
+          civicrm_recurring_entity
+          SET cascade_type = (%1)
+          WHERE entity_id = (%2) AND entity_table = 'civicrm_event'";
+      $params = array(
+                  1 => array($cascadeType, 'Integer'),          
+                  2 => array($entityId, 'Integer')
+                );
+      CRM_Core_DAO::executeQuery($sql, $params);
+      $finalResult['status'] = 'Done';
+    }
+    echo json_encode($finalResult);
+    CRM_Utils_System::civiExit();
+  }
+  
+  public static function generatePreview(){
+    $params = $formValues = $recurDates = array();
+    $formValues = $_REQUEST;
+    if(!empty($formValues)){
+      //Check for mandatory fields
+//      if(!CRM_Utils_Array::value('repetition_frequency_unit', $formValues)){
+//        $recurDates['errors']['repetition_frequency_unit'] = 'Repeats is a required field';
+//      }
+//      if(!CRM_Utils_Array::value('repetition_frequency_interval', $formValues)){
+//        $recurDates['errors']['repetition_frequency_interval'] = 'Repeats every is a required field';
+//      }
+//      if(!CRM_Utils_Array::value('start_action_offset', $formValues) && !CRM_Utils_Array::value('repeat_absolute_date', $formValues)){
+//        $recurDates['errors']['start_action_offset'] = 'Ends is a required field';
+//      }
+      
+      $dbParams = CRM_Core_BAO_RecurringEntity::mapFormValuesToDB($formValues);
+      if(!empty($dbParams)){
+        $recursionObject = CRM_Core_BAO_RecurringEntity::getRecursionFromReminderByDBParams($dbParams);
+        if(CRM_Utils_Array::value('event_id', $formValues)){
+          $parent_event_id = CRM_Core_BAO_RecurringEntity::getParentFor($formValues['event_id'], 'civicrm_event');
+          if(!$parent_event_id){
+            $parent_event_id = $formValues['event_id'];
+          }
+          $params['parent_event_id'] = $parent_event_id;
+          $params['parent_event_start_date'] = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $params['parent_event_id'], 'start_date');
+          $params['parent_event_end_date'] = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $params['parent_event_id'], 'end_date');
+        }
+        $recurResult = CRM_Core_Form_RecurringEntity::generateRecursions($recursionObject, $params); 
+        $count = 1;
+        foreach ($recurResult as $key => $value) {
+          $recurDates[$count]['start_date'] = date('M d, Y h:i:s A \o\n l', strtotime($value['start_date']));
+          if($value['end_date']){
+            $recurDates[$count]['end_date'] = date('M d, Y h:i:s A \o\n l', strtotime($value['end_date']));
+          }
+          $count++;
+        }
+      }
+    }
+    echo json_encode($recurDates);
+    CRM_Utils_System::civiExit();
+  }
+  
+}
+
index 771631b7179fba95028ed71e052db8be37a8ca37..5210b985139009724e08f3e98b86c1cf7816e276 100644 (file)
@@ -206,6 +206,7 @@ class CRM_Event_BAO_Query {
       }
     }
   }
+  
 
   /**
    * @param $query
@@ -248,14 +249,46 @@ class CRM_Event_BAO_Query {
           'civicrm_event', 'event_end_date', 'end_date', 'End Date'
         );
         return;
-
+        
       case 'event_id':
         $query->_where[$grouping][] = "civicrm_event.id $op {$value}";
         $eventTitle = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $value, 'title');
         $query->_qill[$grouping][] = ts('Event') . " $op {$eventTitle}";
         $query->_tables['civicrm_event'] = $query->_whereTables['civicrm_event'] = 1;
         return;
-
+        
+      case 'event_include_repeating_events':
+        /**
+         * Include Repeating Events
+         */
+        //Get parent of this event
+        $exEventId = '';
+        if($query->_where[$grouping]){
+          foreach($query->_where[$grouping] as $key => $val){
+            if (strstr($val, 'civicrm_event.id =')) {
+              $exEventId = $val;
+              $extractEventId = explode(" ", $val);
+              $value = $extractEventId[2];
+              unset($query->_where[$grouping][$key]);
+            }
+          }
+          $extractEventId = explode(" ", $exEventId);
+          $value = $extractEventId[2];
+          unset($query->_where[$grouping][$key]);
+        }
+        $thisEventHasParent = CRM_Core_BAO_RecurringEntity::getParentFor($value, 'civicrm_event');
+        if($thisEventHasParent){
+          $getAllConnections = CRM_Core_Form_RecurringEntity::getAllConnectedEvents($thisEventHasParent);
+          if($getAllConnections->entity_id){
+            $op = "IN";
+            $value = "($getAllConnections->entity_id)";
+          }
+        }
+        $query->_where[$grouping][] = "civicrm_event.id $op {$value}";
+        $query->_qill[$grouping][] = ts('Include Repeating Events (If Any) ') . " = TRUE";
+        $query->_tables['civicrm_event'] = $query->_whereTables['civicrm_event'] = 1;
+        return;
+       
       case 'event_type_id':
 
         $eventTypes = CRM_Core_OptionGroup::values("event_type");
@@ -263,7 +296,7 @@ class CRM_Event_BAO_Query {
         $query->_qill[$grouping][] = ts('Event Type - %1', array(1 => $eventTypes[$value]));
         $query->_tables['civicrm_event'] = $query->_whereTables['civicrm_event'] = 1;
         return;
-
+        
       case 'participant_test':
         // We dont want to include all tests for sql OR CRM-7827
         if (!$value || $query->getOperator() != 'OR') {
@@ -602,6 +635,7 @@ class CRM_Event_BAO_Query {
     $form->add('text', 'participant_fee_id', ts('Fee Level'), array('class' => 'big crm-ajax-select'));
 
     CRM_Core_Form_Date::buildDateRange($form, 'event', 1, '_start_date_low', '_end_date_high', ts('From'), FALSE);
+    $eventIncludeRepeatingEvents = &$form->addElement('checkbox', "event_include_repeating_events", NULL, ts(' Include Repeating Events (If Any) ? '));
 
     $status = CRM_Event_PseudoConstant::participantStatus(NULL, NULL, 'label');
     foreach ($status as $id => $Name) {
@@ -638,7 +672,7 @@ class CRM_Event_BAO_Query {
     }
 
     CRM_Campaign_BAO_Campaign::addCampaignInComponentSearch($form, 'participant_campaign_id');
-
+    
     $form->assign('validCiviEvent', TRUE);
     $form->setDefaults(array('participant_test' => 0));
   }
index 62b688c2e9af145009abe60f1a961cc62fb4475b..d15b18a6afd4ce41ac3ab1a61e9e92feb81963d5 100644 (file)
@@ -84,6 +84,11 @@ class CRM_Event_Form_ManageEvent extends CRM_Core_Form {
    * the participant records
    */
   protected $_campaignID = NULL;
+  
+  /**
+   * Check if repeating event
+   */
+  protected $_isRepeatingEvent;
 
   /**
    * Function to set variables up before form is built
@@ -96,13 +101,14 @@ class CRM_Event_Form_ManageEvent extends CRM_Core_Form {
     if (in_array('CiviEvent', $config->enableComponents)) {
       $this->assign('CiviEvent', TRUE);
     }
-
+      
     $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'add', 'REQUEST');
 
     $this->assign('action', $this->_action);
 
     $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE, NULL, 'GET');
     if ($this->_id) {
+      $this->_isRepeatingEvent = CRM_Core_BAO_RecurringEntity::getParentFor($this->_id, 'civicrm_event');
       $this->assign('eventId', $this->_id);
       if (!empty($this->_addBlockName) && empty($this->_addProfileBottom) && empty($this->_addProfileBottomAdd)) {
         $this->add('hidden', 'id', $this->_id);
@@ -148,8 +154,13 @@ class CRM_Event_Form_ManageEvent extends CRM_Core_Form {
         CRM_Utils_System::setTitle(ts('Edit Event Template') . " - $title");
       }
       else {
+        $configureText = ts('Configure Event');
         $title = CRM_Utils_Array::value('title', $eventInfo);
-        CRM_Utils_System::setTitle(ts('Configure Event') . " - $title");
+        //If it is a repeating event change title
+        if($this->_isRepeatingEvent){
+          $configureText = 'Configure Repeating Event';
+        }
+        CRM_Utils_System::setTitle($configureText . " - $title");
       }
       $this->assign('title', $title);
     }
@@ -176,6 +187,12 @@ class CRM_Event_Form_ManageEvent extends CRM_Core_Form {
     }
 
     $this->_templateId = (int) CRM_Utils_Request::retrieve('template_id', 'Integer', $this);
+    
+    //Is a repeating event
+    if($this->_isRepeatingEvent){
+      $isRepeat = 'repeat';
+      $this->assign('isRepeat', $isRepeat);
+    }
 
     // also set up tabs
     CRM_Event_Form_ManageEvent_TabHeader::build($this);
diff --git a/CRM/Event/Form/ManageEvent/Repeat.php b/CRM/Event/Form/ManageEvent/Repeat.php
new file mode 100644 (file)
index 0000000..680bb13
--- /dev/null
@@ -0,0 +1,199 @@
+<?php
+
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+/**
+ * Description of Repeat
+ *
+ * @author Priyanka
+ */
+class CRM_Event_Form_ManageEvent_Repeat extends CRM_Event_Form_ManageEvent {
+  
+  /**
+   * Schedule Reminder Id
+   */
+  protected $_scheduleReminderId = NULL;
+  
+  /**
+   * Schedule Reminder data
+   */
+  protected $_scheduleReminderDetails = array();
+  
+  /**
+   *  Parent Event ID
+   */
+  protected $_parentEventId = NULL;
+  
+  /**
+   * Parent Event Start Date
+   */
+  protected $_parentEventStartDate = NULL;
+  
+  /**
+   * Parent Event End Date
+   */
+  protected $_parentEventEndDate = NULL;
+  
+  /**
+   * Exclude date information 
+   */
+  public $_excludeDateInfo = array();
+  
+  protected $_pager = NULL;
+  
+  
+  
+  function preProcess() {
+    parent::preProcess();
+    $this->assign('currentEventId', $this->_id);
+    
+    $checkParentExistsForThisId = CRM_Core_BAO_RecurringEntity::getParentFor($this->_id, 'civicrm_event');
+    $checkParentExistsForThisId;
+    //If this ID has parent, send parent id
+    if($checkParentExistsForThisId){
+      $this->_scheduleReminderDetails = CRM_Core_Form_RecurringEntity::getReminderDetailsByEventId($checkParentExistsForThisId);
+      $this->_parentEventId = $checkParentExistsForThisId;
+      
+      /**
+     * Get connected event information list
+     */
+      //Get all connected event ids
+      $allEventIds = CRM_Core_Form_RecurringEntity::getAllConnectedEvents($checkParentExistsForThisId);
+      if($allEventIds->entity_id){
+        //echo "<pre>"; print_r($eventIds);
+        //list($offset, $rowCount) = $this->_pager->getOffsetAndRowCount();
+        $params = array();
+        $query = "
+          SELECT *
+          FROM civicrm_event
+          WHERE id IN (".$allEventIds->entity_id.")
+          ORDER BY start_date asc
+           ";
+
+        $dao = CRM_Core_DAO::executeQuery($query, $params, TRUE, 'CRM_Event_DAO_Event');
+        //$permissions = CRM_Event_BAO_Event::checkPermission();
+        while($dao->fetch()){
+//          if(in_array($dao->id, $permissions[CRM_Core_Permission::VIEW])){
+          if($dao->id){
+            $manageEvent[$dao->id] = array();
+            CRM_Core_DAO::storeValues($dao, $manageEvent[$dao->id]);
+          }
+        }
+        $this->assign('rows', $manageEvent);
+      }
+    }else{
+      //ELse send this id as parent
+      $this->_scheduleReminderDetails = CRM_Core_Form_RecurringEntity::getReminderDetailsByEventId($this->_id);
+      $this->_parentEventId = $this->_id;
+    }
+    //Assign this to hide summary
+    $this->assign('scheduleReminderId', $this->_scheduleReminderDetails->id);
+    
+    $parentEventParams = array('id' => $this->_id);
+    $parentEventValues = array();
+    $parentEventReturnProperties = array('start_date', 'end_date');
+    $parentEventAttributes = CRM_Core_DAO::commonRetrieve('CRM_Event_DAO_Event', $parentEventParams, $parentEventValues, $parentEventReturnProperties);
+    $this->_parentEventStartDate = $parentEventAttributes->start_date;
+    $this->_parentEventEndDate = $parentEventAttributes->end_date;
+    
+    //Get option exclude date information
+    //$groupId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', 'event_repeat_exclude_dates_'.$this->_parentEventId, 'id', 'name');
+    CRM_Core_OptionValue::getValues(array('name' => 'event_repeat_exclude_dates_'.$this->_parentEventId), $optionValue);
+    $excludeOptionValues = array();
+    if(!empty($optionValue)){
+      foreach($optionValue as $key => $val){
+        $excludeOptionValues[$val['value']] = date('m/d/Y', strtotime($val['value']));
+      }
+      $this->_excludeDateInfo = $excludeOptionValues;
+    } 
+  }
+  
+  /**
+   * This function sets the default values for the form. For edit/view mode
+   * the default values are retrieved from the database
+   *
+   * @access public
+   *
+   * @return None
+   */
+  function setDefaultValues() {
+    $defaults = array();
+    
+    //Set Schedule Reminder Id
+      $this->_scheduleReminderId = $this->_scheduleReminderDetails->id;
+
+    // Check if there is id for this event in Reminder table
+    if($this->_scheduleReminderId){
+      $defaults['repetition_frequency_unit'] = $this->_scheduleReminderDetails->repetition_frequency_unit;
+      $defaults['repetition_frequency_interval'] = $this->_scheduleReminderDetails->repetition_frequency_interval;
+      $defaults['start_action_condition'] = array_flip(explode(",",$this->_scheduleReminderDetails->start_action_condition));
+      foreach($defaults['start_action_condition'] as $key => $val){
+        $val = 1;
+        $defaults['start_action_condition'][$key] = $val;
+      }
+      list($defaults['repeat_event_start_date'], $defaults['repeat_event_start_date_time']) = CRM_Utils_Date::setDateDefaults($this->_parentEventStartDate, 'activityDateTime');
+      $defaults['start_action_offset'] = $this->_scheduleReminderDetails->start_action_offset;
+      if($this->_scheduleReminderDetails->start_action_offset){
+        $defaults['ends'] = 1;
+      }
+      list($defaults['repeat_absolute_date']) = CRM_Utils_Date::setDateDefaults($this->_scheduleReminderDetails->absolute_date);
+      if($this->_scheduleReminderDetails->absolute_date){
+        $defaults['ends'] = 2;
+      }
+      $defaults['limit_to'] = $this->_scheduleReminderDetails->limit_to;
+      if($this->_scheduleReminderDetails->limit_to){
+        $defaults['repeats_by'] = 1;
+      }
+      $explodeStartActionCondition = array();
+      $explodeStartActionCondition = explode(" ", $this->_scheduleReminderDetails->start_action_date);
+      $defaults['start_action_date_1'] = $explodeStartActionCondition[0];
+      $defaults['start_action_date_2'] = $explodeStartActionCondition[1];
+      if($this->_scheduleReminderDetails->start_action_date){
+        $defaults['repeats_by'] = 2;
+      }
+      //echo "<pre>"; print_r($this->_excludeDateInfo);
+      $defaults['exclude_date_list'] = array('a', 'b');
+         /* array
+        (
+            0 => '08/25/2014',
+            1 => '08/28/2014'
+        );*/
+    } 
+    return $defaults;
+  }
+  
+  public function buildQuickForm() {
+    CRM_Core_Form_RecurringEntity::buildQuickForm($this);
+  }
+   
+  public function postProcess() {
+    if($this->_id){
+      $params = $this->controller->exportValues($this->_name); 
+      $params['parent_event_id'] = $this->_parentEventId;
+      $params['parent_event_start_date'] = $this->_parentEventStartDate;
+      $params['parent_event_end_date'] = $this->_parentEventEndDate;
+      //Unset event id
+      unset($params['id']);
+      
+      //Set Schedule Reminder id
+      $params['id'] = $this->_scheduleReminderId;
+      $url = 'civicrm/event/manage/repeat';
+      $urlParams = "action=update&reset=1&id={$this->_id}";
+      
+      //Check if isChangeInRepeatConfiguration is set in params
+//      if($params['isChangeInRepeatConfiguration'] == 1){
+//        CRM_Core_Form_RecurringEntity::updateRecurCriterias($this->_id);
+//      }
+      CRM_Core_Form_RecurringEntity::postProcess($params, 'event');
+      CRM_Utils_System::redirect(CRM_Utils_System::url($url, $urlParams));
+      //CRM_Core_Error::debug_var('Event Recursion');
+    }else{
+        CRM_Core_Error::fatal("Could not find Event ID");
+    }  
+  }
+  
+}
\ No newline at end of file
index e488114b651be0e604f9710791b213b76c82b8f7..d8316ec857817042e40075cc0e9a5c262faa89c9 100644 (file)
@@ -89,6 +89,7 @@ class CRM_Event_Form_ManageEvent_TabHeader {
     $tabs['conference'] = array('title' => ts('Conference Slots')) + $default;
     $tabs['friend'] = array('title' => ts('Tell a Friend')) + $default;
     $tabs['pcp'] = array('title' => ts('Personal Campaigns')) + $default;
+    $tabs['repeat'] = array('title' => ts('Repeat')) + $default;
 
 
     // check if we're in shopping cart mode for events
@@ -111,6 +112,8 @@ LEFT JOIN  civicrm_action_mapping  map ON ( map.entity_value = 'civicrm_event' )
 LEFT JOIN  civicrm_action_schedule sch ON ( sch.mapping_id = map.id AND sch.entity_value = %1 )
 WHERE      e.id = %1
 ";
+      //Check if repeat is configured
+      $eventHasParent = CRM_Core_BAO_RecurringEntity::getParentFor($eventID, 'civicrm_event');
       $params = array(1 => array($eventID, 'Integer'));
       $dao = CRM_Core_DAO::executeQuery($sql, $params);
       if (!$dao->fetch()) {
@@ -134,6 +137,9 @@ WHERE      e.id = %1
       if (!$dao->is_reminder) {
         $tabs['reminder']['valid'] = FALSE;
       }
+      if(!$eventHasParent){
+        $tabs['repeat']['valid'] = FALSE;
+      }
     }
 
     // see if any other modules want to add any tabs
index 9df6e77c816fca42dec102b071b2231ff3a12e56..0a5b01a14d5b51ca8ca37d855736665053310ac5 100644 (file)
@@ -92,6 +92,11 @@ class CRM_Event_Page_ManageEvent extends CRM_Core_Page {
           'extra' => 'onclick = "return confirm(\'' . $copyExtra . '\');"',
           'title' => ts('Copy Event'),
         ),
+        'repeat' => array(
+          'title' => ts('Repeat Event'),
+          'url' => 'civicrm/event/manage/repeat',
+          'field' => 'is_pcp_enabled',
+        )
       );
     }
     return self::$_actionLinks;
@@ -311,6 +316,15 @@ ORDER BY start_date desc
     while ($dao->fetch()) {
       if (in_array($dao->id, $permissions[CRM_Core_Permission::VIEW])) {
         $manageEvent[$dao->id] = array();
+        $isRepeatingEvent = CRM_Core_BAO_RecurringEntity::getParentFor($dao->id, 'civicrm_event');
+        $manageEvent[$dao->id]['repeat'] = '';
+        if($isRepeatingEvent){
+          if($dao->id == $isRepeatingEvent){
+            $manageEvent[$dao->id]['repeat'] = 'Repeating Event - (Parent)';
+          }else{
+            $manageEvent[$dao->id]['repeat'] = 'Repeating Event - (Child)';
+          }
+        }
         CRM_Core_DAO::storeValues($dao, $manageEvent[$dao->id]);
 
         // form all action links
index 9222b5a92147b6cee067cb852091c56ed914511a..de94dbd9170442978cb427848ce9ddd10a704e3b 100644 (file)
      <is_ssl>true</is_ssl>
      <weight>950</weight>
   </item>
+  <item>
+     <path>civicrm/event/manage/repeat</path>
+     <title>Repeat Event</title>
+     <page_callback>CRM_Event_Form_ManageEvent_Repeat</page_callback>
+     <access_arguments>access CiviEvent</access_arguments>
+     <is_ssl>true</is_ssl>
+     <weight>960</weight>
+  </item>
   <item>
      <path>civicrm/event/manage/conference</path>
      <title>Conference Slots</title>
     <page_callback>CRM_Event_Form_ParticipantFeeSelection</page_callback>
     <access_arguments>access CiviEvent</access_arguments>
   </item>
+  <item>
+     <path>civicrm/ajax/recurringEntity/update_cascade_type</path>
+     <page_callback>CRM_Core_Page_Ajax_RecurringEntity::updateCascadeType</page_callback>
+     <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>
+     <access_arguments>access CiviCRM,access CiviEvent</access_arguments>
+  </item>
 </menu>
diff --git a/templates/CRM/Event/Form/ConfirmSubmit.tpl b/templates/CRM/Event/Form/ConfirmSubmit.tpl
new file mode 100644 (file)
index 0000000..5bca022
--- /dev/null
@@ -0,0 +1,103 @@
+{*
+ +--------------------------------------------------------------------+
+ | CiviCRM version 4.4                                                |
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC (c) 2004-2013                                |
+ +--------------------------------------------------------------------+
+ | 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        |
+ +--------------------------------------------------------------------+
+*}
+  <div id="dialog" style="display:none;">
+      Would you like to change this event only, or this and following events in series?<br/><br/>
+      <div style="display: inline-block">
+          <div style="display:inline-block;width:100%;">
+              <div style="width:30%;float:left;">
+                  <button class="dialog-button only-this-event">Only this Event</button>
+              </div>
+              <div style="width:70%;float:left;">All other events in the series will remain same</div></div>
+          <div style="display:inline-block;width:100%;">
+              <div style="width:30%;float:left;">
+                  <button class="dialog-button this-and-all-following-event">This and Following Events</button>
+              </div>
+              <div style="width:70%;float:left;">This and all the following events will be changed</div>
+          </div>
+      </div>
+  </div>
+  <input type="hidden" value="" name="isRepeatingEvent" id="is-repeating-event"/>
+{literal}
+    <style type="text/css">
+        .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;
+        }
+    </style>
+{/literal}
+{*{foreach from=$form.buttons item=button key=key name=btns}
+    {if $key|substring:0:4 EQ '_qf_'}
+    {/if}
+{/foreach}*}
+{if $isRepeat eq 'repeat'}
+    {literal}
+        <script type="text/javascript">
+        cj(document).ready(function() {
+           cj("#dialog").dialog({ autoOpen: false });
+            cj('div.crm-submit-buttons span.crm-button input[value="Save"], div.crm-submit-buttons span.crm-button input[value="Save and Done"]').click( function () {
+                cj("#dialog").dialog('open');
+                cj("#dialog").dialog({
+                    title: 'Save recurring event',
+                    width: '650',
+                    position: 'center',
+                    //draggable: false,
+                    buttons: {
+                        Cancel: function() { //cancel
+                            cj( this ).dialog( "close" );
+                        }
+                    }
+                });
+                return false;
+            });
+            cj(".this-and-all-following-event").click(function(){
+                var eventID ={/literal}{$id}{literal};
+                if(eventID != ""){
+                    var ajaxurl = CRM.url("civicrm/ajax/recurringEntity/update_cascade_type");
+                    var data    = {cascadeType: 2, entityId: eventID};
+                    cj.ajax({
+                      dataType: "json",
+                      data: data,
+                      url:  ajaxurl,
+                      success: function (result) {
+                          cj("#dialog").dialog('close');
+                      }
+                    });
+                }
+            });
+            cj(".only-this-event").click(function(){
+                cj("#dialog").dialog('close');
+                cj("form").submit();
+            });
+        });
+        </script>
+    {/literal}
+{/if}
index 2f3de3509de52f5429f1d3caba977c7479d9e4c3..92923e358214a4753b012d71c7ee0d1707aa6336 100644 (file)
     </tr>
   </table>
   <div id="customData"></div>
+  {include file="CRM/Form/validate.tpl"}
   {*include custom data js file*}
-  {include file="CRM/common/customData.tpl"}
+  {include file="CRM/Event/Form/ConfirmSubmit.tpl"}
   {literal}
     <script type="text/javascript">
       CRM.$(function($) {
index 930aaffc1150ce2f07a6cce053459986b7af2350..cded386492f26225c017fd9d0b735a0742510fe6 100644 (file)
     </div>
     </div>
     </div>
+{include file="CRM/Event/Form/ConfirmSubmit.tpl"}
 <div class="crm-submit-buttons">
    {include file="CRM/common/formButtons.tpl" location="bottom"}
 </div>
index 4a32041df5850fba2822453c72adddffed76082f..7ac4ae09fb053e6c88f6272fbe88a490f5193fd0 100644 (file)
         <td id="locUsedMsg" colspan="3">
         </td>
       </tr>
-
+     
     </table>
     {/if}
-
+    
 
 
     <div id="newLocation">
@@ -87,6 +87,7 @@
     </td>
   </tr>
   </table>
+ {include file="CRM/Event/Form/ConfirmSubmit.tpl"}
 <div class="crm-submit-buttons">
    {include file="CRM/common/formButtons.tpl" location="bottom"}
 </div>
index cbc515ae9ae271c686c4047c4663469f2a0f724e..065af190b7a8a2cf2bafb453bf9c8982bc2e74b8 100644 (file)
@@ -353,6 +353,7 @@ class="crm-hover-button crm-button-add-profile"><span
 </fieldset>
 </div> {*end of div registration_blocks*}
     </div>
+  {include file="CRM/Event/Form/ConfirmSubmit.tpl"}   
   <div class="crm-submit-buttons">
     {include file="CRM/common/formButtons.tpl" location="bottom"}
   </div>
diff --git a/templates/CRM/Event/Form/ManageEvent/Repeat.hlp b/templates/CRM/Event/Form/ManageEvent/Repeat.hlp
new file mode 100644 (file)
index 0000000..91f78d4
--- /dev/null
@@ -0,0 +1,81 @@
+{*
+ +--------------------------------------------------------------------+
+ | CiviCRM version 4.4                                                |
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC (c) 2004-2010                                |
+ +--------------------------------------------------------------------+
+ | 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        |
+ +--------------------------------------------------------------------+
+*}
+
+{htxt id="id-repeats-title"}
+{ts}Repeats{/ts}
+{/htxt}
+{htxt id="id-repeats"}
+  {ts}{/ts}
+{/htxt}
+
+{htxt id="id-repeats-every-title"}
+{ts}Repeats every{/ts}
+{/htxt}
+{htxt id="id-repeats-every"}
+  {ts}This option defines the interval.{/ts}
+{/htxt}
+
+{htxt id="id-repeats-on-title"}
+{ts}Repeats on{/ts}
+{/htxt}
+{htxt id="id-repeats-on"}
+  {ts}{/ts}
+{/htxt}
+
+{htxt id="id-repeats-by-month-title"}
+{ts}Repeats by day of the month{/ts}
+{/htxt}
+{htxt id="id-repeats-by-month"}
+  {ts}{/ts}
+{/htxt}
+
+{htxt id="id-repeats-by-week-title"}
+{ts}Repeats by day of the week{/ts}
+{/htxt}
+{htxt id="id-repeats-by-week"}
+  {ts}{/ts}
+{/htxt}
+
+{htxt id="id-ends-after-title"}
+{ts}Ends{/ts}
+{/htxt}
+{htxt id="id-ends-after"}
+  {ts}{/ts}
+{/htxt}
+
+{htxt id="id-ends-on-title"}
+{ts}Ends{/ts}
+{/htxt}
+{htxt id="id-ends-on"}
+  {ts}{/ts}
+{/htxt}
+
+{htxt id="id-exclude-date-title"}
+{ts}Exclude Date{/ts}
+{/htxt}
+{htxt id="id-exclude-date"}
+  {ts}Dates added here would be ignored for repeating events{/ts}
+{/htxt}
\ No newline at end of file
diff --git a/templates/CRM/Event/Form/ManageEvent/Repeat.tpl b/templates/CRM/Event/Form/ManageEvent/Repeat.tpl
new file mode 100644 (file)
index 0000000..3950499
--- /dev/null
@@ -0,0 +1,91 @@
+{*
+ +--------------------------------------------------------------------+
+ | CiviCRM version 4.5                                                |
+ +--------------------------------------------------------------------+
+ | 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        |
+ +--------------------------------------------------------------------+
+*}
+<div class="crm-block crm-form-block crm-event-manage-repeat-form-block">
+{include file="CRM/Core/Form/RecurringEntity.tpl"}
+{if $rows}
+<div id="event_status_id" class="crm-block crm-manage-events crm-accordion-wrapper">
+  <div class="crm-accordion-header">Connected Repeating Events</div>
+  <div class="crm-accordion-body">
+  {strip}
+  {include file="CRM/common/jsortable.tpl"}
+    <table id="options" class="display">
+      <thead>
+      <tr>
+        <th>{ts}Event{/ts}</th>
+        <th>{ts}Public?{/ts}</th>
+        <th>{ts}Starts{/ts}</th>
+        <th>{ts}Ends{/ts}</th>
+        <th>{ts}Active?{/ts}</th>
+        <th>{ts}Event Link{/ts}</th>
+        <th class="hiddenElement"></th>
+        <th class="hiddenElement"></th>
+      </tr>
+      </thead>
+      {foreach from=$rows key=keys item=row}
+        {if $keys neq 'tab'}
+          {if $currentEventId eq $row.id}
+              {assign var="highlight" value=" highlight-record"}
+          {else}
+              {assign var="highlight" value=""}
+          {/if}
+          <tr id="row_{$row.id}" class="{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})
+          </td>
+          <td class="crm-event-is_public{$highlight}">{if $row.is_public eq 1} {ts}Yes{/ts} {else} {ts}No{/ts} {/if}</td>
+          <td class="crm-event-start_date{$highlight}">{$row.start_date|crmDate:"%b %d, %Y %l:%M %P"}</td>
+          <td class="crm-event-end_date{$highlight}">{$row.end_date|crmDate:"%b %d, %Y %l:%M %P"}</td>
+          <td class="crm-event_status{$highlight}" id="row_{$row.id}_status">
+            {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>
+          </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>
+        </tr>
+        {/if}
+      {/foreach}
+    </table>
+  {include file="CRM/common/pager.tpl" location="bottom"}
+  {/strip}
+  </div>
+</div>
+{/if}
+</div>
+{*Hide Summary*}
+{if empty($scheduleReminderId)}
+    {literal}
+        <script type="text/javascript">
+        cj(document).ready(function() {
+            if(cj('#rec-summary').length){
+                cj('#rec-summary').parent().parent().hide();
+            }
+        });
+        </script>
+    {/literal}
+{/if}
\ No newline at end of file
index 6095070c6a703821e1643c598d086d3b4ab1d86f..d584db8251334c5f1404fe5ae055f877ec30e4cd 100755 (executable)
     </script>
   {/literal}
   {/if}
+  {include file="CRM/Event/Form/ConfirmSubmit.tpl"}
   <div class="crm-submit-buttons">
     {include file="CRM/common/formButtons.tpl" location="bottom"}
   </div>
index 2e8f85966d2445c23ddfba4841110431b0b3c3e2..74e0798512de019c48d60494e1e9516b6ab219af 100644 (file)
         </tr>
     </table>
     </div>
+  {include file="CRM/Event/Form/ConfirmSubmit.tpl"}
   <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div>
 </div>
 
index 3bdb87907ea7f3106b0105ff57a12f6637654da6..ecd5cc0e8bddab97e09e9a9c29f2afa07022f29c 100644 (file)
@@ -90,6 +90,7 @@
   </table>
 {/crmRegion}
 </div>
+{include file="CRM/Event/Form/ConfirmSubmit.tpl"}
 <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div>
 </div>
 {include file="CRM/common/showHideByFieldValue.tpl"
index 726da804dc0225e0851f6864aa9bdbf38038eef1..e504902d87d8da719c59297acfc1564a1fb30c78 100644 (file)
     <onDelete>SET NULL</onDelete>
     <add>4.5</add>
   </foreignKey>
+  <field>
+    <name>used_for</name>
+    <type>varchar</type>
+    <length>64</length>
+    <comment>Maintained for recurring entity</comment>
+    <add>4.4</add>
+  </field>
 </table>
diff --git a/xml/schema/Core/RecurringEntity.xml b/xml/schema/Core/RecurringEntity.xml
new file mode 100644 (file)
index 0000000..e43f334
--- /dev/null
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="iso-8859-1" ?>
+
+<table>
+  <base>CRM/Core</base>
+  <class>RecurringEntity</class>
+  <name>civicrm_recurring_entity</name>
+  <add>1.7</add>
+  <log>true</log>
+  <field>
+      <name>id</name>
+      <title>ID</title>
+      <type>int unsigned</type>
+      <required>true</required>      
+      <add>1.7</add>
+  </field>
+  <primaryKey>
+       <name>id</name>
+       <autoincrement>true</autoincrement>
+  </primaryKey>
+  <field>
+      <name>parent_id</name>
+      <type>int unsigned</type>
+      <title>Parent ID</title>
+      <required>true</required>
+      <add>1.7</add>
+  </field>
+  <field>
+      <name>entity_id</name>
+      <type>int unsigned</type>
+      <title>Entity ID</title>
+      <add>1.7</add>
+  </field>
+  <field>
+      <name>entity_table</name>
+      <type>varchar</type>
+      <title>Entity Table</title>
+      <required>true</required>
+      <add>1.7</add>
+  </field>
+</table>
\ No newline at end of file
index ca448f2106d2620375a6183296016a101af204cb..aaac22233adb934604a36c79c546824b6e67b52f 100644 (file)
@@ -54,4 +54,5 @@
   <xi:include href="Setting.xml"              parse="xml" />
   <xi:include href="PrintLabel.xml"           parse="xml" />
   <xi:include href="WordReplacement.xml"      parse="xml" />
+  <xi:include href="RecurringEntity.xml"      parse="xml" />
 </tables>