<!--#include file="../../owFunctions/I_GeneralFunctions.asp"-->
<%sPath = "../"%>
<!--#include file="../../owTemplates/Template_AllLeft.asp"-->
<%
	'************************************************************************************
	'*																					*
	'*	MODIFICATION TO THIS SCRIPT OR ANY FILES INCLUDED WITH 							*
	'*		ONEWORLDSTORE IS DONE AT YOUR OWN RISK!										*
	'*	Product  : OneWorldStore														*
	'*	Version  : 9.0000																*
	'*	Modified : June 2004															*
	'*	Copyright:	Copyright (C) 2004 OneWorldStore.Com								*
	'*				Registration Number: 1024507										*
	'*				http://strategis.ic.gc.ca/											*
	'*																					*
	'************************************************************************************

	
	'************************************************************************************
	'*																					*
	'*																					*
	'*																					*
	'************************************************************************************
	Sub ActionSubroutine()

		if ( NOT bHasAccount ) then
			response.redirect "../owCustomerAuthenticate.asp"
		Else
			sIDOrder = CONVERSION_SQLEncode2(request("idOrder"),12)
			if sIDOrder = "" then 
				Call owMessage(LANG_DT( "CANCEL_MISSINGORDER", "Unable to find the requested order." ), C_ERROR)
			Else
				sSQLText = "SELECT AccountUnq, orderStatus, OriginalCreditPmt, CurrentCreditOwed FROM orders WHERE idOrder=" & sIDOrder
				Call DB_getFromDatabase(sSQLText, rsStoreData, "")
				if iLoginAccountUnq <> CDbl(Trim(rsStoreData("AccountUnq"))) then 
					Call owMessage(LANG_DT( "CANCEL_NONMATCHINGACCOUNT", "Unable to find a matching order for your account." ), C_ERROR)
				Else
					If ( CInt(Trim(rsStoreData("orderStatus"))) <> C_PENDING ) Then 
						' only pending orders can be cancelled
						Call owMessage(LANG_DT( "CANCEL_NOTPENDING", "Unfortunately, due to the fact that this order is not in ""Pending"" status, it cannot be cancelled." ), C_ERROR)
					Else
					
						sSQLText = "UPDATE orders SET orderStatus=" & C_CANCELLED & " WHERE idOrder=" & sIDOrder
						call DB_updateDatabase(sSQLText)
						
						sEmailBody	= LANG_DT( "CANCEL_EMAIL1", "This order has been cancelled by the customer." ) & VbCrlf
						sEmailBody	= sEmailBody & LANG_DT( "CANCEL_EMAIL2", "Please visit your store manager if you wish to review the cancelled order information." ) & VbCrlf & VbCrlf
						sEmailBody	= sEmailBody & LANG_DT( "CANCEL_EMAIL3", "Powered by OneWorldStore" ) & VbCrlf
						sEmailBody	= sEmailBody & LANG_DT( "CANCEL_EMAIL4", "http://www.OneWorldStore.com" )
						
						sSubject	= LANG_DT( "CANCEL_EMAILSUBJECT", "Cancelled Order #" ) & sOWOrderPrefix & sIDOrder
						
						call sendmail (sOWCompany, sOWEmailSender, sOWEmailAdmin, sSubject, sEmailBody)

						Call owMessage(LANG_DT( "CANCEL_CONFIRM", "Your selected order was cancelled." ), C_SUCCESS)
					End If
				End If
				Call DB_closeRecordset(rsStoreData)
			End If
		End If

	End Sub
	'************************************************************************************
%>