<?php 
include('config.php');
if(hasAccessTo('DAILY')){
?>
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
	<meta name="description" content="">
	<meta name="author" content="">
	<title>Statistiques journalières</title>
	<?php include('include/css.php') ?>
</head>

<body>
<?php include('header.php') ?>
<?php
  $filterAgencies = ((isset($GLOBALS["STATS_CONF"]["CLOISONNEMENT"]) && $GLOBALS["STATS_CONF"]["CLOISONNEMENT"]) || ($_SESSION['user'] == "admin" && $_SESSION["profil"] != 100)) ? true : false;
  $profils_access = $GLOBALS["BO_CONF"]["ACCESS_PROFILES"]["CHARTS"] ? $GLOBALS["BO_CONF"]["ACCESS_PROFILES"]["CHARTS"] : array('1','2','10');
  $filter = ((!hasAccess(false,true) || (isset($_SESSION['profil']) && in_array($_SESSION["profil"], $profils_access))) && $filterAgencies) ? (' AND id_agence IN ('.getAllowedAgencies().')') : '';
  $result = excuteQuery('select nom_agence, id_agence, code_agence  from '.AGENCIES_TABLE.' where supp = 0'.$filter.' and is_active = 1 order by nom_agence');
//  var_dump($result['stmt']->fetchAll());exit;
  ?>
<div class="container-fluid">
  	<div class="row">
      <div class="col-md-12 col-lg-12 title card-box">     
        <form autocomplete="off" class="form-inline" id="chart_filter" method="post">
        <div class="form-group col-12 col-lg-4 col-md-5 col-sm-12">
            <label for="agence" class="inline-form-label">Agence :</label>
            <select class="form-control" id="agence" name="agence">
                <option value="">-- Sélectionner --</option>                
                <?php while($row =$result['stmt']->fetch(PDO::FETCH_ASSOC)){ ?>
                  <option value="<?= $row['id_agence']?>" <?php if($_SESSION['user'] == 'conseiller' && $_SESSION['agence'] == $row['id_agence']) echo 'selected'; ?>><?php echo $row['nom_agence']?></option>
                <?php } ?>
              </select>
          </div>
          
          <div class="form-group col-12 col-lg-4 col-md-5 col-sm-12">
            <label for="jour" class="inline-form-label">Jour :</label>
            <input type="text" class="form-control date_picker" id="jour" placeholder="Sélectionner une date" name="jour" autocomplete="off">
          </div>

          <div class="form-group col-12 col-lg-4 col-md-2 col-sm-6 m-top-button"> 
            <button type="submit" class="btn btn-primary ld-ext-right" id="submit-btn"> Soumettre <div class="ld ld-ring ld-spin"></div></button>
          </div>
        </form>          
      </div>
      
    </div>

    <div class="row display-none chart-summery">
    	<div class="card-box col-md-12 col-lg-12">
        <div class="row">
          <h6 class="col-sm-12 col-md-4 col-lg-4 mt-1 mb-0 boldfont">
            STATISTIQUES JOURNALIERES
          </h6>
          <h6 class="col-sm-12 col-md-4 col-lg-4 agence-name mt-1 mb-0 boldfont">
            
          </h6>
          <h6 class="col-sm-12 col-md-4 col-lg-4 generate-time mt-1 mb-0 boldfont">
            
          </h6>
        </div>          
      </div>
    </div>

    <div class="row chart-result-summery">
    	<div class="card-box col-md-12 col-lg-12 ">
        <div id="cardValue"></div>  
      </div>
    </div>

    <div class="row display-none chart-div">
      <div class="card-box-chart col-md-12 col-lg-12">
          <h5 class="text-dark header-title m-t-0 m-b-30 textcenter">Nombre de visites journalières (par 1/2 heure)</h4>
          <div class="widget-chart pull-in text-center">
            <div id="chart_div1" class="chartMinhight"></div>
          </div>
      </div>
    </div>

  <div class="row display-none chart-div">
    <div class="card-box-chart col-md-12 col-lg-12 ">
        <h5 class="text-dark header-title m-t-0 m-b-30 textcenter">Part des RDV (jour)</h4>
        <div class="widget-chart pull-in text-center">
          <div id="chart_div2" class="chartMinhight"></div>
        </div>
    </div>
  </div>

  <div class="row display-none chart-div">
    <div class="card-box-chart col-md-12 col-lg-12 ">
        <h5 class="text-dark  header-title m-t-0 m-b-30 textcenter">Comparaison jour sélectionné / journée type (nombre total de visites)</h4>
        <div class="widget-chart pull-in text-center">
          <div id="chart_div3" class="chartMinhight"></div>
        </div>
    </div>
  </div>  
  
</div>

<!-- /.container -->
<!-- Bootstrap core JavaScript -->
<?php include('include/js.php') ?>
<script type="text/javascript" src="chartjs/dailychart.js?123"></script>
<?php
}
else{
?>
	<h2>Vous n'&ecirc;tes pas autoris&eacute; &agrave; acc&eacute;der &agrave; cette page !</h2>
<?php
}
?>
</body>
</html>