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

<asp:Content ID="Content1" ContentPlaceHolderID="CP" runat="Server">
    <script>

        var OrgGroupId
        var TypeId
        var CommonOrgGroupBatchId
        var FilterType
        $(document).ready(function () {
            var myurl = window.location.href;
            var keyval = myurl.split('?')[1].split('&');
            OrgGroupId = parseInt(keyval[0].split('=')[1].toString());
            CommonOrgGroupBatchId = parseInt(keyval[1].split('=')[1].toString());
            TypeId = 21;
            FilterType = $("#drpFilter").val();;
            //if (item.RoleDashletId == 71 && item.IsCheck == true) {
            //    document.getElementById("AdmissionCountOrgHead").style.display = "block";
            //}
            EmployeeSummaryStatuswiseDataBind(OrgGroupId, TypeId, FilterType, CommonOrgGroupBatchId);
        });


        function EmployeeSummaryStatuswiseDataBind(OrgGroupId, TypeId, FilterType, CommonOrgGroupBatchId) {
            debugger;
            $.ajax({
                type: "POST",
                url: "ConsolidateEmployeeSummaryStatusDashBoard.aspx/EmployeeSummaryDataGet",
                data: JSON.stringify({ "OrgGroupId": parseInt(OrgGroupId), "TypeId": 21, "FilterType": FilterType, "CommonOrgGroupBatchId": parseInt(CommonOrgGroupBatchId) }),
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (result) {
                    var obj = (result.d);
                    var tblEmployeesummaryOrgWise = "";

                    if (obj != "") {
                        tblEmployeesummaryOrgWise += "<tr><th>OrganizationDepartment</th><th>Total</th><th>Active</th></tr>";
                        $.each(obj, function (i, item) {
                            tblEmployeesummaryOrgWise += "<tr><td>" + item.OrganizationDepartment + "</a></td><td>" + item.Total + "</td><td>" + item.Active + "</td></tr>";
                        });

                    }
                    else { tblAdmissionCountOrgWise += "<tr><td colspan='8' class='record'>No records found..!!</td></tr>"; }
                    document.getElementById("tblEmployeeSummaryOrgWise").innerHTML = tblEmployeesummaryOrgWise;
                }
            });
        }
        function EmployeeSummaryGenderwiseDataBind(OrgGroupId, TypeId, FilterType, CommonOrgGroupBatchId) {
            $.ajax({
                type: "POST",
                url: "ConsolidateEmployeeSummaryStatusDashBoard.aspx/EmployeeSummaryDataGet",
                data: JSON.stringify({ "OrgGroupId": parseInt(OrgGroupId), "TypeId": 21, "FilterType": FilterType, "CommonOrgGroupBatchId": parseInt(CommonOrgGroupBatchId) }),
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (result) {
                    var obj = (result.d);
                    var tblEmployeesummaryOrgWise = "";

                    if (obj != "") {
                        tblEmployeesummaryOrgWise += "<tr><th>OrganizationDepartment</th><th>Male</th><th>Female</th></tr>";
                        $.each(obj, function (i, item) {
                            tblEmployeesummaryOrgWise += "<tr><td>" + item.OrganizationDepartment + "</a></td><td>" + item.Male + "</td><td>" + item.Female + "</td></tr>";
                        });

                    }
                    else { tblAdmissionCountOrgWise += "<tr><td colspan='8' class='record'>No records found..!!</td></tr>"; }
                    document.getElementById("tblEmployeeSummaryOrgWise").innerHTML = tblEmployeesummaryOrgWise;
                }
            });
        }
        function EmployeeSummaryGroupwiseDataBind(OrgGroupId, TypeId, FilterType, CommonOrgGroupBatchId) {
            $.ajax({
                type: "POST",
                url: "ConsolidateEmployeeSummaryStatusDashBoard.aspx/EmployeeSummaryDataGet",
                data: JSON.stringify({ "OrgGroupId": parseInt(OrgGroupId), "TypeId": 21, "FilterType": FilterType, "CommonOrgGroupBatchId": parseInt(CommonOrgGroupBatchId) }),
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (result) {
                    var obj = (result.d);
                    var tblEmployeesummaryOrgWise = "";

                    if (obj != "") {
                        tblEmployeesummaryOrgWise += "<tr><th>OrganizationDepartment</th><th>Teaching</th><th>NonTeaching</th></tr>";
                        $.each(obj, function (i, item) {
                            tblEmployeesummaryOrgWise += "<tr><td>" + item.OrganizationDepartment + "</a></td><td>" + item.Teaching + "</td><td>" + item.NonTeaching + "</td></tr>";
                        });

                    }
                    else { tblAdmissionCountOrgWise += "<tr><td colspan='8' class='record'>No records found..!!</td></tr>"; }
                    document.getElementById("tblEmployeeSummaryOrgWise").innerHTML = tblEmployeesummaryOrgWise;
                }
            });
        }
        function EmployeeSummaryTypewiseDataBind(OrgGroupId, TypeId, FilterType, CommonOrgGroupBatchId) {
            $.ajax({
                type: "POST",
                url: "ConsolidateEmployeeSummaryStatusDashBoard.aspx/EmployeeSummaryTypewiseDataGet",
                data: JSON.stringify({ "OrgGroupId": parseInt(OrgGroupId), "TypeId": 21, "FilterType": FilterType, "CommonOrgGroupBatchId": parseInt(CommonOrgGroupBatchId) }),
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (result) {
                    document.getElementById("tblEmployeeSummaryOrgWise").innerHTML = result.d;
                    //debugger;
                    //var obj = (result.d);
                    //var tblEmployeesummaryOrgWise = "";
                    //var EmployeeType = [];
                    //if (obj != "") {
                    //    tblEmployeesummaryOrgWise += "<tr><th>Organization</th>";

                         
                    //        var i;
                    //        if (EmployeeType.length == 0) {
                    //            tblEmployeesummaryOrgWise += "<th>" + obj[0].EmployeeType + "</th>";
                    //            EmployeeType.push(obj[0].EmployeeType);
                    //        }
                            
                    //        for (i = 1; i < obj.length; i++) {
                    //            var Count = 0;
                    //            for (j = 1; j <= EmployeeType.length; j++) {
                    //                if (EmployeeType[j] == obj[i].EmployeeType) {
                    //                    Count++;
                    //                }
                    //            }
                    //            if (Count == 0) {
                    //                tblEmployeesummaryOrgWise += "<th>" + obj[i].EmployeeType + "</th>";
                    //                EmployeeType.push(obj[i].EmployeeType);
                    //            }
                                
                    //        }
                    //        tblEmployeesummaryOrgWise += "</tr>";
                        
                    //    $.each(obj, function (i, item) {
                    //        tblEmployeesummaryOrgWise += "<tr><td>" + item.OrgName + "</a></td><td>" + item.Teaching + "</td><td>" + item.NonTeaching + "</td></tr>";
                    //    });

                    //}
                    //else { tblAdmissionCountOrgWise += "<tr><td colspan='8' class='record'>No records found..!!</td></tr>"; }
                    //document.getElementById("tblEmployeeSummaryOrgWise").innerHTML = tblEmployeesummaryOrgWise;
                }
            });
        }
        function drpFilterFunction() {
            //debugger;
            $("#tblEmployeeSummaryOrgWise").html('');
            FilterType = $("#drpFilter").val();

            $("#FeeStatusLoader").css("display", "block");
            if (FilterType == 'Statuswise') {
                EmployeeSummaryStatuswiseDataBind(OrgGroupId, TypeId, FilterType, CommonOrgGroupBatchId);
            }
            else if (FilterType == 'Genderwise') {
                EmployeeSummaryGenderwiseDataBind(OrgGroupId, TypeId, FilterType, CommonOrgGroupBatchId);
            }
            else if (FilterType == 'EmployeeGroupwise') {
                EmployeeSummaryGroupwiseDataBind(OrgGroupId, TypeId, FilterType, CommonOrgGroupBatchId);
            }
            else if (FilterType == 'EmployeeTypewise') {
                EmployeeSummaryTypewiseDataBind(OrgGroupId, TypeId, FilterType, CommonOrgGroupBatchId);
            }
        }
        function BackOrgFunction() { window.location.href = "../MobileView/ConsolidateDashBoard.aspx"; CurrentBatchGet(); }
        function DashBoard() { window.location.href = "../MobileView/DashBoard.aspx"; }
    </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 d-inline-flex">
                        <span class='btn btn-home btn-icon' onclick='DashBoard()' title='home'><span><i class='material-icons'>home</i></span></span>
                        <div class="d-inline-flex w-100">
                            <label class="header-topic justify-content-center" id="HeaderLabel">Consolidate DashBoard</label>
                        </div>
                        <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" id="HeaderTitle">
                    </div>
                </div>
            </div>

            <div class="bg-white row center-block">
                <div class="container-fluid">
                    <div class="gutters-tiny push js-appear-enabled animated fadeIn overflow-hidden" data-toggle="appear">
                        <div class="himssuHeader1WireBox col-md-12 pTop5" id="AdmissionCountOrgHead" style="display: block">
                            <h3 class="table-topic">Employee Summary</h3>

                            <div class="cBoth"></div>
                            <div class="custom-select width-17">
                                <div class='fLeft pRight5'>
                                    <select id='drpFilter' onchange="drpFilterFunction()">
                                        <option selected="selected" value='Statuswise'>Statuswise</option>
                                        <option value='Genderwise'>Genderwise</option>
                                        <option value='EmployeeGroupwise'>EmployeeGroupwise</option>
                                        <option value='EmployeeTypewise'>EmployeeTypewise</option>
                                    </select>
                                    &nbsp;&nbsp;<img id="ResultSummaryLoader" style="display: none; position: relative; left: 113%; top: -51px;" src="../../Images/Loading1.gif" />
                                </div>
                                <div class="cBoth"></div>
                            </div>
                            <div class="cBoth"></div>

                            <div class='table-responsive'>
                                <table id='tblEmployeeSummaryOrgWise' class='table table-striped table-bordered'>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

        </ContentTemplate>
    </asp:UpdatePanel>

</asp:Content>
