%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%
' *** Restrict Access To Page: Grant or deny access to this page
MM_authorizedUsers="userEdit,bookEdit,webmaster"
MM_authFailedURL="/Bookings/Secure/sorryAccess.asp"
MM_grantAccess=false
If Session("MM_Username") <> "" Then
If (false Or CStr(Session("MM_UserAuthorization"))="") Or _
(InStr(1,MM_authorizedUsers,Session("MM_UserAuthorization"))>=1) Then
MM_grantAccess = true
End If
End If
If Not MM_grantAccess Then
MM_qsChar = "?"
If (InStr(1,MM_authFailedURL,"?") >= 1) Then MM_qsChar = "&"
MM_referrer = Request.ServerVariables("URL")
if (Len(Request.QueryString()) > 0) Then MM_referrer = MM_referrer & "?" & Request.QueryString()
MM_authFailedURL = MM_authFailedURL & MM_qsChar & "accessdenied=" & Server.URLEncode(MM_referrer)
Response.Redirect(MM_authFailedURL)
End If
%>
<%
Dim MM_editAction
MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))
If (Request.QueryString <> "") Then
MM_editAction = MM_editAction & "?" & Server.HTMLEncode(Request.QueryString)
End If
' boolean to abort record edit
Dim MM_abortEdit
MM_abortEdit = false
%>
<%
' IIf implementation
Function MM_IIf(condition, ifTrue, ifFalse)
If condition = "" Then
MM_IIf = ifFalse
Else
MM_IIf = ifTrue
End If
End Function
%>
<%
' *** Delete Record: construct a sql delete statement and execute it
If (CStr(Request("MM_delete")) = "form2") Then
If (Not MM_abortEdit) Then
' execute the delete
Set MM_editCmd = Server.CreateObject ("ADODB.Command")
MM_editCmd.ActiveConnection = MM_trevs_STRING
MM_editCmd.CommandText = "DELETE * FROM Visits WHERE IDvisit = ?"
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param1", 5, 1, -1, MM_IIF(Request.QueryString("IDvisit"), Request.QueryString("IDvisit"), null)) ' adDouble
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close
Response.Redirect("/Bookings/selectVisit.asp")
End If
End If
%>
<%
If (CStr(Request("MM_update")) = "form1") Then
If (Not MM_abortEdit) Then
' execute the update
Dim MM_editCmd
Set MM_editCmd = Server.CreateObject ("ADODB.Command")
MM_editCmd.ActiveConnection = MM_trevs_STRING
MM_editCmd.CommandText = "UPDATE Visits SET IDclient = ?, Vname = ?, Vnote = ?, VdateFrom = ?, VdateTo = ?, LastEditUserID = ? WHERE IDvisit = ?"
MM_editCmd.Prepared = true
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param1", 5, 1, -1, MM_IIF(Request.Form("IDclient"), Request.Form("IDclient"), null)) ' adDouble
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param2", 202, 1, 31, Request.Form("Vname")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param3", 202, 1, 255, Request.Form("Vnote")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param4", 135, 1, -1, MM_IIF(Request.Form("VFrom"), Request.Form("VFrom"), null)) ' adDBTimeStamp
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param5", 135, 1, -1, MM_IIF(Request.Form("VTo"), Request.Form("VTo"), null)) ' adDBTimeStamp
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param3", 202, 1, 255, Session("MM_Username")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param6", 5, 1, -1, MM_IIF(Request.Form("MM_recordId"), Request.Form("MM_recordId"), null)) ' adDouble
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close
' append the query string to the redirect URL
' Dim MM_editRedirectUrl
' MM_editRedirectUrl = "/Bookings/editVisit.asp"
' If (Request.QueryString <> "") Then
' If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0) Then
' MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
' Else
' MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
' End If
' End If
' Response.Redirect(MM_editRedirectUrl)
End If
End If
%>
<%
Dim visit__MMColParam
visit__MMColParam = "44"
If (Request.QueryString("IDvisit") <> "") Then
visit__MMColParam = Request.QueryString("IDvisit")
End If
%>
<%
Dim visit
Dim visit_cmd
Dim visit_numRows
Set visit_cmd = Server.CreateObject ("ADODB.Command")
visit_cmd.ActiveConnection = MM_trevs_STRING
visit_cmd.CommandText = "SELECT * FROM VisitsQuery WHERE IDvisit = ?"
visit_cmd.Prepared = true
visit_cmd.Parameters.Append visit_cmd.CreateParameter("param1", 5, 1, -1, visit__MMColParam) ' adDouble
Set visit = visit_cmd.Execute
visit_numRows = 0
%>
<%
Dim clients
Dim clients_cmd
Dim clients_numRows
Set clients_cmd = Server.CreateObject ("ADODB.Command")
clients_cmd.ActiveConnection = MM_trevs_STRING
clients_cmd.CommandText = "SELECT client, IDclient FROM ClientsQuery ORDER BY client ASC"
clients_cmd.Prepared = true
Set clients = clients_cmd.Execute
clients_numRows = 0
%>
<%
'Edit Visit - IDvisit passed from Form (method=GET)
Session("IDvisit") = Request.QueryString("IDvisit")
%>
Note: This page edits visit details - NOT client details.
If changing the dates or times of a visit you will need to check
if
the dates and times of any bookings need amending as well.
Deleting a visit is not reversable and will result in all associated
bookings for that visit also being deleted. Please use with caution.
<%
visit.Close()
Set visit = Nothing
%>
<%
clients.Close()
Set clients = Nothing
%>
<% 'Returns the date formatted to Medium length ie "27 Jun 57"
function dateMed(dt)
dateMed=Day(dt)
dateMed=dateMed & " " & MonthNAme(Month(dt),true)
dateMed=dateMed & " " & Right(Year(dt),2)
end function
%>
<%
Function USDate(x) 'swop date format UK to USA for SQL use
If Not IsDate(x) Then Exit Function
USDate = Month(x) & "/" & Day(x) & "/" & Year(x) & " "
If Hour(x)<10 then
USDate = USDate & "0" & Hour(x) & ":"
else
USDate = USDate & Hour(x) & ":"
end if
If Minute(x)<10 then
USDate = USDate & "0" & Minute(x)
else
USDate = USDate & Minute(x)
end if
End Function
%>
<%
Function shortYr(x) 'swop date format dd/mm/yyyy to dd/mm/yy for display
If Not IsDate(x) Then Exit Function
shortYr = Day(x) & "/" & Month(x) & "/" & Right(Year(x),2)
End Function
%>
<% 'Returns random password (alpha numeric) length = Count
Function R_Pswd(count)
Dim i, pwstr
pwstr = "ABCDEFGHKMNPQRSTUVWXYZ23456789" 'Char to choose pswd from
Randomize
R_Pswd = Mid(pwstr,Int(Rnd()*22+1),1) '1st Char = alpha
i=1
do while i