 <?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' => 'Role', '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-striped table-bordered dt-responsive nowrap" style="width:100%">
            <thead>
                <tr>
                    <th>Code</th>
                    <th>Label</th>
                    <th>Description</th>
                    <th>Actions</th>
                </tr>
            </thead>
            <tfoot>
                <tr>
                    <th>Code</th>
                   <th>Label</th>
                    <th>Description</th>
                     <th>Actions</th>
                </tr>
            </tfoot>
            <tbody>
            </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/sb-admin-2.js');?>"></script>
    <script src="<?php echo $this->baseUrl("script/jquery.dataTables.min.js");?>"></script>
    <script src="<?php echo $this->baseUrl("script/dataTableResponsive.js");?>"></script>
    <script src="<?php echo $this->baseUrl("script/dataTables.bootstrap.min.js");?>"></script>
    <script src="<?php echo $this->baseUrl("script/dataTables.buttons.min.js");?>"></script>
    <script src="<?php echo $this->baseUrl("script/jszip.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/buttons.html5.min.js");?>"></script>
    <script src="<?php echo $this->baseUrl("script/buttons.print.min.js");?>"></script>
    <script src="<?php echo $this->baseUrl('script/loadingoverlay.min.js');?>"></script>
     <script src="<?php echo $this->baseUrl('script/jquery.slimscroll.min.js');?>"></script>
      <script src="<?php echo $this->baseUrl("script/jquery-confirm.min.js");?>"></script>
      <script src="<?php echo $this->baseUrl('script/jquery.toast.min.js');?>"></script> 
      <script src="<?php echo $this->baseUrl('script/canvasjs.min.js');?>"></script>
      <script src="<?php echo $this->baseUrl("script/moment.js");?>"></script>
<!-- FastClick -->
<script src="<?php echo $this->baseUrl('script/fastclick.js');?>"></script>
<!-- AdminLTE App -->
<script src="<?php echo $this->baseUrl('script/adminlte.min.js');?>"></script>
<script src="<?php echo $this->baseUrl('script/demo.js');?>"></script>
     <script type="text/javascript">
          $(document).ajaxSend(function(event, jqxhr, settings){
            $.LoadingOverlay("show");
        });
        
        $(document).ajaxComplete(function(event, jqxhr, settings){
            $.LoadingOverlay("hide");
        });
        $('.sidebar-menu').tree();
        
        
       
      
      var $myTable = $("#mytable").DataTable({
                                 responsive: true,
                                "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'
                                ],
                                 scrollY: 50,
                scroller: {
                    loadingIndicator: true
                },
                                "processing" : true,
                                "serverSide" : true,
                                "ajax" : {
                                         url : "<?php echo $this->url(array('controller' => 'Role', 'action' => 'datatable')); ?>",
                                         type : "POST"
                                },
                                columns : [
                                                    null,
                                                    null,
                                                    null,
                                                   { render : function(data, type, row, meta) {
                                                         return '<a href="/qms/public/customer/' + row[0] + '/edit">Edit</a>';
                                                     }
                                                   }, 
                                                  
                                                    
                                              ]
                              });
    
   $("body").on("click",".deletePurpose",function(e){
           e.preventDefault();
           var idUser = parseInt($(this).attr("idUtilisateur"));
           var parent = $(this).parent().parent();
           $.confirm({
                title: 'Suppression',
                content: "Voulez-vous vraiment supprimer cet utilisateur?",
                theme: 'white',
                animationBounce: 2.5,
                confirmButton: 'supprimer',
                cancelButton: 'annuler',
                autoClose: "cancel|15000",
                confirm: function() {

                    var params = {idUser: idUser};
                    $.ajax({
                        url: "<?php echo $this->url(array('controller' => 'Utilisateur', 'action' => 'supprimer')); ?>",
                        type: "POST",
                        dataType: "json",
                        data: params,
                        success: function(data) {
                            if (data.type === "success") {
                                $myTable.row(parent).remove().draw();
                            } else {
                                $.toast({
                                    heading: "erreur",
                                    text: "un problème est survenu lors de la suppression",
                                    icon: "error",
                                    hideAfter: false,
                                    stack: false,
                                    position: 'mid-center'
                                });
                            }
                        },
                        error: function() {
                            $.toast({
                                    heading: "serveut inactif",
                                    text: "MVOLYEMANAGER n'arrive pas à accéder au serveur , si cela persiste veuillez contacter MELLCO",
                                    icon: "error",
                                    hideAfter: false,
                                    stack: false,
                                    position: 'mid-center'
                            });
                        }
                    });

                }
            });
        });
        $("body").on("click",".consultePurpose",function(e){
           e.preventDefault();
           var idUser = parseInt($(this).attr("idUtilisateur"));
           //var parent = $(this).parent().parent();
           var params = {idUser: idUser};
                    $.ajax({
                        url: "<?php echo $this->url(array('controller' => 'Utilisateur', 'action' => 'consulter')); ?>",
                        type: "POST",
                        dataType: "json",
                        data: params,
                        success: function(data) {
                           
                        },
                        error: function() {
                            $.toast({
                                    heading: "serveut inactif",
                                    text: "MVOLYEMANAGER n'arrive pas à accéder au serveur , si cela persiste veuillez contacter MellGroup ",
                                    icon: "error",
                                    hideAfter: false,
                                    stack: false,
                                    position: 'mid-center'
                            });
                        }
                    });
        });
    </script>

</body>

</html>