-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0e4a847
commit 2e69ec5
Showing
5 changed files
with
196 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// editar_tema.php | ||
<?php | ||
require_once '../conexao.php'; | ||
require_once '../Class/Temas.php'; | ||
|
||
session_start(); | ||
|
||
// Verifique se o usuário está autenticado | ||
if(!isset($_SESSION['idUsuario'])) { | ||
header("Location: ../login/login.html"); | ||
exit(); | ||
} | ||
|
||
if ($_SERVER["REQUEST_METHOD"] == "POST") { | ||
$tema = new Temas($conn); | ||
|
||
$idTema = $_POST['idTema']; | ||
$nomeTema = $_POST['nomeTema']; | ||
$descricaoTema = $_POST['descricaoTema']; | ||
|
||
$tema->setNomeTema($nomeTema); | ||
$tema->setDescricaoTema($descricaoTema); | ||
|
||
if ($tema->editarTema($idTema)) { | ||
// Redirecione para a página de gerenciamento de temas após a edição | ||
header("Location: ../gerenciarTema.php"); | ||
exit(); | ||
} else { | ||
// Trate o erro, se necessário | ||
echo "Erro ao editar o tema."; | ||
} | ||
} | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
/* Adicione isso ao seu CSS existente */ | ||
|
||
/* Estilos comuns para modais de inserção e edição */ | ||
.modal-common { | ||
display: none; | ||
position: fixed; | ||
top: 0; | ||
left: 0; | ||
width: 100%; | ||
height: 100%; | ||
background-color: rgba(0, 0, 0, 0.5); | ||
} | ||
|
||
.modal-common-content { | ||
background-color: #fefefe; | ||
padding: 20px; | ||
border: 1px solid #888; | ||
width: 80%; | ||
max-width: 430px; | ||
} | ||
|
||
.fechar { | ||
position: absolute; | ||
top: 10px; | ||
right: 10px; | ||
font-size: 28px; | ||
font-weight: bold; | ||
cursor: pointer; | ||
} | ||
|
||
/* Estilos específicos para modal de inserção */ | ||
#formularioCadastro { | ||
display: grid; | ||
gap: 10px; | ||
} | ||
|
||
#formularioCadastro label { | ||
display: block; | ||
font-weight: bold; | ||
margin-bottom: 5px; | ||
} | ||
|
||
#formularioCadastro input, | ||
#formularioCadastro textarea, | ||
#formularioCadastro select { | ||
width: 100%; | ||
padding: 8px; | ||
box-sizing: border-box; | ||
border: 1px solid #ccc; | ||
border-radius: 4px; | ||
} | ||
|
||
#formularioCadastro button { | ||
background-color: #4caf50; | ||
color: white; | ||
padding: 10px; | ||
border: none; | ||
border-radius: 4px; | ||
cursor: pointer; | ||
} | ||
|
||
#formularioCadastro button:hover { | ||
background-color: #45a049; | ||
} | ||
|
||
/* Estilos específicos para modal de edição */ | ||
#formularioEdicao { | ||
display: grid; | ||
gap: 10px; | ||
} | ||
|
||
#formularioEdicao label { | ||
display: block; | ||
font-weight: bold; | ||
margin-bottom: 5px; | ||
} | ||
|
||
#formularioEdicao input, | ||
#formularioEdicao textarea, | ||
#formularioEdicao select { | ||
width: 100%; | ||
padding: 8px; | ||
box-sizing: border-box; | ||
border: 1px solid #ccc; | ||
border-radius: 4px; | ||
} | ||
|
||
#formularioEdicao button { | ||
background-color: #4caf50; | ||
color: white; | ||
padding: 10px; | ||
border: none; | ||
border-radius: 4px; | ||
cursor: pointer; | ||
} | ||
|
||
#formularioEdicao button:hover { | ||
background-color: #45a049; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,69 +27,9 @@ | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Cadastro de Usuários</title> | ||
<link rel="stylesheet" href="css/format.css"> | ||
<link rel="stylesheet" href="css/modal.css"> | ||
<style> | ||
/* Adicione ao seu CSS existente */ | ||
|
||
.modal { | ||
display: none; | ||
position: fixed; | ||
top: 0; | ||
left: 0; | ||
width: 100%; | ||
height: 100%; | ||
background-color: rgba(0, 0, 0, 0.5); | ||
} | ||
|
||
.modal-content { | ||
background-color: #fefefe; | ||
padding: 20px; | ||
border: 1px solid #888; | ||
width: 80%; | ||
max-width: 430px; /* Ajuste a largura máxima conforme necessário */ | ||
} | ||
|
||
.fechar { | ||
position: absolute; | ||
top: 10px; | ||
right: 10px; | ||
font-size: 28px; | ||
font-weight: bold; | ||
cursor: pointer; | ||
} | ||
|
||
#formularioCadastro { | ||
display: grid; | ||
gap: 10px; | ||
} | ||
|
||
#formularioCadastro label { | ||
display: block; | ||
font-weight: bold; | ||
margin-bottom: 5px; | ||
} | ||
|
||
#formularioCadastro input, | ||
#formularioCadastro textarea, | ||
#formularioCadastro select { | ||
width: 100%; | ||
padding: 8px; | ||
box-sizing: border-box; | ||
border: 1px solid #ccc; | ||
border-radius: 4px; | ||
} | ||
|
||
#formularioCadastro button { | ||
background-color: #4caf50; | ||
color: white; | ||
padding: 10px; | ||
border: none; | ||
border-radius: 4px; | ||
cursor: pointer; | ||
} | ||
|
||
#formularioCadastro button:hover { | ||
background-color: #45a049; | ||
} | ||
|
||
</style> | ||
<script src="https://code.jquery.com/jquery-3.6.4.min.js"></script> | ||
<script> | ||
|
@@ -110,6 +50,20 @@ | |
}); | ||
</script> | ||
|
||
<script> | ||
function abrirEditarModal(id, nome, descricao) { | ||
$("#editIdTema").val(id); | ||
$("#editNomeTema").val(nome); | ||
$("#editDescricaoTema").val(descricao); | ||
$("#editarModal").css("display", "block"); | ||
} | ||
|
||
function fecharEditarModal() { | ||
$("#editarModal").css("display", "none"); | ||
} | ||
</script> | ||
|
||
|
||
</head> | ||
|
||
<body page='lista'> | ||
|
@@ -147,8 +101,8 @@ | |
<button id="abrirModal">Inserir</button> | ||
</div> | ||
|
||
<div id="myModal" class="modal"> | ||
<div class="modal-content"> | ||
<div id="myModal" class="modal modal-common"> | ||
<div class="modal-content modal-common-content"> | ||
<span class="fechar">×</span> | ||
<h2>Cadastrar Novo Tema</h2> | ||
<form id="formularioCadastro" action="Controllers/gravar_tema.php" method="post"> | ||
|
@@ -203,10 +157,8 @@ | |
</td> | ||
<td> | ||
<!-- Botão Editar --> | ||
<a href="Views/editarUsuario.php?id=<?php echo $user['idUsuarios']; ?>" | ||
style="display: inline-block;"> | ||
<button>Editar</button> | ||
</a> | ||
<button onclick="abrirEditarModal('<?php echo $lista['idTemas']; ?>', '<?php echo $lista['NomeTema']; ?>', | ||
'<?php echo $lista['descricaoTema']; ?>')">Editar</button> | ||
|
||
<form method="post" action="Controllers/excluir_tema.php" style="display: inline-block;"> | ||
<input type="hidden" name="id" value="<?= $lista['idTemas']; ?>"> | ||
|
@@ -224,6 +176,23 @@ | |
<p>Nenhum usuário cadastrado.</p> | ||
<?php endif; ?> | ||
|
||
<!-- Novo modal para edição --> | ||
<div id="editarModal" class="modal modal-common"> | ||
<div class="modal-content modal-common-content"> | ||
<span class="fechar" onclick="fecharEditarModal()">×</span> | ||
<h2>Editar Tema</h2> | ||
<form id="formularioEdicao" action="Views/editarTema.php" method="post"> | ||
<input type="hidden" id="editIdTema" name="idTema"> | ||
<label for="editNomeTema">Nome do Tema:</label> | ||
<input type="text" id="editNomeTema" name="nomeTema" placeholder="Nome do Tema" required> | ||
<label for="editDescricaoTema">Descrição do Tema:</label> | ||
<textarea id="editDescricaoTema" name="descricaoTema" rows="4" cols="50" | ||
placeholder="Descrição do Tema"></textarea> | ||
<button type="submit">Salvar Alterações</button> | ||
</form> | ||
</div> | ||
</div> | ||
|
||
</div> | ||
</div> | ||
<script type="module" src="https://unpkg.com/[email protected]/dist/ionicons/ionicons.esm.js"></script> | ||
|