<!DOCTYPE html>
<html lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <meta http-equiv="refresh" content="3">
  <title>DataTables | Gentelella</title>
  <link href="../vendors/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
  <link href="../vendors/font-awesome/css/font-awesome.min.css" rel="stylesheet">
  <link href="../vendors/nprogress/nprogress.css" rel="stylesheet">
  <link href="../vendors/iCheck/skins/flat/green.css" rel="stylesheet">
  <link href="../vendors/datatables.net-bs/css/dataTables.bootstrap.min.css" rel="stylesheet">
  <link href="../vendors/datatables.net-buttons-bs/css/buttons.bootstrap.min.css" rel="stylesheet">
  <link href="../vendors/datatables.net-fixedheader-bs/css/fixedHeader.bootstrap.min.css" rel="stylesheet">
  <link href="../vendors/datatables.net-responsive-bs/css/responsive.bootstrap.min.css" rel="stylesheet">
  <link href="../vendors/datatables.net-scroller-bs/css/scroller.bootstrap.min.css" rel="stylesheet">
  <link href="../build/css/custom.min.css" rel="stylesheet">
  <style>
  #datatable td, #datatable th {
    text-align: center; /* Centraliza o texto das células */
  }
</style>
</head>
<body class="nav-md">
<div class="container body">
  <div class="main_container">
    <!-- Sidebar, top navigation, and other components... -->

    <!-- page content -->
    <div class="right_col" role="main">
      <div class="">
        <div class="page-title">
          <div class="title_left">
            <h3>Controle de fluxo</h3>
          </div>
        </div>
        <div class="clearfix"></div>
        <div class="row">
          <div class="col-md-12 col-sm-12 col-xs-12">
            <div class="x_panel">
              <div class="x_title">
                <h2>Puxador Comunidade v1.31</h2>
                <!-- Toolboxes etc... -->
              </div>
              <div class="x_content">
                <table id="datatable" class="table table-striped table-bordered">
                  <thead>
                    <tr>
                      <th>Data Coleta</th>
                      <th>Lid</th>
                      <th>Origem</th>
                      <th>Status</th>
                      <th>Data Envio</th>
                      <th>User Envio</th>
                    </tr>
                  </thead>
                  <tbody>
                    <?php
                    $servername = "br386.hostgator.com.br:3306";
                    $username = "onabet10_dashboard";
                    $password = "102030Bacon!";
                    $dbname = "onabet10_brejonetwork";
                    $conn = new mysqli($servername, $username, $password, $dbname);
                    $conn->set_charset("utf8mb4");
                    if ($conn->connect_error) {
                      die("Connection failed: " . $conn->connect_error);
                    }
                    $sql = "SELECT data_coleta, lid, origem, status, data_envio, user_envio FROM dados_whatsapp WHERE status IN ('aguardando', 'enviado', 'pendente') ORDER BY data_coleta DESC LIMIT 50";
                    $result = $conn->query($sql);
                    if ($result->num_rows > 0) {
                      while($row = $result->fetch_assoc()) {
                        echo "<tr>
                                <td>" . $row["data_coleta"] . "</td>
                                <td>" . $row["lid"] . "</td>
                                <td>" . $row["origem"] . "</td>
                                <td>" . $row["status"] . "</td>
                                <td>" . $row["data_envio"] . "</td>
                                <td>" . $row["user_envio"] . "</td>
                              </tr>";
                      }
                    } else {
                      echo "<tr><td colspan='6'>No data found</td></tr>";
                    }
                    $conn->close();
                    ?>
                  </tbody>
                </table>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
    <!-- /page content -->

    <!-- footer content -->
    <footer>
      <div class="pull-right">
        Gentelella - Bootstrap Admin Template by <a href="https://colorlib.com">Colorlib</a>
      </div>
      <div class="clearfix"></div>
    </footer>
    <!-- /footer content -->
  </div>
</div>
<!-- jQuery, Bootstrap, and other scripts... -->
</body>
</html>
