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

<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_bouteille.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 bouteille 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>Description</th>
                      <th>S Vide</th>
                      <th>S Remplie</th>
                      <th>Details</th>
                      <th>Quantite L</th>
                      <th>Etat</th>
                      <th>Options</th>
                    </tr>
                  </thead>
                  <tbody>

                    <?php
                    foreach ($resultat as $key) 
                    {
                     $commune= $this->Model->getRequete("SELECT standard_prix_status.*,standard_status.DESCRIPTION FROM `standard_prix_status` JOIN standard_status ON standard_status.ID_STANDARD=standard_prix_status.ID_STANDARD WHERE `ID_TAILLE_BOUTEILLE` = ".$key['ID_TAILLE_BOUTEILLE']."");
                     $datas= '<table class="table">';
                     $datas.='<tr>

                     <td class="text-right"><b>Qualite</b></td>
                     <td class="text-right"><b>Montant</b></td>
                     <td class="text-right"><b>Actions</b></td>

                     </tr>';
                     $totolpayabe =0;
                     foreach($commune as $commun){

                      $datas.= '<tr>
                      <td>'.$commun["DESCRIPTION"].'</td>
                      <td class="text-right">'.$commun["MONTANT"].'</td>
                      <td class="text-right"><a class="dropdown-item" href="'.base_url("configuration/Type_Bouteille/prix_update/".$commun['ID_STANDARD_PRIX']).'">   <i class="fas fa-edit"></i> </a>
                      </td>

                      </tr>';

                    }
                    $datas.= '</table>';

                    if(!empty($commune)){
                      $dets= "<td>  <button type='button' class='btn btn-primary btn-xs' data-toggle='modal' data-target='#myModal".$key['ID_TAILLE_BOUTEILLE']."'>
                      <i class='fas fa-eye'></i>
                      </button>

                      <!-- Modal -->
                      <div class='modal fade' id='myModal".$key['ID_TAILLE_BOUTEILLE']."' tabindex='-1' role='dialog' aria-labelledby='myModalLabel'>
                      <div class='modal-dialog' role='document'>
                      <div class='modal-content'>
                      <div class='modal-header'>
                      <h4 class='modal-title' id='myModalLabel'>Details</h4>
                      <button type='button' class='close' data-dismiss='modal' aria-label='Close'><span aria-hidden='true'>&times;</span></button>

                      </div>
                      <div class='modal-body'>
                      ".$datas."
                      </div>
                      <div class='modal-footer'>
                      <button type='button' class='btn btn-default' data-dismiss='modal'>Fermer</button>
                      </div>
                      </div>
                      </div>
                      </div></td>";
                    }else{
                     $dets= "<td><i class='fas fa-circle-notch'></i></td>";

                   }



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

                   echo "<tr>
                   <td>".$key['DESCRIPTION']."</td>
                   <td>".$key['LIMITE_VIDE']."</td>
                   <td>".$key['LIMITE_PLEIN']."</td>
                   ".$dets."

                   <td>".$key['QUANTITE_LITRE']."</td>

                   <td>".$stat."</td>
                   <td><div class='modal fade' id='desactcat".$key['ID_TAILLE_BOUTEILLE']."' 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['DESCRIPTION'].")?</h6>
                   </div>
                   <div class='modal-footer'>
                   <button type='button' class='btn btn-default' data-dismiss='modal'>Annuler</button>
                   <a href='".base_url("configuration/Type_Bouteille/".$fx."/".$key['ID_TAILLE_BOUTEILLE'])."' 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("configuration/Type_Bouteille/index_update/".$key['ID_TAILLE_BOUTEILLE'])."'> Modifier </a> </li>
                   <li><a class='dropdown-item' href='#' data-toggle='modal' data-target='#desactcat".$key['ID_TAILLE_BOUTEILLE']."'> ".$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)');
    $(this).removeClass('btn-default').addClass('btn-primary btn-dark');

  });
</script>
</body>
</html>
