<%@ control language="VB" autoeventwireup="false" inherits="RCC_HelpDesk_SubmitTicket, MachSol.MachPanel.Web" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="EM" %>
<%@ Register Src="../CC/SearchCustomer.ascx" TagName="SearchCustomer" TagPrefix="EM" %>
<%@ Register Src="~/RCC/Clients/CC/ClientsList.ascx" TagName="ClientsList" TagPrefix="EM" %>
<%@ Register Assembly="obout_Editor" Namespace="OboutInc.Editor" TagPrefix="obout" %>


    <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 Txt_Client = document.getElementById(array[0] + 'Txt_Client');
            var TxBx_Subject = document.getElementById(array[0] + 'TxBx_Subject');
            var TxBx_Body = oboutGetEditor('TxBx_Body').getContent();

            if (Txt_Client.value.trim().length == 0) {
                alert("<%= Resources.Content.SelectCustomer%>");
                return false;
            }

            if (TxBx_Subject.value.trim().length == 0) {
                alert("<%= Resources.Content.EnterSubject%>");
                return false;
            }

            if (TxBx_Body.trim().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>

    <ajax:UpdatePanel ID="UP_Panel" runat="server">
        <ContentTemplate>
            <asp:Panel ID="Pnl_Filter" runat="server" DefaultButton="Btn_Submit">
                <div class="col-xs-12">
                    <div class="card">
                        <div class="body">

                            <div class="card">
                                <div class="header" id="Div_Heading" runat="server">
                                    <h3>
                                        <%= Resources.Content.SD1016%>                                                                                                                                
                                    </h3>
                                </div>
                                <div class="body">
                                    <div class="row">
                                        <div class="col-sm-2 col-xs-12 row-label">
                                            *
                            <asp:Literal ID="Literal7" runat="server" EnableViewState="false" Text="<%$ Resources:Content,GN0000850%>" />:
                                        </div>
                                        <div class="col-sm-4 col-xs-12">
                                            <div class="form-group">
                                                <div class="form-line">
                                                    <asp:TextBox ID="Txt_Client" ReadOnly="true" runat="server" Width="300px" />
                                                    <asp:RequiredFieldValidator ID="RFV_Txt_Client" runat="server" Display="None" SetFocusOnError="True"
                                                        ControlToValidate="Txt_Client" ValidationGroup="addMessage" />
                                                </div>
                                            </div>
                                        </div>
                                        <div class="col-sm-6 col-xs-12">
                                            <asp:Button ID="Btn_SelectClient" CausesValidation="false" SkinID="goButton" runat="server"
                                                Text="<%$ Resources:Content,GN0000890%>" CssClass="btn btn-primary" />
                                        </div>
                                    </div>
                                    <div class="row">
                                        <div class="col-sm-2 row-label col-xs-12">
                                            <asp:Literal ID="Literal8" runat="server" EnableViewState="false" Text="<%$ Resources:Content,GN00001340%>" />:
                                        </div>
                                        <div class="col-sm-4 col-xs-12">
                                            <div class="form-group">
                                                <div class="form-line">
                                                    <asp:TextBox ID="TxBx_CC" runat="server" MaxLength="250" Width="300px" />
                                                </div>

                                                <small>
                                                    <asp:Literal ID="Literal9" runat="server" EnableViewState="false" Text="<%$ Resources:Content,String555%>" />
                                                </small>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <div class="col-sm-2 col-xs-12 row-label">
                                            *
                            <asp:Literal ID="Literal2" runat="server" EnableViewState="false" Text="<%$ Resources:Content,GN0000371%>" />:
                                        </div>
                                        <div class="col-sm-4 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" />
                                                </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="Literal3" runat="server" EnableViewState="false" Text="<%$ Resources:Content,GN0000374%>" />:
                                        </div>
                                        <div class="col-sm-4 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" EnableViewState="false" Text="<%$ Resources:Content,GN0001300%>" />:
                                        </div>
                                        <div class="col-sm-4 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" EnableViewState="false" Text="<%$ Resources:Content,GN00001337%>" />:
                                        </div>
                                        <div class="col-sm-4 col-xs-12">
                                            <div class="form-group">
                                                <div class="form-line">
                                                    <input id="Attachment" type="file" runat="server" size="50" />
                                                    <asp:Button SkinID="goButton" ID="Btn_Upload" runat="server" Text="<%$ Resources:Content,DGN1110451%>" Style="display: none;" CssClass="btn btn-primary btnAction" />
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label>
                                                    <asp:Label ID="Lbl_AttachmentSizeNote" runat="server" /></label>
                                            </div>
                                            <div>
                                                <asp:HiddenField ID="HF_PostType" runat="server" Value="-1" />
                                                <%--<div id="Div_NoAttachedFiles" runat="server" style="color: blue">No attachments.</div>--%>
                                                <asp:GridView AllowPaging="false" AllowSorting="false" ID="GV_Attachment" Width="100%" HorizontalAlign="center" runat="server"
                                                    AutoGenerateColumns="False" CssClass="table table-bordered table-hover table-striped" GridLines="None">
                                                    <Columns>
                                                        <asp:TemplateField HeaderText="<%$ Resources:Content,DGN1110452%>" HeaderStyle-HorizontalAlign="Left">
                                                            <ItemTemplate>
                                                                <div id="Div_FileName" runat="server">
                                                                </div>
                                                            </ItemTemplate>
                                                        </asp:TemplateField>
                                                        <asp:TemplateField HeaderText="<%$ Resources:Content,DGN1119982%>" HeaderStyle-HorizontalAlign="Left">
                                                            <ItemTemplate>
                                                                <div id="Div_FileSize" runat="server">
                                                                </div>
                                                            </ItemTemplate>
                                                        </asp:TemplateField>
                                                        <asp:TemplateField HeaderText="<%$ Resources:Content,GN0000360%>" HeaderStyle-HorizontalAlign="Left">
                                                            <ItemTemplate>
                                                                <asp:LinkButton CommandName="Remove" ID="LB_Remove" runat="server" Text="<%$ Resources:Content,GN0000278%>" CssClass="btn btn-primary btnAction" />
                                                            </ItemTemplate>
                                                        </asp:TemplateField>
                                                    </Columns>
                                                </asp:GridView>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <div class="col-sm-2 col-xs-12 row-label">
                                            *
                            <asp:Literal ID="Literal6" runat="server" EnableViewState="false" Text="<%$ Resources:Content,GN0000774%>" />:
                                        </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" />
                                                <asp:HiddenField ID="HF_Body" runat="server" />
                                            </div>
                                        </div>
                                    </div>
                                    <div class="row">

                                        <div class="col-xs-12">
                                            <asp:ValidationSummary HeaderText='<%$ Resources:Content, EM000001 %>' ID="ValidationSummary1"
                                                runat="server" ShowMessageBox="True" ShowSummary="False" ValidationGroup="addMessage" />
                                            <asp:Button ID="Btn_Submit" runat="server" Text="<%$ Resources:Content,GN0000710%>"
                                                ValidationGroup="addMessage" CssClass="btn btn-primary" />
                                             <asp:Button ID="Btn_Cancel" runat="server" Text="<%$ Resources:Content,GN0000572%>"
                                                CausesValidation="false" CssClass="btn btn-primary" Visible="false" />
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <table class="tblNewListing" cellpadding="0" cellspacing="0" border="0" width="98%">

                    <tr>
                        <td class="shade"></td>
                        <td>
                            <div>
                            </div>

                        </td>
                    </tr>
                    <tr>
                        <td class="shade"></td>
                        <td></td>
                    </tr>
                    <tr>
                        <td class="noborder"></td>
                        <td class="noborder"></td>
                    </tr>
                </table>
            </asp:Panel>
        </ContentTemplate>
        <Triggers>
            <ajax:PostBackTrigger ControlID="Btn_Submit" />
            <ajax:PostBackTrigger ControlID="Btn_Cancel" />
        </Triggers>
    </ajax:UpdatePanel>
    <%--Required for Attachment--%>
    <div id="dummy" style="display: none">
    </div>
    <%-- End Required for Attachment--%>
    <ajax:UpdatePanel ID="UP_Inter" runat="server" UpdateMode="Conditional">
        <ContentTemplate>
            <asp:Button ID="Btn_Dummy2" Style="display: none" runat="server" />
            <asp:Panel ID="Panel2" runat="server" CssClass="width-modal-popup-auto" Style="display: none;">
                <div class="col-xs-12">
                    <div class="card">
                        <div class="header container-fluid">
                            <h3 class="pull-left"><%= Resources.Content.GN0000889%></h3>
                            <span>
                                <button type="button" class="close" onclick="$find('<%=MPE_ClientsList.ClientID%>').hide();">&times;</button>
                            </span>
                        </div>
                        <div class="body">
                            <div class="row">
                                <EM:ClientsList ID="ClientsList" runat="server" />
                            </div>
                        </div>
                    </div>
                </div>
            </asp:Panel>
            <EM:ModalPopupExtender runat="server" ID="MPE_ClientsList" BackgroundCssClass="modalBackground"
                DropShadow="false" PopupControlID="Panel2" TargetControlID="Btn_Dummy2">
            </EM:ModalPopupExtender>
        </ContentTemplate>
    </ajax:UpdatePanel>