<?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 notice_title ='$_POST[FirstFilterValue]'";

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

        $AndWhere = "";

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

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

    }



    $sql = "SELECT * FROM notice WHERE admin_ref = '$_SESSION[uref]' AND notice_recycle = '1' $AndWhere ORDER BY notice_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)) {

            //referance count start//

            $ap_total_rows= 0;

        

            $state_sql = mysqli_query($con, "SELECT * FROM state WHERE id = '$rows[notice_state]' ");

            if($state_row = mysqli_fetch_assoc($state_sql)){

                $state_name = $state_row["name"];

            }else{

                $state_name = "";

            }



            $dist_sql = mysqli_query($con, "SELECT * FROM dist WHERE id = '$rows[notice_dist]' ");

            if($dist_row = mysqli_fetch_assoc($dist_sql)){

                $dist_name = $dist_row["distName"];

            }else{

                $dist_name = "";

            }

            //referance count end//

            ?>

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

    <div class="single-dis-admin mb-2">

        <div class='row align-items-center'>

            <div class='col-md-10 col-xs-9'>

                <div class="d-flex justify-content-between align-items-center">

                    <div class="intro-admin">

                        <a style='color:orange;font-size:17px;' class='viewDetails' data-toggle='modal'

                            data-target='#adminDetailsModal'>

                            <i class='fa fa-bell' aria-hidden='true'></i> <b><?php echo $rows["notice_title"];?></b>

                        </a>

                    </div>

                </div>

            </div>

            <div class='col-md-2 col-xs-3 d-flex justify-content-between'>

                <a href='view-notice.php?view_id=<?php echo $rows["notice_id"];?>' class='btn btn-info text-white'

                    title='Click to View'><i class='fa fa-eye' aria-hidden='true'></i>

                </a>

                <br>

                <a href='view-notice.php?edit_id=<?php echo $rows["notice_id"];?>' class='btn btn-primary'

                    title='Click to Edit'><i class='fa fa-edit' aria-hidden='true'></i>

                </a>

                <br>

                <a href='view-notice.php?del_id=<?php echo $rows["notice_id"];?>' class='delete btn btn-danger'

                    title='Click to Delete'><i class='fa fa-trash' aria-hidden='true'></i> </a>

            </div>

        </div>

    </div>

</li>

<?php

          $c++;

        }

        mysqli_close($con);

    }

}

?>