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

<asp:Content ID="Content1" ContentPlaceHolderID="CP" runat="Server">
    <script>
        var BatchId;
        var Header = [];
        var ReHeader;
        var statusId = 0;
        var BatchId = 0;
        var OrgId = 0;
        $(document).ready(function () {
            var myurl = window.location.href;
            var keyval = myurl.split('?')[1].split('&');
            BatchId = parseInt(keyval[0].split('=')[1].toString());
            OrgId = parseInt(keyval[1].split('=')[1].toString());
            GetOrgId();
        });

        function PageName() {

            window.location.href = "../MobileView/FeeDashBoard.aspx?OrgId=" + OrgId
        }
        function GetOrgId() {
            $.ajax({
                type: "POST",
                url: "ReceiptEntry.aspx/GetOrgId",
                data: JSON.stringify({ "OrgId": OrgId }),
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (result) {
                    var obj = (result.d);
                    Header[0] = "<h5 class='page-title'><a href='#' onclick='PageName()'>" + obj[0].Title + "</a></h5><div class='cBoth'></div><h5 class='page-title' ><a href='#' onclick='PageName()'>Receipt Entry</a></h5>";
                    $("#HeaderLabel").text("Fee Dashboard");
                    document.getElementById("HeaderTitle").innerHTML = Header;
                    ReceiptBookDataBind();
                    ReHeader = document.getElementById("HeaderTitle").innerHTML;
                }
            });
        }
        function HeaderDisplay(id) {
            if (id == 1) {
                document.getElementById("ReceiptBookHead").style.display = "block";
                document.getElementById("OrganizationListHead").style.display = "none";
                document.getElementById("ClassDivisionHead").style.display = "none";
                document.getElementById("StudentHead").style.display = "none";
                $("#Depart").hide();
                $("#division").hide();
                $("#class").hide();
                document.getElementById("HeaderTitle").innerHTML = ReHeader;
                Header = [];
            }
            else if (id == 2) {
                document.getElementById("ReceiptBookHead").style.display = "none";
                document.getElementById("OrganizationListHead").style.display = "block";
                document.getElementById("ClassDivisionHead").style.display = "none";
                document.getElementById("StudentHead").style.display = "none";
                $("#Student").hide();
                $("#Depart").show();
                $("#division").hide();
                $("#class").hide();
                var h1 = [Header[0], Header[1]];
                Header = h1;
            }
            else if (id == 3) {
                document.getElementById("ReceiptBookHead").style.display = "none";
                document.getElementById("OrganizationListHead").style.display = "none";
                document.getElementById("ClassDivisionHead").style.display = "block";
                document.getElementById("StudentHead").style.display = "none";
                $("#Depart").show();
                $("#division").hide();
                $("#class").show();
            }
        }


        function ReceiptBookDataBind() {
            $.ajax({
                type: "POST",
                url: "ReceiptEntry.aspx/ReceiptBookDataBind",
                data: JSON.stringify({ "BatchId": parseInt(BatchId), "OrgGroupId": parseInt(OrgId) }),
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (result) {
                    var obj = (result.d);
                    var tlbReceiptBook = "";
                    var total = 0;
                    if (obj != "") {
                        tlbReceiptBook += "<tr><th>Receipt Book</th><th style='text-align:right;'> Amount </th></tr>";
                        $.each(obj, function (i, item) {
                            console.log(item.ReceiptBookId, item.ReceiptBook, item.ReceiptAmount);
                            tlbReceiptBook += "<tr><td><a onclick='OrganizationListDataBind(" + item.ReceiptBookId + ",\"" + item.ReceiptBook + " \")'>" + item.ReceiptBook + "</a></td><td style='text-align:right;'>" + item.ReceiptAmount + "</td></tr>";
                            total += parseInt(item.ReceiptAmount);

                        });

                        tlbReceiptBook += "<tr><td style='font-weight:bold'>Total</td><td style='font-weight:bold; text-align:right;'>" + total + "</td></tr>";
                    }
                    else { tlbReceiptBook += "<tr><td colspan='8' class='record'>No records found..!!</td></tr>"; }
                    document.getElementById("tlbReceiptBook").innerHTML = tlbReceiptBook;
                    document.getElementById("ReceiptBookHead").style.display = "block";
                    document.getElementById("OrgHead").style.display = "none";

                }

            });
        }

        function OrganizationListDataBind(ReceiptBookId, ReceiptBook) {
            $.ajax({
                type: "POST",
                url: "ReceiptEntry.aspx/OrganizationListDataBind",
                data: JSON.stringify({ "ReceiptBookId": parseInt(ReceiptBookId), "BatchId": parseInt(BatchId), "OrgGroupId": parseInt(OrgId) }),
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (result) {
                    var obj = (result.d);
                    var tblOrganizationList = "";
                    var total = 0;
                    Header[0] = ReHeader;
                    if (obj != "") {
                        tblOrganizationList += "<tr><th>Organization Name</th><th style='text-align:right;'> Amount</th></tr>";
                        $.each(obj, function (i, item) {
                            console.log(ReceiptBookId, item.OrgId, item.OrganizationName, item.ReceiptAmount);
                            tblOrganizationList += "<tr><td><a onclick='StudentDivisionBind(" + ReceiptBookId + "," + item.OrgId + ",\"" + item.OrganizationName + " \")'>" + item.OrganizationName + "</a></td><td style='text-align:right;'>" + item.ReceiptAmount + "</td></tr>";
                            total += parseInt(item.ReceiptAmount);

                        });
                        Header[1] = " <h5 class='page-title' style='display:Block' id='Depart'><a href='#' onclick='HeaderDisplay(1)'>" + ReceiptBook + "</a></h5>";
                        tblOrganizationList += "<tr><td style='font-weight:bold'>Total</td><td style='font-weight:bold; text-align:right;'>" + total + "</td></tr>";
                    }
                    else { tblOrganizationList += "<tr><td colspan='8' class='record'>No records found..!!</td></tr>"; }
                    document.getElementById("tblOrganizationList").innerHTML = tblOrganizationList;
                    document.getElementById("HeaderTitle").innerHTML = '';
                    $.each(Header, function (i, item) {
                        document.getElementById("HeaderTitle").innerHTML += Header[i];
                    });
                    document.getElementById("ReceiptBookHead").style.display = "none";
                    document.getElementById("OrganizationListHead").style.display = "block";
                    document.getElementById("OrgHead").style.display = "none";
                    document.getElementById("ClassDivisionHead").style.display = "none";
                    statusId = 1;
                }

            });
        }

        function StudentDivisionBind(ReceiptBookId, Id, OrganizationName) {
            $.ajax({
                type: "POST",
                url: "ReceiptEntry.aspx/StudentDivisionBind",
                data: JSON.stringify({ "ReceiptBookId": parseInt(ReceiptBookId), "BatchId": parseInt(BatchId), "OrgGroupId": parseInt(OrgId), "Id": parseInt(Id) }),
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (result) {
                    var obj = (result.d);
                    var tblClassDivision = "";
                    var total = 0;
                    if (obj != "") {
                        tblClassDivision += "<tr><th>Class Division </th><th style='text-align:right;'> Amount</th></tr>";
                        $.each(obj, function (i, item) {
                            console.log(ReceiptBookId, item.DivisionId, item.DivisionName, item.ReceiptAmount);
                            tblClassDivision += "<tr><td><a onclick='StudentListDataBind(" + ReceiptBookId + "," + item.DivisionId + "," + Id + ",\"" + item.DivisionName + " \")'>" + item.DivisionName + "</a></td><td style='text-align:right;'>" + item.ReceiptAmount + "</td></tr>";
                            total += parseInt(item.ReceiptAmount);

                        });
                        Header[2] = " <h5 class='page-title' style='display:block'  id='class'><a href='#' onclick='HeaderDisplay(2)'>" + OrganizationName + "</a></h5>";
                        tblClassDivision += "<tr><td style='font-weight:bold'>Total</td><td style='font-weight:bold; text-align:right;'>" + total + "</td></tr>";
                    }
                    else { tblOrganizationList += "<tr><td colspan='8' class='record'>No records found..!!</td></tr>"; }
                    document.getElementById("tblClassDivision").innerHTML = tblClassDivision;
                    document.getElementById("HeaderTitle").innerHTML = '';
                    $.each(Header, function (i, item) {
                        document.getElementById("HeaderTitle").innerHTML += Header[i];
                    });
                    document.getElementById("ReceiptBookHead").style.display = "none";
                    document.getElementById("OrganizationListHead").style.display = "none";
                    document.getElementById("ClassDivisionHead").style.display = "block";
                    document.getElementById("StudentHead").style.display = "none";
                    statusId = 2;
                }

            });
        }

        function dashboardpage() {
            window.location.href = "../MobileView/FeeDashBoard.aspx";
        }
        function StudentListDataBind(ReceiptBookId, DivisionId, Id, DivisionName) {

            $.ajax({
                type: "POST",
                url: "ReceiptEntry.aspx/StudentListDataBind",
                data: JSON.stringify({ "ReceiptBookId": parseInt(ReceiptBookId), "BatchId": parseInt(BatchId), "OrgGroupId": parseInt(OrgId), "DivisionId": parseInt(DivisionId), "Id": parseInt(Id) }),
                // data: JSON.stringify({ "Id": Id, "Group": Group, "BatchId": parseInt(BatchId), "DivisionId": parseInt(DivisionId) }),
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (result) {
                    var obj = (result.d);
                    var tblstudent = "";
                    if (obj != "") {
                        tblstudent += "<tr><th>Receipt No</th><th> Code</th><th> Name</th><th style='text-align:right;'> Amount</th></tr>";
                        $.each(obj, function (i, item) {
                            console.log(ReceiptBookId, DivisionId, OrgId, item.Code, item.Name, item.ReceiptAmount);
                            tblstudent += "<tr><td>" + item.ReceiptNumber + "</td><td>" + item.Code + "</td><td>" + item.Name + "</td><td style='text-align:right;'>" + item.ReceiptAmount + "</td></tr>";
                        });
                        Header[3] = " <h5 class='page-title' style='display:block' id='division'><a href='#' onclick='HeaderDisplay(3)'>" + DivisionName + "</a></h5>";
                    }
                    else { tblstudent += "<tr><td colspan='8' class='record'>No records found..!!</td></tr>"; }
                    document.getElementById("tblstudent").innerHTML = tblstudent;
                    document.getElementById("HeaderTitle").innerHTML = '';
                    $.each(Header, function (i, item) {
                        // alert('' + Header[i]);
                        document.getElementById("HeaderTitle").innerHTML += Header[i];

                    });
                    document.getElementById("ReceiptBookHead").style.display = "none";
                    document.getElementById("OrganizationListHead").style.display = "none";
                    document.getElementById("ClassDivisionHead").style.display = "none";
                    document.getElementById("StudentHead").style.display = "block";
                    //$("#Student").show();
                    statusId = 3;

                }
            });
        }
        function BackOrgFunction() {
            if (statusId != 0 || statusId != null) {
                if (statusId == 3) {
                    document.getElementById("ReceiptBookHead").style.display = "none";
                    document.getElementById("OrganizationListHead").style.display = "none";
                    document.getElementById("ClassDivisionHead").style.display = "block";
                    document.getElementById("StudentHead").style.display = "none";
                    //$("#Student").show();
                    //$("#Depart").show();
                    //$("#class").show();
                    $("#division").hide();
                    statusId--;
                }
                else if (statusId == 2) {
                    document.getElementById("ReceiptBookHead").style.display = "none";
                    document.getElementById("OrganizationListHead").style.display = "block";
                    document.getElementById("ClassDivisionHead").style.display = "none";
                    document.getElementById("StudentHead").style.display = "none";
                    $("#class").hide();
                    $("#division").hide();
                    var h1 = [Header[0], Header[1]];
                    Header = h1;
                    statusId--;
                }
                else if (statusId == 1) {
                    document.getElementById("ReceiptBookHead").style.display = "block";
                    document.getElementById("OrganizationListHead").style.display = "none";
                    document.getElementById("ClassDivisionHead").style.display = "none";
                    document.getElementById("StudentHead").style.display = "none";
                    $("#Depart").hide();
                    $("#class").hide();
                    $("#division").hide();
                    document.getElementById("HeaderTitle").innerHTML = ReHeader;
                    Header = [];
                    statusId--;
                }
                else {
                    window.location.href = "../MobileView/FeeDashBoard.aspx?OrgId=" + OrgId
                }
            }
            else {
                window.location.href = "../MobileView/FeeDashBoard.aspx?OrgId=" + OrgId
            }

        }
        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>
                        <label class="header-topic justify-content-center" id="HeaderLabel"></label>
                        <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="OrgHead" style="display: block">
                            <h3 class="table-topic">Organization</h3>
                            <%-- <asp:PlaceHolder ID="DepartMentPlaceHolder" runat="server" /> --%>
                            <div class='himsBoxContent'>
                                <div class='table-responsive'>
                                    <table id='tblOrg' class='table table-striped table-bordered'>
                                    </table>
                                </div>
                            </div>
                        </div>
                        <div class="himssuHeader1WireBox col-md-12 pTop5" id="ReceiptBookHead" style="display: none">
                            <h3 class="table-topic">Receipt Book</h3>
                            <%-- <asp:PlaceHolder ID="DepartMentPlaceHolder" runat="server" /> --%>
                            <div class='himsBoxContent'>
                                <div class='table-responsive'>
                                    <table id='tlbReceiptBook' class='table table-striped table-bordered'>
                                    </table>
                                </div>
                            </div>
                        </div>
                        <div class="himssuHeader1WireBox col-md-12 pTop5" id="OrganizationListHead" style="display: none">
                            <h3 class="table-topic">Organization List</h3>
                            <%-- <asp:PlaceHolder ID="DepartMentPlaceHolder" runat="server" /> --%>
                            <div class='himsBoxContent'>
                                <div class='table-responsive'>
                                    <table id='tblOrganizationList' class='table table-striped table-bordered'>
                                    </table>
                                </div>
                            </div>
                        </div>
                        <div class="himssuHeader1WireBox col-md-12 pTop5" id="ClassDivisionHead" style="display: none">
                            <h3 class="table-topic">Class Division Name</h3>
                            <%-- <asp:PlaceHolder ID="DepartMentPlaceHolder" runat="server" /> --%>
                            <div class='himsBoxContent'>
                                <div class='table-responsive'>
                                    <table id='tblClassDivision' 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>



            <%--<script>

       function openDiv(obj) {
           //debugger;
           var id = $(obj);
          // document.getElementById("txtDistance").value = id;
           if ($('.Detail1_' + id[0]).css('display') == 'none') {
               $('.Detail1_' + id[0]).css('display', 'table-row');
               $('.DetailNew1_' + id[0]).css('display', 'table-row');
               //  $('.Detail_' + id).css('display', 'none');
               //$('.DetailNew_' + id).css('display', 'none');
           }
           else {
               $('.Detail1_' + id[0]).css('display', 'none');
               $('.DetailNew1_' + id[0]).css('display', 'none');
           }
       }

       function openDivNew(obj) {
           // debugger;
           
            var id = $(obj);
           // alert(id[0]);
           // alert(obj);
           $("#Departmentid").val(obj);
           // document.getElementById("Departmentid") = id[0].tostring();
           if ($('.Detail1_' + id[0]).css('display') == 'none') {
               $('.Detail1_' + id[0]).css('display', 'table-row');
               $('.DetailNew_' + id[0]).css('display', 'table-row');
             //  $('.Detail_' + id).css('display', 'none');
               //$('.DetailNew_' + id).css('display', 'none');
           }
           else {
               $('.Detail1_' + id[0]).css('display', 'none');
               $('.DetailNew_' + id[0]).css('display', 'none');
           }
       }

       function ClassDisplay(obj) {
           //debugger;
           var id = $(obj);
           $("#ClassHiddenId").val(obj);
           if ($('.ClassDisplay' + id[0]).css('display') == 'none') {
               $('.ClassDisplay' + id[0]).css('display', 'table-row');
               $('.ClassDisplay1' + id[0]).css('display', 'table-row');
               //  $('.Detail_' + id).css('display', 'none');
               //$('.DetailNew_' + id).css('display', 'none');
           }
           else {
               $('.ClassDisplay' + id[0]).css('display', 'none');
               $('.ClassDisplay1' + id[0]).css('display', 'none');
           }
       }

       function Studentdisplay(obj) {
           //debugger;
           var id = $(obj);
           $("#DivisionHiddenId").val(obj);
           if ($('.Studentdisplay' + id[0]).css('display') == 'none') {
               $('.Studentdisplay' + id[0]).css('display', 'table-row');
               $('.Studentdisplay1' + id[0]).css('display', 'table-row');
               //  $('.Detail_' + id).css('display', 'none');
               //$('.DetailNew_' + id).css('display', 'none');
           }
           else {
               $('.Studentdisplay' + id[0]).css('display', 'none');
               $('.Studentdisplay1' + id[0]).css('display', 'none');
           }
       }
    </script>--%>
        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>
