<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ConfirmerList.aspx.cs" Inherits="Mail_PermitSend_ConfirmerList" 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>
    <style>
        .table-fixed
        {
            table-layout:fixed;
        }
        .mail-wrap
        {
            word-break: break-all;
            white-space: normal;
        }
        .col-subject
        {
            overflow: hidden;
            white-space: nowrap;
            text-overflow: ellipsis;            
        }
    </style>
    <script type="text/javascript">
        $(document).ready(function () {
        });

        function ViewMessage(clId, pageIndex) {
            location.href = "View.aspx?mode=<%=_mode%>&clid=" + clId + "&page=" + pageIndex + "&<%=_dgParam%>";
        }

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

        function ListWait() {
            location.href = "ConfirmerList.aspx?<%=_dgParam%>";
        }

        function ListAll() {
            location.href = "ConfirmerList.aspx?mode=ListAll&<%=_dgParam%>";
        }

        function OpenComment(event, clid) {
            event.stopPropagation();

            // 코멘트 출력은 Dialog 설정과 관련없이 대화상자로 처리한다.
            Dialog.setMessage('<asp:Literal runat="server" Text="<%$ Resources:, Comment%>" />', '<asp:Literal runat="server" Text="<%$ Resources:Dialog, OK%>" />', '<asp:Literal runat="server" Text="<%$ Resources:Dialog, Cancel%>" />');
            Dialog.setUseBrowserConfirm(false);
            

            $.ajax({
                type: "POST",
                url: "CallAjax.aspx/GetComment",
                data: JSON.stringify({ clid: clid }),
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (response) {
                    Dialog.alert(response.d);
                },
                failure: function (response) {
                }
            });
        }
    </script>

    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server">
            <CompositeScript>
                <Scripts>
                    <asp:ScriptReference Path="~/libs/tabs/common.js" />
                    <asp:ScriptReference Path="~/libs/tabs/dialog.js" />
                </Scripts>
            </CompositeScript>
        </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="folderToolButton" class="btn btn-primary" onclick="OpenFolders()"><span class="fa-solid fa-folder-open"></span></button>
                    <button type="button" id="listWaitToolButton" class="btn btn-primary" onclick="ListWait()"><asp:Localize ID="Localize2" runat="server" meta:resourcekey="L02">승인</asp:Localize></button>
                    <button type="button" id="listAllToolButton" class="btn btn-primary" onclick="ListAll()"><asp:Localize ID="Localize3" runat="server" meta:resourcekey="L03">전체</asp:Localize></button>
                </div>
            </div>
        </div>

        <div class="container-fluid" style="padding-top:40px">
            <asp:GridView ID="MsgGridView" runat="server" Width="100%" CssClass="table table-hover table-fixed" AutoGenerateColumns="false" 
                AllowPaging="true" PageSize="20" AllowSorting="true" GridLines="None" ShowHeaderWhenEmpty="true" ShowHeader="true" 
                DataSourceID="MailApvDataSource" EnableViewState="true" DataKeyNames="cl_id"
                OnPreRender="MsgGridView_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("cl_id"))%>">
                                <div class="col-xs-12">
                                    <div class="row">
                                        <div class="col-xs-12 col-subject">
                                            <%# Server.HtmlEncode((string)Eval("cl_subject"))%>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <div class="col-xs-12 mail-wrap">
                                            <small><%# Server.HtmlEncode((string)Eval("cl_from"))%></small> <span class="glyphicon glyphicon-arrow-right"></span> 
                                            <small><%# Server.HtmlEncode((string)Eval("cl_to"))%></small>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <div class="col-xs-6">
                                            <small><%# GetDate((DateTime)Eval("cl_date"))%></small>
                                        </div>
                                        <div class="col-xs-6 text-right">
                                            <small><%# GetStatus((int)Eval("cl_flag"), Eval("cl_confirmdate"), (int)Eval("cl_count"), (Guid)Eval("cl_id"))%></small>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns> 
                <PagerSettings PageButtonCount="5" Mode="NumericFirstLast" />
                <PagerStyle CssClass="mc-gridpager"/>
            </asp:GridView>
        </div>

        <asp:ObjectDataSource ID="MailApvDataSource" runat="server" TypeName="MailApvDataSource" SelectMethod="GetMessages" OnSelecting="MailApvDataSource_Selecting">
            <SelectParameters>
                <asp:QueryStringParameter Name="listMode" Type="String" QueryStringField="mode" DefaultValue="ListWait" />
                <asp:Parameter Name="approverId" Type="String" />
            </SelectParameters>
        </asp:ObjectDataSource>
    </form>
</body>
</html>
