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

<asp:Content ID="Content1" ContentPlaceHolderID="CP" runat="Server">
       <script>
           var OrgGroupId = 0;
           var Count = 0;
           var drpOrgGroup = '';
           var drpBatch = '';
           var OrgBatchId = 0;
           var StatusId;
           $(document).ready(function () {
               var myurl = window.location.href;
               var url = decodeURIComponent(myurl);
               console.log(url);
               var keyval = myurl.split('?')[1].split('&');
               OrgGroupId = parseInt(keyval[0].split('=')[1].toString());
               Count = parseInt(keyval[1].split('=')[1].toString());
               CommonOrgGroupBatchId = parseInt(keyval[2].split('=')[1].toString());
               FromDate = keyval[3].split('=')[1].toString();
               ToDate = keyval[4].split('=')[1].toString();
             //  OrgGroupNameGet();
               //CurrentBatchGet();
               //var tblDropdown = "<tr><th style='width: 65.3%;'><select id='drpOrganization' class='form-control' onchange='OrganizationFunction()'><option value='0'>Select</option></select></th><th><select id='drpBatch' class='form-control' onchange='BatchFunction()'><option value='0'>Select</option></select></th></tr>";
               // document.getElementById("tblDropdown").innerHTML = tblDropdown;
              
               ReceiptBookCollectionDataBind();
               
              // ReceiptBookCollectionDataBind();


           });
           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 BatchFunction() {
               
               OrgBatchId = $("#drpBatch").val();
              // $("#drpBatch").val(OrgBatchId);
               ReceiptBookCollectionDataBind();
           }
           function ReceiptBookCollectionDataBind() {
               //$("#LoaderDiv1").show();
               $.ajax({
                   //async: false,
                   type: "POST",
                   url: "ConsolidateReceiptDetailsDashBoard.aspx/ReceiptBookCollectionDataBind",
                   data: JSON.stringify({ "OrgGroupId": parseInt(OrgGroupId), "OrgBatchId": parseInt(OrgBatchId), "CommonOrgGroupBatchId": CommonOrgGroupBatchId, "FromDate": FromDate, "ToDate": ToDate }),
                   contentType: "application/json; charset=utf-8",
                   dataType: "json",
                   success: function (result) {
                       var obj = (result.d);
                       var tblReceiptCollection = "";
                       
                       ///  var total = 0;
                       if (obj != "") {
                          // tblDropdown += "<thead><tr><th><select id='drpOrganization' onchange='OrganizationFunction()'><option value='0'>Select</option></select></th><th><select id='drpBatch' onchange='BatchFunction()'><option value='0'>Select</option></select></th></tr>";
                           if (Count == 1) { tblReceiptCollection += "<tr><th>ReceiptBook - Collection Group</th><th>Count</th></tr>"; }
                           if (Count == 2) { tblReceiptCollection += "<tr><th>ReceiptBook - Collection Group</th><th>Receipt Amount</th></tr>"; }
                           if (Count == 3) { tblReceiptCollection += "<tr><th>ReceiptBook - Collection Group</th><th>Cancel Amount</th></tr>"; }
                           $.each(obj, function (i, item) {
                               if (Count == 1)
                               { tblReceiptCollection += "<tr><td>" + item.ReceiptCollection + "</td><td><a onclick='ReceiptBookCollectionGroupDetailDataBind(" + item.ReceiptId + "," + item.CollectionGroupId + ")'>" + item.ReceiptCount + "</a></td></tr>"; }
                               else if (Count == 2)
                               { tblReceiptCollection += "<tr><td>" + item.ReceiptCollection + "</td><td><a onclick='ReceiptBookCollectionGroupDetailDataBind(" + item.ReceiptId + "," + item.CollectionGroupId + ")'>" + item.ReceiptAmount + "</a></td></tr>"; }
                               else if (Count == 3)
                               { tblReceiptCollection += "<tr><td>" + item.ReceiptCollection + "</td><td><a onclick='ReceiptBookCollectionGroupDetailDataBind(" + item.ReceiptId + "," + item.CollectionGroupId + ")'>" + item.CancelAmount + "</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 { tblReceiptCollection += "<tr><td colspan='8' class='record'>No records found..!!</td></tr>"; }
                       //document.getElementById("tblDropdown").innerHTML = tblDropdown;
                       document.getElementById("tblReceiptCollection").innerHTML = tblReceiptCollection;
                      
                      // OrgBatchId = $("#drpBatch").val();
                     // alert(OrgBatchId);
                       // console.log(Header);
                   },
                   error: function (xhr, status, error) {
                       var err = eval("(" + xhr.responseText + ")");
                       console.log(err.Message);
                       $("#LoaderDiv1").hide();
                   }
               });
           }
           function ReceiptBookCollectionGroupDetailDataBind(ReceiptBookId,CollectionGroupId) {
               //$("#LoaderDiv").show();
               $.ajax({
                   type: "POST",
                   url: "ConsolidateReceiptDetailsDashBoard.aspx/ReceiptBookCollectionGroupDetailDataBind",
                   data: JSON.stringify({ "OrgGroupId": parseInt(OrgGroupId), "OrgBatchId": parseInt(OrgBatchId), "ReceiptBookId": parseInt(ReceiptBookId), "CollectionGroupId": parseInt(CollectionGroupId) ,"CommonOrgGroupBatchId": CommonOrgGroupBatchId, "FromDate": FromDate, "ToDate": ToDate }),
                   contentType: "application/json; charset=utf-8",
                   dataType: "json",
                   success: function (result) {
                      //alert(result.d);
                       var obj = (result.d);
                       var tblReceiptDetail = "";
                       //  var total = 0;
                       if (obj != "") {
                           tblReceiptDetail += "<tr><th>Receipt No</th><th>Code</th><th>Name</th><th>Amount</th></tr>";
                           $.each(obj, function (i, item) {
                               console.log(item.IsObsolete);
                               if (Count == 1 || Count == 2 && item.IsObsolete == false)
                               { tblReceiptDetail += "<tr><td>" + item.ReceiptNumber + "</td><td>" + item.Code + "</td><td>" + item.Name + "</td><td>" + item.ReceiptAmount + "</td></tr>"; }
                               if (Count == 3 && item.IsObsolete == true)
                               { tblReceiptDetail += "<tr><td>" + item.ReceiptNumber + "</td><td>" + item.Code + "</td><td>" + item.Name + "</td><td>" + item.ReceiptAmount + "</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("tblReceiptDetail").innerHTML = tblReceiptDetail;
                       document.getElementById("ReceiptCollectionHead").style.display = "none";
                       document.getElementById("ReceiptDetailHead").style.display = "block";
                        StatusId =1
                      // $("#LoaderDiv1").hide();
                       // console.log(Header);
                   },
                   error: function (xhr, status, error) {
                       var err = eval("(" + xhr.responseText + ")");
                       console.log(err.Message);
                      // $("#LoaderDiv1").hide();
                   }
               });
           }
           //function CancelReceiptBookCollectionDataBind() {
           //    //$("#LoaderDiv1").show();
           //    $.ajax({
           //        //async: false,
           //        type: "POST",
           //        url: "ConsolidateReceiptDetailsDashBoard.aspx/CancelReceiptBookCollectionDataBind",
           //        data: JSON.stringify({ "OrgGroupId": parseInt(OrgGroupId), "OrgBatchId": parseInt(OrgBatchId) }),
           //        contentType: "application/json; charset=utf-8",
           //        dataType: "json",
           //        success: function (result) {
           //            var obj = (result.d);
           //            var tblReceiptDetail = "";
           //            ///  var total = 0;
           //            if (obj != "") {
           //               // tblDropdown += "<thead><tr><th><select id='drpOrganization' onchange='OrganizationFunction()'><option value='0'>Select</option></select></th><th><select id='drpBatch' onchange='BatchFunction()'><option value='0'>Select</option></select></th></tr>";
           //                tblReceiptDetail += "<tr><th>Receipt No</th><th>Code</th><th>Name</th><th>Amount</th></tr>";
           //                $.each(obj, function (i, item) {
           //                    tblReceiptDetail += "<tr><td>" + item.ReceiptNumber + "</td><td>" + item.Code + "</td><td>" + item.Name + "</td><td>" + item.ReceiptAmount + "</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("tblDropdown").innerHTML = tblDropdown;
           //            document.getElementById("tblReceiptDetail").innerHTML = tblReceiptDetail;
           //            document.getElementById("ReceiptCollectionHead").style.display = "none";
           //            document.getElementById("ReceiptDetailHead").style.display = "block";
           //            StatusId = 2
                      // OrgBatchId = $("#drpBatch").val();
                     // alert(OrgBatchId);
           //            // 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("ReceiptCollectionHead").style.display = "block";
                   document.getElementById("ReceiptDetailHead").style.display = "none";
                   StatusId--;
               }
               else if (StatusId == 1) {
                   document.getElementById("ReceiptCollectionHead").style.display = "block";
                   document.getElementById("ReceiptDetailHead").style.display = "none";
                   StatusId--;
               } else { window.location.href = "../MobileView/ConsolidateDashBoard.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">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">
                        <%--<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="ReceiptCollectionHead" >
                            <h3 class="table-topic">ReceiptBook - Collection Group</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='tblReceiptCollection' 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="ReceiptDetailHead" style="display:none">
                            <h3 class="table-topic">Receipt Detail</h3>
                            <%-- <asp:PlaceHolder ID="DepartMentPlaceHolder" runat="server" /> --%>
                            <div class='himsBoxContent'>
                                <div class='table-responsive'>
                                    <table id='tblReceiptDetail' class='table table-striped table-bordered'>
                                    </table>
                                </div>
                            </div>
                        </div>
                        <div class="himssuHeader1WireBox col-md-12 pTop5" id="CancelReceiptHead" style="display: none">
                            <h3 class="table-topic">Cancel Receipt</h3>
                            <%-- <asp:PlaceHolder ID="DepartMentPlaceHolder" runat="server" /> --%>
                            <div class='himsBoxContent'>
                                <div class='table-responsive'>
                                    <table id='tblcancelReceipt' 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>
