 <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 Enquiry</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="#">Student</a></li>
              <li class="breadcrumb-item active">All Enquiry</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 Enquiry</h3>
              <?php if(check_user_permission('student_enq_add')): ?>
                <div class="card-tools">
                  <a href="<?php echo base_url()?>/admin/students/add_new_enquiry" class="btn btn-success btn-sm"><i class="fa fa-plus" aria-hidden="true"></i> Add Enquiry</a>
                </div>
              <?php endif; ?>
          </div>
            <!-- /.card-header -->
            <div class="card-body">
              <table id="example1" class="table table-bordered table-striped">
                <thead>
                <tr>
                  <th>Student Name</th>
                  <th>Details</th>
                  <th>Course</th>
                  <th>Enquiry Details</th>
                  <th>Status</th>
                  <th></th>
                </tr>
                </thead>
                <tbody>
                <?php $i=1; foreach ($all_students as $student):?>
                <tr>
                  <td><?php echo $student->user_name ?></td>
                  <td>
                    Mob. : <b><?php echo $student->user_mobile ?></b>
                    <?php if($student->user_email): ?>
                      <br/>
                      Email : <b><?php echo $student->user_email ?></b>
                    <?php endif;?>
                    <br/>
                    Gender : <b><?php echo $student->user_gender ?></b>
                    <?php if($student->user_dob != '0000-00-00'): ?>
                      <br/>
                      DOB : <b><?php echo date('d-m-Y', strtotime($student->user_dob)); ?></b>
                    <?php endif; ?>
                    <?php if($student->user_qualification): ?>
                      <br/>
                      Qulification : <b><?php echo $student->user_qualification ?></b>
                    <?php endif; ?>
                    <?php if($student->user_pin_code): ?>
                      <br/>
                      Address : <b>
                      <?php echo $student->user_village ?>, <?php echo $student->user_taluka ?>, <?php echo $student->user_dist ?>, <?php echo $student->user_state ?> - <?php echo $student->user_pin_code ?></b>
                    <?php endif;?>
                  </td>
                  <td>
                    <?php 
                    foreach (json_decode($student->course_interest) as $course_details) 
                    {
                        $course = $this->course->get_course_by_id_for_enquiry_page($course_details);
                    ?>
                    <span class="badge badge-success"><?php echo $course->title; ?></span>
                  <?php }?>

                  </td>
                  <td>
                    Source : <b><?php echo $student->lead_name; ?></b>
                    <br/>
                    Date : <b><?php echo date('d-m-Y', strtotime($student->inq_date)); ?></b>
                    <br/>
                    Interest level: <b><?php echo $student->inq_interest; ?></b>
                    <br/>
                     Demo Lecture : <b><?php echo $student->inq_req_demo; ?></b>
                    <br/>
                    <span class="badge badge-primary">Assign To : <?php echo $student->assign_name; ?></span>
                  </td>
                  <td>
                    <?php if($student->status == 0): ?>
                      <span class="badge badge-warning">New</span>
                    <?php elseif($student->status == 1): ?>
                      <span class="badge badge-info">In Process</span>
                    <?php elseif($student->status == 2): ?>
                      <span class="badge badge-success">Admitted</span>
                    <?php elseif($student->status == 3): ?> 
                      <span class="badge badge-danger">Lost</span>
                    <?php elseif($student->status == 5): ?> 
                      <span class="badge badge-danger">Junk</span>
                    <?php endif;?>
                  </td>
                  <td class="text-left py-0 align-middle">
                    <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 dropdown-menu-right">
                            <a class="dropdown-item" href="<?php echo base_url(); ?>admin/students/edit_enquiry/<?php echo $student->id; ?>"><i class="fas fa-edit"></i>&nbsp;&nbsp;Edit Enquiry</a>
                          <div class="dropdown-divider"></div>
                            <a class="dropdown-item" href="<?php echo base_url(); ?>admin/students/all_followup/<?php echo $student->id; ?>" ><i class="fas fa-phone"></i>&nbsp;&nbsp;Follow Up</a>
                          <?php if($student->status != 2): ?>
                          <div class="dropdown-divider"></div>
                            <a class="dropdown-item" href="javascript:void(0)" onclick="change_status(<?php echo $student->id; ?>, <?php echo $student->status; ?>)"><i class="fas fa-pencil-alt"></i>&nbsp;&nbsp;Change Status</a>
                          <?php endif;?>
                          <div class="dropdown-divider"></div>
                            <a class="dropdown-item" href="javascript:void(0)" onclick="openWhatsApp('<?php echo $student->user_mobile ?>')"><i class="fa fa-whatsapp"></i>&nbsp;&nbsp;Whatsapp</a>
                          <!-- <div class="dropdown-divider"></div>
                            <a class="dropdown-item" href="javascript:void(0)" data-toggle="modal" data-target="#editLead<?php echo $i; ?>"><i class="fa fa-plus"></i>&nbsp;&nbsp;New Admission</a> -->
                        </div>
                      </div>
                    </div>
                  </td>
                </tr>
                <?php $i++; ?>
                <?php endforeach; ?>
                </tbody>
              </table>
            </div>
          </div>
      </div><!--/. container-fluid -->
    </section>
    <!-- /.content -->
  </div>
<div class="modal fade" id="status" 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 Status</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/students/change_enquiry_status'); ?>
        <div class="modal-body">
          <div class="form-group">
            <label for="recipient-name" class="col-form-label">Select Status</label>
            <select type="text" class="form-control" id="student_status" name="status">
              <option value="0">New</option>
              <option value="1">In Process</option>
              <option value="2">Admitted</option>
              <option value="3">Lost</option>
              <option value="5">Junk</option>
            </select>
          </div>
        </div>
        <input type="hidden" class="form-control" id="student_id" name="id">
        <div class="modal-footer">
          <button type="submit" onclick="return confirm('Are you sure?')" class="btn btn-primary">Update</button>
        </div>
      <?php echo form_close(); ?>
    </div>
  </div>
</div>
<script type="text/javascript">
function openWhatsApp(mob) {
    let link = "https://api.whatsapp.com/send?phone=" + mob;
    window.open(link, "_blank");
}
function change_status(e, status) 
{
  $('#status').modal('show');
  $('#student_id').val(e);
  $('#student_status').val(status);
}
</script>