<%
' Page Number
Dim Page 
Page = "25"

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

Dim Title, Action
Title = "Create New"
Action = "create"

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

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

   Dim SQLAtt

   If Not Request("GoAction") = "remove" then

	If Request("GoAction") = "create" Or Request("GoAction") = "clone" Then
		Item_ID = "NULL"
	ElseIf Request("GoAction") = "edit" Then
		Item_ID = "'" & Request("Item_ID") & "'"
	End If

	If UCase(Request("InActive")) = "TRUE" Then
		InActive = "1"
	Else
		InActive = "NULL"
	End If

	SQLAtt = "Update_Ticket_List @Group_ID='" & Session("Admin_Group_ID") & "', @Item_ID = " & Item_ID & ", @Name ='" & Request("Item_Name") & "', @Marketing_Desc = '" & Request("MarketDesc") & "', "
	SQLAtt = SQLAtt & "@Restrictions = '" & Request("Restrictions") & "', @InActive = " & InActive & ", @Merchandise_Type_ID='1'"
'	Response.Write SQLAtt
	Set RSAtt = Conn.Execute(SQLAtt)

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

   Else
	
	SQLAtt = "Remove_Merchandise_List @Group_ID='" & Session("Admin_Group_ID") & "', @Item_ID = " & Replace(Request("Item_ID"),"'","''") & ""
	
	Set RSAtt = Conn.Execute(SQLAtt)

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

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

	If LCase(Request.Form("ticket_action")) = "edit" Then
		Title = "Edit Existing"
		Action="edit"
	ElseIf LCase(Request.Form("ticket_action")) = "clone" Then
		Title = "Cloned Item"
		Action = "clone"
	ElseIf LCase(Request.Form("ticket_action")) = "remove" Then
		Title = "<font color=""#FF7777"">Remove Item</font>"
		Action = "remove"
	End If
		
End If




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

Dim Price_Items
Set Price_Items = Conn.Execute("Select ILM.* from Inventory_List_Merchandise ILM Inner Join Inventory_Item_Group_Map IIGM On IIGM.Item_ID = ILM.Item_ID Where IIGM.Group_ID = '" & Session("Admin_Group_ID") & "' Order By ILM.[Name]")

Dim None_Found
None_Found = True

If Action = "edit" or Action="clone" or Action="remove" Then

	Dim Price_Info
	Set Price_Info = Conn.Execute("Select ILM.* from Inventory_List_Merchandise ILM Inner Join Inventory_Item_Group_Map IIGM On IIGM.Item_ID = ILM.Item_ID Where IIGM.Group_ID = '" & Session("Admin_Group_ID") & "' And IIGM.Item_ID = '" & Request.Form("ticket_type") & "'")

	Dim Item_Name, Marketing_Desc, InActive, Restrictions, Item_ID

	If Not Price_Info.EOF Then 
		Item_ID = Price_Info("Item_ID")
		Item_Name = Price_Info("Name")
		Marketing_Desc = Price_Info("Marketing_Description")
		InActive = Price_Info("InActive")
		Restrictions = Price_Info("Restrictions")
		None_Found = False
	End If		

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 Ticket_Action() {
  if (form1.ticket_action.value == 'create') {
	form1.cont.value='4';
	form1.submit();
  }
}

function Ticket_Form() {
  if (form1.ticket_action.value == 'create') {
	alert('Must select an edit option first.');
	form1.ticket_type.selectedIndex = '0';
  } else {
	form1.cont.value='3';
	form1.submit();
  }
}

function Sub_Form(cont) {
  if (form1.GoAction.value == 'remove') {
	form1.cont.value=cont;
	form1.submit(); 
  } else {
    if (form1.Item_Name.value == '') {
	alert('Please enter a name for the item.');
    } else {
	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">
</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="25">
<input type="hidden" name="cont" value="3">
<input type="hidden" name="GoAction" value="<%= Action %>">
<input type="hidden" name="Item_ID" value="<% If Not Action="clone" Then Response.Write(Request("ticket_type")) %>">
  <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">Define Ticket Types - <font color="#FFFFCC"><b><%= Title %></b></font></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="145">&nbsp;</td>
      <td width="236">&nbsp;</td>
      <td width="119">&nbsp;</td>
    </tr>
    <tr> 
      <td height="14" colspan="3"> 
      <table border="0" cellspacing="2" cellpadding="2" width="100%">
		<tr><td align="right">
			<select name="ticket_action" id="ticket_action" onchange="Ticket_Action()">
				<option value="create" <% If Action = "create" then Response.Write ("selected")%>>Create New</option>
<% If Not Price_Items.EOF Then %>
				<option value="clone" <% If Action = "clone" then Response.Write ("selected")%>>- Clone New From Existing</option>
				<option value="edit" <% If Action = "edit" then Response.Write ("selected")%>>- Edit Existing</option>
				<option value="remove" <% If Action = "remove" then Response.Write ("selected")%>>- Remove Existing</option>                    
<% End If %>
			</select>&nbsp;
<% If Not Price_Items.EOF Then %>
			</td><td align="right" width="50%">
			<select name="ticket_type" id="ticket_type" onchange="Ticket_Form()">
				<option value="">Select</option>
			<% Do While Not Price_Items.EOF %>
				<option value="<%=Price_Items("Item_ID")%>" <% If Item_ID=Price_Items("Item_ID") Then Response.Write "selected"%>><% If Price_Items("InActive") = True Then Response.Write ("N:") Else Response.Write("A:") End If %><%=Price_Items("Name")%></option>
			<% Price_Items.MoveNext
				Loop %>
			</select>
<% End If %></td></tr></table>
      </td>
    </tr>
    <tr>
		<td colspan="3">&nbsp;</td>
    </tr>

<% If Not Action="remove" Then %>
    <tr>
      <td width="145" height="14" class="manage-menu-bold">Name:</td>
      <td width="236" height="14">
        <input type="text" name="Item_Name" id="Item_Name" size="35" <% If None_Found = False And Action="edit" Then Response.Write ("value=""" & Item_Name & """")%>>
      </td>
      <td width="119" height="14">&nbsp;</td>
    </tr>
    <tr> 
      <td width="145" class="manage-menu-bold">Marketing<br>Description:</td>
      <td width="236"> 
        <textarea name="MarketDesc" rows="3" cols="35"><% If None_Found = False Then Response.Write (Marketing_Desc) %></textarea>
      </td>
      <td width="119">&nbsp;</td>
    </tr>
    <tr> 
      <td width="145" class="manage-menu-bold">&nbsp;</td>
      <td width="236">&nbsp;</td>
      <td width="119">&nbsp;</td>
    </tr>
    <tr> 
      <td width="145" class="manage-menu-bold">Restrictions:</td>
      <td width="236"> 
        <textarea name="Restrictions" rows="3" cols="35"><% If None_Found = False Then Response.Write (Restrictions) %></textarea>
      </td>
      <td width="119">&nbsp;</td>
    </tr>
    <tr> 
      <td width="145">&nbsp;</td>
      <td width="236">&nbsp;</td>
      <td width="119">&nbsp;</td>
    </tr>
    <tr> 
      <td width="145">&nbsp;</td>
      <td width="236" align="right" class="manage-menu">Is this item Inactive?</td> 
      <td width="119" align="left"><input type="checkbox" name="InActive" value="True" <% If InActive = True Then Response.Write ("checked")%>>&nbsp;Yes</td>
    </tr>
<% Else %>
    <tr> 
      <td colspan="3" class="manage-menu-bold"><font color="#FF3333">You are about to remove the item: <%= Item_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></td>
    </tr>
<% End If %>
    <tr> 
      <td width="145">&nbsp;</td>
      <td width="236">&nbsp;</td>
      <td width="119">&nbsp;</td>
    </tr>
  </table>
<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('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('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 %>