<?php
/* Smarty version 4.5.6, created on 2026-01-25 12:22:41
  from '/var/www/html/tivi/panel/templates/settings/preset_form.tpl' */

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


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


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

<?php $_smarty_tpl->inheritance->endChild($_smarty_tpl, "layout.tpl");
}
/* {block "content"} */
class Block_5570412476975fd0189ac79_12608873 extends Smarty_Internal_Block
{
public $subBlocks = array (
  'content' => 
  array (
    0 => 'Block_5570412476975fd0189ac79_12608873',
  ),
);
public function callBlock(Smarty_Internal_Template $_smarty_tpl) {
?>

<div class="container-fluid">
    <!-- Header -->
    <div class="d-flex align-items-center mb-4">
        <a href="<?php echo $_smarty_tpl->tpl_vars['baseUrl']->value;?>
/settings/presets" class="btn btn-outline-secondary me-3">
            <i class="bi bi-arrow-left"></i>
        </a>
        <div>
            <h4 class="mb-1"><?php echo $_smarty_tpl->tpl_vars['pageTitle']->value;?>
</h4>
            <p class="text-muted mb-0">
                <?php if ($_smarty_tpl->tpl_vars['preset']->value) {?>Edytuj zestaw ustawień<?php } else { ?>Utwórz nowy zestaw ustawień<?php }?>
            </p>
        </div>
    </div>

    <form method="post">
        <input type="hidden" name="csrf_token" value="<?php echo $_smarty_tpl->tpl_vars['csrfToken']->value;?>
">

        <div class="row">
            <!-- Podstawowe info -->
            <div class="col-lg-4">
                <div class="card mb-4">
                    <div class="card-header">
                        <h5 class="mb-0">Informacje o presecie</h5>
                    </div>
                    <div class="card-body">
                        <div class="mb-3">
                            <label class="form-label">Nazwa <span class="text-danger">*</span></label>
                            <input type="text" name="name" class="form-control" 
                                   value="<?php echo (($tmp = $_smarty_tpl->tpl_vars['preset']->value['name'] ?? null)===null||$tmp==='' ? '' ?? null : $tmp);?>
" required
                                   placeholder="np. Włącz zegar">
                        </div>

                        <div class="mb-3">
                            <label class="form-label">Opis</label>
                            <textarea name="description" class="form-control" rows="3"
                                      placeholder="Opcjonalny opis..."><?php echo (($tmp = $_smarty_tpl->tpl_vars['preset']->value['description'] ?? null)===null||$tmp==='' ? '' ?? null : $tmp);?>
</textarea>
                        </div>

                        <div class="form-check form-switch">
                            <input type="checkbox" name="is_active" class="form-check-input" id="isActive" value="1"
                                   <?php if ((($tmp = $_smarty_tpl->tpl_vars['preset']->value['is_active'] ?? null)===null||$tmp==='' ? 1 ?? null : $tmp)) {?>checked<?php }?>>
                            <label class="form-check-label" for="isActive">Aktywny</label>
                        </div>
                    </div>
                </div>

                <div class="d-grid gap-2">
                    <button type="submit" class="btn btn-primary btn-lg">
                        <i class="bi bi-check-lg me-1"></i>
                        <?php if ($_smarty_tpl->tpl_vars['preset']->value) {?>Zapisz zmiany<?php } else { ?>Utwórz preset<?php }?>
                    </button>
                    <a href="<?php echo $_smarty_tpl->tpl_vars['baseUrl']->value;?>
/settings/presets" class="btn btn-outline-secondary">Anuluj</a>
                </div>
            </div>

            <!-- Ustawienia do presetu -->
            <div class="col-lg-8">
                <div class="card">
                    <div class="card-header">
                        <h5 class="mb-0">Wybierz ustawienia dla presetu</h5>
                    </div>
                    <div class="card-body">
                        <?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="mb-4">
                            <h6 class="text-muted border-bottom pb-2 mb-3">
                                <i class="bi bi-folder me-1"></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);?>

                            </h6>
                            
                            <?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;
?>
                            <div class="row mb-3 align-items-center">
                                <div class="col-md-5">
                                    <div class="form-check">
                                        <input type="checkbox" class="form-check-input preset-toggle" 
                                               id="toggle_<?php echo $_smarty_tpl->tpl_vars['def']->value['id'];?>
" data-def-id="<?php echo $_smarty_tpl->tpl_vars['def']->value['id'];?>
"
                                               <?php if ((isset($_smarty_tpl->tpl_vars['presetValues']->value[$_smarty_tpl->tpl_vars['def']->value['id']]))) {?>checked<?php }?>>
                                        <label class="form-check-label" for="toggle_<?php echo $_smarty_tpl->tpl_vars['def']->value['id'];?>
">
                                            <?php echo $_smarty_tpl->tpl_vars['def']->value['label'];?>

                                        </label>
                                    </div>
                                    <small class="text-muted ms-4"><code><?php echo $_smarty_tpl->tpl_vars['def']->value['key'];?>
</code></small>
                                </div>
                                <div class="col-md-7">
                                    <div class="preset-value-container" id="container_<?php echo $_smarty_tpl->tpl_vars['def']->value['id'];?>
" 
                                         style="<?php if (!(isset($_smarty_tpl->tpl_vars['presetValues']->value[$_smarty_tpl->tpl_vars['def']->value['id']]))) {?>display:none<?php }?>">
                                        <?php if ($_smarty_tpl->tpl_vars['def']->value['type'] == 'boolean') {?>
                                        <select name="items[<?php echo $_smarty_tpl->tpl_vars['def']->value['id'];?>
]" class="form-select form-select-sm">
                                            <option value="true" <?php if (((($tmp = $_smarty_tpl->tpl_vars['presetValues']->value[$_smarty_tpl->tpl_vars['def']->value['id']] ?? null)===null||$tmp==='' ? $_smarty_tpl->tpl_vars['def']->value['default_value'] ?? null : $tmp)) == 'true') {?>selected<?php }?>>true</option>
                                            <option value="false" <?php if (((($tmp = $_smarty_tpl->tpl_vars['presetValues']->value[$_smarty_tpl->tpl_vars['def']->value['id']] ?? null)===null||$tmp==='' ? $_smarty_tpl->tpl_vars['def']->value['default_value'] ?? null : $tmp)) == 'false') {?>selected<?php }?>>false</option>
                                        </select>
                                        <?php } elseif ($_smarty_tpl->tpl_vars['def']->value['options']) {?>
                                        <select name="items[<?php echo $_smarty_tpl->tpl_vars['def']->value['id'];?>
]" class="form-select form-select-sm">
                                            <?php
$_from = $_smarty_tpl->smarty->ext->_foreach->init($_smarty_tpl, $_smarty_tpl->tpl_vars['def']->value['options'], 'opt');
$_smarty_tpl->tpl_vars['opt']->do_else = true;
if ($_from !== null) foreach ($_from as $_smarty_tpl->tpl_vars['opt']->value) {
$_smarty_tpl->tpl_vars['opt']->do_else = false;
?>
                                            <option value="<?php echo $_smarty_tpl->tpl_vars['opt']->value['value'];?>
" <?php if (((($tmp = $_smarty_tpl->tpl_vars['presetValues']->value[$_smarty_tpl->tpl_vars['def']->value['id']] ?? null)===null||$tmp==='' ? $_smarty_tpl->tpl_vars['def']->value['default_value'] ?? null : $tmp)) == $_smarty_tpl->tpl_vars['opt']->value['value']) {?>selected<?php }?>>
                                                <?php echo $_smarty_tpl->tpl_vars['opt']->value['label'];?>

                                            </option>
                                            <?php
}
$_smarty_tpl->smarty->ext->_foreach->restore($_smarty_tpl, 1);?>
                                        </select>
                                        <?php } elseif ($_smarty_tpl->tpl_vars['def']->value['type'] == 'string') {?>
                                        <input type="text" name="items[<?php echo $_smarty_tpl->tpl_vars['def']->value['id'];?>
]" class="form-control form-control-sm"
                                               value="<?php echo (($tmp = $_smarty_tpl->tpl_vars['presetValues']->value[$_smarty_tpl->tpl_vars['def']->value['id']] ?? null)===null||$tmp==='' ? $_smarty_tpl->tpl_vars['def']->value['default_value'] ?? null : $tmp);?>
">
                                        <?php } else { ?>
                                        <input type="number" name="items[<?php echo $_smarty_tpl->tpl_vars['def']->value['id'];?>
]" class="form-control form-control-sm"
                                               value="<?php echo (($tmp = $_smarty_tpl->tpl_vars['presetValues']->value[$_smarty_tpl->tpl_vars['def']->value['id']] ?? null)===null||$tmp==='' ? $_smarty_tpl->tpl_vars['def']->value['default_value'] ?? null : $tmp);?>
">
                                        <?php }?>
                                    </div>
                                </div>
                            </div>
                            <?php
}
$_smarty_tpl->smarty->ext->_foreach->restore($_smarty_tpl, 1);?>
                        </div>
                        <?php
}
$_smarty_tpl->smarty->ext->_foreach->restore($_smarty_tpl, 1);?>
                    </div>
                </div>
            </div>
        </div>
    </form>
</div>
<?php
}
}
/* {/block "content"} */
/* {block "scripts"} */
class Block_17315686946975fd018b8136_16642983 extends Smarty_Internal_Block
{
public $subBlocks = array (
  'scripts' => 
  array (
    0 => 'Block_17315686946975fd018b8136_16642983',
  ),
);
public function callBlock(Smarty_Internal_Template $_smarty_tpl) {
?>


<?php echo '<script'; ?>
>
document.querySelectorAll('.preset-toggle').forEach(function(checkbox) {
    checkbox.addEventListener('change', function() {
        var defId = this.dataset.defId;
        var container = document.getElementById('container_' + defId);
        var input = container.querySelector('input, select');
        
        if (this.checked) {
            container.style.display = 'block';
            if (input) input.disabled = false;
        } else {
            container.style.display = 'none';
            if (input) {
                input.disabled = true;
                // Wyczyść wartość żeby nie była wysyłana
                if (input.tagName === 'INPUT') {
                    input.value = '';
                }
            }
        }
    });
    
    // Inicjalizacja - ustaw disabled dla ukrytych
    var defId = checkbox.dataset.defId;
    var container = document.getElementById('container_' + defId);
    var input = container.querySelector('input, select');
    if (!checkbox.checked && input) {
        input.disabled = true;
    }
});
<?php echo '</script'; ?>
>

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