<%@ page title="" language="C#" masterpagefile="~/Pages/Common/MasterPages/MainMasterPage_new.master" autoeventwireup="true" inherits="Pages_Components_Alert_EventTemplate, App_Web_1bmyk3nb" enableEventValidation="false" viewStateEncryptionMode="Never" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
<%@ Register Src="~/UserControls/GridViewPager/GridViewPager.ascx" TagName="GridViewPager" TagPrefix="uc1" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<%@ Register Src="~/UserControls/Common/ScreenGroup/ScreenGroup.ascx" TagName="ScreenGroupControl" TagPrefix="ScreenGroup" %>
<%@ Register Src="~/UserControls/Common/StudentSearch/StudentSearch.ascx" TagName="StudentSearch" TagPrefix="Std" %>

<asp:Content ID="Content1" ContentPlaceHolderID="CP" runat="Server">
    <style>
        #DetailModal p {
            text-align: unset;
        }
    </style>
    <asp:UpdatePanel ID="SetWorkingDaysUpdatePanel" runat="server">
        <ContentTemplate>
            <Std:StudentSearch ID="StudentSearch" Visible="false" runat="server" />
            <div id="divContentPage" class="divcontentpagemargin">

                <div class="dashBoardLeftCont" valign="top">
                    <div class="himssuHeader3WireBox">
                        <table width="0px" cellpadding="0" cellspacing="0">
                            <tr>
                                <td>
                                    <div class="himsBoxContent">
                                        <div class="leftUlMenu">
                                            <ScreenGroup:ScreenGroupControl EnableViewState="true" ID="ScreenGroupControl" ScreenGroupId="124"
                                                Visible="true" runat="server" />
                                        </div>
                                    </div>
                                </td>
                            </tr>
                        </table>
                    </div>
                </div>
                <div class="row whiteboxpaddingleft">
                    <div class="himssuHeader1WireBox  card card-box">
                        <div class="himsBoxHeader card-head">
                            <div class="leftdiv">
                            </div>
                            <div class="himsBoxTitle">
                                <div class="headerText">
                                    <header>
                                        <i class="fas fa-search"></i>
                                        <asp:Label ID="Label1" runat="server" Text="Event Template"></asp:Label>
                                    </header>
                                </div>
                            </div>
                            <div class="fRight mt-27" runat="server" id="CommonUpdateDiv">
                                <asp:CheckBox ID="IsAllOrgCheckBox" runat="server" Text="Applicable To All Organization" />
                                <%--    <asp:Label ID="IsAllOrgLabel" runat="server" Text="Applicable To All Organization"></asp:Label>--%>
                            </div>
                        </div>



                        <div class="himsBoxContent card-body">
                            <div class="contentHolder">
                                <div class="outerBox pTop5 col-md-3">
                                    <div class="controlLabelWidth">
                                        <asp:Label ID="AlertModeLabel" SkinID="MandatoryLabel" runat="server" Text="Alert Mode"></asp:Label>
                                    </div>
                                    <div class="fLeft pRight5">
                                        <asp:DropDownList runat="server" ID="AlertModeDropDownList" SkinID="CustomWidthDropDownList"
                                            CssClass="form-control" onmouseleave="showHideTooltip()" onmouseenter="showHideTooltip()"
                                            AutoPostBack="true" OnSelectedIndexChanged="AlertModeDropDownList_OnSelectedIndexChanged">
                                        </asp:DropDownList>
                                    </div>
                                </div>

                                <div class=" col-md-12">
                                    <div class="alert-info " runat="server" id="AlertInfoWithMobileApp">
                                        <b>For Default Alert To	:</b>
                                        <br>
                                        <b>Mail :  </b>abc@abc.com,xyz@xyz.com 
                                        <br>
                                        <b>Sms :  </b>XXXXX99999,XXXXX88888
                                        <br>
                                        <b>Mobile App : </b>E1001,E1002(Employee Code)
                                         <br>
                                        <b>WhatsApp : </b>XXXXX99999,XXXXX88888
                                    </div>
                                    <div class="alert-info " runat="server" id="AlertInfoWithoutMobileApp">
                                        <b>For Default Alert To	:</b>
                                        <br>
                                        <b>Mail :  </b>abc@abc.com,xyz@xyz.com 
                                        <br>
                                        <b>Sms :  </b>XXXXX99999,XXXXX88888
                                        <br>
                                        <b>WhatsApp : </b>XXXXX99999,XXXXX88888
                                    </div>
                                </div>
                                <div class="cBoth p-0">
                                </div>

                                <div id="Div1" class="himssuHeader6WireBox col-md-12" runat="server">
                                    <div class="himsBoxHeader card-head inner" id="GridViewPagerDiv" runat="server">
                                        <div class="leftdiv">
                                        </div>
                                        <div class="himsBoxTitle">
                                            <div class="gridHeaderText">
                                                <header>
                                                    <asp:Label ID="GridViewLabel" Text="List" runat="server" />
                                                </header>
                                            </div>
                                        </div>
                                    </div>
                                    <div id="DetailModal" class="modal fadeInDown" role="dialog">
                                        <div class="modal-dialog">
                                            <!-- Modal content-->
                                            <div class="modal-content padd-0">
                                                <div class="modal-body">
                                                    <button type="button" class="close" data-dismiss="modal">&times;</button>
                                                    <!--Your modal content goes here-->
                                                    <div id="DetailDescription">
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>

                                    <div class="himsBoxContent">
                                        <div id="Div4" runat="server" class="table-responsive">
                                            <asp:GridView ID="EventTemplateGridView" runat="server" AutoGenerateColumns="False" CssClass="table table-striped table-bordered table-hover"
                                                EmptyDataText="No Records Found !!" AllowPaging="false" OnRowDataBound="EventTemplateGridView_RowDataBound"
                                                OnPageIndexChanging="EventTemplateGridView_PageIndexChanging" ShowHeader="True"
                                                DataKeyNames="EventId,ModuleId,IsAllowAutoSend,FieldName">
                                                <Columns>
                                                    <asp:BoundField DataField="ModuleName" HeaderText="Module Name" ItemStyle-Width="10%" HeaderStyle-HorizontalAlign="Left"></asp:BoundField>
                                                    <asp:TemplateField HeaderText="Event" ItemStyle-Width="10%" ItemStyle-HorizontalAlign="Left"
                                                        ItemStyle-Wrap="true" HeaderStyle-HorizontalAlign="Left">
                                                        <ItemTemplate>
                                                            <asp:LinkButton ID="EventDetailButton" runat="server" Text='<%# Bind("EventName") %>' CommandName="Select"
                                                                SkinID="0" OnClick="EventDetailButton_Click" Visible="false"></asp:LinkButton>
                                                            <asp:Label ID="EventLabel" runat="server" Text='<%# Bind("EventName") %>'></asp:Label>
                                                        </ItemTemplate>
                                                    </asp:TemplateField>
                                                    <asp:BoundField DataField="FieldName" HeaderText="Field Name" ItemStyle-Width="5%" HeaderStyle-HorizontalAlign="Left"></asp:BoundField>
                                                    <asp:TemplateField ItemStyle-Width="10%" HeaderText="Subject" ItemStyle-HorizontalAlign="Left"
                                                        ItemStyle-Wrap="true" HeaderStyle-HorizontalAlign="Left">
                                                        <ItemTemplate>
                                                            <asp:TextBox ID="MailSubjectTextBox" runat="server" Text='<%# Bind("MailSubject") %>'
                                                                MaxLength="100" SkinID="CustomWidthLabel" Width="154px"></asp:TextBox>
                                                        </ItemTemplate>
                                                    </asp:TemplateField>
                                                    <asp:TemplateField ItemStyle-Width="10%" HeaderText="Template" ItemStyle-HorizontalAlign="Left"
                                                        ItemStyle-Wrap="true" HeaderStyle-HorizontalAlign="Left">
                                                        <ItemTemplate>
                                                            <asp:TextBox ID="TemplateTextBox" runat="server" Text='<%# Bind("TemplateName") %>'
                                                                SkinID="MultiLineTextBox" Width="400px" TextMode="MultiLine" Height="80px"></asp:TextBox>
                                                        </ItemTemplate>
                                                    </asp:TemplateField>
                                                    <asp:TemplateField ItemStyle-Width="5%" HeaderText="Message Length" ItemStyle-HorizontalAlign="Center"
                                                        ItemStyle-Wrap="true" HeaderStyle-HorizontalAlign="Left">
                                                        <ItemTemplate>
                                                            <asp:Label ID="MessageLengthLabel" runat="server" Text='<%# Bind("MessageLength") %>'></asp:Label>
                                                        </ItemTemplate>
                                                    </asp:TemplateField>
                                                    <asp:TemplateField ItemStyle-Width="10%" HeaderText="SMS Count" ItemStyle-HorizontalAlign="Center"
                                                        ItemStyle-Wrap="true" HeaderStyle-HorizontalAlign="Left">
                                                        <ItemTemplate>
                                                            <asp:Label ID="SMSCountLabel" runat="server" Text='<%# Bind("SMSCount") %>'></asp:Label>
                                                        </ItemTemplate>
                                                    </asp:TemplateField>
                                                    <asp:TemplateField ItemStyle-Width="20%" HeaderText="Default Alert To" ItemStyle-HorizontalAlign="Left"
                                                        ItemStyle-Wrap="true" HeaderStyle-HorizontalAlign="Left">
                                                        <ItemTemplate>
                                                            <asp:TextBox ID="DefaultAlertToTextBox" runat="server" Text='<%# Bind("DefaultAlertTo") %>'
                                                                MaxLength="100" SkinID="CustomWidthLabel" Width="154px" Enabled='<%# Bind("IsAssignDefaultAlert") %>'></asp:TextBox>
                                                        </ItemTemplate>
                                                    </asp:TemplateField>
                                                    <asp:TemplateField ItemStyle-Width="20%" HeaderText="Default Alert To EUId" ItemStyle-HorizontalAlign="Left"
                                                        ItemStyle-Wrap="true" HeaderStyle-HorizontalAlign="Left">
                                                        <ItemTemplate>
                                                            <asp:TextBox ID="DefaultAlertToEUIdTextBox" runat="server" Text='<%# Bind("DefaultAlertToEUId") %>' oninput="validateInput(this)"
                                                                MaxLength="500" SkinID="CustomWidthLabel" Width="154px" Enabled='<%# Bind("IsAssignDefaultAlert") %>'></asp:TextBox>
                                                        </ItemTemplate>
                                                    </asp:TemplateField>
                                                    <asp:TemplateField ItemStyle-Width="20%" HeaderText="Email CC" ItemStyle-HorizontalAlign="Left"
                                                        ItemStyle-Wrap="true" HeaderStyle-HorizontalAlign="Left">
                                                        <ItemTemplate>
                                                            <asp:TextBox ID="EmailCCTextBox" runat="server" Text='<%# Bind("EMailCC") %>'
                                                                MaxLength="100" SkinID="CustomWidthLabel" Width="154px" onchange="ValidateMail(this);"></asp:TextBox>
                                                        </ItemTemplate>
                                                    </asp:TemplateField>
                                                    <asp:TemplateField ItemStyle-Width="20%" HeaderText="Email BCC" ItemStyle-HorizontalAlign="Left"
                                                        ItemStyle-Wrap="true" HeaderStyle-HorizontalAlign="Left">
                                                        <ItemTemplate>
                                                            <asp:TextBox ID="EmailBCCTextBox" runat="server" Text='<%# Bind("EMailBCC") %>'
                                                                MaxLength="100" SkinID="CustomWidthLabel" Width="154px" onchange="ValidateMail(this);"></asp:TextBox>
                                                        </ItemTemplate>
                                                    </asp:TemplateField>
                                                    <asp:TemplateField HeaderStyle-HorizontalAlign="Center" HeaderStyle-Width="5%" ItemStyle-Width="5%" ItemStyle-HorizontalAlign="Center">
                                                        <HeaderTemplate>
                                                            <label class="rt-chkbox rt-chkbox-outline">
                                                                <asp:CheckBox ID="AllCheckBox" runat="server" OnCheckedChanged="AllCheckBox_checked" AutoPostBack="true" />
                                                                <%--    <asp:Label ID="lblAllCHeckBox" runat="server" Text="Auto Send"></asp:Label>--%>
                                                                <span></span>
                                                                Auto Send
                                                            </label>
                                                        </HeaderTemplate>
                                                        <ItemTemplate>
                                                            <label class="rt-chkbox rt-chkbox-outline">
                                                                <asp:CheckBox ID="IsAutoSendCheckBox" runat="server" Checked='<%# Bind("IsAutoSend") %>' />
                                                                <span></span>
                                                            </label>
                                                        </ItemTemplate>
                                                    </asp:TemplateField>
                                                    <asp:TemplateField ItemStyle-Width="15%" HeaderText="Template ID" ItemStyle-HorizontalAlign="Left"
                                                        ItemStyle-Wrap="true" HeaderStyle-HorizontalAlign="Left">
                                                        <ItemTemplate>
                                                            <asp:TextBox ID="SMSTemplateIDTextBox" runat="server" Text='<%# Bind("SMSTemplateID") %>'
                                                                SkinID="CustomWidthLabel" Width="154px"></asp:TextBox>
                                                        </ItemTemplate>
                                                    </asp:TemplateField>
                                                    <asp:TemplateField ItemStyle-Width="15%" HeaderText="WhatsApp Template" ItemStyle-HorizontalAlign="Left"
                                                        ItemStyle-Wrap="true" HeaderStyle-HorizontalAlign="Left">
                                                        <ItemTemplate>
                                                            <asp:TextBox ID="WhatsAppTemplateTextBox" runat="server" Text='<%# Bind("WhatsAppTemplate") %>'
                                                                SkinID="CustomWidthLabel" Width="154px"></asp:TextBox>
                                                        </ItemTemplate>
                                                    </asp:TemplateField>
                                                    <asp:TemplateField ItemStyle-Width="15%" HeaderText="WhatsApp Template Language" ItemStyle-HorizontalAlign="Left"
                                                        ItemStyle-Wrap="true" HeaderStyle-HorizontalAlign="Left">
                                                        <ItemTemplate>
                                                            <asp:TextBox ID="WhatsAppNamespaceTextBox" runat="server" Text='<%# Bind("WhatsAppTemplateLanguage") %>'
                                                                SkinID="CustomWidthLabel" Width="154px"></asp:TextBox>
                                                        </ItemTemplate>
                                                    </asp:TemplateField>
                                                </Columns>
                                                <PagerSettings Visible="False" />
                                            </asp:GridView>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>

                    </div>

                </div>
            </div>
        </ContentTemplate>
    </asp:UpdatePanel>
    <%--   <script data-main="../../../JavaScript/rjs/encrypt/event-template-encrypt" src="../../../JavaScript/rjs/require.js"></script>--%>
    <script data-main='<%=ResolveUrl("~/JavaScript/rjs/event-template")%>' src='<%=ResolveUrl("~/JavaScript/rjs/require.js")%>'></script>

    <script type="text/javascript">
        function EventDetails(Obj) {
            $('#DetailModal').modal('toggle');
            $('#DetailDescription').html('');
            $('#DetailDescription').append(Obj);
        }
        function ValidateMail(obj) {

            var emails = obj.value.split(",");

            var regex = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/;
            var invalidEmails = [];

            for (var i = 0; i < emails.length; i++) {
                // Trim whitespaces from email address
                emails[i] = emails[i].trim();

                // Check email against our regex to determine if email is valid
                if (emails[i] == "" || !regex.test(emails[i])) {
                    invalidEmails.push(emails[i]);
                }
            }

            if (invalidEmails == 0) {
                return (true);
            }

            alert("You have entered an invalid email address!");

            obj.value = "";
            return (false);
        }

        function validateInput(input) {
            var regex = /^\d+(,\d+)*(,\d*)?$/;  // Mantis Id : 0029269
            var value = input.value.trim();

            if (!regex.test(value)) {
                // Invalid input, remove non-numeric and non-comma characters
                input.value = value.replace(/[^\d,]/g, '');

                // Remove consecutive commas
                input.value = input.value.replace(/,+/g, ',');

                // Remove leading commas
                input.value = input.value.replace(/^,+/g, '');
            }
        }
    </script>
</asp:Content>
