 <?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-10">
              <div class="alert alert-danger" id="msg" style="display:none" class="col-sm-2">
                 <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
              </div>
              <div id="connectheader">
                <div class="page-header">                    
                  <h3><span class="glyphicon glyphicon-th-list"></span>  Rapport des actitivités des utilisateurs (Log)</h3>
                </div>
              </div>
             <div class="row">
           
           

               
                    <div class="row">

                        <div class="form-group col-lg-6 col-sm-6 col-xs-6">

                            <label for="pointDeVente">Utilisateur:</label>
                            <select class="form-control selectpicker" id="utilisateur" name="utilisateur" data-live-search='true'>
                                
                                 <option value="-1" > --- Tous ---</option>
                                 <?php
                                    foreach ($this->listeUtilisateur as $elt) :
                                    ?>
                                 <option value='<?php echo $elt->getIdutilisateur() ?>'><?php echo utf8_encode($elt->getIdpersonne()->getNom()." ".$elt->getIdpersonne()->getPrenom()); ?></option>                           

                                    <?php
                                endforeach;
                               ?>
                            </select>
                        </div>
                         <div class="col-lg-6 col-sm-6 col-xs-6">
                        <div class="form-group">
                            <label for="periode">Période</label>
                            <input placeholder="période de consultation" name="periode" id="periode" class="form-control picker" onchange=""/>
                        </div>
                    </div>
                    </div>
                <div class="clearfix"></div>
                <div class="col-sm-12">
                    <!-- <button class=" btn btn-primary pull-right" rel="">Imprimer</button>-->
                    <button  class="btn btn-microsoft" id="print">Afficher</button>
                </div>
                
                <div class="clearfix"></div>

                <div class="clearfix"></div>
                <hr/> 
                <div  id="cacher" class="hidden"  cellspacing="0" width="100%">
                <table id="table" class='table-bordered table-striped table' cellspacing='15' width='100%'>
            <thead>
            <tr>
                <th>N°</th>
                <th>Utilisateur</th>
                <th>Activités</th>
                <th>Date </th>
            </tr>
                    </thead>
                     <tbody id='contenu'></tbody>
                    <tfoot>
            <tr>
                <th>N°</th>
                <th>Utilisateur</th>
                <th>Activités</th>
                <th>Date </th>
            </tr>
                    </tfoot>
                   
                        
                    </table>
                </div>


            
                 </div>
          </div>
      </div>
     

    </section>
    <!-- /.content -->
  </div>
  <!-- /.content-wrapper -->
 <?php include_once PUBLIC_PATH. '/files_to_include/footer_content.php'; ?>
  
   <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/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/jquery.datetimepicker.full.js");?>"></script>
      <script src="<?php echo $this->baseUrl("script/moment.js");?>"></script>
      <script src="<?php echo $this->baseUrl("script/daterangepicker.js"); ?>"></script>
      <script src="<?php echo $this->baseUrl("script/bootstrap.select.min.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 options = {};
    $('#rtl-wrap').show();
    options.locale = {
        direction: $('#rtl').is(':checked') ? 'rtl' : 'ltr',
        format: 'YYYY/MM/DD',
        separator: ' - ',
        applyLabel: 'Apply',
        cancelLabel: 'Cancel',
        fromLabel: 'From',
        toLabel: 'To',
        customRangeLabel: 'Custom',
        daysOfWeek: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'],
        monthNames: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
        firstDay: 1
    };
  var    myTable = $("#table").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'
                                ]
                            });
     $('#periode').daterangepicker(options);
      
      $("#print").click(function(){
                //pointDeVente = getSelectValue("pointDeVente");
                
                var list = $("#periode").val();
        list = list.toString();
        var chaine1 = list.substr(0, list.search("-"));
        var chaine2 = list.substr(12, list.length + 1);
//        var date1 = new Date(list.substr(0, list.search("-")));
//        var date2 = new Date(list.substr(11, list.length + 1));
                var params = { user: "", dated: "", datef: ""};
                if ($("#utilisateur").val() !== "-1")
                    params.user = $("#utilisateur").val();
                if ($("#dated").val() !== "")
                    params.dated = chaine1;
                if ($("#datef").val() !== "")
                    params.datef = chaine2;
               $.ajax({
              url: "<?php echo $this->url(array('controller' => 'Log', 'action' => 'index')); ?>",
            dataType: "json",
            type: "POST",
            data: params,
            beforeSend: function () {
                $("#contenu").LoadingOverlay("show");
            },
            success: function (response) {
                 if (response.type =="success") {
                     $("#cacher").removeClass("hidden");
                      $("#table").DataTable().row().destroy();
                            $("#contenu").html(response.table);
                            
                            myTable = $("#table").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'
                                ]
                            });
                             myTable.rows().draw();
                            //document.getElementById("login").value=''; 
                        }else{
                             $.toast({
                                    heading: "erreur",
                                    text: "un problème est survenu lors de la consultation",
                                    icon: "error",
                                    hideAfter: false,
                                    stack: false,
                                    position: 'mid-center'
                                });
                        }
            },
            complete: function () {
                $("#contenu").LoadingOverlay("hide");
            },
            error: function () {

            }
        });

              
      }) 
          
                
            
    </script>

</body>

</html>