 <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">Refund Fees</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="#">Fees Management</a></li>
              <li class="breadcrumb-item active">Refund Fees</li>

            </ol>
          </div><!-- /.col -->
        </div><!-- /.row -->
      </div><!-- /.container-fluid -->
    </div>
    <!-- /.content-header -->
    <?php echo form_open(base_url().'admin/fees_management/update_refund');?>
    <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">Refund Fees for <b><?php echo $student->user_name; ?></h3>
              </div>
              <!-- /.card-header -->
              <div class="card-body">
                <div class="row">

                  <div class="col-md-12">
                    <div class="form-group">
                       <label for="inputEmail" class="col-sm-12 col-form-label">Select Course <span class="required">*</span></label>
                       <div class="col-sm-12">
                          <select class="form-control" onchange="get_course_price(this.value)" name="fee_student_course" placeholder="Enter Notice Content" required="required" id="fee_student_course">
                            <option value="">Select</option>
                          </select>
                       </div>
                    </div>
                  </div>

                  <div class="col-md-2">
                    <div class="form-group">
                       <label for="inputEmail" class="col-sm-12 col-form-label">Course Price <span class="required">*</span></label>
                       <div class="col-sm-12">
                          <input class="form-control"  name="fee_student_course_price" placeholder="Enter Course Price" required="required" id="course_price" readonly>
                       </div>
                    </div>
                  </div>
                  <div class="col-md-2">
                    <div class="form-group">
                       <label for="inputEmail" class="col-sm-12 col-form-label">Total Amount <span class="required">*</span></label>
                       <div class="col-sm-12">
                          <input class="form-control"  name="fee_student_course_main_price"  required="required" id="main_price" readonly>
                       </div>
                    </div>
                  </div>
                  <div class="col-md-2">
                    <div class="form-group">
                       <label for="inputEmail" class="col-sm-12 col-form-label">Total Paid Amount <span class="required">*</span></label>
                       <div class="col-sm-12">
                          <input class="form-control"  name="fee_student_course_due"  required="required" id="due_ammount" readonly>
                       </div>
                    </div>
                  </div>
                  <div class="col-md-3">
                    <div class="form-group">
                       <label for="inputEmail" class="col-sm-12 col-form-label">Processing Amount</label>
                       <div class="col-sm-12">
                          <input class="form-control" onkeyup="calculate()" name="st_course_refund_process_fee"  id="processing_amount" placeholder="Enter Processing Amount">
                       </div>
                    </div>
                  </div>
                  <div class="col-md-3">
                    <div class="form-group">
                       <label for="inputEmail" class="col-sm-12 col-form-label">Refund Amount (Rs.)<span class="required">*</span></label>
                       <div class="col-sm-12">
                          <input class="form-control" name="st_course_refund_amount" placeholder="Refund Amount" required="required" id="down_payment" readonly>
                       </div>
                    </div>
                  </div>
                  <script type="text/javascript">
                    function calculate() 
                    {
                      var due_amount = $('#due_ammount').val();
                      var process_amt = $('#processing_amount').val();
                      var due_amt = due_amount - process_amt;
                      $('#down_payment').val(due_amt);
                    }
                  </script>
                  
                  <input class="form-control" type="hidden" id="due_ammount_2">

                  <input type="hidden" class="form-control"  name="fee_student_id" value="<?php echo $student->user_id; ?>">

                  <div class="col-md-12">
                    <div class="form-group">
                       <button name="form1" style="float: right" type="submit" class="btn btn-success btn-sm">Save</button>
                    </div>
                  </div>
                  
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </section>

   
    <?php echo form_close();?>
    <!-- /.content -->
  </div>
<script type="text/javascript">
$(function () {
    get_course_by_student_id(<?php echo $student->user_id; ?>)
  });

function get_course_by_student_id(e) 
{
  $.ajax({
    beforeSend: function() {
       $(".loader").show();
    },
    type: "GET",
    dataType:"JSON",
    async: true,
    url: '<?php echo base_url(); ?>admin/students/get_course_by_student_id_for_refund/'+e,
    success: function (data) 
    {
        $('#fee_student_course').html(data.option);
        $(".loader").hide();
    },
    error: function (e) {
      console.log(e.responseText)
      $(".loader").hide();
    }
  });
}
function get_course_price(e) 
{
  var st_id = '<?php echo $student->user_id; ?>';
  $.ajax({
    beforeSend: function() {
       $(".loader").show();
    },
    type: "GET",
    dataType:"JSON",
    async: true,
    url: '<?php echo base_url(); ?>admin/students/get_course_price_by_course_id_for_refund/'+e+'/'+st_id,
    success: function (data) 
    {
        $('#course_price').val(data.price);
        $('#main_price').val(data.main_price);
        $('#down_payment').val(data.due_ammount);
        $('#due_ammount').val(data.due_ammount);
        $('#due_ammount_2').val(data.due_ammount);
        $('#no_instalment').val(data.no_instalment);
        $('#no_days').val(data.no_days);
        $('#start_date').val(data.start_date);
        $("#exam_approve").val(data.exam_approve);
        if(data.no_instalment > 0)
        {
          get_instalment_table_by_user_id(st_id, e);
        }
        
        $(".loader").hide();
    },
    error: function (e) {
      console.log(e.responseText)
      $(".loader").hide();
    }
  });
}

function get_instalment_table_by_user_id(st_id, e) 
{
    $.ajax({
      beforeSend: function() {
         $(".loader").show();
      },
      type: "GET",
      dataType:"JSON",
      async: true,
      url: '<?php echo base_url(); ?>admin/fees_management/get_instalment_table_by_user_id/'+e+'/'+st_id,
      success: function (data) 
      {
          $('#data').html(data);
          $(".loader").hide();
      },
      error: function (e) {
        console.log(e.responseText)
        $(".loader").hide();
      }
  });
}
</script>
<style type="text/css">
.check-box
{

}
</style>