<?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($data_up_for)){
        $AndWhere = "AND ph_for ='$data_up_for'";
    }
    if (!empty($_POST['FirstFilterValue']) && empty($_POST['SecondFilterValue'])) {
        $AndWhere = "AND ph_for ='$_POST[FirstFilterValue]'";
    }elseif (empty($_POST['FirstFilterValue']) && !empty($_POST['SecondFilterValue'])) {
        $AndWhere = "";
    }elseif (!empty($_POST['FirstFilterValue']) && !empty($_POST['SecondFilterValue'])) {
         $AndWhere = "AND ph_for ='$_POST[FirstFilterValue]'";
    }

    $sql = "SELECT * FROM payment_history WHERE ph_up_by = '$_SESSION[uid]' AND ph_recycle = '1' $AndWhere ORDER BY phid 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)) {
            $fran_sql = mysqli_query($con, "SELECT * FROM users WHERE uid = '$rows[ph_for]'");
            if($fran_row = mysqli_fetch_assoc($fran_sql)){
                $franName = $fran_row["uname"];
            }
            ?>
<li class='clearfix' style='float: none;'>
    <div class="single-dis-admin mb-2">
        <div class='row align-items-center'>
            <div class='col-md-11 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-user' aria-hidden='true'></i> <b><?php echo $franName;?></b> <br>
                        </a>
                        <i class='fa fa-calendar' aria-hidden='true'></i> Payout Date : <?php echo $rows["ph_upDate"];?>
                    </div>
                </div>
            </div>
            <div class='col-md-1 d-flex justify-content-between'>
                <?php if(!empty($data_up_for)){?>
                <a href='payout.php?user=<?php echo $data_up_for;?>&view_id=<?php echo $rows["phid"];?>'
                    class='btn btn-info text-white btn-sm' title='Click to View'><i class='fa fa-eye'
                        aria-hidden='true'></i>
                </a>
                <br>
                <a href='payout.php?user=<?php echo $data_up_for;?>&edit_id=<?php echo $rows["phid"];?>'
                    class='btn btn-primary btn-sm' title='Click to Edit'><i class='fa fa-edit' aria-hidden='true'></i>
                </a>
                <!--<br>
                <a href='payout.php?user=<?php echo $data_up_for;?>&rec_id=<?php echo $rows["phid"];?>'
                    class='delete btn btn-danger btn-sm' title='Click to Delete'><i class='fa fa-trash'
                        aria-hidden='true'></i> </a>-->
                <?php } else{?>
                <a href='payout.php?view_id=<?php echo $rows["phid"];?>' class='btn btn-info text-white btn-sm'
                    title='Click to View'><i class='fa fa-eye' aria-hidden='true'></i>
                </a>
                <br>
                <a href='payout.php?edit_id=<?php echo $rows["phid"];?>' class='btn btn-primary btn-sm'
                    title='Click to Edit'><i class='fa fa-edit' aria-hidden='true'></i>
                </a>
                <!--<br>
                <a href='payout.php?rec_id=<?php echo $rows["phid"];?>' 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);
    }
}
?>