<%
Dim Page 
Page = "26"

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

Dim Attraction_ID, Action

If (UCase(Request.ServerVariables("REQUEST_METHOD")) = "POST" And Request.Form("page") = "0") Then

  If Not Request.Form("Attraction_ID") = "" Then

	Attraction_ID = Request.Form("Attraction_ID")

	If Request.Form("Attraction_ID") = "" Then
		Attraction_ID = "0"
	End If

	Session("Admin_Group_ID") = Attraction_ID
		
	Else
	
		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

End If


Dim SQLAtt
Dim Item_ID, Price_Desc, Cost, Regular_Price, Display_Price, Status, Display_Pricing, Pricing_URL

Dim Edit
Edit = False

Action = "create"

If (UCase(Request.ServerVariables("REQUEST_METHOD")) = "POST" And Request.Form("page") = Page And (Request.Form("cont") = "1" Or Request.Form("cont") = "2")) Then


'	@Inventory_List_ID int = NULL,
'	@Item_ID int,
'	@Merchant_ID,
'	@Group_ID,
'	@Description nvarchar(300),
'	@Cost nvarchar(50),
'	@Gate_Price nvarchar(50),
'	@Display_Price nvarchar(50),
'	@Do_Not_Display_Price bit,
'	@Realm int
	
		SQLAtt = "[Avante].[dbo].[Update_Ticket_Price] "
	
		If Not Request("Inventory_List_ID") = "" and Not Request("Inventory_List_ID") = "package" Then
			SQLAtt = SQLAtt & "@Inventory_List_ID='" & Request("Inventory_List_ID") & "', "
		End If
	
		SQLAtt = SQLAtt & "@Merchant_ID='" & Request("Merchant_ID") & "', "
		SQLAtt = SQLAtt & "@Group_ID='" & Request("Admin_Group_ID") & "', "
		SQLAtt = SQLAtt & "@Item_ID='" & Request("Item_ID") & "', "
		SQLAtt = SQLAtt & "@Description='" & Request("Description") & "', "
	
		If Request("cost") = "" Then
			SQLAtt = SQLAtt & "@Cost=Null, "
		Else
			SQLAtt = SQLAtt & "@Cost=" & Request("cost") & ", "
		End If
	
	
		If Request("gate") = "" Then
			SQLAtt = SQLAtt & "@Regular_Price=Null, "
		Else
			SQLAtt = SQLAtt & "@Regular_Price=" & Request("gate") & ", "
		End If
	
	
		If Request("display") = "" Then
			SQLAtt = SQLAtt & "@Display_Price=Null, "
		Else
			SQLAtt = SQLAtt & "@Display_Price=" & Request("display") & ","
		End If
	
		SQLAtt = SQLAtt & "@Do_Not_Display_Price='" & Request("Do_Not_Display_Price") & "', "
		SQLAtt = SQLAtt & "@Realm='" & Request("Admin_Realm") & "', "
	
		If Request("Item_Status") = "" Then
			SQLAtt = SQLAtt & "@Status='1', "
		Else
			SQLAtt = SQLAtt & "@Status='0', "
		End If

		SQLAtt = SQLAtt & "@Pricing_URL='" & Request("Pricing_URL") & "',"

		If Request("GoAction") = "package-create" Or Request("GoAction") = "package-edit" Then
			SQLAtt = SQLAtt & "@Packaged='1' "
		Else
			SQLAtt = SQLAtt & "@Packaged='0' "
		End If

		
		'Response.Write SQLAtt
		Conn.Execute SQLAtt

	If Request("Cont") = "1" Then 
		Response.Redirect "default-attractions.asp"
	Else
		'Response.Redirect "attraction-pricing.asp"
	End If

ElseIf (UCase(Request.ServerVariables("REQUEST_METHOD")) = "POST" And Request.Form("page") = Page And Request.Form("cont") = "3") Then

	If Not Request("Inventory_List_ID") = "" And Not LCase(Request("Inventory_List_ID")) = "package" Then

		Action = "edit"
		Edit = True
		SQLAtt = "Select * From Inventory_List_Merchandise ILM Inner Join Inventory_Price_Merchandise IPM On IPM.Item_ID = ILM.Item_ID Where IPM.Inventory_List_ID='" & Replace(Request("Inventory_List_ID"),"'", "''") & "'"
		Set RSAtt = Conn.Execute(SQLAtt)

		Item_ID = RSAtt("Item_ID")
		Price_Desc = RSAtt("Description")
		Cost = RSAtt("Cost")
		Regular_Price = RSAtt("Regular_Price")
		Display_Price = RSAtt("Display_Price")
		Item_Status = RSAtt("Status")
		Display_Pricing = RSAtt("Do_Not_Display_Price")
		Pricing_URL = RSAtt("Pricing_URL")
		Packaged = RSAtt("Packaged")
		
		If Packaged = True Then Action = "package-edit"

	ElseIf LCase(Request("Inventory_List_ID")) = "package" Then
		Action = "package-create"
	End If

ElseIf (UCase(Request.ServerVariables("REQUEST_METHOD")) = "POST" And Request.Form("page") = Page And Request.Form("cont") = "4") Then

	Action = "remove"

ElseIf (UCase(Request.ServerVariables("REQUEST_METHOD")) = "POST" And Request.Form("page") = Page And (Request.Form("cont") = "5" Or Request.Form("cont") = "6")) Then

	SQLAtt = "Remove_Merchandise_Price @Inventory_List_ID='" & Request("Inventory_List_ID") & "'"
	Conn.Execute SQLAtt

	If Request("Cont") = "5" Then 
		Response.Redirect "default-attractions.asp"
	Else
		'Response.Redirect "attraction-pricing.asp"
	End If

End If

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

Dim SQLPNames, RSPNames
SQLPNames = "Select Distinct [Description] from [Avante].[dbo].[Inventory_Price_Merchandise] IPM Inner Join [Inventory_List_Merchandise] ILM On IPM.Item_ID = ILM.Item_ID Where ILM.[Merchandise_Type_ID] = '1' Order By [Description]"
Set RSPNames = Conn.Execute(SQLPNames)

%>
<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_showHideLayer_toggle() { //v3.0
  var i,p,v,obj,args=MM_showHideLayer_toggle.arguments;
  for (i=0; i<(args.length); i+=1) if ((obj=MM_findObj(args[i]))!=null) { 
    v = obj.style.visibility;
    if (obj.style) { 
		obj=obj.style; 
		v=(v=='hidden')?'visible':(v='visible')?'hidden':v; 
		}
    obj.visibility=v; }
}
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 Item_Action() {
	form1.cont.value='3';
	form1.submit();
}

function Item_Remove() {
  if (form1.Inventory_List_ID.value != '') {
	form1.cont.value='4';
	form1.submit();
  }
}

function Item_Clone() {
form1.Inventory_List_ID.selectedIndex = '0';
form1.GoAction.value='create';
form1.Description.value = '';

}

function Sub_Form(cont) {
 if (cont == '5' || cont == '6') {
   form1.cont.value=cont;
   form1.submit();
 } else if (!form1.Item_ID.value == '') {  
   form1.cont.value=cont;
   form1.submit();
 } else {
   alert ('Please select a ticket type.');
 }
}
//-->
</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">
</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" name="page" value="26">
<input type="hidden" name="cont" value="">
<input type="hidden" name="Merchant_ID" value="<%=Session("Merchant_ID")%>">
<input type="hidden" name="Admin_Realm" value="<%=Session("Admin_Realm")%>">
<input type="hidden" name="Admin_Group_ID" value="<%=Session("Admin_Group_ID")%>">
<input type="hidden" name="GoAction" id="GoAction" value="<%=Action%>">
  <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">Attraction Pricing</td>

      <td bgcolor="#5e5ebe
" align="right" width="187"><a href="default-attractions.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>
  <table width="500" border="0" cellspacing="0" cellpadding="2" align="center">
    <tr> 
      <td width="161">&nbsp;</td>
      <td width="185">&nbsp;</td>
      <td width="154">&nbsp;</td>
    </tr>
<!--    <tr>       <td class="manage-menu-bold">Action Selection:</td>      <td class="manage-menu" colspan="2">        <select name="Inventory_Action" id="Inventory_List_ID" onchange="Item_Action()">          <option value="">Create a New Price Point</option>          <option value="package">Create a New Package Item</option>		</select>	  </td>	</tr>-->	
    <tr> 
      <td class="manage-menu-bold">Item Selection:</td>
      <td class="manage-menu" colspan="2">
      <%
        Set RSAttr = Server.CreateObject("ADODB.Recordset")
        RSAttr.Open "Select * From Inventory_List_Merchandise ILM Inner Join Inventory_Price_Merchandise IPM On IPM.Item_ID = ILM.Item_ID Where IPM.Group_ID = '" & Session("Admin_Group_ID") & "' And Not IPM.Removed=1 Order By IPM.[Packaged], IPM.[Status], ILM.[Name], IPM.[Description]", Conn
        %>
        <select name="Inventory_List_ID" id="Inventory_List_ID" onchange="Item_Action()">
          <option value="">Create a New Price Point</option>
          <%
          Do while Not RSAttr.EOF%>
          <option value="<%=RSAttr("Inventory_List_ID")%>" <% 
			If Edit = True Or Action="remove" Then 
				If Int(RSAttr("Inventory_List_ID")) = Int(Request("Inventory_List_ID")) Then 
					Response.Write "selected"
					Inventory_Name = RSAttr("Name") & ": " & RSAttr("Description") 
				End If 
			End If
			%>><%	
			If RSAttr("Packaged") = True Then 
				Response.Write "P: " 
			ElseIf RSAttr("Status") = True Then 
				Response.Write "A: " 
			Else 
				Response.Write "N: " 
			End If %><%=RSAttr("Name") & ": " & RSAttr("Description") %></option>
          <%
          RSAttr.MoveNext()
          Loop%>          
        </select>
        <%
        RSAttr.Close()
        %>
      </td>
    </tr>
    <tr> 
      <td width="161">&nbsp;</td>
      <td width="185">&nbsp;</td>
      <td width="154">&nbsp;</td>
    </tr>

<% If Not Action="remove" Then %>
    <tr> 
      <td class="manage-menu-bold">Ticket Name:</td>
      <td class="manage-menu">
      <%If Request.QueryString("Attraction_ID") = "" Then
        Set RSAttr = Server.CreateObject("ADODB.Recordset")
        RSAttr.Open "Select * From Inventory_List_Merchandise ILM Inner Join Inventory_Item_Group_Map IIGM On IIGM.Item_ID = ILM.Item_ID Where Group_ID = '" & Session("Admin_Group_ID") & "' Order By ILM.[Name]", Conn
        %>
        <select name="Item_ID">
          <option value selected>List of Available Ticket Types</option>
          <%
          Do while Not RSAttr.EOF%>
          <option value="<%=RSAttr("Item_ID")%>" <% If Edit = True Then If RSAttr("Item_ID") = Item_ID Then Response.Write "selected" End If %>><%=RSAttr("Name")%></option>
          <%
          RSAttr.MoveNext()
          Loop%>          
        </select>
        <%
        RSAttr.Close()
        Else
        Set RSAttr = Server.CreateObject("ADODB.Recordset")
        RSAttr.Open "Select * From Inventory_List_Merchandise Where Item_ID = '" & Request.QueryString("Attraction_ID") & "'", Conn
        Response.Write ("<input type=""text"" readonly size=""30"" style=""{border-style:none;background-color:transparent}"" value=""" & RSAttr("Name") & """>")
        Response.Write ("<input type=""hidden"" name=""Item_ID"" value=""" & RSAttr("Item_ID") & """>")
        RSAttr.Close()
        End If
        %>
      </td>
      <td class="manage-menu">&nbsp;</td>
    </tr>
    <tr> 
      <td class="manage-menu-bold">Price Description:</td>
      <td class="manage-menu" valign="center"><input type="text" name="Description" size="30" <% If Edit = True Then Response.Write ("value=""" & Price_Desc & """")%></td>
      <td class="manage-menu"><img src="images/down-button.gif" align="center" onClick="MM_showHideLayer_toggle('descriptions')" style="{cursor:hand}">&nbsp;<font size="1">Click</font></td>
    </tr>
  </table>
  <table width="500" border="0" cellspacing="0" cellpadding="0" align="center">
    <tr align="center">
      <td width="131" class="manage-menu">&nbsp;</td>
      <td width="140" class="manage-menu">&nbsp;</td>
      <td width="124" class="manage-menu">&nbsp;</td>
    </tr>
    <tr> 
      <td align="center" width="131" class="sub-head">Cost</td>
      <td align="center" width="140" class="sub-head">Gate</td>
      <td align="center" width="124" class="sub-head">Display</td>
    </tr>
    <tr align="center"> 
      <td width="131" class="manage-menu"> $ 
        <input type="text" name="cost" size="4" <% If Edit = True Then Response.Write ("value=""" & Cost & """")%>>
      </td>
      <td width="140" class="manage-menu"> $ 
        <input type="text" name="gate" size="4" <% If Edit = True Then Response.Write ("value=""" & Regular_Price & """")%>>
      </td>
      <td width="124" class="manage-menu"> $ 
        <input type="text" name="display" size="4" <% If Edit = True Then Response.Write ("value=""" & Display_Price & """")%>>
      </td>
    </tr>
    <tr align="center">
      <td width="131" class="manage-menu">&nbsp;</td>
      <td width="140" class="manage-menu">&nbsp;</td>
      <td width="124" class="manage-menu">&nbsp;</td>
    </tr>
    <tr align="center">
      <td width="131" class="manage-menu">Status: <input type="checkbox" name="Item_Status" value="0" <% If Edit = True And Item_Status = False Then Response.Write ("checked")%>> Off </td>
      <td colspan="2" class="manage-menu">Display Pricing for this Ticket? <input type="checkbox" name="Do_Not_Display_Price" value="1" onClick="MM_showHideLayer_toggle('pricing')" <% If Edit = True And Display_Pricing = True Then Response.Write ("checked")%>> No</td>
    </tr>
    <tr align="center">
      <td width="131" class="manage-menu">&nbsp;</td>
      <td width="140" class="manage-menu">&nbsp;</td>
      <td width="124" class="manage-menu">&nbsp;</td>
    </tr>
    <tr align="center">
      <td colspan="3" class="manage-menu">
            <div id="pricing" style="position:relative; width:100%; height:30px; z-index:8; left: 0px; top: 0px; visibility: <% If Edit = True And Display_Pricing = True Then Response.Write ("visible") else Response.Write("hidden") End If %>"> 
			    URL For Pricing Information: <input type="text" size="30" name="Pricing_URL" <% If Edit = True Then Response.Write ("value=""" & Pricing_URL & """") Else Response.Write("value=""http://""")%>>
            </div>
	  </td>
    </tr>

<% If Edit = True Then %>
    <tr> 
      <td colspan="3"><img src="images/shim.gif" height="2" width="1"></td>
    </tr>
    <tr> 
      <td colspan="3" bgcolor="#5e5ebe
"><img src="images/shim.gif" height="1" width="1"></td>
    </tr>
    <tr> 
      <td valign="top" colspan="3" align="center" class="manage-menu"><table border="0" cellspacing="0" cellpadding="0" width="100%">
       <tr>
        <!--<td valign="top" align="left"><font size="1"><a onClick="Item_Remove('4')" style="{cursor:hand; text-decoration:none; background-color:#e3e3e3;}" class="manage-menu"><font size="1">&nbsp;Clone into package item&nbsp;</font></a></font></td>-->
        <td valign="top" align="left"><font size="1"><a onClick="Item_Clone()" style="{cursor:hand; text-decoration:none; background-color:#e3e3e3;}" class="manage-menu"><font size="1">&nbsp;Clone into another item&nbsp;</font></a></font></td>
		<td></td>
        <td valign="top" align="right"><font size="1"><a onClick="Item_Remove()" style="{cursor:hand; text-decoration:none; background-color:#e3e3e3;}" class="manage-menu"><font size="1">&nbsp;Remove this price point&nbsp;</font></a></font></td>
       </tr>
      </table></td>
    </tr>
    <tr> 
      <td colspan="3" bgcolor="#5e5ebe
"><img src="images/shim.gif" height="1" width="1"></td>
    </tr>
<% End If %>    

    <tr> 
      <td width="161" class="manage-menu"><font size="1">&nbsp;</font></td>
      <td width="185" class="manage-menu"><font size="1">&nbsp;</font></td>
      <td width="154" class="manage-menu"><font size="1">&nbsp;</font></td>
    </tr>

<% Else %>
    <tr> 
      <td colspan="3" class="manage-menu-bold"><font color="#FF3333">You are about to remove the price point:<br>&nbsp;&nbsp; - <%= Inventory_Name %><br><br> Are you sure you want to do this?<br><br> If so, Continue Wizard or Submit Changes to remove.<br><br> If not, click on 'Remove Existing' and select another option.</font><br><br></td>
    </tr>
<% End If %>
  </table>

<% If Not RSPNames.EOF Then %>
<div name="descriptions" id="descriptions" align="center" style="position:absolute; width:201; height:100%; z-index:3; top: 185px; left: 50%; visibility: hidden; overflow: auto">
<table border="0" cellspacing="0" cellpadding="0" width="100%" bgcolor="#ececec">
<tr bgcolor="#f7f7f7">
    <td class="sub-heard" align="right" valign="top"><img src="images/click-button.gif" onClick="MM_showHideLayer_toggle('descriptions')" style="{cursor:hand}"></td>
</tr>
<tr>
    <td align="center"><table border="0" cellspacing="0" cellpadding="0" bgcolor="#ffffff" width="98%" height="98%"><tr><td><% 
   Do While Not RSPNames.EOF %>
	<% If Not RSPNames("Description") = "" Then %>
		<a onclick="form1.Description.value='<%=RSPNames("Description")%>';MM_showHideLayer_toggle('descriptions');" class="manage-menu" style="{cursor:hand}"><font size="1">&nbsp;- <%=RSPNames("Description")%></font></a><br>
<%	   End If
 	RSPNames.MoveNext
   Loop
%></td></tr></table></td>
</tr><tr><td bgcolor="#ececec" height="2"><img src="images/shim.gif" height="2" width="1"></td></tr></table></div>
<% End If %>

  <table width="525" border="0" cellspacing="0" cellpadding="0" align="center">
  <tr bgcolor="#5e5ebe
"> 
    <td align="right" width="49%" height="18"><a href="javascript:Sub_Form('<% If Action="remove" Then Response.Write "5" Else Response.Write "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%" height="18"><a href="javascript:Sub_Form('<% If Action="remove" Then Response.Write "6" Else Response.Write "2" %>');" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image2','','images/icon-continue-wizard-2.gif',1)"><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 %>