<?php $this->view("includes/Inc_pagehead");?>
<!-- Page Styles Goes Here-->

<?php $this->view("includes/Inc_navigation");?>
<div class="m-grid__item m-grid__item--fluid m-wrapper">
  <!-- BEGIN: Subheader -->
  <div class="m-subheader ">
    <div class="d-flex align-items-center">
      <div class="mr-auto">
        <h3 class="m-subheader__title m-subheader__title--separator">
          Manage Employee Profiles
        </h3>
        <ul class="m-subheader__breadcrumbs m-nav m-nav--inline">
          <li class="m-nav__item m-nav__item--home">
            <a href="#" class="m-nav__link m-nav__link--icon">
              <i class="m-nav__link-icon la la-home"></i>
            </a>
          </li>
          <li class="m-nav__separator">
            -
          </li>
          <li class="m-nav__item">
            <a href="<?php echo base_url().'dashboard'?>" class="m-nav__link">
              <span class="m-nav__link-text">
                Home
              </span>
            </a>
          </li>
          <li class="m-nav__separator">
            -
          </li>
          <li class="m-nav__item">
            <a href="<?php echo base_url().'employees' ?>" class="m-nav__link">
              <span class="m-nav__link-text">
                Employees
              </span>
            </a>
          </li>


        </ul>
      </div>
      <div>

      </div>
    </div>
  </div>
  <!-- END: Subheader -->
  <div class="m-content">
    <div class="m-portlet m-portlet--mobile m-portlet--info m-portlet--head-solid-bg m-portlet--bordered m-portlet--rounded">
      <div class="m-portlet__head">
        <div class="m-portlet__head-caption">
          <div class="m-portlet__head-title">
            <h3 class="m-portlet__head-text">
              List of Employees
            </h3>
          </div>
        </div>
        <div class="m-portlet__head-tools">
          <?php if($this->session->userdata('user_role')!='auditor' || $this->session->userdata('user_data_permission')['adding']==1) { ?>
            <a href="#" data-toggle="modal" data-target="#employee_add_modal" class="btn btn-focus m-btn m-btn--custom m-btn--icon m-btn--air m-btn--pill">
              <span>
                <i class="la la-plus"></i>
                <span>
                  Add New Employee
                </span>
              </span>
            </a>
          <?php } ?>
        </div>
      </div>
      <div class="m-portlet__body">
        <!--begin: Datatable -->
        <table width="100%" class="table m-table nowrap table-header-fixed table-striped table-bordered table-hover table-header-fixed" id="employee_view_table">
          <thead>
            <tr class="">
              <th>Sl No</th>
              <th>Emp Id</th>
              <th>Name</th>
              <th>Employee Code</th>
              <th>Department</th>
              <th>Designation</th>
              <th>Contact</th>
              <th>Address</th>
              <th>Gender</th>
              <th>DOB</th>
              <th>Nationality</th>
              <th>Sponsor</th>
              <th>Work Location</th>
              <th>Date of Arrival</th>
              <th>Date of Join</th>
              <th>Basic Wage</th>
              <th>Wage Type</th>
              <th>Basic Wage Fixed</th>
              <th>Opening Balance<br/>Payable (Salary)</th>
              <th>Food Allowance</th>
              <th>Incentive</th>
              <th><?php echo $this->config->item('Employee_civil_id_name'); ?></th>
              <th><?php echo $this->config->item('Employee_civil_id_name'); ?> Expiry Date</th>
              <th><?php echo $this->config->item('Employee_civil_id_name'); ?> Remaining Days</th>
              <th><?php echo $this->config->item('Employee_civil_id_name'); ?> Status</th>
              <th>Passport No</th>
              <th>Passport Expiry Date</th>
              <th>Passport Remaining Days</th>
              <th>Passport Status</th>
              <th>Health Card No</th>
              <th>Health Card Expiry Date</th>
              <th>Bank Name</th>
              <th>Bank A/C No</th>
              <th>Bank Card Expiry</th>
              <th>T-Shirt Size</th>
              <th>Shoe Size</th>
              <th>Pant Size</th>
              <th>Biometric ID</th>
              <th>Assigned Vehicles<br/>(For Driver Dept)</th>
              <th>Creation</th>
              <th>Actions</th>
              <th>Basic Wage Fixed</th>
              <th>User ID</th>
              <th>Department</th>
              <th>Assigned Vehicles</th>
            </tr>
          </thead>
          <tbody>
          </tbody>
        </table>

      </div>
    </div>

    <!--end: Datatable -->
    <div class="modal fade" tabindex="-1" id="employee_add_modal" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
      <div class="modal-dialog " role="document" style="max-width: 800px">
        <div class="modal-content">
          <div class="modal-header" style="background-color: #36a3f7;border-radius: 4px">
            <h5 class="modal-title" id="exampleModalLabel" style="color: #ffffff" >
              Create New Employee
            </h5>
            <button type="button" class="close" data-dismiss="modal" aria-label="Close">
              <span aria-hidden="true">
                &times;
              </span>
            </button>
          </div>
          <form autocomplete="off" id="form_employee_add" data-modal-id="employee_add_modal" method="post" action="<?php echo base_url().'employees/create'?>" enctype="multipart/form-data" class="m-form m-form--fit m-form--state m-form--label-align-right " >
            <div class="modal-body" style="padding-left: 40px;padding-right: 40px">
              <div class="m-form__content">
                <div class="m-alert m-alert--icon alert alert-warning m--hide" role="alert" id="form_employee_add_msg">
                  <div class="m-alert__icon">
                    <i class="la la-warning"></i>
                  </div>
                  <div class="m-alert__text">
                    Oh snap! Change a few things up and try submitting again.
                  </div>
                  <div class="m-alert__close">
                    <button type="button" class="close" data-close="alert" aria-label="Close"></button>
                  </div>
                </div>
              </div>
              <div class="row">
                <div class="col-lg-5 padding-0">
                  <div class="form-group m-form__group" >
                    <label for="user_name">
                      Employee Name
                    </label>
                    <div class="m-input-icon m-input-icon--right">
                      <input required type="text" name="name" class="form-control m-input m-input--pill m-input--air form_employee_add_fields" placeholder="Employee Name">
                      <span class="m-input-icon__icon m-input-icon__icon--right"><span><i class="fa fa-user"></i></span></span>
                    </div>
                    <span class="m-form__help"></span>
                  </div>
                </div>
                <div class="col-lg-4 padding-0">
                  <div class="form-group m-form__group" >
                    <label for="user_name">
                      Designation
                    </label>
                    <div class="m-input-icon m-input-icon--right">
                      <input required type="text" name="designation" class="form-control m-input m-input--pill m-input--air form_employee_add_fields" placeholder="Designation">
                      <span class="m-input-icon__icon m-input-icon__icon--right"><span><i class="fa fa-tag"></i></span></span>
                    </div>
                    <span class="m-form__help"></span>
                  </div>
                </div>
                <div class="col-lg-3 padding-0">
                  <div class="form-group m-form__group" >
                    <label for="user_name">
                      Employee Code
                    </label>
                    <div class="m-input-icon m-input-icon--right">
                      <input type="text" name="employee_code" class="form-control m-input m-input--pill m-input--air form_employee_add_fields" placeholder="Employee Code">
                      <span class="m-input-icon__icon m-input-icon__icon--right"><span><i class="fa fa-tag"></i></span></span>
                    </div>
                    <span class="m-form__help"></span>
                  </div>
                </div>
              </div>
              <div class="row">
                <div class="col-lg-5 padding-0">
                  <div class="form-group m-form__group" >
                    <label for="user_name">
                      Address
                    </label>
                    <div class="input-group m-input-group m-input-group--pill m-input-group--air">
                      <textarea type="text" name="address" class="form-control m-input form_employee_add_fields" placeholder="Address" aria-describedby="basic-addon1"></textarea>
                    </div>
                    <span class="m-form__help"></span>
                  </div>
                </div>
                <div class="col-lg-4 padding-0">
                  <div class="form-group m-form__group" >
                    <label for="user_name">
                      Contact No
                    </label>
                    <div class="m-input-icon m-input-icon--right">
                      <input type="text" name="contact_no" class="form-control m-input m-input--pill m-input--air form_employee_add_fields" placeholder="Contact No">
                      <span class="m-input-icon__icon m-input-icon__icon--right"><span><i class="fa fa-phone"></i></span></span>
                    </div>
                    <span class="m-form__help"></span>
                  </div>
                </div>
                <div class="col-lg-3 padding-0">
                  <div class="form-group m-form__group">
                    <label>
                      Gender
                    </label>
                    <div class="m-radio-inline" style="padding-top: 10px;">
                      <label class="m-radio m-radio--solid m-radio--state-danger">
                        <input required type="radio" class="form_fields_radio"  name="gender" value="Male"> Male
                        <span></span>
                      </label>
                      <label class="m-radio m-radio--solid m-radio--state-warning">
                        <input type="radio" class="form_fields_radio" name="gender"  value="Female"> Female
                        <span></span>
                      </label>
                    </div>
                    <span class="m-form__help"></span>
                  </div>
                </div>
              </div>
              <div class="row">
                <div class="col-lg-3 padding-0">
                  <div class="form-group m-form__group" >
                    <label for="user_name">Date of Birth</label>
                    <input data-date-format="dd-mm-yyyy" class="form-control m-input m-input--air m-input--pill form_employee_add_fields" name="dob" id="dob_add" placeholder="Date of Birth" type="text" />
                    <span class="m-form__help"></span>
                  </div>
                </div>
                <div class="col-lg-3 padding-0">
                  <div class="form-group m-form__group" >
                    <label for="user_name">
                      Nationality
                    </label>
                    <input type="text" name="nationality" class="form-control m-input m-input--pill m-input--air form_employee_add_fields" placeholder="Nationality">
                    <span class="m-form__help"></span>
                  </div>
                </div>
                <div class="col-lg-3 padding-0">
                  <div class="form-group m-form__group" >
                    <label for="user_name">
                      Sponsor
                    </label>
                    <input type="text" name="sponsor" class="form-control m-input m-input--pill m-input--air form_employee_add_fields" placeholder="Sponsor">
                    <span class="m-form__help"></span>
                  </div>
                </div>
                <div class="col-lg-3 padding-0">
                  <div class="form-group m-form__group" >
                    <label for="user_name">
                      Work Location
                    </label>
                    <input type="text" name="work_location" class="form-control m-input m-input--pill m-input--air form_employee_add_fields" placeholder="Work Location">
                    <span class="m-form__help"></span>
                  </div>
                </div>
              </div>
              <div class="row">
                <div class="col-lg-3 padding-0">
                  <div class="form-group m-form__group" >
                    <label for="user_name">
                      <?php echo $this->config->item('Employee_civil_id_name'); ?>
                    </label>
                    <div class="m-input-icon m-input-icon--right">
                      <input type="text" name="civil_id" class="form-control m-input m-input--pill m-input--air form_employee_add_fields" placeholder="<?php echo $this->config->item('Employee_civil_id_name'); ?>">
                      <span class="m-input-icon__icon m-input-icon__icon--right"><span><i class="fa fa-user"></i></span></span>
                    </div>
                    <span class="m-form__help"></span>
                  </div>
                </div>
                <div class="col-lg-3 padding-0">
                  <div class="form-group m-form__group" >
                    <label for="user_name">
                      <?php echo $this->config->item('Employee_civil_id_name'); ?> Expiry Date
                    </label>
                    <div class="m-input-icon m-input-icon--right">
                      <input type="text" data-date-format="dd-mm-yyyy" name="civil_id_expiry_date" id="civil_id_expiry_date_add" class="form-control m-input m-input--pill m-input--air form_employee_add_fields" placeholder="<?php echo $this->config->item('Employee_civil_id_name'); ?> Expiry Date">
                      <span class="m-input-icon__icon m-input-icon__icon--right"><span><i class="fa fa-calendar"></i></span></span>
                    </div>
                    <span class="m-form__help"></span>
                  </div>
                </div>
                <div class="col-lg-3 padding-0">
                  <div class="form-group m-form__group" >
                    <label for="user_name">
                      Passport No
                    </label>
                    <div class="m-input-icon m-input-icon--right">
                      <input type="text" name="passport_no" class="form-control m-input m-input--pill m-input--air form_employee_add_fields" placeholder="Passport No">
                      <span class="m-input-icon__icon m-input-icon__icon--right"><span><i class="fa fa-user"></i></span></span>
                    </div>
                    <span class="m-form__help"></span>
                  </div>
                </div>
                <div class="col-lg-3 padding-0">
                  <div class="form-group m-form__group" >
                    <label for="user_name">
                      Passport Expiry Date
                    </label>
                    <div class="m-input-icon m-input-icon--right">
                      <input type="text" data-date-format="dd-mm-yyyy" name="passport_expiry_date" id="passport_expiry_date_add" class="form-control m-input m-input--pill m-input--air form_employee_add_fields" placeholder="Passport Expiry Date">
                      <span class="m-input-icon__icon m-input-icon__icon--right"><span><i class="fa fa-calendar"></i></span></span>
                    </div>
                    <span class="m-form__help"></span>
                  </div>
                </div>
                <div class="col-lg-3 padding-0">
                  <div class="form-group m-form__group" >
                    <label for="user_name">
                      Health Card No
                    </label>
                    <div class="m-input-icon m-input-icon--right">
                      <input type="text" name="health_card_no" class="form-control m-input m-input--pill m-input--air form_employee_add_fields" placeholder="Health Card No">
                      <span class="m-input-icon__icon m-input-icon__icon--right"><span><i class="fa fa-user"></i></span></span>
                    </div>
                    <span class="m-form__help"></span>
                  </div>
                </div>
                <div class="col-lg-3 padding-0">
                  <div class="form-group m-form__group" >
                    <label for="user_name">
                      Health Card Expiry Date
                    </label>
                    <div class="m-input-icon m-input-icon--right">
                      <input type="text" data-date-format="dd-mm-yyyy" name="health_card_expiry_date" id="health_card_expiry_date_add" class="form-control m-input m-input--pill m-input--air form_employee_add_fields" placeholder="Health Card Expiry Date">
                      <span class="m-input-icon__icon m-input-icon__icon--right"><span><i class="fa fa-calendar"></i></span></span>
                    </div>
                    <span class="m-form__help"></span>
                  </div>
                </div>
                <div class="col-lg-3 padding-0">
                  <div class="form-group m-form__group" >
                    <label for="user_name">Joined Date</label>
                    <input data-date-format="dd-mm-yyyy" class="form-control m-input m-input--air m-input--pill form_employee_add_fields" name="joined_date" id="joined_date_add" placeholder="Joined Date" type="text" />
                    <span class="m-form__help"></span>
                  </div>
                </div>
                <div class="col-lg-3 padding-0">
                  <div class="form-group m-form__group" >
                    <label for="user_name">Arrived Date</label>
                    <input data-date-format="dd-mm-yyyy" class="form-control m-input m-input--air m-input--pill form_employee_add_fields" name="arrived_date" id="arrived_date_add" placeholder="Arrived Date" type="text" />
                    <span class="m-form__help"></span>
                  </div>
                </div>
                <div class="col-lg-4 padding-0">
                  <div class="form-group m-form__group" >
                    <label for="user_name">
                      Bank Name
                    </label>
                    <div class="m-input-icon m-input-icon--right">
                      <input type="text" name="bank_name" class="form-control m-input m-input--pill m-input--air form_employee_add_fields" placeholder="Bank Name">
                      <span class="m-input-icon__icon m-input-icon__icon--right"><span><i class="fa fa-edit"></i></span></span>
                    </div>
                    <span class="m-form__help"></span>
                  </div>
                </div>
                <div class="col-lg-5 padding-0">
                  <div class="form-group m-form__group" >
                    <label for="user_name">
                      Bank A/C No
                    </label>
                    <div class="m-input-icon m-input-icon--right">
                      <input type="text" name="bank_account_no" class="form-control m-input m-input--pill m-input--air form_employee_add_fields" placeholder="Bank A/C No">
                      <span class="m-input-icon__icon m-input-icon__icon--right"><span><i class="fa fa-edit"></i></span></span>
                    </div>
                    <span class="m-form__help"></span>
                  </div>
                </div>
                <div class="col-lg-3 padding-0">
                  <div class="form-group m-form__group" >
                    <label for="user_name">
                      Card Expiry Date
                    </label>
                    <div class="m-input-icon m-input-icon--right">
                      <input type="text" data-date-format="dd-mm-yyyy" name="bank_card_expiry_date" id="bank_card_expiry_date_add" class="form-control m-input m-input--pill m-input--air form_employee_add_fields" placeholder="Card Expiry Date">
                      <span class="m-input-icon__icon m-input-icon__icon--right"><span><i class="fa fa-calendar"></i></span></span>
                    </div>
                    <span class="m-form__help"></span>
                  </div>
                </div>
              </div>
              <div class="row">
                <div class="col-lg-3 padding-0">
                  <div class="m-form__group form-group" >
                    <label class="col-form-label">Salary Basic Wage Type</label>
                    <div class="m-radio-inline">
                      <label class="m-radio m-radio--solid m-radio--state-info">
                        <input required type="radio" name="basic_wage_type" class="" value="Hourly"> Hourly
                        <span></span>
                      </label>
                      <label class="m-radio m-radio--solid m-radio--state-brand">
                        <input required type="radio" name="basic_wage_type" class="" value="Daily"> Daily
                        <span></span>
                      </label>
                      <label class="m-radio m-radio--solid m-radio--state-success">
                        <input type="radio" name="basic_wage_type" class="" value="Monthly"> Monthly
                        <span></span>
                      </label>
                    </div>
                    <span class="m-form__help"></span>
                  </div>
                </div>
                <div class="col-lg-3 padding-0">
                  <div class="form-group m-form__group" >
                    <label for="user_name">
                      Basic Wage
                    </label>
                    <div class="m-input-icon m-input-icon--right ">
                      <input required type="text" name="basic_wage" class="form-control m-input m-input--pill m-input--air form_employee_add_fields" placeholder="Basic Wage">
                      <span class="m-input-icon__icon m-input-icon__icon--right"><span><?php echo $this->config->item('Currency_currency_format'); ?></span></span>
                    </div>
                    <span class="m-form__help"></span>
                  </div>
                </div>
                <div class="col-lg-3 padding-0">
                  <div class="m-form__group form-group">
                    <label class="col-form-label">Fixed Basic Wage</label>
                    <div class="m-radio-inline">
                      <label class="m-radio m-radio--solid m-radio--state-warning">
                        <input type="radio" name="fixed_basic_wage" class="" checked value="1"> Yes
                        <span></span>
                      </label>
                      <label class="m-radio m-radio--solid m-radio--state-danger">
                        <input type="radio" id="fixed_basic_wage_add_no" disabled name="fixed_basic_wage" class="" value="0"> No
                        <span></span>
                      </label>
                    </div>
                    <span class="m-form__help" id="fixed_basic_wage_add_info">*Yes = Worked Days Not Dependable</span>
                  </div>
                </div>
                <div class="col-lg-3 padding-0">
                  <div class="form-group m-form__group" >
                    <label for="user_name" style="text-align:left">
                      Opening Balance Payable (Salary)
                    </label>
                    <div class="m-input-icon m-input-icon--right ">
                      <input required type="text" name="opening_balance" class="form-control m-input m-input--pill m-input--air form_employee_add_fields" placeholder="Opening Balance">
                      <span class="m-input-icon__icon m-input-icon__icon--right"><span><?php echo $this->config->item('Currency_currency_format'); ?></span></span>
                    </div>
                    <span class="m-form__help"></span>
                  </div>
                </div>
                <div class="col-lg-3 padding-0">
                  <div class="form-group m-form__group" >
                    <label for="user_name" style="text-align:left">
                      Food Allowance
                    </label>
                    <div class="m-input-icon m-input-icon--right ">
                      <input required type="text" name="food_allowance" value="0" class="form-control m-input m-input--pill m-input--air form_employee_add_fields" placeholder="Food Allowance">
                      <span class="m-input-icon__icon m-input-icon__icon--right"><span><?php echo $this->config->item('Currency_currency_format'); ?></span></span>
                    </div>
                    <span class="m-form__help"></span>
                  </div>
                </div>
                <div class="col-lg-3 padding-0">
                  <div class="form-group m-form__group" >
                    <label for="user_name" style="text-align:left">
                      Incentive
                    </label>
                    <div class="m-input-icon m-input-icon--right ">
                      <input required type="text" name="incentive" value="0" class="form-control m-input m-input--pill m-input--air form_employee_add_fields" placeholder="Incentive">
                      <span class="m-input-icon__icon m-input-icon__icon--right"><span><?php echo $this->config->item('Currency_currency_format'); ?></span></span>
                    </div>
                    <span class="m-form__help"></span>
                  </div>
                </div>
                <div class="col-lg-6 padding-0">
                  <div class="form-group m-form__group">
                    <label for="user_name">
                      Department
                    </label>
                    <div class="input-group m-input-group m-input-group--pill">
                      <div class="input-group-prepend">
                        <a href="#hr_department_add_modal"   data-toggle="modal" data-target="#hr_department_add_modal" class="btn btn-focus">
                          <i class="fa fa-plus-circle"></i>
                        </a>
                      </div>
                      <select style="width: 80%"  class="form-control m-select2 m-select2-general form_employee_add_select" required id="hr_department_add" name="department">

                      </select>
                    </div>
                    <span class="m-form__help"></span>
                  </div>
                </div>
              </div>
              <div class="row">
                <div class="col-lg-3 padding-0">
                  <div class="form-group m-form__group" >
                    <label for="user_name" style="text-align:left">
                      T-Shirt Size
                    </label>
                    <input type="text" name="t_shirt_size" class="form-control m-input m-input--pill m-input--air form_employee_add_fields" placeholder="T-Shirt Size">
                    <span class="m-form__help"></span>
                  </div>
                </div>
                <div class="col-lg-3 padding-0">
                  <div class="form-group m-form__group" >
                    <label for="user_name" style="text-align:left">
                      Shoe Size
                    </label>
                    <input type="text" name="shoes_size" class="form-control m-input m-input--pill m-input--air form_employee_add_fields" placeholder="Shoe Size">
                    <span class="m-form__help"></span>
                  </div>
                </div>
                <div class="col-lg-3 padding-0">
                  <div class="form-group m-form__group" >
                    <label for="user_name" style="text-align:left">
                      Pant Size
                    </label>
                    <input type="text" name="pant_size" class="form-control m-input m-input--pill m-input--air form_employee_add_fields" placeholder="Pant Size">
                    <span class="m-form__help"></span>
                  </div>
                </div>
                <?php if($this->config->item('app_module_vehicle_management')==1){ ?>
                  <div class="col-lg-6" id="assigned_vehicle_add_div" style="display:none">
                    <div class="form-group m-form__group m-select2--pill">
                      <label for="user_name">
                        Assigned Vehicles
                      </label>
                      <div class="m-select2 m-select2--air m-select2--pill">
                        <select multiple="multiple" style="width: 100%" class="form-control m-select2 m-select2-multiple form_employee_add_select"  id="assigned_vehicles_add" name="assigned_vehicles[]" data-placeholder="Select Vehicles">
                          <?php foreach ($owned_vehicles as $key => $value) { ?>
                            <option value="<?php echo $value->id?>"><?php echo $value->vehicle_name." [".$value->vehicle_no."]" ?></option>
                          <?php } ?>
                        </select>
                      </div>
                      <span class="m-form__help"></span>
                    </div>
                  </div>
                <?php } ?>
                <?php if($this->config->item('HR_punching_machine_attendance')==1){ ?>
                  <div class="col-lg-3 padding-0">
                    <div class="form-group m-form__group" >
                      <label for="user_name">
                        Biometric ID
                      </label>
                      <div class="m-input-icon m-input-icon--right">
                        <input type="text" name="biometric_id" class="form-control m-input m-input--pill m-input--air form_employee_add_fields" placeholder="Biometric ID">
                        <span class="m-input-icon__icon m-input-icon__icon--right"><span><i class="fa fa-user"></i></span></span>
                      </div>
                      <span class="m-form__help"></span>
                    </div>
                  </div>
                <?php } ?>
              </div>
            </div>
            <div class="modal-footer">
              <button type="button" class="btn btn-secondary" data-dismiss="modal">
                Close
              </button>
              <button type="submit" class="btn btn-primary form_submit_btn">
                Submit
              </button>
            </div>
          </form>
        </div>
      </div>
    </div>
    <div class="modal fade" tabindex="-1" id="employee_edit_modal" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
      <div class="modal-dialog " role="document" style="max-width: 800px">
        <div class="modal-content">
          <div class="modal-header" style="background-color: #00c5dc;border-radius: 4px">
            <h5 class="modal-title" id="exampleModalLabel" style="color: #ffffff" >
              Edit Employee Details
            </h5>
            <button type="button" class="close" data-dismiss="modal" aria-label="Close">
              <span aria-hidden="true">
                &times;
              </span>
            </button>
          </div>
          <form autocomplete="off" data-modal-id="employee_edit_modal" id="form_employee_edit" method="post" action="<?php echo base_url().'employees/update'?>" enctype="multipart/form-data" class="m-form m-form--fit m-form--state m-form--label-align-right " >
            <div class="modal-body" style="padding-left: 40px;padding-right: 40px">
              <div class="m-form__content">
                <div class="m-alert m-alert--icon alert alert-warning m--hide" role="alert" id="form_employee_edit_msg">
                  <div class="m-alert__icon">
                    <i class="la la-warning"></i>
                  </div>
                  <div class="m-alert__text">
                    Oh snap! Change a few things up and try submitting again.
                  </div>
                  <div class="m-alert__close">
                    <button type="button" class="close" data-close="alert" aria-label="Close"></button>
                  </div>
                </div>
              </div>
              <div class="row">
                <div class="col-lg-5 padding-0">
                  <div class="form-group m-form__group" >
                    <label for="user_name">
                      Employee Name
                    </label>
                    <div class="m-input-icon m-input-icon--right">
                      <input required type="text" id="name_edit" name="name" class="form-control m-input m-input--pill m-input--air form_employee_edit_fields" placeholder="Employee Name">
                      <span class="m-input-icon__icon m-input-icon__icon--right"><span><i class="fa fa-user"></i></span></span>
                    </div>
                    <span class="m-form__help"></span>
                  </div>
                </div>
                <div class="col-lg-4 padding-0">
                  <div class="form-group m-form__group" >
                    <label for="user_name">
                      Designation
                    </label>
                    <div class="m-input-icon m-input-icon--right">
                      <input type="text" id="designation_edit" name="designation" class="form-control m-input m-input--pill m-input--air form_employee_edit_fields" placeholder="Designation">
                      <span class="m-input-icon__icon m-input-icon__icon--right"><span><i class="fa fa-tag"></i></span></span>
                    </div>
                    <span class="m-form__help"></span>
                  </div>
                </div>
                <div class="col-lg-3 padding-0">
                  <div class="form-group m-form__group" >
                    <label for="user_name">
                      Employee Code
                    </label>
                    <div class="m-input-icon m-input-icon--right">
                      <input type="text" name="employee_code" id="employee_code_edit" class="form-control m-input m-input--pill m-input--air form_employee_edit_fields" placeholder="Employee Code">
                      <span class="m-input-icon__icon m-input-icon__icon--right"><span><i class="fa fa-tag"></i></span></span>
                    </div>
                    <span class="m-form__help"></span>
                  </div>
                </div>
              </div>
              <div class="row">
                <div class="col-lg-5 padding-0">
                  <div class="form-group m-form__group" >
                    <label for="user_name">
                      Address
                    </label>
                    <div class="input-group m-input-group m-input-group--pill m-input-group--air">
                      <textarea type="text" name="address" id="address_edit" class="form-control m-input form_employee_edit_fields" placeholder="Address" aria-describedby="basic-addon1"></textarea>
                    </div>
                    <span class="m-form__help"></span>
                  </div>
                </div>
                <div class="col-lg-4 padding-0">
                  <div class="form-group m-form__group" >
                    <label for="user_name">
                      Contact No
                    </label>
                    <div class="m-input-icon m-input-icon--right">
                      <input type="text" id="contact_no_edit" name="contact_no" class="form-control m-input m-input--pill m-input--air form_employee_edit_fields" placeholder="Contact No">
                      <span class="m-input-icon__icon m-input-icon__icon--right"><span><i class="fa fa-phone"></i></span></span>
                    </div>
                    <span class="m-form__help"></span>
                  </div>
                </div>
                <div class="col-lg-3 padding-0">
                  <div class="form-group m-form__group">
                    <label>
                      Gender
                    </label>
                    <div class="m-radio-inline" style="padding-top: 10px;">
                      <label class="m-radio m-radio--solid m-radio--state-danger">
                        <input required type="radio" class="form_fields_radio"  name="gender_edit" value="Male"> Male
                        <span></span>
                      </label>
                      <label class="m-radio m-radio--solid m-radio--state-warning">
                        <input type="radio" class="form_fields_radio" name="gender_edit"  value="Female"> Female
                        <span></span>
                      </label>
                    </div>
                    <span class="m-form__help"></span>
                  </div>
                </div>
              </div>
              <div class="row">
                <div class="col-lg-3 padding-0">
                  <div class="form-group m-form__group" >
                    <label for="user_name">Date of Birth</label>
                    <input data-date-format="dd-mm-yyyy" class="form-control m-input m-input--air m-input--pill form_employee_edit_fields" name="dob" id="dob_edit" placeholder="Date of Birth" type="text" />
                    <span class="m-form__help"></span>
                  </div>
                </div>
                <div class="col-lg-3 padding-0">
                  <div class="form-group m-form__group" >
                    <label for="user_name">
                      Nationality
                    </label>
                    <input type="text" name="nationality" id="nationality_edit" class="form-control m-input m-input--pill m-input--air form_employee_edit_fields" placeholder="Nationality">
                    <span class="m-form__help"></span>
                  </div>
                </div>
                <div class="col-lg-3 padding-0">
                  <div class="form-group m-form__group" >
                    <label for="user_name">
                      Sponsor
                    </label>
                    <input type="text" name="sponsor" id="sponsor_edit" class="form-control m-input m-input--pill m-input--air form_employee_edit_fields" placeholder="Sponsor">
                    <span class="m-form__help"></span>
                  </div>
                </div>
                <div class="col-lg-3 padding-0">
                  <div class="form-group m-form__group" >
                    <label for="user_name">
                      Work Location
                    </label>
                    <input type="text" name="work_location" id="work_location_edit" class="form-control m-input m-input--pill m-input--air form_employee_edit_fields" placeholder="Work Location">
                    <span class="m-form__help"></span>
                  </div>
                </div>
              </div>
              <div class="row">
                <div class="col-lg-3 padding-0">
                  <div class="form-group m-form__group" >
                    <label for="user_name">
                      <?php echo $this->config->item('Employee_civil_id_name'); ?>
                    </label>
                    <div class="m-input-icon m-input-icon--right">
                      <input type="text" name="civil_id" id="civil_id_edit" class="form-control m-input m-input--pill m-input--air form_employee_edit_fields" placeholder="<?php echo $this->config->item('Employee_civil_id_name'); ?>">
                      <span class="m-input-icon__icon m-input-icon__icon--right"><span><i class="fa fa-user"></i></span></span>
                    </div>
                    <span class="m-form__help"></span>
                  </div>
                </div>
                <div class="col-lg-3 padding-0">
                  <div class="form-group m-form__group" >
                    <label for="user_name">
                      <?php echo $this->config->item('Employee_civil_id_name'); ?> Expiry Date
                    </label>
                    <div class="m-input-icon m-input-icon--right">
                      <input type="text" data-date-format="dd-mm-yyyy" name="civil_id_expiry_date" id="civil_id_expiry_date_edit" class="form-control m-input m-input--pill m-input--air form_employee_edit_fields" placeholder="<?php echo $this->config->item('Employee_civil_id_name'); ?> Expiry Date">
                      <span class="m-input-icon__icon m-input-icon__icon--right"><span><i class="fa fa-calendar"></i></span></span>
                    </div>
                    <span class="m-form__help"></span>
                  </div>
                </div>
                <div class="col-lg-3 padding-0">
                  <div class="form-group m-form__group" >
                    <label for="user_name">
                      Passport No
                    </label>
                    <div class="m-input-icon m-input-icon--right">
                      <input type="text" name="passport_no" id="passport_no_edit" class="form-control m-input m-input--pill m-input--air form_employee_edit_fields" placeholder="Passport No">
                      <span class="m-input-icon__icon m-input-icon__icon--right"><span><i class="fa fa-user"></i></span></span>
                    </div>
                    <span class="m-form__help"></span>
                  </div>
                </div>
                <div class="col-lg-3 padding-0">
                  <div class="form-group m-form__group" >
                    <label for="user_name">
                      Passport Expiry Date
                    </label>
                    <div class="m-input-icon m-input-icon--right">
                      <input type="text" data-date-format="dd-mm-yyyy" name="passport_expiry_date" id="passport_expiry_date_edit" class="form-control m-input m-input--pill m-input--air form_employee_edit_fields" placeholder="Passport Expiry Date">
                      <span class="m-input-icon__icon m-input-icon__icon--right"><span><i class="fa fa-calendar"></i></span></span>
                    </div>
                    <span class="m-form__help"></span>
                  </div>
                </div>
                <div class="col-lg-3 padding-0">
                  <div class="form-group m-form__group" >
                    <label for="user_name">
                      Health Card No
                    </label>
                    <div class="m-input-icon m-input-icon--right">
                      <input type="text" name="health_card_no" id="health_card_no_edit" class="form-control m-input m-input--pill m-input--air form_employee_edit_fields" placeholder="Health Card No">
                      <span class="m-input-icon__icon m-input-icon__icon--right"><span><i class="fa fa-user"></i></span></span>
                    </div>
                    <span class="m-form__help"></span>
                  </div>
                </div>
                <div class="col-lg-3 padding-0">
                  <div class="form-group m-form__group" >
                    <label for="user_name">
                      Health Card Expiry Date
                    </label>
                    <div class="m-input-icon m-input-icon--right">
                      <input type="text" data-date-format="dd-mm-yyyy" name="health_card_expiry_date" id="health_card_expiry_date_edit" class="form-control m-input m-input--pill m-input--air form_employee_edit_fields" placeholder="Health Card Expiry Date">
                      <span class="m-input-icon__icon m-input-icon__icon--right"><span><i class="fa fa-calendar"></i></span></span>
                    </div>
                    <span class="m-form__help"></span>
                  </div>
                </div>
                <div class="col-lg-3 padding-0">
                  <div class="form-group m-form__group" >
                    <label for="user_name">Joined Date</label>
                    <input data-date-format="dd-mm-yyyy" class="form-control m-input m-input--air m-input--pill form_employee_edit_fields" name="joined_date" id="joined_date_edit" placeholder="Joined Date" type="text" />
                    <span class="m-form__help"></span>
                  </div>
                </div>
                <div class="col-lg-3 padding-0">
                  <div class="form-group m-form__group" >
                    <label for="user_name">Arrived Date</label>
                    <input data-date-format="dd-mm-yyyy" class="form-control m-input m-input--air m-input--pill form_employee_edit_fields" name="arrived_date" id="arrived_date_edit" placeholder="Arrived Date" type="text" />
                    <span class="m-form__help"></span>
                  </div>
                </div>
                <div class="col-lg-4 padding-0">
                  <div class="form-group m-form__group" >
                    <label for="user_name">
                      Bank Name
                    </label>
                    <div class="m-input-icon m-input-icon--right">
                      <input type="text" name="bank_name" id="bank_name_edit" class="form-control m-input m-input--pill m-input--air form_employee_edit_fields" placeholder="Bank Name">
                      <span class="m-input-icon__icon m-input-icon__icon--right"><span><i class="fa fa-edit"></i></span></span>
                    </div>
                    <span class="m-form__help"></span>
                  </div>
                </div>
                <div class="col-lg-5 padding-0">
                  <div class="form-group m-form__group" >
                    <label for="user_name">
                      Bank A/C No
                    </label>
                    <div class="m-input-icon m-input-icon--right">
                      <input type="text" name="bank_account_no" id="bank_account_no_edit" class="form-control m-input m-input--pill m-input--air form_employee_edit_fields" placeholder="Bank A/C No">
                      <span class="m-input-icon__icon m-input-icon__icon--right"><span><i class="fa fa-edit"></i></span></span>
                    </div>
                    <span class="m-form__help"></span>
                  </div>
                </div>
                <div class="col-lg-3 padding-0">
                  <div class="form-group m-form__group" >
                    <label for="user_name">
                      Card Expiry Date
                    </label>
                    <div class="m-input-icon m-input-icon--right">
                      <input type="text" data-date-format="dd-mm-yyyy" name="bank_card_expiry_date" id="bank_card_expiry_date_edit" class="form-control m-input m-input--pill m-input--air form_employee_edit_fields" placeholder="Card Expiry Date">
                      <span class="m-input-icon__icon m-input-icon__icon--right"><span><i class="fa fa-calendar"></i></span></span>
                    </div>
                    <span class="m-form__help"></span>
                  </div>
                </div>
              </div>
              <div class="row">
                <div class="col-lg-3 padding-0">
                  <div class="m-form__group form-group" >
                    <label class="col-form-label">Basic Wage Type</label>
                    <div class="m-radio-inline">
                      <label class="m-radio m-radio--solid m-radio--state-info">
                        <input required type="radio" name="basic_wage_type_edit" class="" value="Hourly"> Hourly
                        <span></span>
                      </label>
                      <label class="m-radio m-radio--solid m-radio--state-brand">
                        <input required type="radio" name="basic_wage_type_edit" class="" value="Daily"> Daily
                        <span></span>
                      </label>
                      <label class="m-radio m-radio--solid m-radio--state-success">
                        <input type="radio" name="basic_wage_type_edit" class="" value="Monthly"> Monthly
                        <span></span>
                      </label>
                    </div>
                    <span class="m-form__help"></span>
                  </div>
                </div>
                <div class="col-lg-3 padding-0">
                  <div class="form-group m-form__group" >
                    <label for="user_name">
                      Basic Wage
                    </label>
                    <div class="m-input-icon m-input-icon--right">
                      <input required type="text" id="basic_wage_edit" name="basic_wage" class="form-control m-input m-input--pill m-input--air form_employee_edit_fields" placeholder="Basic Wage">
                      <span class="m-input-icon__icon m-input-icon__icon--right"><span><?php echo $this->config->item('Currency_currency_format'); ?></span></span>
                    </div>
                    <span class="m-form__help"></span>
                  </div>
                </div>
                <div class="col-lg-3 padding-0">
                  <div class="m-form__group form-group">
                    <label class="col-form-label">Fixed Basic Wage</label>
                    <div class="m-radio-inline">
                      <label class="m-radio m-radio--solid m-radio--state-warning">
                        <input type="radio" name="fixed_basic_wage_edit" class="" checked value="1"> Yes
                        <span></span>
                      </label>
                      <label class="m-radio m-radio--solid m-radio--state-danger">
                        <input type="radio" id="fixed_basic_wage_edit_no" disabled name="fixed_basic_wage_edit" class="" value="0"> No
                        <span></span>
                      </label>
                    </div>
                    <span class="m-form__help" id="fixed_basic_wage_edit_info">*Yes = Worked Days Not Dependable</span>
                  </div>
                </div>
                <div class="col-lg-3 padding-0">
                  <div class="form-group m-form__group" >
                    <label for="user_name">
                      Opening Balance Payable (Salary)
                    </label>
                    <div class="m-input-icon m-input-icon--right ">
                      <input required type="text" name="opening_balance" id="opening_balance_edit" class="form-control m-input m-input--pill m-input--air form_employee_edit_fields" placeholder="Opening Balance">
                      <span class="m-input-icon__icon m-input-icon__icon--right"><span><?php echo $this->config->item('Currency_currency_format'); ?></span></span>
                    </div>
                    <span class="m-form__help"></span>
                  </div>
                </div>
                <div class="col-lg-3 padding-0">
                  <div class="form-group m-form__group" >
                    <label for="user_name" style="text-align:left">
                      Food Allowance
                    </label>
                    <div class="m-input-icon m-input-icon--right ">
                      <input required type="text" name="food_allowance" id="food_allowance_edit" value="0" class="form-control m-input m-input--pill m-input--air form_employee_edit_fields" placeholder="Food Allowance">
                      <span class="m-input-icon__icon m-input-icon__icon--right"><span><?php echo $this->config->item('Currency_currency_format'); ?></span></span>
                    </div>
                    <span class="m-form__help"></span>
                  </div>
                </div>
                <div class="col-lg-3 padding-0">
                  <div class="form-group m-form__group" >
                    <label for="user_name" style="text-align:left">
                      Incentive
                    </label>
                    <div class="m-input-icon m-input-icon--right ">
                      <input required type="text" name="incentive" id="incentive_edit" value="0" class="form-control m-input m-input--pill m-input--air form_employee_edit_fields" placeholder="Incentive">
                      <span class="m-input-icon__icon m-input-icon__icon--right"><span><?php echo $this->config->item('Currency_currency_format'); ?></span></span>
                    </div>
                    <span class="m-form__help"></span>
                  </div>
                </div>
                <div class="col-lg-6 padding-0">
                  <div class="form-group m-form__group">
                    <label for="user_name">
                      Department
                    </label>
                    <div class="input-group m-input-group m-input-group--pill">
                      <div class="input-group-prepend">
                        <a href="#hr_department_edit_modal"   data-toggle="modal" data-target="#hr_department_edit_modal" class="btn btn-focus">
                          <i class="fa fa-plus-circle"></i>
                        </a>
                      </div>
                      <select style="width: 80%"  class="form-control m-select2 m-select2-general form_employee_edit_select" required id="hr_department_edit" name="department">

                      </select>
                    </div>
                    <span class="m-form__help"></span>
                  </div>
                </div>
                <input type="hidden" name="employee_id" id="employee_id_edit">
              </div>
              <div class="row">
                <div class="col-lg-3 padding-0">
                  <div class="form-group m-form__group" >
                    <label for="user_name" style="text-align:left">
                      T-Shirt Size
                    </label>
                    <input type="text" name="t_shirt_size" id="t_shirt_size_edit" class="form-control m-input m-input--pill m-input--air form_employee_edit_fields" placeholder="T-Shirt Size">
                    <span class="m-form__help"></span>
                  </div>
                </div>
                <div class="col-lg-3 padding-0">
                  <div class="form-group m-form__group" >
                    <label for="user_name" style="text-align:left">
                      Shoe Size
                    </label>
                    <input type="text" name="shoes_size" id="shoes_size_edit" class="form-control m-input m-input--pill m-input--air form_employee_edit_fields" placeholder="Shoe Size">
                    <span class="m-form__help"></span>
                  </div>
                </div>
                <div class="col-lg-3 padding-0">
                  <div class="form-group m-form__group" >
                    <label for="user_name" style="text-align:left">
                      Pant Size
                    </label>
                    <input type="text" name="pant_size" id="pant_size_edit" class="form-control m-input m-input--pill m-input--air form_employee_edit_fields" placeholder="Pant Size">
                    <span class="m-form__help"></span>
                  </div>
                </div>
                <?php if($this->config->item('HR_punching_machine_attendance')==1){ ?>
                  <div class="col-lg-3 padding-0">
                    <div class="form-group m-form__group" >
                      <label for="user_name">
                        Biometric ID
                      </label>
                      <div class="m-input-icon m-input-icon--right">
                        <input type="text" name="biometric_id" id="biometric_id_edit" class="form-control m-input m-input--pill m-input--air form_employee_edit_fields" placeholder="Biometric ID">
                        <span class="m-input-icon__icon m-input-icon__icon--right"><span><i class="fa fa-user"></i></span></span>
                      </div>
                      <span class="m-form__help"></span>
                    </div>
                  </div>
                <?php } ?>
                <?php if($this->config->item('app_module_vehicle_management')==1){ ?>
                  <div class="col-lg-6" id="assigned_vehicle_edit_div" style="display:none">
                    <div class="form-group m-form__group m-select2--pill">
                      <label for="user_name">
                        Assigned Vehicles
                      </label>
                      <div class="m-select2 m-select2--air m-select2--pill">
                        <select multiple="multiple" style="width: 100%" class="form-control m-select2 m-select2-multiple form_employee_edit_select"  id="assigned_vehicles_edit" name="assigned_vehicles[]" data-placeholder="Select Vehicles">
                          <?php foreach ($owned_vehicles as $key => $value) { ?>
                            <option value="<?php echo $value->id?>"><?php echo $value->vehicle_name." [".$value->vehicle_no."]" ?></option>
                          <?php } ?>
                        </select>
                      </div>
                      <span class="m-form__help"></span>
                    </div>
                  </div>
                <?php } ?>

              </div>
            </div>
            <div class="modal-footer">
              <button type="button" class="btn btn-secondary" data-dismiss="modal">
                Close
              </button>
              <button type="submit" class="btn btn-primary form_submit_btn">
                Submit
              </button>
            </div>
          </form>
        </div>
      </div>
    </div>
    <div class="modal fade" tabindex="-1" id="employee_delete_modal" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
      <div class="modal-dialog " role="document" >
        <form id="form_employee_delete" data-modal-id="employee_delete_modal" autocomplete="off" method="post" action="<?php echo base_url().'employees/delete'?>" class="form-horizontal">
          <div class="modal-content">
            <div class="alert alert-danger" role="alert" style="margin-bottom: 0px">
              <button type="button" class="close" data-dismiss="modal"></button>
              <br/>
              <h4 class="alert-heading">Warning! Please Confirm Your Action</h4>
              <br/>
              <p> Are You Sure to Delete this Data ?. All the Associated Data will Lost. </p>
              <p>
                <button class="btn btn-danger form_submit_btn" type="submit" name="submit">Confirm & Delete</button>
                <button type="button" class="btn btn-primary modal-dismiss" data-dismiss="modal">Cancel</button>
              </p>
              <input type="hidden" name="employee_id" id="employee_id_delete">
            </div>
          </div>
        </form>
      </div>
    </div>

  </div>
</div>
</div>
<!-- end:: Body -->
<!-- begin::Footer -->
<?php $this->view("modules/include_modals/modal_hr_department_add");?>
<?php $this->view("includes/Inc_footer");?>
<!-- end::Footer -->
</div>
<!-- end:: Page -->

<?php $this->view("includes/Inc_sidebar");?>
<?php $this->view("includes/Inc_scripts");?>

<!--begin::Page Snippets -->
<script>
$("#hr_menu").addClass('m-menu__item--active m-menu__item--open');
$("#hr_menu_1").addClass('m-menu__item--active');

$("#duty_start_time_add").timepicker({
  defaultTime: "<?php echo date("h:i A", strtotime($this->config->item('HR_duty_start_time'))) ?>",
  minuteStep: 1,
})
$("#duty_end_time_add").timepicker({
  defaultTime: "<?php echo date("h:i A", strtotime($this->config->item('HR_duty_end_time'))) ?>",
  minuteStep: 1,
})
$("#joined_date_add,#joined_date_edit,#dob_add,#dob_edit,#civil_id_expiry_date_add,#civil_id_expiry_date_edit,#passport_expiry_date_add,#passport_expiry_date_edit,#health_card_expiry_date_add,#health_card_expiry_date_edit,#bank_card_expiry_date_add,#bank_card_expiry_date_edit,#arrived_date_add,#arrived_date_edit").datepicker({
  todayHighlight: !0,
  orientation: "bottom left",
  templates: {
    leftArrow: '<i class="la la-angle-left"></i>',
    rightArrow: '<i class="la la-angle-right"></i>'
  }
})
$("#joined_date_add,#joined_date_edit,#dob_add,#dob_edit,#civil_id_expiry_date_add,#civil_id_expiry_date_edit,#passport_expiry_date_add,#passport_expiry_date_edit,#health_card_expiry_date_add,#health_card_expiry_date_edit,#bank_card_expiry_date_add,#bank_card_expiry_date_edit,#arrived_date_add,#arrived_date_edit").inputmask("dd-mm-yyyy");
$("#hr_department_add").select2({
  placeholder: "Select Department",
  dropdownParent: $("#form_employee_add")
})
$("#hr_department_edit").select2({
  placeholder: "Select Department",
  dropdownParent: $("#form_employee_edit")
})
$("#assigned_vehicles_add").select2({
  placeholder: "Select Vehicles",
  dropdownParent: $("#form_employee_add")
})
$("#assigned_vehicles_edit").select2({
  placeholder: "Select Vehicles",
  dropdownParent: $("#form_employee_edit")
})
function select_hr_department(select_id,selected_value=''){
  $('#'+select_id).html('');
  $('#'+select_id).append("<option disabled selected >Select Department</option>");
  $.post("<?php echo base_url() ?>employees/select_departments_list",{},function(data) {
    var obj = $.parseJSON(data);
    var i=0;
    if(obj.count>0) {
      while (i < obj.data.length) {
        $('#'+select_id).append("<option value=" + obj.data[i]['department_id'] + ">" + obj.data[i]['department_name'] + "</option>");
        i++;
      }
      if(selected_value!=''){
        $('#'+select_id).val(selected_value).trigger("change");
      }
    }
  })
}
select_hr_department('hr_department_add');
$('#hr_department_add').on("change", function(e) {
  var department = $('#hr_department_add :selected').val();
  if(department==1){
    $("#assigned_vehicle_add_div").show();
  }else{
    $("#assigned_vehicle_add_div").hide();
  }
});
$('#hr_department_edit').on("change", function(e) {
  var department = $('#hr_department_edit :selected').val();
  if(department==1){
    $("#assigned_vehicle_edit_div").show();
  }else{
    $("#assigned_vehicle_edit_div").hide();
  }
});
var table = $('#employee_view_table').DataTable({
  "ajax":{
    url :"<?php echo base_url().'employees/select_employee' ?>", // json datasource
    type: "post", // type of method  , by default would be get
    data: function(d){

    }
  },
  "bProcessing": true,
  "deferRender": true,
  "bDeferRender": true,
  "scrollX" : true,
  buttons: [
    { extend: 'print', className: 'btn dark btn-outline',exportOptions: {columns: ':visible'},title: 'List of Employees' },
    { extend: 'csv', className: 'btn purple btn-outline ' },
    { extend: 'colvis', className: 'btn dark btn-outline', text: 'Columns'}
  ],
  dom:"<'row'<'col-sm-6 text-left'B><'col-sm-6 text-right'f>>\n\t\t\t<'row'<'col-sm-12'tr>>\n\t\t\t<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7 dataTables_pager'lp>>", // horizobtal scrollable datatable
  "lengthMenu": [
    [25, 50, 100, -1],
    [25, 50, 100, "All"] // change per page values here
  ],
  // set the initial value
  "pageLength": 25,
  "columnDefs": [
    {
      "targets": [ 1,41,42,43,44<?php if($this->session->userdata('user_role')=='auditor'){ echo ",40"; } ?><?php if($this->config->item('HR_punching_machine_attendance')!=1){ echo ",37"; }?> ],
      className: "hidden"
    }
  ],
  'order': [[0, 'desc']]
});

$(".table_filter").on("change", function() {
  table.ajax.reload();
});
$(".hide_column").hide();

$(".form_submit_btn").click(function (e) {
  e.preventDefault();
  var a = $(this),
  l = $(this).closest("form"),
  action = l.attr('action');
  var form_id = l.attr('id');
  l.validate({
    rules: {
      op_balance: {
        number: !0
      },
      basic_wage: {
        number: !0
      },
      contact_no: {
        number: !0
      }
    }, invalidHandler: function (e, r) {
      var i = $("#" + form_id + "_msg");
      i.removeClass("m--hide").show(), mUtil.scrollTo(i, -200)
    }, submitHandler: function (e) {
    }
  }), l.valid() && (a.addClass("m-loader m-loader--right m-loader--light").attr("disabled", !0),
  l.ajaxSubmit({
    url: action,
    success: function (e, t, r, s) {
      var modal_id = l.attr('data-modal-id');
      var form_type = l.attr('data-form-type');
      $("#" + form_id + "_msg").addClass("m--hide");
      // Block UI
      mApp.blockPage({
        overlayColor: "#000000",
        type: "loader",
        state: "success",
        message: "Please wait..."
      }), setTimeout(function () {
        mApp.unblockPage()
      }, 2e3);
      var obj = $.parseJSON(e);
      if (obj.status == 1) {
        a.removeClass("m-loader m-loader--right m-loader--light").attr("disabled", !1);
        $("#"+modal_id).modal('toggle');
        $("."+form_id+"_fields").val('');
        $("."+form_id+"_select").val('').trigger("change");
        toastr[obj.flashdata_type](obj.flashdata_msg, obj.flashdata_title);
        table.ajax.reload();
        $('input[name=basic_wage_type]').prop('checked', false);
        select_hr_department('hr_department_add');
        select_hr_department('hr_department_edit');
      } else {
        a.removeClass("m-loader m-loader--right m-loader--light").attr("disabled", !1);
        toastr[obj.flashdata_type](obj.flashdata_msg, obj.flashdata_title);
      }
      if (obj == null) {
        setTimeout(function () {
          a.removeClass("m-loader m-loader--right m-loader--light").attr("disabled", !1);
          toastr["warning"]("Your Attempt is Timed Out. Please Try Again.", "Timed Out");
        }, 2e4)
      }
    },error: function() {
      a.removeClass("m-loader m-loader--right m-loader--light").attr("disabled", !1);
      toastr["error"]("Sorry. There Has Been Some Error Occurred. Please Try Again.", "Error");
    }
  })
)
});
</script>
<script>
$('body').on('change', 'input[type=radio][name=basic_wage_type]', function() {
  var basic_wage_type = $("input[name='basic_wage_type']:checked").val();
  if(basic_wage_type=='Monthly'){
    $("#fixed_basic_wage_add_no").attr('disabled',false);
  }else{
    $("#fixed_basic_wage_add_no").attr('disabled',true);
  }
})
$('body').on('change', 'input[type=radio][name=fixed_basic_wage]', function() {
  var fixed_basic_wage = $("input[name='fixed_basic_wage']:checked").val();
  if(fixed_basic_wage==1){
    $("#fixed_basic_wage_add_info").text("*Yes = Worked Days Not Dependable");
  }else{
    $("#fixed_basic_wage_add_info").text("*No = Worked Days Dependable");
  }
})

$('body').on('change', 'input[type=radio][name=basic_wage_type_edit]', function() {
  var basic_wage_type = $("input[name='basic_wage_type_edit']:checked").val();
  if(basic_wage_type=='Monthly'){
    $("#fixed_basic_wage_edit_no").attr('disabled',false);
  }else{
    $("#fixed_basic_wage_edit_no").attr('disabled',true);
  }
})
$('body').on('change', 'input[type=radio][name=fixed_basic_wage_edit]', function() {
  var fixed_basic_wage = $("input[name='fixed_basic_wage_edit']:checked").val();
  if(fixed_basic_wage==1){
    $("#fixed_basic_wage_edit_info").text("*Yes = Worked Days Not Dependable");
  }else{
    $("#fixed_basic_wage_edit_info").text("*No = Worked Days Dependable");
  }
})
$('body').on('click', '#employee_edit_btn', function() {
  var no = $(this).closest('tr').children('td');
  $('#employee_id_edit').val(no.eq(1).text());
  $('#name_edit').val(no.eq(2).text());
  $('#employee_code_edit').val(no.eq(3).text());
  $('#designation_edit').val(no.eq(5).text());
  $('#contact_no_edit').val(no.eq(6).text());
  $('#address_edit').val(no.eq(7).text());
  if(no.eq(8).text()!=''){
    $('input[type=radio][name=gender_edit][value='+no.eq(8).text()+']').prop('checked',true);
  }
  $('#dob_edit').datepicker("setDate", no.eq(9).text());
  $('#nationality_edit').val(no.eq(10).text());
  $('#sponsor_edit').val(no.eq(11).text());
  $('#work_location_edit').val(no.eq(12).text());
  $('#arrived_date_edit').datepicker("setDate", no.eq(13).text());
  $('#joined_date_edit').datepicker("setDate", no.eq(14).text());
  var basic_wage_type = no.eq(16).text();
  $("input[name=basic_wage_type_edit][value='"+basic_wage_type+"']").prop('checked', 'checked');
  $('#basic_wage_edit').val(no.eq(15).text());
  var basic_wage_fixed = no.eq(41).text();
  $("input[name=fixed_basic_wage_edit][value='"+basic_wage_fixed+"']").prop('checked', 'checked');
  if(basic_wage_type=='Monthly'){
    $("#fixed_basic_wage_edit_no").attr('disabled',false);
  }else{
    $("#fixed_basic_wage_edit_no").attr('disabled',true);
  }
  if(basic_wage_fixed==1){
    $("#fixed_basic_wage_edit_info").text("*Yes = Worked Days Not Dependable");
  }else{
    $("#fixed_basic_wage_edit_info").text("*No = Worked Days Dependable");
  }
  $('#opening_balance_edit').val(no.eq(18).text());
  $('#food_allowance_edit').val(no.eq(19).text());
  $('#incentive_edit').val(no.eq(20).text());
  $('#civil_id_edit').val(no.eq(21).text());
  $('#civil_id_expiry_date_edit').datepicker("setDate", no.eq(22).text());
  $('#passport_no_edit').val(no.eq(25).text());
  $('#passport_expiry_date_edit').datepicker("setDate", no.eq(26).text());
  $('#health_card_no_edit').val(no.eq(29).text());
  $('#health_card_expiry_date_edit').datepicker("setDate", no.eq(30).text());
  $('#bank_name_edit').val(no.eq(31).text());
  $('#bank_account_no_edit').val(no.eq(32).text());
  $('#bank_card_expiry_date_edit').datepicker("setDate", no.eq(33).text());
  $('#t_shirt_size_edit').val(no.eq(34).text());
  $('#shoes_size_edit').val(no.eq(35).text());
  $('#pant_size_edit').val(no.eq(36).text());
  $('#biometric_id_edit').val(no.eq(37).text());
  select_hr_department('hr_department_edit',no.eq(43).text());

  var assigned_vehicles = (no.eq(44).text()).split(',');
  $('#assigned_vehicles_edit').val(assigned_vehicles).trigger('change');
})
$('body').on('click', '#employee_delete_btn', function() {
  var no = $(this).closest('tr').children('td');
  $('#employee_id_delete').val(no.eq(1).text());
})

</script>
