From 7a4bb524a6941c48326988015044f76dbd6dba20 Mon Sep 17 00:00:00 2001 From: deepak-srivastava Date: Mon, 2 Feb 2015 17:13:08 +0000 Subject: [PATCH] support for multiple recurring activities --- CRM/Activity/Form/Activity.php | 63 ++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 30 deletions(-) diff --git a/CRM/Activity/Form/Activity.php b/CRM/Activity/Form/Activity.php index 99d080e344..d806d7722f 100644 --- a/CRM/Activity/Form/Activity.php +++ b/CRM/Activity/Form/Activity.php @@ -964,39 +964,42 @@ class CRM_Activity_Form_Activity extends CRM_Contact_Form_Task { $activity = $this->processActivity($params); } - //Set for repeat configuration in create mode - $params['entity_id'] = $this->_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) { - $params['parent_entity_id'] = $checkParentExistsForThisId; - $scheduleReminderDetails = CRM_Core_BAO_RecurringEntity::getReminderDetailsByEntityId($checkParentExistsForThisId, $params['entity_table']); - } - else { - $params['parent_entity_id'] = $params['entity_id']; - $scheduleReminderDetails = CRM_Core_BAO_RecurringEntity::getReminderDetailsByEntityId($params['entity_id'], $params['entity_table']); - } - if (property_exists($scheduleReminderDetails, 'id')) { - $params['schedule_reminder_id'] = $scheduleReminderDetails->id; + $activityIds = empty($this->_activityIds) ? array($this->_activityId) : $this->_activityIds; + foreach ($activityIds as $activityId) { + // 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) { + $params['parent_entity_id'] = $checkParentExistsForThisId; + $scheduleReminderDetails = CRM_Core_BAO_RecurringEntity::getReminderDetailsByEntityId($checkParentExistsForThisId, $params['entity_table']); + } + else { + $params['parent_entity_id'] = $params['entity_id']; + $scheduleReminderDetails = CRM_Core_BAO_RecurringEntity::getReminderDetailsByEntityId($params['entity_id'], $params['entity_table']); + } + if (property_exists($scheduleReminderDetails, 'id')) { + $params['schedule_reminder_id'] = $scheduleReminderDetails->id; + } } - } - $params['dateColumns'] = array('activity_date_time'); + $params['dateColumns'] = array('activity_date_time'); - //Unset activity id - unset($params['id']); - $linkedEntities = array( - array( - 'table' => 'civicrm_activity_contact', - 'findCriteria' => array( - 'activity_id' => $this->_activityId, + // unset activity id + unset($params['id']); + $linkedEntities = array( + array( + 'table' => 'civicrm_activity_contact', + 'findCriteria' => array( + 'activity_id' => $activityId, + ), + 'linkedColumns' => array('activity_id'), + 'isRecurringEntityRecord' => FALSE, ), - 'linkedColumns' => array('activity_id'), - 'isRecurringEntityRecord' => FALSE, - ), - ); - CRM_Core_Form_RecurringEntity::postProcess($params, 'civicrm_activity', $linkedEntities); + ); + CRM_Core_Form_RecurringEntity::postProcess($params, 'civicrm_activity', $linkedEntities); + } return array('activity' => $activity); } -- 2.25.1