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

<asp:Content ID="Content1" ContentPlaceHolderID="CP" runat="Server">
    <script>
        //var Day;
        var Header = [];
        var ReHeader;
        var BatchId;
        var statusId = 0;
        var BatchId = 0;
        var OrgId = 0;

        $(document).ready(function () {
            var myurl = window.location.href;
            var keyval = myurl.split('?')[1].split('&');
            // Day = parseInt(keyval[0].split('=')[1].toString());
            //Id = OrgId = parseInt(keyval[0].split('=')[1].toString());
            //Group = keyval[1].split('=')[1].toString();
            BatchId = parseInt(keyval[0].split('=')[1].toString());
            OrgId = parseInt(keyval[1].split('=')[1].toString());
            GetOrgId();
        });
        function GetOrgId() {
            $.ajax({
                type: "POST",
                url: "AdditionalFee.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()'>Additional Fee</a></h5>";
                    $("#HeaderLabel").text("Fee Dashboard");
                    document.getElementById("HeaderTitle").innerHTML = Header;
                    ReHeader = document.getElementById("HeaderTitle").innerHTML;
                    ReceiptBookDataBind();
                }
            });
        }
        function PageName() {
            window.location.href = "../MobileView/FeeDashBoard.aspx?OrgId=" + OrgId;
        }
        function HeaderDisplay(id) {
            if (id == 1) {
                document.getElementById("ReceiptHead").style.display = "Block";
                document.getElementById("FeeHead").style.display = "none";
                document.getElementById("FeeMaster").style.display = "none";
                $("#ReceiptBook").hide();
                $("#DivisionClass").hide();
                document.getElementById("HeaderTitle").innerHTML = ReHeader;
                Header = [];
            }
            else if (id == 2) {
                document.getElementById("ReceiptHead").style.display = "none";
                document.getElementById("FeeHead").style.display = "Block";
                document.getElementById("FeeMaster").style.display = "none";
                $("#ReceiptBook").show();
                $("#DivisionClass").hide();


            }
        }
        function dashboardpage() {
            window.location.href = "../MobileView/FeeCollection.aspx"
        }

        function ReceiptBookDataBind() {
            $.ajax({
                type: "POST",
                url: "AdditionalFee.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 total = 0;
                    var tblReceipt = "";

                    if (obj != "") {
                        tblReceipt += "<tr><th>Receipt Book </th><th style='text-align:right;'> Amount</th></tr>";
                        $.each(obj, function (i, item) {
                            // alert(item.DepartmentName);
                            tblReceipt += "<tr><td><a onclick='FeeHeadDataBind(" + item.ReceiptBookId + ",\"" + item.ReceiptBook + " \") '>" + item.ReceiptBook + "</a></td><td style='text-align:right;'>" + item.AdditionalAmount + "</td></tr>";
                            total += parseInt(item.AdditionalAmount);
                        });
                        tblReceipt += "<tr><td style='font-weight:bold'>Total</td><td style='font-weight:bold;text-align:right;'>" + total + "</td></tr>";
                    }
                    else { tblReceipt += "<tr><td colspan='8' class='record'>No records found..!!</td></tr>"; }
                    // alert(obj);
                    document.getElementById("tblReceipt").innerHTML = tblReceipt;
                    document.getElementById("ReceiptHead").style.display = "block";
                    document.getElementById("OrgHead").style.display = "none";
                }
            });
        }

        function FeeHeadDataBind(ReceiptBookId, ReceiptBook) {

            $.ajax({
                type: "POST",
                url: "AdditionalFee.aspx/FeeHeadDataBind",
                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 tblFeeHead = "";
                    var total = 0;

                    Header[0] = ReHeader;
                    if (obj != "") {
                        tblFeeHead += "<tr><th>Fee Head</th><th style='text-align:right;'> Amount</th></tr>";
                        $.each(obj, function (i, item) {
                            // alert(item.DepartmentName);
                            tblFeeHead += "<tr><td><a onclick='FeeMasterDataBind(" + item.FeeHeadId + "," + ReceiptBookId + ",\"" + item.FeeHead + "\")'>" + item.FeeHead + "</a></td><td style='text-align:right;'>" + item.AdditionalAmount + "</td></tr>";
                            total += parseInt(item.AdditionalAmount);
                        });
                        tblFeeHead += "<tr><td style='font-weight:bold'>Total</td><td style='font-weight:bold; text-align:right;' >" + total + "</td></tr>";
                        Header[1] = "<h5 class='page-title'  id='ReceiptBook'><a href='#' onclick='HeaderDisplay(1)'>" + ReceiptBook + "</a></h5>";
                    }
                    else { tblFeeHead += "<tr><td colspan='8' class='record'>No records found..!!</td></tr>"; }
                    // alert(obj);
                    document.getElementById("tblFeeHead").innerHTML = tblFeeHead;
                    document.getElementById("HeaderTitle").innerHTML = '';
                    $.each(Header, function (i, item) {
                        // alert('' + Header[i]    );
                        document.getElementById("HeaderTitle").innerHTML += Header[i];

                    });
                    document.getElementById("ReceiptHead").style.display = "none";
                    document.getElementById("FeeHead").style.display = "Block";
                    statusId = 1;
                }
            });
        }
        function FeeMasterDataBind(FeeHeadId, ReceiptBookId, FeeHead) {

            $.ajax({
                type: "POST",
                url: "AdditionalFee.aspx/FeeMasterDataBind",
                data: JSON.stringify({ "FeeHeadId": parseInt(FeeHeadId), "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 tblFeeMaster = "";
                    var total = 0;
                    if (obj != "") {
                        tblFeeMaster += "<tr><th>Fee Master</th><th style='text-align:right;'> Amount</th></tr>";
                        $.each(obj, function (i, item) {
                            // alert(item.DepartmentName);
                            tblFeeMaster += "<tr><td>" + item.FeeMaster + "</td><td style='text-align: right'>" + item.AdditionalAmount + "</td></tr>";
                            total += parseInt(item.AdditionalAmount);
                        });
                        tblFeeMaster += "<tr><td style='font-weight:bold'>Total</td><td style='font-weight:bold; text-align: right' colspan='2'>" + total + "</td></tr>";
                        Header[2] = " <h5 class='page-title' style='display:Block' id='DivisionClass'><a href='#' onclick='HeaderDisplay(2)'>" + FeeHead + "</a></h5>";
                    }
                    else { tblFeeMaster += "<tr><td colspan='8' class='record'>No records found..!!</td></tr>"; }
                    // alert(obj);
                    document.getElementById("tblFeeMaster").innerHTML = tblFeeMaster;
                    document.getElementById("HeaderTitle").innerHTML = '';
                    $.each(Header, function (i, item) {
                        // alert('' + Header[i]    );
                        document.getElementById("HeaderTitle").innerHTML += Header[i];

                    });
                    document.getElementById("ReceiptHead").style.display = "none";
                    document.getElementById("FeeHead").style.display = "none";
                    document.getElementById("FeeMaster").style.display = "Block";
                    statusId = 2;
                }
            });
        }
        function BackOrgFunction() {
            if (statusId != 0 || statusId != null) {
                if (statusId == 2) {
                    document.getElementById("ReceiptHead").style.display = "none";
                    document.getElementById("FeeHead").style.display = "Block";
                    document.getElementById("FeeMaster").style.display = "none";
                    $("#ReceiptBook").show();
                    $("#DivisionClass").hide();
                    statusId--;
                }
                else if (statusId == 1) {
                    document.getElementById("ReceiptHead").style.display = "Block";
                    document.getElementById("FeeHead").style.display = "none";
                    document.getElementById("FeeMaster").style.display = "none";
                    $("#ReceiptBook").hide();
                    $("#DivisionClass").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">

                        <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="ReceiptHead" 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='tblReceipt' class='table table-striped table-bordered'>
                                    </table>
                                </div>
                            </div>
                        </div>
                        <div class="himssuHeader1WireBox col-md-12 pTop5" id="FeeHead" style="display: none">
                            <h3 class="table-topic">Fee Head</h3>
                            <%-- <asp:PlaceHolder ID="DepartMentPlaceHolder" runat="server" /> --%>
                            <div class='himsBoxContent'>
                                <div class='table-responsive'>
                                    <table id='tblFeeHead' class='table table-striped table-bordered'>
                                    </table>
                                </div>
                            </div>
                        </div>
                        <div class="himssuHeader1WireBox col-md-12 pTop5" id="FeeMaster" style="display: none">
                            <h3 class="table-topic">Fee Master</h3>
                            <%-- <asp:PlaceHolder ID="DepartMentPlaceHolder" runat="server" /> --%>
                            <div class='himsBoxContent'>
                                <div class='table-responsive'>
                                    <table id='tblFeeMaster' class='table table-striped table-bordered'>
                                    </table>
                                </div>
                            </div>
                        </div>

                    </div>
                </div>
            </div>
            <script>
                function openNav() {
                    document.getElementById("mySidenav").style.width = "344px";
                }

                function closeNav() {
                    document.getElementById("mySidenav").style.width = "0";
                }
            </script>
            <script>

                function openDiv(obj) {
                    //debugger;
                    var id = $(obj);
                    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) {

                    var id = $(obj);
                    $("#DivisionIdHidden").val(obj);
                    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 openDivNew11(obj) {

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