<?php include('fncr-geral/configuracao_geral.php');
$pagina = "clubes";

$id_clube = $_GET['clube'];

$sql_clube = $bd->getConexao()->prepare('SELECT * FROM clubes WHERE id = :id_clube');
$sql_clube->bindValue(':id_clube', $id_clube, PDO::PARAM_STR);
if( $sql_clube->execute() ) { $resul_clube = $sql_clube->fetch(PDO::FETCH_ASSOC);}

// Cadastrando Novo Cliente
if(isset($_POST['postar']) && $_POST['postar'] == 'comentario') {
  // Postando comentário
  $sql_post = $bd->getConexao()->prepare('INSERT INTO clubes_registros
        (id_clube, id_usuario, data, hora, texto) VALUES
        ("'.$id_clube.'", "'.$usuario_id.'", "'.$data.'", "'.$hora.'", "'.$_POST['postagem'].'")');
  if ($sql_post->execute()) ;
}

// Registros
$sql_registros = $bd->getConexao()->prepare('
SELECT clubes_registros.*,
  usuarios.nome as usuario,
  usuarios.nivel as nivel,
  DATE_FORMAT(clubes_registros.data,"%d/%m/%Y") AS data_post
FROM clubes_registros
  LEFT JOIN usuarios ON usuarios.id = clubes_registros.id_usuario
WHERE clubes_registros.id_clube = :id_clube ORDER BY id DESC');
$sql_registros->bindValue(':id_clube', $id_clube, PDO::PARAM_STR);
if( $sql_registros->execute() ) { $resul_registros = $sql_registros->fetchall(PDO::FETCH_ASSOC);}


?>
<!DOCTYPE html>
<html lang="pt-br">
<head>
    <?php include('fncr-geral/html-head.php');?>

  <link rel="stylesheet" type="text/css" href="js/datatables2/media/css/jquery.dataTables.css">
  <script type="text/javascript" language="javascript" src="js/datatables2/media/js/jquery.dataTables.js"></script>

</head>
<body>

<!-- BARRA SUPERIOR -->
<?php include('barra-sup.php');?>
<!-- MENU PRINCIPAL -->
<?php include('menu.php');?>

<section id="content">

<div class="clearfix padder bg-fncr-clearfix">
<h3 class="m-b">Clubes - <?php echo $resul_clube['nome']; ?></h3>

</div>

<section id="content" class="content-sidebar bg-white" style="padding-bottom: 100px">
<!-- .main -->
<section class="main">
<br>

<div class="col-lg-12">

  <!-- .comment-list -->
  <section class="comment-list block">

    <article class="comment-item media" style="margin-bottom: 25px;">
      <section class="media-body">
        <form method="post" action="" data-validate="parsley" enctype="multipart/form-data">
        <input type="hidden" name="postar" value="comentario"/>
          <div class="col-app-11">
            <input type="text" class="form-control" data-required="true" name="postagem" placeholder="Digite o coment&aacute;rio aqui"/>
          </div>
          <div class="col-app-1">
            <button class="btn btn-info btn-xs pull-right">POSTAR</button>
          </div>
        </form>
      </section>
    </article>
<?php foreach($resul_registros as $linha_registros){
  if($linha_registros['nivel'] == 0){
    $avatar = 'icone_admin.png';
  }else{
    $avatar = 'icone_user.png';
  }
  ?>
    <article class="comment-item media arrow arrow-left">
      <a class="pull-left thumb-small avatar"><img src="images/<?php echo $avatar ?>" class="img-circle"></a>
      <section class="media-body panel">
        <header class="panel-heading clearfix">
          <a><?php echo $linha_registros['usuario']; ?></a>
          <span class="text-muted m-l-small pull-right"><?php echo $linha_registros['data_post']; ?> - <?php echo echohora($linha_registros['hora']); ?> <i class="fa fa-calendar"></i></span>
        </header>
        <div class="panel-body">
          <div><?php echo $linha_registros['texto']; ?></div>
        </div>
      </section>
    </article>
<?php } ?>
  </section>


</div>

</section>
<!-- /.main -->
</section>

<!-- FOOTER -->
<?php include('footer.php');?>


<!-- app -->
<script src="js/app.js"></script>
<script src="js/app.plugin.js"></script>
<script src="js/app.data.js"></script>
<!-- Sparkline Chart -->
<script src="js/charts/sparkline/jquery.sparkline.min.js"></script>
<!-- Easy Pie Chart -->
<script src="js/charts/easypiechart/jquery.easy-pie-chart.js"></script>
  <!-- select2 -->
<script src="js/select2/select2.min.js"></script>
  <!-- fuelux -->
<script src="js/fuelux/fuelux.js"></script>
<!-- datepicker -->
<script src="js/datepicker/bootstrap-datepicker.js"></script>
<!-- slider -->
<script src="js/slider/bootstrap-slider.js"></script>
<!-- file input -->
<script src="js/file-input/bootstrap.file-input.js"></script>
<!-- combodate -->
<script src="js/combodate/moment.min.js"></script>
<script src="js/combodate/combodate.js"></script>
<!-- parsley -->
<script src="js/parsley/parsley.min.js"></script>

</body>
</html>
<?php $bd = null; $bd_fn = null;?>