<!DOCTYPE html>
<html lang="en">

<head>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">
    <title>SalesM</title>
    <link href="<?php echo $this->baseUrl('css/bootstrap.min.css');?>" rel="stylesheet">
    <link rel="icon" type="image/png" href="<?php echo $this->baseUrl('img/logo_fag.png');?>" />
    <link href="<?php echo $this->baseUrl('css/metisMenu.min.css');?>" rel="stylesheet">
    <link href="<?php echo $this->baseUrl('css/sb-admin-2.css');?>" rel="stylesheet">
    <link href="<?php echo $this->baseUrl('css/morris.css');?>" rel="stylesheet">
    <link href="<?php echo $this->baseUrl('css/font-awesome.min.css');?>" rel="stylesheet" type="text/css">
    <link href="<?php echo $this->baseUrl('css/dataTables.bootstrap.min.css');?>" rel="stylesheet">
    <link href="<?php echo $this->baseUrl('css/buttons.bootstrap.min.css');?>" rel="stylesheet">
    <link href="<?php echo $this->baseUrl('css/buttons.dataTables.min.css');?>" rel="stylesheet">
    <link href="<?php echo $this->baseUrl('css/jquery.dataTables.min.css');?>" rel="stylesheet">
    <link rel="stylesheet" href="<?php echo $this->baseUrl('/css/jquery-confirm.min.css');?>">
    <link href="<?php echo $this->baseUrl('css/jquery.toast.min.css');?>" rel="stylesheet">
    <link href="<?php echo $this->baseUrl('css/jquery.datetimepicker.min.css');?>" rel="stylesheet">
    <link href="<?php echo $this->baseUrl("css/bootstrap-select.min.css");?>" rel="stylesheet">
</head>


<body>
    
     <div id="wrapper">
            
            <!-- Navigation -->
        <nav class="navbar navbar-default navbar-static-top" role="navigation" style="margin-bottom: 0">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <h5 class="navbar-brand">PV Manager</h5></a>
            </div>

            <ul class="nav navbar-top-links navbar-right">
<!--                <li class="dropdown">
                    <a class="dropdown-toggle" data-toggle="dropdown" href="#">
                        <i class="fa fa-bell fa-fw"></i>  <i class="fa fa-caret-down"></i>
                    </a>
                    <ul class="dropdown-menu dropdown-alerts">
                        <li>
                            <a href="#">
                               
                            </a>
                        </li>
                    </ul>
                     /.dropdown-alerts 
                </li>-->
                <li class="dropdown">
                    <a class="dropdown-toggle" data-toggle="dropdown" href="#">
                        <i class="fa fa-user fa-fw"></i>  <i class="fa fa-caret-down"></i>
                    </a>
                    <ul class="dropdown-menu dropdown-user">
                        <li><a href="#"><i class="fa fa-user fa-fw"></i>Profil</a>
                        </li>
                        <li class="divider"></li>
                        <li><a href="<?php echo $this->url(array('controller' => 'Index', 'action' => 'deconnexion')); ?>"><i class="fa fa-sign-out fa-fw"></i>Déconnexion</a>
                        </li>
                    </ul>
                </li>
            </ul>
            <!-- /.navbar-top-links -->
            <!-- La partie menu doit venir d'un fichier externe à inclure -->
            <?php include_once PUBLIC_PATH. '/files_to_include/navigation.php'; ?>
        </nav>

            
            <div id="page-wrapper">
                <div class="row">
                    <div class="col-lg-12">
                        <h3 class="page-header"><span class="fa fa-bars" style="color:blue;"></span> Rapport des actitivités des utilisateurs (Log) </h3>
                    </div>
                </div>
                <div class="row">
                    
    
            <form role="form" method='post' action="" class="col-lg-12">

                <div>
                    <div class="col-sm-12">

                        <div class="form-group">

                            <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>
           
                    <div class="clearfix"></div>

                    
                    <div class="col-sm-6">
                        <div class="form-group">
                            <label for="dated">Date Début :</label>
                            <input placeholder="entrez une date" name="dated" id="dated" class="form-control picker" onchange=""/>
                        </div>
                    </div>
                    <div class="col-sm-6">
                        <div class="form-group">
                            <label for="datef">Date Fin:</label>
                            <input placeholder="entrez une date" name="datef" id="datef" 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-primary" id="affiche"  onclick="Afficher();">Afficher</button>
                </div>
                <div class="clearfix"></div>

                <div class="clearfix"></div>
                <hr/> 
                <div id="table" class="hidden" cellspacing="0" width="100%">
                <table id='classictable' 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>
                    <tfoot>
            <tr>
                <th>N°</th>
                <th>Utilisateur</th>
                <th>Activités</th>
                <th>Date </th>
            </tr>
                    </tfoot>
                    <tbody id='contenu'>
                    </table>
                </div>


            </form>
            <div class="clearfix"></div>
       
             
                </div>
            </div>
            </div>
     <div class="row">
                <div style="background-color : #1ab7ea ; min-height: 70px ; position: absolute; bottom :0px;">
                   <br/><p class="col-lg-12" style="text-align: center; color: white;">Conçu par <a style="color: black;" href="http://fagiciel.com">FAGICIEL</a></p>
               </div>
     </div>
        <!--  -->
        <!-- js file -->
    <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/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/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/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/bootstrap.select.min.js");?>"></script>

        <!-- Sripts -->
        <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");
        });
         
         $("#menu-44").addClass("active");
         $("#menu-8").addClass("active");
         $('#side-menu').metisMenu();
      
         var Tableo;
        
         jQuery.datetimepicker.setLocale('fr');
         $(".picker").datetimepicker({
            timepicker: false,
            format: 'd-m-Y'
         });
         $('.print').on("click",function(e){
                e.preventDefault();
//                pointDeVente = getSelectValue("pointDeVente");
//                if(pointDeVente == -2){
//                     $("#msg").show();
//                        $('#msg').html("Sélectionner un point de vente");
//                       $('#msg').delay(1000).fadeOut(2000);
//                       return;
//                }
                var params = { caissier : "", modepaiement: "", dated: "", datef: ""};
                            
                if ($("#dated").val() !== "")
                    params.dated = $("#dated").val();
                if ($("#datef").val() !== "")
                    params.datef = $("#datef").val();
               
        $.ajax({
                    // chargement du fichier externe monfichier-ajax.php 
                    url: "<?php echo $this->url(array('controller' => 'Mvtcaisse', 'action' => 'imprimerrapportcaisse')); ?>",
                    // Passage des données au fichier externe (ici le nom cliqué)  
                    //data     : {NomEleve: "M3B"}, 
                    data: params,
                    cache: false,
                    dataType : "json",
                    error: function(request, error) { // Info Debuggage si erreur         
                        alert("Erreur : responseText: "+request.responseText);
                    },
                    success: function(data) {
                       data.public =  "http://" + data.public + "/" + data.fichier;
                        window.open(data.public); 
                        $.toast({
                               heading : 'statut',
                               text : " Si le fichier ne s'ouvre pas , <a href='" + data.public + "' target=_blank >  cliquer ici </a>",
                               icon : 'info',
                               hideAfter : false,
                               position : { top : cursorY - 100 , left : cursorX -250 }
                        });
                    },
                    complete: function() { // Info Debuggage si erreur         
                        //$("#loadueclass").removeClass("fa fa-spinner fa-spin");
                    }
                });
		return false;
         });      
            
         $("#affiche").on("click",function(e){
             e.preventDefault();
            // Afficher();
         });
    
    
         function Afficher() { 
                //pointDeVente = getSelectValue("pointDeVente");
                var params = { user: "", dated: "", datef: ""};
                if ($("#utilisateur").val() !== "-1")
                    params.user = $("#utilisateur").val();
                if ($("#dated").val() !== "")
                    params.dated = $("#dated").val();
                if ($("#datef").val() !== "")
                    params.datef = $("#datef").val();
             

                $.ajax({ //alert('Affiche bien ici');
                    // chargement du fichier externe monfichier-ajax.php 
                    url: "<?php echo $this->url(array('controller' => 'Log', 'action' => 'index')); ?>",
                    
                    data: params,
                    cache: false,
                    dataType: "json",
                    error: function(request, error) {      
                        //alert("Erreur : responseText: "+request.responseText);
                    },
                    success: function(data) {
                        if (data.msg === 0) {
                            $("#table").removeClass("hidden");
                            $("#table").show();
                            $("#table").empty();
                            $("#table").html(data.msg2);
                            Tableo = $("#classictable").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'
                                ]
                            });
                            //document.getElementById("login").value=''; 
                        } else {
                            $("#msg1").attr("class", "alert alert-danger");
                            $("#msg1").show();
                            $("#msg1").html(data.msgerr);
                            setTimeout(function() {
                                $("#msg1").hide();
                            }, 3000);
                        }
                    },
                    complete: function() { // Info Debuggage si erreur         
                        //$("#loadueclass").removeClass("fa fa-spinner fa-spin");
                    }
                });
                //---
                return false;
            }
            
          

    
           

        </script>
    </body>








