<?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_perte_stock.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">Perte stock</h3>
              </div>
              <!-- /.card-header -->
              <div class="card-body">
               



                <table id="example1" class="table table-bordered table-striped" style="width:100%">
        <thead>
            <tr>
                <th>Date Perte</th>
                <th>Type Bouteille</th>
                <th>Taille</th>
                <th>Quantite</th>
                <th>Date</th>
                <th>Motif</th>
            </tr>
        </thead>
        <tbody>
          <?php

          $resultat=$this->Model->getRequete('SELECT `ID_RETOUR_STOCK`, `DATE_RETOUR_STOCK`, syst_type_bouteille.DESCRIPTION AS TYPE_BOUTEILLE, syst_taille_bouteille.DESCRIPTION AS TAILLE_BOUTEILLE, `QUANTITE`, stock_motif_retour.DESCRIPTION AS MOTIF, `DATE_ENREGISTREMENT`, `ID_USER`, `COMMENTAIRE` FROM `stock_retour_stock` JOIN syst_type_bouteille ON syst_type_bouteille.ID_TYPE_BOUTEILLE = stock_retour_stock.ID_TYPE_BOUTEILLE JOIN syst_taille_bouteille ON syst_taille_bouteille.ID_TAILLE_BOUTEILLE = stock_retour_stock.ID_TAILLE_BOUTEILLE JOIN stock_motif_retour ON stock_motif_retour.ID_MOTIF_RETOUR = stock_retour_stock.ID_MOTIF_RETOUR WHERE  PERTE_RETOUR = 2 AND syst_type_bouteille.ID_TYPE_BOUTEILLE=2');

          foreach ($resultat as $key) 
         {
          
      
          
          echo "<tr>
                <td>".$key['DATE_RETOUR_STOCK']."</td>
                <td>".$key['TYPE_BOUTEILLE']."</td>
                <td>".$key['TAILLE_BOUTEILLE']."</td>
                <td>".$key['QUANTITE']."</td>
                <td>".$key['DATE_ENREGISTREMENT']."</td>";
          echo "<td>



          <div class='modal fade' id='modalmotif".$key['ID_RETOUR_STOCK']."'>
        <div class='modal-dialog modal-lg'>
          <div class='modal-content'>
            <div class='modal-header'>
              <h4 class='modal-title'>Motif</h4>
              <button type='button' class='close' data-dismiss='modal' aria-label='Close'>
                <span aria-hidden='true'>&times;</span>
              </button>
            </div>
            
            
            <div class='modal-body'>
            <div class='form-group col-lg-12'>
            ".$key['MOTIF']."
              </div>
            </div>
            
            <div class='modal-footer justify-content-between'>
              <button type='button' class='btn btn-default' data-dismiss='modal'>Fermer</button>
            </div>
            
            
          </div>
        </div>
      </div>
          




          
          
          <a class='btn btn-xs btn-primary' data-toggle='modal' data-target='#modalmotif".$key['ID_RETOUR_STOCK']."' href='#'> Motif </a></td>";
               
         echo "</tr>";
       }
          ?>
            
        </tbody>
        
    </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>

<script type="text/javascript">
  function changelist() {
document.getElementById("myForm").submit();
  }

  $('#reservation').daterangepicker({

        locale: {
        format: 'DD/MM/YYYY'
      }
    })
  $('.select').select2();

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