<!DOCTYPE html>
<html lang="fa">
<head>
    <meta charset="UTF-8">
    <title>فرم ثبت نامه</title>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/persian-datepicker@0.4.5/dist/css/persian-datepicker.min.css">
    <script src="https://cdn.jsdelivr.net/npm/persian-datepicker@0.4.5/dist/js/persian-datepicker.min.js"></script>
</head>
<body>
    <h2>فرم ثبت نامه</h2>
    <form action="submit_letter.php" method="POST">
        <label for="subject">موضوع نامه:</label>
        <input type="text" id="subject" name="subject" required><br><br>

        <label for="description">متن توضیحات:</label>
        <textarea id="description" name="description" rows="4" cols="50" required></textarea><br><br>

        <label for="action_time">زمان مجاز اقدام:</label>
        <input type="text" id="action_time" name="action_time" required><br><br>

        <label for="assignee">ارجاع گیرنده:</label>
        <select id="assignee" name="assignee" required>
            <?php
            require_once "db_connection.php";
            $conn = new mysqli("localhost", "anreoalb_archive", "Shahrooz@2681", "anreoalb_archive");
            if ($conn->connect_error) {
                die("Connection failed: " . $conn->connect_error);
            }
            $query = "SELECT user_id, first_name, last_name FROM users";
            $result = $conn->query($query);
            if ($result->num_rows > 0) {
                while ($row = $result->fetch_assoc()) {
                    echo "<option value='" . $row['user_id'] . "'>" . $row['first_name'] . " " . $row['last_name'] . "</option>";
                }
            }
            $conn->close();
            ?>
        </select><br><br>

        <input type="submit" value="ثبت نامه">
    </form>

    <script>
        $(document).ready(function() {
            $('#action_time').persianDatepicker({
                timePicker: {
                    enabled: true
                },
                format: 'YYYY/MM/DD HH:mm',
                autoClose: true
            });
        });
    </script>
</body>
</html>
