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/hyperflight/! bs5/delivery-table-show.asp
<%Option Explicit%>
<%
' === delivery-table-show DEBUG USE to show contents of a table ===

%>
<!--#include file="dbfunctions.asp"-->
<!--#include file="apputils.asp"-->
<!--#include file="customutils.asp"-->


<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=windows-1252"> 
<meta charset="windows-1252">
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<head>

<link href="/common/bootstrap/3.4.1/css/bootstrap.min.css" rel="stylesheet">

<script src="/common/jquery/jquery-3.6.4.min.js"></script>
<script src="/common/bootstrap/3.4.1/js/bootstrap.min.js"></script>


<title><%=GetDeliveryTableName%></title>

</head>

<body>

<div class="container-fluid">
  <div class="row">
    <div class="col-lg-12">

<%

ShowDeliveryTable GetDeliveryTableName

Finalise
%>

    </div>
  </div>
</div>

</body>
</html>

<%

Function GetDeliveryTableName
  GetDeliveryTableName = CleanRequestQueryString("dtn")
End Function

Function GetShowAll
  GetShowAll = CleanRequestQueryString("all") = "yes"
End Function

Sub ShowDeliveryTable(ATableName)
  Dim LSQL, LWhere
  
  If ATableName = "deliverycosts_uk" Or ATableName = "deliverycosts_int_rm" Or ATableName = "deliverycosts_int_fedex" Then
    If GetShowAll Then
      LWhere = ""
    Else
      LWhere = " WHERE Enabled"
    End If
    LSQL = "SELECT * FROM " & CleanSQLStr(ATableName) & LWhere & " ORDER BY ID" ' Agent, Courier, Service, PackageSize, WeightUpTo"
  ElseIf ATableName = "delivery_package_names" Then
    LSQL = "SELECT * FROM delivery_package_names" &_
      " ORDER BY LargeLetter DESC, Tube DESC, Length" 
  ElseIf ATableName = "countries" Then
    If GetShowAll Then
      LWhere = ""
    Else
      LWhere = " WHERE Enabled = 'Yes'"
    End If
    LSQL = "SELECT Country, CodeA2, CodeA3, PostalArea, RegionCode, Options, RMPreferredServiceCode AS `RMPreferredServiceCode`, RMZone, FedExZone" &_
      " FROM countries" & LWhere & " ORDER BY Country"
  Else
    Response.Write "Invalid table name"
    Exit Sub
  End If  
  
  Response.Write "<h2>" & ATableName & "</h2>"
  
  Dim LURL, LText
  LURL = GetStoreURL + Request.ServerVariables("SCRIPT_NAME") + "?dtn=" + ATableName 
  If Not GetShowAll Then
    LURL = LURL + "&all=yes"
    LText = "Showing enabled only"
  Else
    LText = "Showing all"
  End If        
  Response.Write "<p><a href=""" + LURL + """>" + LText + "</a></p>"
  
  Dim LRecordCount
  LRecordCount = 0
  
  OpenQuery(LSQL)
  ShowTableHeader
  Do While Not EndOfQuery
    ShowTableRecord
    LRecordCount = LRecordCount + 1
    NextQueryRecord
  Loop
  ShowTableFooter(LRecordCount)
  
End Sub

Sub 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 id="datatable1" class="table table-responsive table-condensed table-bordered table-striped" style="width:100%"> 
  <thead>
    <tr class="small">
  <%
  Dim i, LFieldName, LFieldCount
  
  LFieldCount = oRS.Fields.Count
    
  For i = 0 To LFieldCount - 1
    LFieldName = LoRS.Fields.Item(i).Name

    Response.Write "<th>" & LFieldName & "</th>"   
  Next
%>  
    </tr>
  </thead>
  <tbody>
<%
End Sub

Sub ShowTableFooter(ARecordCount)
%>
  </tbody>
</table>
<p>Records: <%=ARecordCount%></p>
<%
End Sub

Sub 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 class="small">
  <%
  Dim i, LFieldName, LFieldValue, LFieldCount
  
  LFieldCount = oRS.Fields.Count
  
  For i = 0 To LFieldCount - 1
    LFieldName = LoRS.Fields.Item(i).Name
    LFieldValue = LoRS.Fields.Item(i)
    Response.Write "<td>" & LFieldValue & "</td>"
  Next
%>  
    </tr>
<%
End Sub

%>