<?php
require_once "common/header.php";
require_once "include/db_handler.php";

if (isset($_GET['id'])) {
    $id = $_GET['id'];
    $message = $db->getSingleMessage($id);
}
?>

<body>

<div class="container-fluid">
    <div class="row">
        <?php
        require_once "common/sidebar.php";
        ?>
        <div class="right-column">
            <?php
            require_once "common/navbar.php";
            ?>
            <main class="main-content p-5" role="main">
                <div class="row mb-5">
                    <div class="col-md-12">
                        <div class="card">
                            <div class="card-mailbox">
                                <div class="row mx-0">

                                    <div class="col-lg-12">
                                        <div class="mailbox-container mailbox-message-view" data-email-id="1">
                                            <div class="mailbox-controls clearfix">
                                                <div class="email-pager-top">
                                                    <div class="email-pager-container">
                                                        <div class="btn-group" role="group"
                                                             aria-label="Previous or Next Page">
                                                            <button type="button"
                                                                    class="btn btn-primary email-list-previous"
                                                                    data-toggle="tooltip" title="Previous">
                                                                <i class="batch-icon batch-icon-arrow-left"></i>
                                                            </button>
                                                            <button type="button"
                                                                    class="btn btn-primary email-list-next"
                                                                    data-toggle="tooltip" title="Next">
                                                                <i class="batch-icon batch-icon-arrow-right"></i>
                                                            </button>
                                                        </div>
                                                    </div>


                                                </div>
                                            </div>
                                            <div class="message-subject h2">
                                                <?php echo $message[0]['subject'] ?>

                                            </div>
                                            <div class="message-general-info-container">
                                                <div class="message-controls">
                                                    <div class="btn-group">

                                                        <button type="button" class="btn btn-secondary"
                                                                data-qp-link="compose.php?id=<?php echo $message[0]['id']; ?>">
                                                            <i class="batch-icon batch-icon-reply"></i>
                                                            Reply
                                                        </button>
                                                        <button type="button"
                                                                class="btn btn-secondary dropdown-toggle dropdown-toggle-split"
                                                                data-toggle="dropdown" aria-haspopup="true"
                                                                aria-expanded="false" data-flip="false">
                                                            <span class="sr-only">Toggle Dropdown</span>
                                                        </button>
                                                        <div class="dropdown-menu dropdown-menu-right"
                                                             aria-labelledby="reply-mail-dropdown">
                                                            <a class="dropdown-item" href="forward.php?id=<?php echo $message[0]['id']; ?>">
                                                                <i class="batch-icon batch-icon-options"></i>
                                                                Forward Message
                                                            </a>
                                                            <a class="dropdown-item" href="#">
                                                                <i class="batch-icon batch-icon-envelope"></i>
                                                                Mark as Unread
                                                            </a>
                                                            <a class="dropdown-item" href="#">
                                                                <i class="batch-icon batch-icon-bin-alt-2"></i>
                                                                Delete Message
                                                            </a>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="message-general-info">
                                                    <div class="message-sender-image">
                                                        <a href="#">
                                                            <div class="profile-picture bg-gradient bg-primary float-right d-flex mr-3">
                                                                <img src="assets/img/profile-pic.jpg" width="44"
                                                                     height="44">
                                                            </div>
                                                        </a>
                                                    </div>
                                                    <div class="message-sender">
                                                        From: <span
                                                                class="sender-name"><?php echo $message[0]['name'] ?></span>
                                                        <span class="sender-email">(<?php echo $message[0]['email'] ?>
                                                            )</span>
                                                    </div>
                                                    <div class="message-recepient">
                                                        To: <span class="recepient-name">Me</span> <span
                                                                class="send-date"><?php $db->timeAgo($message[0]['dateCreated']); ?></span>
                                                        - [ <a href="#"
                                                               id="show-others"><?php echo $message[0]['recipient'] ?></a>
                                                        ]
                                                    </div>

                                                </div>
                                            </div>
                                            <div class="message-body-container">
                                                <div class="message-body">
                                                    <p class="mb-4">
                                                        Hey Queenter,
                                                    </p>
                                                    <?php echo $message[0]['message'] ?>
                                                    <p class="mt-5">
                                                        Kind Regards,<br>
                                                        <?php echo $message[0]['name'] ?>
                                                    </p>
                                                </div>


                                            </div>

                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </main>
        </div>
    </div>
</div>
<?php
require_once "modals/add_article.php";
require_once "modals/logout.php";
require_once "modals/add_category.php";
require_once "common/footer.php";
?>
