<!--#include virtual="/includes/topofpage.asp"-->
<%
Dim Page 
Page = "20"

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 Item_ID, Edit_Date, ii, Date_Arr, Edit_Month, Edit_Day, Edit_Year

ii=0 'Counter for number of Invnetory_List_IDs displayed

Set Item_ID = Request.QueryString("Item")
Set Edit_Date = Request.QueryString("Date")
Date_Arr = Split(Edit_Date, "-")
Edit_Month = Date_Arr(0)
Edit_Day = Date_Arr(1)
Edit_Year = Date_Arr(2)


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

<%'Posting Variables on Save
	If (UCase(Request.ServerVariables("REQUEST_METHOD")) = "POST" And Request.Form("page") = Page) Then
		
		Realm = Session("Site_Realm")
		
		Dim i, Form_String, Sub_String, Room_Total, Amenity_Package, Attribute_ID, Assigned_Rooms
		Dim SQL, TextField, ErrMsg
		
		Dim Item, Allocated, Alarm
		Dim SingleNet, SingleClub, SingleWeb, SinglePref					
		Dim DoubleNet, DoubleClub, DoubleWeb, DoublePref, Blackout
		Dim Start_Day, Start_Month, Start_Year, End_Day, End_Month, End_Year
		Dim Start_Date, End_Date
	
		For Each i in Request.Form("list_id")
				'Response.Write (i & "<br>")

					'Item
						'TextField = "Item_ID" & i
					    'Item = Request.Form(TextField)
					    Item = i
					
					' Start_Day
						TextField = "Start_Day" & i
						Start_Day = Request.Form(TextField)
						
					' Start_Month
						TextField = "Start_Month" & i
						Start_Month = Request.Form(TextField)
						
					' Start_Year
						TextField = "Start_Year" & i
						Start_Year = Request.Form(TextField)
						
					' Start_Date
						Start_Date = "" & Start_Month & "/" & Start_Day & "/" & Start_Year & ""
					
					' End_Day
						TextField = "End_Day" & i
						End_Day = Request.Form(TextField)
						
					' End_Month
						TextField = "End_Month" & i
						End_Month = Request.Form(TextField)
						
					' End_Year
						TextField = "End_Year" & i
						End_Year = Request.Form(TextField)
					
					' End_Date
						End_Date = "" & End_Month & "/" & End_Day & "/" & End_Year & ""	
						
					' Allocated
						TextField = "Allocated" & i
						Allocated = Request.Form(TextField)

					'Alarm
						TextField = "Alarm" & i
						Alarm = Request.Form(TextField)

					' --
					'SingleNet
						TextField = "SingleNet" & i
						SingleNet = Request.Form(TextField)
					'SingleClub
						TextField = "SingleClub" & i
						SingleClub = Request.Form(TextField)
					'SingleWeb
						TextField = "SingleWeb" & i
						SingleWeb = Request.Form(TextField)
					'SinglePref					
						TextField = "SinglePref" & i
						SinglePref = Request.Form(TextField)

					' --
					'DoubleNet
					'	TextField = "DoubleNet" & i
					'	DoubleNet = Request.Form(TextField)
					'DoubleClub
					'	TextField = "DoubleClub" & i
					'	DoubleClub = Request.Form(TextField)
					'DoubleWeb
					'	TextField = "DoubleWeb" & i
					'	DoubleWeb = Request.Form(TextField)
					'DoublePref
					'	TextField = "DoublePref" & i
					'	DoublePref = Request.Form(TextField)

					' --
					'Blackout Exempt
						CheckboxField = "Blackout_Exempt" & i
						Blackout = Request.Form(CheckboxField)						
						

						SQL = "Edit_Inventory_Lodging @Inventory_List_ID = '" & Item & "', "
						SQL = SQL & "@Allocation = '" & Allocated & "', @Alarm = '" & Alarm & "', "

						If SingleNet = "" Then 
							ErrMsg = ErrMsg & "(" & Item & ") Single Net Rate is Empty<br>"
						Else
							SQL = SQL & "@Rate_SNGL = " & SingleNet & ", "
						End If
							
						'If DoubleNet = "" Then
						'	ErrMsg = ErrMsg & "(" & Item & ") Double Net Rate is Empty<br>"
						'Else
						'	SQL = SQL & "@Rate_DBL = " & DoubleNet & ", "
						'End If

						If SingleClub = "" Then	
							ErrMsg = ErrMsg & "(" & Item & ") Single Club Rate is Empty<br>"
						Else
							SQL = SQL & "@Cost_Club_SNGL = " & SingleClub & ", "
						End If
									
						'If DoubleClub = "" Then
						'	ErrMsg = ErrMsg & "(" & Item & ") Double Club Rate is Empty<br>"
						'Else
						'	SQL = SQL & "@Cost_Club_DBL = " & DoubleClub & ", "
						'End If
								
						If SingleWeb = "" Then		
							ErrMsg = ErrMsg & "(" & Item & ") Single Web Rate is Empty<br>"
						Else
							SQL = SQL & "@Cost_Web_SNGL = " & SingleWeb & ", "
						End If
							
						'If DoubleWeb = "" Then
						'	ErrMsg = ErrMsg & "(" & Item & ") Double Web Rate is Empty<br>"
						'Else
						'	SQL = SQL & "@Cost_Web_DBL = " & DoubleWeb & ", "
						'End If
							
						If SinglePref = "" Then
							ErrMsg = ErrMsg & "(" & Item & ") Single Preferred Rate is Empty<br>"
						Else
							SQL = SQL & "@Cost_Pref_SNGL = " & SinglePref & ", "
						End If

						'If DoublePref = "" Then
						'	ErrMsg = ErrMsg & "(" & Item & ") Double Preferred Rate is Empty<br>"
						'Else
						'	SQL = SQL & "@Cost_Pref_DBL = " & DoublePref & ", "
						'End If
						
						If Blackout ="True" Then
							SQL = SQL & "@Blackout_Exempt =1"
						Else						
							SQL = SQL & "@Blackout_Exempt =0"
						End If	
								
				'Response.Write SQL & "<BR><BR>"

				If ErrMsg = "" Then
					Response.Write SQL
					Conn.Execute (SQL)
				Else
					Response.Write "*****************************************************************<BR>"
					Response.Write "Errors Received:<BR><br>"
					Response.Write ErrMsg
					Response.Write "<br><a href=""javascript:history.back()"">Click here to return to edit mode</a><br>"
					Response.Write "*****************************************************************<BR>"
					Response.End
				End If
		    Next 
				'Response.Write "*******************<BR>"
				
	    ' Linking to the next page
	    If Request.Form("cont") = "1" Then Response.Redirect "default-lodging.asp"
	    If Request.Form("cont") = "2" Then Response.Redirect "calendar.asp?txtMonth=" & Edit_Month & "&txtYear=" & Edit_Year

	End If
%>

<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>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<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]+"'");
}

function Sub_Form (cont)
{
  form1.cont.value=cont
  form1.submit();
}
//-->
</script>
<link rel="stylesheet" href="../Style-sheets/manage-menu-bold.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">
<link rel="stylesheet" href="/Style-sheets/standard-input-form.css" type="text/css">
</head>

<body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onLoad="MM_preloadImages('images/icon-return-to-main-2.gif','images/icon-submit-changes-2.gif','images/icon-continue-wizard-2.gif')">
<form name="form1" method="post" action="">
<INPUT type="hidden" id=page name=page value="<%=Page%>">
<INPUT type="hidden" id=cont name=cont >
  <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="center">EDIT Existing Allocations</td>
      <td bgcolor="#5e5ebe" align="right" width="187"><a href="default-lodging.asp" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image1','','images/icon-return-to-main-2.gif',1)"><img src="images/icon-return-to-main.gif" width="75" height="17" 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">No Entity Selected! Go 
        back and choose a location to edit from the dropdown menu.</td>
    </tr>
    <% End If %>
    <% RSName.Close %>
  </table>
  <%		' Getting Inventory Types with active Inventory
	Dim SQLInv, RSInv
	SQLInv = "execute Get_Inventory_Details @Item_Id='" & Item_ID & "', @Date='" & Edit_Date & "'"
	'Response.Write SQLInv
	Set RSInv=Conn.Execute(SQLInv)
  %>  

  <table width="481" border="0" cellspacing="0" cellpadding="2" align="center">
        <tr> 
      <td colspan="2" class="manage-menu" height="225" valign="top"> 
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
          </table>          
		<%	
		  If Not RSInv.EOF Then
		  Do While Not RSInv.EOF
		%>          
		  <input type="hidden" name="list_id" value="<%=RSInv("Inventory_List_ID")%>">
          <Table width="481" border="0" cellspacing="0" cellpadding="2" align="center">
          <TR>&nbsp;</TR>
          <tr align="center"> 
            <td colspan="4" class="manage-menu"><%=RSInv("RM_Type")%> / <%=RSInv("Amenity_PKG")%></td>
          </tr>
          <tr align="center"> 
            <td colspan="4" class="manage-menu">For&nbsp;&nbsp;<%=RSInv("Month")%>&nbsp;&nbsp;<%=RSInv("Day")%>,&nbsp;&nbsp;<%=RSInv("Year")%></td>
          </tr>
          <tr align="center"> 
            <td colspan="4" class="manage-menu"><font size="1">(<%=RSInv("Inventory_List_ID")%>)</font></td>
          </tr>
          <tr></tr>
          <tr align="center"> 
            <td width="10%" class="manage-menu">Property Total</td>
            <td width="10%" class="manage-menu">Allocated</td>
			<td width="10%" class="manage-menu">Available</td>
            <td width="10%" class="manage-menu">Alarm Level</td>
          </tr>
          <tr align="center"> 
            <td width="10%" class="manage-menu"><font face="Verdana, Arial, Helvetica, sans-serif" size="2"><%=RSInv("Total_On_Prop")%></font></td>
            <td width="10%"><input type="text" name="Allocated<%=RSInv("Inventory_List_ID")%>" size="4" value="<%=RSInv("Allocation")%>"></td>
            <td width="10%" class="manage-menu"><font face="Verdana, Arial, Helvetica, sans-serif" size="2"<%IF RSInv("Available")<> RSInv("Allocation") Then Response.Write "Color='Red'" End IF%>>  <%=RSInv("Available")%></font></td>
            <td width="10%"> <input type="text" name="Alarm<%=RSInv("Inventory_List_ID")%>" size="4" value="<%=RSInv("Alarm")%>"></td>
          </tr>
        </table>
        <table width="100%" border="0" cellspacing="1" cellpadding="0" bgcolor="#CCCCCC">
          <tr align="center"> 
            <td class="sm-hdln" width="24%" >&nbsp;</td>
            <td class="sm-hdln" width="16%" >Net</td>
            <td class="sm-hdln" width="15%" >Club</td>
            <td class="sm-hdln" width="19%" >Web</td>
            <td class="sm-hdln" width="26%" >Preferred</td>
          </tr>
          <tr> 
            <td width="24%" class="manage-menu" >Single</td>
            <td width="16%" class="input-box" align="center" > 
              <input type="text" name="SingleNet<%=RSInv("Inventory_List_ID")%>" size="5" class="input-box" value="<%=RSInv("Rate_SNGL")%>">
            </td>
            <td width="15%" class="input-box" align="center" > 
              <input type="text" name="SingleClub<%=RSInv("Inventory_List_ID")%>" size="5" class="input-box" value="<%=RSInv("Cost_Club_SNGL")%>">
            </td>
            <td width="19%" class="input-box" align="center" > 
              <input type="text" name="SingleWeb<%=RSInv("Inventory_List_ID")%>" size="5" class="input-box" value="<%=RSInv("Cost_Web_SNGL")%>">
            </td>
            <td width="26%" class="input-box" align="center" > 
              <input type="text" name="SinglePref<%=RSInv("Inventory_List_ID")%>" size="5" class="input-box" value="<%=RSInv("Cost_Pref_SNGL")%>">
            </td>
          </tr>
          <!--<tr> 
            <td width="24%" class="manage-menu" >DBL</td>
            <td width="16%" class="input-box" align="center" > 
              <input type="text" name="DoubleNet<%=RSInv("Inventory_List_ID")%>" size="5" class="input-box" value="<%=RSInv("Rate_DBL")%>">
            </td>
            <td width="15%" class="input-box" align="center" > 
              <input type="text" name="DoubleClub<%=RSInv("Inventory_List_ID")%>" size="5" class="input-box" value="<%=RSInv("Cost_Club_DBL")%>">
            </td>
            <td width="19%" class="input-box" align="center" > 
              <input type="text" name="DoubleWeb<%=RSInv("Inventory_List_ID")%>" size="5" class="input-box" value="<%=RSInv("Cost_Web_DBL")%>">
            </td>
            <td width="26%" class="input-box" align="center" > 
              <input type="text" name="DoublePref<%=RSInv("Inventory_List_ID")%>" size="5" class="input-box" value="<%=RSInv("Cost_Pref_DBL")%>">
            </td>-->
          </tr>
			<td colspan="5" width="24%" class="manage-menu" align="center">
				Check if this room and date are Blackout Date Exempt:
				<input type="checkbox" name="Blackout_Exempt<%=RSInv("Inventory_List_ID")%>" value="True" <% If RSInv("Blackout_Exempt") = True then Response.Write "Checked" End IF%>>
			</td>
          <tr>
          </tr>
        </table>
		<%
					RSInv.movenext
					ii=ii+1
				Loop 
			End IF 
			RSInv.Close
		%>
      </td>
    </tr>
  </table>

  <table width="525" border="0" cellspacing="0" cellpadding="0" align="center">
   <tr bgcolor="#5e5ebe"> 
		<td align="right" width="49%" bgcolor="#5e5ebe">
			<a href="javascript:Sub_Form('1');" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('submitchanges','','images/icon-submit-changes-2.gif',1)">
				<img src="images/icon-submit-changes.gif" width="200" height="15" name="submitchanges" border="0">
			</a>
		</td>
		<td width="51%">
			<a href="javascript:Sub_Form('2');" onmouseover="MM_swapImage('Image2','','images/icon-continue-wizard-2.gif',1)"  onmouseout=MM_swapImgRestore()>
				<img src="images/icon-continue-wizard.gif" width="150" height="15" usemap="#continue" border="0" name="Image2">
			</a>
		  </td>
	</tr>
  <tr> 
    <td width="49%">&nbsp;</td>
    <td width="51%">&nbsp;</td>
  </tr>
</table>
</form>
</body>
</html>
<%
Set Conn = Nothing
%>