$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('event_id', $formParams)){
+ $parent_event_id = self::getParentFor($formParams['event_id'], 'civicrm_event');
+ if($parent_event_id){
+ $dbParams['entity_value'] = $parent_event_id;
+ }else{
+ $dbParams['entity_value'] = $formParams['event_id'];
+ }
}
if(CRM_Utils_Array::value('repetition_start_date', $formParams)) {
}
//Delete relations if any from recurring entity tables before inserting new relations for this entity id
- if($params['parent_event_id']){
- $getRelatedEntities = CRM_Core_BAO_RecurringEntity::getEntitiesForParent($params['parent_event_id'], 'civicrm_event', FALSE);
+ if($params['event_id']){
+ $getRelatedEntities = CRM_Core_BAO_RecurringEntity::getEntitiesFor($params['event_id'], 'civicrm_event', TRUE);
$participantDetails = CRM_Core_BAO_RecurringEntity::getParticipantCountforEvent($getRelatedEntities);
//Check if participants exists for events
foreach ($getRelatedEntities as $key => $value) {
- if(!CRM_Utils_Array::value($value['id'], $participantDetails['countByID'])){
+ if(!CRM_Utils_Array::value($value['id'], $participantDetails['countByID']) && $value['id'] != $params['event_id']){
CRM_Event_BAO_Event::del($value['id']);
}
}
- CRM_Core_BAO_RecurringEntity::delEntityRelations($params['parent_event_id'], 'civicrm_event');
+ CRM_Core_BAO_RecurringEntity::delEntityRelations($params['event_id'], 'civicrm_event');
}
$recursion = new CRM_Core_BAO_RecurringEntity();
}
//Show the list of participants registered for the events if any
- $getConnectedEntities = CRM_Core_BAO_RecurringEntity::getEntitiesForParent($parentEventId, 'civicrm_event', FALSE);
+ $getConnectedEntities = CRM_Core_BAO_RecurringEntity::getEntitiesForParent($parentEventId, 'civicrm_event', TRUE);
if($getConnectedEntities){
$participantDetails = CRM_Core_BAO_RecurringEntity::getParticipantCountforEvent($getConnectedEntities);
if(!empty($participantDetails['countByName'])){