<%@ Page Language="C#" AutoEventWireup="true" CodeFile="List.aspx.cs" Inherits="Approval_List" meta:resourcekey="Page" %>
<%@ Register src="../Common/TopNavbar.ascx" tagname="TopNavbar" tagprefix="tabs" %>

<!DOCTYPE html>

<html>
<head runat="server">
    <title></title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../libs/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="../libs/fontawesome/css/all.min.css" >
    <script type="text/javascript" src="../libs/jquery-3.2.1.min.js"></script>
    <script type="text/javascript" src="../libs/bootstrap/js/bootstrap.min.js"></script>
</head>
<body>
    <script type="text/javascript">
        $(document).ready(function () {
        });

        function ViewDocument(apdId, appId, folderType) {
            location.href = "View.aspx?document=" + apdId + "&person=" + appId + "&type=" + folderType;
        }

        function Refresh() {
            location.href = "List.aspx?type=<%=_paramType%>";
        }

        function OpenFolders() {
            location.href = "Folders.aspx";
        }

        function GotoToApprovalFolders() {
            location.href = "List.aspx?type=<%=AppFolderDataSource.APPROVAL_FOLDERID%>";
        }

        function SearchOnEnter(event) {
            if (event.keyCode == 13) {
                __doPostBack("SearchButton", "");
                return false;
            }
            return true;
        }
    </script>

    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>

        <tabs:TopNavbar ID="TopMenu1" runat="server" />

        <div class="container-fluid topNavbarRegion">
            <div class="row" id="toolBar" data-spy="affix">
                <div class="col-xs-12" style="padding-top:2px;padding-bottom:2px;">
                    <button type="button" id="refreshToolButton" class="btn btn-primary" onclick="Refresh()"><span class="fa-solid fa-rotate-right"></span></button>
                    <button type="button" id="folderToolButton" class="btn btn-primary" onclick="OpenFolders()"><span class="fa-solid fa-folder-open"></span></button>
                    <button type="button" id="gotoToolButton" class="btn btn-primary" onclick="GotoToApprovalFolders()"><span class="fa-solid fa-signature"></span></button>
                    <button type="button" id="searchCollapseButton" class="btn btn-primary" data-toggle="collapse" data-target="#searchPanel"><span class="fa-solid fa-magnifying-glass"></span></button>
                </div>
            </div>
        </div>

        <div class="container-fluid" style="padding-top:40px">
            <div id="searchPanel" runat="server" class="collapse">
                <div class="row">
                    <div class="col-xs-9">
                        <asp:DropDownList ID="CategoryList" runat="server" CssClass="form-control">
                            <asp:ListItem Text="문서번호" Value="1" meta:resourcekey="CL01"></asp:ListItem>
                            <asp:ListItem Text="제목" Value="2" Selected="True" meta:resourcekey="CL02"></asp:ListItem>
                            <asp:ListItem Text="내용" Value="6" meta:resourcekey="CL03"></asp:ListItem>
                            <asp:ListItem Text="기안자" Value="8" meta:resourcekey="CL04"></asp:ListItem>
                        </asp:DropDownList>
                    </div>
                    <div class="col-xs-3">
                        <button type="button" id="searchButton" class="btn btn-default" onclick="__doPostBack('SearchButton', '')"><span class="fa-solid fa-magnifying-glass"></span></button>
                    </div>
                </div>
                <div class="row">
                    <div class="col-xs-9">
                        <asp:TextBox ID="KeywordTextBox" runat="server" CssClass="form-control" AutoPostBack="false" onkeydown="return SearchOnEnter(event);" />
                    </div>
                    <div class="col-xs-3">
                        <button type="button" id="searchCancelButton" class="btn btn-default" onclick="__doPostBack('SearchCancelButton', '')"><span class="fa-solid fa-xmark"></span></button>
                    </div>
                </div>
            </div>

            <asp:GridView ID="ApvDocGridView" runat="server" Width="100%" CssClass="table table-hover" AutoGenerateColumns="false" 
                AllowPaging="true" PageSize="20" AllowSorting="true" GridLines="None" ShowHeaderWhenEmpty="true" ShowHeader="true" 
                DataSourceID="DocPersonDataSource" EnableViewState="true" DataKeyNames="PersonID"                 
                OnPreRender="ApvDocGridView_PreRender">
                <EmptyDataTemplate>
                    <div>
                        <asp:Localize ID="Localize1" runat="server" meta:resourcekey="L01">결재 문서가 존재하지 않습니다.</asp:Localize>
                    </div>
                </EmptyDataTemplate> 
                <Columns>
                    <asp:TemplateField>
                        <HeaderStyle Font-Size="Larger" />
                        <ItemTemplate>
                            <div class="row" onclick="<%# GetClickEventFunction((Guid)Eval("DocumentID"), (Guid)Eval("PersonID"))%>">
                                <div class="col-xs-8">
                                    <%# GetSubject((Guid)Eval("DocumentID"), (Guid)Eval("PersonID"), (string)Eval("Subject"), (DateTime)Eval("ReadDate"))%>
                                    <small><%# GetAttachmentImage((int)Eval("AttachCount"))%></small>
                                </div>
                                <div class="col-xs-4 text-right">
                                    <small><%# WebUser.CurrentUser.ToLocalTime((DateTime)Eval("CreateDate")).ToString("d")%></small>
                                </div> 
                            </div>
                            <div class="row">
                                <div class="col-xs-8" onclick="<%# GetClickEventFunction((Guid)Eval("DocumentID"), (Guid)Eval("PersonID"))%>">
                                    <%#: Eval("Code")%> / <%#: Eval("Drafter")%>
                                </div> 
                                <div class="col-xs-4 text-right">
                                    <%# GetStatus((Guid)Eval("DocumentID"), (int)Eval("Status"), (int)Eval("CompleteStep"), (int)Eval("PersonStep"), (int)Eval("PersonRights"))%>    
                                </div> 
                            </div>
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns> 
                <PagerSettings PageButtonCount="5" Mode="NumericFirstLast" />
                <PagerStyle CssClass="mc-gridpager"/>
            </asp:GridView>
        </div>

        <div style="display:none">
            <asp:LinkButton ID="SearchButton" runat="server" OnClick="SearchButton_Click" Text="" />
            <asp:LinkButton ID="SearchCancelButton" runat="server" OnClick="SearchCancelButton_Click" Text="" />
        </div>

        <asp:ObjectDataSource ID="DocPersonDataSource" runat="server" TypeName="DocPersonDataSource"
            SelectMethod="GetApvDocs" SelectCountMethod="GetTotalCount" EnablePaging="true">
        </asp:ObjectDataSource>
        <asp:ObjectDataSource ID="SearchedDocPersonDataSource" runat="server" TypeName="SearchedDocPersonDataSource"
            SelectMethod="GetApvDocs" SelectCountMethod="GetTotalCount" EnablePaging="true">
        </asp:ObjectDataSource>
    </form>
</body>
</html>
