
 <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">Course Fee Setting</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="#">Setting</a></li>
              <li class="breadcrumb-item active">Course Fee Setting</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 Course</h3>
          </div>
            <!-- /.card-header -->
            <div class="card-body">
              <table id="example1" class="table table-bordered table-striped">
                <thead>
                <tr>
                  <th>ID</th>
                  <th>Course Name</th>
                  <th>Price</th>
                  <th></th>
                </tr>
                </thead>
                <tbody>
                <?php $i=1; foreach ($all_course as $course):
                  $this->db->where('atp_c_p_atp_id', $atp_id);
                  $this->db->where('atp_c_p_course_id', $course->id);
                  $atp_price = $this->db->get('atp_course_price')->row();
                ?>
                <tr>
                  <td><?php echo $i ?></td>
                  <td><?php echo $course->title; ?></td>
                  <td>
                    <?php if($atp_price): ?>
                      <span class="badge badge-success"><?php echo $atp_price->atp_c_p_course_price; ?></span>
                    <?php else: ?>
                      <span class="badge badge-danger">Not Set</span>
                    <?php endif;?>

                  </td>
                  <td>
                    <div class="input-group mb-3">
                      <div class="input-group-prepend">
                        <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
                        Action
                        </button>
                        <div class="dropdown-menu">
                          <a class="dropdown-item" href="javascript:void(0)" onclick="set_price(<?php echo $course->id; ?>, <?php echo $atp_price->atp_c_p_course_price; ?>)"><i class="fas fa-edit"></i>&nbsp;&nbsp;Edit</a>
                        </div>
                      </div>
                    </div>
                  </td>
                </tr>
                <?php $i++; ?>
                <?php endforeach; ?>
                </tbody>
              </table>
            </div>
          </div>
      </div><!--/. container-fluid -->
    </section>
    <!-- /.content -->
  </div>
<script type="text/javascript">
function set_price(course_id, atp_price) 
{
  $('#price_modal').modal('show');
  $('#course_id').val(course_id);
  $('#atp_price').val(atp_price);
}
</script>

<div class="modal fade" id="price_modal" 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">Update Price</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/setting/update_course_price_for_atp');?>
        <div class="modal-body">
          <div class="form-group">
            <label for="recipient-name" class="col-form-label">Course price</label>
            <input type="number" class="form-control" placeholder="Enter Course Price" required name="atp_c_p_course_price" id="atp_price">
          </div>
        </div>

        <input type="hidden" class="form-control" required name="atp_c_p_course_id" id="course_id">
        <input type="hidden" class="form-control" required name="atp_c_p_atp_id" value="<?php echo $atp_id; ?>">

        <div class="modal-footer">
          <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
          <button type="submit" class="btn btn-primary">Save</button>
        </div>
      <?php echo form_close();?>
    </div>
  </div>
</div>