HEX
Server: Microsoft-IIS/10.0
System: Windows NT ITPWINWEBSVR22 10.0 build 20348 (Windows Server 2022) AMD64
User: www.conferencesearch.co.uk (0)
PHP: 8.3.30
Disabled: NONE
Upload Files
File: D:/web/circ.itp/2025-09-01/new/radiator-despatch-cache.asp
<%Option Explicit%>
<!--#include file="dbfunctions.asp"-->
<!--#include file="apputils.asp"-->
<!--#include file="customutils.asp"-->
<%DisableCache%>

<%
' (SS,20/04/21) For displaying radiator despatch cache status
' (SS,01/09/25) Modified to send to WooCommerce site, also added to fetch via scheduler every hour

%>


<html>
<head>
<title>Radiator Despatch Cache Status</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;   
}
</style>
</head>
<body>

<div class="container-fluid">

<h1>Radiator Despatch Cache Status</h1>

<%

If Not DespatchDatesEnabled Then
  Response.Write "<h2 class=""alert-danger"">!!! Despatch Dates Feature Not Enabled !!!</h2>"
End If

  Dim LDespatchDays, LStartTime, LTimeTaken
  LStartTime = Timer 
  LDespatchDays = CustomGetRadiatorDespatchDays(True)
  LTimeTaken = Timer - LStartTime

  Response.Write("<table class=""table table2 table-responsive table-sm table-bordered table-striped"" style=""width: auto;"">")
  Response.Write("<tr><th>Despatch Days</th><td>" & LDespatchDays & "</td></tr>")
  Response.Write("<tr><th>Despatch From Date</th><td>" & Application("RadiatorDespatchFromDate") & "</td></tr>")
  Response.Write("<tr><th>Despatch By Date</th><td>" & Application("RadiatorDespatchByDate") & "</td></tr>")
  Response.Write("<tr><th>Time Taken</th><td>" & FormatNumber(LTimeTaken, 4, True) & "</td></tr>")
  Response.Write("<tr><th>Earliest Timestamp</th><td>" & Application("RadiatorDespatchEarliestTimestamp") & "</td></tr>")
  Response.Write("<tr><th>Last Timestamp</th><td>" & Application("RadiatorDespatchDaysTimestamp") & "</td></tr>")
  Response.Write("<tr><th>Run Count</th><td>" & Application("RadiatorDespatchRunCount") & "</td></tr>")
  Response.Write("<tr><th>Run Time Total</th><td>" & FormatNumber(Application("RadiatorDespatchRunTimeTotal"), 4, True) & "</td></tr>")
  Response.Write("<tr><th>Run Time Avg</th><td>" & FormatNumber(Application("RadiatorDespatchRunTimeTotal") / Application("RadiatorDespatchRunCount"), 4, True) & "</td></tr>")
  Response.Write("<tr><th>Run Time Min</th><td>" & FormatNumber(Application("RadiatorDespatchRunTimeMin"), 4, True) & "</td></tr>")
  Response.Write("<tr><th>Run Time Max</th><td>" & FormatNumber(Application("RadiatorDespatchRunTimeMax"), 4, True) & "</td></tr>")
  Response.Write("</table>")
  
  ' (SS,1/9/25) send the latest despatch days to WooCommerce (customutils.asp)
  CustomSendDespatchDaysToWooCommerce
   
  Finalise

%>

</div>

</body>
</html>

<%

' (SS,3/6/20) returns true or false for given checkbox value, non-blank means True, "" is False
Function L_CheckedValue(AName, ADefault)  
  Dim LValue, LResult
  LValue = Request(AName)
  If LValue = "" Then
    LResult = ADefault
  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

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
        
    ' (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>"
  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 Not L_GetCustomField(LFieldName, LFieldValue) Then
      LFieldValue = LoRS.Fields.Item(i)
    End If
    Response.Write "<td>" & LFieldValue & "</td>"
  Next
%>  
    </tr>
<%
End Sub

Sub L_ShowTableFooter
%>
  </tbody>
</table>
<%
End Sub

' (SS,9/4/21)
Function L_GetCustomField(AFieldName, ByRef AFieldValue)
  Dim LResult
  LResult = True
  If AFieldName = "WorkingDayNo" Then
    FWorkingDayNo = FWorkingDayNo + 1  
    AFieldValue = FWorkingDayNo
  ElseIf AFieldName = "CumulativeRadiators" Then
    ' *** oRS is a global defined in dbfunctions.asp perhaps create a function to return this, or a create a different solutions
    FCumulativeRadiators = FCumulativeRadiators + NZ(oRS("Radiators"))
    AFieldValue = FCumulativeRadiators
  ElseIf AFieldName = "ProductionRate" Then
    AFieldValue = CustomGetDailyRadProductionRate    
  ElseIf AFieldName = "ProductionRateCumulative" Then
    AFieldValue = CustomGetDailyRadProductionRate * FWorkingDayNo
    If AFieldValue <= FCumulativeRadiators then
      AFieldValue = "<span class=""text-danger""><b>" & AFieldValue & "</b></span>"
    Else
      AFieldValue = "<span class=""text-success""><b>" & AFieldValue & "</b></span>"
    End If
  ElseIf AFieldName = "Availability" Then 
    AFieldValue = "No"
    If FWorkingDayNo >= CustomGetMinRadDespatchDays And oRS("DespatchByDate") >= CustomGetLastUsedRadDespatchByDate Then
      If FCumulativeRadiators < (CustomGetDailyRadProductionRate * FWorkingDayNo) Then
        AFieldValue = "Yes"
      End If
    End If
  Else
    LResult = False
  End If
  L_GetCustomField = LResult
End Function

%>