<?php

    session_start();

    include "../db.php";

    date_default_timezone_set('Asia/Kolkata');

    $currentTime = date('M j, Y g:i a');

    



    if ( !isset($_SESSION['uid']) && !isset($_SESSION['uref']) && !isset($_SESSION['utype']) && !isset($_SESSION['uname']) )

        header("Location: logout.php");



    $admin_2_run = "SELECT admin_ref FROM users WHERE uref = '$_SESSION[uref]'";

    $admin_2_row2 = mysqli_query($con, $admin_2_run);

    $admin_2_row = mysqli_fetch_assoc($admin_2_row2);

    $admin_2 = $admin_2_row["admin_ref"];



    $std_sql = "SELECT uname,sclass FROM users WHERE uid = '$_SESSION[uid]'";

    $std_run = mysqli_query($con, $std_sql);

    $std_row = mysqli_fetch_assoc($std_run);

    $std_name = $std_row["uname"];

    $std_classid = $std_row["sclass"];



?>

<!DOCTYPE html>

<html lang="en">

<head>

 <?php include "includes/meta.php"; ?>        

    <?php include "includes/css.php"; ?>      

  



</head>

<body id="page-top" class="mt-55">



    <div style="margin-top: 70px;"></div>



      <?php include "includes/header2.php"; ?>

<div class="container">

            <div class="row">

                <div class="col-12 col-sm-12 col-md-12">

                        <div clas s="card-body">

                            <h1 class="h3 mb-2 text-gray-800 text-center">Attendance</h1>

                            <hr>

                                <div class="row filter">

                                        

                                        <div class="filter-input-3" style=" margin-left:18px">

                                            <div class="form-group">

                                                <font>Subject</font>

                                                <select class="ThirdFilterValue form-control" id="sub-category-dropdown">

                                                </select>

                                              </div>

                                        </div>

                                         <div class="filter-input-3">

                                               <div class="form-group">

                                                <font>Starting Date</font>

                                                <input type="date" class="form-control" id="First1FilterValue">

                                              </div>

                                        </div>

                                        <div class="filter-input-3">

                                              <div class="form-group">

                                                <font>Ending Date</font>

                                                <input type="date" class="form-control" id="First2FilterValue">

                                              </div>

                                        </div>

                                        <div class="filter-btn" >

                                              <button type="button" id="filter" class="btn"> Search </button>

                                        </div>

                                </div>

                            <hr>

                                                    <div class="row">

                                <!--loader -->

                                 <div class="col-12" id='loader'>

                                    <ul style="list-style: none; padding-left: 0;">

                                      <?php 

                                        for ($count = 0; $count < 4; $count++) {

                                  

                                            echo '<li>

                                            <div class="ph-item">

                                            <div cl ass="ph-test">

                                            <div class="ph-row">

                                            <div class="ph-col-12 big"></div>

                                            <div class="ph-col-12"></div>

                                            <div class="ph-col-12"></div>

                                            <div class="ph-col-12"></div>

                                            <div class="ph-col-12"></div>

                                            <div class="ph-col-12"></div>

                                            </div></div>

                                            </div>

                                            </li>';

                                        }

                                      ?>

                                    </ul>

                                </div>

                                <!-- loader -->

                                <div class="col-12" id="full-table">

                                        <div class="timeline" id="full-table-data"></></div>

                                </div>

                                <div class="col-12" id="filter-table" style="display: none;">

                                        <div class="timeline" id="filter-table-data"></></div>

                                </div>

                            </div>

                        

                        </div>

                    </div>



                </div>



            </div>



            <?php include "includes/ft.php"; ?>

            <?php include "includes/js.php"; ?>









<script>

    //dropdown TWO filter Start//

  $(document).ready(function(){

                                                                 

        var load_filter_flag = '';

        var First1FilterValue = '';

        var First2FilterValue = '';

        var SecondFilterValue = '';

        var ThirdFilterValue = '';

        $("#filter").click(function(){

            First1FilterValue = $('#First1FilterValue').val();

            First2FilterValue = $('#First2FilterValue').val();

            SecondFilterValue = $('.SecondFilterValue').val();

            ThirdFilterValue = $('.ThirdFilterValue').val();

            load_filter_flag = 0;

            if (First1FilterValue != '' || First2FilterValue != '' || SecondFilterValue != '' || ThirdFilterValue != '') {

                //alert(name);

                $.ajax({

                    url:'attendance-Ajax.php',

                    type:'post',

                    data:{

                      First1FilterValue:First1FilterValue,

                      First2FilterValue:First2FilterValue,

                      SecondFilterValue:SecondFilterValue,

                      ThirdFilterValue:ThirdFilterValue,

                      start:load_filter_flag,

                      id:id

                    },

                    success:function(result){

                      $('#full-table').hide();

                      $('#filter-table').show();

                      $('#filter-table-data').html(result);

                      load_filter_flag += 12;

                    },

                    complete:function(data){

                        /* Hide loader container */

                        $("#loader").hide();

                    }

                });

            }else{

                alert('Plz Select an Option');

                $('#full-table').show();

                $('#filter-table').hide();

            }

        });





        function loadMoreFilter(start){

            console.log('Filter'+start);

            if (load_filter_flag > 0) {

              //alert(name);

                  $.ajax({

                    url:'attendance-Ajax.php',

                    type:'post',

                    data:{

                      First1FilterValue:First1FilterValue,

                      First2FilterValue:First2FilterValue,

                      SecondFilterValue:SecondFilterValue,

                      ThirdFilterValue:ThirdFilterValue,

                      start:start,

                      id:id

                    },

                    success:function(result){

                      $('#filter-table-data').append(result);

                      load_filter_flag += 12;

                    }

                  });

             

            }

        }

// Scroll Loading of Full Data //

        var id = <?php echo $_SESSION['uid']; ?>;

        var load_flag = 0;

        loadMore(load_flag);

        function loadMore(start){

            //console.log('total'+start);

            console.log(id);

            $.ajax({

                url: 'attendance-Ajax.php',

                type: 'post',

                data: {

                      start:start,

                      id:id

                    },

                success:function(result){

                    $('#full-table-data').append(result);

                    load_flag += 12;

                },

                complete:function(data){

                    /* Hide loader container */

                    $("#loader").hide();

                }

            });

        }



        $(window).scroll(function(){

        

            if ($(window).scrollTop() >= $(document).height()-$(window).height()) {

                //console.log('call');

                if (load_filter_flag>0) {

                    loadMoreFilter(load_filter_flag); 

                }else{

                    loadMore(load_flag);

                }

                

                

            }

            

        });



  });



$(document).ready(function() {



        var category_id = "<?php echo $std_classid; ?>";

        var admin_2 = "<?php echo $admin_2; ?>";

        $.ajax({

            url: "notes-upload-CatSubcat-Ajax.php",

            type: "POST",

            data: {

            admin_2: admin_2,

            category_id: category_id

            },

            cache: false,

            success: function(result){

            $("#sub-category-dropdown").html(result);

            }

        });



});



</script>





    <script>

        $(document).ready(function(){

            

            $('#modal1').on('show.bs.modal', function(e){

                var src1 = $(e.relatedTarget).attr('src');

                $(this).find('.modal-body > img').attr('src', src1);

            });

        });

    </script>





</body>

</html>

