<!--#include file="../includes/Pagefunctions.asp"--> 
<%

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

' Product Types
'
' Inventory_Type_ID
'
'1	Lodging	Lodging Inventory Type for Motel and Hotels
'2	Merchandise	For Item, tickets, etc
'3	Lodging Items	Lodging Item IDs
'4	Merchandise Items	Merchandise Item IDs


For Each Room_Item in Request("Room_Items")

	Room_Package = Int(Request.Form("Room_Item_Package" & Room_Item))
	Package_Name = Request.Form("Package_Name")
	Package_Type_ID = Request.Form("Package_Type_ID")
	Package_Duration_ID = Request.Form("Package_Duration_ID")
	Marketing_Headline = Request.Form("Marketing_Headline")
	Short_Description = Request.Form("Short_Description")
	Long_Description = Request.Form("Long_Description")
	People_Ratio = Request.Form("People_Ratio")
	Time_Share = Request.Form("Time_Share")

	Package_Cost = Request.Form("total" & Room_Package)
	Nightly_Cost = Request.Form("nightly" & Room_Package)

	Package_City = Request.Form("City")
	Package_State = Request.Form("State")
	Package_Country = Request.Form("Country")

	Num_Adults = Request.Form("Num_Adults")
	Num_Children = Request.Form("Num_Children")
	Num_Nights = Int(Request.Form("Num_Nights"))

	Lodging = Request.Form("Lodging")
	Tickets = Request.Form("Tickets")
	Food_Bev = Request.Form("Food_Bev")
	Transport = Request.Form("Transport")

	Disabled = Request.Form("Disabled" & Room_Package)
	Budget = Request.Form("Budget" & Room_Package)

	Item_Logo_Group = Request.Form("logo" & Room_Package)
	
	Effective_Date = Request.Form("Effective_Date" & Room_Package)
	Expire_Date = Request.Form("Expire_Date" & Room_Package)
	
	If Trim(Effective_Date) = "" Then 
		Effective_Date = "NULL"
	Else
		Effective_Date = "'" & Effective_Date & "'"
	End If
	
	If Trim(Expire_Date) = "" Then 
		Expire_Date = "NULL"
	Else
		Expire_Date = "'" & Expire_Date & "'"
	End If

	Inventory_Type_ID = 3 'Lodging Item IDs, not List ID's
	Status = 1 ' Active Package Item

	Room_Group = Request.Form("Room_Item_Group" & Room_Item)
	Lodging_Name = Request.Form("Lodging_Name" & Room_Group)	

	Room_Occupancy = Int(Request.Form("Room_Item_Occ" & Room_Item))
	Room_Name = Request.Form("Room_Item_Name" & Room_Item)
	Room_Quantity = Int(Request.Form("Num_Rooms"))
	Room_Markup = Request.Form("P" & Room_Package & "_Room_Item_Markup" & Room_Item)
	
	If Trim(Room_Markup) = "" Then Room_Markup = "0"

	If Package_Cost = "" Then 
		Package_Cost = "NULL"
	Else
		Package_Cost = "" & Package_Cost & ""
	End If

	If Nightly_Cost = "" Then 
		Nightly_Cost = "NULL"
	Else
		Nightly_Cost = "" & Nightly_Cost & ""
	End IF



	SQL = "[Avante].[dbo].[Update_Package] "
	SQL = SQL & "	@Package_Name ='" & FormatSpecText(Package_Name) & "',"
	SQL = SQL & "	@Package_Type_ID ='" & Package_Type_ID & "',"
	SQL = SQL & "	@Package_Duration_ID ='" & Package_Duration_ID & "',"
	SQL = SQL & "	@Package_Headline ='" & FormatSpecText(Marketing_Headline) & "',"
	SQL = SQL & "	@Package_Desc ='" & FormatSpecText(Short_Description) & "',"
	SQL = SQL & "	@Package_Desc_Detail = '" & FormatSpecText(Long_Description) & "',"
	SQL = SQL & "	@People_Ratio = '" & People_Ratio & "',"
	SQL = SQL & "	@Num_Adults ='" & Num_Adults & "',"
	SQL = SQL & "	@Num_Children = '" & Num_Children & "',"
	SQL = SQL & "	@Num_Nights = '" & Num_Nights & "',"
	SQL = SQL & "	@Lodging = '" & Lodging & "',"
	SQL = SQL & "	@Tickets = '" & Tickets & "',"
	SQL = SQL & "	@Food_Bev = '" & Food_Bev & "',"
	SQL = SQL & "	@Transportation = '" & Transport & "',"
	SQL = SQL & "	@Disabled = '" & Disabled & "',"
	SQL = SQL & "	@Budget = '" & Budget & "',"
	SQL = SQL & "	@Effective_Date = " & Effective_Date & ","
	SQL = SQL & "	@Expire_Date = " & Expire_Date & ","
	SQL = SQL & "	@Package_Cost = " & Package_Cost & ","
	SQL = SQL & "	@Nightly_Cost = " & Nightly_Cost & ","
	SQL = SQL & "	@Realm_ID = '" & Session("Admin_Realm") & "',"
	SQL = SQL & "	@Group_ID = '" & Session("Entity_Group_ID") & "',"
	SQL = SQL & "	@Item_Logo_Group = '" & Item_Logo_Group & "',"
	SQL = SQL & "	@Package_City = '" & Package_City & "',"
	SQL = SQL & "	@Package_State = '" & Package_State & "',"
	SQL = SQL & "	@Package_Country = '" & Package_Country & "',"
	SQL = SQL & "	@Time_Share = '" & Time_Share & "' "
	'Response.Write(SQL)
	Set RSPackage = Conn.Execute(SQL)
	
	Package_ID = RSPackage("Package_ID")
	
	SQL = "[Avante].[dbo].[Update_Package_Detail] "
	SQL = SQL & "	@Package_ID ='" & Package_ID & "',"
	SQL = SQL & "	@Group_ID ='" & Room_Group & "',"
	SQL = SQL & "	@Quantity ='" & Room_Quantity & "',"
	SQL = SQL & "	@Inventory_ID ='" & Room_Item & "',"
	SQL = SQL & "	@Inventory_Type_ID ='" & Inventory_Type_ID & "',"
	SQL = SQL & "	@Markup ='" & Room_Markup & "',"
	SQL = SQL & "	@Status ='" & Status & "'"
	'Response.Write (SQL)
	Set RSPackage = Conn.Execute(SQL)
	Detail_ID = RSPackage("Detail_ID")

	For each Item in Request.Form("Items_" & Room_Group)

		Item_Group = Request.Form("Item_Group" & Item)
		Item_Quantity = Request.Form("Item_Quantity" & Item)
		Item_Markup = Request.Form("P" & Room_Package & "_Item_Markup" & Item)
		Status = 1
		Inventory_Type_ID = 2
		
		If Trim(Item_Markup) = "" Then Item_Markup = "0"

		SQL = "[Avante].[dbo].[Update_Package_Detail] "
		SQL = SQL & "	@Package_ID ='" & Package_ID & "',"
		SQL = SQL & "	@Group_ID ='" & Item_Group & "',"
		SQL = SQL & "	@Quantity ='" & Item_Quantity & "',"
		SQL = SQL & "	@Inventory_ID ='" & Item & "',"
		SQL = SQL & "	@Inventory_Type_ID ='" & Inventory_Type_ID & "',"
		SQL = SQL & "	@Markup ='" & Item_Markup & "',"
		SQL = SQL & "	@Status ='" & Status & "'"
		'Response.Write (SQL)
		Set RSPackage = Conn.Execute(SQL)
		Detail_ID = RSPackage("Detail_ID")

	Next
			
	For each Att_Item in Request.Form("Att_Items")

		Att_Group = Request.Form("Att_Group" & Att_Item)
		Att_Quantity = Request.Form("Att_Quantity" & Att_Item)
		Att_Markup = Request.Form("P" & Room_Package & "_Att_Item_Markup" & Att_Item)
		Status = 1
		Inventory_Type_ID = 2
		
		If Trim(Att_Markup) = "" Then Att_Markup = "0"

		SQL = "[Avante].[dbo].[Update_Package_Detail] "
		SQL = SQL & "	@Package_ID ='" & Package_ID & "',"
		SQL = SQL & "	@Group_ID ='" & Att_Group & "',"
		SQL = SQL & "	@Quantity ='" & Att_Quantity & "',"
		SQL = SQL & "	@Inventory_ID ='" & Att_Item & "',"
		SQL = SQL & "	@Inventory_Type_ID ='" & Inventory_Type_ID & "',"
		SQL = SQL & "	@Markup ='" & Att_Markup & "',"
		SQL = SQL & "	@Status ='" & Status & "'"
		'Response.Write (SQL)
		Set RSPackage = Conn.Execute(SQL)
		Detail_ID = RSPackage("Detail_ID")

	Next

	For each Merch_Item in Request.Form("Merch_Items")

		Merch_Group = Request.Form("Merch_Group" & Merch_Item)
		Merch_Quantity = Request.Form("Merch_Quantity" & Merch_Item)
		Merch_Markup = Request.Form("P" & Room_Package & "_Merch_Item_Markup" & Merch_Item)
		Status = 1
		Inventory_Type_ID = 2
		
		If Trim(Merch_Markup) = "" Then Merch_Markup = "0"

		SQL = "[Avante].[dbo].[Update_Package_Detail] "
		SQL = SQL & "	@Package_ID ='" & Package_ID & "',"
		SQL = SQL & "	@Group_ID ='" & Merch_Group & "',"
		SQL = SQL & "	@Quantity ='" & Merch_Quantity & "',"
		SQL = SQL & "	@Inventory_ID ='" & Merch_Item & "',"
		SQL = SQL & "	@Inventory_Type_ID ='" & Inventory_Type_ID & "',"
		SQL = SQL & "	@Markup ='" & Merch_Markup & "',"
		SQL = SQL & "	@Status ='" & Status & "'"
		'Response.Write (SQL)
		Set RSPackage = Conn.Execute(SQL)
		Detail_ID = RSPackage("Detail_ID")

	Next

	For each Food_Bev_Item in Request.Form("Food_Bev_Items")

		Food_Bev_Group = Request.Form("Food_Bev_Group" & Food_Bev_Item)
		Food_Bev_Quantity = Request.Form("Food_Bev_Quantity" & Food_Bev_Item)
		Food_Bev_Markup = Request.Form("P" & Room_Package & "_Food_Bev_Item_Markup" & Food_Bev_Item)
		
		If Trim(Food_Bev_Markup) = "" Then Food_Bev_Markup = "0"
		
		Status = 1
		Inventory_Type_ID = 2

		SQL = "[Avante].[dbo].[Update_Package_Detail] "
		SQL = SQL & "	@Package_ID ='" & Package_ID & "',"
		SQL = SQL & "	@Group_ID ='" & Food_Bev_Group & "',"
		SQL = SQL & "	@Quantity ='" & Food_Bev_Quantity & "',"
		SQL = SQL & "	@Inventory_ID ='" & Food_Bev_Item & "',"
		SQL = SQL & "	@Inventory_Type_ID ='" & Inventory_Type_ID & "',"
		SQL = SQL & "	@Markup ='" & Food_Bev_Markup & "',"
		SQL = SQL & "	@Status ='" & Status & "'"
		'Response.Write (SQL)		
		Set RSPackage = Conn.Execute(SQL)
		Detail_ID = RSPackage("Detail_ID")

	Next

Next

Session("default_page") = "default-packages.asp"
Response.Redirect Session("default_page")

%>

<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>Packages Created</title>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<!--
<%
For Each item in Request.Form
  If Not UCase(item) = "PAGE" And Not UCase(item) = "CONT" Then
	For each value in Request.Form(item)
%>
		<input type="hidden" name="<%=item%>" value="<%=value%>">
		<%=item%> : <%=value%><br>
<%
	Next
  End If
Next
%>
-->
</body>
</html>
