HEX
Server: Microsoft-IIS/10.0
System: Windows NT ITPWINWEBSVR22 10.0 build 20348 (Windows Server 2022) AMD64
User: www.conferencesearch.co.uk (0)
PHP: 8.3.30
Disabled: NONE
Upload Files
File: D:/web archive/conferencesearch (old) (to delete)/bookdev/apputils2.asp
<%

' Additional App Utils for new Booking pages '
' ------------------------------------------ '
' (SS,31/8/06)'
' (SS,15/12/06) Added ConvertURLToHTML and ConvertToISONamedHTML to be W3C compliant
' (SS,21/05/07) Added Function RemoveHTMLTags
' (SS,3/3/09) Changed to GetPageName to capitalise "registration"
' (SS,29/7/09) various changes for new Conference Admin feature to show delegate list and allow bookings to be marked as paid

Function GetStylesheetName
	Dim LValue
	LValue = GetStyleValue("Style")
	If LValue = "" Then LValue = "Original"
	GetStylesheetName = LCase(LValue) + ".css"
End Function

Function GetHighlightColor
	GetHighlightColor = GetStyleValue("Highlight Colour") ' "#0167BB" '"#426BBA" '
End Function

Function GetBackgroundColor
	GetBackgroundColor = GetStyleValue("Background Colour") ' "#0167BB" '"#426BBA" '
End Function

Function GetStyleValue(AName)
	Dim LQuery

	' if value already stored in session then get it from session else from database

	If AName = "Style" Then
		LQuery = "style"
	ElseIf AName = "Highlight Colour" Then
	  LQuery = "hc"
	Else
		LQuery = "bc"
	End If

	If Request(LQuery) <> "" Then Session(LQuery) = Request(LQuery)

	If Session(LQuery) <> "" Then
		GetStyleValue = Session(LQuery)
	Else
	  Dim LConferenceID
	  LConferenceID = FConferenceID ' (SS,2/12/06) was = Request("id")
	  If LConferenceID = "" Then
	  	GetStyleValue = ""
		Else
	  	GetStyleValue = GetConferenceDetailField(LConferenceID, "Style", AName, "Text")
	  End If
	End If
End Function

Function GetText(AName)
  Dim LConferenceID
  LConferenceID = FConferenceID ' (SS,2/12/06) was = Request("id")

  If AName = "Title" Then
  	GetText = "Conference Search - Delegate Registration Form"
  Else
  	GetText = ""
  End If
  ' look up heading from conference details table '
  If LConferenceID <> "" Then
  	Dim LText
  	LText = GetConferenceDetailField(LConferenceID, "Text", AName, "Text")
  	If LText <> "" Then GetText = LText
  End If
End Function

Function GetPageName
  Dim LConferenceID
  LConferenceID = FConferenceID ' (SS,2/12/06) was = Request("id")

	GetPageName = ""
	Dim LPage
  LPage = Request("page")

  If LPage = "" And Request("did") <> "" Then LPage = "registration" ' (SS,2/12/06) force registration page when delegate id is passed

  OpenQuery("SELECT Name FROM conferencedetails WHERE ConferenceID = '" + LConferenceID + "' AND Type = 'Tabs' ORDER BY SortOrder, Name")

  ' default to first page '
  If LPage = "" Then
  	If Not EndOfQuery Then LPage = GetQueryValue("Name")
  Else
    ' look for proper page name (i.e. not lowercase and with spaces)
    Dim LName
		Do While Not EndOfQuery
			LName = GetQueryValue("Name")
			If LPage = LCase(ReplaceStr(LName, " ", "")) Then
			  LPage = LName
			  Exit Do
			End If
			NextQueryRecord
		Loop
  End If

  CloseQuery
  
  ' (SS,3/3/09) added following to ensure leading uppercase "R" as requested by Ruth
  If LPage = "registration" Then
  	LPage = "Registration"
  ' (SS,27/7/09) added conference admin
  ElseIf LCase(LPage) = "conferenceadmin" Then
  	' if op is "list" the "Delegate List" else "Mark as Paid"
  	If Request("op") = "list" Then
  		LPage = "Delegate List"
  	ElseIf Request("op") = "paid" Then
  		LPage = "Mark as Paid"
  	Else	
  		LPage = "Conference Admin"
  	End If
  End If

  GetPageName = LPage
End Function

Function GetMenu
  Dim LConferenceID
  LConferenceID = FConferenceID ' (SS,2/12/06) was = Request("id")
  GetMenu = ""
  If LConferenceID = "" Then Exit Function

  Dim LCurrentPage, LMenu, LMenuItem, LName, LPage
  LCurrentPage = GetPageName
	LMenu = ""
	OpenQuery("SELECT Name FROM conferencedetails WHERE ConferenceID = '" + LConferenceID + "' AND Type = 'Tabs' ORDER BY SortOrder, Name")
	Do While Not EndOfQuery
		LName = GetQueryValue("Name")
		LPage = LCase(ReplaceStr(LName, " ", ""))

		If LName = LCurrentPage Then
			LMenuItem = "<li class=""active"">"
		Else
			LMenuItem = "<li>"
		End If
		' (SS,15/12/06) replaced & with &amp; in following to ensure it passes the W3C HTML validation
		LMenuItem = LMenuItem + "<a href=""" & ConvertURLToHTML("index.asp?id=" + LConferenceID + "&page=" + LPage) + """>" + LName + "</a></li>" & CRLF

		LMenu = LMenu + LMenuItem
		NextQueryRecord
	Loop
	CloseQuery
	GetMenu = LMenu
End Function

' (SS,27/7/09) returns true if current page conference admin or registration form
Function FullWidthPage
	Dim LPage 
	LPage = LCase(Request("page"))
	FullWidthPage = IsConferenceAdminPage Or IsRegistrationForm
End Function

' (SS,27/7/09)
Function IsConferenceAdminPage
	IsConferenceAdminPage = LCase(Request("page")) = "conferenceadmin"
End Function

' (SS,27/7/09) returns true if there are pictures for current conference
Function ArePictures
	If FConferenceID = "" Then
		ArePictures = False
		Exit Function 
	End If
	ArePictures = GetValueFromQuery("TotalPictures", "SELECT COUNT(*) AS TotalPictures FROM conferencedetails WHERE ConferenceID = '" + CleanSQLStr(FConferenceID) + "' AND Type = 'Pictures'") > 0
End Function

Function GetPictures
  Dim LConferenceID
  LConferenceID = FConferenceID ' (SS,2/12/06) was = Request("id")
  GetPictures = ""
  If LConferenceID = "" Then Exit Function

  Dim LPictures, LPictureItem, LName, LURL
	LPictures = ""
	OpenQuery("SELECT ID, Name, Text FROM conferencedetails WHERE ConferenceID = '" + LConferenceID + "' AND Type = 'Pictures' ORDER BY SortOrder, Name")
	Do While Not EndOfQuery
		LName = GetQueryValue("Name")
		LURL = Trim(GetQueryValue("Text"))

		If LURL = "" Then
			LPictureItem = ""
		Else
			LPictureItem = "<a href=""" + LURL + """ target=""_blank"">"
		End If

		LPictureItem = LPictureItem + "<img src=""getpic.asp?id=" & GetQueryValue("ID") & """ alt=""" + Iif(LURL<>"",LURL,LName) + """>"

    If LURL <> "" Then LPictureItem = LPictureItem + "</a>"
		LPictureItem = LPictureItem + "<br>" & CRLF

		LPictures = LPictures + LPictureItem
		NextQueryRecord
	Loop
	CloseQuery
	GetPictures = LPictures

End Function

Function GetPageText
	Dim LPageName, LPageText
	LPageName = GetPageName
	LPageText = GetConferenceDetailField(FConferenceID, "Tabs", LPageName, "Text")
	LPageText = ReplaceWithLinks(LPageText)
	LPageText = ConvertToISONamedHTML(LPageText) ' (SS,15/12/06)
	GetPageText = LPageText
End Function

' (SS,15/12/06) converts the ampersand in given string to HTMP compatible
' i.e. to ensure it passes the W3C validation
Function ConvertURLToHTML(AURL)
  ConvertURLToHTML = Replace(AURL, "&", "&amp;")
End Function

' (SS,15/12/06) following converts given text into HTML W3C ISO etc standard
' currently just the 4 quote characters are converted
Function ConvertToISONamedHTML(AValue)
  ' following taken from http://theorem.ca/~mvcorks/code/charsets/named-entities.html
  '145  U+2018  &#x2018;  �  &lsquo;  �  left single quotation mark
  '146  U+2019  &#x2019;  �  &rsquo;  �  right single quotation mark
  '147  U+201C  &#x201C;  �  &ldquo;  �  left double quotation mark
  '148  U+201D  &#x201D;  �  &rdquo;  �  right double quotation mark
  Dim LValue
  LValue = AValue
  LValue = Replace(LValue, Chr(145), "&lsquo;")
  LValue = Replace(LValue, Chr(146), "&rsquo;")
  LValue = Replace(LValue, Chr(147), "&ldquo;")
  LValue = Replace(LValue, Chr(148), "&rdquo;")
  ConvertToISONamedHTML = LValue
End Function

' (SS,21/5/07) added to allow remove of tags for title
Function RemoveHTMLTags(AValue)
	Dim i, c, LLen, LNewValue, LInTag
	LLen = Len(AValue)
	LNewValue = ""
	LInTag = False
	For i = 1 to LLen
		c = Mid(AValue, i, 1)
		If c = "<" Then
			LInTag = True
		ElseIf c = ">" Then
			LInTag = False
		ElseIf Not LInTag Then
			LNewValue = LNewValue + c
		End If
	Next
	RemoveHTMLTags = LNewValue
End Function

Sub ShowPage
	Const CONTACTFORMTOKEN = "[CONTACTFORM]"
	Dim LPageText, LPos
	LPageText = GetPageText

	' check for contact form, if found then show the contact form or send the email
	LPos = Instr(LPageText, CONTACTFORMTOKEN)
	If LPos > 0 And Trim(FCSLEmailAddress) <> "" Then
		If Request("postcontactform") = "yes" Then
			Dim LName, LEmail, LTelephone, LEnquiry
			LName = Request("Name")
			LEmail = Request("Email")
			LTelephone = Request("Telephone")
			LEnquiry = Request("Enquiry")

			If LName <> "" And LEmail <> "" And LEnquiry <> "" Then
				Dim LBody
				LBody = ""
				LBody = LBody + "Name   : " + LName + CRLF
				LBody = LBody + "Email  : " + LEmail + CRLF
				LBody = LBody + "Tel    : " + LTelephone + CRLF
				LBody = LBody + "Enquiry: " + CRLF + LEnquiry
				SendEmail FCSLEmailAddress, "", LEmail, "Contact Form - " & FConferenceName, LBody, ""
			End If
			ShowContactFormThankYou
		Else
			ShowContactForm Mid(LPageText, 1, LPos - 1), Mid(LPageText, LPos + Len(CONTACTFORMTOKEN)), FCSLEmailAddress
		End If
	Else
		Response.Write(GetPageText)
	End If

	If FHasAccommodationLink Then SetUpAccommodationForm
End Sub

Function ReplaceWithLinks(AText)
	Dim LText
	LText = AText
	LText = Replace(LText, "[REGISTRATIONLINK]", GetRegistrationLink)

	If Instr(LText, "[ACCOMMODATIONLINK]") > 0 Then
		FHasAccommodationLink = True
		LText = Replace(LText, "[ACCOMMODATIONLINK]", GetAccommodationLink)
	Else
		FHasAccommodationLink = False
	End If

  If Instr(LText, "[ANOTHERBOOKINGLINK]") > 0 Then
  	FHasMakeAnotherBookingLink = True
  	LText = Replace(LText, "[ANOTHERBOOKINGLINK]", GetMakeAnotherBookingLink)
	Else
  	FHasMakeAnotherBookingLink = False
  End If

  LText = Replace(LText, "[ACCOMMODATIONLINK2]", GetAccommodationLink2)
  LText = Replace(LText, "[PAYSLIPLINK]", GetPaySlipLink)
  LText = Replace(LText, "[PAYPALLINK]", GetPayPalLink)
  LText = Replace(LText, "[CHEQUEBANKTRANSFERLINK]", GetChequeBankTransferLink)
  ReplaceWithLinks = LText
End Function

Function GetRegistrationLink
	GetRegistrationLink = "<a href=""" + GetRegistrationFormLink(False) + """>Click here to register now</a>"
End Function

Function GetAccommodationLink
	GetAccommodationLink = "<a href=""javascript:document.frmAccommodation.submit()"">Click here to book accommodation</a>"
End Function

Function GetAccommodationLinkNoHref
	GetAccommodationLinkNoHref = Trim(GetConferenceDetailField(FConferenceID, "Text", "Accommodation Link", "Text"))
End Function

Function GetAccommodationLink2
	GetAccommodationLink2 = "<a href=""" & Trim(GetConferenceDetailField(FConferenceID, "Text", "Accommodation Link 2", "Text")) & """>Click here to book accommodation</a>"
End Function

Function GetMakeAnotherBookingLink
	GetMakeAnotherBookingLink = "<a href=""javascript:document.frmAnother.submit()"">Click here to make another booking</a>"
End Function

Function GetMakeAnotherBookingLinkNoHref
	GetMakeAnotherBookingLinkNoHref = GetRegistrationFormLink(True)
End Function

Function GetPaySlipLink
	GetPaySlipLink = "<a href=""order-print.asp?sid=" & Session.SessionID & "&order=" & FDelegateID & """ target=""_blank"">Click here to Print Payment slip</a>"
End Function

Function GetPayPalLink
	GetPayPalLink = "<a href=""javascript:document.frmPayPal.submit()"">Click here to Pay by Credit Card using PayPal</a>"
End Function

Function GetChequeBankTransferLink
	GetChequeBankTransferLink = "<a href=""" + GetRegistrationFormLink(False) + "&pm=cbt" + """>Click here to Pay by Cheque or Bank Transfer</a>"
End Function

' returns given field, blank if not found '
Function GetConferenceDetailField(AConferenceID, AType, AName, AFieldName)
  OpenQuery("SELECT " + AFieldName + " FROM conferencedetails WHERE ConferenceID = '" + AConferenceID + "' AND Type = '" + AType + "' AND Name = '" + AName + "'")
  If Not EndOfQuery Then
	GetConferenceDetailField = GetQueryValue(AFieldName)
  Else
  	GetConferenceDetailField = ""
  End If
  CloseQuery
End Function

Function TabsDefined
  OpenQuery("SELECT ID FROM conferencedetails WHERE ConferenceID = '" + FConferenceID + "' AND Type = 'Tabs'")
  TabsDefined = Not EndOfQuery
  CloseQuery
End Function

Function IsNewVersion
  ' (SS,24/10/06) removed And Request("page") <> "" because in case it's used on first page
	IsNewVersion = IsRegistrationForm ' And Request("page") <> ""
End Function

Function IsRegistrationForm
	' (SS,2/12/06) added Or Request("did")
  IsRegistrationForm = Request("cmd") = "form" Or Request("did") <> ""
End Function

Function GetBankTransferChequeConfirmation
	GetBankTransferChequeConfirmation = ReplaceWithLinks(GetConferenceDetailField(FConferenceID, "Text", "Bank Trans/Chq Confirm", "Text"))
End Function

Function GetPayPalConfirmation
	GetPayPalConfirmation = ReplaceWithLinks(GetConferenceDetailField(FConferenceID, "Text", "PayPal Confirm", "Text"))
End Function

Function GetPayPalCancelMessage
	GetPayPalCancelMessage = ReplaceWithLinks(GetConferenceDetailField(FConferenceID, "Text", "PayPal Cancel", "Text"))
End Function

Sub SetUpAccommodationForm
%>
<form name = "frmAccommodation" action="<%=GetAccommodationLinkNoHref%>" method="post" class="nospace">
<input type="hidden" name="Title"         value="<%=Session("Title")%>">
<input type="hidden" name="FirstName"     value="<%=Session("FirstName")%>">
<input type="hidden" name="Surname"       value="<%=Session("Surname")%>">
<input type="hidden" name="Organisation"  value="<%=Session("Organisation")%>">
<input type="hidden" name="Address1"  		value="<%=Session("AddressLine1")%>">
<input type="hidden" name="Address2"  		value="<%=Session("AddressLine2")%>">
<input type="hidden" name="Address3"  		value="<%=Session("Town")%>">
<input type="hidden" name="Address4"  		value="<%=Session("County")%>">
<input type="hidden" name="Postcode"  		value="<%=Session("Postcode")%>">
<input type="hidden" name="Country"  			value="<%=Session("Country")%>">
<input type="hidden" name="Telephone"  		value="<%=Session("Telephone")%>">
<input type="hidden" name="Email"  				value="<%=Session("Email")%>">
<input type="hidden" name="EmailConfirm"  value="<%=Session("Email")%>">
</form>
<%
End Sub

Sub SetUpMakeAnotherBookingForm
' (SS,8/10/14) added Email and RetypeEmail
%>
<form name = "frmAnother" action="<%=GetMakeAnotherBookingLinkNoHref%>" method="post" class="nospace">
<input type="hidden" name="Organisation"  value="<%=Session("Organisation")%>">
<input type="hidden" name="AddressLine1"  value="<%=Session("AddressLine1")%>">
<input type="hidden" name="AddressLine2"  value="<%=Session("AddressLine2")%>">
<input type="hidden" name="Town"  				value="<%=Session("Town")%>">
<input type="hidden" name="County"  			value="<%=Session("County")%>">
<input type="hidden" name="Postcode"  		value="<%=Session("Postcode")%>">
<input type="hidden" name="Country"  			value="<%=Session("Country")%>">
<input type="hidden" name="Telephone"  		value="<%=Session("Telephone")%>">
<input type="hidden" name="Email"  				value="<%=Session("Email")%>">
<input type="hidden" name="RetypeEmail"   value="<%=Session("Email")%>">
</form>
<%
End Sub


' (SS,27/7/09) only conference admin person will be using this section
Sub ConferenceAdmin
	' save the password if supplied
	If Request("pw") <> "" Then
		Session("ConferencePassword") = Request("pw") ' save in session only conference admin person will be using this section
	End If
	Dim LPassword
	LPassword = GetValueFromQuery("Password", "SELECT Password FROM conferences WHERE ConferenceID = '" & CleanSQLStr(FConferenceID) & "'")
	If LPassword = "" Then
		Response.Write("Sorry, conference admin not allowed because no password is set for this conference")
	ElseIf LPassword <> Session("ConferencePassword") Then	
		DoGetPassword
	Else ' display menu, the list or mark as paid
		Dim LOperation
		LOperation = Request("op") 
		If LOperation = "" Then
			ShowConferenceAdminMenu
		ElseIf LOperation = "list" Then
			ShowDelegateList
		ElseIf LOperation = "paid" Then
			MarkDelegateAsPaid
		End If					
	End If
End Sub

' (SS,27/7/09) 
Sub ShowDelegateList
	ShowDelegateListHeader
	Dim LDateBooked
	OpenQuery("SELECT d.* FROM delegates d INNER JOIN venues v ON v.VenueID = d.VenueID WHERE v.ConferenceID = '" & CleanSQLStr(FConferenceID) & "' ORDER BY VenueID, DelegateID")
	Do While Not EndOfQuery			
		' following line takes just the date part of date/time
		LDateBooked = GetQueryField("DateTimeBooked")
		LDateBooked = Right("0" & DatePart("d", LDateBooked), 2) & "/" & Right("0" & DatePart("m", LDateBooked), 2) & "/" & DatePart("yyyy", LDateBooked)
		ShowDelegateListItem GetQueryField("DelegateID"), LDateBooked, GetQueryField("Title"), GetQueryField("FirstName"), GetQueryField("Surname"), GetQueryField("Organisation"), GetQueryField("AmountCharged"), GetQueryField("Status") 
		NextQueryRecord
	Loop	
	CloseQuery
	ShowDelegateListFooter
End Sub

' (SS,27/7/09)
Sub MarkDelegateAsPaid
	Dim LErrorMessage, LDelegateID, LShowGetDelegateID, LShowDelegateDetails, LDoMarkAsPaid
	
	LErrorMessage = ""
	LShowGetDelegateID = True
	LShowDelegateDetails = False
	LDoMarkAsPaid = False
	LDelegateID = Trim(Request("didforpaid"))
	If LDelegateID <> "" Then
		If IsValidDelegateForConference(LDelegateID) Then
			If Request("submit") = "Mark as Paid" Then
				LDoMarkAsPaid = True
			Else
				LShowDelegateDetails = True				
			End If
			LShowGetDelegateID = False
		Else
			LErrorMessage = "No such Delegate ID record exists"
		End If
	End If
	
	If LDoMarkAsPaid Then
		UpdateOrderStatusForOrderPlaced LDelegateID, STATUS_PAID, "Other", "Via Conference Admin"
		ShowMarkAsPaidConfirmation LDelegateID
	ElseIf LShowGetDelegateID Then
		ShowMarkAsPaidGetDelegateID LErrorMessage
	ElseIf LShowDelegateDetails Then
		Dim LAddress
		OpenQuery("SELECT * FROM delegates WHERE DelegateID = '" & CleanSQLStr(LDelegateID) & "'")
		If Not EndOfQuery	Then	
			ShowMarkAsPaidDelegateDetails GetQueryField("DelegateID"), Trim(GetQueryField("Title") + " " + GetQueryField("FirstName") + " " + GetQueryField("Surname")), GetQueryField("AddressLine1"), GetQueryField("AddressLine2"), GetQueryField("Town"), GetQueryField("County"), GetQueryField("Postcode"), GetQueryField("Country"), GetQueryField("Email"), GetQueryField("AmountCharged"), GetQueryField("Status") 
		End If	
		CloseQuery
	End If
End Sub

' (SS,27/7/09) returns true if given delegate id is valid for current conference
Function IsValidDelegateForConference(ADelegateID)
	IsValidDelegateForConference = NB(GetValueFromQuery("DelegateID", "SELECT d.DelegateID FROM delegates d INNER JOIN venues v ON v.VenueID = d.VenueID WHERE v.ConferenceID = '" & CleanSQLStr(FConferenceID) & "' AND d.DelegateID = '" & ADelegateID & "'")) <> ""
End Function
%>