<?php
/* Smarty version 4.5.6, created on 2025-12-20 23:17:51
  from '/var/www/html/tivi/panel/templates/reports/logins.tpl' */

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


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

<?php $_smarty_tpl->inheritance->endChild($_smarty_tpl, "layout.tpl");
}
/* {block "content"} */
class Block_12871859936947208f31f319_34796017 extends Smarty_Internal_Block
{
public $subBlocks = array (
  'content' => 
  array (
    0 => 'Block_12871859936947208f31f319_34796017',
  ),
);
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">
    <div class="d-flex justify-content-between align-items-center mb-4">
        <div>
            <h4 class="mb-1">Historia logowań</h4>
            <p class="text-muted mb-0">Pełna historia logowań do systemu</p>
        </div>
        <a href="<?php echo $_smarty_tpl->tpl_vars['baseUrl']->value;?>
/reports/export/logins" class="btn btn-outline-primary">
            <i class="bi bi-download me-1"></i>Eksport CSV
        </a>
    </div>

    <!-- Statystyki -->
    <div class="row g-4 mb-4">
        <div class="col-sm-6 col-xl-3">
            <div class="card">
                <div class="card-body">
                    <div class="d-flex justify-content-between">
                        <div>
                            <p class="text-muted mb-1">Wszystkie logowania (30 dni)</p>
                            <h4 class="mb-0"><?php echo (($tmp = $_smarty_tpl->tpl_vars['stats']->value['logins']['total'] ?? null)===null||$tmp==='' ? 0 ?? null : $tmp);?>
</h4>
                        </div>
                        <div class="text-primary"><i class="bi bi-door-open fs-1"></i></div>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-sm-6 col-xl-3">
            <div class="card">
                <div class="card-body">
                    <div class="d-flex justify-content-between">
                        <div>
                            <p class="text-muted mb-1">Udane</p>
                            <h4 class="mb-0 text-success"><?php echo (($tmp = $_smarty_tpl->tpl_vars['stats']->value['logins']['successful'] ?? null)===null||$tmp==='' ? 0 ?? null : $tmp);?>
</h4>
                        </div>
                        <div class="text-success"><i class="bi bi-check-circle fs-1"></i></div>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-sm-6 col-xl-3">
            <div class="card">
                <div class="card-body">
                    <div class="d-flex justify-content-between">
                        <div>
                            <p class="text-muted mb-1">Nieudane</p>
                            <h4 class="mb-0 text-danger"><?php echo (($tmp = $_smarty_tpl->tpl_vars['stats']->value['logins']['failed'] ?? null)===null||$tmp==='' ? 0 ?? null : $tmp);?>
</h4>
                        </div>
                        <div class="text-danger"><i class="bi bi-x-circle fs-1"></i></div>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-sm-6 col-xl-3">
            <div class="card">
                <div class="card-body">
                    <div class="d-flex justify-content-between">
                        <div>
                            <p class="text-muted mb-1">Unikalne IP</p>
                            <h4 class="mb-0"><?php echo (($tmp = $_smarty_tpl->tpl_vars['stats']->value['logins']['unique_ips'] ?? null)===null||$tmp==='' ? 0 ?? null : $tmp);?>
</h4>
                        </div>
                        <div class="text-info"><i class="bi bi-globe fs-1"></i></div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- Filtry -->
    <div class="card mb-4">
        <div class="card-body">
            <form method="get" class="row g-3">
                <div class="col-md-3">
                    <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['filters']->value['user_id'] == $_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-2">
                    <input type="text" name="ip" class="form-control" placeholder="Adres IP" value="<?php echo (($tmp = $_smarty_tpl->tpl_vars['filters']->value['ip_address'] ?? null)===null||$tmp==='' ? '' ?? null : $tmp);?>
">
                </div>
                <div class="col-md-2">
                    <select name="success" class="form-select">
                        <option value="">Wszystkie</option>
                        <option value="1" <?php if ($_smarty_tpl->tpl_vars['filters']->value['success'] === true) {?>selected<?php }?>>Udane</option>
                        <option value="0" <?php if ($_smarty_tpl->tpl_vars['filters']->value['success'] === false) {?>selected<?php }?>>Nieudane</option>
                    </select>
                </div>
                <div class="col-md-2">
                    <input type="date" name="date_from" class="form-control" value="<?php echo (($tmp = $_smarty_tpl->tpl_vars['filters']->value['date_from'] ?? null)===null||$tmp==='' ? '' ?? null : $tmp);?>
">
                </div>
                <div class="col-md-2">
                    <input type="date" name="date_to" class="form-control" value="<?php echo (($tmp = $_smarty_tpl->tpl_vars['filters']->value['date_to'] ?? null)===null||$tmp==='' ? '' ?? null : $tmp);?>
">
                </div>
                <div class="col-md-1">
                    <button type="submit" class="btn btn-secondary w-100"><i class="bi bi-filter"></i></button>
                </div>
            </form>
        </div>
    </div>

    <!-- Lista logowań -->
    <div class="card">
        <div class="card-body p-0">
            <div class="table-responsive">
                <table class="table table-hover mb-0">
                    <thead>
                        <tr>
                            <th>Użytkownik</th>
                            <th>IP</th>
                            <th>Przeglądarka</th>
                            <th>System</th>
                            <th>Lokalizacja</th>
                            <th>Status</th>
                            <th>Data</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php
$_from = $_smarty_tpl->smarty->ext->_foreach->init($_smarty_tpl, $_smarty_tpl->tpl_vars['logins']->value, 'login');
$_smarty_tpl->tpl_vars['login']->do_else = true;
if ($_from !== null) foreach ($_from as $_smarty_tpl->tpl_vars['login']->value) {
$_smarty_tpl->tpl_vars['login']->do_else = false;
?>
                        <tr>
                            <td><strong><?php echo $_smarty_tpl->tpl_vars['login']->value['username'];?>
</strong></td>
                            <td><code><?php echo $_smarty_tpl->tpl_vars['login']->value['ip_address'];?>
</code></td>
                            <td><?php echo (($tmp = $_smarty_tpl->tpl_vars['login']->value['browser'] ?? null)===null||$tmp==='' ? '-' ?? null : $tmp);?>
</td>
                            <td>
                                <?php echo (($tmp = $_smarty_tpl->tpl_vars['login']->value['os'] ?? null)===null||$tmp==='' ? '-' ?? null : $tmp);?>

                                <?php if ($_smarty_tpl->tpl_vars['login']->value['device_type'] && $_smarty_tpl->tpl_vars['login']->value['device_type'] != 'Desktop') {?>
                                <span class="badge bg-secondary"><?php echo $_smarty_tpl->tpl_vars['login']->value['device_type'];?>
</span>
                                <?php }?>
                            </td>
                            <td>
                                <?php if ($_smarty_tpl->tpl_vars['login']->value['country']) {?>
                                <?php echo (($tmp = $_smarty_tpl->tpl_vars['login']->value['city'] ?? null)===null||$tmp==='' ? '' ?? null : $tmp);?>
 <?php echo $_smarty_tpl->tpl_vars['login']->value['country'];?>

                                <?php } else { ?>
                                <span class="text-muted">-</span>
                                <?php }?>
                            </td>
                            <td>
                                <?php if ($_smarty_tpl->tpl_vars['login']->value['success']) {?>
                                <span class="badge bg-success">OK</span>
                                <?php } else { ?>
                                <span class="badge bg-danger" title="<?php echo (($tmp = $_smarty_tpl->tpl_vars['login']->value['failure_reason'] ?? null)===null||$tmp==='' ? '' ?? null : $tmp);?>
">Błąd</span>
                                <?php }?>
                            </td>
                            <td><?php echo smarty_modifier_date_format($_smarty_tpl->tpl_vars['login']->value['created_at'],"%d.%m.%Y %H:%M");?>
</td>
                        </tr>
                        <?php
}
if ($_smarty_tpl->tpl_vars['login']->do_else) {
?>
                        <tr>
                            <td colspan="7" class="text-center py-4 text-muted">Brak wpisów</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;?>
"><i class="bi bi-chevron-left"></i></a>
                    </li>
                    <?php
$_smarty_tpl->tpl_vars['p'] = new Smarty_Variable(null, $_smarty_tpl->isRenderingCache);$_smarty_tpl->tpl_vars['p']->step = 1;$_smarty_tpl->tpl_vars['p']->total = (int) ceil(($_smarty_tpl->tpl_vars['p']->step > 0 ? min($_smarty_tpl->tpl_vars['pagination']->value['total_pages'],$_smarty_tpl->tpl_vars['pagination']->value['current_page']+2)+1 - (max(1,$_smarty_tpl->tpl_vars['pagination']->value['current_page']-2)) : max(1,$_smarty_tpl->tpl_vars['pagination']->value['current_page']-2)-(min($_smarty_tpl->tpl_vars['pagination']->value['total_pages'],$_smarty_tpl->tpl_vars['pagination']->value['current_page']+2))+1)/abs($_smarty_tpl->tpl_vars['p']->step));
if ($_smarty_tpl->tpl_vars['p']->total > 0) {
for ($_smarty_tpl->tpl_vars['p']->value = max(1,$_smarty_tpl->tpl_vars['pagination']->value['current_page']-2), $_smarty_tpl->tpl_vars['p']->iteration = 1;$_smarty_tpl->tpl_vars['p']->iteration <= $_smarty_tpl->tpl_vars['p']->total;$_smarty_tpl->tpl_vars['p']->value += $_smarty_tpl->tpl_vars['p']->step, $_smarty_tpl->tpl_vars['p']->iteration++) {
$_smarty_tpl->tpl_vars['p']->first = $_smarty_tpl->tpl_vars['p']->iteration === 1;$_smarty_tpl->tpl_vars['p']->last = $_smarty_tpl->tpl_vars['p']->iteration === $_smarty_tpl->tpl_vars['p']->total;?>
                    <li class="page-item<?php if ($_smarty_tpl->tpl_vars['p']->value == $_smarty_tpl->tpl_vars['pagination']->value['current_page']) {?> active<?php }?>">
                        <a class="page-link" href="?page=<?php echo $_smarty_tpl->tpl_vars['p']->value;?>
"><?php echo $_smarty_tpl->tpl_vars['p']->value;?>
</a>
                    </li>
                    <?php }
}
?>
                    <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;?>
"><i class="bi bi-chevron-right"></i></a>
                    </li>
                </ul>
            </nav>
        </div>
        <?php }?>
    </div>
</div>
<?php
}
}
/* {/block "content"} */
}
