<%@ page language="VB" masterpagefile="~/Template/Master_Client.master" autoeventwireup="false" inherits="Clients_SubmitTicket, MachSol.MachPanel.Web" %>

<%@ Register Assembly="obout_Editor" Namespace="OboutInc.Editor" TagPrefix="obout" %>

<asp:Content ID="Content1" ContentPlaceHolderID="CPH_Content" runat="Server">

    <script type="text/javascript" language="javascript">

        function SearchRelatedLinks() {
            var params = "{'SearchText': '" + $get('<%=TxBx_Subject.ClientID%>').value + "'}";
            $.ajax({
                type: "POST",
                url: "SubmitTicket.aspx/GetRelatedBLinks",
                async: true,
                data: params,
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (result) {

                    //Clear div
                    $("#DivInner_RelatedLink").html("");
                    $("#Div_RelatedLinks").addClass("hide");

                    if (result.d.trim() == '') {
                        return;
                    }
                    var json = $.parseJSON(result.d);

                    if (json.data.length > 0) {
                        $("#Div_RelatedLinks").removeClass("hide");
                    }
                    //Iterate through each record
                    for (var i = 0; i < json.data.length; i++) {
                        var link = $("<a>");
                        link.attr("href", json.data[i].url);
                        link.attr("title", json.data[i].title);
                        link.attr("target", "_blank");
                        link.text(json.data[i].title);
                        link.addClass("btn btn-info btn-xs");

                        var $div = $("<div>");
                        $div.html(link);

                        $("#DivInner_RelatedLink").append($div);
                    }
                },
                error: function (result) {
                    console.log(result.responseJSON.Message)
                    //Clear div
                    $("#DivInner_RelatedLink").html("");
                    $("#Div_RelatedLinks").addClass("hide");
                }
            });
        }

        function Upload(Id) {
            var array = Id.split('TxBx_Body');
            var Attachment = document.getElementById(array[0] + 'Attachment');
            var HF_PostType = document.getElementById(array[0] + 'HF_PostType');


            var strTxBx_Subject = document.getElementById(array[0] + 'TxBx_Subject').value.trim();
            var strTxBx_Body = oboutGetEditor('TxBx_Body').getContent().trim();


            if (strTxBx_Subject.length == 0) {
                alert("<%= Resources.Content.EnterSubject%>");
                return false;
            }
            else {
                if (strTxBx_Body.length == 0) {
                    alert("<%= Resources.Content.EnterReply%>");
                    return false;
                }
            }
            if (Attachment.value != "") {
                HF_PostType.value = "1"
                __doPostBack('dummy', '');
                //$object("_PageRequestManager")._doPostBack( "dummy", "" );
                return false;
            }
            else {
                //alert("Click Browse button and select a file to upload.");
                HF_PostType.value = "0"
                //return false;
            }
        }

    </script>
    <asp:Panel ID="Pnl_Submit" runat="server" DefaultButton="Btn_Submit">
        <div class="col-xs-12">
            <div class="card">
                <div class="header">
                    <h3><%= Resources.Content.DGN1110450%>  </h3>
                </div>
                <div class="body">
                    <div class="row">
                        <div class="col-sm-2 col-xs-12 row-label">
                            *
                        <asp:Literal ID="Literal2" runat="server" Text="<%$ Resources:Content,GN0000371%>" EnableViewState="false" />:
                        </div>
                        <div class="col-sm-6 col-xs-12">
                            <div class="form-group">
                                <div class="form-line">
                                    <asp:TextBox ID="TxBx_Subject" runat="server" MaxLength="250" Width="300px" onfocusout="SearchRelatedLinks();" />
                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" Display="None"
                                        SetFocusOnError="True" ControlToValidate="TxBx_Subject" ValidationGroup="addMessage" ErrorMessage="" />
                                </div>
                            </div>
                        </div>
                    </div>
                    <div id="Div_RelatedLinks" class="hide">
                        <div class="row">
                            <div class="col-xs-12 row-label">
                                <asp:Literal ID="LiteralKBLinks" Text="<%$ Resources:Content,PleaseReviewFollowingKB %>" runat="server" />
                            </div>
                            <div class="col-xs-12">
                                <div class="form-group">
                                    <div class="form-line">
                                        <div id="DivInner_RelatedLink" style="max-height: 250px; overflow: auto;"></div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-sm-2 col-xs-12 row-label">
                            <asp:Literal ID="Literal7" runat="server" Text="<%$ Resources:Content,GN00001340%>" EnableViewState="false" />:
                        </div>
                        <div class="col-sm-6 col-xs-12">
                            <div class="form-group">
                                <div class="form-line">
                                    <asp:TextBox ID="TxBx_CC" runat="server" />
                                </div>
                            </div>
                            <asp:Literal ID="Literal9" runat="server" EnableViewState="false" Text="<%$ Resources:Content,String555%>" />
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-sm-2 col-xs-12 row-label">
                            *
                        <asp:Literal ID="Literal3" runat="server" Text="<%$ Resources:Content,GN0000374%>" EnableViewState="false" />:
                        </div>
                        <div class="col-sm-6 col-xs-12">
                            <div class="form-group">
                                <asp:DropDownList ID="RBL_Department" runat="server" />
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-sm-2 col-xs-12 row-label">
                            *
                        <asp:Literal ID="Literal4" runat="server" Text="<%$ Resources:Content,GN0001300%>" EnableViewState="false" />:
                        </div>
                        <div class="col-sm-6 col-xs-12">
                            <div class="form-group">
                                <asp:DropDownList ID="DDL_Importance" runat="server" />
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-sm-2 col-xs-12 row-label">
                            <asp:Literal ID="Literal5" runat="server" Text="<%$ Resources:Content,GN00001337%>" EnableViewState="false" />:
                        </div>
                        <div class="col-sm-6 col-xs-12">
                            <div class="form-group">
                                <input id="Attachment" type="file" runat="server" size="50" />
                                <asp:Button CssClass="btn btn-primary waves-effect" SkinID="goButton" ID="Btn_Upload" runat="server" Text="<%$ Resources:Content,DGN1110451%>" Style="display: none;" />
                                <asp:HiddenField ID="HF_PostType" runat="server" />
                                <asp:GridView ID="GV_Attachment" HorizontalAlign="center" runat="server"
                                    AutoGenerateColumns="False" CssClass="table table-bordered table-hover table-responsive table-striped" GridLines="None">
                                    <Columns>
                                        <asp:TemplateField HeaderText="<%$ Resources:Content,DGN1110452%>" HeaderStyle-HorizontalAlign="Left" HeaderStyle-CssClass="col-xs-5">
                                            <ItemTemplate>
                                                <div id="Div_FileName" runat="server">
                                                </div>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="<%$ Resources:Content,DGN1119982%>" HeaderStyle-HorizontalAlign="Left" HeaderStyle-CssClass="col-xs-5">
                                            <ItemTemplate>
                                                <div id="Div_FileSize" runat="server">
                                                </div>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="<%$ Resources:Content,GN0000360%>" HeaderStyle-HorizontalAlign="Left" HeaderStyle-CssClass="col-xs-2">
                                            <ItemTemplate>
                                                <asp:LinkButton CommandName="Remove" ID="LB_Remove" runat="server" Text="<%$ Resources:Content,GN0000278%>" />
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                    </Columns>
                                </asp:GridView>
                            </div>

                            <div class="form-group">
                                <label>
                                    <asp:Label ID="Lbl_AttachmentSizeNote" runat="server" /></label>
                            </div>
                        </div>
                    </div>

                    <div class="row">
                        <div class="col-sm-2 col-xs-12 row-label">
                            *
                        <asp:Literal ID="Literal6" runat="server" Text="<%$ Resources:Content,GN0000774%>" EnableViewState="false" />:
                        </div>
                        <div class="col-sm-10 col-xs-12">
                            <div class="form-group">
                                <obout:Editor ID="TxBx_Body" Submit="false" ShowWaitMessage="false" AjaxWait="false" runat="server" Appearance="custom">
                                    <Buttons>
                                        <obout:Select Name="FontName" />
                                        <obout:Select Name="FontSize" />
                                        <obout:HorizontalSeparator />
                                        <obout:Toggle Name="Bold" />
                                        <obout:Toggle Name="Italic" />
                                        <obout:Toggle Name="Underline" />
                                        <obout:Toggle Name="StrikeThrough" />
                                        <obout:Toggle Name="SuperScript" />
                                        <obout:Toggle Name="SubScript" />
                                        <obout:HorizontalSeparator />
                                        <obout:Method Name="ForeColor" />
                                        <obout:Method Name="ForeColorClear" />
                                        <obout:Method Name="BackColor" />
                                        <obout:Method Name="BackColorClear" />
                                        <obout:VerticalSeparator />
                                        <obout:Method Name="Redo" />
                                        <obout:Method Name="Undo" />
                                        <obout:HorizontalSeparator />
                                        <obout:Method Name="Cut" />
                                        <obout:Method Name="Copy" />
                                        <obout:Method Name="Paste" />
                                        <obout:Method Name="PasteText" />
                                        <obout:HorizontalSeparator />
                                        <obout:Method Name="Paragraph" />
                                        <obout:Method Name="GetFormat" />
                                        <obout:Method Name="ApplyFormat" />
                                        <obout:HorizontalSeparator />
                                        <obout:Method Name="JustifyLeft" />
                                        <obout:Method Name="JustifyCenter" />
                                        <obout:Method Name="JustifyRight" />
                                        <obout:Method Name="JustifyFull" />
                                        <obout:HorizontalSeparator />
                                        <obout:Method Name="OrderedList" />
                                        <obout:Method Name="BulletedList" />
                                        <obout:HorizontalSeparator />
                                        <obout:Method Name="InsertHR" />
                                        <obout:Method Name="CreateLink" />
                                        <obout:Method Name="InsertAnchor" />
                                        <obout:Method Name="InsertIMG" />
                                        <obout:HorizontalSeparator />
                                        <obout:Method Name="ClearStyles" />
                                    </Buttons>
                                </obout:Editor>
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" Display="None"
                                    SetFocusOnError="True" ControlToValidate="TxBx_Body" ValidationGroup="addMessage" ErrorMessage="" />
                                <asp:HiddenField ID="HF_Body" runat="server" />
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-xs-12">
                            <asp:ValidationSummary ID="VS" HeaderText='<%$ Resources:Content,EM000001%>' runat="server"
                                ShowMessageBox="True" ShowSummary="False" ValidationGroup="addMessage" />
                            <asp:Button CssClass="btn btn-primary waves-effect" SkinID="saveButton" ID="Btn_Submit" runat="server" Text="<%$ Resources:Content,GN0000710%>"
                                ValidationGroup="addMessage" CausesValidation="true" />
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </asp:Panel>
    <%--Required for Attachment--%>
    <div id="dummy" style="display: none">
    </div>
    <%-- End Required for Attachment--%>
</asp:Content>

