<?php
/* Smarty version 4.5.6, created on 2025-12-17 18:25:33
  from '/var/www/html/tivi/panel/templates/sessions/index.tpl' */

/* @var Smarty_Internal_Template $_smarty_tpl */
if ($_smarty_tpl->_decodeProperties($_smarty_tpl, array (
  'version' => '4.5.6',
  'unifunc' => 'content_6942e78db51639_06719878',
  'has_nocache_code' => false,
  'file_dependency' => 
  array (
    '9ab00e89aedc0680cb2678c7265fb7d91e36e95d' => 
    array (
      0 => '/var/www/html/tivi/panel/templates/sessions/index.tpl',
      1 => 1765992142,
      2 => 'file',
    ),
  ),
  'includes' => 
  array (
  ),
),false)) {
function content_6942e78db51639_06719878 (Smarty_Internal_Template $_smarty_tpl) {
$_smarty_tpl->_loadInheritance();
$_smarty_tpl->inheritance->init($_smarty_tpl, true);
?>


<?php 
$_smarty_tpl->inheritance->instanceBlock($_smarty_tpl, 'Block_20516107096942e78db43c90_87389373', "content");
?>


<?php 
$_smarty_tpl->inheritance->instanceBlock($_smarty_tpl, 'Block_17837325876942e78db50e88_25202826', "scripts");
?>

<?php $_smarty_tpl->inheritance->endChild($_smarty_tpl, "layout.tpl");
}
/* {block "content"} */
class Block_20516107096942e78db43c90_87389373 extends Smarty_Internal_Block
{
public $subBlocks = array (
  'content' => 
  array (
    0 => 'Block_20516107096942e78db43c90_87389373',
  ),
);
public function callBlock(Smarty_Internal_Template $_smarty_tpl) {
$_smarty_tpl->_checkPlugins(array(0=>array('file'=>'/var/www/html/tivi/vendor/smarty/smarty/libs/plugins/modifier.date_format.php','function'=>'smarty_modifier_date_format',),1=>array('file'=>'/var/www/html/tivi/vendor/smarty/smarty/libs/plugins/modifier.truncate.php','function'=>'smarty_modifier_truncate',),));
?>

<div class="container-fluid">
    <!-- Header -->
    <div class="mb-4">
        <h4 class="mb-1">Aktywne sesje</h4>
        <p class="text-muted mb-0">Monitorowanie aktywnych użytkowników</p>
    </div>

    <!-- Stats -->
    <div class="row g-4 mb-4">
        <div class="col-md-4">
            <div class="stat-card stat-card-success">
                <div class="stat-icon">
                    <i class="bi bi-circle-fill text-success"></i>
                </div>
                <div class="stat-content">
                    <div class="stat-value"><?php echo $_smarty_tpl->tpl_vars['stats']->value['active_now'];?>
</div>
                    <div class="stat-label">Aktywnych teraz</div>
                </div>
                <div class="stat-footer">
                    <small>Aktywność w ciągu ostatnich 10 minut</small>
                </div>
            </div>
        </div>
        <div class="col-md-4">
            <div class="stat-card stat-card-primary">
                <div class="stat-icon">
                    <i class="bi bi-person-badge"></i>
                </div>
                <div class="stat-content">
                    <div class="stat-value"><?php echo $_smarty_tpl->tpl_vars['stats']->value['total_sessions'];?>
</div>
                    <div class="stat-label">Wszystkich sesji</div>
                </div>
                <div class="stat-footer">
                    <small>Niewygasłe sesje</small>
                </div>
            </div>
        </div>
        <div class="col-md-4">
            <div class="stat-card stat-card-warning">
                <div class="stat-icon">
                    <i class="bi bi-clock-history"></i>
                </div>
                <div class="stat-content">
                    <div class="stat-value"><?php echo $_smarty_tpl->tpl_vars['stats']->value['remember_me_sessions'];?>
</div>
                    <div class="stat-label">Zapamiętaj mnie</div>
                </div>
                <div class="stat-footer">
                    <small>Sesje z włączonym "zapamiętaj mnie"</small>
                </div>
            </div>
        </div>
    </div>

    <!-- Active Now -->
    <div class="card mb-4">
        <div class="card-header d-flex justify-content-between align-items-center">
            <h5 class="card-title mb-0">
                <i class="bi bi-circle-fill text-success me-2" style="font-size: 0.6rem;"></i>
                Aktywni teraz <span class="badge bg-success ms-2"><?php echo $_smarty_tpl->tpl_vars['stats']->value['active_now'];?>
</span>
            </h5>
            <small class="text-muted">Ostatnia aktywność &lt; 10 minut</small>
        </div>
        <div class="card-body p-0">
            <div class="table-responsive">
                <table class="table table-hover align-middle mb-0">
                    <thead>
                        <tr>
                            <th>Użytkownik</th>
                            <th>IP</th>
                            <th>Ostatnia aktywność</th>
                            <th>Zapamiętaj</th>
                            <th>Zalogowany od</th>
                            <th class="text-end">Akcje</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php
$_from = $_smarty_tpl->smarty->ext->_foreach->init($_smarty_tpl, $_smarty_tpl->tpl_vars['activeSessions']->value, 'session');
$_smarty_tpl->tpl_vars['session']->do_else = true;
if ($_from !== null) foreach ($_from as $_smarty_tpl->tpl_vars['session']->value) {
$_smarty_tpl->tpl_vars['session']->do_else = false;
?>
                        <tr>
                            <td>
                                <strong><?php echo $_smarty_tpl->tpl_vars['session']->value['username'];?>
</strong>
                                <?php if ($_smarty_tpl->tpl_vars['session']->value['role'] == 'admin') {?>
                                <span class="badge bg-warning text-dark ms-1">Admin</span>
                                <?php }?>
                            </td>
                            <td><code><?php echo $_smarty_tpl->tpl_vars['session']->value['ip'];?>
</code></td>
                            <td>
                                <span class="text-success">
                                    <i class="bi bi-circle-fill me-1" style="font-size: 0.5rem;"></i>
                                    <?php echo smarty_modifier_date_format($_smarty_tpl->tpl_vars['session']->value['last_activity_local'],"%H:%M:%S");?>

                                </span>
                            </td>
                            <td>
                                <?php if ($_smarty_tpl->tpl_vars['session']->value['remember_me']) {?>
                                <span class="badge bg-info"><i class="bi bi-check"></i> Tak</span>
                                <?php } else { ?>
                                <span class="badge bg-secondary">Nie</span>
                                <?php }?>
                            </td>
                            <td><?php echo smarty_modifier_date_format($_smarty_tpl->tpl_vars['session']->value['created_at_local'],"%d.%m.%Y %H:%M");?>
</td>
                            <td class="text-end">
                                <button type="button" 
                                        class="btn btn-sm btn-outline-danger" 
                                        class="terminate-btn" 
                                        
                                        data-session-id="<?php echo $_smarty_tpl->tpl_vars['session']->value['id'];?>
"
                                        data-username="<?php echo $_smarty_tpl->tpl_vars['session']->value['username'];?>
"
                                        title="Zakończ sesję">
                                    <i class="bi bi-x-circle"></i>
                                </button>
                            </td>
                        </tr>
                        <?php
}
if ($_smarty_tpl->tpl_vars['session']->do_else) {
?>
                        <tr>
                            <td colspan="6" class="text-center py-4 text-muted">
                                <i class="bi bi-moon-stars me-2"></i>Brak aktywnych użytkowników
                            </td>
                        </tr>
                        <?php
}
$_smarty_tpl->smarty->ext->_foreach->restore($_smarty_tpl, 1);?>
                    </tbody>
                </table>
            </div>
        </div>
    </div>

    <!-- All Sessions -->
    <div class="card">
        <div class="card-header">
            <h5 class="card-title mb-0">
                <i class="bi bi-list-ul me-2"></i>
                Wszystkie sesje <span class="badge bg-secondary ms-2"><?php echo $_smarty_tpl->tpl_vars['stats']->value['total_sessions'];?>
</span>
            </h5>
        </div>
        <div class="card-body p-0">
            <div class="table-responsive">
                <table class="table table-hover align-middle mb-0">
                    <thead>
                        <tr>
                            <th>Użytkownik</th>
                            <th>IP</th>
                            <th>Ostatnia aktywność</th>
                            <th>Status</th>
                            <th>Zapamiętaj</th>
                            <th>Przeglądarka</th>
                            <th class="text-end">Akcje</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php
$_from = $_smarty_tpl->smarty->ext->_foreach->init($_smarty_tpl, $_smarty_tpl->tpl_vars['allSessions']->value, 'session');
$_smarty_tpl->tpl_vars['session']->do_else = true;
if ($_from !== null) foreach ($_from as $_smarty_tpl->tpl_vars['session']->value) {
$_smarty_tpl->tpl_vars['session']->do_else = false;
?>
                        <?php $_smarty_tpl->_assignInScope('isActive', false);?>
                        <?php
$_from = $_smarty_tpl->smarty->ext->_foreach->init($_smarty_tpl, $_smarty_tpl->tpl_vars['activeSessions']->value, 'active');
$_smarty_tpl->tpl_vars['active']->do_else = true;
if ($_from !== null) foreach ($_from as $_smarty_tpl->tpl_vars['active']->value) {
$_smarty_tpl->tpl_vars['active']->do_else = false;
?>
                            <?php if ($_smarty_tpl->tpl_vars['active']->value['id'] == $_smarty_tpl->tpl_vars['session']->value['id']) {?>
                                <?php $_smarty_tpl->_assignInScope('isActive', true);?>
                            <?php }?>
                        <?php
}
$_smarty_tpl->smarty->ext->_foreach->restore($_smarty_tpl, 1);?>
                        <tr class="<?php if ($_smarty_tpl->tpl_vars['isActive']->value) {?>table-success<?php }?>">
                            <td>
                                <strong><?php echo $_smarty_tpl->tpl_vars['session']->value['username'];?>
</strong>
                                <?php if ($_smarty_tpl->tpl_vars['session']->value['role'] == 'admin') {?>
                                <span class="badge bg-warning text-dark ms-1">Admin</span>
                                <?php }?>
                            </td>
                            <td><code><?php echo $_smarty_tpl->tpl_vars['session']->value['ip'];?>
</code></td>
                            <td>
                                <?php if ($_smarty_tpl->tpl_vars['isActive']->value) {?>
                                <span class="text-success">
                                    <i class="bi bi-circle-fill me-1" style="font-size: 0.5rem;"></i>
                                    <?php echo smarty_modifier_date_format($_smarty_tpl->tpl_vars['session']->value['last_activity_local'],"%H:%M:%S");?>

                                </span>
                                <?php } else { ?>
                                <span class="text-muted"><?php echo smarty_modifier_date_format($_smarty_tpl->tpl_vars['session']->value['last_activity_local'],"%d.%m %H:%M");?>
</span>
                                <?php }?>
                            </td>
                            <td>
                                <?php if ($_smarty_tpl->tpl_vars['isActive']->value) {?>
                                <span class="badge bg-success">Online</span>
                                <?php } else { ?>
                                <span class="badge bg-secondary">Offline</span>
                                <?php }?>
                            </td>
                            <td>
                                <?php if ($_smarty_tpl->tpl_vars['session']->value['remember_me']) {?>
                                <span class="badge bg-info"><i class="bi bi-check"></i></span>
                                <?php } else { ?>
                                <span class="badge bg-secondary">-</span>
                                <?php }?>
                            </td>
                            <td>
                                <small class="text-muted" title="<?php echo $_smarty_tpl->tpl_vars['session']->value['user_agent'];?>
">
                                    <?php echo smarty_modifier_truncate($_smarty_tpl->tpl_vars['session']->value['user_agent'],30);?>

                                </small>
                            </td>
                            <td class="text-end">
                                <button type="button" 
                                        class="btn btn-sm btn-outline-danger" 
                                        class="terminate-btn" 
                                        
                                        data-session-id="<?php echo $_smarty_tpl->tpl_vars['session']->value['id'];?>
"
                                        data-username="<?php echo $_smarty_tpl->tpl_vars['session']->value['username'];?>
"
                                        title="Zakończ sesję">
                                    <i class="bi bi-x-circle"></i>
                                </button>
                            </td>
                        </tr>
                        <?php
}
if ($_smarty_tpl->tpl_vars['session']->do_else) {
?>
                        <tr>
                            <td colspan="7" class="text-center py-4 text-muted">
                                Brak aktywnych sesji
                            </td>
                        </tr>
                        <?php
}
$_smarty_tpl->smarty->ext->_foreach->restore($_smarty_tpl, 1);?>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>

<!-- Hidden form -->
<form id="terminateForm" method="post" action="<?php echo $_smarty_tpl->tpl_vars['baseUrl']->value;?>
/admin/sessions/terminate" style="display:none;">
    <input type="hidden" name="csrf_token" value="<?php echo $_smarty_tpl->tpl_vars['csrfToken']->value;?>
">
    <input type="hidden" name="session_id" id="terminateSessionId">
</form>
<?php
}
}
/* {/block "content"} */
/* {block "scripts"} */
class Block_17837325876942e78db50e88_25202826 extends Smarty_Internal_Block
{
public $subBlocks = array (
  'scripts' => 
  array (
    0 => 'Block_17837325876942e78db50e88_25202826',
  ),
);
public function callBlock(Smarty_Internal_Template $_smarty_tpl) {
?>


<?php echo '<script'; ?>
>
(function() {
    var swalConfig = {
        background: '#1a1d21',
        color: '#e1e1e1',
        confirmButtonColor: '#0d6efd',
        cancelButtonColor: '#6c757d'
    };

    // Terminate session
    document.querySelectorAll('.terminate-btn').forEach(function(btn) {
        btn.addEventListener('click', function() {
            var sessionId = this.dataset.sessionId;
            var username = this.dataset.username;

            Swal.fire({
                title: 'Zakończ sesję',
                html: 'Czy na pewno chcesz zakończyć sesję użytkownika <strong>"' + username + '"</strong>?<br><br><small class="text-muted">Użytkownik zostanie natychmiast wylogowany.</small>',
                icon: 'question',
                showCancelButton: true,
                confirmButtonText: 'Zakończ sesję',
                cancelButtonText: 'Anuluj',
                confirmButtonColor: '#dc3545',
                background: swalConfig.background,
                color: swalConfig.color
            }).then(function(result) {
                if (result.isConfirmed) {
                    document.getElementById('terminateSessionId').value = sessionId;
                    document.getElementById('terminateForm').submit();
                }
            });
        });
    });

    // Auto-refresh co 30 sekund
    setTimeout(function() {
        location.reload();
    }, 30000);
})();
<?php echo '</script'; ?>
>

<?php
}
}
/* {/block "scripts"} */
}
