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

<asp:Content ID="Content1" ContentPlaceHolderID="CP" runat="Server">
    <%--<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>--%>
    <%--  <script src="https://code.jquery.com/jquery-1.12.1.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>--%>
    <%--<script src="~/App_Themes/mis_db/Java Script/sorttable.js"></script>--%>
    <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">
                        <%--<span class='btn btn-home btn-icon' onclick='DashBoard()' title='home'><span><i class='material-icons'>home</i></span></span>
                        <input type="button" value="&#xf3e5;" id="bntBackOrg" onclick="BackOrgFunction()" skinid="0" class="float-right btn btn-back btn-icon fas" />--%>
                    </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">Student Search
                                </h2>
                            </div>
                            <div class='row'>
                                <div id='SuIddiv' class='col-md-3 col-sm-4 col-xs-12' visible='false'>
                                    <div class='controllabelwidth'>
                                        <label id='suidlabel'>su id</label>
                                    </div>
                                    <div class='fleft pright5'>
                                        <input type='text' id="txtSuId" class="form-control" value="<%= SUId %>" name="SUId" />
                                    </div>
                                </div>
                                <div class='col-md-3 col-sm-4 col-xs-12'>
                                    <div class='controlLabelWidth'>
                                        <label>Organization<span style="color: red"> *</span></label>
                                    </div>
                                    <div class='fLeft pRight5'>
                                        <select id='drpOrganization' class="form-control" onchange="OnOrgDrop()">
                                            <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<span style="color: red"> *</span></label>
                                    </div>
                                    <div class='fLeft pRight5'>
                                        <select id='drpBatch' class="form-control" onchange="OnBatchDrop()">
                                            <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>Department</label>
                                    </div>
                                    <div class='fLeft pRight5'>
                                        <select id='drpDepartment' class="form-control" onchange="OnDepartDrop()">
                                            <option selected="selected" value='0'>All</option>
                                        </select>
                                    </div>
                                </div>
                                <div class='col-md-3 col-sm-4 col-xs-12'>
                                    <div class='controlLabelWidth'>
                                        <label id='ClassLabel'>Class</label>
                                    </div>
                                    <div class='fLeft pRight5'>
                                        <select id='drpClass' class="form-control" onchange="OnClassDrop()">
                                            <option selected="selected" value="0">All</option>
                                        </select>
                                    </div>
                                </div>
                                <div class='col-md-3 col-sm-4 col-xs-12'>
                                    <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'>
                                    <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'>
                                    <div class='controllabelwidth'>
                                        <label id='orderbylabel' runat='server' text='order by'>order by</label>
                                    </div>
                                    <div class='fleft pright5'>
                                        <select id='drpOrderby' class="form-control" onchange="OrderBy()">
                                            <option value='1' selected="selected">Roll No</option>
                                            <option value='2'>ID No</option>
                                        </select>
                                    </div>
                                </div>
                                <div class='col-md-3 col-sm-4 col-xs-12'>
                                    <div class='controlLabelWidth'>
                                        <label>ID No</label>
                                    </div>
                                    <div class='fLeft pRight5 '>
                                        <input type='Text' class="form-control" value="<%= IdNo %>" id="txtIdNo" name="IdNo" />
                                    </div>
                                </div>
                                <div class='col-md-3 col-sm-4 col-xs-12'>
                                    <div class='controlLabelWidth'>
                                        <label>First Name</label>
                                    </div>
                                    <div class='fLeft pRight5'>
                                        <input type='Text' class="form-control" value="" id="txtFirstName" />
                                    </div>
                                </div>

                                <div class='col-md-3 col-sm-4 col-xs-12'>
                                    <div class='controlLabelWidth'>
                                        <label>Last Name</label>
                                    </div>
                                    <div class='fLeft pRight5'>
                                        <input type='Text' class="form-control" value="" id="txtLastName" />
                                    </div>
                                </div>
                                <div class='col-md-3 col-sm-4 col-xs-12'>
                                    <div class='controlLabelWidth'>
                                        <label id="RollNoLabel">Roll No</label>
                                    </div>
                                    <div class='fLeft pRight5'>
                                        <input type='Text' class="form-control" value="" id="txtRollNo" />
                                    </div>
                                </div>







                                <%--  <div class='col-md-3 col-sm-4 col-xs-12 mt38'>
                                    <label class="material-checkbox">
                                        <asp:CheckBox ID='ShowWithPhotoCheckBox' runat='server' AutoPostBack='false' />
                                        <span>Show With Photo</span>
                                    </label>
                                </div>--%>
                                <div class='text-center col-md-12'>
                                    <input type="button" id="btnSearch" value="Search" class="btn btn-search" onclick="return OnSearch()" />
                                    <input type="button" id="ClearButton" value="Clear" class="btn btn-clear" onclick="return OnClear()" />

                                </div>
                                <%--  <div class="input col-md-1 col-xs-2">
            <!--		Show Numbers Of Rows 		-->
            <select class="form-control" name="state" id="maxRows">
                <option value="5000">Show ALL Rows</option>
                <option value="10">10</option>
                <option value="20">20</option>
                <option value="30">30</option>
            </select>
        </div>--%>
                                <div class='col-md-12'>
                                    <div class='table-responsive mt-3'>
                                        <table class='table table-striped table-hover table-bordered sortable' id='tblDepartment'>
                                            <tbody>
                                            </tbody>
                                        </table>

                                        <nav>
                                            <ul class="pagination"></ul>
                                        </nav>
                                    </div>
                                    <div class="se-pre-con" id="LoaderDiv1" style="display: none"></div>
                                </div>
                                <%--   <div class="himssuHeader1WireBox col-md-12 pTop5" style="max-height: 300px; overflow-y: auto;">


                                    <asp:PlaceHolder ID="StudentSearchPlaceHolder" runat="server" />
                                </div>--%>
                            </div>
                            <div>
                            </div>
                        </div>
                    </div>

                    <script type="text/javascript">
                        var OrgId = 0;
                        var BatchId = 0;
                        var DeptId = 0;
                        $(document).ready(function () {
                            GetOrganization()
                            // DepartmentDrop();
                            StatusDrop();
                        });
                        function GetOrganization() {
                            $.ajax({
                                type: "POST",
                                url: "StudentSearch.aspx/GetOrganization",
                                contentType: "application/json; charset=utf-8",
                                dataType: "json",
                                success: function (result) {
                                    $("#drpOrganization").html(result.d);
                                    OnOrgDrop();
                                    //ClassDrop(DeptId);
                                }
                            });
                        }
                        function OnOrgDrop() {
                            OrgId = $("#drpOrganization").val();
                            $.ajax({
                                type: "POST",
                                url: "StudentSearch.aspx/GetBatch",
                                data: JSON.stringify({ "OrgId": OrgId }),
                                contentType: "application/json; charset=utf-8",
                                dataType: "json",
                                success: function (result) {
                                    $("#drpBatch").html(result.d);

                                    //ClassDrop(DeptId);
                                }
                            });

                            $.ajax({
                                type: "POST",
                                url: "StudentSearch.aspx/GetDepatment",
                                data: JSON.stringify({ "OrgId": OrgId }),
                                contentType: "application/json; charset=utf-8",
                                dataType: "json",
                                success: function (result) {
                                    $("#drpDepartment").html(result.d);

                                    //ClassDrop(DeptId);
                                }
                            });
                            $.ajax({
                                type: "POST",
                                url: "StudentSearch.aspx/GetClass",
                                data: JSON.stringify({ "DeptId": DeptId, "OrgId": OrgId }),
                                contentType: "application/json; charset=utf-8",
                                dataType: "json",
                                success: function (result) {
                                    $("#drpClass").html(result.d)
                                    OnClassDrop()
                                }
                            });
                        }
                        function DepartmentDrop() {
                            $.ajax({
                                type: "POST",
                                url: "StudentSearch.aspx/GetDepatment",
                                contentType: "application/json; charset=utf-8",
                                dataType: "json",
                                success: function (result) {
                                    $("#drpDepartment").html(result.d);

                                    //ClassDrop(DeptId);
                                }
                            });
                        }
                        function OnDepartDrop() {
                            DeptId = $("#drpDepartment").val();
                            $.ajax({
                                type: "POST",
                                url: "StudentSearch.aspx/GetClass",
                                data: JSON.stringify({ "DeptId": DeptId }),
                                contentType: "application/json; charset=utf-8",
                                dataType: "json",
                                success: function (result) {
                                    $("#drpClass").html(result.d)
                                }
                            });
                        }
                        function OnClassDrop() {
                            //$("#drpClass").change(function () {
                            var myparam = $("#drpClass").val();
                            var OrgId = $("#drpOrganization").val();
                            // alert(myparam);
                            $.ajax({
                                type: "POST",
                                url: "StudentSearch.aspx/GetDivision",
                                data: JSON.stringify({ "id": myparam, "OrgId": OrgId }),
                                contentType: "application/json; charset=utf-8",
                                dataType: "json",
                                success: function (result) {
                                    //alert(result.d);
                                    $("#drpDivision").html(result.d);
                                }
                                //});
                            });
                        }
                        function StatusDrop() {
                            $.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 OnSearch() {
                            $("#LoaderDiv1").show();
                            var flag = true;
                            if ($("#txtSuId").val() == "" && $("#txtFirstName").val() == "" && $("#txtLastName").val() == "" && $("#txtIdNo").val() == "" && $("#drpClass").val() == 0 || $("#drpBatch").val() == 0 || $("#drpOrganization").val() == 0)
                            { alert('Please select any other field'); flag = false; $("#LoaderDiv1").hide(); return; }
                            else {
                                //if ($("#txtFirstName").val() == "")
                                //{ alert('Enter any one criteria'); flag = false; }
                                //else { $("#txtFirstName").val() = "" }
                                //if ($("#txtLastName").val() == "")
                                //{ alert('Enter any one criteria'); flag = false; }
                                //else { $("#txtLastName").val() = "" }
                                //if ($("#drpClass").val() == 0)
                                //{ alert('Enter any one criteria'); flag = false; }
                                //else { $("#drpClass").val() = 0 }
                                // if (flag == false) { return true } else { return false }

                                OrgId = $("#drpOrganization").val();
                                BatchId = $("#drpBatch").val();
                                DeptId = $("#drpDepartment").val();
                                var ClassId = $("#drpClass").val();
                                var RollNo = $.trim($("#txtRollNo").val());
                                var NO = parseInt(RollNo) || 0;
                                var Code = $.trim($("#txtIdNo").val());
                                var StatusId = $("#drpStatus").val();
                                var DivisionId = $("#drpDivision").val();
                                var FirstName = $.trim($("#txtFirstName").val());
                                var LastName = $.trim($("#txtLastName").val());
                                var SuId = $.trim($("#txtSuId").val());
                                var OrderBy = $("#drpOrderby").val();

                                $.ajax({
                                    type: "POST",
                                    url: "StudentSearch.aspx/StudentProfileDetailGet",
                                    data: JSON.stringify({ "OrgId": OrgId, "BatchId": BatchId, "DeptId": DeptId, "ClassId": ClassId, "RollNo": NO, "Code": Code, "StatusId": StatusId, "DivisionId": DivisionId, "FirstName": FirstName, "LastName": LastName, "SuId": SuId, "OrderBy": OrderBy }),
                                    contentType: "application/json; charset=utf-8",
                                    dataType: "json",
                                    success: function (result) {

                                        if (result.d != "") {
                                            // document.getElementById("dvExamGridDiv").innerHTML = item.EmpGrid;
                                            $("#tblDepartment").html(result.d);
                                            //document.getElementById("tblDepartment").innerHTML += "<thead><tr><th>Profile</th><th>360 View</th><th onclick='sortTable(0)'> Gr No</th><th>Name</th><th>Class</th><th onclick='sortTable(1)'>RollNo</th><th>Status</th></tr></thead>";
                                            document.getElementById("tblDepartment").innerHTML += "<thead><tr><th onclick='sortTable(0)'> Student Detail</th></tr></thead>";
                                        }
                                        else { document.getElementById("tblDepartment").innerHTML = "<tr><td colspan='7' class='record'>No records found..!!..!!</td></tr>"; }
                                        $("#LoaderDiv1").hide();


                                    },
                                    error: function (xhr, status, error) {
                                        var err = eval("(" + xhr.responseText + ")");
                                        console.log(err.Message);
                                        $("#LoaderDiv1").hide();
                                    }
                                });
                                return true
                            }
                        }

                        function ProfileFunction(StudentId) {
                            var ClassId = $("#drpClass").val();
                            var StatusId = $("#drpStatus").val();
                            var DivisionId = $("#drpDivision").val();
                            window.location.href = "../MobileView/StudentProfile.aspx?OrgId=" + OrgId + "&BatchId=" + BatchId + "&ClassId=" + ClassId + "&StatusId=" + StatusId + "&DivisionId=" + DivisionId + "&StudentId=" + StudentId;
                            //alert(StudentId);
                        }
                        function Student360ViewFunction(AcademicId) {
                            window.location.href = "../MobileView/Student360View.aspx?AcademicId=" + AcademicId + "&BatchId=" + BatchId;
                        }
                        function AssessmentView(AcademicId) {
                            window.location.href = "../MobileView/Student360View.aspx?AcademicId=" + AcademicId + "&BatchId=" + BatchId + "&Assessment";
                        }
                        function FeeView(AcademicId) {
                            window.location.href = "../MobileView/Student360View.aspx?AcademicId=" + AcademicId + "&BatchId=" + BatchId + "&Fee";
                        }
                        function OnClear() {
                            $("#drpOrganization").val(0);
                            $("#drpBatch").val(0);
                            $("#drpClass").val(0);
                            $("#txtIdNo").val("");
                            $("#txtRollNo").val("")
                            $("#drpStatus").val(0);
                            $("#drpDivision").val(0);
                            $("#txtFirstName").val("");
                            $("#txtLastName").val("");
                            $("#txtSuId").val("");
                            $("#drpDepartment").val(0);
                            $("#drpOrderby").val(0);
                            $("#tblDepartment").html("");
                            GetOrganization();
                        }
                        function BackOrgFunction() { window.location.href = "../MobileView/DashBoard.aspx"; }
                        function DashBoard() { window.location.href = "../MobileView/DashBoard.aspx"; }
                    </script>
        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>
