
 <div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <div class="content-header">
      <div class="container-fluid">
        <div class="row mb-2">
          <div class="col-sm-6">
            <h1 class="m-0 text-dark">All Student Doubt</h1>
          </div><!-- /.col -->
          <div class="col-sm-6">
            <ol class="breadcrumb float-sm-right">
              <li class="breadcrumb-item"><a href="<?php echo base_url() ?>admin/admin/dashboard">Dashboard</a></li>
              <li class="breadcrumb-item"><a href="#">My Task</a></li>
              <li class="breadcrumb-item active">All Student Doubt</li>

            </ol>
          </div><!-- /.col -->
        </div><!-- /.row -->
      </div><!-- /.container-fluid -->
    </div>
    <!-- /.content-header -->
    <!-- Main content -->
    <section class="content">
      <div class="container-fluid">
        <div class="card card-default">
          <div class="card-header">
            <h3 class="card-title">View All Student Doubt</h3>
          </div>
            <!-- /.card-header -->
            <div class="card-body">
              <table id="example1" class="table table-bordered table-striped">
                <thead>
                <tr>
                  <th>ID</th>
                  <th>Student Name</th>
                  <th>Course Name</th>
                  <th>Chapters</th>
                  <th>Lession</th>
                  <th>Batch Name</th>
                  <th></th>
                </tr>
                </thead>
                <tbody>
                <?php $i=1; foreach ($all_doubt as $doubt):
                $this->db->where('batch_id', $doubt->doubt_batch);
                $batch = $this->db->get('student_batch')->row();
                ?>
                <tr>
                  <td><?php echo $i ?></td>
                  <td><?php echo $doubt->user_name ?></td>
                  <td><?php echo $doubt->title ?></td>
                  <td><?php echo $doubt->ch_lession_name ?></td>
                  <td><?php echo json_decode($doubt->ch_chapters)[$doubt->doubt_lession]?></td>
                  <td><?php echo $batch->batch_name; ?></td>
                  <th><button data-toggle="modal" data-target="#doubtModal<?php echo $doubt->doubt_id; ?>" class="btn btn-success btn-sm">View</button></th>
                </tr>
                <?php $i++; ?>
                <?php endforeach; ?>
                </tbody>
              </table>
            </div>
          </td>
        </div>
      </div>
    </section>
  </div>
<?php $i=1; foreach ($all_doubt as $doubt): ?>
<div class="modal fade" id="doubtModal<?php echo $doubt->doubt_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">Conversion Details || <?php echo $doubt->user_name ?></h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <?php echo form_open(base_url().'admin/course/submit_relplay_message_for_doubt');?>
        <div class="modal-body">
          <?php 
            $this->db->where('doubt_replay_id', $doubt->doubt_id);
            $all_doubts = $this->db->get('student_doubt')->result();
            foreach ($all_doubts as $doubt_all):
            if($doubt_all->doubt_is_student == 0): ?>
            <div class="row mt-1">
              <div class="col-sm-6">
                <div class="background">
                  <b>Student : <?php echo $doubt->user_name ?></b>
                  <p><?php echo $doubt_all->doubt_message ?></p>
                </div>
              </div>
              <div class="col-sm-6">
              </div>
            </div>
          <?php else: ?>
            <div class="row mt-1">
              <div class="col-sm-6">
              </div>
              <div class="col-sm-6">
                <div class="background">
                  <b>Instructor  : You</b>
                  <p><?php echo $doubt_all->doubt_message ?></p>
                </div>
              </div>
            </div>
          <?php endif ?>
          <?php endforeach ?>
          <div class="form-group">
            <label for="message-text" class="col-form-label">Message:</label>
            <textarea class="form-control" id="message-text" name="doubt_message" required></textarea>
          </div>
          <input type="hidden" name="doubt_user_id" value="<?php echo user()->user_id; ?>">
          <input type="hidden" name="doubt_chapter" value="<?php echo $doubt->doubt_chapter; ?>">
          <input type="hidden" name="doubt_lession" value="<?php echo $doubt->doubt_lession; ?>">
          <input type="hidden" name="doubt_course_id" value="<?php echo $doubt->doubt_course_id; ?>">
          <input type="hidden" name="doubt_batch" value="<?php echo $doubt->doubt_batch; ?>">
          <input type="hidden" name="doubt_replay_id" value="<?php echo $doubt->doubt_id; ?>">
          <input type="hidden" name="doubt_is_student" value="1">
          <input type="hidden" name="doubt_is_first" value="0">
        </div>
        <div class="modal-footer">
          <button type="submit" class="btn btn-primary">Submit</button>
        </div>
      <?php echo form_close();?>
    </div>
  </div>
</div>
<?php endforeach ?>

<style type="text/css">
.background
{
  background: #e5e7eb;
  padding: 10px;
/*   border-radius: 10%; */
}
</style>