<%@ page language="C#" autoeventwireup="true" inherits="Pages_MobileView_NoOfTransport, App_Web_o2bmcyxc" 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 statusId;
        var Header;
        var ReHeader;
        $(document).ready(function () {
            var myurl = window.location.href;
            var keyval = myurl.split('?')[1].split('&');
            Id = OrgId = parseInt(keyval[0].split('=')[1].toString());
            Group = keyval[1].split('=')[1].toString();
            BatchId = parseInt(keyval[2].split('=')[1].toString());
            $.ajax({
                type: "POST",
                url: "NoOfTransport.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()'>Transport</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()'>Transport</a></h5>";
                        $("#HeaderLabel").text("EIS DashBoard");
                    }

                    document.getElementById("HeaderTitle").innerHTML = Header;
                    ReHeader = document.getElementById("HeaderTitle").innerHTML;
                }
            });
             TransportDataBind();
        });

        function HeaderDisplay(id) {
            if (id == 1) {
                document.getElementById("TransportHead").style.display = "block";
                document.getElementById("StudentHead").style.display = "none";
                $("#Transport").hide();
                Header = '' + ReHeader;
            }
        }
        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 TransportDataBind() {
            $.ajax({
                type: "POST",
                url: "NoOfTransport.aspx/TransportDataBind",
                data: JSON.stringify({ "Id": Id, "Group": Group, "BatchId": parseInt(BatchId) }),
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (result) {
                    var obj = (result.d);
                    var tblTransport = "";
                    var total = 0;
                    if (obj != "")
                    {
                        tblTransport += "<tr><th>Transport Name</th><th>Transport Student Count</th></tr>";
                        $.each(obj, function (i, item) {
                            tblTransport += "<tr><td><a onclick='StudentTransportDataBind(" + item.TransportId + ",\"" + item.TransportName + " \")'>" + item.TransportName + "</a></td><td>" + item.TransportStudentCount + "</td></tr>";
                            total += parseInt(item.TransportStudentCount);
                        });
                        tblTransport += "<tr><td style='font-weight:bold'>Total</td><td style='font-weight:bold'>" + total + "</td></tr>";
                    }
                    else { tblTransport += "<tr><td colspan='8' class='record'>No records found..!!</td></tr>"; }
                    document.getElementById("tblTransport").innerHTML = tblTransport;
                }

            });
        }

        function StudentTransportDataBind(TransportId, TransportName)
        {
            $.ajax({
                type: "POST",
                url: "NoOfTransport.aspx/StudentTransportDataBind",
                data: JSON.stringify({ "Id": Id, "Group": Group, "TransportId": TransportId, "BatchId": parseInt(BatchId) }),
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (result) {
                    var obj = (result.d);
                    var tblStudent = "";
                    if (obj != "")
                    {
                        tblStudent += "<tr><th>Transport Code</th><th>Transport Student Name</th></tr>";
                        $.each(obj, function (i, item) {
                            tblStudent += "<tr><td>" + item.Code + "</td><td>" + item.Name + "</td></tr>";
                        });
                       Header += " <h5 class='page-title' style='display:Block' id='Transport'><a href='#' onclick='HeaderDisplay(1)'>" + TransportName + "</a></h5>";
                    }
                    else { tblStudent += "<tr><td colspan='8' class='record'>No records found..!!</td></tr>"; }
                    document.getElementById("tblStudent").innerHTML = tblStudent;
                    document.getElementById("HeaderTitle").innerHTML = Header;
                    document.getElementById("TransportHead").style.display = "none";
                    document.getElementById("StudentHead").style.display = "block";
                    statusId = 1;
                }

            });
        }
        function BackOrgFunction() {
            //if (statusId == 0) {
            //    document.getElementById("TransportHead").style.display = "none";
            //    document.getElementById("StudentHead").style.display = "none";
            //    document.getElementById("OrgHead").style.display = "block";
            //    statusId--;
            //}
            //else 
            if (statusId == 1)
            {
                document.getElementById("TransportHead").style.display = "block";
                document.getElementById("StudentHead").style.display = "none";
                $("#Transport").hide();
                Header = '' + ReHeader;
                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="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"></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">
                       
                          <div class="himssuHeader1WireBox col-md-12 pTop5" id="TransportHead" style="display:block">
                                        <h3 class="table-topic">Transport</h3>
                                       <%-- <asp:PlaceHolder ID="DepartMentPlaceHolder" runat="server" /> --%>
                                        <div class='himsBoxContent'><div class='table-responsive'>
                                             <table id='tblTransport' 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">Transport</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>
<%--                            <div id="NoofStudentDepartDiv">
                                    <div class="himssuHeader1WireBox col-md-12 pTop5">
                                <h2 class="table-topic">Student Transport </h2>
                                <asp:PlaceHolder ID="StudentTransportPlaceHolder" runat="server" />
                            </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);
                     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>
