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

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


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


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

<?php $_smarty_tpl->inheritance->endChild($_smarty_tpl, "layout.tpl");
}
/* {block "content"} */
class Block_90061366969750075561239_67146323 extends Smarty_Internal_Block
{
public $subBlocks = array (
  'content' => 
  array (
    0 => 'Block_90061366969750075561239_67146323',
  ),
);
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">
    <!-- Header -->
    <div class="d-flex flex-wrap justify-content-between align-items-center mb-4">
        <div>
            <h4 class="mb-1">Zestawy ustawień (Presety)</h4>
            <p class="text-muted mb-0">Gotowe zestawy parametrów do szybkiego aplikowania</p>
        </div>
        <a href="<?php echo $_smarty_tpl->tpl_vars['baseUrl']->value;?>
/settings/add-preset" class="btn btn-primary">
            <i class="bi bi-plus-lg me-1"></i>Dodaj preset
        </a>
    </div>

    <!-- Presets -->
    <div class="row">
        <?php
$_from = $_smarty_tpl->smarty->ext->_foreach->init($_smarty_tpl, $_smarty_tpl->tpl_vars['presets']->value, 'preset');
$_smarty_tpl->tpl_vars['preset']->do_else = true;
if ($_from !== null) foreach ($_from as $_smarty_tpl->tpl_vars['preset']->value) {
$_smarty_tpl->tpl_vars['preset']->do_else = false;
?>
        <div class="col-md-6 col-lg-4 mb-4">
            <div class="card h-100">
                <div class="card-header d-flex justify-content-between align-items-center">
                    <h5 class="mb-0">
                        <i class="bi bi-collection me-2"></i>
                        <?php echo $_smarty_tpl->tpl_vars['preset']->value['name'];?>

                    </h5>
                    <?php if ($_smarty_tpl->tpl_vars['preset']->value['is_active']) {?>
                    <span class="badge bg-success">Aktywny</span>
                    <?php } else { ?>
                    <span class="badge bg-secondary">Nieaktywny</span>
                    <?php }?>
                </div>
                <div class="card-body">
                    <?php if ($_smarty_tpl->tpl_vars['preset']->value['description']) {?>
                    <p class="text-muted"><?php echo $_smarty_tpl->tpl_vars['preset']->value['description'];?>
</p>
                    <?php }?>
                    <p class="mb-2">
                        <strong><?php echo $_smarty_tpl->tpl_vars['preset']->value['items_count'];?>
</strong> ustawień w presecie
                    </p>
                    <small class="text-muted">
                        Utworzony przez: <?php echo (($tmp = $_smarty_tpl->tpl_vars['preset']->value['created_by_name'] ?? null)===null||$tmp==='' ? 'System' ?? null : $tmp);?>
<br>
                        <?php echo smarty_modifier_date_format($_smarty_tpl->tpl_vars['preset']->value['created_at'],"%d.%m.%Y %H:%M");?>

                    </small>
                </div>
                <div class="card-footer">
                    <div class="btn-group w-100">
                        <a href="<?php echo $_smarty_tpl->tpl_vars['baseUrl']->value;?>
/settings/edit-preset?id=<?php echo $_smarty_tpl->tpl_vars['preset']->value['id'];?>
" class="btn btn-outline-primary">
                            <i class="bi bi-pencil me-1"></i>Edytuj
                        </a>
                        <button type="button" class="btn btn-outline-danger delete-btn" 
                                data-id="<?php echo $_smarty_tpl->tpl_vars['preset']->value['id'];?>
" data-name="<?php echo htmlspecialchars((string)$_smarty_tpl->tpl_vars['preset']->value['name'], ENT_QUOTES, 'UTF-8', true);?>
">
                            <i class="bi bi-trash me-1"></i>Usuń
                        </button>
                    </div>
                </div>
            </div>
        </div>
        <?php
}
if ($_smarty_tpl->tpl_vars['preset']->do_else) {
?>
        <div class="col-12">
            <div class="alert alert-info">
                <i class="bi bi-info-circle me-2"></i>
                Brak presetów. <a href="<?php echo $_smarty_tpl->tpl_vars['baseUrl']->value;?>
/settings/add-preset">Dodaj pierwszy preset</a>.
            </div>
        </div>
        <?php
}
$_smarty_tpl->smarty->ext->_foreach->restore($_smarty_tpl, 1);?>
    </div>
</div>

<!-- Delete Form -->
<form id="deleteForm" method="post" action="<?php echo $_smarty_tpl->tpl_vars['baseUrl']->value;?>
/settings/delete-preset" 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_33054314669750075567ef3_56708289 extends Smarty_Internal_Block
{
public $subBlocks = array (
  'scripts' => 
  array (
    0 => 'Block_33054314669750075567ef3_56708289',
  ),
);
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 name = this.dataset.name;
        
        Swal.fire({
            title: 'Potwierdź usunięcie',
            html: 'Czy na pewno chcesz usunąć preset <strong>"' + name + '"</strong>?',
            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"} */
}
