<?php 

include "../db.php";

session_start();

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

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

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

    $AndWhere ='';

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

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

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

        $AndWhere = "";

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

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

    }



    $sql = "SELECT * FROM data WHERE data_catagory = 'Documents' AND data_recycle = '1' AND data_up_for = '$data_up_for' $AndWhere ORDER BY data_sl_no 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 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-file' aria-hidden='true'></i> <b><?php echo $rows["data_title"];?></b>

                        </a>

                    </div>

                </div>

            </div>

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

                <a href='uplodDocuments.php?user=<?php echo $data_up_for;?>&view_id=<?php echo $rows["data_sl_no"];?>'

                    class='btn btn-info text-white btn-sm' title='Click to View'><i class='fa fa-eye'

                        aria-hidden='true'></i>

                </a>

                <?php if($rows["data_subCategory"] == "KYC"){?>

                <button type="button" class="btn btn-outline-secondary btn-sm" disabled>KYC Document</button>

                <?php } if($rows["data_subCategory"] != "KYC"){?>

                <br>

                <a href='uplodDocuments.php?user=<?php echo $data_up_for;?>&edit_id=<?php echo $rows["data_sl_no"];?>'

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

                </a>

                <br>

                <a href='uplodDocuments.php?user=<?php echo $data_up_for;?>&rec_id=<?php echo $rows["data_sl_no"];?>'

                    class='delete btn btn-danger btn-sm' title='Click to Delete'><i class='fa fa-trash'

                        aria-hidden='true'></i> </a>

                <?php }?>

            </div>

        </div>

    </div>

</li>

<?php

          $c++;

        }

        mysqli_close($con);

    }

}

?>