
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
    <div class="content-header">
      <div class="container-fluid">
         <div class="row mb-2">
            <div class="col-sm-6">
               <h1 class="m-0 text-dark">Update Workforce </h1>
            </div>
            <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="#">Workforce Management</a></li>
                  <li class="breadcrumb-item active">Update Workforce  </li>
               </ol>
            </div>
         </div>
      </div>
   </div>
   <section class="content">
      <div class="container">
         <div class="row"> 
            <div class="col-md-12 col-lg-12">
               <div class="container-fluid">
                  <div class="card card-default">
                     <div class="card-header">
                        <h3 class="card-title">Update Workforce </h3>
                        <div class="float-right">
                           <a href="<?php echo base_url() ?>/admin/employee/view_all_employee" class="btn btn-success btn-sm">View All Workforce </a>
                        </div>
                     </div>
                     <?php echo form_open('admin/employee/employee_update/'.$user->user_id ); ?>
                     <div class="card-body">
                        <div class="row">
                           <div class="col-sm-3">
                              <div class="form-group row">
                                 <label for="inputName" class="col-sm-12 col-form-label">Workforce  Role <span style="color:red">*</span></label>
                                 <div class="col-sm-12">
                                    <select type="text" onchange="check_role(this.value)" name="user_role" class="form-control" required="required">
                                       <option value="">Select Role</option>
                                       <?php foreach ($all_role as $role):?>
                                          <option <?php if($role->role_name == $user->user_role){echo 'selected';}?> value="<?php echo $role->role_name ?>"><?php echo $role->role_name ?></option>
                                       <?php endforeach;?>
                                    </select>
                                 </div>
                              </div>
                           </div>
                           <div class="col-sm-3">
                              <div class="form-group row">
                                 <label for="inputName" class="col-sm-12 col-form-label">Workforce  Designation <span style="color:red">*</span></label>
                                 <div class="col-sm-12">
                                    <select type="text" name="user_designation" class="form-control" required="required">
                                       <option value="">Select</option>
                                       <?php foreach ($all_designation as $designation):?>
                                          <option <?php if($designation->role_name == $user->user_designation){echo 'selected';}?> value="<?php echo $designation->role_name ?>"><?php echo $designation->role_name ?></option>
                                       <?php endforeach;?>
                                    </select>
                                 </div>
                              </div>
                           </div>
                           <div class="col-sm-6">
                              <div class="form-group row">
                                 <label for="inputName" class="col-sm-12 col-form-label">Workforce  Name <span style="color:red">*</span></label>
                                 <div class="col-sm-12">
                                    <input type="text" name="user_name" class="form-control" placeholder="Enter Workforce  Name" required="required" value="<?php echo $user->user_name; ?>">
                                 </div>
                              </div>
                           </div>
                           <div class="col-sm-6">
                              <div class="form-group row">
                                 <label for="inputName" class="col-sm-12 col-form-label">Workforce  Email ID <span style="color:red">*</span></label>
                                 <div class="col-sm-12">
                                    <input type="email" name="user_email" class="form-control" placeholder="Enter Workforce  Email ID" required="required" value="<?php echo $user->user_email; ?>" pattern="[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}$">
                                 </div>
                              </div>
                           </div>
                           <div class="col-sm-6">
                              <div class="form-group row">
                                 <label for="inputName" class="col-sm-12 col-form-label">Workforce  Mobile No. <span style="color:red">*</span></label>
                                 <div class="col-sm-12">
                                    <input type="text" name="user_mobile" class="form-control" placeholder="Enter Workforce  Mobile No. (** This is Login ID **)" required="required" value="<?php echo $user->user_mobile; ?>" pattern="[1-9]{1}[0-9]{9}">
                                 </div>
                              </div>
                           </div>
                           <div class="col-sm-12">
                              <div class="form-group row">
                                 <label for="inputName" class="col-sm-12 col-form-label">Workforce  Pin Code <span style="color:red">*</span></label>
                                 <div class="col-sm-12">
                                    <input type="number" name="user_pin_code" id="pin_code" class="form-control" placeholder="Enter Workforce  Pin Code" required="required" value="<?php echo $user->user_pin_code; ?>">
                                 </div>
                              </div>
                           </div>
                           <div class="col-sm-12">
                              <div class="form-group row">
                                 <label for="inputName" class="col-sm-12 col-form-label">Workforce  Address </label>
                                 <div class="col-sm-12">
                                    <textarea type="text" name="user_address" class="form-control" placeholder="Enter Workforce  Address" ><?php echo $user->user_address; ?></textarea>
                                 </div>
                              </div>
                           </div>
                           
                           <div class="col-sm-4">
                              <div class="form-group row">
                                 <label for="inputName" class="col-sm-12 col-form-label">Workforce  Area <span style="color:red">*</span></label>
                                 <div class="col-sm-12">
                                    <select name="user_work_taulka" id="area" class="form-control" required="required">
                                       <option value="<?php echo $user->user_post; ?>"><?php echo $user->user_post; ?></option>
                                    </select>
                                 </div>
                              </div>
                           </div>
                           <div class="col-sm-4">
                              <div class="form-group row">
                                 <label for="inputName" class="col-sm-12 col-form-label"> Workforce  Dist <span style="color:red">*</span></label>
                                 <div class="col-sm-12">
                                    <input type="text" name="user_work_dist" id="city" class="form-control" placeholder="Workforce  Dist" required="required" readonly="" value="<?php echo $user->user_dist; ?>">
                                 </div>
                              </div>
                           </div>
                           <div class="col-sm-4">
                              <div class="form-group row">
                                 <label for="inputName" class="col-sm-12 col-form-label">Workforce  State <span style="color:red">*</span></label>
                                 <div class="col-sm-12">
                                    <input type="text" name="user_work_state" id="state" class="form-control" placeholder="Workforce  State" required="required" readonly="" value="<?php echo $user->user_state; ?>">
                                 </div>
                              </div>
                           </div>
                           <div class="col-sm-6 hide_on_teacher">
                              <div class="form-group row">
                                 <label for="inputName" class="col-sm-12 col-form-label">Workforce Paid Status <span style="color:red">*</span></label>
                                 <div class="col-sm-12">
                                    <select name="user_paid_status" id="paid_status" class="form-control" placeholder="Enter Workforce Owner Aadhar Card No">
                                       <option value="">Select</option>
                                       <option <?php if($user->user_paid_status == 'Paid'){echo 'selected';}?> value="Paid">Paid</option>
                                       <option <?php if($user->user_paid_status == 'Rental'){echo 'selected';}?> value="Rental">Rental</option>
                                    </select>
                                 </div>
                              </div>
                           </div>
                           <div class="col-sm-6 hide_on_teacher">
                              <div class="form-group row">
                                 <label for="inputName" class="col-sm-12 col-form-label">Workforce Pay/Rental Amount <span style="color:red">*</span></label>
                                 <div class="col-sm-12">
                                    <input name="user_rental_amount" min="1" id="rental_amt" type="number" class="form-control" placeholder="Enter Workforce Pay/Rental Amount" value="<?php echo $user->user_rental_amount; ?>">
                                      
                                 </div>
                              </div>
                           </div>
                           
                        </div>
                        <div class="form-group row" id="submit_button-2">
                           <div class="offset-sm-0 col-sm-10">
                              <button  type="submit" class="btn btn-success setting-submit" name="submit">Save</button>
                           </div>
                        </div>   
                     </div>
                     <?php echo form_close(); ?>
                  </div>
               </div>
            </div>
          </div>
         </div>
      </div>
   </div>
</section>
<?php echo $user->user_paid_status?>
</div>
<style type="text/css">
#alert3, .hide_on_teacher
{
   display: none;
}
</style>
<script type="text/javascript">
$( document ).ready(function() {
    check_role('<?php echo $user->user_role?>')
});
function check_role(e) 
{
   if(e == 'Teacher')
   {
      $('.hide_on_teacher').show();
      $('#paid_status').attr('required', true);
      $('#rental_amt').attr('required', true);
   }
   else
   {
      $('.hide_on_teacher').hide();
      $('#paid_status').attr('required', false);
      $('#rental_amt').attr('required', false);
   }
}
$('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>