<?php 

  include "../db.php";

    session_start();



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

    

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

    $AndWhere ='';



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



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



    }elseif (empty($_POST['FirstFilterValue']) && !empty($_POST['SecondFilterValue'])) {



        $AndWhere = "";



    }elseif (!empty($_POST['FirstFilterValue']) && !empty($_POST['SecondFilterValue'])) {

        

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

    }





     $sql = "SELECT * FROM users  WHERE utype = 'Teacher' AND udisplay !='disable' AND admin_ref = '$_SESSION[uref]' $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)) {

            

            $s_output .= 

                "

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

                <div class='row'>

                    



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

                        <i class='fa fa-user-circle' aria-hidden='true' style='color:orange;font-size:18px;'></i> <b style='color:black;font-size:16px;'>$rows[uname]</b>  

                        

                        <br>

                         <a href='tel:$rows[ucontact]' class='small text-dark text-decoration-none' title='Click here to Call'> <i class='fa fa-phone fa-rotate-90'></i> $rows[ucontact] </a> 



                        <br>

                        <button class='btn btn-primary btn-sm viewDetails' data-toggle='modal' data-target='#teacherDetailsModal' data-name='$rows[uname]'  data-dist='$rows[dist]' data-pin='$rows[pin]' data-userid='$rows[uphone]' data-pass='$rows[upass]' data-address='$rows[saddress]' data-qualification='$rows[uqualification]' data-date='$rows[ucreated]'> View Details </button>



                        <a href='view-teacher-notes.php?t_ref=$rows[uref]' class='btn btn-primary btn-sm'> Notes </a>

                    

                    </div>



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

                        

                        <a href='edit-teacher.php?edit_id=$rows[uid]' class='m-2 btn btn-success btn-sm' style='width:35px;' title='Click to Edit'><i class='fa fa-pencil-square-o' aria-hidden='true' style='font-size:17px;'></i> </a>

                        <br>

                        <a href='view-teacher.php?del_id=$rows[uid]' class='delete m-2 btn btn-danger btn-sm' style='width:35px;' title='Click to Delete'><i class='fa fa-trash-o' aria-hidden='true' style='font-size:19px;'></i> </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',

                    'font-size' : '20px'

                });

                $('.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 qualification = $(this).data('qualification');

                $('#modalqualification').text(qualification);

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

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

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

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

                

            });

        });

    </script>

