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

<asp:Content ID="Content1" ContentPlaceHolderID="CP" runat="Server">
    <script>
        var Id;
        var OrgId;
        var OrgGroupId;
        var Group;
        var BatchId;
        var Day;
        var statusId;
        var Header;
        var ReHeader;
        $(document).ready(function () {
            var myurl = window.location.href;
            var keyval = myurl.split('?')[1].split('&');
            OrgId = parseInt(keyval[0].split('=')[1].toString());
            Id = OrgId = parseInt(keyval[0].split('=')[1].toString());
            Group = keyval[1].split('=')[1].toString();
            BatchId = parseInt(keyval[2].split('=')[1].toString());
            Day = parseInt(keyval[3].split('=')[1].toString());
           
            $.ajax({
                type: "POST",
                url: "NoOfInquiryCount.aspx/GetOrgId",
                data: JSON.stringify({ "Id": Id, "Group": Group }),
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (result) {
                    var obj = (result.d);
                    if (Group == "OrgId") {
                        Header = "<h5 class='page-title'><a href='#' onclick='dashboardpage()'>" + obj[0].Title + "</a></h5>"+
                          " <h5 class='page-title' ><a href='#' onclick='PageName()'>Admission Inquiry</a></h5>";
                        $("#HeaderLabel").text("MIS DashBoard");
                    }
                    else {
                        Header = "<h5 class='page-title'><a href='#' onclick='dashboardpage()'>" + obj[0].Title + "</a></h5>"+
                          " <h5 class='page-title' ><a href='#' onclick='PageName()'>Admission Inquiry</a></h5>";
                        $("#HeaderLabel").text("EIS DashBoard");
                    }

                    document.getElementById("HeaderTitle").innerHTML = Header;
                }
            });
            if (Group == "OrgId")
            { ClassDataBind(); }
            else { OrganizationGet(); }
           // ClassDataBind();
        });
        function PageName() {
            if (Group == "OrgId") {
                window.location.href = "../MobileView/MobileDashBoard2.aspx?OrgId=" + Id;
            }
            else {
                window.location.href = "../MobileView/MobileDashBoard2.aspx?OrgGroupId=" + Id;
            }
        }
        function dashboardpage() {
            if (Group == "OrgId") {
                window.location.href = "../MobileView/MobileDashBoard2.aspx?OrgId=" + Id;
            }
            else {
                window.location.href = "../MobileView/MobileDashBoard2.aspx?OrgGroupId=" + Id;
            }
        }
        function OrganizationGet() {
            $.ajax({
                type: "POST",
                url: "NoOfInquiryCount.aspx/OrganizationGet",
                data: JSON.stringify({ "Day": parseInt(Day), "OrgId": OrgId, "BatchId": parseInt(BatchId) }),
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (result) {
                    var obj = (result.d);
                    var tblOrg = "";
                    var total = 0;
                    if (obj != "") {
                        tblOrg += "<tr><th>Organization Name</th><th>Count</th></tr>";
                        $.each(obj, function (i, item) {

                            if (Day == -1)
                            { tblOrg += "<tr><td ><a onclick='ClassDataBind(" + item.OrgId + ")'>" + item.Organization + "</a></td><td>" + item.YesterdayCount + "</td></tr>"; total += parseInt(item.YesterdayCount); }
                            else if (Day == 1)
                            { tblOrg += "<tr><td ><a onclick='ClassDataBind(" + item.OrgId + ")'>" + item.Organization + "</a></td><td>" + item.DailyCount + "</td></tr>"; total += parseInt(item.DailyCount); }
                            else if (Day == 7)
                            { tblOrg += "<tr><td><a onclick='ClassDataBind(" + item.OrgId + ")'>" + item.Organization + "</a></td><td>" + item.WeeklyCount + "</td></tr>"; total += parseInt(item.WeeklyCount); }
                            else
                            { tblOrg += "<tr><td ><a onclick='ClassDataBind(" + item.OrgId + ")'>" + item.Organization + "</a></td><td>" + item.MonthlyCount + "</td></tr>"; total += parseInt(item.MonthlyCount); }
                        });
                        tblOrg += "<tr><td style='font-weight:bold'>Total</td><td style='font-weight:bold'>" + total + "</td></tr>";
                        // Header += " <h5 class='page-title' style='display:Block' id='ClassName'><a href='#' onclick='HeaderDisplay(1)'>" + ClassName + "</a></h5>";
                    }
                    else { tblOrg += "<tr><td colspan='8' class='record'>No records found..!!</td></tr>"; }
                    // alert(obj);
                    document.getElementById("tblOrg").innerHTML = tblOrg;
                    document.getElementById("ClassHead").style.display = "none";
                    document.getElementById("OrgHead").style.display = "block";
                    statusId = 0;
                    // document.getElementById("HeaderTitle").innerHTML = Header;
                }
            });
        }
        function ClassDataBind(Id) {
            if (Group == "OrgId")
            { OrgGroupId = 0; }
            else { OrgGroupId = OrgId;; OrgId = Id;  }
            $.ajax({
                type: "POST",
                url: "NoOfInquiryCount.aspx/ClassDataBind",
                data: JSON.stringify({ "OrgId": OrgId, "Group": Group, "BatchId": parseInt(BatchId), "Day": Day, "OrgGroupId": OrgGroupId }),
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (result) {
                    var obj = (result.d);
                    var tblClss = "";
                    var total = 0;
                    if (obj != "")
                    {
                        tblClss += "<tr><th>Class Name</th><th>Student Count</th></tr>";
                        $.each(obj, function (i, item) {
                            //console.log(item.i);
                            if (Day == -1)
                            { tblClss += "<tr><td>" + item.ClassName + "</td><td>" + item.YesterdayCount + "</td></tr>"; total += parseInt(item.YesterdayCount); }
                            else if (Day == 1)
                            { tblClss += "<tr><td>" + item.ClassName + "</td><td>" + item.DailyCount + "</td></tr>"; total += parseInt(item.DailyCount); }
                            else if (Day == 7)
                            { tblClss += "<tr><td>" + item.ClassName + "</td><td>" + item.WeeklyCount + "</td></tr>"; total += parseInt(item.WeeklyCount); }
                            else
                            { tblClss += "<tr><td>" + item.ClassName + "</td><td>" + item.MonthlyCount + "</td></tr>"; total += parseInt(item.MonthlyCount); }

                        });
                        
                        tblClss += "<tr><td style='font-weight:bold'>Total</td><td style='font-weight:bold'>" + total + "</td></tr>";
                    }
                    else { tblClss += "<tr><td colspan='8' class='record'>No records found..!!</td></tr>"; }
                    // alert(obj);
                    //Header += " <h5 class='page-title' style='display:Block' id='Depart'><a href='#' onclick=''>Student Inquiry</a></h5>";
                    document.getElementById("tblClss").innerHTML = tblClss;
                    document.getElementById("ClassHead").style.display = "block";
                    document.getElementById("OrgHead").style.display = "none";
                   // document.getElementById("HeaderTitle").innerHTML = Header;
                }

            });
        }

        function BackOrgFunction()
        {
            if (statusId == 0) {
                if (Group == "OrgId")
                { window.location.href = "../MobileView/MobileDashBoard2.aspx?OrgId=" + OrgId; }
                else {
                    document.getElementById("ClassHead").style.display = "none";
                    //document.getElementById("RemarkHead").style.display = "none";
                    document.getElementById("OrgHead").style.display = "block";
                    statusId--;
                }
            }
            else {
                if (Group == "OrgId")
                { window.location.href = "../MobileView/MobileDashBoard2.aspx?OrgId=" + Id; }
                else { window.location.href = "../MobileView/MobileDashBoard2.aspx?OrgGroupId=" + Id; }
            }
        }
        function DashBoard() { window.location.href = "../MobileView/DashBoard.aspx"; }
    </script>
    <asp:UpdatePanel ID="DoctorScheduleUpdatePanel" runat="server">
        <ContentTemplate>
               <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"></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="page-header row mb20">
                <div class="col-xl-12 col-sm-12 col-xs-12 border-bottom-inline xs-padd0">
                    <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="ClassHead" style="display:none">
                                        <h3 class="table-topic">Class Wise Student</h3>
                                       <%-- <asp:PlaceHolder ID="DepartMentPlaceHolder" runat="server" /> --%>
                                        <div class='himsBoxContent'><div class='table-responsive'>
                                             <table id='tblClss' class='table table-striped table-bordered'>
                                            </table>
                                            </div></div>
                                    </div>


                             <div id="NoofStudentClassDiv" >
                                   <div class="himssuHeader1WireBox col-md-12 pTop5">
                                        <%--<div class="himsBoxHeader page-bar col-xl-12 col-md-12 col-sm-12 padd-0">
                                            <div class="width-100 border-bottom-inline">
                                                <div class=" pull-left  main-topic">
                                                    <Label ID="StudentLabel" Class="page-title">Class Wise Student</Label>
                                                </div>
                                            </div>
                                        </div>--%>
                                          <%-- <h2 id="ClassPlace">Class Wise Student</h2>
                                           <asp:PlaceHolder ID="ClassPlaceHolder" runat="server" />      --%>                                 
                                       <%--    <div class="himsBoxContent card-body col-md-12 col-xl-12">
                                            <div class="table-responsive ">
                                                <asp:GridView runat="server" ID="NoofStudentClassGridView" Width="100%" AutoGenerateColumns="False"
                                                    EmptyDataText="No Records Found !!" AllowPaging="false" CssClass="table table-striped table-bordered"
                                                    ShowHeader="True">
                                                    <Columns>

                                                        <asp:BoundField DataField="ClassDivision" HeaderText="Class" ItemStyle-Width="10%" HeaderStyle-HorizontalAlign="Left" />
                                                        <asp:BoundField DataField="DepartName" HeaderText="Department Name" ItemStyle-Width="50%" HeaderStyle-HorizontalAlign="Left" />
                                                        <asp:BoundField DataField="StudentCount" HeaderText="Active Student" ItemStyle-Width="20%" HeaderStyle-HorizontalAlign="Left" />
                                                        <asp:BoundField DataField="TotalCount" HeaderText="Total Student" ItemStyle-Width="20%" HeaderStyle-HorizontalAlign="Left" />

                                                    </Columns>
                                                    <PagerSettings Visible="False" />
                                                </asp:GridView>
                                                <div class="col-xl-12 pTop5">
                                                    <div class="offset-xl-7 col-xl-4 col-sm-6">
                                                        <div class="col-xl-8 col-sm-6">
                                                            <asp:Label ID="DepartmentActiveLabel" runat="server" Font-Bold="true"></asp:Label>
                                                        </div>
                                                        <div class="col-xl-4 col-sm-6">
                                                            <asp:Label ID="DepartmentTotalLabel" runat="server" Font-Bold="true"></asp:Label>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>--%>
                                    </div>
                                </div>
                   <%--     <div id="NoofStudentDiv">
                            <div>
                                <h2 id="StudentPlace">Student Wise Student</h2>
                                <asp:PlaceHolder ID="StudentPlaceHolder" runat="server" />      
                            </div>
                        </div>--%>
                 </div>
                                </div>
                 </div>
                             
            <script>
                //function HideButton()
                //{
                //   // debugger;
                //    var pathArray = window.location.search.split('?');
                   
                   
                //   // var myurl = "journey?reference=123&line=A&destination=China&operator=Belbo&departure=1043&vehicle=ARC";
              
                //    var newPathname = "";
                //    for (i = 0; i < pathArray.length; i++) {
                //        newPathname += "&";
                //        newPathname += pathArray[i];
                //        console.log(pathArray[i]);
                //    }
                //}
                
                //function BindData()
                //{
                //    debugger;
                //    $.ajax({
                //        url: '/Pages/MobileView/NoOfStudent.aspx/BindDepartmentData?Id=1103',
                //        type: "Get",
                //        contentType: "application/json; charset=utf-8",
                //        dataType: "json",
                //        success: function (data) {
                //            debugger;
                //            var innerHtml = '<table class="table table-responsive search-api table-striped table-bordered"> <thead><tr><th>Sub ID</th><th>Super Key</th><th>Contact Name</th><th>Publication</th><th>Sub Code</th><th>Start Date</th><th>Expiry Date</th><th>Copies</th><th>Sales Person</th></tr></thead><tbody>';
                //            var paging_All = ''
                //            var current = 1;
                //            //console.log("..." + data.resultSet.length);
                //            $.each(data.resultSet, function (i, item) {
                //                var rows = '<tr>' +
                //                    '<td>' + item.SubId + '</td>' +
                //                    '<td>' + item.SuperKey + '</td>' +
                //                    '<td>' + item.ContactName + '</td>' +
                //                    '<td>' + item.Publication + '</td>' +
                //                    '<td>' + item.SubCode + '</td>' +
                //                    '<td>' + item.StartDate + '</td>' +
                //                    '<td>' + item.ExpireDate + '</td>' +
                //                    '<td>' + item.Copies + '</td>' +
                //                    '<td>' + item.SalesPerson + '</td>' +
                //                    '</tr>';
                //                innerHtml += rows;
                //            });
                //            innerHtml += ' </tbody></table>';
                //            $('#divSubscription').html('');
                //            $('#divSubscription').html(innerHtml);
                //            //$('.search-api').DataTable();

                //        },
                //        error: function (data) {
                //            console.log(data);
                //        }
                //    });
             //   }
            </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) {
          // debugger;
           var id = $(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');
           }
       }
    </script>
        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>
