<?php
require_once "includes/inc_all_user.php";

$row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT user_config_calendar_first_day FROM user_settings WHERE user_id = $session_user_id"));
$user_config_calendar_first_day = intval($row['user_config_calendar_first_day']);

?>

<div class="card card-dark">
    <div class="card-header">
        <h3 class="card-title"><i class="fas fa-fw fa-globe me-2"></i>Preferences</h3>
    </div>
    <div class="card-body">

        <form action="post.php" method="post" enctype="multipart/form-data" autocomplete="off">
            <input type="hidden" name="csrf_token" value="<?= $_SESSION['csrf_token'] ?>">

            <div class="mb-3">
                <h5>Dark Mode</h5>

                <div class="btn-group" role="group">
                    <input class="btn-check" type="radio" name="dark_mode" id="light-mode" autocomplete="off" <?php if ($user_config_theme_dark === 0) { echo "checked"; } ?>>
                    <label class="btn btn-outline-primary" for="light-mode"><i class="fas fa-sun me-2"></i>Light</label>
                    <input class="btn-check" type="radio" name="dark_mode" id="dark-mode" autocomplete="off" value="1" <?php if ($user_config_theme_dark === 1) { echo "checked"; } ?>>
                    <label class="btn btn-outline-dark" for="dark-mode"><i class="fas fa-moon me-2"></i>Dark</label>
                </div>
            </div>

            <div class="mb-3">
                <label>Calendar starts on<strong class="text-danger">*</strong></label>
                <div class="input-group">
                        <span class="input-group-text"><i class="fa fa-fw fa-calendar-day"></i></span>
                    <select class="form-select select2" name="calendar_first_day" required>
                        <option <?php if ($user_config_calendar_first_day == '0') { echo "selected"; } ?> value="0" >Sunday</option>
                        <option <?php if ($user_config_calendar_first_day == '1') { echo "selected"; } ?> value="1" >Monday</option>
                    </select>
                </div>
            </div>

            <button type="submit" name="edit_your_user_preferences" class="btn btn-primary"><i class="fas fa-check me-2"></i>Save</button>

        </form>

    </div>
</div>

<?php
require_once "../../includes/footer.php";
