Page 1 of 1

CGCalendar template for Availability

Posted: Sun Oct 11, 2009 3:48 pm
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??

Re: CGCalendar template for Availability

Posted: Mon Oct 12, 2009 8:36 am
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!

Re: CGCalendar template for Availability

Posted: Mon Oct 12, 2009 2:29 pm
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.

Re: CGCalendar template for Availability

Posted: Mon Oct 12, 2009 6:24 pm
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?

Re: CGCalendar template for Availability

Posted: Mon Oct 12, 2009 6:36 pm
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}

Re: CGCalendar template for Availability

Posted: Mon Oct 12, 2009 9:04 pm
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

Re: CGCalendar template for Availability

Posted: Thu Oct 15, 2009 1:11 pm
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!

Re: CGCalendar template for Availability

Posted: Thu Oct 15, 2009 1:25 pm
by christiaans
Is it possible you could post the Availability template as well? That'd be awesome, because I really like it.

Re: CGCalendar template for Availability

Posted: Fri Aug 27, 2010 5:20 pm
by moonoo
I second that, I'm struggling with the availability module templates as well.. if it was available that would be sweet!

Re: CGCalendar template for Availability

Posted: Tue Sep 13, 2011 8:50 pm
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

Re: CGCalendar template for Availability

Posted: Mon Jul 09, 2012 8:28 am
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