home
/
u529748449
/
domains
/
borabilhete.com
/
public_html
/
admin
➕ New
📤 Upload
✎ Editing:
editar_evento.php
← Back
<?php // admin/editar_evento.php require_once __DIR__ . '/conexao.php'; require_once __DIR__ . '/auth.php'; error_reporting(E_ALL); ini_set('display_errors', 1); date_default_timezone_set('America/Sao_Paulo'); // Somente admin e produtor require_login(['admin','produtor']); if (($_SESSION['role'] ?? '') === 'agente') { header('Location: validar_ingresso.php'); exit; } $isAdmin = (($_SESSION['role'] ?? '') === 'admin'); $produtorId = (int)($_SESSION['produtor_id'] ?? 0); // Sanitiza ID $id_evento = (isset($_GET['id']) && ctype_digit($_GET['id'])) ? (int)$_GET['id'] : 0; if ($id_evento <= 0) { http_response_code(400); exit("ID do evento não informado."); } // ---- Busca evento com ESCOPO de permissão ---- if ($isAdmin) { $sql = "SELECT * FROM eventos WHERE id = ? LIMIT 1"; $st = $conn->prepare($sql); $st->bind_param('i', $id_evento); } else { $sql = "SELECT * FROM eventos WHERE id = ? AND produtor_id = ? LIMIT 1"; $st = $conn->prepare($sql); $st->bind_param('ii', $id_evento, $produtorId); } $st->execute(); $evento = $st->get_result()->fetch_assoc(); $st->close(); if (!$evento) { http_response_code(403); exit("Você não tem permissão para editar este evento ou ele não existe."); } // ---- Busca setores do evento (já que o evento é autorizado) ---- $stmt_setores = $conn->prepare("SELECT * FROM setores WHERE id_evento = ? ORDER BY id ASC"); $stmt_setores->bind_param("i", $id_evento); $stmt_setores->execute(); $result_setores = $stmt_setores->get_result(); $setores = $result_setores->fetch_all(MYSQLI_ASSOC); $stmt_setores->close(); function h($s){ return htmlspecialchars((string)$s, ENT_QUOTES, 'UTF-8'); } function dtLocal(?string $ts): string { return $ts ? date('Y-m-d\TH:i', strtotime($ts)) : ''; } ?> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Editar Evento</title> <link rel="stylesheet" href="css/editar_evento.css"> </head> <body> <h2>Editar Evento</h2> <form method="POST" action="salvar_edicao_evento.php" enctype="multipart/form-data"> <input type="hidden" name="id_evento" value="<?= (int)$evento['id'] ?>"> <label>Nome:</label> <input type="text" name="nome" value="<?= h($evento['nome']) ?>" required> <label>Data e Hora:</label> <input type="datetime-local" name="data" value="<?= h(dtLocal($evento['data'])) ?>" required> <label>Local:</label> <input type="text" name="local" value="<?= h($evento['local']) ?>" required> <label>Descrição:</label> <textarea name="descricao"><?= h($evento['descricao'] ?? '') ?></textarea> <label>Imagem de Topo (4:5):</label> <input type="file" name="imagem_topo"> <label>Imagem do Mapa:</label> <input type="file" name="imagem_mapa"> <h3>Setores</h3> <?php foreach ($setores as $index => $setor): ?> <div class="setor-block"> <input type="hidden" name="setores[<?= $index ?>][id]" value="<?= (int)$setor['id'] ?>"> Nome: <input type="text" name="setores[<?= $index ?>][nome]" value="<?= h($setor['nome_setor']) ?>" required> Preço: <input type="number" step="0.01" name="setores[<?= $index ?>][preco]" value="<?= h($setor['preco']) ?>" required> Quantidade Total: <input type="number" name="setores[<?= $index ?>][quantidade]" value="<?= h($setor['quantidade_total']) ?>" required> Descrição: <textarea name="setores[<?= $index ?>][descricao]"><?= h($setor['descricao'] ?? '') ?></textarea> <label>Início das Vendas:</label> <input type="datetime-local" name="setores[<?= $index ?>][inicio_vendas]" value="<?= h(dtLocal($setor['inicio_vendas'])) ?>"> <label>Fim das Vendas:</label> <input type="datetime-local" name="setores[<?= $index ?>][fim_vendas]" value="<?= h(dtLocal($setor['fim_vendas'])) ?>"> <label><input type="checkbox" name="setores[<?= $index ?>][excluir]"> Excluir setor</label> </div> <?php endforeach; ?> <h4>Adicionar Novo Setor:</h4> <div class="setor-block"> Nome: <input type="text" name="novo_setor[nome]"> Preço: <input type="number" step="0.01" name="novo_setor[preco]"> Quantidade Total: <input type="number" name="novo_setor[quantidade]"> Descrição: <textarea name="novo_setor[descricao]"></textarea> <label>Início das Vendas:</label> <input type="datetime-local" name="novo_setor[inicio_vendas]"> <label>Fim das Vendas:</label> <input type="datetime-local" name="novo_setor[fim_vendas]"> </div> <br><button type="submit">Salvar Alterações</button> </form> <p><a href="listar_eventos.php">← Voltar para lista de eventos</a></p> </body> </html>
💾 Save Changes
Cancel
📤 Upload File
×
Select File
Upload
Cancel
➕ Create New
×
Type
📄 File
📁 Folder
Name
Create
Cancel
✎ Rename Item
×
Current Name
New Name
Rename
Cancel
🔐 Change Permissions
×
Target File
Permission (e.g., 0755, 0644)
0755
0644
0777
Apply
Cancel