<link rel="stylesheet" href="<?php echo admin_css(); ?>plugins/bs-stepper/css/bs-stepper.min.css">
<link rel="stylesheet" href="<?php echo admin_css(); ?>plugins/select2-bootstrap4-theme/select2-bootstrap4.min.css">
<script src="<?php echo admin_css(); ?>dist/js/webcamjs-master/webcam.min.js"></script>
<?php 
$this->db->select('a.*, b.title, b.atp_course_price, b.course_price, b.discounted_price');
$this->db->from('student_course a');
$this->db->join('course b', 'b.id = a.st_course_course_id');
$this->db->where('a.st_course_student_id', $student->user_id);
$course_data = $this->db->get()->result();

$all_batch = $this->setting_model->get_all_batch(); 
if(!$all_batch)
{
?>
<script type="text/javascript">
$( document ).ready(function() {
    $('#subscribeModal').modal({backdrop: 'static', keyboard: false}, 'show');
});
</script>
<div class="modal fade text-center py-5"  id="subscribeModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
    <div class="modal-dialog modal-md" role="document">
        <div class="modal-content">
            <div class="modal-body">
                <a class="h2 text-danger" ><b>Oops! 😟</b></a>
                <h3 class="pt-2 pb-2 mb-0 text-secondary">Batch Not Found</h3>
                <h5><a href="<?php echo base_url(); ?>admin/master/add_batch">Click Here To Add</a></h5>
            </div>
        </div>
    </div>
</div>
<?php }elseif(!$course_data){?>
  <script type="text/javascript">
$( document ).ready(function() {
    $('#subscribeModal').modal({backdrop: 'static', keyboard: false}, 'show');
});
</script>
<div class="modal fade text-center py-5"  id="subscribeModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
    <div class="modal-dialog modal-md" role="document">
        <div class="modal-content">
            <div class="modal-body">
                <a class="h2 text-danger" ><b>Oops! 😟</b></a>
                <h3 class="pt-2 pb-2 mb-0 text-secondary">Course Fee Not Setup</h3>
                <h5><a href="<?php echo base_url(); ?>admin/setting/course_fee_setting">Click Here To Add</a></h5>
            </div>
        </div>
    </div>
</div>
<?php }?>
 <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">Edit Student</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">Edit Student</li>

            </ol>
          </div><!-- /.col -->
        </div><!-- /.row -->
      </div><!-- /.container-fluid -->
    </div>
    <!-- /.content-header -->
    <!-- Main content -->
    <section class="content">
      <div class="container-fluid">

        <div class="row">
          <div class="col-sm-12">
            <div class="card card-default">
              <div class="card-header">
                <h3 class="card-title">Edit Student</h3>
                <div class="card-tools">
                  <a href="<?php echo base_url()?>admin/students/admitted_student" class="btn btn-primary btn-sm"><i class="fa fa-eye" aria-hidden="true"></i> View Student</a>
                </div>
              </div>
              <!-- /.card-header -->
              <?php echo form_open_multipart('admin/students/update_adminssion_student/'.$student->user_id, ['id' => 'inq_form']); ?>
              <div class="card-body p-0">
                 <div class="bs-stepper">
                    <div class="bs-stepper-header" role="tablist">
                       <div class="step active" data-target="#personal-information">
                          <button type="button" class="step-trigger" role="tab" aria-controls="logins-part" id="logins-part-trigger">
                          <span class="bs-stepper-circle">1</span>
                          <span class="bs-stepper-label">Personal Information</span>
                          </button>
                       </div>
                       <div class="line"></div>
                       <div class="step" data-target="#communication-details">
                          <button type="button" class="step-trigger" role="tab" aria-controls="information-part" id="information-part-trigger">
                          <span class="bs-stepper-circle">2</span>
                          <span class="bs-stepper-label">Communication Details</span>
                          </button>
                       </div>
                       <div class="line"></div>
                       <div class="step" data-target="#know-us">
                          <button type="button" class="step-trigger" role="tab" aria-controls="information-part" id="information-part-trigger">
                          <span class="bs-stepper-circle">4</span>
                          <span class="bs-stepper-label">Image Upload</span>
                          </button>
                       </div>
                       <div class="line"></div>
                       <div class="step" data-target="#course-details">
                          <button type="button" class="step-trigger" role="tab" aria-controls="information-part" id="information-part-trigger">
                          <span class="bs-stepper-circle">3</span>
                          <span class="bs-stepper-label">Student Onboard</span>
                          </button>
                       </div>
                       

                    </div>
                    <div class="bs-stepper-content">
                      
                       <div id="personal-information" class="content active" role="tabpanel" aria-labelledby="logins-part-trigger">
                        <div class="row">
                          <div class="col-sm-3">
                            <div class="form-group">
                               <label for="exampleInputEmail1">Student First Name <span style="color:red">*</span></label>
                               <input type="text" class="form-control" placeholder="Enter Student First Name" required id="student_name_f" name="user_f_name" value="<?php echo $student->user_f_name ?>">
                            </div>
                          </div>
                          <div class="col-sm-3">
                            <div class="form-group">
                               <label for="exampleInputEmail1">Student Middle Name </label>
                               <input type="text" class="form-control" placeholder="Enter Student Middle Name" id="student_name" name="user_m_name" value="<?php echo $student->user_m_name ?>">
                            </div>
                          </div>
                          <div class="col-sm-3">
                            <div class="form-group">
                               <label for="exampleInputEmail1">Student Last Name <span style="color:red">*</span></label>
                               <input type="text" class="form-control" placeholder="Enter Student Last Name" required id="student_name_l" name="user_l_name" value="<?php echo $student->user_l_name ?>">
                            </div>
                          </div>
                          <div class="col-sm-3">
                            <div class="form-group">
                               <label for="exampleInputEmail1">Student Qualification <span style="color:red">*</span></label>
                               <input type="text" class="form-control" placeholder="Enter Student Qualification" name="user_qualification" id="user_qualification" value="<?php echo $student->user_qualification ?>">
                            </div>
                          </div>
                          <div class="col-sm-6">
                            <div class="form-group">
                               <label for="exampleInputEmail1">Student College/School <span style="color:red">*</span></label>
                               <input type="text" class="form-control" placeholder="Enter College/School Name" name="user_school_college_name" id="user_school_college_name" value="<?php echo $student->user_school_college_name ?>">
                            </div>
                          </div>
                          <div class="col-sm-6">
                            <div class="form-group">
                               <label for="exampleInputEmail1">Student Aadhar No <span style="color:red">*</span></label>
                               <input required type="text" class="form-control" placeholder="Enter Aadhar No." name="user_aadhar_no" id="user_aadhar_no" value="<?php echo $student->user_aadhar_no ?>">
                            </div>
                          </div>
                          <div class="col-sm-6">
                            <div class="form-group">
                               <label for="exampleInputEmail1">Student Birth date <span style="color:red">*</span></label>
                               <input required type="date" class="form-control" placeholder="Enter Aadhar No." name="user_do" id='user_dob' value="<?php echo $student->user_dob ?>" max="<?php echo date('Y-m-d')?>">
                            </div>
                          </div>
                          <div class="col-sm-6">
                            <div class="form-group">
                               <label for="exampleInputEmail1">Student Gender <span style="color:red">*</span></label>
                               <select required id="user_gender" class="form-control" placeholder="Enter Aadhar No." name="user_gende">
                                <option value="">Select</option>
                                <option <?php if($student->user_gender == 'Male'){echo 'selected';} ?> value="Male">Male</option>
                                <option <?php if($student->user_gender == 'Female'){echo 'selected';} ?> value="Feamle">Feamle</option>
                               </select>
                            </div>
                          </div>
                          <div class="col-sm-4 d-none">
                            <div class="form-group">
                               <label for="exampleInputEmail1">Student Admission Date <span style="color:red">*</span></label>
                               <input type="date" class="form-control" placeholder="Enter Aadhar No." name="user_created_at" value="<?php echo $student->user_created_at ?>">
                            </div>
                          </div>
                          <div class="col-sm-12">
                            <button type="button" class="btn btn-primary" onclick="stepper.next()">Next</button>
                          </div>
                        </div>
                       </div>

                       <div id="communication-details" class="content" role="tabpanel" aria-labelledby="information-part-trigger">
                          <div class="row">
                          <div class="col-sm-6">
                            <div class="form-group">
                               <label for="exampleInputEmail1">Student Mobile No <span style="color:red">*</span></label>
                               <input type="number" class="form-control" placeholder="Enter Student Mobile No" required id="student_mobile" name="user_mobile" value="<?php echo $student->user_mobile ?>">
                            </div>
                          </div>
                          <div class="col-sm-6">
                            <div class="form-group">
                               <label for="exampleInputEmail1">Student Email ID <span style="color:red">*</span></label>
                               <input required type="email" class="form-control" placeholder="Enter Student Email ID" name="user_email" id="user_email" value="<?php echo $student->user_email ?>">
                            </div>
                          </div>
                          <div class="col-sm-5">
                            <div class="form-group">
                               <label for="exampleInputEmail1">Student Address Pin Code <span style="color:red">*</span></label>
                               <input required type="number" class="form-control" placeholder="Enter Student Address Pin Code" name="user_pin_code" id="pin_code" value="<?php echo $student->user_pin_code ?>">
                            </div>
                          </div>
                          <div class="col-sm-7">
                            <div class="form-group">
                               <label for="exampleInputEmail1">Student Village <span style="color:red">*</span></label>
                               <input required type="text" class="form-control" placeholder="Enter Student Village" name="user_village" id="user_village" value="<?php echo $student->user_village ?>">
                            </div>
                          </div>
                          <div class="col-sm-4">
                            <div class="form-group">
                               <label for="exampleInputEmail1">Student City <span style="color:red">*</span></label>
                               <select required type="text" class="form-control" name="user_taluka" id="area">
                                  <option value="<?php echo $student->user_taluka ?>"><?php echo $student->user_taluka ?></option>
                               </select>
                            </div>
                          </div>
                          <div class="col-sm-4">
                            <div class="form-group">
                               <label for="exampleInputEmail1">Student Dist <span style="color:red">*</span></label>
                               <input type="text" class="form-control" placeholder="Enter Student Dist" name="user_dist" id="city" readonly value="<?php echo $student->user_dist ?>" required>
                            </div>
                          </div>
                          <div class="col-sm-4">
                            <div class="form-group">
                               <label for="exampleInputEmail1">Student State <span style="color:red">*</span></label>
                               <input type="text" class="form-control" placeholder="Enter Student Dist" name="user_state" id="state" readonly value="<?php echo $student->user_state ?>" required>
                            </div>
                          </div>
                          <div class="col-sm-12">
                            <button type="button"  class="btn btn-primary" onclick="stepper.previous()">Previous</button>
                            <button type="button" style="float:right" class="btn btn-primary" onclick="stepper.next()">Next</button>
                          </div>
                        </div>
                       </div>

                       <div id="know-us" class="content" role="tabpanel" aria-labelledby="information-part-trigger">
                          <div class="row">
                            <div class="col-sm-12">

                              <div class="row image-wrapper">
                                <div class="col-sm-6 col-6">
                                  <div class="d-flex align-items-center justify-content-center">
                                    <div id="my_camera"></div>
                                  </div>
                                  <input type="button" class="btn btn-warning mt-2" value="Take Snapshot" onClick="take_snapshot()">
                                  <input type="hidden" name="image" class="image-tag">
                                </div>
                                <div class="col-md-6 col-6">
                                  <?php if($student->user_photo): ?>
                                    <div id="results"><img src="<?php echo base_url() ?><?php echo $student->user_photo ?>" height="100px"></div>
                                  <?php else: ?>
                                    <div id="results">Your Captured/Upload image will appear here...</div>
                                  <?php endif; ?>
                                    <input type="file" name="file_image" class="form-control mt-5" accept="image/*" id="imgInp">
                                </div>
                              </div>
                            </div>

                            <div class="col-sm-12 mt-5">
                              <button type="button"  class="btn btn-primary" onclick="stepper.previous()">Previous</button>
                              <button type="button" style="float:right" class="btn btn-primary" onclick="stepper.next()">Next</button>
                              
                            </div>
                          </div>
                        </div>
                       

                       <div id="course-details" class="content " role="tabpanel" aria-labelledby="information-part-trigger">
                          <div class="row">
                            <div class="col-sm-8">
                              <div class="form-group">
                                <label for="exampleInputEmail1">Multiple Course Admission</label>
                                <select type="text" class="form-control" placeholder="Enter Student Dist" id="course_list">
                                  <option value="">Select</option>
                                  <?php foreach ($all_course as $key => $course_d):?>
                                    <option value="<?php echo $course_d->id; ?>"><?php echo $course_d->title; ?></option>
                                  <?php endforeach; ?>
                                </select>
                              </div>
                            </div>
                            <div class="col-sm-4">
                              <button type="button" onclick="add_new_course()" style="position:absolute;bottom:20px" class="btn btn-success align-self-end mt-auto">Add Course</button>
                            </div>
                            <div class="col-sm-12">
                              <table id="example2" class="table table-bordered table-striped">
                                <thead>
                                <tr>
                                  <td>No</td>
                                  <th>Course Name</th>
                                  <th>Batch</th>
                                  <th>Admission Date</th>
                                  <th>Payment/Batch Status</th>
                                </tr>
                                </thead>
                                <tbody>
                                <?php $b=1; foreach ($course_data as $course):?>
                                <tr>
                                  <td><?php echo $b; ?></td>
                                  <td><?php echo $course->title ?></td>
                                  <th>
                                    <select class="form-control" id="course_admission_batch_<?php echo $course->st_course_id; ?>">
                                      <option value="">Select A Batch *</option>
                                    <?php foreach ($all_batch as $key => $batch):?>
                                      <option <?php if($batch->batch_id == $course->st_course_batch){echo 'selected';}?> value="<?php echo $batch->batch_id; ?>"><?php echo $batch->batch_name; ?></option>
                                    <?php endforeach;?>
                                    </select>
                                    <button class="btn btn-success btn-xs" type="button" onclick="update_batch_data(<?php echo $course->st_course_id; ?>, <?php echo $course->st_course_status; ?>)">Update</button>
                                  </th>
                                  <td><input class="form-control" type="date" value="<?php echo $course->st_course_date ?>" id="course_admission_date_<?php echo $course->st_course_id; ?>">
                                    <button class="btn btn-success btn-xs" type="button" onclick="update_admission_date(<?php echo $course->st_course_id; ?>)">Update</button>
                                </td>
                                  <td>
                                    <?php if($course->st_course_status == 0): ?>
                                      <button data-toggle="modal" data-target="#payment_model<?php echo $course->st_course_id; ?>" type="button" class="btn btn-warning btn-xs"><b>Pay Course Reg. Fee </b></button>
                                    <?php else: ?>
                                      <span class="badge badge-success">Payment Complete</span>
                                    <?php endif;?>
                                    <br/> 
                                    <?php if($course->st_course_batch == 0): ?>
                                      <span class="badge badge-danger">Batch Not Assign</span>
                                    <?php else: ?>
                                      <span class="badge badge-success">Batch Assigned</span>
                                    <?php endif;?>
                                  </td>
                                </tr>
                                <?php $b++; ?>
                                <?php endforeach; ?>
                                </tbody>
                              </table>
                            </div>
                            <div class="col-sm-12">
                              <button type="button"  class="btn btn-primary" onclick="stepper.previous()">Previous</button>
                              <button type="button" onclick="form_submit()" style="float:right" class="btn btn-success">Submit</button>
                            </div>
                          </div>
                       </div>


                        <?php echo form_close();?>
                       </div>
                    </div>
                 </div>
              </div>
            </div>
          </div>
      </div>
    </div>
  </section>
</div>
<?php $b=1; foreach ($course_data as $course):?>
  <?php if($course->st_course_status == 0): ?>
    <div class="modal fade" id="payment_model<?php echo $course->st_course_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">Your Current Wallet Balance : <b><?php echo user()->user_wallet_balance; ?></b>
              <br/>
             Course Price : <b><?php if($course->discounted_price){echo $main_c_price = $course->discounted_price;}else{echo $main_c_price = $course->course_price;}; ?></b>
            </h5>

            <button type="button" class="close" data-dismiss="modal" aria-label="Close">
              <span aria-hidden="true">&times;</span>
            </button>
          </div>
          <form id>
          <div class="modal-body">
            <table class="table-s">
              <tr>
                <th class="text-center">Description</th>
                <th class="text-center">Amount</th>
              </tr>
              <tr>
                <td>Student Registration Fee <b>(<?php echo $percantage_amt = pack_details_by_id(atp_details()->user_atp_current_package)->package_student_reg_fee; ?>%)</b></td>
                <td><b class="float-right">
                  <?php echo $main_amt = ($percantage_amt / 100) * $main_c_price; ?></b>
                </td>
              </tr>
              <tr>
                <td>Do You Want Digital Certificate 
                  <select onclick="calculate(this.value, <?php echo $course->st_course_id; ?>, <?php echo $main_amt; ?>)" id="is_digital_certificate_<?php echo $course->st_course_id; ?>">
                    <option value="2">No</option>
                    <option value="1">Yes</option>
                  </select>
                </td>
                <td><b class="float-right" id="digi_amt_<?php echo $course->st_course_id; ?>">0</b></td>
              </tr>
              <tr>
                <td><b>Total</b></td>
                <td><b class="float-right" id="main_amt_<?php echo $course->st_course_id; ?>"><?php echo $main_amt; ?></b></td>
              </tr>
            </table>
            <input type="hidden" name="main_amt" id="amt_main_<?php echo $course->st_course_id; ?>" value="<?php echo $main_amt; ?>">
            <input type="hidden" name="st_course_id" value="<?php echo $course->st_course_id; ?>">
          </div>
          <div class="modal-footer">
            <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
            <button type="button" onclick="student_course_payment(<?php echo $course->st_course_id; ?>)" class="btn btn-primary">Pay Now</button>
          </div>
        </div>
      </div>
    </div>
  <?php endif; 
endforeach; ?>
<script type="text/javascript">
function calculate(val, id, main_amt) 
{
    if(val == 2)
    {
      $('#digi_amt_'+id).html(0)
      $('#main_amt_'+id).html(main_amt);
      $('#amt_main_'+id).val(main_amt);
    }
    else
    {
      $('#digi_amt_'+id).html(<?php echo pack_details_by_id(atp_details()->user_atp_current_package)->package_digital_certificate_price; ?>);
      $('#main_amt_'+id).html(main_amt + <?php echo pack_details_by_id(atp_details()->user_atp_current_package)->package_digital_certificate_price; ?>);
      $('#amt_main_'+id).val(main_amt + <?php echo pack_details_by_id(atp_details()->user_atp_current_package)->package_digital_certificate_price; ?>);

    }
}
</script>


<style type="text/css">
.table-s, .table-s td, .table-s th {
  border: 1px solid black;
  padding: 5px;
}

.table-s {
  border-collapse: collapse;
  width: 100%;
}
#my_camera
{
  border:2px dotted;
}
.bs-stepper-content
{
  padding:20px;
}
.image-wrapper {
  text-align: center;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
}
</style>
<script language="JavaScript">
function add_new_course() 
{
  var course_id = $('#course_list').val();
  var student_id = "<?php echo $student->user_id; ?>";
  var atp_id = "<?php echo $student->user_atp; ?>";
  if(confirm("Are you sure you want to Payment?"))
  {
      $.ajax({
        beforeSend: function() {
           $(".loader").show();
        },
        type: "POST",
        dataType:"JSON",
        async: true,
        data : {course_id:course_id, student_id:student_id, atp_id:atp_id},
        url: '<?php echo base_url(); ?>/admin/students/add_new_course_for_student',
        success: function (data) 
        {
            if(data == 1)
            {
              swal('Done!', "Course Successfully Added", 'success');
              $("#example2").load(location.href + " #example2");
              $(".loader").hide();
            }
            else
            {
              swal('Oops!', "Course Already Added", 'error');
              $(".loader").hide();
            }
            
        },
        error: function () {
          swal('Oops!', "Course Already Added", 'error');
          $(".loader").hide();
        }
      });
  }
  else
  {
      return false;
  }
}
function student_course_payment(e) 
{
  if(confirm("Are you sure you want to Payment?"))
  {
    var is_digital_certificate = $('#is_digital_certificate_'+e).val();
    var amt_main = $('#amt_main_'+e).val();
    var course_id = e;
      $.ajax({
        beforeSend: function() {
          $('#payment_model'+e).modal('hide');
           $(".loader").show();
        },
        type: "POST",
        dataType:"JSON",
        async: true,
        data : {is_digital_certificate:is_digital_certificate, amt_main:amt_main, course_id:course_id},
        url: '<?php echo base_url(); ?>/admin/students/student_course_payment',
        success: function (data) 
        {
            swal('Done!', "Payment Done", 'success');
            $("#example2").load(location.href + " #example2");
            $(".loader").hide();
        },
        error: function () {
          $(".loader").hide();
        }
      });
  }
  else
  {
      return false;
  }
}
imgInp.onchange = evt => {
  const [file] = imgInp.files
  if (file) {
    document.getElementById('results').innerHTML = '<img height="100px" src="'+URL.createObjectURL(file)+'"/>';
  }
}
Webcam.set({
    width: 100,
    height: 140,
    image_format: 'jpeg',
    jpeg_quality: 90,
    force_flash: false
});
Webcam.attach( '#my_camera' );
function take_snapshot() {
    Webcam.snap( function(data_uri) {
        $(".image-tag").val(data_uri);
        document.getElementById('results').innerHTML = '<img src="'+data_uri+'"/>';
    });
}
function form_submit() 
{
  var name_f = $('#student_name_f').val();
  var name_l = $('#student_name_l').val();
  var user_qualification = $('#user_qualification').val();
  var user_school_college_name = $('#user_school_college_name').val();
  var user_aadhar_no = $('#user_aadhar_no').val();
  var user_dob = $('#user_dob').val();
  var user_gender = $('#user_gender').val();
  var student_mobile = $('#student_mobile').val();
  var user_email = $('#user_email').val();
  var pin_code = $('#pin_code').val();
  var user_village = $('#user_village').val();
  var area = $('#area').val();

  if(name_f == '')
  {
    swal('Opps!', 'Please Enter Student First Name', 'error');
    return false;
  }
  if(name_l == '')
  {
    swal('Opps!', 'Please Enter Student Last Name', 'error');
    return false;
  }
  if(user_qualification == '')
  {
    swal('Opps!', 'Please Enter Student Qulification.', 'error');
    return false;
  }
  if(user_school_college_name == '')
  {
    swal('Opps!', 'Please Enter Student School/College Name.', 'error');
    return false;
  }
  if(user_aadhar_no == '')
  {
    swal('Opps!', 'Please Enter Student Aadhar Card No.', 'error');
    return false;
  }
  if(user_dob == '')
  {
    swal('Opps!', 'Please Enter Student date of Birth.', 'error');
    return false;
  }
  if(user_gender == '')
  {
    swal('Opps!', 'Please Select Student Gender.', 'error');
    return false;
  }
  if(student_mobile == '')
  {
    swal('Opps!', 'Please Enter Student Mobile.', 'error');
    return false;
  }
  if(user_email == '')
  {
    swal('Opps!', 'Please Enter Student Email ID.', 'error');
    return false;
  }
  if(pin_code == '')
  {
    swal('Opps!', 'Please Enter Student Address Pin Code.', 'error');
    return false;
  }
  if(user_village == '')
  {
    swal('Opps!', 'Please Enter Student Village Address.', 'error');
    return false;
  }
  if(area == '')
  {
    swal('Opps!', 'Please Select Student Area.', 'error');
    return false;
  }

  $( "#inq_form" ).submit();

}

document.addEventListener('DOMContentLoaded', function () {
  window.stepper = new Stepper(document.querySelector('.bs-stepper'))
});
</script>
<script src="<?php echo admin_css(); ?>plugins/bs-stepper/js/bs-stepper.min.js"></script>

<script type="text/javascript">
$('body').on('change', '#pin_code', function () {
    let pin_code = $('#pin_code').val();
    if (pin_code == 0) {
            swal ( "Oops" ,  "Please Enter Pin Code!" ,  "warning" );
        return false;
    }
    $.ajax({
      beforeSend: function() {
         $(".loader").show();
      },
      type: "GET",
      dataType:"JSON",
      async: true,
      url: '<?php echo base_url(); ?>/admin/admin/get_aadress_detaile_by_pin_code/'+pin_code,
      success: function (data) 
      {
          $('#area').html(data.area);
          $('#city').val(data.city);
          $('#state').val(data.state);
          $(".loader").hide();
      },
      error: function () {
        $(".loader").hide();
      }
    });
});
$(function () {
    $("#example2").DataTable({
      "responsive": true, "lengthChange": true, "autoWidth": false,  "searching": false, info: false, paging: false,
    }).buttons().container().appendTo('#example1_wrapper .col-md-6:eq(0)');
  });
function update_admission_date(id) 
{
  var adm_date = $('#course_admission_date_'+id).val();
  $.ajax({
    beforeSend: function() {
       $(".loader").show();
    },
    type: "POST",
    dataType:"JSON",
    async: true,
    data: {adm_date:adm_date, id:id},
    url: '<?php echo base_url(); ?>/admin/students/update_admission_date',
    success: function (data) 
    {
        swal('Done!', 'Admissio Date Successfully Update', 'success');
        $(".loader").hide();
    },
    error: function () {
      $(".loader").hide();
    }
  });
}

function update_batch_data(id, status) 
{
  if(status == 0)
  {
    swal('Oops!', 'Please Pay Course Registration Fee First', 'error');
  }
  else
  {
    var batch = $('#course_admission_batch_'+id).val();
    if(!batch)
    {
      swal('Oops!', 'Please Select A Batch First', 'error');
      return false;
    }
    $.ajax({
      beforeSend: function() {
         $(".loader").show();
      },
      type: "POST",
      dataType:"JSON",
      async: true,
      data: {batch:batch, id:id},
      url: '<?php echo base_url(); ?>/admin/students/update_admission_batch',
      success: function (data) 
      {
          swal('Done!', 'Batch Successfully Update', 'success');
          $("#example2").load(location.href + " #example2");
          $(".loader").hide();
      },
      error: function () {
        $(".loader").hide();
      }
    });
  }
}
</script>