My Little Help Desk - ASP Help Forum
My Little Help Desk - ASP Help Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 My Little Help Desk - ASP Help
 Active Server Pages
 HTML and ASP HELP URGENTLY PLEASE
 New Topic  Reply to Topic
Author Topic  

darrylf290567

Australia
1 Posts

Posted - 10/24/2006 :  21:50:24  Show Profile  Reply with Quote
I am trying to write a calculated variable that is on a asp page and in the same page a procedure uses this variable to get the value out of it and place it in an xml file when the file has been created by this procedure. The variable name is TotalOrder and when you search for it in the asp file you will see. I tried to initialise it out of the while loop and even declared it in the asp page where its used and when it writes it out to the xml then the TotalOrder variable value is null. Maybe if you can analyse the code and come up with a solution it will be much appreciated.

Look for the words that I have placed in the below asp code to show you where the variable is:
'look at this variable

Please help as soon as possible. Thank you kindly for your assistance.

The asp file is shown below:

<!--#include file="../inc/adovbs.asp" -->
<!--#include file="../inc/std.asp" -->
<!--#include file="../inc/const.asp" -->

<!--#include file="../inc/securitycheck.asp" -->

<% if not security(sWarehouseManager) then response.redirect("/nosec.asp") %>

<html>
<head>
<title>
<% rw BrandName %>
</title>
<!--#include file="../inc/commonmenuscripts.asp" -->

<table width=<% = ScreenWidth %> border=0 cellpadding=0 cellspacing=0>
<tr valign=top>
<td width=<% = TableSpacing %>>
 
</td>


<td width=<% = TableWidth %> class="bodytext">

<!-- main page content -->

<span class="bodyhead">Despatch Order</span><p>

<%

Dim Section
Dim onorder
Dim inproduction
Dim StockSubData
Dim ID
Dim Override
Dim dbconn
Dim product
Dim NewCode
Dim rsSub
Dim SubError
Dim DetailID
Dim sqlSub
Dim rsDetail
Dim backOrdered
Dim sqlOrder
Dim rs
Dim rsShipTran
Dim rsTrans
Dim rsShip
Dim ShipTransID
Dim First
Dim FormError
Dim OrderFinished
Dim InputQty
Dim DespatchNum
Dim LastShortageDate
Dim LastStockTakeReqDate
Dim StockID
Dim Shipped
Dim Ordered
Dim reorder
Dim InStock
Dim NewBalance
Dim sqOrder
Dim rsOD
Dim FinDate
Dim ViewShipURL
Dim rsDeliverBy
Dim SQL
Dim rsCarriers
Dim deliverBy
Dim ShipmentOrderDetailID
Dim ShipmentOrderID
Dim ShipmentDate
Dim ShipmentQty
Dim TransQtyU
Dim TransLastStockTakeReqDate
Dim retval
Dim ShipTransFlag
Dim AddShipTransIDSQL
Dim DespatchEmailAddress
Dim DespatchEmailBody
Dim DespatchEmailSubject
Dim InputDiscountpercent
Dim InputFinalValue
Dim TotalOrder 'look at this variable


'These procedures are used to build and send the XML to send to Salmat

sub SubmitXMLToPrism()
Dim docPurchaser
Dim elPWCScript
Dim elFirstTable
Dim elSecondTable
Dim el1stChildUpdateForFirstTable
Dim el2ndChildUpdateForFirstTable
Dim childel1stUpdate
Dim childel2ndUpdate
Dim childel3rdUpdate
Dim childel4thUpdate
Dim childel5thUpdate
Dim childel6thUpdate
Dim elLineItem
Dim bOrderNumber, bJobNumber, bJobPart, bOpCode, bTotalQty, bRef
Dim sFilename
Dim sOldFilename
Dim fsoPurchaseOrder
Dim tsPurchaseOrder
Dim iDuplicate
Dim objPI
Dim i

bOrderNumber = false
bJobNumber = false
bJobPart = false
bOpCode = false
bTotalQty = false
bRef = false

'make sure all the required information is there
If ID > "" Then bOrderNumber = True
If Request ("jobnumber") > "" Then bJobNumber = True
If Request ("jobpart") > "" Then bJobPart = True
If Request ("opcode") > "" Then bOpCode = True
If Request ("txtTotalQty") > "" Then bTotalQty = True
If ID > "" Then bRef = True


'If (bOrderNumber AND bJobNumber AND bJobPart AND bOpCode AND bTotalQty AND bRef) Then
'all required information is present, let's build the xml document.
Set docPurchaseOrder = Server.CreateObject("MSXML2.DOMDocument")
Set elPWCScript = docPurchaseOrder.createElement("PWCScript")
docPurchaseOrder.appendChild elPWCScript
elPWCScript.setAttribute "Version", "181223"
Set elFirstTable = docPurchaseOrder.createElement("Table")
elPWCScript.appendChild elFirstTable
elFirstTable.setAttribute "Name", "FB"
elFirstTable.setAttribute "Action", "Add"

Set el1stChildUpdateForFirstTable = docPurchaseOrder.createElement("Update")
elFirstTable.appendChild el1stChildUpdateForFirstTable
el1stChildUpdateForFirstTable.setAttribute "Name", "FB_SHIFT"
el1stChildUpdateForFirstTable.setAttribute "Value", "PWC"

Set el2ndChildUpdateForFirstTable = docPurchaseOrder.createElement("Update")
elFirstTable.appendChild el2ndChildUpdateForFirstTable
el2ndChildUpdateForFirstTable.setAttribute "Name", "FB_DESC"
el2ndChildUpdateForFirstTable.setAttribute "Value", "My Inventory order#" & Request("ID")

Set elSecondTable = docPurchaseOrder.createElement("Table")
elFirstTable.appendChild elSecondTable
elSecondTable.setAttribute "Name", "FT"
elSecondTable.setAttribute "Action", "Add"

Set childel1stUpdate = docPurchaseOrder.createElement("Update")
elSecondTable.appendChild childel1stUpdate
childel1stUpdate.setAttribute "Name", "FT_EMP_CODE"
childel1stUpdate.setAttribute "Value", "PWC"

Set childel2ndUpdate = docPurchaseOrder.createElement("Update")
elSecondTable.appendChild childel2ndUpdate
childel2ndUpdate.setAttribute "Name", "FT_JOB_NUM"
childel2ndUpdate.setAttribute "Value", Request("jobnumber")

Set childel3rdUpdate = docPurchaseOrder.createElement("Update")
elSecondTable.appendChild childel3rdUpdate
childel3rdUpdate.setAttribute "Name", "FT_JOB_PART"
childel3rdUpdate.setAttribute "Value", Request("jobpart")

Set childel4thUpdate = docPurchaseOrder.createElement("Update")
elSecondTable.appendChild childel4thUpdate
childel4thUpdate.setAttribute "Name", "FT_OP_CODE"
childel4thUpdate.setAttribute "Value", Request("opcode")

Set childel5thUpdate = docPurchaseOrder.createElement("Update")
elSecondTable.appendChild childel5thUpdate
childel5thUpdate.setAttribute "Name", "FT_QTY"
childel5thUpdate.setAttribute "Value", TotalOrder 'look at this variable


Set childel6thUpdate = docPurchaseOrder.createElement("Update")
elSecondTable.appendChild childel6thUpdate
childel6thUpdate.setAttribute "Name", "FT_EXT_REF"
childel6thUpdate.setAttribute "Value", Request("ID")

'Create the xml processing instruction.
Set objPI = docPurchaseOrder.createProcessingInstruction("xml", "version='1.0'")

'Append the processing instruction to the XML document.
docPurchaseOrder.insertBefore objPI, docPurchaseOrder.childNodes(0)

'now let's persist the document to a file
sFilename = "C:\temp\"
sFilename = sFilename & "PWC_my_"
sFilename = sFilename & Request("ID")
sFilename = sFilename & "_"
sFilename = sFilename & DatePart("yyyy", Now())
sFilename = sFilename & DatePart("m", Now())
sFilename = sFilename & DatePart("d", Now())
sFilename = sFilename & "_"
sFilename = sFilename & DatePart("h", Now())
sFilename = sFilename & DatePart("n", Now())
sFilename = sFilename & DatePart("s", Now())
sOldFilename = sFilename
sFilename = sFilename & ".xml"
Set fsoPurchaseOrder = Server.CreateObject("Scripting.FileSystemObject")
iDuplicate = 1

While fsoPurchaseOrder.FileExists(sFilename)
sFilename = sOldFilename & "_" & iDuplicate & ".xml"
Wend
docPurchaseOrder.save sFilename
'end if
end sub



set StockSubData = CreateObject("Scripting.Dictionary")
ID = request("id")
Override = request("or") = "true"
set dbconn = Server.CreateObject("ADODB.Connection")

InputDiscountpercent = 0
InputFinalValue = 0
stopwatch "start"


dbconn.open ODBCsource

stopwatch "Connection created"


'--------------------------------------------------------------------------------
' Now perform the despatch
'--------------------------------------------------------------------------------

sqlOrder = "SELECT * FROM nDespatchOrder2 WHERE OrderID = " & ID & " AND WarehouseID = " & WarehouseID
PDebug sqlOrder
response.flush


set rs = Server.CreateObject("ADODB.Recordset")
rs.Open sqlOrder, dbconn, adCmdText
' rs.Open sqlOrder, dbconn, adOpenDynamic, AdLockPessimistic, adCmdText
stopwatch "nDespatchOrder2 open"


if rs.eof then
PrintError("Order detail not found.")
else
dbconn.BeginTrans
FormError = false
First = true
OrderFinished = true
ShipTransFlag = true ' this is set True outside the loop so only runs once and returne a ShipTransID
if isnumeric(request("shipcost")) then PackShipVal = request("shipcost")

if DevDebug then rw "<table border=1>"
stopwatch "begin creating shipment"
do while not rs.eof
Pdebug "IN THE LOOP NOW WITH TOTAL RECORD COUNT " & rs.recordcount
TransQtyU = 0
if Override then
InputQty = rs("Ordered") - rs("Shipped")
else
InputQty = trim(request("Q." & rs("OrderDetailID")))
if display_invoicemanage then
InputValue = trim(request("V." & rs("OrderDetailID")))
InputDiscountpercent = trim(request("dc" & rs("OrderDetailID")))
InputFinalValue = trim(request("fv" & rs("OrderDetailID")))
end if
end if

'rw "inputValue " & inputvalue
'rw "inputDiscountpercent " & InputDiscountpercent
'rw "inputFinalVale " & inputFinalValue

if isnumeric(InputQty) and len(InputQty) > 0 then
InputQty = clng(InputQty)
if InputQty > 0 then
if DevDebug then rw "<tr>"
DespatchNum = DespatchNum + 1
ShipmentOrderDetailID = rs("OrderDetailID")
ShipmentOrderID = rs("OrderID")
ShipmentDate = getnow()
ShipmentQty = InputQty
LastShortageDate=rs("LastShortageDate")
LastStocktakeReqDate=rs("LaststocktakeReqDate")
StockID = rs("StockID")
Shipped = rs("Shipped")
Ordered = rs("Ordered")
Reorder = rs("Reorder")
InStock = rs("InStock")
OnOrder = rs("OnOrder")
DeliverBy = rs("DeliverBy")
AssocCustID = rs("AssocCustID")
AssocCustName = rs("ClientName")
PDebug "Old OnOrder: " & OnOrder
PDebug "New OnOrder: " & OnOrder - InputQty
InProduction = clng(trim(rs("InProduction")))
Pdebug "stockid=" & stockid
Pdebug "InProduction=" & Inproduction
Pdebug "rs(InProduction)=" & rs("InProduction") & "."
if InputQty + Shipped > Ordered then
PrintError "<b>" & rs("StockName") & "</b> - you can not oversupply.<br>"
FormError = true
else
if InputQty > InStock then
PrintError "<b>" & rs("StockName") & "</b> - insufficient stock available.<br>"
FormError = true
else
if display_invoicemanage then ' check unit invoice value supplied
if isnumeric(InputValue) and len(InputValue) > 0 then
' Set unit value in OrderDetailID

SQL = "UPDATE OrderDetail SET UnitCost = '" & replace(InputValue, ",", "") & "' WHERE OrderDetailID = " & ShipmentOrderDetailID
dbconn.execute (SQL)
pdebug "using inputvalue " & SQL
else
printerror "<b>" & rs("StockName") & "</b> - you must supplied a unit value.<br>"
FormError = true
end if
end if
TransQtyU = InStock - InputQty
if DevDebug then rw "<td class=""bodytext"">" & StockID & "</td>"
if DevDebug then rw "<td class=""bodytext"">" & rs("StockName") & "</td>"
if DevDebug then rw "<td class=""bodytext"">" & InStock & "</td>"
if DevDebug then rw "<td class=""bodytext"">" & - InputQty & "</td>"
if DevDebug then rw "<td class=""bodytext"">" & InStock - InputQty & "</td>"
StockSubData.item(cstr(StockID)) = InStock - InputQty
end if
PDebug "STOCKID = " & stockid & "QTYU = " & TransQtyU & ", reorderlevel= " & (clng(reorder) * clng(StocktakeReqVariable) )
if (clng(TransQtyU) <= (clng(reorder) * clng(StocktakeReqVariable) ) ) then
TransLastStockTakeReqDate = TimSpecificFormatDate(getNow())
else
TransLastStockTakeReqDate = LastStocktakeReqDate
end if


'prepare the date values firstly
if not isNULL(LastShortageDate) then
LastShortageDate = "'" & DateToSQLFormat(LastShortageDate) & "'"
else
LastShortageDate = "NULL"
end if
if not isNULL(TransLastStockTakeReqDate) then
TransLastStockTakeReqDate = "'" & DateToSQLFormat(TransLastStockTakeReqDate) & "'"
else
TransLastStockTakeReqDate = "NULL"
end if

'-- add shipment record --

if not FormError then
' create ship trans header
If ShipTransFlag then 'only runs once
ShipTransFlag = false
set rsShipTran = dbconn.execute("EXEC AddShipTrans @Orderid=" & ShipmentOrderID & ", @UserID=" & UserID)
ShipTransID = clng(rsShipTran(0))
rsShipTran.close: set rsShipTran = nothing
Pdebug "ShipTransID: " & ShipTransID
retval = (CBool(dbconn.Errors.Count = 0)) 'returns true if no errors
If retval=false then
PrintError "Add shiptrans failed."
Pdebug dbconn.Errors(dbConn.Errors.Count-1).Description
end if

' create invoice header
if display_invoicemanage then
set rsInvoiceHeader = server.createObject("ADODB.recordset")
rsInvoiceHeader.Open "ClientInvoices", dbconn, adOpenKeyset, AdLockPessimistic, adCmdTable
rsInvoiceHeader.addnew
rsInvoiceHeader("UserID") = UserID
rsInvoiceHeader("ShipTransID") = ShipTransID
rsInvoiceHeader("ClientCustomerID") = AssocCustID
rsInvoiceHeader("TaxRate") = TaxRate
rsInvoiceHeader("PackShipVal") = PackShipVal
rsInvoiceHeader.update
HeaderID = rsInvoiceHeader("InvoiceID")
setPackShipTypeSQL = "UPDATE ClientInvoices SET PackShipDesc = (SELECT PackShipDesc FROM WarehousePackShip WHERE WarehousePackShipID = " & request("packtype") & ") WHERE InvoiceID = " & HeaderID
pdebug setPackShipTypeSQL
dbconn.execute(setPackShipTypeSQL)
rsInvoiceHeader.close
end if
end if

SQL = "AddShippedDetail @ShipTransID=" & ShipTransID & ", @orderDetailID=" & ShipmentOrderDetailID & ", @Qty=" & ShipmentQty
Pdebug SQL
dbconn.execute SQL
retval = (CBool(dbconn.Errors.Count = 0)) 'returns true if no errors
If retval=false then
PrintError "Add shipment failed."
Pdebug dbconn.Errors(dbConn.Errors.Count-1).Description
end if

'-- add transaction record --

SQL = "AddTransactionDespatch2 @CrossRef=" & ShipTransID & ", @warehouseid=" & warehouseID & ", @stockid=" & stockID & ", @QDelta=" & (-InputQty) & ", @QtyU=" & TransQtyU & ", @UserID=" & UserID & ", @Reorder=" & Reorder & ", @transtype=""Despatch"", @lastshortagedate=" & LastShortageDate & ", @Laststocktakereqdate=" & TransLastStockTakeReqDate & ", @InProduction=" & InProduction
Pdebug sql
dbconn.execute SQL
retval = (CBool(dbconn.Errors.Count = 0)) 'returns true if no errors
Pdebug "Retval= " & retval
if retval = false then
PrintError "Add transaction failed."
Pdebug dbconn.Errors(dbconn.Errors.Count-1).Description
end if



if display_invoicemanage then
set rsInvoiceItem = server.createObject("ADODB.recordset")
rsInvoiceItem.Open "ClientInvoiceItems", dbconn, adOpenKeyset, AdLockPessimistic, adCmdTable
rsInvoiceItem.addnew
rsInvoiceItem("NetValue") = InputValue * InputQty
rsInvoiceItem("TaxableValue") = InputValue * InputQty
rsInvoiceItem("Description") = rs("StockName")
rsInvoiceItem("SectionName") = rs("CategoryName")
rsInvoiceItem("Code") = rs("Code")
rsInvoiceItem("TaxCode") = 10
rsInvoiceItem("InvoiceID") = HeaderID
rsInvoiceItem("Qty") = InputQty
rsInvoiceItem("StockID") = stockID
if not isnull(InputDiscountpercent) and len(InputDiscountpercent) > 0 then
rsInvoiceItem("Discount") = InputDiscountpercent
else
rsInvoiceItem("Discount") = 0
end if
rsInvoiceItem.update
rsInvoiceItem.close
end if
else
Pdebug "AddShippedDetail not executed."
end if

end if
if DevDebug then rw "</tr>"
end if
elseif len(InputQty) > 0 then
PrintError "<b>" & rs("StockName") & "</b> - invalid quantity entered.<br>"
FormError = true
end if
pdebug "moving next"
rs.movenext
loop
stopwatch "shipment complete"

if DevDebug then rw "</table>"
if not FormError and DespatchNum = 0 then
PrintError "No items to despatch."
FormError = true
end if

if FormError or SubError then
PrintError "<p>Shipment <b>not</b> recorded due to one or more errors."
rw "<p align=right><a href=""javascript:window.history.back()"">Go Back</a></p>"
dbconn.RollbackTrans

elseif DespatchNum > 0 then
dbconn.execute("UpdateShipQty " & ID)
retval = (CBool(dbconn.Errors.Count = 0)) 'returns true if no errors
If retval=false then
PrintError "UpdateShipQty failed."
Pdebug dbconn.Errors(dbConn.Errors.Count-1).Description
end if

stopwatch "shipQty updated"

' check if order as completed
sqlOrder = "SELECT COUNT (*) AS RecCount FROM orderdetail WHERE" & _
" OrderID = " & ID & " AND QtyShipped < QtyU"
set rsOD = Server.CreateObject("ADODB.Recordset")
rsOD.Open sqlOrder, dbconn, adOpenKeyset, AdLockPessimistic, adCmdText
stopwatch "orderDetails to get count is open"
if rsOD("RecCount") = 0 then ' no outstanding line items
PDebug "Closing Order"
FinDate = getnow()
CloseSQL = "UPDATE Orders SET DateFilled = '" & year(FinDate) & _
"-" & month(FinDate) & "-" & day(FinDate) & " " & ConvertTimeonly(FinDate) & "' WHERE " & _
"OrderID = " & ID
PDebug CloseSQL
dbconn.execute(CloseSQL)

retval = (CBool(dbconn.Errors.Count = 0)) 'returns true if no errors
If retval=false then
PrintError "Update Orders failed."
Pdebug dbconn.Errors(dbConn.Errors.Count-1).Description
end if
end if
rsOD.close
set rsOD = nothing

stopwatch "orderdetails to get count is closed"
ViewShipURL = CurrentURL & "?pg=vs&id=" & ShipTransID
rw "<span style=""color: green;"">Goods successfully despatched.</span><p>"
rw "<table border=0 cellspacing=2 cellpadding=2>"
rw "<tr valign=top><td colspan=2>"
rw "The following document(s) will open in a new window suitable for printing.</td></tr>"
rw "<tr valign=top><td class=""tablehead"" width=100>Consignment  </td>"
rw "<td class=""bodytext"" width=150>"
rw "<a href=""../reports/shipadvice.asp?id=" & ShipTransID & """ target=""_blank"">" & ShipTransID & "</a>"
rw "</td></tr>"
if display_invoicemanage then
rw "<tr valign=top><td class=""tablehead"" width=100>Invoice  </td>"
rw "<td class=""bodytext"" width=150>"
rw "<a href=""../reports/viewinvoice.asp?id=" & HeaderID & "&ccid=" & AssocCustID & """ target=""_blank"">" & HeaderID & "</a>"
rw "</td></tr>"
end if
rw "</table><p><br>"
rw "<table border=0 cellspacing=2 cellpadding=2>"
rw "<tr valign=top><td colspan=2>"
rw "The following link(s) can be used to reload the required page in this window.</td></tr>"
rw "<tr valign=top><td class=""tablehead"" width=100>View Order  </td>"
rw "<td class=""bodytext"" width=150>"
rw "<a href=""vieworder.asp?id=" & ID & """>" & ID & "</a>"
rw "</td></tr>"
if display_invoicemanage then
rw "<tr valign=top><td class=""tablehead"" width=100>View Customer  </td>"
rw "<td class=""bodytext"" width=150>"
rw "<a href=""../contacts/custdetail.asp?id=" & AssocCustID & """>" & AssocCustName & "</a>"
rw "</td></tr>"
end if
rw "</table><p><br>"

'display the list of Carriers that the user can ship with
set rsCarriers = Server.CreateObject("ADODB.Recordset")
sql = "select carrierName, carrierid from nWarehouseCarrier where warehouseid = " & warehouseID
Pdebug sql
rsCarriers.Open sql, dbconn, adOpenForwardOnly, adLockReadOnly, adCmdtext

stopwatch "getting list of carriers"
Pdebug "select carrierName, carrierid from nWarehouseCarrier where warehouseid = " & warehouseID

if not rsCarriers.eof then

rw "<p><table>"

if len(DeliverBy) <> 0 then
rw "<tr><td COLSPAN=2 class=""bodytext"">The Client would like this order delivered by <span class=""error"">" & DeliverBY & "</span>. </td></tr>"
else
rw "<tr><td COLSPAN=2 class=""bodytext"">The Client has no delivery preference. </td></tr>"
end if
rw "<tr>"
rw "<td class=""bodytext"">Print Con Note via: </td><td class=""bodytext""> </td></tr>"

while not rsCarriers.eof
rw "<tr><td class=""bodytext""> </td><td class=""bodytext""><a href=""printConNote.asp?shid=" & shiptransid & "&id="& ID & "&CarrierID=" & rsCarriers("carrierid") & """>" & rsCarriers("CarrierName") & " </td></tr>"
rsCarriers.moveNext
wend
rw "</table>"
end if
rsCarriers.close
set rsCarriers = nothing
stopwatch "list of carriers obtained"

'dbconn.RollbackTrans '******* FOR TESTING ONLY*********
dbconn.CommitTrans

'firstly we want to get the order number that this con belongs to.
OrderSQL="SELECT ShippedDetail.ShipTransID,OrderDetail.OrderID,ShipTrans.ShippedDate" &_
" FROM (ShippedDetail INNER JOIN ShipTrans ON ShippedDetail.ShipTransID = ShipTrans.ShipTransID) INNER JOIN (OrderDetail INNER JOIN Orders ON OrderDetail.OrderID = Orders.OrderID) ON ShippedDetail.OrderDetailID = OrderDetail.OrderDetailID" &_
" WHERE ClientID = '" & ClientID & "'" & _
" GROUP BY ShippedDetail.ShipTransID,OrderDetail.OrderID, ShipTrans.ShippedDate" &_
" HAVING ShippedDetail.ShipTransID='" & ShipTransID & "'"

Pdebug OrderSQL & "<p>"

set rsConOrderID = Server.CreateObject("ADODB.Recordset")
rsConOrderID.Open OrderSQL, dbconn, adOpenKeyset, AdLockPessimistic, adCmdText
StopWatch("Loaded Recordset 1")

if rsConOrderID.eof then
PageError = true
PrintError "Order not found or detail deleted."
rw "<p align=right><a href=""javascript:window.history.back()"">Go Back</a></p>"
OrderID=0
ShippedDate="01/01/99" 'some crazy date
else
OrderID=rsConOrderID("OrderID")
ShippedDate=rsConOrderID("ShippedDate")
end if

rsConOrderID.close

'go and get all the orders from this con first ********************** group for duplicates
DetailSQLThisCon = "SELECT Stock.StockID, Stock.Code, Stock.StockName, sum(OrderDetail.QtyU) as Qtyu, Sum(OrderDetail.QtyShipped) as QtyShipped, Sum(ShippedDetail.Qty) as Qty, ShippedDetail.ShipTransID, Stock.ClientID" & _
" FROM (OrderDetail INNER JOIN Stock ON OrderDetail.StockID = Stock.StockID) INNER JOIN ShippedDetail ON OrderDetail.OrderDetailID = ShippedDetail.OrderDetailID" & _
" WHERE ((ShippedDetail.ShipTransID)=" & ShipTransID & ") " & _
" GROUP BY Stock.StockID, Stock.Code, Stock.StockName, OrderDetail.OrderID, Stock.ClientID , ShippedDetail.ShipTransID" & _
" ORDER BY Stock.StockName"


PDebug DetailSQLThisCon & "<p>"
set rsConDetailThisCon = Server.CreateObject("ADODB.Recordset")
rsConDetailThisCon.Open DetailSQLThisCon, dbconn, adOpenKeyset, AdLockPessimistic, adCmdText
StopWatch("Loaded Recordset 2")


'now go and get all shipped details from this order ********************** group for duplicates

DetailSQLThisOrder="SELECT Stock.StockID, Stock.Code, Stock.StockName, Sum(OrderDetail.qtyu) as qtyu, Sum(OrderDetail.QtyShipped) as QtyShipped, OrderDetail.OrderID, Stock.ClientID" & _
" FROM OrderDetail INNER JOIN Stock ON OrderDetail.StockID = Stock.StockID" & _
" WHERE (((OrderDetail.OrderID)=" & Orderid &"))" & _
" GROUP BY Stock.StockID, Stock.Code, Stock.StockName, OrderDetail.OrderID, Stock.ClientID" & _
" ORDER BY Stock.StockName"


'get some summary details about this con

SummarySQL = "SELECT Orders.OrderID, Orders.ClientID, Orders.WarehouseID, Orders.CustomerRef, Orders.DateEntered, Orders.DelAddID, Users.UsersName, Warehouse.WarehouseName, Orders.DeliverBy, Orders.ContactName, Orders.Country, Orders.Company, Orders.Address1, Orders.Address2, Orders.Suburb, Orders.ReceiverEmail, Orders.State, Orders.Postcode, Orders.Phone" & _
" FROM ((Orders INNER JOIN Users ON Orders.UserID = Users.UserID) INNER JOIN Warehouse ON Orders.WarehouseID = Warehouse.WarehouseID) " & _
" WHERE ((Orders.Deleted) Is Null) AND Orders.orderid=" & orderid

PDebug DetailSQLThisOrder & "<p>"
PDebug SummarySQL & "<p>"

Response.flush

set rsConDetailThisOrder = Server.CreateObject("ADODB.Recordset")
rsConDetailThisOrder.Open DetailSQLThisOrder, dbconn, adOpenKeyset, AdLockPessimistic, adCmdText
StopWatch("Loaded Recordset 3")
set rsConSummary = Server.CreateObject("ADODB.Recordset")
rsConSummary.Open SummarySQL, dbconn, adOpenKeyset, AdLockPessimistic, adCmdText
StopWatch("Loaded Recordset 4")

if rsConSummary.eof then
PageError = true
PrintError "Order not found or detail deleted."
rw "<p align=right><a href=""javascript:window.history.back()"">Go Back</a></p>"
else

'print data to screen
DespatchEmailAddress = rsConSummary("ReceiverEmail")
If not isnull(DespatchEmailAddress) then
DespatchEmailBody = "<table border=0 cellspacing=2 cellpadding=2>"
DespatchEmailBody = DespatchEmailBody & " <tr valign=top>"
DespatchEmailBody = DespatchEmailBody & " <td nowrap class=""tablehead""><span style=""color: white;"">Receiver</span></td>"
DespatchEmailBody = DespatchEmailBody & " </tr>"
if rsConSummary("DelAddID") = 0 then
Company = rsConSummary("Company")
Address1 = rsConSummary("Address1")
Address2 = rsConSummary("Address2")
Suburb = rsConSummary("Suburb")
State = rsConSummary("State")
'DespatchEmailAddress = rsConsummary("ReceiverEmail")
Country = rsConSummary("Country")
PC = rsConSummary("Postcode")
Phone = rsConSummary("Phone")
else
set rsA = dbconn.Execute("SELECT * FROM qryAddressBook" & " WHERE AddressID = " & rsConSummary("DelAddID"))
if not (rsA.eof and rsA.bof) then
Company = rsA("Company")
Address1 = rsA("Street1")
Address2 = rsA("Street2")
Suburb = rsA("Suburb")
State = rsA("State")
Country = rsA("Country")
PC = rsA("PC")
Phone = rsA("Phone")
end if
rsA.close
end if
if len(Company) > 0 then Address = Company & "<br>"
Address = Address & Address1 & "<br>"
if len(Address2) > 0 then Address = Address & Address2 & "<br>"

'POS system returns null suburb, so check 4 this

if suburb=NULL or suburb="" or suburb="NULL" then
Address = Address & " " & State & " " & PC & "<br>"
else
Address = Address & "" & ucase(Suburb) & " " & State & " " & PC & "<br>"
end if
Address = Address & Country

strShipAdviceQ = "<html><head>"
strShipAdviceQ = strShipAdviceQ & "<style> Body {font-size: 12px;"
strShipAdviceQ = strShipAdviceQ & "font-family: tahoma, arial, helvetica, sans-serif;"
strShipAdviceQ = strShipAdviceQ & " color: black; }"

strShipAdviceQ = strShipAdviceQ & "a:link {"
strShipAdviceQ = strShipAdviceQ & "color: #2244AA;"
strShipAdviceQ = strShipAdviceQ & " text-decoration: none;"
strShipAdviceQ = strShipAdviceQ & " }" & vbCrLf
strShipAdviceQ = strShipAdviceQ & " a:visited {"
strShipAdviceQ = strShipAdviceQ & " color: #2244AA;"
strShipAdviceQ = strShipAdviceQ & " text-decoration: none;"
strShipAdviceQ = strShipAdviceQ & " }" & vbCrLf
strShipAdviceQ = strShipAdviceQ & "a:hover {"
strShipAdviceQ = strShipAdviceQ & " text-decoration: underline;"
strShipAdviceQ = strShipAdviceQ & " }" & vbCrLf
strShipAdviceQ = strShipAdviceQ & "a:active{"
strShipAdviceQ = strShipAdviceQ & " color: #2244AA;"
strShipAdviceQ = strShipAdviceQ & " text-decoration: none;"
strShipAdviceQ = strShipAdviceQ & " }" & vbCrLf

strShipAdviceQ = strShipAdviceQ & ".openOrderLink:link {"
strShipAdviceQ = strShipAdviceQ & " color: #2244AA;"
strShipAdviceQ = strShipAdviceQ & " text-decoration: none;"
strShipAdviceQ = strShipAdviceQ & " }" & vbCrLf
strShipAdviceQ = strShipAdviceQ & ".openOrderLink:visited {"
strShipAdviceQ = strShipAdviceQ & " color: #cc00cc;"
strShipAdviceQ = strShipAdviceQ & " text-decoration: none;"
strShipAdviceQ = strShipAdviceQ & " }" & vbCrLf
strShipAdviceQ = strShipAdviceQ & ".openOrderLink:hover {"
strShipAdviceQ = strShipAdviceQ & " text-decoration: underline;"
strShipAdviceQ = strShipAdviceQ & " }" & vbCrLf
strShipAdviceQ = strShipAdviceQ & ".openOrderLink:active{"
strShipAdviceQ = strShipAdviceQ & " color: #2244AA;"
strShipAdviceQ = strShipAdviceQ & " text-decoration: none;"
strShipAdviceQ = strShipAdviceQ & " }" & vbCrLf
strShipAdviceQ = strShipAdviceQ & "h1 {font-size: 12px; font-weight:normal;}" & vbCrLf
strShipAdviceQ = strShipAdviceQ & "h2 {font-size: 14px; font-weight:normal;}" & vbCrLf
strShipAdviceQ = strShipAdviceQ & "h3 {font-size: 16px; font-weight: bold;}" & vbCrLf
strShipAdviceQ = strShipAdviceQ & "h4 {font-size: 18px; font-weight: bold;}" & vbCrLf
strShipAdviceQ = strShipAdviceQ & "h5 {font-size: 20px; font-weight: bold;}" & vbCrLf

strShipAdviceQ = strShipAdviceQ & ".error {"
strShipAdviceQ = strShipAdviceQ & " font-size: 12px;"
strShipAdviceQ = strShipAdviceQ & " color: red;"
strShipAdviceQ = strShipAdviceQ & " }" & vbCrLf

strShipAdviceQ = strShipAdviceQ & ".success {"
strShipAdviceQ = strShipAdviceQ & " font-size: 12px;"
strShipAdviceQ = strShipAdviceQ & " color: green;"
strShipAdviceQ = strShipAdviceQ & " }" & vbCrLf

strShipAdviceQ = strShipAdviceQ & ".debug {"
strShipAdviceQ = strShipAdviceQ & " font-size: 9pt;"
strShipAdviceQ = strShipAdviceQ & " font-family: tahoma, arial, helvetica, sans-serif;"
strShipAdviceQ = strShipAdviceQ & " color: green;"
strShipAdviceQ = strShipAdviceQ & " }" & vbCrLf

strShipAdviceQ = strShipAdviceQ & ".tablehead {"
strShipAdviceQ = strShipAdviceQ & " font-size: 12px;"
strShipAdviceQ = strShipAdviceQ & " font-weight: bold;"
strShipAdviceQ = strShipAdviceQ & " font-family: tahoma, arial, helvetica, sans-serif;"
strShipAdviceQ = strShipAdviceQ & " background-color:#000066;"
strShipAdviceQ = strShipAdviceQ & " color: white;"
strShipAdviceQ = strShipAdviceQ & " }" & vbCrLf

strShipAdviceQ = strShipAdviceQ & "a.tablehead:link {"
strShipAdviceQ = strShipAdviceQ & " color: white;"
strShipAdviceQ = strShipAdviceQ & " }" & vbCrLf

strShipAdviceQ = strShipAdviceQ & "a.tablehead:hover {"
strShipAdviceQ = strShipAdviceQ & " text-decoration: underline;"
strShipAdviceQ = strShipAdviceQ & " }" & vbCrLf

strShipAdviceQ = strShipAdviceQ & "a.tablehead:visited {"
strShipAdviceQ = strShipAdviceQ & " color: white;"
strShipAdviceQ = strShipAdviceQ & " }" & vbCrLf

strShipAdviceQ = strShipAdviceQ & "a.tablehead:active {"
strShipAdviceQ = strShipAdviceQ & " color: white;"
strShipAdviceQ = strShipAdviceQ & " }" & vbCrLf

strShipAdviceQ = strShipAdviceQ & " .tableCellNormal {font-family:Tahoma, Arial, Helvetica, sans-serif;font-weight:normal;font-size:10pt;}" & vbCrLf

strShipAdviceQ = strShipAdviceQ & ".tableCellColoured {font-family:Tahoma, Arial, Helvetica, sans-serif;font-weight:normal;font-size:10pt;background-color:#cccccc;}" & vbCrLf

strShipAdviceQ = strShipAdviceQ & ".small {"
strShipAdviceQ = strShipAdviceQ & " font-size: 10px;"
strShipAdviceQ = strShipAdviceQ & " font-family: tahoma, arial, helvetica, sans-serif;"
strShipAdviceQ = strShipAdviceQ & " color: black;"
strShipAdviceQ = strShipAdviceQ & " }" & vbCrLf

strShipAdviceQ = strShipAdviceQ & " .bodytext {"
strShipAdviceQ = strShipAdviceQ & " font-size: 12px;"
strShipAdviceQ = strShipAdviceQ & " font-family: tahoma, arial, helvetica, sans-serif;"
strShipAdviceQ = strShipAdviceQ & " color: black;"
strShipAdviceQ = strShipAdviceQ & " }" & vbCrLf

strShipAdviceQ = strShipAdviceQ & ".bodywhite {"
strShipAdviceQ = strShipAdviceQ & " font-size: 9pt;"
strShipAdviceQ = strShipAdviceQ & " font-family: tahoma, arial, helvetica, sans-serif;"
strShipAdviceQ = strShipAdviceQ & " color: white;"
strShipAdviceQ = strShipAdviceQ & " }" & vbCrLf

strShipAdviceQ = strShipAdviceQ & ".bodyhead {"
strShipAdviceQ = strShipAdviceQ & " font-size: 14px;"
strShipAdviceQ = strShipAdviceQ & " font-weight: bold;"
strShipAdviceQ = strShipAdviceQ & " text-decoration: underline;"
strShipAdviceQ = strShipAdviceQ & " font-family: tahoma, arial, helvetica, sans-serif;"
strShipAdviceQ = strShipAdviceQ & " color: black;"
strShipAdviceQ = strShipAdviceQ & " }" & vbCrLf

strShipAdviceQ = strShipAdviceQ & ".leftmenu {"
strShipAdviceQ = strShipAdviceQ & " font-size: 12px;"
strShipAdviceQ = strShipAdviceQ & " font-family: tahoma, arial, helvetica, sans-serif;"
strShipAdviceQ = strShipAdviceQ & " font-weight: normal;"
strShipAdviceQ = strShipAdviceQ & " }" & vbCrLf

strShipAdviceQ = strShipAdviceQ & ".topmenu {"
strShipAdviceQ = strShipAdviceQ & " font-size: 12px;"
strShipAdviceQ = strShipAdviceQ & " font-family: tahoma, arial, helvetica, sans-serif;"
strShipAdviceQ = strShipAdviceQ & " color: black;"
strShipAdviceQ = strShipAdviceQ & " }" & vbCrLf

strShipAdviceQ = strShipAdviceQ & "a.topmenu:link {"
strShipAdviceQ = strShipAdviceQ & " color: blue;"
strShipAdviceQ = strShipAdviceQ & " }" & vbCrLf

strShipAdviceQ = strShipAdviceQ & "a.topmenu:hover {"
strShipAdviceQ = strShipAdviceQ & " text-decoration: underline;"
strShipAdviceQ = strShipAdviceQ & " }" & vbCrLf

strShipAdviceQ = strShipAdviceQ & "a.topmenu:visited {"
strShipAdviceQ = strShipAdviceQ & " color: blue;"
strShipAdviceQ = strShipAdviceQ & " }" & vbCrLf

strShipAdviceQ = strShipAdviceQ & "a.topmenu:active {"
strShipAdviceQ = strShipAdviceQ & " color: blue;"
strShipAdviceQ = strShipAdviceQ & " }" & vbCrLf
strShipAdviceQ = strShipAdviceQ & "</style><head>"

ClientName = Session("brand")



' the above code is only for the style sheet etc
strShipAdviceQ = strShipAdviceQ & "<body>" & vbCrLf
DespatchEmailBody = strShipAdviceQ & "<span class=""bodyhead"" style=""font-size:16pt;"">Shipment Advice for " & ClientName & "</span><p>" & vbCrLf
DespatchEmailBody = DespatchEmailBody & " <tr valign=top>"
DespatchEmailBody = DespatchEmailBody & " <td class=""bodytext"">An order placed through MyInventory has been despatched. This notice is for your information only and no reply or action on your part is necessary.</td><p></tr>" & vbCrLf

DespatchEmailBody = DespatchEmailBody & " <tr><td class=""bodytext"">Your e-mail address was provided for notification by the person submitting the order.</td><p><p></tr>" & vbCrLf

DespatchEmailBody = DespatchEmailBody & " <tr><td class=""bodytext"">If you have any enquiries regarding this notice please contact the person named below.</td><p><p></tr>" & vbCrLf
DespatchEmailBody = DespatchEmailBody & " <tr><td class=""bodytext""> </td></tr><p><p>"
DespatchEmailBody = DespatchEmailBody & " <tr><td class=""bodytext"" style=""font-size:14pt;"">" & rsConSummary("ContactName") & "<br>" & Address & "</td>" & vbCrLf
DespatchEmailBody = DespatchEmailBody & " </tr></table><p>"

DespatchEmailBody = DespatchEmailBody & " <table border=0 cellspacing=2 cellpadding=2>" & vbCrLf
DespatchEmailBody = DespatchEmailBody & " <tr valign=top style=""background-color:#d1d6e6;"">" & vbCrLf



DespatchEmailBody = DespatchEmailBody & " <td nowrap class=""tablehead""><span style=""color: black; FONT-WEIGHT: bold; FONT-SIZE: 11px; FONT-FAMILY: tahoma, arial, helvetica, sans-serif; BACKGROUND-COLOR: #d1d6e6 "">Consignment Number</span></td>" & vbCrLf
DespatchEmailBody = DespatchEmailBody & " <td nowrap class=""tablehead""><span style=""color: black; FONT-WEIGHT: bold; FONT-SIZE: 11px; FONT-FAMILY: tahoma, arial, helvetica, sans-serif; BACKGROUND-COLOR: #d1d6e6 "">Order Number</span></td>" & vbCrLf
DespatchEmailBody = DespatchEmailBody & " <td nowrap class=""tablehead""><span style=""color: black; FONT-WEIGHT: bold; FONT-SIZE: 11px; FONT-FAMILY: tahoma, arial, helvetica, sans-serif; BACKGROUND-COLOR: #d1d6e6 "">Ship From</span></td>" & vbCrLf
DespatchEmailBody = DespatchEmailBody & " <td nowrap class=""tablehead""><span style=""color: black; FONT-WEIGHT: bold; FONT-SIZE: 11px; FONT-FAMILY: tahoma, arial, helvetica, sans-serif; BACKGROUND-COLOR: #d1d6e6 "">Ship Method</span></td>" & vbCrLf
DespatchEmailBody = DespatchEmailBody & " <td nowrap class=""tablehead""><span style=""color: black; FONT-WEIGHT: bold; FONT-SIZE: 11px; FONT-FAMILY: tahoma, arial, helvetica, sans-serif; BACKGROUND-COLOR: #d1d6e6 "">Customer Ref</span></td>" & vbCrLf
DespatchEmailBody = DespatchEmailBody & " </tr>"
DespatchEmailBody = DespatchEmailBody & " <tr valign=top>" & vbCrLf
DespatchEmailBody = DespatchEmailBody & " <td class=""bodytext"">" & rsConDetailThisCon("ShipTransId") & "</td>" & vbCrLf
DespatchEmailBody = DespatchEmailBody & " <td class=""bodytext"">" & rsConSummary("OrderID") & "</td>" & vbCrLf
DespatchEmailBody = DespatchEmailBody & " <td class=""bodytext"">" & rsConSummary("WarehouseName") & "</td>" & vbCrLf
DespatchEmailBody = DespatchEmailBody & " <td class=""bodytext"">" & rsConSummary("DeliverBy") & "</td>" & vbCrLf
DespatchEmailBody = DespatchEmailBody & " <td class=""bodytext"">" & vbCrLf
if not isnull(rsConSummary("CustomerRef")) then DespatchEmailBody = DespatchEmailBody & replace(rsConSummary("CustomerRef"), "/", " ")
DespatchEmailBody = DespatchEmailBody & "  </td>"
DespatchEmailBody = DespatchEmailBody & " </tr></table><br>"

DespatchEmailBody = DespatchEmailBody & " <table border=0 cellspacing=2 cellpadding=2>" & vbCrLf
DespatchEmailBody = DespatchEmailBody & " <tr valign=top style=""background-color:#d1d6e6;"">" & vbCrLf
DespatchEmailBody = DespatchEmailBody & " <td class=""tablehead""><span style=""color: black; FONT-WEIGHT: bold; FONT-SIZE: 11px; FONT-FAMILY: tahoma, arial, helvetica, sans-serif; BACKGROUND-COLOR: #d1d6e6 "">Entered By</span></td>" & vbCrLf
DespatchEmailBody = DespatchEmailBody & " <td class=""tablehead""><span style=""color: black; FONT-WEIGHT: bold; FONT-SIZE: 11px; FONT-FAMILY: tahoma, arial, helvetica, sans-serif; BACKGROUND-COLOR: #d1d6e6 "">Entered</span></td>" & vbCrLf
DespatchEmailBody = DespatchEmailBody & " <td class=""tablehead""><span style=""color: black; FONT-WEIGHT: bold; FONT-SIZE: 11px; FONT-FAMILY: tahoma, arial, helvetica, sans-serif; BACKGROUND-COLOR: #d1d6e6 "">Despatched</span></td>" & vbCrLf
DespatchEmailBody = DespatchEmailBody & " </tr>" & vbCrLf
DespatchEmailBody = DespatchEmailBody & " <tr valign=top>" & vbCrLf
DespatchEmailBody = DespatchEmailBody & " <td class=""bodytext"">" & rsConSummary("UsersName") & "</td>" & vbCrLf
DespatchEmailBody = DespatchEmailBody & " <td class=""bodytext"" nowrap>" & ConvertDate(rsConSummary("DateEntered")) & " " & ConvertTime(rsConSummary("DateEntered")) & " "
DespatchEmailBody = DespatchEmailBody & " <td class=""bodytext"" nowrap>" & ConvertDate(ShippedDate) & " " & ConvertTime(ShippedDate) & " "
DespatchEmailBody = DespatchEmailBody & " </tr></table><br><p>" & vbCrLf


WH = rsConSummary("WarehouseID")
DespatchEmailBody = DespatchEmailBody & " <table border=0 cellspacing=2 cellpadding=2>"

'display all from this order, filling in shipped qty where it was in this con.
do while not rsConDetailThisOrder.eof
StockID = rsConDetailThisOrder("StockID")
Code = rsConDetailThisOrder("Code")
Name = rsConDetailThisOrder("StockName")
Ordered = rsConDetailThisOrder("QtyU")

'if this shipment belongs to this con, then display it as being sent in this con.
' ok...this is how the following algorithm works. Designed by Tim Downing
' both the Order and Con record sets are ordered by stockname, but we will use numbers for this example.
' so if the first con is 3, then orders will check its first orders 1,2 and 3 against it until
' it finds the duplicate 3. whence it will display the shipped qty of con 3. Now that 3 has been covered we
' move onto the next con, which is 4, and onto the next order which is also 4, and wa-la another duplicate.
'
' This method allows us to check if an item was in the con, without having to check this item against
' all the items in the con, which is very time expensive!

if not rsConDetailThisCon.eof then

response.flush
if clng(rsConDetailThisOrder("StockID")) = clng(rsConDetailThisCon("StockID")) then
Shipped = rsConDetailThisCon("Qty")


rsConDetailThisCon.movenext

else
Shipped = 0
end if
else
Shipped=0 'cannot be in this con coz all the items in this con have been found duplicates already
end if

ShippedTotal = rsConDetailThisOrder("QtyShipped")
BackOrdered = Ordered - ShippedTotal

if ((shipped > 0) OR (backordered > 0)) then
CurItemNum = CurItemNum + 1
if (CurItemNum - 1) mod ListSize = 0 then
DespatchEmailBody = DespatchEmailBody & " <tr valign=top style=""background-color:#d1d6e6;"">" & vbCrLf
DespatchEmailBody = DespatchEmailBody & " <td width=20 class=""tablehead""><span style=""color: black; FONT-WEIGHT: bold; FONT-SIZE: 11px; FONT-FAMILY: tahoma, arial, helvetica, sans-serif; BACKGROUND-COLOR: #d1d6e6 "">Code</span></td>" & vbCrLf
DespatchEmailBody = DespatchEmailBody & " <td class=""tablehead""><span style=""color: black; FONT-WEIGHT: bold; FONT-SIZE: 11px; FONT-FAMILY: tahoma, arial, helvetica, sans-serif; BACKGROUND-COLOR: #d1d6e6 "">Description</span></td>" & vbCrLf
DespatchEmailBody = DespatchEmailBody & " <td width=20 class=""tablehead""><span style=""color: black; FONT-WEIGHT: bold; FONT-SIZE: 11px; FONT-FAMILY: tahoma, arial, helvetica, sans-serif; BACKGROUND-COLOR: #d1d6e6 "">Quantity<br>Ordered</span></td>" & vbCrLf
DespatchEmailBody = DespatchEmailBody & " <td width=20 class=""tablehead""><span style=""color: black; FONT-WEIGHT: bold; FONT-SIZE: 11px; FONT-FAMILY: tahoma, arial, helvetica, sans-serif; BACKGROUND-COLOR: #d1d6e6 "">Quantity<br>Shipped</span></td>" & vbCrLf
DespatchEmailBody = DespatchEmailBody & " <td width=20 class=""tablehead""><span style=""color: black; FONT-WEIGHT: bold; FONT-SIZE: 11px; FONT-FAMILY: tahoma, arial, helvetica, sans-serif; BACKGROUND-COLOR: #d1d6e6 "">Quantity<br>B/Ordered</span></td>" & vbCrLf
DespatchEmailBody = DespatchEmailBody & " </tr>"
end if

if CurItemNum mod 2 = 1 then RowStyle = " style=""background-color:#f2f2f2;""" else RowStyle = ""
DespatchEmailBody = DespatchEmailBody & " <tr valign=top" & RowStyle & ">"
DespatchEmailBody = DespatchEmailBody & "<td class=""bodytext"">" & Code & "</td>" & vbCrLf
DespatchEmailBody = DespatchEmailBody & " <td class=""bodytext"">" & Name & "</td>" & vbCrLf
DespatchEmailBody = DespatchEmailBody & " <td class=""bodytext"" align=right" & NumStyle & "> " & fnum(Ordered,0) & "</td>" & vbCrLf
DespatchEmailBody = DespatchEmailBody & " <td class=""bodytext"" align=right" & NumStyle & "> " & fnum(Shipped,0) & "</td>" & vbCrLf
DespatchEmailBody = DespatchEmailBody & " <td class=""bodytext"" align=right" & NumStyle & "> " & fnum(BackOrdered,0) & "</td>" & vbCrLf
DespatchEmailBody = DespatchEmailBody & " </tr>" & vbCrLf


TotalOrder = TotalOrder + Ordered 'look at this variable
TotalBackOrder = TotalBackOrder + BackOrdered
TotalShipped = TotalShipped + Shipped
end if
rsConDetailThisOrder.movenext
loop

'now display all the other shipped details in the order, which did not appear in the con
if CurItemNum > 0 then
DespatchEmailBody = DespatchEmailBody & " <tr><td class=""bodytext""><b>Total</b></td>" & vbCrLf
DespatchEmailBody = DespatchEmailBody & " <td class=""bodytext"">(" & CurItemNum & " Items)</td>" & vbCrLf
DespatchEmailBody = DespatchEmailBody & " <td align=right class=""bodytext""> <b>" & fnum(TotalOrder,0) & "</b></td>" & vbCrLf
DespatchEmailBody = DespatchEmailBody & " <td align=right class=""bodytext""> <b>" & fnum(TotalShipped,0) & "</b></td>" & vbCrLf
DespatchEmailBody = DespatchEmailBody & " <td align=right class=""bodytext""> <b>" & fnum(TotalBackOrder,0) & "</b></td>" & vbCrLf
DespatchEmailBody = DespatchEmailBody & " </tr>" & vbCrLf
else
DespatchEmailBody = DespatchEmailBody & " <tr><td colspan=2 class=""bodytext"">No Outstanding Items</td></tr>" & vbCrLf
end if
DespatchEmailBody = DespatchEmailBody & " </table><p>"
DespatchEmailBody = DespatchEmailBody & " <table><tr><td class=""bodytext""> --------------------------------------------------------------------------------------------------------</td></tr>" & vbCrLf
DespatchEmailBody = DespatchEmailBody & " <tr><td class=""bodytext""> System provided by My Inventory Pty Ltd </td></tr>" & vbCrLf
DespatchEmailBody = DespatchEmailBody & " <tr><td class=""bodytext""> w: <a href=""http://www.myinventory.com.au""> http://www.myinventory.com.au </a></td></tr>" & vbCrLf
DespatchEmailBody = DespatchEmailBody & " <tr><td class=""bodytext""> e: <a href=""mailto:info@myinventory.com.au"">info@myinventory.com.au</a></td></tr>" & vbCrLf
DespatchEmailBody = DespatchEmailBody & " </table></body></html>" & vbCrLf
DespatchEmailSubject = "MyI Shipment Advice for " & ClientName
pdebug "sending email at address " & despatchemailaddress

'SendEmail "ahmer.sajjad@danielspc.com.au", DespatchEmailSubject, DespatchEmailBody
SendEmail DespatchEmailAddress, DespatchEmailSubject, DespatchEmailBody

else

pdebug "no email address in the order table"
end if
end if

rsConDetailThisCon.close
rsConDetailThisOrder.close
rsConSummary.close

StopWatch("Finished displaying order")

else
PrintError "No items to despatch."
Pdebug "DespatchNum = 0 "
dbconn.rollbacktrans
end if


end if

SubmitXMLToPrism()

stopwatch "closing connections"
rs.close
set rs = nothing

dbconn.close
set dbconn = nothing

stopwatch "all closed"
%>

<!--#include file="../inc/postproc.asp" -->

<!-- end main content -->
</td>
</tr>
</table>

<!--#include file="../inc/commonmenuscriptsfooter.asp" -->
</body>
</html>


alorentz

66 Posts

Posted - 10/29/2006 :  07:24:51  Show Profile  Reply with Quote
Sorry for delay. Not sure if I understand, but it appears you are trying to use the TotalOrder variable in XML before you ever assign it a value. VBScript is processed top-down, and I don't see any functions or subs to initialize the variable before you use it in XML.
Go to Top of Page
  Topic  
 New Topic  Reply to Topic
Jump To:
My Little Help Desk - ASP Help Forum © mylittlehelpdesk.com Go To Top Of Page
Snitz Forums 2000