<%@ page language="C#" autoeventwireup="true" inherits="Pages_MobileView_EmployeeSearch, App_Web_10j51jit" 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 type="text/javascript">
        var OrgId = 0;
        $(document).ready(function () {
            GetOrganization();
            // DepartmentDrop();
            //// TypeDrop();
            //OnSearch();
        });
        function GetOrganization() {
            $.ajax({
                type: "POST",
                url: "EmployeeSearch.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: "EmployeeSearch.aspx/GetDepatment",
                data: JSON.stringify({ "OrgId": OrgId }),
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (result) {
                    $("#drpDepartment").html(result.d);
                    $.ajax({
                        type: "POST",
                        url: "EmployeeSearch.aspx/GetType",
                        data: JSON.stringify({ "OrgId": OrgId }),
                        contentType: "application/json; charset=utf-8",
                        dataType: "json",
                        success: function (result) {
                            $("#drpEmployeeType").html(result.d);
                        }
                    });
                }
            });

        }
        //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 DepartmentDrop() {
            $.ajax({
                type: "POST",
                url: "EmployeeSearch.aspx/GetDepatment",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (result) {
                    $("#drpDepartment").html(result.d);
                }
            });
        }
        function TypeDrop() {
            $.ajax({
                type: "POST",
                url: "EmployeeSearch.aspx/GetType",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (result) {
                    $("#drpEmployeeType").html(result.d);
                }
            });
        }


        function OnSearch() {
            var AllowReadPermission = "";
            $("#LoaderDiv1").show();
            var flag = true;
            //if ($("#drpOrganization").val() == 0 || $("#txtCode").val() == "" && $("#txtName").val() == "" && $("#txtSurName").val() == "" && $("#drpEmployeeType").val() == 0 && $("#drpDepartment").val() == 0)
            //if ($("#drpOrganization").val() == 0)
            //{ alert('Enter any one  * criteria'); flag = false; $("#LoaderDiv1").hide(); return; }
            //else {
                var Code = $.trim($("#txtCode").val());
                OrgId = $("#drpOrganization").val();
                var Name = $.trim($("#txtName").val());
                var SurName = $.trim($("#txtSurName").val());
                var DepartmentId = $("#drpDepartment").val();
                var StatusId = $("#drpStatus").val();
                var EmpType = $.trim($("#drpEmployeeType").val());

                $.ajax({
                    type: "POST",
                    url: "EmployeeSearch.aspx/PermissionGet",
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    success: function (result) {

                        if (result.d == "True") {
                            AllowReadPermission = true;
                        }
                        else {
                            AllowReadPermission = false;
                        }
                    },
                    error: function (xhr, status, error) {
                        var err = eval("(" + xhr.responseText + ")");
                        console.log(err.Message);
                        $("#LoaderDiv1").hide();
                    }
                });


                $.ajax({
                    type: "POST",
                    url: "EmployeeSearch.aspx/EmployeeProfileDetailGet",
                    data: JSON.stringify({ "OrgId": OrgId, "Code": Code, "Name": Name, "SurName": SurName, "DepartmentId": DepartmentId, "StatusId": StatusId, "EmpType": EmpType }),
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    success: function (result) {
                        //alert(result.d);
                        if (result.d != "") {
                            // document.getElementById("dvExamGridDiv").innerHTML = item.EmpGrid;
                            $("#tblDepartment").html(result.d);
                            if (AllowReadPermission == true)
                                document.getElementById("tblDepartment").innerHTML += "<thead> <tr><th>Profile</th><th>360 View</th><th>Code</th><th>Name</th><th>Employee Type</th><th>Organization Department</th><th>Status</th></tr></thead>";
                            else
                                document.getElementById("tblDepartment").innerHTML += "<thead> <tr><th>Profile</th><th>Code</th><th>Name</th><th>Employee Type</th><th>Organization Department</th><th>Status</th></tr></thead>";
                        }
                        else { document.getElementById("tblDepartment").innerHTML = "<tr><td colspan='7' class='record'>No records found..!!</td></tr>"; }
                        //if (item.AttedanceGrid != "") {
                        //    document.getElementById("tblDepartment").innerHTML = result.d;
                        //}
                        //else { document.getElementById("tblDepartment").innerHTML = "<tr><td class='record'>No records found..!!..!!</td></tr>"; }
                        // $("#tblDepartment").html(result.d);
                        $("#LoaderDiv1").hide();
                    },
                    error: function (xhr, status, error) {
                        var err = eval("(" + xhr.responseText + ")");
                        console.log(err.Message);
                        $("#LoaderDiv1").hide();
                    }
                });
                return true;
            //}
        }
        function ProfileFunction(EmployeeId) {
            window.location.href = "../MobileView/EmployeeProfile.aspx?EmployeeId=" + EmployeeId;
            //alert(StudentId);
        }
        function Employee360Function(EmployeeId, BatchId) {
            window.location.href = "../MobileView/Employee360View.aspx?EmployeeId=" + EmployeeId + "&BatchId=" + BatchId + "&OrgId=" + OrgId;

            //alert(StudentId);
        }

        function OnClear() {
            $("#drpOrganization").val(0)
            $("#txtCode").val("");
            $("#drpEmployeeType").val(0);
            $("#txtName").val("");
            $("#txtSurName").val("");
            $("#drpDepartment").val(0);
            $("#drpStatus").val(0);
            // $("#tblDepartment").html("");
            $("#tblDepartment").html("");
            GetOrganization();
        }
        function BackOrgFunction() { window.location.href = "../MobileView/DashBoard.aspx"; }
        function DashBoard() { window.location.href = "../MobileView/DashBoard.aspx"; }
    </script>
    <asp:UpdatePanel ID="DoctorScheduleUpdatePanel" runat="server">
        <ContentTemplate>
            <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="page-header row mb20">
                <div class="col-xl-12 col-sm-12 col-xs-12 border-bottom-inline xs-padd0">
                    <div class="main-topic inner" id="HeaderTitle">
                    </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">Employee Search
                                </h2>
                            </div>
                            <div class='row'>
                                <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="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 id="DivisionLabel">Department</label>
                                    </div>
                                    <div class='fLeft pRight5' id="divDivision" runat="server">
                                        <select id='drpDepartment' 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>Employee Type</label>
                                    </div>
                                    <div class='fLeft pRight5'>
                                        <select id='drpEmployeeType' 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='ClassLabel'>Status</label>
                                    </div>
                                    <div class='fLeft pRight5'>
                                        <select id='drpStatus' class="form-control">
                                            <option selected="selected" value="0">All</option>
                                            <option value='7'>Active</option>
                                            <option value='9'>Left</option>
                                            <option value='8'>Suspended</option>
                                            <option value='10'>Unknown</option>
                                        </select>
                                    </div>
                                </div>
                                <div class='col-md-3 col-sm-4 col-xs-12'>
                                    <div class='controlLabelWidth'>
                                        <label>Code<span style="color: red"></span></label>
                                    </div>
                                    <div class='fLeft pRight5 '>
                                        <input type='Text' class="form-control" value="" id="txtCode" />
                                    </div>
                                </div>

                                <div class='col-md-3 col-sm-4 col-xs-12'>
                                    <div class='controlLabelWidth'>
                                        <label>Name</label>
                                    </div>
                                    <div class='fLeft pRight5'>
                                        <input type='Text' class="form-control" value="" id="txtName" />
                                    </div>
                                </div>
                                <div class='col-md-3 col-sm-4 col-xs-12'>
                                    <div class='controlLabelWidth'>
                                        <label>SurName</label>
                                    </div>
                                    <div class='fLeft pRight5'>
                                        <input type='Text' class="form-control" value="" id="txtSurName" />
                                    </div>
                                </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='col-md-12'>
                                    <div class='table-responsive mt-3 ' style="overflow-y: auto;">
                                        <table class='table table-striped table-hover table-bordered' id='tblDepartment'>
                                            <tbody></tbody>
                                        </table>
                                    </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>
                </div>
            </div>
            <script>
                function openNav() {
                    document.getElementById("mySidenav").style.width = "344px";
                }

                function closeNav() {
                    document.getElementById("mySidenav").style.width = "0";
                }
            </script>
        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>
