/** * Page Liste des formations */ public function listFormations($userName, $slug, $toShow = false) { $formationManager = new \Manager\FormationManager(); if ($userName == 'all') { $userId = false; } else { $userId = $this->getUser()['id']; } $formations = $formationManager->listFormations($userId, $slug); // mise en forme pour affichage de la date et la durée foreach ($formations as $key => $value) { $date = \DateTime::createFromFormat('Y-m-d H:i:s', $value['dateCreated']); if ($date->format('U') > strtotime("-2 days")) { $formations[$key]['news'] = true; } else { $formations[$key]['news'] = false; } $formations[$key]['dateCreated'] = $date->format('j/m/Y'); $date = \DateTime::createFromFormat('Y-m-d H:i:s', $value['dateFormation']); $formations[$key]['dateFormation'] = $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']) > 40) { $formations[$key]['description'] = $newTruncante->tokenTruncate($formations[$key]['description'], 40); } $inscription = new \Manager\InscriptionManager(); $nbrInscrit = $inscription->countInscription($formations[$key]['id']); if ($nbrInscrit == $formations[$key]['totalNumberPlace']) { $formations[$key]['msg'] = 'complete'; } else { if ($date->format('U') - strtotime("+2 days") > 2 * 24 * 60 * 1000) { $formations[$key]['msg'] = 'not-delay'; } else { $formations[$key]['msg'] = false; } } } $next = $slug + 1; if (count($formations) < 16) { $next = false; } if (count($formations) == 16) { $suite = $formationManager->listFormations($userId, $slug + 1); if (count($suite) == 0) { $next = false; } } if (!$toShow) { $this->show('formation/list_formations', ["formations" => $formations, "prec" => $slug - 1, "next" => $next]); } else { return $formations; } }
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]); }