<!---Set the width and height parameters for the table--->
<cfparam name="width" default="98%">
<cfparam name="height" default="100%">
<!---Set the parameter to tell the Calendar to use the full day names--->
<cfparam name="daynames" default="full">
<!---Set the parameter for the current Date--->
<cfparam name="currentyear" default="#year(now())#">
<cfparam name="currentmonth" default="#month(now())#">
<cfparam name="currentday" default="#day(now())#">
<!--- If this page was reached through a link on the calendar create variables for it--->
<cfif isDefined('datelast')>
<cfif datelast eq createdate(currentyear,currentmonth,1)>
<cfelse>
<cfset currentyear = year(url.datelast)>
<cfset currentmonth = month(url.datelast)>
<cfset currentday = day(url.datelast)>
</cfif>
<cfelseif isDefined('datenext')>
<cfif datenext eq createdate(currentyear,currentmonth,1)>
<cfelse>
<cfset currentyear = year(url.datenext)>
<cfset currentmonth = month(url.datenext)>
<cfset currentday = day(url.datenext)>
</cfif>
</cfif>
<cfset firstofmonth = createdate(currentyear,currentmonth,1)>
<cfset dow = dayofweek(firstofmonth)>
<cfset pad = dow - 1>
<cfif currentmonth eq 1>
<cfset lastyear = currentyear - 1>
<cfset nextyear = currentyear>
<cfset lastmonth = 12>
<cfset nextmonth = 2>
<cfelseif currentmonth eq 12>
<cfset nextyear = currentyear + 1>
<cfset lastyear = currentyear>
<cfset nextmonth = 1>
<cfset lastmonth = 11>
<cfelse>
<cfset lastyear = currentyear>
<cfset nextyear = currentyear>
<cfset nextmonth = currentmonth + 1>
<cfset lastmonth = currentmonth - 1>
</cfif>
<!---
Current Year: <cfdump var="#currentyear#"><br />
Current Month: <cfdump var="#currentmonth#"><br />
Current Day: <cfdump var="#currentday#"><br />
Days in month: <cfdump var="#daysinmonth(currentmonth)#">
Month Start On: <cfdump var="#firstofmonth#"><br />
Next Months Year: <cfdump var="#nextyear#"><br />
Last Months Year: <cfdump var="#lastyear#"><br />
Next Month: <cfdump var="#nextmonth#"><br />
Last Month: <cfdump var="#lastmonth#"><br />
--->
<!---Set the first day of the month, the day of the weekd of that day and the amount of padding necessary into variables--->
<cfset firstOfTheMonth = createDate(currentyear,currentmonth,1)>
<cfset dow = dayofWeek(firstOfTheMonth)>
<cfset pad = dow - 1>
<!--- Create the table header with the names of each day--->
<cfoutput>
<table border="1" width="#width#" height="#height#">
<tr>
<th colspan="7">
<cfoutput>
<cfif daynames eq 'full'><a href="monthview.cfm?datelast=#createdate(lastyear,lastmonth,1)#" style="text-decoration:none; "><<</a></cfif>
#monthasstring(currentmonth)# #currentyear#
<cfif daynames eq 'full'><a href="monthview.cfm?datenext=#createdate(nextyear,nextmonth,1)#" style="text-decoration:none; ">>></a></cfif>
</cfoutput>
</th>
</tr>
<tr>
<cfloop index="x" from="1" to="7">
<th width="14%">
<cfif daynames eq 'full'>
#dayOfWeekAsString(x)#
<cfelseif daynames eq 'short'>
</cfif>
</th>
</cfloop>
</tr>
</cfoutput>
<!---Start the row--->
<tr>
<!---If the pad variable is greater than 0 then create a column that is that wide.--->
<cfif pad gt 0>
<cfoutput><td colspan="#pad#"> </td></cfoutput>
</cfif>
<!---Figure out how many days are in the month--->
<cfset days = daysInMonth(currentmonth)>
<!--- Set the counter to include the pad variable--->
<cfset counter = pad + 1>
<!---Begin the loop through the days in the month--->
<cfloop index="x" from="1" to="#days#">
<!---If we are on the current day then highlight it in yellow--->
<cfif x is currentday>
<cfif daynames eq 'full'>
<td bgcolor="yellow" valign="top">
<cfelse>
<td valign="middle" align="center">
</cfif>
<cfelse>
<td valign="top">
</cfif>
<!---Actually output the day #--->
<cfoutput>
#x#</td>
</cfoutput>
<!---Add one to the counter--->
<cfset counter = counter + 1>
<!---If the counter hites 8 than the end of the week has been reached the row must end--->
<cfif counter is 8>
</tr>
<!---If it isn't the end of the month then set the counter back to 1--->
<cfif x lt days>
<cfset counter = 1>
<cfoutput>
<tr>
</cfoutput>
</cfif>
</cfif>
</cfloop>
<!---If the counter is not 8 but it is the end of the month then create a new column that is enough cloumns wide to finish the row.--->
<cfif counter is not 8>
<cfset endPad = 8 - counter>
<td colspan="#endPad#"> </td></tr>
</cfif>
</table>
Has anyone else ever had this problem? If so how did you fix it.

New Topic/Question
Reply




MultiQuote




|