File: D:/web/castironradiatorcentre/changes prev/2024-02-29 (copies)/tested-rads3 - Copy (4).asp
<%Option Explicit%>
<!--#include file="dbfunctions.asp"-->
<!--#include file="apputils.asp"-->
<!--#include file="customutils.asp"-->
<%DisableCache%>
<%
' (SS,02/11/22) New, based on Tested Rads Shopping Admin report
' (SS,07/03/23) Added Untested Stock Locations
' (SS,22/03/23) Removed Locations column, made correction to value shown in brackets in Untested Stock Locations column
' (SS,30/03/23) Modified to default to "Required Only" checked by default, awkward change, had to add a hidden form element
Dim L_HideFieldList
L_HideFieldList = ""
' (SS,7/3/23)
Dim FHasUntestedLiveStock
%>
<html>
<head>
<title>Tested Radiators Expected Stock</title>
<link href="css/all.min.css" rel="stylesheet" />
<script src="https://code.jquery.com/jquery.min.js"></script>
<style>
.table td, .table th {
text-align: center;
}
.table2 th {
text-align: right;
}
/* (SS,22/3/23) */
.location-clamp {
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
overflow: hidden;
}
</style>
</head>
<body>
<div class="container-fluid">
<h2>Tested Radiators Expected Stock</h2>
<form method="get" name="frmChoice" class="form-inline">
<%
Dim LShowRequiredOnly, LShowStockLevel
LShowRequiredOnly = L_CheckedValue("requiredonly", True)
LShowStockLevel = L_CheckedValue("stocklevel", False)
%>
<label class="checkbox-inline">
<input type="checkbox" class="form-check-input" id="id_requiredonly" onchange="itp_submit()">Required Only
</label>
<label class="checkbox-inline">
<input type="checkbox" class="form-check-input" id="stocklevel" name="stocklevel" value="yes" onchange="itp_submit()">Running Stock Level
</label>
<!-- <button type="submit" class="btn btn-default">Submit</button> -->
<input type="hidden" name="requiredonly" value="">
</form>
<script>
$('#id_requiredonly').prop('checked', <%=L_BoolToJS(LShowRequiredOnly)%>);
$('#stocklevel').prop('checked', <%=L_BoolToJS(LShowStockLevel)%>);
function itp_submit()
{
var itp_requiredonly_value;
if ($('#id_requiredonly').prop('checked')) {
itp_requiredonly_value = "yes"
}
else {
itp_requiredonly_value = "no"
}
// alert(itp_requiredonly_value);
document.frmChoice.requiredonly.value = itp_requiredonly_value;
document.frmChoice.submit();
}
</script>
<%
Dim LSQL
LSQL = GetTestedRadsSQL
Dim L_DataArray, L_FieldCount, L_ExtraFieldCount, L_RecordCount
L_HideFieldList = "SortOrder,ProductID"
' L_ShowTable LSQL
Dim LExtraFieldList
LExtraFieldList = GetPicklistColumns
' (SS,7/3/23) added new Untested Stock Location column to populate later
LExtraFieldList = LExtraFieldList + ",Untested Stock Locations"
'Response.Write "###" & LExtraFieldList & "###" & BR
L_CopySQLToArray LSQL, LExtraFieldList
AddPicklists
SetMiscFields
L_ShowTableFromArray
%>
<script>
$('.location-clamp-select').click(function () {
$(this).toggleClass("location-clamp");
});
</script>
<%Finalise%>
</div>
</body>
</html>
<%
' (SS,2/11/22)
Function GetTestedRadsSQL
Dim LSQL
LSQL = "SELECT tr.*, p.ProductCode, pa.AttributeValue AS Style, p.SortOrder " &_
"FROM tested_rads tr " &_
"INNER JOIN products p ON p.ProductID = tr.ProductID " &_
"INNER JOIN product_attributes pa ON pa.ProductID = p.ProductID AND pa.AttributeID = 8 " &_
"ORDER BY p.SortOrder, ProductID, Primer, Sections DESC"
' (SS,22/3/23) removed Location from between Primer and ThreeWeeksStock
LSQL = "SELECT SortOrder, ProductID, Style, Primer, Sections, ThreeWeeksStock AS `Three~Weeks~Stock`, MinStock AS `Min~Stock`, ShelfStock AS `Shelf~Stock` FROM (" &_
LSQL & ") a " &_
"ORDER BY SortOrder, ProductID, Primer, Sections DESC"
GetTestedRadsSQL = LSQL
End Function
' (SS,2/11/22)
Function L_InFieldList(AFieldName)
L_InFieldList = InStr("," + L_HideFieldList + ",", "," + AFieldName + ",") = 0
End Function
' (SS,2/11/22)
Sub L_CopySQLToArray(ASQL, AExtraFieldList)
L_RecordCount = 0
OpenQuery(ASQL)
Do While Not EndOfQuery
NextQueryRecord
L_RecordCount = L_RecordCount + 1
Loop
' oRS is global reference to record set used by OpenQuery (untidy I know)
' Response.Write "###" & L_RecordCount & "###" & BR
' get field names
Dim r, f, LFieldName, LFieldValue
L_FieldCount = oRS.Fields.Count
' count extra fields
Dim aSplit, n
aSplit = Split(AExtraFieldList, ",")
If IsArray(aSplit) Then
L_ExtraFieldCount = UBound(aSplit) + 1
Else
L_ExtraFieldCount = 0
End If
' set the data array size
' L_RecordCount + 1 used for total row at the end
Redim L_DataArray(L_FieldCount + L_ExtraFieldCount, L_RecordCount + 1)
For f = 0 To L_FieldCount - 1
LFieldName = oRS.Fields.Item(f).Name
' save in first record in array
L_DataArray(f, 0) = LFieldName
' Response.Write "###" & LFieldName & "###" & BR
Next
If L_ExtraFieldCount > 0 Then
For n = 0 To L_ExtraFieldCount - 1
' save in first record in array
L_DataArray(L_FieldCount + n, 0) = aSplit(n)
' Response.Write "###" & aSplit(n) & "###" & BR
Next
End If
CloseQuery
' copy each record, field by field to array
OpenQuery(ASQL)
r = 0
Do While Not EndOfQuery
r = r + 1
For f = 0 To L_FieldCount - 1
LFieldValue = oRS.Fields.Item(f).Value
L_DataArray(f, r) = LFieldValue
Next
NextQueryRecord
Loop
CloseQuery
' fill in extra fields with 0
For r = 1 To L_RecordCount
For f = L_FieldCount To L_FieldCount + L_ExtraFieldCount
L_DataArray(f, r) = 0
Next
Next
End Sub
' (SS,2/11/22)
Function GetPicklistColumns
Dim LSQL, LList
LSQL = "SELECT IF(o.PickListID IS NULL, 'NOP', o.PickListID) AS Picklist " &_
"FROM orders o " &_
"INNER JOIN orderdetails od ON od.OrderNo = o.OrderNo " &_
"INNER JOIN products p ON p.ProductID = od.ProductID " &_
"LEFT JOIN product_attributes pa ON pa.ProductID = od.ProductID AND pa.AttributeID = 1 " &_
"LEFT JOIN order_progress_pick_lists pl ON pl.PickListID = o.PickListID " &_
"LEFT JOIN tested_rads_picked trp ON trp.PickListID = o.PickListID " &_
"INNER JOIN order_detail_options odo ON odo.OrderDetailID = od.OrderDetailID AND odo.OptionName = 'Sections' " &_
"WHERE (o.PickListID IS NOT NULL AND trp.PickListID IS NULL ) OR (o.PickListID IS NULL AND o.PaymentReceived AND o.Status <> 'CANCELLED' AND o.Status <> 'COMPLETED' AND o.ReadyForDespatch IS NULL) " &_
"GROUP BY Picklist"
LList = ""
OpenQuery(LSQL)
Do While Not EndOfQuery
If LList <> "" Then LList = LList & ","
LList = LList & GetQueryValue("Picklist")
NextQueryRecord
Loop
CloseQuery
' add SOLD and REQ (later Unsold~Shelf~Stock)
If LList <> "" Then LList = LList & ","
LList = LList & "Unsold~Shelf~Stock,Sold,REQ"
GetPicklistColumns = LList
End Function
' (SS,2/11/22)
Sub AddPicklists
Const PRODUCT_ID = 1, PRIMER = 3, SECTIONS = 4
Dim LSQL, LProductID, LPrimer, LSections, LRads, LPicklist
Dim r, f, LSoldIndex
LSoldIndex = GetArrayFieldIndex("Sold")
LSQL = "SELECT IF(o.PickListID IS NULL, 'NOP', o.PickListID) AS PickListID, pl.PickListDate, od.ProductID, od.ProductCode, " &_
"IF(odo2.OptionValue LIKE '%white%', 'White', 'Black') AS Primer, CONVERT(odo.OptionValue, UNSIGNED) AS Sections, " &_
"SUM(od.Qty - od.QtyRestocked) AS Rads " &_
"FROM orders o " &_
"INNER JOIN orderdetails od ON od.OrderNo = o.OrderNo " &_
"INNER JOIN products p ON p.ProductID = od.ProductID " &_
"LEFT JOIN product_attributes pa ON pa.ProductID = od.ProductID AND pa.AttributeID = 1 " &_
"LEFT JOIN order_progress_pick_lists pl ON pl.PickListID = o.PickListID " &_
"LEFT JOIN tested_rads_picked trp ON trp.PickListID = o.PickListID " &_
"INNER JOIN order_detail_options odo ON odo.OrderDetailID = od.OrderDetailID AND odo.OptionName = 'Sections' " &_
"INNER JOIN order_detail_options odo2 ON odo2.OrderDetailID = od.OrderDetailID AND odo2.OptionName = 'Paint Finish' " &_
"WHERE ((o.PickListID IS NOT NULL AND trp.PickListID IS NULL ) OR (o.PickListID IS NULL AND o.PaymentReceived AND o.Status <> 'CANCELLED' AND o.Status <> 'COMPLETED' AND o.ReadyForDespatch IS NULL)) AND AttributeValue = 'Radiator' AND SubproductOrderDetailID IS NULL " &_
"GROUP BY PickListID, ProductID, ProductCode, Primer, Sections DESC"
OpenQuery(LSQL)
Do While Not EndOfQuery
LPicklist = GetQueryValue("PicklistID")
LProductID = GetQueryValue("ProductID")
LPrimer = GetQueryValue("Primer")
LSections = GetQueryValue("Sections")
LRads = CLng(GetQueryValue("Rads"))
' locate and add in array
For r = 1 To L_RecordCount
If L_DataArray(PRODUCT_ID, r) = LProductID AND L_DataArray(PRIMER, r) = LPrimer AND L_DataArray(SECTIONS, r) = LSections Then
For f = L_FieldCount To L_FieldCount + L_ExtraFieldCount
If L_DataArray(f, 0) = LPicklist Then
L_DataArray(f, r) = L_DataArray(f, r) + LRads
L_DataArray(LSoldIndex, r) = L_DataArray(LSoldIndex, r) + LRads
Exit For
End If
Next
Exit For
End If
Next
NextQueryRecord
Loop
CloseQuery
End Sub
' (SS,2/11/22)
Sub SetMiscFields
Dim r, f, LMinStockIndex, LShelfStockIndex, LSoldIndex, LReqIndex, LThreeWeeksStockIndex, LUnsoldIndex, LValue
LMinStockIndex = GetArrayFieldIndex("Min~Stock")
LShelfStockIndex = GetArrayFieldIndex("Shelf~Stock")
LSoldIndex = GetArrayFieldIndex("Sold")
LReqIndex = GetArrayFieldIndex("REQ")
LThreeWeeksStockIndex = GetArrayFieldIndex("Three~Weeks~Stock")
LUnsoldIndex = GetArrayFieldIndex("Unsold~Shelf~Stock")
For r = 1 To L_RecordCount
L_DataArray(LReqIndex, r) = L_DataArray(LMinStockIndex, r) - L_DataArray(LShelfStockIndex, r) + L_DataArray(LSoldIndex, r)
L_DataArray(LUnsoldIndex, r) = L_DataArray(LShelfStockIndex, r) - L_DataArray(LSoldIndex, r)
' blank if 0 or less
If L_DataArray(LReqIndex, r) <= 0 Then L_DataArray(LReqIndex, r) = ""
' total the appropriate columns
For f = LThreeWeeksStockIndex To L_FieldCount + L_ExtraFieldCount
LValue = L_DataArray(f, r)
If LValue = "" Then LValue = 0
L_DataArray(f, L_RecordCount + 1) = L_DataArray(f, L_RecordCount + 1) + LValue
Next
Next
End Sub
' (SS,2/11/22)
Function GetArrayFieldIndex(AFieldName)
GetArrayFieldIndex = -1
Dim f
For f = 0 To L_FieldCount + L_ExtraFieldCount
If L_DataArray(f, 0) = AFieldName Then
GetArrayFieldIndex = f
Exit For
End If
Next
End Function
' (SS,3/6/20) returns true or false for given checkbox value, non-blank means True, "" is False
' (SS,30/3/23) changed to handle "no", "false" and "0" as False
Function L_CheckedValue(AName, ADefault)
Dim LValue, LResult
LValue = LCase(Request(AName))
If LValue = "" Then
LResult = ADefault
' (SS,30/3/23)
ElseIf LValue = "no" Or LValue = "false" Or LValue = "0" Then
LResult = False
Else
LResult = True ' LValue = "yes"
End If
L_CheckedValue = LResult
End Function
' (SS,3/6/20) returns True or False as a string "true" or "false" for javascript
Function L_BoolToJS(AValue)
If AValue Then
L_BoolToJS = "true"
Else
L_BoolToJS = "false"
End If
End Function
' (SS,2/11/22)
Sub L_ShowTableFromArray
Const CL_ORANGE = " style=""background-color:orange"""
Const CL_RED = " style=""background-color:red"""
Const CL_WHITE = " style=""background-color:white"""
Const CL_BLACK = " style=""background-color:black; color:white"""
L_ShowTableArrayHeader
Dim r, f, LFieldName, LFieldValue, LStyle, LNewFieldValue
Dim LMinStockIndex, LMinStock, LShelfStockIndex, LShelfStock, LNOPIndex, LREQIndex, LREQ
LMinStockIndex = GetArrayFieldIndex("Min~Stock")
LShelfStockIndex = GetArrayFieldIndex("Shelf~Stock")
LNOPIndex = GetArrayFieldIndex("NOP")
LREQIndex = GetArrayFieldIndex("REQ")
' (SS,7/3/23)
Dim LUntestedStockLocationIndex, LProductIDIndex, LPrimerIndex, LSectionsIndex
LUntestedStockLocationIndex = GetArrayFieldIndex("Untested Stock Locations")
LProductIDIndex = GetArrayFieldIndex("ProductID")
LPrimerIndex = GetArrayFieldIndex("Primer")
LSectionsIndex = GetArrayFieldIndex("Sections")
For r = 1 To L_RecordCount
LMinStock = L_DataArray(LMinStockIndex, r)
LShelfStock = L_DataArray(LShelfStockIndex, r)
LREQ = L_DataArray(LREQIndex, r)
' filter to show only REQ with value if range has a value
If Not LShowRequiredOnly Or LREQ <> "" Then
Response.Write "<tr>"
For f = 0 To L_FieldCount + L_ExtraFieldCount - 1
LFieldName = L_DataArray(f, 0)
If L_InFieldList(LFieldName) Then
LFieldValue = L_DataArray(f, r)
' Response.Write "<td>" & LFieldValue & "</td>"
LStyle = ""
If LFieldName = "Primer" Then
If LFieldValue = "Black" Then
LStyle = CL_BLACK
Else
LStyle = CL_WHITE
End If
ElseIf LFieldName = "Unsold~Shelf~Stock" Or LFieldName = "Shelf~Stock" Then
If LFieldValue <> "" Then
If LFieldValue <= 0 Then
LStyle = CL_RED
ElseIf LFieldValue < LMinStock Then
LStyle = CL_ORANGE
End If
End If
' if picklist field
ElseIf f > LShelfStockIndex And f <= LNOPIndex Then
LShelfStock = LShelfStock - LFieldValue
If LShelfStock <= 0 Then
LStyle = CL_RED
ElseIf LShelfStock < LMinStock Then
LStyle = CL_ORANGE
End If
' if value query string is not zero i.e. "s" then as previous Shopping Admin report with decrementing shelf stock value instead
' in boid if in picklist
If LShowStockLevel Then
LNewFieldValue = LShelfStock
If LFieldValue <> 0 Then LNewFieldValue = "<b>" & LNewFieldValue & "</b>"
LFieldValue = LNewFieldValue
Else
If LFieldValue = 0 Then LFieldValue = "" ' show 0 as blank
End If
ElseIf f = LREQIndex Then
' if REQ field and value then show as red in bold
If LFieldValue <> "" Then
LStyle = " style=""color:red;font-weight:bold"""
End If
' (SS,7/3/23)
ElseIf f = LUntestedStockLocationIndex Then
' LFieldValue = "Testing 123"
' the 3 parameters are ProductID, Primer, Sections
LFieldValue = GetUntestedStockLocations(L_DataArray(LProductIDIndex, r), L_DataArray(LPrimerIndex, r), L_DataArray(LSectionsIndex, r))
'LStyle = " style=""font-size:x-small;background-color:green;color:white"""
If GetHasUntestedLiveStock Then
LStyle = " style=""font-size:x-small"""
Else
LStyle = " style=""font-size:x-small;background-color:#16F529"""
End If
' (SS,22/3/23)
'LFieldValue = "<span style=""display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden;"">" & LFieldValue & "</span>"
LFieldValue = "<span class=""location-clamp-select location-clamp"">" & LFieldValue & "</span>"
End If
Response.Write "<td" & LStyle & ">" & LFieldValue & "</td>"
End If
Next
Response.Write "</tr>"
End If
Next
L_ShowTableArrayTotals
L_ShowTableArrayFooter
End Sub
' (SS,2/11/22)
Sub L_ShowTableArrayHeader
' for each field
%>
<table class="table table-responsive table-sm table-bordered table-striped" style="width: auto;">
<thead>
<tr>
<%
Dim f, LFieldName
Dim n, aSplit, LOutput
For f = 0 To L_FieldCount + L_ExtraFieldCount - 1
LFieldName = L_DataArray(f, 0)
If L_InFieldList(LFieldName) Then
' (SS,1/5/20) added ~ for wordwrap onto multiple lines
LOutput = ""
aSplit = Split(LFieldName, "~")
If IsArray(aSplit) Then
For n = 0 to UBound(aSplit)
If LOutput <> "" Then LOutput = LOutput & "<br>"
LOutput = LOutput & aSplit(n)
Next
End If
Response.Write "<th class=""small"">" & LOutput & "</th>"
End If
Next
%>
</tr>
</thead>
<tbody>
<%
End Sub
' (SS,2/11/22)
Sub L_ShowTableArrayTotals
Dim f, LFieldName, LFieldValue, LThreeWeeksStockIndex
LThreeWeeksStockIndex = GetArrayFieldIndex("Three~Weeks~Stock")
Response.Write "<tr>"
Response.Write "<td colspan=""4""><b>Totals</b></td>"
For f = LThreeWeeksStockIndex To L_FieldCount + L_ExtraFieldCount - 2 ' (SS,7/3/23) changed 1 to 2 (new "Untested Stock Locations" column)
LFieldName = L_DataArray(f, 0)
If L_InFieldList(LFieldName) Then
LFieldValue = L_DataArray(f, L_RecordCount + 1)
Response.Write "<td><b>" & LFieldValue & "</b></td>"
End If
Next
Response.Write "</tr>"
End Sub
' (SS,2/11/22)
Sub L_ShowTableArrayFooter
%>
</tbody>
</table>
<%
End Sub
Sub L_ShowTable(ASQL)
OpenQuery(ASQL)
L_ShowTableHeader
Do While Not EndOfQuery
L_ShowTableRecord
NextQueryRecord
Loop
L_ShowTableFooter
End Sub
Sub L_ShowTableHeader
' for each field
Dim LoRS
Set LoRS = oRS ' *** oRS is a global defined in dbfunctions.asp perhaps create a function to return this, or a create a different solutions
%>
<table class="table table-responsive table-sm table-bordered table-striped" style="width: auto;">
<thead>
<tr>
<%
Dim i, LFieldName, LFieldCount
LFieldCount = oRS.Fields.Count
For i = 0 To LFieldCount - 1
LFieldName = LoRS.Fields.Item(i).Name
If L_InFieldList(LFieldName) Then
' (SS,1/5/20) added ~ for wordwrap onto multiple lines
Dim n, aSplit, LOutput
LOutput = ""
aSplit = Split(LFieldName, "~")
If IsArray(aSplit) Then
For n = 0 to UBound(aSplit)
If LOutput <> "" Then LOutput = LOutput & "<br>"
LOutput = LOutput & aSplit(n)
Next
End If
Response.Write "<th class=""small"">" & LOutput & "</th>"
End If
Next
%>
</tr>
</thead>
<tbody>
<%
End Sub
Sub L_ShowTableRecord
' for each field
Dim LoRS
Set LoRS = oRS ' *** oRS is a global defined in dbfunctions.asp perhaps create a function to return this, or a create a different solutions
%>
<tr>
<%
Dim i, LFieldName, LFieldValue, LFieldCount
LFieldCount = oRS.Fields.Count
For i = 0 To LFieldCount - 1
LFieldName = LoRS.Fields.Item(i).Name
If L_InFieldList(LFieldName) Then
LFieldValue = LoRS.Fields.Item(i)
Response.Write "<td>" & LFieldValue & "</td>"
End If
Next
%>
</tr>
<%
End Sub
Sub L_ShowTableFooter
%>
</tbody>
</table>
<%
End Sub
' (SS,7/3/23)
' check if live stock,
' then if applicable check maker a and maker b stock
' show alert (green background) if stock is only container order
Function GetUntestedStockLocations(AProductID, APrimer, ASections)
Dim LResult, LLine
LResult = ""
Dim LSQL, LMakerASections, LMakerBSections, LMakerABSame
If GetSQL2Values("SELECT MakerASections, MakerBSections FROM rad_sections_map WHERE ProductID = " & AProductID & " AND Primer = '" & APrimer & "' AND Sections = " & ASections, LMakerASections, LMakerBSections) Then
LMakerASections = NB(LMakerASections)
LMakerBSections = NB(LMakerBSections)
LMakerABSame = LMakerASections <> "" And LMakerBSections <> "" And LMakerASections = LMakerBSections
Dim LDirectStock, LMakerAStock, LMakerBStock
LDirectStock = ""
LMakerAStock = ""
LMakerBStock = ""
Dim LHasLiveStock
LHasLiveStock = False
ClearHasUntestedLiveStock
LDirectStock = GetUntestedStockLocation(AProductID, APrimer, ASections, LHasLiveStock)
If LMakerASections <> "" Then LMakerAStock = GetUntestedStockLocation(AProductID, APrimer, LMakerASections, LHasLiveStock)
If LMakerBSections <> "" Then LMakerBStock = GetUntestedStockLocation(AProductID, APrimer, LMakerBSections, LHasLiveStock)
' LResult = "Maker A: " & LMakerASections & ", Maker B: " & LMakerBSections
If LDirectStock <> "" Then LResult = LDirectStock
If LMakerAStock <> "" Then LResult = LResult & IIf(LResult = "", "", BR) & "<b>Maker A" + IIf(LMakerABSame, "/B", "") & " (" & LMakerASections & " section):</b>" & BR & LMakerAStock
If LMakerBStock <> "" And Not LMakerABSame Then LResult = LResult & IIf(LResult = "", "", BR) & "<b>Maker B (" & LMakerBSections & " section):</b>" & BR & LMakerBStock
If LHasLiveStock Then SetHasUntestedLiveStock ' LResult = LResult & BR & "(*)"
Else
LResult = "*** not found in rad_sections_map ***"
End If
GetUntestedStockLocations = LResult
End Function
' (SS,7/3/23)
Function GetHasUntestedLiveStock
GetHasUntestedLiveStock = FHasUntestedLiveStock
End Function
' (SS,7/3/23)
Sub ClearHasUntestedLiveStock
FHasUntestedLiveStock = False
End Sub
' (SS,7/3/23)
Sub SetHasUntestedLiveStock
FHasUntestedLiveStock = True
End Sub
' (SS,7/3/23)
Function GetUntestedStockLocation(AProductID, APrimer, ASections, ByRef AHasLiveStock)
Dim LResult, LLine
LResult = ""
Dim LSQL
LSQL = "SELECT * FROM untested_rads ur " &_
"INNER JOIN untested_rad_sublocations urs ON urs.SublocationID = ur.SublocationID " &_
"INNER JOIN untested_rad_locations url ON url.LocationID = urs.LocationID " &_
"WHERE ProductID = " & AProductID & " AND Primer = '" & APrimer & "' AND Sections = " & ASections & " AND url.IsStock AND urs.StockType = 'Rads' " &_
"AND LocationName <> 'Shed 2 (on test)'" &_
"ORDER BY url.SortOrder, LocationName, urs.SortOrder, SublocationName"
OpenQuery(LSQL)
Do While Not EndOfQuery
' (SS,22/3/22) corrected GetFieldValue("Qty") & GetFieldValue("PalletSize") to GetFieldValue("Qty") * GetFieldValue("PalletSize")
LLine = GetFieldValue("LocationName") & " " & GetFieldValue("SublocationName") & " (" & CLng(GetFieldValue("Qty")) * CLng(GetFieldValue("PalletSize")) & ")"
LLine = ReplaceStr(LLine, "~", " ETA ")
LLine = ReplaceStr(LLine, "Container Order", "CO")
If GetFieldValue("HasOrders") = 0 Then AHasLiveStock = True
If LResult <> "" Then LResult = LResult & BR
LResult = LResult & LLine
NextQueryRecord
Loop
CloseQuery
GetUntestedStockLocation = LResult
End Function
%>