<?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_demande_conge.php';
    ?>

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

      <!-- Default box -->
      <div class="card">
      
      <div class="card card-primary">
              <div class="card-header">
                <h3 class="card-title">Ajout des jours de cong&eacute;</h3>
              </div>
              <?php 
             if(!empty($this->session->flashdata('message')))
               echo $this->session->flashdata('message');
               // echo $this->table->generate($employe);
            ?>
              <!-- /.card-header -->
              <!-- form start -->
              <form id="FormData" action="<?php echo base_url()?>conge/Enregistrer_Conge/add" method="POST" accept-charset="utf-8" enctype="multipart/form-data">
                <div class="card-body row">
                
                <div class="form-group col-lg-4">
                    <label for="exampleInputEmail1">Direction <spam class="text-danger">*</spam></label>
                    <select class="custom-select" name="ID_DIRECTION" id="ID_DIRECTION" onchange="get_departement(this)">
                          <option>-- Select --</option>
                          <?php
                          foreach ($direction as $directions) {
                           echo"<option value='".$directions['ID_DIRECTION']."'>".$directions['DESCRIPTION']."</option>";
                          }
                          ?>
                        </select>
                    
                  </div>
                   <div class="form-group col-lg-4">
                     <label for="exampleInputEmail1">Service</label>
                     <select class="custom-select" name="ID_SERVICE" id="ID_SERVICE" onchange="get_service(this)" >
                          
                         </select>
                    
                   </div> 

                   <div class="form-group col-lg-4">
                     <label for="exampleInputEmail1">Section</label>
                     <select class="custom-select" name="ID_SECTION" id="ID_SECTION" onchange="get_employe(this)">
                          
                         </select>
                    
                   </div>  

                  

                   <div class="form-group col-lg-12">
                     <label for="exampleInputEmail1">Employ&eacute; <spam class="text-danger">*</spam></label>
                     <select class="form-control select2 select2-primary"  id="ID_EMPLOYE" name="ID_EMPLOYE" data-dropdown-css-class="select2-primary" style="width: 100%;">
                    
                     <option>-- Select --</option>
                   </select>

                   </div> 

                  <?php
                // }
                  ?>

                  

                  

                  

                <!-- <div class="col-lg-12">
                <h5 >Employ&eacute;</h5>
                </div> -->
                  

                  <div class="form-group col-lg-4">
                    <label for="exampleInputEmail1">Type conge <spam class="text-danger">*</spam></label>
                    <select class="custom-select" name="ID_TYPE_CONGE" id="ID_TYPE_CONGE">
                          <option>-- Select --</option>
                          <?php
                          foreach ($type_conge as $type_conges) {
                           echo"<option value='".$type_conges['ID_TYPE_CONGE']."'>".$type_conges['NOM_CONGE']."</option>";
                          }
                          ?>
                        </select>
                    <?php echo form_error('ID_TYPE_CONGE', '<div class="text-danger">', '</div>'); ?>
                  </div> 

                  <!-- <div class="form-group col-lg-3" id="resultas">
                  <label for="exampleInputEmail1">Nb de jours Restant</label> <input type="number" class="form-control" id="SOLDE_NB_JOURS" name="SOLDE_NB_JOURS" value="">
                  </div>  -->

                  <div class="form-group col-lg-4">
                    <label for="exampleInputEmail1">Nb de jours restant <spam class="text-danger">*</spam></label>
                    <input type="number" class="form-control" id="NB_JOURS_CREDITE" name="NB_JOURS_CREDITE" placeholder="" value="<?=set_value('NB_JOURS_CREDITE')?>">
                    <?php echo form_error('NB_JOURS_CREDITE', '<div class="text-danger">', '</div>'); ?>
                  </div> 

                  <div class="form-group col-lg-4">
                    <label for="exampleInputPassword1">Exercice <spam class="text-danger">*</spam></label>
                    <select class="custom-select" name="ID_EXERCICE" id="ID_EXERCICE">
                          <option>-- Select --</option>
                          <?php
                          foreach ($exercices as $exercicess) {
                           echo"<option value='".$exercicess['ID_EXERCICE']."'>".$exercicess['DESCRIPTION']."</option>";
                          }
                          ?>
                        </select>
                    </div>
                    <?php echo form_error('ID_EXERCICE', '<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();
//  alert(ID_DIRECTION);
 $.post('<?php echo base_url('rh/Employe/get_departement')?>',
     {ID_DIRECTION:ID_DIRECTION},
     function(data){
       $('#ID_SERVICE').html(data);
     });

 $.post('<?php echo base_url('conge/Demande_Conge/get_departement')?>',
     {ID_DIRECTION:ID_DIRECTION},
     function(data){
       $('#ID_EMPLOYE').html(data);
     });

}
</script>

<script>
function get_service(va){
 var ID_SERVICE= $(va).val();
 $.post('<?php echo base_url('rh/Employe/get_service')?>',
     {ID_SERVICE:ID_SERVICE},
     function(data){
       $('#ID_SECTION').html(data);
     });
 $.post('<?php echo base_url('conge/Demande_Conge/get_service')?>',
     {ID_SERVICE:ID_SERVICE},
     function(data){
       $('#ID_EMPLOYE').html(data);
     });
}
</script>

<script>

function get_employe(va){
 var ID_SECTION= $(va).val();
 
 $.post('<?php echo base_url('conge/Demande_Conge/get_employe')?>',
     {ID_SECTION:ID_SECTION},
     function(data){
       $('#ID_EMPLOYE').html(data);
     });
}
</script>

<script>

// function get_credit_conge(va){

//  $.post('<?php echo base_url('conge/Demande_Conge/get_credit_conge')?>',
//      {
//       ID_EMPLOYE:$('#ID_EMPLOYE').val(),
//       ID_TYPE_CONGE:$('#ID_TYPE_CONGE').val()
//      },
//      function(data){
//        $('#resultas').html(data);
//      });
// }
</script>
<script>
  $(function () {
   
    //Date picker
    $('#DATE_ENTRE_SERVICE').datetimepicker({
        format: 'L'
    });   

  })
 


</script>
<script>
  $(function () {
    //Initialize Select2 Elements
    $('.select2').select2()

    //Initialize Select2 Elements
    $('.select2bs4').select2({
      theme: 'bootstrap4'
    })
  })
</script>

<script>
  $(function () {
    //Date picker
    $('#DATE_DEMANDE').datetimepicker({
        format: 'L'
    });   
  })
</script>
</body>
</html>
