<?php include('header.php'); ?>
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
  <!-- Content Header (Page header) -->
  <section class="content-header">
    <div class="container-fluid">
      <div class="row mb-2">
        <div class="col-sm-6">
          <h1 class="card-title">Inbox</h1>
        </div>
        <div class="col-sm-6">
          <ol class="breadcrumb float-sm-right">
            <li class="breadcrumb-item"><a href="#">Home</a></li>
            <li class="breadcrumb-item active">Inbox</li>
          </ol>
        </div>
      </div>
    </div><!-- /.container-fluid -->
  </section>

  <!-- Main content -->
  <section class="content">
    <div class="row">
      <div class="col-md-3">
        <a href="compose.php" class="btn btn-dark btn-block mb-3">Compose</a>

        <div class="card">
          <div class="card-header">
            <h3 class="card-title">Folders</h3>

            <div class="card-tools">
              <button type="button" class="btn btn-tool" data-card-widget="collapse">
                <i class="fas fa-minus"></i>
              </button>
            </div>
          </div>
          <div class="card-body p-0">
            <ul class="nav nav-pills flex-column">
              <li class="nav-item">
                <a href="#" class="nav-link">
                  <i class="fas fa-inbox"></i> Inbox
                  <span class="badge bg-dark float-right">1</span>
                </a>
              </li>
              <li class="nav-item">
                <a href="compose.php" class="nav-link">
                  <i class="fas fa-inbox"></i> Compose
                </a>
              </li>
              <li class="nav-item">
                <a href="sent.php" class="nav-link">
                  <i class="far fa-envelope"></i> Sent
                  <span class="badge bg-warning float-right">2</span>

                </a>
              </li>
              <li class="nav-item">
                <a href="draft.php" class="nav-link">
                  <i class="far fa-file-alt"></i> Drafts
                  <span class="badge bg-danger float-right">0 </span>

                </a>
              </li>

            </ul>
          </div>
          <!-- /.card-body -->
        </div>

      </div>
      <!-- /.col -->
      <div class="col-md-9">
        <div class="card card-dark card-outline">
          <div class="card-header">
            <h3 class="card-title">Inbox</h3>
          
          </div>
          <!-- /.card-header -->
          <div class="card-body">

            <table id="example1" class="table table-bordered table-striped">
              <thead>
                <tr>
                  <th>Date time</th>
                  <th>Subject</th>
                  <th>Status</th>
                  <th>Action</th>
                </tr>
              </thead>
              <tbody>
                <?php
                include('connection.php');
                $query = mysqli_query($conn, "SELECT * FROM compose");
                while ($data = mysqli_fetch_assoc($query)) {
                ?>
                  <tr>
                    <td class="mailbox-date"><?php echo $data['date_time']; ?></td>
                    <td class="mailbox-name"> <a href="read_massage.php?id=<?php echo $data['id']; ?>"><?php echo $data['subject']; ?></a></td>

                    <td class="mailbox-attachment"><?php echo $data['status']; ?></td>
                    <td class="mailbox" style="color:red;font-weight:600"><a href="compose_delete.php?id=<?php echo $data['id']; ?>" class="btn btn-danger btn-xs"><i class="fas fa-trash"></i></a></td>
                  </tr>
                <?php } ?>
              </tbody>

            </table>
          </div>

          <!-- /.card-body -->
          <div class="card-footer p-0">
            <div class="mailbox-controls">
           
              <!-- /.float-right -->
            </div>
          </div>
        </div>
        <!-- /.card -->
      </div>
      <!-- /.col -->
    </div>
    <!-- /.row -->
  </section>
  <!-- /.content -->
</div>
<!-- /.content-wrapper -->

<!-- jQuery -->


<script src="https://cdn.jsdelivr.net/npm/sweetalert2@10"></script>
<script>
<?php if (isset($_GET['error'])) { ?>
Swal.fire({
    icon: 'error',
    title: 'Error',
    text: '<?php echo $_GET['error']; ?>',
});
<?php } ?>

<?php if (isset($_GET['success'])) { ?>
Swal.fire({
    icon: 'success',
    title: 'Success',
    text: '<?php echo $_GET['success']; ?>',
});
<?php } ?>
</script>
<?php include('footer.php'); ?>