<?php
if (!isset($_GET['url']))
    $menu_name = 'Dashboard';
else {
    $url = explode('/', $_GET['url']);
    if ($url[0] == null)
        $menu_name = 'Dashboard';
    else
        $menu_name = $url[0];
    if (empty($menu_name))
        $menu_name = 'Dashboard';
}
$menu_name = strtolower($menu_name);
?>
<style type="text/css">
    #SideBarNav_Left .menu-items .detailed {
        width: 100%;
        padding-right: 0;

    }

    #SideBarNav_Left .menu-items .detailed>.title {
        height: 40px;
        line-height: 40px;

    }

    #SideBarNav_Left .menu-items .detailed .fa,
    #SideBarNav_Left .menu-items .detailed .pg-charts {
        color: #fff;
    }
</style>
<script src="<?php echo THEME_PATH; ?>js/jquery.nicescroll.min.js"></script>
<div class="sidebar-menu" id="SideBarNav_Left">
    <ul class="menu-items">
        <?php
        if ($permissions->hasPermission('Messages')) {
        ?>
            <li class="m-t-30 open">
                <a href="messages" class="detailed">
                    <span class=""><?php print CommonLanguage::getMessage('messages'); ?></span>
                    <span title="<?php print CommonLanguage::getMessage('messages'); ?>" class="icon-thumbnail ActiveSideBar_messages"><i class="fa fa-comments"></i></span>
                </a>
            </li>
        <?php
        }
        if ($permissions->hasPermission('Dashboard')) {
        ?>
            <li class="">
                <a href="Dashboard" class="detailed">
                    <span class=""><?php print CommonLanguage::getMessage('dashboard'); ?></span>
                    <span title="<?php print CommonLanguage::getMessage('dashboard'); ?>" class="icon-thumbnail ActiveSideBar_dashboard "><i class="pg-charts"></i></span>
                </a>
            </li>

        <?php
        }
        if ($permissions->hasPermission('Accounting')) {
        ?>
            <li class="">
                <a href="ACC" class="detailed">
                    <span class=""><?php print CommonLanguage::getMessage('accounting'); ?></span>
                    <span title="<?php print CommonLanguage::getMessage('accounting'); ?>" class="icon-thumbnail ActiveSideBar_acc "><i class="fa fa-money"></i></span>
                </a>
            </li>
        <?php
        }
        if ($permissions->hasPermission('Inventory')) {
        ?>
            <li class="">
                <a href="Inventory" class="detailed">
                    <!--<a href="Inventory/InventoryDashboard" class="detailed">-->
                    <span class=""><?php print CommonLanguage::getMessage('inventory'); ?></span>
                    <span title="<?php print CommonLanguage::getMessage('inventory'); ?>" class="icon-thumbnail ActiveSideBar_inventory"><i class="fa fa-archive"></i></span>
                </a>
            </li>
        <?php
        }
        if ($permissions->hasPermission('POS')) {
        ?>
            <li class="">
                <a href='<?php echo smc_session()['default_setting']['activate_smart_diner'] == 1  ? 'main_page' : 'main_pos'; ?>' class="detailed">
                    <span class=""><?php print CommonLanguage::getMessage('pos'); ?></span>
                    <span title="<?php print CommonLanguage::getMessage('pos'); ?>" class="icon-thumbnail ActiveSideBar_pos"><i class="fa fa-usd"></i></span>
                </a>
            </li>
        <?php
        }
        if ($permissions->hasPermission('pos_distribution')) {
        ?>
            <li class="">
                <a href='<?php echo  'pos_distribution'; ?>' class="detailed">
                    <span class=""><?php print CommonLanguage::getMessage('pos_distribution'); ?></span>
                    <span title="<?php print CommonLanguage::getMessage('pos_distribution'); ?>" class="icon-thumbnail ActiveSideBar_pos"><i class="fa fa-tasks"></i></span>
                </a>
            </li>
        <?php
        }
        if ($permissions->hasPermission('HRM')) {
        ?>
            <li class="">
                <a href="HRM" class="detailed">
                    <!--<a href="HRM/HRMDashboard" class="detailed">-->
                    <span class=""><?php print CommonLanguage::getMessage('hrm'); ?></span>
                    <span title="<?php print CommonLanguage::getMessage('hrm'); ?>" class="icon-thumbnail ActiveSideBar_hrm"><i class="fa fa-user"></i></span>
                </a>
            </li>
        <?php
        }
        if ($permissions->hasPermission('Stock')) {
        ?>
            <li class="">
                <a href="Stock" class="detailed">
                    <!--<a href="Stock/StockDashboard" class="detailed">-->
                    <span class=""><?php print CommonLanguage::getMessage('stock'); ?></span>
                    <span title="<?php print CommonLanguage::getMessage('stock'); ?>" class="icon-thumbnail ActiveSideBar_stock"><i class="fa fa-th-large"></i></span>
                </a>
            </li>
        <?php
        }
        if ($permissions->hasPermission('Garage')) {
        ?>
            <li class="">
                <a href="Garage" class="detailed">
                    <!--<a href="Garage/GarageDashboard" class="detailed">-->
                    <span class=""><?php print CommonLanguage::getMessage('garage'); ?></span>
                    <span title="<?php print CommonLanguage::getMessage('garage'); ?>" class="icon-thumbnail ActiveSideBar_garage"><i class="fa fa-truck"></i></span>
                </a>
            </li>

        <?php
        }
        if ($permissions->hasPermission('production')) {
        ?>
            <li class="">
                <a href="Maintenance" class="detailed">
                    <!--<a href="Garage/GarageDashboard" class="detailed">-->
                    <span class=""><?php print CommonLanguage::getMessage('production'); ?></span>
                    <span title="<?php print CommonLanguage::getMessage('production'); ?>" class="icon-thumbnail ActiveSideBar_maintenance"><i class="fa fa-wrench"></i></span>
                </a>
            </li>
        <?php
        }
        if ($permissions->hasPermission('Setting')) {
        ?>
            <li class="">
                <a href="Settings" class="detailed">
                    <!--<a href="Garage/GarageDashboard" class="detailed">-->
                    <span class=""><?php print CommonLanguage::getMessage('setting'); ?></span>
                    <span title="<?php print CommonLanguage::getMessage('setting'); ?>" class="icon-thumbnail ActiveSideBar_settings"><i class="fa fa-gear"></i></span>
                </a>
            </li>
        <?php
        }
        if ($permissions->hasPermission('general')) {
        ?>
            <li class="">
                <a href="general" class="detailed">
                    <!--<a href="Garage/GarageDashboard" class="detailed">-->
                    <span class=""><?php print CommonLanguage::getMessage('general'); ?></span>
                    <span title="<?php print CommonLanguage::getMessage('general'); ?>" class="icon-thumbnail ActiveSideBar_general"><i class="fa fa-cogs"></i></span>
                </a>
            </li>
        <?php
        }
        if ($permissions->hasPermission('crm')) {
        ?>
            <li class="">
                <a href="crm" class="detailed">
                    <!--<a href="Garage/GarageDashboard" class="detailed">-->
                    <span class=""><?php print CommonLanguage::getMessage('crm'); ?></span>
                    <span title="<?php print CommonLanguage::getMessage('crm'); ?>" class="icon-thumbnail ActiveSideBar_crm"><i class="fa fa-user"></i></span>
                </a>
            </li>
        <?php }
        if ($permissions->hasPermission('ticketing')) {
        ?>
            <li class="">
                <a href="Ticketing" class="detailed">
                    <!--<a href="Garage/GarageDashboard" class="detailed">-->
                    <span class=""><?php print CommonLanguage::getMessage('ticketing'); ?></span>
                    <span title="<?php print CommonLanguage::getMessage('ticketing'); ?>" class="icon-thumbnail ActiveSideBar_ticketing"><i class="fa fa-ticket"></i></span>
                </a>
            </li>
        <?php }
        if ($permissions->hasPermission('others_module')) { ?>
            <li class="">
                <a href="javascript:;"><span class="title">Others</span>
                    <span class="arrow "></span></a>
                <span class="icon-thumbnail"><i class="fa fa-bars"></i></span>
                <ul class="sub-menu">
                    <?php if ($permissions->hasPermission('db_backup')) { ?>
                        <li class="">
                            <a href="backup.php?is_download=1"><?php print CommonLanguage::getMessage('backup') ?></a>
                            <!--<span class="icon-thumbnail"></span>-->
                            <span title="<?php print CommonLanguage::getMessage('backup'); ?>" class="icon-thumbnail ActiveSideBar_backup"><i class="fa fa-cloud-download"></i></span>

                        </li>
                    <?php }
                    if ($permissions->hasPermission('app_tracking_map')) { ?>
                        <li class="">
                            <a href="others/app_tracking_map"><?php echo CommonLanguage::getMessage('track_map') ?></a>
                            <span class="icon-thumbnail"><i class="fa fa-map"></i></span>
                        </li>
                    <?php }
                    if ($permissions->hasPermission('db_sync_backup')) { ?>
                        <li class="">
                            <a href="sync_backup/send_db_ftp.php"><?php print CommonLanguage::getMessage('sync_backup') ?></a>
                            <!--<span class="icon-thumbnail"></span>-->
                            <span title="<?php print CommonLanguage::getMessage('sync_backup'); ?>" class="icon-thumbnail ActiveSideBar_backup"><i class="fa fa-cloud-download"></i></span>

                        </li>
                    <?php } ?>

                </ul>
            </li>

        <?php }
        $website_panel = smc_session()['default_setting']['website_panel'];
        if ($permissions->hasPermission('website_panel') && !empty($website_panel)) {
            $website_panel = json_decode($website_panel, true); ?>
            <li class="">
                <a href="javascript:void(0);" data-src="<?php echo $website_panel['url'] . "/admin/Admin?is_pop=1&smc__auto_login=" . CommonFunctions::encryptAutoLogin($website_panel['user_name'], $website_panel['password']); ?>" class="detailed openFrame">
                    <span class=""><?php print CommonLanguage::getMessage('website_panel'); ?></span>
                    <span title="<?php print CommonLanguage::getMessage('website_panel'); ?>" class="icon-thumbnail ActiveSideBar_website_panel"><i class="fa fa-columns"></i></span>
                </a>
            </li>
        <?php } ?>
    </ul>
    <div class="clearfix"></div>
</div>
</nav>

<script>
    var current_page = "<?php echo $menu_name; ?>";
    var PageStyles = {
        "dashboard": "bg-danger",
        "acc": "bg-complete",
        "inventory": "bg-primary",
        "pos": "bg-info",
        "hrm": "bg-success",
        "production": "bg-danger",
        "stock": "bg-complete-darker",
        "garage": "bg-success-darker",
        "score": "bg-success-darker",
        "useractivity": "bg-logging",
        "settings": "bg-info-light",
        "crm": "bg-complete-dark",
        "maintenance": "bg-success-dark",
        "general": "bg-primary-darker",
        "ticketing": "bg-complete",
    }

    $("#SideBarNav_Left span.ActiveSideBar_" + current_page).addClass(PageStyles[current_page])
</script>