<?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;
$currentBaseDir = dirname($_SERVER['PHP_SELF']);
include($_SESSION['basedir'] . "core.php");

$svaTool = new svaTool();

$errorCode = 0;

$password = NULL;
$confPasswd = NULL;

$startDateTime = addslashes($_REQUEST['startDateTime']);
$endDateTime = addslashes($_REQUEST['endDateTime']);
$userId = addslashes($_REQUEST['userId']);
$status = addslashes($_REQUEST['statut']);
$granularity = $_REQUEST['granularity'];
//$teamId = addslashes($_REQUEST['teamId']);
$customerType = addslashes($_REQUEST['customerType']);

//print_r($_REQUEST);
/*
  $startDateTime = "2019-04-01 00:00:00";
  $endDateTime =  "2019-05-01 00:00:00";
  $userId = 66;
  $status =-1;
 */

$res = $dba->getTop10CompaniesByType($customerType,$startDateTime, $endDateTime, $granularity, 10);
$data = "";

$cmpt = 1;
$total = count($res);

?>

<div class="btn-group">

    <button class="btn  btn-sm dropdown-toggle" data-toggle="dropdown"><i class="fa fa-bars"></i> Exporter</button>
    <ul class="dropdown-menu exp-drop" role="menu">
        <li>
            <a href="#" onclick="$('#<?php echo $tblName; ?>').tableExport({type: 'excel', escape: 'false'});" > ,
                <img src="assets/dist/img/xls.png" width="24" alt="logo"> XLS</a>
        </li>
        <li>
            <a href="#" onclick="$('#<?php echo $tblName; ?>').tableExport({type: 'csv', escape: 'false'});"> 
                <img src="assets/dist/img/csv.png" width="24" alt="logo"> CSV</a>
        </li>
        <li>
            <a href="#" onclick="$('#<?php echo $tblName; ?>').tableExport({type: 'txt', escape: 'false'});"> 
                <img src="assets/dist/img/txt.png" width="24" alt="logo"> TXT</a>
        </li>

        <li class="divider"></li> 
    </ul>

</div>

<!-- ./Plugin content:powerpoint,txt,pdf,png,word,xl -->
<div class="table-responsive">

    <table id="<?php echo $tblName; ?>"  width="100%" height="100%" class="table table-striped table-bordered" >
        <thead>
            <tr>
                <th>Date</th>
                <th>Raison Sociale</th>
                <th>Total</th>
            </tr>
        </thead>
        
        
         <tbody>
            <?php for ($i = 0; $i < $total; $i++) { ?>
                <tr>
                    <td><?php echo $res[$i]['eventDate']; ?></td>
                    <td><?php echo $res[$i]['location_v']; ?></td>
                    <td><?php echo $res[$i]['total']; ?></td>
                </tr>

            <?php } ?>
        </tbody>
        
    </table>



</div>

<script type="text/javascript" >
    $(document).ready(function () {





        var dataUrl = "<?php echo $currentBaseDir; ?>/return_json_default.php?json=[]";
        table = $('#<?php echo $tblName; ?>').DataTable();



    });
</script>