<?php
include "classes/class.loader.php";
$html = new html();
$html->bacground_emoji();
$calls = new functions();
$db = new db();

?>
<style>
    body {
        background-color: #bebebee7;
        color: white;
        overflow: scroll;
    }
</style>
<div class="header">
    <input type="text" id="username" name="username" value="<?php echo $_SESSION['username']; ?>" readonly />
    <button onclick="window.location.href='home.php'">HOME</button>
    <button onclick="window.location.href='profile.php'">PAYMENTS</button>
    <button onclick="window.location.href='bookings.php'">BOOKINGS</button>
    <button onclick="window.location.href='news.php'" style="border: 2px solid white">NEWS</button>
    <button onclick="window.location.href='help.php'">HELP</button>
    <button onclick="window.location.href='services.php'">SERVICES</button>

</div>


<div class="home_container">
    <div class="container_wide">
        <form action="upload_news.php" method="post" id="news_form">
            <div class="container_wide" id="calendar_container" style="width:50vw">
                <label>HEADER</label>
                <input type="text" id="heading" name="heading" value="">
                <br>
                <label>DESCRIPTION</label>
                <textarea id="description" name="description" rows="10"></textarea>
                <br>
                <label>IMAGE</label>
                <input type="file" id="image" name="image">
                <br><br>
                <input type="submit" value="SEND">
            </div>
        </form>
        <div id="message"></div>
        <script>
            document.addEventListener("DOMContentLoaded", function () {
                document.getElementById('news_form').addEventListener('submit', function (e) {
                    alert("Uploading...");
                    e.preventDefault();
                    let formData = new FormData(this);
                    let xhr = new XMLHttpRequest();
                    xhr.open('POST', 'upload_news.php', true);
                    xhr.onload = function () {
                        if (xhr.status >= 200 && xhr.status < 400) {
                            document.getElementById('message').innerHTML = xhr.responseText;
                        }
                    };
                    xhr.send(formData);
                });
            });
        </script>



    </div>
</div>

