<cfapplication name="gCal">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Cal</title>
<link rel="stylesheet" href="css/master.css" type="text/css" media="screen" charset="utf-8" />
<script src="js/jquery-1.3.min.js" type="text/javascript"> </script>
<script src="js/coda.js" type="text/javascript"> </script>
</head>
<cfif not structKeyExists(application, "gCal") or structKeyExists(url, "reinit")>
<cfset application.gCal = createObject("component", "GoogleCalendar").init("info@example.de","mypass",+1)>
</cfif>
<!--- Default should be current month --->
<cfparam name="form.date" default="#createdate(year(now()),month(now()),1)#">
<!--- stuff for calculating the padding --->
<cfset start=form.date>
<cfset end=DaysInMonth(start)>
<cfset firstDay=dayofweek(start)-2>
<!---- retrieve all available events --->
<cfset events = application.gCal.getEvents(calid="mycalID",maxevents=100,orderby="starttime",sortdir="d")>
<cfoutput>
<body>
<h1>Events</h1>
<form action="" enctype="multipart/form-data" method="post">
<select name="date">
<!--- Selections for a full year --->
<cfloop from="1" to="12" index="m">
<option value="#createdate(year(now()),m,1)#">#dateformat(createdate(year(now()),m,1),"dd-mm-yyyy")#</option>
</cfloop>
</select>
<input type="submit" />
</form>
<table cellspacing="0">
<thead>
<tr>
<th>Mo</th><th>Di</th><th>Mi</th>
<th>Do</th><th>Fr</th><th>Sa</th>
<th>So</th>
</tr>
</thead>
<tbody>
<tr>
<!--- Counter for cells --->
<cfset x=1>
<!--- Padding if 1. of month isn't a monday ---->
<cfif firstDay gt 0>
<td class="padding" colspan="#firstDay#"></td>
<!--- padding cells must be added to counter --->
<cfset x=x+firstDay>
</cfif>
<!--- Loop every day in current month --->
<cfloop from="1" to="#end#" index="i">
<!--- is there an event today? ---->
<cfquery dbtype="query" name="today">
SELECT * FROM events WHERE starttime BETWEEN #createdatetime(year(start),month(start),i,0,0,0)# AND #createdatetime(year(start),month(start),i,23,59,59)# OR endtime BETWEEN #createdatetime(year(start),month(start),i,0,0,0)# AND #createdatetime(year(start),month(start),i,23,59,59)#
</cfquery>
<!--- hilite today or event ---->
<td<cfif day(now()) eq i and not today.recordcount> class="today"</cfif> <cfif today.recordcount>class="date_has_event"</cfif>>#i#
<!---- insert event --->
<cfif today.recordcount>
<div class="events">
<ul>
<cfloop query="today">
<li>
<span class="title">#title#</span>
<span class="desc">
Von: #dateformat(starttime,"dd.mm.yyyy")# #timeformat(starttime,"HH:mm")# Uhr <br />
Bis: #dateformat(endtime,"dd.mm.yyyy")# #timeformat(endtime,"HH:mm")# Uhr <br />
#where#<br />
#content#</span>
</li>
</cfloop>
</ul>
</div>
</cfif>
</td>
<!--- start a new row every 7th cell ---->
<cfif x MOD 7 eq 0></tr><tr></cfif>
<cfset x++>
</cfloop>
<!--- 5 rows with 7 cells each = 35 --->
<cfif 35-(x-1) gt 0>
<!--- add padding to the end if needed --->
<td class="padding" colspan="#35-(x-1)#"></td>
</cfif>
</tbody>
<tfoot>
<th>Mo</th><th>Di</th><th>Mi</th>
<th>Do</th><th>Fr</th><th>Sa</th>
<th>So</th>
</tfoot>
</table>
</body></cfoutput>
</html>