<?php 
include('config.php');
$statType = 'YEARLY';
if(hasAccessTo($statType)){
?>
<!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 annuelles</title>
    <?php include('include/css.php'); ?>
    <link rel="stylesheet" href="css/annual-chart.css">
</head>

<body>
    <?php 
    include('header.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');
?>
    <div class="container-fluid">
        <div class="row">
            <div class="col-md-12 col-lg-12 title card-box">
                <form autocomplete="false" class="form-inline" id="chart_filter" method="post">
                    <div class="form-group col-lg-4 col-md-6 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 if($GLOBALS["STATS_CONF"]["CAPCA_AMS_DR"]){?><option value="-1" style="background-color: #ddd;">RESEAU DE PROXIMITE</option><?php } ?>
                            <?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'; ?>>
                                <?= $row['nom_agence']?>
                            </option>
                            <?php } ?>
                        </select>
                    </div>
                    <div class="form-group col-lg-4 col-md-6 col-sm-12">
                        <label for="annee" class="inline-form-label">Année :</label>
                        <input type="text" class="form-control date_picker_year" id="annee" placeholder="Sélectionner Année"
                            name="annee" autocomplete="off">
                    </div>
                    <div class="form-group col-lg-4 col-md-6 col-sm-12">
                        <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 ANNUELLES
                    </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="row">
                <div class="col-sm-12 col-md-6 col-lg-6 pl-0 cardValue-parent">
                    <div id="cardValue" class="card-box" style="display: flex !important;flex-wrap: wrap !important;align-content: center !important;align-items: center !important;justify-content: center !important;"></div>
                </div>
                <div class="col-sm-12 col-md-6 col-lg-6 pr-0 previousYearSummary-parent">
                    <div id="previousYearSummary" class="card-box">
                        <div class="first-year-progress">
                            <span class="year-name"></span>
                            <div class="progress">
                                <div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="40"
                                    aria-valuemin="0" aria-valuemax="100"></div>
                                <div class="col-md-2 mt-1">
                                    <div class="first-year-progress-count font-weight-bold"></div>
                                </div>
                            </div>
                        </div>
                        <div class="second-year-progress mt-4 progress-custom">
                            <span class="year-name"></span>
                            <div class="progress">
                                <div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="40"
                                    aria-valuemin="0" aria-valuemax="100"></div>
                                <div class="col-md-2 mt-1">
                                    <div class="second-year-progress-count font-weight-bold"></div>
                                </div>
                                <div class="progress-value" id="progress-value">
                            </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="row display-none chart-div">
            <div class="card-box col-md-12 col-lg-12">
                <h5 class="text-dark header-title m-t-0 m-b-30 textcenter">Nombre de visites annuelles (par mois)</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 col-md-12 col-lg-12 ">
                <h5 class="text-dark header-title m-t-0 m-b-30 textcenter">Part des RDV (taux annuel)</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 col-md-12 col-lg-12 ">
                <h5 class="text-dark header-title m-t-0 m-b-30 textcenter">Part des RDV (par mois)</h4>
                    <div class="widget-chart pull-in text-center">
                        <div id="chart_div5" class="chartMinhight"></div>
                    </div>
            </div>
        </div>
        <div class="row display-none chart-div">
            <div class="card-box col-md-12 col-lg-12 ">
                <h5 class="text-dark  header-title m-t-0 m-b-30 textcenter">Durées moyennes d'attente (minutes)</h4>
                    <div class="widget-chart pull-in text-center">
                        <div id="chart_div3" class="chartMinhight"></div>
                    </div>
            </div>
        </div>
        <div class="row display-none chart-div">
            <div class="card-box col-md-12 col-lg-12 ">
                <h5 class="text-dark  header-title m-t-0 m-b-30 textcenter">Durées moyennes d'entretien (minutes)</h4>
                    <div class="widget-chart pull-in text-center">
                        <div id="chart_div4" class="chartMinhight"></div>
                    </div>
            </div>
        </div>
    </div>
    <!-- /.container -->
    <!-- Bootstrap core JavaScript -->
    <?php include('include/js.php') ?>
    <script type="text/javascript" src="chartjs/annualchart.js?123"></script>
<?php
}
else{
?>
    <h2>Vous n'&ecirc;tes pas autoris&eacute; &agrave; acc&eacute;der &agrave; cette page !</h2>
<?php
}
?>
</body>

</html>