<?php require_once('../Connections/conn_sustentabilidade.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_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);
?>
<!doctype html>
<html lang="pt-br">
<head>
<meta charset="utf-8">
<title>Eventos</title>
	<!-- CSS do Bootstrap -->
	<link href="../bootstrap/css/bootstrap.min.css" rel="stylesheet">
</head>

<body>
	<?php include_once ("menu_adm.php");?>
<section class="container" id=tabela>
		<h1>Tabela de Eventos</h1>
		<hr>
  <table class="table-responsive">
			<table class="table table-striped table-hover">
				<thead>
					<tr>
						<th>Nome</th>
						<th>Local</th>
						<th>Público</th>
						<th>Tipo</th>
						<th>Imagem</th>
						<th>Descrição</th>
						<th>Destaque</th>
						<th colspan="2">
							<a href="evento_insere.php"><button class="btn btn-success btn-xs btn-block"><span class="glyphicon glyphicon-plus"></span>&nbsp;Inserir</button></a>
						</th>
					</tr>
				</thead>
				<tbody>
					<?php do { ?>
					<tr>
						<td><?php echo $row_eventos_lista['nome_evento']?></td>
						<td><?php echo $row_eventos_lista['local_evento']?></td>
						<td><?php echo $row_eventos_lista['publico_evento']?></td>
						<td><?php echo $row_eventos_lista['rotulo_tipo']?></td>
						<td><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><?php echo $row_eventos_lista['descr_evento']?></td>
						<td><?php echo $row_eventos_lista['destaque_evento']?></td>
						<td>
						  <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>&nbsp;Alterar</button></a>
						</td>
						<td>
						  <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> &nbsp;Deletar</button></a>
						</td>
					</tr>
					<?php } while ($row_eventos_lista = mysql_fetch_assoc($eventos_lista)); ?>
				</tbody>
			</table>
		</table>
	</section>
	
	<!-- Jquery (obrigatório para plugin JS do Bootstrap) -->
<script src="../bootstrap/jquery.min.js"></script>
	
    <!-- Plugin JS-->
<script src="../bootstrap/js/bootstrap.min.js"></script>
</body>
</html>
<?php
mysql_free_result($eventos_lista);
?>
