<?php
/**
 * BIS Campaign — email campaign module router (email channel only).
 */
include_once(__DIR__ . "/../config/web_mysqlconnect.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'] ?? ''));

if ($token === 'bulk_email_report') {
    $sidebar_active = 'campaign_report';
} elseif ($token === 'email_queue_report') {
    $sidebar_active = 'email_queue';
} else {
    $sidebar_active = 'email_campaign';
}
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>
                <?php
                if ($token == 'web_bulksms') {
                    $_GET['campaign'] = 'Email';
                    include_once("omnichannel_config/web_bulksms.php");
                } else if ($token == 'bulk_email_report') {
                    include_once("omnichannel_config/bulk_email_report.php");
                } else if ($token == 'email_queue_report') {
                    include_once("omnichannel_config/email_queue_report.php");
                } else {
                    echo "<script>window.location.href = '../web_logout.php';</script>";
                    exit;
                }
                ?>
            </div>
        </div>
        <div class="footer">
            <?php include("includes/web_footer.php"); ?>
        </div>
    </div>
<script type="text/javascript" src="<?=$SiteURL?>public/js/jquery.datetimepicker.js"></script>
<script type="text/javascript" src="<?=$SiteURL?>public/bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="<?=$SiteURL?>public/bootstrap/js/bootstrap.js"></script>
<script type="text/javascript" src="<?=$SiteURL?>public/js/select2.min.js"></script>
<script type="text/javascript" src="<?=$SiteURL?>public/js/bulk_script.js"></script>
