Your IP : 216.73.216.212


Current Path : /home/ataenra/www/ATA/INTRANET/Admin/Gestion_ACC/charts/
Upload File :
Current File : /home/ataenra/www/ATA/INTRANET/Admin/Gestion_ACC/charts/graphsitesrepart.php

<?php
  $req = $dbco->query("SELECT COUNT(*) as Nbconso FROM gest_acc_sites WHERE ID_pmo = '$IDpmo' AND site_type ='Conso'"); 
  $nbconso = $req->fetch();
  $req->closeCursor();

  $req = $dbco->query("SELECT COUNT(*) as Nbprod FROM gest_acc_sites WHERE ID_pmo = '$IDpmo' AND site_type ='Prod'"); 
  $nbprod = $req->fetch();
  $req->closeCursor();

  $req = $dbco->query("SELECT COUNT(*) as Nbautoconso FROM gest_acc_sites WHERE ID_pmo = '$IDpmo' AND site_type ='AutoConso'"); 
  $nbautoconso = $req->fetch();
  $req->closeCursor();

  $req1 = $dbco->query("SELECT SUM(Consos) AS Consos_total FROM gest_acc_sites WHERE ID_pmo = '$IDpmo' AND site_type ='AutoConso'");
  $totalconsos = $req1->fetch();
  $req1->closeCursor();

  $req1 = $dbco->query("SELECT SUM(Consos) AS Consos_total FROM gest_acc_sites WHERE ID_pmo = '$IDpmo' AND site_type ='AutoConso'");
  $totalconsos = $req1->fetch();
  $req1->closeCursor();

  $req1 = $dbco->query("SELECT SUM(Prods) AS Prods_total FROM gest_acc_sites WHERE ID_pmo = '$IDpmo' AND etat = 'Complet' AND site_type ='AutoConso'");
  $totalprods = $req1->fetch();
  $req1->closeCursor();

  $req1 = $dbco->query("SELECT SUM(AutoConso) AS tac FROM gest_acc_sites WHERE ID_pmo = '$IDpmo' AND etat = 'Complet' AND site_type ='AutoConso'");
  $tac = $req1->fetch();
  $req1->closeCursor();

  $req1 = $dbco->query("SELECT SUM(Injection) AS Injection_total FROM gest_acc_sites WHERE ID_pmo = '$IDpmo' AND etat = 'Complet' AND site_type ='AutoConso'");
  $totalinjection = $req1->fetch();
  $req1->closeCursor();

  $req1 = $dbco->query("SELECT SUM(Consos) AS Consos_total FROM gest_acc_sites WHERE ID_pmo = '$IDpmo' AND site_type IN ('Prod','Conso')");
  $totalconsos2 = $req1->fetch();
  $req1->closeCursor();

  $req2 = $dbco->query("SELECT SUM(base_conso_kwh) AS CC, SUM(soutirage_kwh) AS SOUT, SUM(prod_kwh) AS PR, SUM(autoconso_kwh) AS AC, SUM(injection_kwh) AS INJ FROM gest_acc_pmo_heures WHERE ID_pmo = '$IDpmo'");
  $totaux = $req2->fetch();
  $req2->closeCursor();
  $req2 = $dbco->query("SELECT SUM(conso_base_kwh) AS CC, SUM(conso_kwh) AS SOUT, SUM(AutoConso_kwh) AS AC FROM gest_acc_autoconso_heures");
  $totaux2 = $req2->fetch();
  $req2->closeCursor();









?>
<script>
		new Chart(document.getElementById("doughnutChartID"), {
			type: 'doughnut',
			data: {
				datasets: [{
                    
					data: [<?php echo "".$nbprod['Nbprod'].", ".$nbautoconso['Nbautoconso'].", ".$nbconso['Nbconso'].""; ?>],
					backgroundColor: ['rgb(99, 255, 151)',
                                        'rgb(54, 162, 235)',
                                        'rgb(255, 205, 86)'],
				}],
				labels: ['Sites de Production', 'Sites en ACI', 'Sites de Consommation'],
			},
            options: {  
                plugins: {
                    legend: {
                            display: true,
                           
                            }
                        }
                        }
		});
</script>
<script>
		new Chart(document.getElementById("doughnutChartID1"), {
			type: 'doughnut',
			data: {
				datasets: [{
                    
					data: [<?php echo "".$totalconsos['Consos_total'].", ".round($totalautoconso['AutoConso_total']).", ".round($totalinjection['Injection_total']).""; ?>],
					backgroundColor: ['rgb(241, 74, 74)',
                                      'rgb(54, 162, 235)',
                                      'rgb(255, 205, 86)'],
				        }],
			labels: ['Soutirage kwh', 'AutoConso kwh', 'Energie PV restante kwh'],
			},
			options: {
				
                plugins: {
                    legend: {
                            display: true,
                            position: 'right'
                            }
                        }
                        }
		});
</script>

<script>
		new Chart(document.getElementById("doughnutChartID2"), {
			type: 'doughnut',
            
			data: {
				datasets: [{
                    
					data: [<?php echo "".round($totaux['CC']+$tac['tac']).", ".round($totaux['SOUT']).", ".round($totaux['AC']+$tac['tac']).", ".round($totaux['INJ']).""; ?>],
					backgroundColor: ['rgb(241, 74, 74)',
                                      'rgb(54, 162, 235)',
                                      'rgb(99, 255, 151)',
                                      'rgb(255, 205, 86)'],
				}],
				labels: ['Conso Base kwh', 'Soutirage kwh', 'AutoConsommation kwh', 'Revente EDF kwh'],
			},
			options: {
				
                plugins: {
                    legend: {
                            display: true,
                            position: 'right'
                            }
                        }
                        }
		});
	</script>