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

<asp:Content ID="Content1" ContentPlaceHolderID="CP" runat="Server">
 
    <asp:UpdatePanel runat="server" ID="DoctorScheduleUpdatePanel">
        <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>
                <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="top-btn col-md-12">
                <div class="custom-select ">
                    <div class='fLeft pRight5'>
                        <select id="drpOrganization" onchange="OrganizationFunction()">
                            <option value='0'>demo</option>
                        </select>
                    </div>
                </div>

            </div>
            <div class="page-header mb37">
                <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-body-dark row center-block">
                <div class="container-fluid">
                    <div class="gutters-tiny push js-appear-enabled animated fadeIn" data-toggle="appear">
                        <div class="tab row">
                            <div class="block newdb height252 row arrow-up">

                                <div class="col-xl-4 col-md-6 col-sm-12 col-xs-12 min-h" id="AbsentStudentListblog" style="display:none">
                                    <div class="card table-card box box-primary">
                                        <div class="card-header box-header yellow-border">
                                            <h3><i class="material-icons dp48">error_outline</i>Absent Student List</h3>
                                        </div>
                                        <div class="card-block">
                                            <div class='table-responsive'>
                                                <table id='tblAbsentStudentDashboard' class='table table-striped table-bordered'>
                                                </table>
                                            </div>
                                        </div>
                                        <div class="se-pre-con" id="LoaderDiv1" style="display: none"></div>
                                    </div>
                                </div>

                                <div class="col-xl-4 col-md-6 col-sm-12 col-xs-12 min-h" id="AbsentEmployeeListblog" style="display:none">
                                    <div class="card table-card box box-primary">
                                        <div class="card-header box-header red-border">
                                            <h3><i class="material-icons dp48">error_outline</i>Absent Employee List</h3>
                                        </div>
                                        <div class="card-block">
                                            <div class='table-responsive'>
                                                <table id='tblAbsentEmployeeDashboard' class='table table-striped table-bordered'>
                                                </table>
                                            </div>
                                        </div>
                                        <div class="se-pre-con" id="LoaderDiv2" style="display: none"></div>
                                    </div>
                                </div>

                                <div class="col-xl-4 col-md-6 col-sm-12 col-xs-12 min-h" id="HomeWork(Not Given)blog" style="display:none">
                                    <div class="card table-card box box-primary">
                                        <div class="card-header box-header green-border">
                                            <h3><i class="material-icons dp48">book</i>Home Work (Not Given)</h3>
                                        </div>
                                        <div class="card-block">
                                            <div class='table-responsive'>
                                                <table id='tblHomeworkNotGivenDashboard' class='table table-striped table-bordered'>
                                                </table>
                                            </div>
                                        </div>
                                        <div class="se-pre-con" id="LoaderDiv3" style="display: none"></div>
                                    </div>
                                </div>

                                <div class="col-xl-4 col-md-6 col-sm-12 col-xs-12 min-h" id="NotAddedattendanceblog" style="display:none">
                                    <div class="card table-card box box-primary">
                                        <div class="card-header box-header purple-border">
                                            <h3><i class="material-icons dp48">format_list_bulleted</i>Attendance - Not Added attendance</h3>
                                        </div>
                                        <div class="card-block">
                                            <div class='table-responsive'>
                                                <table id='tblAttendanceNotAddedDashboard' class='table table-striped table-bordered'>
                                                </table>
                                            </div>
                                        </div>
                                        <div class="se-pre-con" id="LoaderDiv4" style="display: none"></div>
                                    </div>
                                </div>


                                <div class="col-xl-4 col-md-6 col-sm-12 col-xs-12 min-h" id="MorePendingFeeblog" style="display:none">
                                    <div class="card table-card box box-primary">
                                        <div class="card-header box-header orange-border">
                                            <h3><i class="material-icons dp48">monetization_on</i>Fee - More Pending Fee</h3>
                                        </div>
                                        <div class="card-block">
                                            <div class='table-responsive'>
                                                <table id='tblPendingFeeCollectionGroupDashboard' class='table table-striped table-bordered'>
                                                </table>
                                            </div>
                                        </div>
                                        <div class="se-pre-con" id="LoaderDiv5" style="display: none"></div>
                                    </div>
                                </div>

                            </div>
                        </div>
                    </div>
                </div>
            </div>
               <script>
                   var Id;
                   var Group;
                   var BatchId;
                   var mySessionVar;
                   var R;
                   var RR;
                   var idList = [];
                   var idCount = 0;
                   var NewBatchId;

                   $(document).ready(function () {
                       var myurl = window.location.href;
                       if (myurl != "") {
                           var spliturl = myurl.split('?');

                           if (spliturl.length > 1) {
                               var keyval = myurl.split('?')[1].split('&');
                               Id = parseInt(keyval[0].split('=')[1].toString());
                           }
                           else { sessionStorage.clear(); }
                       }
                       BatchId = 0;
                       $.ajax({
                           type: "POST",
                           url: "AlertInnerdashboard.aspx/GetOrgDropDownList",
                           // data: JSON.stringify({ "OrgGroupId": parseInt(OrgId) }),
                           contentType: "application/json; charset=utf-8",
                           dataType: "json",
                           success: function (result) {
                               $("#drpOrganization").val(0);

                               $("#drpOrganization").html(result.d);
                               mySessionOrg = sessionStorage.getItem("NewId");
                               if (mySessionOrg == null || mySessionOrg == "" || mySessionOrg == undefined) {
                                   Id = $("#drpOrganization option:first").val();
                               }
                               else {
                                   $("#drpOrganization").val(mySessionOrg);
                                   Id = mySessionOrg;
                               }
                               AssignPermission();
                           },
                           error: function (xhr, status, error) {
                               var err = eval("(" + xhr.responseText + ")");
                               console.log(err.Message);
                           }
                       });
                   });
                   function OrganizationFunction() {

                       Id = $("#drpOrganization").val();
                       sessionStorage.setItem('NewId', Id);
                       $("#drpOrganization").val(Id);
                       GetOrgId();
                       AbsentStudentDashboardGet();
                   }

                   function AssignPermission() {
                       $.ajax({
                           type: "POST",
                           url: "AlertInnerDashboard.aspx/AssignPermission",
                           contentType: "application/json; charset=utf-8",
                           dataType: "json",
                           success: function (result) {
                               var obj = (result.d);
                               var OrgGroupId = "";
                               $.each(obj, function (i, item) {
                                   if (item.RoleDashletId == 62 && item.IsCheck == true) {
                                       document.getElementById("AbsentStudentListblog").style.display = "block";
                                   }
                                   else if (item.RoleDashletId == 63 && item.IsCheck == true) {
                                       document.getElementById("AbsentEmployeeListblog").style.display = "block";
                                   }
                                   else if (item.RoleDashletId == 64 && item.IsCheck == true) {
                                       document.getElementById("HomeWork(Not Given)blog").style.display = "block";
                                   }
                                   else if (item.RoleDashletId == 65 && item.IsCheck == true) {
                                       document.getElementById("NotAddedattendanceblog").style.display = "block";
                                   }
                                   else if (item.RoleDashletId == 66 && item.IsCheck == true) {
                                       document.getElementById("MorePendingFeeblog").style.display = "block";
                                   }
                               });
                               GetOrgId();
                           },
                           error: function (xhr, status, error) {
                               var err = eval("(" + xhr.responseText + ")");
                               console.log(err.Message);
                           }
                       });
                   }

                   function GetOrgId() {
                       $.ajax({
                           type: "POST",
                           url: "AlertInnerdashboard.aspx/GetOrgId",
                           data: JSON.stringify({ "Id": Id }),
                           contentType: "application/json; charset=utf-8",
                           dataType: "json",
                           success: function (result) {
                               var obj = (result.d);

                               var Header = "<h5 class='page-title'>" + obj[0].Title + "</h5>";
                               $("#HeaderLabel").text("Attention Dashboard");
                               document.getElementById("HeaderTitle").innerHTML = Header;
                               AbsentStudentDashboardGet();
                           },
                           error: function (xhr, status, error) {
                               var err = eval("(" + xhr.responseText + ")");
                               console.log(err.Message);
                           }
                       });
                   }

                   function AbsentStudentDashboardGet() {
                       $("#LoaderDiv1").show();
                       $.ajax({
                           type: "POST",
                           url: "AlertInnerdashboard.aspx/AbsentStudentDashboardGet",
                           data: JSON.stringify({ "OrgGroupId": Id }),
                           contentType: "application/json; charset=utf-8",
                           dataType: "json",
                           success: function (result) {
                               var obj = (result.d);
                               var tblAbsentStudentDashboard = "";
                               //var total = 0;
                               if (obj != "") {
                                   tblAbsentStudentDashboard += "<thead><tr><th>Org Id</th><th>Code</th><th>Student Name</th><th>Absent Count</th></tr></thead>";
                                   $.each(obj, function (i, item) {

                                       tblAbsentStudentDashboard += "<tr><td>" + item.OrgId + "</td><td>" + item.Code + "</td><td>" + item.StudentName + "</td><td>" + item.StudentCount + "</td></tr>";
                                       //total += parseInt(item.StudentCount);
                                   });
                                   //tblAbsentStudentDashboard += "<tr><td style='font-weight:bold'>&nbsp;</td><td style='font-weight:bold'>&nbsp;</td><td style='font-weight:bold'>Total</td><td style='font-weight:bold'>" + total + "</td></tr>";
                               }
                               else { tblAbsentStudentDashboard += "<tr><td colspan='3' class='record'>No records found..!!</td></tr>"; }

                               document.getElementById("tblAbsentStudentDashboard").innerHTML = tblAbsentStudentDashboard;
                               $("#LoaderDiv1").hide();
                               AbsentEmployeeDashboardGet();
                           },
                           error: function (xhr, status, error) {
                               var err = eval("(" + xhr.responseText + ")");
                               console.log(err.Message);
                           }
                       });
                   }

                   function AbsentEmployeeDashboardGet() {
                       $("#LoaderDiv2").show();
                       $.ajax({
                           type: "POST",
                           url: "AlertInnerdashboard.aspx/AbsentEmployeeDashboardGet",
                           data: JSON.stringify({ "OrgGroupId": Id }),
                           contentType: "application/json; charset=utf-8",
                           dataType: "json",
                           success: function (result) {
                               var obj = (result.d);
                               var tblAbsentEmployeeDashboard = "";
                               //var total = 0;
                               if (obj != "") {
                                   tblAbsentEmployeeDashboard += "<thead><tr><th>Org Id</th><th>Code</th><th>Employee Name</th><th>Absent Count</th></tr></thead>";
                                   $.each(obj, function (i, item) {

                                       tblAbsentEmployeeDashboard += "<tr><td>" + item.OrgId + "</td><td>" + item.Code + "</td><td>" + item.EmployeeName + "</td><td>" + item.AbsentCount + "</td></tr>";
                                       // total += parseInt(item.AbsentCount);
                                   });
                                   // tblAbsentEmployeeDashboard += "<tr><td style='font-weight:bold'>&nbsp;</td><td style='font-weight:bold'>&nbsp;</td><td style='font-weight:bold'>Total</td><td style='font-weight:bold'>" + total + "</td></tr>";
                               }
                               else { tblAbsentEmployeeDashboard += "<tr><td colspan='3' class='record'>No records found..!!</td></tr>"; }

                               document.getElementById("tblAbsentEmployeeDashboard").innerHTML = tblAbsentEmployeeDashboard;
                               $("#LoaderDiv2").hide();
                               HomeworkNotGivenDashboardGet();
                           },
                           error: function (xhr, status, error) {
                               var err = eval("(" + xhr.responseText + ")");
                               console.log(err.Message);
                           }
                       });
                   }

                   function HomeworkNotGivenDashboardGet() {
                       $("#LoaderDiv3").show();
                       $.ajax({
                           type: "POST",
                           url: "AlertInnerdashboard.aspx/HomeworkNotGivenDashboardGet",
                           data: JSON.stringify({ "OrgGroupId": Id }),
                           contentType: "application/json; charset=utf-8",
                           dataType: "json",
                           success: function (result) {
                               var obj = (result.d);
                               var tblHomeworkNotGivenDashboard = "";
                               //var total = 0;
                               if (obj != "") {
                                   tblHomeworkNotGivenDashboard += "<thead><tr><th>Org Id</th><th>Code</th><th>Employee Name</th><th>Subject</th><th>Day</th></tr></thead>";
                                   $.each(obj, function (i, item) {

                                       tblHomeworkNotGivenDashboard += "<tr><td>" + item.OrgId + "</td><td>" + item.Code + "</td><td>" + item.EmployeeName + "</td><td>" + item.EmployeeSubject + "</td><td>" + item.DayCount + "</td></tr>";
                                       //total += parseInt(item.DayCount);
                                   });
                                   // tblHomeworkNotGivenDashboard += "<tr><td style='font-weight:bold'>&nbsp;</td><td style='font-weight:bold'>&nbsp;</td><td style='font-weight:bold'>&nbsp;</td><td style='font-weight:bold'>Total</td><td style='font-weight:bold'>" + total + "</td></tr>";
                               }
                               else { tblHomeworkNotGivenDashboard += "<tr><td colspan='4' class='record'>No records found..!!</td></tr>"; }

                               document.getElementById("tblHomeworkNotGivenDashboard").innerHTML = tblHomeworkNotGivenDashboard;
                               $("#LoaderDiv3").hide();
                               AttendanceNotAddedDashboardGet();
                           },
                           error: function (xhr, status, error) {
                               var err = eval("(" + xhr.responseText + ")");
                               console.log(err.Message);
                           }
                       });
                   }

                   function AttendanceNotAddedDashboardGet() {
                       $("#LoaderDiv4").show();
                       $.ajax({
                           type: "POST",
                           url: "AlertInnerdashboard.aspx/AttendanceNotAddedDashboardGet",
                           data: JSON.stringify({ "OrgGroupId": Id }),
                           contentType: "application/json; charset=utf-8",
                           dataType: "json",
                           success: function (result) {
                               var obj = (result.d);
                               var tblAttendanceNotAddedDashboard = "";
                               //var total = 0;
                               if (obj != "") {
                                   tblAttendanceNotAddedDashboard += "<thead><tr><th>Org Id</th><th>Class</th><th>Code</th><th>Employee Name</th><th>Not Added Count</th></tr></thead>";
                                   $.each(obj, function (i, item) {

                                       tblAttendanceNotAddedDashboard += "<tr><td>" + item.OrgId + "</td><td>" + item.Class + "</td><td>" + item.Code + "</td><td>" + item.EmployeeName + "</td><td>" + item.NotAddedCount + "</td></tr>";
                                       //total += parseInt(item.Day);
                                   });
                               }
                               else { tblAttendanceNotAddedDashboard += "<tr><td colspan='2' class='record'>No records found..!!</td></tr>"; }

                               document.getElementById("tblAttendanceNotAddedDashboard").innerHTML = tblAttendanceNotAddedDashboard;
                               $("#LoaderDiv4").hide();
                               PendingFeeCollectionGroupDashboardGet();
                           },
                           error: function (xhr, status, error) {
                               var err = eval("(" + xhr.responseText + ")");
                               console.log(err.Message);
                           }
                       });
                   }


                   function PendingFeeCollectionGroupDashboardGet() {
                       $("#LoaderDiv5").show();
                       $.ajax({
                           type: "POST",
                           url: "AlertInnerdashboard.aspx/PendingFeeCollectionGroupDashboardGet",
                           data: JSON.stringify({ "OrgGroupId": Id }),
                           contentType: "application/json; charset=utf-8",
                           dataType: "json",
                           success: function (result) {
                               var obj = (result.d);
                               var tblPendingFeeCollectionGroupDashboard = "";
                               var TotalPendingCount = 0;
                               var TotalPendingAmount = 0;
                               if (obj != "") {
                                   tblPendingFeeCollectionGroupDashboard += "<thead><tr><th>Collection Group</th><th>Pending Amount</th><th>Pending Count</th></tr></thead>";
                                   $.each(obj, function (i, item) {
                                       tblPendingFeeCollectionGroupDashboard += "<tr><td><a href='../MobileView/FeeDetailDashboard.aspx?OrgGroupId=" + Id + "&CollectionGroupId=" + item.CollectionGroupId + "'>" + item.CollectionGroupName + "</a></td><td>" + item.PendingAmount + "</td><td>" + item.PendingCount + "</td></tr>";
                                       TotalPendingCount += parseInt(item.PendingCount);
                                       TotalPendingAmount += parseInt(item.PendingAmount);
                                   });
                                   tblPendingFeeCollectionGroupDashboard += "<tr><td style='font-weight:bold'>Total</td><td style='font-weight:bold'>" + TotalPendingAmount + "</td><td style='font-weight:bold'>" + TotalPendingCount + "</td></tr>";
                               }
                               else { tblPendingFeeCollectionGroupDashboard += "<tr><td colspan='2' class='record'>No records found..!!</td></tr>"; }
                               document.getElementById("tblPendingFeeCollectionGroupDashboard").innerHTML = tblPendingFeeCollectionGroupDashboard;
                               $("#LoaderDiv5").hide();
                           },
                           error: function (xhr, status, error) {
                               var err = eval("(" + xhr.responseText + ")");
                               console.log(err.Message);
                           }
                       });
                   }

                   function BackOrgFunction() {
                       sessionStorage.removeItem('idList');
                       sessionStorage.removeItem('idCount');
                       window.location.href = "../MobileView/DashBoard.aspx";
                   }

                   function DashBoard() {
                       sessionStorage.removeItem('idList');
                       sessionStorage.removeItem('idCount');
                       window.location.href = "../MobileView/DashBoard.aspx";
                   }
    </script>
            <script>
                function openNav() {
                    document.getElementById("mySidenav").style.width = "344px";
                }

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