<?php
/**
 * BIS Campaign — email administration router.
 */
include("admin/web_admin_function.php");

if (!empty($_GET['token'])) {
    $_SESSION['bis_sidebar_token'] = trim((string) base64_decode($_GET['token']));
}
$token = $_SESSION['bis_sidebar_token'] ?? trim((string) base64_decode($_GET['token'] ?? ''));

$smtp_tokens = [
    'view_imap_smtp', 'new_imap', 'new_smtp',
    'new_mail_sign', 'mail_sign', 'spam_mail', 'new_spam_mail', 'reply_template',
];
$sidebar_active = in_array($token, $smtp_tokens, true) ? 'email_smtp' : 'campaign_templates';
include('includes/crm_page_start.php');
?>
<body>
    <div class="wrapper">
        <div class="container-fluid">
            <div class="row" style="min-height:90vh">
                <div class="col-sm-2" style="padding-left:0">
                    <?php include "includes/sidebar.php"; ?>
                </div>
                <div class="col-sm-2 mt-3" style="padding-left:0">
                    <?php include("includes/web_master_services.php"); ?>
                </div>
                <div class="col-sm-8 mt-3" style="padding-left:0">
                    <div class="rightpanels">
                        <?php
                        if ($token == 'email_sms_template') {
                            include_once("admin/bulk_template.php");
                        } else if ($token == 'new_bulk_template') {
                            include_once("admin/new_bulk_template.php");
                        } else if ($token == 'view_imap_smtp') {
                            include_once("admin/web_imap_smtp.php");
                        } else if ($token == 'new_imap') {
                            include_once("admin/web_new_imap.php");
                        } else if ($token == 'new_smtp') {
                            include_once("admin/web_new_smtp.php");
                        } else if ($token == 'new_mail_sign') {
                            include_once("admin/new_mail_sign.php");
                        } else if ($token == 'mail_sign') {
                            include_once("admin/web_mail_sign.php");
                        } else if ($token == 'spam_mail') {
                            include_once("admin/spam_mail.php");
                        } else if ($token == 'new_spam_mail') {
                            include_once("admin/new_spam_mail.php");
                        } else if ($token == 'reply_template') {
                            include_once("admin/email_reply_templates.php");
                        } else {
                            echo "<script>window.location.href = '../web_logout.php';</script>";
                            exit;
                        }
                        ?>
                    </div>
                </div>
            </div>
        </div>
        <div class="footer">
            <?php include("includes/web_footer.php"); ?>
        </div>
    </div>
</body>
<script src="<?=$SiteURL?>public/js/select2.min.js"></script>
<script src="<?=$SiteURL?>public/js/admin_master.js"></script>
<script src="<?=$SiteURL?>public/js/doc-upload.js"></script>
<script src="<?=$SiteURL?>public/js/jquery-ui-timepicker-addon2.js"></script>
<script src="<?=$SiteURL?>public/js/jquery.datepick.js"></script>
