Commit | Line | Data |
---|---|---|
2aa397bc TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
4 | | CiviCRM version 4.6 | | |
5 | +--------------------------------------------------------------------+ | |
6 | | Copyright CiviCRM LLC (c) 2004-2014 | | |
7 | +--------------------------------------------------------------------+ | |
8 | | This file is a part of CiviCRM. | | |
9 | | | | |
10 | | CiviCRM is free software; you can copy, modify, and distribute it | | |
11 | | under the terms of the GNU Affero General Public License | | |
12 | | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | | |
13 | | | | |
14 | | CiviCRM is distributed in the hope that it will be useful, but | | |
15 | | WITHOUT ANY WARRANTY; without even the implied warranty of | | |
16 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | | |
17 | | See the GNU Affero General Public License for more details. | | |
18 | | | | |
19 | | You should have received a copy of the GNU Affero General Public | | |
20 | | License and the CiviCRM Licensing Exception along | | |
21 | | with this program; if not, contact CiviCRM LLC | | |
22 | | at info[AT]civicrm[DOT]org. If you have questions about the | | |
23 | | GNU Affero General Public License or the licensing of CiviCRM, | | |
24 | | see the CiviCRM license FAQ at http://civicrm.org/licensing | | |
25 | +--------------------------------------------------------------------+ | |
d25dd0ee | 26 | */ |
2aa397bc TO |
27 | |
28 | /** | |
29 | * | |
30 | * | |
31 | * @package CRM | |
32 | * @copyright CiviCRM LLC (c) 2004-2014 | |
33 | * $Id$ | |
34 | * | |
35 | */ | |
353ffa53 | 36 | |
2aa397bc TO |
37 | /** |
38 | * This class generates form components for processing Entity | |
39 | * | |
40 | */ | |
41 | class CRM_Core_Form_RecurringEntity { | |
42 | /** | |
43 | * Current entity id | |
44 | */ | |
45 | protected static $_entityId = NULL; | |
46 | ||
47 | /** | |
48 | * Schedule Reminder ID | |
49 | */ | |
50 | protected static $_scheduleReminderID = NULL; | |
51 | ||
52 | /** | |
53 | * Schedule Reminder data | |
54 | */ | |
55 | protected static $_scheduleReminderDetails = array(); | |
56 | ||
57 | /** | |
58 | * Parent Entity ID | |
59 | */ | |
60 | protected static $_parentEntityId = NULL; | |
61 | ||
62 | /** | |
63 | * Exclude date information | |
64 | */ | |
65 | public static $_excludeDateInfo = array(); | |
66 | ||
67 | /** | |
68 | * Entity Table | |
69 | */ | |
70 | public static $_entityTable; | |
71 | ||
72 | /** | |
73 | * Checks current entityID has parent | |
74 | */ | |
75 | public static $_hasParent = FALSE; | |
76 | ||
77 | public static function preProcess($entityTable) { | |
78 | self::$_entityId = (int) CRM_Utils_Request::retrieve('id', 'Positive'); | |
79 | self::$_entityTable = $entityTable; | |
80 | ||
81 | if (self::$_entityId && $entityTable) { | |
82 | $checkParentExistsForThisId = CRM_Core_BAO_RecurringEntity::getParentFor(self::$_entityId, $entityTable); | |
83 | if ($checkParentExistsForThisId) { | |
84 | self::$_hasParent = TRUE; | |
85 | self::$_parentEntityId = $checkParentExistsForThisId; | |
86 | self::$_scheduleReminderDetails = CRM_Core_BAO_RecurringEntity::getReminderDetailsByEntityId($checkParentExistsForThisId, $entityTable); | |
87 | } | |
88 | else { | |
89 | self::$_parentEntityId = self::$_entityId; | |
90 | self::$_scheduleReminderDetails = CRM_Core_BAO_RecurringEntity::getReminderDetailsByEntityId(self::$_entityId, $entityTable); | |
91 | } | |
92 | if (property_exists(self::$_scheduleReminderDetails, 'id')) { | |
93 | self::$_scheduleReminderID = self::$_scheduleReminderDetails->id; | |
94 | } | |
95 | } | |
96 | if ($entityTable) { | |
92fcb95f | 97 | CRM_Core_OptionValue::getValues(array('name' => $entityTable . '_repeat_exclude_dates_' . self::$_parentEntityId), $optionValue); |
2aa397bc TO |
98 | $excludeOptionValues = array(); |
99 | if (!empty($optionValue)) { | |
22e263ad | 100 | foreach ($optionValue as $key => $val) { |
2aa397bc TO |
101 | $excludeOptionValues[$val['value']] = date('m/d/Y', strtotime($val['value'])); |
102 | } | |
103 | self::$_excludeDateInfo = $excludeOptionValues; | |
104 | } | |
105 | } | |
106 | } | |
107 | ||
108 | /** | |
109 | * Set default values for the form. For edit/view mode | |
110 | * the default values are retrieved from the database | |
111 | * | |
112 | * | |
16b10e64 | 113 | * @return array |
2aa397bc TO |
114 | */ |
115 | public static function setDefaultValues() { | |
116 | $defaults = array(); | |
117 | if (self::$_scheduleReminderID) { | |
118 | $defaults['repetition_frequency_unit'] = self::$_scheduleReminderDetails->repetition_frequency_unit; | |
119 | $defaults['repetition_frequency_interval'] = self::$_scheduleReminderDetails->repetition_frequency_interval; | |
120 | $defaults['start_action_condition'] = array_flip(explode(",", self::$_scheduleReminderDetails->start_action_condition)); | |
22e263ad | 121 | foreach ($defaults['start_action_condition'] as $key => $val) { |
2aa397bc TO |
122 | $val = 1; |
123 | $defaults['start_action_condition'][$key] = $val; | |
124 | } | |
125 | $defaults['start_action_offset'] = self::$_scheduleReminderDetails->start_action_offset; | |
126 | if (self::$_scheduleReminderDetails->start_action_offset) { | |
127 | $defaults['ends'] = 1; | |
128 | } | |
129 | list($defaults['repeat_absolute_date']) = CRM_Utils_Date::setDateDefaults(self::$_scheduleReminderDetails->absolute_date); | |
130 | if (self::$_scheduleReminderDetails->absolute_date) { | |
131 | $defaults['ends'] = 2; | |
132 | } | |
133 | $defaults['limit_to'] = self::$_scheduleReminderDetails->limit_to; | |
134 | if (self::$_scheduleReminderDetails->limit_to) { | |
135 | $defaults['repeats_by'] = 1; | |
136 | } | |
137 | $explodeStartActionCondition = array(); | |
138 | if (self::$_scheduleReminderDetails->entity_status) { | |
139 | $explodeStartActionCondition = explode(" ", self::$_scheduleReminderDetails->entity_status); | |
140 | $defaults['entity_status_1'] = $explodeStartActionCondition[0]; | |
141 | $defaults['entity_status_2'] = $explodeStartActionCondition[1]; | |
142 | } | |
143 | if (self::$_scheduleReminderDetails->entity_status) { | |
144 | $defaults['repeats_by'] = 2; | |
145 | } | |
146 | } | |
147 | return $defaults; | |
148 | } | |
149 | ||
150 | public static function buildQuickForm(&$form) { | |
151 | if (self::$_entityTable) { | |
152 | $entityType = explode("_", self::$_entityTable); | |
153 | if ($entityType[1]) { | |
154 | $form->assign('entityType', ucwords($entityType[1])); | |
155 | } | |
156 | } | |
157 | $form->assign('currentEntityId', self::$_entityId); | |
158 | $form->assign('entityTable', self::$_entityTable); | |
159 | $form->assign('scheduleReminderId', self::$_scheduleReminderID); | |
160 | $form->assign('hasParent', self::$_hasParent); | |
161 | ||
162 | $form->_freqUnits = array('hour' => 'hour') + CRM_Core_OptionGroup::values('recur_frequency_units'); | |
163 | foreach ($form->_freqUnits as $val => $label) { | |
164 | if ($label == "day") { | |
165 | $label = "dai"; | |
166 | } | |
167 | $freqUnitsDisplay[$val] = ts('%1ly', array(1 => $label)); | |
168 | } | |
169 | // echo "<pre>";print_r($freqUnitsDisplay); | |
170 | $dayOfTheWeek = array( | |
353ffa53 TO |
171 | 'monday' => 'Monday', |
172 | 'tuesday' => 'Tuesday', | |
173 | 'wednesday' => 'Wednesday', | |
174 | 'thursday' => 'Thursday', | |
175 | 'friday' => 'Friday', | |
176 | 'saturday' => 'Saturday', | |
177 | 'sunday' => 'Sunday', | |
178 | ); | |
2aa397bc TO |
179 | $form->add('select', 'repetition_frequency_unit', ts('Repeats:'), $freqUnitsDisplay); |
180 | $numericOptions = CRM_Core_SelectValues::getNumericOptions(1, 30); | |
181 | $form->add('select', 'repetition_frequency_interval', ts('Repeats every:'), $numericOptions, '', array('style' => 'width:55px;')); | |
182 | $form->addDateTime('repetition_start_date', ts('Repetition Start Date'), FALSE, array('formatType' => 'activityDateTime')); | |
22e263ad | 183 | foreach ($dayOfTheWeek as $key => $val) { |
92fcb95f | 184 | $startActionCondition[] = $form->createElement('checkbox', $key, NULL, substr($val . " ", 0, 3)); |
2aa397bc TO |
185 | } |
186 | $form->addGroup($startActionCondition, 'start_action_condition', ts('Repeats on')); | |
187 | $roptionTypes = array( | |
353ffa53 TO |
188 | '1' => ts('day of the month'), |
189 | '2' => ts('day of the week'), | |
190 | ); | |
2aa397bc TO |
191 | $form->addRadio('repeats_by', ts("Repeats By:"), $roptionTypes, array(), NULL); |
192 | $getMonths = CRM_Core_SelectValues::getNumericOptions(1, 31); | |
193 | $form->add('select', 'limit_to', '', $getMonths, FALSE, array('style' => 'width:55px;')); | |
194 | $dayOfTheWeekNo = array( | |
353ffa53 TO |
195 | 'first' => 'First', |
196 | 'second' => 'Second', | |
197 | 'third' => 'Third', | |
198 | 'fourth' => 'Fourth', | |
199 | 'last' => 'Last', | |
200 | ); | |
2aa397bc TO |
201 | $form->add('select', 'entity_status_1', ts(''), $dayOfTheWeekNo); |
202 | $form->add('select', 'entity_status_2', ts(''), $dayOfTheWeek); | |
203 | $eoptionTypes = array( | |
353ffa53 TO |
204 | '1' => ts('After'), |
205 | '2' => ts('On'), | |
206 | ); | |
2aa397bc TO |
207 | $form->addRadio('ends', ts("Ends:"), $eoptionTypes, array(), NULL); |
208 | $form->add('text', 'start_action_offset', ts(''), array('size' => 3, 'maxlength' => 2)); | |
209 | $form->addFormRule(array('CRM_Core_Form_RecurringEntity', 'formRule')); | |
210 | $form->addDate('repeat_absolute_date', ts('On'), FALSE, array('formatType' => 'mailing')); | |
211 | $form->addDate('exclude_date', ts('Exclude Date(s)'), FALSE); | |
353ffa53 TO |
212 | $select = $form->add('select', 'exclude_date_list', ts(''), self::$_excludeDateInfo, FALSE, array( |
213 | 'style' => 'width:150px;', | |
af9b09df | 214 | 'size' => 4, |
353ffa53 | 215 | )); |
2aa397bc TO |
216 | $select->setMultiple(TRUE); |
217 | $form->addElement('button', 'add_to_exclude_list', '>>', 'onClick="addToExcludeList(document.getElementById(\'exclude_date\').value);"'); | |
218 | $form->addElement('button', 'remove_from_exclude_list', '<<', 'onClick="removeFromExcludeList(\'exclude_date_list\')"'); | |
219 | $form->addElement('hidden', 'copyExcludeDates', '', array('id' => 'copyExcludeDates')); | |
220 | $form->addElement('hidden', 'allowRepeatConfigToSubmit', '', array('id' => 'allowRepeatConfigToSubmit')); | |
221 | $form->addButtons(array( | |
222 | array( | |
223 | 'type' => 'submit', | |
224 | 'name' => ts('Save'), | |
225 | 'isDefault' => TRUE, | |
226 | ), | |
227 | array( | |
228 | 'type' => 'cancel', | |
21dfd5f5 | 229 | 'name' => ts('Cancel'), |
2aa397bc TO |
230 | ), |
231 | ) | |
232 | ); | |
233 | } | |
234 | ||
235 | /** | |
236 | * Global validation rules for the form | |
237 | * | |
a1a2a83d TO |
238 | * @param array $values |
239 | * Posted values of the form. | |
2aa397bc | 240 | * |
a6c01b45 CW |
241 | * @return array |
242 | * list of errors to be posted back to the form | |
2aa397bc TO |
243 | */ |
244 | public static function formRule($values) { | |
245 | $errors = array(); | |
246 | //Process this function only when you get this variable | |
247 | if ($values['allowRepeatConfigToSubmit'] == 1) { | |
248 | $dayOfTheWeek = array('monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday'); | |
249 | //Repeats | |
250 | if (!CRM_Utils_Array::value('repetition_frequency_unit', $values)) { | |
251 | $errors['repetition_frequency_unit'] = ts('This is a required field'); | |
252 | } | |
253 | //Repeats every | |
254 | if (!CRM_Utils_Array::value('repetition_frequency_interval', $values)) { | |
255 | $errors['repetition_frequency_interval'] = ts('This is a required field'); | |
256 | } | |
257 | //Ends | |
258 | if (CRM_Utils_Array::value('ends', $values)) { | |
259 | if ($values['ends'] == 1) { | |
260 | if (empty($values['start_action_offset'])) { | |
261 | $errors['start_action_offset'] = ts('This is a required field'); | |
262 | } | |
4c9b6178 | 263 | elseif ($values['start_action_offset'] > 30) { |
2aa397bc TO |
264 | $errors['start_action_offset'] = ts('Occurrences should be less than or equal to 30'); |
265 | } | |
266 | } | |
267 | if ($values['ends'] == 2) { | |
268 | if (CRM_Utils_Array::value('repeat_absolute_date', $values)) { | |
269 | $entityStartDate = CRM_Utils_Date::processDate($values['repetition_start_date']); | |
270 | $end = CRM_Utils_Date::processDate($values['repeat_absolute_date']); | |
271 | if (($end < $entityStartDate) && ($end != 0)) { | |
272 | $errors['repeat_absolute_date'] = ts('End date should be after current entity\'s start date'); | |
273 | } | |
274 | } | |
275 | else { | |
276 | $errors['repeat_absolute_date'] = ts('This is a required field'); | |
277 | } | |
278 | } | |
279 | } | |
280 | else { | |
281 | $errors['ends'] = ts('This is a required field'); | |
282 | } | |
283 | ||
284 | //Repeats BY | |
285 | if (CRM_Utils_Array::value('repeats_by', $values)) { | |
286 | if ($values['repeats_by'] == 1) { | |
287 | if (CRM_Utils_Array::value('limit_to', $values)) { | |
288 | if ($values['limit_to'] < 1 && $values['limit_to'] > 31) { | |
289 | $errors['limit_to'] = ts('Invalid day of the month'); | |
290 | } | |
291 | } | |
292 | else { | |
293 | $errors['limit_to'] = ts('Invalid day of the month'); | |
294 | } | |
295 | } | |
296 | if ($values['repeats_by'] == 2) { | |
297 | if (CRM_Utils_Array::value('entity_status_1', $values)) { | |
298 | $dayOfTheWeekNo = array(first, second, third, fourth, last); | |
299 | if (!in_array($values['entity_status_1'], $dayOfTheWeekNo)) { | |
300 | $errors['entity_status_1'] = ts('Invalid option'); | |
301 | } | |
302 | } | |
303 | else { | |
304 | $errors['entity_status_1'] = ts('Invalid option'); | |
305 | } | |
306 | if (CRM_Utils_Array::value('entity_status_2', $values)) { | |
307 | if (!in_array($values['entity_status_2'], $dayOfTheWeek)) { | |
308 | $errors['entity_status_2'] = ts('Invalid day name'); | |
309 | } | |
310 | } | |
311 | else { | |
312 | $errors['entity_status_2'] = ts('Invalid day name'); | |
313 | } | |
314 | } | |
315 | } | |
316 | } | |
317 | return $errors; | |
318 | } | |
319 | ||
320 | /** | |
321 | * Process the form submission | |
322 | * | |
323 | * | |
16b10e64 | 324 | * @return void |
2aa397bc TO |
325 | */ |
326 | public static function postProcess($params = array(), $type, $linkedEntities = array()) { | |
327 | //Check entity_id not present in params take it from class variable | |
328 | if (!CRM_Utils_Array::value('entity_id', $params)) { | |
329 | $params['entity_id'] = self::$_entityId; | |
330 | } | |
331 | //Process this function only when you get this variable | |
332 | if ($params['allowRepeatConfigToSubmit'] == 1) { | |
333 | if (CRM_Utils_Array::value('entity_table', $params) && CRM_Utils_Array::value('entity_id', $params) && $type) { | |
334 | $params['used_for'] = $type; | |
335 | if (!CRM_Utils_Array::value('parent_entity_id', $params)) { | |
336 | $params['parent_entity_id'] = self::$_parentEntityId; | |
337 | } | |
338 | if (CRM_Utils_Array::value('schedule_reminder_id', $params)) { | |
339 | $params['id'] = $params['schedule_reminder_id']; | |
340 | } | |
341 | else { | |
342 | $params['id'] = self::$_scheduleReminderID; | |
343 | } | |
344 | ||
345 | //Save post params to the schedule reminder table | |
346 | $recurobj = new CRM_Core_BAO_RecurringEntity(); | |
347 | $dbParams = $recurobj->mapFormValuesToDB($params); | |
348 | ||
349 | //Delete repeat configuration and rebuild | |
350 | if (CRM_Utils_Array::value('id', $params)) { | |
351 | CRM_Core_BAO_ActionSchedule::del($params['id']); | |
352 | unset($params['id']); | |
353 | } | |
354 | $actionScheduleObj = CRM_Core_BAO_ActionSchedule::add($dbParams); | |
355 | ||
356 | //exclude dates | |
357 | $excludeDateList = array(); | |
358 | if (CRM_Utils_Array::value('copyExcludeDates', $params) && CRM_Utils_Array::value('parent_entity_id', $params) && $actionScheduleObj->entity_value) { | |
359 | //Since we get comma separated values lets get them in array | |
360 | $excludeDates = array(); | |
361 | $excludeDates = explode(",", $params['copyExcludeDates']); | |
362 | ||
363 | //Check if there exists any values for this option group | |
364 | $optionGroupIdExists = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', | |
353ffa53 TO |
365 | $type . '_repeat_exclude_dates_' . $params['parent_entity_id'], |
366 | 'id', | |
367 | 'name' | |
368 | ); | |
2aa397bc TO |
369 | if ($optionGroupIdExists) { |
370 | CRM_Core_BAO_OptionGroup::del($optionGroupIdExists); | |
371 | } | |
372 | $optionGroupParams = | |
353ffa53 TO |
373 | array( |
374 | 'name' => $type . '_repeat_exclude_dates_' . $actionScheduleObj->entity_value, | |
375 | 'title' => $type . ' recursion', | |
376 | 'is_reserved' => 0, | |
377 | 'is_active' => 1, | |
378 | ); | |
2aa397bc TO |
379 | $opGroup = CRM_Core_BAO_OptionGroup::add($optionGroupParams); |
380 | if ($opGroup->id) { | |
381 | $oldWeight = 0; | |
382 | $fieldValues = array('option_group_id' => $opGroup->id); | |
22e263ad | 383 | foreach ($excludeDates as $val) { |
2aa397bc | 384 | $optionGroupValue = |
353ffa53 TO |
385 | array( |
386 | 'option_group_id' => $opGroup->id, | |
387 | 'label' => CRM_Utils_Date::processDate($val), | |
388 | 'value' => CRM_Utils_Date::processDate($val), | |
389 | 'name' => $opGroup->name, | |
390 | 'description' => 'Used for recurring ' . $type, | |
391 | 'weight' => CRM_Utils_Weight::updateOtherWeights('CRM_Core_DAO_OptionValue', $oldWeight, CRM_Utils_Array::value('weight', $params), $fieldValues), | |
392 | 'is_active' => 1, | |
393 | ); | |
2aa397bc TO |
394 | $excludeDateList[] = $optionGroupValue['value']; |
395 | CRM_Core_BAO_OptionValue::add($optionGroupValue); | |
396 | } | |
397 | } | |
398 | } | |
399 | ||
400 | //Set type for API | |
401 | $apiEntityType = array(); | |
402 | $apiEntityType = explode("_", $type); | |
403 | if (!empty($apiEntityType[1])) { | |
404 | $apiType = $apiEntityType[1]; | |
405 | } | |
406 | //Delete relations if any from recurring entity tables before inserting new relations for this entity id | |
407 | if ($params['entity_id']) { | |
408 | //If entity has any pre delete function, consider that first | |
409 | if (CRM_Utils_Array::value('pre_delete_func', CRM_Core_BAO_RecurringEntity::$_recurringEntityHelper[$params['entity_table']]) && | |
353ffa53 TO |
410 | CRM_Utils_Array::value('helper_class', CRM_Core_BAO_RecurringEntity::$_recurringEntityHelper[$params['entity_table']]) |
411 | ) { | |
2aa397bc TO |
412 | call_user_func(array( |
413 | CRM_Core_BAO_RecurringEntity::$_recurringEntityHelper[$params['entity_table']]['helper_class'], | |
af9b09df | 414 | call_user_func_array(CRM_Core_BAO_RecurringEntity::$_recurringEntityHelper[$params['entity_table']]['pre_delete_func'], array($params['entity_id'])), |
353ffa53 TO |
415 | ) |
416 | ); | |
2aa397bc TO |
417 | } |
418 | //Ready to execute delete on entities if it has delete function set | |
419 | if (CRM_Utils_Array::value('delete_func', CRM_Core_BAO_RecurringEntity::$_recurringEntityHelper[$params['entity_table']]) && | |
353ffa53 TO |
420 | CRM_Utils_Array::value('helper_class', CRM_Core_BAO_RecurringEntity::$_recurringEntityHelper[$params['entity_table']]) |
421 | ) { | |
2aa397bc TO |
422 | //Check if pre delete function has some ids to be deleted |
423 | if (!empty(CRM_Core_BAO_RecurringEntity::$_entitiesToBeDeleted)) { | |
424 | foreach (CRM_Core_BAO_RecurringEntity::$_entitiesToBeDeleted as $eid) { | |
425 | $result = civicrm_api3( | |
426 | ucfirst(strtolower($apiType)), | |
427 | CRM_Core_BAO_RecurringEntity::$_recurringEntityHelper[$params['entity_table']]['delete_func'], | |
428 | array( | |
429 | 'sequential' => 1, | |
430 | 'id' => $eid, | |
431 | ) | |
432 | ); | |
433 | if ($result['error']) { | |
434 | CRM_Core_Error::statusBounce('Error creating recurring list'); | |
435 | } | |
436 | } | |
437 | } | |
438 | else { | |
439 | $getRelatedEntities = CRM_Core_BAO_RecurringEntity::getEntitiesFor($params['entity_id'], $params['entity_table'], FALSE); | |
440 | foreach ($getRelatedEntities as $key => $value) { | |
441 | $result = civicrm_api3( | |
442 | ucfirst(strtolower($apiType)), | |
443 | CRM_Core_BAO_RecurringEntity::$_recurringEntityHelper[$params['entity_table']]['delete_func'], | |
444 | array( | |
445 | 'sequential' => 1, | |
446 | 'id' => $value['id'], | |
447 | ) | |
448 | ); | |
449 | if ($result['error']) { | |
450 | CRM_Core_Error::statusBounce('Error creating recurring list'); | |
451 | } | |
452 | } | |
453 | } | |
454 | } | |
455 | ||
456 | // find all entities from the recurring set. At this point we 'll get entities which were not deleted | |
457 | // for e.g due to participants being present. We need to delete them from recurring tables anyway. | |
458 | $pRepeatingEntities = CRM_Core_BAO_RecurringEntity::getEntitiesFor($params['entity_id'], $params['entity_table']); | |
22e263ad | 459 | foreach ($pRepeatingEntities as $val) { |
2aa397bc TO |
460 | CRM_Core_BAO_RecurringEntity::delEntity($val['id'], $val['table'], TRUE); |
461 | } | |
462 | } | |
463 | ||
464 | $recursion = new CRM_Core_BAO_RecurringEntity(); | |
353ffa53 TO |
465 | $recursion->dateColumns = $params['dateColumns']; |
466 | $recursion->scheduleId = $actionScheduleObj->id; | |
2aa397bc TO |
467 | |
468 | if (!empty($excludeDateList)) { | |
469 | $recursion->excludeDates = $excludeDateList; | |
470 | $recursion->excludeDateRangeColumns = $params['excludeDateRangeColumns']; | |
471 | } | |
472 | if (CRM_Utils_Array::value('intervalDateColumns', $params)) { | |
473 | $recursion->intervalDateColumns = $params['intervalDateColumns']; | |
474 | } | |
475 | $recursion->entity_id = $params['entity_id']; | |
476 | $recursion->entity_table = $params['entity_table']; | |
477 | if (!empty($linkedEntities)) { | |
478 | $recursion->linkedEntities = $linkedEntities; | |
479 | } | |
480 | ||
481 | $recurResult = $recursion->generate(); | |
482 | ||
483 | $status = ts('Repeat Configuration has been saved'); | |
484 | CRM_Core_Session::setStatus($status, ts('Saved'), 'success'); | |
485 | } | |
486 | } | |
487 | } | |
488 | ||
489 | /** | |
490 | * Return a descriptive name for the page, used in wizard header | |
491 | * | |
492 | * @return string | |
493 | */ | |
494 | public function getTitle() { | |
495 | return ts('Repeat Entity'); | |
496 | } | |
497 | ||
498 | } |