<!--#include file="./includes/sql.asp"-->
<!--#include file="./includes/validation.asp"-->
<!--#include file="./includes/error_handler.asp"-->
<!--#include file="./includes/db_helpers.asp"-->
<%
	' Initialize error handling
	Call InitializeErrorHandling("deactivatenotification.asp")

	' Get notificationid
	Dim notificationid
	notificationid = Trim(Request.Querystring("notificationid"))

	' Validate notificationid
	If Not ValidateID(notificationid) Then
		Call HandleValidationError("displaynotifications.asp", "INVALID_ID")
	End If

	' Verify the notification exists
	If Not RecordExists(objConn, "notifications", "notificationid", notificationid) Then
		Call HandleValidationError("displaynotifications.asp", "NOT_FOUND")
	End If

	' Deactivate using parameterized query and set endtime to NOW()
	Dim strSQL, recordsAffected
	strSQL = "UPDATE notifications SET isactive = 0, endtime = NOW() WHERE notificationid = ?"
	recordsAffected = ExecuteParameterizedUpdate(objConn, strSQL, Array(notificationid))

	' Cleanup and redirect
	Call CleanupResources()

	Response.Redirect("displaynotifications.asp")
%>
