<%@ Language=VBScript %> <% '************************************************************************* ' DO NOT MODIFY THIS SCRIPT IF YOU WANT UPDATES TO WORK! ' Function : Order Discount Maintenance ' Product : CandyPress Store Administration ' Version : 2.5 ' Modified : February 2004 ' Copyright: Copyright (C) 2004 CandyPress.Com ' See "license.txt" for this product for details regarding ' licensing, usage, disclaimers, distribution and general ' copyright requirements. If you don't have a copy of this ' file, you may request one at webmaster@candypress.com '************************************************************************* Option explicit Response.Buffer = true const adminLevel = 1 %> <% 'Database dim mySQL, cn, rs 'DiscOrder dim idDiscOrder dim discCode dim discPerc dim discAmt dim discFromAmt dim discToAmt dim discStatus dim discOnceOnly dim discValidFrom dim discValidTo 'Work Fields dim I dim action '************************************************************************* 'Open Database Connection call openDB() 'Store Configuration if loadConfig() = false then response.redirect "sysMsg.asp?errMsg=" & server.URLEncode("Could not load Store Configuration settings.") end if %>

Order Discount Maintenance

<% 'Get action action = trim(Request.QueryString("action")) if len(action) = 0 then action = trim(Request.Form("action")) end if action = lCase(action) if action <> "edit" and action <> "add" then response.redirect "sysMsg.asp?errMsg=" & server.URLEncode("Invalid Action Indicator.") end if 'Get idDiscOrder if action = "edit" then idDiscOrder = trim(Request.QueryString("recId")) if len(idDiscOrder) = 0 then idDiscOrder = trim(Request.Form("recId")) end if if idDiscOrder = "" or not isNumeric(idDiscOrder) then response.redirect "sysMsg.asp?errMsg=" & server.URLEncode("Invalid Record ID.") end if end if 'Get Order Discount Record if action = "edit" then mySQL="SELECT idDiscOrder,discCode,discPerc,discAmt," _ & " discFromAmt,discToAmt,discStatus," _ & " discOnceOnly,discValidFrom,discValidTo " _ & "FROM DiscOrder " _ & "WHERE idDiscOrder = " & idDiscOrder set rs = openRSexecute(mySQL) if rs.eof then response.redirect "sysMsg.asp?errMsg=" & server.URLEncode("Invalid Record ID.") else discCode = rs("discCode") discPerc = rs("discPerc") discAmt = rs("discAmt") discFromAmt = rs("discFromAmt") discToAmt = rs("discToAmt") discStatus = rs("discStatus") discOnceOnly = rs("discOnceOnly") discValidFrom = rs("discValidFrom") discValidTo = rs("discValidTo") end if call closeRS(rs) end if 'Edit if action = "edit" then if len(trim(Request.QueryString("msg"))) > 0 then %> <%=Request.QueryString("msg")%>

<% end if %> Edit Order Discount  <%call maintNavLinks()%>

Discount Code
Order Amount From
Order Amount To
Discount Percentage %
Discount Amount
Status
Use Once Only?
Date Valid From <%call dateSelect("F",discValidFrom)%>
Date Valid To <%call dateSelect("T",discValidTo)%>



<% end if 'Add if action = "add" then %> Add Order Discount  <%call maintNavLinks()%>

Discount Code
Order Amount From
Order Amount To
Discount Percentage %
Discount Amount
Status
Use Once Only?
Date Valid From <%call dateSelect("F","")%>
Date Valid To <%call dateSelect("T","")%>



<% end if if action = "edit" or action = "add" then %>
Help and Instructions :
Discount Code - Mandatory. Unique alpha-numeric code that will be entered by the customer to qualify for a discount. Don't use any special characters or spaces.

Order Amount From - Mandatory. The minimum total order amount (excluding taxes and shipping) required to qualify for the discount.

Order Amount To - Mandatory. The maximum total order amount (excluding taxes and shipping) required to qualify for the discount.

Discount Percentage - Optional if Discount Amount is entered. The percentage of the the total order amount (excluding taxes and shipping) that will be deducted from the order total.

Discount Amount - Optional if Discount Percentage is entered. The amount of the the total order amount (excluding taxes and shipping) that will be deducted from the order total.

Status - Mandatory. A discount has to be "Active" to be available for use. To prevent a discount from being used, set this to "InActive" or "Used". Discounts that can only be used once (see below), will automatically be set to "Used".

Use Once Only? - Mandatory. If set to "Yes", the system will automatically update the status to "Used" after the first time the discount has been applied by any customer.

Date Valid From - Mandatory. The date from which the discount will be valid (DD/MM/YYYY).

Date Valid To - Mandatory. The date from which the discount will no longer be valid (DD/MM/YYYY).

<% end if call closedb() %> <% '********************************************************************* 'Create Navigation Links '********************************************************************* sub maintNavLinks() %> [ List Discounts ] <% end sub '********************************************************************* 'Create Date Drop Down boxes '********************************************************************* sub dateSelect(FromOrTo,strDate) 'Declare some variables local to this subroutine dim strY, strM, strD 'Validate From / To indicator FromOrTo = UCase(trim(FromOrTo)) if FromOrTo <> "F" and FromOrTo <> "T" then response.redirect "sysMsg.asp?errMsg=" & server.URLEncode("Invalid From/To Indicator passed to date routine.") end if if FromOrTo = "T" then FromOrTo = "To" else FromOrTo = "From" end if 'Get date parameter and extract Y, M and D. 'Default to today's date if invalid or empty. if len(strDate) = 8 and isNumeric(strDate) then strY = mid(strDate,1,4) strM = mid(strDate,5,2) strD = mid(strDate,7,2) else strY = year(now()) strM = left("00",2-len(datePart("m",now()))) & datePart("m",now()) strD = left("00",2-len(datePart("d",now()))) & datePart("d",now()) end if %> / / <% end sub %>