<?php 

  include_once "../db.php";

  include_once "includes/function.php";

  

  session_start();



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

    

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

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

     $AndWhere ='';



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



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



    }

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



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



    }



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



        $AndWhere .= "AND u.sclass='$_POST[ThirdFilterValue]' ";



    }

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



        $AndWhere .= "AND f.fyear='$_POST[ForthFilterValue]' ";



    }



    $sql = "SELECT f.*, u.uid, u.uname, u.sclass FROM fees  AS f  INNER JOIN  users AS u ON u.uphone = f.sid WHERE uploadedby = '$_SESSION[uref]' AND f.sclass ='$cid' $AndWhere  ORDER BY id 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)) {

            $showClass=showClass($con,$rows['sclass']);

            $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><i class='fa fa-calendar' aria-hidden='true'></i>  $rows[fmonth], $rows[fyear]

                    &nbsp; &nbsp; <i class='fa fa-inr' aria-hidden='true'></i>  $rows[amount]

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

                    </div>



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

                    <a href='edit-fees.php?edit_id=$rows[fref]' class='m-2 btn btn-success btn-sm' style='width:60px;' title='Click to Edit'> Edit </a>

                    <br>

                    <a href='view-fees.php?del_id=$rows[id]' class='delete m-2 btn btn-danger btn-sm' style='width:60px;' title='Click to Delete'> Delete </a>

                    </div>

                </div>

                </li>

                ";

          $c++;

        }



        mysqli_close($con);



        echo $s_output;

    }



}

?>