403Webshell
Server IP : 103.118.17.23  /  Your IP : 216.73.216.169
Web Server : Microsoft-IIS/10.0
System : Windows NT RESELLERPLESK22 10.0 build 20348 (Windows Server 2016) AMD64
User : IWAM_plesk(default) ( 0)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  E:/Inetpub/vhosts/mesa.org.in/httpdocs/panel/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : E:/Inetpub/vhosts/mesa.org.in/httpdocs/panel/bedlist.asp
<%@ CodePage="65001" %>
<%
Response.Buffer = EW_RESPONSE_BUFFER
%>
<!--#include file="ewcfg.asp"-->
<!--#include file="bedinfo.asp"-->
<!--#include file="aspfn.asp"-->
<!--#include file="userfn.asp"-->
<% Call ew_Header(False, EW_CHARSET, False) %>
<%

' Define page object
Dim bed_list
Set bed_list = New cbed_list
Set Page = bed_list

' Page init processing
Call bed_list.Page_Init

' Page main
Call bed_list.Page_Main

' Global Page Rendering event (in userfn*.asp)
Page_Rendering()

' Page Render event
bed_list.Page_Render()
%>
<!--#include file="header.asp"-->
<% If bed.Export = "" Then %>
<script type="text/javascript">
// Form object
var CurrentPageID = EW_PAGE_ID = "list";
var CurrentForm = fbedlist = new ew_Form("fbedlist", "list");
fbedlist.FormKeyCountName = '<%= bed_list.FormKeyCountName %>';
// Form_CustomValidate event
fbedlist.Form_CustomValidate = 
 function(fobj) { // DO NOT CHANGE THIS LINE!
 	// Your custom validation code here, return false if invalid. 
 	return true;
 }
// Use JavaScript validation or not
<% If EW_CLIENT_VALIDATE Then %>
fbedlist.ValidateRequired = true; // Use JavaScript validation
<% Else %>
fbedlist.ValidateRequired = false; // No JavaScript validation
<% End If %>
// Dynamic selection lists
<% Set arAS = Nothing %>
// Form object for search
var CurrentSearchForm = fbedlistsrch = new ew_Form("fbedlistsrch");
</script>
<script type="text/javascript">
// Write your client script here, no need to add script tags.
</script>
<% End If %>
<% If bed.Export = "" Then %>
<div class="ewToolbar">
<% If bed_list.TotalRecs > 0 And bed_list.ExportOptions.Visible Then %>
<% Call bed_list.ExportOptions.Render("body", "", "", "", "", "") %>
<% End If %>
<% If bed_list.SearchOptions.Visible Then %>
<% Call bed_list.SearchOptions.Render("body", "", "", "", "", "") %>
<% End If %>
<% If bed_list.FilterOptions.Visible Then %>
<% Call bed_list.FilterOptions.Render("body", "", "", "", "", "") %>
<% End If %>
<div class="clearfix"></div>
</div>
<% End If %>
<% If bed.Export = "" Or EW_EXPORT_MASTER_RECORD And bed.Export = "print" Then %>
<% End If %>
<%

	'bed_list.TotalRecs = bed_list.Recordset.RecordCount ' Already loaded ' ASP
	bed_list.StartRec = 1
	If bed_list.DisplayRecs <= 0 Then ' Display all records
		bed_list.DisplayRecs = bed_list.TotalRecs
	End If
	If Not (bed.ExportAll And bed.Export <> "") Then
		Call bed_list.SetupStartRec ' Set up start record position
	End If

	' Load records ' ASP
	Set bed_list.Recordset = bed_list.LoadRecordset(bed_list.StartRec-1, bed_list.DisplayRecs)

	' Set no record found message
	If bed.CurrentAction = "" And bed_list.TotalRecs = 0 Then
		If bed_list.SearchWhere = "0=101" Then
			bed_list.WarningMessage = Language.Phrase("EnterSearchCriteria")
		Else
			bed_list.WarningMessage = Language.Phrase("NoRecord")
		End If
	End If
Call bed_list.RenderOtherOptions
%>
<% If Security.IsLoggedIn() Then %>
<% If bed.Export = "" And bed.CurrentAction = "" Then %>
<form name="fbedlistsrch" id="fbedlistsrch" class="form-inline ewForm ewExtSearchForm" action="<%= ew_CurrentPage %>">
<% SearchPanelClass = ew_IIf(bed_list.SearchWhere <> "", " in", " in") %>
<div id="fbedlistsrch_SearchPanel" class="ewSearchPanel collapse<%= SearchPanelClass %>">
<input type="hidden" name="cmd" value="search">
<input type="hidden" name="t" value="bed">
	<div class="ewBasicSearch">
<div id="xsr_1" class="ewRow">
	<div class="ewQuickSearch input-group">
	<input type="text" name="<%= EW_TABLE_BASIC_SEARCH %>" id="<%= EW_TABLE_BASIC_SEARCH %>" class="form-control" value="<%= ew_HtmlEncode(bed.BasicSearch.getKeyword()) %>" placeholder="<%= ew_HtmlEncode(Language.Phrase("Search")) %>">
	<input type="hidden" name="<%= EW_TABLE_BASIC_SEARCH_TYPE %>" id="<%= EW_TABLE_BASIC_SEARCH_TYPE %>" value="<%= ew_HtmlEncode(bed.BasicSearch.getSearchType()) %>">
	<div class="input-group-btn">
		<button type="button" data-toggle="dropdown" class="btn btn-default"><span id="searchtype"><%= bed.BasicSearch.getSearchTypeNameShort() %></span><span class="caret"></span></button>
		<ul class="dropdown-menu pull-right" role="menu">
			<li<% If bed.BasicSearch.getSearchType() = "" Then Response.Write " class=""active""" %>><a href="javascript:void(0);" onclick="ew_SetSearchType(this)"><%= Language.Phrase("QuickSearchAuto") %></a></li>
			<li<% If bed.BasicSearch.getSearchType() = "=" Then Response.Write " class=""active""" %>><a href="javascript:void(0);" onclick="ew_SetSearchType(this,'=')"><%= Language.Phrase("QuickSearchExact") %></a></li>
			<li<% If bed.BasicSearch.getSearchType() = "AND" Then Response.Write " class=""active""" %>><a href="javascript:void(0);" onclick="ew_SetSearchType(this,'AND')"><%= Language.Phrase("QuickSearchAll") %></a></li>
			<li<% If bed.BasicSearch.getSearchType() = "OR" Then Response.Write " class=""active""" %>><a href="javascript:void(0);" onclick="ew_SetSearchType(this,'OR')"><%= Language.Phrase("QuickSearchAny") %></a></li>
		</ul>
	<button class="btn btn-primary ewButton" name="btnsubmit" id="btnsubmit" type="submit"><%= Language.Phrase("SearchBtn") %></button>
	</div>
	</div>
</div>
	</div>
</div>
</form>
<% End If %>
<% End If %>
<% Call bed_list.ShowPageHeader %>
<% Call bed_list.ShowMessage %>
<% If bed_list.TotalRecs > 0 Or bed.CurrentAction <> "" Then %>
<div class="box ewBox ewGrid<% If bed.IsAddOrEdit() Then %> ewGridAddEdit<% End If %> bed">
<% If bed.Export = "" Then %>
<div class="box-header ewGridUpperPanel">
<% If bed.CurrentAction <> "gridadd" And bed.CurrentAction <> "gridedit" Then %>
<form name="ewPagerForm" class="form-inline ewForm ewPagerForm" action="<%= ew_CurrentPage %>">
<% If ew_Empty(bed_list.Pager) Then Set bed_list.Pager = ew_NewNumericPagerBase(bed_list.StartRec, bed_list.DisplayRecs, bed_list.TotalRecs, bed_list.RecRange, bed_list.AutoHidePager) %>
<% If bed_list.Pager.RecordCount > 0 And bed_list.Pager.Visible Then %>
<div class="ewPager">
<div class="ewNumericPage"><ul class="pagination">
	<% If bed_list.Pager.FirstButton.Enabled Then %>
	<li><a href="<%= bed_list.PageUrl %>start=<%= bed_list.Pager.FirstButton.Start %>"><%= Language.Phrase("PagerFirst") %></a></li>
	<% End If %>
	<% If bed_list.Pager.PrevButton.Enabled Then %>
	<li><a href="<%= bed_list.PageUrl %>start=<%= bed_list.Pager.PrevButton.Start %>"><%= Language.Phrase("PagerPrevious") %></a></li>
	<% End If %>
	<% For Each PagerItem In bed_list.Pager.Items %>
		<li<% if Not PagerItem.Enabled Then Response.Write " class=""active""" End If %>><a href="<% If PagerItem.Enabled Then Response.Write bed_list.PageUrl & "start=" & PagerItem.Start Else Response.Write "#" End If %>"><%= PagerItem.Text %></a></li>
	<% Next %>
	<% If bed_list.Pager.NextButton.Enabled Then %>
	<li><a href="<%= bed_list.PageUrl %>start=<%= bed_list.Pager.NextButton.Start %>"><%= Language.Phrase("PagerNext") %></a></li>
	<% End If %>
	<% If bed_list.Pager.LastButton.Enabled Then %>
	<li><a href="<%= bed_list.PageUrl %>start=<%= bed_list.Pager.LastButton.Start %>"><%= Language.Phrase("PagerLast") %></a></li>
	<% End If %>
</ul></div>
</div>
<% End If %>
<% If bed_list.Pager.RecordCount > 0 Then %>
<div class="ewPager ewRec">
	<span><%= Language.Phrase("Record") %>&nbsp;<%= bed_list.Pager.FromIndex %>&nbsp;<%= Language.Phrase("To") %>&nbsp;<%= bed_list.Pager.ToIndex %>&nbsp;<%= Language.Phrase("Of") %>&nbsp;<%= bed_list.Pager.RecordCount %></span>
</div>
<% End If %>
</form>
<% End If %>
<div class="ewListOtherOptions">
<%
	Call bed_list.AddEditOptions.Render("body", "", "", "", "", "")
	Call bed_list.DetailOptions.Render("body", "", "", "", "", "")
	Call bed_list.ActionOptions.Render("body", "", "", "", "", "")
%>
</div>
<div class="clearfix"></div>
</div>
<% End If %>
<form name="fbedlist" id="fbedlist" class="form-inline ewForm ewListForm" action="<%= ew_CurrentPage %>" method="post">
<% If bed_list.CheckToken Then %>
<input type="hidden" name="<%= EW_TOKEN_NAME %>" value="<%= bed_list.Token %>">
<% End If %>
<input type="hidden" name="t" value="bed">
<div id="gmp_bed" class="<% If ew_IsResponsiveLayout() Then %>table-responsive <% End If %>ewGridMiddlePanel">
<% If bed_list.TotalRecs > 0 Or bed.CurrentAction = "gridedit" Then %>
<table id="tbl_bedlist" class="table ewTable">
<thead>
	<tr class="ewTableHeader">
<%

' Header row
bed.RowType = EW_ROWTYPE_HEADER
Call bed_list.RenderListOptions

' Render list options (header, left)
Call bed_list.ListOptions.Render("header", "left", "", "", "", "")
%>
<% If bed.ID.Visible Then ' ID %>
	<% If bed.SortUrl(bed.ID) = "" Then %>
		<th data-name="ID" class="<%= bed.ID.HeaderCellClass() %>"><div id="elh_bed_ID" class="bed_ID"><div class="ewTableHeaderCaption"><%= bed.ID.FldCaption %></div></div></th>
	<% Else %>
		<th data-name="ID" class="<%= bed.ID.HeaderCellClass() %>"><div class="ewPointer" onclick="ew_Sort(event,'<%= bed.SortUrl(bed.ID) %>',1);"><div id="elh_bed_ID" class="bed_ID">
			<div class="ewTableHeaderBtn"><span class="ewTableHeaderCaption"><%= bed.ID.FldCaption %></span><span class="ewTableHeaderSort"><% If bed.ID.Sort = "ASC" Then %><span class="caret ewSortUp"></span><% ElseIf bed.ID.Sort = "DESC" Then %><span class="caret"></span><% End If %></span></div>
		</div></div></th>
	<% End If %>
<% End If %>
<% If bed.Page_Name.Visible Then ' Page_Name %>
	<% If bed.SortUrl(bed.Page_Name) = "" Then %>
		<th data-name="Page_Name" class="<%= bed.Page_Name.HeaderCellClass() %>"><div id="elh_bed_Page_Name" class="bed_Page_Name"><div class="ewTableHeaderCaption"><%= bed.Page_Name.FldCaption %></div></div></th>
	<% Else %>
		<th data-name="Page_Name" class="<%= bed.Page_Name.HeaderCellClass() %>"><div class="ewPointer" onclick="ew_Sort(event,'<%= bed.SortUrl(bed.Page_Name) %>',1);"><div id="elh_bed_Page_Name" class="bed_Page_Name">
			<div class="ewTableHeaderBtn"><span class="ewTableHeaderCaption"><%= bed.Page_Name.FldCaption %><%= Language.Phrase("SrchLegend") %></span><span class="ewTableHeaderSort"><% If bed.Page_Name.Sort = "ASC" Then %><span class="caret ewSortUp"></span><% ElseIf bed.Page_Name.Sort = "DESC" Then %><span class="caret"></span><% End If %></span></div>
		</div></div></th>
	<% End If %>
<% End If %>
<%

' Render list options (header, right)
Call bed_list.ListOptions.Render("header", "right", "", "", "", "")
%>
	</tr>
</thead>
<tbody><!-- Table body -->
<%
If bed.ExportAll And bed.Export <> "" Then
	bed_list.StopRec = bed_list.TotalRecs
Else

	' Set the last record to display
	If bed_list.TotalRecs > bed_list.StartRec + bed_list.DisplayRecs - 1 Then
		bed_list.StopRec = bed_list.StartRec + bed_list.DisplayRecs - 1
	Else
		bed_list.StopRec = bed_list.TotalRecs
	End If
End If

' Move to first record
bed_list.RecCnt = bed_list.StartRec - 1
If Not bed_list.Recordset.EOF Then

	' Already positioned at first record, no need to move
	'bed_list.Recordset.MoveFirst
	'If bed_list.StartRec > 1 Then bed_list.Recordset.Move bed_list.StartRec - 1

ElseIf Not bed.AllowAddDeleteRow And bed_list.StopRec = 0 Then
	bed_list.StopRec = bed.GridAddRowCount
End If

' Initialize Aggregate
bed.RowType = EW_ROWTYPE_AGGREGATEINIT
Call bed.ResetAttrs
Call bed_list.RenderRow
bed_list.RowCnt = 0
Do While CLng(bed_list.RecCnt) < CLng(bed_list.StopRec)
	bed_list.RecCnt = bed_list.RecCnt + 1
	If CLng(bed_list.RecCnt) >= CLng(bed_list.StartRec) Then
		bed_list.RowCnt = bed_list.RowCnt + 1

	' Set up key count
	bed_list.KeyCount = bed_list.RowIndex
	Call bed.ResetAttrs
	bed.CssClass = ""
	If bed.CurrentAction = "gridadd" Then
	Else
		Call bed_list.LoadRowValues(bed_list.Recordset) ' Load row values
	End If
	bed.RowType = EW_ROWTYPE_VIEW ' Render view

	' Set up row id / data-rowindex
	Call bed.RowAttrs.AddAttributes(Array(Array("data-rowindex", bed_list.RowCnt), Array("id", "r" & bed_list.RowCnt & "_bed"), Array("data-rowtype", bed.RowType)))

	' Render row
	Call bed_list.RenderRow

	' Render list options
	Call bed_list.RenderListOptions
%>
	<tr<%= bed.RowAttributes %>>
<%

' Render list options (body, left)
Call bed_list.ListOptions.Render("body", "left", bed_list.RowCnt, "", "", "")
%>
	<% If bed.ID.Visible Then ' ID %>
		<td data-name="ID"<%= bed.ID.CellAttributes %>>
<span id="el<%= bed_list.RowCnt %>_bed_ID" class="bed_ID">
<span<%= bed.ID.ViewAttributes %>>
<%= bed.ID.ListViewValue %>
</span>
</span>
</td>
	<% End If %>
	<% If bed.Page_Name.Visible Then ' Page_Name %>
		<td data-name="Page_Name"<%= bed.Page_Name.CellAttributes %>>
<span id="el<%= bed_list.RowCnt %>_bed_Page_Name" class="bed_Page_Name">
<span<%= bed.Page_Name.ViewAttributes %>>
<%= bed.Page_Name.ListViewValue %>
</span>
</span>
</td>
	<% End If %>
<%

' Render list options (body, right)
Call bed_list.ListOptions.Render("body", "right", bed_list.RowCnt, "", "", "")
%>
	</tr>
<%
	End If
	If bed.CurrentAction <> "gridadd" Then
		bed_list.Recordset.MoveNext
	End If
Loop
%>
</tbody>
</table>
<% End If %>
<% If bed.CurrentAction = "" Then %>
<input type="hidden" name="a_list" id="a_list" value="">
<% End If %>
</div>
</form>
<%

' Close recordset and connection
bed_list.Recordset.Close
Set bed_list.Recordset = Nothing
%>
<% If bed.Export = "" Then %>
<div class="box-footer ewGridLowerPanel">
<% If bed.CurrentAction <> "gridadd" And bed.CurrentAction <> "gridedit" Then %>
<form name="ewPagerForm" class="ewForm form-inline ewPagerForm" action="<%= ew_CurrentPage %>">
<% If ew_Empty(bed_list.Pager) Then Set bed_list.Pager = ew_NewNumericPagerBase(bed_list.StartRec, bed_list.DisplayRecs, bed_list.TotalRecs, bed_list.RecRange, bed_list.AutoHidePager) %>
<% If bed_list.Pager.RecordCount > 0 And bed_list.Pager.Visible Then %>
<div class="ewPager">
<div class="ewNumericPage"><ul class="pagination">
	<% If bed_list.Pager.FirstButton.Enabled Then %>
	<li><a href="<%= bed_list.PageUrl %>start=<%= bed_list.Pager.FirstButton.Start %>"><%= Language.Phrase("PagerFirst") %></a></li>
	<% End If %>
	<% If bed_list.Pager.PrevButton.Enabled Then %>
	<li><a href="<%= bed_list.PageUrl %>start=<%= bed_list.Pager.PrevButton.Start %>"><%= Language.Phrase("PagerPrevious") %></a></li>
	<% End If %>
	<% For Each PagerItem In bed_list.Pager.Items %>
		<li<% if Not PagerItem.Enabled Then Response.Write " class=""active""" End If %>><a href="<% If PagerItem.Enabled Then Response.Write bed_list.PageUrl & "start=" & PagerItem.Start Else Response.Write "#" End If %>"><%= PagerItem.Text %></a></li>
	<% Next %>
	<% If bed_list.Pager.NextButton.Enabled Then %>
	<li><a href="<%= bed_list.PageUrl %>start=<%= bed_list.Pager.NextButton.Start %>"><%= Language.Phrase("PagerNext") %></a></li>
	<% End If %>
	<% If bed_list.Pager.LastButton.Enabled Then %>
	<li><a href="<%= bed_list.PageUrl %>start=<%= bed_list.Pager.LastButton.Start %>"><%= Language.Phrase("PagerLast") %></a></li>
	<% End If %>
</ul></div>
</div>
<% End If %>
<% If bed_list.Pager.RecordCount > 0 Then %>
<div class="ewPager ewRec">
	<span><%= Language.Phrase("Record") %>&nbsp;<%= bed_list.Pager.FromIndex %>&nbsp;<%= Language.Phrase("To") %>&nbsp;<%= bed_list.Pager.ToIndex %>&nbsp;<%= Language.Phrase("Of") %>&nbsp;<%= bed_list.Pager.RecordCount %></span>
</div>
<% End If %>
</form>
<% End If %>
<div class="ewListOtherOptions">
<%
	Call bed_list.AddEditOptions.Render("body", "bottom", "", "", "", "")
	Call bed_list.DetailOptions.Render("body", "bottom", "", "", "", "")
	Call bed_list.ActionOptions.Render("body", "bottom", "", "", "", "")
%>
</div>
<div class="clearfix"></div>
</div>
<% End If %>
</div>
<% End If %>
<% If bed_list.TotalRecs = 0 And bed.CurrentAction = "" Then ' Show other options %>
<div class="ewListOtherOptions">
<%
	Call bed_list.AddEditOptions.Render("body", "", "", "", "", "")
	Call bed_list.DetailOptions.Render("body", "", "", "", "", "")
	Call bed_list.ActionOptions.Render("body", "", "", "", "", "")
%>
</div>
<div class="clearfix"></div>
<% End If %>
<% If bed.Export <> "" Then %>
<script type="text/javascript">
ew_ApplyTemplate("body", "", "bedlist", "<%= bed.CustomExport %>");
</script>
<% End If %>
<% If bed.Export = "" Then %>
<script type="text/javascript">
fbedlistsrch.FilterList = <%= bed_list.GetFilterList() %>;
fbedlistsrch.Init();
fbedlist.Init();
</script>
<% End If %>
<%
Call bed_list.ShowPageFooter
If EW_DEBUG_ENABLED Then Response.Write ew_DebugMsg()
%>
<% If bed.Export = "" Then %>
<script type="text/javascript">
// Write your table-specific startup script here
// document.write("page loaded");
</script>
<% End If %>
<!--#include file="footer.asp"-->
<%

' Clean up and drop page object
Call bed_list.Page_Terminate("")
Set bed_list = Nothing
%>
<%

'
' Page Class
'
Class cbed_list

	' Page ID
	Public Property Get PageID
		PageID = "list"
	End Property

	' Project ID
	Public Property Get ProjectID
		ProjectID = "panel"
	End Property

	' Table Name
	Public Property Get TableName
		TableName = "bed"
	End Property

	' Page Object Name
	Public Property Get PageObjName
		PageObjName = "bed_list"
	End Property

	' Field (ID)
	Public Property Get ID
		Set ID = bed.ID
	End Property

	' Field (Page_Name)
	Public Property Get Page_Name
		Set Page_Name = bed.Page_Name
	End Property

	' Field (Title)
	Public Property Get Title
		Set Title = bed.Title
	End Property

	' Field (Description)
	Public Property Get Description
		Set Description = bed.Description
	End Property

	' Field (Enable)
	Public Property Get Enable
		Set Enable = bed.Enable
	End Property

	' Field (Sequence)
	Public Property Get Sequence
		Set Sequence = bed.Sequence
	End Property

	' Field (IP)
	Public Property Get IP
		Set IP = bed.IP
	End Property

	' Field (Date)
	Public Property Get zDate
		Set zDate = bed.zDate
	End Property

	' Field (Username)
	Public Property Get Username
		Set Username = bed.Username
	End Property

	' Get field object dictionary (ASP)
	Public Property Get Fields
		Set Fields = bed.Fields
	End Property

	' Get field object by name (alias of Fields) (ASP)
	Public Function GetField(Name)
		Set GetField = Fields.Get(Name)
	End Function

	' Get field object by parm (ASP)
	Public Function GetFieldByParm(Parm)
		Dim keys, key
		keys = Fields.Keys()
		For Each key In keys
			If Fields.Get(key).FldParm = Parm Then
				Set GetFieldByParm = Fields.Get(key)
				Exit Function
			End If
		Next
		Set GetFieldByParm = Nothing
	End Function

	' Custom actions (ASP)
	Dim CustomActions

	' Export document (ASP)
	Dim ExportDoc

	' Grid form hidden field names
	Dim FormName
	Dim FormActionName
	Dim FormKeyName
	Dim FormOldKeyName
	Dim FormBlankRowName
	Dim FormKeyCountName

	' Page headings
	Dim Heading
	Dim Subheading

	' Page heading
	Function PageHeading()
		PageHeading = ""
		If Heading <> "" Then
			PageHeading = Heading
		ElseIf ew_NotEmpty(bed) Then
			PageHeading = bed.TableCaption
		End If
	End Function

	' Page subheading
	Function PageSubheading()
		If Subheading <> "" Then
			PageSubheading = Subheading
		Else
			PageSubheading = ""
			If TableName <> "" Then
				PageSubheading = Language.Phrase(PageID)
			End If
		End If
	End Function

	' Page Name
	Public Property Get PageName
		PageName = ew_CurrentPage()
	End Property

	' Page Url
	Public Property Get PageUrl
		PageUrl = ew_CurrentPage() & "?"
		If bed.UseTokenInUrl Then PageUrl = PageUrl & "t=" & bed.TableVar & "&" ' add page token
	End Property

	' Common URLs
	Dim AddUrl
	Dim EditUrl
	Dim CopyUrl
	Dim DeleteUrl
	Dim ViewUrl
	Dim ListUrl

	' Export URLs
	Dim ExportPrintUrl
	Dim ExportHtmlUrl
	Dim ExportExcelUrl
	Dim ExportWordUrl
	Dim ExportXmlUrl
	Dim ExportCsvUrl
	Dim ExportPdfUrl

	' Custom export
	Dim ExportExcelCustom
	Dim ExportWordCustom
	Dim ExportPdfCustom
	Dim ExportEmailCustom

	' Inline URLs
	Dim InlineAddUrl
	Dim InlineCopyUrl
	Dim InlineEditUrl
	Dim GridAddUrl
	Dim GridEditUrl
	Dim MultiDeleteUrl
	Dim MultiUpdateUrl

	' Message
	Public Property Get Message
		Message = Session(EW_SESSION_MESSAGE)
	End Property

	Public Property Let Message(v)
		Dim msg
		msg = Session(EW_SESSION_MESSAGE)
		Call ew_AddMessage(msg, v)
		Session(EW_SESSION_MESSAGE) = msg
	End Property

	Public Property Get FailureMessage
		FailureMessage = Session(EW_SESSION_FAILURE_MESSAGE)
	End Property

	Public Property Let FailureMessage(v)
		Dim msg
		msg = Session(EW_SESSION_FAILURE_MESSAGE)
		Call ew_AddMessage(msg, v)
		Session(EW_SESSION_FAILURE_MESSAGE) = msg
	End Property

	Public Property Get SuccessMessage
		SuccessMessage = Session(EW_SESSION_SUCCESS_MESSAGE)
	End Property

	Public Property Let SuccessMessage(v)
		Dim msg
		msg = Session(EW_SESSION_SUCCESS_MESSAGE)
		Call ew_AddMessage(msg, v)
		Session(EW_SESSION_SUCCESS_MESSAGE) = msg
	End Property

	Public Property Get WarningMessage
		WarningMessage = Session(EW_SESSION_WARNING_MESSAGE)
	End Property

	Public Property Let WarningMessage(v)
		Dim msg
		msg = Session(EW_SESSION_WARNING_MESSAGE)
		Call ew_AddMessage(msg, v)
		Session(EW_SESSION_WARNING_MESSAGE) = msg
	End Property

	' Methods to clear message
	Public Sub ClearMessage()
		Session(EW_SESSION_MESSAGE) = ""
	End Sub

	Public Sub ClearFailureMessage()
		Session(EW_SESSION_FAILURE_MESSAGE) = ""
	End Sub

	Public Sub ClearSuccessMessage()
		Session(EW_SESSION_SUCCESS_MESSAGE) = ""
	End Sub

	Public Sub ClearWarningMessage()
		Session(EW_SESSION_WARNING_MESSAGE) = ""
	End Sub

	Public Sub ClearMessages()
		Session(EW_SESSION_MESSAGE) = ""
		Session(EW_SESSION_FAILURE_MESSAGE) = ""
		Session(EW_SESSION_SUCCESS_MESSAGE) = ""
		Session(EW_SESSION_WARNING_MESSAGE) = ""
	End Sub

	' Show Message
	Public Sub ShowMessage()
		Dim hidden, html, sMessage
		hidden = False
		html = ""

		' Message
		sMessage = Message
		Call Message_Showing(sMessage, "")
		If sMessage <> "" Then ' Message in Session, display
			If Not hidden Then sMessage = "<button type=""button"" class=""close"" data-dismiss=""alert"">&times;</button>" & sMessage
			html = html & "<div class=""alert alert-info ewInfo"">" & sMessage & "</div>"
			Session(EW_SESSION_MESSAGE) = "" ' Clear message in Session
		End If

		' Warning message
		Dim sWarningMessage
		sWarningMessage = WarningMessage
		Call Message_Showing(sWarningMessage, "warning")
		If sWarningMessage <> "" Then ' Message in Session, display
			If Not hidden Then sWarningMessage = "<button type=""button"" class=""close"" data-dismiss=""alert"">&times;</button>" & sWarningMessage
			html = html & "<div class=""alert alert-warning ewWarning"">" & sWarningMessage & "</div>"
			Session(EW_SESSION_WARNING_MESSAGE) = "" ' Clear message in Session
		End If

		' Success message
		Dim sSuccessMessage
		sSuccessMessage = SuccessMessage
		Call Message_Showing(sSuccessMessage, "success")
		If sSuccessMessage <> "" Then ' Message in Session, display
			If Not hidden Then sSuccessMessage = "<button type=""button"" class=""close"" data-dismiss=""alert"">&times;</button>" & sSuccessMessage
			html = html & "<div class=""alert alert-success ewSuccess"">" & sSuccessMessage & "</div>"
			Session(EW_SESSION_SUCCESS_MESSAGE) = "" ' Clear message in Session
		End If

		' Failure message
		Dim sErrorMessage
		sErrorMessage = FailureMessage
		Call Message_Showing(sErrorMessage, "failure")
		If sErrorMessage <> "" Then ' Message in Session, display
			If Not hidden Then sErrorMessage = "<button type=""button"" class=""close"" data-dismiss=""alert"">&times;</button>" & sErrorMessage
			html = html & "<div class=""alert alert-danger ewError"">" & sErrorMessage & "</div>"
			Session(EW_SESSION_FAILURE_MESSAGE) = "" ' Clear message in Session
		End If
		Response.Write "<div class=""ewMessageDialog""" & ew_IIf(hidden, " style=""display: none;""", "") & ">" & html & "</div>"
	End Sub
	Dim PageHeader
	Dim PageFooter

	' Show Page Header
	Public Sub ShowPageHeader()
		Dim sHeader
		sHeader = PageHeader
		Call Page_DataRendering(sHeader)
		If sHeader <> "" Then ' Header exists, display
			Response.Write "<p>" & sHeader & "</p>"
		End If
	End Sub

	' Show Page Footer
	Public Sub ShowPageFooter()
		Dim sFooter
		sFooter = PageFooter
		Call Page_DataRendered(sFooter)
		If sFooter <> "" Then ' Footer exists, display
			Response.Write "<p>" & sFooter & "</p>"
		End If
	End Sub

	'
	' Validate Page request
	'
	Public Function IsPageRequest()
		If bed.UseTokenInUrl Then
			IsPageRequest = False
			If ew_NotEmpty(ObjForm) Then
				IsPageRequest = (bed.TableVar = ObjForm.GetValue("t"))
			End If
			If Request.QueryString("t").Count > 0 Then
				IsPageRequest = (bed.TableVar = Request.QueryString("t"))
			End If
		Else
			IsPageRequest = True
		End If
	End Function
	Dim Token
	Dim CheckToken
	Dim TokenTimeout

	' Valid Post
	Function ValidPost()
		If Not CheckToken Or Not ew_IsPost() Then
			ValidPost = True
			Exit Function
		End If
		If Request.Form(EW_TOKEN_NAME).Count = 0 Then
			ValidPost = False
			Exit Function
		End If
		ValidPost = ew_CheckToken(Request.Form(EW_TOKEN_NAME),TokenTimeout)
	End Function

	' Create Token
	Sub CreateToken()
		If CheckToken And Token = "" Then
			Token = ew_CreateToken()
			gsToken = Token ' Save to global variable
		End If
	End Sub

	'
	' Class initialize
	'
	Private Sub Class_Initialize()
		Session.LCID = 1033 ' Always use US locale id
		If IsEmpty(StartTimer) Then StartTimer = Timer ' Init start time

		' Grid form hidden field names
		FormName = "fbedlist"
		FormActionName = "k_action"
		FormKeyName = "k_key"
		FormOldKeyName = "k_oldkey"
		FormBlankRowName = "k_blankrow"
		FormKeyCountName = "key_count"

		' Check Token
		Token = ""
		CheckToken = EW_CHECK_TOKEN
		TokenTimeout = 0
		TokenTimeout = ew_SessionTimeoutTime()

		' Initialize language object
		If IsEmpty(Language) Then
			Set Language = New cLanguage
			Call Language.LoadPhrases
		End If

		' Initialize table object
		If IsEmpty(bed) Then Set bed = New cbed
		Set Table = bed
		ExportExcelCustom = False
		ExportWordCustom = False
		ExportPdfCustom = True ' Always use ew_ApplyTemplate
		ExportEmailCustom = True ' Always use ew_ApplyTemplate

		' Initialize URLs
		ExportPrintUrl = PageUrl & "export=print"
		ExportExcelUrl = PageUrl & "export=excel"
		ExportWordUrl = PageUrl & "export=word"
		ExportHtmlUrl = PageUrl & "export=html"
		ExportXmlUrl = PageUrl & "export=xml"
		ExportCsvUrl = PageUrl & "export=csv"
		ExportPdfUrl = PageUrl & "export=pdf"
		AddUrl = "bedadd.asp"
		InlineAddUrl = PageUrl & "a=add"
		GridAddUrl = PageUrl & "a=gridadd"
		GridEditUrl = PageUrl & "a=gridedit"
		MultiDeleteUrl = "beddelete.asp"
		MultiUpdateUrl = "bedupdate.asp"

		' Initialize form object
		Set ObjForm = Nothing

		' Get resize object
		Call ew_GetResizeObj

		' Intialize page id (for backward compatibility)
		EW_PAGE_ID = "list"

		' Initialize table name (for backward compatibility)
		EW_TABLE_NAME = "bed"

		' Debug message
		Call ew_LoadDebugMsg

		' Open connection to the database
		If IsEmpty(Conn) Then
			Set Conn = ew_Connect(bed.TableDBID)
		End If

		' List options
		Set ListOptions = New cListOptions
		ListOptions.TableVar = bed.TableVar

		' Custom actions
		Set CustomActions = Dictionary()

		' Export options
		Set ExportOptions = New cListOptions
		ExportOptions.TableVar = bed.TableVar
		ExportOptions.Tag = "div"
		ExportOptions.TagClassName = "ewExportOption"

		' Other options
		Set AddEditOptions = New cListOptions
		AddEditOptions.Tag = "div"
		AddEditOptions.TagClassName = "ewAddEditOption"
		Set DetailOptions = New cListOptions
		DetailOptions.Tag = "div"
		DetailOptions.TagClassName = "ewDetailOption"
		Set ActionOptions = New cListOptions
		ActionOptions.Tag = "div"
		ActionOptions.TagClassName = "ewActionOption"

		' Filter options
		Set FilterOptions = New cListOptions
		FilterOptions.Tag = "div"
		FilterOptions.TagClassName = "ewFilterOption fbedlistsrch"

		' List actions
		Set ListActions = New cListActions
	End Sub

	'
	' Page_Init
	'
	Sub Page_Init()

		' User profile
		Set UserProfile = New cUserProfile

		' Security
		Set Security = New cAdvancedSecurity
		If Not Security.IsLoggedIn() Then Security.AutoLogin()
		Call Security.LoadCurrentUserLevel(ProjectID & TableName)
		If Not Security.CanList Then
			Call Security.SaveLastUrl
			Call Page_Terminate(ew_GetUrl("default.asp"))
		End If

		' Get grid add count
		Dim gridaddcnt
		gridaddcnt = Request.QueryString(EW_TABLE_GRID_ADD_ROW_COUNT)
		If IsNumeric(gridaddcnt) Then
			If gridaddcnt > 0 Then
				bed.GridAddRowCount = gridaddcnt
			End If
		End If

		' Set up list options
		Call SetupListOptions
		Call bed.ID.SetVisibility(bed)
		If bed.IsAdd() Or bed.IsCopy() Or bed.IsGridAdd() Then
			bed.ID.Visible = False
		End If
		Call bed.Page_Name.SetVisibility(bed)

		' Global page loading event (in userfn*.asp)
		Call Page_Loading

		' Page load event, used in current page
		Call Page_Load

		' Check token
		If Not ValidPost() Then
			Response.Write Language.Phrase("InvalidPostRequest")
			Call Page_Terminate("")
			Response.End
		End If

		' Process auto fill
		Dim results
		If Request.Form("ajax") = "autofill" Then
			results = bed.GetAutoFill(Request.Form("name"), Request.Form("q"))
			If results <> "" Then

				' Clean output buffer
				If Response.Buffer Then Response.Clear
				Response.Write results
				Call Page_Terminate("")
				Response.End
			End If
		End If

		' Create Token
		Call CreateToken

		' Setup other options
		Call SetupOtherOptions

		' Set up custom action (backward compatibility)
		Dim sKey, sAction
		For Each sKey In CustomActions.Keys()
			sAction = CustomActions.Get(sKey)
			Call ListActions.Add(sKey, sAction, True, EW_ACTION_POSTBACK, EW_ACTION_MULTIPLE, "", "glyphicon glyphicon-star ewIcon")
		Next

		' Show checkbox column if multiple action
		Dim listact
		For i = 0 to ListActions.Count - 1
			Set listact = ListActions(i)
			If listact.SelectType = EW_ACTION_MULTIPLE And listact.Allow Then
				ListOptions("checkbox").Visible = True
				Exit For
			End If
		Next
	End Sub

	'
	' Page_Terminate
	'
	Sub Page_Terminate(url)
		If Request.Form("customexport")&"" = "" Then

			' Page unload event, used in current page
			Call Page_Unload

			' Global page unloaded event (in userfn*.asp)
			Call Page_Unloaded
		End If

		' Export
		If ew_NotEmpty(bed) Then
			If bed.Export <> "" And Request.Form("data").Count > 0 Then
				Dim sContent
				sContent = Request.Form("data")
				gsExportFile = Request.Form("filename")
				If gsExportFile = "" Then gsExportFile = bed.TableVar
				If bed.Export = "pdf" Then
					Call ExportPdf(sContent)
				ElseIf bed.Export = "email" Then
					Response.Write ExportEmail(sContent)
				ElseIf bed.Export = "excel" Then
					Call ExportExcel(sContent)
				ElseIf bed.Export = "word" Then
					Call ExportWord(sContent)
				End If
			End If
		End If
		Dim sRedirectUrl
		sRedirectUrl = url
		Call Page_Redirecting(sRedirectUrl)
		Call ew_CloseConn ' Close Connection
		Set Security = Nothing
		Set ListOptions = Nothing
		Set CustomActions = Nothing ' ASP
		Set ObjForm = Nothing
		Set gResizeObj = Nothing

		' Go to URL if specified
		If gsExport & "" = "" Then
			If sRedirectUrl <> "" Then
				If Response.Buffer Then Response.Clear
				Call ew_SaveDebugMsg
				Response.Redirect sRedirectUrl
			End If
		End If
		Set bed = Nothing
		Call ew_CleanUp
	End Sub

	'
	' Page_Terminate (End)
	'

	Dim ListOptions ' List options
	Dim ExportOptions ' Export options
	Dim SearchOptions ' Search options
	Dim AddEditOptions ' Other options (add edit)
	Dim DetailOptions ' Other options (detail)
	Dim ActionOptions ' Other options (action)
	Dim FilterOptions ' Filter options
	Dim ListActions ' List actions
	Dim SelectedCount
	Dim SelectedIndex
	Dim DisplayRecs ' Number of display records
	Dim StartRec, StopRec, TotalRecs, RecRange
	Dim AutoHidePager, AutoHidePageSizeSelector
	Dim DefaultSearchWhere ' Default search WHERE clause
	Dim SearchWhere
	Dim RecCnt
	Dim EditRowCnt
	Dim StartRowCnt
	Dim RowCnt, RowIndex
	Dim Attrs
	Dim RecPerRow
	Dim MultiColumnClass
	Dim MultiColumnEditClass
	Dim MultiColumnCnt
	Dim MultiColumnEditCnt
	Dim GridCnt
	Dim ColCnt
	Dim KeyCount
	Dim RowAction
	Dim RowOldKey ' Row old key (for copy)
	Dim DbMasterFilter, DbDetailFilter
	Dim MasterRecordExists
	Dim MultiSelectKey
	Dim Command
	Dim RestoreSearch
	Dim Recordset, OldRecordset, DetailPages

	'
	' Page main
	'
	Sub Page_Main()
		SelectedCount = 0
		SelectedIndex = 0
		DisplayRecs = 20
		RecRange = 10
		AutoHidePager = EW_AUTO_HIDE_PAGER
		AutoHidePageSizeSelector = EW_AUTO_HIDE_PAGE_SIZE_SELECTOR
		RecCnt = 0 ' Record count
		KeyCount = 0 ' Key count
		StartRowCnt = 1

		' Search filters
		Dim sSrchAdvanced, sSrchBasic, sFilter
		sSrchAdvanced = "" ' Advanced search filter
		sSrchBasic = "" ' Basic search filter
		SearchWhere = "" ' Search where clause
		DefaultSearchWhere = ""
		sFilter = ""

		' Restore search
		RestoreSearch = False

		' Get command
		Command = LCase(Request.QueryString("cmd")&"")

		' Master/Detail
		DbMasterFilter = "" ' Master filter
		DbDetailFilter = "" ' Detail filter
		If IsPageRequest Then ' Validate request

			' Process list action first
			If ProcessListAction() Then ' Ajax request
				Call Page_Terminate("")
				Response.End
			End If

			' Handle reset command
			Call ResetCmd

			' Set up Breadcrumb
			If bed.Export = "" Then
				Call SetupBreadcrumb
			End If

			' Hide list options
			If bed.Export <> "" Then
				Call ListOptions.HideAllOptions(Array("sequence"))
				ListOptions.UseDropDownButton = False ' Disable drop down button
				ListOptions.UseButtonGroup = False ' Disable button group
			ElseIf bed.CurrentAction = "gridadd" Or bed.CurrentAction = "gridedit" Then
				Call ListOptions.HideAllOptions(Array())
				ListOptions.UseDropDownButton = False ' Disable drop down button
				ListOptions.UseButtonGroup = False ' Disable button group
			End If

			' Hide options
			If bed.Export <> "" Or bed.CurrentAction <> "" Then
				Call ExportOptions.HideAllOptions(Array())
				Call FilterOptions.HideAllOptions(Array())
			End If

			' Hide other options
			If bed.Export <> "" Then
				Call AddEditOptions.HideAllOptions(Array())
				Call DetailOptions.HideAllOptions(Array())
				Call ActionOptions.HideAllOptions(Array())
			End If

			' Get default search criteria
			Call ew_AddFilter(DefaultSearchWhere, BasicSearchWhere(True))

			' Get basic search values
			Call LoadBasicSearchValues

			' Restore filter list
			Call ProcessFilterList

			' Restore search parms from Session if not searching / reset / export
			If (bed.Export <> "" Or Command <> "search" And Command <> "reset" And Command <> "resetall") And Command <> "json" And CheckSearchParms() Then
				Call RestoreSearchParms
			End If

			' Call Recordset SearchValidated event
			Call bed.Recordset_SearchValidated()

			' Set Up Sorting Order
			Call SetupSortOrder

			' Get basic search criteria
			If gsSearchError = "" Then
				sSrchBasic = BasicSearchWhere(False)
			End If
		End If ' End Validate Request

		' Restore display records
		If Command <> "json" And bed.RecordsPerPage <> "" Then
			DisplayRecs = bed.RecordsPerPage ' Restore from Session
		Else
			DisplayRecs = 20 ' Load default
		End If

		' Load Sorting Order
		If Command <> "json" Then Call LoadSortOrder

		' Load search default if no existing search criteria
		If Not CheckSearchParms() Then

			' Load basic search from default
			bed.BasicSearch.Keyword = bed.BasicSearch.KeywordDefault
			bed.BasicSearch.SearchType = bed.BasicSearch.SearchTypeDefault
			Call bed.BasicSearch.setSearchType(bed.BasicSearch.SearchTypeDefault)
			If bed.BasicSearch.Keyword <> "" Then
				sSrchBasic = BasicSearchWhere(False)
			End If
		End If

		' Build search criteria
		Call ew_AddFilter(SearchWhere, sSrchAdvanced)
		Call ew_AddFilter(SearchWhere, sSrchBasic)

		' Call Recordset Searching event
		Call bed.Recordset_Searching(SearchWhere)

		' Save search criteria
		If Command = "search" And Not RestoreSearch Then
			bed.SearchWhere = SearchWhere ' Save to Session
			StartRec = 1 ' Reset start record counter
			bed.StartRecordNumber = StartRec
		ElseIf Command <> "json" Then
			SearchWhere = bed.SearchWhere
		End If
		sFilter = ""
		Call ew_AddFilter(sFilter, DbDetailFilter)
		Call ew_AddFilter(sFilter, SearchWhere)

		' Set up filter
		If Command = "json" Then
			bed.UseSessionForListSQL = False ' Do not use session for ListSQL
			bed.CurrentFilter = sFilter
		Else
			bed.SessionWhere = sFilter
			bed.CurrentFilter = ""
		End If

		' Load record count first ' ASP
		TotalRecs = bed.ListRecordCount()

		' Search options
		Call SetupSearchOptions
	End Sub

	'
	' Build filter for all keys
	'
	Function BuildKeyFilter()
		Dim rowindex, sThisKey
		Dim sKey
		Dim sWrkFilter, sFilter
		sWrkFilter = ""

		' Update row index and get row key
		rowindex = 1
		ObjForm.Index = rowindex
		sThisKey = ObjForm.GetValue("k_key") & ""
		Do While sThisKey <> ""
			If SetupKeyValues(sThisKey) Then
				sFilter = bed.KeyFilter
				If sWrkFilter <> "" Then sWrkFilter = sWrkFilter & " OR "
				sWrkFilter = sWrkFilter & sFilter
			Else
				sWrkFilter = "0=1"
				Exit Do
			End If

			' Update row index and get row key
			rowindex = rowindex + 1 ' Next row
			ObjForm.Index = rowindex
			sThisKey = ObjForm.GetValue("k_key") & ""
		Loop
		BuildKeyFilter = sWrkFilter
	End Function

	'
	' Set up key values
	'
	Function SetupKeyValues(key)
		Dim arrKeyFlds
		arrKeyFlds = Split(key&"", EW_COMPOSITE_KEY_SEPARATOR)
		If UBound(arrKeyFlds) >= 0 Then
			bed.ID.FormValue = arrKeyFlds(0)
			If Not IsNumeric(bed.ID.FormValue) Then
				SetupKeyValues = False
				Exit Function
			End If
		End If
		SetupKeyValues = True
	End Function

	' Get list of filters
	Function GetFilterList()

		' Initialize
		Dim sFilterList, sWrk, sSavedFilterList

		' Initialize
		sFilterList = ""
		sSavedFilterList = ""
		sFilterList = ew_Concat(sFilterList, bed.ID.AdvancedSearch.ToJson(), ",") ' Field ID
		sFilterList = ew_Concat(sFilterList, bed.Page_Name.AdvancedSearch.ToJson(), ",") ' Field Page_Name
		sFilterList = ew_Concat(sFilterList, bed.Title.AdvancedSearch.ToJson(), ",") ' Field Title
		sFilterList = ew_Concat(sFilterList, bed.Description.AdvancedSearch.ToJson(), ",") ' Field Description
		sFilterList = ew_Concat(sFilterList, bed.Enable.AdvancedSearch.ToJson(), ",") ' Field Enable
		sFilterList = ew_Concat(sFilterList, bed.Sequence.AdvancedSearch.ToJson(), ",") ' Field Sequence
		sFilterList = ew_Concat(sFilterList, bed.IP.AdvancedSearch.ToJson(), ",") ' Field IP
		sFilterList = ew_Concat(sFilterList, bed.zDate.AdvancedSearch.ToJson(), ",") ' Field Date
		sFilterList = ew_Concat(sFilterList, bed.Username.AdvancedSearch.ToJson(), ",") ' Field Username
		If bed.BasicSearch.Keyword <> "" Then
			sWrk = """" & EW_TABLE_BASIC_SEARCH & """:""" & ew_JsEncode2(bed.BasicSearch.Keyword) & """,""" & EW_TABLE_BASIC_SEARCH_TYPE & """:""" & ew_JsEncode2(bed.BasicSearch.SearchType) & """"
			sFilterList = ew_Concat(sFilterList, sWrk, ",")
		End If
		sFilterList = ew_RegExReplace(",$", sFilterList, "")

		' Return filter list in json
		If sFilterList <> "" Then
			sFilterList = """data"":{" & sFilterList & "}"
		End If
		If sSavedFilterList <> "" Then
			If sFilterList <> "" Then
				sFilterList = sFilterList & ","
			End If
			sFilterList = sFilterList & """filters"":" & sSavedFilterList
		End If
		GetFilterList = ew_IIf(sFilterList <> "", "{" & sFilterList & "}" , "null")
	End Function

	' Process filter list
	Sub ProcessFilterList()
		Dim filters, result
		If Request.Form("ajax") = "savefilters" Then
			filters = Request.Form("filters")
			Call UserProfile.SetSearchFilters(CurrentUserName(), "fbedlistsrch", filters)

			' Clean output buffer
			If Response.Buffer Then Response.Clear
			Set result = Dictionary()
			Call result.Add("success", True)
			Call ResponseJson
			Response.Write "[" & result.ToJson() & "]"
			Set result = Nothing
			Call Page_Terminate("")
			Response.End
		ElseIf Request.Form("cmd") = "resetfilter" Then
			RestoreFilterList()
		End If
	End Sub

	' Restore list of filters
	Function RestoreFilterList()
		Dim filter

		' Return if not reset filter
		If Request.Form("cmd") & "" <> "resetfilter" Then
			RestoreFilterList = False
			Exit Function
		End If
		If Request.form("filter").Count > 0 Then
			Set filter = ew_JsonDecode(Request.Form("filter"))
			Command = "search"

			' Field ID
			If filter.Exists("x_ID") Then
				bed.ID.AdvancedSearch.SearchValue = filter("x_ID")
			End If
			If filter.Exists("z_ID") Then
				bed.ID.AdvancedSearch.SearchOperator = filter("z_ID")
			End If
			If filter.Exists("v_ID") Then
				bed.ID.AdvancedSearch.SearchCondition = filter("v_ID")
			End If
			If filter.Exists("y_ID") Then
				bed.ID.AdvancedSearch.SearchValue2 = filter("y_ID")
			End If
			If filter.Exists("w_ID") Then
				bed.ID.AdvancedSearch.SearchOperator2 = filter("w_ID")
			End If
			Call bed.ID.AdvancedSearch.Save

			' Field Page_Name
			If filter.Exists("x_Page_Name") Then
				bed.Page_Name.AdvancedSearch.SearchValue = filter("x_Page_Name")
			End If
			If filter.Exists("z_Page_Name") Then
				bed.Page_Name.AdvancedSearch.SearchOperator = filter("z_Page_Name")
			End If
			If filter.Exists("v_Page_Name") Then
				bed.Page_Name.AdvancedSearch.SearchCondition = filter("v_Page_Name")
			End If
			If filter.Exists("y_Page_Name") Then
				bed.Page_Name.AdvancedSearch.SearchValue2 = filter("y_Page_Name")
			End If
			If filter.Exists("w_Page_Name") Then
				bed.Page_Name.AdvancedSearch.SearchOperator2 = filter("w_Page_Name")
			End If
			Call bed.Page_Name.AdvancedSearch.Save

			' Field Title
			If filter.Exists("x_Title") Then
				bed.Title.AdvancedSearch.SearchValue = filter("x_Title")
			End If
			If filter.Exists("z_Title") Then
				bed.Title.AdvancedSearch.SearchOperator = filter("z_Title")
			End If
			If filter.Exists("v_Title") Then
				bed.Title.AdvancedSearch.SearchCondition = filter("v_Title")
			End If
			If filter.Exists("y_Title") Then
				bed.Title.AdvancedSearch.SearchValue2 = filter("y_Title")
			End If
			If filter.Exists("w_Title") Then
				bed.Title.AdvancedSearch.SearchOperator2 = filter("w_Title")
			End If
			Call bed.Title.AdvancedSearch.Save

			' Field Description
			If filter.Exists("x_Description") Then
				bed.Description.AdvancedSearch.SearchValue = filter("x_Description")
			End If
			If filter.Exists("z_Description") Then
				bed.Description.AdvancedSearch.SearchOperator = filter("z_Description")
			End If
			If filter.Exists("v_Description") Then
				bed.Description.AdvancedSearch.SearchCondition = filter("v_Description")
			End If
			If filter.Exists("y_Description") Then
				bed.Description.AdvancedSearch.SearchValue2 = filter("y_Description")
			End If
			If filter.Exists("w_Description") Then
				bed.Description.AdvancedSearch.SearchOperator2 = filter("w_Description")
			End If
			Call bed.Description.AdvancedSearch.Save

			' Field Enable
			If filter.Exists("x_Enable") Then
				bed.Enable.AdvancedSearch.SearchValue = filter("x_Enable")
			End If
			If filter.Exists("z_Enable") Then
				bed.Enable.AdvancedSearch.SearchOperator = filter("z_Enable")
			End If
			If filter.Exists("v_Enable") Then
				bed.Enable.AdvancedSearch.SearchCondition = filter("v_Enable")
			End If
			If filter.Exists("y_Enable") Then
				bed.Enable.AdvancedSearch.SearchValue2 = filter("y_Enable")
			End If
			If filter.Exists("w_Enable") Then
				bed.Enable.AdvancedSearch.SearchOperator2 = filter("w_Enable")
			End If
			Call bed.Enable.AdvancedSearch.Save

			' Field Sequence
			If filter.Exists("x_Sequence") Then
				bed.Sequence.AdvancedSearch.SearchValue = filter("x_Sequence")
			End If
			If filter.Exists("z_Sequence") Then
				bed.Sequence.AdvancedSearch.SearchOperator = filter("z_Sequence")
			End If
			If filter.Exists("v_Sequence") Then
				bed.Sequence.AdvancedSearch.SearchCondition = filter("v_Sequence")
			End If
			If filter.Exists("y_Sequence") Then
				bed.Sequence.AdvancedSearch.SearchValue2 = filter("y_Sequence")
			End If
			If filter.Exists("w_Sequence") Then
				bed.Sequence.AdvancedSearch.SearchOperator2 = filter("w_Sequence")
			End If
			Call bed.Sequence.AdvancedSearch.Save

			' Field IP
			If filter.Exists("x_IP") Then
				bed.IP.AdvancedSearch.SearchValue = filter("x_IP")
			End If
			If filter.Exists("z_IP") Then
				bed.IP.AdvancedSearch.SearchOperator = filter("z_IP")
			End If
			If filter.Exists("v_IP") Then
				bed.IP.AdvancedSearch.SearchCondition = filter("v_IP")
			End If
			If filter.Exists("y_IP") Then
				bed.IP.AdvancedSearch.SearchValue2 = filter("y_IP")
			End If
			If filter.Exists("w_IP") Then
				bed.IP.AdvancedSearch.SearchOperator2 = filter("w_IP")
			End If
			Call bed.IP.AdvancedSearch.Save

			' Field Date
			If filter.Exists("x_zDate") Then
				bed.zDate.AdvancedSearch.SearchValue = filter("x_zDate")
			End If
			If filter.Exists("z_zDate") Then
				bed.zDate.AdvancedSearch.SearchOperator = filter("z_zDate")
			End If
			If filter.Exists("v_zDate") Then
				bed.zDate.AdvancedSearch.SearchCondition = filter("v_zDate")
			End If
			If filter.Exists("y_zDate") Then
				bed.zDate.AdvancedSearch.SearchValue2 = filter("y_zDate")
			End If
			If filter.Exists("w_zDate") Then
				bed.zDate.AdvancedSearch.SearchOperator2 = filter("w_zDate")
			End If
			Call bed.zDate.AdvancedSearch.Save

			' Field Username
			If filter.Exists("x_Username") Then
				bed.Username.AdvancedSearch.SearchValue = filter("x_Username")
			End If
			If filter.Exists("z_Username") Then
				bed.Username.AdvancedSearch.SearchOperator = filter("z_Username")
			End If
			If filter.Exists("v_Username") Then
				bed.Username.AdvancedSearch.SearchCondition = filter("v_Username")
			End If
			If filter.Exists("y_Username") Then
				bed.Username.AdvancedSearch.SearchValue2 = filter("y_Username")
			End If
			If filter.Exists("w_Username") Then
				bed.Username.AdvancedSearch.SearchOperator2 = filter("w_Username")
			End If
			Call bed.Username.AdvancedSearch.Save
			If filter.Exists(EW_TABLE_BASIC_SEARCH) Then
				Call bed.BasicSearch.setKeyword(filter(EW_TABLE_BASIC_SEARCH))
			End If
			If filter.Exists(EW_TABLE_BASIC_SEARCH_TYPE) Then
				Call bed.BasicSearch.setSearchType(filter(EW_TABLE_BASIC_SEARCH_TYPE))
			End If
			Set filter = Nothing
		End If
	End Function

	'
	' Return basic search SQL
	'
	Function BasicSearchSQL(arKeywords, typ)
		Dim sWhere
		sWhere = ""
			Call BuildBasicSearchSQL(sWhere, bed.Page_Name, arKeywords, typ)
			Call BuildBasicSearchSQL(sWhere, bed.Title, arKeywords, typ)
			Call BuildBasicSearchSQL(sWhere, bed.Description, arKeywords, typ)
			Call BuildBasicSearchSQL(sWhere, bed.Enable, arKeywords, typ)
			Call BuildBasicSearchSQL(sWhere, bed.IP, arKeywords, typ)
			Call BuildBasicSearchSQL(sWhere, bed.Username, arKeywords, typ)
		BasicSearchSQL = sWhere
	End Function

	'
	' Build basic search SQL
	'
	Sub BuildBasicSearchSQL(Where, Fld, arKeywords, typ)
		Dim sDefcond, arSQL, arCond, cnt, i, j, ar
		Dim Keyword, sWrk, sFldExpression, bQuoted, sSql
		sDefCond = ew_IIf(typ = "OR", "OR", "AND")
		arSQL = Array() ' Array for SQL parts
		arCond = Array() ' Array for search conditions
		cnt = UBound(arKeywords)+1
		j = 0 ' Number of SQL parts
		For i = 0 to cnt-1
			Keyword = arKeywords(i)
			Keyword = Trim(Keyword)
			If EW_BASIC_SEARCH_IGNORE_PATTERN <> "" Then
				Keyword = ew_RegExReplace(EW_BASIC_SEARCH_IGNORE_PATTERN, Keyword, "\")
				ar = Split(Keyword, "\")
			Else
				ar = Array(Keyword)
			End If
			For Each Keyword In ar
				If Keyword <> "" Then
					sWrk = ""
					If Keyword = "OR" And typ = "" Then
						If j > 0 Then
							arCond(j-1) = "OR"
						End If
					ElseIf Keyword = EW_NULL_VALUE Then
						sWrk = Fld.FldExpression & " IS NULL"
					ElseIf Keyword = EW_NOT_NULL_VALUE Then
						sWrk = Fld.FldExpression & " IS NOT NULL"
					ElseIf Fld.FldIsVirtual Then
						sWrk = Fld.FldVirtualExpression & ew_Like(ew_QuotedValueBase("%" & Keyword & "%", EW_DATATYPE_STRING, bed.TableDBID), bed.TableDBID)
					ElseIf Fld.FldDataType <> EW_DATATYPE_NUMBER Or IsNumeric(Keyword) Then
						sWrk = Fld.FldBasicSearchExpression & ew_Like(ew_QuotedValueBase("%" & Keyword & "%", EW_DATATYPE_STRING, bed.TableDBID), bed.TableDBID)
					End If
					If sWrk <> "" Then
						If j > 0 Then
							ReDim Preserve arSQL(j)
							ReDim Preserve arCond(j)
						Else
							ReDim arSQL(0)
							ReDim arCond(0)
						End If
						arSQL(j) = sWrk
						arCond(j) = sDefCond
						j = j + 1
					End If
				End If
			Next
		Next
		cnt = UBound(arSQL)+1
		bQuoted = False
		sSql = ""
		If cnt > 0 Then
			For i = 0 to cnt-2
				If arCond(i) = "OR" Then
					If Not bQuoted Then sSql = sSql & "("
					bQuoted = True
				End If
				sSql = sSql & arSQL(i)
				If bQuoted And arCond(i) <> "OR" Then
					sSql = sSql & ")"
					bQuoted = False
				End If
				sSql = sSql & " " & arCond(i) & " "
			Next
			sSql = sSql & arSQL(cnt-1)
			If bQuoted Then
				sSql = sSql & ")"
			End If
		End If
		If sSql <> "" Then
			If Where <> "" Then Where = Where & " OR "
			Where = Where & "(" & sSql & ")"
		End If
	End Sub

	'
	' Return Basic Search Where based on search keyword and type
	'
	Function BasicSearchWhere(bDefault)
		Dim sSearchStr, sSearchKeyword, sSearchType
		Dim sSearch, arKeyword, sKeyword, ar, Match, Matches, p, str, i
		sSearchStr = ""
		sSearchKeyword = ew_IIf(bDefault, bed.BasicSearch.KeywordDefault, bed.BasicSearch.Keyword)
		sSearchType = ew_IIf(bDefault, bed.BasicSearch.SearchTypeDefault, bed.BasicSearch.SearchType)

		' Get search SQL
		If sSearchKeyword <> "" Then
			ar = bed.BasicSearch.KeywordList(bDefault)

			' Search keyword in any fields
			If (sSearchType = "OR" Or sSearchType = "AND") And bed.BasicSearch.BasicSearchAnyFields Then
				For i = 0 to UBound(ar)
					sKeyword = ar(i)
					If sKeyword <> "" Then
						If sSearchStr <> "" Then sSearchStr = sSearchStr & " " & sSearchType & " "
						sSearchStr = sSearchStr & "(" & BasicSearchSQL(Array(sKeyword), sSearchType) & ")"
					End If
				Next
			Else
				sSearchStr = BasicSearchSQL(ar, sSearchType)
			End If
			If Not bDefault And ew_InArray(Command, Array("", "reset", "resetall")) Then Command = "search"
		End If
		If Not bDefault And Command = "search" Then
			Call bed.BasicSearch.setKeyword(sSearchKeyword)
			Call bed.BasicSearch.setSearchType(sSearchType)
		End If
		BasicSearchWhere = sSearchStr
	End Function

	' Check if search parm exists
	Function CheckSearchParms()

		' Check basic search
		If bed.BasicSearch.IssetSession() Then
			CheckSearchParms = True
			Exit Function
		End If
		CheckSearchParms = False
	End Function

	' Clear all search parameters
	Sub ResetSearchParms()

		' Clear search where
		SearchWhere = ""
		bed.SearchWhere = SearchWhere

		' Clear basic search parameters
		Call ResetBasicSearchParms
	End Sub

	' Load advanced search default values
	Function LoadAdvancedSearchDefault()
		LoadAdvancedSearchDefault = False
	End Function

	' Clear all basic search parameters
	Sub ResetBasicSearchParms()
		Call bed.BasicSearch.UnsetSession
	End Sub

	'
	' Restore all search parameters
	'
	Sub RestoreSearchParms()

		' Restore search flag
		RestoreSearch = True

		' Restore basic search values
		Call bed.BasicSearch.Load()
	End Sub

	'
	' Set up Sort parameters based on Sort Links clicked
	'
	Sub SetupSortOrder()
		Dim sOrderBy
		Dim sSortField, sLastSort, sThisSort
		Dim bCtrl

		' Check for an Order parameter
		If Request.QueryString("order").Count > 0 Then
			bed.CurrentOrder = Request.QueryString("order")
			bed.CurrentOrderType = Request.QueryString("ordertype")

			' Field ID
			Call bed.UpdateSort(bed.ID)

			' Field Page_Name
			Call bed.UpdateSort(bed.Page_Name)
			bed.StartRecordNumber = 1 ' Reset start position
		End If
	End Sub

	'
	' Load Sort Order parameters
	'
	Sub LoadSortOrder()
		Dim sOrderBy
		sOrderBy = bed.SessionOrderBy ' Get order by from Session
		If sOrderBy = "" Then
			If bed.SqlOrderBy <> "" Then
				sOrderBy = bed.SqlOrderBy
				bed.SessionOrderBy = sOrderBy
			End If
		End If
	End Sub

	'
	' Reset command based on querystring parameter "cmd"
	'
	Sub ResetCmd()

		' Check if reset command
		If Left(Command,5) = "reset" Then

			' Reset search criteria
			If Command = "reset" Or Command = "resetall" Then
				Call ResetSearchParms
			End If

			' Reset Sort Criteria
			If Command = "resetsort" Then
				Dim sOrderBy
				sOrderBy = ""
				bed.SessionOrderBy = sOrderBy
				bed.ID.Sort = ""
				bed.Page_Name.Sort = ""
			End If

			' Reset start position
			StartRec = 1
			bed.StartRecordNumber = StartRec
		End If
	End Sub

	' Set up list options
	Sub SetupListOptions()
		Dim item

		' Add group option item
		Set item = ListOptions.Add(ListOptions.GroupOptionName)
		item.Body = ""
		item.OnLeft = False
		item.Visible = False

		' View
		Set item = ListOptions.Add("view")
		item.CssClass = "text-nowrap;"
		item.Visible = Security.IsLoggedIn()
		item.OnLeft = False

		' Edit
		Set item = ListOptions.Add("edit")
		item.CssClass = "text-nowrap;"
		item.Visible = Security.IsLoggedIn()
		item.OnLeft = False

		' List actions
		Set item = ListOptions.Add("listactions")
		item.CssClass = "text-nowrap;"
		item.OnLeft = False
		item.Visible = False
		item.ShowInButtonGroup = False
		item.ShowInDropDown = False

		' Checkbox
		Set item = ListOptions.Add("checkbox")
		item.Visible = Security.IsLoggedIn()
		item.OnLeft = False
		item.Header = "<input type=""checkbox"" name=""key"" id=""key"" onclick=""ew_SelectAllKey(this);"">"
		item.ShowInDropDown = False
		item.ShowInButtonGroup = False

		' Drop down button for ListOptions
		ListOptions.UseImageAndText = True
		ListOptions.UseDropDownButton = False
		ListOptions.DropDownButtonPhrase = Language.Phrase("ButtonListOptions")
		ListOptions.UseButtonGroup = False
		If ListOptions.UseButtonGroup And ew_IsMobile() Then
			ListOptions.UseDropDownButton = True
		End If
		ListOptions.ButtonClass = "btn-sm" ' Class for button group
		Call ListOptions_Load
		Call SetupListOptionsExt

		' Set up group item visibility
		ListOptions(ListOptions.GroupOptionName).Visible = ListOptions.GroupOptionVisible
	End Sub

	' Render list options
	Sub RenderListOptions()
		Dim item, links, cancelurl
		Call ListOptions.LoadDefault

		' Call ListOptions_Rendering event
		Call ListOptions_Rendering
			Dim viewcaption
			viewcaption = ew_HtmlTitle(Language.Phrase("ViewLink"))
			If Security.IsLoggedIn() Then
				ListOptions("view").Body = "<a class=""ewRowLink ewView"" title=""" & viewcaption & """ data-caption=""" & viewcaption & """ href=""" & ew_HtmlEncode(ViewUrl) & """>" & Language.Phrase("ViewLink") & "</a>"
			Else
				ListOptions("view").Body = ""
			End If
			Dim editcaption
			Set item = ListOptions("edit")
			editcaption = ew_HtmlTitle(Language.Phrase("EditLink"))
			If Security.IsLoggedIn() Then
				item.Body = "<a class=""ewRowLink ewEdit"" title=""" & editcaption & """ data-caption=""" & editcaption & """ href=""" & ew_HtmlEncode(EditUrl) & """>" & Language.Phrase("EditLink") & "</a>"
			Else
				item.Body = ""
			End If

		' Set up list action buttons
		Dim oListOpt, body, content, link
		Dim listact, action, caption, icon
		Set oListOpt = ListOptions("listactions")
		If ew_NotEmpty(oListOpt) And bed.Export = "" And bed.CurrentAction = "" Then
			body = ""
			links = Array()
			For i = 0 to ListActions.Count - 1
				Set listact = ListActions(i)
				If listact.SelectType = EW_ACTION_SINGLE And listact.Allow Then
					action = listact.Action
					caption = listact.Caption
					icon = ew_IIf(listact.Icon <> "", "<span class=""" & ew_HtmlEncode(Replace(listact.Icon, " ewIcon", "")) & """ data-caption=""" & ew_HtmlTitle(caption) & """></span> " , "")
					If UBound(links) < 0 Then
						ReDim links(0)
					Else
						ReDim Preserve links(UBound(links)+1)
					End If
					links(UBound(links)) = "<li><a class=""ewAction ewListAction"" data-action=""" & ew_HtmlEncode(action) & """ data-caption=""" & ew_HtmlTitle(caption) & """ href="""" onclick=""ew_SubmitAction(event,jQuery.extend({key:" & bed.KeyToJson() & ",data:{rnd:" & ew_Random() & "}}," & listact.ToJson(True) & "));return false;"">" & icon & listact.Caption & "</a></li>"
					If UBound(links) = 0 Then ' Single button
						body = "<a class=""ewAction ewListAction"" data-action=""" & ew_HtmlEncode(action) & """ title=""" & ew_HtmlTitle(caption) & """ data-caption=""" & ew_HtmlTitle(caption) & """ href="""" onclick=""ew_SubmitAction(event,jQuery.extend({key:" & bed.KeyToJson() & ",data:{rnd:" & ew_Random() & "}}," & listact.ToJson(True) & "));return false;"">" & Language.Phrase("ListActionButton") & "</a>"
					End If
				End If
			Next
			If UBound(links) > 0 Then ' More than one buttons, use dropdown
				body = "<button class=""dropdown-toggle btn btn-default btn-sm ewActions"" title=""" & ew_HtmlTitle(Language.Phrase("ListActionButton")) & """ data-toggle=""dropdown"">" & Language.Phrase("ListActionButton") & "<b class=""caret""></b></button>"
				content = ""
				For Each link In links
					content = content & "<li>" & link & "</li>"
				Next
				body = body & "<ul class=""dropdown-menu" & ew_IIf(oListOpt.OnLeft, "", " dropdown-menu-right") & """>" & content & "</ul>"
				body = "<div class=""btn-group"">" & body & "</div>"
			End If
			If UBound(links) >= 0 Then
				oListOpt.Body = body
				oListOpt.Visible = True
			End If
		End If
		ListOptions("checkbox").Body = "<input type=""checkbox"" name=""key_m"" class=""ewMultiSelect"" value=""" & ew_HtmlEncode(bed.ID.CurrentValue) & """ onclick=""ew_ClickMultiCheckbox(event);"">"
		Call RenderListOptionsExt
		Call ListOptions_Rendered
	End Sub

	' Set up other options
	Sub SetupOtherOptions()
		Dim opt, item, DetailTableLink, ar, i, caption, url, addcaption
		Set opt = AddEditOptions

		' Add
		Set item = opt.Add("add")
		addcaption = ew_HtmlTitle(Language.Phrase("AddLink"))
		item.Body = "<a class=""ewAddEdit ewAdd"" title=""" & addcaption & """ data-caption=""" & addcaption & """ href=""" & ew_HtmlEncode(AddUrl) & """>" & Language.Phrase("AddLink") & "</a>"
		item.Visible = (AddUrl <> "" And Security.IsLoggedIn())
		Set opt = ActionOptions

		' Add multi delete
		Set item = opt.Add("multidelete")
		item.Body = "<a class=""ewAction ewMultiDelete"" title=""" & ew_HtmlTitle(Language.Phrase("DeleteSelectedLink")) & """ data-caption=""" & ew_HtmlTitle(Language.Phrase("DeleteSelectedLink")) & """ href="""" onclick=""ew_SubmitAction(event,{f:document.fbedlist,url:'" & MultiDeleteUrl & "'});return false;"">" & Language.Phrase("DeleteSelectedLink") & "</a>"
		item.Visible = (Security.IsLoggedIn())

		' Set up options default
		Set opt = AddEditOptions
		opt.UseImageAndText = True
		opt.DropDownButtonPhrase = Language.Phrase("ButtonAddEdit")
		opt.UseDropDownButton = False
		opt.UseButtonGroup = True
		opt.ButtonClass = "btn-sm" ' Class for button group
		Set item = opt.Add(opt.GroupOptionName)
		item.Body = ""
		item.Visible = False
		Set opt = DetailOptions
		opt.UseImageAndText = True
		opt.DropDownButtonPhrase = Language.Phrase("ButtonDetails")
		opt.UseDropDownButton = False
		opt.UseButtonGroup = True
		opt.ButtonClass = "btn-sm" ' Class for button group
		Set item = opt.Add(opt.GroupOptionName)
		item.Body = ""
		item.Visible = False
		Set opt = ActionOptions
		opt.UseImageAndText = True
		opt.DropDownButtonPhrase = Language.Phrase("ButtonActions")
		opt.UseDropDownButton = False
		opt.UseButtonGroup = True
		opt.ButtonClass = "btn-sm" ' Class for button group
		Set item = opt.Add(opt.GroupOptionName)
		item.Body = ""
		item.Visible = False

		' Filter button
		Set opt = FilterOptions
		Set item = opt.Add("savecurrentfilter")
		item.Body = "<a class=""ewSaveFilter"" data-form=""fbedlistsrch"" href=""#"">" & Language.Phrase("SaveCurrentFilter") & "</a>"
		item.Visible = True
		Set item = opt.Add("deletefilter")
		item.Body = "<a class=""ewDeleteFilter"" data-form=""fbedlistsrch"" href=""#"">" & Language.Phrase("DeleteFilter") & "</a>"
		item.Visible = True
		opt.UseDropDownButton = True
		opt.UseButtonGroup = Not FilterOptions.UseDropDownButton
		opt.DropDownButtonPhrase = Language.Phrase("Filters")

		' Add group option item
		Set item = opt.Add(FilterOptions.GroupOptionName)
		item.Body = ""
		item.Visible = False
	End Sub

	' Render other options
	Sub RenderOtherOptions()
		Dim opt, item, i, action, caption, icon, Name, cancelurl
			Set opt = ActionOptions
			opt.UseImageAndText = True

			' Set up list action buttons
			Dim listact
			For i = 0 to ListActions.Count - 1
				Set listact = ListActions(i)
				If listact.SelectType = EW_ACTION_MULTIPLE Then
					action = listact.Action
					caption = listact.Caption
					icon = ew_IIf(listact.Icon <> "", "<span class=""" & ew_HtmlEncode(listact.Icon) & """ data-caption=""" & ew_HtmlEncode(caption) & """></span> ", caption)
					Set item = opt.Add("custom_" & Action)
					item.Body = "<a class=""ewAction ewListAction"" title=""" & ew_HtmlEncode(caption) & """ data-caption=""" & ew_HtmlEncode(caption) & """ href="""" onclick=""ew_SubmitAction(event,jQuery.extend({f:document.fbedlist}," & listact.ToJson(True) & "));return false;"">" & icon & "</a>"
					item.Visible = listact.Allow
				End If
			Next

			' Hide grid edit and other options
			If TotalRecs <= 0 Then
				Set opt = AddEditOptions
				Set item = opt("gridedit")
				If ew_NotEmpty(item) Then item.Visible = False
				Set opt = ActionOptions
				Call opt.HideAllOptions(Array())
			End If
	End Sub

	' Process list action
	Function ProcessListAction()
		Dim userlist, user, sFilter, UserAction, Processed, ActionCaption
		userlist = ""
		user = ""
		sFilter = bed.GetKeyFilter
		UserAction = Request.Form("useraction") & ""
		Processed = False
		If sFilter <> "" And UserAction <> "" Then

			' Check permission first
			Dim listact
			ActionCaption = UserAction
			If ListActions.Exists(UserAction) Then
				Set listact = ListActions(UserAction)
				ActionCaption = listact.Caption
				If Not listact.Allow Then
					errmsg = Replace(Language.Phrase("CustomActionNotAllowed"), "%s", ActionCaption)
					If Request.Form("ajax") = UserAction Then ' Ajax
						Response.Write "<p class=""text-danger"">" & errmsg & "</p>"
					Else
						FailureMessage = errmsg
					End If
					ProcessListAction = False
				End If
			End If
			Dim cnn, sSql
			bed.CurrentFilter = sFilter
			sSql = bed.SQL
			Set cnn = bed.TableConnection
			cnn.BeginTrans
			bed.CurrentAction = UserAction

			' Load recordset
			Dim Rs
			Set Rs = ew_LoadRecordsetByDbid(sSql, bed.TableDBID)
			If Not Rs.EOF Then Rs.MoveFirst

			' Call row custom action event
			SelectedCount = Rs.RecordCount
			SelectedIndex = 0
			Do While Not Rs.EOF
				SelectedIndex = SelectedIndex + 1
				Processed = Row_CustomAction(UserAction, Rs)
				If Not Processed Then
					Exit Do
				End If
				Rs.MoveNext
			Loop
			Rs.Close
			Set Rs = Nothing
			If Processed Then
				cnn.CommitTrans ' Commit the changes
				If SuccessMessage = "" Then
					SuccessMessage = Replace(Language.Phrase("CustomActionCompleted"), "%s", ActionCaption) ' Set up success message
				End If
			Else
				cnn.RollbackTrans ' Rollback transaction

				' Set up error message
				If SuccessMessage <> "" Or FailureMessage <> "" Then

					' Use the message, do nothing
				ElseIf bed.CancelMessage <> "" Then
					FailureMessage = bed.CancelMessage
					bed.CancelMessage = ""
				Else
					FailureMessage = Replace(Language.Phrase("CustomActionFailed"), "%s", ActionCaption)
				End If
			End If
			bed.CurrentAction = "" ' Clear action
			If Request.Form("ajax") = UserAction Then ' Ajax
				If SuccessMessage <> "" Then
					Response.Write "<p class=""text-success"">" & SuccessMessage & "</p>"
					Call ClearSuccessMessage ' Clear message
				End If
				If FailureMessage <> "" Then
					Response.Write "<p class=""text-danger"">" & FailureMessage & "</p>"
					Call ClearFailureMessage ' Clear message
				End If
				ProcessListAction = True
			End If
		Else
			ProcessListAction = False ' Not ajax request
		End If
	End Function

	' Set up search options
	Sub SetupSearchOptions()
		Dim item, SearchToggleClass
		Set SearchOptions = New cListOptions
		SearchOptions.TableVar = bed.TableVar
		ExportOptions.Tag = "div"
		SearchOptions.TagClassName = "ewSearchOption"

		' Search button
		Set item = SearchOptions.Add("searchtoggle")
		SearchToggleClass = ew_IIf(SearchWhere <> "", " active", " active")
		item.Body = "<button type=""button"" class=""btn btn-default ewSearchToggle" & SearchToggleClass & """ title=""" & Language.Phrase("SearchPanel") & """ data-caption=""" & Language.Phrase("SearchPanel") & """ data-toggle=""button"" data-form=""fbedlistsrch"">" & Language.Phrase("SearchLink") & "</button>"
		item.Visible = True

		' Show all button
		Set item = SearchOptions.Add("showall")
		item.Body = "<a class=""btn btn-default ewShowAll"" title=""" & Language.Phrase("ShowAll") & """ data-caption=""" & Language.Phrase("ShowAll") & """ href=""" & PageUrl & "cmd=reset"">" & Language.Phrase("ShowAllBtn") & "</a>"
		item.Visible = (SearchWhere <> DefaultSearchWhere And SearchWhere <> "0=101")

		' Button group for search
		SearchOptions.UseDropDownButton = False
		SearchOptions.UseImageAndText = True
		SearchOptions.UseButtonGroup = True
		SearchOptions.DropDownButtonPhrase = Language.Phrase("ButtonSearch")

		' Add group option item
		Set item = SearchOptions.Add(SearchOptions.GroupOptionName)
		item.Body = ""
		item.Visible = False

		' Hide search options
		If bed.Export <> "" Or bed.CurrentAction <> "" Then
			Call SearchOptions.HideAllOptions(Array())
		End If
	End Sub

	Sub SetupListOptionsExt()
	End Sub

	Sub RenderListOptionsExt()
	End Sub
	Dim Pager

	'
	' Set up Starting Record parameters based on Pager Navigation
	'
	Sub SetupStartRec()
		Dim PageNo

		' Exit if DisplayRecs = 0
		If DisplayRecs = 0 Then Exit Sub
		If IsPageRequest Then ' Validate request

			' Check for a START parameter
			If Request.QueryString(EW_TABLE_START_REC).Count > 0 Then
				StartRec = Request.QueryString(EW_TABLE_START_REC)
				bed.StartRecordNumber = StartRec
			ElseIf Request.QueryString(EW_TABLE_PAGE_NO).Count > 0 Then
				PageNo = Request.QueryString(EW_TABLE_PAGE_NO)
				If IsNumeric(PageNo) Then
					StartRec = (PageNo-1)*DisplayRecs+1
					If StartRec <= 0 Then
						StartRec = 1
					ElseIf StartRec >= ((TotalRecs-1)\DisplayRecs)*DisplayRecs+1 Then
						StartRec = ((TotalRecs-1)\DisplayRecs)*DisplayRecs+1
					End If
					bed.StartRecordNumber = StartRec
				End If
			End If
		End If
		StartRec = bed.StartRecordNumber

		' Check if correct start record counter
		If Not IsNumeric(StartRec) Or StartRec = "" Then ' Avoid invalid start record counter
			StartRec = 1 ' Reset start record counter
			bed.StartRecordNumber = StartRec
		ElseIf CLng(StartRec) > CLng(TotalRecs) Then ' Avoid starting record > total records
			StartRec = ((TotalRecs-1)\DisplayRecs)*DisplayRecs+1 ' Point to last page first record
			bed.StartRecordNumber = StartRec
		ElseIf (StartRec-1) Mod DisplayRecs <> 0 Then
			StartRec = ((StartRec-1)\DisplayRecs)*DisplayRecs+1 ' Point to page boundary
			bed.StartRecordNumber = StartRec
		End If
	End Sub

	'
	' Load basic search values
	'
	Sub LoadBasicSearchValues()
		bed.BasicSearch.Keyword = Request.QueryString(EW_TABLE_BASIC_SEARCH)&""
		If bed.BasicSearch.Keyword <> "" And Command = "" Then Command = "search"
		bed.BasicSearch.SearchType = Request.QueryString(EW_TABLE_BASIC_SEARCH_TYPE)&""
	End Sub

	'
	' Load recordset
	'
	Function LoadRecordset(offset, rowcnt)
		Dim sSql, rs, useSelectLimit, dbType, hasOrderBy
		useSelectLimit = rowcnt > 0 And offset >= 0
		dbType = ew_GetConnectionType(bed.TableDBID)
		If dbType = "MSSQL" Then
			If ew_IsMsSql2012(bed.TableDBID) Then dbType = "MSSQL2012" ' ASP
		End If

		' Load List page SQL
		sSql = bed.ListSQL
		If useSelectLimit Then
			hasOrderBy = bed.SqlOrderBy <> "" Or bed.SessionOrderBy <> ""
			sSql = ew_GetSelectLimitSql(sSql, rowcnt, offset, hasOrderBy, dbType)
		End If

		' Load recordset
		Set rs = ew_LoadRecordsetByDbid(sSql, bed.TableDBID)
		If Not useSelectLimit Or dbType <> "MSSQL2012" And dbType <> "MYSQL" And dbType <> "POSTGRESQL" Then ' ASP
			If offset > 0 And Not rs.EOF Then rs.Move offset
		End If

		' Call Recordset Selected event
		Call bed.Recordset_Selected(rs)
		Set LoadRecordset = rs
	End Function

	'
	' Load row based on key values
	'
	Function LoadRow()
		Dim RsRow, sSql, sFilter
		sFilter = bed.KeyFilter

		' Call Row Selecting event
		Call bed.Row_Selecting(sFilter)

		' Load SQL based on filter
		bed.CurrentFilter = sFilter
		sSql = bed.SQL
		Call ew_SetDebugMsg("LoadRow: " & sSql) ' Show SQL for debugging
		Set RsRow = ew_LoadRowByDbid(sSql, bed.TableDBID)
		If RsRow.EOF Then
			LoadRow = False
		Else
			LoadRow = True
			RsRow.MoveFirst
			Call LoadRowValues(RsRow) ' Load row values
		End If
		RsRow.Close
		Set RsRow = Nothing
	End Function

	'
	' Load row values from recordset
	'
	Sub LoadRowValues(RsRow)
		Dim sDetailFilter
		If Not EW_DEBUG_ENABLED Then On Error Resume Next
		If IsNull(RsRow) Then
			Set RsRow = NewRow()
		End If

		' Call Row Selected event
		Call bed.Row_Selected(RsRow)
		If ew_Empty(RsRow) Then Exit Sub
		If RsRow.EOF Then Exit Sub
		bed.ID.DbValue = RsRow("ID")
		bed.Page_Name.DbValue = RsRow("Page_Name")
		bed.Title.DbValue = RsRow("Title")
		bed.Description.DbValue = RsRow("Description")
		bed.Enable.DbValue = RsRow("Enable")
		bed.Sequence.DbValue = RsRow("Sequence")
		bed.IP.DbValue = RsRow("IP")
		bed.zDate.DbValue = RsRow("Date")
		bed.Username.DbValue = RsRow("Username")
	End Sub

	' Return a row with default values
	Function NewRow
		Dim cnn, rs, sSql, sFilter

		' Clear any previous errors
		Err.Clear
		Set cnn = bed.TableConnection
		sFilter = bed.CurrentFilter
		bed.CurrentFilter = "(0 = 1)"
		sSql = bed.SQL
		bed.CurrentFilter = sFilter
		Set rs = Server.CreateObject("ADODB.Recordset")
		rs.CursorLocation = 3 ' adUseClient
		Call ew_SetDebugMsg("NewRow: " & sSql) ' Show SQL for debugging
		rs.Open sSql, cnn, 3, 4 ' adOpenStatic, adLockBatchOptimistic

		' Disconnect the Recordset
		Set rs.ActiveConnection = Nothing

		' Add new record
		rs.AddNew
		rs("Page_Name") = Null
		rs("Title") = Null
		rs("Description") = Null
		rs("Enable") = Null
		rs("Sequence") = Null
		rs("IP") = Null
		rs("Date") = Null
		rs("Username") = Null

		' Return the recordset
		If Err.Number = 0 Then
			Set NewRow = rs
		Else
			Set NewRow = Nothing
		End If
	End Function

	' Load DbValue from recordset
	Sub LoadDbValues(Rs)
		If Not EW_DEBUG_ENABLED Then On Error Resume Next
		If ew_Empty(Rs) Then Exit Sub
		If Rs.EOF Then Exit Sub
		bed.ID.m_DbValue = Rs("ID")
		bed.Page_Name.m_DbValue = Rs("Page_Name")
		bed.Title.m_DbValue = Rs("Title")
		bed.Description.m_DbValue = Rs("Description")
		bed.Enable.m_DbValue = Rs("Enable")
		bed.Sequence.m_DbValue = Rs("Sequence")
		bed.IP.m_DbValue = Rs("IP")
		bed.zDate.m_DbValue = Rs("Date")
		bed.Username.m_DbValue = Rs("Username")
	End Sub

	' Load old record
	Function LoadOldRecord()

		' Load key values from Session
		Dim bValidKey
		bValidKey = True
		If bed.GetKey("ID")&"" <> "" Then
			bed.ID.CurrentValue = bed.GetKey("ID") ' ID
		Else
			bValidKey = False
		End If

		' Load old record
		OldRecordset = Null
		If bValidKey Then
			bed.CurrentFilter = bed.KeyFilter
			Dim sSql
			sSql = bed.SQL
			Set OldRecordset = ew_LoadRecordsetByDbid(sSql, bed.TableDBID)
		End If
		Call LoadRowValues(OldRecordset) ' Load row values
		LoadOldRecord = bValidKey
	End Function

	'
	' Render row values based on field settings
	'
	Sub RenderRow()

		' Initialize URLs
		ViewUrl = bed.ViewUrl("")
		EditUrl = bed.EditUrl("")
		InlineEditUrl = bed.InlineEditUrl
		CopyUrl = bed.CopyUrl("")
		InlineCopyUrl = bed.InlineCopyUrl
		DeleteUrl = bed.DeleteUrl

		' Call Row Rendering event
		Call bed.Row_Rendering

		'
		' Common render codes for all row types
		'
		' ID
		' Page_Name
		' Title
		' Description
		' Enable
		' Sequence
		' IP
		' Date
		' Username
		'
		' View Row
		'

		If bed.RowType = EW_ROWTYPE_VIEW Then ' View row

			' ID
			bed.ID.ViewValue = bed.ID.CurrentValue
			bed.ID.ViewCustomAttributes = ""

			' Page_Name
			bed.Page_Name.ViewValue = bed.Page_Name.CurrentValue
			bed.Page_Name.ViewCustomAttributes = ""

			' Title
			bed.Title.ViewValue = bed.Title.CurrentValue
			bed.Title.ViewCustomAttributes = ""

			' Enable
			If Not IsNull(bed.Enable.CurrentValue) Then
				bed.Enable.ViewValue = bed.Enable.OptionCaption(bed.Enable.CurrentValue)
			Else
				bed.Enable.ViewValue = Null
			End If
			bed.Enable.ViewCustomAttributes = ""

			' Sequence
			bed.Sequence.ViewValue = bed.Sequence.CurrentValue
			bed.Sequence.ViewCustomAttributes = ""

			' IP
			bed.IP.ViewValue = bed.IP.CurrentValue
			bed.IP.ViewCustomAttributes = ""

			' Date
			bed.zDate.ViewValue = bed.zDate.CurrentValue
			bed.zDate.ViewValue = ew_FormatDateTime(bed.zDate.ViewValue, 0)
			bed.zDate.ViewCustomAttributes = ""

			' Username
			bed.Username.ViewValue = bed.Username.CurrentValue
			bed.Username.ViewCustomAttributes = ""

			' View refer script
			' ID

			bed.ID.LinkCustomAttributes = ""
			bed.ID.HrefValue = ""
			bed.ID.TooltipValue = ""

			' Page_Name
			bed.Page_Name.LinkCustomAttributes = ""
			bed.Page_Name.HrefValue = ""
			bed.Page_Name.TooltipValue = ""
		End If

		' Call Row Rendered event
		If bed.RowType <> EW_ROWTYPE_AGGREGATEINIT Then
			Call bed.Row_Rendered
		End If
	End Sub

	' Set up Breadcrumb
	Sub SetupBreadcrumb()
		Dim PageId, url
		Set Breadcrumb = New cBreadcrumb
		url = Mid(ew_CurrentUrl(), InStrRev(ew_CurrentUrl(), "/") + 1)
		url = ew_RegExReplace("\?cmd=reset(all){0,1}$", url, "") ' Remove cmd=reset / cmd=resetall
		Call Breadcrumb.Add("list", bed.TableVar, url, "", bed.TableVar, True)
	End Sub

	' Setup lookup filters of a field
	Sub SetupLookupFilters(fld, pageId)
		pageId = ew_IIf(ew_EmptyStr(pageId), bed_list.PageID, pageId)
		Select Case fld.FldVar
		End Select
	End Sub

	' Setup AutoSuggest filters of a field
	Sub SetupAutoSuggestFilters(fld, pageId)
		pageId = ew_IIF(ew_EmptyStr(pageId), bed_list.PageID, pageId)
		Select Case fld.FldVar
		End Select
	End Sub

	Sub ExportPdf(html)
		Response.Write html
	End Sub

	' Page Load event
	Sub Page_Load()

		'Response.Write "Page Load"
	End Sub

	' Page Unload event
	Sub Page_Unload()

		'Response.Write "Page Unload"
	End Sub

	' Page Redirecting event
	Sub Page_Redirecting(url)

		'url = newurl
	End Sub

	' Message Showing event
	' typ = ""|"success"|"failure"|"warning"
	Sub Message_Showing(msg, typ)

		' Example:
		'If typ = "success" Then
		'	msg = "your success message"
		'ElseIf typ = "failure" Then
		'	msg = "your failure message"
		'ElseIf typ = "warning" Then
		'	msg = "your warning message"
		'Else
		'	msg = "your message"
		'End If

	End Sub

	' Page Render event
	Sub Page_Render()

		'Response.Write "Page Render"
	End Sub

	' Page Data Rendering event
	Sub Page_DataRendering(header)

		' Example:
		'header = "your header"

	End Sub

	' Page Data Rendered event
	Sub Page_DataRendered(footer)

		' Example:
		'footer = "your footer"

	End Sub

	' Form Custom Validate event
	Function Form_CustomValidate(CustomError)

		'Return error message in CustomError
		Form_CustomValidate = True
	End Function

	' ListOptions Load event
	Sub ListOptions_Load()

		'Example: 
		' Dim opt
		' Set opt = ListOptions.Add("new")
		' opt.OnLeft = True ' Link on left
		' Call opt.MoveTo(0) ' Move to first column

	End Sub

	' ListOptions Rendering event
	Sub ListOptions_Rendering()

		'Example: 
		' xxx.DetailAdd = (...condition...) ' Set to True or False conditionally
		' xxx.DetailEdit = (...condition...) ' Set to True or False conditionally
		' xxx.DetailView = (...condition...) ' Set to True or False conditionally

	End Sub

	' ListOptions Rendered event
	Sub ListOptions_Rendered()

		'Example: 
		'ListOptions.GetItem("new").Body = "xxx"

	End Sub

	' Row Custom Action event
	Function Row_CustomAction(action, rs)

		' Return False to abort
		Row_CustomAction = True
	End Function

	' Page Exporting event
	' ExportDoc = export document object
	Function Page_Exporting()

		'ExportDoc.Text = "my header" ' Export header
		'Page_Exporting = False ' Return False to skip default export and use Row_Export event

		Page_Exporting = True ' Return True to use default export and skip Row_Export event
	End Function

	' Row Export event
	' ExportDoc = export document object
	Sub Row_Export(rs)

		'ExportDoc.Text = ExportDoc.Text & "my content" ' Build HTML with field value: rs("MyField") or MyField.ViewValue
	End Sub

	' Page Exported event
	' ExportDoc = export document object
	Sub Page_Exported()

		'ExportDoc.Text = ExportDoc.Text & "my footer" ' Export footer
		'Response.Write ExportDoc.Text

	End Sub
End Class
%>

Youez - 2016 - github.com/yon3zu
LinuXploit