<?php 
include 'config.php';

// বিল পেমেন্ট আপডেট (১ মাস বাড়িয়ে দেওয়া)
if(isset($_GET['pay_id'])){
    $id = $_GET['pay_id'];
    $new_expiry = date('Y-m-d', strtotime('+1 month'));
    mysqli_query($conn, "UPDATE customers SET expiry_date='$new_expiry', status='active' WHERE id=$id");
    header("Location: customer_list.php");
}

$result = mysqli_query($conn, "SELECT * FROM customers");
?>

<h3>Customer List</h3>
<table border="1" cellpadding="10">
    <tr>
        <th>Username</th>
        <th>Expiry Date</th>
        <th>Status</th>
        <th>Action</th>
    </tr>
    <?php while($row = mysqli_fetch_assoc($result)): ?>
    <tr>
        <td><?php echo $row['username']; ?></td>
        <td><?php echo $row['expiry_date']; ?></td>
        <td><?php echo $row['status']; ?></td>
        <td>
            <?php if($row['status'] == 'deactivated'): ?>
                <a href="?pay_id=<?php echo $row['id']; ?>">Bill Paid (Activate)</a>
            <?php else: ?>
                Active
            <?php endif; ?>
        </td>
    </tr>
    <?php endwhile; ?>
</table>
