<%
Class AdminOrdersController_Class
    Private m_useLayout
    Private m_title

    Private Sub Class_Initialize()
        m_useLayout = True
        m_title = "Orders"
    End Sub

    Public Property Get useLayout
        useLayout = m_useLayout
    End Property

    Public Property Let useLayout(v)
        m_useLayout = v
    End Property

    Public Property Get Title
        Title = m_title
    End Property

    Public Property Let Title(v)
        m_title = v
    End Property

    '-------------------------------------------------------------------------------------------------------------------
    ' GET: list orders (searchable by email/jurisdiction #, paginated) with a mailto link to
    ' resend the continuation URL for each.
    '-------------------------------------------------------------------------------------------------------------------
    Public Sub Index()
        Dim orders, searchTerm, pageNum, perPage, pageCount, recordCount
        perPage = 20

        searchTerm = Trim(Request.QueryString("q"))

        If IsNumeric(Request.QueryString("page")) And CLng(Request.QueryString("page")) >= 1 Then
            pageNum = CLng(Request.QueryString("page"))
        Else
            pageNum = 1
        End If

        Set orders = OrdersRepository().SearchPaged(searchTerm, perPage, pageNum, pageCount, recordCount)

        ' If the requested page is past the last one (e.g. a stale bookmark after a search
        ' narrows the results), clamp to the last real page and re-fetch.
        If pageCount > 0 And pageNum > pageCount Then
            pageNum = pageCount
            Set orders = OrdersRepository().SearchPaged(searchTerm, perPage, pageNum, pageCount, recordCount)
        End If
    %>
    <!--#include file="../views/AdminOrders/index.asp" -->
    <%
    End Sub

End Class

Dim AdminOrdersController_Class__Singleton
Function AdminOrdersController()
    If IsEmpty(AdminOrdersController_Class__Singleton) Then
        Set AdminOrdersController_Class__Singleton = New AdminOrdersController_Class
    End If
    Set AdminOrdersController = AdminOrdersController_Class__Singleton
End Function
%>
