<?php 
include "../db.php";
session_start();
if (isset($_POST['start'])) {
    $start= mysqli_real_escape_string($con,$_POST['start']);
    $uref_code= mysqli_real_escape_string($con,$_POST['uref_code']);
    $userId= mysqli_real_escape_string($con,$_POST['userId']);
    $AndWhere ='';
    if (!empty($_POST['FirstFilterValue']) && empty($_POST['SecondFilterValue'])) {
        $AndWhere = "AND uname ='$_POST[FirstFilterValue]'";
    }elseif (empty($_POST['FirstFilterValue']) && !empty($_POST['SecondFilterValue'])) {
        $AndWhere = "AND referal_code ='$_POST[SecondFilterValue]'";
    }elseif (!empty($_POST['FirstFilterValue']) && !empty($_POST['SecondFilterValue'])) {
         $AndWhere = "AND uname ='$_POST[FirstFilterValue]'";
    }

    $sql = "SELECT * FROM users WHERE utype = 'Sub Associate' AND admin_ref = '$uref_code' AND udisplay != 'disabled' $AndWhere ORDER BY uid 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-9 col-xs-9'>
                <div class="d-flex justify-content-between align-items-center">
                    <div class="intro-admin">
                        <a style='color:orange;font-size:17px;text-decoration:none;' class='viewDetails'
                            data-toggle='modal' data-target='#adminDetailsModal'>
                            <i class='fa fa-user' aria-hidden='true'></i> <b><?php echo $rows["uname"];?></b> [
                            <?php echo $rows["referal_code"];?> ]
                        </a>
                    </div>
                </div>
            </div>
            <div class='col-md-3 d-flex justify-content-between align-items-center'>
                <a href='uplodDocuments.php?user=<?php echo $rows["uid"];?>&show_list' class='btn btn-primary btn-sm'
                    title='Click to Edit'>Document
                </a>
                <!-- Agreement Button --
                <a href='agreementDownload.php?user=<?php echo $rows["uid"];?>' class='btn btn-primary btn-sm'
                    title='Click to Agreement Page'>Agreement
                </a>-->
                <a href='subFranchiee-list.php?franchisee=<?php echo $userId;?>&view_id=<?php echo $rows["uid"];?>'
                    class='btn btn-info text-white btn-sm' title='Click to View'><i class='fa fa-eye'
                        aria-hidden='true'></i>
                </a>
            </div>
        </div>
    </div>
</li>

<?php
          $c++;
        }
        mysqli_close($con);
    }
}
?>