<?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']) ) {

        header("Location: logout.php");

        exit();

    }

    if ( $_SESSION['utype'] != 'master_admin' && $_SESSION['uref'] != 'fssdf4543frts' ) {

        header("Location: logout.php");

        exit();

    }

?>

<!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">

<?php 

    $ref_sql = "SELECT * FROM Users WHERE uref_code = '$_GET[uref_id]'";

    $ref_result = mysqli_query($con,$ref_sql);

    $ref_rows=mysqli_fetch_assoc($ref_result)

 ?>                        

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

                            <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">

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

                                </div>

                            </div>

                        

                        </div>

                    </div>



                </div>



            </div>



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

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



    

    <div class="modal fade" id="modalNotes" tabindex="-1" role="dialog" aria-labelledby="modelTitleId" aria-hidden="true">

        <div class="modal-dialog" role="document">

            <div class="modal-content">

                <div class="modal-header">

                    <h5 class="modal-name badge badge-primary text-light" id="modalName"></h5>

                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">

                        <span aria-hidden="true">&times;</span>

                    </button>

                </div>

                <div class="modal-body">

                    <span class="modal-css" id="modalData"></span>

                    <hr>

                    

                    <span id=modalIMG></span>

                </div>

                <div class="modal-footer">

                    <button type="button" class="btn btn-warning text-dark" data-dismiss="modal">Close</button>

                </div>

            </div>

        </div>

    </div>

    

<script>



  $(document).ready(function(){

                                                                 

// Scroll Loading of Full Data //

        var load_flag = 0;

        var uref_id = "<?php echo $_GET['uref_id']; ?>";

        loadMore(load_flag);

        function loadMore(start){

            console.log('total'+start);

            $.ajax({

                url: 'view-under-ref-user-Ajax.php',

                type: 'post',

                data: {

                      start:start,

                      uref_id:uref_id

                    },

                success:function(result){

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

                    load_flag += 10;

                },

                complete:function(data){

                    /* Hide loader container */

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

                }

            });

        }



        $(window).scroll(function(){

        

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

                //console.log('call');

                    loadMore(load_flag);

                }

            

        });



  });



</script>





</body>

</html>