<?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) -->
    
    <section class="content-header">
      <div class="container-fluid">
        <div class="row mb-2">
          <div class="col-sm-6">
            <h1><?php echo $title?></h1>
          </div>
          <div class="col-sm-6 text-right">
          <a class="btn btn-outline-primary btn-sm <?php if($this->router->method == 'index') echo 'active';?>" href="<?=base_url('requisition_externe/Stock')?>">En stock actuel</a>
          <a class="btn btn-outline-primary btn-sm <?php if($this->router->method == 'listing') echo 'active';?>" href="<?=base_url('requisition_externe/Stock/listing')?>">Pas en stock</a>
          </div>
        </div>
      </div><!-- /.container-fluid -->
    </section>

    <!-- 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 elements <?php if($this->router->method == 'index') echo 'En stock actuellement';?> <?php if($this->router->method == 'listing') echo 'Pas en stock actuellement';?></h3>
              </div>
              <!-- /.card-header -->
              <div class="card-body">
                <table id="example1" class="table table-bordered table-striped table-hover">
                  <thead>
                  <tr>
                    <th>Article</th>
                    <th>Date Demande</th>
                    <th>Q. Recu</th>
                    <th>Q. Actuel</th>
                    <th>Q. Sortie</th>
                    <th>Détail Sortie</th>
                    <th>Détail Acquition</th>
                  </tr>
                  </thead>
                  <tbody>

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

                     echo "<tr>
                     <td>".$key['ARTICLE_ELEMENT']."</td>
                     <td>".$key['DATE_DEMANDE']."</td>
                     <td>".$key['QUANTITE_ENTREE_STOCK']."</td>
                     <td>".$key['QUANTITE_ACTUEL']."</td>
                     <td>".$key['QUANTITE_SORTIE']."</td>
                     <td>
                     
                     <button type='button' class='btn btn-primary btn-xs' data-toggle='modal' data-target='#myModal".$key['ID_REQ_EXTERNE_STOCK']."'><i class='fa fa-list'></i> Details de sortie</button>
  <div class='modal fade' id='myModal".$key['ID_REQ_EXTERNE_STOCK']."' 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'>
      
      </div>
      <div class='modal-footer'>
        <button type='button' class='btn btn-default' data-dismiss='modal'>Close</button>
      </div>
    </div>
  </div>
</div>
                     </td>
                     <td>
                    
                   </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>
