<!--#include file="../../owFunctions/I_GeneralFunctions.asp"-->
<!--#include file="../header.asp"-->
<%
	'************************************************************************************
	'*																					*
	'*	MODIFICATION TO THIS SCRIPT OR ANY FILES INCLUDED WITH 							*
	'*		ONEWORLDSTORE IS DONE AT YOUR OWN RISK!										*
	'*	Product  : OneWorldStore														*
	'*	Version  : 9.0000																*
	'*	Modified : June 2004															*
	'*	Copyright:	Copyright (C) 2004 OneWorldStore.Com								*
	'*				Registration Number: 1024507										*
	'*				http://strategis.ic.gc.ca/											*
	'*																					*
	'************************************************************************************
	
	sAction				= Trim(Request("sAction"))
	sSort				= Trim(Request("sSort"))
	sSearchText			= Trim(Request("sSearchText"))
	sSearch				= Trim(Request("sSearch"))
	bResetDBLoc			= False
	sURL				= "owListOptionsGroup.asp"
	sTarget				= "owMain"
	
	If ( sAction = "Delete" ) Then
		For Each sCheckbox In Request.Form
			If ( InStr(sCheckbox, "sDelete") > 0 ) Then
				sTemp = Replace(sCheckbox, "sDelete", "")
				sSuccess = DeleteOptionsGroup(sTemp)
			End If
		Next
		bResetDBLoc = True
	End If
	
	If ( sSearchText <> "" ) Then
		If ( sSearch = "FirstChar" ) Then
			sTempSearch = " AND optionGroupDesc LIKE '" & sSearchText & "%'"
		Else
			sTempSearch = " AND " & sSearch & " LIKE '%" & sSearchText & "%'"
		End If
	Else
		sTempSearch = ""
	End If

	sSQLText	= "SELECT * FROM optionsGroups WHERE idOptionGroup>1" & sTempSearch
	sSQLCount	= "SELECT Count(*) FROM optionsGroups WHERE idOptionGroup>1" & sTempSearch

	If ( sSort <> "" ) Then
		sSQLText = sSQLText & " ORDER BY " & sSort
	Else
		sSQLText = sSQLText
	End If

	iBeginPagination = SetupPagination( sSQLCount, bResetTtlNumItems, bResetDBLoc )
	Call PaginationQuery( sSQLText, rsStoreData, iBeginPagination )

	%>
	<script language = "javascript">
		parent.owBodyFooter.location="owBodyFooter.asp?sAction=<%=sAction%>&sSearchText=<%=sSearchText%>&sSort=<%=sSort%>&sSearch=<%=sSearch%>&iOWNumPerPage=<%=iOWNumPerPage%>&iTtlNumItems=<%=iTtlNumItems%>&iDBLoc=<%=iDBLoc%>"
	</script>
	<%
	
	If ( sSuccess <> "" ) Or ( rsStoreData.EOF ) Then
		If ( sSuccess <> "" ) Then
			%>
			<script language = "javascript">
				parent.owBodyTopNav.location="owBodyTopNav.asp?sMessage=<%=Server.URLEncode(sSuccess)%>"
			</script>
			<%
		End If
		If ( rsStoreData.EOF ) Then
			%>
			<script language = "javascript">
				parent.owBodyTopNav.location="owBodyTopNav.asp?sMessage=<%=Server.URLEncode(LANG_DT( "OPTION_NOGROUP", "** No Option Groups found **" ))%>"
			</script>
			<%
		End If
	Else
		' just refresh the top bar to remove any "Save" buttons or old messages
		%>
		<script language = "javascript">
			parent.owBodyTopNav.location="owBodyTopNav.asp?sMessage="
		</script>
		<%
	End If
	sQueryString = "sSearchText=" & Server.URLEncode(sSearchText) & "&sSearch=" & Server.URLEncode(Trim(sSearch)) & "&sSort="
	%>
	<script language = "javascript">
		
		function ColumnOn(sStyle)
		{
			sStyle.background	= "#F5C058";
		}
		function ColumnOff(sStyle)
		{
			sStyle.background	= "#C3DAF9";
		}
		
		function ColumnDataOn(sStyle)
		{
			sStyle.background	= "#EAF1F9";
		}
		function ColumnDataOff(sStyle)
		{
			sStyle.background	= "#FFFFFF";
		}
		
	</script>
	<body bgcolor="C3DAF9" text="#000000" topmargin="0" leftmargin="0">
		<table width=100% border="0" cellpadding="2" cellspacing="0" style="font-size: 11px" bgcolor=FFFFFF>
		<form action='owListOptionsGroup.asp' method='post' name='OptionsGroupList'>
			<input type='hidden' name='sAction' value=''>
			<input type='hidden' name='sSort' value=''>
			<tr> 
				<td class="ColumnHead" align="center"><%=LANG_DT( "SELECT", "Select" )%></td>
				<td align="center" onClick="location.href='owListOptionsGroup.asp?<%=sQueryString%>idOptionGroup'" onMouseOver="ColumnOn(this.style);" onMouseOut="ColumnOff(this.style);" class="ColumnHead"><%=LANG_DT( "OPTION_GROUPID", "ID" )%></td>
				<td onClick="location.href='owListOptionsGroup.asp?<%=sQueryString%>OptionGroupDesc'" onMouseOver="ColumnOn(this.style);" onMouseOut="ColumnOff(this.style);" class="ColumnHead"><%=LANG_DT( "OPTION_GROUPNAME", "Option Group Name" )%></td>
				<td onClick="location.href='owListOptionsGroup.asp?<%=sQueryString%>Type'" onMouseOver="ColumnOn(this.style);" onMouseOut="ColumnOff(this.style);" class="ColumnHead"><%=LANG_DT( "OPTION_GROUPTYPE", "Group Type" )%></td>
			</tr>
			<%
			sSQLCount = 0
			While ( ( NOT rsStoreData.EOF ) And ( sSQLCount < iOWNumPerPage ) )
				idOptionGroup	= rsStoreData("idOptionGroup")
				sType			= rsStoreData("Type")
				sQueryString2	= sQueryString & sSort & "&idOptionGroup=" & idOptionGroup
				%>
				<tr onMouseOver="ColumnDataOn(this.style);" onMouseOut="ColumnDataOff(this.style);"> 
					<td width=5% class='ColumnData' align="center"><input size="1" type="checkbox" style="font-size: 6px;" name="sDelete<%=idOptionGroup%>" value="46"></td>
					<td width=5% onclick="location.href='owModifyOptionGroups.asp?<%=sQueryString2%>'" class='ColumnData' align="center"><%=idOptionGroup%>&nbsp;</td>
					<td onclick="location.href='owModifyOptionGroups.asp?<%=sQueryString2%>'" class='ColumnData'><%=rsStoreData("optionGroupDesc")%>&nbsp;</td>
					<td onclick="location.href='owModifyOptionGroups.asp?<%=sQueryString2%>'" class='ColumnData'>
						<%
						Select Case sType
							Case "Radio"
								Response.Write LANG_DT( "OPTION_RADIO", "Radio Buttons" )
							Case "Checkbox"
								Response.Write LANG_DT( "OPTION_CHECKBOX", "Checkboxes" )
							Case "Dropdown"
								Response.Write LANG_DT( "OPTION_DROPDOWN", "Dropdown List" )
							Case "Text"
								Response.Write LANG_DT( "OPTION_TEXT", "Text Field" )
							Case "Memo"
								Response.Write LANG_DT( "OPTION_MEMO", "Memo Field" )
							Case "File"
								Response.Write LANG_DT( "OPTION_FILE", "File Upload" )
							Case "Multipick"
								Response.Write LANG_DT( "OPTION_MULTIPICK", "Multipick Pick List" )
						End Select
						%>
						&nbsp;
					</td>
				</tr>
				<%
				sSQLCount = sSQLCount + 1
				rsStoreData.moveNext
			Wend
			Call DB_closeRecordset(rsStoreData)
			%>
    		</form>
  		</table>
	<!--#include file="../footer.asp"-->
	<%
	'************************************************************************************


	'************************************************************************************
	'*																					*
	'*																					*
	'*																					*
	'************************************************************************************
	Function DeleteOptionsGroup(sIDOptionGroup)

		If ( NOT bOWBackOfficeDemoMode ) Then	' just do a cursory check in case hackers try to replicate the forms on their computers (return no error)
			' remove options from the group
			Call DB_updateDatabase("DELETE FROM Options_OptionsGroups WHERE idOptionGroup = " & sIDOptionGroup)
			
			' remove from products
			Call DB_updateDatabase("DELETE FROM OptionsGroups_Products WHERE idOptionGroup = " & sIDOptionGroup)
			
			' now delete the group
			Call DB_updateDatabase("DELETE FROM OptionsGroups WHERE idOptionGroup = " & sIDOptionGroup)
			
			DeleteOptionsGroup = LANG_DT( "OPTION_DELETEOK", "** Deletion Successful **" )
		End If
	
	End Function
	'************************************************************************************
	%>