<%option explicit%> <% Const FeaturetypeList="Dropdown,Checkbox,Radio,SelectList,Usertext,Userprice,Quantity,Multiplier,QtyProduct,Textarea" ShopCheckAdmin "shopa_editdisplay.asp" '******************************* ' VP-ASP 6.00 June 29, 2005 ' Display fields in one record of one table ' setting field to keyword "NULL" sets field to empty ' Feb 7, 2004 ' Sept 11, add Qtyproduct ' Dec 5, 2005 Fix featuremulti in non English environment ' May 30, 2005 add translink link '******************************* dim Addaction,Updateaction, Deleteaction dim rstemp dim which dim idfield dim dbtable, conn dim helpfile Dim featuretypes(20), yesnos(3), yesnocount, featuretypecount dim strfeaturenum, strfeatureprice, strfeatureid, strfeaturedefault Addaction=Request.form("add") Updateaction=Request.form("update") Deleteaction=request("delete") SetupDefaults GetInputValues If DeleteAction<>"" then DeleteRecord end if sError="" EditOpenDatabase conn, database,dbtable If Addaction = "" and Updateaction = "" Then AdminPageHeader GenerateForm AdminPageTrailer Else AdminPageHeader UpdateRecord GenerateForm AdminPageTrailer end if Shopclosedatabase conn '************************ Sub GetInputValues ' ID, allows editing a record which=request("which") 'VP-ASP 6.09 - Precautionary Security Fix if which > "" then If not isnumeric(which) then shoperror "ID must be numeric" end if end if idfield=request("idfield") dbtable= request("table") If idfield="" then dbtable="prodfeatures" idfield="id" end if database=request("database") ValidateTable if dbtable = "" then shoperror getlang("langeditselectfail") end if End Sub ' Sub ValidateTable '******************************************** 'See if user has access to this table Dim UserTables, i dim tablecount if getconfig("XRestrictAdminTables")<>"Yes" then exit sub UserTables=GetSess("UserTables") If Isnull(UserTables) then exit sub end if if UserTables="" then exit Sub else UserTables=split(GetSess("UserTables"),",",-1,1) end if tablecount=ubound(UserTables) for i = 0 to tablecount if ucase(dbtable)=ucase(Usertables(i)) then exit sub end if next 'Debugwrite "table being chnaged from " & dbtable dbtable="" end sub Sub GenerateForm dim sqltemp if which <> "" then sqltemp="select * from " & dbtable sqltemp=sqltemp & " where " & idfield & "=" & which 'Debugwrite sqltemp set rstemp=conn.execute(sqltemp) end if DisplayForm if which <> "" then rstemp.close set rstemp=nothing end if end Sub '**************************** Sub DisplayForm() strfeaturemulti=yesnos(1) strfeaturerequired=yesnos(1) strfeaturedefault=yesnos(1) if which <> "" then GetFieldvalue "featureid","id",strfeatureid GetFieldvalue "feature Number","featurenum",strfeaturenum GetFieldvalue "feature caption","featurecaption",strfeaturecaption GetFieldvalue "feature name","featurename",strfeaturename GetFieldvalue "feature price","featureprice",strfeatureprice GetFieldvalue "feature Type","featuretype",strfeaturetype GetFieldvalue "feature multi","featuremulti",strfeaturemulti ' not really a boolean field If strfeaturemulti="" then strfeaturemulti=yesnos(1) end if GetFieldvalue "feature required","featurerequired",strfeaturerequired ' in shopproductsubs CorrectBooleanProgram strfeaturerequired ' turn into yes no GetFieldvalue "feature image","featureimage",strfeatureimage GetFieldvalue "feature weight","featureweight",strfeatureweight GetFieldvalue getlang("LangOtherfields") & " ","featureother",strfeatureother GetFieldvalue getlang("LangOtherfields") & " 1","featureother1",strfeatureother1 GetFieldvalue getlang("LangOtherfields"),"featuredefault",strfeaturedefault GetFieldvalue "feature percent","featurepercent",strfeaturepercent if isnull(strfeaturedefault) then strfeaturedefault=0 end if CorrectBooleanProgram strfeaturedefault ' turn into yes no end if %>
<%shopwriteheader "Product Features Setup"%> <% if which<>"" then response.write "" end if response.write "" if which <> "" then response.write "" end if response.write "" %>
" & getlang("langadminadvanced") & " " & getlang("LangCommonEdit") & "Back To " & ucase(left(dbtable, 1)) & right(dbtable, len(dbtable) - 1) & "
<%shopwriteerror sError%>
<% response.write "
" ' shopwriteheader getlang("LangEdit02") GenerateDisplayHeader "Basic Information" GenerateDisplayBodyHeader response.write "
" If which<>"" then Response.Write("  ") Response.Write("") 'VP-ASP 6.50 - Moved Delete button to be on same line as Add and Update Response.Write("  ") Response.write "

" response.write "

" else Response.Write("") end if Response.Write "

" if which > "" then FormatEditRowStatic "","id",strfeatureid end if FormatEditRow getlang("LangProductfeature") & " " & getlang("Langcommonnumber"),"featurenum",strfeaturenum FormatEditRow getlang("LangProductFeature") & " " & getlang("langcommoncaption"),"featurecaption",strfeaturecaption 'VP-ASP 6.50 - changed to a text area 'FormatEditRow getlang("LangProductFeature") & " " & getlang("LangCommonName"),"featurename",strfeaturename FormatEditRowTextArea getlang("LangProductFeature") & " " & getlang("LangCommonName"),"featurename",strfeaturename FormatEditRow getlang("LangProductFeature") & " " & getlang("LangProductPrice"),"featureprice",strfeatureprice Response.write tablerow & tablecolumn & getlang("LangProductFeature") & " " & getlang("Langcommontype") & tablecolumnend & "") FormatEditRowBoolean getlang("langfeaturemultiple"),"featuremulti",strfeaturemulti, yesnos, yesnocount',helpfile FormatEditRowBoolean getlang("langfeaturerequired"),"featurerequired",strfeaturerequired, yesnos,yesnocount',helpfile FormatEditRowBoolean getlang("langfeaturedefault"),"featuredefault",strfeaturedefault, yesnos,yesnocount',helpfile FormatEditRow getlang("LangProductFeature") & " % ","featurepercent",strfeaturepercent FeatureRowImage getlang("LangProductFeature") & " " & getlang("LangProductImage"),"featureimage",strfeatureimage,"featureimage" FormatEditRow getlang("LangProductfeature") & " " & getlang("LangProductWeight"),"featureweight",strfeatureweight FormatEditRow getlang("LangOtherfields") & " ","featureother",strfeatureother FormatEditRow getlang("LangOtherfields") & " 1","featureother1",strfeatureother1 Response.Write(TableDefEnd & "

") response.write "
" If which<>"" then Response.Write("  ") Response.Write("") 'VP-ASP 6.50 - Moved Delete button to be on same line as Add and Update Response.Write("  ") Response.write "

" response.write "

" else Response.Write("") end if response.write "
" GenerateDisplayBodyFooter AddHiddenFields Response.Write("") AddtranslateLinkMenu conn, which, dbtable gethelp "prodfeatures" end sub '************ ' Sub UpdateRecord dim sqltemp 'VP-ASP 6.50 - broadened defintion of IF statement to cover cases where xmysql hasn't been set if ucase(xdatabasetype) = "MYSQL" OR ucase(xdatabasetype) = "MYSQL351" OR getconfig("xMYSQL")="Yes" then MYSQLProcessrecord updateaction, conn, dbtable, idfield, which exit sub end if If updateaction<>"" then sqltemp="select * from " & dbtable sqltemp= sqltemp & " where " & idfield & "=" & which Set rstemp = Server.CreateObject("ADODB.Recordset") rstemp.open sqltemp, conn, 1, 3 rstemp.Update else Set rstemp = Server.CreateObject("ADODB.Recordset") rstemp.open dbtable, conn, adOpenKeyset, adLockOptimistic rstemp.AddNew end if GenerateUpdateSQL which = rstemp(idfield) rstemp.close set rstemp=nothing sError= sError & "
" & getlang("LangEdit03") & "" end sub ' ******** general Sql Sub GenerateUpdateSQL() Dim howmanyfields dim fieldname, fieldvalue, fieldtype dim i howmanyfields=rstemp.fields.count -1 rstemp.update for i=1 to howmanyfields fieldname = rstemp(i).name fieldvalue = request.form(fieldname) fieldtype=rstemp(i).type Adjustfieldvalues fieldname, fieldvalue EUpdatefield fieldname,fieldvalue next rstemp.update end sub Sub EUpdateField (fieldname, fieldvalue) 'on error resume next 'Debugwrite fieldname & "value=" & fieldvalue if fieldvalue="" then rstemp(Fieldname)=NULL exit sub end if if ucase(fieldvalue)="NULL" then rstemp(Fieldname)=NULL else rstemp(Fieldname)=fieldvalue end if end sub Sub DeleteRecord dim myconn 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 GetFieldvalue (caption, fieldname, fieldvalue) fieldvalue=rstemp(fieldname) if isnull(fieldvalue) then fieldvalue="" end if end sub Sub SetupDefaults Parserecord featuretypelist, featuretypes, featuretypecount,"," Yesnos(0)=replace( getlang("langcommonYes")," ","") Yesnos(1)=replace( getlang("LangCommonNo")," ","") yesnocount=2 end sub Sub Adjustfieldvalues (fieldname, fieldvalue) select case fieldname case "featuremulti" If fieldvalue=yesnos(1) then fieldvalue="" else fieldvalue="Yes" end if ' fix boolean values case "featurerequired" If Fieldvalue=yesnos(0) then fieldvalue=1 else fieldvalue=0 end if case "featuredefault" If Fieldvalue=yesnos(0) then fieldvalue=1 else fieldvalue=0 end if end select end sub Sub AddHiddenFields Formathiddenfield "idfield",idfield Formathiddenfield "which",which Formathiddenfield "table",dbtable end sub Sub FormatHiddenField (fieldname, fieldvalue) response.write "" & vbcrlf end sub Sub FeatureRowImage (caption, fieldname, fieldvalue,dbfield) dim uploadurl dim imageurl imageurl="" uploadurl="" If fieldvalue<>"" then imageurl="" & getlang("langcommonview") & "" end if If Getconfig("xupload")="Yes" then 'if which<>"" then uploadurl="shopa_uploadpop.asp?form=editform&formfield=" & fieldname & "&id=" & which & "&field=" & dbfield & "&table=prodfeatures&idfield=id&url=" & server.urlencode("shopa_editprodfeatures.asp") 'end if end if Response.Write tablerow & tableColumn & caption & tablecolumnend response.write "" response.write "" end sub '************************************************************************************ ' Link to shopa_translatelist.asp if the product has been added '************************************************************************************ Sub AddtranslateLink If which="" then exit sub if getconfig("xtranslate")<>"Yes" then exit sub response.write "
" response.write "" & getlang("langadminlanguages") & "" end sub %>
" GenerateselectNV featuretypes,strfeaturetype,"featuretype",featuretypecount, "" response.write ("
" If uploadurl<>"" then ' Response.write "
" & getlang("langupload") & "

" Response.write " " & getlang("langupload") & "" end if If imageurl<>"" then response.write " " & imageurl end if response.write "