<!--#include virtual="inc/dbConn.inc"-->
<%
'--+++--> Orders_ReceiveArray.asp
Response.Buffer = False '--+++--> HOLY SHIT!!!
Dim ar_LAPN, iCount
Dim ar_vCode(10), ar_vFName(10), ar_vActive(10), iVends
ar_LAPN = Split(Request.Form("LAPN"), ",")
iCount = Request.Form("iCount")
Dim ar_nVend00, ar_pVend00
ReDim ar_nVend00(10)
ReDim ar_pVend00(10)
Dim MyConn, MyQuery, mRS '-----> SQL Query Variables
set MyConn = Server.CreateObject("ADODB.Connection")
MyConn.Open(MySQL)
MyQuery = "SELECT VendorCode, VendorFName, Active, BorderColor, FontClass FROM VendorNames"
Set mRS = MyConn.Execute(MyQuery)
If mRS.BOF And mRS.EOF Then
Response.Write("MySQL Query Failed! " & MyQuery)
Response.End
Else
iVends = 0
mRS.MoveFirst
WHILE NOT mRS.EOF
ar_vActive(iVends) = mRS("Active") '--+++--> Add Column for Vendor X Only if They're Active
ar_vCode(iVends) = mRS("VendorCode")
ar_vFName(iVends) = mRS("VendorFName")
if ar_vActive(iVends) Then '--------------------------------------+++-->
ar_nVend00(iVends) = Request.Form("nVend00" & iVends)
ar_pVend00(iVends) = Request.Form("pVend00" & iVends)
end if
iVends = iVends + 1 '--+++--> This MUST be Here so the Vend00x Number Matches the db Info.
mRS.MoveNext
WEND
iVends = iVends - 1
End If
'============== MySQL TimeStamp Functions next 3
function mysqltimestamp(aspts)
dim thetime,thedate
aspts=cstr(aspts)
thedate=left(aspts,instr(aspts," ")-1)
thetime=right(aspts,len(aspts)-instr(aspts," "))
mysqltimestamp=mysqldate(thedate)&" "&mysqltime(thetime)
end function
function mysqlDate(d)
dim strNewDate
strNewDate = year( d ) & "-" & month( d ) & "-" & day(d)
mysqlDate = strNewDate
end function
function mysqlTime(t)
dim strSuffix, arTime, i, x
t = trim( Lcase( t ) )
if inStr( t, "pm" ) > 0 OR inStr( t, "am" ) > 0 then
strSuffix = right( t, 2 )
t = left( t, inStr( t, strSuffix ) -2 )
t = trim( t )
end if
for i = 1 to len( t )
x = mid( t, i, 1 )
if not isNumeric( x ) and x <> ":" then t = replace( t, x, "" )
next
arTime = split( t, ":" )
t = ""
for i = 0 to 2
if uBound( arTime ) < i then redim preserve arTime( i )
if i = 0 then
if strSuffix = "pm" and cInt( arTime( i ) ) < 12 then
arTime( i ) = cInt( arTime( i ) ) + 12
end if
end if
do until len( arTime( i ) ) = 2
arTime( i ) = "0" & arTime( i )
loop
t = t & arTime( i )
if i < 2 then t = t & ":"
next
arTime = null
if dir = 2 then t = t & " " & strSuffix
mysqlTime = t
end function
'============== END MySQL TimeStamp Functions
TimeDate = mysqltimestamp(Now)
%>
Production Parts Order<br>
<%
for iV=0 to iVends
Dim ar_nV, ar_pV
if ar_vActive(iV) Then '------( IF Vendor X IS Active )-------+++-->
ar_nV = Split(ar_nVend00(iV), ",")
ar_pV = Split(ar_pVend00(iV), ",")
for i=0 to iCount
if ar_nV(i) > 0 Then '--+++--> Create Entry Only IF the Part has a Quantity
MyQuery = "SELECT Printer, Description FROM Inventory WHERE LAPN = '" & ar_LAPN(i) & "'"
Set mRS = MyConn.Execute(MyQuery)
Printer = mRS("Printer")
Description = mRS("Description")
MyQuery = "INSERT INTO OrderHistory (LAPN, Printer, Description, Quantity, PriceEach, Vendor, timeStamp) " &_
"VALUES ('" & ar_LAPN(i) & "', '" & Printer & "', '" & Description & "', '" & ar_nV(i) &_
"', '" & ar_pV(i) & "', '" & ar_vFName(iV) & "', '" & TimeDate & "')"
MyConn.Execute(MyQuery)
' Response.Write(MyQuery & "<br>")
end if
next
end if
next
mRS.Close
MyConn.Close '------------> Close db Connection,
Set mRS = Nothing
Set MyConn = Nothing '----> Free Memory & Leave!
Response.Redirect "./"
%>