<?php
include('../include/db_conx.php');
isset($_SESSION['admin_login']);
if (!isset($_SESSION['admin_login'])) {
    header("location: auth-login.php");
    exit();
} else {
    include('../include/admin_head.php');
?>



    <body>

        <!-- <body data-layout="horizontal"> -->

        <!-- Begin page -->
        <div id="layout-wrapper">

            <?php include('../include/admin_header.php'); ?>

            <!-- ========== Left Sidebar Start ========== -->

            <!-- Left Sidebar End -->
            <?php include('../include/admin_sidebar.php'); ?>



            <!-- ============================================================== -->
            <!-- Start right Content here -->
            <!-- ============================================================== -->
            <div class="main-content">

                <div class="page-content">
                    <div class="container-fluid">

                        <!-- start page title -->
                        <div class="row">
                            <div class="col-12">
                                <div class="page-title-box d-sm-flex align-items-center justify-content-between">
                                    <h4 class="mb-sm-0 font-size-18">Security </h4>

                                    <div class="page-title-right">
                                        <ol class="breadcrumb m-0">
                                            <li class="breadcrumb-item"><a href="javascript: void(0);">Clients</a></li>
                                            <li class="breadcrumb-item active">Clients List</li>
                                        </ol>
                                    </div>

                                </div>
                            </div>
                        </div>
                        <!-- end page title -->



                        <div class="row">
                            <div class="col-lg-12">
                                <div class="card">
                                    <div class="card-body">
                                        <div class="row">
                                            <div class="col-sm">
                                                <div class="mb-4">
                                                    <a href='../register.php'>
                                                        <button type="button" class="btn btn-light waves-effect waves-light"><i class="bx bx-plus me-1"></i> Add New Client</button>

                                                    </a>

                                                </div>
                                            </div>
                                            <div class="col-sm-auto">
                                                <div class="d-flex align-items-center gap-1 mb-4">
                                                    <div class="input-group datepicker-range" style='line-height:2;'>
                                                        <?php echo $today ?>
                                                        &nbsp
                                                        <button class="input-group-text" id="date1" data-toggle><i class="bx bx-calendar-event"></i></button>
                                                    </div>

                                                </div>
                                            </div>
                                        </div>
                                        <!-- end row -->

                                        <div>
                                            <form method='POST'>
                                                <div class="mb-3">
                                                    <input type="email" name='msg_email' class="form-control" placeholder="To" required>
                                                </div>

                                                <div class="mb-3">
                                                    <input type="text" class="form-control" placeholder="Subject" name='msg_subject' required>
                                                </div>
                                                <div class="mb-3 email-editor">
                                                    <textarea id="email-editor" name='msg_content' required>

                                                    </textarea>
                                                </div>
                                                <button type="submit" name='msgSubmit' class="btn btn-primary waves-effect waves-light"> Submit</button>
                                            </form>

                                        </div>

                                        <?php
                                        if (isset($_POST['msgSubmit'])) {
                                            $msg_email = $db_conx->real_escape_string($_POST['msg_email']);
                                            $msg_subject = $db_conx->real_escape_string($_POST['msg_subject']);
                                            $msg_content = $db_conx->real_escape_string($_POST['msg_content']);


                                            $toEmail = $msg_email;


                                            // Subject
                                            $notificationSubject = $msg_subject;

                                            // Message
                                            $messageBody = '
                                                <!DOCTYPE html>
                                                <html lang="en">

                                                <head>
                                                    <meta charset="UTF-8">
                                                    <meta name="viewport" content="width=device-width, initial-scale=1.0">
                                                    <style>
                                                        body {
                                                            font-family: Arial, sans-serif;
                                                            margin: 0;
                                                            padding: 0;
                                                            background-color: #f4f4f4;
                                                        }

                                                        .container {
                                                            width: 100%;
                                                            max-width: 600px;
                                                            margin: auto;
                                                            background: #ffffff;
                                                            border-radius: 8px;
                                                            overflow: hidden;
                                                            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
                                                        }

                                                        .header {
                                                            background: #1c3f00;
                                                            color: #fff;
                                                            padding: 20px;
                                                            text-align: center;
                                                            margin: 10px;
                                                            border-radius: 10px;
                                                        }

                                                        .content {
                                                            padding: 20px;
                                                        }

                                                        .footer {
                                                            background: #f4f4f4;
                                                            text-align: center;
                                                            padding: 10px;
                                                            font-size: 12px;
                                                            color: #777777;
                                                        }

                                                        .logo {
                                                            width: 300px;
                                                    
                                                            margin: 2px auto;
                                                    
                                                        }

                                                        li {
                                                            margin-bottom: 15px;
                                                        }
                                                        img{
                                                        max-width: 100%;
                                                            }
                                                    </style>
                                                </head>

                                                <body>
                                                    <div class="logo">
                                                        <img src="https://' . $sitelink . '/images/logo.png" alt="' . $sitename . '" data-default="' . $sitename . '" />
                                                    </div>
                                                    <div class="container">

                                                        <div class="header">
                                                            <h2>' . $msg_subject . '</h2>
                                                        </div>
                                                        <div class="content">
                                                          ' . $msg_content . '
                                                        </div>
                                                        <div class="footer">
                                                            <p>&copy; 2024 Your Company. All rights reserved.</p>
                                                        </div>
                                                    </div>
                                                </body>

                                                </html>
                                                ';

                                            sendMail(
                                                $toEmail,
                                                $messageBody,
                                                $notificationSubject
                                            );
                                        }

                                        ?>




                                        <!-- end table responsive -->
                                    </div>
                                    <!-- end card body -->
                                </div>
                                <!-- end card -->
                            </div>
                            <!-- end col -->
                        </div>
                        <!-- end row -->
                    </div> <!-- container-fluid -->
                </div>
                <!-- End Page-content -->


                <?php include('../include/admin_footer.php'); ?>
            </div>
            <!-- end main content-->

        </div>
        <!-- END layout-wrapper -->




        <!-- Right bar overlay-->
        <div class="rightbar-overlay"></div>

        <!-- JAVASCRIPT -->
        <script src="assets/libs/jquery/jquery.min.js"></script>
        <script src="assets/libs/bootstrap/js/bootstrap.bundle.min.js"></script>
        <script src="assets/libs/metismenu/metisMenu.min.js"></script>
        <script src="assets/libs/simplebar/simplebar.min.js"></script>
        <script src="assets/libs/node-waves/waves.min.js"></script>
        <script src="assets/libs/feather-icons/feather.min.js"></script>
        <!-- pace js -->
        <script src="assets/libs/pace-js/pace.min.js"></script>

        <!--ckeditor js-->
        <script src="assets/libs/%40ckeditor/ckeditor5-build-classic/build/ckeditor.js"></script>

        <!-- email editor init -->
        <script src="assets/js/pages/email-editor.init.js"></script>

        <script src="assets/js/app.js"></script>
    </body>

    </html>

<?php  } ?>