Closed HeneryH closed 3 years ago
Seems like the Civi reports use the following query for each event to check the current number of participants:
SELECT * FROM civicrm_participant
WHERE
event_id = [x]
and maybe some additional tests AND Participant Status (ID) = Registered AND Participant is not a Test
The following code hack between the comment lines will a) append " FULL" to the title and b) null out the hyperlink for any event that is fully booked. I will look into how to put an option on the Ext Config Screen to toggle this feature and also look into other ways to make it better.
./ext/com.osseed.eventcalendar/CRM/Eventcalendar/Page/ShowEvents.php
$dao = CRM_Core_DAO::executeQuery($query);
$eventCalendarParams = array ('title' => 'title', 'start' => 'start', 'url' => 'url');
if(!empty($settings['event_end_date'])) {
$eventCalendarParams['end'] = 'end';
}
while ($dao->fetch()) {
$eventData = array();
$dao->url = html_entity_decode(CRM_Utils_System::url('civicrm/event/info', 'id='.$dao->id));
foreach ($eventCalendarParams as $k) {
$eventData[$k] = $dao->$k;
if(!empty($eventTypes)) {
$eventData['backgroundColor'] = "#{$eventTypes[$dao->event_type]}";
$eventData['textColor'] = $this->_getContrastTextColor($eventData['backgroundColor']);
$eventData['eventType'] = $civieventTypesList[$dao->event_type];
}
}
/****************************/
$result = civicrm_api3('Event', 'getsingle', [
'return' => ['is_full'],
'id' => $dao->id,
]);
if( !($result['is_error']) && ( $result['is_full'] == "1" ) ) {
$eventData['url']='';
$eventData['title'].=' FULL';
}
/****************************/
$events['timeDisplay'] = $settings['event_time'];
$events['isfilter'] = $settings['event_event_type_filter'];
$events['events'][] = $eventData;
$eventTypesFilter[$dao->event_type] = $civieventTypesList[$dao->event_type];
}
@HeneryH As per your requirement have added the "enrollment status" functionality setting, under multiple calendar. Please check the updated version of eventcalendar.
Digging into the Event-Calendar code I can see where the php code is pulling information from the civi-events database table. Makes sense. From that table one can get the name and start/end times for the event as well as a lot of other info. Including the max amount of participants.
BUT, it doesn't have the current amount of participants. Ugh. Could have been so simple.
Any ideas on how I can find out whether or not a civi-event item is full or not and change the calendar graphic accordingly? Even just putting a 1/4 for one out of four taken. Or 2/4 or 3/4 or FULL.
I'm using this calendar as a sort of booking tool for reserving club assets. If there are four slots available and all are taken, it would be nice to show that that slot is full.