CGCalendar template for Availability

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Locked
christiaans
Power Poster
Power Poster
Posts: 300
Joined: Tue Mar 04, 2008 10:37 am

CGCalendar template for Availability

Post by christiaans »

Guys,

Is there any way you can use the calendar view from the CGCalendar module in the Availabilty module? The availability module is perfect, but the display is not what I am looking for, it takes up too much of my page..

Since I haven't worked with php/smarty for a long time, I am afraid I can't figure it out myself..

Anyone to the rescue??
clj83
Forum Members
Forum Members
Posts: 195
Joined: Tue Jul 07, 2009 4:09 pm

Re: CGCalendar template for Availability

Post by clj83 »

Hey,

I agree it would be great if there was a simple CGCalendar type Calendar available in Availability.

I would be happy if it didnt have interactivity (e.g. No day report links or booking links) and it just showed the correct date in the correct color. I.e. White = Available, Blue = Booked, etc...

The calendar could then be alot smaller than the current choices and easier to use for the client as it would like more like standard calendars.

Thanks!
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

Re: CGCalendar template for Availability

Post by calguy1000 »

Here's a working example of the dates-across calendar template for a number of resources, and a working example of using cgcalendar for a single resource.  it wasn't that hard to modify the cgcalendar/availability calendar templates to do this.

It'll be a little bit more complicated now with partially reserved days, etc.
Attachments
confirm4.jpg
confirm3.jpg
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
clj83
Forum Members
Forum Members
Posts: 195
Joined: Tue Jul 07, 2009 4:09 pm

Re: CGCalendar template for Availability

Post by clj83 »

Hi Calguy,
That's awesome. Does the resource link with the CG Calendar automatically or do you have to manually update the CG Calendar one? Any chance you could post the CG Calendar template you used please? Or will this option be available in an upgraded Availability module?
Last edited by clj83 on Mon Oct 12, 2009 6:29 pm, edited 1 time in total.
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

Re: CGCalendar template for Availability

Post by calguy1000 »

Here's the CGCalendar Template:
It uses alot of jquery/ajax stuff

Code: Select all

{*
  CGCalendar template to include resource information for a particular resource from the availability module.
  CGCalendar is called from the availability resource detail page like this: 
  {CGCalendar calendartemplate='small' use_session='avail_detail_' cal_rsrcid=$rsrc.id}
*}

{assign var='cactionid' value=$actionid}
<div id='cal-{$cactionid}'>{* ajax stuff depends on this id *}
{* javascript stuff that will perform ajax calls *}
<__script__ type='text/javascript'>
/* <![CDATA[ */
{literal}
function ajax_load(url,elem)
{  
   var tmp = url + "&showtemplate=false";
   var tmp2 = tmp.replace(/amp;/g,'');
   jQuery(elem).load(tmp2); 
}

jQuery(document).ready(function($)
    {
        jQuery("a.tooltip").cluetip({cursor: 'pointer'});
        jQuery("span.tooltip").cluetip({cursor: 'pointer'});
});  //end

{/literal}
/* ]]> */
</__script>

{assign var='url_next' value=$navigation.next}
{assign var='url_prev' value=$navigation.prev}
{if isset($actionparams.cal_rsrcid)}
  {* adjust next and previous urls to pass along the resource id *}
  {assign var='rsrcid' value=$actionparams.cal_rsrcid}
  {capture assign='url_next'}{$navigation.next}&cntnt01cal_rsrcid={$rsrcid}{/capture}
  {capture assign='url_prev'}{$navigation.prev}&cntnt01cal_rsrcid={$rsrcid}{/capture}
  {* get availability information for this resource id *}
  {Availability action='calendar' calendartemplate='empty' resources=$rsrcid month=$month year=$year}
  {assign var='orig_rsrcid' value=$rsrcid}
  {assign var='rsrcid' value=1}
{/if}

{strip}
<div>
  <a href="#" onclick="ajax_load('{$url_prev}','#cal-{$cactionid}'); return false;">prev</a>
  {$month_names[$month]} {$year}
  <a href="#" onclick="ajax_load('{$url_next}','#cal-{$cactionid}'); return false;">next</a>
</div>
<table class="availabilitysmall">
<caption>{$grid[0][$rsrcid]->label} Availability</caption>
<tbody><tr>
{foreach from=$day_names item=day key=key}
<th abbr="{$day}">{$day_short_names[$key]}</th>
{/foreach}</tr>

<tr>
{* initial empty days *}
{if $first_of_month_weekday_number > 0}
<td colspan="{$first_of_month_weekday_number}"></td>
{/if}

{* iterate over the days of this month *}
{assign var=weekday value=$first_of_month_weekday_number}
{foreach from=$days item=day key=key}
{if $weekday == 7}
	{assign var=weekday value=0}
</tr>
<tr>
{/if}

{assign var='obj' value=$grid.$key.$rsrcid}
<td style="background-color: {$grid[$key][$rsrcid]->bg}; color: {$grid[$key][$rsrcid]->fg};">
 {module_action_link module='Availability' action='dayview' day=$key month=$month year=$year rsrcid=$orig_rsrcid urlonly=1 assign='cluetip_url'}
  {if $obj->status == 'closed' or $obj->status == 'reserved'}
    <span class="tooltip" rel="{$cluetip_url}&showtemplate=false">{$key}</span>
  {else}
    {* create a link to the availability module add reservation action *}
    {module_action_link module='Availability' action='addresvn' day=$key month=$month year=$year rsrcid=$orig_rsrcid page='reservations' urlonly=1 jsfriendly=1 assign='addresvn_url'}
    <a class="tooltip" href="{$addresvn_url}" rel="{$cluetip_url}&showtemplate=false">{$key}</a>
  {/if}
</td>
{math assign=weekday equation="x + 1" x=$weekday}
{/foreach}

{* remaining empty days *}
{if $weekday != 7}
<td colspan="{math equation="7-x" x=$weekday}"></td>
{/if}


</tr>
</tbody></table>

{/strip}
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
clj83
Forum Members
Forum Members
Posts: 195
Joined: Tue Jul 07, 2009 4:09 pm

Re: CGCalendar template for Availability

Post by clj83 »

That is fantastic, thank so much Calguy. Do you think you will be able to get the partially reserved days working?

Cheers

Chris
christiaans
Power Poster
Power Poster
Posts: 300
Joined: Tue Mar 04, 2008 10:37 am

Re: CGCalendar template for Availability

Post by christiaans »

Hadn't been active for a few days, but coming back this is an AWESOME result. Thanks a bunch!

If it hadn't been the fact that my client is an extreme cheapskate, I would have come to you in the first place!
christiaans
Power Poster
Power Poster
Posts: 300
Joined: Tue Mar 04, 2008 10:37 am

Re: CGCalendar template for Availability

Post by christiaans »

Is it possible you could post the Availability template as well? That'd be awesome, because I really like it.
moonoo
Forum Members
Forum Members
Posts: 77
Joined: Fri Jan 08, 2010 12:23 am

Re: CGCalendar template for Availability

Post by moonoo »

I second that, I'm struggling with the availability module templates as well.. if it was available that would be sweet!
bunker
Forum Members
Forum Members
Posts: 30
Joined: Wed Mar 18, 2009 5:59 pm

Re: CGCalendar template for Availability

Post by bunker »

Hi all..

I should be able to achive what i want, but to have the availability template would sure make my day!

thx
Tablenet
New Member
New Member
Posts: 5
Joined: Sat Dec 03, 2011 1:31 pm

Re: CGCalendar template for Availability

Post by Tablenet »

Dear all,

Thank you for this integration between Availability and CGCalendar.
I 'm trying to display 6 months and it doesn't work.

I tried different things and I failed !

I have the same issue if I want to display 3 calendars for 3 different resources on the same page.

Any idea ?

Regards
Sam
Locked

Return to “Modules/Add-Ons”