%option explicit%>
<%
ShopCheckAdmin "shopa_stock.asp"
'***********************************************************
' VP-ASP Shop Administration
' Stock Low Report Summary
' inputs are table, database
' Version 6.50 Jan 21, 2004
' 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= getlang("LangstockInvalidStock")
end if
else
Stocklimit=getconfig("XstockLow") ' Default from shop$config
if isnumeric(Stocklimit) then
stocklimit= clng(stocklimit)
else
Serror= getlang("LangstockInvalidStock")
end if
end if
limit=request("Limit")
if limit="" then
limit=100 ' Stock display
end if
If not Isnumeric(limit) then
Serror= getlang("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
GenerateSQL
ShopOpendatabaseP dbc
Set rs = Server.CreateObject ("ADODB.Recordset")
rs.Open SQL, dbc, adOpenStatic,adLockReadOnly,adCmdtext
ReportHeader
if rs.eof then
Response.write "
" & getlang("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
GenerateDisplayHeader getlang("LangStock01")
GenerateDisplayBodyHeader
%>
<%=getlang("LangStockNum") & count %>
<% GenerateDisplayBodyFooter end sub ' Sub ProduceDetail dim count dim total dim nopayment count=0 total=0 nopayment=0 GenerateDisplayHeader getlang("LangStock01") GenerateDisplayBodyHeader 'VP-ASP 6.09 - for print friendly reports response.write "" FormatTableStart limit=clng(limit) While Not rs.EOF and count