<?php 

  include "../../db.php";

  session_start();



if (isset($_POST['start'])) {

    

    $start= mysqli_real_escape_string($con,$_POST['start']);

    $AndWhere ='';



    if ( !empty($_POST['FirstFilterValue']) ) {



        $AndWhere .= "AND uname='$_POST[FirstFilterValue]' ";



    }



    if ( !empty($_POST['SecondFilterValue']) ) {





        $AndWhere .= "AND ucontact='$_POST[SecondFilterValue]' ";



    }



    if (!empty($_POST['ThirdFilterValue'])) {



        $AndWhere .= "";

    }



     $sql = "SELECT * FROM users  WHERE utype = 'Member' AND udisplay = 'disable'  $AndWhere ORDER BY uid DESC LIMIT $start,10";



    $res = mysqli_query($con,$sql);

    if ($total_rows=mysqli_num_rows($res)>0) {

        $s_output='';

          $c = $start+1;

        while ($rows=mysqli_fetch_assoc($res)) {



            $ap_total_rows= 0;

            $ap_sql = "SELECT * FROM users WHERE upload_ref_code = '$rows[uref_code]' AND reg_approved= '1'";

            $ap_res = mysqli_query($con,$ap_sql);

            $ap_total_rows=mysqli_num_rows($ap_res);



            $not_ap_total_rows= 0;

            $not_ap_sql = "SELECT * FROM users WHERE upload_ref_code = '$rows[uref_code]' AND reg_approved= '0'";

            $not_ap_res = mysqli_query($con,$not_ap_sql);

            $not_ap_total_rows=mysqli_num_rows($not_ap_res);

           

            

            if ($rows['reg_approved']==1) {

            $s_output .= 

                "

                <li class='clearfix' style='float: none;'>

                <div class='row'>

                    



                    <div class='col-md-10 col-xs-8 second-item'>

                    <a data-toggle='modal'  class='viewDetails' data-toggle='modal' data-target='#studentDetailsModal' data-name='$rows[uname]'  data-dist='$rows[uremark]' data-pin='$rows[uref_code]' data-userid='$rows[ucontact]' data-pass='$rows[uremark]' data-address='$rows[saddress]' data-classs='$rows[uremark]' data-date='$rows[ucreated]' data-email='$rows[uemail]'>



                            <i class='fa fa-pencil-square-o' aria-hidden='true'style='color:orange;font-size:17px;'></i> <b style='color:black;font-size:15px;'>$rows[uname]</b>  

                       </a>

                        <br>

                         <i class='fa fa-list-ul'></i> $rows[uqualification]

                        &nbsp; &nbsp;<i class='fa fa-line-chart'></i> $ap_total_rows

                        &nbsp;

                        <i class='fa fa-ban'></i> $not_ap_total_rows

                        <br>

                        <i class='fa fa-clock-o text-primary'></i> $rows[ucreated]

                        



                        

                    </div>



                    <div class='col-md-2 col-xs-4 third-item'>



                        <a href='view-member.php?restore_id=$rows[uid]' class='m-2 btn btn-success btn-sm' sty le='width:35px;'> Restore </a>

                        

                    </div>

                </div>

                </li>

                ";

               }

          $c++;

        }



        mysqli_close($con);



        echo $s_output;

    }



}

?>



    <script>

        $(document).ready(function(){



            $('.viewDetails').on('click', function () {

                var name = $(this).data('name');

                $('#modalName').text(name);

                $('.modal-css').css({

                    'color' : 'black'

                    

                });

                $('.modal-name').css({

                    'text-align' : 'center',

                    'color' : 'black'

                });

                $('.modal-id').css({

                    'color' : 'red',

                    'font-weight' : 'bold'

                });

                var dist = $(this).data('dist');

                $('#modalDist').text(dist);

                var pin = $(this).data('pin');

                $('#modalPin').text(pin);

                var userid = $(this).data('userid');

                $('#modalId').text(userid);

                var pass = $(this).data('pass');

                $('#modalPass').text(pass);

                var classs = $(this).data('classs');

                $('#modalClass').text(classs);

                var address = $(this).data('address');

                $('#modalAddress').text(address);

                var date = $(this).data('date');

                $('#modalDate').text(date);

                var email = $(this).data('email');

                $('#modalEmail').text(email);

                

            });

        });

    </script>



