<% Response.Expires = 0 Response.ExpiresAbsolute = Now() - 1 Response.AddHeader "pragma", "no-cache" Response.AddHeader "cache-control", "private, no-cache, no-store, must-revalidate" %> <% If Not IsLoggedIn And Request.Cookies(ewProjectName)("autologin") = "autologin" And Request.Cookies(ewProjectName)("password") <> "" Then Response.Redirect "login.asp" Call LoadUserLevel() If IsLoggedIn Then ewCurSec = CurrentUserLevelPriv("hotels") Else ewCurSec = GetAnonymousPriv("hotels") End If If (ewCurSec And ewAllowList) <> ewAllowList Then Response.Redirect "login.asp" %> <% ' Initialize common variables x_HotelID = Null: ox_HotelID = Null: z_HotelID = Null x_HotelLogo = Null: ox_HotelLogo = Null: z_HotelLogo = Null fs_x_HotelLogo = 0: fn_x_HotelLogo = "": ct_x_HotelLogo = "" wd_x_HotelLogo = 0: ht_x_HotelLogo = 0: a_x_HotelLogo = "" x_HotelName = Null: ox_HotelName = Null: z_HotelName = Null x_HotelCategory = Null: ox_HotelCategory = Null: z_HotelCategory = Null x_Governorate = Null: ox_Governorate = Null: z_Governorate = Null x_BtriefLocation = Null: ox_BtriefLocation = Null: z_BtriefLocation = Null x_HotelDescription = Null: ox_HotelDescription = Null: z_HotelDescription = Null x_Photo1 = Null: ox_Photo1 = Null: z_Photo1 = Null fs_x_Photo1 = 0: fn_x_Photo1 = "": ct_x_Photo1 = "" wd_x_Photo1 = 0: ht_x_Photo1 = 0: a_x_Photo1 = "" x_Photo2 = Null: ox_Photo2 = Null: z_Photo2 = Null fs_x_Photo2 = 0: fn_x_Photo2 = "": ct_x_Photo2 = "" wd_x_Photo2 = 0: ht_x_Photo2 = 0: a_x_Photo2 = "" x_Photo3 = Null: ox_Photo3 = Null: z_Photo3 = Null fs_x_Photo3 = 0: fn_x_Photo3 = "": ct_x_Photo3 = "" wd_x_Photo3 = 0: ht_x_Photo3 = 0: a_x_Photo3 = "" x_Photo4 = Null: ox_Photo4 = Null: z_Photo4 = Null fs_x_Photo4 = 0: fn_x_Photo4 = "": ct_x_Photo4 = "" wd_x_Photo4 = 0: ht_x_Photo4 = 0: a_x_Photo4 = "" x_Photo5 = Null: ox_Photo5 = Null: z_Photo5 = Null fs_x_Photo5 = 0: fn_x_Photo5 = "": ct_x_Photo5 = "" wd_x_Photo5 = 0: ht_x_Photo5 = 0: a_x_Photo5 = "" x_Photo6 = Null: ox_Photo6 = Null: z_Photo6 = Null fs_x_Photo6 = 0: fn_x_Photo6 = "": ct_x_Photo6 = "" wd_x_Photo6 = 0: ht_x_Photo6 = 0: a_x_Photo6 = "" x_NearbySightseeing = Null: ox_NearbySightseeing = Null: z_NearbySightseeing = Null x_HotelFacilities = Null: ox_HotelFacilities = Null: z_HotelFacilities = Null x_RoomFacilities = Null: ox_RoomFacilities = Null: z_RoomFacilities = Null x_RoomCategory = Null: ox_RoomCategory = Null: z_RoomCategory = Null x_RoomFacilitiesCategory = Null: ox_RoomFacilitiesCategory = Null: z_RoomFacilitiesCategory = Null x_RoomFacilitiesSubcategory = Null: ox_RoomFacilitiesSubcategory = Null: z_RoomFacilitiesSubcategory = Null x_Featured = Null: ox_Featured = Null: z_Featured = Null %> <% nStartRec = 0 nStopRec = 0 nTotalRecs = 0 nRecCount = 0 nRecActual = 0 sDbWhereMaster = "" sDbWhereDetail = "" sSrchAdvanced = "" psearch = "" psearchtype = "" sSrchBasic = "" sSrchWhere = "" sDbWhere = "" sOrderBy = "" sSqlMaster = "" nDisplayRecs = 20 nRecRange = 10 ' Multi Column nRecPerRow = 3 ' Open connection to the database Set conn = Server.CreateObject("ADODB.Connection") conn.Open xDb_Conn_Str ' Handle Reset Command ResetCmd() ' Get Search Criteria for Advanced Search SetUpAdvancedSearch() ' Get Search Criteria for Basic Search SetUpBasicSearch() ' Build Search Criteria If sSrchAdvanced <> "" Then If sSrchWhere <> "" Then sSrchWhere = sSrchWhere & " AND " sSrchWhere = sSrchWhere & "(" & sSrchAdvanced & ")" End If If sSrchBasic <> "" Then If sSrchWhere <> "" Then sSrchWhere = sSrchWhere & " AND " sSrchWhere = sSrchWhere & "(" & sSrchBasic & ")" End If ' Save Search Criteria If sSrchWhere <> "" Then Session(ewSessionTblSearchWhere) = sSrchWhere nStartRec = 1 ' reset start record counter Session(ewSessionTblStartRec) = nStartRec Else sSrchWhere = Session(ewSessionTblSearchWhere) Call RestoreSearch() End If ' Build Filter condition sDbWhere = "" If (ewCurSec And ewAllowList) <> ewAllowList Then sDbWhere = "(0=1)" End If If sDbWhereDetail <> "" Then If sDbWhere <> "" Then sDbWhere = sDbWhere & " AND " sDbWhere = sDbWhere & "(" & sDbWhereDetail & ")" End If If sSrchWhere <> "" Then If sDbWhere <> "" Then sDbWhere = sDbWhere & " AND " sDbWhere = sDbWhere & "(" & sSrchWhere & ")" End If ' Set Up Sorting Order sOrderBy = "" SetUpSortOrder() ' Set up SQL sSql = ewBuildSql(ewSqlSelect, ewSqlWhere, ewSqlGroupBy, ewSqlHaving, ewSqlOrderBy, sDbWhere, sOrderBy) 'Response.Write sSql ' Uncomment to show SQL for debugging %> Continental Tours | Travel Agency | Hotels in <% Response.Write x_Governorate %> <% ' Set up Record Set Set rs = Server.CreateObject("ADODB.Recordset") rs.CursorLocation = 3 rs.Open sSql, conn, 1, 2 nTotalRecs = rs.RecordCount If nDisplayRecs <= 0 Then ' Display All Records nDisplayRecs = nTotalRecs End If nStartRec = 1 SetUpStartRec() ' Set Up Start Record Position %>
Hotel Name  
">
Hotel Category  
<% lst_x_HotelCategory = "" Response.Write lst_x_HotelCategory %>
City  
<% lst_x_Governorate = "" Response.Write lst_x_Governorate %>
    Advanced Search
checked<% End If %>>Exact phrase  checked<% End If %>>All words  checked<% End If %>>Any word
<% If (ewCurSec And ewAllowAdd) = ewAllowAdd Then %>
Add

<% End If %> <% If Session(ewSessionMessage) <> "" Then %>

<%= Session(ewSessionMessage) %>

<% Session(ewSessionMessage) = "" ' Clear message End If %> <% If nTotalRecs > 0 Then %>
<% ' Set the last record to display nStopRec = nStartRec + nDisplayRecs - 1 ' Move to first record directly for performance reason nRecCount = nStartRec - 1 If Not rs.Eof Then rs.MoveFirst rs.Move nStartRec - 1 End If nRecActual = 0 Do While (Not rs.Eof) And (nRecCount < nStopRec) nRecCount = nRecCount + 1 If CLng(nRecCount) >= CLng(nStartRec) Then nRecActual = nRecActual + 1 ' Set row color sItemRowClass = " class=""ewTableRow""" sListTrJs = "" ' Display alternate color for rows If nRecCount Mod 2 <> 1 Then sItemRowClass = " class=""ewTableRow""" End If x_HotelID = rs("HotelID") x_HotelLogo = rs("HotelLogo") x_HotelName = rs("HotelName") x_HotelCategory = rs("HotelCategory") x_Governorate = rs("Governorate") x_BtriefLocation = rs("BtriefLocation") x_HotelDescription = rs("HotelDescription") x_Photo1 = rs("Photo1") x_Photo2 = rs("Photo2") x_Photo3 = rs("Photo3") x_Photo4 = rs("Photo4") x_Photo5 = rs("Photo5") x_Photo6 = rs("Photo6") x_NearbySightseeing = rs("NearbySightseeing") x_HotelFacilities = rs("HotelFacilities") x_RoomFacilities = rs("RoomFacilities") x_RoomCategory = rs("RoomCategory") x_RoomFacilitiesCategory = rs("RoomFacilitiesCategory") x_RoomFacilitiesSubcategory = rs("RoomFacilitiesSubcategory") x_Featured = rs("Featured") %> <% If (nRecActual Mod nRecPerRow = 1) OR (nRecPerRow < 2) Then %> <% End If %> <% If (nRecActual Mod nRecPerRow = 0) Or (nRecPerRow < 2) Then %> <% End If %> <% End If rs.MoveNext Loop %> <% If (nRecActual Mod nRecPerRow) <> 0 Then For i = 1 to (nRecPerRow - nRecActual Mod nRecPerRow) %> <% Next %> <% End If %>
"> <% Response.Write x_HotelName %>

<% If Not IsNull(x_Photo1) Then %> "> <% End If %>

<% If Not IsNull(x_HotelCategory) Then sSqlWrk = "SELECT `HotelCategory` FROM `hotelcategory`" sTmp = x_HotelCategory sSqlWrk = sSqlWrk & " WHERE `HotelCategory` = '" & AdjustSql(sTmp) & "'" Set rswrk = conn.Execute(sSqlWrk) If Not rswrk.Eof Then sTmp = rswrk("HotelCategory") End If rswrk.Close Set rswrk = Nothing Else sTmp = Null End If ox_HotelCategory = x_HotelCategory ' Backup Original Value x_HotelCategory = sTmp %> <% Response.Write x_HotelCategory %> <% x_HotelCategory = ox_HotelCategory ' Restore Original Value %>
<% If Not IsNull(x_Governorate) Then sSqlWrk = "SELECT `Governorate` FROM `governorate`" sTmp = x_Governorate sSqlWrk = sSqlWrk & " WHERE `Governorate` = '" & AdjustSql(sTmp) & "'" Set rswrk = conn.Execute(sSqlWrk) If Not rswrk.Eof Then sTmp = rswrk("Governorate") End If rswrk.Close Set rswrk = Nothing Else sTmp = Null End If ox_Governorate = x_Governorate ' Backup Original Value x_Governorate = sTmp %> <% Response.Write x_Governorate %> <% x_Governorate = ox_Governorate ' Restore Original Value %>
<% If (ewCurSec And ewAllowEdit) = ewAllowEdit Then %> ">Edit  <% End If %> <% If (ewCurSec And ewAllowDelete) = ewAllowDelete Then %> Delete <% End If %>
<% If nRecActual > 0 Then %> <% If (ewCurSec And ewAllowDelete) = ewAllowDelete Then %>

<% End If %> <% End If %>

<% End If %> <% ' Close recordset and connection rs.Close Set rs = Nothing conn.Close Set conn = Nothing %>
<% ' Display page numbers If nTotalRecs > 0 Then rsEof = (nTotalRecs < (nStartRec + nDisplayRecs)) If CLng(nTotalRecs) > CLng(nDisplayRecs) Then ' Find out if there should be Backward or Forward Buttons on the TABLE. If nStartRec = 1 Then isPrev = False Else isPrev = True PrevStart = nStartRec - nDisplayRecs If PrevStart < 1 Then PrevStart = 1 %> Prev <% End If If (isPrev Or (Not rsEof)) Then x = 1 y = 1 dx1 = ((nStartRec-1)\(nDisplayRecs*nRecRange))*nDisplayRecs*nRecRange+1 dy1 = ((nStartRec-1)\(nDisplayRecs*nRecRange))*nRecRange+1 If (dx1+nDisplayRecs*nRecRange-1) > nTotalRecs Then dx2 = (nTotalRecs\nDisplayRecs)*nDisplayRecs+1 dy2 = (nTotalRecs\nDisplayRecs)+1 Else dx2 = dx1+nDisplayRecs*nRecRange-1 dy2 = dy1+nRecRange-1 End If While x <= nTotalRecs If x >= dx1 And x <= dx2 Then If CLng(nStartRec) = CLng(x) Then %> <%=y%> <% Else %> <%=y%> <% End If x = x + nDisplayRecs y = y + 1 ElseIf x >= (dx1-nDisplayRecs*nRecRange) And x <= (dx2+nDisplayRecs*nRecRange) Then If x+nRecRange*nDisplayRecs < nTotalRecs Then %> <%=y%>-<%=y+nRecRange-1%> <% Else ny=(nTotalRecs-1)\nDisplayRecs+1 If ny = y Then %> <%=y%> <% Else %> <%=y%>-<%=ny%> <% End If End If x=x+nRecRange*nDisplayRecs y=y+nRecRange Else x=x+nRecRange*nDisplayRecs y=y+nRecRange End If Wend End If ' Next link If NOT rsEof Then NextStart = nStartRec + nDisplayRecs isMore = True %> Next <% Else isMore = False End If %>
<% End If If CLng(nStartRec) > CLng(nTotalRecs) Then nStartRec = nTotalRecs nStopRec = nStartRec + nDisplayRecs - 1 nRecCount = nTotalRecs - 1 If rsEof Then nRecCount = nTotalRecs If nStopRec > nRecCount Then nStopRec = nRecCount %> Hotels <%= nStartRec %> to <%= nStopRec %> of <%= nTotalRecs %> <% Else %> <% If (ewCurSec And ewAllowList) = ewAllowList Then %> <% If sSrchWhere = "0=101" Then %> <% Else %> No records found <% End If %> <% Else %> You do not have the right permission to view the page <% End If %> <% End If %>
<% '------------------------------------------------------------------------------- ' Function SetUpAdvancedSearch ' - Set up Advanced Search parameter based on querystring parameters from Advanced Search Page ' - Variables setup: sSrchAdvanced Sub SetUpAdvancedSearch() Dim arrFldOpr, arrFldOpr2, sSrchStr ' Field HotelName sSrchStr = "" x_HotelName = Request.QueryString("x_HotelName") z_HotelName = Request.QueryString("z_HotelName") arrFldOpr = Split(z_HotelName, ",") If x_HotelName <> "" And IsValidOpr(arrFldOpr) Then sSrchStr = sSrchStr & "`HotelName` " & arrFldOpr(0) & " " & _ arrFldOpr(1) & AdjustSql(x_HotelName) & arrFldOpr(2) End If If sSrchStr <> "" Then If sSrchAdvanced <> "" Then sSrchAdvanced = sSrchAdvanced & " AND " sSrchAdvanced = sSrchAdvanced & "(" & sSrchStr & ")" End If ' Field HotelCategory sSrchStr = "" x_HotelCategory = Request.QueryString("x_HotelCategory") z_HotelCategory = Request.QueryString("z_HotelCategory") arrFldOpr = Split(z_HotelCategory, ",") If x_HotelCategory <> "" And IsValidOpr(arrFldOpr) Then sSrchStr = sSrchStr & "`HotelCategory` " & arrFldOpr(0) & " " & _ arrFldOpr(1) & AdjustSql(x_HotelCategory) & arrFldOpr(2) End If If sSrchStr <> "" Then If sSrchAdvanced <> "" Then sSrchAdvanced = sSrchAdvanced & " AND " sSrchAdvanced = sSrchAdvanced & "(" & sSrchStr & ")" End If ' Field Governorate sSrchStr = "" x_Governorate = Request.QueryString("x_Governorate") z_Governorate = Request.QueryString("z_Governorate") arrFldOpr = Split(z_Governorate, ",") If x_Governorate <> "" And IsValidOpr(arrFldOpr) Then sSrchStr = sSrchStr & "`Governorate` " & arrFldOpr(0) & " " & _ arrFldOpr(1) & AdjustSql(x_Governorate) & arrFldOpr(2) End If If sSrchStr <> "" Then If sSrchAdvanced <> "" Then sSrchAdvanced = sSrchAdvanced & " AND " sSrchAdvanced = sSrchAdvanced & "(" & sSrchStr & ")" End If ' Field HotelFacilities sSrchStr = "" x_HotelFacilities = Request.QueryString("x_HotelFacilities") z_HotelFacilities = Request.QueryString("z_HotelFacilities") arrFldOpr = Split(z_HotelFacilities, ",") If x_HotelFacilities <> "" And IsValidOpr(arrFldOpr) Then sSrchStr = sSrchStr & "`HotelFacilities` " & arrFldOpr(0) & " " & _ arrFldOpr(1) & AdjustSql(x_HotelFacilities) & arrFldOpr(2) End If If sSrchStr <> "" Then If sSrchAdvanced <> "" Then sSrchAdvanced = sSrchAdvanced & " AND " sSrchAdvanced = sSrchAdvanced & "(" & sSrchStr & ")" End If ' Field RoomFacilities sSrchStr = "" x_RoomFacilities = Request.QueryString("x_RoomFacilities") z_RoomFacilities = Request.QueryString("z_RoomFacilities") arrFldOpr = Split(z_RoomFacilities, ",") If x_RoomFacilities <> "" And IsValidOpr(arrFldOpr) Then sSrchStr = sSrchStr & "`RoomFacilities` " & arrFldOpr(0) & " " & _ arrFldOpr(1) & AdjustSql(x_RoomFacilities) & arrFldOpr(2) End If If sSrchStr <> "" Then If sSrchAdvanced <> "" Then sSrchAdvanced = sSrchAdvanced & " AND " sSrchAdvanced = sSrchAdvanced & "(" & sSrchStr & ")" End If ' Field RoomCategory sSrchStr = "" x_RoomCategory = Request.QueryString("x_RoomCategory") z_RoomCategory = Request.QueryString("z_RoomCategory") arrFldOpr = Split(z_RoomCategory, ",") If x_RoomCategory <> "" And IsValidOpr(arrFldOpr) Then sSrchStr = sSrchStr & "`RoomCategory` " & arrFldOpr(0) & " " & _ arrFldOpr(1) & AdjustSql(x_RoomCategory) & arrFldOpr(2) End If If sSrchStr <> "" Then If sSrchAdvanced <> "" Then sSrchAdvanced = sSrchAdvanced & " AND " sSrchAdvanced = sSrchAdvanced & "(" & sSrchStr & ")" End If ' Field RoomFacilitiesCategory sSrchStr = "" x_RoomFacilitiesCategory = Request.QueryString("x_RoomFacilitiesCategory") z_RoomFacilitiesCategory = Request.QueryString("z_RoomFacilitiesCategory") arrFldOpr = Split(z_RoomFacilitiesCategory, ",") If x_RoomFacilitiesCategory <> "" And IsValidOpr(arrFldOpr) Then sSrchStr = sSrchStr & "`RoomFacilitiesCategory` " & arrFldOpr(0) & " " & _ arrFldOpr(1) & AdjustSql(x_RoomFacilitiesCategory) & arrFldOpr(2) End If If sSrchStr <> "" Then If sSrchAdvanced <> "" Then sSrchAdvanced = sSrchAdvanced & " AND " sSrchAdvanced = sSrchAdvanced & "(" & sSrchStr & ")" End If ' Field RoomFacilitiesSubcategory sSrchStr = "" x_RoomFacilitiesSubcategory = Request.QueryString("x_RoomFacilitiesSubcategory") z_RoomFacilitiesSubcategory = Request.QueryString("z_RoomFacilitiesSubcategory") arrFldOpr = Split(z_RoomFacilitiesSubcategory, ",") If x_RoomFacilitiesSubcategory <> "" And IsValidOpr(arrFldOpr) Then sSrchStr = sSrchStr & "`RoomFacilitiesSubcategory` " & arrFldOpr(0) & " " & _ arrFldOpr(1) & AdjustSql(x_RoomFacilitiesSubcategory) & arrFldOpr(2) End If If sSrchStr <> "" Then If sSrchAdvanced <> "" Then sSrchAdvanced = sSrchAdvanced & " AND " sSrchAdvanced = sSrchAdvanced & "(" & sSrchStr & ")" End If ' Field Featured sSrchStr = "" x_Featured = Request.QueryString("x_Featured") z_Featured = Request.QueryString("z_Featured") arrFldOpr = Split(z_Featured, ",") If x_Featured <> "" And IsValidOpr(arrFldOpr) Then sSrchStr = sSrchStr & "`Featured` " & arrFldOpr(0) & " " & _ arrFldOpr(1) & AdjustSql(x_Featured) & arrFldOpr(2) End If If sSrchStr <> "" Then If sSrchAdvanced <> "" Then sSrchAdvanced = sSrchAdvanced & " AND " sSrchAdvanced = sSrchAdvanced & "(" & sSrchStr & ")" End If If sSrchAdvanced <> "" Then ' save settings Session(ewSessionTblAdvSrch & "_x_HotelName") = x_HotelName Session(ewSessionTblAdvSrch & "_x_HotelCategory") = x_HotelCategory Session(ewSessionTblAdvSrch & "_x_Governorate") = x_Governorate Session(ewSessionTblAdvSrch & "_x_HotelFacilities") = x_HotelFacilities Session(ewSessionTblAdvSrch & "_x_RoomFacilities") = x_RoomFacilities Session(ewSessionTblAdvSrch & "_x_RoomCategory") = x_RoomCategory Session(ewSessionTblAdvSrch & "_x_RoomFacilitiesCategory") = x_RoomFacilitiesCategory Session(ewSessionTblAdvSrch & "_x_RoomFacilitiesSubcategory") = x_RoomFacilitiesSubcategory Session(ewSessionTblAdvSrch & "_x_Featured") = x_Featured End If End Sub ' Function to check if the search operators are valid Function IsValidOpr(arOpr) Dim Opr IsValidOpr = IsArray(arOpr) If IsValidOpr Then IsValidOpr = (UBound(arOpr) >= 2) If IsValidOpr Then For Each Opr In arOpr Opr = UCase(Trim(Opr)) If Not (Opr = "=" Or Opr = "<" Or Opr = "<=" Or _ Opr = ">" Or Opr = ">=" Or Opr = "<>" Or _ Opr = "LIKE" Or Opr = "NOT LIKE" Or Opr = "BETWEEN" Or _ Opr = "'" Or Opr = "'%" Or Opr = "%'" Or Opr = "#" Or Opr = "") Then IsValidOpr = False Exit For End If Next End If End Function '------------------------------------------------------------------------------- ' Function BasicSearchSQL ' - Build WHERE clause for a keyword Function BasicSearchSQL(Keyword) Dim sKeyword sKeyword = AdjustSql(Keyword) BasicSearchSQL = "" BasicSearchSQL = BasicSearchSQL & "`HotelName` LIKE '%" & sKeyword & "%' OR " BasicSearchSQL = BasicSearchSQL & "`HotelCategory` LIKE '%" & sKeyword & "%' OR " BasicSearchSQL = BasicSearchSQL & "`Governorate` LIKE '%" & sKeyword & "%' OR " BasicSearchSQL = BasicSearchSQL & "`NearbySightseeing` LIKE '%" & sKeyword & "%' OR " BasicSearchSQL = BasicSearchSQL & "`HotelFacilities` LIKE '%" & sKeyword & "%' OR " BasicSearchSQL = BasicSearchSQL & "`RoomFacilities` LIKE '%" & sKeyword & "%' OR " BasicSearchSQL = BasicSearchSQL & "`RoomCategory` LIKE '%" & sKeyword & "%' OR " BasicSearchSQL = BasicSearchSQL & "`RoomFacilitiesCategory` LIKE '%" & sKeyword & "%' OR " BasicSearchSQL = BasicSearchSQL & "`RoomFacilitiesSubcategory` LIKE '%" & sKeyword & "%' OR " BasicSearchSQL = BasicSearchSQL & "`Featured` LIKE '%" & sKeyword & "%' OR " If Right(BasicSearchSQL, 4) = " OR " Then BasicSearchSQL = Left(BasicSearchSQL, Len(BasicSearchSQL)-4) End Function '------------------------------------------------------------------------------- ' Function SetUpBasicSearch ' - Set up Basic Search parameter based on form elements pSearch & pSearchType ' - Variables setup: sSrchBasic Sub SetUpBasicSearch() Dim arKeyword, sKeyword psearch = Request.QueryString(ewTblBasicSrch) psearchtype = Request.QueryString(ewTblBasicSrchType) If psearch <> "" Then If psearchtype <> "" Then While InStr(psearch, " ") > 0 sSearch = Replace(psearch, " ", " ") Wend arKeyword = Split(Trim(psearch), " ") For Each sKeyword In arKeyword sSrchBasic = sSrchBasic & "(" & BasicSearchSQL(sKeyword) & ") " & psearchtype & " " Next Else sSrchBasic = BasicSearchSQL(psearch) End If End If If Right(sSrchBasic, 4) = " OR " Then sSrchBasic = Left(sSrchBasic, Len(sSrchBasic)-4) If Right(sSrchBasic, 5) = " AND " Then sSrchBasic = Left(sSrchBasic, Len(sSrchBasic)-5) If psearch <> "" then Session(ewSessionTblBasicSrch) = psearch Session(ewSessionTblBasicSrchType) = psearchtype End If End Sub '------------------------------------------------------------------------------- ' Function ResetSearch ' - Clear all search parameters ' Sub ResetSearch() ' Clear search where sSrchWhere = "" Session(ewSessionTblSearchWhere) = sSrchWhere ' Clear advanced search parameters Session(ewSessionTblAdvSrch & "_x_HotelName") = "" Session(ewSessionTblAdvSrch & "_x_HotelCategory") = "" Session(ewSessionTblAdvSrch & "_x_Governorate") = "" Session(ewSessionTblAdvSrch & "_x_HotelFacilities") = "" Session(ewSessionTblAdvSrch & "_x_RoomFacilities") = "" Session(ewSessionTblAdvSrch & "_x_RoomCategory") = "" Session(ewSessionTblAdvSrch & "_x_RoomFacilitiesCategory") = "" Session(ewSessionTblAdvSrch & "_x_RoomFacilitiesSubcategory") = "" Session(ewSessionTblAdvSrch & "_x_Featured") = "" Session(ewSessionTblBasicSrch) = "" Session(ewSessionTblBasicSrchType) = "" End Sub '------------------------------------------------------------------------------- ' Function RestoreSearch ' - Restore all search parameters ' Sub RestoreSearch() ' Restore advanced search settings x_HotelName = Session(ewSessionTblAdvSrch & "_x_HotelName") x_HotelCategory = Session(ewSessionTblAdvSrch & "_x_HotelCategory") x_Governorate = Session(ewSessionTblAdvSrch & "_x_Governorate") x_HotelFacilities = Session(ewSessionTblAdvSrch & "_x_HotelFacilities") x_RoomFacilities = Session(ewSessionTblAdvSrch & "_x_RoomFacilities") x_RoomCategory = Session(ewSessionTblAdvSrch & "_x_RoomCategory") x_RoomFacilitiesCategory = Session(ewSessionTblAdvSrch & "_x_RoomFacilitiesCategory") x_RoomFacilitiesSubcategory = Session(ewSessionTblAdvSrch & "_x_RoomFacilitiesSubcategory") x_Featured = Session(ewSessionTblAdvSrch & "_x_Featured") psearch = Session(ewSessionTblBasicSrch) psearchtype = Session(ewSessionTblBasicSrchType) End Sub '------------------------------------------------------------------------------- ' Function SetUpSortOrder ' - Set up Sort parameters based on Sort Links clicked ' - Variables setup: sOrderBy, Session(TblOrderBy), Session(Tbl_Field_Sort) Sub SetUpSortOrder() Dim sOrder, sSortField, sLastSort, sThisSort Dim bCtrl ' Check for an Order parameter If Request.QueryString("order").Count > 0 Then sOrder = Request.QueryString("order") ' Field `HotelName` If sOrder = "HotelName" Then sSortField = "`HotelName`" sLastSort = Session(ewSessionTblSort & "_x_HotelName") If sLastSort = "ASC" Then sThisSort = "DESC" Else sThisSort = "ASC" Session(ewSessionTblSort & "_x_HotelName") = sThisSort Else If Session(ewSessionTblSort & "_x_HotelName") <> "" Then Session(ewSessionTblSort & "_x_HotelName") = "" End If ' Field `HotelCategory` If sOrder = "HotelCategory" Then sSortField = "`HotelCategory`" sLastSort = Session(ewSessionTblSort & "_x_HotelCategory") If sLastSort = "ASC" Then sThisSort = "DESC" Else sThisSort = "ASC" Session(ewSessionTblSort & "_x_HotelCategory") = sThisSort Else If Session(ewSessionTblSort & "_x_HotelCategory") <> "" Then Session(ewSessionTblSort & "_x_HotelCategory") = "" End If ' Field `Governorate` If sOrder = "Governorate" Then sSortField = "`Governorate`" sLastSort = Session(ewSessionTblSort & "_x_Governorate") If sLastSort = "ASC" Then sThisSort = "DESC" Else sThisSort = "ASC" Session(ewSessionTblSort & "_x_Governorate") = sThisSort Else If Session(ewSessionTblSort & "_x_Governorate") <> "" Then Session(ewSessionTblSort & "_x_Governorate") = "" End If Session(ewSessionTblOrderBy) = sSortField & " " & sThisSort Session(ewSessionTblStartRec) = 1 End If sOrderBy = Session(ewSessionTblOrderBy) If sOrderBy = "" Then If ewSqlOrderBy <> "" And ewSqlOrderBySessions <> "" Then sOrderBy = ewSqlOrderBy Session(ewSessionTblOrderBy) = sOrderBy Dim arOrderBy, i arOrderBy = Split(ewSqlOrderBySessions, ",") For i = 0 to UBound(arOrderBy)\2 Session(ewSessionTblSort & "_" & arOrderBy(i*2)) = arOrderBy(i*2+1) Next End If End If End Sub '------------------------------------------------------------------------------- ' Function SetUpStartRec ' - Set up Starting Record parameters based on Pager Navigation ' - Variables setup: nStartRec Sub SetUpStartRec() Dim nPageNo ' Check for a START parameter If Request.QueryString(ewTblStartRec).Count > 0 Then nStartRec = Request.QueryString(ewTblStartRec) Session(ewSessionTblStartRec) = nStartRec ElseIf Request.QueryString("pageno").Count > 0 Then nPageNo = Request.QueryString("pageno") If IsNumeric(nPageNo) Then nStartRec = (nPageNo-1)*nDisplayRecs+1 If nStartRec <= 0 Then nStartRec = 1 ElseIf nStartRec >= ((nTotalRecs-1)\nDisplayRecs)*nDisplayRecs+1 Then nStartRec = ((nTotalRecs-1)\nDisplayRecs)*nDisplayRecs+1 End If Session(ewSessionTblStartRec) = nStartRec Else nStartRec = Session(ewSessionTblStartRec) End If Else nStartRec = Session(ewSessionTblStartRec) End If ' Check if correct start record counter If Not IsNumeric(nStartRec) Or nStartRec = "" Then ' Avoid invalid start record counter nStartRec = 1 ' Reset start record counter Session(ewSessionTblStartRec) = nStartRec ElseIf CLng(nStartRec) > CLng(nTotalRecs) Then ' Avoid starting record > total records nStartRec = ((nTotalRecs-1)\nDisplayRecs)*nDisplayRecs+1 ' point to last page first record Session(ewSessionTblStartRec) = nStartRec End If End Sub '------------------------------------------------------------------------------- ' Function ResetCmd ' - Clear list page parameters ' - RESET: reset search parameters ' - RESETALL: reset search & master/detail parameters ' - RESETSORT: reset sort parameters Sub ResetCmd() Dim sCmd ' Get Reset Cmd If Request.QueryString("cmd").Count > 0 Then sCmd = Request.QueryString("cmd") ' Reset Search Criteria If LCase(sCmd) = "reset" Then Call ResetSearch() ' Reset Search Criteria & Session Keys ElseIf LCase(sCmd) = "resetall" Then Call ResetSearch() ' Reset Sort Criteria ElseIf LCase(sCmd) = "resetsort" Then sOrderBy = "" Session(ewSessionTblOrderBy) = sOrderBy If Session(ewSessionTblSort & "_x_HotelName") <> "" Then Session(ewSessionTblSort & "_x_HotelName") = "" If Session(ewSessionTblSort & "_x_HotelCategory") <> "" Then Session(ewSessionTblSort & "_x_HotelCategory") = "" If Session(ewSessionTblSort & "_x_Governorate") <> "" Then Session(ewSessionTblSort & "_x_Governorate") = "" End If ' Reset Start Position (Reset Command) nStartRec = 1 Session(ewSessionTblStartRec) = nStartRec End If End Sub %>