%option explicit%>
<%
ShopCheckAdmin "shopa_stock.asp"
'***********************************************************
' VP-ASP Shop Administration
' Stock Low Report Summary
' inputs are table, database
' Version 4.00
' invoked shopa_addproduct if table=products
'*************************************************************
Dim dbtable
Dim fields(10)
dim fieldcount
Dim File
Dim ScriptResponder
Dim Dbc
dim Action
dim Stocklimit
Dim Limit
Dim rs
dim Idfield
scriptresponder="shopa_addproduct.asp"
idfield="catalogID"
GetInput
If Action = "" or Serror<>"" Then
DisplayForm
Else
GenerateSQL
WriteReport
end if
'********************************
Sub GetInput
Serror=""
dbtable="Products"
action=request("summary")
if action<>"" then
action="SUMMARY"
else
action=request("Details")
if action<>"" then
action="DETAILS"
end if
end if
limit=100 ' Stock display
If action<>"" then
ValidateFields
end if
end sub
Sub ValidateFields
Stocklimit=request("StockLimit")
if Stocklimit<>"" then
if isnumeric(Stocklimit) then
stocklimit= clng(stocklimit)
else
Serror=LangstockInvalidStock
end if
else
Stocklimit=getconfig("XstockLow") ' Default from shop$config
if isnumeric(Stocklimit) then
stocklimit= clng(stocklimit)
else
Serror=LangstockInvalidStock
end if
end if
limit=request("Limit")
if limit="" then
limit=100 ' Stock display
end if
If not Isnumeric(limit) then
Serror=LangstockInvalidRow
end if
end sub
'
Sub GenerateSQL
dim limitsql
sql="select * from products "
if Stocklimit <> "" then
sql = sql & " Where cstock <= " & Stocklimit
end if
Sql = SQL & " order by " & idfield
'debugwrite sql
end sub
'
Sub WriteReport
' Generate table
AdminPageHeader
ShopOpendatabase dbc
Set rs = Server.CreateObject ("ADODB.Recordset")
rs.Open SQL, dbc, adOpenStatic,adLockReadOnly,adCmdtext
ReportHeader
if rs.eof then
Response.write "
" & LangStockNone & ""
else
If Action="SUMMARY" then
ProduceSummary
else
ProduceDetail
end if
end if
AdMinPageTrailer
end sub
'
Sub ReportHeader
end sub
'
Sub ProduceSummary
dim count
dim total
dim nopayment
count=0
total=0
nopayment=0
While Not rs.EOF
count=count+1
rs.movenext
wend
rs.close
shopclosedatabase dbc
response.write "
"
Response.write "
" & LangStockNum & count
response.write "