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

           $(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 = 2;
               Type = 'StatusOrgGroupWise';
               AdmissionStatusStudentDataBind(OrgGroupId, TypeId, Type);
           });

           function AdmissionStatusStudentDataBind(OrgGroupId, TypeId, Type) {
               $.ajax({
                   type: "POST",
                   url: "ConsolidateOverallInquiryStatusDashBoard.aspx/AdmissionStatusOverallGet",
                   data: JSON.stringify({ "OrgGroupId": parseInt(OrgGroupId), "TypeId": 2, "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='ClassWiseStatus(" + item.OrgId + "," + item.InquiryStatusId + "," + item.InquiryMainStatusId + ")'>" + item.StatusCount + "</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;
                       statusId = 0;
                   }
               });
           }
           function ClassWiseStatus(OrgId, InquiryStatusId, InquiryMainStatusId)
           {
               $.ajax({
                   type: "POST",
                   url: "ConsolidateOverallInquiryStatusDashBoard.aspx/ClssWiseStatusGet",
                   data: JSON.stringify({ "OrgGroupId": parseInt(OrgGroupId), "CommonOrgGroupBatchId": parseInt(CommonOrgGroupBatchId), "OrgId": parseInt(OrgId),"InquiryStatusId":parseInt(InquiryStatusId),"InquiryMainStatusId":parseInt(InquiryMainStatusId) }),
                   contentType: "application/json; charset=utf-8",
                   dataType: "json",
                   success: function (result) {
                       var obj = (result.d);
                       var total = 0;
                       var tblClassWiseStatus = "";
                       if (obj != "") {
                           tblClassWiseStatus += "<tr><th>Class</th><th>Count</th></tr>";
                           $.each(obj, function (i, item) {
                               // alert(item.DepartmentName);
                               tblClassWiseStatus += "<tr><td>" + item.ClassName + "</a></td><td><a onclick='StudentListGet(" + item.ClassId + "," + OrgId + "," + InquiryStatusId + "," + InquiryMainStatusId + ") '>" + item.StatusCount + "</td></tr>";
                               total += parseInt(item.StatusCount);
                           });
                           tblClassWiseStatus += "<tr><td style='font-weight:bold'>Total</td><td style='font-weight:bold'>" + total + "</td></tr>";
                       }
                       else { tblClassWiseStatus += "<tr><td colspan='8' class='record'>No records found..!!</td></tr>"; }
                       // alert(obj);
                       document.getElementById("tblClassWiseStatus").innerHTML = tblClassWiseStatus;
                       document.getElementById("ClassWiseHead").style.display = "block";
                       document.getElementById("AdmissionCountOrgHead").style.display = "none";
                       statusId = 1;
                   }
               });
           }

           function StudentListGet(ClassId, OrgId, InquiryStatusId, InquiryMainStatusId)
           {
               $.ajax({
                   type: "POST",
                   url: "ConsolidateOverallInquiryStatusDashBoard.aspx/StudentListGet",
                   data: JSON.stringify({ "OrgGroupId": parseInt(OrgGroupId), "CommonOrgGroupBatchId": parseInt(CommonOrgGroupBatchId), "OrgId": parseInt(OrgId), "InquiryStatusId": parseInt(InquiryStatusId), "ClassId": parseInt(ClassId), "InquiryMainStatusId": parseInt(InquiryMainStatusId) }),
                   contentType: "application/json; charset=utf-8",
                   dataType: "json",
                   success: function (result) {
                       var obj = (result.d);
                       var total = 0;
                       var tblStudentList = "";
                       if (obj != "") {
                           tblStudentList += "<tr><th>Inquiry Id</th><th>Student Name</th><th>Contact No</th></tr>";
                           $.each(obj, function (i, item) {
                               // alert(item.DepartmentName);
                               tblStudentList += "<tr><td>" + item.InquiryId + "</a></td><td>" + item.StudentName + "</td><td>" + item.ContactNo + "</td></tr>";
                               //total += parseInt(item.StatusCount);
                           });
                           //tblStudentList += "<tr><td style='font-weight:bold'>Total</td><td style='font-weight:bold'>" + total + "</td></tr>";
                       }
                       else { tblStudentList += "<tr><td colspan='8' class='record'>No records found..!!</td></tr>"; }
                       // alert(obj);
                       document.getElementById("tblStudentList").innerHTML = tblStudentList;
                       document.getElementById("StduentWiseHead").style.display = "block";
                       document.getElementById("ClassWiseHead").style.display = "none";
                       document.getElementById("AdmissionCountOrgHead").style.display = "none";
                       statusId = 2;
                   }
               });
           }
           function BackOrgFunction() {
               if (statusId == 1) {
                   document.getElementById("StduentWiseHead").style.display = "none";
                   document.getElementById("ClassWiseHead").style.display = "none";
                   document.getElementById("AdmissionCountOrgHead").style.display = "block";
                   statusId--;
               }
               else if (statusId == 2) {
                   document.getElementById("StduentWiseHead").style.display = "none";
                   document.getElementById("ClassWiseHead").style.display = "block";
                   document.getElementById("AdmissionCountOrgHead").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 Inquiry 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="ClassWiseHead" style="display: none">
                            <h3 class="table-topic">Admission Inquiry class Wise</h3>
                            <div class='himsBoxContent pTop5'>
                                <div class='table-responsive'>
                                    <table id='tblClassWiseStatus' class='table table-striped table-bordered'>
                                    </table>
                                </div>
                            </div>
                        </div>
                           <div class="himssuHeader1WireBox col-md-12 pTop5" id="StduentWiseHead" style="display: none">
                            <h3 class="table-topic">Student List</h3>
                            <div class='himsBoxContent pTop5'>
                                <div class='table-responsive'>
                                    <table id='tblStudentList' class='table table-striped table-bordered'>
                                    </table>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </ContentTemplate>
    </asp:UpdatePanel>
 
</asp:Content>
