<%@ Page Language="c#" CodeBehind="Search.aspx.cs" AutoEventWireup="True" Inherits="eDocument.Server.Administrator.ExecutedProcess.Search" MasterPageFile="~/Site.Master" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="Server">

    <div class="skjema-admin__page-pre-title">
        Logg (innsendinger)
    </div>
    <h1 class="skjema-admin__page-title mt-0 skjema-admin__mb-40">
        Søk på referanse-ID
    </h1>

    <p class="mb-4">
        Søk i innsendte skjema
    </p>

    <div class="mb-4">
        <asp:Label 
            ID="Label1" 
            CssClass="skjema-admin__page__label"
            runat="server">
            Referanse-ID
        </asp:Label>

        <div class="skjema-admin__search-bar">
            <asp:TextBox 
                CssClass="skjema-admin__search-bar__input"
                ID="txtReferenceNumber" 
                runat="server">
            </asp:TextBox>

            <asp:Button 
                ID="btnSearch" 
                 CssClass="skjema-admin__button skjema-admin__button--primary"
                runat="server" 
                Text="Søk" 
                OnClick="btnSearch_Click">
            </asp:Button>
        </div>

        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Du må angi et referansenummer"
            ControlToValidate="txtReferenceNumber"></asp:RequiredFieldValidator>
    </div>


    <div id="details" runat="server">
        <div class="mb-4" runat="server" Visible="False">
            <asp:Label
                ID="Label11"
                CssClass="skjema-admin__page__label"
                runat="server">
                Innsendt av:
            </asp:Label>

            <asp:Label ID="lblConsumer" runat="server"></asp:Label>
        </div>

        <div class="mb-4">
            <asp:Label
                ID="Label2"
                CssClass="skjema-admin__page__label"
                runat="server">
                Skjema:
            </asp:Label>

            <asp:Label ID="lblTemplate" runat="server"></asp:Label>
        </div>

        <div class="mb-4">
            <asp:Label
                ID="Label3"
                CssClass="skjema-admin__page__label"
                runat="server">
                Opprettet:
            </asp:Label>

            <asp:Label ID="lblCreated" runat="server"></asp:Label>
        </div>

        <div class="mb-4">
            <asp:Label
                ID="Label4"
                CssClass="skjema-admin__page__label"
                runat="server">
                Innsendt:
            </asp:Label>

            <asp:Label ID="lblSubmitted" runat="server"></asp:Label>
        </div>
    </div>
    
    <div runat="server" id="divExecuted" Visible="False">
        <h3 class="skjema-admin__underline-title">
            Kjørte prosesser
        </h3>

        <asp:DataGrid 
            ID="dgExecutedProcess" 
            runat="server" 
            Border="0"
            CssClass="skjema-admin__table"
            AutoGenerateColumns="False">

            <Columns>
                <asp:BoundColumn Visible="False" DataField="ExecutedProcessID"></asp:BoundColumn>
                <asp:BoundColumn Visible="False" DataField="eDocumentInstanceID"></asp:BoundColumn>
                <asp:BoundColumn Visible="True" DataField="ProcessName" HeaderText="Prosess-navn"></asp:BoundColumn>
                <asp:BoundColumn Visible="True" DataField="Text" HeaderText="Logg"></asp:BoundColumn>
                <%--<asp:BoundColumn Visible="True" DataField="ConsumerUsername" HeaderText="Innsendt av brukernavn"></asp:BoundColumn>--%>
                <%--<asp:BoundColumn Visible="True" DataField="ConsumerName" HeaderText="Innsendt av navn"></asp:BoundColumn>--%>
                <%--<asp:BoundColumn Visible="True" DataField="eDocumentTemplateName" HeaderText="Skjema"></asp:BoundColumn>--%>
                <%--<asp:BoundColumn Visible="True" DataField="eDocumentTemplateVersionVersion" HeaderText="Versjon"></asp:BoundColumn>--%>
                <%--<asp:BoundColumn Visible="True" DataField="eDocumentInstanceCreatedOn" HeaderText="Søknad opprettet"></asp:BoundColumn>--%>
                <%--<asp:BoundColumn Visible="True" DataField="eDocumentInstanceSubmittedOn" HeaderText="Søknad innsendt"></asp:BoundColumn>--%>
                <asp:BoundColumn Visible="True" DataField="ProcessStartedOn" HeaderText="Prosess startet"></asp:BoundColumn>
                <asp:BoundColumn Visible="True" DataField="ProcessEndedOn" HeaderText="Prosess avsluttet"></asp:BoundColumn>
                <asp:ButtonColumn Text="Restart" CommandName="Restart"></asp:ButtonColumn>

                <asp:TemplateColumn HeaderText="" Visible="False">
                    <ItemTemplate>
                        <asp:HyperLink Target="_blank" ID="lnkShowXml" runat="server" Text='Vis XML' NavigateUrl='<%# "~/eDocumentInstance/DownloadXmlResponse.aspx?eDocumentInstanceID=" + DataBinder.Eval(Container.DataItem, "eDocumentInstanceID") + "&SubscriberConsumerID=" + DataBinder.Eval(Container.DataItem, "ExecutionRequestedByConsumerID") %>' />
                    </ItemTemplate>
                </asp:TemplateColumn>

                <asp:HyperLinkColumn Target="_blank" DataNavigateUrlFormatString="~/eDocumentInstance/DownloadPdfResponse.aspx?eDocumentInstanceID={0}"
                    DataNavigateUrlField="eDocumentInstanceID" Text="Vis PDF" Visible="False" />
            </Columns>
        </asp:DataGrid>
    </div>
    
    
    <div runat="server" id="divAborted" Visible="False">
        <h3 class="skjema-admin__underline-title">
            Avbrutte prosesser
        </h3>
        <asp:DataGrid 
            ID="dgAborted" 
            runat="server" 
            Border="0"
            OnItemCommand="dgAborted_OnItemCommand"
            CssClass="skjema-admin__table"
            AutoGenerateColumns="False">

            <Columns>
                <asp:BoundColumn Visible="False" DataField="Id"></asp:BoundColumn>
                <asp:BoundColumn Visible="False" DataField="InstanceId"></asp:BoundColumn>
                <asp:BoundColumn Visible="True" DataField="ProcessName" HeaderText="Prosess-navn"></asp:BoundColumn>
                <asp:BoundColumn Visible="True" DataField="Description" HeaderText="Logg"></asp:BoundColumn>
                <asp:BoundColumn Visible="True" DataField="StackTrace" HeaderText="Detaljert feil"></asp:BoundColumn>
                <%--<asp:BoundColumn Visible="True" DataField="ConsumerUsername" HeaderText="Innsendt av brukernavn"></asp:BoundColumn>--%>
                <%--<asp:BoundColumn Visible="True" DataField="ConsumerName" HeaderText="Innsendt av navn"></asp:BoundColumn>--%>
                <%--<asp:BoundColumn Visible="True" DataField="eDocumentTemplateName" HeaderText="Skjema"></asp:BoundColumn>--%>
                <%--<asp:BoundColumn Visible="True" DataField="eDocumentTemplateVersionVersion" HeaderText="Versjon"></asp:BoundColumn>--%>
                <%--<asp:BoundColumn Visible="True" DataField="eDocumentInstanceCreatedOn" HeaderText="Søknad opprettet"></asp:BoundColumn>--%>
                <%--<asp:BoundColumn Visible="True" DataField="eDocumentInstanceSubmittedOn" HeaderText="Søknad innsendt"></asp:BoundColumn>--%>
                <asp:BoundColumn Visible="True" DataField="AbortedOn" HeaderText="Avbrutt"></asp:BoundColumn>
                <asp:ButtonColumn Text="Restart" CommandName="Restart"></asp:ButtonColumn>
                <asp:ButtonColumn Text="Fjern" CommandName="Remove"></asp:ButtonColumn>
            </Columns>
        </asp:DataGrid>
    </div>

    <p>
        <asp:Button 
            ID="btnExecuteProcess" 
            CssClass="skjema-admin__button"
            runat="server" 
            Text="Eksekver prosess" 
            Enabled="False" 
            OnClick="btnExecuteProcess_Click">
        </asp:Button>
        
        <asp:Button 
            ID="btnDelete" 
            CssClass="skjema-admin__button"
            runat="server" 
            Text="Slett skjema" 
            Enabled="True" 
            OnClick="btnDelete_Click">
        </asp:Button>
    </p>

    <p>
        <asp:Label ID="lblMessage" runat="server" ForeColor="Red"></asp:Label>
    </p>
    
    <asp:Panel ID="pnlAbortedRestarted" Visible="False" runat="server" CssClass="skjema-admin__modal" data-jscomponent="modal">
        <div class="skjema-admin__modal__window">

            <button class="skjema-admin__modal__close" type="button" data-jscomponent="modalClose"></button>

            <asp:Label CssClass="skjema-admin__page__label" Text="Den avbrutte prosessen er startet på nytt." runat="server" />

            <div>
                <asp:Button CssClass="skjema-admin__button skjema-admin__button--primary" runat="server" ID="btnConfirmAbortedRestarted" OnClick="btnConfirmAbortedRestarted_OnClick" Text="OK" />
            </div>
        </div>
    </asp:Panel>
    
    <asp:Panel ID="pnlExecutedRestarted" Visible="False" runat="server" CssClass="skjema-admin__modal" data-jscomponent="modal">
        <div class="skjema-admin__modal__window">

            <button class="skjema-admin__modal__close" type="button" data-jscomponent="modalClose"></button>

            <asp:Label CssClass="skjema-admin__page__label" Text="Prosessen er startet på nytt." runat="server" />

            <div>
                <asp:Button CssClass="skjema-admin__button skjema-admin__button--primary" runat="server" ID="btnConfirmExecutedRestarted" OnClick="btnConfirmExecutedRestarted_OnClick" Text="OK" />
            </div>
        </div>
    </asp:Panel>

    <asp:Panel ID="pnlConfirmDelete" Visible="False" runat="server" CssClass="skjema-admin__modal" data-jscomponent="modal">
        <div class="skjema-admin__modal__window">

            <button class="skjema-admin__modal__close" type="button" data-jscomponent="modalClose"></button>

            <asp:Label CssClass="skjema-admin__page__label" Text="Sletting innebærer at alle spor etter innsendingen blir borte. Er du helt sikker på at du vil slette skjemaet? " runat="server" />
            
            <asp:Label id="lblDeleteInstanceErrorMessage" runat="server" CssClass="skjema-admin__page__label" ForeColor="Red"  runat="server" />

            <div>
                <asp:Button CssClass="skjema-admin__button skjema-admin__button--primary" runat="server" ID="btnConfirmDelete" OnClick="btnConfirmDelete_OnClick" Text="Ja, slett skjemaet" />

                <asp:Button CssClass="skjema-admin__button skjema-admin__button" runat="server" ID="btnCancelDelete" OnClick="btnCancelDelete_OnClick" Text="Nei, IKKE slett skjemaet" />
            </div>
        </div>
    </asp:Panel>
    
    <asp:Panel ID="pnlDeleted" Visible="False" runat="server" CssClass="skjema-admin__modal" data-jscomponent="modal">
        <div class="skjema-admin__modal__window">

            <button class="skjema-admin__modal__close" type="button" data-jscomponent="modalClose"></button>

            <asp:Label CssClass="skjema-admin__page__label" Text="Skjemaet er nå slettet." runat="server" />

            <div>
                <asp:Button CssClass="skjema-admin__button skjema-admin__button--primary" runat="server" ID="btnDeletedStatusOk" OnClick="btnDeletedStatusOk_OnClick" Text="OK" />
            </div>
        </div>
    </asp:Panel>

    <asp:Panel ID="pnlAbortedCanceled" Visible="False" runat="server" CssClass="skjema-admin__modal" data-jscomponent="modal">
        <div class="skjema-admin__modal__window">

            <button class="skjema-admin__modal__close" type="button" data-jscomponent="modalClose"></button>

            <asp:Label CssClass="skjema-admin__page__label" Text="Den avbrutte prosessen er fjernet." runat="server" />

            <div>
                <asp:Button CssClass="skjema-admin__button skjema-admin__button--primary" runat="server" ID="btnConfirmAborteCanceled" OnClick="btnConfirmAborteCanceled_OnClick" Text="OK" />
            </div>
        </div>
    </asp:Panel>
</asp:Content>
