| Current Path : /home/ataenra/www/ATA/INTRANET/Admin/Gestion_ACC/charts/ |
| Current File : /home/ataenra/www/ATA/INTRANET/Admin/Gestion_ACC/charts/graphflux_AC_site.php |
<?php
$IDsite = $_GET['ID'];
$IDpmo = $_GET['IDpmo'];
$chart5 = $dbco->prepare("SELECT C.Autoconso_mois AS mois, P.prod_mois, C.Conso_base_kwh AS cb, C.AutoConso_kwh AS ac, C.Conso_kwh AS cf, C.injection_kwh AS inj, P.prod_kwh as pr
FROM gest_acc_autoconso_mois C JOIN gest_acc_prod_mois P ON C.ID_acc_site=P.ID_acc_site AND C.Autoconso_mois=P.prod_mois WHERE C.ID_acc_site ='$IDsite'");
$chart5->execute();
$tabm = "";
$tabc = "";
$tabac = "";
$tabacc = "";
$tabinj = "";
$tabss = "";
$tabpr = "";
$i=1;
while ($C5 = $chart5->fetch(PDO::FETCH_OBJ)) {
$chart6 = $dbco->prepare("SELECT mois, autoconso_cor_kwh AS acc FROM gest_acc_pmo_site_".$IDsite."_mois WHERE mois = '$C5->mois'");
$chart6->execute();
$C6 = $chart6->fetch(PDO::FETCH_OBJ);
if($i == 1){
$Vc = round($C5->cb);
$Vac = round($C5->ac);
$Vacc = round($C6->acc);
$Vinj = round($C5->inj);
$Vss = round($C5->cf-$C6->acc);
$Vpr = round($C5->pr);
}else{
$Vc = ", ".round($C5->cb)."";
$Vac = ", ".round($C5->ac)."";
$Vacc = ", ".round($C6->acc)."";
$Vinj = ", ".round($C5->inj)."";
$Vss = ", ".round($C5->cf-$C6->acc)."";
$Vpr = ", ".round($C5->pr)."";
}
$tabc .= $Vc;
$tabac .= $Vac;
$tabacc .= $Vacc;
$tabinj .= $Vinj;
$tabss .= $Vss;
$tabpr .= $Vpr;
$i++;
}
?>
<script>
new Chart(document.getElementById("barfluxsite"), {
type: 'bar',
data: {
labels: ['Janvier', 'Fevrier','Mars','Avril','Mai','Juin','Juillet','Aout','Septembre','Octobre','Novembre','Decembre'],
datasets: [
{
label: 'Soutirage',
data: [<?php echo $tabss; ?>],
backgroundColor: ['rgb(235, 186, 53)'],
stack: 'Stack 0',
},
{
label: 'ACI',
data: [<?php echo $tabac; ?>],
backgroundColor: ['rgb(42, 107, 228)'],
stack: 'Stack 0',
},
{
label: 'ACC',
data: [<?php echo $tabacc; ?>],
backgroundColor: ['rgb(42, 191, 228)'],
stack: 'Stack 0',
},
{
label: 'Surplus',
data: [<?php echo $tabinj; ?>],
backgroundColor: ['rgb(240, 255, 37)'],
stack: 'Stack 0',
},
{
label: 'Consommation de base',
data: [<?php echo $tabc; ?>],
backgroundColor: ['rgb(255, 37, 37)'],
stack: 'Stack 1',
},
{
label: 'Production PV',
data: [<?php echo $tabpr; ?>],
backgroundColor: ['rgb(37, 255, 66)'],
stack: 'Stack 2',
},
],
},
options: {
maintainAspectRatio: true,
plugins: {
title: {
display: true,
},
},
responsive: true,
scales: {
x: {
stacked: true,
},
y: {
stacked: true
}
}
}
}
);
</script>