 <?php include_once PUBLIC_PATH. '/files_to_include/header_content.php'; ?>
<!-- =============================================== -->

  <!-- Left side column. contains the sidebar -->
  <aside class="main-sidebar" id="aside_menu" >
      <section class="sidebar">
          <ul class="sidebar-menu">
            <?php include_once PUBLIC_PATH. '/files_to_include/menu.php'; ?>
          </ul>
      </section>
  </aside>
   <!-- Content Wrapper. Contains page content -->
   <div class="content-wrapper " style="background-color: white; td{border: solid  2px #000; }">
   

    <!-- Main content -->
    <section class="content">
        <div class="row">
         <div class="col-lg-offset-1 col-lg-11">
              
              <div id="connectheader">
                <div class="page-header">                    
                  <h3><span class="glyphicon glyphicon-th-list"></span> Liste des profils</h3>
                </div>
              </div>
             <div class="col-lg-12" style="position: relative;top: -20px;">
                  <a class="pull-right" href="<?php echo $this->url(array('controller' => 'Profil', 'action' => 'enregistrer'), NULL, TRUE); ?>"><button type="button" class="btn btn-microsoft"><i class="fa fa-plus-circle fa-3x"></i></button></a><br/><br/>
              </div>
           
              
              <table id="mytable" class="table table-responsive table-bordered">
                        <thead>
                           <th>N°</th>
                           <th>Nom</th>
                           <th>Unite organisationnelle</th>
                           <th>Actions</th>
                        </thead>
                        <tfoot>
                           <th>N°</th>
                           <th>Nom</th>
                           <th>Unite organisationnelle</th>
                           <th>Actions</th>
                        </tfoot>
                        <tbody>
                    <?php
                     $i = 1;
                        foreach( $this->listeprofils as $profil){
                            $idp = $profil->getIdprofil();
                            ?>
                        <tr>
                        <td><?php echo $i;?></td>
                        <td><?php echo $profil->getNom();?></td>
                        <td><?php echo $profil->getOrgunit();?></td>
                        <td>
                            <!-- <a href="<?php echo $this->url(array('controller' => 'Profil', 'action' => 'consulter' , 'id' =>$idp)); ?>"><i class='fa fa-search' ></i></a> -->
                            <a href="<?php echo $this->url(array('controller' => 'Profil', 'action' => 'editer' , 'id' =>$idp) ); ?>"><i class='fa fa-1x fa-edit clickcursor bluelink' ></i></a>
                            <a href="#" onclick="deleteLine(<?= $idp; ?>, <?= $i++; ?>)"> <span title='Supprimer' class='glyphicon glyphicon-trash bluelink'></span> </a>
                        </td>
                        </tr>
               <?php    }
                    ?>
                        </tbody>
                    </table>
          </div>
      </div>
     

    </section>
    <!-- /.content -->
  </div>
  <!-- /.content-wrapper -->
 <?php include_once PUBLIC_PATH. '/files_to_include/footer_content.php'; ?>
  
   <!-- Sripts -->	
    <script src="<?php echo $this->baseUrl('script/jquery.min.js');?>"></script>
    <script src="<?php echo $this->baseUrl('script/bootstrap.min.js');?>"></script>
    <script src="<?php echo $this->baseUrl('script/app.min.js');?>"></script>
    <script src="<?php echo $this->baseUrl('script/i18next-1.7.1.min.js');?>"></script>
    <script src="<?php echo $this->baseUrl('script/metisMenu.min.js');?>"></script>
    <script src="<?php echo $this->baseUrl('script/sb-admin-2.js');?>"></script>
    <script src="<?php echo $this->baseUrl("script/jquery.dataTables.min.js");?>"></script>
    <script src="<?php echo $this->baseUrl("script/dataTables.bootstrap.min.js");?>"></script>
    <script src="<?php echo $this->baseUrl("script/pdfmake.min.js");?>"></script>
    <script src="<?php echo $this->baseUrl("script/vfs_fonts.js");?>"></script>
    <script src="<?php echo $this->baseUrl("script/jquery.toast.min.js");?>"></script>
  <script src="<?php echo $this->baseUrl("script/jquery-confirm.min.js");?>"></script>
    <script src="<?php echo $this->baseUrl('script/loadingoverlay.min.js');?>"></script>
    <script type="text/javascript">
        
        $(document).ajaxSend(function(event, jqxhr, settings){
            $.LoadingOverlay("show");
        });
        
        $(document).ajaxComplete(function(event, jqxhr, settings){
            $.LoadingOverlay("hide");
        });
        
      
      $("#mytable").DataTable({
                                "language": {
                                    "zeroRecords": " aucune donnée disponible ",
                                    "infoEmpty": "Aucune donnée disponible",
                                    "search": "recherche",
                                    "infoFiltered": ""
                                },
                                "bLengthChange": false,
                                "destroy" : true,
                                dom: 'Bfrtip',
                                buttons: [
                                  'copy', 'csv', 'excel', 'pdf', 'print'
                                ]
                              });
        
function deleteLine(idf, val)
{
     $.confirm({
                title: 'Suppression',
                content: "Voulez-vous vraiment supprimer cet profil?",
                theme: 'white',
                animationBounce: 2.5,
                confirmButton: 'supprimer',
                cancelButton: 'annuler',
                autoClose: "cancel|15000",
                confirm: function() {

                   $.ajax({
        // chargement du fichier externe monfichier-ajax.php 
        url      : "<?php echo $this->url(array('controller' => 'Profil', 'action' => 'supprimer')); ?>",
        // Passage des données au fichier externe (ici le nom cliqué)  
        //data     : {NomEleve: "M3B"}, 
        data     : {id: idf},
        cache    : false,
        dataType : "text",
        error    : function(request, error) { // Info Debuggage si erreur         
                     //alert("Erreur : responseText: "+request.responseText);
                   },
       success: function (response) { //message venant du controlleur/serveur
                    var res = JSON.parse(response);
                    if ($.trim(res.msg) == "Succes") {
                        window.location.href = "<?php echo $this->url(array('controller' => 'Profil', 'action' => 'index'),null,true); ?>";
                    }
                    else {
                        //alert(res.msg.toString());
                        $("#msg").show();
                        $('#msg').html(res.msg);
                       $('#msg').delay(1000).fadeOut(2000);
                    }
                    //console.log(response);
                }      
     });

                }
            });
      
     //---
    return false;    
    }
    

    </script>

</body>

</html>