<%@ LANGUAGE="VBSCRIPT" %> <% PageStrings = "339, 361, 470, 496, 503, 508, 509, 545, 634, 635, 641, 642, 653, 665, 666, 680, 827, 837, 1186" 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. '=============================================== '----------------------------------------------- 'CREATE INVOICE '----------------------------------------------- numOrderID = request.querystring("ON_ID")*1 numLangID = request.querystring("LANG_ID")*1 '----------------------------------------------- 'LOOKUP LANGUAGE AND ITS INVOICE TEMPLATE FILE '----------------------------------------------- strQuery = "SELECT * FROM tblCactuShopLanguages WHERE LANG_ID = " & numLangID Call ExecuteSQL(strQuery, numCursorType, objRecordSet) strPathToInvoice = server.mappath(objRecordSet("LANG_SkinLocation") & "invoice.htm") Set objFileSystem = CreateObject("Scripting.FileSystemObject") 'Now we know where to look for skin, check it exists If objFileSystem.FileExists(strPathToInvoice) then 'read file and store as string Set objFile = objFileSystem.GetFile(strPathToInvoice) Set objTextStream = objFile.OpenAsTextStream(1,0) strPageBaseText = objTextStream.ReadAll set objTextStream = nothing set objFile = nothing Else 'no template found - display error and stop response.write("No invoice.htm template found at " & strPathToInvoice & "

" & vbcrlf) response.end End if set objFileSystem = nothing objRecordSet.close '----------------------------------------------- 'LOOKUP THIS ORDER RECORD '----------------------------------------------- strQuery = "SELECT * FROM (((tblCactuShopInvoiceRows INNER JOIN tblCactuShopOrderNumbers ON tblCactuShopInvoiceRows.IR_OrderNumber = tblCactuShopOrderNumbers.ON_ID) INNER JOIN tblCactuShopCurrencies ON tblCactuShopCurrencies.CUR_ID = tblCactuShopOrderNumbers.ON_CurrencyID) INNER JOIN tblCactuShopCardholderDetails ON tblCactuShopOrderNumbers.ON_CardholderID = tblCactuShopCardholderDetails.CD_ID) INNER JOIN tblCactuShopLanguages ON tblCactuShopOrderNumbers.ON_Language = tblCactuShopLanguages.LANG_ID WHERE ON_ID = " & numOrderID Call ExecuteSQL(strQuery, numCursorType, objRecordSet) numRecordCount = objRecordSet.recordcount If numRecordCount>0 then CD_ID = objRecordSet("CD_ID") CD_CardholderEUVATNum = objRecordSet("CD_CardholderEUVATNum") CD_CardholderName = SafeHTMLEncode(objRecordSet("CD_CardholderName")) CD_CardholderCompany = SafeHTMLEncode(objRecordSet("CD_CardholderCompany")) CD_CardholderStreetAddress = SafeHTMLEncode(objRecordSet("CD_CardholderStreetAddress")) CD_CardholderTownCity = SafeHTMLEncode(objRecordSet("CD_CardholderTownCity")) CD_CardholderCounty = SafeHTMLEncode(objRecordSet("CD_CardholderCounty")) CD_CardholderPostCode = SafeHTMLEncode(objRecordSet("CD_CardholderPostCode")) CD_CardholderCountry = GetCountryString(objRecordSet("CD_CardholderCountry"), numLangID) CD_ShippingName = SafeHTMLEncode(objRecordSet("CD_ShippingName")) CD_ShippingStreetAddress = SafeHTMLEncode(objRecordSet("CD_ShippingStreetAddress")) CD_ShippingTownCity = SafeHTMLEncode(objRecordSet("CD_ShippingTownCity")) CD_ShippingCounty = SafeHTMLEncode(objRecordSet("CD_ShippingCounty")) CD_ShippingPostCode = SafeHTMLEncode(objRecordSet("CD_ShippingPostCode")) CD_ShippingCountry = GetCountryString(objRecordSet("CD_ShippingCountry"), numLangID) ON_Details = objRecordSet("ON_Details") ON_TotalPrice = objRecordSet("ON_TotalPrice") ON_Date = objRecordSet("ON_Date") ON_Status = objRecordSet("ON_Status") ON_Details = objRecordSet("ON_Details") ON_LastModified = objRecordSet("ON_LastModified") ON_Sent = objRecordSet("ON_Sent") ON_Invoiced = objRecordSet("ON_Invoiced") ON_Shipped = objRecordSet("ON_Shipped") ON_Paid = objRecordSet("ON_Paid") ON_CouponCode = objRecordSet("ON_CouponCode") ON_CouponDiscountTotal = objRecordSet("ON_CouponDiscountTotal") ON_PricesIncTax = objRecordSet("ON_PricesIncTax") ON_TaxDue = objRecordSet("ON_TaxDue") ON_Language = objRecordSet("ON_Language") numShippingPriceExTax = objRecordSet("ON_ShippingPrice") numShippingPriceIncTax = objRecordSet("ON_ShippingPrice") + objRecordSet("ON_ShippingTax") numOrderHandlingPriceExTax = objRecordSet("ON_OrderHandlingCharge") numOrderHandlingPriceIncTax = numOrderHandlingPriceExTax + objRecordSet("ON_OrderHandlingChargeTax") numTotal = objRecordSet("ON_TotalPrice") numDiscountPercentage = objRecordSet("ON_DiscountPercentage") CUR_Symbol = objRecordSet("CUR_Symbol") CUR_HasDecimals = objRecordSet("CUR_HasDecimals") CD_ID = objRecordSet("CD_ID") End if '----------------------------------------------- 'LOOKUP COUPON IF THERE IS ONE '----------------------------------------------- If ON_CouponCode<>"" then strQuery2 = "SELECT * FROM tblCactuShopCoupons WHERE CP_CouponCode='" & ON_CouponCode & "'" Call ExecuteSQL(strQuery2, numCursorType, objRecordSet2) CP_DiscountValue = objRecordSet2("CP_DiscountValue") CP_DiscountType = objRecordSet2("CP_DiscountType") If CP_DiscountType = "f" then CP_DiscountValue = ON_CouponDiscountTotal CP_CouponCode = objRecordSet2("CP_CouponCode") objRecordSet2.close End if '----------------------------------------------- 'REPLACE TAGS WITH VALUES '----------------------------------------------- strBillingAddress = replace(CD_CardholderName & "
" & CD_CardholderCompany & "
" & CD_CardholderStreetAddress & "
" & CD_CardholderTownCity & "
" & CD_CardholderCounty & "
" & CD_CardholderPostcode & "
" & CD_CardholderCountry, "

", "
") strShippingAddress = replace(CD_ShippingName & "
" & CD_ShippingStreetAddress & "
" & CD_ShippingTownCity & "
" & CD_ShippingCounty & "
" & CD_ShippingPostcode & "
" & CD_ShippingCountry, "

", "
") strPageBaseText = replace(strPageBaseText, "xxxBILLINGxxx", strBillingAddress) strPageBaseText = replace(strPageBaseText, "xxxSHIPPINGxxx", strShippingAddress) strPageBaseText = replace(strPageBaseText, "xxxON_IDxxx", numOrderID) strPageBaseText = replace(strPageBaseText, "xxxPOxxx", ON_PONumber) strPageBaseText = replace(strPageBaseText, "xxxCD_IDxxx", CD_ID) strPageBaseText = replace(strPageBaseText, "xxxDATExxx", FriendlyDate(ON_Date, "d")) strPageBaseText = replace(strPageBaseText, "xxxVATNUMxxx", CD_CardholderEUVATNum) aryTemplate = split(strPageBaseText, "xxxINVOICEROWSxxx", -1) response.write(aryTemplate(0)) %> <% '----------------------------------------- 'PRICES INCLUDING TAX '----------------------------------------- If ON_PricesIncTax = "y" then If Application(LICENSENUMBER & "showtaxdisplay") = "y" then %> <% Else %> <% End if Else '----------------------------------------- 'PRICES EXCLUDING TAX '----------------------------------------- %> <% End if %> <% '----------------------------------------- 'CREATE INVOICE ROWS '----------------------------------------- do while NOT objRecordSet.EOF %> <% '----------------------------------------- 'PRICES INCLUDING TAX '----------------------------------------- If ON_PricesIncTax = "y" then If Application(LICENSENUMBER & "showtaxdisplay") = "y" then %> <% Else %> <% End if %> <% Else '----------------------------------------- 'PRICES EXCLUDING TAX '----------------------------------------- %> <% End if %> <% '----------------------------------------------- 'CALCULATE INVOICE TOTALS 'The total amount without tax is not stored - 'this is calculated from the invoice rows 'records as we cycle through them here. '----------------------------------------------- If ON_PricesIncTax = "y" then 'PRICES INCLUDING TAX numRowPriceExTax = Round((objRecordSet("IR_Quantity") * (objRecordSet("IR_PricePerItem") - objRecordSet("IR_TaxPerItem"))) - 0.0001, 2) numRowPriceIncTax = objRecordSet("IR_PricePerItem") * objRecordSet("IR_Quantity") 'Price of row inc tax (row = items x qty) numTotalPriceExTax = numTotalPriceExTax + numRowPriceExTax numTotalPriceIncTax = numTotalPriceIncTax + numRowPriceIncTax 'Running total of order price ex tax Else 'PRICES EXCLUDING TAX numRowPriceExTax = Round(objRecordSet("IR_PricePerItem") * objRecordSet("IR_Quantity") , 2) numRowPriceIncTax = objRecordSet("IR_PricePerItem") * objRecordSet("IR_Quantity") * (1 + objRecordSet("IR_TaxPerItem")) 'Price of row ex tax (row = items x qty) numTotalPriceExTax = numTotalPriceExTax + numRowPriceExTax numTotalPriceIncTax = numTotalPriceIncTax + numRowPriceIncTax 'Running total of order price ex tax End if objRecordSet.movenext loop '----------------------------------------------- 'BUILD TOTALS STRING '----------------------------------------------- If ON_TaxDue=1 then strOrderValueTotal = GetString("ContentText_TotalOrderValue") & " = " & CUR_Symbol & " " & CurrencyDisplay(numTotalPriceIncTax, 1, CUR_HasDecimals) & "
" strShipping = GetString("ContentText_Shipping") & " = " & CUR_Symbol & " " & CurrencyDisplay(numShippingPriceIncTax, 1, CUR_HasDecimals) If numOrderHandlingPriceIncTax > 0 then strOrderHandlingCharge = "
" & GetString("ContentText_OrderHandlingCharge") & " = " & CUR_Symbol & " " & CurrencyDisplay(numOrderHandlingPriceIncTax, 1, CUR_HasDecimals) Else strOrderValueTotal = GetString("ContentText_TotalOrderValue") & " = " & CUR_Symbol & " " & CurrencyDisplay(numTotalPriceExTax, 1, CUR_HasDecimals) & "
" strShipping = GetString("ContentText_Shipping") & " = " & CUR_Symbol & " " & CurrencyDisplay(numShippingPriceExTax, 1, CUR_HasDecimals) If numOrderHandlingPriceExTax > 0 then strOrderHandlingCharge = "
" & GetString("ContentText_OrderHandlingCharge") & " = " & CUR_Symbol & " " & CurrencyDisplay(numOrderHandlingPriceExTax, 1, CUR_HasDecimals) End if If ON_CouponCode <> "" then If CP_DiscountType = "p" then strCouponDiscount = GetString("ContentText_CouponDiscount") & " = " & CP_DiscountValue & "%
" Else strCouponDiscount = GetString("ContentText_CouponDiscount") & " = " & CUR_Symbol & " " & CurrencyDisplay(CP_DiscountValue, 1, CUR_HasDecimals) & "
" End if End if If numDiscountPercentage <> 0 then strDiscountPercentage = GetString("ContentText_Discount") & " = " & numDiscountPercentage & "%
" End if strTotal = "
" & GetString("ContentText_Total") & " = " & CUR_Symbol & " " & CurrencyDisplay(numTotal, 1, CUR_HasDecimals) & "
" strTotal = strOrderValueTotal & strCouponDiscount & strDiscountPercentage & strShipping & strOrderHandlingCharge & "
" & strTotal aryTemplate(1) = replace(aryTemplate(1), "xxxTOTALSxxx", strTotal) %>
<% WriteString("ContentText_ExTax") %>  <% WriteString("ContentText_IncTax") %> <% WriteString("ContentText_Price") %> <% WriteString("ContentText_Price") %>  <% WriteString("ContentText_Tax") %> (%) <% WriteString("ContentText_Qty") %> <% WriteString("ContentText_Total") %>
<% response.write(objRecordSet("IR_VersionName")) %>
<% response.write(objRecordSet("IR_VersionCode")) %><% response.write(CUR_Symbol & " " & CurrencyDisplay(objRecordSet("IR_PricePerItem") - objRecordSet("IR_TaxPerItem"), 1, objRecordSet("CUR_HasDecimals"))) %> <% response.write(CUR_Symbol & " " & CurrencyDisplay(objRecordSet("IR_TaxPerItem"), 1, objRecordSet("CUR_HasDecimals"))) %><% response.write(CUR_Symbol & " " & CurrencyDisplay(objRecordSet("IR_PricePerItem"), 1, objRecordSet("CUR_HasDecimals"))) %><% response.write(objRecordSet("IR_Quantity")) %> <% response.write(CUR_Symbol & " " & CurrencyDisplay(objRecordSet("IR_PricePerItem") * objRecordSet("IR_Quantity"), 1, objRecordSet("CUR_HasDecimals"))) %><% response.write(CUR_Symbol & " " & CurrencyDisplay(objRecordSet("IR_PricePerItem"), 1, objRecordSet("CUR_HasDecimals"))) %> <% response.write(objRecordSet("IR_TaxPerItem")*100) %> <% response.write(objRecordSet("IR_Quantity")) %> <% response.write(CUR_Symbol & " " & CurrencyDisplay(0.0001 + (objRecordSet("IR_PricePerItem") * objRecordSet("IR_Quantity") * (1 + objRecordSet("IR_TaxPerItem"))), 1, objRecordSet("CUR_HasDecimals"))) %>
<% response.write(aryTemplate(1)) objDataConn.Close set objDataConn = nothing %>