Page 1 of 1

A simple booking system with CGCalendar

Posted: Tue Nov 13, 2012 10:55 am
by Torpedine
Recently I built a website for an engineering firm http://www.studiolatrofa.it, with a simple and nice booking system for the meetings.

These where the requests:

1. The user goes to the booking page and checks the calendar for a free time slot;
2. the user logs in or registers himself on the website (SelfRegistration Module) and can book a meeting with the staff - time slots are obviously not allowed to overlap (a simple setting in CGCalendar)
3. to maintain the privacy, only the staff can see the meetings' detail: the simple user can only see a NOT AVAILABLE message, along with the taken time slot.

To do this you only have to modify the "Calendar" template on CGCalendar: it's better if you create another Calendar template, calling it in a way that suits you, and change the lines from 23 to 29, where you can find this code:

Code: Select all

<td {if isset($day.class)}class="{$day.class}"{/if}>
{if isset($day.events.0)}<a href="{$day.url}">{$key}</a>
<ul>
{foreach from=$day.events item=event}
<li><a href="{$event.url}">{$event.event_title}</a></li>
{/foreach}
</ul></a>
With this other lines of code:

Code: Select all

<td {if isset($day.class)}class="{$day.class}"{/if}>
{if isset($day.events.0)}
   {if $ccuser->memberof('Staff') }
      <a href="{$day.url}">{$key}</a>
   {else}
      {$key}
{/if}
<ul>
{foreach from=$day.events item=event}
{if $ccuser->memberof('Staff') }
 <li>{$event.event_date_start|date_format:"%H:%M"}-{$event.event_date_end|date_format:"%H:%M"}: <br/><a href="{$event.url}">{$event.event_title}</a></li>
{else}
<li>{$event.event_date_start|date_format:"%H:%M"}-{$event.event_date_end|date_format:"%H:%M"}: NOT AVAILABLE</li>
{/if}
{/foreach}
</ul>
What we have done?
We have changed the way to CGCalendar module displays the events on the calendar view.

The first "if" statement displays the link to the detail view, put on the date number, only if a "Staff" member in logged in; other users see only a simple date without any link.

The second "if", again, displays the detail only to the Staff, otherwise displays only the timeslot and a "Not available" message.

Note the I created the "Staff" FEU group because the Firm Staff can see all the meetings in the Calendar View, much nicer and organised than the Admin one on the back end.

This was my first tip for CMS Made Simple, I Hope it will be useful.

You can contact me here on the forum or on twitter @gianlucasavini

Re: A simple booking system with CGCalendar (tutorial)

Posted: Tue Nov 13, 2012 12:02 pm
by compufairy
Thank you for sharing :-)

- Anne-Mieke

Re: A simple booking system with CGCalendar

Posted: Wed May 01, 2013 5:33 pm
by blackhawk
Thank you Torpedine for the post! If you don't mind me asking, what was the module you used to do the actual booking process, along with CGCalendar?

Re: A simple booking system with CGCalendar

Posted: Thu May 02, 2013 7:41 am
by Torpedine
No one. All the bookings are for office meetings, so everything is managed in CGCalendar

Re: A simple booking system with CGCalendar

Posted: Thu May 02, 2013 10:42 pm
by blackhawk
wow! That's awesome. I will give this a shot in my current project!

Thanks