<?php
/* Smarty version 4.5.6, created on 2025-12-22 20:42:13
  from '/var/www/html/tivi/panel/templates/reports/audit.tpl' */

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


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

<?php $_smarty_tpl->inheritance->endChild($_smarty_tpl, "layout.tpl");
}
/* {block "content"} */
class Block_62906916269499f15d01044_57889080 extends Smarty_Internal_Block
{
public $subBlocks = array (
  'content' => 
  array (
    0 => 'Block_62906916269499f15d01044_57889080',
  ),
);
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 zmian</h4>
            <p class="text-muted mb-0">Szczegółowy dziennik zmian w systemie</p>
        </div>
    </div>

    <!-- Filtry -->
    <div class="card mb-4">
        <div class="card-body">
            <form method="get" class="row g-3">
                <div class="col-md-2">
                    <select name="entity_type" class="form-select">
                        <option value="">Wszystkie typy</option>
                        <option value="user" <?php if ($_smarty_tpl->tpl_vars['filters']->value['entity_type'] == 'user') {?>selected<?php }?>>Użytkownicy</option>
                        <option value="device" <?php if ($_smarty_tpl->tpl_vars['filters']->value['entity_type'] == 'device') {?>selected<?php }?>>Urządzenia</option>
                        <option value="playlist" <?php if ($_smarty_tpl->tpl_vars['filters']->value['entity_type'] == 'playlist') {?>selected<?php }?>>Playlisty</option>
                        <option value="note" <?php if ($_smarty_tpl->tpl_vars['filters']->value['entity_type'] == 'note') {?>selected<?php }?>>Notatki</option>
                        <option value="settings" <?php if ($_smarty_tpl->tpl_vars['filters']->value['entity_type'] == 'settings') {?>selected<?php }?>>Ustawienia</option>
                        <option value="auth" <?php if ($_smarty_tpl->tpl_vars['filters']->value['entity_type'] == 'auth') {?>selected<?php }?>>Autoryzacja</option>
                        <option value="admin" <?php if ($_smarty_tpl->tpl_vars['filters']->value['entity_type'] == 'admin') {?>selected<?php }?>>Administracja</option>
                    </select>
                </div>
                <div class="col-md-2">
                    <select name="action" class="form-select">
                        <option value="">Wszystkie akcje</option>
                        <option value="create" <?php if ($_smarty_tpl->tpl_vars['filters']->value['action'] == 'create') {?>selected<?php }?>>Utworzenie</option>
                        <option value="update" <?php if ($_smarty_tpl->tpl_vars['filters']->value['action'] == 'update') {?>selected<?php }?>>Aktualizacja</option>
                        <option value="delete" <?php if ($_smarty_tpl->tpl_vars['filters']->value['action'] == 'delete') {?>selected<?php }?>>Usunięcie</option>
                        <option value="clone" <?php if ($_smarty_tpl->tpl_vars['filters']->value['action'] == 'clone') {?>selected<?php }?>>Klonowanie</option>
                        <option value="block" <?php if ($_smarty_tpl->tpl_vars['filters']->value['action'] == 'block') {?>selected<?php }?>>Blokada</option>
                        <option value="unblock" <?php if ($_smarty_tpl->tpl_vars['filters']->value['action'] == 'unblock') {?>selected<?php }?>>Odblokowanie</option>
                        <option value="activate" <?php if ($_smarty_tpl->tpl_vars['filters']->value['action'] == 'activate') {?>selected<?php }?>>Aktywacja</option>
                        <option value="deactivate" <?php if ($_smarty_tpl->tpl_vars['filters']->value['action'] == 'deactivate') {?>selected<?php }?>>Dezaktywacja</option>
                        <option value="login" <?php if ($_smarty_tpl->tpl_vars['filters']->value['action'] == 'login') {?>selected<?php }?>>Logowanie</option>
                        <option value="logout" <?php if ($_smarty_tpl->tpl_vars['filters']->value['action'] == 'logout') {?>selected<?php }?>>Wylogowanie</option>
                        <option value="password_reset" <?php if ($_smarty_tpl->tpl_vars['filters']->value['action'] == 'password_reset') {?>selected<?php }?>>Reset hasła</option>
                        <option value="password_changed" <?php if ($_smarty_tpl->tpl_vars['filters']->value['action'] == 'password_changed') {?>selected<?php }?>>Zmiana hasła</option>
                        <option value="copy" <?php if ($_smarty_tpl->tpl_vars['filters']->value['action'] == 'copy') {?>selected<?php }?>>Kopiowanie</option>
                        <option value="move" <?php if ($_smarty_tpl->tpl_vars['filters']->value['action'] == 'move') {?>selected<?php }?>>Przeniesienie</option>
                        <option value="pin" <?php if ($_smarty_tpl->tpl_vars['filters']->value['action'] == 'pin') {?>selected<?php }?>>Przypięcie</option>
                        <option value="unpin" <?php if ($_smarty_tpl->tpl_vars['filters']->value['action'] == 'unpin') {?>selected<?php }?>>Odpięcie</option>
                    </select>
                </div>
                <div class="col-md-2">
                    <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="date" name="date_from" class="form-control" value="<?php echo (($tmp = $_smarty_tpl->tpl_vars['filters']->value['date_from'] ?? null)===null||$tmp==='' ? '' ?? null : $tmp);?>
" placeholder="Od">
                </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);?>
" placeholder="Do">
                </div>
                <div class="col-md-2">
                    <button type="submit" class="btn btn-secondary w-100"><i class="bi bi-filter me-1"></i>Filtruj</button>
                </div>
            </form>
        </div>
    </div>

    <!-- Lista zmian -->
    <div class="card">
        <div class="card-body p-0">
            <div class="table-responsive">
                <table class="table table-hover mb-0">
                    <thead>
                        <tr>
                            <th style="width: 140px;">Data</th>
                            <th>Użytkownik</th>
                            <th>Typ</th>
                            <th>Obiekt</th>
                            <th>Akcja</th>
                            <th>Zmiany</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 class="small"><?php echo smarty_modifier_date_format($_smarty_tpl->tpl_vars['log']->value['created_at'],"%d.%m.%Y %H:%M");?>
</td>
                            <td>
                                <strong><?php echo (($tmp = $_smarty_tpl->tpl_vars['log']->value['username'] ?? null)===null||$tmp==='' ? 'System' ?? null : $tmp);?>
</strong>
                                <?php if ($_smarty_tpl->tpl_vars['log']->value['ip_address']) {?>
                                <br><small class="text-muted"><?php echo $_smarty_tpl->tpl_vars['log']->value['ip_address'];?>
</small>
                                <?php }?>
                            </td>
                            <td>
                                <?php if ($_smarty_tpl->tpl_vars['log']->value['entity_type'] == 'user') {?>
                                <span class="badge bg-primary"><i class="bi bi-person me-1"></i>Użytkownik</span>
                                <?php } elseif ($_smarty_tpl->tpl_vars['log']->value['entity_type'] == 'device') {?>
                                <span class="badge bg-success"><i class="bi bi-tv me-1"></i>Urządzenie</span>
                                <?php } elseif ($_smarty_tpl->tpl_vars['log']->value['entity_type'] == 'playlist') {?>
                                <span class="badge bg-warning text-dark"><i class="bi bi-list-ul me-1"></i>Playlista</span>
                                <?php } elseif ($_smarty_tpl->tpl_vars['log']->value['entity_type'] == 'note') {?>
                                <span class="badge bg-secondary"><i class="bi bi-sticky me-1"></i>Notatka</span>
                                <?php } elseif ($_smarty_tpl->tpl_vars['log']->value['entity_type'] == 'settings') {?>
                                <span class="badge bg-info"><i class="bi bi-gear me-1"></i>Ustawienia</span>
                                <?php } elseif ($_smarty_tpl->tpl_vars['log']->value['entity_type'] == 'auth') {?>
                                <span class="badge bg-dark"><i class="bi bi-shield-lock me-1"></i>Autoryzacja</span>
                                <?php } elseif ($_smarty_tpl->tpl_vars['log']->value['entity_type'] == 'admin') {?>
                                <span class="badge bg-danger"><i class="bi bi-sliders me-1"></i>Administracja</span>
                                <?php } else { ?>
                                <span class="badge bg-secondary"><?php echo $_smarty_tpl->tpl_vars['log']->value['entity_type'];?>
</span>
                                <?php }?>
                            </td>
                            <td>
                                <?php if ($_smarty_tpl->tpl_vars['log']->value['entity_name']) {?>
                                <?php echo $_smarty_tpl->tpl_vars['log']->value['entity_name'];?>

                                <?php } else { ?>
                                <span class="text-muted">ID: <?php echo $_smarty_tpl->tpl_vars['log']->value['entity_id'];?>
</span>
                                <?php }?>
                            </td>
                            <td>
                                <?php if ($_smarty_tpl->tpl_vars['log']->value['action'] == 'create') {?>
                                <span class="badge bg-success"><i class="bi bi-plus-circle me-1"></i>Utworzono</span>
                                <?php } elseif ($_smarty_tpl->tpl_vars['log']->value['action'] == 'update') {?>
                                <span class="badge bg-info"><i class="bi bi-pencil me-1"></i>Zmieniono</span>
                                <?php } elseif ($_smarty_tpl->tpl_vars['log']->value['action'] == 'delete') {?>
                                <span class="badge bg-danger"><i class="bi bi-trash me-1"></i>Usunięto</span>
                                <?php } elseif ($_smarty_tpl->tpl_vars['log']->value['action'] == 'clone') {?>
                                <span class="badge bg-primary"><i class="bi bi-copy me-1"></i>Sklonowano</span>
                                <?php } elseif ($_smarty_tpl->tpl_vars['log']->value['action'] == 'block') {?>
                                <span class="badge bg-warning text-dark"><i class="bi bi-lock me-1"></i>Zablokowano</span>
                                <?php } elseif ($_smarty_tpl->tpl_vars['log']->value['action'] == 'unblock') {?>
                                <span class="badge bg-success"><i class="bi bi-unlock me-1"></i>Odblokowano</span>
                                <?php } elseif ($_smarty_tpl->tpl_vars['log']->value['action'] == 'activate') {?>
                                <span class="badge bg-success"><i class="bi bi-check-circle me-1"></i>Aktywowano</span>
                                <?php } elseif ($_smarty_tpl->tpl_vars['log']->value['action'] == 'deactivate') {?>
                                <span class="badge bg-secondary"><i class="bi bi-x-circle me-1"></i>Dezaktywowano</span>
                                <?php } elseif ($_smarty_tpl->tpl_vars['log']->value['action'] == 'login') {?>
                                <span class="badge bg-primary"><i class="bi bi-box-arrow-in-right me-1"></i>Logowanie</span>
                                <?php } elseif ($_smarty_tpl->tpl_vars['log']->value['action'] == 'login_failed') {?>
                                <span class="badge bg-danger"><i class="bi bi-x-octagon me-1"></i>Nieudane logowanie</span>
                                <?php } elseif ($_smarty_tpl->tpl_vars['log']->value['action'] == 'logout') {?>
                                <span class="badge bg-secondary"><i class="bi bi-box-arrow-left me-1"></i>Wylogowanie</span>
                                <?php } elseif ($_smarty_tpl->tpl_vars['log']->value['action'] == 'password_reset') {?>
                                <span class="badge bg-warning text-dark"><i class="bi bi-key me-1"></i>Reset hasła</span>
                                <?php } elseif ($_smarty_tpl->tpl_vars['log']->value['action'] == 'password_changed') {?>
                                <span class="badge bg-info"><i class="bi bi-key-fill me-1"></i>Zmiana hasła</span>
                                <?php } elseif ($_smarty_tpl->tpl_vars['log']->value['action'] == 'copy') {?>
                                <span class="badge bg-info"><i class="bi bi-files me-1"></i>Skopiowano</span>
                                <?php } elseif ($_smarty_tpl->tpl_vars['log']->value['action'] == 'move') {?>
                                <span class="badge bg-warning text-dark"><i class="bi bi-arrow-right-circle me-1"></i>Przeniesiono</span>
                                <?php } elseif ($_smarty_tpl->tpl_vars['log']->value['action'] == 'pin') {?>
                                <span class="badge bg-primary"><i class="bi bi-pin-fill me-1"></i>Przypięto</span>
                                <?php } elseif ($_smarty_tpl->tpl_vars['log']->value['action'] == 'unpin') {?>
                                <span class="badge bg-secondary"><i class="bi bi-pin me-1"></i>Odpięto</span>
                                <?php } else { ?>
                                <span class="badge bg-secondary"><?php echo $_smarty_tpl->tpl_vars['log']->value['action'];?>
</span>
                                <?php }?>
                            </td>
                            <td>
                                <?php if ($_smarty_tpl->tpl_vars['log']->value['old_values_decoded'] || $_smarty_tpl->tpl_vars['log']->value['new_values_decoded']) {?>
                                <button type="button" class="btn btn-sm btn-outline-secondary" 
                                        data-bs-toggle="modal" data-bs-target="#changesModal<?php echo $_smarty_tpl->tpl_vars['log']->value['id'];?>
">
                                    <i class="bi bi-eye"></i> Szczegóły
                                </button>
                                
                                <!-- Modal ze zmianami -->
                                <div class="modal fade" id="changesModal<?php echo $_smarty_tpl->tpl_vars['log']->value['id'];?>
" tabindex="-1">
                                    <div class="modal-dialog modal-lg">
                                        <div class="modal-content">
                                            <div class="modal-header">
                                                <h5 class="modal-title">Szczegóły zmiany</h5>
                                                <button type="button" class="btn-close" data-bs-dismiss="modal"></button>
                                            </div>
                                            <div class="modal-body">
                                                <div class="row">
                                                    <?php if ($_smarty_tpl->tpl_vars['log']->value['old_values_formatted']) {?>
                                                    <div class="col-md-6">
                                                        <h6 class="text-danger"><i class="bi bi-dash-circle me-1"></i>Przed:</h6>
                                                        <pre class="bg-dark text-light p-3 rounded small" style="max-height: 400px; overflow: auto;"><?php echo htmlspecialchars((string)$_smarty_tpl->tpl_vars['log']->value['old_values_formatted'], ENT_QUOTES, 'UTF-8', true);?>
</pre>
                                                    </div>
                                                    <?php }?>
                                                    <?php if ($_smarty_tpl->tpl_vars['log']->value['new_values_formatted']) {?>
                                                    <div class="col-md-6">
                                                        <h6 class="text-success"><i class="bi bi-plus-circle me-1"></i>Po:</h6>
                                                        <pre class="bg-dark text-light p-3 rounded small" style="max-height: 400px; overflow: auto;"><?php echo htmlspecialchars((string)$_smarty_tpl->tpl_vars['log']->value['new_values_formatted'], ENT_QUOTES, 'UTF-8', true);?>
</pre>
                                                    </div>
                                                    <?php }?>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <?php } else { ?>
                                <span class="text-muted">-</span>
                                <?php }?>
                            </td>
                        </tr>
                        <?php
}
if ($_smarty_tpl->tpl_vars['log']->do_else) {
?>
                        <tr>
                            <td colspan="6" class="text-center py-4 text-muted">Brak wpisów w dzienniku</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['filters']->value['entity_type']) {?>&entity_type=<?php echo $_smarty_tpl->tpl_vars['filters']->value['entity_type'];
}
if ($_smarty_tpl->tpl_vars['filters']->value['action']) {?>&action=<?php echo $_smarty_tpl->tpl_vars['filters']->value['action'];
}
if ($_smarty_tpl->tpl_vars['filters']->value['user_id']) {?>&user_id=<?php echo $_smarty_tpl->tpl_vars['filters']->value['user_id'];
}
if ($_smarty_tpl->tpl_vars['filters']->value['date_from']) {?>&date_from=<?php echo $_smarty_tpl->tpl_vars['filters']->value['date_from'];
}
if ($_smarty_tpl->tpl_vars['filters']->value['date_to']) {?>&date_to=<?php echo $_smarty_tpl->tpl_vars['filters']->value['date_to'];
}?>"><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'], 'p');
$_smarty_tpl->tpl_vars['p']->do_else = true;
if ($_from !== null) foreach ($_from as $_smarty_tpl->tpl_vars['p']->value) {
$_smarty_tpl->tpl_vars['p']->do_else = false;
?>
                        <?php if ($_smarty_tpl->tpl_vars['p']->value === '...') {?>
                        <li class="page-item disabled"><span class="page-link">...</span></li>
                        <?php } else { ?>
                        <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;
if ($_smarty_tpl->tpl_vars['filters']->value['entity_type']) {?>&entity_type=<?php echo $_smarty_tpl->tpl_vars['filters']->value['entity_type'];
}
if ($_smarty_tpl->tpl_vars['filters']->value['action']) {?>&action=<?php echo $_smarty_tpl->tpl_vars['filters']->value['action'];
}
if ($_smarty_tpl->tpl_vars['filters']->value['user_id']) {?>&user_id=<?php echo $_smarty_tpl->tpl_vars['filters']->value['user_id'];
}
if ($_smarty_tpl->tpl_vars['filters']->value['date_from']) {?>&date_from=<?php echo $_smarty_tpl->tpl_vars['filters']->value['date_from'];
}
if ($_smarty_tpl->tpl_vars['filters']->value['date_to']) {?>&date_to=<?php echo $_smarty_tpl->tpl_vars['filters']->value['date_to'];
}?>"><?php echo $_smarty_tpl->tpl_vars['p']->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['filters']->value['entity_type']) {?>&entity_type=<?php echo $_smarty_tpl->tpl_vars['filters']->value['entity_type'];
}
if ($_smarty_tpl->tpl_vars['filters']->value['action']) {?>&action=<?php echo $_smarty_tpl->tpl_vars['filters']->value['action'];
}
if ($_smarty_tpl->tpl_vars['filters']->value['user_id']) {?>&user_id=<?php echo $_smarty_tpl->tpl_vars['filters']->value['user_id'];
}
if ($_smarty_tpl->tpl_vars['filters']->value['date_from']) {?>&date_from=<?php echo $_smarty_tpl->tpl_vars['filters']->value['date_from'];
}
if ($_smarty_tpl->tpl_vars['filters']->value['date_to']) {?>&date_to=<?php echo $_smarty_tpl->tpl_vars['filters']->value['date_to'];
}?>"><i class="bi bi-chevron-right"></i></a>
                    </li>
                </ul>
            </nav>
        </div>
        <?php }?>
    </div>
</div>
<?php
}
}
/* {/block "content"} */
}
