147 lines
5.2 KiB
PHP
Executable File
147 lines
5.2 KiB
PHP
Executable File
<?php
|
|
// fichier conf BDD
|
|
include("mysql_compat.php");
|
|
include("conf.php");
|
|
|
|
// Connexion BDD
|
|
$db_connection=mysql_connect($db_host,$db_user,$password);
|
|
|
|
|
|
// Création du fichier PDF
|
|
include("fpdf.php");
|
|
|
|
// Création du fichier PDF
|
|
$pdf=new FPDF("P","mm","A4");
|
|
$pdf->SetFont('Arial','',14);
|
|
$pdf->Open();
|
|
$pdf->AddPage();
|
|
|
|
// Récup des données
|
|
$id_club=$_GET['club'];
|
|
|
|
/* Récupére les badges avec comptes inactifs */
|
|
$badges=array();
|
|
if(isset($_GET['compte']) and $_GET['compte']=='inact') {
|
|
$lien_cpte='inact';
|
|
$titre2="- Comptes inactifs";
|
|
$requete="SELECT * FROM badge_joueurs WHERE id_club='$id_club' ORDER BY id_joueur ASC";
|
|
$reponse=mysqli_query($db_connection, $requete) or die ("Erreur no".mysqli_errno($db_connection)()." : ".mysqli_error($db_connection)()."<br>");
|
|
$existe_badges=mysqli_num_rows($reponse);
|
|
if($existe_badges > 0) {
|
|
while($badge=mysqli_fetch_object($reponse)) {
|
|
if($badge->id_joueur != 0) {
|
|
$requete="SELECT actif_debut, actif_fin FROM compte WHERE id_joueur='$badge->id_joueur' AND id_club='$id_club'";
|
|
$rep=mysqli_query($db_connection, $requete) or die ("Erreur no".mysqli_errno($db_connection)()." : ".mysqli_error($db_connection)()."<br>");
|
|
$compte=mysqli_fetch_object($rep);
|
|
$ts_debut=conversion_ts_mysql($compte->actif_debut);
|
|
$ts_fin=conversion_ts_mysql($compte->actif_fin);
|
|
$ts_now=time();
|
|
if($ts_debut > $ts_now or $ts_now > $ts_fin) {
|
|
array_push($badges, $badge->id_badge);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
/* Sinon tous les badges avec comptes actifs */
|
|
else {
|
|
$lien_cpte='act';
|
|
$titre2="- Tous les comptes";
|
|
$requete="SELECT * FROM badge_joueurs WHERE id_club='$id_club' ORDER BY id_joueur ASC";
|
|
$reponse=mysqli_query($db_connection, $requete) or die ("Erreur no".mysqli_errno($db_connection)()." : ".mysqli_error($db_connection)()."<br>");
|
|
$existe_badges=mysqli_num_rows($reponse);
|
|
if($existe_badges > 0) {
|
|
while($badge=mysqli_fetch_object($reponse)) {
|
|
if($badge->id_joueur != 0) {
|
|
array_push($badges, $badge->id_badge);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
$requete="SELECT nom FROM club WHERE id_club='$id_club'";
|
|
$reponse=mysqli_query($db_connection, $requete) or die ("Erreur no".mysqli_errno($db_connection)()." : ".mysqli_error($db_connection)()."<br>");
|
|
$club=mysqli_fetch_object($reponse);
|
|
$titre="Badges du club $club->nom $titre2";
|
|
$pdf->Cell(190,10,$titre,1,0,'C');
|
|
$pdf->Ln();
|
|
$pdf->Ln();
|
|
|
|
$nb_badges=count($badges);
|
|
$pdf->Cell(190,10,"$nb_badges badges",0,0,'C');
|
|
$pdf->Ln();
|
|
|
|
if(count($badges) > 0) {
|
|
$pdf->SetFont('Arial','',12);
|
|
$pdf->Cell(20,10,"Badge",1,0,'C');
|
|
$pdf->Cell(30,10,"Nom",1,0,'C');
|
|
$pdf->Cell(30,10,"Prenom",1,0,'C');
|
|
$pdf->Cell(20,10,"Num FFT",1,0,'C');
|
|
$pdf->Cell(30,10,"Num Tel",1,0,'C');
|
|
$pdf->Cell(40,10,"Email",1,0,'C');
|
|
$pdf->Cell(20,10,"Compte",1,0,'C');
|
|
$pdf->Ln();
|
|
for($i=0;$i<count($badges);$i++) {
|
|
$pdf->SetFont('Arial','',11);
|
|
$requete="SELECT * FROM badge_joueurs WHERE id_badge='$badges[$i]'";
|
|
$reponse=mysqli_query($db_connection, $requete) or die ("Erreur no".mysqli_errno($db_connection)()." : ".mysqli_error($db_connection)()."<br>");
|
|
$badge=mysqli_fetch_object($reponse);
|
|
$pdf->Cell(20,10,"$badge->numero_badge",1,0,'C');
|
|
$requete="SELECT nom, prenom, numero_fft, e_mail FROM joueur WHERE id_joueur='$badge->id_joueur'";
|
|
$rep=mysqli_query($db_connection, $requete) or die ("Erreur no".mysqli_errno($db_connection)()." : ".mysqli_error($db_connection)()."<br>");
|
|
$joueur=mysqli_fetch_object($rep);
|
|
$pdf->Cell(30,10,"$joueur->nom",1,0,'C');
|
|
$pdf->Cell(30,10,"$joueur->prenom",1,0,'C');
|
|
$pdf->Cell(20,10,"$joueur->numero_fft",1,0,'C');
|
|
$requete="SELECT numero FROM telephone WHERE id_joueur='$badge->id_joueur'";
|
|
$rep=mysqli_query($db_connection, $requete) or die ("Erreur no".mysqli_errno($db_connection)()." : ".mysqli_error($db_connection)()."<br>");
|
|
$tel=mysqli_fetch_object($rep);
|
|
$pdf->Cell(30,10,"$tel->numero",1,0,'C');
|
|
if(strlen($joueur->e_mail) > 25) {
|
|
$pdf->SetFont('Arial','',7);
|
|
}
|
|
else {
|
|
$pdf->SetFont('Arial','',9);
|
|
}
|
|
$pdf->Cell(40,10,"$joueur->e_mail",1,0,'C');
|
|
$pdf->SetFont('Arial','',11);
|
|
$requete="SELECT actif_debut, actif_fin FROM compte WHERE id_joueur='$badge->id_joueur' AND id_club='$id_club'";
|
|
$rep=mysqli_query($db_connection, $requete) or die ("Erreur no".mysqli_errno($db_connection)()." : ".mysqli_error($db_connection)()."<br>");
|
|
$compte=mysqli_fetch_object($rep);
|
|
$ts_debut=conversion_ts_mysql($compte->actif_debut);
|
|
$ts_fin=conversion_ts_mysql($compte->actif_fin);
|
|
$ts_now=time();
|
|
if($ts_debut <= $ts_now and $ts_now <= $ts_fin) {
|
|
$pdf->SetFillColor(0, 255, 0);
|
|
$pdf->Cell(20,10," ",1,0,'C',1);
|
|
}
|
|
else {
|
|
$pdf->SetFillColor(255, 0, 0);
|
|
$pdf->Cell(20,10," ",1,0,'C',1);
|
|
}
|
|
$pdf->SetFillColor($[''], $[''],$['']);
|
|
$pdf->Ln();
|
|
}
|
|
}
|
|
|
|
// Affichage du PDF
|
|
$pdf->Output();
|
|
|
|
// fermeture connexion bdd
|
|
mysql_close($db_connection);
|
|
|
|
|
|
function conversion_ts_mysql($champ_ts) {
|
|
$annee=substr($champ_ts, 0, 4);
|
|
$mois=substr($champ_ts, 5, 2);
|
|
$jour=substr($champ_ts, 8, 2);
|
|
$heure=substr($champ_ts,11, 2);
|
|
$min=substr($champ_ts, 14, 2);
|
|
$sec=substr($champ_ts, 17, 2);
|
|
|
|
$ts=mktime($h, $min, $sec, $mois, $jour, $annee);
|
|
|
|
return $ts;
|
|
}
|
|
|
|
?>
|