569 lines
32 KiB
PHP
Raw Normal View History

2021-11-19 22:12:23 -03:00
<?php require_once('../Connections/conn_sustentabilidade.php'); ?>
<?php include("acesso.php"); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
mysql_select_db($database_conn_sustentabilidade, $conn_sustentabilidade);
$query_usuarios_lista = "SELECT * FROM tbusuarios";
$usuarios_lista = mysql_query($query_usuarios_lista, $conn_sustentabilidade) or die(mysql_error());
$row_usuarios_lista = mysql_fetch_assoc($usuarios_lista);
$totalRows_usuarios_lista = mysql_num_rows($usuarios_lista);
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form-usuarios-insere")) {
$insertSQL = sprintf("INSERT INTO tbusuarios (login_usuario, senha_usuario, nivel_usuario) VALUES (%s, %s, %s)",
GetSQLValueString($_POST['login_usuario'], "text"),
GetSQLValueString($_POST['senha_usuario'], "text"),
GetSQLValueString($_POST['nivel_usuario'], "text"));
mysql_select_db($database_conn_sustentabilidade, $conn_sustentabilidade);
$Result1 = mysql_query($insertSQL, $conn_sustentabilidade) or die(mysql_error());
$insertGoTo = "index.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
#TiposLista
mysql_select_db($database_conn_sustentabilidade, $conn_sustentabilidade);
$query_tipos_lista = "SELECT * FROM tbtipos";
$tipos_lista = mysql_query($query_tipos_lista, $conn_sustentabilidade) or die(mysql_error());
$row_tipos_lista = mysql_fetch_assoc($tipos_lista);
$totalRows_tipos_lista = mysql_num_rows($tipos_lista);
#fim
#InsereEventos
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form_tipo_insere")) {
$insertSQL = sprintf("INSERT INTO tbtipos (sigla_tipo, rotulo_tipo) VALUES (%s, %s)",
GetSQLValueString($_POST['sigla_tipo'], "text"),
GetSQLValueString($_POST['rotulo_tipo'], "text"));
mysql_select_db($database_conn_sustentabilidade, $conn_sustentabilidade);
$Result1 = mysql_query($insertSQL, $conn_sustentabilidade) or die(mysql_error());
$insertGoTo = "index.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
#Fim
#ListarEventos
mysql_select_db($database_conn_sustentabilidade, $conn_sustentabilidade);
$query_eventos_lista = "SELECT * FROM vw_tbeventos";
$eventos_lista = mysql_query($query_eventos_lista, $conn_sustentabilidade) or die(mysql_error());
$row_eventos_lista = mysql_fetch_assoc($eventos_lista);
$totalRows_eventos_lista = mysql_num_rows($eventos_lista);
#Fim
#InserirEventos
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form_evento_insere")) {
$insertSQL = sprintf("INSERT INTO tbeventos (id_evento, nome_evento, local_evento, publico_evento, imagem_evento, descr_evento, destaque_evento, tipo_evento) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['id_evento'], "int"),
GetSQLValueString($_POST['nome_evento'], "text"),
GetSQLValueString($_POST['local_evento'], "text"),
GetSQLValueString($_POST['publico_evento'], "text"),
GetSQLValueString($_FILES['imagem_evento']['name'], "text"),
GetSQLValueString($_POST['descr_evento'], "text"),
GetSQLValueString($_POST['destaque_evento'], "text"),
GetSQLValueString($_POST['tipo_evento'], "int"));
mysql_select_db($database_conn_sustentabilidade, $conn_sustentabilidade);
$Result1 = mysql_query($insertSQL, $conn_sustentabilidade) or die(mysql_error());
$insertGoTo = "index.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
mysql_select_db($database_conn_sustentabilidade, $conn_sustentabilidade);
$query_select_tipo = "SELECT * FROM tbtipos ORDER BY rotulo_tipo ASC";
$select_tipo = mysql_query($query_select_tipo, $conn_sustentabilidade) or die(mysql_error());
$row_select_tipo = mysql_fetch_assoc($select_tipo);
$totalRows_select_tipo = mysql_num_rows($select_tipo);
if(isset($_POST['enviar'])){
$nome_img=$_FILES['imagem_evento']['name'];
$tmp_img=$_FILES['imagem_evento']['tmp_name'];
$dir_img="../imagens/".$nome_img;
move_uploaded_file($tmp_img,$dir_img);
}
#Fim
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<link href="../bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="../css/estilo.css" rel="stylesheet">
<link rel="stylesheet" href="../css/font-face/stylesheet.css">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<nav>
<?php include_once("menu_adm.php"); ?>
</nav>
<?php if($_SESSION['MM_UserGroup'] == 'sup') : ?>
<!-- Modal Listar Usuarios -->
<div class="modal fade" id="modalusuarios" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="exampleModalLabel"><b>Listar Usuários</b></h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<div class="container-fluid">
<div class="table-responsive">
<table id="mytable" class="table table-bordered">
<thead>
<th>Id</th>
<th>Login Usuário</th>
<th class="esconde600">Senha Usuário</th>
<th class="esconde600">Nivel Usúario</th>
<th colspan="2">
<p data-placement="top" data-toggle="tooltip" title="Delete">
</p>
</th>
</thead>
<tbody>
<?php do { ?>
<tr>
<td><?php echo $row_usuarios_lista['id_usuario']; ?></td>
<td><?php echo $row_usuarios_lista['login_usuario']; ?></td>
<td class="esconde600"><?php echo $row_usuarios_lista['senha_usuario']; ?></td>
<td class="esconde600"><?php echo $row_usuarios_lista['nivel_usuario']; ?></td>
<td>
<p data-placement="top" data-toggle="tooltip" title="Edit">
<a href="usuarios_altera.php?id_usuario=<?php echo $row_usuarios_lista['id_usuario']; ?>">
<button class="btn btn-primary btn-xs btn-block"><span class="glyphicon glyphicon-pencil"></span></button></a>
</td>
<td>
<p data-placement="top" data-toggle="tooltip" title="Delete"><a href="usuarios_exclui.php?id_usuario=<?php echo $row_usuarios_lista['id_usuario']?>"><button class="btn btn-danger btn-xs" ><span class="glyphicon glyphicon-trash"></span></button></a>
</p>
</td>
</tr>
<?php } while ($row_usuarios_lista = mysql_fetch_assoc($usuarios_lista)); ?>
</tbody>
</table>
</div>
</div>
<div class="modal-footer">
<center><button type="button" class="btn btn-secondary" data-dismiss="modal" style="color:black;">Fechar</button></center>
</div>
</div>
</div>
</div>
</div>
<!-- Fim do Listar usuarios -->
<?php endif; ?>
<?php if($_SESSION['MM_UserGroup'] == 'sup') : ?>
<!-- Modal Inserir Usuarios -->
<div class="modal fade" id="modalinsereusuarios" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="exampleModalLabel"><b>Usuários Insere</b></h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<div class="container-fluid">
<div class="col-lg-12">
<form name="form-usuarios-insere" action="<?php echo $editFormAction; ?>" method="POST" id="form_usuarios_insere" enctype="multipart/form-data">
<label for="nome_usuario">Nome:</label>
<p class="input-group">
<span class="input-group-addon"><span class="glyphicon glyphicon-user"></span></span>
<input name="login_usuario" class="form-control input" type="text" id="login_usuario" maxlength="30" required placeholder="Digite o seu login">
</p>
<label for="senha_usuario">Senha:</label>
<p class="input-group">
<span class="input-group-addon">
<i class="fas fa-lock"></i></span>
<input name="senha_usuario" class="form-control input" type="password" id="senha_usuario" maxlength="16" required placeholder="Digite sua senha">
</p>
<br>
<h5>
Nivel de Usúario:
<h5>
<p class="hidden"><b>Nível de Permissão:</b><br>
<p>
<input name="nivel_usuario" type="radio" id="nivel_usuario" value="sup" required>
<label for="nivel_usuario_sup">Super Usuário</label>
<br>
<input name="nivel_usuario" type="radio" id="nivel_usuario" value="com" required >
<label for="nivel_usuario_com"> <b>Usuário Comum</b></label>
</p>
<p><input class="btn btn-success " type="submit" value="Registrar">
<input type="hidden" name="MM_insert" value="form-usuarios-insere">
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Final Inserir Usuarios -->
<?php endif;?>
<!-- Modal Alterar Usuarios -->
<!-- Final Alterar Usuarios -->
<!-- Modal Listar Categoria -->
<div class="modal fade" id="modalcategoria" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="exampleModalLabel"><b>Categoria de Eventos</b></h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<section class="container-fluid">
<section class="col-lg-12">
<div class="table-responsive">
<table class="table">
<thead>
<tr>
<th class="esconde-xs-xs">Rotulo</th>
<th>Sigla</th>
</tr>
</thead>
<tbody>
<?php do { ?>
<tr>
<td class="esconde-xs-xs"><?php echo $row_tipos_lista['rotulo_tipo']?></td>
<td><?php echo $row_tipos_lista['sigla_tipo']?></td>
<td>
<a href="tipo_altera.php?id_tipo=<?php echo $row_tipos_lista['id_tipo']?>">
<button class="btn btn-primary btn-xs btn-block"><span class="glyphicon glyphicon-pencil"></span></button></a>
</td>
<td>
<a href="tipo_deleta.php?id_tipo=<?php echo $row_tipos_lista['id_tipo']?>"><button class="btn btn-danger btn-xs btn-block"><span class="glyphicon glyphicon-trash"></span></button></a>
</td>
</tr>
<?php } while ($row_tipos_lista = mysql_fetch_assoc($tipos_lista)); ?>
</tbody>
</table>
</div>
</section>
</section>
</div>
</div>
</div>
</div>
<!-- Final Modal Categoria -->
<!-- Modal Inserir cat Eventos -->
<div class="modal fade" id="modalinserircateventos" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="exampleModalLabel"><b>Inserir Categoria</b></h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<section id="insere_centro" class="container-fluid">
<section id="form" class="container">
<section class="col-sm-5">
<form name="form_tipo_insere" action="<?php echo $editFormAction; ?>" method="POST" id="form_rotulo_insere" enctype="multipart/form-data">
<label for="rotulo_tipo">Rótulo:</label>
<p class="input-group">
<span class="input-group-addon"></span>
<input name="rotulo_tipo" class="form-control input" type="text" id="rotulo_tipo" maxlength="15" required placeholder="Digite o rótulo">
</p>
<label for="sigla_tipo">Sigla:</label>
<p class="input-group">
<span class="input-group-addon"></span>
<input name="sigla_tipo" class="form-control input" type="text" id="sigla_tipo" maxlength="3" required placeholder="Digite uma sigla" >
</p>
<p>
<div class="btn-group btn-group-justified" role="group" aria-label="...">
<div class="btn-group" role="group">
<input class="btn btn-success btn-block" type="submit" value="Inserir">
</div>
<div class="btn-group" role="group">
<input class="btn btn-danger btn-block" type="reset" value="Limpar">
</div>
</div>
</p>
<input type="hidden" name="MM_insert" value="form_tipo_insere">
</form>
</section>
</section>
</section>
</div>
</div>
</div>
</div>
<!-- Final inserir cat eventos -->
<!-- Listar Eventos -->
<div class="modal fade bs-example-modal-lg" id="modallistareventos" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="exampleModalLabel"><b>Listar Eventos</b></h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<section class="container">
<div class="table-responsive">
<table class="table">
<thead>
<tr>
<th>Nome</th>
<th class="esconde">Local</th>
<th class="esconde600">Público</th>
<th class="esconde600">Tipo</th>
<th class="hidden-sm hidden-xs">Imagem</th>
<th class="hidden-xs">Descrição</th>
<th class="hidden-xs"></th>
<th class="esconde-xs-xs"></th>
<th class="hidden-sm hidden-md hidden-lg"></th>
</tr>
</thead>
<tbody>
<?php do { ?>
<tr>
<td><?php echo mb_strimwidth($row_eventos_lista['nome_evento'],0,10,"...");?></td>
<td class="esconde"><?php echo $row_eventos_lista['local_evento']?></td>
<td class="esconde600"><?php echo $row_eventos_lista['publico_evento']?></td>
<td class="esconde600"><?php echo $row_eventos_lista['rotulo_tipo']?></td>
<td class="hidden-sm hidden-xs"><img src="../imagens/<?php echo $row_eventos_lista['imagem_evento']?>" class="img-thumbnail" width="100px">
<a href="evento_imagem.php?id_evento=<?php echo $row_eventos_lista['id_evento']?>"><button class="btn btn-primary btn-xs btn-block"><span class="glyphicon glyphicon-pencil"></span>&nbsp;Alterar Img</button></a>
</td>
<td class="hidden-xs"><?php echo mb_strimwidth($row_eventos_lista['descr_evento'],0,30,"...")?></td>
<td class="esconde-xs-xs">
<?php if ($row_eventos_lista['destaque_evento'] == 'Sim'){
echo("<span class='glyphicon glyphicon-star'></span>");
}else if ($row_eventos_lista['destaque_evento']== 'Nao'){
echo("<span class='glyphicon glyphicon-star-empty'></span>");
}?>
</td>
<td class="">
<a href="evento_altera.php?id_evento=<?php echo $row_eventos_lista['id_evento']?>"><button class="btn btn-primary btn-xs btn-block"><span class="glyphicon glyphicon-pencil"></span></button></a>
<a href="evento_deleta.php?id_evento=<?php echo $row_eventos_lista['id_evento']?>"><button class="btn btn-danger btn-xs btn-block"><span class="glyphicon glyphicon-trash"></span></button></a>
</td>
<td class="hidden-sm hidden-md hidden-lg"><a href="../eventos_detalhe.php?id_evento=<?php echo $row_eventos_lista['id_evento'];?>" ><span class="glyphicon glyphicon-eye-open"></span></a></td>
</tr>
<?php } while ($row_eventos_lista = mysql_fetch_assoc($eventos_lista)); ?>
</tbody>
</table>
</section>
<div class="modal-footer">
<center><button type="button" class="btn btn-secondary" data-dismiss="modal" style="color:black;">Fechar</button></center>
</div>
</div>
</div>
</div>
</div>
<!-- fim Listar Eventos -->
<!-- Modal Eventos Insere -->
<div class="modal fade" id="modaleventosinsere" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="exampleModalLabel"><b>Inserir Eventos</b></h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<section id="insere_centro" class="container-fluid">
<section id="form" class="container">
<section class="col-sm-5">
<form name="form_evento_insere" action="<?php echo $editFormAction; ?>" method="POST" id="form_evento_insere" enctype="multipart/form-data">
<input type="hidden" name="id_usuario">
<label for="nome_evento">Evento:</label>
<p class="input-group">
<span class="input-group-addon"></span>
<input name="nome_evento" class="form-control input" type="text" id="nome_evento" maxlength="50" required placeholder="Nome do Evento">
</p>
<label for="publico_evento">Publico:</label>
<p class="input-group">
<span class="input-group-addon"></span>
<input name="publico_evento" class="form-control input" type="text" id="publico_evento" maxlength="30" required placeholder="Ex.: Todos" >
</p>
<label for="tipo_evento">Tipo:</label>
<p class="input-group">
<span class="input-group-addon"></span>
<select name="tipo_evento" id="tipo_evento" required>
<?php do { ?>
<option value="<?php echo $row_select_tipo['id_tipo']?>">
<?php echo $row_select_tipo['rotulo_tipo']?>
</option>
<?php } while ($row_select_tipo = mysql_fetch_assoc($select_tipo));
$rows = mysql_num_rows($select_tipo);
if($rows > 0) {
mysql_data_seek($select_tipo, 0);
$row_select_tipo = mysql_fetch_assoc($select_tipo);
}
?>
</select>
</p>
<label for="local_evento">Local:</label>
<p class="input-group">
<span class="input-group-addon"></span>
<input name="local_evento" class="form-control input" type="text" id="local_evento" maxlength="30" required placeholder="Ex.: Itapetininga" >
</p>
<p>
<b>Escolha a imagem:</b><br>
<input type="file" name="imagem_evento" id="imagem_evento">
</p>
<label for="descr_evento">Descrição:</label>
<p>
<textarea name="descr_evento" id="descr_evento" cols="35" rows="5" maxlength="1500"></textarea>
</p>
<div>
<label for="destaque_evento"><b>É destaque?:</b></label>
<div class="btn-group btn-group-toggle" data-toggle="buttons">
<label class="btn btn-warning">
<input name="destaque_evento" type="radio" id="destaque_evento_s" value="Sim" required> Sim
</label>
<label class="btn btn-warning">
<input name="destaque_evento" type="radio" id="destaque_evento_n" value="Nao" required checked> Não
</label>
</div>
</div>
<br>
<div class="btn-group btn-group-justified" role="group" aria-label="...">
<div class="btn-group" role="group">
<input class="btn btn-success btn-block" type="submit" value="Adicionar" name="enviar" id="enviar">
</div>
<div class="btn-group" role="group">
<input class="btn btn-danger btn-block" type="reset" value="Limpar">
</div>
</div>
<input type="hidden" name="MM_insert" value="form_evento_insere">
</form>
</section>
</section>
</section>
</div>
</div>
</div>
</div>
<!-- Final eventos insere -->
<main class="container">
<section>
<hr>
<h1 id="h1areaadm">Área administrativa</h1>
<div class="row">
<div class="col-sm-6 col-md-4">
<div class="thumbnail thumbnailadm">
<img src="../imagens/user.png" width="250px" height="250px" alt="...">
</center>
<br>
<center><font id="admimagens" size="5px" ><b>Usuários</b></font></center>
<br>
<div class="alert alert-success" role="alert">
<div class="btn-group btn-group-justified" role="group">
<div class="btn-group" role="group">
<button data-toggle="modal" data-target="#modalusuarios" type="button" class="btn btn-default <?php if($_SESSION['MM_UserGroup'] == 'com'){ echo "disabled";}?>">Listar</button>
</div>
<div class="btn-group" role="group">
<button data-toggle="modal" data-target="#modalinsereusuarios" type="button" class="btn btn-default <?php if($_SESSION['MM_UserGroup'] == 'com'){ echo "disabled";}?>">Inserir</button>
</div>
</div>
</div>
</div>
</div>
<div class="col-sm-6 col-md-4">
<div class="thumbnail thumbnailadm">
<img src="../imagens/tipos evento.png" width="250px" height="250px" alt="">
<br>
<center><font id="admimagens2" size="5px"><b>Categorias de Eventos</b></font></center>
<br>
<div class="alert alert-success" role="alert">
<div class="btn-group btn-group-justified" role="group">
<div class="btn-group" role="group">
<button data-toggle="modal" data-target="#modalcategoria" type="button" class="btn btn-default">Listar</button>
</div>
<div class="btn-group" role="group">
<button data-toggle="modal" data-target="#modalinserircateventos" type="button" class="btn btn-default">Inserir</button>
</div>
</div>
</div>
</div>
</div>
<div class="col-sm-6 col-md-4">
<div class="thumbnail thumbnailadm">
<img src="../imagens/eventos.png" width="250px" height="250px" alt="">
<br>
<center><font id="admimagens3" size="5px" ><b>Eventos</b></font></center>
<br>
<div class="alert alert-success" role="alert">
<div class="btn-group btn-group-justified" role="group">
<div class="btn-group" role="group">
<button data-toggle="modal" data-target="#modallistareventos" type="button" class="btn btn-default">Listar</button>
</div>
<div class="btn-group" role="group">
<button data-toggle="modal" data-target="#modaleventosinsere" type="button" class="btn btn-default">Inserir</button
</div>
</div>
</div>
</div>
</div>
</div>
</section>
</main>
<script src="../bootstrap/jquery.min.js"></script>
<script src="../bootstrap/js/bootstrap.min.js"></script>
</body>
<center><font size="2px" color="white">© 2019 SustentaItape - Sustentabilidade. Todos os direitos reservados.</font></center>
</html>