<?php 

  include "../db.php";

  session_start();

    $class_sql = "SELECT sclass FROM users WHERE uref = '$_SESSION[uref]'";

    $class_result = mysqli_query($con, $class_sql);

    $class_row = mysqli_fetch_assoc($class_result);

    $userClass = $class_row["sclass"];



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

    

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

    $AndWhere ='';



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



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



    }



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



        $sf_sql = "SELECT sid,sclass FROM class WHERE uploadedby = '$_SESSION[uref]' AND sid='$_POST[SecondFilterValue]'";

        $sf_run = mysqli_query($con, $sf_sql);

        $sf_rows = mysqli_fetch_assoc($sf_run);



        $AndWhere .= "AND n_class='$sf_rows[sid]' ";



    }



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



       $tf_sql = "SELECT sc_id,sc_name FROM subject WHERE uploadedby = '$_SESSION[uref]' AND sc_id='$_POST[ThirdFilterValue]'";

        $tf_run = mysqli_query($con, $tf_sql);

        $tf_rows = mysqli_fetch_assoc($tf_run);



        $AndWhere .= "AND n_subject='$tf_rows[sc_id]' ";

    }





   $sql = "SELECT * FROM fees WHERE sid = '$_SESSION[uid]' $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)) {



            $s_output .= 

                "

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

                <div class='row'>

                    



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

                        <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[fmonth]</b> ( <b style='color:black;'><i class='fa fa-inr'></i></b> $rows[amount] )  

                        <br>

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

                        

                    </div>



                    

                </div>

                </li>

                ";

          $c++;

        }



        mysqli_close($con);



        echo $s_output;

    }



}

?>



    <script>

        $(document).ready(function(){



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

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

              console.log(title);

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



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

                    'color' : 'black'

                });

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

                    'text-align' : 'center',

                    'color' : 'black',

                    'font-size' : '20px'

                });

                var note = $(this).data('note_script');

                $('#modalData').html(note);

                

            });

        });

    </script>