<%@ Language=VBScript %> <%Option Explicit%> <% '///////////// DB CONNECTION ////////////////////// dim SQL, oConn, oRs, OrderID, BANKID, ShipCountry set oConn = Server.CreateObject("ADODB.Connection") oConn.open Application("ConStr") set oRs = Server.CreateObject("ADODB.Recordset") '///////////// DB CONNECTION ////////////////////// if session("UserID") & "" = "" then Response.Redirect("error.asp") end if '//////////////////////////////////////// VALUES FROM HIDDEN FIELDS (Order3.asp)///////////////////////////////////////// dim Comp1ID, Comp2ID, Addrress1ID, Addrress2ID, chargeway, present, wishcard, payway, price, expensives, CountAllItems, total, BANK_ID, PaperID, BoxID Comp1ID = Request("Comp1ID") : Comp2ID = Request("Comp2ID") Addrress1ID = Request("Addrress1ID") : Addrress2ID = Request("Addrress2ID") chargeway = Request("chargeway") : payway = Request("payway") present = Request("present") : wishcard = Request("wishcard") : if present & "" = "" then present = 0 price = Request("price") : expensives = Request("expensives") BANK_ID = session("BANK_ID") : if BANK_ID & "" = "" then BANK_ID = "null" else BANKID = "'" & BANK_ID & "'" PaperID = Request.Form("PaperID"): if PaperID & "" = "" OR PaperID = "-1" then PaperID = "null" session("PaperID") = "" BoxID = Request.Form("BoxID") : if BoxID & "" = "" OR BoxID = "-1" then BoxID = "null" session("BoxID") = "" '//////////////////////////////////////// VALUES FROM HIDDEN FIELDS ///////////////////////////////////////////////////// '/////////DIORTHWSH TIMWN PRIN TO INSERT ///////////////// if Comp1ID & "" = "" then Comp1ID = "null" if Comp2ID & "" = "" then Comp2ID = "null" if Addrress1ID & "" = "" then Addrress1ID = "null" if Addrress2ID & "" = "" then Addrress2ID = "null" if expensives & "" = "" then expensives = "null" else expensives = Replace(expensives,",",".") if wishcard & "" = "" then wishcard = "null" else wishcard = "'" & wishcard & "'" '/////////DIORTHWSH TIMWN PRIN TO INSERT ///////////////// '///////////////////////// INSERT ORDER VALUES INTO ORDERS TABLE ////////////////////////////////////////////////////////////////////////////////////// SQL = "Insert into Orders (SendAddressU, ChargeAddressU, SendAddressC, ChargeAddressC, Paymethod, ChargeMethod, OrderDate, OrderPrice, OrderExpensives, Present, PresentText, UID, BANK_ID, PaperID, BoxID) values "&_ "(" & Addrress2ID & ", " & Addrress1ID & ", " & Comp2ID & ", " & Comp1ID & ", " & payway & ", " & chargeway & ", "&_ " convert(SmallDateTime,'" & datepart("yyyy",Date) & "-" & datepart("m",Date) & "-" & datepart("d",Date) & "', 120), "&_ Replace(price,",",".") & ", " & expensives & ", " & present & ", " & wishcard & ", " & session("UserID") &", '" & BANK_ID & "'," & PaperID & ", " & BoxID & ")" '///////////////////////// INSERT ORDER VALUES INTO ORDERS TABLE ////////////////////////////////////////////////////////////////////////////////////// '////// GET ORDERID ////////////////// oConn.execute SQL SQL = "Select @@IDENTITY as OrderID" oRs.open SQL, oConn, 3,1,1 OrderID = oRs("OrderID") oRs.close '////// GET ORDERID ////////////////// '///// PAIRNW TIS TIMES APO TON PINAKA ORDER KAI TIS BAZW STON ORDERITEMS.META KANW DELETE TA ITEMS APO TON ORDER /////////////////////////////////////// dim CountItems, AllItems, i , myprice, Discount SQL = "Select ShowBasket.*, IsNull(UserDiscount.Discount,0) as Discount from ShowBasket left outer join UserDiscount on UserDiscount.ProdCategID = ShowBasket.ProdCategID AND UserDiscount.UserID = ShowBasket.UserID where ShowBasket.UserID = " & session("UserID") oRs.open SQL, oConn, 3,1,1 while NOT oRs.EOF if oRs("Discount") <> 0 then myprice = round(cdbl(oRs("ProdPriceRetail"))-cdbl((cdbl(oRs("Discount") )*cdbl(oRs("ProdPriceRetail")))/100),2) Discount = oRs("Discount") else myprice = formatnumber(oRs("ProdPriceBulk"),2) Discount = "null" end if SQL = "Insert into OrderItems values "&_ "(" & OrderID & ", " & oRs("ItemID") & ", " & oRs("ItemQuantity")& ", '" & Replace(myprice,",",".") & "', " & session("UserID") & ", " & oRs("ItemQuantity")& "," & Discount & ")" oConn.execute SQL oRs.MoveNext wend oRs.close SQL = "Select ShowBasket.*, UserDiscount.Discount from ShowBasket left outer join UserDiscount on UserDiscount.ProdCategID = ShowBasket.ProdCategID AND UserDiscount.UserID = ShowBasket.UserID where ShowBasket.UserID = " & session("UserID") oRs.open SQL, oConn, 3,1,1 CountItems = oRs.RecordCount AllItems = oRs.getRows() oConn.execute "Delete From [Order] where UserID = " & session("UserID") oRs.close '///// PAIRNW TIS TIMES APO TON PINAKA ORDER KAI TIS BAZW STON ORDERITEMS.META KANW DELETE TA ITEMS APO TON ORDER /////////////////////////////////////// '///// PAIRNW TO EMAIL TOY USER /////////////// SQL = "Select UEmail from [User] where UID=" & session("UserID") oRs.open SQL, oConn, 3,1,1 if oRs.EOF = false then dim UEmail UEmail = oRs("UEmail") end if oRs.close '///// PAIRNW TO EMAIL TOY USER /////////////// '/////////////////////////// GTIAXNW TO MAIL BODY POU 8A STEILW STON PELATH ////////////////////////////////////////////////// dim body, AddPrice, ChargeAddress, ChargeAddress1, SendAddress, SendAddress1 AddPrice = 0:price = "" if chargeway = 0 then chargeway = ""&BReceipt(lg)&"" else chargeway = ""&BTimol(lg)&"" if Cstr(payway) ="0"then payway = BaskCredit(lg) if Cstr(payway) = "1" then payway = BaskOnDeliv(lg) if Cstr(payway) = "2" then payway = Pistosi(lg) if present = "1" AND wishcard & "" <> "" AND wishcard <> "null" then present = ""&Bask2(lg)&"" & Replace(wishcard,chr(13),"
") & ""&_ "" else present = "" end if if CountItems > 0 then for i=0 to CountItems-1 if AllItems(7,i) <> 0 then myprice = round(cdbl(AllItems(6,i))-cdbl((cdbl(AllItems(7,i) )*cdbl(AllItems(6,i)))/100),2) else myprice = formatnumber(AllItems(2,i),2) end if price = price & "" & i+1 & "."&_ "" & AllItems(0,i) & ""&_ "" & AllItems(1,i) & ""&_ "" & AllItems(3,i) & ""&_ "" & myprice & " €" AddPrice = AddPrice + (myprice*AllItems(3,i)) CountAllItems = CountAllItems + AllItems(3,i) next price= ""&BaskTitle2(lg)&""&BaskTitle3(lg)&""&BaskTitle4(lg)&""&BaskTitle5(lg)&""&BaskTitle6(lg)&" *" & price end if if Comp1ID <> "null" then SQL = "Select * from UserCompanies where CompID = " & Comp1ID &" AND UID = " & session("UserID") oRs.open SQL, oConn, 3,1,1 ChargeAddress = oRs.getRows oRs.close ChargeAddress1 = ""&_ ""&_ ""&_ ""&_ ""&_ "
"&BName(lg)&"" & ChargeAddress(2,0) & ""&BActivity(lg)&"" & ChargeAddress(3,0) & "
"&BAFM(lg)&"" & ChargeAddress(4,0) & ""&BDOY(lg)&"" & ChargeAddress(5,0) & "
"&BAddr(lg)&"" & ChargeAddress(6,0) & ""&BZipCode(lg)&"" & ChargeAddress(8,0) & "
"&BTOwn(lg)&"" & ChargeAddress(7,0) & ""&BTel(lg)&"" & ChargeAddress(11,0) & "
"&BCountry(lg)&"" & ChargeAddress(9,0) & ""&BFAX(lg)&"" & ChargeAddress(12,0) & "
" ShipCountry = ChargeAddress(12,0) end if if Comp2ID <> "null" then SQL = "Select * from UserCompanies where CompID = " & Comp2ID &" AND UID = " & session("UserID") oRs.open SQL, oConn, 3,1,1 SendAddress = oRs.getRows oRs.close SendAddress1 = ""&_ ""&_ ""&_ ""&_ ""&_ "
"&BName(lg)&"" & SendAddress(2,0) & ""&BActivity(lg)&"" & SendAddress(3,0) & "
"&BAFM(lg)&"" & SendAddress(4,0) & ""&BDOY(lg)&"" & SendAddress(5,0) & "
"&BAddr(lg)&"" & SendAddress(6,0) & ""&BZipCode(lg)&"" & SendAddress(8,0) & "
"&BTOwn(lg)&"" & SendAddress(7,0) & ""&BTel(lg)&"" & SendAddress(11,0) & "
"&BCountry(lg)&"" & SendAddress(9,0) & ""&BFAX(lg)&"" & SendAddress(12,0) & "
" end if if Addrress1ID <> "null" then SQL = "Select * from UserAddresses where AddrressID = " & Addrress1ID &" AND UID = " & session("UserID") oRs.open SQL, oConn, 3,1,1 ChargeAddress = oRs.getRows oRs.close ChargeAddress1 = ""&_ ""&_ ""&_ ""&_ "
"&BName2(lg)&"" & ChargeAddress(10,0) & ""&BName3(lg)&"" & ChargeAddress(11,0) & "
"&BAddr(lg)&"" & ChargeAddress(2,0) & ""&BZipCode(lg)&"" & ChargeAddress(6,0) & "
"&BTOwn(lg)&"" & ChargeAddress(3,0) & ""&BTel(lg)&"" & ChargeAddress(7,0) & "
"&BCountry(lg)&"" & ChargeAddress(4,0) & "  
" ShipCountry = ChargeAddress(4,0) end if if Addrress2ID <> "null" then SQL = "Select * from UserAddresses where AddrressID = " & Addrress2ID &" AND UID = " & session("UserID") oRs.open SQL, oConn, 3,1,1 SendAddress = oRs.getRows oRs.close SendAddress1 = ""&_ ""&_ ""&_ ""&_ "
"&BName2(lg)&"" & SendAddress(10,0) & ""&BName3(1)&"" & SendAddress(11,0) & "
"&BAddr(lg)&"" & SendAddress(2,0) & ""&BZipCode(lg)&"" & SendAddress(6,0) & "
"&BTOwn(lg)&"" & SendAddress(3,0) & ""&BTel(lg)&"" & SendAddress(7,0) & "
"&BCountry(lg)&"" & SendAddress(4,0) & "  
" end if ' ================== PAPER & BOX ================================== dim PaperData, PaperExist, PaperMail if PaperID & "" <> "" then SQL = "Select PaperID, PaperTitle"&lang&", PaperDescr"&lang&", PaperPhoto from Paper where PaperShow=1 AND PaperID = " & PaperID oRs.open SQL, oConn, 3,1,1 if oRs.EOF = false then PaperData = oRs.GetRows() PaperMail = ""&_ ""&_ ""&_ "
"&BaskTitle29(lg)&"
"&_ ""&_ ""&_ ""&_ ""&_ ""&_ "
"&_ ""&_ ""&_ "
"&_ "
"&_ "" & PaperData(1,0)& "
"&_ "" & PaperData(2,0) & ""&_ "
"&_ "
" end if oRs.close else PaperMail ="" end if dim BoxData, BoxExist, BoxPrice, BoxMail if BoxID & "" <> "" then SQL = "Select BoxID, BoxTitle"&lang&", BoxDescr"&lang&", BoxPhoto, BoxPrice from Box where BoxShow=1 AND BoxID = " & BoxID oRs.open SQL, oConn, 3,1,1 if oRs.EOF = false then BoxData = oRs.GetRows() BoxPrice = BoxData(4,0) BoxMail = ""&_ ""&_ ""&_ "
"&BaskTitle26(lg)&"
"&_ ""&_ ""&_ ""&_ ""&_ ""&_ "
"&_ ""&_ ""&_ "
" &_ "
"&_ "
"&_ "" & BoxData(1,0) & "
"&_ "" & BoxData(2,0) & "
"&_ "
"&_ "
" end if oRs.close else BoxPrice = 0 BoxMail = "" end if ' ================== PAPER & BOX ================================== if trim(ShipCountry) = "ΕΛΛΑΔΑ (ΑΘΗΝΑ)" OR trim(ShipCountry) = "GREECE (ATHENS)" then expensives = ""&Bask13(lg)&"" else expensives = round(cdbl(cdbl(AddPrice)*0.1),2) end if if expensives <> ""&Bask13(lg)&"" then total = formatnumber((AddPrice+expensives),2) else total = formatnumber(AddPrice,2) end if body = "" & PageTitle& ""&_ ""&_ ""&_ ""&_ "
"&_ ""&_ ""&_ ""&_ ""&_ ""&_ "
 " & DATE() & " - "&Bask11(lg)&"
"&_ ""&_ ""&_ "
"&_ ""&_ ""&_ ""&_ "
"&Bask1(lg)&"
"&_ ""&_ ""&_ ""&_ ""&_ ""&_ ""&_ ""&_ ""&_ ""&_ ""&_ ""&_ ""&_ ""&_ ""&_ ""&_ ""&_ "
"&Basketpay(lg)&"
"& ChargeAddress1 &"
"&BasketSend(lg)&"
" & SendAddress1 & "
"&_ ""&_ ""&_ ""&_ ""&_ ""&_ ""&_ ""&_ ""&_ present &_ "
"&BasketWayofpay(lg)&""& chargeway & "
"&BasketWayofpay2(lg)&"" & payway & "
"&Bask6(lg)&"Courier
"&_ paperMail&_ boxMail&_ "
"&Bask3(lg)&"
"&_ ""&_ price &_ ""&_ "" if BoxPrice <> "0" AND BoxPrice <> "" then body = body & "" end if body = body & ""&_ ""&_ "
"&BaskTitle10(lg)&"" & formatnumber(AddPrice,2) & "
"&Bask4(lg)&"" & expensives& "
"&Bask14(lg)&"" & BoxPrice & "
"&Bask7(lg)&"" & cdbl(total) + cdbl(BoxPrice) & "
"&_ "
"&_ "

"&_ "" '/////////////////////////// GTIAXNW TO MAIL BODY POU 8A STEILW STON PELATH ////////////////////////////////////////////////// '///////////// APOSTOLH EMAIL //////////////////////// dim objMail set objMail = CreateObject("CDONTS.NewMail") objMail.BodyFormat = 0 objMail.MailFormat = 0 objMail.From = "info@degustibus.gr" objMail.to = UEmail objMail.bcc = "info@degustibus.gr" objMail.subject = ""&Bask12(1)&"" objMail.Body = body objMail.send set objMail = Nothing '///////////// APOSTOLH EMAIL //////////////////////// Response.redirect "OrderEnd.asp" %>