<%@ page language="C#" autoeventwireup="true" inherits="Pages_MobileView_Default, App_Web_pifj025g" 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 StatusId = 0;

        $(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());
            //alert(CommonOrgGroupBatchId);
            TypeId = 1;
            Type = 'StatusOrgGroupWise';

            AdmissionStatusStudentDataBind(OrgGroupId, TypeId, Type);
        });

        function AdmissionStatusStudentDataBind(OrgGroupId, TypeId, Type) {
            $.ajax({
                type: "POST",
                url: "ConsolidateAdmissionOrgGroupStatusDashBoard.aspx/AdmissionStatusOverallGet",
                data: JSON.stringify({ "OrgGroupId": parseInt(OrgGroupId), "TypeId": 1, "Type": 'StatusOrgGroupWise', "CommonOrgGroupBatchId": parseInt(CommonOrgGroupBatchId) }),
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (result) {
                    var obj = (result.d);
                    var tblAdmissionStatusCountOrgWise = "";
                    var totaladmissionorgwise = 0;
                    var alreadyAdded = [];
                    if (obj != "") {
                        tblAdmissionStatusCountOrgWise += "<tr><th>Inquiry Status</th><th>Count</th></tr>";
                        $.each(obj, function (j, item1) {

                            if (alreadyAdded.indexOf(item1.Organization) >= 0)
                            { }
                            else
                            {
                                tblAdmissionStatusCountOrgWise += "<tr><th colspan='9'>" + item1.Organization + "</th></tr>";
                                $.each(obj, function (i, item) {
                                    if (item.OrgId === item1.OrgId) {
                                        tblAdmissionStatusCountOrgWise += "<tr><td>" + item.Status + "</td><td><a onclick='AdmissionClassWise(" + item.InquiryStatusId + ",\"" + item.OrgId + "\")'>" + item.StatusCount + "</a></td></tr>";
                                        totaladmissionorgwise += parseInt(item.StatusCount);
                                    }
                                    else {
                                    }
                                });
                                alreadyAdded.push(item1.Organization);
                            }
                        });
                        tblAdmissionStatusCountOrgWise += "<tr><td style='font-weight:bold'>Total</td><td style='font-weight:bold'>" + totaladmissionorgwise + "</td></tr>";
                    }
                    else { tblAdmissionStatusCountOrgWise += "<tr><td colspan='8' class='record'>No records found..!!</td></tr>"; }
                    document.getElementById("tblAdmissionStatusCountOrgWise").innerHTML = tblAdmissionStatusCountOrgWise;
                }
            });
        }

        function AdmissionClassWise(InquiryStatusId, OrgId) {
            $.ajax({
                type: "POST",
                url: "ConsolidateAdmissionOrgGroupStatusDashBoard.aspx/AdmissionClassWise",
                data: JSON.stringify({ "OrgGroupId": parseInt(OrgGroupId), "TypeId": 1, "Type": 'StatusOrgGroupWise', "CommonOrgGroupBatchId": parseInt(CommonOrgGroupBatchId), "InquiryStatusId": parseInt(InquiryStatusId), "OrgId": parseInt(OrgId) }),
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (result) {
                    var obj = (result.d);
                    var tblAdmissionStatusCountClassWise = "";
                    var totaladmissionorgwise = 0;
                    var alreadyAdded = [];
                    if (obj != "") {
                        tblAdmissionStatusCountClassWise += "<tr><th>Class</th><th>Count</th></tr>";
                        $.each(obj, function (j, item) {

                               // tblAdmissionStatusCountClassWise += "<tr><th colspan='9'>" + item1.ClassName + "</th></tr>";
                           
                            tblAdmissionStatusCountClassWise += "<tr><td>" + item.ClassName + "</td><td><a onclick='AdmissionStudentWise(" + InquiryStatusId + ",\"" + OrgId + "\",\"" + item.ClassId + "\")'>" + item.StatusCount + "</a></td></tr>";
                                        totaladmissionorgwise += parseInt(item.StatusCount);
                                    
                        });
                        tblAdmissionStatusCountClassWise += "<tr><td style='font-weight:bold'>Total</td><td style='font-weight:bold'>" + totaladmissionorgwise + "</td></tr>";
                    }
                    else { tblAdmissionStatusCountOrgWise += "<tr><td colspan='8' class='record'>No records found..!!</td></tr>"; }
                    document.getElementById("tblAdmissionStatusCountClassWise").innerHTML = tblAdmissionStatusCountClassWise;
                    document.getElementById("AdmissionCountOrgHead").style.display = "none";
                    document.getElementById("AdmissionCountClassWise").style.display = "block";
                    StatusId = 2;

                }
            });
        }


        function AdmissionStudentWise(InquiryStatusId, OrgId, ClassId) {
            $.ajax({
                type: "POST",
                url: "ConsolidateAdmissionOrgGroupStatusDashBoard.aspx/AdmissionStudentWise",
                data: JSON.stringify({ "OrgGroupId": parseInt(OrgGroupId), "TypeId": 1, "Type": 'StatusOrgGroupWise', "CommonOrgGroupBatchId": parseInt(CommonOrgGroupBatchId), "InquiryStatusId": parseInt(InquiryStatusId), "OrgId": parseInt(OrgId),"ClassId":parseInt(ClassId) }),
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (result) {
                    var obj = (result.d);
                    var tblAdmissionStduntWise = "";
                    var totaladmissionorgwise = 0;
                    var alreadyAdded = [];
                    if (obj != "") {
                        tblAdmissionStduntWise += "<tr><th>Form</th><th>StudentName</th><th>ContactNo</th></tr>";
                        $.each(obj, function (j, item) {

                            // tblAdmissionStatusCountClassWise += "<tr><th colspan='9'>" + item1.ClassName + "</th></tr>";

                            tblAdmissionStduntWise += "<tr><td>" + item.InquiryId + "</td><td>" + item.StudentName + "</td><td>" + item.ContactNo + "</td></tr>";
                            //totaladmissionorgwise += parseInt(item.StatusCount);

                        });
                        //tblAdmissionStduntWise += "<tr><td style='font-weight:bold'>Total</td><td style='font-weight:bold'>" + totaladmissionorgwise + "</td></tr>";
                    }
                    else { tblAdmissionStduntWise += "<tr><td colspan='8' class='record'>No records found..!!</td></tr>"; }
                    document.getElementById("tblAdmissionStduntWise").innerHTML = tblAdmissionStduntWise;
                    document.getElementById("AdmissionCountOrgHead").style.display = "none";
                    document.getElementById("AdmissionCountClassWise").style.display = "none";
                    document.getElementById("AdmissionStduntWise").style.display = "block";
                    
                    StatusId = 2;

                }
            });
        }

        function BackOrgFunction() {
            if (StatusId == 2) {
                document.getElementById("AdmissionCountOrgHead").style.display = "none";
                document.getElementById("AdmissionStduntWise").style.display = "none";
                document.getElementById("AdmissionCountClassWise").style.display = "block";
                StatusId--;
            }
            else if (StatusId == 1) {
                document.getElementById("AdmissionStduntWise").style.display = "none";
                document.getElementById("AdmissionCountOrgHead").style.display = "block";
                document.getElementById("AdmissionCountClassWise").style.display = "none";
                StatusId--;
            }
            else { 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">Admission Status Summary</h3>
                            <div class='himsBoxContent pTop5'>
                                <div class='table-responsive'>
                                    <table id='tblAdmissionStatusCountOrgWise' class='table table-striped table-bordered'>
                                    </table>
                                </div>
                            </div>
                        </div>
                          <div class="himssuHeader1WireBox col-md-12 pTop5" id="AdmissionCountClassWise" style="display: none">
                            <h3 class="table-topic">Admission Class Wise</h3>
                            <div class='himsBoxContent pTop5'>
                                <div class='table-responsive'>
                                    <table id='tblAdmissionStatusCountClassWise' class='table table-striped table-bordered'>
                                    </table>
                                </div>
                            </div>
                        </div>
                            <div class="himssuHeader1WireBox col-md-12 pTop5" id="AdmissionStduntWise" style="display: none">
                            <h3 class="table-topic">Admission Stdunt Wise</h3>
                            <div class='himsBoxContent pTop5'>
                                <div class='table-responsive'>
                                    <table id='tblAdmissionStduntWise' class='table table-striped table-bordered'>
                                    </table>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </ContentTemplate>
    </asp:UpdatePanel>

</asp:Content>
