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/castironradiatorcentre/radiator-availability.asp
<%Option Explicit%>
<!--#include file="dbfunctions.asp"-->
<!--#include file="apputils.asp"-->
<!--#include file="customutils.asp"-->
<%DisableCache%>

<%
' (SS,8/4/21) for testing radiator availability feature

%>


<html>
<head>
<title>Radiator Availability</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 Availability</h1>

<%

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

Dim LAvailabilityDate, LAvailabilityDayRange

Dim LDailyProductionRate, i
LDailyProductionRate = ParseInt(Trim(CleanSQLStr(Request("dailyproductionrate"))))
If LDailyProductionRate <= 0 Then
  LDailyProductionRate = CustomGetDailyRadProductionRate ' set default
End If

FStartTimer = Timer

' (SS,14/4/21)
Dim LDespatchByDate, LDespatchFromDate

LDespatchByDate = CustomGetNextAvailableDespatchByDate(LAvailabilityDayRange, LDespatchFromDate)

'Response.Write("###" & GetTimer & "###" & BR)

'FStartTimer = Timer
'Response.Write CustomGetRadiatorDespatchDays(True) & BR
'Response.Write("###" & GetTimer & "###" & BR)


  Response.Write("<table class=""table table2 table-responsive table-sm table-bordered table-striped"" style=""width: auto;"">")
  Response.Write("<tr><th>Working Days</th><td>" & LAvailabilityDayRange & "</td></tr>")
  Response.Write("<tr><th>Despatch From Date</th><td>" & LDespatchFromDate & "</td></tr>")
  Response.Write("<tr><th>Despatch By Date</th><td>" & LDespatchByDate & "</td></tr>")
  Response.Write("<tr><th>Last Used Despatch By Date</th><td>" & CustomGetLastUsedRadDespatchByDate & "</td></tr>")
  Response.Write("<tr><th>Daily Production Rate</th><td>" & CustomGetDailyRadProductionRate & "</td></tr>")
  Response.Write("</table>")
  

  
%>  
<form method="get" class="form-inline" >  

  <div class="form-group">   
    <label for="dailyproductionrate">Daily Production Rate</label>  
    <select class="form-control" name="dailyproductionrate" id="dailyproductionrate" onchange="this.form.submit()">
<%For i = 1 To 100%>
      <option value="<%=i%>"><%=i%></option>
<%Next%>      
    </select>    
  </div>
  
</form>  


<script>
$('#dailyproductionrate option[value=<%=LDailyProductionRate%>]').attr('selected','selected');
</script>


<%
' (SS,7/12/21) added FProductionRateCumulative
Dim LSQL, FWorkingDayNo, FCumulativeRadiators, FProductionRateCumulative
LSQL = CustomGetNADBD_SQL

FWorkingDayNo = 0
FCumulativeRadiators = 0
FProductionRateCumulative = 0 ' (SS,7/12/21)

L_ShowTable LSQL

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)
' (SS,7/12/21) changed to use new CustomIsChristmasBreak function, also new FProductionRateCumulative
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 = LDailyProductionRate
    ' (SS,7/12/21) replaced above with following
    If CustomIsChristmasBreak(oRS("DespatchByDate")) Then
      AFieldValue = 0
    Else
      AFieldValue = LDailyProductionRate
    End If    
    
  ElseIf AFieldName = "ProductionRateCumulative" Then
    ' AFieldValue = LDailyProductionRate * FWorkingDayNo
    ' (SS,7/12/21) added following to replace above, allow Christmas break to be taken into account where production rate is zero
    If Not CustomIsChristmasBreak(oRS("DespatchByDate")) Then
      FProductionRateCumulative = FProductionRateCumulative + LDailyProductionRate
    End If
    AFieldValue = FProductionRateCumulative
    
    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 < (LDailyProductionRate * FWorkingDayNo) Then
        AFieldValue = "Yes"
      End If
    End If
  Else
    LResult = False
  End If
  L_GetCustomField = LResult
End Function

%>