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

/* @var Smarty_Internal_Template $_smarty_tpl */
if ($_smarty_tpl->_decodeProperties($_smarty_tpl, array (
  'version' => '4.5.6',
  'unifunc' => 'content_6942e789003367_30037742',
  'has_nocache_code' => false,
  'file_dependency' => 
  array (
    '5afa03266984d8af08b0f7a6edf76be96fb97d46' => 
    array (
      0 => '/var/www/html/tivi/panel/templates/logs/list.tpl',
      1 => 1765992175,
      2 => 'file',
    ),
  ),
  'includes' => 
  array (
  ),
),false)) {
function content_6942e789003367_30037742 (Smarty_Internal_Template $_smarty_tpl) {
$_smarty_tpl->_loadInheritance();
$_smarty_tpl->inheritance->init($_smarty_tpl, true);
?>


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


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

<?php $_smarty_tpl->inheritance->endChild($_smarty_tpl, "layout.tpl");
}
/* {block "content"} */
class Block_7505998416942e788f38c32_45171038 extends Smarty_Internal_Block
{
public $subBlocks = array (
  'content' => 
  array (
    0 => 'Block_7505998416942e788f38c32_45171038',
  ),
);
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="d-flex flex-wrap justify-content-between align-items-center mb-4">
        <div>
            <h4 class="mb-1">Logi aplikacji</h4>
            <p class="text-muted mb-0">Historia akcji użytkowników</p>
        </div>
        <button type="button" class="btn btn-outline-danger" id="clearLogsBtn">
            <i class="bi bi-trash me-1"></i>Wyczyść stare logi
        </button>
    </div>

    <!-- Tabs -->
    <ul class="nav nav-tabs mb-4">
        <li class="nav-item">
            <a class="nav-link active" href="<?php echo $_smarty_tpl->tpl_vars['baseUrl']->value;?>
/admin/logs">
                <i class="bi bi-journal-text me-1"></i>Logi aplikacji
            </a>
        </li>
        <li class="nav-item">
            <a class="nav-link" href="<?php echo $_smarty_tpl->tpl_vars['baseUrl']->value;?>
/admin/logs/api">
                <i class="bi bi-cloud-arrow-down me-1"></i>Logi API
            </a>
        </li>
    </ul>

    <!-- Filters -->
    <div class="card mb-4">
        <div class="card-body">
            <form method="get" class="row g-3">
                <div class="col-md-8">
                    <select name="user_id" class="form-select">
                        <option value="">Wszyscy użytkownicy</option>
                        <?php
$_from = $_smarty_tpl->smarty->ext->_foreach->init($_smarty_tpl, $_smarty_tpl->tpl_vars['users']->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;
?>
                        <option value="<?php echo $_smarty_tpl->tpl_vars['user']->value['id'];?>
" <?php if ($_smarty_tpl->tpl_vars['filterUserId']->value == $_smarty_tpl->tpl_vars['user']->value['id']) {?>selected<?php }?>><?php echo $_smarty_tpl->tpl_vars['user']->value['username'];?>
</option>
                        <?php
}
$_smarty_tpl->smarty->ext->_foreach->restore($_smarty_tpl, 1);?>
                    </select>
                </div>
                <div class="col-md-4">
                    <button type="submit" class="btn btn-secondary w-100">
                        <i class="bi bi-filter me-1"></i>Filtruj
                    </button>
                </div>
            </form>
        </div>
    </div>

    <!-- Logs Table -->
    <div class="card">
        <div class="card-body p-0">
            <div class="table-responsive">
                <table class="table table-hover align-middle mb-0">
                    <thead>
                        <tr>
                            <th>Data</th>
                            <th>Użytkownik</th>
                            <th>Akcja</th>
                            <th>Szczegóły</th>
                            <th>IP</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php
$_from = $_smarty_tpl->smarty->ext->_foreach->init($_smarty_tpl, $_smarty_tpl->tpl_vars['logs']->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="text-nowrap"><?php echo smarty_modifier_date_format($_smarty_tpl->tpl_vars['log']->value['created_at'],"%d.%m.%Y");?>
</span>
                                <br><small class="text-muted"><?php echo smarty_modifier_date_format($_smarty_tpl->tpl_vars['log']->value['created_at'],"%H:%M:%S");?>
</small>
                            </td>
                            <td><?php echo (($tmp = $_smarty_tpl->tpl_vars['log']->value['username'] ?? null)===null||$tmp==='' ? '<span class="text-muted">System</span>' ?? null : $tmp);?>
</td>
                            <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 if ($_smarty_tpl->tpl_vars['log']->value['details']) {?>
                                <small><?php echo smarty_modifier_truncate($_smarty_tpl->tpl_vars['log']->value['details'],80);?>
</small>
                                <?php } else { ?>
                                <span class="text-muted">-</span>
                                <?php }?>
                            </td>
                            <td><code><?php echo $_smarty_tpl->tpl_vars['log']->value['ip'];?>
</code></td>
                        </tr>
                        <?php
}
if ($_smarty_tpl->tpl_vars['log']->do_else) {
?>
                        <tr>
                            <td colspan="5" class="text-center py-5">
                                <div class="text-muted mb-3">
                                    <i class="bi bi-journal" style="font-size: 3rem;"></i>
                                </div>
                                <p class="mb-0">Brak logów</p>
                            </td>
                        </tr>
                        <?php
}
$_smarty_tpl->smarty->ext->_foreach->restore($_smarty_tpl, 1);?>
                    </tbody>
                </table>
            </div>
        </div>

        <?php if ($_smarty_tpl->tpl_vars['pagination']->value['total_pages'] > 1) {?>
        <div class="card-footer">
            <nav>
                <ul class="pagination pagination-sm mb-0 justify-content-center">
                    <li class="page-item<?php if (!$_smarty_tpl->tpl_vars['pagination']->value['has_prev']) {?> disabled<?php }?>">
                        <a class="page-link" href="?page=<?php echo $_smarty_tpl->tpl_vars['pagination']->value['current_page']-1;
if ($_smarty_tpl->tpl_vars['filterUserId']->value) {?>&user_id=<?php echo $_smarty_tpl->tpl_vars['filterUserId']->value;
}?>">
                            <i class="bi bi-chevron-left"></i>
                        </a>
                    </li>
                    <?php
$_from = $_smarty_tpl->smarty->ext->_foreach->init($_smarty_tpl, $_smarty_tpl->tpl_vars['pagination']->value['pages'], 'page');
$_smarty_tpl->tpl_vars['page']->do_else = true;
if ($_from !== null) foreach ($_from as $_smarty_tpl->tpl_vars['page']->value) {
$_smarty_tpl->tpl_vars['page']->do_else = false;
?>
                        <?php if ($_smarty_tpl->tpl_vars['page']->value === '...') {?>
                        <li class="page-item disabled"><span class="page-link">...</span></li>
                        <?php } else { ?>
                        <li class="page-item<?php if ($_smarty_tpl->tpl_vars['page']->value == $_smarty_tpl->tpl_vars['pagination']->value['current_page']) {?> active<?php }?>">
                            <a class="page-link" href="?page=<?php echo $_smarty_tpl->tpl_vars['page']->value;
if ($_smarty_tpl->tpl_vars['filterUserId']->value) {?>&user_id=<?php echo $_smarty_tpl->tpl_vars['filterUserId']->value;
}?>"><?php echo $_smarty_tpl->tpl_vars['page']->value;?>
</a>
                        </li>
                        <?php }?>
                    <?php
}
$_smarty_tpl->smarty->ext->_foreach->restore($_smarty_tpl, 1);?>
                    <li class="page-item<?php if (!$_smarty_tpl->tpl_vars['pagination']->value['has_next']) {?> disabled<?php }?>">
                        <a class="page-link" href="?page=<?php echo $_smarty_tpl->tpl_vars['pagination']->value['current_page']+1;
if ($_smarty_tpl->tpl_vars['filterUserId']->value) {?>&user_id=<?php echo $_smarty_tpl->tpl_vars['filterUserId']->value;
}?>">
                            <i class="bi bi-chevron-right"></i>
                        </a>
                    </li>
                </ul>
            </nav>
        </div>
        <?php }?>
    </div>
</div>

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


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

    document.getElementById('clearLogsBtn').addEventListener('click', function() {
        Swal.fire({
            title: 'Wyczyść stare logi',
            html: '<p>Usuń logi starsze niż:</p>' +
                '<div class="input-group">' +
                '<input type="number" id="swal-days" class="form-control" value="30" min="1" max="365">' +
                '<span class="input-group-text">dni</span>' +
                '</div>',
            icon: 'warning',
            showCancelButton: true,
            confirmButtonText: 'Wyczyść',
            cancelButtonText: 'Anuluj',
            confirmButtonColor: '#dc3545',
            background: swalConfig.background,
            color: swalConfig.color,
            preConfirm: function() {
                var days = document.getElementById('swal-days').value;
                if (!days || days < 1 || days > 365) {
                    Swal.showValidationMessage('Podaj liczbę dni (1-365)');
                    return false;
                }
                return days;
            }
        }).then(function(result) {
            if (result.isConfirmed) {
                document.getElementById('clearLogsDays').value = result.value;
                document.getElementById('clearLogsForm').submit();
            }
        });
    });
})();
<?php echo '</script'; ?>
>

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