<?php
    include('connection.php');
    // echo "data : ".$_GET['rv_id'];
    $getReservationId = isset($_GET['rv_id']) ? $_GET['rv_id'] : "";
?>

<thead>
    <tr>
        <th>ID</th>
        <th>Date</th>
        <th>Amount</th>
        <th>Payment method</th>
        <th>Recorded By</th>
        <th>Upload By</th>
        <th>Verified By</th>
        <!-- <th>Status</th> -->
        <th>Note</th>
        <th>Action</th>
    </tr>
</thead>
<tbody>
    <?php
        $resultPayment = mysqli_query($conn, "SELECT * FROM reservation_payment WHERE rv_id=$getReservationId ORDER BY rvp_date DESC");
        while($rowPayment = mysqli_fetch_array($resultPayment))
        {
    ?>
    <tr>
        <td><?php echo $rowPayment['rvp_id'];?></a></td>
        <td><?php echo $rowPayment['rvp_date'];?></td>
        <td>RM <?php echo $rowPayment['rvp_amount'];?></td>
        <td><?php switch($rowPayment['rvp_method']){
        case 0: echo "Unknown"; break;
        case 1: echo "Bank In/Cash Payment"; break;
        case 2: echo "Cash"; break;
    }?></td>
        <td>
            <?php if($rowPayment['a_id']){ echo getDetailByTable('admin',$rowPayment['a_id'])['a_username']; } ?>
        </td>
        <td>
            <?php if($rowPayment['rvp_uploaded_by']){ echo getDetailByTable('admin',$rowPayment['rvp_uploaded_by'])['a_username']; } ?>
        </td>
        <td>
            <?php if($rowPayment['rvp_verified_by']){ echo getDetailByTable('admin',$rowPayment['rvp_verified_by'])['a_username']; if($rowPayment['rvp_status']){echo "<br>";} } ?>
            <?php if($rowPayment['rvp_status']){echo "previously verified";} ?>
        </td>
        <!-- <td>
            <?php switch($rowPayment['rvp_status']){
        case 0: echo "<a href='?pagecontent=reservation_view&status=1&id=".$getReservationId."&rvpid=".$rowPayment['rvp_id']."'><button class='btn btn-xs btn-danger'>Unverified</button></a>"; break;
        case 1: echo "<a href='?pagecontent=reservation_view&status=0&id=".$getReservationId."&rvpid=".$rowPayment['rvp_id']."'><button class='btn btn-xs btn-primary'>Verified</button></a>"; break;
    }?>
        </td> -->
        <td><?php echo $rowPayment['rvp_note'];?></td>
        <td>
            <a href="?pagecontent=reservation_view&update=y&id=<?php echo $getReservationId; ?>&rvpid=<?php echo $rowPayment['rvp_id']; ?>&date=<?php echo $rowPayment['rvp_date']; ?>&method=<?php echo $rowPayment['rvp_method']; ?>&amount=<?php echo $rowPayment['rvp_amount']; ?>&note=<?php echo $rowPayment['rvp_note']; ?>#updatePayment"><button type="button" class="btn btn-xs btn-primary">Update</button></a>
        </td>
    </tr>
    <?php
        }
    ?>
</tbody>