<?php 

  include "../db.php";

  include "includes/function.php";

  session_start();



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





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



    }



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



        $AndWhere .= "";

    }



     $sql = "SELECT * FROM notice_table  WHERE n_by = '$_SESSION[uref]'  $AndWhere ORDER BY n_sl 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)) {

            $uploadedImage = $rows["notice"];

            $showFullDate = showFullDate($rows["n_date"]);

            if (empty($rows["n_classid"])) {

                $classShow ='';

            }else{

                $classShow = '<i class="fa fa-graduation-cap" aria-hidden="true"></i> '.showClass($con,$rows["n_classid"]);

            }

            

            $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-target='#modalNotes' data-title='$rows[n_title]'  data-note_script='$rows[m_notice]' data-img='$rows[notice]'>



                            <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[n_title]</b>  

                       

                        <br>

                        <i class='fa fa-clock-o text-primary'></i> $showFullDate 

                        &nbsp; &nbsp; <i class='fa fa-list-ul'></i> $rows[type]

                        &nbsp; &nbsp; $classShow

                        

                    </a>

                    </div>



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

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

                        <br>

                        <a href='view-notice.php?del_id=$rows[n_sl]&homework=$rows[notice]' 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;

    }



}

?>



   <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);



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

                console.log(img);

                imgCode = "<img src='../upload/notice/"+img+"' width='100%'>";

                console.log(imgCode);

                $('#modalIMG').html(imgCode);

                

            });

        });

    </script>