/** * Page d'accueil */ public function home() { $newFormation = new \Manager\FormationManager(); $countFormation = $newFormation->countFormations(); $newUser = new \Manager\UserManager(); $countKikologue = $newUser->countKikologue(); $this->show('default/home', ['nbrFormation' => $countFormation['nbrFormation'], 'nbrKikologue' => $countKikologue['nbrKikologue']]); }
public function listInscriptions($userName, $slug) { $userId = $this->getUser()['id']; $newinscription = new \Manager\InscriptionManager(); $liste = $newinscription->listInscriptions($userId, $slug); $formations = []; foreach ($liste as $key => $value) { $newformation = new \Manager\FormationManager(); $formations[] = $newformation->find($value['formationId']); } foreach ($formations as $key => $value) { $date = \DateTime::createFromFormat('Y-m-d H:i:s', $value['dateFormation']); $formations[$key]['dateFormation'] = $date->format('j/m/Y'); $date = \DateTime::createFromFormat('Y-m-d H:i:s', $value['dateCreated']); $formations[$key]['dateCreated'] = $date->format('j/m/Y'); $duration = explode(":", $value['duration']); $formations[$key]['duration'] = $duration[0] . 'h' . $duration[1] . 'min'; if ($formations[$key]['image'] == '') { $formations[$key]['image'] = 'defaultformation.png'; } $newTruncante = new \Utils\Truncater(); if (strlen($formations[$key]['description']) > 30) { $formations[$key]['description'] = $newTruncante->tokenTruncate($formations[$key]['description'], 30); } } $next = $slug + 1; if (count($formations) < 16) { $next = false; } if (count($formations) == 16) { $suite = $newinscription->listInscriptions($userId, $slug + 1); if (count($suite) == 0) { $next = false; } } $this->show('inscription/list_inscriptions', ["formations" => $formations, "prec" => $slug - 1, "next" => $next]); }
public function creditKikos($token) { if ($token == '1234') { // Va récupérer toutes les formations avec top_credit = 0 $newformation = new \Manager\FormationManager(); $listes = $newformation->listFormationsToCredit(); // Pour chacun des formations récupérer : foreach ($listes as $key => $value) { // Compte le nombre d'inscrit à cette formation $newinscription = new \Manager\InscriptionManager(); $nbrInscrit = $newinscription->countInscription($value['formationId']); // crédite le formateur de kikos = au nombre d'inscrits if ($nbrInscrit > 0) { $newuser = new \Manager\UserManager(); $newuser->manageKikos($value['userId'], 'add', $nbrInscrit); } // Mise à jour du top Credit $newformation->update(['topCredit' => 1], $value['formationId']); } } else { $this->showForbidden(); } }