<?php
/* Smarty version 4.5.6, created on 2025-12-23 13:15:30
  from '/var/www/html/tivi/panel/templates/playlists/form.tpl' */

/* @var Smarty_Internal_Template $_smarty_tpl */
if ($_smarty_tpl->_decodeProperties($_smarty_tpl, array (
  'version' => '4.5.6',
  'unifunc' => 'content_694a87e2f412f0_09843314',
  'has_nocache_code' => false,
  'file_dependency' => 
  array (
    '0d8d3808db5e814d4b712c65815b73e727764eb1' => 
    array (
      0 => '/var/www/html/tivi/panel/templates/playlists/form.tpl',
      1 => 1766432924,
      2 => 'file',
    ),
  ),
  'includes' => 
  array (
    'file:partials/entity_notes.tpl' => 1,
  ),
),false)) {
function content_694a87e2f412f0_09843314 (Smarty_Internal_Template $_smarty_tpl) {
$_smarty_tpl->_loadInheritance();
$_smarty_tpl->inheritance->init($_smarty_tpl, true);
?>


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


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

<?php $_smarty_tpl->inheritance->endChild($_smarty_tpl, "layout.tpl");
}
/* {block "content"} */
class Block_345320975694a87e2f1e274_90452591 extends Smarty_Internal_Block
{
public $subBlocks = array (
  'content' => 
  array (
    0 => 'Block_345320975694a87e2f1e274_90452591',
  ),
);
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="row justify-content-center">
        <div class="col-lg-8">
            <!-- Header -->
            <div class="d-flex align-items-center mb-4">
                <a href="<?php echo $_smarty_tpl->tpl_vars['baseUrl']->value;?>
/playlists<?php if ((($tmp = $_smarty_tpl->tpl_vars['data']->value['device_id'] ?? null)===null||$tmp==='' ? 0 ?? null : $tmp)) {?>?device_id=<?php echo $_smarty_tpl->tpl_vars['data']->value['device_id'];
}?>" 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['isEdit']->value) {?>Edytuj konfigurację playlisty<?php } else { ?>Dodaj nową playlistę do urządzenia<?php }?>
                    </p>
                </div>
            </div>

            <!-- Form Card -->
            <div class="card">
                <div class="card-body">
                    <?php if ((($tmp = $_smarty_tpl->tpl_vars['error']->value ?? null)===null||$tmp==='' ? false ?? null : $tmp)) {?>
                    <div class="alert alert-danger">
                        <i class="bi bi-exclamation-circle me-2"></i><?php echo $_smarty_tpl->tpl_vars['error']->value;?>

                    </div>
                    <?php }?>

                    <form method="post" id="playlistForm">
                        <input type="hidden" name="csrf_token" value="<?php echo $_smarty_tpl->tpl_vars['csrfToken']->value;?>
">
                        
                        <!-- Basic Info -->
                        <div class="row mb-4">
                            <div class="col-md-6">
                                <label class="form-label">Urządzenie <span class="text-danger">*</span></label>
                                <select name="device_id" class="form-select" required <?php if ($_smarty_tpl->tpl_vars['isEdit']->value) {?>disabled<?php }?>>
                                    <option value="">Wybierz urządzenie...</option>
                                    <?php
$_from = $_smarty_tpl->smarty->ext->_foreach->init($_smarty_tpl, $_smarty_tpl->tpl_vars['devices']->value, 'device');
$_smarty_tpl->tpl_vars['device']->do_else = true;
if ($_from !== null) foreach ($_from as $_smarty_tpl->tpl_vars['device']->value) {
$_smarty_tpl->tpl_vars['device']->do_else = false;
?>
                                    <option value="<?php echo $_smarty_tpl->tpl_vars['device']->value['id'];?>
" <?php if (((($tmp = $_smarty_tpl->tpl_vars['data']->value['device_id'] ?? null)===null||$tmp==='' ? 0 ?? null : $tmp)) == $_smarty_tpl->tpl_vars['device']->value['id']) {?>selected<?php }?>>
                                        <?php echo (($tmp = $_smarty_tpl->tpl_vars['device']->value['name'] ?? null)===null||$tmp==='' ? $_smarty_tpl->tpl_vars['device']->value['mac'] ?? null : $tmp);?>
 (<?php echo $_smarty_tpl->tpl_vars['device']->value['mac'];?>
)
                                        <?php if ($_smarty_tpl->tpl_vars['isAdmin']->value) {?> - <?php echo $_smarty_tpl->tpl_vars['device']->value['username'];
}?>
                                    </option>
                                    <?php
}
$_smarty_tpl->smarty->ext->_foreach->restore($_smarty_tpl, 1);?>
                                </select>
                            </div>
                            <div class="col-md-6">
                                <label class="form-label">Nazwa playlisty <span class="text-danger">*</span></label>
                                <input type="text" name="name" class="form-control" value="<?php echo (($tmp = $_smarty_tpl->tpl_vars['data']->value['name'] ?? null)===null||$tmp==='' ? '' ?? null : $tmp);?>
" required>
                            </div>
                        </div>

                        <div class="row mb-4">
                            <div class="col-md-6">
                                <label class="form-label">Typ playlisty <span class="text-danger">*</span></label>
                                <select name="type" id="playlistType" class="form-select" required>
                                    <option value="xtream" <?php if (((($tmp = $_smarty_tpl->tpl_vars['data']->value['type'] ?? null)===null||$tmp==='' ? 'xtream' ?? null : $tmp)) == 'xtream') {?>selected<?php }?>>Xtream Codes</option>
                                    <option value="m3u" <?php if (((($tmp = $_smarty_tpl->tpl_vars['data']->value['type'] ?? null)===null||$tmp==='' ? '' ?? null : $tmp)) == 'm3u') {?>selected<?php }?>>M3U Link</option>
                                    <option value="stalker" <?php if (((($tmp = $_smarty_tpl->tpl_vars['data']->value['type'] ?? null)===null||$tmp==='' ? '' ?? null : $tmp)) == 'stalker') {?>selected<?php }?>>Stalker Portal</option>
                                </select>
                            </div>
                            <div class="col-md-3">
                                <label class="form-label">Kolejność</label>
                                <input type="number" name="sort_order" class="form-control" value="<?php echo (($tmp = $_smarty_tpl->tpl_vars['data']->value['sort_order'] ?? null)===null||$tmp==='' ? 0 ?? null : $tmp);?>
" min="0">
                            </div>
                            <div class="col-md-3">
                                <label class="form-label">Status</label>
                                <div class="form-check form-switch mt-2">
                                    <input type="checkbox" name="is_active" id="is_active" class="form-check-input" value="1" <?php if ((($tmp = $_smarty_tpl->tpl_vars['data']->value['is_active'] ?? null)===null||$tmp==='' ? 1 ?? null : $tmp)) {?>checked<?php }?>>
                                    <label class="form-check-label" for="is_active">Aktywna</label>
                                </div>
                            </div>
                        </div>

                        <!-- Xtream Fields -->
                        <div id="xtreamFields" class="type-fields">
                            <h6 class="border-bottom pb-2 mb-3"><i class="bi bi-broadcast me-2"></i>Konfiguracja Xtream</h6>
                            <div class="row mb-3">
                                <div class="col-md-12">
                                    <label class="form-label">Host <span class="text-danger">*</span></label>
                                    <input type="url" name="host" class="form-control" value="<?php echo (($tmp = $_smarty_tpl->tpl_vars['data']->value['host'] ?? null)===null||$tmp==='' ? '' ?? null : $tmp);?>
" placeholder="http://example.com:8080">
                                    <small class="text-muted">Adres serwera Xtream (z portem)</small>
                                </div>
                            </div>
                            <div class="row mb-3">
                                <div class="col-md-6">
                                    <label class="form-label">Username <span class="text-danger">*</span></label>
                                    <input type="text" name="username" class="form-control" value="<?php echo (($tmp = $_smarty_tpl->tpl_vars['data']->value['username'] ?? null)===null||$tmp==='' ? '' ?? null : $tmp);?>
">
                                </div>
                                <div class="col-md-6">
                                    <label class="form-label">Password <span class="text-danger">*</span></label>
                                    <input type="text" name="password" class="form-control" value="<?php echo (($tmp = $_smarty_tpl->tpl_vars['data']->value['password'] ?? null)===null||$tmp==='' ? '' ?? null : $tmp);?>
">
                                </div>
                            </div>
                        </div>

                        <!-- M3U Fields -->
                        <div id="m3uFields" class="type-fields" style="display:none;">
                            <h6 class="border-bottom pb-2 mb-3"><i class="bi bi-link-45deg me-2"></i>Konfiguracja M3U</h6>
                            <div class="mb-3">
                                <label class="form-label">URL playlisty <span class="text-danger">*</span></label>
                                <input type="url" name="url" class="form-control" value="<?php echo (($tmp = $_smarty_tpl->tpl_vars['data']->value['url'] ?? null)===null||$tmp==='' ? '' ?? null : $tmp);?>
" placeholder="http://example.com/playlist.m3u">
                            </div>
                            <div class="mb-3">
                                <label class="form-label">EPG Link</label>
                                <input type="url" name="m3u_epg_link" class="form-control" value="<?php echo (($tmp = $_smarty_tpl->tpl_vars['data']->value['epg_link'] ?? null)===null||$tmp==='' ? '' ?? null : $tmp);?>
" placeholder="http://example.com/epg.xml">
                                <small class="text-muted">Opcjonalny link do programu TV</small>
                            </div>
                        </div>

                        <!-- Stalker Fields -->
                        <div id="stalkerFields" class="type-fields" style="display:none;">
                            <h6 class="border-bottom pb-2 mb-3"><i class="bi bi-hdd-network me-2"></i>Konfiguracja Stalker</h6>
                            <div class="row mb-3">
                                <div class="col-md-6">
                                    <label class="form-label">Server URL <span class="text-danger">*</span></label>
                                    <input type="url" name="server_url" class="form-control" value="<?php echo (($tmp = $_smarty_tpl->tpl_vars['data']->value['server_url'] ?? null)===null||$tmp==='' ? '' ?? null : $tmp);?>
" placeholder="http://example.com:80/c">
                                </div>
                                <div class="col-md-6">
                                    <label class="form-label">Referrer URL</label>
                                    <input type="url" name="referrer_url" class="form-control" value="<?php echo (($tmp = $_smarty_tpl->tpl_vars['data']->value['referrer_url'] ?? null)===null||$tmp==='' ? '' ?? null : $tmp);?>
" placeholder="http://example.com/c">
                                </div>
                            </div>
                            <div class="row mb-3">
                                <div class="col-md-6">
                                    <label class="form-label">MAC Address <span class="text-danger">*</span></label>
                                    <input type="text" name="mac_address" class="form-control" value="<?php echo (($tmp = $_smarty_tpl->tpl_vars['data']->value['mac_address'] ?? null)===null||$tmp==='' ? '' ?? null : $tmp);?>
" placeholder="00:1A:79:XX:XX:XX">
                                </div>
                                <div class="col-md-6">
                                    <label class="form-label">Serial Number</label>
                                    <input type="text" name="serial_number" class="form-control" value="<?php echo (($tmp = $_smarty_tpl->tpl_vars['data']->value['serial_number'] ?? null)===null||$tmp==='' ? '' ?? null : $tmp);?>
">
                                </div>
                            </div>
                            <div class="row mb-3">
                                <div class="col-md-4">
                                    <label class="form-label">Device ID</label>
                                    <input type="text" name="stalker_device_id" class="form-control" value="<?php echo (($tmp = $_smarty_tpl->tpl_vars['data']->value['device_id'] ?? null)===null||$tmp==='' ? '' ?? null : $tmp);?>
">
                                </div>
                                <div class="col-md-4">
                                    <label class="form-label">Device ID 2</label>
                                    <input type="text" name="device_id2" class="form-control" value="<?php echo (($tmp = $_smarty_tpl->tpl_vars['data']->value['device_id2'] ?? null)===null||$tmp==='' ? '' ?? null : $tmp);?>
">
                                </div>
                                <div class="col-md-4">
                                    <label class="form-label">Signature</label>
                                    <input type="text" name="signature" class="form-control" value="<?php echo (($tmp = $_smarty_tpl->tpl_vars['data']->value['signature'] ?? null)===null||$tmp==='' ? '' ?? null : $tmp);?>
">
                                </div>
                            </div>
                            <div class="mb-3">
                                <label class="form-label">EPG Link</label>
                                <input type="url" name="stalker_epg_link" class="form-control" value="<?php echo (($tmp = $_smarty_tpl->tpl_vars['data']->value['epg_link'] ?? null)===null||$tmp==='' ? '' ?? null : $tmp);?>
" placeholder="http://example.com/epg.xml">
                            </div>
                        </div>

                        <?php if ($_smarty_tpl->tpl_vars['isEdit']->value) {?>
                        <div class="mb-4">
                            <div class="form-check">
                                <input type="checkbox" name="update_timestamp" id="update_timestamp" class="form-check-input" value="1">
                                <label class="form-check-label" for="update_timestamp">
                                    Aktualizuj update_date na aktualny czas
                                </label>
                            </div>
                            <small class="text-muted">Obecna wartość: <?php echo smarty_modifier_date_format($_smarty_tpl->tpl_vars['data']->value['update_date'],"%d.%m.%Y %H:%M:%S");?>
</small>
                        </div>
                        <?php } else { ?>
                        <div class="mb-4">
                            <label class="form-label">Uwagi <span class="text-muted">(opcjonalne)</span></label>
                            <div class="input-group">
                                <span class="input-group-text"><i class="bi bi-sticky"></i></span>
                                <textarea name="initial_note" 
                                          class="form-control" 
                                          rows="2" 
                                          placeholder="Notatka dodana przy tworzeniu playlisty..."><?php echo (($tmp = $_smarty_tpl->tpl_vars['data']->value['initial_note'] ?? null)===null||$tmp==='' ? '' ?? null : $tmp);?>
</textarea>
                            </div>
                            <small class="text-muted">Zostanie zapisana jako notatka do tej playlisty</small>
                        </div>
                        <?php }?>

                        <div class="d-flex gap-2">
                            <button type="submit" class="btn btn-primary">
                                <i class="bi bi-check-lg me-1"></i>
                                <?php if ($_smarty_tpl->tpl_vars['isEdit']->value) {?>Zapisz zmiany<?php } else { ?>Dodaj playlistę<?php }?>
                            </button>
                            <a href="<?php echo $_smarty_tpl->tpl_vars['baseUrl']->value;?>
/playlists<?php if ((($tmp = $_smarty_tpl->tpl_vars['data']->value['device_id'] ?? null)===null||$tmp==='' ? 0 ?? null : $tmp)) {?>?device_id=<?php echo $_smarty_tpl->tpl_vars['data']->value['device_id'];
}?>" class="btn btn-secondary">Anuluj</a>
                        </div>
                    </form>
                </div>
            </div>

            <?php if ($_smarty_tpl->tpl_vars['isEdit']->value) {?>
            <!-- Info Card -->
            <div class="card mt-4">
                <div class="card-header">
                    <h6 class="mb-0"><i class="bi bi-info-circle me-2"></i>Informacje</h6>
                </div>
                <div class="card-body">
                    <div class="row">
                        <div class="col-6">
                            <small class="text-muted d-block">Utworzona</small>
                            <span><?php echo smarty_modifier_date_format($_smarty_tpl->tpl_vars['data']->value['created_at'],"%d.%m.%Y %H:%M");?>
</span>
                        </div>
                        <div class="col-6">
                            <small class="text-muted d-block">Ostatnia aktualizacja</small>
                            <span><?php echo smarty_modifier_date_format($_smarty_tpl->tpl_vars['data']->value['updated_at'],"%d.%m.%Y %H:%M");?>
</span>
                        </div>
                        <div class="col-6 mt-3">
                            <small class="text-muted d-block">Update Date (timestamp)</small>
                            <span><?php echo $_smarty_tpl->tpl_vars['data']->value['update_date'];?>
</span>
                        </div>
                        <div class="col-6 mt-3">
                            <small class="text-muted d-block">Urządzenie</small>
                            <span><?php echo (($tmp = $_smarty_tpl->tpl_vars['data']->value['device_name'] ?? null)===null||$tmp==='' ? $_smarty_tpl->tpl_vars['data']->value['mac'] ?? null : $tmp);?>
</span>
                        </div>
                    </div>
                </div>
            </div>
            
                        <div class="mt-4">
                <?php $_smarty_tpl->_subTemplateRender("file:partials/entity_notes.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, $_smarty_tpl->cache_lifetime, array('entityType'=>"playlist",'entityId'=>$_smarty_tpl->tpl_vars['data']->value['id']), 0, false);
?>
            </div>
            <?php }?>
        </div>
    </div>
</div>
<?php
}
}
/* {/block "content"} */
/* {block "scripts"} */
class Block_48512064694a87e2f408f9_02746681 extends Smarty_Internal_Block
{
public $subBlocks = array (
  'scripts' => 
  array (
    0 => 'Block_48512064694a87e2f408f9_02746681',
  ),
);
public function callBlock(Smarty_Internal_Template $_smarty_tpl) {
?>

<?php echo '<script'; ?>
>
const typeSelect = document.getElementById('playlistType');
const typeFields = document.querySelectorAll('.type-fields');

function showTypeFields(type) {
    typeFields.forEach(f => f.style.display = 'none');
    const target = document.getElementById(type + 'Fields');
    if (target) target.style.display = 'block';
    
    // Clear required from hidden fields, add to visible
    document.querySelectorAll('.type-fields input[data-required]').forEach(input => {
        input.required = false;
    });
    if (target) {
        target.querySelectorAll('input[data-required]').forEach(input => {
            input.required = true;
        });
    }
}

typeSelect.addEventListener('change', function() {
    showTypeFields(this.value);
});

// Mark required fields
document.querySelectorAll('#xtreamFields input').forEach(input => {
    if (input.name === 'host' || input.name === 'username' || input.name === 'password') {
        input.dataset.required = 'true';
    }
});
document.querySelectorAll('#m3uFields input').forEach(input => {
    if (input.name === 'url') {
        input.dataset.required = 'true';
    }
});
document.querySelectorAll('#stalkerFields input').forEach(input => {
    if (input.name === 'server_url' || input.name === 'mac_address') {
        input.dataset.required = 'true';
    }
});

// Init
showTypeFields(typeSelect.value);
<?php echo '</script'; ?>
>
<?php
}
}
/* {/block "scripts"} */
}
