%@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 Clients WHERE IDclient = ?"
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param1", 5, 1, -1, MM_IIF(Request.QueryString("IDclient"), Request.QueryString("IDclient"), null)) ' adDouble
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close
Response.Redirect("/Bookings/selectClient.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 Clients SET Cgroup = ?, Csection = ?, Cdistrict = ?, Ccounty = ?, Ccountry = ?, Ccontact = ?, Cjob = ?, Caddr1 = ?, Caddr2 = ?, Caddr3 = ?, Cpostcode = ?, Cphone = ?, Cmobile = ?, Cemail = ?, Cnote = ? WHERE IDclient = ?"
MM_editCmd.Prepared = true
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param1", 202, 1, 63, Request.Form("Cgroup")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param2", 202, 1, 63, Request.Form("Csection")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param3", 202, 1, 63, Request.Form("Cdistrict")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param4", 202, 1, 63, Request.Form("Ccounty")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param5", 202, 1, 63, Request.Form("Ccountry")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param6", 202, 1, 63, Request.Form("Ccontact")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param7", 202, 1, 63, Request.Form("Cjob")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param8", 202, 1, 63, Request.Form("Caddr1")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param9", 202, 1, 63, Request.Form("Caddr2")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param10", 202, 1, 63, Request.Form("Caddr3")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param11", 202, 1, 63, Request.Form("Cpostcode")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param12", 202, 1, 63, Request.Form("Cphone")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param13", 202, 1, 63, Request.Form("Cmobile")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param14", 202, 1, 63, Request.Form("Cemail")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param15", 202, 1, 255, Request.Form("Cnote")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param16", 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/selectClient.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 clients__MMColParam
clients__MMColParam = "1"
If (Request.QueryString("IDclient") <> "") Then
clients__MMColParam = Request.QueryString("IDclient")
End If
%>
<%
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 * FROM Clients WHERE IDclient = ?"
clients_cmd.Prepared = true
clients_cmd.Parameters.Append clients_cmd.CreateParameter("param1", 5, 1, -1, clients__MMColParam) ' adDouble
Set clients = clients_cmd.Execute
clients_numRows = 0
%>
<%
' Set Session IDclient to value selected 0 = new client request
Session("IDclient")=Request.Form("IDclient")
' test if Client already exists (>0) if so go and create a new Visit
' Otherwise create a New Client
if Request.Form("IDclient")>"0" then 'Go manage visit selected
Server.Transfer("/bookings/createVisit.asp")
end if
%>
Rhydd Covert Edit Client
Edit a Client
This page is to Edit and update the Clients Details.
Please check the client above is the correct one to edit.
The name displayed on the rest of the RATS system will be
"Group Section District"
You may wish to consider this when adding the above details.
<%
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)
If Not IsDate(x) Then Exit Function
USDate = "#" & Month(x) & "/" & Day(x) & "/" & Year(x) & "#"
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