<?php
  include VIEWPATH.'includes/new_header.php';
  ?>
<body class="hold-transition sidebar-mini">
<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">
      <div class="container-fluid">
        <div class="row">
          <div class="col-12">
            
            <!-- /.card -->

            <div class="card card-primary">
              <div class="card-header">
                <h3 class="card-title">Liste des employ&eacute; d&eacute;j&agrave; enregistr&eacute;</h3>
              </div>
              <!-- /.card-header -->
              <div class="card-body">
                <table id="example1" class="table table-bordered table-striped table-hover">
                  <thead>
                  <tr>
                    <th>Nom</th>
                    <th>Sexe</th>
                    <th>Email</th>
                    <th>Telephone</th>
                    <th>Depuis</th>
                    <th>Affectation</th>
                    <th>Status</th>
                    <th>Action</th>
                  </tr>
                  </thead>
                  <tbody>

                  <?php
                    foreach ($resultat as $key) 
                    {
                     
                     if ($key['STATUS'] == 1) {
                       $stat = 'Actif';
                       $fx = 'desactiver';
                       $col = 'btn-danger';
                       $titr = 'Désactiver';
                       $stitr = 'voulez-vous désactiver cet employ&eacute; ';
                       $bigtitr = 'Désactivation de cet employ&eacute;';
                     }
                     else{
                       $stat = 'Innactif';
                       $fx = 'reactiver';
                       $col = 'btn-primary';
                       $titr = 'Réactiver';
                       $stitr = 'voulez-vous réactiver cet employ&eacute; ';
                       $bigtitr = 'Réactivation de cet employ&eacute;';
                     }

                     echo "<tr>
                     <td>".$key['NOM']." ".$key['PRENOM']."</td>
                     <td>".$key['SEXE']."</td>
                     <td>".$key['EMAIL']."</td>
                     <td>".$key['TEL']."</td>
                     <td>".$key['DATE_ENTRE_SERVICE']."</td>
                     <td>
                     <div class='modal fade' id='affectation".$key['ID_EMPLOYE']."'>
        <div class='modal-dialog'>
          <div class='modal-content'>
            <div class='modal-header'>
              <h4 class='modal-title'>Affectation de ".$key['NOM']." ".$key['PRENOM']."</h4>
              <button type='button' class='close' data-dismiss='modal' aria-label='Close'>
                <span aria-hidden='true'>&times;</span>
              </button>
            </div>
            <div class='modal-body'>
              <table class='table'>
                     <tr>
                      <td>Direction</td>
                      <td>".$key['DIRECTION']."</td>
                     </tr>
                     <tr>
                      <td>Service</td>
                      <td>".$key['SERVICE']."</td>
                     </tr>
                     <tr>
                      <td>Section</td>
                      <td>".$key['SECTION']."</td>
                     </tr>
                     <tr>
                      <td>Debut Affectation</td>
                      <td>".$key['DATE_DEBUT']."</td>
                     </tr>
                     <tr>
                      <td>Role dans les congés</td>
                      <td>".$key['RESPONSABILITE']."</td>
                     </tr>
              </table>
            </div>
            <div class='modal-footer justify-content-between'>
              <button type='button' class='btn btn-primary' data-dismiss='modal'>Fermer</button>
            </div>
          </div>
        </div>
      </div>
                    <button type='button' class='btn btn-primary btn-sm' data-toggle='modal' data-target='#affectation".$key['ID_EMPLOYE']."'>
                  Affectation
                </button>
                     </td>
                     <td>".$stat."</td>
                     <td><div class='modal fade' id='desactcat".$key['ID_EMPLOYE']."' tabindex='-1' role='dialog' aria-labelledby='basicModal' aria-hidden='true'>
                     <div class='modal-dialog modal-sm'>
                       <div class='modal-content'>
                         <div class='modal-header'>
                           <h4 class='modal-title' id='myModalLabel'>".$bigtitr."</h4>
                           <button type='button' class='close' data-dismiss='modal' aria-label='Close'>
                             <span aria-hidden='true'>&times;</span>
                           </button>
                         </div>
                         <div class='modal-body'>
                           <h6><b>Mr/Mme , </b> ".$stitr." (".$key['NOM']." ".$key['NOM'].")?</h6>
                         </div>
                         <div class='modal-footer'>
                           <button type='button' class='btn btn-default' data-dismiss='modal'>Annuler</button>
                           <a href='".base_url("rh/Employe/".$fx."/".$key['ID_EMPLOYE'])."' class='btn ".$col."'>".$titr."</a>
                         </div>
                       </div>
                     </div>
                   </div>
                   
                             <div class='dropdown '>
                                       <a class='btn btn-primary btn-sm dropdown-toggle' data-toggle='dropdown'>Actions
                                       <span class='caret'></span></a>
                                       <ul class='dropdown-menu dropdown-menu-right'>
                                       <li><a class='dropdown-item' href='".base_url("rh/Employe/details/".$key['ID_EMPLOYE'])."'> Details et Historique </a> </li>
                                       <li><a class='dropdown-item' href='".base_url("rh/Employe/index_update/".$key['ID_EMPLOYE'])."'> Modifier </a> </li>
                                       <li><a class='dropdown-item' href='#' data-toggle='modal' data-target='#desactcat".$key['ID_EMPLOYE']."'> ".$titr." </a> </li>
                                       </ul>
                                     </div></td>
                   </tr>";
           
                     
                                     
                  // $tabledata[]=$chambr;
                }
                  ?>
                  
                  </tfoot>
                </table>
              </div>
              <!-- /.card-body -->
            </div>
            <!-- /.card -->
          </div>
          <!-- /.col -->
        </div>
        <!-- /.row -->
      </div>
      <!-- /.container-fluid -->
    </section>
    <!-- /.content -->
  </div>
  <!-- /.content-wrapper -->

  <?php
 include VIEWPATH.'includes/new_copy_footer.php';  
  ?>
  

  <!-- Control Sidebar -->
  <aside class="control-sidebar control-sidebar-dark">
    <!-- Control sidebar content goes here -->
  </aside>
  <!-- /.control-sidebar -->
</div>

<!-- ./wrapper -->
<?php
  include VIEWPATH.'includes/new_script.php';
  ?>

<!-- Page specific script -->
<script>
  $(function () {
    $("#example1").DataTable({
      "responsive": true, "lengthChange": false, "autoWidth": false,
      "buttons": [ "excel", "pdf", "print", "colvis"]
    }).buttons().container().appendTo('#example1_wrapper  .col-md-6:eq(0)');
   
  });
</script>
</body>
</html>
