<%@ Page Language="C#" AutoEventWireup="true" CodeFile="View.aspx.cs" Inherits="Approval_View" meta:resourcekey="Page" %>

<!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 type="text/css">
        .docTypeBox {
            display: flex;
        }
        .docTypeBox .last {
            margin-left: auto;
        }
    </style>
    <script type="text/javascript">
        var darkView = { enabled: false };

        $(document).ready(function () {
            // 다크 모드 여부 확인
            if (window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches) {
                var v = localStorage.getItem("apv_darkview");
                if (v !== null) {
                    darkView = JSON.parse(v);
                } else {
                    darkView = { enabled: true };
                }
                SetDarkView(darkView.enabled);
            } else {
                document.getElementById("toggleDarkView").style.display = "none";
            }
        });

        function OpenApply() {
            location.href = "ApplyApproval.aspx?person=<%=_personId%>&btext=" + encodeURIComponent("<%=_approveButtonText%>");
        }

        function OpenReject() {
            location.href = "RejectApproval.aspx?person=<%=_personId%>&btext=" + encodeURIComponent("<%=_declineButtonText%>");
        }

        function OpenSuspend() {
            location.href = "SuspendApproval.aspx?person=<%=_personId%>";
        }

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

        function ToggleDarkView() {
            darkView.enabled = !darkView.enabled;
            SetDarkView(darkView.enabled);
            localStorage.setItem("apv_darkview", JSON.stringify(darkView));
            return false;
        }

        function SetDarkView(toggle) {
            if (toggle) {
                $("#bodyDiv").css({
                    "background-color": "rgba(0, 0, 0, 0)",
                    "color": $("body").css("color")
                });
            } else {
                $("#bodyDiv").css({
                    "background-color": "#fff",
                    "color": "#333"
                });
            }
        }
    </script>

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

        <div class="container-fluid">
            <div class="row" id="toolBar" data-spy="affix">
                <div class="col-xs-12" style="padding-top:2px;padding-bottom:2px;">
                    <button type="button" id="approveToolButton" runat="server" class="btn btn-primary" disabled="disabled" onclick="OpenApply()"><span class="fa-regular fa-circle-check"></span> <%=_approveButtonText%></button>
                    <button type="button" id="declineToolButton" runat="server" class="btn btn-primary" disabled="disabled" onclick="OpenReject()"><span class="fa-regular fa-circle-xmark"></span> <%=_declineButtonText%></button>
                    <button type="button" id="suspendToolButton" runat="server" class="btn btn-primary" disabled="disabled" style="display:none;" onclick="OpenSuspend()"><span class="fa-regular fa-circle-pause"></span> <asp:Localize ID="Localize10" runat="server" meta:resourcekey="L10">보류</asp:Localize></button>
                    <span>&nbsp;</span>
                    <button type="button" id="closeToolButton" class="btn btn-primary" onclick="GotoList();"><span class="fa-solid fa-bars"></span></button>
                </div>
            </div>
        </div>

        <div class="container-fluid" style="padding-top:42px">
            <table class="table table-bordered table-condensed">
                <thead>
                    <tr>
                        <th><asp:Localize ID="Localize1" runat="server" meta:resourcekey="L01">결재종류</asp:Localize></th>
                        <th><asp:Localize ID="Localize2" runat="server" meta:resourcekey="L02">결재정보</asp:Localize></th>
                        <th class="text-center"><asp:Localize ID="Localize3" runat="server" meta:resourcekey="L03">상태</asp:Localize></th>
                    </tr>
	            </thead>
                <tbody>
                    <asp:Repeater ID="ApvStepRepeater" runat="server">
                        <ItemTemplate>
                            <tr>
		                        <td>
                                    <%# GetRight((int)Eval("Rights"), (int)Eval("Step"))%>
                                </td>
                                <td>
                                    <div><%# GetName((Guid)Eval("Id"), (string)Eval("Name"), (string)Eval("Department")) %></div>
                                    <div><%# GetApvDate((DateTime)Eval("DecisionDate"))%></div>
                                </td>
                                <td class="text-center">
                                    <%# GetStatus((int)Eval("Rights"), (int)Eval("Status"))%> 
                                </td>
	                        </tr>
                            <%# GetReject((string)Eval("Reject"))%>
                        </ItemTemplate>
                    </asp:Repeater>
	            </tbody>
            </table>

            <div class="row">
                <div class="col-xs-3">
                    <asp:Localize ID="Localize4" runat="server" meta:resourcekey="L04">문서 종류</asp:Localize>:
                </div>
                <div class="col-xs-9 docTypeBox">
                    <span><asp:Literal ID="DocTypeLabel" runat="server" Mode="Encode"></asp:Literal></span>
                    <span id="toggleDarkView" class="last"><a href="#" onclick="return ToggleDarkView()"><i class="fa-solid fa-circle-half-stroke"></i></a></span>
                </div>
            </div>
            <div class="row">
                <div class="col-xs-3">
                    <asp:Localize ID="Localize5" runat="server" meta:resourcekey="L05">문서 번호</asp:Localize>:
                </div>
                <div class="col-xs-9">
                    <asp:Label ID="CodeLabel" runat="server"></asp:Label>
                </div>
            </div>
            <div class="row">
                <div class="col-xs-3">
                    <asp:Localize ID="Localize11" runat="server" meta:resourcekey="L11">등록일</asp:Localize>:
                </div>
                <div class="col-xs-9">
                    <asp:Label ID="CreateDateLabel" runat="server"></asp:Label>
                </div>
            </div>
            <div class="row">
                <div class="col-xs-3">
                    <asp:Localize ID="Localize6" runat="server" meta:resourcekey="L06">제목</asp:Localize>:
                </div>
                <div class="col-xs-9">
                    <asp:Literal ID="SubjectLabel" runat="server" Mode="Encode"></asp:Literal>
                </div>
            </div>
            <div class="row">
                <div class="col-xs-3">
                    <small><asp:Localize ID="Localize7" runat="server" meta:resourcekey="L07">보존 기한</asp:Localize>:</small>
                </div>
                <div class="col-xs-9">
                    <small><asp:Label ID="KeepDaysLabel" runat="server"></asp:Label></small>
                </div>
            </div>
            <div id="RefereePanel" runat="server" class="row collapse">
                <div class="col-xs-3">
                    <small><asp:Localize ID="Localize8" runat="server" meta:resourcekey="L08">참조자</asp:Localize>:</small>
                </div>
                <div class="col-xs-9">
                    <small><asp:Literal ID="RefereeLabel" runat="server" Mode="Encode"></asp:Literal></small>
                </div>
            </div>
            <div id="CirculationPanel" runat="server" class="row collapse">
                <div class="col-xs-3">
                    <small class="text-muted"><asp:Localize ID="Localize9" runat="server" meta:resourcekey="L09">회람</asp:Localize>:</small>
                </div>
                <div class="col-xs-9">
                    <small class="text-muted"><asp:Literal ID="CirculationLabel" runat="server" Mode="Encode"></asp:Literal></small>
                </div>
            </div>
            <div id="attachPanel" runat="server" class="collapse">
                <hr />
                <div class="mc-likeLink" data-toggle="collapse" data-target="#attachList">
                    <div class="row" style="padding-bottom:0.5em">
                        <div class="col-xs-12">
                            <i class="fa-solid fa-paperclip"></i> <asp:Label ID="AttachSummaryLabel" runat="server"></asp:Label>
                        </div>
                    </div>
                </div>
                <div id="attachList" class="list-group collapse">
                    <asp:Literal ID="AttachListTag" runat="server" />
                </div>
            </div>
            <hr />
            <div id="bodyDiv" style="min-height: 150px;padding: 5px 10px;overflow:auto">
                <asp:PlaceHolder ID="MsgBodyHolder" runat="server" EnableViewState="false"></asp:PlaceHolder>
            </div>
        </div>
    </form>
</body>
</html>
