<?php
/* Smarty version 4.5.6, created on 2025-12-20 13:59:44
  from '/var/www/html/tivi/panel/templates/dashboard.tpl' */

/* @var Smarty_Internal_Template $_smarty_tpl */
if ($_smarty_tpl->_decodeProperties($_smarty_tpl, array (
  'version' => '4.5.6',
  'unifunc' => 'content_69469dc0e70ba8_34394687',
  'has_nocache_code' => false,
  'file_dependency' => 
  array (
    '4e5a23c2649fd18b3e13eae9405d752879658fa8' => 
    array (
      0 => '/var/www/html/tivi/panel/templates/dashboard.tpl',
      1 => 1766235525,
      2 => 'file',
    ),
  ),
  'includes' => 
  array (
  ),
),false)) {
function content_69469dc0e70ba8_34394687 (Smarty_Internal_Template $_smarty_tpl) {
$_smarty_tpl->_loadInheritance();
$_smarty_tpl->inheritance->init($_smarty_tpl, true);
?>


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

<?php $_smarty_tpl->inheritance->endChild($_smarty_tpl, "layout.tpl");
}
/* {block "content"} */
class Block_53423724769469dc0e3fb37_15733243 extends Smarty_Internal_Block
{
public $subBlocks = array (
  'content' => 
  array (
    0 => 'Block_53423724769469dc0e3fb37_15733243',
  ),
);
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',),));
?>

<div class="container-fluid">
    <?php if ($_smarty_tpl->tpl_vars['isAdmin']->value) {?>
        <div class="row g-4 mb-4">
        <div class="col-sm-6 col-xl-3">
            <div class="stat-card stat-card-primary">
                <div class="stat-icon">
                    <i class="bi bi-people"></i>
                </div>
                <div class="stat-content">
                    <div class="stat-value"><?php echo $_smarty_tpl->tpl_vars['userStats']->value['total'];?>
</div>
                    <div class="stat-label">Użytkownicy</div>
                </div>
                <div class="stat-footer">
                    <span><i class="bi bi-person-check me-1"></i><?php echo $_smarty_tpl->tpl_vars['userStats']->value['users'];?>
 userów, <?php echo $_smarty_tpl->tpl_vars['userStats']->value['resellers'];?>
 resellerów</span>
                </div>
            </div>
        </div>
        
        <div class="col-sm-6 col-xl-3">
            <div class="stat-card stat-card-success">
                <div class="stat-icon">
                    <i class="bi bi-tv"></i>
                </div>
                <div class="stat-content">
                    <div class="stat-value"><?php echo $_smarty_tpl->tpl_vars['deviceStats']->value['total'];?>
</div>
                    <div class="stat-label">Urządzenia</div>
                </div>
                <div class="stat-footer">
                    <span class="text-warning"><i class="bi bi-shield-x me-1"></i><?php echo $_smarty_tpl->tpl_vars['deviceStats']->value['blocked'];?>
 zablokowanych</span>
                </div>
            </div>
        </div>
        
        <div class="col-sm-6 col-xl-3">
            <div class="stat-card stat-card-warning">
                <div class="stat-icon">
                    <i class="bi bi-list-ul"></i>
                </div>
                <div class="stat-content">
                    <div class="stat-value"><?php echo $_smarty_tpl->tpl_vars['playlistStats']->value['total'];?>
</div>
                    <div class="stat-label">Playlisty</div>
                </div>
                <div class="stat-footer">
                    <span>
                        <?php echo $_smarty_tpl->tpl_vars['playlistStats']->value['by_type']['xtream'];?>
 Xtr | <?php echo $_smarty_tpl->tpl_vars['playlistStats']->value['by_type']['m3u'];?>
 M3U | <?php echo $_smarty_tpl->tpl_vars['playlistStats']->value['by_type']['stalker'];?>
 Stk
                    </span>
                </div>
            </div>
        </div>
        
        <div class="col-sm-6 col-xl-3">
            <div class="stat-card stat-card-info">
                <div class="stat-icon">
                    <i class="bi bi-person-check"></i>
                </div>
                <div class="stat-content">
                    <div class="stat-value"><?php echo $_smarty_tpl->tpl_vars['userStats']->value['today_logins'];?>
</div>
                    <div class="stat-label">Logowań dziś</div>
                </div>
                <div class="stat-footer">
                    <span><i class="bi bi-shield-check me-1"></i><?php echo $_smarty_tpl->tpl_vars['userStats']->value['admins'];?>
 administratorów</span>
                </div>
            </div>
        </div>
    </div>

        <?php if ($_smarty_tpl->tpl_vars['resellerStats']->value && count($_smarty_tpl->tpl_vars['resellerStats']->value) > 0) {?>
    <div class="card mb-4">
        <div class="card-header">
            <h5 class="card-title mb-0"><i class="bi bi-shop me-2"></i>Resellerzy - wykorzystanie limitów</h5>
        </div>
        <div class="card-body p-0">
            <div class="table-responsive">
                <table class="table table-hover mb-0">
                    <thead>
                        <tr>
                            <th>Reseller</th>
                            <th>Użytkownicy</th>
                            <th>Urządzenia</th>
                            <th>Playlisty</th>
                            <th>Akcje</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php
$_from = $_smarty_tpl->smarty->ext->_foreach->init($_smarty_tpl, $_smarty_tpl->tpl_vars['resellerStats']->value, 'reseller');
$_smarty_tpl->tpl_vars['reseller']->do_else = true;
if ($_from !== null) foreach ($_from as $_smarty_tpl->tpl_vars['reseller']->value) {
$_smarty_tpl->tpl_vars['reseller']->do_else = false;
?>
                        <tr>
                            <td><strong><?php echo $_smarty_tpl->tpl_vars['reseller']->value['username'];?>
</strong></td>
                            <td>
                                <div class="d-flex align-items-center">
                                    <div class="progress flex-grow-1 me-2" style="height: 6px; width: 80px;">
                                        <div class="progress-bar bg-primary" style="width: <?php if ($_smarty_tpl->tpl_vars['reseller']->value['max_users'] > 0) {
echo round((float) ($_smarty_tpl->tpl_vars['reseller']->value['users_count']/$_smarty_tpl->tpl_vars['reseller']->value['max_users']*100), (int) 0, (int) 1);
} else { ?>0<?php }?>%"></div>
                                    </div>
                                    <span class="small"><?php echo $_smarty_tpl->tpl_vars['reseller']->value['users_count'];?>
/<?php echo $_smarty_tpl->tpl_vars['reseller']->value['max_users'];?>
</span>
                                </div>
                            </td>
                            <td>
                                <div class="d-flex align-items-center">
                                    <div class="progress flex-grow-1 me-2" style="height: 6px; width: 80px;">
                                        <div class="progress-bar bg-success" style="width: <?php if ($_smarty_tpl->tpl_vars['reseller']->value['max_devices'] > 0) {
echo round((float) ($_smarty_tpl->tpl_vars['reseller']->value['devices_used']/$_smarty_tpl->tpl_vars['reseller']->value['max_devices']*100), (int) 0, (int) 1);
} else { ?>0<?php }?>%"></div>
                                    </div>
                                    <span class="small" title="własne: <?php echo $_smarty_tpl->tpl_vars['reseller']->value['devices_own'];?>
, przydzielone: <?php echo $_smarty_tpl->tpl_vars['reseller']->value['devices_allocated'];?>
"><?php echo $_smarty_tpl->tpl_vars['reseller']->value['devices_used'];?>
/<?php echo $_smarty_tpl->tpl_vars['reseller']->value['max_devices'];?>
</span>
                                </div>
                            </td>
                            <td>
                                <div class="d-flex align-items-center">
                                    <div class="progress flex-grow-1 me-2" style="height: 6px; width: 80px;">
                                        <div class="progress-bar bg-info" style="width: <?php if ($_smarty_tpl->tpl_vars['reseller']->value['max_playlists'] > 0) {
echo round((float) ($_smarty_tpl->tpl_vars['reseller']->value['playlists_used']/$_smarty_tpl->tpl_vars['reseller']->value['max_playlists']*100), (int) 0, (int) 1);
} else { ?>0<?php }?>%"></div>
                                    </div>
                                    <span class="small" title="własne: <?php echo $_smarty_tpl->tpl_vars['reseller']->value['playlists_own'];?>
, przydzielone: <?php echo $_smarty_tpl->tpl_vars['reseller']->value['playlists_allocated'];?>
"><?php echo $_smarty_tpl->tpl_vars['reseller']->value['playlists_used'];?>
/<?php echo $_smarty_tpl->tpl_vars['reseller']->value['max_playlists'];?>
</span>
                                </div>
                            </td>
                            <td>
                                <a href="<?php echo $_smarty_tpl->tpl_vars['baseUrl']->value;?>
/users/edit?id=<?php echo $_smarty_tpl->tpl_vars['reseller']->value['id'];?>
" class="btn btn-sm btn-outline-primary">
                                    <i class="bi bi-pencil"></i>
                                </a>
                            </td>
                        </tr>
                        <?php
}
$_smarty_tpl->smarty->ext->_foreach->restore($_smarty_tpl, 1);?>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
    <?php }?>

    <div class="row g-4">
        <!-- Recent Users -->
        <div class="col-lg-6">
            <div class="card">
                <div class="card-header d-flex justify-content-between align-items-center">
                    <h5 class="card-title mb-0">
                        <i class="bi bi-people me-2"></i>Ostatni użytkownicy
                    </h5>
                    <a href="<?php echo $_smarty_tpl->tpl_vars['baseUrl']->value;?>
/users" class="btn btn-sm btn-outline-primary">Zobacz wszystkich</a>
                </div>
                <div class="card-body p-0">
                    <div class="table-responsive">
                        <table class="table table-hover mb-0">
                            <thead>
                                <tr>
                                    <th>Użytkownik</th>
                                    <th>Rola</th>
                                    <th>Urządzenia</th>
                                    <th>Ostatnie logowanie</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php
$_from = $_smarty_tpl->smarty->ext->_foreach->init($_smarty_tpl, $_smarty_tpl->tpl_vars['recentUsers']->value, 'user');
$_smarty_tpl->tpl_vars['user']->do_else = true;
if ($_from !== null) foreach ($_from as $_smarty_tpl->tpl_vars['user']->value) {
$_smarty_tpl->tpl_vars['user']->do_else = false;
?>
                                <tr>
                                    <td>
                                        <strong><?php echo $_smarty_tpl->tpl_vars['user']->value['username'];?>
</strong>
                                        <?php if (!$_smarty_tpl->tpl_vars['user']->value['is_active']) {?><span class="badge bg-danger ms-1">Nieaktywny</span><?php }?>
                                    </td>
                                    <td>
                                        <?php if ($_smarty_tpl->tpl_vars['user']->value['role'] == 'admin') {?>
                                        <span class="badge bg-danger">Admin</span>
                                        <?php } elseif ($_smarty_tpl->tpl_vars['user']->value['role'] == 'reseller') {?>
                                        <span class="badge bg-primary">Reseller</span>
                                        <?php } else { ?>
                                        <span class="badge bg-secondary">User</span>
                                        <?php }?>
                                    </td>
                                    <td>
                                        <?php if ($_smarty_tpl->tpl_vars['user']->value['role'] == 'admin') {?>
                                        <span class="text-muted">∞</span>
                                        <?php } elseif ($_smarty_tpl->tpl_vars['user']->value['role'] == 'reseller') {?>
                                        <span class="text-info"><?php echo $_smarty_tpl->tpl_vars['user']->value['devices_count']+$_smarty_tpl->tpl_vars['user']->value['devices_allocated'];?>
</span><span class="text-muted">/<?php echo $_smarty_tpl->tpl_vars['user']->value['max_devices'];?>
</span>
                                        <?php } else { ?>
                                        <?php echo $_smarty_tpl->tpl_vars['user']->value['devices_count'];?>
/<?php echo $_smarty_tpl->tpl_vars['user']->value['device_limit'];?>

                                        <?php }?>
                                    </td>
                                    <td>
                                        <?php if ($_smarty_tpl->tpl_vars['user']->value['last_login']) {?>
                                        <?php echo smarty_modifier_date_format($_smarty_tpl->tpl_vars['user']->value['last_login'],"%d.%m.%Y %H:%M");?>

                                        <?php } else { ?>
                                        <span class="text-muted">Nigdy</span>
                                        <?php }?>
                                    </td>
                                </tr>
                                <?php
}
if ($_smarty_tpl->tpl_vars['user']->do_else) {
?>
                                <tr>
                                    <td colspan="4" class="text-center text-muted py-4">Brak użytkowników</td>
                                </tr>
                                <?php
}
$_smarty_tpl->smarty->ext->_foreach->restore($_smarty_tpl, 1);?>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>

        <!-- Recent Logs -->
        <div class="col-lg-6">
            <div class="card">
                <div class="card-header d-flex justify-content-between align-items-center">
                    <h5 class="card-title mb-0">
                        <i class="bi bi-journal-text me-2"></i>Ostatnie logi
                    </h5>
                    <a href="<?php echo $_smarty_tpl->tpl_vars['baseUrl']->value;?>
/admin/logs" class="btn btn-sm btn-outline-primary">Zobacz wszystkie</a>
                </div>
                <div class="card-body p-0">
                    <div class="table-responsive">
                        <table class="table table-hover mb-0">
                            <thead>
                                <tr>
                                    <th>Akcja</th>
                                    <th>Użytkownik</th>
                                    <th>Data</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php
$_from = $_smarty_tpl->smarty->ext->_foreach->init($_smarty_tpl, $_smarty_tpl->tpl_vars['recentLogs']->value, 'log');
$_smarty_tpl->tpl_vars['log']->do_else = true;
if ($_from !== null) foreach ($_from as $_smarty_tpl->tpl_vars['log']->value) {
$_smarty_tpl->tpl_vars['log']->do_else = false;
?>
                                <tr>
                                    <td>
                                        <span class="badge bg-<?php echo (($tmp = $_smarty_tpl->tpl_vars['log']->value['badge_class'] ?? null)===null||$tmp==='' ? 'info' ?? null : $tmp);?>
">
                                            <?php echo $_smarty_tpl->tpl_vars['log']->value['action'];?>

                                        </span>
                                    </td>
                                    <td><?php echo (($tmp = $_smarty_tpl->tpl_vars['log']->value['username'] ?? null)===null||$tmp==='' ? 'System' ?? null : $tmp);?>
</td>
                                    <td><?php echo smarty_modifier_date_format($_smarty_tpl->tpl_vars['log']->value['created_at'],"%d.%m %H:%M");?>
</td>
                                </tr>
                                <?php
}
if ($_smarty_tpl->tpl_vars['log']->do_else) {
?>
                                <tr>
                                    <td colspan="3" class="text-center text-muted py-4">Brak logów</td>
                                </tr>
                                <?php
}
$_smarty_tpl->smarty->ext->_foreach->restore($_smarty_tpl, 1);?>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <?php } elseif ($_smarty_tpl->tpl_vars['isReseller']->value) {?>
        
        <div class="row g-4 mb-4">
        <div class="col-sm-6 col-xl-3">
            <div class="stat-card stat-card-primary">
                <div class="stat-icon">
                    <i class="bi bi-people"></i>
                </div>
                <div class="stat-content">
                    <div class="stat-value"><?php echo $_smarty_tpl->tpl_vars['resellerUsage']->value['users']['used'];?>
/<?php echo $_smarty_tpl->tpl_vars['resellerUsage']->value['users']['max'];?>
</div>
                    <div class="stat-label">Moi użytkownicy</div>
                </div>
                <div class="stat-footer">
                    <a href="<?php echo $_smarty_tpl->tpl_vars['baseUrl']->value;?>
/users" class="text-primary">
                        <i class="bi bi-arrow-right me-1"></i>Zarządzaj
                    </a>
                </div>
            </div>
        </div>
        
        <div class="col-sm-6 col-xl-3">
            <div class="stat-card stat-card-success">
                <div class="stat-icon">
                    <i class="bi bi-tv"></i>
                </div>
                <div class="stat-content">
                    <div class="stat-value"><?php echo $_smarty_tpl->tpl_vars['resellerUsage']->value['devices']['used'];?>
/<?php echo $_smarty_tpl->tpl_vars['resellerUsage']->value['devices']['max'];?>
</div>
                    <div class="stat-label">Urządzenia (pula)</div>
                </div>
                <div class="stat-footer">
                    <span class="small">własne: <?php echo $_smarty_tpl->tpl_vars['resellerUsage']->value['devices']['own'];?>
, rozdane: <?php echo $_smarty_tpl->tpl_vars['resellerUsage']->value['devices']['allocated'];?>
</span>
                </div>
            </div>
        </div>
        
        <div class="col-sm-6 col-xl-3">
            <div class="stat-card stat-card-warning">
                <div class="stat-icon">
                    <i class="bi bi-list-ul"></i>
                </div>
                <div class="stat-content">
                    <div class="stat-value"><?php echo $_smarty_tpl->tpl_vars['resellerUsage']->value['playlists']['used'];?>
/<?php echo $_smarty_tpl->tpl_vars['resellerUsage']->value['playlists']['max'];?>
</div>
                    <div class="stat-label">Playlisty (pula)</div>
                </div>
                <div class="stat-footer">
                    <span class="small">własne: <?php echo $_smarty_tpl->tpl_vars['resellerUsage']->value['playlists']['own'];?>
, rozdane: <?php echo $_smarty_tpl->tpl_vars['resellerUsage']->value['playlists']['allocated'];?>
</span>
                </div>
            </div>
        </div>
        
        <div class="col-sm-6 col-xl-3">
            <div class="stat-card stat-card-info">
                <div class="stat-icon">
                    <i class="bi bi-hdd-stack"></i>
                </div>
                <div class="stat-content">
                    <div class="stat-value"><?php echo $_smarty_tpl->tpl_vars['totalManagedDevices']->value;?>
</div>
                    <div class="stat-label">Urządzeń w systemie</div>
                </div>
                <div class="stat-footer">
                    <span class="small"><?php echo $_smarty_tpl->tpl_vars['totalManagedPlaylists']->value;?>
 playlist łącznie</span>
                </div>
            </div>
        </div>
    </div>

    <div class="row g-4">
                <div class="col-lg-6">
            <div class="card">
                <div class="card-header d-flex justify-content-between align-items-center">
                    <h5 class="card-title mb-0">
                        <i class="bi bi-people me-2"></i>Moi użytkownicy
                    </h5>
                    <a href="<?php echo $_smarty_tpl->tpl_vars['baseUrl']->value;?>
/users" class="btn btn-sm btn-outline-primary">Zobacz wszystkich</a>
                </div>
                <div class="card-body p-0">
                    <div class="table-responsive">
                        <table class="table table-hover mb-0">
                            <thead>
                                <tr>
                                    <th>Użytkownik</th>
                                    <th>Urządzenia</th>
                                    <th>Playlisty</th>
                                    <th>Ostatnie logowanie</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php
$_from = $_smarty_tpl->smarty->ext->_foreach->init($_smarty_tpl, $_smarty_tpl->tpl_vars['myUsers']->value, 'user');
$_smarty_tpl->tpl_vars['user']->do_else = true;
if ($_from !== null) foreach ($_from as $_smarty_tpl->tpl_vars['user']->value) {
$_smarty_tpl->tpl_vars['user']->do_else = false;
?>
                                <tr>
                                    <td><strong><?php echo $_smarty_tpl->tpl_vars['user']->value['username'];?>
</strong></td>
                                    <td><?php echo $_smarty_tpl->tpl_vars['user']->value['devices_count'];?>
/<?php echo $_smarty_tpl->tpl_vars['user']->value['device_limit'];?>
</td>
                                    <td><?php echo (($tmp = $_smarty_tpl->tpl_vars['user']->value['playlists_count'] ?? null)===null||$tmp==='' ? 0 ?? null : $tmp);?>
/<?php echo $_smarty_tpl->tpl_vars['user']->value['playlist_limit'];?>
</td>
                                    <td>
                                        <?php if ($_smarty_tpl->tpl_vars['user']->value['last_login']) {?>
                                        <?php echo smarty_modifier_date_format($_smarty_tpl->tpl_vars['user']->value['last_login'],"%d.%m %H:%M");?>

                                        <?php } else { ?>
                                        <span class="text-muted">Nigdy</span>
                                        <?php }?>
                                    </td>
                                </tr>
                                <?php
}
if ($_smarty_tpl->tpl_vars['user']->do_else) {
?>
                                <tr>
                                    <td colspan="4" class="text-center py-4">
                                        <p class="text-muted mb-2">Nie masz jeszcze użytkowników</p>
                                        <a href="<?php echo $_smarty_tpl->tpl_vars['baseUrl']->value;?>
/users/add" class="btn btn-sm btn-primary">
                                            <i class="bi bi-plus-lg me-1"></i>Dodaj użytkownika
                                        </a>
                                    </td>
                                </tr>
                                <?php
}
$_smarty_tpl->smarty->ext->_foreach->restore($_smarty_tpl, 1);?>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>

                <div class="col-lg-6">
            <div class="card">
                <div class="card-header d-flex justify-content-between align-items-center">
                    <h5 class="card-title mb-0">
                        <i class="bi bi-tv me-2"></i>Moje urządzenia
                    </h5>
                    <a href="<?php echo $_smarty_tpl->tpl_vars['baseUrl']->value;?>
/devices" class="btn btn-sm btn-outline-primary">Zobacz wszystkie</a>
                </div>
                <div class="card-body p-0">
                    <div class="table-responsive">
                        <table class="table table-hover mb-0">
                            <thead>
                                <tr>
                                    <th>Nazwa</th>
                                    <th>MAC</th>
                                    <th>Playlisty</th>
                                    <th>Status</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php
$_from = $_smarty_tpl->smarty->ext->_foreach->init($_smarty_tpl, $_smarty_tpl->tpl_vars['myDevices']->value, 'device');
$_smarty_tpl->tpl_vars['device']->do_else = true;
if ($_from !== null) foreach ($_from as $_smarty_tpl->tpl_vars['device']->value) {
$_smarty_tpl->tpl_vars['device']->do_else = false;
?>
                                <tr>
                                    <td><strong><?php echo (($tmp = $_smarty_tpl->tpl_vars['device']->value['name'] ?? null)===null||$tmp==='' ? 'Bez nazwy' ?? null : $tmp);?>
</strong></td>
                                    <td><code class="small"><?php echo $_smarty_tpl->tpl_vars['device']->value['mac'];?>
</code></td>
                                    <td><span class="badge bg-info"><?php echo $_smarty_tpl->tpl_vars['device']->value['playlists_count'];?>
</span></td>
                                    <td>
                                        <?php if ($_smarty_tpl->tpl_vars['device']->value['is_blocked']) {?>
                                        <span class="badge bg-danger">Zablokowane</span>
                                        <?php } else { ?>
                                        <span class="badge bg-success">Aktywne</span>
                                        <?php }?>
                                    </td>
                                </tr>
                                <?php
}
if ($_smarty_tpl->tpl_vars['device']->do_else) {
?>
                                <tr>
                                    <td colspan="4" class="text-center py-4">
                                        <p class="text-muted mb-2">Brak własnych urządzeń</p>
                                        <?php if ($_smarty_tpl->tpl_vars['resellerUsage']->value['devices']['available_for_self'] > 0) {?>
                                        <a href="<?php echo $_smarty_tpl->tpl_vars['baseUrl']->value;?>
/devices/add" class="btn btn-sm btn-primary">
                                            <i class="bi bi-plus-lg me-1"></i>Dodaj urządzenie
                                        </a>
                                        <?php }?>
                                    </td>
                                </tr>
                                <?php
}
$_smarty_tpl->smarty->ext->_foreach->restore($_smarty_tpl, 1);?>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <?php } else { ?>
        <div class="row g-4 mb-4">
        <div class="col-sm-6 col-xl-4">
            <div class="stat-card stat-card-primary">
                <div class="stat-icon">
                    <i class="bi bi-tv"></i>
                </div>
                <div class="stat-content">
                    <div class="stat-value"><?php echo $_smarty_tpl->tpl_vars['myDevicesCount']->value;?>
/<?php echo $_smarty_tpl->tpl_vars['deviceLimit']->value;?>
</div>
                    <div class="stat-label">Moje urządzenia</div>
                </div>
                <div class="stat-footer">
                    <a href="<?php echo $_smarty_tpl->tpl_vars['baseUrl']->value;?>
/devices" class="text-primary">
                        <i class="bi bi-arrow-right me-1"></i>Zarządzaj urządzeniami
                    </a>
                </div>
            </div>
        </div>
        
        <div class="col-sm-6 col-xl-4">
            <div class="stat-card stat-card-success">
                <div class="stat-icon">
                    <i class="bi bi-list-ul"></i>
                </div>
                <div class="stat-content">
                    <div class="stat-value"><?php echo $_smarty_tpl->tpl_vars['myPlaylistsCount']->value;?>
/<?php echo $_smarty_tpl->tpl_vars['playlistLimit']->value;?>
</div>
                    <div class="stat-label">Moje playlisty</div>
                </div>
                <div class="stat-footer">
                    <a href="<?php echo $_smarty_tpl->tpl_vars['baseUrl']->value;?>
/playlists" class="text-success">
                        <i class="bi bi-arrow-right me-1"></i>Zarządzaj playlistami
                    </a>
                </div>
            </div>
        </div>
        
        <div class="col-sm-12 col-xl-4">
            <div class="stat-card stat-card-info">
                <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['currentUser']->value['username'];?>
</div>
                    <div class="stat-label">Twoje konto</div>
                </div>
                <div class="stat-footer">
                    <span>
                        <i class="bi bi-calendar3 me-1"></i>
                        Utworzone: <?php echo smarty_modifier_date_format($_smarty_tpl->tpl_vars['currentUser']->value['created_at'],"%d.%m.%Y");?>

                    </span>
                </div>
            </div>
        </div>
    </div>

        <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-tv me-2"></i>Moje urządzenia
            </h5>
            <div>
                <?php if ($_smarty_tpl->tpl_vars['myDevicesCount']->value < $_smarty_tpl->tpl_vars['deviceLimit']->value) {?>
                <a href="<?php echo $_smarty_tpl->tpl_vars['baseUrl']->value;?>
/devices/add" class="btn btn-sm btn-primary">
                    <i class="bi bi-plus-lg me-1"></i>Dodaj urządzenie
                </a>
                <?php }?>
                <a href="<?php echo $_smarty_tpl->tpl_vars['baseUrl']->value;?>
/devices" class="btn btn-sm btn-outline-secondary ms-1">
                    Zobacz wszystkie
                </a>
            </div>
        </div>
        <div class="card-body p-0">
            <div class="table-responsive">
                <table class="table table-hover mb-0">
                    <thead>
                        <tr>
                            <th>Nazwa</th>
                            <th>MAC</th>
                            <th>Kod</th>
                            <th>Playlisty</th>
                            <th>Status</th>
                            <th>Akcje</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php
$_from = $_smarty_tpl->smarty->ext->_foreach->init($_smarty_tpl, $_smarty_tpl->tpl_vars['myDevices']->value, 'device');
$_smarty_tpl->tpl_vars['device']->do_else = true;
if ($_from !== null) foreach ($_from as $_smarty_tpl->tpl_vars['device']->value) {
$_smarty_tpl->tpl_vars['device']->do_else = false;
?>
                        <tr>
                            <td><strong><?php echo (($tmp = $_smarty_tpl->tpl_vars['device']->value['name'] ?? null)===null||$tmp==='' ? 'Bez nazwy' ?? null : $tmp);?>
</strong></td>
                            <td><code><?php echo $_smarty_tpl->tpl_vars['device']->value['mac'];?>
</code></td>
                            <td><code><?php echo $_smarty_tpl->tpl_vars['device']->value['code'];?>
</code></td>
                            <td>
                                <a href="<?php echo $_smarty_tpl->tpl_vars['baseUrl']->value;?>
/playlists?device_id=<?php echo $_smarty_tpl->tpl_vars['device']->value['id'];?>
" class="badge bg-info text-decoration-none">
                                    <?php echo $_smarty_tpl->tpl_vars['device']->value['playlists_count'];?>
 playlist
                                </a>
                            </td>
                            <td>
                                <?php if ($_smarty_tpl->tpl_vars['device']->value['is_blocked']) {?>
                                <span class="badge bg-danger">Zablokowane</span>
                                <?php } else { ?>
                                <span class="badge bg-success">Aktywne</span>
                                <?php }?>
                            </td>
                            <td>
                                <a href="<?php echo $_smarty_tpl->tpl_vars['baseUrl']->value;?>
/playlists/add?device_id=<?php echo $_smarty_tpl->tpl_vars['device']->value['id'];?>
" class="btn btn-sm btn-outline-success" title="Dodaj playlistę">
                                    <i class="bi bi-plus-lg"></i>
                                </a>
                                <a href="<?php echo $_smarty_tpl->tpl_vars['baseUrl']->value;?>
/devices/edit?id=<?php echo $_smarty_tpl->tpl_vars['device']->value['id'];?>
" class="btn btn-sm btn-outline-primary" title="Edytuj">
                                    <i class="bi bi-pencil"></i>
                                </a>
                            </td>
                        </tr>
                        <?php
}
if ($_smarty_tpl->tpl_vars['device']->do_else) {
?>
                        <tr>
                            <td colspan="6" class="text-center py-5">
                                <div class="text-muted mb-3">
                                    <i class="bi bi-tv" style="font-size: 3rem;"></i>
                                </div>
                                <p class="mb-3">Nie masz jeszcze żadnych urządzeń</p>
                                <a href="<?php echo $_smarty_tpl->tpl_vars['baseUrl']->value;?>
/devices/add" class="btn btn-primary">
                                    <i class="bi bi-plus-lg me-1"></i>Dodaj pierwsze urządzenie
                                </a>
                            </td>
                        </tr>
                        <?php
}
$_smarty_tpl->smarty->ext->_foreach->restore($_smarty_tpl, 1);?>
                    </tbody>
                </table>
            </div>
        </div>
    </div>

        <?php if ($_smarty_tpl->tpl_vars['recentPlaylists']->value && count($_smarty_tpl->tpl_vars['recentPlaylists']->value) > 0) {?>
    <div class="card">
        <div class="card-header d-flex justify-content-between align-items-center">
            <h5 class="card-title mb-0">
                <i class="bi bi-list-ul me-2"></i>Ostatnie playlisty
            </h5>
            <a href="<?php echo $_smarty_tpl->tpl_vars['baseUrl']->value;?>
/playlists" class="btn btn-sm btn-outline-primary">Zobacz wszystkie</a>
        </div>
        <div class="card-body p-0">
            <div class="table-responsive">
                <table class="table table-hover mb-0">
                    <thead>
                        <tr>
                            <th>Nazwa</th>
                            <th>Typ</th>
                            <th>Urządzenie</th>
                            <th>Status</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php
$_from = $_smarty_tpl->smarty->ext->_foreach->init($_smarty_tpl, $_smarty_tpl->tpl_vars['recentPlaylists']->value, 'playlist');
$_smarty_tpl->tpl_vars['playlist']->do_else = true;
if ($_from !== null) foreach ($_from as $_smarty_tpl->tpl_vars['playlist']->value) {
$_smarty_tpl->tpl_vars['playlist']->do_else = false;
?>
                        <tr>
                            <td><strong><?php echo $_smarty_tpl->tpl_vars['playlist']->value['name'];?>
</strong></td>
                            <td>
                                <?php if ($_smarty_tpl->tpl_vars['playlist']->value['type'] == 'xtream') {?>
                                <span class="badge bg-primary">Xtream</span>
                                <?php } elseif ($_smarty_tpl->tpl_vars['playlist']->value['type'] == 'm3u') {?>
                                <span class="badge bg-success">M3U</span>
                                <?php } else { ?>
                                <span class="badge bg-warning">Stalker</span>
                                <?php }?>
                            </td>
                            <td><code class="small"><?php echo (($tmp = $_smarty_tpl->tpl_vars['playlist']->value['device_name'] ?? null)===null||$tmp==='' ? $_smarty_tpl->tpl_vars['playlist']->value['mac'] ?? null : $tmp);?>
</code></td>
                            <td>
                                <?php if ($_smarty_tpl->tpl_vars['playlist']->value['is_active']) {?>
                                <span class="badge bg-success">Aktywna</span>
                                <?php } else { ?>
                                <span class="badge bg-secondary">Nieaktywna</span>
                                <?php }?>
                            </td>
                        </tr>
                        <?php
}
$_smarty_tpl->smarty->ext->_foreach->restore($_smarty_tpl, 1);?>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
    <?php }?>
    <?php }?>
</div>
<?php
}
}
/* {/block "content"} */
}
