<?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_type_document_interne.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 de type de documents interne 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>Details</th>
                    <th>Etat</th>
                    <th>Action</th>
                  </tr>
                  </thead>
                  <tbody>

                  <?php
                    foreach ($resultat as $key) 
                    {

                      
                      $etape=$this->Model->getRequete('SELECT doc_interne_etape.DESCRIPTION, config_profil.DESCRIPTION AS PROFIL, NUMERO FROM `doc_interne_etape` JOIN config_profil ON config_profil.PROFIL_ID = doc_interne_etape.ID_PROFIL WHERE ID_TYPE_DOC_INTERNE = '.$key['ID_TYPE_DOC_INTERNE'].' AND doc_interne_etape.STATUS=1 ORDER BY NUMERO');
                      $tables='<table class="table">';
                      $tables.='<tr>';
                        $tables.='<td>Nom</td>';
                        $tables.='<td>Profil</td>';
                        $tables.='<td>Numero</td>';
                        $tables.='</tr>';
                      foreach ($etape as $value) {
                        $tables.='<tr>';
                        $tables.='<td>'.$value['DESCRIPTION'].'</td>';
                        $tables.='<td>'.$value['PROFIL'].'</td>';
                        $tables.='<td>'.$value['NUMERO'].'</td>';
                        $tables.='</tr>';
                      }
                      $tables.='</table>';

                     
                     if ($key['STATUS'] == 1) {
                       $fx = 'desactiver';
                       $col = 'btn-danger';
                       $titr = 'Désactiver';
                       $stitr = 'voulez-vous désactiver ce type de documents ';
                       $bigtitr = 'Désactivation de ce type de documents';
                       $stat ='Actif';
                     }
                     else{
                       $fx = 'reactiver';
                       $col = 'btn-primary';
                       $titr = 'Réactiver';
                       $stitr = 'voulez-vous réactiver ce type de documents ';
                       $bigtitr = 'Réactivation de ce type de documents';
                       $stat ='Innactif';
                     }

                     echo "<tr>
                     <td>".$key['DESCRIPTION']."</td>
                     <td>
                     
                     <button type='button' class='btn btn-primary btn-xs' data-toggle='modal' data-target='#myModal".$key['ID_TYPE_DOC_INTERNE']."'><i class='fa fa-list'></i> Details</button>
  <div class='modal fade' id='myModal".$key['ID_TYPE_DOC_INTERNE']."' tabindex='-1' role='dialog' aria-labelledby='myModalLabel'>
  <div class='modal-dialog modal-lg' role='document'>
    <div class='modal-content '>
      <div class='modal-header'>
        <button type='button' class='close' data-dismiss='modal' aria-label='Close'><span aria-hidden='true'>&times;</span></button>
        
      </div>
      <div class='modal-body'>
      ".$tables."
      </div>
      <div class='modal-footer'>
        <button type='button' class='btn btn-default' data-dismiss='modal'>Close</button>
      </div>
    </div>
  </div>
</div>
                     </td>
                     <td>".$stat."</td>
                     <td><div class='modal fade' id='desactcat".$key['ID_TYPE_DOC_INTERNE']."' 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."desactcat</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['DESCRIPTION'].")?</h6>
                         </div>
                         <div class='modal-footer'>
                           <button type='button' class='btn btn-default' data-dismiss='modal'>Annuler</button>
                           <a href='".base_url("document_interne/Type_Documents/".$fx."/".$key['ID_TYPE_DOC_INTERNE'])."' 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("document_interne/Type_Documents/index_update/".$key['ID_TYPE_DOC_INTERNE'])."'> Modifier </a> </li>
                                       <li><a class='dropdown-item' href='#' data-toggle='modal' data-target='#desactcat".$key['ID_TYPE_DOC_INTERNE']."'> ".$titr." </a> </li>
                                       </ul>
                                     </div></td>
                   </tr>";
           
                }
                  ?>
                  
                  </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>
