<?php
/* Smarty version 4.5.3, created on 2024-12-03 18:50:49
  from '/var/www/html/admin/ui/ui_custom/dashboard.tpl' */

/* @var Smarty_Internal_Template $_smarty_tpl */
if ($_smarty_tpl->_decodeProperties($_smarty_tpl, array (
  'version' => '4.5.3',
  'unifunc' => 'content_674f28d9c362e1_73667848',
  'has_nocache_code' => false,
  'file_dependency' => 
  array (
    'f580f270b2ef83300f09d95b3bc50ab4bc61f86a' => 
    array (
      0 => '/var/www/html/admin/ui/ui_custom/dashboard.tpl',
      1 => 1733095419,
      2 => 'file',
    ),
  ),
  'includes' => 
  array (
    'file:sections/header.tpl' => 1,
    'file:pagination.tpl' => 1,
    'file:sections/footer.tpl' => 1,
  ),
),false)) {
function content_674f28d9c362e1_73667848 (Smarty_Internal_Template $_smarty_tpl) {
$_smarty_tpl->_subTemplateRender("file:sections/header.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, $_smarty_tpl->cache_lifetime, array(), 0, false);
?>
<style>
    /* Base card styling with smooth hover effects */
    .card, .shadow-sm {
        transition: transform 0.3s ease, box-shadow 0.3s ease; /* Smooth zoom and shadow transitions */
    }
    
    /* Hover effect for all cards */
    .card:hover, .shadow-sm:hover {
        transform: scale(1.05); /* Slight zoom effect */
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2); /* Enhanced shadow */
    }
</style>
<div class="row mb-4">
    <?php if (in_array($_smarty_tpl->tpl_vars['_admin']->value['user_type'],array('SuperAdmin','Admin','Report'))) {?>
        <div class="col-lg-3 col-md-6 col-sm-12 mb-3">
            <a href="<?php echo $_smarty_tpl->tpl_vars['_url']->value;?>
reports/by-date" class="text-decoration-none">
                <div class="card shadow h-100" style="border-left: 5px solid #3444d5; cursor: pointer;">
                    <div class="card-body p-3">
                        <div class="d-flex justify-content-between align-items-center">
                            <div>
                                <div class="text-muted small" style="font-size: 1rem;"><?php echo Lang::T('Income Today');?>
</div>
                                <div class="font-weight-bold" style="font-size: 1.75rem;">
                                    <sup><?php echo $_smarty_tpl->tpl_vars['_c']->value['currency_code'];?>
</sup>
                                    <?php echo number_format($_smarty_tpl->tpl_vars['iday']->value,0,$_smarty_tpl->tpl_vars['_c']->value['dec_point'],$_smarty_tpl->tpl_vars['_c']->value['thousands_sep']);?>

                                </div>
                            </div>
                            <i class="fas fa-calendar-day text-info" style="font-size: 2.5rem;"></i>
                        </div>
                    </div>
                </div>
            </a>
        </div>

        <div class="col-lg-3 col-md-6 col-sm-12 mb-3">
            <a href="<?php echo $_smarty_tpl->tpl_vars['_url']->value;?>
reports/by-period" class="text-decoration-none">
                <div class="card shadow h-100" style="border-left: 5px solid #28a745; cursor: pointer;">
                    <div class="card-body p-3">
                        <div class="d-flex justify-content-between align-items-center">
                            <div>
                                <div class="text-muted small" style="font-size: 1rem;"><?php echo Lang::T('Income This Month');?>
</div>
                                <div class="font-weight-bold" style="font-size: 1.75rem;">
                                    <sup><?php echo $_smarty_tpl->tpl_vars['_c']->value['currency_code'];?>
</sup>
                                    <?php if ((isset($_smarty_tpl->tpl_vars['imonth']->value))) {
echo number_format($_smarty_tpl->tpl_vars['imonth']->value,0,$_smarty_tpl->tpl_vars['_c']->value['dec_point'],$_smarty_tpl->tpl_vars['_c']->value['thousands_sep']);
} else { ?>N/A<?php }?>
                                </div>
                            </div>
                            <i class="fas fa-calendar-alt text-success" style="font-size: 2.5rem;"></i>
                        </div>
                    </div>
                </div>
            </a>
        </div>
        
    <?php }?>

    <div class="col-lg-3 col-md-6 col-sm-12 mb-3">
        <a href="<?php echo $_smarty_tpl->tpl_vars['_url']->value;?>
plan/list" class="text-decoration-none">
            <div class="card shadow h-100" style="border-left: 5px solid #ffc107; cursor: pointer;">
                <div class="card-body p-3">
                    <div class="d-flex justify-content-between align-items-center">
                        <div>
                            <div class="text-muted small" style="font-size: 1rem;"><?php echo Lang::T('Users Active');?>
</div>
                            <div class="font-weight-bold" style="font-size: 1.75rem;"><?php echo $_smarty_tpl->tpl_vars['u_act']->value;?>
</div>
                        </div>
                        <i class="ion ion-person text-warning" style="font-size: 2.5rem;"></i>
                    </div>
                </div>
            </div>
        </a>
    </div>
    
    <div class="col-lg-3 col-md-6 col-sm-12 mb-3">
        <a href="<?php echo $_smarty_tpl->tpl_vars['_url']->value;?>
customers/list" class="text-decoration-none">
            <div class="card shadow h-100" style="border-left: 5px solid #dc3545; cursor: pointer;">
                <div class="card-body p-3">
                    <div class="d-flex justify-content-between align-items-center">
                        <div>
                            <div class="text-muted small" style="font-size: 1rem;"><?php echo Lang::T('Total Users');?>
</div>
                            <div class="font-weight-bold" style="font-size: 1.75rem;"><?php echo $_smarty_tpl->tpl_vars['c_all']->value;?>
</div>
                        </div>
                        <i class="fas fa-users text-danger" style="font-size: 2.5rem;"></i>
                    </div>
                </div>
            </div>
        </a>
    </div>
</div>


<div class="row mb-4">
<div class="col-xl-2 col-xxl-3 col-lg-4 col-sm-4 mb-3">
    <a href="<?php echo $_smarty_tpl->tpl_vars['_url']->value;?>
customers/list" class="text-decoration-none">
        <div class="card shadow-sm h-100" style="border-left: 5px solid #3444d5; cursor: pointer; height: 60px;">
            <div class="card-body p-1">
                <div class="d-flex justify-content-between align-items-center">
                    <div>
                        <div class="text-muted small"><?php echo Lang::T('Online Users');?>
</div>
                        <h4 class="font-weight-bold" id="total-online-users"></h4>
                    </div>
                    <i class="fas fa-users text-secondary" style="font-size: 2.5rem;"></i>
                </div>
            </div>
        </div>
    </a>
</div>
<div class="col-xl-2 col-xxl-3 col-lg-4 col-sm-4 mb-3">
    <a href="<?php echo $_smarty_tpl->tpl_vars['_url']->value;?>
data/usage" class="text-decoration-none">
        <div class="card shadow-sm h-100" style="border-left: 5px solid #FFC107; cursor: pointer; height: 60px;">
            <div class="card-body p-1">
                <div class="d-flex justify-content-between align-items-center">
                    <div>
                        <div class="text-muted small"><?php echo Lang::T('Data Usage');?>
</div>
                        <h4 class="font-weight-bold" id="total_data"></h4>
                    </div>
                    <i class="fas fa-signal text-warning" style="font-size: 2.5rem;"></i>
                </div>
            </div>
        </div>
    </a>
</div>
<div class="col-xl-2 col-xxl-3 col-lg-4 col-sm-4 mb-3">
    <a href="<?php echo $_smarty_tpl->tpl_vars['_url']->value;?>
onlineusers/hotspot" class="text-decoration-none">
        <div class="card shadow-sm h-100" style="border-left: 5px solid #28A745; cursor: pointer; height: 60px;">
            <div class="card-body p-1">
                <div class="d-flex justify-content-between align-items-center">
                    <div>
                        <div class="text-muted small"><?php echo Lang::T('Online Hotspot Users');?>
</div>
                        <h4 class="font-weight-bold" id="online-hotspot-users"></h4>
                    </div>
                    <i class="fas fa-wifi text-success" style="font-size: 2.5rem;"></i>
                </div>
            </div>
        </div>
    </a>
</div>
<div class="col-xl-2 col-xxl-3 col-lg-4 col-sm-4 mb-3">
    <a href="<?php echo $_smarty_tpl->tpl_vars['_url']->value;?>
plugin/pppoe_monitor_router_menu" class="text-decoration-none">
        <div class="card shadow-sm h-100" style="border-left: 5px solid #17A2B8; cursor: pointer; height: 60px;">
            <div class="card-body p-1">
                <div class="d-flex justify-content-between align-items-center">
                    <div>
                        <div class="text-muted small"><?php echo Lang::T('Online PPPoE Users');?>
</div>
                        <h4 class="font-weight-bold" id="online-ppp-users"></h4>
                    </div>
                    <i class="fas fa-network-wired text-info" style="font-size: 2.5rem;"></i>
                </div>
            </div>
        </div>
    </a>
</div>
</div>

<div class="row mb-4">
    <div class="col-md-4">
        <?php if ($_smarty_tpl->tpl_vars['run_date']->value) {?>
            <?php $_smarty_tpl->_assignInScope('current_time', time());?>
            <?php $_smarty_tpl->_assignInScope('run_time', strtotime($_smarty_tpl->tpl_vars['run_date']->value));?>
            <?php if ($_smarty_tpl->tpl_vars['current_time']->value-$_smarty_tpl->tpl_vars['run_time']->value > 3600) {?>
                <div class="panel panel-cron-warning mb-3">
                    <div class="panel-heading"><i class="fa fa-clock-o"></i> &nbsp; <?php echo Lang::T('Cron has not run for over 1 hour. Please check your setup.');?>
</div>
                </div>
            <?php } else { ?>
                <div class="panel panel-cron-success mb-3">
                    <div class="panel-heading"><?php echo Lang::T('Cron Job last ran on');?>
: <?php echo $_smarty_tpl->tpl_vars['run_date']->value;?>
</div>
                </div>
            <?php }?>
        <?php } else { ?>
            <div class="panel panel-cron-danger mb-3">
                <div class="panel-heading"><i class="fa fa-warning"></i> &nbsp; <?php echo Lang::T('Cron appear not been setup, please check your cron setup.');?>
</div>
            </div>
        <?php }?>
    </div>
    <div class="col-md-4">
        <?php if ($_smarty_tpl->tpl_vars['_c']->value['router_check'] && count($_smarty_tpl->tpl_vars['routeroffs']->value) > 0) {?>
        <div class="panel panel-danger">
            <div class="panel-heading text-bold"><?php echo Lang::T('Routers Offline');?>
</div>
            <div class="table-responsive">
                <table class="table table-condensed">
                    <tbody>
                        <?php
$_from = $_smarty_tpl->smarty->ext->_foreach->init($_smarty_tpl, $_smarty_tpl->tpl_vars['routeroffs']->value, 'ros');
$_smarty_tpl->tpl_vars['ros']->do_else = true;
if ($_from !== null) foreach ($_from as $_smarty_tpl->tpl_vars['ros']->value) {
$_smarty_tpl->tpl_vars['ros']->do_else = false;
?>
                            <tr>
                                <td><a href="<?php echo $_smarty_tpl->tpl_vars['_url']->value;?>
routers/edit/<?php echo $_smarty_tpl->tpl_vars['ros']->value['id'];?>
" class="text-bold text-red"><?php echo $_smarty_tpl->tpl_vars['ros']->value['name'];?>
</a></td>
                                <td data-toggle="tooltip" data-placement="top" class="text-red"
                                        title="<?php echo Lang::dateTimeFormat($_smarty_tpl->tpl_vars['ros']->value['last_seen']);?>
"><?php echo Lang::timeElapsed($_smarty_tpl->tpl_vars['ros']->value['last_seen']);?>

                                </td>
                            </tr>
                        <?php
}
$_smarty_tpl->smarty->ext->_foreach->restore($_smarty_tpl, 1);?>
                    </tbody>
                </table>
            </div>
        </div>
    <?php }?>
    </div>
    <div class="col-md-4">
        <?php if ($_smarty_tpl->tpl_vars['_c']->value['hide_pg'] != 'yes') {?>
            <div class="panel panel-success mb-3">
                <div class="panel-heading"><?php echo Lang::T('Payment Gateway');?>
: <?php echo str_replace(',',', ',$_smarty_tpl->tpl_vars['_c']->value['payment_gateway']);?>
</div>
            </div>
        <?php }?>
    </div>
</div>
    
    
    <ol class="breadcrumb">
        <li><?php echo Lang::dateFormat($_smarty_tpl->tpl_vars['start_date']->value);?>
-</li>
        <li><?php echo Lang::dateFormat($_smarty_tpl->tpl_vars['current_date']->value);?>
</li>
        <?php if ($_smarty_tpl->tpl_vars['_c']->value['enable_balance'] == 'yes' && in_array($_smarty_tpl->tpl_vars['_admin']->value['user_type'],array('SuperAdmin','Admin','Report'))) {?>
            <li onclick="window.location.href = '<?php echo $_smarty_tpl->tpl_vars['_url']->value;?>
customers&search=&order=balance&filter=Active&orderby=desc'" style="cursor: pointer;">
                <?php echo Lang::T('Customer Balance');?>
 <sup><?php echo $_smarty_tpl->tpl_vars['_c']->value['currency_code'];?>
</sup>
                <b><?php echo number_format($_smarty_tpl->tpl_vars['cb']->value,0,$_smarty_tpl->tpl_vars['_c']->value['dec_point'],$_smarty_tpl->tpl_vars['_c']->value['thousands_sep']);?>
</b>
            </li>
        <?php }?>
    </ol>
    


    <div class="row">
        <div class="col-md-6">
            <?php if ($_smarty_tpl->tpl_vars['_c']->value['hide_mrc'] != 'yes') {?>
                <div class="card card-solid">
                    <div class="card-header">
                        <i class="fa fa-th"></i> <!-- Uniform icon size -->
                        <h3 class="card-title"><?php echo Lang::T('Daily Active Users');?>
</h3>
                        <div class="card-tools pull-right"></div>
                    </div>
                    <div class="card-body border-radius-none">
                        <canvas class="chart" id="activeUsersChart" style="height: 250px;"></canvas>
                    </div>
                </div>
            <?php }?>
        </div>
    
        <div class="col-md-6">
            <?php if ($_smarty_tpl->tpl_vars['_c']->value['hide_tms'] != 'yes') {?>
                <div class="card card-solid">
                    <div class="card-header">
                        <i class="fa fa-inbox"></i> <!-- Uniform icon size -->
                        <h3 class="card-title"><?php echo Lang::T('Daily Sales');?>
</h3>
                        <div class="card-tools pull-right"></div>
                    </div>
                    <div class="card-body border-radius-none">
                        <canvas class="chart" id="dailySalesChart" style="height: 250px;"></canvas>
                    </div>
                </div>
            <?php }?>
        </div>
    </div>
    
    <div class="row">
        <div class="col-md-6">
            <?php if ($_smarty_tpl->tpl_vars['_c']->value['hide_tms'] != 'yes') {?>
                <div class="card card-solid">
                    <div class="card-header">
                        <i class="fa fa-inbox"></i> <!-- Uniform icon size -->
                        <h3 class="card-title"><?php echo Lang::T('Total Monthly Sales');?>
</h3>
                        <div class="card-tools pull-right"></div>
                    </div>
                    <div class="card-body border-radius-none">
                        <canvas class="chart" id="salesChart" style="height: 250px;"></canvas>
                    </div>
                </div>
            <?php }?>
        </div>
    
        <div class="col-md-6">
            <?php if ($_smarty_tpl->tpl_vars['_c']->value['hide_mrc'] != 'yes') {?>
                <div class="card card-solid">
                    <div class="card-header">
                        <i class="fa fa-th"></i> <!-- Uniform icon size -->
                        <h3 class="card-title"><?php echo Lang::T('Monthly Registered Customers');?>
</h3>
                        <div class="card-tools pull-right"></div>
                    </div>
                    <div class="card-body border-radius-none">
                        <canvas class="chart" id="chart" style="height: 250px;"></canvas>
                    </div>
                </div>
            <?php }?>
        </div>
    
        <div class="col-md-12">
            <div class="card card-info card-hovered mb20 activities">
                <div class="card-header">
                    <h3 class="text-xl font-medium mb-2">
                        <i class="fa fa-credit-card"></i> <!-- Uniform icon size -->
                        <?php echo Lang::T('Recent Transactions');?>

                    </h3>
                </div>
                <div class="card-body">
                    <div class="table-responsive mt-4">
                        <table class="table table-striped table-bordered table-hover">
                            <thead>
                                <tr>
                                    <th>Username</th>
                                    <th>Price</th>
                                    <th>Recharged On</th>
                                    <th>Recharged Time</th>
                                    <th>Type</th>
                                    <th>Method</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php
$_from = $_smarty_tpl->smarty->ext->_foreach->init($_smarty_tpl, $_smarty_tpl->tpl_vars['latestTransactions']->value, 'transaction');
$_smarty_tpl->tpl_vars['transaction']->do_else = true;
if ($_from !== null) foreach ($_from as $_smarty_tpl->tpl_vars['transaction']->value) {
$_smarty_tpl->tpl_vars['transaction']->do_else = false;
?>
                                <tr>
                                    <!-- Make the username a clickable link that redirects to the customer page -->
                                    <td>
                                        <a href="<?php echo $_smarty_tpl->tpl_vars['_url']->value;?>
customers/viewu/<?php echo $_smarty_tpl->tpl_vars['transaction']->value['username'];?>
" class="text-decoration-none">
                                            <?php echo $_smarty_tpl->tpl_vars['transaction']->value['username'];?>

                                        </a>
                                    </td>
                                    <td><?php echo $_smarty_tpl->tpl_vars['transaction']->value['price'];?>
</td>
                                    <td><?php echo $_smarty_tpl->tpl_vars['transaction']->value['recharged_on'];?>
</td>
                                    <td><?php echo $_smarty_tpl->tpl_vars['transaction']->value['recharged_time'];?>
</td>
                                    <td><?php echo $_smarty_tpl->tpl_vars['transaction']->value['type'];?>
</td>
                                    <td><?php echo $_smarty_tpl->tpl_vars['transaction']->value['method'];?>
</td>
                                </tr>
                                <?php
}
$_smarty_tpl->smarty->ext->_foreach->restore($_smarty_tpl, 1);?>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
    
    <div class="row">
        <!-- Hotspot Package Utilization Chart -->
        <div class="col-md-6">
            <?php if ($_smarty_tpl->tpl_vars['_c']->value['hide_tms'] != 'yes') {?>
                <div class="card card-solid">
                    <div class="card-header">
                        <i class="fa fa-wifi"></i> <!-- Uniform icon size -->
                        <h3 class="card-title"><?php echo Lang::T('Hotspot Package Utilization');?>
</h3>
                        <div class="card-tools pull-right"></div>
                    </div>
                    <div class="card-body border-radius-none">
                        <canvas class="chart" id="hotspotChart" style="height: 50px;"></canvas>
                    </div>
                </div>
            <?php }?>
        </div>
    
        <!-- PPPOE Package Utilization Chart -->
        <div class="col-md-6">
            <?php if ($_smarty_tpl->tpl_vars['_c']->value['hide_mrc'] != 'yes') {?>
                <div class="card card-solid">
                    <div class="card-header">
                        <i class="fa fa-plug"></i> <!-- Uniform icon size -->
                        <h3 class="card-title"><?php echo Lang::T('PPPOE Package Utilization');?>
</h3>
                        <div class="card-tools pull-right"></div>
                    </div>
                    <div class="card-body border-radius-none">
                        <canvas class="chart" id="pppoeChart" style="height: 250px;"></canvas>
                    </div>
                </div>
            <?php }?>
        </div>
    </div>
    
    <div class="row">
        <!-- Expired Users Column -->
        <div class="col-md-8">
            <div class="card card-warning mb-3">
                <div class="card-header">
                    <h3>
                        <i class="fa fa-user-times"></i> <!-- Uniform icon size -->
                        <?php echo Lang::T('User Expired, Today');?>

                    </h3>
                </div>
                <div class="card-body">
                    <table class="table table-bordered">
                        <caption><?php echo Lang::T('List of users whose accounts expired today');?>
</caption>
                        <thead>
                            <tr>
                                <th scope="col"><?php echo Lang::T('Username');?>
</th>
                                <th scope="col"><?php echo Lang::T('Created / Expired');?>
</th>
                                <th scope="col"><?php echo Lang::T('Internet Package');?>
</th>
                                <th scope="col"><?php echo Lang::T('Location');?>
</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php
$_from = $_smarty_tpl->smarty->ext->_foreach->init($_smarty_tpl, $_smarty_tpl->tpl_vars['expire']->value, 'expired');
$_smarty_tpl->tpl_vars['expired']->do_else = true;
if ($_from !== null) foreach ($_from as $_smarty_tpl->tpl_vars['expired']->value) {
$_smarty_tpl->tpl_vars['expired']->do_else = false;
?>
                                <?php $_smarty_tpl->_assignInScope('rem_exp', ((string)$_smarty_tpl->tpl_vars['expired']->value['expiration'])." ".((string)$_smarty_tpl->tpl_vars['expired']->value['time']));?>
                                <?php $_smarty_tpl->_assignInScope('rem_started', ((string)$_smarty_tpl->tpl_vars['expired']->value['recharged_on'])." ".((string)$_smarty_tpl->tpl_vars['expired']->value['recharged_time']));?>
                                <tr>
                                    <td>
                                        <a href="<?php echo $_smarty_tpl->tpl_vars['_url']->value;?>
customers/viewu/<?php echo $_smarty_tpl->tpl_vars['expired']->value['username'];?>
">
                                            <?php echo $_smarty_tpl->tpl_vars['expired']->value['username'];?>

                                        </a>
                                    </td>
                                    <td>
                                        <small data-toggle="tooltip" title="<?php echo Lang::dateAndTimeFormat($_smarty_tpl->tpl_vars['expired']->value['recharged_on'],$_smarty_tpl->tpl_vars['expired']->value['recharged_time']);?>
">
                                            <?php echo Lang::timeElapsed($_smarty_tpl->tpl_vars['rem_started']->value);?>

                                        </small>
                                        /
                                        <span data-toggle="tooltip" title="<?php echo Lang::dateAndTimeFormat($_smarty_tpl->tpl_vars['expired']->value['expiration'],$_smarty_tpl->tpl_vars['expired']->value['time']);?>
">
                                            <?php echo Lang::timeElapsed($_smarty_tpl->tpl_vars['rem_exp']->value);?>

                                        </span>
                                    </td>
                                    <td>
                                        <span class="badge bg-info"><?php echo Lang::T($_smarty_tpl->tpl_vars['expired']->value['namebp']);?>
</span>
                                    </td>
                                    <td>
                                        <span class="badge bg-secondary"><?php echo Lang::T($_smarty_tpl->tpl_vars['expired']->value['routers']);?>
</span>
                                    </td>
                                </tr>
                            <?php
}
$_smarty_tpl->smarty->ext->_foreach->restore($_smarty_tpl, 1);?>
                        </tbody>
                    </table>
                </div>
                &nbsp; <?php $_smarty_tpl->_subTemplateRender("file:pagination.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, $_smarty_tpl->cache_lifetime, array(), 0, false);
?>
            </div>
        </div>
    
        <!-- Activity Log Column -->
        <div class="col-md-4">
            <?php if ($_smarty_tpl->tpl_vars['_c']->value['hide_al'] != 'yes') {?>
                <div class="card card-info mb-3">
                    <div class="card-header">
                        <a href="<?php echo $_smarty_tpl->tpl_vars['_url']->value;?>
logs">
                            <i class="fa fa-history"></i> <!-- Uniform icon size -->
                            <?php echo Lang::T('Activity Log');?>

                        </a>
                    </div>
                    <div class="card-body">
                        <ul class="list-unstyled">
                            <?php
$_from = $_smarty_tpl->smarty->ext->_foreach->init($_smarty_tpl, $_smarty_tpl->tpl_vars['dlog']->value, 'dlogs');
$_smarty_tpl->tpl_vars['dlogs']->do_else = true;
if ($_from !== null) foreach ($_from as $_smarty_tpl->tpl_vars['dlogs']->value) {
$_smarty_tpl->tpl_vars['dlogs']->do_else = false;
?>
                                <li>
                                    <span class="time small text-muted"><?php echo Lang::timeElapsed($_smarty_tpl->tpl_vars['dlogs']->value['date'],true);?>
</span>
                                    <p><?php echo $_smarty_tpl->tpl_vars['dlogs']->value['description'];?>
</p>
                                </li>
                            <?php
}
$_smarty_tpl->smarty->ext->_foreach->restore($_smarty_tpl, 1);?>
                        </ul>
                    </div>
                </div>
            <?php }?>
        </div>
    </div>
    



<?php echo '<script'; ?>
 src="https://cdn.jsdelivr.net/npm/chart.js"><?php echo '</script'; ?>
>

<?php echo '<script'; ?>
 type="text/javascript">

<?php if ($_smarty_tpl->tpl_vars['_c']->value['hide_mrc'] != 'yes') {?>
    
        document.addEventListener("DOMContentLoaded", function() {
            // Daily Sales Chart Script
            var dailySales = JSON.parse('<?php echo $_smarty_tpl->tpl_vars['dailySales']->value;?>
');
            var salesLabels = [];
            var salesData = [];
            
            dailySales.forEach(function(sale) {
                var date = new Date(sale.date);
                salesLabels.push(date.toLocaleDateString('en-US', { month: 'short', day: 'numeric' }));
                salesData.push(sale.amount);
            });

            var ctxSales = document.getElementById('dailySalesChart').getContext('2d');
            new Chart(ctxSales, {
                type: 'line',
                data: {
                    labels: salesLabels,
                    datasets: [{
                        label: 'Daily Sales',
                        data: salesData,
                        borderColor: 'rgb(75, 192, 192)',
                        tension: 0.1,
                        fill: true,
                        backgroundColor: 'rgba(75, 192, 192, 0.2)',
                        borderColor: 'rgb(75, 192, 192)',
                        borderWidth: 1
                    }]
                },
                options: {
                    responsive: true,
                    plugins: {
                        legend: {
                            display: false
                        },
                        tooltip: {
                            callbacks: {
                                label: function(context) {
                                    return 'Sales: $' + context.parsed.y.toFixed(2);
                                }
                            }
                        }
                    },
                    scales: {
                        x: {
                            grid: {
                                display: false
                            }
                        },
                        y: {
                            beginAtZero: true,
                            grid: {
                                color: 'rgba(0, 0, 0, 0.1)'
                            },
                            ticks: {
                                callback: function(value, index, values) {
                                    return '' + value.toFixed(0);
                                }
                            }
                        }
                    },
                    elements: {
                        point: {
                            radius: 0
                        }
                    }
                }
            });
        });
    
<?php }?>

<?php if ($_smarty_tpl->tpl_vars['_c']->value['hide_mrc'] != 'yes') {?>
    
        document.addEventListener("DOMContentLoaded", function() {
            // Active Users Chart Script
            var activeUsers = JSON.parse('<?php echo strtr((string)$_smarty_tpl->tpl_vars['activeUsersData']->value, array("\\" => "\\\\", "'" => "\\'", "\"" => "\\\"", "\r" => "\\r", 
                       "\n" => "\\n", "</" => "<\/", "<!--" => "<\!--", "<s" => "<\s", "<S" => "<\S",
                       "`" => "\\`", "\${" => "\\\$\{"));?>
');
            var userLabels = [];
            var userData = [];

            activeUsers.forEach(function(user) {
                var date = new Date(user.recharged_on + 'T00:00:00'); // Ensure date is correctly parsed
                userLabels.push(date.toLocaleDateString('en-US', { month: 'short', day: 'numeric' }));
                userData.push(user.count);
            });

            var ctxUsers = document.getElementById('activeUsersChart').getContext('2d');
            new Chart(ctxUsers, {
                type: 'line',
                data: {
                    labels: userLabels,
                    datasets: [{
                        label: 'Active Users',
                        data: userData,
                        borderColor: 'rgb(54, 162, 235)',
                        tension: 0.1,
                        fill: true,
                        backgroundColor: 'rgba(54, 162, 235, 0.2)',
                        borderColor: 'rgb(54, 162, 235)',
                        borderWidth: 1
                    }]
                },
                options: {
                    responsive: true,
                    plugins: {
                        legend: {
                            display: false
                        },
                        tooltip: {
                            callbacks: {
                                label: function(context) {
                                    return 'Users: ' + context.parsed.y.toFixed(0);
                                }
                            }
                        }
                    },
                    scales: {
                        x: {
                            grid: {
                                display: false
                            }
                        },
                        y: {
                            beginAtZero: true,
                            grid: {
                                color: 'rgba(0, 0, 0, 0.1)'
                            },
                            ticks: {
                                callback: function(value, index, values) {
                                    return '' + value.toFixed(0);
                                }
                            }
                        }
                    },
                    elements: {
                        point: {
                            radius: 0
                        }
                    }
                }
            });
        });
    
<?php }?>

    <?php if ($_smarty_tpl->tpl_vars['_c']->value['hide_mrc'] != 'yes') {?>
        
            document.addEventListener("DOMContentLoaded", function() {
                var counts = JSON.parse('<?php echo json_encode($_smarty_tpl->tpl_vars['monthlyRegistered']->value);?>
');

                var monthNames = [
                    'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
                    'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'
                ];

                var labels = [];
                var data = [];

                for (var i = 1; i <= 12; i++) {
                    var month = counts.find(count => count.date === i);
                    labels.push(month ? monthNames[i - 1] : monthNames[i - 1].substring(0, 3));
                    data.push(month ? month.count : 0);
                }

                var ctx = document.getElementById('chart').getContext('2d');
                var chart = new Chart(ctx, {
                    type: 'bar',
                    data: {
                        labels: labels,
                        datasets: [{
                            label: 'Registered Members',
                            data: data,
                            backgroundColor: [
                                'rgba(255, 99, 132, 0.2)',
                                'rgba(255, 159, 64, 0.2)',
                                'rgba(255, 205, 86, 0.2)',
                                'rgba(75, 192, 192, 0.2)',
                                'rgba(54, 162, 235, 0.2)',
                                'rgba(153, 102, 255, 0.2)',
                                'rgba(201, 203, 207, 0.2)'
                            ],
                            borderColor: [
                                'rgb(255, 99, 132)',
                                'rgb(255, 159, 64)',
                                'rgb(255, 205, 86)',
                                'rgb(75, 192, 192)',
                                'rgb(54, 162, 235)',
                                'rgb(153, 102, 255)',
                                'rgb(201, 203, 207)'
                            ],
                            borderWidth: 1
                        }]
                    },
                    options: {
                        responsive: true,
                        scales: {
                            x: {
                                grid: {
                                    display: false
                                }
                            },
                            y: {
                                beginAtZero: true,
                                grid: {
                                    color: 'rgba(0, 0, 0, 0.1)'
                                }
                            }
                        }
                    }
                });
            });
        
    <?php }?>

<?php if ($_smarty_tpl->tpl_vars['_c']->value['hide_mrc'] != 'yes') {?>
    
    document.addEventListener("DOMContentLoaded", function() {
        var hotspotData = JSON.parse('<?php echo json_encode($_smarty_tpl->tpl_vars['hotspot_utilization']->value);?>
');
        var pppoeData = JSON.parse('<?php echo json_encode($_smarty_tpl->tpl_vars['pppoe_utilization']->value);?>
');

        function createDoughnutChart(ctx, data, label) {
            new Chart(ctx, {
                type: 'doughnut',
                data: {
                    labels: Object.keys(data),
                    datasets: [{
                        label: label,
                        data: Object.values(data),
                        backgroundColor: [
                            'rgba(255, 99, 132, 0.2)',
                            'rgba(54, 162, 235, 0.2)',
                            'rgba(255, 206, 86, 0.2)',
                            'rgba(75, 192, 192, 0.2)',
                            'rgba(153, 102, 255, 0.2)',
                            'rgba(255, 159, 64, 0.2)',
                            'rgba(201, 203, 207, 0.2)'
                        ],
                        borderColor: [
                            'rgb(255, 99, 132)',
                            'rgb(54, 162, 235)',
                            'rgb(255, 206, 86)',
                            'rgb(75, 192, 192)',
                            'rgb(153, 102, 255)',
                            'rgb(255, 159, 64)',
                            'rgb(201, 203, 207)'
                        ],
                        borderWidth: 1
                    }]
                },
                options: {
                    responsive: true,                   
                }
            });
        }

        var ctxHotspot = document.getElementById('hotspotChart').getContext('2d');
        createDoughnutChart(ctxHotspot, hotspotData, 'Hotspot Packages');

        var ctxPPPOE = document.getElementById('pppoeChart').getContext('2d');
        createDoughnutChart(ctxPPPOE, pppoeData, 'PPPOE Packages');
    });
    
<?php }?>

    <?php if ($_smarty_tpl->tpl_vars['_c']->value['hide_tms'] != 'yes') {?>
        
            document.addEventListener("DOMContentLoaded", function() {
                var monthlySales = JSON.parse('<?php echo json_encode($_smarty_tpl->tpl_vars['monthlySales']->value);?>
');

                var monthNames = [
                    'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
                    'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'
                ];

                var labels = [];
                var data = [];

                for (var i = 1; i <= 12; i++) {
                    var month = findMonthData(monthlySales, i);
                    labels.push(month ? monthNames[i - 1] : monthNames[i - 1].substring(0, 3));
                    data.push(month ? month.totalSales : 0);
                }

                var ctx = document.getElementById('salesChart').getContext('2d');
                var chart = new Chart(ctx, {
                    type: 'line',
                    data: {
                        labels: labels,
                        datasets: [{
                            label: 'Monthly Sales',
                            data: data,
                            fill: true,
                            backgroundColor: 'rgba(56, 161, 105, 0.2)', // Use the primary color with transparency
                            borderColor: 'rgba(56, 161, 105, 1)', // Use the primary color
                            borderWidth: 1
                        }]
                    },
                    options: {
                        responsive: true,
                        scales: {
                            x: {
                                grid: {
                                    display: true
                                }
                            },
                            y: {
                                beginAtZero: true,
                                grid: {
                                    color: 'rgba(0, 0, 0, 0.1)'
                                }
                            }
                        }
                    }
                });
            });

            function findMonthData(monthlySales, month) {
                for (var i = 0; i < monthlySales.length; i++) {
                    if (monthlySales[i].month === month) {
                        return monthlySales[i];
                    }
                }
                return null;
            }
        
    <?php }
echo '</script'; ?>
>
<?php echo '<script'; ?>
 src="https://code.jquery.com/jquery-3.6.0.min.js"><?php echo '</script'; ?>
>
    <?php echo '<script'; ?>
>
    $(document).ready(function() {
        $.ajax({
            url: "<?php echo $_smarty_tpl->tpl_vars['_url']->value;?>
onlineusers/sms_balance",
            method: 'GET',
            dataType: 'json',
            success: function(response) {
            if (response.status === 'success' && response.data && response.data.remaining_balance) {
                $('#sms-balance').text(response.data.remaining_balance);
            } else if (response.message) {
                $('#sms-balance').text('Error: ' + response.message);
            } else {
                $('#sms-balance').text('Unknown error');
            }
        },
            error: function() {
                $('#sms-balance').text('Failed to fetch balance');
            }
        });
    });
    <?php echo '</script'; ?>
>

<?php echo '<script'; ?>
>
$(document).ready(function() {
    $.ajax({
        url: "<?php echo $_smarty_tpl->tpl_vars['_url']->value;?>
onlineusers/summary", // Adjust this URL to your actual endpoint
        type: 'GET',
        dataType: 'json', // Ensure the expected response is JSON
        success: function(data) {
            console.log('Data fetched successfully:', data);
            $('#total-online-users').text(data.total_users);
            $('#online-hotspot-users').text(data.hotspot_users);
            $('#online-ppp-users').text(data.ppoe_users);
				$('#total_data').text(data.total_bytes);
        },
        error: function(error) {
            console.log('Error fetching data:', error);
        }
    });
});
<?php echo '</script'; ?>
>
</div>
<?php $_smarty_tpl->_subTemplateRender("file:sections/footer.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, $_smarty_tpl->cache_lifetime, array(), 0, false);
}
}
