<?php include('header.php'); ?>
<?php
include('connection.php');

if (isset($_GET['id'])) {
    $emailId = $_GET['id'];

    // Fetch email details from the database based on the email ID
    $query = mysqli_query($conn, "SELECT * FROM compose WHERE id = $emailId");
    $data = mysqli_fetch_assoc($query);

    if ($data) {
        // Display email details
        $subject = $data['subject'];
        $message = $data['message'];
        $status = $data['status'];
        $attachment = $data['attachment'];
        $date_time = $data['date_time'];
    } else {
        // Handle case where email with the specified ID is not found
        echo "user not found.";
    }
} else {
    // Handle case where no email ID is provided in the URL
    echo "user ID not provided.";
}
?>

  <!-- 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">Massage Read</h1>
          </div>
          
        </div>
      </div><!-- /.container-fluid -->
    </section>

    <!-- Main content -->
    <section class="content">
      <div class="container-fluid">
        <div class="row">
          <div class="col-md-3">
            <a href="mailbox.php" class="btn btn-dark btn-block mb-3">Back to Inbox</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="mailbox.php" class="nav-link">
                  <i class="fas fa-inbox"></i> Draft 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">Read Mail</h3>

              <div class="card-tools">
              
              </div>
            </div>
            <!-- /.card-header -->
            <div class="card-body p-0">
              <div class="mailbox-read-info">
                
                <h5 style="color:blue;font-weight:500"><?php echo $subject; ?>
                  <span class="mailbox-read-time float-right"><?php echo $date_time; ?></span></h5>
              </div>
           
              <div class="mailbox-read-message">
               

                <p><?php echo $message; ?></p>
                
              </div>
              <!-- /.mailbox-read-message -->
            </div>
            <!-- /.card-body -->
            <div class="card-footer bg-white">
              <ul class="mailbox-attachments d-flex align-items-stretch clearfix">
              
              
                <li>
                  <span class="mailbox-attachment-icon has-img"><img src="uploads/<?php echo $attachment; ?>" alt=""></span>

                  <div class="mailbox-attachment-info mt-1">
                    <a href="#" class="mailbox-attachment-name"><i class="fas fa-camera"></i><?php echo $attachment; ?></a>
                        <span class="mailbox-attachment-size clearfix mt-1">
                          
                          <a href="#" class="btn btn-default btn-sm float-right"><i class="fas fa-cloud-download-alt"></i></a>
                        </span>
                  </div>
                </li>
                
              </ul>
            </div>
            <!-- /.card-footer -->
            <div class="card-footer">
          
              <button type="button" class="btn btn-default"><i class="far fa-trash-alt"></i> Delete</button>
              <a  href="mailbox.php" type="button" class="btn btn-default"><i class="fa fa-arrow-left" aria-hidden="true"></i> Back</a>
            </div>
            <!-- /.card-footer -->
          </div>
          <!-- /.card -->
        </div>
        <!-- /.col -->
      </div>
      <!-- /.row -->
      </div><!-- /.container-fluid -->
    </section>
    <!-- /.content -->
  </div>
  <!-- /.content-wrapper -->
  
<?php include('footer.php'); ?>