<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">

 <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 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">Edit enquiry</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 Enquiry</h3>
                <div class="card-tools">
                  <a href="<?php echo base_url()?>admin/students/all_enquiry" class="btn btn-primary btn-sm"><i class="fa fa-eye" aria-hidden="true"></i> View Enquiry</a>
                </div>
              </div>
              <!-- /.card-header -->
              <?php echo form_open('admin/students/update_enquiry/'.$enquiry->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="#Follow-up-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">Follow-up 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">How you know us?</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 $enquiry->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 $enquiry->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 $enquiry->user_l_name ?>">
                            </div>
                          </div>
                          <div class="col-sm-3">
                            <div class="form-group">
                               <label for="exampleInputEmail1">Student Qualification</label>
                               <input type="text" class="form-control" placeholder="Enter Student Qualification" name="user_qualification" value="<?php echo $enquiry->user_qualification ?>">
                            </div>
                          </div>
                          <div class="col-sm-6">
                            <div class="form-group">
                               <label for="exampleInputEmail1">Student College/School</label>
                               <input type="text" class="form-control" placeholder="Enter College/School Name" name="user_school_college_name" value="<?php echo $enquiry->user_school_college_name ?>">
                            </div>
                          </div>
                          <div class="col-sm-6">
                            <div class="form-group">
                               <label for="exampleInputEmail1">Student Aadhar No</label>
                               <input type="text" class="form-control" placeholder="Enter Aadhar No." name="user_aadhar_no" value="<?php echo $enquiry->user_aadhar_no ?>">
                            </div>
                          </div>
                          <div class="col-sm-6">
                            <div class="form-group">
                               <label for="exampleInputEmail1">Student Birth date</label>
                               <input type="date" class="form-control" placeholder="Enter Aadhar No." name="user_dob" value="<?php echo $enquiry->user_dob ?>">
                            </div>
                          </div>
                          <div class="col-sm-6">
                            <div class="form-group">
                               <label for="exampleInputEmail1">Student Gender</label>
                               <select class="form-control" placeholder="Enter Aadhar No." name="user_gender">
                                <option <?php if($enquiry->user_dob == 'Male'){echo 'selected';} ?> value="Male">Male</option>
                                <option <?php if($enquiry->user_dob == 'Female'){echo 'selected';} ?> value="Feamle">Feamle</option>
                               </select>
                            </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 $enquiry->user_mobile ?>">
                            </div>
                          </div>
                          <div class="col-sm-6">
                            <div class="form-group">
                               <label for="exampleInputEmail1">Student Email ID</label>
                               <input type="email" class="form-control" placeholder="Enter Student Email ID" name="user_email" value="<?php echo $enquiry->user_email ?>">
                            </div>
                          </div>
                          <div class="col-sm-5">
                            <div class="form-group">
                               <label for="exampleInputEmail1">Student Address Pin Code</label>
                               <input type="number" class="form-control" placeholder="Enter Student Address Pin Code" name="user_pin_code" id="pin_code" value="<?php echo $enquiry->user_pin_code ?>">
                            </div>
                          </div>
                          <div class="col-sm-7">
                            <div class="form-group">
                               <label for="exampleInputEmail1">Student Village</label>
                               <input type="text" class="form-control" placeholder="Enter Student Village" name="user_village" value="<?php echo $enquiry->user_village ?>">
                            </div>
                          </div>
                          <div class="col-sm-4">
                            <div class="form-group">
                               <label for="exampleInputEmail1">Student City</label>
                               <select type="text" class="form-control" name="user_taluka" id="area">
                                  <option value="<?php echo $enquiry->user_taluka ?>"><?php echo $enquiry->user_taluka ?></option>
                               </select>
                            </div>
                          </div>
                          <div class="col-sm-4">
                            <div class="form-group">
                               <label for="exampleInputEmail1">Student Dist</label>
                               <input type="text" class="form-control" placeholder="Enter Student Dist" name="user_dist" id="city" readonly value="<?php echo $enquiry->user_dist ?>">
                            </div>
                          </div>
                          <div class="col-sm-4">
                            <div class="form-group">
                               <label for="exampleInputEmail1">Student State</label>
                               <input type="text" class="form-control" placeholder="Enter Student Dist" name="user_state" id="state" readonly value="<?php echo $enquiry->user_state ?>">
                            </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="Follow-up-details" class="content" role="tabpanel" aria-labelledby="information-part-trigger">
                          <div class="row">
                          <div class="col-sm-12">
                            <div class="form-group">
                               <label for="exampleInputEmail1">Course Interested <span style="color:red">*</span></label>
                               <select class="form-control select2" required id="student_course" name="course_interest[]" multiple="multiple" data-placeholder="You can choose multiple courses">
                                  <option value=""></option>
                                  <?php foreach ($all_course as $course): ?>
                                    <option
                                    <?php foreach (json_decode($enquiry->course_interest) as $course_interest): ?>
                                      <?php if($course_interest == $course->id){echo 'selected';}?>
                                    <?php endforeach ?>

                                     value="<?php echo $course->id; ?>"><?php echo $course->title; ?></option>
                                  <?php endforeach ?>
                               </select>
                            </div>
                          </div>
                          <div class="col-sm-6">
                            <div class="form-group">
                               <label for="exampleInputEmail1">Interest level</label>
                               <select class="form-control" placeholder="Enter Aadhar No." name="inq_interest">
                                <option <?php if($enquiry->inq_interest == 'Hot'){echo 'selected';}?> value="Hot">Hot</option>
                                <option <?php if($enquiry->inq_interest == 'Warm'){echo 'selected';}?> value="Warm">Warm</option>
                                <option <?php if($enquiry->inq_interest == 'Cold'){echo 'selected';}?> value="Cold">Cold</option>
                                <option <?php if($enquiry->inq_interest == 'Junk'){echo 'selected';}?> value="Junk">Junk</option>
                               </select>
                            </div>
                          </div>
                          <div class="col-sm-6">
                            <div class="form-group">
                               <label for="exampleInputEmail1">Requires Demo Lecture</label>
                               <select class="form-control" placeholder="Enter Aadhar No." name="inq_req_demo">
                                <option <?php if($enquiry->inq_req_demo == 'Yes'){echo 'selected';} ?> value="Yes">Yes</option>
                                <option <?php if($enquiry->inq_req_demo == 'No'){echo 'selected';} ?> value="No">No</option>
                               </select>
                            </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-3">
                            <div class="form-group">
                               <label for="exampleInputEmail1">Lead Source <span style="color:red">*</span></label>
                               <select class="form-control" required id="inq_lead_source" name="inq_lead_source">
                                  <option value="">Select</option>
                                  <?php foreach ($all_lead as $lead): ?>
                                    <option <?php if($enquiry->inq_lead_source == $lead->lead_name_id){echo 'selected';}?> value="<?php echo $lead->lead_name_id; ?>"><?php echo $lead->lead_name; ?></option>
                                  <?php endforeach ?>
                               </select>
                            </div>
                          </div>
                          <div class="col-sm-3">
                            <div class="form-group">
                               <label for="exampleInputEmail1">Ref. name</label>
                               <input class="form-control" placeholder="Enter Ref. name" name="inq_ref_no" value="<?php echo $enquiry->inq_ref_no ?>">
                            </div>
                          </div>
                          <div class="col-sm-3">
                            <div class="form-group">
                               <label for="exampleInputEmail1">Assign To <span style="color:red">*</span></label>
                               <select class="form-control" name="assign_to" id="assign_to" required>
                                <option value="">Select</option>
                                <?php foreach ($all_employee as $employee): ?>
                                  <option <?php if($enquiry->assign_to == $employee->user_id){echo 'selected';} ?> value="<?php echo $employee->user_id; ?>"><?php echo $employee->user_name; ?> (<?php echo $employee->user_role; ?>)</option>
                                <?php endforeach ?>
                               </select>
                            </div>
                          </div>
                          <div class="col-sm-3">
                            <div class="form-group">
                               <label for="exampleInputEmail1">Enquiry Date <span style="color:red">*</span></label>
                               <input class="form-control" type="date" id="inq_date" placeholder="Enter Ref. name" name="inq_date" required value="<?php echo $enquiry->inq_date ?>">
                            </div>
                          </div>
                          <div class="col-sm-12">
                            <div class="form-group">
                               <label for="exampleInputEmail1">Note <small>(If Any)</small></label>
                               <textarea class="form-control" placeholder="Enter Note" name="inq_note"><?php echo $enquiry->inq_note ?></textarea>
                            </div>
                          </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>
                        <?php echo form_close();?>
                       </div>
                    </div>
                 </div>
              </div>
            </div>
          </div>
      </div>
    </div>
  </section>
</div>
<script type="text/javascript">
function form_submit() 
{
  var name_f = $('#student_name_f').val();
  var name_l = $('#student_name_l').val();
  var student_mobile = $('#student_mobile').val();
  var student_course = $('#student_course').val();
  var inq_lead_source = $('#inq_lead_source').val();
  var assign_to = $('#assign_to').val();
  var inq_date = $('#inq_date').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(student_mobile == '')
  {
    swal('Opps!', 'Please Enter Student Mobile No.', 'error');
    return false;
  }
  if(student_course == '')
  {
    swal('Opps!', 'Please Enter Student Course.', 'error');
    return false;
  }
  if(inq_lead_source == '')
  {
    swal('Opps!', 'Please Select Lead Source.', 'error');
    return false;
  }
  if(assign_to == '')
  {
    swal('Opps!', 'Please Select Assign To.', 'error');
    return false;
  }
  if(inq_date == '')
  {
    swal('Opps!', 'Please Select Enquiry Date', '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();
      }
    });
});

</script>