<% @Language="vbscript" %>
<!--#include virtual="/includes/topofpage.asp"-->

<%

	
  ' force declaration of all variables

  
  Dim intYear, intMonth, intDay
  Dim intNumberOfDays, strDaysInMonths
  Dim strDate, strMonthName
  Dim strStyle, strTitle
  Dim strMethod, strURL  
  Dim strFirstDay, strLastDay, strCurrentDay
  Dim dtmPrev, dtmNext
  Dim X,Y,Z
  Dim WriteStr
  Dim Base_Rate, Base_Rate_SQL
  Dim Avail, jumpd, rsInv_Rate_SNGL, rsInv_Rate_DBL, Rate_Changed
  
  ' find out the URL of the page and the HTTP method used
  strMethod = UCase(Request.ServerVariables("REQUEST_METHOD"))
  strURL = LCase(Request.ServerVariables("URL"))
  
  ' if it's a GET then it's a regular browser request
  If strMethod="GET" Then
  
	If Request.QueryString("txtMonth") = "" And Request.QueryString("txtYear") = "" Then
		' use today's date
		intDay   = CInt(Day(Date()))
		intMonth = CInt(Month(Date()))
		intYear  = CInt(Year(Date()))
    
		strFirstDay = CStr(intMonth) & "-1-" & CStr(intYear)
		strDate  = CStr(intMonth) & "-" & CStr(intDay) & "-" & CStr(intYear)
	Else
		intDay   = CInt(Day(Date()))
		intMonth = CInt(Request.QueryString("txtMonth"))
		intYear  = CInt(Request.QueryString("txtYear"))
    
		strFirstDay = CStr(intMonth) & "-1-" & CStr(intYear)
		strDate     = strFirstDay
	End If	
    
  ' if it's a POST then it's a specific request
  Else
    If Request.Form("Page") = "0" Then
		' use today's date
		intDay   = CInt(Day(Date()))
		intMonth = CInt(Month(Date()))
		intYear  = CInt(Year(Date()))
    
		strFirstDay = CStr(intMonth) & "-1-" & CStr(intYear)
		strDate  = CStr(intMonth) & "-" & CStr(intDay) & "-" & CStr(intYear)
    Else
		' get the submitted date
		intDay   = CInt(Day(Date()))
		intMonth = CInt(Request.Form("txtMonth"))
		intYear  = CInt(Request.Form("txtYear"))
    
		strFirstDay = CStr(intMonth) & "-1-" & CStr(intYear)
		strDate     = strFirstDay
    End If
  End If
  
  ' is a date in a leap year?
  Function IsLeapYearDate(dtmTestDate)
    IsLeapYearDate = False
    If IsDate(dtmTestDate) Then
      Dim dtmTempDate
      dtmTempDate = "1/31/" & Year(dtmTestDate)
      dtmTempDate = DateAdd("m", 1, dtmTempDate)
      If Day(dtmTempDate) = 29 Then IsLeapYearDate = True
    End If
  End Function

  ' create string of days in months
  If IsLeapYearDate("1/1/" & intYear) Then      
    strDaysInMonths = "312931303130313130313031"
  Else
    strDaysInMonths = "312831303130313130313031"
  End If
  
  ' get some date stuff
  strMonthName    = CStr(MonthName(intMonth))
  intNumberOfDays = CInt(Mid(strDaysInMonths,((intMonth-1)*2)+1,2))
  strLastDay      = CStr(intMonth) & "-" & intNumberOfDays & "-" & CStr(intYear)
  
  ' build the page title
  strTitle = "Calendar for " & strMonthName & " " & intYear

  ' get the next and previous months for the menus
  dtmPrev = CDate(DateAdd("m", -1, strDate))
  dtmNext = CDate(DateAdd("m",  1, strDate))


Dim Conn
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open Application("conn_string")

If (UCase(Request.ServerVariables("REQUEST_METHOD")) = "POST" And Request.Form("page") = "0") Then
	If Request.Form("Admin_Group_ID") <> "" Then
		Session("Admin_Group_ID") = Request.Form("Admin_Group_ID")
	End If
	
	If Session("Admin_Group_ID") = "" Then
		Session("Admin_Group_ID") = "0"
	End If
End If

Dim SQLName, RSName
SQLName = "get_entity_from_group @Group_ID='" & Session("Admin_Group_ID") & "'"
'Response.Write SQLName
Set RSName=Conn.Execute(SQLName)

  
%>
<html>
<STYLE>
BODY {SCROLLBAR-FACE-COLOR: #5e5ebe; SCROLLBAR-HIGHLIGHT-COLOR: #5e5ebe; SCROLLBAR-SHADOW-COLOR: #5e5ebe; SCROLLBAR-3DLIGHT-COLOR: #5e5ebe; SCROLLBAR-ARROW-COLOR:  #6666CC; SCROLLBAR-TRACK-COLOR: #E3E3E3; SCROLLBAR-DARKSHADOW-COLOR: #666666; }
</STYLE>
<head>
<title><%=strTitle%></title>
<script language="JavaScript">
<!--
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
//-->
</script>
<link rel="stylesheet" href="../Style-sheets/standard-input-form.css" type="text/css">
<link rel="stylesheet" href="/Style-sheets/headline.css" type="text/css">
<link rel="stylesheet" href="/Style-sheets/galley-text-indent.css" type="text/css">
</head>

<body>

  <table width="525" border="0" cellspacing="0" cellpadding="2" align="center">
    <tr> 
      <td width="338">&nbsp;</td>
      <td align="right" width="187">&nbsp;</td>
    </tr>
    <tr> 
      <td width="338" bgcolor="#5e5ebe" class="headline-ffffff" 

align="middle">View of Existing Inventory for Entity</td>

      <td bgcolor="#5e5ebe" align="right" width="187"><A onmouseover="MM_swapImage('Image1','','images/icon-return-to-main-2.gif',1)" onmouseout=MM_swapImgRestore() href="default-lodging.asp"><IMG height=17 src="images/icon-return-to-main.gif" width=75 useMap=#returntomain border=0 name=Image1></A></td>
    </tr>
    <% If Not RSName.EOF Then %>
    <tr> 
      <td class="galley-text-indent" colspan="2"><%=RSName("Name")%>                               - <%=RSName("City")%>                                   , 
        <%=RSName("State")%>&nbsp; <%=RSName("ZIP")%></td>
    </tr>
    <% Else %>
    <tr> 
      <td class="galley-text-indent-alert" colspan="2">
      <P align=center>No Entity Selected! Please go back a page&nbsp;and choose 
      a location to edit from the dropdown menu.</P>    
                  </td>
    </tr>
    <% End If %>
    <% RSName.Close %>
  </table>

<table border="0" cellspacing="0" cellpadding="0" width="500" align="center">
<tr><td align="middle">
<h1 align="center"><%=strTitle%></h1>

  <table border="0" width="500">
	<tr><td colspan="3"><form action="<%=strURL%>" method="post" id=form1 name=form1><table border="0" width="100%" cellspacing="0" cellpadding="0">
		<td align="right">
		<select name="txtMonth">
			<option value="1">January</option>
			<option value="2">February</option>
			<option value="3">March</option>
			<option value="4">April</option>
			<option value="5">May</option>
			<option value="6">June</option>
			<option value="7">July</option>
			<option value="8">August</option>
			<option value="9">September</option>
			<option value="10">October</option>
			<option value="11">November</option>
			<option value="12">December</option>																		
		</select>
		</td><td>
		<select name="txtYear">
			<option>2001</option>
			<option>2002</option>
			<option>2003</option>
			<option>2004</option>
			<option>2005</option>
		</select>
			</td>
			<td align="left"><input type="submit" style="WIDTH:50px" value="View" id=submit1 name=submit1></td>
			</tr></table></form></td></tr>
    <tr>
      <td align="left">
        <form action="<%=strURL%>" method="post">
          <input type="hidden" name="txtMonth" value="<%=Month(dtmPrev)%>">
          <input type="hidden" name="txtYear" value="<%=Year(dtmPrev)%>">
          <input type="submit" style="WIDTH: 150px" value="View <%=MonthName(Month(dtmPrev))%>">
        </form>
      </td>
    <% If (intMonth <> Month(Date())) Or (intYear <> Year(Date())) Then %>
      <td align="middle">
        <form action="<%=strURL%>" method="post">
          <input type="hidden" name="txtMonth" value="<%=Month(Date())%>">
          <input type="hidden" name="txtYear" value="<%=Year(Date())%>">
          <input type="submit" style="WIDTH: 150px" value ="View Current Month">
        </form>
      </td>
    <% Else %>
		<td>&nbsp;</td>
    <% End If %>
      <td align="right">
        <form action="<%=strURL%>" method="post">
          <input type="hidden" name="txtMonth" value="<%=Month(dtmNext)%>">
          <input type="hidden" name="txtYear" value="<%=Year(dtmNext)%>">
          <input type="submit" style="WIDTH: 150px" value="View <%=MonthName(Month(dtmNext))%>">
        </form>
      </td>
    </tr>
  </table>

<hr id=HR1>

<table border="1" cellpadding="2" cellspacing="2" width="651">
<tr>
<%

Base_Rate_SQL = "Get_Base_Rate_Group_Date @Group_ID='" & Session("Admin_Group_ID") & "', @Start_Date = '" & CStr(intMonth) & "-" & "01" & "-" & CStr(intYear) & "', @End_Date = '" & CStr(intMonth) & "-" & CStr(intNumberOfDays) & "-" & CStr(intYear) & "'"
Set Base_Rate = Conn.Execute(Base_Rate_SQL)

'Debug code
'Response.Write Base_Rate_SQL


  ' print the weekday names
  For X = 1 to 7
    Response.Write "<th width=""93"" bgcolor=""#5e5ebe"" class=""headline-cccc99"">" & WeekdayName(X) & "</th>" & vbCrLf
  Next
%>
</tr>
<tr height="1">
<%  
  ' print empty table cells for the beginning days not in the current month
  If (Weekday(strFirstDay)-1) Then  
    For X = 1 to (Weekday(strFirstDay)-1)
      Response.Write "<td>&#xa0;</td>" & vbCrLf
    Next
  End If

  ' loop through the days in the current month
   For X = 1 to intNumberOfDays

    ' get the day we're working on
    strCurrentDay = CStr(intMonth) & "-" & X & "-" & CStr(intYear)
    
    
    ' start the table cell for a day
	Response.Write "<td id=""" & X & """ align=""center"" valign=""top"" width=""93"">"

    Response.Write "<div align=""left""><a name=""" & X & """><font color=""#000000"" face=""Verdana"" size=""1"">" & X & " </font></div>" & vbCrLf
	
	Dim strInv, rsInv, Pic, strDet, rsDet, alt, rsInv_Rate

    strInv = "execute Get_Inventory_Types @Group_ID='" & Session("Admin_Group_ID") & "', @Date='" & strCurrentDay & "'"
	
	'Response.Write Session("Admin_Group_ID") & "  " & strCurrentDay
	
	Set rsInv = Conn.Execute(strInv)

	'strInv = "Get_Base_Rate_Group_Date '" & Session("Admin_Group_ID") & "', '" & CStr(intMonth) & "-" & "01" & "-" & CStr(intYear) & "', '" & CStr(intMonth) & "-" & CStr(intNumberOfDays) & "-" & CStr(intYear) & "'"
	'strInv = "Get_Base_Rate_Group_Date @Group_ID='" & Session("Admin_Group_ID") & "', @Date = '" & strCurrentDay & "', @Start_Date = '" & CStr(intMonth) & "-" & "01" & "-" & CStr(intYear) & "', @End_Date = '" & CStr(intMonth) & "-" & CStr(intNumberOfDays) & "-" & CStr(intYear) & "'"
	'Set rsInv = Conn.Execute(strInv)
	
	'Response.Write strInv
    
	If Not rsInv.EOF and Not Base_Rate.EOF Then
		
		Do Until rsInv.EOF Or Base_Rate.EOF
		
'142	Double Double
'143	Double King
'144	Double Queen
'411	Single
'412	Single Double
'413	Single King
'414	Single Queen
'435	Suite
'550	Double Singles
'553 Cottages
		If rsInv("Att_ID") = 142 Then 
			Pic = "dd"
		ElseIf rsInv("Att_ID") = 143 Then
			Pic = "kk"
		ElseIf rsInv("Att_ID") = 144 Then
			Pic = "qq"
		ElseIf rsInv("Att_ID") = 411 Then
			Pic = "s"
		ElseIf rsInv("Att_ID") = 412 Then
			Pic = "d"		
		ElseIf rsInv("Att_ID") = 413 Then
			Pic = "k"		
		ElseIf rsInv("Att_ID") = 414 Then
			Pic = "q"
		ElseIf rsInv("Att_ID") = 435 Then
			Pic = "suite"
		ElseIf rsInv("Att_ID") = 550 Then
			Pic = "ss"
		ElseIf rsInv("Att_ID") = 553 Then
			Pic = "c"
		End If

		jumpd = 0
		rsInv_Rate_SNGL = ""
		'rsInv_Rate_DBL = ""
		
		rsInv_Rate_SNGL	= Base_Rate("Rate_Single")
		'rsInv_Rate_DBL = Base_Rate("Rate_Double")

		strDet = "Get_Inventory_Details_SNGL @Item_Id='" & rsInv("Item_ID") & "', @Date = '" & strCurrentDay & "'"
		
		'Response.Write strDet
		
		Set rsDet = Conn.Execute(strDet)
		
		'Response.Write strDet & " - " & strInv
		alt = rsInv("Att_Desc") & " - " & rsInv("Name") & Chr(13) 	

		Avail = False
		Rate_Changed = False

		If Not rsDet.EOF Then
			Do Until rsDet.EOF
				alt = alt & " - (" & rsDet("Inventory_List_ID") & ")" & Chr(13)
				alt = alt & "Allocation: " & rsDet("Allocation") & Chr(13)
				alt = alt & "Available: " & rsDet("Available") & Chr(13)
				alt = alt & "Net Cost (Single): " & rsDet("Rate_SNGL") & Chr(13)
				if rsDet("Rate_SNGL") <> Base_Rate("Rate_Single") Then Rate_Changed = True
				if Not rsDet("Allocation") = "0" Then Avail = True
				rsDet.MoveNext
			Loop

			If Not Avail = True Then		
				Pic = "icons/" & Pic & "-z.gif"
			ElseIf Rate_Changed = True Then
				Pic = "icons/" & Pic & "-r.gif"
			Else
				Pic = "icons/" & Pic & ".gif"
			End If

			WriteStr = WriteStr & "<a href=""room-rate-allocation_EDIT.asp?Item=" & rsInv("Item_ID") & "&Date=" & strCurrentDay & """>"
			WriteStr = WriteStr & "<img src=""" & Pic & """ alt=""" & alt & """ border=""0"">"
			WriteStr = WriteStr & "</a> "
		End If

		Set rsDet = Nothing
		rsInv.MoveNext
		Base_Rate.MoveNext
		
		Loop
		rsInv.MoveFirst
		Base_Rate.MoveFirst
		If Not WriteStr = "" Then Response.Write (Mid(WriteStr,1,Len(WriteStr)-1))
		WriteStr = ""
	End If


    ' end the table cell for a day
    Response.Write "</td>" & vbCrLf

    ' if the current day is then end of a week then output the end of the table row
    If (Weekday(strCurrentDay) = 7) And (strCurrentDay <> strLastDay) Then
      Response.Write "</tr>" & vbCrLf & "<tr>" & vbCrLf
    End If

   Next
  
  ' print empty table cells for the ending days not in the current month
  If (7-Weekday(strLastDay)) Then  
    For X = 1 to (7-Weekday(strLastDay))
      Response.Write "<td>&#xa0;</td>" & vbCrLf
    Next
  End If
  
%>
</tr>
</table>
</td></tr></table>
<hr width="512" align="center">
<table width="525" border="0" cellspacing="0" cellpadding="0" align="center" id=TABLE2>
      <tr bgcolor="#5e5ebe"> 
      <td align="right" width="49%" bgcolor="#5e5ebe"><A onmouseover="MM_swapImage('submitchanges','','images/icon-submit-changes-2.gif',1)" onmouseout=MM_swapImgRestore() href="default-lodging.asp" ><IMG height=15 src="images/icon-submit-changes.gif" width=200 border=0 name=submitchanges></A></td>
      <td width="51%"><A onmouseover="MM_swapImage('Image2','','images/icon-continue-wizard-2.gif',1)" onmouseout=MM_swapImgRestore() href="tax-rates_admin.asp" ><IMG height=15 src="images/icon-continue-wizard.gif" width=150 useMap=#continue border=0 name=Image2></A></td>
  </tr>
  <tr> 
    <td width="49%">&nbsp;</td>
    <td width="51%">&nbsp;</td>
  </tr>
</table>


</body>
</html> 

<%
Set RSName = Nothing
Set RSInv = Nothing
Set Conn = Nothing
%>