<?php
//Activamos el almacenamiento en el buffer
ob_start();
session_start();

if (!isset($_SESSION["nombre"])) {
    header("Location: login.html");
} else {
    require 'header.php';

    if ($_SESSION['chat_interno'] == 1) {
?>
<!--Contenido-->
      <div class="content-wrapper">        
        <!-- Main content -->
        <section class="content">
            <div class="row">
              <div class="col-md-8 col-md-offset-2">
                  
                <!-- DIRECT CHAT -->
                <div class="box box-primary direct-chat direct-chat-primary">
                    <div class="box-header with-border">
                        <h3 class="box-title"><i class="fa fa-comments"></i> Chat Interno del Personal</h3>
                    </div>
                    <!-- /.box-header -->
                    
                    <div class="box-body">
                        <!-- Conversations are loaded here -->
                        <div class="direct-chat-messages" id="chat-box" style="height: 500px; overflow-y: scroll;">
                            <!-- Los mensajes se llenan por JS -->
                        </div>
                        <!--/.direct-chat-messages-->
                    </div>
                    <!-- /.box-body -->
                    
                    <div class="box-footer">
                        <form id="formularioChat" action="#" method="post">
                            <div class="input-group">
                                <input type="text" name="mensaje" id="mensaje" placeholder="Escribe un mensaje..." class="form-control" autocomplete="off" required>
                                <span class="input-group-btn">
                                    <button type="submit" id="btnEnviar" class="btn btn-primary btn-flat"><i class="fa fa-send"></i> Enviar</button>
                                </span>
                            </div>
                        </form>
                    </div>
                    <!-- /.box-footer-->
                </div>
                <!--/.direct-chat -->

              </div><!-- /.col -->
          </div><!-- /.row -->
      </section><!-- /.content -->

    </div><!-- /.content-wrapper -->
  <!--Fin-Contenido-->
<?php
    } else {
        require 'noacceso.php';
    }
    require 'footer.php';
?>
<script type="text/javascript" src="scripts/chat.js"></script>
<?php 
}
ob_end_flush();
?>
