@using Common
@model string
<div class="main">
    <form method="post" class="form-horizontal form form-group-sm" action="@Url.Action()">
        <div class="control-group">
            <label class="control-label">收件人</label>
            <div class="controls form-inline">
                <input type="text" id="receiver" name="receiver" disabled class="form-control" style="width:80%" value="" data-validate="dataType:'*" nullMsg:'请填写收件人!">
                @if (Request.QueryString["action"] != "1")
                {
                    <button type="button" class="btn btn-default btn-sm ui-dialog xzyh" data-custom-params="title: '选择用户', url: '@Url.Action("SelectFriends","Friends")', width: '790px', height: '90%', target: '_self'">选择好友</button>
                }
                <span class="help-block"></span>
            </div>
        </div>
        <div class="control-group">
            <label class="control-label">标题</label>
            <div class="controls">
                <input type="text" id="title" name="title" disabled class="form-control" style="width:80%" value="" data-validate="dataType:'*" nullMsg:'请填写标题!">
                <span class="help-block"></span>
            </div>
        </div>
        <div class="control-group">
            <label class="control-label">信息内容</label>
            <div class="controls">
                <textarea name="content" id="content" style="width:100%;height:400px;" data-validate="dataType:'editor" nullMsg:'请填写信息内容!"></textarea>
                <script charset="utf-8" src="/e/incs/kindeditor/kindeditor.js"></script>
                <script type="text/javascript">
                    var KE_content;
                    KindEditor.ready(function (K) {
                        KE_content = K.create('#content',
                            {
                                uploadJson: kindeditor_uploadJson,
                                fileManagerJson: kindeditor_fileManagerJson,
                                allowFileManager: false,
                                items: SmallEditor,
                                filterMode: false,
                                extraFileUploadParams: { table: 'pa_msg_outbox', field: 'content', username: '@ViewBag.siteId' },
                                afterBlur: function () { this.sync(); }
                            }
                        );
                    });
                </script>
                <span class="help-block"></span>
            </div>
        </div>
        <div class="postarea text-center sendout">
            <span class="help-block"></span>         
            <input type="hidden" id="id" name="id" value="" />
            <input type="hidden" id="uid" name="uid" value="@PA.GetCurrentUser().Uid"/>
            <input type="hidden" id="thedate" name="thedate" value="@DateTime.Now"/>
            <input type="hidden" id="guid" name="guid" value="@PA.NewGuid()" />
            @if (Request.QueryString["action"] != "1")
            {
                <button type="button" class="btn btn-primary btn-sm ui-pagePost" data-custom-params="url:'@Url.Action()'">发送</button>
            }
            @if (Request.QueryString["action"] != "2")
            {
                <button type="button" class="btn btn-primary btn-sm ui-dialog" data-custom-params="title:'转发内容',url:'@Url.Action("Edit")?id=@Request.QueryString["id"]&action=2',width:'900px',height:'90%',beforeExecute:'Forward'">转发</button>
            }
            @if (Request.QueryString["action"] != "3")
            {
                <button type="button" class="btn btn-primary btn-sm ui-dialog" data-custom-params="title:'重发',url:'@Url.Action("Edit")?id=@Request.QueryString["id"]&action=3',width:'900px',height:'90%',beforeExecute:'SendAgain'">重发</button>
            }
            <button type="button" class="btn btn-default btn-sm ui-closeDialog">关闭</button>
        </div>
    </form>
</div>


<script type="text/javascript">
    $(function () {
        var ajaxUrl = "@Url.Action("DetailData")?id=" + Request("id");
        $(".form").FormBind(data);

        var msg_id = $("#id").val();
        var username = CallAjax("get", false, "@Url.Action("GetReceiverUid")", "msg_id=" + msg_id);
        $("#receiver").val(username);

        if (Request("action") == "1") {

        } else if (Request("action") == "2") {
            $("#receiver,#title").removeAttr("disabled");
            $("#receiver").val("");
        } else if (Request("action") == "3") {
            $("#receiver,#title").removeAttr("disabled");
        }
    })
    function Forward()
    {
        CloseDialog()
    }
    function SendAgain() {
        CloseDialog()
    }
</script>