<div class="content-wrapper">
   <section class="content-header">
      <div class="container-fluid">
         <div class="row mb-2">
            <div class="col-sm-6">
               <h1>All Message</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">All Message </li>
               </ol>
            </div>
         </div>
      </div>
   </section>
   <section class="content">
      <div class="container-fluid">
         <div class="row">
            
            <div class="col-md-12">
               <div class="card card-success">
                  <div class="card-header">
                     <h3 class="card-title">View All Message</h3>
                  </div>
                  <div class="card-body">
                     <table id="example1" class="example2 table table-bordered table-striped">
                        <thead>
                           <tr>
                              <th>ID</th>
                              <th>Name</th>
                              <th>Details</th>
                              <th>Message</th>
                              <th>Is Replay</th>
                              <th></th>
                           </tr>
                        </thead>
                        <tbody>
                           <?php $i=1; foreach ($all_message as $message): ?>
                           <tr>
                              <td><?php echo $i; ?></td>
                              <td><?php echo $message->name; ?></td>
                              <td><span class="badge badge-success">Email : <?php echo $message->email; ?></span><br/>
                                 <span class="badge badge-primary"><?php echo $message->phone; ?></span></td>
                              <td><?php echo $message->message; ?></td>
                              <td>
                                 <?php if($message->is_reply == 0): ?>
                                    <span class="badge badge-danger">No</span>
                                 <?php else: ?>
                                    <span class="badge badge-success">Yes</span>
                                 <?php endif; ?>
                              </td>
                              <td>
                                  <a href="#" data-toggle="modal" data-target="#email_model<?php echo $message->id ?>" class="btn btn-success btn-sm"><i class="fas fa-envelope"></i></a>

                                   <a href="<?php echo base_url()?>/admin/contact_message/delete_message/<?php echo $message->id; ?>" onclick="return confirm('Are you sure?')" class="btn btn-danger btn-sm"><i class="fas fa-trash"></i></a>
                              </td>
                           </tr>
                           <?php $i++; endforeach ?>
                        </tbody>
                     </table>
                  </div>
               </div>
            </div> 
         </div>
      </div>
   </section>
</div>
<?php $i=1; foreach ($all_message as $message): ?>
<div class="modal fade" id="email_model<?php echo $message->id ?>" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="exampleModalLabel">Send Email</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <?php echo form_open_multipart(base_url().'/admin/contact_message/send_email/'.$message->id) ?>
      <div class="modal-body">
       <div class="form-group">
         <label for="recipient-name" class="col-form-label">Email Subject:</label>
         <input type="text" class="form-control"  placeholder="Enter Email Subject" name="subject" required>
       </div>
       <div class="form-group">
         <label for="message-text" class="col-form-label">Message:</label>
         <textarea class="form-control text-editor" name="message" required></textarea>
       </div>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
        <button type="submit" class="btn btn-primary">Send Email</button>
      </div>
      <?php echo form_close() ?>
    </div>
  </div>
</div>
<?php $i++; endforeach ?>