<?php 
include 'config.php'; 
if(!isset($_SESSION['user_id'])) exit();

$client_id = $_GET['client_id'];
$client = $conn->query("SELECT name FROM clients WHERE id = $client_id")->fetch_assoc();
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Add Payment</title>
    <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;600&display=swap" rel="stylesheet">
    <style>
        body { font-family: 'Poppins', sans-serif; background: #f8f9fc; padding: 50px; }
        .form-card { background: #fff; max-width: 500px; margin: auto; padding: 30px; border-radius: 12px; box-shadow: 0 10px 25px rgba(0,0,0,0.05); }
        input, select, textarea { width: 100%; padding: 12px; margin: 10px 0; border: 1px solid #ddd; border-radius: 8px; box-sizing: border-box; }
        .btn { background: #1cc88a; color: white; padding: 12px; border: none; width: 100%; border-radius: 8px; font-weight: 600; cursor: pointer; }
    </style>
</head>
<body>
    <div class="form-card">
        <h2>Record Payment</h2>
        <p>Client: <b><?php echo $client['name']; ?></b></p>
        <hr style="margin: 15px 0; border: 0; border-top: 1px solid #eee;">
        
        <form action="handle_payment.php" method="POST">
            <input type="hidden" name="client_id" value="<?php echo $client_id; ?>">
            
            <label>Amount Received (PKR)</label>
            <input type="number" name="amount" placeholder="e.g. 50000" required>
            
            <label>Payment Method</label>
            <select name="method">
                <option value="Cash">Cash</option>
                <option value="Bank Transfer">Bank Transfer</option>
                <option value="Check">Check</option>
                <option value="Online">Online</option>
            </select>
            
            <label>Payment Date</label>
            <input type="date" name="p_date" value="<?php echo date('Y-m-d'); ?>" required>
            
            <label>Short Note</label>
            <textarea name="notes" placeholder="e.g. Advance for Umrah Ticket"></textarea>
            
            <button type="submit" class="btn">Save Payment</button>
        </form>
    </div>
</body>
</html>