<% ShopCheckAdmin "shopa_editdisplay.asp" '************************************************************* ' Version 5.00 Adds a product to database ' July 8, 2003 ' Create a form ' Get fields from the form ' Update the table ' minor fixes Nov 19, 2003 '*************************************************************** Dim FeatureCount dim strcategorylist, strsubcategorylist Dim Features Dim dbtable Dim Actiontype, deleteaction Dim Which Dim arrFeatures Dim sAction Dim Cselect dim NoSubcategories Dim Productvalues,Productfieldcount Dim CurrentCategories(500), currentcategorycount Dim CurrentSubCategories(500), currentsubcategorycount Dim strbillprice,strinstallments,strinstallmenttype,strinstallmentinterval Dim Yesnos(2), yesnocount cSelect=getlang("LangCommonSelect") dim simplemode NoSubcategories=getlang("LangNoSubcategories") GetTable SetupYesnos Dim myconn sError="" SetSess "CurrentURL","shopa_addproduct.asp" dim helpfile helpfile="shopa_producthelp.htm" ShopOpenDatabase myconn GetFeatures ResetProductOtherValues sAction=Request.form("Update") Deleteaction=request("delete") If DeleteAction<>"" then DeleteRecord end if if sAction<>"" then sAction="FIX" else sAction=Request("Add") if sAction<>"" then sAction="ADD" end if end if If sAction = "" Then AdminPageHeader FormatEditHelpHeader if which<>"" then ' being called to update record GetExistingProduct end if DisplayForm AdminPageTrailer Else actiontype=sAction GetFormData ValidateData() AdminPageHeader FormatEditHelpHeader if sError = "" Then CorrectbooleanHuman boolhide UpdateProduct if ActionType="ADD" then serror= "Product " & strcname & getlang("LangProductAdded") & " catalogid=" & GetSess("Productid") & "
" else sError= "Product " & strcname & getlang("LangProductUpdated") & "catalogid=" & GetSess("Productid") & "
" end if GetExistingProduct else lngcatalogid=which end if DisplayForm AdminPageTrailer end if ShopClosedatabase myconn Sub GetTable dbtable = request.querystring("table") if dbtable="" then dbtable=request.form("dbtable") end if if dbtable="" then dbtable="products" end if Which=request("which") if which<>"" then SetSess "Productid",which ActionType="FIX" end if end sub Sub GetFormData lngCatalogid = Request.Form("lngCatalogid") strCcode = Request.Form("strCcode") strCname = Request.Form("strCname") memCdescription = Request.Form("memCdescription") curCprice = Request.Form("curCprice") strFeatures = Request.Form("strFeatures") arrFeatures = Request.Form("arrFeatures") strCimageurl = Request.Form("strCimageurl") strButtonimage = Request.Form("strButtonimage") datCdateavailable = Request.Form("datCdateavailable") lngCstock = Request.Form("lngCstock") lngCcategory = Request.Form("lngCcategory") strWeight = Request.Form("strWeight") strMfg = Request.Form("strMfg") strCdescurl = Request.Form("strCdescurl") lngSubcategoryid = Request.Form("Subcategoryid") strRetailPrice = Request.Form("strRetailPrice") strSpecialoffer = Request.Form("strSpecialOffer") strAllowUserText = Request.Form("strAllowUserText") strPother1 = Request.Form("strPother1") strPother2 = Request.Form("strPother2") strPother3 = Request.Form("strPother3") strPother4 = Request.Form("strPother4") strPother5 = Request.Form("strPother5") strlevel3 = Request.Form("strlevel3") strlevel4 = Request.Form("strlevel4") strlevel5 = Request.Form("strlevel5") strproductuserid = request.form("strproductuserid") strtemplate = request.form("strtemplate") memexdesc = request.form("memexdesc") strextendedimage = request.form("strextendedimage") strselectlist = request.form("strselectlist") strkeywords=request.form("strkeywords") strMinimumQuantity=request("strminimumquantity") strsupplierid=request("strsupplierid") if not isnumeric(strsupplierid) then strsupplierid=0 end if boolhide=request("boolhide") If Strsupplierid="" then if Getsess("Supplierid")<>"" then strsupplierid=getsess("Supplierid") end if end if strcrossselling=request("strcrossselling") strcategorylist=request("strcategorylist") strsubcategorylist=request("strsubcategorylist") strclanguage=request("strclanguage") strgroupfordiscount=request("strgroupfordiscount") strattachment=request("strattachment") strdownload=request("strdownload") strcustomermatch=request("strcustomermatch") strproductmatch=request("strproductmatch") If strsubcategorylist=cselect then strsubcategorylist="" end if strpoints=request("strpoints") strpointstobuy=request("strpointstobuy") strprice2=request("strprice2") strprice3=request("strprice3") strMaximumQuantity=request("strmaximumquantity") strbillprice=request("billprice") strinstallments=request("billinstallments") strinstallmenttype=request("billinstallmenttype") strinstallmentinterval=request("billinterval") strfrontpage=request("strfrontpage") GetProductOtherFields end sub Sub ValidateData sError="" if strcName="" Then sError = sError & getlang("LangProductname") & " " & getlang("langcustrequired") & "
" end if if memCdescription="" Then sError = sError & getlang("LangProductDescription") & " " & getlang("langcustrequired") & "
" end if if curCPrice="" then sError = sError & getlang("LangproductPrice") & " " & getlang("langcustrequired") & "
" else if Not IsNumeric(curcPrice) then sError = sError & getlang("LangUserPriceError") & " " & langproductprice & "
" end if end if if Request.Form("strCategoryList").Count =0 then sError = sError & getlang("LangProductCategory") & " " & getlang("langcustrequired") & "
" else If lngccAtegory=cSelect then sError = sError & getlang("LangProductCategory") & " " & getlang("langcustrequired") & "
" end if end if if datCdateavailable<>"" then if Not IsDate(datCdateavailable) then sError = sError & getlang("LangProductDateAvailable") & " " & getlang("LangInvaliddate") & "
" end if end if if lngcStock<>"" then if Not IsNumeric(lngcStock) then sError = sError & getlang("LangUserPriceError") & " " & getlang("langproductstock") & "
" end if end if If LngSubcategoryid=cSelect then lngsubcategoryid="" end if end sub Sub UpdateProduct if getconfig("xMYSQL")="Yes" then MYSQLUpdateproduct which=getsess("productid") exit sub end if dim sqlo dim rso dim filtersql GetProductFeatures Set objRS = Server.CreateObject("ADODB.Recordset") If ActionType="FIX" then filtersql ="select * from products Where catalogid=" & GetSess("productID") objRS.open filtersql, myconn, adOpenKeyset, adLockOptimistic objRS.Update else objRS.open "products", myconn, adOpenKeyset, adLockOptimistic objRS.AddNew end if pupdatefield "ccode", strccode pupdatefield "cname", strcname pupdatefield "cdescription", memcdescription pupdatefield "cprice", curcprice pupdatefield "ccategory", lngccategory pupdatefield "category", strcategory ' pupdatefield "features", strfeatures pupdatefield "cimageurl", strcimageurl pupdatefield "buttonimage", strbuttonimage pupdatefield "cdescurl", strcdescurl ' pupdatefield "cdateavailable", datcdateavailable pupdatefield "cstock", lngcstock pupdatefield "weight", strweight pupdatefield "mfg", strmfg ' pupdatefield "pother1", strpother1 pupdatefield "pother2", strpother2 pupdatefield "pother3", strpother3 pupdatefield "pother4", strpother4 pupdatefield "pother5", strpother5 pupdatefield "level3", strlevel3 pupdatefield "level4", strlevel4 pupdatefield "level5", strlevel5 pupdatefield "subcategoryid", 0 pupdatefield "specialoffer", strspecialoffer pupdatefield "retailprice", strretailprice pupdatefield "allowusertext", strallowusertext pupdatefield "template", strtemplate pupdatefield "extendeddesc", memexdesc pupdatefield "extendedimage", strextendedimage pupdatefield "selectlist", strselectlist pupdatefield "keywords", strkeywords pupdatefield "minimumquantity", strminimumquantity pupdatefield "supplierid", strsupplierid pupdatefield "crossselling", strcrossselling pupdatefield "clanguage", strclanguage pupdatefield "groupfordiscount", strgroupfordiscount pupdatefield "orderattachment", strattachment pupdatefield "orderdownload", strdownload pupdatefield "customermatch", strcustomermatch pupdatefield "productmatch", strproductmatch pupdatefield "hide", boolhide pupdatefield "points", strpoints pupdatefield "pointstobuy", strpointstobuy pupdatefield "price2", strprice2 pupdatefield "price3", strprice3 ' 5.0 pupdatefield "maximumquantity", strmaximumquantity pupdatefield "frontpage", strfrontpage pupdatefield "billprice",strbillprice pupdatefield "billinstallments",strinstallments pupdatefield "billinstallmenttype",strinstallmenttype pupdatefield "billinterval",strinstallmentinterval if strproductuserid="" then pupdatefield "userid", getsess("shopadmin") ' user that added product else pupdatefield "userid", strproductuserid ' user that added product end if UpdateProductOtherFields objrs objrs.update lngcatalogid=clng(objrs("catalogid")) which=lngcatalogid setsess "productid",lngcatalogid objrs.close set objrs=nothing UpdateCategory lngCatalogId, strCategoryList, strsubcategorylist end Sub ' Sub PUpdateField (fieldname, fieldvalue) 'debugwrite fieldname on error resume next if fieldvalue="" then objRS(Fieldname)=NULL exit sub end if 'Debugwrite fieldname & "value=" & fieldvalue if ucase(fieldvalue)="NULL" then objRS(Fieldname)=NULL else objRS(Fieldname)=fieldvalue end if end sub Sub DisplayForm dim featurevaluecount dim featurevalues Dim sRowColor sRowColor=getconfig("xTableRowColor") shopwriteHeader getlang("LangProductUpdate01") shopwriteerror sError if which<>"" then response.write "" & getlang("LangCommonEdit") & "  " end if response.write "" & getlang("LangEditSelectSetup") & "" if which="" then Response.Write("
") else Response.Write("") end if Response.Write tabledef if which<>"" or lngcatalogid<>"" then PCreateRowdisplay "Catalogid", "lngCatalogid", lngCatalogid end if '************ Start of Simple Mode ********************* pHeaderrow getlang("LangCommonRequired") PCreateRowText getlang("LangProductName"), "strCname", strCname,1,"" PCreateRowText getlang("LangProductDescription"), "memcdescription", memcdescription,3,"cdescription" PCreateRow getlang("LangProductPrice"),"curCprice", curCprice Response.write tablerow & tablecolumn & getlang("LangProductCategory") & tablecolumnend & "" GetCurrentCategories lngcatalogid GenerateSelectTableMULTCAT "categories","strcategorylist", Currentcategories,currentcategorycount,"","catdescription","categoryid","catdescription" response.write ("") FormatEditHelp "ccategory", helpfile Response.write "" pHeaderrow getlang("LangOtherFields") & " - " & LangProductImage PCreateRow getlang("LangProductCode"),"strCcode",strcCode '************* End if Simple mode ******************** ' If simplemode<>"Yes" then pcreaterow getlang("langproductextended"),"strcdescurl",strcdescurl PCreateRowText getlang("LangProductEXtendedDescription"), "memexdesc", memexdesc,3,"extendeddesc" PCreateRowimage getlang("LangProductImage"),"strcimageurl",strcimageurl,"cimageurl" PCreateRowimage getlang("LangProductOrderButton"), "strButtonimage",strButtonimage,"buttonimage" PCreateRowimage getlang("LangProductExtendedImage"),"strextendedimage",strExtendedImage,"extendedimage" pHeaderrow getlang("LangOtherFields") & " - " & LangProductProduct Response.write tablerow & tablecolumn & getlang("LangProductSubCategory") & tablecolumnend & "" GetCurrentSubCategories lngcatalogid GenerateSelectTableMULTSUBCAT "categories","strsubcategorylist", Currentsubcategories,currentsubcategorycount,cSelect,"catdescription","categoryid","catdescription" response.write ("") FormatEditHelp "subcategoryid", helpfile response.write("") PCreateRow getlang("LangProductFeatureNumber"),"strFeatures",strFeatures Response.write tablerow & tablecolumn & getlang("LangProductFeatures") & tablecolumnend & "" Featurevaluecount=0 GenerateSelectMult features,featurecount, Featurevalues,Featurevaluecount,"arrFeatures", "None" response.write ("") FormatEditHelp "strfeatures", helpfile response.write ("") PCreateRow getlang("LangProductRetailPrice"),"strRetailPrice",strRetailPrice PCreateRow getlang("LangProductPrice") & " " & 2,"strprice2",strprice2 PCreateRow getlang("LangProductPrice") & " " & 3,"strprice3",strprice3 pHeaderrow getlang("LangOtherFields") & " - " & LangAdminStock PCreateRow getlang("langProductStock"),"lngCstock", lngCstock PCreateRow getlang("LangProductWeight"),"strWeight", strWeight PCreateRow getlang("LangProductManu"),"strMfg",strMfg PCreateRow getlang("LangFrontpage"),"strfrontpage",strfrontpage If GetSess("Admintype")="SUPER" then If getconfig("xAddProductSupplierDropDown")="Yes" then Response.write tablerow & tablecolumn & getlang("LangSupplierNumber") & tablecolumnend & "" GenerateSelectTable "suppliers","strsupplierid", strsupplierid,cSelect,"name","supplierid","name" response.write ("") else PCreateRow getlang("LangSupplierNumber"),"strSupplierid",strsupplierid end if end if PHeaderRow getlang("LangOtherFields") PCreateRow getlang("LangCrossSelling"),"strCrossSelling",strCrossSelling PCreateRow getlang("LangProductDateavailable"),"datCdateavailable",datCdateavailable PCreateRow getlang("LangProductSelectList"),"strselectlist",strSelectList PCreateRow getlang("LangProductMinimumQuantity"),"strminimumquantity",strMinimumQuantity PCreateRow getlang("LangProductMaximumQuantity"),"strMaximumquantity",strMaximumQuantity '5.0 If boolhide="" then boolhide=yesnos(1) FormateditrowBoolean getlang("LangHideProduct"),"boolhide",boolhide,yesnos,yesnocount,helpfile PCreateRow getlang("LangProductOther1"),"strPother1", strPother1 PCreateRow getlang("LangProductOther2"),"strPother2",strPother2 PCreateRow getlang("LangProductOther3"),"strPother3",strPother3 PCreateRow getlang("LangProductOther4"),"strPother4",strPother4 PCreateRow getlang("LangProductOther5"),"strPother5",strPother5 PCreateRow getlang("LangOtherfields") & " 3" ,"strlevel3",strlevel3 PCreateRow getlang("LangOtherfields") & " 4" ,"strlevel4",strlevel4 PCreateRow getlang("LangOtherfields") & " 5" ,"strlevel5",strlevel5 PCreateRow getlang("LangProductSpecialOffer"),"strSpecialOffer",strSpecialoffer ' PCreateRow getlang("LangAllowUserText"),"strAllowUserText", strAllowUserText PCreateRow getlang("LangProductKeywords"),"strkeywords",strKeywords PHeaderRow "Advanced Fields" PCreateRow getlang("LangOrderattachment"),"strattachment",strattachment PCreateRow getlang("LangOrderdownload"),"strdownload",strdownload PCreateRow getlang("LangProductTemplate"),"strtemplate",strtemplate PCreateRow getlang("LangGroupForDiscount"),"strgroupfordiscount",strgroupfordiscount PCreateRow getlang("LangLanguage"),"strclanguage",strclanguage PCreateRow getlang("LangCustomermatch"),"strcustomermatch",strcustomermatch PCreateRow getlang("LangProductMatch"),"strproductmatch",strproductmatch PCreateRow getlang("LangPoints"),"strpoints",strpoints PCreateRow getlang("LangRedeemPoints"),"strpointstobuy",strpointstobuy If GetSess("Admintype")="SUPER" then PCreateRow getlang("LangProductUserid"),"strProductUserid",strProductUserid end if If getconfig("xbilling")="Yes" then PHeaderRow getlang("LangBillInstallments") PCreateRow getlang("LangBilling"),"billprice",strbillprice PCreateRow getlang("LangBillInstallments"),"billinstallments",strinstallments PCreateRow getlang("LangBillInstallmentType"),"billinstallmenttype",strinstallmenttype PCreateRow getlang("LangBillInterval"),"billinterval",strinstallmentinterval end if end if AddProductOtherfields ' Response.Write("

") Response.Write("") If lngcatalogid<>"" then Response.Write("  ") Response.Write("

") end if PCreateHiddenField "simplemode",simplemode Response.Write("

") End Sub Sub PCreateRow (caption, fieldname, fieldvalue) Response.Write tablerow & tableColumn & caption & tablecolumnend & "" & "" FormatEditHelp fieldname, helpfile Response.write "" end sub ' Sub PHeaderRow (caption) Response.Write ReportHeadrow & ReportHeadColumn & "" & caption & "" & tablecolumnend & tablecolumn & " " & ReportHeadColumnend & ReportrowEnd end sub Sub PCreateRowImage (caption, fieldname, fieldvalue,dbfield) dim uploadurl dim imageurl imageurl="" uploadurl="" If fieldvalue<>"" then imageurl="" & getlang("langcommonview") & "" end if If Getconfig("xupload")="Yes" then if lngcatalogid<>"" then uploadurl="shopa_upload.asp?id=" & lngcatalogid & "&field=" & dbfield & "&table=products&idfield=catalogid&url=" & server.urlencode("shopa_addproduct.asp") end if end if Response.Write tablerow & tableColumn & caption If imageurl<>"" then response.write "
" & imageurl end if If uploadurl<>"" then Response.write "
" & getlang("langupload") & "" end if Response.write tablecolumnend response.write "" response.write "" FormatEditHelp fieldname, helpfile response.write "" end sub '******************************** Sub GetFeatures dim sql dim rsCat sql = "select distinct featurenum, featurecaption from prodfeatures order by featurecaption" featurecount=0 Set rsCat = myconn.Execute(SQL) if not rscat.eof then redim Features(getconfig("xMaxFeatureCaptions")) else featurecount=0 end if Do While NOT rscat.EOF features(featurecount)= rscat("featurecaption") & " [" & rscat("featurenum") & "]" featurecount=featurecount+1 rscat.movenext loop rscat.close set rscat=nothing end sub Sub RowHeader (Header) Dim srowColor srowColor="FFFFFF" Response.Write("" & header &"") end sub ' Sub GetProductFeatures dim tempFeatures dim featurecount dim featurearry dim featurename dim featurenum dim i Dim FeaturesArray ' if user typed in features use it if strfeatures<>"" then exit sub end if FeatureCount = Request("arrFeatures").Count if Featurecount=0 then strfeatures="" exit sub end if tempFeatures=Request("arrFeatures") FeaturesArray= Split(tempFeatures, ", ", -1, 1) If FeaturesArray(0)="None" then strfeatures="" exit sub end if strfeatures="" for i = 0 to featurecount-1 ParseOption FeaturesArray(i), featurename, featurenum if strfeatures <>"" then strfeatures = strfeatures &"," end if strfeatures=strfeatures & featurenum next 'debugwrite strfeatures end sub ' Sub ParseOption (Productoption, OptionName, OptionPrice) ' Option is in Form option [$xx.yy] Dim spos, epos Dim namelength OptionPrice=0 Optionname=Productoption const bracket= "[" const bracketend= "]" spos = instr(1,Productoption, bracket) if spos=0 then exit sub end if Namelength=spos-1 If namelength> 0 then Optionname= mid(ProductOption,1,namelength) end if spos=spos+1 epos = instr(spos,ProductOption,bracketend) if epos=0 then exit sub end if Length=epos-spos OptionPrice=Mid(ProductOption,spos,length) 'Response.write OptionPrice end sub Sub GetExistingProduct dim getsql 'on error resume next lngcatalogid=GetSess("productid") getsql="select * from products where catalogid=" & lngcatalogid Set objRS = myconn.Execute(getsql) If objRS.EOF Then lngCatalogid = "" strCcode = "" strCname = "" memCdescription = "" curCprice = "" strFeatures = "" strCimageurl = "" strButtonimage = "" datCdateavailable = "" lngCstock = "" lngCcategory = "" strCategory = "" strWeight = "" strMfg = "" strCdescurl = "" strPother1 = "" strPother2 = "" strPother3 = "" lngSubcategoryID="" Else memcdescription = objrs("cdescription") memexdesc = objrs("extendeddesc") strproductuserid = objrs("userid") if isnull(strproductuserid) then strproductuserid="" end if if getsess("admintype")<>"SUPER" then if ucase(strproductuserid) <> ucase(getsess("shopadmin")) then objrs.close set objrs=nothing shopclosedatabase myconn responseredirect "shoperror.asp?msg=" & server.urlencode (getlang("langeditselectfail")) exit sub end if end if lngcatalogid = objrs("catalogid") strccode = objrs("ccode") strcname = objrs("cname") curcprice = objrs("cprice") strfeatures = objrs("features") strcimageurl = objrs("cimageurl") strbuttonimage = objrs("buttonimage") datcdateavailable = objrs("cdateavailable") lngcstock = objrs("cstock") lngccategory = objrs("ccategory") strcategory = objrs("category") strweight = objrs("weight") strmfg = objrs("mfg") strsupplierid=objrs("supplierid") strcrossselling=objrs("crossselling") strcdescurl = objrs("cdescurl") strpother1 = objrs("pother1") strpother2 = objrs("pother2") strpother3 = objrs("pother3") strpother4 = objrs("pother4") strpother5 = objrs("pother5") strlevel3 = objrs("level3") strlevel4 = objrs("level4") strlevel5 = objrs("level5") setsess "productid", lngcatalogid strspecialoffer = objrs("specialoffer") strallowusertext = objrs("allowusertext") strretailprice = objrs("retailprice") strproductuserid = objrs("userid") strtemplate = objrs("template") strextendedimage = objrs("extendedimage") strselectlist = objrs("selectlist") strkeywords= objrs("keywords") strminimumquantity = objrs("minimumquantity") boolhide = objrs("hide") CorrectBooleanProgram boolhide strclanguage=objrs("clanguage") strgroupfordiscount=objrs("groupfordiscount") strattachment=objrs("orderattachment") strdownload=objrs("orderdownload") strcustomermatch=objrs("customermatch") strproductmatch=objrs("productmatch") lngsubcategoryid=objrs("subcategoryid") if isnull(lngsubcategoryid) then lngsubcategoryid="" end if strpoints=objrs("points") strpointstobuy=objrs("pointstobuy") strprice2=objrs("price2") strprice3=objrs("price3") strmaximumquantity = objrs("maximumquantity") strfrontpage = objrs("frontpage") strbillprice=objrs("billprice") strinstallments=objrs("billinstallments") strinstallmenttype=objrs("billinstallmenttype") strinstallmentinterval=objrs("billinterval") GetProductOtherFieldsDb objrs End If End Sub 'objRS.close Sub AddOtherFields If otherfields="" then exit sub othercount=ubound(otherfields) dim i for i = 0 to othercount PCreateRow otherfields(i),otherfields(i),Othervalues(i) next end sub 'Add additional fields here Function GetOtherFields GetOtherfields="" 'GetOtherfields="abc","DEF") end function Sub UpdateCategory( lngCatalogId, Category, subcategories) dim cmd dim sql,i sql="delete from prodcategories where intcatalogid=" & lngcatalogid myconn.execute(sql) Category=Split(Category, ", ") LngcCategory=category(0) For i=0 to UBOUND(Category) sql="insert into prodcategories (intcategoryid,intcatalogid) values (" & category(i) & "," & lngcatalogid & ")" myconn.execute(sql) Next sql="Update products set ccategory=" & lngccategory & " where catalogid=" & lngcatalogid myconn.execute(sql) if subcategories="" then exit sub Category=Split(subcategories, ", ") LngcCategory=category(0) For i=0 to UBOUND(Category) sql="insert into prodcategories (intcategoryid,intcatalogid) values (" & category(i) & "," & lngcatalogid & ")" myconn.execute(sql) Next End Sub Sub GetCurrentCategories (catalogId) CurrentCategoryCount=0 dim catidRS, strsql If not isnumeric(catalogId) then exit sub if catalogid="" then exit sub strsql="SELECT prodcategories.intcategoryid " strsql=strsql & " FROM prodcategories, categories " strsql=strsql & " Where prodcategories.intcategoryid = categories.categoryid " strsql=strsql & " AND categories.highercategoryid=0 " strsql=strsql & " AND prodcategories.intcatalogid=" & catalogid 'debugwrite strsql Set catidRs=myconn.execute(strsql) do while not catidrs.eof CurrentCategories(currentcategorycount)=catidrs("intcategoryid") Currentcategorycount=currentcategorycount+1 catidrs.movenext loop catidrs.close set catidrs=nothing end sub Sub GetCurrentSubCategories (catalogId) CurrentSubCategoryCount=0 dim catidRS, strsql If not isnumeric(catalogId) then exit sub if catalogid="" then exit sub strsql="SELECT prodcategories.intcategoryid " strsql=strsql & " FROM prodcategories, categories " strsql=strsql & " Where prodcategories.intcategoryid = categories.categoryid " strsql=strsql & " AND categories.highercategoryid<>0 " strsql=strsql & " AND prodcategories.intcatalogid=" & catalogid 'debugwrite strsql Set catidRs=myconn.execute(strsql) do while not catidrs.eof CurrentsubCategories(currentsubcategorycount)=catidrs("intcategoryid") Currentsubcategorycount=currentsubcategorycount+1 catidrs.movenext loop catidrs.close set catidrs=nothing 'Debugwrite "subcatcount=" & currentsubcategorycount end sub Sub GenerateSelectTableMULTCAT (table, selectname, currentvalues, currentvaluecount,FirstField, sortfield, rsfieldname, rsdisplayfield) %> " genrs.close set genrs=nothing End Sub ' Sub GenerateSelectTableMULTSUBCAT (table, selectname, currentvalues, currentvaluecount,FirstField, sortfield, rsfieldname, rsdisplayfield) If getconfig("xaddproductsubcategorybycategory")="Yes" then if lngccategory="" then exit sub end if end if %> " genrs.close set genrs=nothing 'debugwrite gensql End Sub Sub GenerateSelectTable (table, selectname, currentvalue, Firstfield, sortfield, rsfieldname, rsdisplayfield) %> " exit sub end if end if end if 'debugwrite gensql Set genrs=myconn.execute(gensql) ' Generates Select with values Do while not genrs.eof rsfieldvalue=genrs(rsfieldname) displayfieldvalue=genrs(rsdisplayfield) If currentvalue= rsfieldvalue then response.write "" else response.write "" end if genrs.movenext loop response.write "" genrs.close set genrs=nothing End Sub Sub AddProductOtherFields dim words(50),wordcount, captions(50), capcount,i if getconfig("xProductOtherFields")<>"" then PHeaderRow "Customer Created Fields" Parserecord getconfig("xProductOtherFields"), words, wordcount,"," Parserecord getconfig("xProductOtherCaptions"), captions, capcount,"," for i = 0 to wordcount-1 If isarray(Productvalues) then PCreateRow captions(i),words(i), Productvalues(i) else PCreateRow captions(i),words(i), "" end if next end if end sub ' Sub GetProductOtherFields dim words(50),wordcount,i if getconfig("xProductOtherFields")="" then exit sub Parserecord getconfig("xProductOtherFields"), words, wordcount,"," If not isarray(productvalues) then redim Productvalues(wordcount) end if productfieldcount=wordcount for i = 0 to wordcount-1 productvalues(i)=request(words(i)) next End sub ' Sub GetProductOtherFieldsDB(objrs) dim words(50),wordcount,i on error resume next if getconfig("xProductOtherFields")="" then exit sub Parserecord getconfig("xProductOtherFields"), words, wordcount,"," If not isarray(productvalues) then redim Productvalues(wordcount) end if productfieldcount=wordcount for i = 0 to wordcount-1 productvalues(i)=objrs(words(i)) if isnull(productvalues(i)) then productvalues(i)="" end if next End sub Sub UpdateProductOtherFields (rs) on error resume next dim words(50),wordcount,i if getconfig("xProductOtherFields")="" then exit sub If not isarray(Productvalues) then exit sub Parserecord getconfig("xProductOtherFields"), words, wordcount,"," for i = 0 to wordcount-1 If Productvalues(i)<> "" then rs(words(i))=Productvalues(i) else rs(words(i))=NULL end if next end sub Sub ResetProductOtherValues Setsess "Productvalues","" simplemode=request("simplemode") If simplemode="" then simplemode=getconfig("xproductaddsimplemode") end if end sub Sub PCreateRowText (caption, fieldname, fieldvalue, rows, realname) dim url, htmlurl, linkurl url="shopa_addproduct.asp?which=" & which htmlurl="shopa_htmledit.asp?which=" & which & "&idfield=catalogid&table=products&fieldname=" & realname htmlurl=htmlurl & "&url=" & server.urlencode(url) Linkurl="" & "HTML edit" & "" Response.write tablerow & tablecolumn & caption If getconfig("xhtmleditor")="Yes" then If realname<>"" and which<>"" Then Response.write "
" & linkurl end if end if response.write tablecolumnend response.write "" response.write "" FormatEditHelp fieldname, helpfile response.write "" end sub Sub PCreateRowDisplay (caption, fieldname, fieldvalue) Response.write tablerow & tablecolumn & caption & tablecolumnend response.write tablecolumn & fieldvalue & tablecolumnend FormatEditHelp fieldname, helpfile Response.write tablerowend end sub Sub DeleteRecord dim myconn dim idfield idfield="catalogid" Gettable EditOpenDatabase myconn, database,dbtable dim sql, url sql="delete from " & dbtable & " where " & idfield & "=" & which myconn.execute(sql) shopclosedatabase myconn url="shopa_editdisplay.asp?table=" & dbtable responseredirect url end sub Sub PcreateHiddenField(fieldname, fieldvalue) response.write "" & vbcrlf end sub Sub SetupYesnos Yesnos(0)=replace(getlang("langcommonYes")," ","") Yesnos(1)=replace(getlang("LangCommonNo")," ","") Yesvalue=yesnos(0) novalue=yesnos(1) Yesnocount=2 end sub %>