Her har vi så selve kalenderen
<!-- #include file="include/dbconnect.asp" -->
<%
Session.LCID = 1033
Response.Buffer = "True"
' -> THESE SUB-ROUTINES MAKE IT POSSIBLE TO HAVE VARIOUS STYLES FOR VARIOUS DATES.
Sub table_data_available(sValue, sClass)
' -> DATES AVAILABLE.
Response.Write "<td class=" & chr(34) & "koncert_kalender_" & sClass & chr(34) & ">" & sValue & "</td>" & vbCrLf
End Sub
' -> TODAY AVAILABLE.
Sub table_data_available_today(sValue, sClass)
Response.Write "<td class=" & chr(34) & "koncert_kalender_" & sClass & chr(34) & ">" & sValue & "</td>" & vbCrLf
End Sub
' -> DATES OCCUPIED.
Sub table_data_occupied(sValue, sClass)
Response.Write "<td class=" & chr(34) & "koncert_kalender_" & sClass & chr(34) & ">" & sValue & "</td>" & vbCrLf
End Sub
' -> TODAY OCCUPIED.
Sub table_data_occupied_today(sValue, sClass)
Response.Write "<td class=" & chr(34) & "koncert_kalender_" & sClass & chr(34) & ">" & sValue & "</td>" & vbCrLf
End Sub
' -> THIS FUNCTION FINDS THE LAST DATE OF THE MONTH.
Function GetLastDay(intMonthNum, intYearNum)
Dim dNextStart
If CInt(intMonthNum) = 12 Then
dNextStart = CDate( "1/1/" & intYearNum)
Else
dNextStart = CDate(intMonthNum +1 & "/1/" & intYearNum)
End If
GetLastDay = Day(dNextStart -1)
End Function
' -> THESE ARE THE CONSTANTS FOR THE WEEKDAYS.
Const cMON = 1, cTUE = 2, cWED = 3, cTHU = 4, cFRI = 5, cSAT = 6, cSUN = 7
' -> THIS GETS THE NAME OF THIS ASP FILE.
sScript = Request.ServerVariables("SCRIPT_NAME")
' -> THIS CHECKS THE MONTH.
If IsEmpty(Request.QueryString("Month")) Or Not IsNumeric(Request.QueryString("Month")) Then
datToday = Date()
intThisMonth = Month(datToday)
ElseIf CInt(Request.QueryString("Month")) <1 Or CInt(Request.QueryString("Month")) >12 Then
datToday = Date()
intThisMonth = Month(datToday)
Else
intThisMonth = CInt(Request.QueryString("Month"))
End If
' -> THIS CHECKS THE YEAR.
If IsEmpty(Request.QueryString("Year")) Or Not IsNumeric(Request.QueryString("Year")) Then
datToday = Date()
intThisYear = Year(datToday)
Else
intThisYear = CInt(Request.QueryString("Year"))
End If
strMonthName = MonthName(intThisMonth)
datFirstDay = DateSerial(intThisYear, intThisMonth, 1)
intFirstWeekDay = WeekDay(datFirstDay, vbMonday)
intLastDay = GetLastDay(intThisMonth, intThisYear)
' -> THIS GETS THE PREVIOUS MONTH AND YEAR.
intPrevMonth = intThisMonth -1
If intPrevMonth = 0 Then
intPrevMonth = 12
intPrevYear = intThisYear -1
Else
intPrevYear = intThisYear
End If
' -> THIS GETS THE NEXT MONTH AND YEAR.
intNextMonth = intThisMonth +1
If intNextMonth >12 Then
intNextMonth = 1
intNextYear = intThisYear +1
Else
intNextYear = intThisYear
End If
' -> THIS FINDS THE LAST DAY OF THE PREVIOUS MONTH BY FINDING THE SUNDAY OF THE LAST MONTH.
LastMonthDate = GetLastDay(intPrevMonth, intPrevYear) - intFirstWeekDay +2
NextMonthDate = 1
intShowDay = 1
' -> THESE ARE THE DATE DEFINITIONS, USED FOR THE SQL.
dFirstDay = "/1/" & intThisMonth & intThisYear
dLastDay = intThisMonth & "/" & intLastDay & "/" & intThisYear
' -> THESE ARE THE MONTHS, TRANSLATED INTO DANISH.
If strMonthName = "January" Then
strMonthName = "januar"
End If
If strMonthName = "February" Then
strMonthName = "februar"
End If
If strMonthName = "March" Then
strMonthName = "marts"
End If
If strMonthName = "April" Then
strMonthName = "april"
End If
If strMonthName = "May" Then
strMonthName = "maj"
End If
If strMonthName = "June" Then
strMonthName = "juni"
End If
If strMonthName = "July" Then
strMonthName = "juli"
End If
If strMonthName = "August" Then
strMonthName = "august"
End If
If strMonthName = "September" Then
strMonthName = "september"
End If
If strMonthName = "October" Then
strMonthName = "oktober"
End If
If strMonthName = "November" Then
strMonthName = "november"
End If
If strMonthName = "December" Then
strMonthName = "december"
End If
' -> THESE ARE THE VARIABLES TO THE DATABASE.
Dim myConn
Dim strSQL
' -> DSNLess CONNECTION TO THE DATABASE.
'Set myConn = Server.CreateObject("ADODB.Connection")
'myConn.Open = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("koncerter.mdb")
strSQL = "SELECT * FROM event ORDER BY e_dato"
Set rs = myConn.Execute(strSQL)
Response.AddHeader "cache-control","private"
Response.AddHeader "pragma","no-cache"
Response.CacheControl = "no-cache"
Response.CacheControl = "private"
Response.Expires = -1
Response.ExpiresAbsolute = Now() -1
%><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="
http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Koncert Kalender (<%=strMonthName & " " & intThisYear%>)</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="expires" content="-1" />
<meta http-equiv="pragma" content="no-cache" />
<meta name="author" content="Koncert Kalender" />
<meta name="description" content="Koncert Kalender" />
<meta name="keywords" content="Koncert Kalender" />
<link href="koncert_kalender.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
<!--
function externalLinks() {
if (!document.getElementsByTagName) return;
var anchors = document.getElementsByTagName("a");
for (var i=0; i<anchors.length; i++) {
var anchor = anchors[i];
if (anchor.getAttribute("href") &&
anchor.getAttribute("rel") == "external")
anchor.target = "detaljer";
}
}
window.onload = externalLinks;
//-->
</script>
</head>
<body>
<!-- MASTER TABLE START -->
<div id="center">
<table cellpadding="0" cellspacing="0" class="koncert_kalender_background">
<tr>
<td>
<table cellpadding="0" cellspacing="1" class="koncert_kalender_headings_background" style="width: 158px">
<tr>
<td class="koncert_kalender_headings" style="width: 20px"><a class="koncert_kalender_arrow" href="<%=sScript%>?month=<%=IntPrevMonth%>&year=<%=IntPrevYear%>"><<</a></td>
<td class="koncert_kalender_headings" style="width: 140px"><%=strMonthName%></td>
<td class="koncert_kalender_headings" style="width: 20px"><a class="koncert_kalender_arrow" href="<%=sScript%>?month=<%=IntNextMonth%>&year=<%=IntNextYear%>">>></a></td>
</tr>
</table>
<table cellpadding="0" cellspacing="1" style="width: 160px">
<tr>
<td class="koncert_kalender_weekday_names">Ma</td>
<td class="koncert_kalender_weekday_names">Ti</td>
<td class="koncert_kalender_weekday_names">On</td>
<td class="koncert_kalender_weekday_names">To</td>
<td class="koncert_kalender_weekday_names">Fr</td>
<td class="koncert_kalender_weekday_names">Lø</td>
<td class="koncert_kalender_weekday_names">Sø</td>
</tr>
</table>
<table cellpadding="0" cellspacing="1" style="width: 160px"><%
' -> THIS SETS THE END OF THE ROWS TO 'FALSE'.
EndRows = False
Response.Write vbCrLf
' -> THIS LOOPS THOUGH ALL TABLE ROWS.
Do While EndRows = False
' -> THIS START A NEW TABLE ROW.
Response.Write "<tr>" & vbCrLf
' -> THIS IS THE LOOP FOR THE DAYS OF THE WEEK.
For intLoopDay = cMON To cSUN
' -> IF THE FIRST DAY IS NOT SUNDAY, THIS SHOWS THE LAST DAY(S) OF PREVIOUS MONTH IN A DIFFERENT CSS STYLE.
If intFirstWeekDay > cMON Then
table_data_available LastMonthDate & " ", "previous_next_month"
LastMonthDate = LastMonthDate +1
intFirstWeekDay = intFirstWeekDay -1
' -> IF THE MONTH STARTS ON A SUNDAY.
Else
' -> IF THE DATES FOR THE MONTH RUNS INTO A NEW WEEK, THIS SHOWS THE FIRST DAY(S) OF THE NEXT MONTH IN A DIFFERENT CSS STYLE.
If intShowDay > intLastDay Then
table_data_available NextMonthDate & " ", "previous_next_month"
NextMonthDate = NextMonthDate +1
EndRows = True
Else
' -> THIS MARKS THE END OF THE ROW IF LAST DAY OF THE MONTH IS REACHED.
If intShowDay = intLastDay Then
EndRows = True
End If
dToday = CDate(intThisMonth & "/" & intShowDay & "/" & intThisYear)
If NOT rs.EOF Then
' -> THIS MARKS AN OCCUPIED DATE.
bReservations = False
' -> IF TODAY IS OCCCUPIED.
Do While Not rs.EOF And bReservations = False And dToday = Date()
' -> IF THE DATE FALLS WITHIN THE RANGE OF DATES IN THE RECORDSET.
If dToday >= rs("e_dato") And dToday <= rs("e_dato") Then
' -> THIS SHOWS THE OCCUPIED DATE(S) IN A DIFFERENT CSS STYLE.
table_data_occupied_today "<a class=" & chr(34) & "today" & chr(34) & " href=" & chr(34) & "koncerter_details.asp?date=" & dToday & chr(34) & " rel=" & chr(34) & "external" & chr(34) & ">" & intShowDay & "</a>" & " ", "occupied_today"
bReservations = True
' -> IF THE START DATE IS GREATER THAN THE DATE ITSELF, EXIT THE LOOP.
ElseIf dToday < rs("e_Dato") Then
Exit Do
Else
rs.MoveNext
End If
Loop
rs.MoveFirst
' -> IF OTHER DAYS THAN TODAY IS OCCCUPIED.
Do While Not rs.EOF And bReservations = False And dToday <> Date()
' -> IF THE DATE FALLS WITHIN THE RANGE OF DATES IN THE RECORDSET.
If dToday >= rs("e_dato") And dToday <= rs("e_dato") Then
' -> THIS SHOWS THE OCCUPIED DATE(S) IN A DIFFERENT CSS STYLE.
table_data_occupied "<a href=" & chr(34) & "koncerter_details.asp?date=" & dToday & chr(34) & " rel=" & chr(34) & "external" & chr(34) & ">" & intShowDay & "</a>" & " ", "occupied"
bReservations = True
' -> IF THE START DATE IS GREATER THAN THE DATE ITSELF, EXIT THE LOOP.
ElseIf dToday < rs("e_dato") Then
Exit Do
Else
rs.MoveNext
End If
Loop
rs.MoveFirst
End If
' -> THIS SHOWS THE AVAILABLE DATE(S) IN A DIFFERENT CSS STYLE.
If bReservations = False And dToday = Date() Then
table_data_available_today "<a class=" & chr(34) & "today" & chr(34) & " href=" & chr(34) & "koncerter_details.asp?date=" & dToday & chr(34) & " rel=" & chr(34) & "external" & chr(34) & ">" & intShowDay & "</a>" & " ", "available_today"
ElseIf bReservations = False And dToday <> Date() Then
table_data_available "<a href=" & chr(34) & "koncerter_details.asp?date=" & dToday & chr(34) & " rel=" & chr(34) & "external" & chr(34) & ">" & intShowDay & "</a>" & " ", "available"
End If
End If
' -> THIS INCREMENTS THE DATE.
intShowDay = intShowDay +1
End If
' -> THIS MOVES TO THE NEXT DAY IN THE WEEK.
Next
Response.Write "</tr>" & vbCrLf & vbCrLf
Loop
%></table>
<table cellpadding="0" cellspacing="1" class="koncert_kalender_headings_background" style="width: 158px">
<tr>
<td class="koncert_kalender_headings" style="width: 20px"><a class="koncert_kalender_arrow" href="<%=sScript%>?month=<%=IntThisMonth%>&year=<%=intThisYear -1%>"><<</a></td>
<td class="koncert_kalender_headings" style="width: 140px"><%=intThisYear%></td>
<td class="koncert_kalender_headings" style="width: 20px"><a class="koncert_kalender_arrow" href="<%=sScript%>?month=<%=IntThisMonth%>&year=<%=intThisYear +1%>">>></a></td>
</tr>
</table>
</td>
</tr>
</table>
<!-- QUICK SEARCH START -->
<form action="<%=sscript%>" method="get">
<div>
<select name="Month"><%For Drop_Down_Month_Number = 1 to 12%>
<option value="<%=Drop_Down_Month_Number%>" <%If Drop_Down_Month_Number = Month(Date()) Then%>selected="selected"<%End If%>><% If Drop_Down_Month_Number = "1" Then
Drop_Down_Month_Name = "jan"
End If
If Drop_Down_Month_Number = "2" Then
Drop_Down_Month_Name = "feb"
End If
If Drop_Down_Month_Number = "3" Then
Drop_Down_Month_Name = "marts"
End If
If Drop_Down_Month_Number = "4" Then
Drop_Down_Month_Name = "apr"
End If
If Drop_Down_Month_Number = "5" Then
Drop_Down_Month_Name = "maj"
End If
If Drop_Down_Month_Number = "6" Then
Drop_Down_Month_Name = "jun"
End If
If Drop_Down_Month_Number = "7" Then
Drop_Down_Month_Name = "jul"
End If
If Drop_Down_Month_Number = "8" Then
Drop_Down_Month_Name = "aug"
End If
If Drop_Down_Month_Number = "9" Then
Drop_Down_Month_Name = "sep"
End If
If Drop_Down_Month_Number = "10" Then
Drop_Down_Month_Name = "okt"
End If
If Drop_Down_Month_Number = "11" Then
Drop_Down_Month_Name = "nov"
End If
If Drop_Down_Month_Number = "12" Then
Drop_Down_Month_Name = "dec"
End If
Response.Write Drop_Down_Month_Name%></option><%Next%>
</select>
<select name="Year"><%For Year_Drop_Down = Year(Date()) -8 to Year(Date()) +8%>
<option value="<%=Year_Drop_Down%>" <%If Year_Drop_Down = Year(Date()) Then%>selected="selected"<%End If%>><%=Year_Drop_Down%></option><%Next%>
</select>
<br />
<input class="searchbutton" onmouseout="this.className='searchbutton'" onmouseover="this.className='searchbuttonHover'" type="submit" value="FIND DATO" />
</div>
</form>
<!-- QUICK SEARCH END -->
</div>
<!-- MASTER TABLE END -->
</body>
</html>
<%
rs.Close
Set rs = Nothing
myConn.Close
Set myConn = Nothing
%>