    <%@ page language="C#" autoeventwireup="true" inherits="Pages_MobileView_Default, App_Web_4u5j5kw0" 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());
               TypeWiseUserSummaryDataBind();
               
              // 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 TypeWiseUserSummaryDataBind() {
               //$("#LoaderDiv1").show();
               $.ajax({
                   //async: false,
                   type: "POST",
                   url: "SummariseUserSummaryDashBoard.aspx/TypeWiseUserSummaryDataBind",
                   data: JSON.stringify({ "OrgGroupId": parseInt(OrgGroupId) }),
                   contentType: "application/json; charset=utf-8",
                   dataType: "json",
                   success: function (result) {
                       var obj = (result.d);
                       var tblTypeWiseUserSummary = "";
                       var total = 0;
                       var RegisteredUsers = 0;
                       var UnRegisteredUsers = 0;
                       if (obj != "") {
                           tblTypeWiseUserSummary += "<tr><th>Type</th><th>User Count</th><th>RegisteredUsers</th><th>UnRegisteredUsers</th></tr>";
                           $.each(obj, function (i, item) {
                               if (item.SourceTypeId == 2003 || item.SourceTypeId == 95)
                               {
                                   tblTypeWiseUserSummary += "<tr><td>" + item.SourceType + "</td><td>" + item.UserCount + "</td><td><a onclick='TypeDetailsUserSummary(1," + OrgGroupId + ",\"" + item.SourceTypeId + "\")'>" + item.RegisteredUsers + "</a></td><td><a onclick='TypeDetailsUserSummary(2," + OrgGroupId + ",\"" + item.SourceTypeId + " \")'>" + item.UnRegisteredUsers + "</a></td></tr>";
                               }
                               else
                               { tblTypeWiseUserSummary += "<tr><td>" + item.SourceType + "</td><td>" + item.UserCount + "</td><td>" + item.RegisteredUsers + "</td><td>" + item.UnRegisteredUsers + "</td></tr>"; }
                               total += parseInt(item.UserCount);
                               RegisteredUsers +=  parseInt(item.RegisteredUsers);
                               UnRegisteredUsers += parseInt(item.UnRegisteredUsers);
                           });
                           tblTypeWiseUserSummary += "<tr><td style='font-weight:bold'>Total</td><td style='font-weight:bold'>" + total + "</td><td style='font-weight:bold'>" + RegisteredUsers + "</td><td style='font-weight:bold'>" + UnRegisteredUsers + "</td></tr>";
                       }
                       else { tblTypeWiseUserSummary += "<tr><td colspan='8' class='record'>No records found..!!</td></tr>"; }
                       document.getElementById("tblTypeWiseUserSummary").innerHTML = tblTypeWiseUserSummary;
                   },
                   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),"Count":parseInt(a) }),
                   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 { tblTypeDetailsUserSummary += "<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": parseInt(DeptRole1), "CommonOrgGroupBatchId": parseInt(CommonOrgGroupBatchId), "FinalId": parseInt(FinalId),"Count":parseInt(a)  }),
                   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)
                                       {
                                           alert(item.RegisteredUsers); if (parseInt(item.RegisteredUsers) == 1) {
                                               alert(item.Id);
                                               alert(item.Name);
                                               alert(item.Contact);
                                               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),"Count":parseInt(a) }),
                   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">Summary 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="TypeWiseUserSummaryHead" >
                            <h3 class="table-topic">Type Wise User Summary</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='tblTypeWiseUserSummary' 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>
