} } else { if ($type == "B") { if ($jeu->jeu_bloque == "1") { $json["resultat"] = false; $json["commentaire"] = "Jeu déjà bloqué"; } else { if ($debug) { echo "Déblocage du jeu\n"; } // Recherche la liste des joueurs $joueurs = new Joueur($db); $stmtJoueurs = $joueurs->litJoueurs(); $listeJoueurs = $stmtJoueurs->fetchAll(PDO::FETCH_ASSOC); // Pronostics des joueurs $pronostic = new Pronostic($db); $pronostic->jeu_id = $jeu->jeu_id; $stmtPronostics = $pronostic->litPronostics(); $listePronostics = $stmtPronostics->fetchAll(PDO::FETCH_ASSOC); $nbJoueurs = 0; for ($j = 0; $j < sizeof($listeJoueurs); $j++) { $joueur_id = $listeJoueurs[$j]["joueur_id"]; if ($listePronostics) { $prono = getPronoJoueur($listePronostics, $joueur_id); } if ($debug && isset($prono)) { echo "Joueur {$joueur_id} a le prono " . getPronostic($prono, 1) . " pour le premier match<br>\n"; } // Pas de pronostic ou alors pronostic vide (car effacé) if (!isset($prono) || isset($prono) && getPronostic($prono, 1) == "") { $nbJoueurs++;
} else { $jeu->saison_id = $saison->saison_id; $jeu->chargeDernierJeu(); } // Jeu bloqué => Saisie du résultat if ($jeu->jeu_bloque == "1") { // Résultat de ce jeu $resultat = new Resultat($db); $resultat->jeu_id = $jeu->jeu_id; $resultat->chargeResultat(); $stmtJeux = $jeu->litJeux(); $listeJeux = $stmtJeux->fetchAll(PDO::FETCH_ASSOC); } else { // Jeu non bloqué => Saisie du pronostic // Pronostics des joueurs $pronostic = new Pronostic($db); $pronostic->jeu_id = $jeu->jeu_id; if (isset($_SESSION['id_joueur'])) { $pronostic->joueur_id = $_SESSION['id_joueur']; } $pronostic->chargePronostic(); // Indicateurs $indicateur = new Indicateur($db); $indicateur->jeu_id = $jeu->jeu_id; $stmtIndicateurs = $indicateur->litIndicateurs(); $indicateurs = $stmtIndicateurs->fetchAll(PDO::FETCH_ASSOC); } //include 'scripts/repartition.php'; include_once 'composants/nav.php'; ?> <div id="page-wrapper">
if (isset($_GET['debug'])) { // Mode debug $debug = true; } // instantiate database and product object $database = new Database(); $db = $database->getConnection(); // Recherche de la saison courante $saison = new Saison($db); $saison = $saison->chargeSaisonCourante(); // Dernier Jeu $jeu = new Jeu($db); $jeu->saison_id = $saison->saison_id; $jeu->chargeDernierJeu(); // Pronostic de ce joueur $pronostic = new Pronostic($db); $pronostic->jeu_id = $jeu->jeu_id; $pronostic->joueur_id = $_SESSION['id_joueur']; $pronostic->chargePronostic(); $json["resultat"] = ""; if (isset($_GET['debug'])) { // Mode debug $debug = true; } // Recherche des informations sur l'indice de gains $json = CalculGains($debug, $jeu, $pronostic); } else { $json["resultat"] = false; $json["commentaire"] = "Pas connecté !"; } echo json_encode($json);
if (strlen(trim($prono['pronostic' . $i])) != 0) { // Oui ? bon on regarde si c'est 1, N ou 2 foreach ($tableauChoix as &$choix) { if (strpos($prono['pronostic' . $i], $choix) !== false) { $moyenne = $moyenne + getIndicateursMatchChoix($listeIndicateurs, $i, $choix); $nbCasesCoches = $nbCasesCoches + 1; //echo "La moyenne vaut {$moyenne} et {$nbCasesCoches} cases cochees<br>"; } } } } // Calcul de l'indice $indice = $moyenne / $nbCasesCoches; $indice = round((100 - $indice) / 10, 2); // Pronostic de tous les joueurs $pronostic2 = new Pronostic($db); $pronostic2->jeu_id = $jeu->jeu_id; $pronostic2->joueur_id = $joueur_id; $pronostic2->chargePronostic(); if ($debug) { echo "Joueur {$joueur_id} : {$joueur_nom}<br>\n"; } // MAJ Si pronostics ! if ($nbCasesCoches > 0) { if ($debug) { echo "Indice calcul : {$indice} a partir de {$nbCasesCoches} pronostics<br>\n"; echo "Avant => indice 7 : " . $pronostic2->IndiceGain7 . ", indice 15 : " . $pronostic2->IndiceGain15 . "<br>\n"; } $pronostic2->IndiceGain7 = 0; $pronostic2->IndiceGain15 = 0; if (strlen(trim($pronostic2->pronostic1)) != 0) {
$saison = new Saison($db); $saison = $saison->chargeSaisonCourante(); // Dernier Jeu $jeu = new Jeu($db); if (isset($_GET['idjeu'])) { $jeu->jeu_id = $_GET['idjeu']; $jeu->chargeJeu(); } else { $jeu->saison_id = $saison->saison_id; $jeu->chargeDernierJeu(); } // Résultat de ce jeu $resultat = new Resultat($db); $resultat->jeu_id = $jeu->jeu_id; // Pronostic de ce joueur $pronostic = new Pronostic($db); $pronostic->jeu_id = $jeu->jeu_id; $pronostic->joueur_id = $_SESSION['id_joueur']; $stmtPronostic = $pronostic->litPronostics(); $pronostics = $stmtPronostic->fetchAll(PDO::FETCH_ASSOC); // Statistique $statistique = new Statistique($db); $statistique->jeu_id = $jeu->jeu_id; $statistique->saison_id = $saison->saison_id; // Recherche la liste des joueurs $joueurs = new Joueur($db); $stmtJoueurs = $joueurs->litJoueurs(); $listeJoueurs = $stmtJoueurs->fetchAll(PDO::FETCH_ASSOC); // Indicateur de ce joueur $indicateur = new Indicateur($db); $indicateur->jeu_id = $jeu->jeu_id;