='$debut' AND r.type='$rub[$i]'";
$reponse=mysqli_query( $db_connection, $requete) or die("Erreur lors de l'execution de la requete
");
$res[$i]=mysqli_num_rows($reponse);
/* Comparaison */
$requete="SELECT r.id_reservation FROM reservation r, reservable t WHERE ";
$requete.="t.id_reservable=r.id_reservable AND t.id_club='$id_club' AND date_resa <='$fin_cmp' AND date_resa>='$debut_cmp' AND r.type='$rub[$i]'";
$reponse=mysqli_query( $db_connection, $requete) or die("Erreur lors de l'execution de la requete
");
$res_cmp[$i]=mysqli_num_rows($reponse);
}
/* Total */
$requete="SELECT r.id_reservation FROM reservation r, reservable t WHERE ";
$requete.="t.id_reservable=r.id_reservable AND t.id_club='$id_club' AND date_resa <='$fin' AND date_resa>='$debut'";
$reponse=mysqli_query( $db_connection, $requete) or die("Erreur lors de l'execution de la requete
");
$nb_resas_total=mysqli_num_rows($reponse);
$requete="SELECT r.id_reservation FROM reservation r, reservable t WHERE ";
$requete.="t.id_reservable=r.id_reservable AND t.id_club='$id_club' AND date_resa <='$fin_cmp' AND date_resa>='$debut_cmp'";
$reponse=mysqli_query( $db_connection, $requete) or die("Erreur lors de l'execution de la requete
");
$nb_resas_total_cmp=mysqli_num_rows($reponse);
/* Graphique */
include ("jpgraph/jpgraph.php");
include ("jpgraph/jpgraph_bar.php");
/* Donnees */
$abs=array($titre, $titre_cmp);
$loisir=array($res[0], $res_cmp[0]);
$cours=array($res[1], $res_cmp[1]);
$champ=array($res[2], $res_cmp[2]);
$tournoi=array($res[3], $res_cmp[3]);
$entretien=array($res[4], $res_cmp[4]);
$autre=array($res[5], $res_cmp[5]);
$total=array($nb_resas_total, $nb_resas_total_cmp);
/* Graphique */
$graph = new Graph(800,600,"auto");
$graph->SetScale("textlin");
$graph->SetShadow();
$graph->img->SetMargin(60,40,50,40);
$graph->SetMarginColor('#CCCCFF');
$graph->title->Set("Comparaison des reservation entre 2 periodes");
$graph->title->SetMargin(20);
// Loisir
$histo_loisir = new BarPlot($loisir);
$histo_loisir->SetFillColor('orange');
$histo_loisir->SetLegend('Loisir');
$histo_loisir->value->Show();
$histo_loisir->value->SetColor('black');
$histo_loisir->value->SetFormat('%d');
// Cours
$histo_cours = new BarPlot($cours);
$histo_cours->SetFillColor('blue');
$histo_cours->SetLegend('Cours');
$histo_cours->value->Show();
$histo_cours->value->SetColor('black');
$histo_cours->value->SetFormat('%d');
// Championnat
$histo_champ = new BarPlot($champ);
$histo_champ->SetFillColor('red');
$histo_champ->SetLegend('Championnat');
$histo_champ->value->Show();
$histo_champ->value->SetColor('black');
$histo_champ->value->SetFormat('%d');
// Tournoi
$histo_tournoi = new BarPlot($tournoi);
$histo_tournoi->SetFillColor('green');
$histo_tournoi->SetLegend('Tournoi');
$histo_tournoi->value->Show();
$histo_tournoi->value->SetColor('black');
$histo_tournoi->value->SetFormat('%d');
// Autre
$histo_autre = new BarPlot($autre);
$histo_autre->SetFillColor('lightblue');
$histo_autre->SetLegend('Autre');
$histo_autre->value->Show();
$histo_autre->value->SetColor('black');
$histo_autre->value->SetFormat('%d');
// Entretien
$histo_entret = new BarPlot($entretien);
$histo_entret->SetFillColor('pink');
$histo_entret->SetLegend('Entretien');
$histo_entret->value->Show();
$histo_entret->value->SetColor('black');
$histo_entret->value->SetFormat('%d');
// Total
$histo_total = new BarPlot($total);
$histo_total->SetFillColor('brown');
$histo_total->SetLegend('Total');
$histo_total->value->Show();
$histo_total->value->SetColor('black');
$histo_total->value->SetFormat('%d');
$gbplot = new AccBarPlot(array($histo_loisir, $histo_cours, $histo_champ,$histo_entret, $histo_autre,$histo_tournoi,$histo_total));
// Position de la légende
$graph->legend->Pos(0.85,0.1,"left","top");
// Ajouter l'ensemble accumulé
$graph->Add($gbplot);
// Paramétrer les axes X et Y
$graph->yaxis->title->Set("Nombre reservations");
$graph->yaxis->title->SetMargin(20);
$graph->xaxis->title->Set("Periode");
$graph->xaxis->SetTickLabels($abs);
$graph->xaxis->title->SetMargin(4);
// Afficher l'image générée
$graph->Stroke();
function nom_mois($mois) {
$noms=array("Janvier","Fevrier","Mars","Avril","Mai","Juin","Juillet","Aout","Septembre","Octobre","Novembre","Decembre");
$mois_tab=$mois-1;
return $noms[$mois_tab];
}
?>