%option explicit%>
<%
dim sAction
'*******************************************************************
' Prompt customer for gift details and add to cart
' VP-ASP 6.50
' November 11, 2006 hk make sure no other products in cart
'********************************************************************
if getconfig("xGiftCertificates")<>"Yes" then
shoperror getlang("LangCustNotAllowed")
end if
Shopinit
GiftCount=0
VerifyProductsinCart ' no other products in cart
sAction=Request("Action")
if sAction="" then
sAction=Request("Action.x")
end if
If sAction = "" Then
ShopPageHeader
if getconfig("xbreadcrumbs") = "Yes" then
response.write "
" & vbCrLf
DisplayForm
ShopPageTrailer
end if
end if
Sub DisplayForm()
Displayerrors
shopwriteheader getlang("LangGiftEasy")
Response.Write(""
end sub
'
Sub AddTo
shopwriteheaderpic getlang("LangGiftWho") , "images/icons/user.gif"
Response.Write "
"
end sub
Sub AddAmount
dim fieldname,fieldvalue
fieldname="CurGiftamount"
Fieldvalue=curgiftamount
shopwriteheaderpic getlang("LangGiftToAmount") , "images/icons/cashier.gif"
Response.Write "
" & tablecolumn
'VPASP 6.00 - write the symbol that the gift cert value needs to be entered in
if getsess("Conversionvalue") <> 1 then
dim theSymbol
getoriginalcurrencysymbol theSymbol
if theSymbol > "" then
response.write theSymbol
end if
end if
%><%
response.write tablecolumnend & tablerowend
Response.write "
"
end sub
Sub AddMessage
shopwriteheaderpic getlang("LangGiftMessage") , "images/icons/note.gif"
Response.write ""
end sub
Sub AddAddresses
shopwriteheaderpic getlang("LangGiftEmailPrompt") , "images/icons/mail.gif"
Response.write ""
end sub
Sub ValidateData
'VP-ASP 6.50 - precautionary security fix
curGiftamount = cleanchars(Request.Form("curGiftamount"))
strGifttoname = cleanchars(Request.Form("strGifttoname"))
strGifttoemail = cleanchars(Request.Form("strGifttoemail"))
strGiftfromname = cleanchars(Request.Form("strGiftfromname"))
strGiftfromemail = cleanchars(Request.Form("strGiftfromemail"))
strGiftmessage = cleanchars(Request.Form("strGiftmessage"))
stremails=cleanchars(request("stremails"))
If curGiftamount = "" Then
sError = sError & getlang("LangGiftTOAmount") & " "
Else
ValidateAmount
end if
If strGifttoemail = "" Then
sError = sError & getlang("LangGiftToemail") & " "
Else
validateemail strGifttoemail
End If
If strGiftfromemail = "" Then
sError = sError & getlang("LangGiftFromEmail") & " "
Else
validateemail strGiftfromemail
End If
If stremails <>"" Then
validateemails
End If
If len(strGiftmessage)> 255 Then
sError = sError & getlang("LangGiftMessageLimit") & len(strgiftMessage) & " "
End If
end sub
Sub WriteInfo
ShoppageHeader
If getsess("customeradmin")="" then
shopwriteheader getlang("LangMailListinfomsg")
else
shopwriteheader getlang("LangEdit03")
end if
ShopPageTrailer
End Sub
Sub DisplayErrors
if sError<> "" then
response.write errorfontstart & SError & errorfontend & " "
Serror=""
end if
end Sub
Sub ValidateAmount
Dim Numamount
dim numLimit
If not isnumeric(curGiftamount) then
Serror=Serror & getlang("LangUserPriceError") & " " & curgiftamount &" "
exit sub
end if
If curgiftamount<0 then
curgiftamount=abs(curgiftamount)
end if
If getconfig("Xgiftlimit")<> "" then
numamount=csng(curGiftamount)
numLimit=csng(getconfig("xgiftlimit"))
If Numamount>numlimit then
Serror=Serror & getlang("LangGiftLimit") & " " & getconfig("xgiftlimit") &" "
end if
end if
end sub
Sub UpdateGift
dim orderamount
GiftCount=GiftCount+1
SetSess "Giftamount", curGiftamount
If strGiftToname="" then
strGiftToName= getlang("LangGiftUnknown")
end if
SetSess "Gifttoname", strGifttoname
If strGiftFromname="" then
strGiftFromName= getlang("LangGiftunknown")
end if
SetSess "Giftfromname", strGiftfromname
SetSess "Gifttoemail", strGiftToemail
SetSess "Giftfromemail", strGiftfromemail
SetSess "Giftmessage", strGiftmessage
SetSess "GiftOtheremails",stremails
SetSess "GiftCount",GiftCount
Orderamount=curgiftamount
orderamount=Orderamount*giftcount
SetSess "Ordertotal",orderamount
SetSess "OrderProducttotal",orderamount
GiftAddToCart ' in shopgiftdb.asp
end sub
Sub ValidateEmails
dim words(20),wordcount, delimiter,i
delimiter=","
ParseRecord stremails,words,wordcount,delimiter
For i = 0 to wordcount-1
validateemail words(i)
next
GiftCount=GiftCount+WordCount
end sub
Sub ValidateEmail (stremail)
If Not InStr(strEmail, "@") > 1 Then
Serror=Serror & getlang("LangInvalidEmail") & " " & stremail & " "
end if
End sub
'******************************************************************************
' VP-ASP 6.5
' Verify if there are products in cart. If yes go to
' Verify shopgiftverify.asp notify user
'******************************************************************************
Sub VerifyProductsinCart
dim scartitem, arrcart,i, cartcount
cartcount = 0
arrCart = GetSessA("CartArray") ' get shopping cart data
scartitem = GetSess("CartCount")
if scartitem > 0 then
for i = 0 to scartitem
if arrcart(cproductid,i) <> getconfig("xgiftproductid") then
cartcount = cartcount + 1
end if
next
end if
If cartcount>0 then
responseredirect "shopgiftverify.asp?option=gift"
end if
end sub
%>