4 * To change this license header, choose License Headers in Project Properties.
5 * To change this template file, choose Tools | Templates
6 * and open the template in the editor.
10 * Description of EntityApplyChangesTo
15 class CRM_Core_Page_AJAX_RecurringEntity
{
17 public static function updateMode() {
18 if(CRM_Utils_Array
::value('mode', $_REQUEST) && CRM_Utils_Array
::value('entityId', $_REQUEST)){
19 $finalResult = array();
20 $mode = CRM_Utils_Type
::escape($_REQUEST['mode'], 'Integer');
21 $entityId = CRM_Utils_Type
::escape($_REQUEST['entityId'], 'Integer');
24 civicrm_recurring_entity
26 WHERE entity_id = %2 AND entity_table = 'civicrm_event'";
28 1 => array($mode, 'Integer'),
29 2 => array($entityId, 'Integer')
31 CRM_Core_DAO
::executeQuery($sql, $params);
32 $finalResult['status'] = 'Done';
34 echo json_encode($finalResult);
35 CRM_Utils_System
::civiExit();
38 public static function generatePreview(){
39 $params = $formValues = $genericResult = array();
40 $formValues = $_REQUEST;
41 if(!empty($formValues)){
42 $recursion = new CRM_Core_BAO_RecurringEntity();
43 $recursion->dateColumns
= array('start_date');
44 $recursion->scheduleFormValues
= $formValues;
45 if (!empty($formValues['exclude_date_list'])) {
46 $recursion->excludeDates
= $formValues['exclude_date_list'];
47 $recursion->excludeDateRangeColumns
= array('start_date', 'end_date');
50 $parentEventId = CRM_Core_BAO_RecurringEntity
::getParentFor($formValues['event_id'], 'civicrm_event');
52 $parentEventId = $formValues['event_id'];
55 $endDate = CRM_Core_DAO
::getFieldValue('CRM_Event_DAO_Event', $parentEventId, 'end_date');
57 $startDate = CRM_Core_DAO
::getFieldValue('CRM_Event_DAO_Event', $parentEventId, 'start_date');
58 $interval = $recursion->getInterval($startDate, $endDate);
59 $recursion->intervalDateColumns
= array('end_date' => $interval);
62 $result = $recursion->generateRecursiveDates();
64 foreach ($result as $key => $value) {
65 $result[$key]['start_date'] = date('M d, Y h:i:s A \o\n l', strtotime($value['start_date']));
66 if($value['end_date']){
67 $result[$key]['end_date'] = date('M d, Y h:i:s A \o\n l', strtotime($value['end_date']));
71 //Show the list of participants registered for the events if any
72 $getConnectedEntities = CRM_Core_BAO_RecurringEntity
::getEntitiesForParent($parentEventId, 'civicrm_event', FALSE);
73 if($getConnectedEntities){
74 $participantDetails = CRM_Core_BAO_RecurringEntity
::getParticipantCountforEvent($getConnectedEntities);
75 if(!empty($participantDetails['countByName'])){
76 $result['participantData'] = $participantDetails['countByName'];
80 echo json_encode($result);
81 CRM_Utils_System
::civiExit();