<!--#include file="../include/opendb.inc"-->
<!--#include file="../include/top.inc"-->


<%
Dim Connection
Dim iBoucleRangees, iBoucleColonnes
Dim objRS, strSQL, nbreEnr ,objRS1, strSQL1
Dim root

%>

<Script language='JavaScript'>
function setPage()
{
	document.frmMonth.submit();
}
</script>

<table>
        <tr> 
          <td width="5">&nbsp;</td>
          <td valign="top" width="738"><table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr> 
          <td width="23" rowspan="2"><img src="<%=path%>/images/innertopleft.gif" width="23" height="23"></td>
          <td bgcolor="#000066" width="1"><img src="<%=path%>/images/clearpix.gif" width="1" height="1"></td>
          <td width="23" rowspan="2"><img src="<%=path%>/images/innertopright.gif" width="23" height="23"></td>
        </tr>
        <tr>
          <td width="100%">&nbsp;</td>
        </tr>
        <tr>
          <td background="<%=path%>/images/leftbg.gif"><img src="<%=path%>/images/clearpix.gif" width="23" height="1"></td>
          <td width="100%" valign="top">
            <table width="680" BORDER="0" CELLPADDING="0" CELLSPACING="0">
              <tr>
                <td align="left" width="394">
               
                                   
                    <table width="100% BORDER="0" CELLPADDING="0" CELLSPACING="1">
                      <tr>
                        <td width="653" valign="top">
                          <div align="center">
                            <center>
                            <table border="0" cellpadding="0" cellspacing="0" width="664">
                              
                              
                              <tr>
                                <td >
                                <!-- calendrier !-->



					
<!-- #include file="i_utils.asp" -->
<%

check_security(1) 

%>

<div align="center">
  <center>
  <b><font class='formtxt' >Réservation des locaux</font></b><br><br>
        <table cellpadding=0 cellspacing=0 border=0 width=570>
		<tr>
  </center>
		<td width=354 valign="top" class="formtxt">
<% sub render_title %>



<table class='SubMenuTitleTable'>
<tr>
<td class='SubMenuTitleLeft'> </td>
<td class='formtxt'><b><A href='index.asp' class='SubMenuTitleFont'>Calendrier</A> &#8250; 
<A href='index.asp?incDate=<%=incDate%>' class='SubMenuTitleFont'><%=GetDateName(DatePart("m",incDate))&" "&DatePart("yyyy",incDate)%></A> &#8250; </b><td>
<td class='SubMenuTitleRight'> </td>
</tr>
</table>
<table class='SubMenuTable'>
<tr>
<td class='SubMenuLeft'> </td>
<td class='formtxt'><A href='upd_events.asp?incDate=<%=incDate%>' class='SubMenuTabFont'>Ajouter
  une réservation</A>&nbsp;&nbsp;&nbsp;</td>
<td class='formtxt'><% if request("wk")="" then %><A href='index.asp?wk=1&incDate=<%=incDate%>' class='SubMenuTabFont'>Semaine</A><% else %><A href='index.asp?incDate=<%=incDate%>' class='SubMenuTabFont'>Mois</A><% end if %></td>
<td class='SubMenuDiv'> </td>
<td class='SubMenuRight'> </td>
</tr>
</table>
<% end sub %>
<%



dim content
dim event_id
dim dt_end
dim CodeAdmin
dim dt_start
dim id
dim b_personal
dim description
dim tm_start
dim tm_end
dim event_name
dim Cat
dim NomU
dim detail_events_sql

sub request_detail_events
''' request form inputs from this form
	event_id = request("event_id")
	dt_end = request("dt_end")
	CodeAdmin = request("CodeAdmin")
	dt_start = request("dt_start")
	id = request("id")
	b_personal = request("b_personal")
	description = request("description")
	tm_start = request("tm_start")
	tm_end = request("tm_end")
	'********
	location = request("location")
	'********
	event_name = request("event_name")
	Cat = request("Cat")
	NomU = request("NomU")
end sub

sub validate_detail_events
''' request and validate data entered from this form
	event_id = trim(request("event_id"))
	dt_end = trim(request("dt_end"))
	CodeAdmin = trim(request("CodeAdmin"))
	dt_start = trim(request("dt_start"))
	id = trim(request("id"))
	b_personal = trim(request("b_personal"))
	description = trim(request("description"))
	tm_start = trim(request("tm_start"))
	tm_end = trim(request("tm_end"))
	'********
	location = trim(request("location"))
	'********
	event_name = trim(request("event_name"))
	Cat = trim(request("Cat"))
	NomU = trim(request("NomU"))
end sub


sub db_select_detail_Events

	incDate1 = "#" & Replace(incDate, "'", "''") & "#"

	detail_Events_sql = "SELECT " & _ 
	"Events.dt_end, " & _ 
	"Events.CodeAdmin, " & _ 
	"Events.dt_start, " & _ 
	"EventsOccur.id, " & _ 
	"EventsOccur.tm_start, " & _ 
	"EventsOccur.tm_end, " & _ 
	"EventsOccur.location, " & _ 
	"Events.event_id, " & _ 
	"Admin.NomU, " & _ 
	"EventsOccur.event_name, " & _ 
	"EventsOccur.description, " & _ 
	"Events.b_personal FROM ((Events LEFT JOIN Admin ON Events.CodeAdmin = Admin.CodeAdmin) LEFT JOIN EventsOccur ON Events.event_id = EventsOccur.event_id) " & _ 
	" WHERE (b_personal = 0 OR b_personal = 2 OR b_personal is null OR Events.CodeAdmin = " & to_sql(session("CodeAdmin"),"number") & ")" & _ 
	" AND (dt_occur = " & incDate1& ") ORDER BY tm_start"
end sub

sub db_delete_detail_Events
	sql = "DELETE FROM EventsOccur" & _ 
	" WHERE " & _ 
	"id = " & to_sql(id,"number") & ""
	'response.write sql
	on error resume next
	cn.Execute(sql)
	if err.number <> 0 then
		b_error = true
	end if
	on error goto 0
end sub


'***************************************************Suite calendrier*************************


do_search = request("do_search")
sortby = request("sortby")
''' request form keys and inputs
id = request("id")

':: request action
action = lcase(request("action"))

':: handle the action
select case action

case "select_detail_events"
'  select the requested key record from database
if id <> "" then
	db_select_detail_Events
else
	b_error = true
	error_list.add "edit_detail_Events", "Specify record to select."
end if


end select

':: handle the default case(s) (ignores value of action parameter)
dim incDate, boxSize, a_events(31)



incDate = request("incDate")
mo = request("mo")
yr = request("yr")

if "mm/dd/yyyy"="mm/dd/yyyy" then
	if incDate = "" and mo <> "" and yr <> "" then incDate = mo & "/1/" & yr
else
	if incDate = "" and mo <> "" and yr <> "" then incDate = "01/" & mo & "/" & yr
end if

if action = "detail" then
	db_select_detail_events
else
	b_display_new_content = true
end if
%>


<%
display_errs
display_msg
%>

<%

if action = "" then

	If incDate = "" Then
		'' get the current months first day
		incDate = DatePart ("m" , Date) & "/01/" & DatePart("yyyy" , Date)
	Else
		incDate = DatePart ("m" , incDate) & "/" & DatePart ("d" , incDate) & "/" & DatePart("yyyy" , incDate)
	End If

	'' pixel size for the cell boxes
	boxSize = "40"
	boxSizeLarge = "40"	
	
	' To change the month, Pass in a date with POST or GET of a valid date
	' to a variable named incDate
	
	Function GetDateName (monthNumber)
	
		Select Case monthNumber
		
			Case 1
				GetDateName = "Janvier"	
			Case 2
				GetDateName = "Février"
			Case 3
				GetDateName = "Mars"
			Case 4
				GetDateName = "Avril"
			Case 5
				GetDateName = "Mai"
			Case 6
				GetDateName = "Juin"
			Case 7
				GetDateName = "Juillet"
			Case 8
				GetDateName = "Août"
			Case 9
				GetDateName = "Septembre"
			Case 10
				GetDateName = "Octobre"
			Case 11
				GetDateName = "Novembre"
			Case 12
				GetDateName = "Décembre"
		End Select
	
	End Function

	function DaysInAnyMonth(iMonth, iYear)
		dim dTemp
		dTemp = DateAdd("d", -1, DateSerial(iYear, iMonth + 1, 1))
		DaysInAnyMonth = Day(dTemp)
	end function

	function WeekdayNameOfFirstOfMonth(iMonth, iYear)
		dim dTemp
		dTemp = WeekdayName(Weekday(iMonth & "/01/" & iYear,VBSunday))
		FirstWeekdayOfMonth = dTemp
		'response.write "<br>1st day of " & iMonth & "/" & iYear & " is a: " & dTemp & "<BR>"
	end function

	function DateFirstWeekdayFallsOn(iMonth, iYear, iWeekdayNumber)
		dim dTemp
		dTemp = iWeekdayNumber - Weekday(iMonth & "/01/" & iYear, 1)
		if dTemp < 0 then dTemp = 0
		dTemp = DateAdd("d",dTemp,iMonth & "/01/" & iYear)
		DateFirstWeekdayFallsOn = dTemp
		'response.write "<br>The 1st " & WeekdayName(iWeekdayNumber) & " of " & iMonth & "/" & iYear & " is on: " & dTemp & "<BR>"
	end function

render_title

if request("wk") = "" then
%>

<!--monthly view-->
<table class='ContentTD' width="560">
	<tr >
	    <td class='formtxt' width="65" align="center" bgcolor="#424288"><font color="#FFFFFF">Dimanche</font></td>
	    <td class='formtxt' width="49" align="center" bgcolor="#424288"><font color="#FFFFFF">Lundi</font></td>
	    <td class='formtxt' width="52" align="center" bgcolor="#424288"><font color="#FFFFFF">Mardi</font></td>
	    <td class='formtxt' width="70" align="center" bgcolor="#424288"><font color="#FFFFFF">Mercredi</font></td>
	    <td class='formtxt'  width="48" align="center" bgcolor="#424288"><font color="#FFFFFF">Jeudi</font></td>
	    <td class='formtxt' width="72" align="center" bgcolor="#424288"><font color="#FFFFFF">Vendredi</font></td>
	    <td class='formtxt' width="67" align="center" bgcolor="#424288"><font color="#FFFFFF">Samedi</font></td>
	</tr>
  
	<%

	'' select events and assign to a_events array
	CatId = request("CatId")
	if CatId = "" then
		sql = "SELECT Events.*, EventsOccur.*, Admin.NomU FROM Events, EventsOccur, Admin WHERE "
		sql = sql + "("
		sql = sql + "b_personal = 0 OR b_personal = 2 OR b_personal is null OR events.CodeAdmin = " & to_sql(session("CodeAdmin"),"number") & ""
		sql = sql + ")"
		sql = sql + "AND"
		sql = sql + "("
		sql = sql + "Events.CodeAdmin = Admin.CodeAdmin"
		sql = sql + ")"
		sql = sql + "AND"
		sql = sql + "("
		sql = sql + "EventsOccur.event_id = Events.event_id"
		sql = sql + ")"
		sql = sql + "AND"
		sql = sql + "("
		sql = sql + "month(dt_occur) = " & month(incDate) & " AND year(dt_occur) = " & year(incDate) & ""
		sql = sql + ")"
		sql = sql + " ORDER BY dt_occur"
		''response.write sql
	else
		sql = "SELECT Events.*, EventsOccur.*, Admin.NomU FROM Events, EventsOccur, Admin WHERE "
		sql = sql + "("
		sql = sql + "b_personal = 0 OR b_personal = 2 OR b_personal is null OR events.CodeAdmin = " & to_sql(session("CodeAdmin"),"number") & ""
		sql = sql + ")"
		sql = sql + "AND"
		sql = sql + "("
		sql = sql + "EventsOccur.catid = " & to_sql(catid,"number") & ""
		sql = sql + ")"
		sql = sql + "AND"
		sql = sql + "("
		sql = sql + "Events.CodeAdmin = Admin.CodeAdmin"
		sql = sql + ")"
		sql = sql + "AND"
		sql = sql + "("
		sql = sql + "EventsOccur.event_id = Events.event_id"
		sql = sql + ")"
		sql = sql + "AND"
		sql = sql + "("
		sql = sql + "month(dt_occur) = " & month(incDate) & " AND year(dt_occur) = " & year(incDate) & ""
		sql = sql + ")"
		sql = sql + " ORDER BY dt_occur"
		'response.write sql
	end if

	set rs = cn.execute(sql)
	days_in_month = DaysInAnyMonth(month(incDate),year(incDate)) 
	lastDate = DateAdd("d",days_in_month-1,incDate)
	
	do until rs.EOF
		dt_start = rs("dt_start")
		dt_end = rs("dt_end")
		'*******
		location = rs("location")
		'*******
		dt_occur = rs("dt_occur")
		recurring = rs("recurring")
		recurring_end = rs("recurring_end")
		b_personal = rs("b_personal")
		CodeAdmin = rs("CodeAdmin")
		NomU = rs("NomU")
		ev_start = 0
		ev_end = 0
		
		if (dt_end = dt_start) OR isnull(dt_end) then
			if b_personal = 2 AND CodeAdmin <> session("CodeAdmin") then
				a_events(day(dt_occur)) = a_events(day(dt_occur)) & NomU & " busy..<br>"
			else
				a_events(day(dt_occur)) = a_events(day(dt_occur)) & "" & left(rs("event_name"),25) & "..<br>"
			end if
		end if
		
	rs.MoveNext
	loop
	rs.Close	
	
	'' calendar loop
		
	dim w, d, count, dispDay, currDay
	dateCount = incDate
	count = 1
	dispDay = 1
	
	for w = 1 to 6
	
	%>

	<tr>

	<%		
  		for d = 1 to 7
					
		if Not (count => DatePart("w" , incDate)) AND (count < 8) then

		%>
		<td width='65' height='<%=boxSize%>' valign='top' align='left' bgcolor="#F2F2F2" class="formtxt">&nbsp;</td>
		<%
			count = count + 1
					
		else
			
			':: current date?
			If "mm/dd/yyyy" ="mm/dd/yyyy" then
				currDy = DatePart("m" , incDate) & "/" & dispDay & "/"
				currDay = DatePart("m" , incDate) & "/" & dispDay & "/" & DatePart("yyyy" , incDate)
			Else
				currDy = dispDay & "/" & DatePart("m" , incDate) & "/"
				currDay = dispDay & "/" & DatePart("m" , incDate) & "/"  & DatePart("yyyy" , incDate)
			End if


			If IsDate(currDay) Then	
				
				':: today					
				If datevalue(currDay) = datevalue(Date) Then
								
				%>
				<td class='formtxt' width='69' align='left' height='<%=boxSize%>' valign='top' bgcolor="#F2F2F2">
				<A class='DataFont' href='upd_events.asp?incDate=<% =currDay %>' style="{font-weight:800;}"><%=dispDay%></a>
				<% if not isEmpty(a_events(dispDay)) then %>
				<table><tr><td class="formtxt">
				<table><tr><td class="formtxt" align='center'width='60' >
				<A href='index.asp?action=detail&incDate=<% =currDay %>&JourDate=<% =currDay %>'>
				<img border="0" src="<%=path%>/images/icon/inboxV.gif" width="25" height="21" alt="<% =a_events(dispDay) %>"></A>
				</td></tr></table>
				</td></tr></table>
				<% end if %></td>
				<%
			
				Else
				':: other date
				%>			
				<td class='formtxt' width='72' align='left' height='<%=boxSize%>' valign='top' bgcolor="#F2F2F2">
				<A class='DataFont' href='upd_events.asp?incDate=<% =currDay %>' title="Ajouter une réservation" >
				<%=dispDay%></A><% if not isEmpty(a_events(dispDay)) then %>
				<table><tr><td class="formtxt"><table><tr><td class="formtxt" align='center'width='60' >
				<A href='index.asp?action=detail&incDate=<% =currDay %>&JourDate=<% =currDay %>'>
				<img border="0" src="<%=path%>/images/icon/inboxV.gif" width="25" height="21" alt="<% =a_events(dispDay) %>">
				</A></td></tr></table></td></tr></table><% end if %></td>
				<%
				End If
				
				count = count + 1
				dispDay = dispDay + 1				
						
			Else
			':: no date spacer cell

			%>
				<td class='formtxt' width='70' align='left' height='<%=boxSize%>' valign='top' bgcolor="#F2F2F2">&nbsp;</td>
			<%

			End If

		end if
					
		next
		'day
		
		%>
		</tr> 
	<%

	next
	'week

	lastmo = DateAdd("M", -1, incDate) 
	nextmo = DateAdd("M", 1, incDate)  
	
	%>
	
	
		
	<form action='index.asp' id=form1 name=form1>
	<tr>
	    <td class='formtxt' colspan=2 width="120">
			<A  href='index.asp?incDate=<% =lastmo %>&CatId=<% =catid %>&CatId2=<% =request("catid2") %>'>
			<b>&lt; <% =GetDateName(month(lastmo)) %></b></A></td>
	    <td class='HeaderTD' colspan=3 align=center width="182">
			<select name=mo class='select'>
			<option value=<%=DatePart("m",incDate)%>><%=GetDateName(DatePart("m",incDate))%>
			</option><option value=1>janvier</option>
			<option value=2>février</option>
			<option value=3>mars</option>
			<option value=4>avril</option>
			<option value=5>mai</option>
			<option value=6>juin</option>
			<option value=7>juillet</option>
			<option value=8>août</option>
			<option value=9>septembre</option>
			<option value=10>octobre</option>
			<option value=11>novembre</option>
			<option value=12>décembre</option>
			</select>
			<select name=yr class='select'>
			<option><%=DatePart("yyyy",incDate)%></option>
			<option>2004</option><option>2005</option>
			<option>2006</option><option>2007</option>
			<option>2008</option><option>2009</option>
			<option>2010</option>
          </select>
          <input class='btnfrm' type=submit value='»»' id=submit1 name=submit1></td>
	    <td class='formtxt' colspan=2 align=right width="145">
			<A  href='index.asp?incDate=<% =nextmo %>&CatId=<% =catid %>&CatId2=<% =request("catid2") %>'>
			<b><% =GetDateName(month(nextmo)) %> &gt;</b></A></td>
	</tr>
	</form>

</table>


<% else %>

<!--weekly view-->
<table border="1" bgcolor="#F8F8F8" width="545" cellspacing="1" bordercolor="#E5E5E5">
	<%

	'' select events and assign to a_events array
	
	if CatId = "" then
		sql = "SELECT Events.*, EventsOccur.*, Admin.NomU FROM Events, EventsOccur, Admin WHERE "
		sql = sql + "("
		sql = sql + "b_personal = 0 OR b_personal = 2 OR b_personal is null OR events.CodeAdmin = " & to_sql(session("CodeAdmin"),"number") & ""
		sql = sql + ")"
		sql = sql + "AND"
		sql = sql + "("
		sql = sql + "Events.CodeAdmin = Admin.CodeAdmin"
		sql = sql + ")"
		sql = sql + "AND"
		sql = sql + "("
		sql = sql + "EventsOccur.event_id = Events.event_id"
		sql = sql + ")"
		sql = sql + "AND"
		sql = sql + "("
		sql = sql + "month(dt_occur) = " & month(incDate) & " AND year(dt_occur) = " & year(incDate) & ""
		sql = sql + ")"
		sql = sql + " ORDER BY dt_occur"
		'response.write sql
	else
		sql = "SELECT * FROM Events, EventsOccur WHERE "
		sql = sql + "("
		sql = sql + "b_personal = 0 OR b_personal is null OR CodeAdmin = " & to_sql(session("CodeAdmin"),"number") & ""
		sql = sql + ")"
		sql = sql + "AND"
		sql = sql + "("
		sql = sql + "EventsOccur.catid = " & to_sql(cat_id,"number") & ""
		sql = sql + ")"
		sql = sql + "AND"
		sql = sql + "("
		sql = sql + "EventsOccur.event_id = Events.event_id"
		sql = sql + ")"
		sql = sql + "AND"
		sql = sql + "("
		sql = sql + "month(dt_occur) = " & month(incDate) & " AND year(dt_occur) = " & year(incDate) & ""
		sql = sql + ")"
		sql = sql + " ORDER BY dt_occur"
		'response.write sql
	end if
	
	set rs = cn.execute(sql)
	days_in_month = DaysInAnyMonth(month(incDate),year(incDate)) 
	lastDate = DateAdd("d",days_in_month-1,incDate)
	
	do until rs.EOF
		dt_start = rs("dt_start")
		dt_end = rs("dt_end")
		'*******
		location = rs("location")
		'*******
		dt_occur = rs("dt_occur")
		recurring = rs("recurring")
		recurring_end = rs("recurring_end")
		b_personal = rs("b_personal")
		NomU = rs("NomU")
		ev_start = 0
		ev_end = 0
		
		
		if (dt_end = dt_start) OR isnull(dt_end) then
			if b_personal = 2 AND CodeAdmin <> session("CodeAdmin") then
				a_events(day(dt_occur)) = a_events(day(dt_occur)) & NomU & " busy.."
			else
				a_events(day(dt_occur)) = a_events(day(dt_occur)) & "" & left(rs("event_name"),25) & ".."
			end if
		end if
	
	rs.MoveNext
	loop
	rs.Close	
	
	'' calendar loop
		
	dateCount = incDate
	count = 1
	dispDay = DatePart("d",incDate)
			
	for d = 1 to 7
					
			If IsDate( DatePart("m" , incDate) & "/" & dispDay & "/" & DatePart("yyyy" , incDate)) Then	
			currDy = DatePart("m" , incDate) & "/" & dispDay & "/"
			currDay = DatePart("m" , incDate) & "/" & dispDay & "/" & DatePart("yyyy" , incDate)

			%>
			<tr>
			<td class='formtxt' width="81" align="left" bgcolor="#EFEFEF">
			<% if weekdayname(weekday(currDay)) = "Saturday" then response.write "Samedi" %> 
			<% if weekdayname(weekday(currDay)) = "Sunday" then response.write "Dimanche" %>
			<% if weekdayname(weekday(currDay)) = "Monday" then response.write "Lundi" %>
			<% if weekdayname(weekday(currDay)) = "Tuesday" then response.write "Mardi" %>
			<% if weekdayname(weekday(currDay)) = "Wednesday" then response.write "Mercredi" %>
			<% if weekdayname(weekday(currDay)) = "Thursday" then response.write "Jeudi" %>
			<% if weekdayname(weekday(currDay)) = "Friday" then response.write "Vendredi" %>
			</td>
			<%

							
			If datevalue(currDay) = datevalue(Date) Then
								
			%>
			<td class='formtxt' align='left' height='<%=boxSize%>' valign='top' width="116">
			<A class='LabelFont' href='index.asp?wk=1&incDate=<% =currDay %>&JourDate=<% =currDay %>'><%=dispDay%></a>
			<% if not isEmpty(a_events(dispDay)) then %><table><tr><td class="formtxt">
			<A href='index.asp?action=detail&incDate=<% =currDay %>' class='dataFont' style="{font-size:10px;}">
			<% =a_events(dispDay) %></A></td></tr></table><% end if %></td>
			<%
			
			Else
			%>			
			<td class='formtxt' align='left' height='<%=boxSize%>' valign='top' width="248">
			<A class='dataFont' href='index.asp?wk=1&incDate=<% =currDay %>&JourDate=<% =currDay %>'><%=dispDay%></A>
			<% if not isEmpty(a_events(dispDay)) then %><table><tr><td class="formtxt">
			<A href='index.asp?action=detail&incDate=<% =currDay %>' class='dataFont' style="{font-size:10px;}">
			<% =a_events(dispDay) %></A></td></tr></table><% end if %></td>
			<%
			End If
			
			count = count + 1
			dispDay = dispDay + 1				
						
			%>
			</tr>
			<%

		end if
					
	next
	'day
		
	lastwk = DateAdd("d", -7, incDate) 
	nextwk = DateAdd("d", 7, incDate)  
	
	%>
	<form action='index.asp' id=form2 name=form2>
    <td width="81">
	<table class='ContentTable' bgcolor="#F8F8F8">
	<tr>
	    <td class='ContentPrevTD' bgcolor="#E5E5E5">&nbsp;</td>
	    <td class='formtxt' bgcolor="#E5E5E5">
			<A class='ContentPrevNextFont' href='index.asp?incDate=<% =nextwk %>&wk=1'>Suivent >></A>
			</td>
	</tr>
	</table>
	</form>

</table>


<% end if %>
<%

else
render_title

%>

<%

page_no = request("page_no")
if page_no = "" then page_no = 1



if detail_Events_sql <> "" then
	cmd.CommandText = detail_Events_sql
	rs.Filter = ""
	rs.CursorLocation = 3
	rs.CacheSize = 5
	rs.Open cmd
	if not rs.EOF then
			rs.MoveFirst
			num_recs = rs.RecordCount
			results = true
	else
		results = false
		rs.Close
	end if
else
	results = false
end if
rec_count = 0

%>

<table class='headerTable'>
<tr>
<td class='formtxt'>
<b>
<%= DatePart("d",incDate) &" "&GetDateName(DatePart("m",incDate))&" "&DatePart("yyyy",incDate)%>  
</b>
</td>
</tr>
</table>
<%

if results = true then

%>

<table  class='ContentTable' width="568">
<tr>
	<td class='formtxt' bgcolor="#424288" width="168"><font color="#FFFFFF">Horaire</font></td>
	<td class='formtxt' bgcolor="#424288" width="241"><font color="#FFFFFF">Titre</font></td>
	<td class='formtxt' bgcolor="#424288" width="158"><font color="#FFFFFF">Local</font>
    </td>
</tr>
<%

do while not rs.EOF

':: read db record
on error resume next
event_id = rs("event_id")
dt_end = rs("dt_end")
'*******
location = rs("location")
'*******
CodeAdmin = rs("CodeAdmin")
dt_start = rs("dt_start")
id = rs("id")
b_personal = rs("b_personal")
description = rs("description")
tm_start = rs("tm_start")
tm_end = rs("tm_end")
event_name = rs("event_name")
Cat = rs("Cat")
NomU = rs("NomU")
on error goto 0

%>
		
		<input type=hidden name="event_id" value="<% =event_id %>">
		
		
		<input type=hidden name="dt_end" value="<% =dt_end %>">
		
		<input type=hidden name="CodeAdmin" value="<% =CodeAdmin %>">
		
		
		<input type=hidden name="dt_start" value="<% =dt_start %>">
		
		
		<input type=hidden name="id" value="<% =id %>">
		

<% event_desc = left(event_desc,100) %>
<tr>
	<td class='formtxt' width=168 nowrap bgcolor="#F8F8F8">
		<%
if tm_start <> "" and tm_end <> "" then
	tm_start = timevalue(tm_start) & " - " & timevalue(tm_end)
elseif tm_start <> "" then
	tm_start = timevalue(tm_start)
else
	tm_start = " --Toute la journée-- "
end if
%><% =tm_start %>
	</td>

	<td class='formtxt' bgcolor="#F8F8F8" width="241" >
		<% if b_personal=2 and session("CodeAdmin") <> CodeAdmin then %><% =NomU %> busy<% else %><a href="upd_events.asp?id=<% =id %>"  class=dataFont><% =event_name %></a>
		<% end if %>
	</td>
	<td class='formtxt' bgcolor="#F8F8F8" width="159" >
		<% 
		
SQL="Select * from Locaux where CodeL = " & Location 
set rsQuery = conn.execute (SQL)
if not rsQuery.EOF then
Response.Write rsQuery("Nom")

end if
%>
        
	</td>
</tr>
<%

rs.MoveNext
rec_count = rec_count + 1
loop
rs.Close

%>

</table>
<%

else

%>

	[Pas de réservation]

<%

end if

%>


<table class='ContentTable'>
<tr>
<td class='formtxt'><br><A href='index.asp?action=detail&incDate=<% =dateadd("d",-1,incDate) %>' class='ContentPrevNextFont'><img alt="Jour précédent" src="<%=path%>/images/precedent.gif" border="0"></A></td>
<td class='formtxt'><br><A href='index.asp?action=detail&incDate=<% =dateadd("d",1,incDate) %>' class='ContentPrevNextFont'><img alt="Jour suivant" src="<%=path%>/images/suivant.gif" border="0"></A></td>
</tr>
</table>
<% end if %>



<%
':: assure that any db resources are freed
on error resume next
rs.Close
set rs = NOTHING
cn.Close
set cn = NOTHING
user_cn.Close
set user_cn = NOTHING
on error goto 0
%>
</td>
    </tr>
  </table>


</div>






							
                        <!-- fin calendrier !-->        
                                
 

                              
                                
                                
                          
                              </tr>
          
          
    
          
          <% if action = "detail" then %>                               
  <!--debut liste des salles -->
  
  <%
'Option explicit
'Dim root
'Dim Connection, objRS, strSQL
Dim journee(), str_nbSalle, i, j, k, l, m, n,p,q, jour, mois, annee,desc()
Dim temps, str_heure, col, debut
'root = "../"

if Request.QueryString("incDate") <> "" then

DateincDate = Request.QueryString("incDate")
jour = day(DateincDate)
mois = month(DateincDate)
annee = year(DateincDate)

Session("jour") = jour
Session("mois") = mois
Session("annee") = annee
  else
jour = day(date())
mois = month(date())
annee = year(date())
 
Session("jour") = day(date())
Session("mois") = month(date())
Session("annee") = year(date())
end if

Set objRS = Server.CreateObject("ADODB.Recordset")
strSQL="SELECT * FROM Locaux"
objRS.Open strSQL,Conn,3,3

if not objRS.EOF then

str_nbSalle=objRS.RecordCount


objRS.MoveFirst 

Redim journee(19, str_nbSalle)

for i=1 to str_nbSalle step 1
	journee(0,i)=objRS("CodeL")
	journee(1,i)=objRS("Nom")
	journee(2,i)=objRS("Description")
		
	objRS.MoveNext 
next

objRS.Close

for l=2 to 18 step 1
	str_heure=l+5 
	journee(l,0)=cdate(str_heure)
next
journee(19,0)=cdate("0")

strSQL="SELECT * FROM EventsOccur WHERE dt_occur=#" & annee & "-" & _
	mois & "-" & jour & "#"
objRS.Open strSQL,Conn,3,3

Redim desc(19, str_nbSalle)

while not objRS.EOF 
	for m=1 to str_nbSalle step 1
		if journee(0,m)=objRS("location") then
			col=m
			desc(0,m)=  hour(objRS("tm_start"))
			desc(1,m)=  hour(objRS("tm_end"))
			exit for
		end if
	next
	
	for q=2 to 19 step 1
	stm_start = hour(objRS("tm_start"))
	
		if journee(q,0)= stm_start then
			debut=q
			desc(2,m)=objRS("tm_start")
			desc(3,m)=objRS("tm_end")
			exit for
		end if
	next

	temps= datediff("h",objRS("tm_start"),objRS("tm_end") ) - 1
	
	for n=debut to debut+temps step 1
		journee(n,col)="X"
	next

	objRS.movenext
Wend

%>


                    
                              <tr>
				<td >
				<br>
				
						<% Response.write "<P align=center>
						<font class='formtxt'><b>Liste des réservations confirmées pour le " & jour & "/" & mois & "/" & annee & "</b></font></P>" %>
				
				</td>
			</tr>
					
                              <tr>
                                <td >
           <!-- salles !-->
           <br>                      
           <table align="center" width="400" cellspacing='0'>
						
			<%
			
	
		Response.Write "<tr>"
		
		Response.Write "<td width='300'>"
				Response.Write "<table border = '1' cellspacing='0' width='210' >"
				Response.Write "<tr>"
				Response.Write "<td bgcolor='#424288' class='formtxt'><font color='#FFFFFF'> Nom de local</font></td>"
				Response.Write "</tr>"
		
			for p=0 to str_nbSalle step 1
				Response.Write "<tr>"%>
				
		<%
					Response.Write "<td bgcolor='#424288' class='formtxt' ><font color='#FFFFFF'>" &  journee(1,p) & "</font></td>"
				Response.Write "</tr>"
			next
			
				Response.Write "<tr>"
				Response.Write "<td bgcolor='#424288' class='formtxt'><font color='#FFFFFF'> Nom de local</font></td>"
				Response.Write "</tr>"
				
				
			Response.Write "</table>"
			Response.Write "</td>"
		
		h=7
		for k=2 to 18 step 1
				
				Response.Write "<td>"
				Response.Write "<table border = '1' cellspacing='0'>"
				Response.Write "<tr>"
				Response.Write "<td  bgcolor='#424288' class='formtxt' ><font color='#FFFFFF'>" & h & "</font></td>"
				Response.Write "</tr>"
				for j=1 to str_nbSalle step 1
					if journee(k,j)="X" then
					Response.Write "<tr>"
						Response.Write "<td bgcolor='#D6DFEF' class='formtxt' ><img border='0'   src='../images/reservation.gif' alt='commence de " &  desc(2,j) & " a " &  desc(3,j) & "'></td>"
					Response.Write "</tr>"
					else
					Response.Write "<tr>"
						Response.Write "<td  class='formtxt' >&nbsp;</td>"
					Response.Write "</tr>"
					end if
				next
				Response.Write "<tr>"
				Response.Write "<td  bgcolor='#424288' class='formtxt' ><font color='#FFFFFF'>" & h & "</font></td>"
				Response.Write "</tr>"
				
				Response.Write "</table>"
				Response.Write "</td>"
				h = h+1
			next
	
		Response.Write "</tr>"
	
	
	%>
	</table>
	
	<!-- fin salles !-->  
	<%end if%>
	
	
	</td>
    </tr>
    <%end if%>                        
                            
                            
                            
                            
                            
                            
                            </table>
                            </center>
                          </div>
                        </td>
                      </tr>
                    </table>
                  
                    <table width="683" BORDER="0" CELLPADDING="0" CELLSPACING="1">
                      <tr>
                        <td width="648" valign="top">
                        </td>
                      </tr>
                    </table>
                  </td>
                </tr>
              </table>
            </td>
            <td width"23" background="<%=path%>/images/rightbg1.gif"><img src="<%=path%>/images/clearpix.gif" width="23" height="1"></td>
          </tr>
          <tr>
            <td width="23" rowspan="2"><img src="<%=path%>/images/innerbottomleft.gif" width="23" height="23"></td>
            <td width="100%">
              <p align="center">&nbsp;</td>
            <td width="23" rowspan="2"><img src="<%=path%>/images/innerbottomright.gif" width="23" height="23"></td>
          </tr>
          <tr>
            <td width="1" bgcolor="#000066" height="1"><img src="<%=path%>/images/clearpix.gif" width="1" height="1"></td>
          </tr>
        </table>
        <font color="#0000FF"><img src="<%=path%>/images/clearpix.gif" width="1" height="22"></font>

  
    <!--#include file="../include/footer.inc"-->