<% Class O_catalogue Private oConn Public oBase Private iID Sub Class_Initialize() Set oBase = Base End Sub Function Connect(sConn,ID) Set oConn = sConn iID = ID End Function Function Navigation(iID) iLevel = oDB.GetValue(oConn,"cat_level","catalogue_setup","WHERE id = " & iID) Select Case iLevel Case 0 iSecure = oDB.GetValue(oConn,"cat_secure","catalogue_setup","WHERE id = " & iID) If iSecure = 1 AND oBase.IsAuthorized = True Then MiniNavigation(iID) ElseIf iSecure = 0 Then MiniNavigation(iID) End If Case 1 iSecure = oDB.GetValue(oConn,"cat_secure","catalogue_setup","WHERE id = " & iID) If iSecure = 1 AND oBase.IsAuthorized = True Then MidiNavigation(iID) ElseIf iSecure = 0 Then MidiNavigation(iID) End If End Select End Function Function MiniNavigation(iID) sFile = oBase.LoadView("catalogue","nav-mini",1) aParts = DoSplit(sFile) sHeader = aParts(0) sQ = oDB.ExecuteQuery(oConn,"SELECT id, title, description, (SELECT COUNT(id) FROM catalogue_products WHERE display = true AND category_id = catalogue_categories.id) AS productCount FROM catalogue_categories WHERE parent_id = 0 AND catalogue_id = " & iID & " ORDER BY sort_order ASC") If IsArray(sQ) Then For i = 0 to uBound(sQ,2) If sQ(3,i) > 0 Then sRepeat = sRepeat & aParts(1) sRepeat = oBase.InsertValue(sRepeat,"TITLE",sQ(1,i)) sRepeat = oBase.InsertValue(sRepeat,"HREF",URL("catalogue","items",sQ(0,i))) End If Next Else sRepeat = "
  • There are currently no products available.
  • " End If sHeader = oBase.InsertValue(sHeader,"CATALOGUE_TITLE",oDB.GetValue(oConn,"title","catalogue_setup","WHERE id = " & iID)) Response.Write(sHeader & sRepeat & aParts(2)) End Function Function MidiNavigation(iID) sFile = oBase.LoadView("catalogue","nav-midi",2) aParts = DoSplit(sFile) sHeader = aParts(0) sFooter = aParts(4) sQ = oDB.ExecuteQuery(oConn,"SELECT id, title, description FROM catalogue_categories WHERE parent_id = 0 AND catalogue_id = " & iID & " ORDER BY cat_order ASC") If IsArray(sQ) Then For i = 0 to uBound(sQ,2) sRepeat = sRepeat & aParts(1) sRepeat = oBase.InsertValue(sRepeat,"TITLE",sQ(1,i)) sRepeat = oBase.InsertValue(sRepeat,"HREF",URL("catalogue","load",sQ(0,i))) sQa = oDB.ExecuteQuery(oConn,"SELECT catalogue_categories.id, catalogue_categories.title, catalogue_categories.description, catalogue_categories.parent_id, catalogue_categories.sort_order FROM catalogue_categories WHERE catalogue_categories.parent_id = " & sQ(0,i) & " ORDER BY catalogue_categories.sort_order ASC") If IsArray(sQa) Then For j = 0 to uBound(sQa,2) sSubRepeat = sSubRepeat & aParts(3) sSubRepeat = oBase.InsertValue(sSubRepeat,"TITLE",sQa(1,j)) sSubRepeat = oBase.InsertValue(sSubRepeat,"HREF",URL2("catalogue","category",sQa(0,j),LCase(GetCategoryProperty(sQa(3,j),"title")) & "/" & LCase(sQa(1,j)))) sSubRepeat = oBase.InsertValue(sSubRepeat,"ITEMS",ListCatItems(sQa(0,j))) Next End If sRepeat = sRepeat & sSubRepeat Next sRepeat = sRepeat & aParts(2) Else sRepeat = "

    There are currently no products available.

    " End If sHeader = oBase.InsertValue(sHeader,"CATALOGUE_TITLE",oDB.GetValue(oConn,"title","catalogue_setup","WHERE id = " & iID)) Response.Write(sHeader & sRepeat & sFooter) End Function Function ListCatItems(intCat) sFile = oBase.LoadView("catalogue","nav-items",1) aParts = DoSplit(sFile) sHeader = aParts(0) sFooter = aParts(2) sQ = oDB.ExecuteQuery(oConn,"SELECT id, title, category_id FROM catalogue_products WHERE category_id = " & intCat) If(IsArray(sQ)) Then For i = 0 to uBound(sQ,2) intParent = GetCategoryProperty(sQ(2,i),"parent_id") sRepeat = sRepeat & aParts(1) sRepeat = oBase.InsertValue(sRepeat,"TITLE",sQ(1,i)) sRepeat = oBase.InsertValue(sRepeat,"HREF",URL2("catalogue","items",sQ(0,i),"destinations/" & LCase(GetCategoryProperty(intParent,"title"))&"/"&LCase(GetCategoryProperty(sQ(2,i),"title"))&"/" & LCase(Escape(sQ(1,i))))) Next End If ListCatItems = sHeader & sRepeat & sFooter End Function Function ListCategories sFile = oBase.LoadView("catalogue","nav-items",1) aParts = DoSplit(sFile) sHeader = aParts(0) sFooter = aParts(2) sQ = oDB.ExecuteQuery(oConn,"SELECT id, title, category_id FROM catalogue_products WHERE category_id = " & intCat) If(IsArray(sQ)) Then For i = 0 to uBound(sQ,2) intParent = GetCategoryProperty(sQ(2,i),"parent_id") sRepeat = sRepeat & aParts(1) sRepeat = oBase.InsertValue(sRepeat,"TITLE",sQ(1,i)) sRepeat = oBase.InsertValue(sRepeat,"HREF",URL2("catalogue","items",sQ(0,i),"destinations/" & LCase(GetCategoryProperty(intParent,"title"))&"/"&LCase(GetCategoryProperty(sQ(2,i),"title"))&"/" & LCase(Escape(sQ(1,i))))) Next End If ListCatItems = sHeader & sRepeat & sFooter End Function Function GetCategoryProperty(intID, strProperty) GetCategoryProperty = oDB.GetValue(oConn,strProperty,"catalogue_categories","WHERE id = " & intID) End Function Function Category(nID) nID = Request.QueryString("id") iLevel = oDB.GetValue(oConn,"catalogue_id","catalogue_categories","WHERE id = " & nID) iSecure = oDB.GetValue(oConn,"cat_secure","catalogue_setup","WHERE id = " & iLevel) If iSecure = 1 AND oBase.IsAuthorized = false Then sFile = oBase.LoadView("catalogue","login",1) aParts = DoSplit(sFile) sHeader = aParts(0) sHeader = oBase.InsertValue(sHeader,"ID",iLevel) sFooter = aParts(2) sContent = aParts(1) ElseIf oBase.IsAuthorized OR iSecure = 0 Then sFile = oBase.LoadView("catalogue","catalogue",1) aParts = DoSplit(sFile) sHeader = aParts(0) sFooter = aParts(2) sHeader = oBase.InsertValue(sHeader,"CATALOGUE_TITLE",oDB.GetValue(oConn,"title","catalogue_setup","WHERE id = " & iLevel)) sQ = oDB.ExecuteQuery(oConn,"SELECT id, title, code, price, model, manufacturer, description FROM catalogue_products WHERE display = True AND category_id = " & nID) If IsArray(sQ) Then For i = 0 to uBound(sQ,2) sRepeat = sRepeat & aParts(1) sRepeat = oBase.InsertValue(sRepeat,"TITLE",sQ(1,i)) sRepeat = oBase.InsertValue(sRepeat,"DESCRIPTION",sQ(6,i)) sRepeat = oBase.InsertValue(sRepeat,"IMAGES",Image(sQ(0,i))) sRepeat = oBase.InsertValue(sRepeat,"PRICE","R " & FormatNumber(sQ(3,i))) sRepeat = oBase.InsertValue(sRepeat,"CODE",sQ(2,i)) sRepeat = oBase.InsertValue(sRepeat,"MANUFACTURER",sQ(5,i)) sRepeat = oBase.InsertValue(sRepeat,"MODEL",sQ(4,i)) sRepeat = oBase.InsertValue(sRepeat,"ID",sQ(0,i)) Next Else sRepeat = "

    There are currently no products in this category.

    " End If End If Response.Write(sHeader & sRepeat & sFooter) End Function Function Items(nID) nID = Request.QueryString("id") iLevel = oDB.GetValue(oConn,"catalogue_id","catalogue_categories","WHERE id = " & nID) iSecure = oDB.GetValue(oConn,"cat_secure","catalogue_setup","WHERE id = " & iLevel) intTier = oDB.GetValue(oConn,"cat_level","catalogue_setup","WHERE id = " & iLevel) If iSecure = 1 AND oBase.IsAuthorized = false Then sFile = oBase.LoadView("catalogue","login",1) aParts = DoSplit(sFile) sHeader = aParts(0) sHeader = oBase.InsertValue(sHeader,"ID",iLevel) sFooter = aParts(2) sContent = aParts(1) ElseIf oBase.IsAuthorized OR iSecure = 0 Then sFile = oBase.LoadView("catalogue","catalogue",1) aParts = DoSplit(sFile) sHeader = aParts(0) sFooter = aParts(2) sHeader = oBase.InsertValue(sHeader,"CATALOGUE_TITLE",oDB.GetValue(oConn,"title","catalogue_setup","WHERE id = " & iLevel)) 'sRepeat = oBase.InsertValue(sRepeat,"MAIN_CATEGORY_TITLE",GetCategoryProperty(GetCategoryProperty(sQ(7,i),"parent_id"),"title")) 'sRepeat = oBase.InsertValue(sRepeat,"CATEGORY_TITLE",oDB.GetValue(oConn,"title","catalogue_categories","WHERE id = " & sQ(7,i))) Select Case intTier Case 0 'Mini Catalogue sQ = oDB.ExecuteQuery(oConn,"SELECT id, title, code, price, model, manufacturer, description, category_id, special_price, on_special, files_id FROM catalogue_products WHERE display = True AND category_id = " & nID) End Select sHeader = oBase.InsertValue(sHeader,"MAIN_CATEGORY_TITLE",GetCategoryProperty(GetCategoryProperty(nID,"parent_id"),"title")) sHeader = oBase.InsertValue(sHeader,"CATEGORY_TITLE",oDB.GetValue(oConn,"title","catalogue_categories","WHERE id = " & nID)) If IsArray(sQ) Then For i = 0 to uBound(sQ,2) sRepeat = sRepeat & aParts(1) sRepeat = oBase.InsertValue(sRepeat,"TITLE",sQ(1,i)) sRepeat = oBase.InsertValue(sRepeat,"DESCRIPTION",sQ(6,i)) sRepeat = oBase.InsertValue(sRepeat,"IMAGES",Images(sQ(10,i))) sRepeat = oBase.InsertValue(sRepeat,"DOCUMENTS",Documents(sQ(10,i))) sRepeat = oBase.InsertValue(sRepeat,"PRICE","R " & FormatNumber(sQ(3,i))) sRepeat = oBase.InsertValue(sRepeat,"CODE",sQ(2,i)) sRepeat = oBase.InsertValue(sRepeat,"MANUFACTURER",sQ(5,i)) sRepeat = oBase.InsertValue(sRepeat,"SPECIAL_PRICE","R " & FormatNumber(sQ(8,i))) sRepeat = oBase.InsertValue(sRepeat,"ON_SPECIAL",sQ(9,i)) sRepeat = oBase.InsertValue(sRepeat,"MODEL",sQ(4,i)) sRepeat = oBase.InsertValue(sRepeat,"ID",sQ(0,i)) sRepeat = oBase.InsertValue(sRepeat,"ENQUIRY_FORM_ACTION",URL("catalogue","submit_enquiry",sQ(0,i))) sRepeat = oBase.InsertValue(sRepeat,"WIDGET",AddToCartWidget(sQ(0,i))) sRepeat = oBase.InsertValue(sRepeat,"COUNTER",i) Next sFooter = oBase.InsertValue(sFooter,"NOTHING",False) Else sFooter = oBase.InsertValue(sFooter,"NOTHING",True) End If End If Response.Write(sHeader & sRepeat & sFooter) End Function Function Product(nID) nID = Request.QueryString("id") sFile = oBase.LoadView("catalogue","catalogue",1) aParts = DoSplit(sFile) sHeader = aParts(0) sFooter = aParts(2) sHeader = oBase.InsertValue(sHeader,"CATALOGUE_TITLE",oDB.GetValue(oConn,"title","catalogue_setup","WHERE id = " & GetItemProperty(nID,"category_id"))) 'sRepeat = oBase.InsertValue(sRepeat,"MAIN_CATEGORY_TITLE",GetCategoryProperty(GetCategoryProperty(sQ(7,i),"parent_id"),"title")) 'sRepeat = oBase.InsertValue(sRepeat,"CATEGORY_TITLE",oDB.GetValue(oConn,"title","catalogue_categories","WHERE id = " & sQ(7,i))) 'Mini Catalogue sQ = oDB.ExecuteQuery(oConn,"SELECT id, title, code, price, model, manufacturer, description, category_id, special_price, on_special, files_id FROM catalogue_products WHERE display = True AND id = " & nID) sHeader = oBase.InsertValue(sHeader,"MAIN_CATEGORY_TITLE",GetCategoryProperty(GetCategoryProperty(GetItemProperty(nID,"category_id"),"parent_id"),"title")) sHeader = oBase.InsertValue(sHeader,"CATEGORY_TITLE",oDB.GetValue(oConn,"title","catalogue_categories","WHERE id = " & GetItemProperty(nID,"category_id"))) If IsArray(sQ) Then For i = 0 to uBound(sQ,2) sRepeat = sRepeat & aParts(1) sRepeat = oBase.InsertValue(sRepeat,"TITLE",sQ(1,i)) sRepeat = oBase.InsertValue(sRepeat,"DESCRIPTION",sQ(6,i)) sRepeat = oBase.InsertValue(sRepeat,"IMAGES",Images(sQ(10,i))) sRepeat = oBase.InsertValue(sRepeat,"DOCUMENTS",Documents(sQ(10,i))) sRepeat = oBase.InsertValue(sRepeat,"PRICE","R " & FormatNumber(sQ(3,i))) sRepeat = oBase.InsertValue(sRepeat,"CODE",sQ(2,i)) sRepeat = oBase.InsertValue(sRepeat,"MANUFACTURER",sQ(5,i)) sRepeat = oBase.InsertValue(sRepeat,"SPECIAL_PRICE","R " & FormatNumber(sQ(8,i))) sRepeat = oBase.InsertValue(sRepeat,"ON_SPECIAL",sQ(9,i)) sRepeat = oBase.InsertValue(sRepeat,"MODEL",sQ(4,i)) sRepeat = oBase.InsertValue(sRepeat,"ID",sQ(0,i)) sRepeat = oBase.InsertValue(sRepeat,"ENQUIRY_FORM_ACTION",URL("catalogue","submit_enquiry",sQ(0,i))) sRepeat = oBase.InsertValue(sRepeat,"WIDGET",AddToCartWidget(sQ(0,i))) Next sFooter = oBase.InsertValue(sFooter,"NOTHING",False) Else sFooter = oBase.InsertValue(sFooter,"NOTHING",True) End If Response.Write(sHeader & sRepeat & sFooter) End Function Function Specials sFile = oBase.LoadView("catalogue","specials",1) aParts = DoSplit(sFile) sHeader = aParts(0) sFooter = aParts(2) sQ = oDB.ExecuteQuery(oConn,"SELECT id, title, special_price FROM catalogue_products WHERE on_special = true and display = 1") If IsArray(sQ) Then For i = 0 to uBound(sQ,2) sRepeat = sRepeat & aParts(1) sRepeat = oBase.InsertValue(sRepeat,"ID",sQ(0,i)) sRepeat = oBase.InsertValue(sRepeat,"TITLE",sQ(1,i)) sRepeat = oBase.InsertValue(sRepeat,"HREF",URL("catalogue","product",sQ(0,i))) sRepeat = oBase.InsertValue(sRepeat,"SPECIAL_PRICE","R " & FormatNumber(sQ(2,i),2)) Next Response.Write(sHeader & sRepeat & sFooter) End If End Function Function Submit_Enquiry(nID) If Trim(LCase(Request.Form("spam"))) = "blue" Then sFile = oBase.LoadView("catalogue","enquiry-email",0) sFile = oBase.InsertValue(sFile,"FIRST_NAME",Request.Form("name")) sFile = oBase.InsertValue(sFile,"LAST_NAME",Request.Form("surname")) sFile = oBase.InsertValue(sFile,"TEL_NUMBER",Request.Form("tel")) sFile = oBase.InsertValue(sFile,"EMAIL_ADDRESS",Request.Form("email")) sFile = oBase.InsertValue(sFile,"MESSAGE",Request.Form("comments")) sFile = oBase.InsertValue(sFile,"DESTINATION",GetCategoryProperty(GetItemProperty(nID,"category_id"),"title") & " - " & GetItemProperty(nID,"title")) oBase.SendEmail Array(Request.Form("name") & " " & Request.Form("surname"),Request.Form("email")),Array(C_ENQUIRY_EMAILS(0,0),C_ENQUIRY_EMAILS(1,0)),"Rufaro Destination Enquiry",sFile Response.Write("

    Thank you. Your enquiry has been sent.

    ") Else Response.Write("

    Error. Please correctly answer the anti-spam question.

    ") End If End Function Function All(nID) nID = Request.QueryString("id") iLevel = nID iSecure = oDB.GetValue(oConn,"cat_secure","catalogue_setup","WHERE id = " & iLevel) If iSecure = 1 AND oBase.IsAuthorized = false Then sFile = oBase.LoadView("catalogue","login",1) aParts = DoSplit(sFile) sHeader = aParts(0) sHeader = oBase.InsertValue(sHeader,"ID",iLevel) sFooter = aParts(2) sContent = aParts(1) ElseIf oBase.IsAuthorized OR iSecure = 0 Then sFile = oBase.LoadView("catalogue","catalogue",1) aParts = DoSplit(sFile) sHeader = aParts(0) sFooter = aParts(2) sHeader = oBase.InsertValue(sHeader,"CATALOGUE_TITLE",oDB.GetValue(oConn,"title","catalogue_setup","WHERE id = " & iLevel)) sQa = oDB.ExecuteQuery(oConn,"SELECT id, title FROM catalogue_categories WHERE catalogue_id = " & iLevel) If IsArray(sQa) Then For j = 0 to uBound(sQa,2) sQ = oDB.ExecuteQuery(oConn,"SELECT id, title, code, price, model, manufacturer, description, files_id FROM catalogue_products WHERE display = True AND category_id = " & sQa(0,j) & " ORDER BY title ASC") If IsArray(sQ) Then For i = 0 to uBound(sQ,2) sRepeat = sRepeat & aParts(1) sRepeat = oBase.InsertValue(sRepeat,"TITLE",sQ(1,i)) sRepeat = oBase.InsertValue(sRepeat,"DESCRIPTION",sQ(6,i)) sRepeat = oBase.InsertValue(sRepeat,"IMAGES",Images(sQ(7,i))) sRepeat = oBase.InsertValue(sRepeat,"PRICE","R " & FormatNumber(sQ(3,i))) sRepeat = oBase.InsertValue(sRepeat,"CODE",sQ(2,i)) sRepeat = oBase.InsertValue(sRepeat,"MANUFACTURER",sQ(5,i)) sRepeat = oBase.InsertValue(sRepeat,"MODEL",sQ(4,i)) sRepeat = oBase.InsertValue(sRepeat,"ID",sQ(0,i)) Next sFooter = oBase.InsertValue(sFooter,"NOTHING",False) End If Next Else sFooter = oBase.InsertValue(sFooter,"NOTHING",True) End If End If Response.Write(sHeader & sRepeat & sFooter) End Function Function Images(intID) sFile = oBase.LoadView("catalogue","images",1) aParts = DoSplit(sFile) sHeader = aParts(0) sFooter = aParts(2) Set oFS = Server.CreateObject("Scripting.FileSystemObject") If oFS.FolderExists(C_ROOT_UPLOADS & "\" & intID) Then Set oFolder = oFS.GetFolder(C_ROOT_UPLOADS & "\" & intID) For Each Image In oFolder.Files sFileName = Split(Image.Name,".") sExt = sFileName(1) Select Case sExt Case "doc" Case "docx" Case "pdf" Case "txt" Case "xls" Case "xlsx" Case Else sRepeat = sRepeat & aParts(1) sRepeat = oBase.InsertValue(sRepeat,"IMG_SRC",C_UPLOADS & "\" & intID & "\" & Image.Name) sRepeat = oBase.InsertValue(sRepeat,"THUMB_SRC",C_UPLOADS & "\" & intID & "\thumbs\" & Image.Name) End Select Next Set oFolder = Nothing End If Set oFS = Nothing Images = sHeader & sRepeat & sFooter End Function Function Documents(intID) sFile = oBase.LoadView("catalogue","documents",1) aParts = DoSplit(sFile) sHeader = aParts(0) sFooter = aParts(2) intCounter = 0 Set oFS = Server.CreateObject("Scripting.FileSystemObject") If oFS.FolderExists(C_ROOT_UPLOADS & "\" & intID) Then Set oFolder = oFS.GetFolder(C_ROOT_UPLOADS & "\" & intID) For Each Image In oFolder.Files sFileName = Split(Image.Name,".") sExt = sFileName(1) Select Case sExt Case "jpg" Case "png" Case "jpeg" Case "gif" Case "bmp" Case Else intCounter = intCounter + 1 sRepeat = sRepeat & aParts(1) sRepeat = oBase.InsertValue(sRepeat,"HREF",C_UPLOADS & "\" & intID & "\" & Image.Name) sRepeat = oBase.InsertValue(sRepeat,"TITLE",HTMLDecode(Image.Name)) End Select Next Set oFolder = Nothing End If Set oFS = Nothing If intCounter > 0 Then Documents = sHeader & sRepeat & sFooter Else Documents = "" End If End Function Function Thumbnail(sID) sID = Replace(sID,"_dot_",".") sID = Replace(sID,"_space_","%20") Response.Write(sID) End Function Function EnquiryAdd(iID) Dim oEnquiries If IsObject(Session("enquiries")) Then Set oEnquiries = Session("enquiries") Else Set oEnquiries = Server.CreateObject("Scripting.Dictionary") End If If Not oEnquiries.Exists(iID) Then oEnquiries.Add iID,1 End If Set Session("enquiries") = oEnquiries Set oEnquiries = Nothing Response.Write("Item(s) added to enquiry items list. You can complete and send your enquiry by clicking on the 'enquiries' link at the top right-hand corner of the page.") End Function Function GetCatalogueID(iID) GetCatalogueID = oDB.GetValue(oConn,"catalogue_id","catalogue_categories","WHERE id = " & iID) End Function Function GetItemProperty(intID,strProperty) GetItemProperty = oDB.GetValue(oConn,strProperty,"catalogue_products","WHERE id = " & intID) End Function Function Authorize(nID) sReturn = False If oBase.IsAuthorized Then sReturn = True ElseIf Request.Form("username") <> "" And Request.Form("password") <> "" Then sQ = oDB.ExecuteQuery(oConn,"SELECT id FROM catalogue_setup WHERE id = " & nID & " AND private_username = '"&Request.Form("username")&"' AND private_password = '"&Request.Form("password")&"'") If IsArray(sQ) Then If sQ(0,0) = nID Then Session("PrivateUser") = Request.Form("username") Session("IsLoggedIn") = sQ(0,0) sReturn = True Else sReturn = False End If Else sReturn = False End If Else sReturn = False End If Response.Redirect(Request.ServerVariables("HTTP_REFERER")) End Function Function CartWidgetSmall intCounter = 0 sFile = oBase.LoadView("catalogue","widget",0) If IsObject(Session("iis_cart")) Then Set oCart = Session("iis_cart") intCounter = oCart.Count Set oCart = Nothing End If sFile = oBase.InsertValue(sFile,"COUNT",intCounter) Response.Write(sFile) End Function Function AddToCartWidget(intID) sFile = oBase.LoadView("catalogue","addtocart",0) sFile = oBase.InsertValue(sFile,"ID",intID) AddToCartWidget = sFile End Function Function Cart_Clear Session("iis_cart") = Null End Function Function Cart_Add(intID) If IsObject(Session("iis_cart")) Then Set oCart = Session("iis_cart") Else Set oCart = Server.CreateObject("Scripting.Dictionary") End If If oCart.Exists(intID) Then oCart(intID) = oCart(intID) + 1 Else oCart.Add intID, 1 End If Set Session("iis_cart") = oCart Set oCart = Nothing Response.Redirect(Request.ServerVariables("HTTP_REFERER") & "&msg=The item has been added to your cart") End Function Function Cart_View(nID) sFile = oBase.LoadView("catalogue","cart-view",1) aParts = DoSplit(sFile) sHeader = aParts(0) sFooter = aParts(2) If IsObject(Session("iis_cart")) Then Set oCart = Session("iis_cart") Else Set oCart = Server.CreateObject("Scripting.Dictionary") End If If oCart.Count > 0 Then intSubTotal = 0 For Each Item in oCart sRepeat = sRepeat & aParts(1) sRepeat = oBase.InsertValue(sRepeat,"TITLE",GetItemProperty(Item,"title")) sRepeat = oBase.InsertValue(sRepeat,"CATEGORY",GetCategoryProperty(GetItemProperty(Item,"category_id"),"title")) sRepeat = oBase.InsertValue(sRepeat,"QTY",oCart(Item)) sRepeat = oBase.InsertValue(sRepeat,"ID",Item) blnSpecial = GetItemProperty(Item,"on_special") If blnSpecial Then intPrice = GetItemProperty(Item,"special_price") Else intPrice = GetItemProperty(Item,"price") End If intLineTotal = intPrice * oCart(Item) intSubTotal = intSubTotal + intLineTotal sRepeat = oBase.InsertValue(sRepeat,"UNIT_PRICE","R " & FormatNumber(intPrice,2)) sRepeat = oBase.InsertValue(sRepeat,"LINE_TOTAL","R " & FormatNumber(intLineTotal,2)) Next sFooter = oBase.InsertValue(sFooter,"HASITEMS",True) sHeader = oBase.InsertValue(sHeader,"HASITEMS",True) sFooter = oBase.InsertValue(sFooter,"NOTHING",False) sFooter = oBase.InsertValue(sFooter,"SUB_TOTAL","R " & FormatNumber(intSubTotal,2)) Else sHeader = oBase.InsertValue(sHeader,"HASITEMS",False) sFooter = oBase.InsertValue(sFooter,"HASITEMS",False) sFooter = oBase.InsertValue(sFooter,"NOTHING",True) sFooter = oBase.InsertValue(sFooter,"SUB_TOTAL","") End If Set oCart = Nothing Response.Write(sHeader & sRepeat & sFooter) End Function Function Cart_Item_Delete(intID) If IsObject(Session("iis_cart")) Then Set oCart = Session("iis_cart") oCart.Remove(intID) Set Session("iis_cart") = oCart Set oCart = Nothing End If Response.Redirect(Request.ServerVariables("HTTP_REFERER")) End Function Function Cart_Item_Increase(intID) If IsObject(Session("iis_cart")) Then Set oCart = Session("iis_cart") oCart(intID) = oCart(intID) + 1 End If Set Session("iis_cart") = oCart Set oCart = Nothing Response.Redirect(Request.ServerVariables("HTTP_REFERER")) End Function Function Cart_Item_Decrease(intID) If IsObject(Session("iis_cart")) Then Set oCart = Session("iis_cart") If oCart(intID) = 1 Then oCart.Remove(intID) Else oCart(intID) = oCart(intID) - 1 End If Set Session("iis_cart") = oCart Set oCart = Nothing End If Response.Redirect(Request.ServerVariables("HTTP_REFERER")) End Function Function Checkout(nID) If Profiles.IsAuthorized Then Response.Write(ConfirmCheckout) Else sFile = oBase.LoadPageView("login",0) sFile = oBase.InsertValue(sFile,"RETURN_URL",URL2("catalogue","cart_view",1,"proceed_logged_in=1")) Response.Write(sFile) End If End Function Function ConfirmCheckout() Call Profiles.Authorize(False) sFile = oBase.LoadView("catalogue","confirm-cart",1) aParts = DoSplit(sFile) sHeader = aParts(0) sFooter = aParts(2) If IsObject(Session("iis_cart")) Then Set oCart = Session("iis_cart") Else Set oCart = Server.CreateObject("Scripting.Dictionary") End If If oCart.Count > 0 Then sHeader = oBase.InsertValue(sHeader,"NAME",Profiles.ProfileProperty(Session("logged_in_id"),"entity_name") & " " & Profiles.ProfileProperty(Session("logged_in_id"),"entity_surname")) sHeader = oBase.InsertValue(sHeader,"BILLING_ADDRESS",HTMLDecode(Replace(Profiles.ProfileProperty(Session("logged_in_id"),"address"),VbCrLf,"
    "))) sHeader = oBase.InsertValue(sHeader,"DELIVERY_ADDRESS",HTMLDecode(Profiles.ProfileProperty(Session("logged_in_id"),"address"))) intSubTotal = 0 For Each Item in oCart sRepeat = sRepeat & aParts(1) sRepeat = oBase.InsertValue(sRepeat,"TITLE",GetItemProperty(Item,"title")) sRepeat = oBase.InsertValue(sRepeat,"CATEGORY",GetCategoryProperty(GetItemProperty(Item,"category_id"),"title")) sRepeat = oBase.InsertValue(sRepeat,"QTY",oCart(Item)) sRepeat = oBase.InsertValue(sRepeat,"ID",Item) blnSpecial = GetItemProperty(Item,"on_special") If blnSpecial Then intPrice = GetItemProperty(Item,"special_price") Else intPrice = GetItemProperty(Item,"price") End If intLineTotal = intPrice * oCart(Item) intSubTotal = intSubTotal + intLineTotal sRepeat = oBase.InsertValue(sRepeat,"UNIT_PRICE","R " & FormatNumber(intPrice,2)) sRepeat = oBase.InsertValue(sRepeat,"LINE_TOTAL","R " & FormatNumber(intLineTotal,2)) Next sFooter = oBase.InsertValue(sFooter,"NOTHING",False) sFooter = oBase.InsertValue(sFooter,"SUB_TOTAL","R " & FormatNumber(intSubTotal,2)) Else sFooter = oBase.InsertValue(sFooter,"NOTHING",True) End If Set oCart = Nothing ConfirmCheckout = sHeader & sRepeat & sFooter End Function Function Confirm(nID) Set oOrder = Server.CreateObject("Scripting.Dictionary") oOrder.Add "profile_id", Session("logged_in_id") oOrder.Add "delivery_name", Request.Form("delivery_name") oOrder.Add "delivery_address", Request.Form("delivery_address") oOrder.Add "order_date", Date() intOrderID = oDB.ExecuteInsert(oConn,"catalogue_orders",oOrder) Set oOrder = Nothing If IsObject(Session("iis_cart")) Then Set oCart = Session("iis_cart") Else Set oCart = Server.CreateObject("Scripting.Dictionary") End If For Each Item in oCart blnSpecial = GetItemProperty(Item,"on_special") If blnSpecial Then intPrice = GetItemProperty(Item,"special_price") Else intPrice = GetItemProperty(Item,"price") End If intLineTotal = intPrice * oCart(Item) oDB.ExecuteNonQuery oConn,"INSERT INTO catalogue_order_products (order_id, product_id, quantity, unit_price) VALUES ("&intOrderID&","&Item&","&oCart(Item)&","&intPrice&")" Next Set oCart = Nothing sContent = oBase.LoadView("catalogue","thanks",0) sEmail = oBase.LoadView("catalogue","email-confirmation",0) strDeliveryAddress = Request.Form("delivery_address") strDeliveryName = Request.Form("delivery_name") oBase.SendEmail Array(C_COMPANY_NAME,C_COMPANY_EMAIL),Array(Profiles.ProfileProperty(Session("logged_in_id"),"entity_name"),Profiles.ProfileProperty(Session("logged_in_id"),"email_address")),"Order Confirmation",sEmail oBase.SendEmail Array(C_COMPANY_NAME,C_COMPANY_EMAIL),Array(Profiles.ProfileProperty(Session("logged_in_id"),"entity_name"),Profiles.ProfileProperty(Session("logged_in_id"),"email_address")),"Your "&C_COMPANY_NAME&" Order",SendOrderEmail(intOrderID, strDeliveryAddress, strDeliveryName) oBase.SendEmail Array(C_COMPANY_NAME,C_COMPANY_EMAIL),Array(C_COMPANY_NAME,C_COMPANY_EMAIL),"New Website Order",SendOrderEmail(intOrderID, strDeliveryAddress,strDeliveryName) Call Cart_Clear Response.Write(sContent) End Function Function SendOrderEmail(intOrderID, strDeliveryAddress, strDeliveryName) Call Profiles.Authorize(False) sFile = oBase.LoadView("catalogue","email-cart",1) aParts = DoSplit(sFile) sHeader = aParts(0) sFooter = aParts(2) If IsObject(Session("iis_cart")) Then Set oCart = Session("iis_cart") Else Set oCart = Server.CreateObject("Scripting.Dictionary") End If If oCart.Count > 0 Then sHeader = oBase.InsertValue(sHeader,"NAME",Profiles.ProfileProperty(Session("logged_in_id"),"entity_name") & " " & Profiles.ProfileProperty(Session("logged_in_id"),"entity_surname")) sHeader = oBase.InsertValue(sHeader,"BILLING_ADDRESS",HTMLDecode(Replace(Profiles.ProfileProperty(Session("logged_in_id"),"address"),VbCrLf,"
    "))) sHeader = oBase.InsertValue(sHeader,"DELIVERY_ADDRESS",Replace(strDeliveryAddress,VbCrLf,"
    ")) sHeader = oBase.InsertValue(sHeader,"DELIVERY_NAME",strDeliveryName) sHeader = oBase.InsertValue(sHeader,"ORDER_ID",intOrderID) intSubTotal = 0 For Each Item in oCart sRepeat = sRepeat & aParts(1) sRepeat = oBase.InsertValue(sRepeat,"TITLE",GetItemProperty(Item,"title")) sRepeat = oBase.InsertValue(sRepeat,"CATEGORY",GetCategoryProperty(GetItemProperty(Item,"category_id"),"title")) sRepeat = oBase.InsertValue(sRepeat,"QTY",oCart(Item)) sRepeat = oBase.InsertValue(sRepeat,"ID",Item) blnSpecial = GetItemProperty(Item,"on_special") If blnSpecial Then intPrice = GetItemProperty(Item,"special_price") Else intPrice = GetItemProperty(Item,"price") End If intLineTotal = intPrice * oCart(Item) intSubTotal = intSubTotal + intLineTotal sRepeat = oBase.InsertValue(sRepeat,"UNIT_PRICE","R " & FormatNumber(intPrice,2)) sRepeat = oBase.InsertValue(sRepeat,"LINE_TOTAL","R " & FormatNumber(intLineTotal,2)) Next sFooter = oBase.InsertValue(sFooter,"SUB_TOTAL","R " & FormatNumber(intSubTotal,2)) End If Set oCart = Nothing SendOrderEmail = sHeader & sRepeat & sFooter End Function End Class %>