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

<asp:Content ID="Content1" ContentPlaceHolderID="CP" runat="Server">
    <script src="../../App_Themes/mis_db/JavaScript/jquery-3.3.1.min.js"></script>
       <script>
           var OrgGroupId = 0;
           var Count = 0;
           var drpOrgGroup = '';
           var drpBatch = '';
           var OrgBatchId = 0;
           var StatusId;
           var DeptRole1;
           var CommonOrgGroupBatchId = 0
           $(document).ready(function () {
               var myurl = window.location.href;
               var url = decodeURIComponent(myurl);
               console.log(url);
               var keyval = myurl.split('?')[1].split('&');
               var click = "",sourcetypeId="";
               OrgGroupId = parseInt(keyval[0].split('=')[1].toString());
               CommonOrgGroupBatchId = parseInt(keyval[1].split('=')[1].toString());
               BookDetailsDataBind();
               
              // ReceiptBookCollectionDataBind();
               $(document).on("change", "#drpDeptRole", function (e) {
                   DeptRole($("#hdnclick").val(), OrgGroupId, $("#hdnSource").val())
               });
           });
           function OrgGroupNameGet()
           {
               var OrgGroup = {};
               OrgGroup.attend = [];
               $.ajax({
                   type: "POST",
                   url: "ConsolidateReceiptDetailsDashBoard.aspx/GetOrgDropDownList",
                   data: JSON.stringify({ "OrgGroupId": parseInt(OrgGroupId) }),
                   contentType: "application/json; charset=utf-8",
                   dataType: "json",
                   success: function (result) {
                       drpOrgGroup = (result.d);
                       $("#drpOrganization").html(drpOrgGroup);
                        CurrentBatchGet();
                   },
                   error: function (xhr, status, error) {
                       var err = eval("(" + xhr.responseText + ")");
                       console.log(err.Message);
                   }    
               });
           }
           function OrganizationFunction() {

               OrgGroupId = $("#drpOrganization").val();
              // $("#drpOrganization").val(OrgGroupId);
               CurrentBatchGet();
               }
           function CurrentBatchGet() {
               $.ajax({
                   type: "POST",
                   url: "ConsolidateReceiptDetailsDashBoard.aspx/GetBatch",
                   data: JSON.stringify({ "OrgGroupId": parseInt(OrgGroupId) }),
                   contentType: "application/json; charset=utf-8",
                   dataType: "json",
                   success: function (result) {
                       drpBatch = (result.d);
                      // OrgBatchId = $("#drpBatch").val();
                       
                       $("#drpBatch").html(drpBatch);
                        
                       
                        //alert(OrgBatchId);
                        
                   },
                   error: function (xhr, status, error) {
                       var err = eval("(" + xhr.responseText + ")");
                       console.log(err.Message);
                   }
               });
           }
           function BookDetailsDataBind() {
               //$("#LoaderDiv1").show();
               $.ajax({
                   //async: false,
                   type: "POST",
                   url: "SummariseLibrarySummaryDashBoard.aspx/BookDetailsDataBind",
                   data: JSON.stringify({ "OrgGroupId": parseInt(OrgGroupId) ,"CommonOrgGroupBatchId": parseInt(CommonOrgGroupBatchId)}),
                   contentType: "application/json; charset=utf-8",
                   dataType: "json",
                   success: function (result) {
                       var obj = (result.d);
                       var tblBookDetails = "";
                       var total = 0;
                       if (obj != "") {
                           tblBookDetails += "<tr><th>Status</th><th>Count</th></tr>";
                           $.each(obj, function (i, item) {
                               tblBookDetails += "<tr><td>" + item.Title + "</td><td>" + item.Count + "</td></tr>";
                               total += parseInt(item.Count);
                           });
                           tblBookDetails += "<tr><td style='font-weight:bold'>Total</td><td style='font-weight:bold'>" + total + "</td></tr>";
                       }
                       else { tblBookDetails += "<tr><td colspan='8' class='record'>No records found..!!</td></tr>"; }
                       document.getElementById("tblBookDetails").innerHTML = tblBookDetails;
                   },
                   complete: function () {
                       $("#UserSummaryLoader").hide();
                   },
                   error: function (xhr, status, error) {
                       var err = eval("(" + xhr.responseText + ")");
                       console.log(err.Message);
                       $("#LoaderDiv1").hide();
                   }
               });
           }
           function TypeDetailsUserSummary(a, OrgGroupId, SourceTypeId) {
               $("#hdnclick").val(a);
               $("#hdnSource").val(SourceTypeId);
               var tblTypeDetailsUserSummary = "";
               if (SourceTypeId == 2003) {
                   tblTypeDetailsUserSummary += "<tr><th>ClassDivision</th><th>Count</th></tr>";
               }
               else {
                   tblTypeDetailsUserSummary += "<tr><th><select id='drpDeptRole' class='form-control''><option selected='selected' value='1' >Department</option><option value='2'>Role</option></select></th><th>Count</th></tr>";
               }
               var DeptRole1 = 1;
               debugger;
               $.ajax({
                   type: "POST",
                   url: "SummariseUserSummaryDashBoard.aspx/TypeDetailsUserSummaryDataBind",
                   data: JSON.stringify({ "OrgGroupId": parseInt(OrgGroupId), "SourceTypeId": parseInt(SourceTypeId), "DeptRole": DeptRole1,"CommonOrgGroupBatchId": parseInt(CommonOrgGroupBatchId) }),
                   contentType: "application/json; charset=utf-8",
                   dataType: "json",
                   success: function (result) {
                       var obj = (result.d);
                      
                       if (obj != "") {
                          
                           $.each(obj, function (i, item) {
                               if (SourceTypeId == 2003) {
                                       if (a == 1)
                                       { tblTypeDetailsUserSummary += "<tr><td>" + item.ClassDivision + "</td><td><a onclick='DetailsUserSummary(1," + OrgGroupId + ",\"" + SourceTypeId + "\",\"" + item.DivisionId + "\",\"" + DeptRole1 + "\")'>" + item.RegisteredUsers + "</a></td></tr>"; }
                                       else
                                       { tblTypeDetailsUserSummary += "<tr><td>" + item.ClassDivision + "</td><td><a onclick='DetailsUserSummary(2," + OrgGroupId + ",\"" + SourceTypeId + "\",\"" + item.DivisionId + "\",\"" + DeptRole1 + "\")'>" + item.UnRegisteredUsers + "</a></td></tr>"; }
                                   }
                               else
                               {
                                   if (DeptRole1 == 1) {
                                       if (a == 1)
                                       { tblTypeDetailsUserSummary += "<tr><td>" + item.DepatmentName + "</td><td><a onclick='DetailsUserSummary(1," + OrgGroupId + ",\"" + SourceTypeId + "\",\"" + item.DepatmentId + "\",\"" + DeptRole1 + "\")'>" + item.RegisteredUsers + "</a></td></tr>"; }
                                       else
                                       { tblTypeDetailsUserSummary += "<tr><td>" + item.DepatmentName + "</td><td><a onclick='DetailsUserSummary(2," + OrgGroupId + ",\"" + item.SourceTypeId + "\",\"" + item.DepatmentId + "\",\"" + DeptRole1 + "\")'>" + item.UnRegisteredUsers + "</a></td></tr>"; }
                                   }
                                   else
                                   {
                                       if (a == 1)
                                       { tblTypeDetailsUserSummary += "<tr><td>" + item.RoleName + "</td><td><a onclick='DetailsUserSummary(1," + OrgGroupId + ",\"" + SourceTypeId + "\",\"" + item.RoleId + "\",\"" + DeptRole1 + "\")'>" + item.RegisteredUsers + "</a></td></tr>"; }
                                       else
                                       { tblTypeDetailsUserSummary += "<tr><td>" + item.RoleName + "</td><td><a onclick='DetailsUserSummary(2," + OrgGroupId + ",\"" + SourceTypeId + "\",\"" + item.RoleId + "\",\"" + DeptRole1 + "\")'>" + item.UnRegisteredUsers + "</a></td></tr>"; }
                                   }
                               }
                               
                               //total += parseInt(item.StudentCount);
                           });
                           //tblFeeStatus += "<tr><td style='font-weight:bold'>Total</td><td style='font-weight:bold'>" + total + "</td></tr>";
                       }
                       else { tblReceiptDetail += "<tr><td colspan='8' class='record'>No records found..!!</td></tr>"; }
                       document.getElementById("tblTypeDetailsUserSummary").innerHTML = tblTypeDetailsUserSummary;
                       document.getElementById("TypeWiseUserSummaryHead").style.display = "none";
                       document.getElementById("TypeDetailsUserSummaryHead").style.display = "block";
                       StatusId = 1
                       DeptRole1 = $("#drpDeptRole").val();
                      // $("#LoaderDiv1").hide();
                       // console.log(Header);
                   },
                   error: function (xhr, status, error) {
                       var err = eval("(" + xhr.responseText + ")");
                       console.log(err.Message);
                      // $("#LoaderDiv1").hide();
                   }
               });
           }
           function DetailsUserSummary(a, OrgGroupId, SourceTypeId, FinalId, DeptRole1) {
               $.ajax({
                   type: "POST",
                   url: "SummariseUserSummaryDashBoard.aspx/DetailsUserSummaryDataBind",
                   data: JSON.stringify({ "OrgGroupId": parseInt(OrgGroupId), "SourceTypeId": parseInt(SourceTypeId), "DeptRole": DeptRole1, "CommonOrgGroupBatchId": parseInt(CommonOrgGroupBatchId), "FinalId": parseInt(FinalId) }),
                   contentType: "application/json; charset=utf-8",
                   dataType: "json",
                   success: function (result) {
                       var obj = (result.d);
                       var tblDetailsUserSummary = "";
                       if (obj != "") {                           
                           tblDetailsUserSummary += "<tr><th>Id</th><th>Name</th><th>Contact</th></tr>";
                           $.each(obj, function (i, item) {
                               if (SourceTypeId == 2003) {
                                   if (a == 1)
                                   { if (item.RegisteredUsers == 1) { tblDetailsUserSummary += "<tr><td>" + item.Id + "</td><td>" + item.Name + "</td><td>" + item.Contact + "</td></tr>"; } }
                                   else
                                   { if (item.UnRegisteredUsers == 1) { tblDetailsUserSummary += "<tr><td>" + item.Id + "</td><td>" + item.Name + "</td><td>" + item.Contact + "</td></tr>"; } }
                               }
                               else {
                                   if (DeptRole == 1) {
                                       if (a == 1)
                                       { if (item.RegisteredUsers == 1) { tblDetailsUserSummary += "<tr><td>" + item.Id + "</td><td>" + item.Name + "</td><td>" + item.Contact + "</td></tr>"; } }
                                       else
                                       { if (item.UnRegisteredUsers == 1) { tblDetailsUserSummary += "<tr><td>" + item.Id + "</td><td>" + item.Name + "</td><td>" + item.Contact + "</td></tr>"; } }
                                   }
                                   else {
                                       if (a == 1 )
                                       { if (item.RegisteredUsers == 1) { tblDetailsUserSummary += "<tr><td>" + item.Id + "</td><td>" + item.Name + "</td><td>" + item.Contact + "</td></tr>"; } }
                                       else
                                       { if (item.UnRegisteredUsers == 1) { tblDetailsUserSummary += "<tr><td>" + item.Id + "</td><td>" + item.Name + "</td><td>" + item.Contact + "</td></tr>"; } }
                                   }
                               }

                               //total += parseInt(item.StudentCount);
                           });
                           //tblFeeStatus += "<tr><td style='font-weight:bold'>Total</td><td style='font-weight:bold'>" + total + "</td></tr>";
                       }
                       else { tblDetailsUserSummary += "<tr><td colspan='8' class='record'>No records found..!!</td></tr>"; }
                       document.getElementById("tblDetailsUserSummary").innerHTML = tblDetailsUserSummary;
                       document.getElementById("TypeWiseUserSummaryHead").style.display = "none";
                       document.getElementById("TypeDetailsUserSummaryHead").style.display = "none";
                       document.getElementById("DetailsUserSummaryHead").style.display = "block";
                       StatusId = 2
                       // $("#LoaderDiv1").hide();
                       // console.log(Header);
                   },
                   error: function (xhr, status, error) {
                       var err = eval("(" + xhr.responseText + ")");
                       console.log(err.Message);
                       // $("#LoaderDiv1").hide();
                   }
               });
           }
           function DeptRole(a, OrgGroupId, SourceTypeId)
           {
               var tblTypeDetailsUserSummary = "";
               tblTypeDetailsUserSummary += "<tr id ='DroopdownList'><th><select id='drpDeptRole' class='form-control'><option value='1' >Department</option><option value='2'>Role</option></select></th><th>Count</th></tr>";
               var DeptRole1 = $('#drpDeptRole').val();
               $.ajax({
                   type: "POST",
                   url: "SummariseUserSummaryDashBoard.aspx/TypeDetailsUserSummaryDataBind",
                   data: JSON.stringify({ "OrgGroupId": parseInt(OrgGroupId), "SourceTypeId": parseInt(SourceTypeId), "DeptRole": DeptRole1, "CommonOrgGroupBatchId": parseInt(CommonOrgGroupBatchId) }),
                   contentType: "application/json; charset=utf-8",
                   dataType: "json",
                   success: function (result) {
                       var obj = (result.d);
                       if (obj != "") {
                           $.each(obj, function (i, item) {
                               if (SourceTypeId == 2003) {
                                   if (a == 1)
                                   { tblTypeDetailsUserSummary += "<tr><td>" + item.ClassDivision + "</td><td><a onclick='DetailsUserSummary(1," + OrgGroupId + ",\"" + SourceTypeId + "\",\"" + item.DivisionId + "\",\"" + DeptRole1 + "\")'>" + item.RegisteredUsers + "</a></td></tr>"; }
                                   else
                                   { tblTypeDetailsUserSummary += "<tr><td>" + item.ClassDivision + "</td><td><a onclick='DetailsUserSummary(2," + OrgGroupId + ",\"" + SourceTypeId + "\",\"" + item.DivisionId + "\",\"" + DeptRole1 + "\")'>" + item.UnRegisteredUsers + "</a></td></tr>"; }
                               }
                               else {
                                   if (DeptRole1 == 1) {
                                       if (a == 1)
                                       { tblTypeDetailsUserSummary += "<tr><td>" + item.DepatmentName + "</td><td><a onclick='DetailsUserSummary(1," + OrgGroupId + ",\"" + SourceTypeId + "\",\"" + item.DepatmentId + "\",\"" + DeptRole1 + "\")'>" + item.RegisteredUsers + "</a></td></tr>"; }
                                       else
                                       { tblTypeDetailsUserSummary += "<tr><td>" + item.DepatmentName + "</td><td><a onclick='DetailsUserSummary(2," + OrgGroupId + ",\"" + item.SourceTypeId + "\",\"" + item.DepatmentId + "\",\"" + DeptRole1 + "\")'>" + item.UnRegisteredUsers + "</a></td></tr>"; }
                                   }
                                   else {
                                       if (a == 1)
                                       { tblTypeDetailsUserSummary += "<tr><td>" + item.RoleName + "</td><td><a onclick='DetailsUserSummary(1," + OrgGroupId + ",\"" + SourceTypeId + "\",\"" + item.RoleId + "\",\"" + DeptRole1 + "\")'>" + item.RegisteredUsers + "</a></td></tr>"; }
                                       else
                                       { tblTypeDetailsUserSummary += "<tr><td>" + item.RoleName + "</td><td><a onclick='DetailsUserSummary(2," + OrgGroupId + ",\"" + SourceTypeId + "\",\"" + item.RoleId + "\",\"" + DeptRole1 + "\")'>" + item.UnRegisteredUsers + "</a></td></tr>"; }
                                   }
                               }
                               //total += parseInt(item.StudentCount);
                              
                           });
                           
                           //tblFeeStatus += "<tr><td style='font-weight:bold'>Total</td><td style='font-weight:bold'>" + total + "</td></tr>";
                       }
                       else { tblReceiptDetail += "<tr><td colspan='8' class='record'>No records found..!!</td></tr>"; }
                       document.getElementById("tblTypeDetailsUserSummary").innerHTML = tblTypeDetailsUserSummary;
                       document.getElementById("TypeWiseUserSummaryHead").style.display = "none";
                       document.getElementById("TypeDetailsUserSummaryHead").style.display = "block";
                       StatusId = 1
                       $('#drpDeptRole').val(DeptRole1);
                       // $("#LoaderDiv1").hide();
                       // console.log(Header);
                   },
                   error: function (xhr, status, error) {
                       var err = eval("(" + xhr.responseText + ")");
                       console.log(err.Message);
                       // $("#LoaderDiv1").hide();
                   }
               });
           }
           function BackOrgFunction() {
               if (StatusId == 2) {
                   document.getElementById("TypeWiseUserSummaryHead").style.display = "none";
                   document.getElementById("TypeDetailsUserSummaryHead").style.display = "block";
                   document.getElementById("DetailsUserSummaryHead").style.display = "none";
                   StatusId--;
               }
               else if (StatusId == 1) {
                   document.getElementById("TypeWiseUserSummaryHead").style.display = "block";
                   document.getElementById("TypeDetailsUserSummaryHead").style.display = "none";
                   StatusId--;
               } else { window.location.href = "../MobileView/SummariseDashBoard.aspx"; }
           }
           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">Summaries 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">
                        <%--<input type="button" value="Back" id="bntBack1" onclick="BackFunction1()" style="display:none" />
                        <input type="button" value="Back" id="bntBack2" onclick="BackFunction2()" style="display:none" />--%>
                        <div class="himssuHeader1WireBox col-md-12 pTop5" id="BookDetailsHead" >
                            <h3 class="table-topic">Book Details</h3>
                            <%-- <asp:PlaceHolder ID="DepartMentPlaceHolder" runat="server" /> --%>
                            <div class='himsBoxContent'>
                                <div class='table-responsive'>
                                    <input type="hidden" id="hdnclick" />
                                    <input type="hidden" id="hdnSource" />
                                    <table id='tblBookDetails' class='table table-striped table-bordered'>
                                    </table>
                                </div>
                            </div>
                            <div class="se-pre-con" id="LoaderDiv1" style="display:none"></div>
                        </div>
                        <div class="himssuHeader1WireBox col-md-12 pTop5" id="TypeDetailsUserSummaryHead" style="display:none">
                            <h3 class="table-topic">Type Details User Summary</h3>
                            <%-- <asp:PlaceHolder ID="DepartMentPlaceHolder" runat="server" /> --%>
                            <div class='himsBoxContent'>
                                <div class='table-responsive'>
                                       <table id='tblDropdown' class='table table-striped table-bordered mb-0'>
                                    </table>
                                    <table id='tblTypeDetailsUserSummary' class='table table-striped table-bordered'>
                                    </table>
                                </div>
                            </div>
                        </div>
                        <div class="himssuHeader1WireBox col-md-12 pTop5" id="DetailsUserSummaryHead" style="display: none">
                            <h3 class="table-topic">Details User Summary</h3>
                            <%-- <asp:PlaceHolder ID="DepartMentPlaceHolder" runat="server" /> --%>
                            <div class='himsBoxContent'>
                                <div class='table-responsive'>
                                    <table id='tblDetailsUserSummary' class='table table-striped table-bordered'>
                                    </table>
                                </div>
                            </div>
                        </div>
                        <div class="himssuHeader1WireBox col-md-12 pTop5" id="DivisionHead" style="display: none">
                            <h3 class="table-topic">Division Wise Student</h3>
                            <%-- <asp:PlaceHolder ID="DepartMentPlaceHolder" runat="server" /> --%>
                            <div class='himsBoxContent'>
                                <div class='table-responsive'>
                                    <table id='tblDivision' class='table table-striped table-bordered'>
                                    </table>
                                </div>
                            </div>
                        </div>
                        <div class="himssuHeader1WireBox col-md-12 pTop5" id="StudentHead" style="display: none">
                            <h3 class="table-topic">Student List </h3>
                            <%-- <asp:PlaceHolder ID="DepartMentPlaceHolder" runat="server" /> --%>
                            <div class='himsBoxContent'>
                                <div class='table-responsive'>
                                    <table id='tblstudent' class='table table-striped table-bordered'>
                                    </table>
                                </div>
                            </div>
                        </div>
                        <%--   <input type="hidden" id="Departmentid" runat="server" />
                         <input type="hidden" id="ClassHiddenId" runat="server" />
                         <input type="hidden" id="DivisionHiddenId" runat="server" />--%>
                    </div>
                </div>
            </div>



        </ContentTemplate>
    </asp:UpdatePanel>
 
</asp:Content>
