<%@ page language="C#" autoeventwireup="true" inherits="Pages_MobileView_SMSPredefine, App_Web_dw2thdpa" masterpagefile="~/Pages/Common/MasterPages/MobileViewMasterPage.master" enableEventValidation="false" viewStateEncryptionMode="Never" %>

<asp:Content ID="Content1" ContentPlaceHolderID="CP" runat="Server">
    <link href="../../App_Themes/jquery-ui.css" rel="stylesheet" />
    <script src="../../JavaScript/rjs/lib/jquery-ui.min.js"></script>
    <script src="../../JavaScript/rjs/lib/1.11.4-jquery-ui.js"></script>
    <style>
        .table-topic.date-topic {
            float: right;
        }

        .table-topic.frst:after {
            width: 62pc;
        }
    </style>
    <asp:UpdatePanel ID="DoctorScheduleUpdatePanel" runat="server">
        <ContentTemplate>
            <div class="page-header row mb20">
                <div class="col-xl-12 col-sm-12 col-xs-12 border-bottom-inline padd-0">
                    <div class="col-md-12 ptb12">
                    </div>
                    <div class="main-topic inner">
                    </div>
                </div>
            </div>
            <div class="bg-white col-md-12 padd-0 center-block mt34">
                <div class="container-fluid row">
                    <div class="gutters-tiny push js-appear-enabled animated fadeIn overflow-hidden" data-toggle="appear">
                        <div class="himsBoxContent  ptb15">
                            <div class="contentHolder col-md-12">
                                <h2 class="box-head">Send Predefine Alert
                                </h2>
                            </div>
                            <div class='row'>
                                <div class='col-md-3 col-sm-4 col-xs-12'>
                                    <div class='fLeft pRight5'>
                                        <input type="checkbox" id="SMSCheckBox" checked onchange="AlertTypeClick()" />
                                        <label for='SMSCheckBox'>SMS</label>
                                    </div>
                                </div>
                                <div class='col-md-3 col-sm-4 col-xs-12'>
                                    <div class='fLeft pRight5'>
                                        <input type="checkbox" id="EmailCheckBox" onchange="AlertTypeClick()" />
                                        <label for='EmailCheckBox'>Email</label>
                                    </div>
                                </div>
                                <div class='col-md-3 col-sm-4 col-xs-12'>
                                    <div class='fLeft pRight5'>
                                        <input type="checkbox" id="MobileAppCheckBox" onchange="AlertTypeClick()" />
                                        <label for='MobileAppCheckBox'>Mobile App</label>
                                    </div>
                                </div>
                                <div class='col-md-3 col-sm-4 col-xs-12'>
                                    <div class='fLeft pRight5'>
                                        <%--By Dhruvik, Change For Mantis: 32497--%>
                                        <input type="checkbox" id="WhatsAppCheckBox" onchange="AlertTypeClick()" runat="server" />
                                        <label for='WhatsAppCheckBox'>WhatsApp</label>
                                    </div>
                                </div>
                                <div class='col-md-3 col-sm-4 col-xs-12'>
                                    <div class='fLeft pRight5'>
                                        <input type="checkbox" id="PrimaryCheckBox" checked />
                                        <label for='PrimaryCheckBox'>Primary</label>
                                    </div>
                                </div>
                                <div class='col-md-3 col-sm-4 col-xs-12'>
                                    <div class='fLeft pRight5'>
                                        <input type="checkbox" id="FatherCheckBox" />
                                        <label for='FatherCheckBox'>Father</label>
                                    </div>
                                </div>
                                <div class='col-md-3 col-sm-4 col-xs-12'>
                                    <div class='fLeft pRight5'>
                                        <input type="checkbox" id="MotherCheckBox" />
                                        <label for='MotherCheckBox'>Mother</label>
                                    </div>
                                </div>
                                <div class='col-md-3 col-sm-4 col-xs-12'>
                                    <div class='fLeft pRight5'>
                                        <input type="checkbox" id="StudentCheckBox" />
                                        <label for='StudentCheckBox'>Student</label>
                                    </div>
                                </div>
                                <div class='col-md-3 col-sm-4 col-xs-12'>
                                    <div class='controlLabelWidth'>
                                        <label>Event<span style="color: red"> *</span></label>
                                    </div>
                                    <div class='fLeft pRight5'>
                                        <select id='drpEvent' class="form-control" onchange="OnEventChange()">
                                            <option selected="selected" value='-1'>Select</option>
                                        </select>
                                    </div>
                                </div>
                                <div class='col-md-3 col-sm-4 col-xs-12'>
                                    <div class='controlLabelWidth'>
                                        <label>Organization</label>
                                    </div>
                                    <div class='fLeft pRight5'>
                                        <select id='drpOrganization' class="form-control" onchange="OnOrganizationChange()">
                                            <option selected="selected" value='0'>Select</option>
                                        </select>
                                    </div>
                                </div>
                                <div class='col-md-3 col-sm-4 col-xs-12'>
                                    <div class='controlLabelWidth'>
                                        <label>Batch</label>
                                    </div>
                                    <div class='fLeft pRight5'>
                                        <select id='drpBatch' class="form-control" onchange="OnBatchChange()">
                                            <option selected="selected" value='0'>Select</option>
                                        </select>
                                    </div>
                                </div>
                                <div class='col-md-3 col-sm-4 col-xs-12 DepartmentDiv d-none'>
                                    <div class='controlLabelWidth'>
                                        <label>Department</label>
                                    </div>
                                    <div class='fLeft pRight5'>
                                        <select id='drpDepartment' class="form-control" onchange="OnDepartmentChange()">
                                            <option selected="selected" value='0'>All</option>
                                        </select>
                                    </div>
                                </div>
                                <div class='col-md-3 col-sm-4 col-xs-12 ClassDiv'>
                                    <div class='controlLabelWidth'>
                                        <label id='ClassLabel'>Class</label>
                                    </div>
                                    <div class='fLeft pRight5'>
                                        <select id='drpClass' class="form-control" onchange="OnClassChange()">
                                            <option selected="selected" value="0">All</option>
                                        </select>
                                    </div>
                                </div>
                                <div class='col-md-3 col-sm-4 col-xs-12 ClassDiv'>
                                    <div class='controlLabelWidth'>
                                        <label id="DivisionLabel">Division</label>
                                    </div>
                                    <div class='fLeft pRight5' id="divDivision" runat="server">
                                        <select id='drpDivision' class="form-control">
                                            <option selected="selected" value="0">All</option>
                                        </select>
                                    </div>
                                </div>
                                <div class='col-md-3 col-sm-4 col-xs-12 StatusDiv d-none'>
                                    <div class='controlLabelWidth'>
                                        <label id='StatusLabel'>Status</label>
                                    </div>
                                    <div class='fLeft pRight5'>
                                        <select id='drpStatus' class="form-control">
                                            <option selected="selected" value="0">All</option>
                                        </select>
                                    </div>
                                </div>
                                <div class='col-md-3 col-sm-4 col-xs-12 ContactDiv d-none'>
                                    <div class='controlLabelWidth'>
                                        <label id='ContactTypeLabel'>Contact Type</label>
                                    </div>
                                    <div class='fLeft pRight5'>
                                        <select id='drpContactType' class="form-control">
                                            <option selected="selected" value="0">All</option>
                                        </select>
                                    </div>
                                </div>
                                <div class='col-md-3 col-sm-4 col-xs-12 BusRouteDiv d-none'>
                                    <div class='controlLabelWidth'>
                                        <label id='TransportLabel'>Transport</label>
                                    </div>
                                    <div class='fLeft pRight5'>
                                        <select id='drpTransport' class="form-control" onchange="OnTransportChange()">
                                            <option selected="selected" value="0">All</option>
                                        </select>
                                    </div>
                                </div>
                                <div class='col-md-3 col-sm-4 col-xs-12 BusRouteDiv d-none'>
                                    <div class='controlLabelWidth'>
                                        <label id='BusRouteLabel'>Bus Route<span style="color: red"> *</span></label>
                                    </div>
                                    <div class='fLeft pRight5'>
                                        <select id='drpBusRoute' class="form-control" onchange="OnBusRouteChange()">
                                            <option selected="selected" value="-1">Select</option>
                                        </select>
                                    </div>
                                </div>
                                <div class='col-md-3 col-sm-4 col-xs-12 BusRouteDiv d-none'>
                                    <div class='fLeft pRight5'>
                                        <input type="checkbox" id="PickupDropCheckBox" onchange="PickupDropCheckBoxChecked(this)" />
                                        <label for='PickupDropCheckBox'>Pickup Point/Drop Point</label>
                                    </div>
                                    <div class='fLeft pRight5 d-none bg-lghtgrey' id="PickupAndDropPointCheckboxList">
                                    </div>
                                </div>
                                <div class='col-md-3 col-sm-4 col-xs-12 HostelDiv d-none'>
                                    <div class='controlLabelWidth'>
                                        <label id='HostelLabel'>Hostel</label>
                                    </div>
                                    <div class='fLeft pRight5'>
                                        <select id='drpHostel' class="form-control">
                                            <option selected="selected" value="0">All</option>
                                        </select>
                                    </div>
                                </div>
                                <div class='col-md-3 col-sm-4 col-xs-12 ForHostelDateDiv d-none'>
                                    <div class='controlLabelWidth'>
                                        <label id="ForHostelDateLabel">Hostel Date</label>
                                    </div>
                                    <div class='fLeft pRight5'>
                                        <input class="form-control" id="ForHostelDatePicker" maxlength="10" onkeyup="return FormatIt(this);" />
                                    </div>
                                </div>
                                <div class='col-md-3 col-sm-4 col-xs-12 AttendanceTypeDiv d-none'>
                                    <div class='controlLabelWidth'>
                                        <label id='AttendanceTypeLabel'>Attendance Type<span style="color: red"> *</span></label>
                                    </div>
                                    <div class='fLeft pRight5'>
                                        <select id='drpAttendanceType' class="form-control" onchange="OnAttendanceTypeChange()">
                                            <option selected="selected" value="0">All</option>
                                        </select>
                                    </div>
                                </div>
                                <div class='col-md-3 col-sm-4 col-xs-12 SubjectDiv d-none'>
                                    <div class='controlLabelWidth'>
                                        <label id='SubjectLabel'>Subject</label>
                                    </div>
                                    <div class='fLeft pRight5'>
                                        <select id='drpSubject' class="form-control">
                                            <option selected="selected" value="0">All</option>
                                        </select>
                                    </div>
                                </div>
                                <div class='col-md-3 col-sm-4 col-xs-12 ReceiptBookDiv d-none'>
                                    <div class='controlLabelWidth'>
                                        <label id='ReceiptBookLabel'>Receipt Book</label>
                                    </div>
                                    <div class='fLeft pRight5'>
                                        <select id='drpReceiptBook' class="form-control" onchange="GetCollectionGroup()">
                                            <option selected="selected" value="0">All</option>
                                        </select>
                                    </div>
                                </div>
                                <div class='col-md-3 col-sm-4 col-xs-12 CollectionGroupDiv d-none'>
                                    <div class='controlLabelWidth'>
                                        <label id='CollectionGroupLabel'>Collection Group</label>
                                    </div>
                                    <div class='fLeft pRight5'>
                                        <select id='drpCollectionGroup' class="form-control">
                                            <option selected="selected" value="0">All</option>
                                        </select>
                                    </div>
                                </div>
                                <div class='col-md-3 col-sm-4 col-xs-12 AdmissionCategoryDiv d-none'>
                                    <div class='controlLabelWidth'>
                                        <label id='AdmissionCategoryLabel'>Fees Category</label>
                                    </div>
                                    <div class='fLeft pRight5'>
                                        <select id='drpAdmissionCategory' class="form-control">
                                            <option selected="selected" value="0">All</option>
                                        </select>
                                    </div>
                                </div>
                                <div class='col-md-3 col-sm-4 col-xs-12 DateDiv FromDateDiv'>
                                    <div class='controlLabelWidth'>
                                        <label id="FromDateLabel">From Date<span style="color: red"> *</span></label>
                                    </div>
                                    <div class='fLeft pRight5'>
                                        <input class="form-control" id="FromDatePicker" maxlength="10" onkeyup="return FormatIt(this);" />
                                    </div>
                                </div>
                                <div class='col-md-3 col-sm-4 col-xs-12 DateDiv'>
                                    <div class='controlLabelWidth'>
                                        <label id="ToDateLabel">To Date<span style="color: red"> *</span></label>
                                    </div>
                                    <div class='fLeft pRight5'>
                                        <input class="form-control" id="ToDatePicker" maxlength="10" onkeyup="return FormatIt(this);" />
                                    </div>
                                </div>
                                <%--Added For Mantis : 35914 by Nilesh--%>
                                <div class='col-md-3 col-sm-4 col-xs-12 AmmountDiv d-none'>
                                    <div class='controlLabelWidth'>
                                        <label id="FromAmountLabel">From Amount</label>
                                    </div>
                                    <div class='fLeft pRight5'>
                                        <input type='Text' class="form-control" value="" id="FromAmountTextBox" onkeypress="return isNumberKey(event)" />
                                    </div>
                                </div>
                                <div class='col-md-3 col-sm-4 col-xs-12 AmmountDiv d-none'>
                                    <div class='controlLabelWidth'>
                                        <label id="ToAmountLabel">To Amount</label>
                                    </div>
                                    <div class='fLeft pRight5'>
                                        <input type='Text' class="form-control" value="" id="ToAmountTextBox" onkeypress="return isNumberKey(event)" />
                                    </div>
                                </div>
                                <div class='col-md-3 col-sm-4 col-xs-12 PassChangeDiv d-none'>
                                    <div class='controlLabelWidth'>
                                        <label id="DaysLabel">Password Reminder Days</label>
                                    </div>
                                    <div class='fLeft pRight5'>
                                        <input type='Text' class="form-control" value="" id="PasswordReminderDaysTextBox" onkeypress="javascript:return isNumberKey(this)" />
                                    </div>
                                </div>
                                <div class='col-md-3 col-sm-4 col-xs-12 AbsentDaysDiv d-none'>
                                    <div class='controlLabelWidth'>
                                        <label id="AbsentDaysLabel">Days<span style="color: red"> *</span></label>
                                    </div>
                                    <div class='fLeft pRight5'>
                                        <input type='Text' class="form-control" value="" id="AbsentDaysTextBox" onkeypress="javascript:return isNumberKey(this)" />
                                    </div>
                                </div>
                                <div class='col-md-3 col-sm-4 col-xs-12 LectureDatediv d-none'>
                                    <div class='controlLabelWidth'>
                                        <label id="LectureDateLabel">Date<span style="color: red"> *</span></label>
                                    </div>
                                    <div class='fLeft pRight5'>
                                        <input class="form-control" id="LectureDatePicker" maxlength="10" onkeyup="return FormatIt(this);" />
                                    </div>
                                </div>
                                <div class='col-md-3 col-sm-4 col-xs-12 DOBDiv d-none'>
                                    <div class='controlLabelWidth'>
                                        <label id="DOBLabel">Date Of Birth<span style="color: red"> *</span></label>
                                    </div>
                                    <div class='fLeft pRight5'>
                                        <input class="form-control" id="DOBDatePicker" maxlength="10" onkeyup="return FormatIt(this);" />
                                    </div>
                                </div>
                                <div class='col-md-3 col-sm-4 col-xs-12 DueDateDiv d-none'>
                                    <div class='controlLabelWidth'>
                                        <label id="DueDateLabel">Due Date<span style="color: red"> *</span></label>
                                    </div>
                                    <div class='fLeft pRight5'>
                                        <input class="form-control" id="DueDatePicker" maxlength="10" onkeyup="return FormatIt(this);" />
                                    </div>
                                </div>
                                <div class='col-md-3 col-sm-4 col-xs-12 ExamDiv d-none'>
                                    <div class='controlLabelWidth'>
                                        <label id='ExamLabel'>Exam<span style="color: red"> *</span></label>
                                    </div>
                                    <div class='fLeft pRight5'>
                                        <select id='drpExam' class="form-control" onchange="OnExamChange()">
                                            <option selected="selected" value="0">All</option>
                                        </select>
                                    </div>
                                </div>
                                <div class='col-md-3 col-sm-4 col-xs-12 ExamDiv ESubjectDiv d-none'>
                                    <div class='controlLabelWidth'>
                                        <label id='ESubjectLabel'>Subject</label>
                                    </div>
                                    <div class='fLeft pRight5'>
                                        <select id='drpESubject' class="form-control">
                                            <option selected="selected" value="0">All</option>
                                        </select>
                                    </div>
                                </div>
                                <div class='col-md-3 col-sm-4 col-xs-12 MonthYearDiv d-none'>
                                    <div class='controlLabelWidth'>
                                        <label id='ForYearLabel'>For Year<span style="color: red"> *</span></label>
                                    </div>
                                    <div class='fLeft pRight5'>
                                        <select id='drpForYear' class="form-control" onchange="OnForYearChange()">
                                            <option selected="selected" value="0">All</option>
                                        </select>
                                    </div>
                                </div>
                                <div class='col-md-3 col-sm-4 col-xs-12 MonthYearDiv d-none'>
                                    <div class='controlLabelWidth'>
                                        <label id='ForMonthLabel'>For Month<span style="color: red"> *</span></label>
                                    </div>
                                    <div class='fLeft pRight5'>
                                        <select id='drpForMonth' class="form-control">
                                            <option selected="selected" value="0">All</option>
                                        </select>
                                    </div>
                                </div>
                                <div class='col-md-12 col-sm-12 col-xs-12 IdsNoDiv d-none'>
                                    <div class='controlLabelWidth'>
                                        <label id="CodeLabel">Ids No (Note : Add Roll No with . Dot seperation (Eg. 2.5.10) OR , Comma seperation (Eg. 2,5,10))</label>
                                    </div>
                                    <div class='fLeft pRight5'>
                                        <textarea class="form-control" id="CodeTextBox" onkeypress="javascript:return isNumberKey(this)"></textarea>
                                    </div>
                                </div>

                                <div class="col-md-12">
                                    <div class="alert alert-info" style="margin-top: 32px">
                                        <div style="color: #FF7F7F">
                                            </b>  * Simple SMS is upto 158 and Multi Language SMS is up to 70 characters in length.
                                                        <br />
                                            * According to government regulations(TRAI), if your DLT process with SMS template registration has not been completed by now, 
                                                then you will not get proper logs in alerts module.
                                                        <br />

                                            <div id="SMsPredefinedv" class="d-none" style="color: #FF7F7F">
                                                * You can send a maximum of 200 to 250 bulk WhatsApp messages at a time, otherwise, your what's app account will be blocked from the WhatsApp side.
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class='col-md-3 col-sm-4 col-xs-12'>
                                    <div class='fLeft pRight5'>
                                        <input type="checkbox" id="SupportSMSInOtherLanguageCheckBox" />
                                        <label for='SupportSMSInOtherLanguageCheckBox'>Support SMS in other language</label>
                                    </div>
                                </div>
                                <div class='col-md-12 col-sm-12 col-xs-12'>
                                    <div class='fLeft pRight5'>
                                        <label id="LFieldsLabel" class="d-none" style="color: BlueViolet; font-weight: bold;">Fields : </label>
                                        <label id="TFieldsLabel" class="d-none"></label>
                                    </div>
                                </div>
                                <div class='col-md-12 col-sm-12 col-xs-12'>
                                    <div class='controlLabelWidth'>
                                        <label id="TemplateLabel">Template</label>
                                    </div>
                                    <div class='fLeft pRight5'>
                                        <textarea maxlength="1000" class="form-control" id="TemplateTextBox" onchange="CountTotalChars()"></textarea>
                                    </div>
                                    <div id="CharCountDiv">
                                        <label id="ForCharLabel">Number Of Character :</label>
                                        <label id="NumberOfCharLabel" style="font-weight: bold"></label>
                                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                        <label id="ForMessageLabel">Number Of Message :</label>
                                        <label id="NumberOfMessageLabel" style="font-weight: bold"></label>
                                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                    </div>
                                </div>
                                <div class='text-center col-md-12'>
                                    <input type="button" id="btnSearch" value="Search" class="btn btn-info" onclick="return OnSearch()" />
                                    <input type="button" id="ClearButton" value="Clear" class="btn btn-clear" onclick="return OnClear()" />
                                    <input type="button" id="btnSendAlert" runat="server" value="Send Alert" class="btn btn-search" onclick="return OnSendAlertClick()" />
                                </div>
                                <div class='col-md-12'>
                                    <div class='table-responsive mt-3'>
                                        <table class='table table-striped table-hover table-bordered sortable' id='tblSMSPredefineGrid'>
                                            <tbody>
                                            </tbody>
                                        </table>
                                        <nav>
                                            <ul class="pagination"></ul>
                                        </nav>
                                    </div>
                                    <div class="se-pre-con" id="LoaderDiv1" style="display: none"></div>
                                </div>
                            </div>
                            <div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <script type="text/javascript">
                var OrgId = 0;
                var BatchId = 0;
                var DeptId = 0;
                var ModuleId = "";
                $(document).ready(function () {
                    var myurl = window.location.href;
                    if (myurl.split('?').length > 1) {
                        var keyval = myurl.split('?')[1].split('&');
                        ModuleId = parseInt(keyval[0].split('=')[1].toString());
                    }
                    $('#FromDatePicker').val($.datepicker.formatDate('dd/mm/yy', new Date()));
                    $('#ToDatePicker').val($.datepicker.formatDate('dd/mm/yy', new Date()));
                    GetAlertPermission();
                    GetOrganization();
                    GetStatus();
                });
                function GetOrganization() {
                    $.ajax({
                        type: "POST",
                        url: "SMSPredefine.aspx/GetOrganization",
                        contentType: "application/json; charset=utf-8",
                        dataType: "json",
                        success: function (result) {
                            $("#drpOrganization").html(result.d);
                            OnOrganizationChange();
                            LoadDropdownList();
                        }
                    });
                }
                function LoadDropdownList() {
                    OrgId = $("#drpOrganization").val();
                    $.ajax({
                        type: "POST",
                        url: "SMSPredefine.aspx/LoadDropdownList",
                        contentType: "application/json; charset=utf-8",
                        dataType: "json",
                        success: function (result) {
                            if (result.d.length > 0) {
                                var data = result.d[0];
                                $("#drpTransport").html(data[0].value);
                                $("#drpContactType").html(data[1].value);
                                $("#drpBusRoute").html(data[2].value);
                                $("#drpHostel").html(data[3].value);
                                $("#drpAdmissionCategory").html(data[4].value);
                                $("#drpForYear").html(data[5].value);
                            }
                        }
                    });
                }
                function OnOrganizationChange() {
                    GetEvent();
                    OrgId = $("#drpOrganization").val();
                    if (OrgId > 0) {
                        GetBatch();
                        GetAttendanceType();
                        GetDepartment();
                    }
                    else {
                        $("#drpBatch").html("<option value='-1'>Select</option>");
                        $("#drpAttendanceType").html("<option value='-1'>Select</option>");
                        $("#drpDepartment").html("<option value='-1'>All</option>");
                    }
                    OnBatchChange();
                    OnAttendanceTypeChange();
                }

                function GetAlertPermission() {
                    $.ajax({
                        type: "POST",
                        url: "SMSPredefine.aspx/GetAlertPermission",
                        contentType: "application/json; charset=utf-8",
                        dataType: "json",
                        success: function (result) {
                            if (result.d.length > 0) {
                                var data = result.d[0];

                                document.getElementById('SMSCheckBox').disabled = !data[0].value;
                                document.getElementById('SMSCheckBox').checked = data[0].value;
                                document.getElementById('EmailCheckBox').disabled = !data[1].value;
                                document.getElementById('MobileAppCheckBox').disabled = !data[2].value;
                                //By Dhruvik, Add For Mantis: 32497
                                if (data[4].value == 'False')
                                    document.getElementById('ctl00_CP_WhatsAppCheckBox').disabled = true;
                                else
                                    document.getElementById('ctl00_CP_WhatsAppCheckBox').disabled = false;
                            }
                        }
                    });
                }

                function GetReceiptBook() {
                    var EventId = $("#drpEvent").val();
                    BatchId = $("#drpBatch").val();
                    $.ajax({
                        type: "POST",
                        url: "SMSPredefine.aspx/GetReceiptBook",
                        data: JSON.stringify({ "EventId": EventId, "BatchId": BatchId }),
                        contentType: "application/json; charset=utf-8",
                        dataType: "json",
                        success: function (result) {
                            $("#drpReceiptBook").html(result.d);
                        }
                    });
                }
                function GetCollectionGroup() {
                    var ReceiptBookId = $("#drpReceiptBook").val();
                    $.ajax({
                        type: "POST",
                        url: "SMSPredefine.aspx/GetCollectionGroup",
                        data: JSON.stringify({ "ReceiptBookId": ReceiptBookId }),
                        contentType: "application/json; charset=utf-8",
                        dataType: "json",
                        success: function (result) {
                            $("#drpCollectionGroup").html(result.d);
                        }
                    });
                }

                function GetEvent() {
                    OrgId = $("#drpOrganization").val();
                    $.ajax({
                        type: "POST",
                        url: "SMSPredefine.aspx/GetEvent",
                        data: JSON.stringify({ "OrgId": OrgId, "ModuleId": ModuleId }),
                        contentType: "application/json; charset=utf-8",
                        dataType: "json",
                        success: function (result) {
                            $("#drpEvent").html(result.d);
                            OnEventChange();
                        }
                    });
                }
                function GetBatch() {
                    $.ajax({
                        type: "POST",
                        url: "SMSPredefine.aspx/GetBatch",
                        data: JSON.stringify({ "OrgId": OrgId }),
                        contentType: "application/json; charset=utf-8",
                        dataType: "json",
                        success: function (result) {
                            $("#drpBatch").html(result.d);
                            OnBatchChange();
                        }
                    });
                }
                function GetClass() {
                    BatchId = $("#drpBatch").val();
                    $.ajax({
                        type: "POST",
                        url: "SMSPredefine.aspx/GetClass",
                        data: JSON.stringify({ "BatchId": BatchId }),
                        contentType: "application/json; charset=utf-8",
                        dataType: "json",
                        success: function (result) {
                            $("#drpClass").html(result.d);
                        }
                    });
                }
                function GetClassDeptwise() {
                    OrgId = $("#drpOrganization").val();
                    var DepartmentId = $("#drpDepartment").val();
                    $.ajax({
                        type: "POST",
                        url: "SMSPredefine.aspx/GetClassDeptwise",
                        data: JSON.stringify({ "OrgId": OrgId, "DepartmentId": DepartmentId }),
                        contentType: "application/json; charset=utf-8",
                        dataType: "json",
                        success: function (result) {
                            $("#drpClass").html(result.d);
                        }
                    });
                }
                function GetAttendanceType() {
                    OrgId = $("#drpOrganization").val();
                    $.ajax({
                        type: "POST",
                        url: "SMSPredefine.aspx/GetAttendanceType",
                        data: JSON.stringify({ "OrgId": OrgId }),
                        contentType: "application/json; charset=utf-8",
                        dataType: "json",
                        success: function (result) {
                            $("#drpAttendanceType").html(result.d);
                        }
                    });
                }
                function GetDepartment() {
                    $.ajax({
                        type: "POST",
                        url: "SMSPredefine.aspx/GetDepatment",
                        data: JSON.stringify({ "OrgId": OrgId }),
                        contentType: "application/json; charset=utf-8",
                        dataType: "json",
                        success: function (result) {
                            $("#drpDepartment").html(result.d);
                        }
                    });
                }
                function GetDivision() {
                    var ClassId = $("#drpClass").val();
                    OrgId = $("#drpOrganization").val();
                    $.ajax({
                        type: "POST",
                        url: "SMSPredefine.aspx/GetDivision",
                        data: JSON.stringify({ "ClassId": ClassId, "OrgId": OrgId }),
                        contentType: "application/json; charset=utf-8",
                        dataType: "json",
                        success: function (result) {
                            $("#drpDivision").html(result.d);
                        }
                    });
                }
                function GetExam() {
                    var ClassId = $("#drpClass").val();
                    BatchId = $("#drpBatch").val();
                    $.ajax({
                        type: "POST",
                        url: "SMSPredefine.aspx/GetExam",
                        data: JSON.stringify({ "BatchId": BatchId, "ClassId": ClassId }),
                        contentType: "application/json; charset=utf-8",
                        dataType: "json",
                        success: function (result) {
                            $("#drpExam").html(result.d);
                        }
                    });
                }
                function GetSubject() {
                    var ClassId = $("#drpClass").val();
                    $.ajax({
                        type: "POST",
                        url: "SMSPredefine.aspx/GetSubject",
                        data: JSON.stringify({ "ClassId": ClassId }),
                        contentType: "application/json; charset=utf-8",
                        dataType: "json",
                        success: function (result) {
                            $("#drpSubject").html(result.d);
                        }
                    });
                }
                function GetStatus() {
                    $.ajax({
                        type: "POST",
                        url: "StudentSearch.aspx/GetStatus",
                        contentType: "application/json; charset=utf-8",
                        dataType: "json",
                        success: function (result) {
                            $("#drpStatus").html(result.d);
                            $("#drpStatus").val(1);
                        }
                    });
                }

                function OnBatchChange() {
                    BatchId = $("#drpBatch").val();
                    if (BatchId > 0) {
                        GetClass();
                    }
                    else {
                        $("#drpClass").html("<option value='-1'>All</option>");
                    }
                    OnClassChange();
                    GetReceiptBook();
                }
                function OnEventChange() {
                    EventId = $("#drpEvent").val();

                    if (EventId > 0) {
                        $.ajax({
                            type: "POST",
                            url: "SMSPredefine.aspx/GetEventFields",
                            data: JSON.stringify({ "EventId": EventId }),
                            contentType: "application/json; charset=utf-8",
                            dataType: "json",
                            success: function (result) {
                                if (result.d.length > 0) {
                                    $("#TFieldsLabel").html(result.d);
                                    $("#LFieldsLabel, #TFieldsLabel").removeClass("d-none");
                                }
                                else {
                                    $("#TFieldsLabel").html("");
                                    $("#LFieldsLabel, #TFieldsLabel").addClass("d-none");
                                }
                            }
                        });
                    }
                    else {
                        $("#TFieldsLabel").html("");
                        $("#TFieldsLabel, #LFieldsLabel").addClass("d-none");
                        <%--Added For Mantis : 35914 by Nilesh--%>
                        $(".AmmountDiv").addClass("d-none");
                    }

                    $(".PassChangeDiv").addClass("d-none");
                    $(".AbsentDaysDiv").addClass("d-none");
                    <%--Added For Mantis : 35914 by Nilesh--%>
                    $(".AmmountDiv").addClass("d-none");

                    if (EventId == "4" || EventId == "3" || EventId == "5" || EventId == "90" || EventId == "76" || EventId == "105") {
                        <%--Added For Mantis : 35914 by Nilesh--%>
                        if (EventId == "4") {
                            $(".AmmountDiv").removeClass("d-none");
                        }
                        else {
                            $(".AmmountDiv").addClass("d-none");
                        }
                        $(".IdsNoDiv").val("");
                        $(".IdsNoDiv").removeClass("d-none");
                    }
                    else {
                        $(".IdsNoDiv").val("");
                        $(".IdsNoDiv").addClass("d-none");
                    }
                    $("#DOBLabel").html("Date Of Birth<span style='color: red'> *</span>");

                    $('#FromDatePicker').val($.datepicker.formatDate('dd/mm/yy', new Date()));
                    $('#ToDatePicker').val($.datepicker.formatDate('dd/mm/yy', new Date()));
                    $('#LectureDatePicker').val($.datepicker.formatDate('dd/mm/yy', new Date()));
                    $('#DOBDatePicker').val($.datepicker.formatDate('dd/mm/yy', new Date()));
                    $('#DueDatePicker').val($.datepicker.formatDate('dd/mm/yy', new Date()));

                    $("#drpClass").val("-1");
                    $("#drpDivision").val("-1");
                    $("#drpDepartment").val("-1");
                    $("#drpContactType").val("-1");
                    $("#drpBusRoute").val("-1");
                    $("#drpAdmissionCategory").val("-1");
                    $("#drpAttendanceType").val("-1");
                    $("#drpSubject").val("-1");
                    $("#drpForYear").val("-1");
                    $("#drpForMonth").val("-1");
                    $("#drpExam").val("-1");
                    $("#drpReceiptBook").val("-1");
                    $("#TemplateTextBox").val("");

                    $("#tblSMSPredefineGrid").html('');

                    if (EventId == "1") //New Admission
                    {
                        $(".ReceiptBookDiv, .AttendanceTypeDiv, .MonthYearDiv, .DepartmentDiv, .ContactDiv, .BusRouteDiv, .HostelDiv, .ForHostelDateDiv, .DOBDiv, .DueDateDiv, .ExamDiv, .AdmissionCategoryDiv").addClass("d-none");
                        $(".DateDiv, .FromDateDiv, .ClassDiv").removeClass("d-none");

                        $('#FromDatePicker').val($.datepicker.formatDate('dd/mm/yy', new Date()));
                        $('#ToDatePicker').val($.datepicker.formatDate('dd/mm/yy', new Date()));
                    }
                    else if (EventId == "2" || EventId == "50" || EventId == "70") //Student Birthday Wish
                    {
                        $(".ReceiptBookDiv, .AttendanceTypeDiv, .DateDiv, .FromDateDiv, .MonthYearDiv, .DepartmentDiv, .ContactDiv, .BusRouteDiv, .HostelDiv, .ForHostelDateDiv, .DueDateDiv, .ExamDiv, .AdmissionCategoryDiv").addClass("d-none");
                        $(".ClassDiv").removeClass("d-none");

                        if (EventId == "50" || EventId == "70")
                        { $(".DOBDiv").addClass("d-none"); }
                        else
                        { $(".DOBDiv").removeClass("d-none"); }

                        $('#FromDatePicker').val($.datepicker.formatDate('dd/mm/yy', new Date()));
                        $('#ToDatePicker').val($.datepicker.formatDate('dd/mm/yy', new Date()));
                    }
                    else if (EventId == "3" || EventId == "31" || EventId == "90" || EventId == "76") //Fee Receipt Entry,Charge Receipt Entry,Cheque Clear,Fee Receipt Cancel
                    {
                        GetReceiptBook();
                        $(".AttendanceTypeDiv, .MonthYearDiv, .DepartmentDiv, .ContactDiv, .BusRouteDiv, .HostelDiv, .ForHostelDateDiv, .DueDateDiv, .ExamDiv, .DOBDiv").addClass("d-none");
                        $(".ReceiptBookDiv, .DateDiv ,.FromDateDiv, .ClassDiv").removeClass("d-none");

                        $('#FromDatePicker').val($.datepicker.formatDate('dd/mm/yy', new Date()));
                        $('#ToDatePicker').val($.datepicker.formatDate('dd/mm/yy', new Date()));

                        if (EventId == "3" || EventId == "90" || EventId == "76")
                        { $(".AdmissionCategoryDiv").removeClass("d-none"); }
                        else
                        { $(".AdmissionCategoryDiv").addClass("d-none"); }
                    }
                    else if (EventId == "4" || EventId == "5" || EventId == "105") // Fee Due,Fee Unpaid Total, Total Pending Fees
                    {
                        GetReceiptBook();
                        $(".AttendanceTypeDiv, .FromDateDiv, .MonthYearDiv, .ContactDiv, .BusRouteDiv, .HostelDiv, .ForHostelDateDiv, .DOBDiv, .DueDateDiv, .ExamDiv").addClass("d-none");
                        $(".ReceiptBookDiv, .DateDiv, .ClassDiv").removeClass("d-none");
                        $(".drpReceiptBook").val("-1");
                        <%--Added For Mantis : 35914 by Nilesh--%>
                        if (EventId == "4") {
                            $(".DepartmentDiv").removeClass("d-none");
                            $(".AmmountDiv").removeClass("d-none");
                        }
                        else {
                            $(".DepartmentDiv").addClass("d-none");
                            $(".AmmountDiv").addClass("d-none");
                        }

                        $('#ToDatePicker').val($.datepicker.formatDate('dd/mm/yy', new Date()));
                        if (EventId == "4" || EventId == "5") {
                            <%--Added For Mantis : 35914 by Nilesh--%>
                            if (EventId == "4") {
                                $(".AmmountDiv").removeClass("d-none");
                            }
                            else {
                                $(".AmmountDiv").addClass("d-none");
                            }
                            $(".AdmissionCategoryDiv").removeClass("d-none");
                        }
                        else { $(".AdmissionCategoryDiv").addClass("d-none"); }

                        if (EventId == "105")
                        { $(".ReceiptBookDiv").addClass("d-none"); }
                    }
                    else if (EventId == "6" || EventId == "7" || EventId == "114") // Result,Result With Subject
                    {
                        $(".ReceiptBookDiv, .AttendanceTypeDiv, .DateDiv, .FromDateDiv, .MonthYearDiv, .DepartmentDiv, .ContactDiv, .BusRouteDiv, .HostelDiv, .ForHostelDateDiv, .DOBDiv, .DueDateDiv, .AdmissionCategoryDiv").addClass("d-none");
                        $(".ClassDiv, .ExamDiv").removeClass("d-none");
                        if (EventId == "6")
                        { $(".ESubjectDiv").addClass("d-none"); }
                        else
                        { $(".ESubjectDiv").removeClass("d-none"); }
                    }
                    else if (EventId == "9" || EventId == "71" || EventId == "72" || EventId == "126") // Employee Birthday Wish
                    {
                        $("#DOBLabel").html("Date Of Joining<span style='color: red'> *</span>");
                        $(".ReceiptBookDiv, .AttendanceTypeDiv, .DateDiv, .FromDateDiv, .MonthYearDiv, .ClassDiv, .ContactDiv, .BusRouteDiv, .HostelDiv, .ForHostelDateDiv, .DueDateDiv, .ExamDiv, .AdmissionCategoryDiv").addClass("d-none");
                        $(".DepartmentDiv").removeClass("d-none");

                        if (EventId == "71" || EventId == "126")
                            $(".DOBDiv").addClass("d-none");
                        else
                            $(".DOBDiv").removeClass("d-none");

                        $('#FromDatePicker').val($.datepicker.formatDate('dd/mm/yy', new Date()));
                        $('#ToDatePicker').val($.datepicker.formatDate('dd/mm/yy', new Date()));
                    }
                    else if (EventId == "10") // Address Book
                    {
                        $(".ReceiptBookDiv, .AttendanceTypeDiv, .DateDiv, .FromDateDiv, .MonthYearDiv, .ClassDiv, .DepartmentDiv, .BusRouteDiv, .HostelDiv, .ForHostelDateDiv, .DOBDiv, .DueDateDiv, .ExamDiv, .AdmissionCategoryDiv").addClass("d-none");
                        $(".ContactDiv").removeClass("d-none");

                        if (document.getElementById('MobileAppCheckBox').checked == true)
                            alert("This Event is not allowed for Mobiile App.");
                    }
                    else if (EventId == "11") // Book Due
                    {
                        $(".ReceiptBookDiv, .AttendanceTypeDiv, .DateDiv, .FromDateDiv, .MonthYearDiv, .ContactDiv, .BusRouteDiv, .HostelDiv, .ForHostelDateDiv, .DOBDiv, .ExamDiv, .AdmissionCategoryDiv").addClass("d-none");
                        $(".ClassDiv, .DepartmentDiv, .DueDateDiv").removeClass("d-none");
                    }
                    else if (EventId == "12") // Bus Route
                    {
                        $(".ReceiptBookDiv, .AttendanceTypeDiv, .DateDiv, .FromDateDiv, .MonthYearDiv, .DepartmentDiv, .ContactDiv, .HostelDiv, .ForHostelDateDiv, .DOBDiv, .DueDateDiv, .ExamDiv, .AdmissionCategoryDiv").addClass("d-none");
                        $(".ClassDiv, .BusRouteDiv").removeClass("d-none");
                    }
                    else if (EventId == "32" || EventId == "33" || EventId == "34") // Hostel
                    {
                        $(".ReceiptBookDiv, .AttendanceTypeDiv, .DateDiv, .FromDateDiv, .MonthYearDiv, .DepartmentDiv, .ContactDiv, .BusRouteDiv, .DOBDiv, .DueDateDiv, .ExamDiv, .AdmissionCategoryDiv").addClass("d-none");
                        $(".ClassDiv, .HostelDiv, .ForHostelDateDiv").removeClass("d-none");

                        if (EventId == "32") {
                            $('#ForHostelDatePicker').val($.datepicker.formatDate('dd/mm/yy', new Date()));
                            $("#ForHostelDateLabel").html("Admission Date<span style='color: red'> *</span>");
                        }
                        if (EventId == "33") {
                            $('#ForHostelDatePicker').val($.datepicker.formatDate('dd/mm/yy', new Date()));
                            $("#ForHostelDateLabel").html("Vacant Date<span style='color: red'> *</span>");
                        }
                        if (EventId == "34") {
                            $('#ForHostelDatePicker').val($.datepicker.formatDate('dd/mm/yy', new Date()));
                            $("#ForHostelDateLabel").html("Log Date<span style='color: red'> *</span>");
                        }
                    }
                    else if (EventId == "13" || EventId == "26") // Absent Student, Present Student
                    {
                        $(".ReceiptBookDiv, .MonthYearDiv, .DepartmentDiv, .ContactDiv, .BusRouteDiv, .HostelDiv, .ForHostelDateDiv, .DOBDiv, .DueDateDiv, .ExamDiv, .AdmissionCategoryDiv").addClass("d-none");
                        $(".AttendanceTypeDiv, .DateDiv, .FromDateDiv, .ClassDiv").removeClass("d-none");

                        $('#FromDatePicker').val($.datepicker.formatDate('dd/mm/yy', new Date()));
                        $('#ToDatePicker').val($.datepicker.formatDate('dd/mm/yy', new Date()));
                    }
                    else if (EventId == "20") //Monthly Attendance
                    {
                        $(".ReceiptBookDiv, .DateDiv, .FromDateDiv, .DepartmentDiv, .ContactDiv, .BusRouteDiv, .HostelDiv, .ForHostelDateDiv, .DOBDiv, .DueDateDiv, .ExamDiv, .AdmissionCategoryDiv").addClass("d-none");
                        $(".AttendanceTypeDiv, .MonthYearDiv, .ClassDiv").removeClass("d-none");
                    }
                    else if (EventId == "97") {
                        $(".ReceiptBookDiv, .AttendanceTypeDiv, .DateDiv, .FromDateDiv, .MonthYearDiv, .DepartmentDiv, .ContactDiv, .BusRouteDiv, .HostelDiv, .ForHostelDateDiv, .DOBDiv, .DueDateDiv, .ExamDiv, .ESubjectDiv, .AdmissionCategoryDiv").addClass("d-none");
                        $(".ClassDiv, .LectureDatediv").removeClass("d-none");
                    }
                    else if (EventId == "103") {
                        $(".ReceiptBookDiv, .AttendanceTypeDiv, .DateDiv, .FromDateDiv, .MonthYearDiv, .ClassDiv, .DepartmentDiv, .ContactDiv, .BusRouteDiv, .HostelDiv, .ForHostelDateDiv, .DOBDiv, .DueDateDiv, .ExamDiv, .ESubjectDiv, .AdmissionCategoryDiv, .LectureDatediv").addClass("d-none");
                        $(".PassChangeDiv").removeClass("d-none");
                    }
                    else if (EventId == "106") // Absent Student Continue
                    {
                        $(".ReceiptBookDiv, .MonthYearDiv, .DepartmentDiv, .ContactDiv, .BusRouteDiv, .HostelDiv, .ForHostelDateDiv, .DOBDiv, .DueDateDiv, .ExamDiv, .AdmissionCategoryDiv, .PassChangeDiv").addClass("d-none");
                        $(".AttendanceTypeDiv, .DateDiv, .FromDateDiv, .ClassDiv, .AbsentDaysDiv").removeClass("d-none");

                        $('#FromDatePicker').val($.datepicker.formatDate('dd/mm/yy', new Date()));
                        $('#ToDatePicker').val($.datepicker.formatDate('dd/mm/yy', new Date()));
                    }
        if (EventId == "27") {
            $(".ReceiptBookDiv, .AttendanceTypeDiv, .FromDateDiv, .MonthYearDiv, .DepartmentDiv, .ContactDiv, .BusRouteDiv, .HostelDiv, .ForHostelDateDiv, .DOBDiv, .DueDateDiv, .ExamDiv, .DateDiv, .AdmissionCategoryDiv, .PassChangeDiv, .AbsentDaysDiv").addClass("d-none");
            $(".ClassDiv").removeClass("d-none");
            GetClass();
        }
        if (EventId == "113") {
            $(".ReceiptBookDiv, .MonthYearDiv, .DepartmentDiv, .ContactDiv, .BusRouteDiv, .HostelDiv, .ForHostelDateDiv, .DOBDiv, .DueDateDiv, .ExamDiv, .AdmissionCategoryDiv").addClass("d-none");
            $(".AttendanceTypeDiv, .DateDiv, .FromDateDiv, .ClassDiv").removeClass("d-none");

            var date = new Date();
            var fromdate = new Date(date.setDate(date.getDate() + (-7)));
            $('#FromDatePicker').val($.datepicker.formatDate('dd/mm/yy', fromdate));
            $('#ToDatePicker').val($.datepicker.formatDate('dd/mm/yy', new Date()));
        }
        else if (EventId == "157") //Monthly Subjectwise Attendance
        {
            $(".ReceiptBookDiv, .DateDiv, .FromDateDiv, .DepartmentDiv, .ContactDiv, .BusRouteDiv, .HostelDiv, .ForHostelDateDiv, .DOBDiv, .DueDateDiv, .ExamDiv, .AdmissionCategoryDiv, .AttendanceTypeDiv").addClass("d-none");
            $(".MonthYearDiv, .ClassDiv, .SubjectDiv").removeClass("d-none");
        }

        if (EventId > 0) {
            var OrgId = $("#drpOrganization").val();
            if (EventId == "32" || EventId == "33" || EventId == "34") // Hostel
            {
                OrgId = OrgId > 0 ? OrgId : 0;
            }
            var AlertModeId = 0;
            if (document.getElementById('SMSCheckBox').checked) {
                AlertModeId = 2;
            }
            else if (document.getElementById('EmailCheckBox').checked) {
                AlertModeId = 1;
            }
            else if (document.getElementById('MobileAppCheckBox').checked) {
                AlertModeId = 3;
            }
            else if (document.getElementById('ctl00_CP_WhatsAppCheckBox').checked) { //Changes for Mantis Id: 0035809 By Hemali
                AlertModeId = 4;
            }

            $.ajax({
                type: "POST",
                url: "SMSPredefine.aspx/GetEventTemplate",
                data: JSON.stringify({ "OrgId": OrgId, "AlertModeId": AlertModeId, "EventId": EventId }),
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (result) {
                    if (result.d.length > 0) {
                        $("#TemplateTextBox").val(result.d);
                        CountTotalChars();
                    }
                    else {
                        $("#TemplateTextBox").html("");
                    }
                }
            });
        }

        if (EventId == "6" || EventId == "7" || EventId == "114") // Result, Result With Subject
        {
            $("#drpDivision").html("<option value='-1'>Select</option>");
            $("#drpExam").html("<option value='-1'>Select</option>");
            $("#drpESubject").html("<option value='-1'>All</option>");
            GetClass();
        }

        if (EventId == "3" || EventId == "4" || EventId == "5" || EventId == "76" || EventId == "84" || EventId == "90" || EventId == "76") {
                        <%--Added For Mantis : 35914 by Nilesh--%>
                        if (EventId == "4") {
                            $(".AmmountDiv").removeClass("d-none");
                        }
                        else {
                            $(".AmmountDiv").addClass("d-none");
                        }
                        $(".CollectionGroupDiv, .ReceiptBookDiv").removeClass("d-none");
                        GetReceiptBook();
                        GetCollectionGroup();
                    }
                    else {
                        $(".CollectionGroupDiv").addClass("d-none");
                    }

                    if (EventId == "50") {
                        $(".StatusDiv").removeClass("d-none");
                        GetStatus();
                        $("#drpStatus").val("1");
                    }
                    else {
                        $(".StatusDiv").addClass("d-none");
                    }
                }
                function OnClassChange() {
                    EventId = $("#drpEvent").val();
                    $("#tblSMSPredefineGrid").html('');
                    var ClassId = $("#drpClass").val();
                    OrgId = $("#drpOrganization").val();
                    if (ClassId > 0) {
                        GetDivision();
                        GetExam();
                    }
                    else {
                        $("#drpDivision").html("<option value='-1'>All</option>");
                        $("#drpExam").html("<option value='-1'>All</option>");
                    }
                    var attendancetype = $("#drpAttendanceType option:selected").text();
                    if (attendancetype == "Subject" || EventId == 157) {
                        $(".SubjectDiv").removeClass("d-none");
                        GetSubject();
                    }
                    else {
                        $("#drpSubject").html("<option value='-1'>Select</option>");
                    }
                }
                function OnExamChange() {
                    var ExamId = $("#drpExam").val();
                    if (ExamId > 0) {
                        $.ajax({
                            type: "POST",
                            url: "SMSPredefine.aspx/GetESubject",
                            data: JSON.stringify({ "ExamId": ExamId }),
                            contentType: "application/json; charset=utf-8",
                            dataType: "json",
                            success: function (result) {
                                $("#drpESubject").html(result.d);
                            }
                        });
                    }
                    else {
                        $("#drpESubject").html("<option value='-1'>All</option>");
                    }
                }
                function OnAttendanceTypeChange() {
                    $("#tblSMSPredefineGrid").html('');
                    var attendancetype = $("#drpAttendanceType option:selected").text();
                    if (attendancetype == "Subject") {
                        $(".SubjectDiv").removeClass("d-none");
                        GetSubject();
                        $("#drpDivision").html("<option value='-1'>Select</option>");
                    }
                    else {
                        $(".SubjectDiv").addClass("d-none");
                        $("#drpSubject").html("<option value='-1'>Select</option>");
                        $("#drpDivision").html("<option value='-1'>All</option>");
                    }
                    GetClass();
                }
                function OnForYearChange() {
                    $("#tblSMSPredefineGrid").html('');
                    var ForYearId = $("#drpForYear").val();
                    if (ForYearId > 0) {
                        $.ajax({
                            type: "POST",
                            url: "SMSPredefine.aspx/GetForMonth",
                            data: JSON.stringify({ "ForYearId": ForYearId }),
                            contentType: "application/json; charset=utf-8",
                            dataType: "json",
                            success: function (result) {
                                $("#drpForMonth").html(result.d);
                            }
                        });
                    }
                    else {
                        $("#drpForMonth").html("<option value='-1'>Select</option>");
                    }
                }
                function OnDepartmentChange() {
                    DeptId = $("#drpDepartment").val();
                    if (DeptId > 0) {
                        GetClassDeptwise();
                    }
                    else {
                        OnOrganizationChange();
                    }
                }
                function OnTransportChange() {
                    var TransportId = $("#drpTransport").val();
                    $.ajax({
                        type: "POST",
                        url: "SMSPredefine.aspx/GetBusRoute",
                        data: JSON.stringify({ "TransportId": TransportId }),
                        contentType: "application/json; charset=utf-8",
                        dataType: "json",
                        success: function (result) {
                            $("#drpBusRoute").html(result.d);
                        }
                    });
                }
                function OnBusRouteChange() {
                    var BusRouteId = $("#drpBusRoute").val();
                    $.ajax({
                        type: "POST",
                        url: "SMSPredefine.aspx/GetPickupAndDropPoint",
                        data: JSON.stringify({ "BusRouteId": BusRouteId }),
                        contentType: "application/json; charset=utf-8",
                        dataType: "json",
                        success: function (result) {
                            $("#PickupAndDropPointCheckboxList").html(result.d);
                            document.getElementById('PickupDropCheckBox').checked = false;
                            $("#PickupAndDropPointCheckboxList").addClass('d-none');
                        }
                    });
                }
                function PickupDropCheckBoxChecked(obj) {
                    if (document.getElementById('PickupDropCheckBox').checked) {
                        $("#PickupAndDropPointCheckboxList").removeClass('d-none');
                    }
                    else {
                        $("#PickupAndDropPointCheckboxList").addClass('d-none');
                    }
                }
            </script>

            <script type="text/javascript">
                $(function () {
                    $("#ForHostelDatePicker").datepicker({
                        dateFormat: 'dd/mm/yy', showOn: "focus"
                    });
                    $("#FromDatePicker").datepicker({
                        dateFormat: 'dd/mm/yy', showOn: "focus"
                    });
                    $("#ToDatePicker").datepicker({
                        dateFormat: 'dd/mm/yy', showOn: "focus"
                    });
                    $("#LectureDatePicker").datepicker({
                        dateFormat: 'dd/mm/yy', showOn: "focus"
                    });
                    $("#DOBDatePicker").datepicker({
                        dateFormat: 'dd/mm/yy', showOn: "focus"
                    });
                    $("#DueDatePicker").datepicker({
                        dateFormat: 'dd/mm/yy', showOn: "focus"
                    });
                    $("#StdAttendanceDate").datepicker({
                        dateFormat: 'dd/mm/yy', showOn: "button",
                        buttonImage: "http://jqueryui.com/resources/demos/datepicker/images/calendar.gif",
                        buttonImageOnly: true
                    });
                });
                function FormatIt(obj) {
                    if (obj.value.length == 2) // Day
                        obj.value = obj.value + "/";
                    if (obj.value.length == 5) // month
                        obj.value = obj.value + "/";
                    if (obj.value.length > 10) // month
                        $(obj).val('');
                }
                function CountTotalChars() {
                    var TemplateTextBox = $("#TemplateTextBox").val();
                    if (TemplateTextBox != null && TemplateTextBox != '') {
                        var CountChar = 0;
                        var CountMessage = 0;
                        var TotalChar = 0;

                        for (var char in TemplateTextBox) {
                            CountChar = CountChar + 1;
                            if (CountChar >= 158) {
                                CountChar = 0;
                                CountMessage += 1;
                            }
                        }

                        TotalChar = CountMessage * 158 + CountChar;
                        $("#NumberOfCharLabel").html(TotalChar);
                        if (CountMessage == 0)
                            $("#NumberOfMessageLabel").html("1");
                        else
                            $("#NumberOfMessageLabel").html(1 + CountMessage);
                    }
                    else {
                        $("#NumberOfMessageLabel").html("0");
                        $("#NumberOfCharLabel").html("0");
                    }
                }
            </script>

            <script type="text/javascript">
                function AlertTypeClick() {
                    var IsSMS = document.getElementById('SMSCheckBox').checked;
                    var IsEmail = document.getElementById('EmailCheckBox').checked;
                    var IsMobileApp = document.getElementById('MobileAppCheckBox').checked;
                    var IsWhatsApp = document.getElementById('ctl00_CP_WhatsAppCheckBox').checked;

                    if (IsSMS == true && IsEmail == true && IsMobileApp == true)
                    { $("#CharCountDiv").removeClass("d-none"); }
                    else if (IsSMS == true)
                    { $("#CharCountDiv").removeClass("d-none"); }
                    else
                    { $("#CharCountDiv").addClass("d-none"); }

                    if (IsWhatsApp == true)
                    { $("#SMsPredefinedv").removeClass("d-none"); }
                    else
                    { $("#SMsPredefinedv").addClass("d-none"); }
                }

                function OnClear() {
                    GetAlertPermission();
                    var li = "<option value='-1'>All</option>";
                    $("#drpEvent").val('-1');
                    $('#FromDatePicker').val($.datepicker.formatDate('dd/mm/yy', new Date()));
                    $('#ToDatePicker').val($.datepicker.formatDate('dd/mm/yy', new Date()));
                    $('#LectureDatePicker').val($.datepicker.formatDate('dd/mm/yy', new Date()));
                    $('#DOBDatePicker').val($.datepicker.formatDate('dd/mm/yy', new Date()));
                    $('#DueDatePicker').val($.datepicker.formatDate('dd/mm/yy', new Date()));
                    $("#drpClass").val('0');
                    $("#drpDivision").html("<option value='-1'>All</option>");
                    $("#drpDivision").val('-1');
                    $("#drpDepartment").val('-1');
                    $("#drpContactType").val('-1');
                    $("#drpBusRoute").val('-1');
                    $("#drpHostel").val('-1');
                    $("#drpReceiptBook").val('-1');
                    $("#drpCollectionGroup").val('-1');
                    $("#drpExam").val('-1');
                    $("#drpSubject").val('-1');
                    $("#drpESubject").val('-1');
                    $("#drpAttendanceType").val('-1');
                    $("#drpAdmissionCategory").val('-1');
                    $("#drpForYear").val('-1');
                    $("#drpForMonth").val('-1');
                    $("#TemplateTextBox").val('');
                    $("#CodeTextBox").val('');
                    $("#PasswordReminderDaysTextBox").val('');
                    $("#AbsentDaysTextBox").val('');

                    document.getElementById('SMSCheckBox').checked = true;
                    document.getElementById('EmailCheckBox').checked = false;
                    document.getElementById('MobileAppCheckBox').checked = false;
                    document.getElementById('ctl00_CP_WhatsAppCheckBox').checked = false;
                    document.getElementById('PrimaryCheckBox').checked = true;
                    document.getElementById('FatherCheckBox').checked = false;
                    document.getElementById('MotherCheckBox').checked = false;
                    document.getElementById('StudentCheckBox').checked = false;
                    document.getElementById('SupportSMSInOtherLanguageCheckBox').checked = false;

                    $("#tblSMSPredefineGrid").html('');
                    $(".IdsNoDiv").val("");
                    $(".IdsNoDiv").addClass("d-none");

                    document.getElementById('PickupDropCheckBox').checked = false;
                    $("#PickupAndDropPointCheckboxList").addClass('d-none');
                    $("#PickupAndDropPointCheckboxList").html('');

                    $("#CharCountDiv").removeClass("d-none");
                    $("#SMsPredefinedv").addClass("d-none");
                }
            </script>

            <script>
                function OnSearch() {
                    $("#LoaderDiv1").show();
                    if (ValidateForSearch()) {
                        var IsSMS = document.getElementById('SMSCheckBox').checked;
                        var IsEmail = document.getElementById('EmailCheckBox').checked;
                        var IsMobileApp = document.getElementById('MobileAppCheckBox').checked;
                        var IsWhatsApp = document.getElementById('ctl00_CP_WhatsAppCheckBox').checked;
                        var EventId = $("#drpEvent").val() > 0 ? $("#drpEvent").val() : "0";
                        var ClassId = $("#drpClass").val() > 0 ? $("#drpClass").val() : "0";
                        var DivisionId = $("#drpDivision").val() > 0 ? $("#drpDivision").val() : "0";
                        OrgId = $("#drpOrganization").val() > 0 ? $("#drpOrganization").val() : "0";
                        BatchId = $("#drpBatch").val() > 0 ? $("#drpBatch").val() : "0";
                        var Template = $("#TemplateTextBox").val();
                        var IdNos = $.trim($("#CodeTextBox").val());
                        var ForHostelDate = "";
                        if (isValidDate2($("#ForHostelDatePicker"))) {
                            ForHostelDate = $('#ForHostelDatePicker').val().split("/").reverse().join("-");
                            ForHostelDate = new Date(ForHostelDate);
                        }
                        var DepartmentId = $("#drpDepartment").val() > 0 ? $("#drpDepartment").val() : "0";

                        var DateOfBirth = "";
                        if (isValidDate2($("#DOBDatePicker"))) {
                            DateOfBirth = $('#DOBDatePicker').val().split("/").reverse().join("-");
                            DateOfBirth = new Date(DateOfBirth);
                        }
                        var DueDate = "";
                        if (isValidDate2($("#DueDatePicker"))) {
                            DueDate = $('#DueDatePicker').val().split("/").reverse().join("-");
                            DueDate = new Date(DueDate);
                        }
                        var ContactTypeId = $("#drpContactType").val() > 0 ? $("#drpContactType").val() : "0";
                        var BusRouteId = $("#drpBusRoute").val() > 0 ? $("#drpBusRoute").val() : "0";
                        var TransportId = $("#drpTransport").val() > 0 ? $("#drpTransport").val() : "0";
                        var HostelId = $("#drpHostel").val() > 0 ? $("#drpHostel").val() : "0";
                        var ReceiptBookId = $("#drpReceiptBook").val() > 0 ? $("#drpReceiptBook").val() : "0";
                        var CollectionGroupId = $("#drpCollectionGroup").val() > 0 ? $("#drpCollectionGroup").val() : "0";
                        var ExamId = $("#drpExam").val() > 0 ? $("#drpExam").val() : "0";
                        var ESubjectId = $("#drpESubject").val() > 0 ? $("#drpESubject").val() : "0";
                        var AttendanceTypeId = $("#drpAttendanceType").val() > 0 ? $("#drpAttendanceType").val() : "0";
                        var SubjectId = $("#drpSubject").val() > 0 ? $("#drpSubject").val() : "0";
                        var FromDate = "";
                        if (isValidDate2($("#FromDatePicker"))) {
                            FromDate = new Date($('#FromDatePicker').val().split("/").reverse().join("-"));
                        }
                        var ToDate = "";
                        if (isValidDate2($("#ToDatePicker"))) {
                            ToDate = new Date($('#ToDatePicker').val().split("/").reverse().join("-"));
                        }
                        var AdmissionCategoryId = $("#drpAdmissionCategory").val() > 0 ? $("#drpAdmissionCategory").val() : "0";
                        var ForYear = $("#drpForYear").val() > 0 ? $("#drpForYear").val() : "0";
                        var ForMonth = $("#drpForMonth").val() > 0 ? $("#drpForMonth").val() : "0";
                        var StatusId = $("#drpStatus").val() > 0 ? $("#drpStatus").val() : "0";
                        var LectureDate = "";
                        if (isValidDate2($("#LectureDatePicker"))) {
                            LectureDate = $('#LectureDatePicker').val().split("/").reverse().join("-");
                            LectureDate = new Date(LectureDate);
                        }
                        var PasswordReminderDays = $.trim($("#PasswordReminderDaysTextBox").val());
                        var AbsentDays = $.trim($("#AbsentDaysTextBox").val());
                        var PickupAndDropPoints = "";
                        $("#PickupAndDropPointCheckboxList input").each(function (index) {
                            var item = $(this);
                            if (item[0].checked) {
                                PickupAndDropPoints = PickupAndDropPoints + item[0].value + ",";
                            }

                        }
                        );
                        PickupAndDropPoints = PickupAndDropPoints.length > 0 ? PickupAndDropPoints.substring(0, PickupAndDropPoints.length - 1) : '';
                        <%--Added For Mantis : 35914 by Nilesh--%>
                        var FromAmount = $("#FromAmountTextBox").val() > 0 ? $("#FromAmountTextBox").val() : "0";
                        var ToAmount = $("#ToAmountTextBox").val() > 0 ? $("#ToAmountTextBox").val() : "0";

                        var Obj = {
                            "EventId": EventId,
                            "IsSMS": IsSMS,
                            "IsEmail": IsEmail,
                            "IsMobileApp": IsMobileApp,
                            "IsWhatsApp": IsWhatsApp,
                            "ClassId": ClassId,
                            "DivisionId": DivisionId,
                            "OrgId": OrgId,
                            "BatchId": BatchId,
                            "Template": Template,
                            "IdNos": IdNos,
                            "ForHostelDate": ForHostelDate,
                            "DepartmentId": DepartmentId,
                            "DateOfBirth": DateOfBirth,
                            "DueDate": DueDate,
                            "ContactTypeId": ContactTypeId,
                            "BusRouteId": BusRouteId,
                            "TransportId": TransportId,
                            "HostelId": HostelId,
                            "ReceiptBookId": ReceiptBookId,
                            "CollectionGroupId": CollectionGroupId,
                            "ExamId": ExamId,
                            "ESubjectId": ESubjectId,
                            "AttendanceTypeId": AttendanceTypeId,
                            "SubjectId": SubjectId,
                            "FromDate": FromDate,
                            "ToDate": ToDate,
                            "AdmissionCategoryId": AdmissionCategoryId,
                            "ForYear": ForYear,
                            "ForMonth": ForMonth,
                            "StatusId": StatusId,
                            "LectureDate": LectureDate,
                            "PasswordReminderDays": PasswordReminderDays,
                            "AbsentDays": AbsentDays,
                            "PickupAndDropPoints": PickupAndDropPoints,
                            <%--Added For Mantis : 35914 by Nilesh--%>
                            "FromAmount": FromAmount,
                            "ToAmount": ToAmount,
                        }

                        $.ajax({
                            type: "POST",
                            url: "SMSPredefine.aspx/SearchButtonClick",
                            data: JSON.stringify({ formData: Obj }),
                            contentType: "application/json; charset=utf-8",
                            dataType: "json",
                            success: function (result) {
                                if (result.d != "") {
                                    $("#tblSMSPredefineGrid").html(result.d);
                                }
                                $("#LoaderDiv1").hide();
                            },
                            error: function (xhr, status, error) {
                                var err = eval("(" + xhr.responseText + ")");
                                console.log(err.Message);
                                $("#LoaderDiv1").hide();
                            }
                        });
                    }
                    else {
                        $("#LoaderDiv1").hide();
                    }
                }

                function ValidateForSearch() {
                    var EventId = $("#drpEvent").val();
                    if (EventId <= 0) {
                        alert('Select Event');
                        return false;
                    }

                    if (EventId == 2 || EventId == 9 || EventId == 72) {
                        if ($("#DOBDatePicker").val() == null || $("#DOBDatePicker").val() == "") {
                            alert('Select ' + $("#DOBLabel").text().split("*")[0]);
                            return false;
                        }
                    }

                    if (EventId == 32) {
                        if ($("#ForHostelDatePicker").val() == null || $("#ForHostelDatePicker").val() == "") {
                            alert('Enter Admission Date');
                            return false;
                        }
                    }

                    if (EventId == 33) {
                        if ($("#ForHostelDatePicker").val() == null || $("#ForHostelDatePicker").val() == "") {
                            alert('Enter Vacant Date');
                            return false;
                        }
                    }

                    if (EventId == 34) {
                        if ($("#ForHostelDatePicker").val() == null || $("#ForHostelDatePicker").val() == "") {
                            alert('Enter Log Date');
                            return false;
                        }
                    }

                    if (EventId == 11) {
                        if ($("#DueDatePicker").val() == null || $("#DueDatePicker").val() == "") {
                            alert('Enter Due Date');
                            return false;
                        }
                    }

                    if (EventId == 6 || EventId == 7 || EventId == 114) {
                        if ($("#drpClass").val() <= 0) {
                            alert("Select Class");
                            return false;
                        }
                        if ($("#drpExam").val() <= 0) {
                            alert("Select Exam");
                            return false;
                        }
                    }

                    if (EventId == 13 || EventId == 20 || EventId == 26 || EventId == 106 || EventId == 113 || EventId == 157) {
                        if ($("#drpAttendanceType").val() <= 0 && EventId != 157) {
                            alert("Select Attendance Type");
                            return false;
                        }
                        else if ($("#drpAttendanceType option:selected").text() == "Subject" || EventId == 157) {
                            if ($("#drpClass").val() <= 0) {
                                alert("Select Class");
                                return false;
                            }
                            if ($("#drpSubject").val() <= 0) {
                                alert("Select Subject");
                                return false;
                            }
                        }
                    }

                    if (EventId == 1 || EventId == 3 || EventId == 13 || EventId == 31 || EventId == 26 || EventId == 90 || EventId == 76 || EventId == 106 || EventId == 113) {
                        if ($("#FromDatePicker").val() == null || $("#FromDatePicker").val() == "") {
                            alert('Enter From Date');
                            return false;
                        }
                        else if ($("#ToDatePicker").val() == null || $("#ToDatePicker").val() == "") {
                            alert('Enter To Date');
                            return false;
                        }
                    }

                    if (EventId == 4 || EventId == 5 || EventId == 105) {
                        if ($("#ToDatePicker").val() == null || $("#ToDatePicker").val() == "") {
                            alert('Enter To Date');
                            return false;
                        }
                    }

                    if (EventId == 20 || EventId == 157) {
                        if ($("#drpForYear").val() <= 0) {
                            alert("Select For Year");
                            return false;
                        }
                        if ($("#drpForMonth").val() <= 0) {
                            alert("Select For Month");
                            return false;
                        }
                    }

                    if (EventId == 103) {
                        if ($("#PasswordReminderDaysTextBox").val() == null || $("#PasswordReminderDaysTextBox").val() == "") {
                            alert('Enter Password Reminder Days');
                            return false;
                        }
                    }

                    if (EventId == 106) {
                        if ($("#AbsentDaysTextBox").val() == null || $("#AbsentDaysTextBox").val() == "") {
                            alert('Enter Days');
                            return false;
                        }
                    }

                    if (EventId == 12) {
                        if ($("#drpBusRoute").val() <= 0) {
                            alert('Select Bus Route');
                            return false;
                        }
                    }
                    return true;
                }

                function HeaderCheckBoxClick() {
                    var checked = document.getElementById("HeaderCheckBox").checked;
                    var SelectCheckBox = document.getElementsByClassName("SelectCheckBox");
                    for (var i = 0; i < SelectCheckBox.length; i++) {
                        SelectCheckBox[i].checked = checked;
                    }
                }

                function SelectCheckBoxClick(obj) {
                    var count = 0;
                    var SelectCheckBox = document.getElementsByClassName("SelectCheckBox");
                    for (var i = 0; i < SelectCheckBox.length; i++) {
                        if (SelectCheckBox[i].checked) { count++; }
                    }
                    if (count == SelectCheckBox.length) {
                        document.getElementById("HeaderCheckBox").checked = true;
                    }
                    else {
                        document.getElementById("HeaderCheckBox").checked = false;
                    }
                }

                function isValidDate2(inputText) {
                    if (inputText.val() != '') {
                        var dateformat = /^(0?[1-9]|[12][0-9]|3[01])[\/\-](0?[1-9]|1[012])[\/\-]\d{4}$/;
                        if (inputText.val().match(dateformat)) {
                            var opera1 = inputText.val().split('/');
                            var opera2 = inputText.val().split('-');
                            lopera1 = opera1.length;
                            lopera2 = opera2.length;
                            if (lopera1 > 1) {
                                var pdate = inputText.val().split('/');
                            }
                            else if (lopera2 > 1) {
                                var pdate = inputText.val().split('-');
                            }
                            var dd = parseInt(pdate[0]);
                            var mm = parseInt(pdate[1]);
                            var yy = parseInt(pdate[2]);
                            var ListofDays = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
                            if (mm == 1 || mm > 2) {
                                if (dd > ListofDays[mm - 1]) {
                                    alert('Invalid date!');
                                    inputText.val('');
                                    return false;
                                }
                            }
                            if (mm == 2) {
                                var lyear = false;
                                if ((!(yy % 4) && yy % 100) || !(yy % 400)) {
                                    lyear = true;
                                }
                                if ((lyear == false) && (dd >= 29)) {
                                    alert('Invalid date!');
                                    inputText.val('');
                                    return false;
                                }
                                if ((lyear == true) && (dd > 29)) {
                                    alert('Invalid date!');
                                    inputText.val('');
                                    return false;
                                }
                            }
                        }
                        else {
                            return false;
                        }
                        return true;
                    }
                    else {
                        return false;
                    }
                }

                function isNumberKey(evt) {
                    var charCode = (evt.which) ? evt.which : event.keyCode;
                    if (charCode != 46 && charCode > 31 && (charCode < 48 || charCode > 57))
                        return false;
                    return true;
                }
            </script>

            <script type="text/javascript">
                function OnSendAlertClick() {

                    var rowcount = $("tr.tabletr").length;
                    if (rowcount > 0) {
                        var selectedcount = $('.SelectCheckBox:checked').length;
                        if (selectedcount > 0) {
                            if (confirm("Do you want to send alert? Total No Of Send Message : " + selectedcount)) {
                                var IsSMS = document.getElementById('SMSCheckBox').checked;
                                var IsEmail = document.getElementById('EmailCheckBox').checked;
                                var IsMobileApp = document.getElementById('MobileAppCheckBox').checked;
                                var IsWhatsApp = document.getElementById('ctl00_CP_WhatsAppCheckBox').checked;
                                var SupportSMSInOtherLanguageCheckBox = document.getElementById('SupportSMSInOtherLanguageCheckBox').checked;
                                var EventId = $("#drpEvent").val() > 0 ? $("#drpEvent").val() : "0";
                                var SourceEvent = $("#drpEvent").val() > 0 ? $("#drpEvent option:selected").text() : "";
                                if (EventId == 10 && IsMobileApp) {
                                    alert("This Event is not allowed for Mobile App.");
                                }

                                var IsPrimary = document.getElementById('PrimaryCheckBox').checked;
                                var IsFather = document.getElementById('FatherCheckBox').checked;
                                var IsMother = document.getElementById('MotherCheckBox').checked;
                                var IsStudent = document.getElementById('StudentCheckBox').checked;

                                if (IsSMS || IsEmail || IsMobileApp || IsWhatsApp) {
                                    if (IsPrimary || IsFather || IsMother || IsStudent) {
                                        var ClassId = $("#drpClass").val() > 0 ? $("#drpClass").val() : "0";
                                        var DivisionId = $("#drpDivision").val() > 0 ? $("#drpDivision").val() : "0";
                                        OrgId = $("#drpOrganization").val();
                                        BatchId = $("#drpBatch").val();
                                        var Template = $("#TemplateTextBox").val();
                                        var IdNos = $.trim($("#CodeTextBox").val());
                                        var ForHostelDate = "";
                                        if (isValidDate2($("#ForHostelDatePicker"))) {
                                            ForHostelDate = $('#ForHostelDatePicker').val().split("/").reverse().join("-");
                                            ForHostelDate = new Date(ForHostelDate);
                                        }
                                        var DepartmentId = $("#drpDepartment").val() > 0 ? $("#drpDepartment").val() : "0";

                                        var DateOfBirth = "";
                                        if (isValidDate2($("#DOBDatePicker"))) {
                                            DateOfBirth = $('#DOBDatePicker').val().split("/").reverse().join("-");
                                            DateOfBirth = new Date(DateOfBirth);
                                        }
                                        var DueDate = "";
                                        if (isValidDate2($("#DueDatePicker"))) {
                                            DueDate = $('#DueDatePicker').val().split("/").reverse().join("-");
                                            DueDate = new Date(DueDate);
                                        }
                                        var ContactTypeId = $("#drpContactType").val() > 0 ? $("#drpContactType").val() : "0";
                                        var BusRouteId = $("#drpBusRoute").val() > 0 ? $("#drpBusRoute").val() : "0";
                                        var TransportId = $("#drpTransport").val() > 0 ? $("#drpTransport").val() : "0";
                                        var HostelId = $("#drpHostel").val() > 0 ? $("#drpHostel").val() : "0";
                                        var ReceiptBookId = $("#drpReceiptBook").val() > 0 ? $("#drpReceiptBook").val() : "0";
                                        var CollectionGroupId = $("#drpCollectionGroup").val() > 0 ? $("#drpCollectionGroup").val() : "0";
                                        var ExamId = $("#drpExam").val() > 0 ? $("#drpExam").val() : "0";
                                        var ESubjectId = $("#drpESubject").val() > 0 ? $("#drpESubject").val() : "0";
                                        var AttendanceTypeId = $("#drpAttendanceType").val() > 0 ? $("#drpAttendanceType").val() : "0";
                                        var SubjectId = $("#drpSubject").val() > 0 ? $("#drpSubject").val() : "0";

                                        var FromDate = "";
                                        if (isValidDate2($("#FromDatePicker"))) {
                                            FromDate = $('#FromDatePicker').val().split("/").reverse().join("-");
                                            FromDate = new Date(FromDate);
                                        }
                                        var ToDate = "";
                                        if (isValidDate2($("#ToDatePicker"))) {
                                            ToDate = $('#ToDatePicker').val().split("/").reverse().join("-");
                                            ToDate = new Date(ToDate);
                                        }
                                        var AdmissionCategoryId = $("#drpAdmissionCategory").val() > 0 ? $("#drpAdmissionCategory").val() : "0";
                                        var ForYear = $("#drpForYear").val() > 0 ? $("#drpForYear").val() : "0";
                                        var ForMonth = $("#drpForMonth").val() > 0 ? $("#drpForMonth").val() : "0";
                                        var StatusId = $("#drpStatus").val() > 0 ? $("#drpStatus").val() : "0";
                                        var LectureDate = "";
                                        if (isValidDate2($("#LectureDatePicker"))) {
                                            LectureDate = $('#LectureDatePicker').val().split("/").reverse().join("-");
                                            LectureDate = new Date(LectureDate);
                                        }
                                        var PasswordReminderDays = $.trim($("#PasswordReminderDaysTextBox").val());
                                        var AbsentDays = $.trim($("#AbsentDaysTextBox").val());
                                        var PickupAndDropPoints = "";
                                        $("#PickupAndDropPointCheckboxList input").each(function (index) {
                                            var item = $(this);
                                            if (item[0].checked) {
                                                PickupAndDropPoints = PickupAndDropPoints + item[0].value + ",";
                                            }

                                        });
                                        PickupAndDropPoints = PickupAndDropPoints.length > 0 ? PickupAndDropPoints.substring(0, PickupAndDropPoints.length - 1) : '';
                                        <%--Added For Mantis : 35914 by Nilesh--%>
                                        var FromAmount = $("#FromAmountTextBox").val() > 0 ? $("#FromAmountTextBox").val() : "0";
                                        var ToAmount = $("#ToAmountTextBox").val() > 0 ? $("#ToAmountTextBox").val() : "0";

                                        var DataList = [];
                                        $(".tablebody tr.tabletr").each(function (index) {
                                            var item = $(this);
                                            var IsSelected = item.find('input.SelectCheckBox:checked').length;
                                            if (IsSelected == 1) {
                                                var Template = item.find('textarea.template').val();
                                                var MobileNo = item.find('input.MobileNo').val();
                                                var EmailId = item.find('input.EmailId').val();
                                                var SourceTypeId = item.find('input.SourceTypeId').val();
                                                var AcademicId = item.find('input.AcademicId').val();
                                                var SourceId = item.find('input.SourceId').val();
                                                var FatherContactNo = item.find('input.FatherContactNo').val();
                                                var FatherMail = item.find('input.FatherMail').val();
                                                var MotherContactNo = item.find('input.MotherContactNo').val();
                                                var MotherMail = item.find('input.MotherMail').val();
                                                var StudentContactNo = item.find('input.StudentContactNo').val();
                                                var StudentEmail = item.find('input.StudentEmail').val();

                                                DataList.push({
                                                    Template: Template,
                                                    MobileNo: MobileNo,
                                                    EmailId: EmailId,
                                                    SourceTypeId: SourceTypeId,
                                                    AcademicId: AcademicId,
                                                    SourceId: SourceId,
                                                    FatherContactNo: FatherContactNo,
                                                    FatherMail: FatherMail,
                                                    MotherContactNo: MotherContactNo,
                                                    MotherMail: MotherMail,
                                                    StudentContactNo: StudentContactNo,
                                                    StudentEmail: StudentEmail
                                                });
                                            }
                                        });
                                        console.log(DataList);

                                        var Obj = {
                                            "EventId": EventId,
                                            "SourceEvent": SourceEvent,
                                            "IsSMS": IsSMS,
                                            "IsEmail": IsEmail,
                                            "IsMobileApp": IsMobileApp,
                                            "IsWhatsApp": IsWhatsApp,
                                            "IsPrimary": IsPrimary,
                                            "IsFather": IsFather,
                                            "IsMother": IsMother,
                                            "IsStudent": IsStudent,
                                            "SupportSMSInOtherLanguageCheckBox": SupportSMSInOtherLanguageCheckBox,
                                            "ClassId": ClassId,
                                            "DivisionId": DivisionId,
                                            "OrgId": OrgId,
                                            "BatchId": BatchId,
                                            "Template": Template,
                                            "IdNos": IdNos,
                                            "ForHostelDate": ForHostelDate,
                                            "DepartmentId": DepartmentId,
                                            "DateOfBirth": DateOfBirth,
                                            "DueDate": DueDate,
                                            "ContactTypeId": ContactTypeId,
                                            "BusRouteId": BusRouteId,
                                            "TransportId": TransportId,
                                            "HostelId": HostelId,
                                            "ReceiptBookId": ReceiptBookId,
                                            "CollectionGroupId": CollectionGroupId,
                                            "ExamId": ExamId,
                                            "ESubjectId": ESubjectId,
                                            "AttendanceTypeId": AttendanceTypeId,
                                            "SubjectId": SubjectId,
                                            "FromDate": FromDate,
                                            "ToDate": ToDate,
                                            "AdmissionCategoryId": AdmissionCategoryId,
                                            "ForYear": ForYear,
                                            "ForMonth": ForMonth,
                                            "StatusId": StatusId,
                                            "LectureDate": LectureDate,
                                            "PasswordReminderDays": PasswordReminderDays,
                                            "AbsentDays": AbsentDays,
                                            "DataList": DataList,
                                            "PickupAndDropPoints": PickupAndDropPoints,
                                            <%--Added For Mantis : 35914 by Nilesh--%>
                                            "FromAmount": FromAmount,
                                            "ToAmount": ToAmount
                                        }

                                        $.ajax({
                                            type: "POST",
                                            url: "SMSPredefine.aspx/SendAlertButtonClick",
                                            data: JSON.stringify({ formData: Obj }),
                                            contentType: "application/json; charset=utf-8",
                                            dataType: "json",
                                            success: function (result) {
                                                if (result.d != "") {
                                                    alert(result.d);
                                                    $("#tblSMSPredefineGrid").html("");
                                                }
                                                $("#LoaderDiv1").hide();
                                            },
                                            error: function (xhr, status, error) {
                                                var err = eval("(" + xhr.responseText + ")");
                                                console.log(err.Message);
                                                $("#LoaderDiv1").hide();
                                            }
                                        });
                                    }
                                    else {
                                        alert("Atleast one from Primary, Father, Mother or Student should be checked");
                                    }
                                }
                                else {
                                    alert("Atleast one from SMS, Email, Mobile App, WhatsApp should be checked");
                                }
                            }
                        }
                        else {
                            alert("There is no any record selected");
                        }
                    }
                    else {
                        alert("Atleast one record should be there");
                    }
                }
            </script>
        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>
