<%@ LANGUAGE="VBSCRIPT" %> <% PageStrings = "32, 359, 401, 697, 801, 802, 803, 804, 805, 806, 807, 808, 1116" strThisBackPage = "orders" %> <% '=============================================== ' CactuShop ASP Shopping Cart ' ©1999-2004 Cactusoft Ltd. www.cactusoft.com '=============================================== ' All rights reserved. ' Use of this code is covered by the terms and ' conditions in the license agreement. No ' unauthorized duplication or distribution is ' permitted. Cactusoft's copyright notices must ' remain in the ASP sections of the code. '=============================================== '----------------------------------------------- 'UPDATE COUPONS 'Creates coupons '----------------------------------------------- CP_DiscountValue = request.form("CP_DiscountValue") numQuantity = request.form("numQuantity") CP_Reusable = request.form("CP_Reusable") CP_DiscountType = request.form("CP_DiscountType") startday = request.form("startday") startmonth = request.form("startmonth") startyear = request.form("startyear") endday = request.form("endday") endmonth = request.form("endmonth") endyear = request.form("endyear") CP_StartDate = startyear & "/" & startmonth & "/" & startday CP_EndDate = endyear & "/" & endmonth & "/" & endday If CP_EndDate = "-/-/-" then CP_EndDate = "2050/12/31" 'EXPIRY IN 50 YEARS OR SO SHOULD IS VIRTUALLY NO EXPIRY! '----------------------------------------------- 'ERROR CHECKING '----------------------------------------------- If Not IsDate(CP_StartDate) then numErrorNo = numErrorNo + 1 strErrorText = strErrorText + "" & Cstr(numErrorNo) & ". " & GetString("FormLabel_StartDate") & " " & GetString("ContentText_NotValidDate") & "
" Else CP_StartDate = CDate(CP_StartDate) End if If Not IsDate(CP_EndDate) then numErrorNo = numErrorNo + 1 strErrorText = strErrorText + "" & Cstr(numErrorNo) & ". " & GetString("FormLabel_EndDate") & " " & GetString("ContentText_NotValidDate") & "
" Else CP_EndDate = CDate(CP_EndDate) End if 'Check the end date isn't before the start date If IsDate(CP_EndDate) And IsDate(CP_StartDate) Then If CP_EndDate < CP_StartDate Then numErrorNo = numErrorNo + 1 strErrorText = strErrorText & "" & CStr(numErrorNo) & ". " & GetString("FormLabel_EndDate") & " " & GetString("ContentText_NotValidEndDate") & "
" End If End If If Not IsNumeric(CP_DiscountValue) then numErrorNo = numErrorNo + 1 strErrorText = strErrorText + "" & Cstr(numErrorNo) & ". " & GetString("FormLabel_CouponValue") & " " & GetString("ContentText_NotNumeric") & "
" ElseIf CP_DiscountValue > 100 then If CP_DiscountType = "p" then CP_DiscountValue = 100 end if End if If Not IsNumeric(numQuantity) then numErrorNo = numErrorNo + 1 strErrorText = strErrorText + "" & Cstr(numErrorNo) & ". " & GetString("FormLabel_CouponQuantity") & " " & GetString("ContentText_NotNumeric") & "
" End if %> <% =GetString("Config_headtitle") %>
<% If numErrorNo = 0 then '----------------------------------------------- 'GENERATE THE COUPON RECORDS '----------------------------------------------- CP_CreatedTime = ReverseFormatYear(now()) If strDatabaseType = "mysql" Then strQuery = "SELECT CP_ID FROM tblCactuShopCoupons ORDER BY CP_ID DESC LIMIT 0, 1" else strQuery = "SELECT TOP 1 CP_ID FROM tblCactuShopCoupons ORDER BY CP_ID Desc" end if Call ExecuteSQL(strQuery, numCursorType, objRecordSet) If objRecordSet.recordcount>0 then numLastCouponID = objRecordSet("CP_ID") else numLastCouponID=0 objRecordSet.close For numCounter = 1 to numQuantity '------------------------------------------------ 'GENERATE A RANDOM ID NUMBER '------------------------------------------------ Randomize() numRandomElement1 = Int(rnd()*26) Randomize() numRandomElement2 = Int(rnd()*26) Randomize() numRandomElement3 = Int(rnd()*26) Randomize() numRandomElement4 = Int(rnd()*26) Randomize() numRandomElement5 = Int(rnd()*26) numThisCouponID = numLastCouponID + numCounter CP_CouponCode= chr(numRandomElement1+65) & chr(numRandomElement2+65) & chr(numRandomElement3+65) & chr(numRandomElement4+65) & chr(numRandomElement5+65) & numThisCouponID strQuery="INSERT INTO tblCactuShopCoupons (CP_CouponCode, CP_Reusable, CP_Used, CP_CreatedTime, CP_StartDate, CP_EndDate, CP_DiscountValue, CP_DiscountType, CP_Enabled) VALUES (" &_ "'" & CP_CouponCode & "'," &_ "'" & CP_Reusable & "'," &_ "'n'," &_ strDateDelimiter & ReverseFormatYear(CP_CreatedTime) & strDateDelimiter & "," &_ strDateDelimiter & ReverseFormatYear(CP_StartDate) & strDateDelimiter & "," &_ strDateDelimiter & ReverseFormatYear(CP_EndDate) & strDateDelimiter & "," &_ CP_DiscountValue & "," &_ "'" & CP_DiscountType & "','y')" Call ExecuteSQL(strQuery, numCursorType, objRecordSet) next %> <% else '----------------------------------------------- 'DISPLAY ERRORS '----------------------------------------------- %> <% end if %>
<% WriteString("PageTitle_Coupons") %>
<% WriteString("ContentText_FollowCouponsCreated") response.write(" " & FriendlyDate(CP_CreatedTime, "t") & ":

" & vbcrlf) '----------------------------------------------- 'GENERATE LIST OF THE ID NUMBERS 'Need to lookup all coupons created with date 'same as CP_CreatedTime above. '----------------------------------------------- If strDatabaseType = "mysql" Then strQuery = "SELECT * FROM tblCactuShopCoupons ORDER BY CP_ID DESC LIMIT 0, " & numQuantity else strQuery = "SELECT TOP " & numQuantity & " * FROM tblCactuShopCoupons ORDER BY CP_ID Desc" end if Call ExecuteSQL(strQuery, numCursorType, objRecordSet) do while NOT objRecordSet.EOF numCoupons = numCoupons + 1 If not (cint(numCoupons) > cint(numQuantity)) then response.write(objRecordSet("CP_CouponCode") & "
" & vbcrlf) end if objRecordSet.movenext loop objRecordSet.close %>
<% WriteString("PageTitle_Problems") %>
<% WriteString("ContentText_Errors") %>
<% =strErrorText %>
<< <% WriteString("ContentText_BackLink") %>
<% objDataConn.Close set objDataConn = nothing %>