<?php
include('db_connection.php');
include 'header.php';
// Fetch all students for the dropdown
$students_query = "SELECT student_id, name FROM students";
$students_result = $conn->query($students_query);

?>

<!DOCTYPE html>
<html>
<head>
    <title>Issue Receipt</title>
    <style>
        form {
            max-width: 600px;
            margin: 50px auto;
            padding: 20px;
            background: #f4f7f8;
            border-radius: 8px;
            box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
        }

        form h2 {
            margin-bottom: 20px;
            font-size: 24px;
            font-weight: 600;
            color: #333;
        }

        label {
            display: block;
            margin-bottom: 10px;
            font-weight: 500;
            color: #666;
        }

        input[type="text"],
        input[type="number"],
        select {
            width: 100%;
            padding: 10px;
            margin-bottom: 20px;
            border: 1px solid #ccc;
            border-radius: 4px;
            box-sizing: border-box;
        }

        button[type="submit"] {
            width: 100%;
            padding: 10px;
            background: #007bff;
            border: none;
            border-radius: 4px;
            color: #fff;
            font-size: 16px;
            cursor: pointer;
        }

        button[type="submit"]:hover {
            background: #0056b3;
        }
    </style>
</head>
<body>
    <h2>Issue Receipt</h2>
    <form action="process_issue_receipt.php" method="post">
        <label for="student_id">Select Student:</label>
        <select name="student_id" id="student_id" required>
            <option value="">Select Student</option>
            <?php while ($row = $students_result->fetch_assoc()): ?>
                <option value="<?php echo htmlspecialchars($row['student_id']); ?>">
                    <?php echo htmlspecialchars($row['name']); ?>
                </option>
            <?php endwhile; ?>
        </select>

        <label for="amount">Amount Paid:</label>
        <input type="number" name="amount" id="amount" step="0.01" required>

        <label for="purpose">Purpose of Payment:</label>
        <input type="text" name="purpose" id="purpose" required>

        <button type="submit">Issue Receipt</button>
    </form>
</body>
</html>

<?php
$conn->close();
?>
