Commit a7ea18bf authored by unknown's avatar unknown

fixed - Post process generates same dates for all the activities, Generalise...

fixed - Post process generates same dates for all the activities, Generalise ajax parameters for preview pop up
parent 78fe87e6
......@@ -950,6 +950,7 @@ class CRM_Activity_Form_Activity extends CRM_Contact_Form_Task {
// save activity
$activity = $this->processActivity($params);
$params['parent_entity_start_date'] = $this->_parentActivityStartDate;
$params['start_date_column_name'] = 'activity_date_time';
//Unset activity id
unset($params['id']);
$linkedEntities = array(
......
......@@ -63,8 +63,14 @@ class CRM_Core_Form_RecurringEntity {
*/
public static $_excludeDateInfo = array();
/**
* Entity Type
*/
public static $_entityType;
static function preProcess($entityType) {
self::$_entityId = (int) CRM_Utils_Request::retrieve('id', 'Positive');
self::$_entityType = $entityType;
if (self::$_entityId && $entityType) {
$checkParentExistsForThisId = CRM_Core_BAO_RecurringEntity::getParentFor(self::$_entityId, 'civicrm_'.$entityType);
if ($checkParentExistsForThisId) {
......@@ -132,6 +138,7 @@ class CRM_Core_Form_RecurringEntity {
static function buildQuickForm(&$form) {
$form->assign('currentEntityId', self::$_entityId);
$form->assign('entityType', self::$_entityType);
$form->_freqUnits = array('hour' => 'hour') + CRM_Core_OptionGroup::values('recur_frequency_units');
foreach ($form->_freqUnits as $val => $label) {
......@@ -357,7 +364,7 @@ class CRM_Core_Form_RecurringEntity {
$participantDetails = CRM_Event_Form_ManageEvent_Repeat::getParticipantCountforEvent($getRelatedEntities);
//Check if participants exists for events
foreach ($getRelatedEntities as $key => $value) {
if (!CRM_Utils_Array::value($value['id'], $participantDetails['countByID']) && $value['id'] != $params['event_id']) {
if (!CRM_Utils_Array::value($value['id'], $participantDetails['countByID']) && $value['id'] != $params['entity_id']) {
CRM_Event_BAO_Event::del($value['id']);
}
}
......@@ -366,12 +373,21 @@ class CRM_Core_Form_RecurringEntity {
}
$recursion = new CRM_Core_BAO_RecurringEntity();
$recursion->dateColumns = array('start_date');
if (CRM_Utils_Array::value('start_date_column_name', $params)) {
$recursion->dateColumns = array($params['start_date_column_name']);
}
$recursion->scheduleId = $actionScheduleObj->id;
if (!empty($excludeDateList)) {
$recursion->excludeDates = $excludeDateList;
$recursion->excludeDateRangeColumns = array('start_date', 'end_date');
$excludeDateRangeColumns = array();
if (CRM_Utils_Array::value('start_date_column_name', $params)) {
$excludeDateRangeColumns[] = $params['start_date_column_name'];
}
if (CRM_Utils_Array::value('end_date_column_name', $params)) {
$excludeDateRangeColumns[] = $params['end_date_column_name'];
}
$recursion->excludeDateRangeColumns = $excludeDateRangeColumns;
}
if ($params['parent_entity_end_date']) {
......
......@@ -62,9 +62,9 @@ class CRM_Core_Page_AJAX_RecurringEntity {
$recursion->excludeDateRangeColumns = array('start_date', 'end_date');
}
$parentEventId = CRM_Core_BAO_RecurringEntity::getParentFor($formValues['event_id'], 'civicrm_event');
$parentEventId = CRM_Core_BAO_RecurringEntity::getParentFor($formValues['entity_id'], 'civicrm_event');
if (!$parentEventId) {
$parentEventId = $formValues['event_id'];
$parentEventId = $formValues['entity_id'];
}
$endDate = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $parentEventId, 'end_date');
......
......@@ -108,6 +108,8 @@ class CRM_Event_Form_ManageEvent_Repeat extends CRM_Event_Form_ManageEvent {
$params = $this->controller->exportValues($this->_name);
$params['parent_entity_start_date'] = $this->_parentEventStartDate;
$params['parent_entity_end_date'] = $this->_parentEventEndDate;
$params['start_date_column_name'] = 'start_date';
$params['end_date_column_name'] = 'end_date';
//Unset event id
unset($params['id']);
......
......@@ -248,9 +248,10 @@
}
});
var ajaxurl = CRM.url("civicrm/ajax/recurringentity/generate-preview");
var eventID = {/literal}{$currentEntityId}{literal};
if (eventID != "") {
ajaxurl += "?event_id="+eventID;
var entityID = {/literal}{$currentEntityId}{literal};
var entityType = '{/literal}{$entityType}{literal}';
if (entityID != "" && entityType != "") {
ajaxurl += "?entity_id="+entityID+"&entity_type="+entityType;
}
var formData = cj('form').serializeArray();
cj.ajax({
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment