<?php
session_start();
$pageSequence = $_SESSION['sequence'];
$toDiv = "contentZone" . $pageSequence;
$resultZoneDiv = "resultZone" . $pageSequence;
$tableZone = "#tableZone" . $pageSequence;
$tblName = "tblReport" . $pageSequence;
$btAdd = "btnAdd" . $pageSequence;
$btDel = "btnDel" . $pageSequence;
$btDelObj = "btnDelObj" . $pageSequence;
$dataSection = "dataSection" . $pageSequence;
$frmName = "form" . $pageSequence;
$resultPath = "resultPath".$pageSequence;

$startDateTimeName = "startDate".$pageSequence ;
$endDateTimeName = "endDate".$pageSequence ;

$startDate = date('Y-m-d')." 00:00:00";
$endDate = date('Y-m-d'). " 23:59:59";

$rPage = $_REQUEST['rPage'];
$rDiv = $_REQUEST['rDiv'];
if (isset($_REQUEST['opId'])) {
    $opId = $_REQUEST['opId'];
}

$_SESSION['sequence']++;
//echo  dirname(__FILE__);  
//echo $_SERVER['DOCUMENT_ROOT'] . "   ".dirname(__FILE__)."  ".str_replace($_SERVER['DOCUMENT_ROOT'],"",dirname(__FILE__)) ;

$currentBaseDir = dirname($_SERVER['PHP_SELF']);
include($_SESSION['basedir'] . "veriflog.php");
include($_SESSION['basedir'] . "core.php");

//$res = $dba->getUserDetailByRight($_SESSION['right'], $_SESSION['ownerId'], false, 0, 0);
$teamList = $dba->getAllTeam(0, false) ;
?>

<!-- Main content -->
<div id="<?php echo $dataSection; ?>">
    <section class="content">
        <div class="row">
            <div class="col-sm-8">
                <div class="panel panel-bd lobidrag">
                    <div class="panel-heading">
                        <div class="btn-group">
                            <a href="#">
                                <h4>Statistiques des equipes la plus efficacement</h4>
                            </a>
                        </div>
                    </div>
                    <div class="panel-body">


                        <form action="<?php echo $currentBaseDir; ?>/rpt_get_scc_stats_teams_efficace.php"  method="post" onsubmit="return false;" id="<?php echo $frmName; ?>">

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



                                <div class="form-group">
                                    <label>Date de début</label>
                                    <div class="form-group">

                                        <div class='input-group date' id='<?php echo $startDateTimeName; ?>'>
                                            <input name="startDateTime" type='text' class="form-control" id="startDateTime"  value="<?php echo $startDate; ?>" size="10"/>
                                            <span class="input-group-addon">
                                                <span class="glyphicon glyphicon-calendar"></span>
                                            </span>
                                        </div>


                                    </div>
                                </div>




                                <div class="form-group">
                                    <label>Date de fin</label>
                                    <div class="form-group">
                                        <div class='input-group date' id='<?php echo $endDateTimeName; ?>'>
                                            <input name="endDateTime" type='text' class="form-control" id="endDateTime"  value="<?php echo $endDate; ?>" size="10"/>
                                            <span class="input-group-addon">
                                                <span class="glyphicon glyphicon-calendar"></span>
                                            </span>
                                        </div>
                                    </div>
                                </div>



                                <div class="reset-button">
                                    <button   type="submit" class="btn addition">Afficher</button>  <button type="button" class="btn close-btn" >Fermer</button>
                                </div>


                            </div>

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




                                <div class="form-group">
                                    <label>Granularité</label>
                                    <select name="granularity" id="granularity" class="form-control">
                                        <option value="%d/%m/%Y %H" >Heure</option>
                                        <option value="%d/%m/%Y" selected="selected" >Jour</option>
                                        <option value="%m/%Y" >Mois</option>



                                    </select>
                                </div>
                                
                       
                                  

                            </div>


                        </form>

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

    </section>

    <section class="content">
        <div class="row">
            <div class="col-sm-12">
                <div class="panel panel-bd lobidrag">
                    <div class="panel-heading">
                        <div class="btn-group" id="buttonexport">
                            <a href="#">
                                <h4>Résultats</h4>
                            </a>
                        </div>
                    </div>
                    <div class="panel-body">
                        
                          <div id="<?php echo $resultPath;  ?>">
                            
                            
                        </div>

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

    </section>
</div>
<script src="plugins/datatables/jquery.dataTables.min.js"></script>
<script src="plugins/datatables/dataTables.bootstrap.min.js"></script>
<script src="plugins/datatables/dataTables.buttons.min.js"></script>
<script src="plugins/datatables/buttons.html5.min.js"></script>
<script type="text/javascript" src="js/jquery.loading.min.js"></script>


<!-- /.content -->
<script type="text/javascript" >
                                        $(document).ready(function () {
                                            
                                            
                                            var dataUrl = "<?php echo $currentBaseDir; ?>/return_json_default.php?json=[]"  ; 
	table = $('#<?php echo $tblName; ?>').DataTable( {
		               ajax: {
								url: dataUrl,
								method: "POST",
								dataSrc: '' 
							  },
						columns : [
									{ data: "Date" },
									{ data: "Qualification" },
									{ data: "Total" }
								]
				         ,
						 processing : true
						,
				        "language": {
						"search": "Filtrer:",
						"emptyTable" : "Table vide",
						"zeroRecords":    "Table vide",
						"lengthMenu":     "Nombre de lignes  _MENU_ ",
					
						"info":           "Affichage de  _START_ &aacute; _END_ sur  _TOTAL_ entr&eacute;es",
						"paginate": {
							"first":      "D&eacute;but",
							"last":       "Fin",
							"next":       "Suivant",
							"previous":   "Pr&eacute;c&eacute;dent"
						},
						"infoEmpty":      "Affichage de  0 &agrave; 0 sur  0 entr&eacute;es"
					  }
					});
                                           

                                            
                                        });
</script>


<script type="text/javascript">
    
    
      $(".close-btn").on('click', function () {
        // create the backdrop and wait for next modal to be triggered
        // $('body').modalmanager('loading');
        $('#loader').loading({
            message: "Chargement...",
            theme: 'dark'

        });

        $("#content-wrapper").load("<?php echo $rPage; ?>");
        $('#loader').loading('stop');

    });
    
    
    

    $('#<?php echo $frmName; ?>').on("submit", function (event) {
        $('#loader').loading({
            message: "Chargement...",
            theme: 'dark'

        });
        var tableStats = $("form").attr('tableStats');
        var chartStats = $("form").attr('chartStats');
        /* var startDateTime = document.getElementById('startDateTime').value;
         var endDateTime = document.getElementById('endDateTime').value;
         var userId = document.getElementById('userId').value;
         var status = document.getElementById('status').value;
         var statsMode = document.getElementById('statsMode').value;
         */

        ///alert(tableStats + "   " + chartStats );

        $.post($(this).attr("action"), $(this).serialize(), function (data) {


           $("#<?php echo $resultPath;  ?>").html(data);

            $('#loader').loading('stop');
            /*
             if ( $.fn.dataTable.fnIsDataTable( '#tblGlobalStats' ) ){
             //alert("Alload");
             // reload instead
             
             
             }
             else {
             
             
             
             } */

        });







        // return false; // prevent normal submit
        event.preventDefault();

    });
    
    
    
    $(function () {
                            $('#<?php echo $startDateTimeName; ?>').datetimepicker({format: 'yyyy-mm-dd hh:ii:ss', autoclose:true, language:'fr'});
                            
                            
                            
                        });

                    
                    
                        $(function () {
                            $('#<?php echo $endDateTimeName; ?>').datetimepicker({format: 'yyyy-mm-dd hh:ii:ss', autoclose:true, language:'fr'});
                        });
                        

</script>

<script type="text/javascript" src="js/jquery.loading.min.js"></script>
<link rel="stylesheet" href="css/jquery-confirm.min.css">
<script src="js/jquery-confirm.min.js"></script>