<?php
  include VIEWPATH.'includes/new_header.php';
  ?>
  
<body class="hold-transition sidebar-mini">
<!-- Site wrapper -->
<div class="wrapper">
  <?php
  include VIEWPATH.'includes/new_top_menu.php';
  include VIEWPATH.'includes/new_menu_principal.php';
  ?>

  

  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <?php 
    include 'includes/menu_employe.php';
    ?>

    <!-- Main content -->
    <section class="content">

      <!-- Default box -->
      <div class="card">
      
      <div class="card card-primary">
              <div class="card-header">
                <h3 class="card-title">Modification d'un Employé</h3>
              </div>
              <!-- /.card-header -->
              <!-- form start -->
              <form id="FormData" action="<?php echo base_url()?>rh/Employe/update" method="POST" enctype="multipart/form-data">
                <div class="card-body row">
                <div class="col-lg-12">
                <h5 >Employ&eacute;</h5>
                </div>
                  <div class="form-group col-lg-6">
                    <label for="exampleInputEmail1">Nom</label>
                    <input type="text" class="form-control" id="NOM" name="NOM" value="<?php echo $data['NOM']?>">
                    <input type="hidden" id="ID_EMPLOYE" name="ID_EMPLOYE" value="<?php echo $data['ID_EMPLOYE']?>">
                    <?php echo form_error('NOM', '<div class="text-danger">', '</div>'); ?>
                  </div> 

                  <div class="form-group col-lg-6">
                    <label for="exampleInputEmail1">Pr&eacute;nom</label>
                    <input type="text" class="form-control" id="PRENOM" name="PRENOM" value="<?php echo $data['PRENOM']?>">
                    <?php echo form_error('PRENOM', '<div class="text-danger">', '</div>'); ?>
                  </div> 

                  <div class="form-group col-lg-6">
                    <label for="exampleInputEmail1">Sexe</label><br>
                    <div class="icheck-primary d-inline">
                        <input type="radio" name="ID_SEXE" value="1" <?php if ($data['ID_SEXE'] == 1) { echo
                          'checked'; }  ?> id="radioSuccess1">
                        <label for="radioSuccess1">
                          Homme
                        </label>
                      </div>
                      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                        <div class="icheck-success d-inline">
                        <input type="radio" name="ID_SEXE" value="2" <?php if ($data['ID_SEXE'] == 2) { echo
                          'checked'; }  ?> id="radioSuccess2">
                        <label for="radioSuccess2">
                          Femme
                        </label>
                      </div>
                    <?php echo form_error('ID_SEXE', '<div class="text-danger">', '</div>'); ?>
                  </div> 

                  <div class="form-group col-lg-6">
                    <label for="exampleInputPassword1">Date d'entree en service</label>
                    <div class="input-group date" id="DATE_ENTRE_SERVICE" data-target-input="nearest">
                        <input type="text" class="form-control datetimepicker-input" data-target="#DATE_ENTRE_SERVICE" name="DATE_ENTRE_SERVICE" value="<?=set_value('DATE_ENTRE_SERVICE')?>"/>
                        <div class="input-group-append" data-target="#DATE_ENTRE_SERVICE" data-toggle="datetimepicker">
                            <div class="input-group-text"><i class="fa fa-calendar"></i></div>
                        </div>
                    </div>
                    <?php echo form_error('DATE_ENTRE_SERVICE', '<div class="text-danger">', '</div>'); ?>
                  </div>

                  <div class="form-group col-lg-6">
                    <label for="exampleInputEmail1">E-mail</label>
                    <input type="email" class="form-control" id="EMAIL" name="EMAIL" value="<?php echo $data['EMAIL']?>">
                    <?php echo form_error('EMAIL', '<div class="text-danger">', '</div>'); ?>
                  </div> 

                  <div class="form-group col-lg-6">
                    <label for="exampleInputEmail1">T&eacute;l&eacute;phone</label>

                    <div class="input-group mb-3">
                  <div class="input-group-prepend">
                    <span class="input-group-text">+257</span>
                  </div>
                  <input type="number" class="form-control" id="TEL" name="TEL"  value="<?php echo $data['TEL']?>">
                </div>
                    <?php echo form_error('TEL', '<div class="text-danger">', '</div>'); ?>
                  </div> 

                  <!-- <h5 class="mt-4 mb-2"></h5> -->
                  <div class="col-lg-12">
                <h5>Affectation de l'employ&eacute;</h5>
                </div>

                <div class="form-group col-lg-3">
                    <label for="exampleInputEmail1">Responsabilit&eacute;</label>
                    <select class="custom-select" name="ID_RESPONSABILITE" id="ID_RESPONSABILITE">
                          <option>-- Select --</option>
                          <?php
                          foreach ($responsabilite as $responsabilites) {
                            if ($responsabilites['ID_RESPONSABILITE']==$affectation['ID_RESPONSABILITE']) {
                              echo"<option value='".$responsabilites['ID_RESPONSABILITE']."' selected>".$responsabilites['DESCRIPTION']."</option>";
                            }
                            else{
                              echo"<option value='".$responsabilites['ID_RESPONSABILITE']."'>".$responsabilites['DESCRIPTION']."</option>";
                            }
                           
                          }
                          ?>
                        </select>
                    
                    <?php echo form_error('ID_RESPONSABILITE', '<div class="text-danger">', '</div>'); ?>
                  </div>
                    
                  <div class="form-group col-lg-3">
                    <label for="exampleInputEmail1">Direction</label>
                        <select class="custom-select" name="ID_DIRECTION" id="ID_DIRECTION" onchange="get_departement(this)" >
                          <option>-- Select --</option>
                          <?php
                          foreach ($direction as $directions) {
                            if ($directions['ID_DIRECTION'] == $affectation['ID_DIRECTION']) {
                              echo"<option value='".$directions['ID_DIRECTION']."' selected>".$directions['DESCRIPTION']."</option>";
                            }
                            else{
                              echo"<option value='".$directions['ID_DIRECTION']."'>".$directions['DESCRIPTION']."</option>";
                            }
                           
                          }
                          ?>
                        </select>
                    
                    <?php echo form_error('ID_DIRECTION', '<div class="text-danger">', '</div>'); ?>
                  </div> 

                  <div class="form-group col-lg-3">
                    <label for="exampleInputEmail1">Departement</label>
                    
                    <select class="custom-select" name="ID_DEPARTEMENT" id="ID_DEPARTEMENT" onchange="get_service(this)">
                          <option>-- Select --</option>
                          <?php
                          foreach ($departement as $departements) {
                            if ($departements['ID_DEPARTEMENT'] == $affectation['ID_DEPARTEMENT']) {
                              echo"<option value='".$departements['ID_DEPARTEMENT']."' selected>".$departements['DESCRIPTION']."</option>";
                            }
                            else{
                              echo"<option value='".$departements['ID_DEPARTEMENT']."'>".$departements['DESCRIPTION']."</option>";
                            }
                           
                          }
                          ?>
                        </select>
                    
                    <?php echo form_error('ID_DEPARTEMENT', '<div class="text-danger">', '</div>'); ?>
                  </div> 

                  <div class="form-group col-lg-3">
                    <label for="exampleInputEmail1">Service</label>
                    <select class="custom-select" name="ID_SERVICE" id="ID_SERVICE">
                    <?php
                          foreach ($service as $services) {
                            if ($services['ID_SERVICE'] == $affectation['ID_SERVICE']) {
                              echo"<option value='".$services['ID_SERVICE']."' selected>".$services['DESCRIPTION']."</option>";
                            }
                            else{
                              echo"<option value='".$services['ID_SERVICE']."'>".$services['DESCRIPTION']."</option>";
                            }
                           
                          }
                          ?>
                        </select>
                    
                    <?php echo form_error('ID_SERVICE', '<div class="text-danger">', '</div>'); ?>
                  </div> 

                  
                  
                   
                  
                  
                       
                 
                  
                </div>
                <!-- /.card-body -->

                <div class="card-footer">
                  <button type="submit" class="btn btn-primary btn-block">Enregistrer</button>
                </div>
              </form>
            </div>
        
        
        <!-- /.card-body -->
        <!-- <div class="card-footer">
          Footer
        </div> -->
        <!-- /.card-footer-->
      </div>
      <!-- /.card -->

    </section>
    <!-- /.content -->
  </div>
  <!-- /.content-wrapper -->

  <?php
 include VIEWPATH.'includes/new_copy_footer.php';  
  ?>
  <!-- /.control-sidebar -->
</div>
<!-- ./wrapper -->
<?php
  include VIEWPATH.'includes/new_script.php';
  ?>
<script>

function get_departement(va){
 var ID_DIRECTION= $(va).val();
 $.post('<?php echo base_url('rh/Employe/get_departement')?>',
     {ID_DIRECTION:ID_DIRECTION},
     function(data){
       $('#ID_DEPARTEMENT').html(data);
     });
}
</script>

<script>

function get_service(va){
 var ID_DEPARTEMENT= $(va).val();
 $.post('<?php echo base_url('rh/Employe/get_service')?>',
     {ID_DEPARTEMENT:ID_DEPARTEMENT},
     function(data){
       $('#ID_SERVICE').html(data);
     });
}
</script>
<script>
  $(function () {
   
    //Date picker
    $('#DATE_ENTRE_SERVICE').datetimepicker({
        format: 'L'
    });   

  })
 


</script>
</body>
</html>