<%@ Page Language="C#" AutoEventWireup="true" CodeFile="MoveTo.aspx.cs" Inherits="Mail_MoveTo" 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/bootstrap/css/animate.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>
    <script type="text/javascript" src="../libs/bootstrap-notify.min.js"></script>
</head>
<body>
    <script type="text/javascript">
        $(document).ready(function () {
            Dialog.setMessage('<asp:Literal runat="server" Text="<%$ Resources:Dialog, Title%>" />', '<asp:Literal runat="server" Text="<%$ Resources:Dialog, OK%>" />', '<asp:Literal runat="server" Text="<%$ Resources:Dialog, Cancel%>" />');
            Dialog.setUseBrowserConfirm(<%=AppSetting.UseBrowserConfirm%>);
        });

        function MoveMessage(folderId) {
            $.ajax({
                type: "POST",
                url: "CallAjax.aspx/MoveMessage",
                data: JSON.stringify({
                    folderId: folderId,
                    msgIds: '<%=_msgIds%>'
                }),
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (response) {
                    // 성공 메시지 출력 후 페이지를 이동시킨다.
                    //$("#successMsg strong").html(response.d);
                    //$("#successMsg").collapse("show");
                    var msg = String.format('<asp:Literal runat="server" Text="<%$ Resources:, Msg02%>" />', response.d);
                    mc7_notify(msg, "success");
                    window.setTimeout(function () {
                        location.href = "List.aspx?folder=<%=_folderId%>&page=<%=_page%>";
                    }, 2000);
                },
                failure: function (response) {
                    Dialog.alert('<asp:Literal runat="server" Text="<%$ Resources:, Msg01%>" />'); // 메시지 이동 작업을 실패했습니다.
                }
            });            
        }
    </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" />
                    <asp:ScriptReference Path="~/libs/tabs/notify.js" />
                </Scripts>
            </CompositeScript>
        </asp:ScriptManager>

        <div class="container-fluid">
            <div id="successMsg" class="alert alert-success collapse">
                <strong>Success!</strong> <asp:Localize ID="Localize1" runat="server" meta:resourcekey="Localize1">개의 메시지가 성공적으로 이동되었습니다.</asp:Localize>
            </div>
            
            <table class="table table-hover">
                <thead>
                    <tr>
                        <th style="font-size:larger">
                            <div class="row">
                                <div class="col-xs-10">
                                    <asp:Localize ID="Localize2" runat="server" meta:resourcekey="Localize2">폴더 선택</asp:Localize>
                                </div>
                                <div class="col-xs-2 text-right">
                                    <button type="button" id="closeToolButton" class="btn btn-primary" onclick="history.back();"><span class="fa-solid fa-xmark"></span></button>
                                </div>
                            </div>
                        </th>
                    </tr>
	            </thead>
                <tbody>
                    <asp:Repeater ID="FolderRepeater" runat="server" DataSourceID="FolderDataSource">
                        <ItemTemplate>
                            <tr>
		                        <td>
                                    <div class="row" style='padding-left:<%# GetIndent((int)Eval("Indent")) %>px;' onclick="MoveMessage('<%#((Guid)Eval("ID"))%>')">
                                        <div class="col-xs-12">
                                            <%# GetFolderInfoEx((Guid)Eval("ID"), (string)Eval("FolderName"), (int)Eval("NewMsgCount"), (int)Eval("MsgCount"))%>
                                        </div>
                                    </div>
                                </td>
	                        </tr>
                        </ItemTemplate>
                    </asp:Repeater>
	            </tbody>
            </table>
        </div>

        <asp:ObjectDataSource ID="FolderDataSource" runat="server" TypeName="MailFolderDataSource" SelectMethod="GetFolders" >
            <SelectParameters>
                <asp:Parameter Name="allMails" Type="Boolean" DefaultValue="false" />
                <asp:Parameter Name="unreadMails" Type="Boolean" DefaultValue="false" />
                <asp:Parameter Name="flaggedMails" Type="Boolean" DefaultValue="false" />
                <asp:Parameter Name="readRecipients" Type="Boolean" DefaultValue="false" />
                <asp:Parameter Name="sendApproval" Type="Boolean" DefaultValue="false" />
                <asp:Parameter Name="spamNotification" Type="Boolean" DefaultValue="false" />
            </SelectParameters>
        </asp:ObjectDataSource>
    </form>
</body>
</html>
