| Server IP : 193.86.120.172 / Your IP : 216.73.216.215 Web Server : Apache/2.4.63 (Unix) System : Linux JServices 3.10.108 #86003 SMP Wed Oct 22 13:20:46 CST 2025 x86_64 User : kubec ( 1026) PHP Version : 8.2.28 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /volume1/web/hotellesnizatisi_cz/new/ |
Upload File : |
<?php
require_once __DIR__ . '/includes/auth.php';
$user = require_section('cenik');
require_once __DIR__ . '/includes/layout.php';
$id = isset($_GET['id']) ? (int)$_GET['id'] : null;
$c = [
'nazev_cs' => '', 'nazev_en' => '', 'nazev_de' => '',
'castka' => 0, 'poradi' => 0, 'aktivni' => 1,
];
if ($id) {
$stmt = db()->prepare('SELECT * FROM web_cenik_polozky WHERE id = ?');
$stmt->execute([$id]);
$row = $stmt->fetch();
if (!$row) {
set_flash('error', 'Položka nebyla nalezena.');
header('Location: cenik.php');
exit;
}
$c = $row;
}
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$values = [
trim($_POST['nazev_cs'] ?? ''),
trim($_POST['nazev_en'] ?? ''),
trim($_POST['nazev_de'] ?? ''),
(float)str_replace(',', '.', $_POST['castka'] ?? '0'),
(int)($_POST['poradi'] ?? 0),
isset($_POST['aktivni']) ? 1 : 0,
];
if ($id) {
db()->prepare('
UPDATE web_cenik_polozky SET nazev_cs=?, nazev_en=?, nazev_de=?, castka=?, poradi=?, aktivni=?
WHERE id=?
')->execute([...$values, $id]);
set_flash('success', 'Položka ceníku byla uložena.');
} else {
db()->prepare('
INSERT INTO web_cenik_polozky (nazev_cs, nazev_en, nazev_de, castka, mena, poradi, aktivni)
VALUES (?,?,?,?,\'CZK\',?,?)
')->execute($values);
set_flash('success', 'Nová položka ceníku byla přidána.');
}
header('Location: cenik.php');
exit;
}
admin_layout_start('cenik', $id ? 'Upravit položku ceníku' : 'Přidat položku ceníku', '', $user);
?>
<form method="post" class="card" style="padding:26px 28px;max-width:600px;">
<h3 style="font-size:.9rem;margin-bottom:14px;">Čeština</h3>
<div class="field"><label for="nazev_cs">Název</label><input type="text" id="nazev_cs" name="nazev_cs" value="<?= htmlspecialchars($c['nazev_cs']) ?>"></div>
<h3 style="font-size:.9rem;margin:22px 0 14px;border-top:1px solid var(--border);padding-top:18px;">English</h3>
<div class="field"><label for="nazev_en">Název</label><input type="text" id="nazev_en" name="nazev_en" value="<?= htmlspecialchars($c['nazev_en']) ?>"></div>
<h3 style="font-size:.9rem;margin:22px 0 14px;border-top:1px solid var(--border);padding-top:18px;">Deutsch</h3>
<div class="field"><label for="nazev_de">Název</label><input type="text" id="nazev_de" name="nazev_de" value="<?= htmlspecialchars($c['nazev_de']) ?>"></div>
<div class="field-row" style="margin-top:22px;border-top:1px solid var(--border);padding-top:18px;">
<div class="field"><label for="castka">Částka (Kč)</label><input type="number" id="castka" name="castka" step="0.01" value="<?= htmlspecialchars((string)$c['castka']) ?>"></div>
<div class="field"><label for="poradi">Pořadí</label><input type="number" id="poradi" name="poradi" value="<?= (int)$c['poradi'] ?>"></div>
</div>
<div class="toggle-row">
<label for="aktivni">Zobrazit na webu</label>
<input type="checkbox" id="aktivni" name="aktivni" <?= $c['aktivni'] ? 'checked' : '' ?>>
<label class="switch" for="aktivni"></label>
</div>
<div style="display:flex;gap:10px;margin-top:24px;">
<button type="submit" class="btn btn-primary">Uložit</button>
<a href="cenik.php" class="btn btn-secondary">Zrušit</a>
</div>
</form>
<?php admin_layout_end(); ?>