Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
SELECT CBB.bookst, CBB.bookend, CC.month, CC.monthid
FROM month AS CC
LEFT JOIN (SELECT CB.bookst, CB.bookend
FROM holbook AS CB
WHERE CB.userholid =44
AND ((cb.bookst BETWEEN '20070101' AND '20071231')
OR (cb.bookend BETWEEN '20070101' AND '20071231')
OR (cb.bookst <= '20070101') AND (cb.bookend >= '20071231')))
AS CBB
ON CC.monthid = month(CBB.bookst)
ORDER BY CC.monthid, CBB.bookst ASC
'use arrays as theyre great!
Set RS = Conn.Execute(sql)
aBookings = rs.GetRows()
rs.close
Response.Write("<table>")
Response.Write("<tr>")
'first row - 31 days
Response.Write("<td colspan =2 class = usersml>Month</td>")
for i=0 to 30
Response.Write ("<td class = usersml>" & i & "</td>")
next
Response.Write("</tr>")
monthid = ""
recCount = 0
'1st loop for month names down left side
for j=0 to UBound(aBookings, 2)
recCount = recCount + 1
monthtxt = aBookings(2,j)
'monthid is primary key
monthid = aBookings(3,j)
blanks = 0
'get days in month
call getDaysInMonth(monthid, motyear)
'need this line cos january didnt work??
if monthid = 1 then monthdays = 31
'add leading zeros to months that need them
if monthid < 10 then
monthid = "0" & monthid
end if
dStartDatemonth = "01/"&monthid&"/"&motyear
Response.Write("<tr bgcolor="& bgcolor & ">")
Response.Write "<td class = mfitsml width =2>"&(monthtxt)& "</td>"
'second loop
for i=0 to monthdays - 1
dCurrDate = DateAdd("d", i, dStartDatemonth)
'fills blanks at end of rows
if monthdays < 31 then
blanks = 31 - monthdays
end if
'blank cell for no holidays
freestr = "<td class = courtcarfree align=center width=""10""><img src=""images/bookbutfree.gif"" width =10 border=0 align=center></td>"
'no holiday so blank cell
if isnull(aBookings(0,j)) or isnull(aBookings(1,j)) then
response.Write(freestr)
else
'there is a holiday so show on day
if datediff("d",dCurrDate,(aBookings(0,j))) <= 0 and _
datediff("d", dCurrDate,(aBookings(1,j))) >= 0 then
response.Write "<td class=courtcarlname align=center width=""10"" align=center>HOL</td>"
end if
else
'bit that checks to see if next holiday is in same month
if ubound(abookings,2) >= j+1 then
if aBookings(2,j+1) = monthtxt then
if datediff("d", dCurrDate , aBookings(1,j)) <= 0 then
j = j + 1
i = i - 1
else
response.Write(freestr)
end if
else
response.Write(freestr)
end if
else
response.Write(freestr)
end if
end if
next
'write blank cells for months that have less than 31 days
for x = 1 to blanks
Response.Write("<td bgcolor=""#666666""></td>")
next
Response.Write("</tr>")
Next
Response.Write("</table>")
function getDaysInMonth(strMonth,strYear)
dim strDays
Select Case cint(strMonth)
Case 1,3,5,7,8,10,12:
strDays = 31
Case 4,6,9,11:
strDays = 30
Case 2:
if ((cint(strYear) mod 4 = 0 and _
cint(strYear) mod 100 <> 0) _
or ( cint(strYear) mod 400 = 0) ) then
strDays = 29
else
strDays = 28
end if
End Select
getDaysInMonth = strDays
monthdays = strDays
end function
%>