Diplaying Timetable

Displaying  a college/school  timetableTimetable in a calender like view is quite complicated. The program code written in classic asp (old asp)  I am keeping here for my future reference.





<%

sql="select * from aa c,bbbe s where c.co_code=s.co_code and s.co_sch_id='" & co_sch_id & "'"
Set ObjRsCo=Myconn.Execute(sql)
If ObjRsCo.Eof Then
   Response.Redirect(BACK_FILE_NAME & "?msgt=schdule missing")
Else
    start_date=ObjRsCo("start_date")
    end_date=ObjRsCo("end_date")
    co_code=ObjRsCo("co_code")
    %>
   

   
   
   
    View Timetable
   
   
   
   


   
   

   
   
    Course Name
   
   
    <%=ObjRsCo("co_name")%>
   
   
   
   
    Course Schedule ID
   
   
    <%=ObjRsCo("co_sch_id")%>
   
   
   
   
    Duration
   
   
    <%=ObjRsCo("duration")%>
    <%=ObjRsCo("duration_type")%>
    From : <%=ddmmyy(ObjRsCo("start_date"))%>
     To  :<%=ddmmyy(ObjRsCo("end_date"))%>
   
   

   
   
    Batch No.
   
   
    <%=ObjRsCo("batch_no_of_co_sch_id")%>
   
   
   
   
    Hall No.
   
   
    <%
    If ObjRsCo("venue") <>"" Then
    Response.write("
Venue : " & ObjRsCo("Venue"))
    End If
    %>
    <%=ObjRsCo("lecture_room_no")%>
   
   
   
   
    Course Type
   
   
    <%=ObjRsCo("ctype_code")%>
   
   
   
   
    Batch Incharge
   
   
    <%=ObjRsCo("schedule_incharge")%>
   
   

   
    <%
    days=end_date - start_date+1
    wdstart_date=weekday(start_date)
    empty_boxes=wdstart_date -1
    wdend_date=weekday(end_date)
    suffix_empty_boxes=7-wdend_date
    total_boxes=empty_boxes + days
    first_date=start_date - empty_boxes
    response.write(total_boxes)
    %>
   

   

   
   
    Click on Date Button for Preparing Timetable
   
   
   
    Sun
   
   
    Mon
   
   
    Tue
   
   
    Wed
   
   
    Thu
   
   
    Fri
   
   
    Sat
   


   

    <%
    for i=1 to total_boxes
        wday=weekday(first_date)
        if wday=7 and day(first_date)>=8 and day(first_date)<=14 then
        second_saturday="yes"
        else
        second_saturday="no"
        end if
        if wday=1 then
        disabled="disabled"
        else
        disabled=""
        end if
        %>
       
        <%
        sql="select distinct(tt_id) from master_timetable where "
        sql=sql & " co_sch_id='" & co_sch_id & "' and "
        sql=sql & tt_date=to_date('"&first_date&"','mm/dd/yyyy')"
        Set ObjRsChk=Myconn.Execute( )
        If ObjRsChk.Eof then
        record_exists_color="#ffcccc"
        Else
        record_exists_color="#d0d0d0"
        End If
        if i <= empty_boxes or i >total_boxes then
            Response.write(" ")
            first_date=first_date +1
        Elseif second_saturday="yes" then
            %>
            <%
            button_style="color:#404040;font-size:9px;font-family:arial;height:30px;width:70px; background-color:<%=record_exists_color%>"
            %>
           
            <%
            Response.write(ddmmyy(first_date))
            Response.write("
2nd Sat")
            first_date=first_date +1
            %>
           
            <%
        Else
            %>
           
            <%
        End if
        %>
       
        <%
        if i mod 7=0 then
            %>
           
           
            <%
        end if
        %>
        <%
    next
    %>
   
    <%
end if
%>