<?php
/* Smarty version 4.5.6, created on 2026-01-24 18:25:02
  from '/var/www/html/tivi/panel/templates/settings/definitions.tpl' */

/* @var Smarty_Internal_Template $_smarty_tpl */
if ($_smarty_tpl->_decodeProperties($_smarty_tpl, array (
  'version' => '4.5.6',
  'unifunc' => 'content_6975006edf6aa7_07104499',
  'has_nocache_code' => false,
  'file_dependency' => 
  array (
    '3e2f5170fad6f01abfc49af3cd52b559de77aaad' => 
    array (
      0 => '/var/www/html/tivi/panel/templates/settings/definitions.tpl',
      1 => 1769259691,
      2 => 'file',
    ),
  ),
  'includes' => 
  array (
  ),
),false)) {
function content_6975006edf6aa7_07104499 (Smarty_Internal_Template $_smarty_tpl) {
$_smarty_tpl->_loadInheritance();
$_smarty_tpl->inheritance->init($_smarty_tpl, true);
?>


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


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

<?php $_smarty_tpl->inheritance->endChild($_smarty_tpl, "layout.tpl");
}
/* {block "content"} */
class Block_8110398136975006ede8a54_40885203 extends Smarty_Internal_Block
{
public $subBlocks = array (
  'content' => 
  array (
    0 => 'Block_8110398136975006ede8a54_40885203',
  ),
);
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.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">Definicje ustawień</h4>
            <p class="text-muted mb-0">Zarządzaj parametrami dostępnymi dla urządzeń</p>
        </div>
        <a href="<?php echo $_smarty_tpl->tpl_vars['baseUrl']->value;?>
/settings/add-definition" class="btn btn-primary">
            <i class="bi bi-plus-lg me-1"></i>Dodaj definicję
        </a>
    </div>

    <!-- Filters -->
    <div class="card mb-4">
        <div class="card-body">
            <form method="get" class="row g-3 align-items-end">
                <div class="col-md-4">
                    <label class="form-label small text-muted">Grupa</label>
                    <select name="group" class="form-select" onchange="this.form.submit()">
                        <option value="">Wszystkie grupy</option>
                        <?php
$_from = $_smarty_tpl->smarty->ext->_foreach->init($_smarty_tpl, $_smarty_tpl->tpl_vars['groups']->value, 'group');
$_smarty_tpl->tpl_vars['group']->do_else = true;
if ($_from !== null) foreach ($_from as $_smarty_tpl->tpl_vars['group']->value) {
$_smarty_tpl->tpl_vars['group']->do_else = false;
?>
                        <option value="<?php echo $_smarty_tpl->tpl_vars['group']->value['group_name'];?>
" <?php if ($_smarty_tpl->tpl_vars['filterGroup']->value == $_smarty_tpl->tpl_vars['group']->value['group_name']) {?>selected<?php }?>>
                            <?php echo (($tmp = $_smarty_tpl->tpl_vars['groupLabels']->value[$_smarty_tpl->tpl_vars['group']->value['group_name']] ?? null)===null||$tmp==='' ? $_smarty_tpl->tpl_vars['group']->value['group_name'] ?? null : $tmp);?>
 (<?php echo $_smarty_tpl->tpl_vars['group']->value['count'];?>
)
                        </option>
                        <?php
}
$_smarty_tpl->smarty->ext->_foreach->restore($_smarty_tpl, 1);?>
                    </select>
                </div>
                
                <?php if ($_smarty_tpl->tpl_vars['filterGroup']->value) {?>
                <div class="col-auto">
                    <a href="<?php echo $_smarty_tpl->tpl_vars['baseUrl']->value;?>
/settings/definitions" class="btn btn-outline-secondary">
                        <i class="bi bi-x-lg"></i>
                    </a>
                </div>
                <?php }?>
            </form>
        </div>
    </div>

    <!-- Definitions grouped -->
    <?php
$_from = $_smarty_tpl->smarty->ext->_foreach->init($_smarty_tpl, $_smarty_tpl->tpl_vars['grouped']->value, 'groupDefs', false, 'groupName');
$_smarty_tpl->tpl_vars['groupDefs']->do_else = true;
if ($_from !== null) foreach ($_from as $_smarty_tpl->tpl_vars['groupName']->value => $_smarty_tpl->tpl_vars['groupDefs']->value) {
$_smarty_tpl->tpl_vars['groupDefs']->do_else = false;
?>
    <div class="card mb-4">
        <div class="card-header">
            <h5 class="mb-0">
                <i class="bi bi-folder me-2"></i>
                <?php echo (($tmp = $_smarty_tpl->tpl_vars['groupLabels']->value[$_smarty_tpl->tpl_vars['groupName']->value] ?? null)===null||$tmp==='' ? $_smarty_tpl->tpl_vars['groupName']->value ?? null : $tmp);?>

                <span class="badge bg-secondary ms-2"><?php echo count($_smarty_tpl->tpl_vars['groupDefs']->value);?>
</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>Klucz</th>
                            <th>Etykieta</th>
                            <th>Typ</th>
                            <th>Min. poziom</th>
                            <th>Domyślna wartość</th>
                            <th>Opcje</th>
                            <th>Status</th>
                            <th class="text-end">Akcje</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php
$_from = $_smarty_tpl->smarty->ext->_foreach->init($_smarty_tpl, $_smarty_tpl->tpl_vars['groupDefs']->value, 'def');
$_smarty_tpl->tpl_vars['def']->do_else = true;
if ($_from !== null) foreach ($_from as $_smarty_tpl->tpl_vars['def']->value) {
$_smarty_tpl->tpl_vars['def']->do_else = false;
?>
                        <tr>
                            <td><code><?php echo $_smarty_tpl->tpl_vars['def']->value['key'];?>
</code></td>
                            <td>
                                <strong><?php echo $_smarty_tpl->tpl_vars['def']->value['label'];?>
</strong>
                                <?php if ($_smarty_tpl->tpl_vars['def']->value['description']) {?>
                                <br><small class="text-muted"><?php echo smarty_modifier_truncate($_smarty_tpl->tpl_vars['def']->value['description'],50);?>
</small>
                                <?php }?>
                            </td>
                            <td>
                                <span class="badge bg-<?php if ($_smarty_tpl->tpl_vars['def']->value['type'] == 'boolean') {?>info<?php } elseif ($_smarty_tpl->tpl_vars['def']->value['type'] == 'int') {?>primary<?php } elseif ($_smarty_tpl->tpl_vars['def']->value['type'] == 'long') {?>warning<?php } else { ?>secondary<?php }?>">
                                    <?php echo $_smarty_tpl->tpl_vars['def']->value['type'];?>

                                </span>
                            </td>
                            <td>
                                <span class="badge bg-<?php if ($_smarty_tpl->tpl_vars['def']->value['min_scope'] == 'global') {?>danger<?php } elseif ($_smarty_tpl->tpl_vars['def']->value['min_scope'] == 'reseller') {?>warning<?php } elseif ($_smarty_tpl->tpl_vars['def']->value['min_scope'] == 'user') {?>info<?php } else { ?>success<?php }?>">
                                    <?php echo $_smarty_tpl->tpl_vars['def']->value['min_scope'];?>

                                </span>
                            </td>
                            <td>
                                <?php if ($_smarty_tpl->tpl_vars['def']->value['type'] == 'boolean') {?>
                                    <?php if ($_smarty_tpl->tpl_vars['def']->value['default_value'] == 'true' || $_smarty_tpl->tpl_vars['def']->value['default_value'] == '1') {?>
                                    <span class="badge bg-success">true</span>
                                    <?php } else { ?>
                                    <span class="badge bg-secondary">false</span>
                                    <?php }?>
                                <?php } else { ?>
                                    <code><?php echo (($tmp = $_smarty_tpl->tpl_vars['def']->value['default_value'] ?? null)===null||$tmp==='' ? '-' ?? null : $tmp);?>
</code>
                                <?php }?>
                            </td>
                            <td>
                                <?php if ($_smarty_tpl->tpl_vars['def']->value['options']) {?>
                                <span class="badge bg-info" title="<?php echo count($_smarty_tpl->tpl_vars['def']->value['options']);?>
 opcji">
                                    <?php echo count($_smarty_tpl->tpl_vars['def']->value['options']);?>
 opcji
                                </span>
                                <?php } else { ?>
                                <span class="text-muted">-</span>
                                <?php }?>
                            </td>
                            <td>
                                <?php if ($_smarty_tpl->tpl_vars['def']->value['is_active']) {?>
                                <span class="badge bg-success">Aktywna</span>
                                <?php } else { ?>
                                <span class="badge bg-secondary">Nieaktywna</span>
                                <?php }?>
                            </td>
                            <td class="text-end">
                                <div class="btn-group btn-group-sm">
                                    <a href="<?php echo $_smarty_tpl->tpl_vars['baseUrl']->value;?>
/settings/edit-definition?id=<?php echo $_smarty_tpl->tpl_vars['def']->value['id'];?>
" class="btn btn-outline-primary" title="Edytuj">
                                        <i class="bi bi-pencil"></i>
                                    </a>
                                    <button type="button" class="btn btn-outline-danger delete-btn" 
                                            data-id="<?php echo $_smarty_tpl->tpl_vars['def']->value['id'];?>
" data-key="<?php echo $_smarty_tpl->tpl_vars['def']->value['key'];?>
" title="Usuń">
                                        <i class="bi bi-trash"></i>
                                    </button>
                                </div>
                            </td>
                        </tr>
                        <?php
}
$_smarty_tpl->smarty->ext->_foreach->restore($_smarty_tpl, 1);?>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
    <?php
}
if ($_smarty_tpl->tpl_vars['groupDefs']->do_else) {
?>
    <div class="alert alert-info">
        <i class="bi bi-info-circle me-2"></i>
        Brak definicji ustawień.
    </div>
    <?php
}
$_smarty_tpl->smarty->ext->_foreach->restore($_smarty_tpl, 1);?>
</div>

<!-- Delete Form -->
<form id="deleteForm" method="post" action="<?php echo $_smarty_tpl->tpl_vars['baseUrl']->value;?>
/settings/delete-definition" style="display:none;">
    <input type="hidden" name="csrf_token" value="<?php echo $_smarty_tpl->tpl_vars['csrfToken']->value;?>
">
    <input type="hidden" name="id" id="deleteId">
</form>
<?php
}
}
/* {/block "content"} */
/* {block "scripts"} */
class Block_9050565446975006edf6022_52932887 extends Smarty_Internal_Block
{
public $subBlocks = array (
  'scripts' => 
  array (
    0 => 'Block_9050565446975006edf6022_52932887',
  ),
);
public function callBlock(Smarty_Internal_Template $_smarty_tpl) {
?>


<?php echo '<script'; ?>
>
document.querySelectorAll('.delete-btn').forEach(function(btn) {
    btn.addEventListener('click', function() {
        var id = this.dataset.id;
        var key = this.dataset.key;
        
        Swal.fire({
            title: 'Potwierdź usunięcie',
            html: 'Czy na pewno chcesz usunąć definicję <strong>"' + key + '"</strong>?<br><small class="text-muted">Zostaną usunięte wszystkie wartości tego ustawienia.</small>',
            icon: 'warning',
            showCancelButton: true,
            confirmButtonText: 'Usuń',
            cancelButtonText: 'Anuluj',
            confirmButtonColor: '#dc3545',
            background: '#1a1d21',
            color: '#e1e1e1'
        }).then(function(result) {
            if (result.isConfirmed) {
                document.getElementById('deleteId').value = id;
                document.getElementById('deleteForm').submit();
            }
        });
    });
});
<?php echo '</script'; ?>
>

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