<?php
namespace App\Controller\Formations;
use App\Classes\AbsencesControle;
use App\Entity\Formations;
use App\Entity\InscriptionsFormations;
use App\Entity\StagiairesAbsences;
use App\Entity\StagiairesReports;
use App\Form\Formations\Attestations\AttestationsRechercherFormType;
use App\Form\Formations\Evaluations\EvaluationsRechercherFormType;
use App\Form\Formations\FormationsRechercherFormType;
use App\Form\Formations\Presences\PresencesStagiaireFormType;
use App\Repository\ConvocationsEtatsRepository;
use App\Repository\ConvocationsReponsesRepository;
use App\Repository\ConvocationsRepository;
use App\Repository\EvaluationsRattrapagesRepository;
use App\Repository\EvaluationsRepository;
use App\Repository\FormationsEtatsRepository;
use App\Repository\FormationsRepository;
use App\Repository\InscriptionsFormationsEtatsRepository;
use App\Repository\InscriptionsFormationsRepository;
use App\Repository\PlagesFormationsRepository;
use App\Repository\PlanningsFormationsRepository;
use App\Repository\SitesRepository;
use App\Repository\StagiairesAbsencesRepository;
use App\Repository\StagiairesReportsRepository;
use App\Repository\StagiairesRepository;
use Doctrine\Persistence\ManagerRegistry;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
use Symfony\Component\HttpFoundation\Cookie;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\ResponseHeaderBag;
use Symfony\Component\Routing\Annotation\Route;
class FormationsController extends AbstractController
{
private $message;
private string $AttestPdfDirectory; //Chemin d'uplaod des fichiers PDF 'config/services.yaml'
public function __construct(SitesRepository $sitesRepository, string $AttestPdfDirectory)
{
$this->sites = $sitesRepository;
$this->AttestPdfDirectory = $AttestPdfDirectory;
}
/**
* @Route("/formations/", name="formations")
*/
public function index(
FormationsRepository $formationsRepository,
SitesRepository $sitesRepository,
FormationsEtatsRepository $formationsEtatsRepository,
Request $request
): Response
{
// $formations = $formationsRepository->findAll();
$formationsEtats = $formationsEtatsRepository->findAll();
//GESTION DES VALEURS DANS LE FORMULAIRE DE RECHERCHES
$cookie = $request->cookies->get('FormationsRecherches');
if($cookie) {
$dataCookie = unserialize($cookie);
$formationIntitule = $dataCookie['formationIntitule'];
$formationDateDebut = $dataCookie['formationDateDebut'];
$formationSite = $dataCookie['formationSite'];
$formationEtat = $dataCookie['formationEtat'];
$formationStagiaire = $dataCookie['formationStagiaire'];
if($formationDateDebut != '') {
$formationDateDebut = $formationDateDebut;
}
else {
$formationDateDebut = null;
}
if($formationSite != '') {
$formationSite = null;
}
else {
$formationSite = null;
}
if($formationEtat != '') {
$formationEtat = $formationsEtatsRepository->find($formationEtat->getId());
}
else {
$formationEtat = null;
}
}
else {
$formationIntitule = null;
$formationDateDebut = null;
$formationSite = null;
$formationEtat = null;
$formationStagiaire = null;
}
$formulaireRecherches = $this->createForm(FormationsRechercherFormType::class, null, [
'formationIntitule' => $formationIntitule,
'formationDateDebut' => $formationDateDebut,
'formationSite' => $formationSite,
'formationEtat' => $formationEtat,
'formationStagiaire' => $formationStagiaire,
]);
$formulaireRecherches->handleRequest($request);
if($formulaireRecherches->isSubmitted() && $formulaireRecherches->isValid())
{
$formationIntitule = $formulaireRecherches->get('intitule')->getData();
$formationDateDebut = $formulaireRecherches->get('dateDebut')->getData();
$formationSite = $formulaireRecherches->get('site')->getData();
$formationEtat = $formulaireRecherches->get('etat')->getData();
$formationStagiaire = $formulaireRecherches->get('stagiaire')->getData();
if($formationSite != null){
$formationSite = $sitesRepository->find($formationSite->getId());
} else {
$formationSite = null;
}
if($formationEtat != null){
$formationEtat = $formationsEtatsRepository->find($formationEtat->getId());
}
else {
$formationEtat = null;
}
//CREATION COOKIE STOCKAGE DES DONNEES DE RECHERCHES
$data = [
'formationIntitule' => $formationIntitule,
'formationDateDebut' => $formationDateDebut,
'formationSite' => $formationSite,
'formationEtat' => $formationEtat,
'formationStagiaire' => $formationStagiaire
];
$data = serialize($data);
$expires = time() + 36000;
//LOCAL
$cookie = Cookie::create('FormationsRecherches', $data, $expires, '/', '', true, true);
// VPS
// $cookie = Cookie::create('FormationsRecherches', $data, $expires, '/', 'ama64.fr',
$res = new Response();
$res->headers->setCookie( $cookie );
$res->sendHeaders();
}
$formations = $formationsRepository->findByListeFormationsRecherhes(
$formationIntitule,
$formationDateDebut,
$formationSite,
$formationEtat,
$formationStagiaire
);
return $this->render('formations/formationsListing.html.twig', [
'formations' => $formations,
'formationsEtats' => $formationsEtats,
'formulaireRecherches' => $formulaireRecherches->createView(),
'formationStagiaire' => $formationStagiaire
]);
}
/**
* @Route("/formations/recherches/initialiser", name="formations_recherches_reset")
*/
public function recherchesReset(): Response
{
$data = [
'formationIntitule' => '',
'formationDateDebut' => '',
'formationSite' => '',
'formationEtat' => '',
'formationStagiaire' => ''
];
$data = serialize($data);
$expires = time() + 36000;
//LOCAL
$cookie = Cookie::create('FormationsRecherches', $data, $expires, '/', '', true, true);
// VPS
// $cookie = Cookie::create('FormationsRecherches', $data, $expires, '/', 'ama64.fr', true, true);
$res = new Response();
$res->headers->setCookie($cookie);
$res->sendHeaders();
return $this->redirectToRoute('formations');
}
/**
* @Route("/formations/afficher/{id}", name="formations_show")
*/
public function showFormation($id, ManagerRegistry $doctrine, ConvocationsRepository $convocationsRepository, PlanningsFormationsRepository $planningsFormationsRepository, FormationsEtatsRepository $formationsEtatsRepository, ConvocationsEtatsRepository $convocationsEtatsRepository, InscriptionsFormationsEtatsRepository $inscriptionsFormationsEtatsRepository, PlagesFormationsRepository $plagesFormationsRepository): Response
{
$entityManager = $doctrine->getManager();
$formation = $entityManager->getRepository(Formations::class)->find($id);
$formationEtat = $formationsEtatsRepository->find($formation->getEtat());
$convocationEtat = $convocationsEtatsRepository->findAll();
$inscriptionEtat = $inscriptionsFormationsEtatsRepository->findAll();
// VERIFIER SI TOUTES LES REPONSES AUX CONVOC ONT ETE TRAITEES
$ConvocAllClosed = $convocationsRepository->findByConvocAllClosed($id);
$formationPlanningConstruit = $formation->getPlanningsFormations()[0];
// dd(empty($formationPlanningConstruit));
// dd($ConvocAllClosed);
if(empty($ConvocAllClosed) && !empty($formationPlanningConstruit)){
$ConvocAllClosed=true;
} else {
$ConvocAllClosed=false;
}
// dd($ConvocAllClosed);
$plannings = $planningsFormationsRepository->findBy(
['formation' => $formation],
['dateDebut' => 'ASC']
);
$convocations = $convocationsRepository->findByOrderByName($id);
$domainesColors = [
0 => 'bg-secondary',
1 => 'bg-primary',
2 => 'bg-success',
3 => 'bg-warning'
];
$jourFr = [
'1' => 'Lundi',
'2' => 'Mardi',
'3' => 'Mercredi',
'4' => 'Jeudi',
'5' => 'Vendredi',
'6' => 'Samedi',
'7' => 'Dimanche',
];
return $this->render('formations/formationsAfficher.html.twig', [
'formation' => $formation,
'plannings' => $plannings,
'message' => $this->message,
'domainesColors' => $domainesColors,
'convocations' => $convocations,
'formationEtat' => $formationEtat,
'convocationEtat' => $convocationEtat,
'ConvocAllClosed' => $ConvocAllClosed,
'inscriptionEtat' => $inscriptionEtat,
'jourFr' => $jourFr,
'nav' => '1'
]);
}
/**
* @Route("/formations/afficher/planning/{idFormation}", name="formations_show_planning")
*/
public function showFormationPlanning($idFormation, FormationsRepository $formationsRepository, PlanningsFormationsRepository $planningsFormationsRepository, FormationsEtatsRepository $formationsEtatsRepository): Response
{
$formation = $formationsRepository->find($idFormation);
$formationEtat = $formationsEtatsRepository->find($formation->getEtat());
// $plannings = $planningsFormationsRepository->findBy(
// ['formation' => $formation],
// ['dateDebut', 'demiJournee' => 'ASC'],
// );
$plannings = $planningsFormationsRepository->createQueryBuilder('p')
->andWhere('p.formation = :idFormation')
// ->andWhere('p.etat = 1')
->setParameter('idFormation', $idFormation)
->orderBy('p.dateDebut', 'ASC')
->addOrderBy('p.demiJournee', 'ASC')
->getQuery()
->getResult();
// dd($plannings);
$domainesColors = [
0 => 'bg-secondary',
1 => 'bg-primary',
2 => 'bg-success',
3 => 'bg-warning'
];
$jourFr = [
'1' => 'Lundi',
'2' => 'Mardi',
'3' => 'Mercredi',
'4' => 'Jeudi',
'5' => 'Vendredi',
'6' => 'Samedi',
'7' => 'Dimanche',
];
return $this->render('formations/formationsAfficherPlanning.html.twig', [
'formation' => $formation,
'plannings' => $plannings,
'message' => $this->message,
'domainesColors' => $domainesColors,
'formationEtat' => $formationEtat,
'jourFr' => $jourFr,
'nav' => '2'
]);
}
/**
* @Route("/formations/afficher/inscriptions/{idFormation}", name="formations_show_inscriptions")
*/
public function showFormationInscriptions(
$idFormation,
FormationsRepository $formationsRepository,
FormationsEtatsRepository $formationsEtatsRepository,
InscriptionsFormationsRepository $inscriptionsFormationsRepository,
InscriptionsFormationsEtatsRepository $inscriptionsFormationsEtatsRepository,
ConvocationsRepository $convocationsRepository,
StagiairesReportsRepository $stagiairesReportsRepository,
StagiairesAbsencesRepository $stagiairesAbsencesRepository
): Response
{
$formation = $formationsRepository->find($idFormation);
$formationEtat = $formationsEtatsRepository->find($formation->getEtat());
$inscriptions = $inscriptionsFormationsRepository->createQueryBuilder('i')
->leftJoin('i.stagiaires', 's')
->where('i.formations = ' . $idFormation)
->andWhere('i.etat < 3')
->orderBy('s.nom', 'ASC')
->addOrderBy('s.prenom', 'ASC')
->getQuery()
->getResult();
$inscriptionEtat = $inscriptionsFormationsEtatsRepository->findAll();
$stagiaireConvocationsTab = [];
$stagiairesReportsTab = [];
$stagairesAbsencesTab = [];
foreach($inscriptions as $inscription) {
$idStagiaire = $inscription->getStagiaires()->getId();
$numBloc = $inscription->getFormations()->getBloc()->getNumBloc();
$convocation = $convocationsRepository->findBy([
'Stagiaire' => $inscription->getStagiaires(),
'formation' => $formation
]);
if(!empty($convocation)) {
$stagiaireConvocationsTab[$idStagiaire] = true;
} else {
$stagiaireConvocationsTab[$idStagiaire] = false;
}
$stagiairesReports = $stagiairesReportsRepository->findBy([
'stagiaires' => $idStagiaire,
'numBloc' => $numBloc
]);
if(!empty($stagiairesReports)) {
$stagiairesReportsTab[$idStagiaire] = [true, count($stagiairesReports)];
} else {
$stagiairesReportsTab[$idStagiaire] = [false, count($stagiairesReports)];
}
$stagiairesAbsences = $stagiairesAbsencesRepository->findBy([
'stagiaires' => $inscription->getStagiaires(),
'numBloc' => $numBloc
]);
if(!empty($stagiairesAbsences)) {
$stagairesAbsencesTab[$idStagiaire] = [true, count($stagiairesAbsences)];
} else {
$stagairesAbsencesTab[$idStagiaire] = [false, count($stagiairesAbsences)];
}
}
// dd($stagiairesReportsTab);
$jourFr = [
'1' => 'Lundi',
'2' => 'Mardi',
'3' => 'Mercredi',
'4' => 'Jeudi',
'5' => 'Vendredi',
'6' => 'Samedi',
'7' => 'Dimanche',
];
return $this->render('formations/formationsAfficherInscriptions.html.twig', [
'formation' => $formation,
'inscriptions' => $inscriptions,
'formationEtat' => $formationEtat,
'inscriptionEtat' => $inscriptionEtat,
'stagiaireConvocationsTab' => $stagiaireConvocationsTab,
'stagiairesReportsTab' => $stagiairesReportsTab,
'stagairesAbsencesTab' => $stagairesAbsencesTab,
'jourFr' => $jourFr,
'nav' => '3'
]);
}
/**
* @Route("/formations/afficher/convocations/{idFormation}", name="formations_show_convocations")
*/
public function showFormationConvocations(
$idFormation,
FormationsRepository $formationsRepository,
ConvocationsRepository $convocationsRepository,
FormationsEtatsRepository $formationsEtatsRepository,
ConvocationsEtatsRepository $convocationsEtatsRepository,
StagiairesReportsRepository $stagiairesReportsRepository,
StagiairesAbsencesRepository $stagiairesAbsencesRepository,
ConvocationsReponsesRepository $convocationsReponsesRepository
): Response
{
$formation = $formationsRepository->find($idFormation);
$formationEtat = $formationsEtatsRepository->find($formation->getEtat());
$convocationEtat = $convocationsEtatsRepository->findAll();
$convocationsResponsesListe = $convocationsReponsesRepository->findAll();
// VERIFIER SI TOUTES LES REPONSES AUX CONVOC ONT ETE TRAITEES
$ConvocAllClosed = $convocationsRepository->findByConvocAllClosed($idFormation);
$formationPlanningConstruit = $formation->getPlanningsFormations()[0];
if(empty($ConvocAllClosed) && !empty($formationPlanningConstruit)){
$ConvocAllClosed=true;
} else {
$ConvocAllClosed=false;
}
$convocations = $convocationsRepository->findByOrderByName($idFormation);
$nbreTotalConvoc = count($convocations);
$stagiairesReportsTab = [];
$stagairesAbsencesTab = [];
foreach($convocations as $convocation) {
$idStagiaire = $convocation->getStagiaire()->getId();
$numBloc = $convocation->getFormation()->getBloc()->getNumBloc();
$stagiairesReports = $stagiairesReportsRepository->findBy([
'stagiaires' => $idStagiaire,
'numBloc' => $numBloc
]);
if(!empty($stagiairesReports)) {
$stagiairesReportsTab[$idStagiaire] = [true, count($stagiairesReports)];
} else {
$stagiairesReportsTab[$idStagiaire] = [false, count($stagiairesReports)];
}
$stagiairesAbsences = $stagiairesAbsencesRepository->findBy([
'stagiaires' => $convocation->getStagiaire(),
'numBloc' => $numBloc
]);
if(!empty($stagiairesAbsences)) {
$stagairesAbsencesTab[$idStagiaire] = [true, count($stagiairesAbsences)];
} else {
$stagairesAbsencesTab[$idStagiaire] = [false, count($stagiairesAbsences)];
}
}
//Vérification si toutes les convocations sont clôturées
$convocationsToutesTraitees = $convocationsRepository->createQueryBuilder('s')
->join('s.formation', 'f')
->andWhere('f.id = '.$idFormation)
->andWhere('s.etat = 1')
->andWhere("s.reponse IS NULL")
->getQuery()
->getResult();
if(empty($convocationsToutesTraitees)) {
$traitementConvocProgress = true;
}
else {
$traitementConvocProgress = false;
}
// dd($ConvocAllClosed);
$jourFr = [
'1' => 'Lundi',
'2' => 'Mardi',
'3' => 'Mercredi',
'4' => 'Jeudi',
'5' => 'Vendredi',
'6' => 'Samedi',
'7' => 'Dimanche',
];
return $this->render('formations/formationsAfficherConvocations.html.twig', [
'formation' => $formation,
'message' => $this->message,
'convocations' => $convocations,
'formationEtat' => $formationEtat,
'convocationEtat' => $convocationEtat,
'convocationsResponsesListe' => $convocationsResponsesListe,
'ConvocAllClosed' => $ConvocAllClosed,
'traitementConvocProgress' => $traitementConvocProgress,
'stagiairesReportsTab' => $stagiairesReportsTab,
'stagairesAbsencesTab' => $stagairesAbsencesTab,
'jourFr' => $jourFr,
'nav' => '4'
]);
}
/**
* @Route("/formations/afficher/presences/{idFormation}", name="formations_show_presences")
*/
public function showFormationPresences(
$idFormation,
FormationsRepository $formationsRepository,
PlanningsFormationsRepository $planningsFormationsRepository,
FormationsEtatsRepository $formationsEtatsRepository,
PlagesFormationsRepository $plagesFormationsRepository
): Response
{
$formation = $formationsRepository->find($idFormation);
$formationEtat = $formationsEtatsRepository->find($formation->getEtat());
$plannings = $planningsFormationsRepository->findBy(
['formation' => $formation],
['dateDebut' => 'ASC']
);
$tabAbsences = [];
//CALCUL DES ABSENCES
foreach($plannings as $planning) {
$plagesAbsences = $plagesFormationsRepository->createQueryBuilder('p')
->select("p")
->andWhere('p.planning = '.$planning->getId())
->andWhere('p.presences = 2')
->andWhere('p.etat = 1')
// ->groupBy('p.stagiaire')
->getQuery()
->getResult();
// dd($plagesAbsences);
$nbreAbsentsPlage = count($plagesAbsences);
$plagesStagiaires = $plagesFormationsRepository->createQueryBuilder('p')
->select("p")
->andWhere('p.planning = '.$planning->getId())
// ->groupBy('p.stagiaire')
->getQuery()
->getResult();
$nbreStagiairesPlage = count($plagesStagiaires);
$tabAbsences[$planning->getId()]=array($nbreAbsentsPlage, $nbreStagiairesPlage);
}
// dd($tabAbsences);
$domainesColors = [
0 => 'bg-secondary',
1 => 'bg-primary',
2 => 'bg-success',
3 => 'bg-warning'
];
$jourFr = [
'1' => 'Lundi',
'2' => 'Mardi',
'3' => 'Mercredi',
'4' => 'Jeudi',
'5' => 'Vendredi',
'6' => 'Samedi',
'7' => 'Dimanche',
];
return $this->render('formations/formationsAfficherPresences2.html.twig', [
'formation' => $formation,
'plannings' => $plannings,
'domainesColors' => $domainesColors,
'formationEtat' => $formationEtat,
'jourFr' => $jourFr,
'tabAbsences' => $tabAbsences,
'nav' => '6',
]);
}
/**
* @Route("/formations/afficher/evaluations/{idFormation}", name="formations_show_eval")
*/
public function showFormationEval(
$idFormation,
EvaluationsRepository $evaluationsRepository,
EvaluationsRattrapagesRepository $evaluationsRattrapagesRepository,
FormationsRepository $formationsRepository,
FormationsEtatsRepository $formationsEtatsRepository,
InscriptionsFormationsRepository $inscriptionsFormationsRepository,
Request $request
): Response
{
$formation = $formationsRepository->find($idFormation);
$formationEtat = $formationsEtatsRepository->find($formation->getEtat());
$inscriptions = $inscriptionsFormationsRepository->findBy(
[
'formations' => $formation,
'etat' => 2
]
);
$rechercheExiste = null;
//GESTION DES VALEURS DANS LE FORMULAIRE DE RECHERCHES
$cookie = $request->cookies->get('EvaluationsRecherches');
if($cookie) {
$rechercheExiste = 1;
$dataCookie = unserialize($cookie);
$evaluationStagiaireNom = $dataCookie['evaluationStagiaireNom'];
$evaluationSaisies = $dataCookie['evaluationSaisies'];
$evaluationResultat = $dataCookie['evaluationResultat'];
$evaluationType = $dataCookie['evaluationType'];
if($evaluationStagiaireNom != '') {
$evaluationStagiaireNom = $evaluationStagiaireNom;
}
else {
$evaluationStagiaireNom = null;
}
if($evaluationSaisies != '') {
$evaluationSaisies = $evaluationSaisies;
}
else {
$evaluationSaisies = null;
}
if($evaluationResultat != '') {
$evaluationResultat = $evaluationResultat;
}
else {
$evaluationResultat = null;
}
if($evaluationType != '') {
$evaluationType = $evaluationType;
}
else {
$evaluationType = null;
}
}
else {
$evaluationStagiaireNom = null;
$evaluationSaisies = null;
$evaluationResultat = null;
$evaluationType = null;
}
$formulaireRecherches = $this->createForm(EvaluationsRechercherFormType::class, null, [
'evaluationStagiaireNom' => $evaluationStagiaireNom,
'evaluationSaisies' => $evaluationSaisies,
'evaluationResultat' => $evaluationResultat,
'evaluationType' => $evaluationType
]);
$formulaireRecherches->handleRequest($request);
if($formulaireRecherches->isSubmitted() && $formulaireRecherches->isValid())
{
$evaluationStagiaireNom = $formulaireRecherches->get('stagiaireNom')->getData();
$evaluationSaisies = $formulaireRecherches->get('saisies')->getData();
$evaluationResultat = $formulaireRecherches->get('resultat')->getData();
$evaluationType = $formulaireRecherches->get('typeEval')->getData();
//CREATION COOKIE STOCKAGE DES DONNEES DE RECHERCHES
$data = [
'evaluationStagiaireNom' => $evaluationStagiaireNom,
'evaluationSaisies' => $evaluationSaisies,
'evaluationResultat' => $evaluationResultat,
'evaluationType' => $evaluationType,
];
$data = serialize($data);
$expires = time() + 36000;
//LOCAL
$cookie = Cookie::create('EvaluationsRecherches', $data, $expires, '/', '', true, true);
// VPS
// $cookie = Cookie::create('FormationsRecherches', $data, $expires, '/', 'ama64.fr',
$res = new Response();
$res->headers->setCookie( $cookie );
$res->sendHeaders();
}
// FIN TRAITEMENT DES RECHERCHES
if($evaluationType == 1) {
$evaluations = $evaluationsRepository->findByEvaluationsRecherches($formation, $evaluationStagiaireNom, $evaluationSaisies, $evaluationResultat);
$evaluationsRattapages = $evaluationsRattrapagesRepository->findByEvaluationsRattrapagesRecherches($formation, $evaluationStagiaireNom, $evaluationSaisies, $evaluationResultat);
$evaluationsRattrapagesTab = [];
foreach($evaluationsRattapages as $rattrapage) {
$evaluationsRattrapagesTab[$rattrapage->getStagiaire()->getId()] = 1;
}
$evaluationsRattapages = "";
}
else if($evaluationType == 2) {
$evaluations = "";
$evaluationsRattapages = $evaluationsRattrapagesRepository->findByEvaluationsRattrapagesRecherches($formation, $evaluationStagiaireNom, $evaluationSaisies, $evaluationResultat);
$evaluationsRattrapagesTab = [];
foreach($evaluationsRattapages as $rattrapage) {
$evaluationsRattrapagesTab[$rattrapage->getStagiaire()->getId()] = 1;
}
// dd($evaluationsRattapages);
}
else {
$evaluations = $evaluationsRepository->findByEvaluationsRecherches($formation, $evaluationStagiaireNom, $evaluationSaisies, $evaluationResultat);
$evaluationsRattapages = $evaluationsRattrapagesRepository->findByEvaluationsRattrapagesRecherches($formation, $evaluationStagiaireNom, $evaluationSaisies, $evaluationResultat);
$evaluationsRattrapagesTab = [];
foreach($evaluationsRattapages as $rattrapage) {
$evaluationsRattrapagesTab[$rattrapage->getStagiaire()->getId()] = 1;
}
}
return $this->render('formations/formationsAfficherEvaluations.html.twig', [
'formation' => $formation,
'formationEtat' => $formationEtat,
'nav' => '7',
'evaluations' => $evaluations,
'evaluationsRattapages' => $evaluationsRattapages,
'evaluationsRattrapagesTab' => $evaluationsRattrapagesTab,
'inscriptions' => $inscriptions,
'formulaireRecherches' => $formulaireRecherches->createView(),
'rechercheExiste' => $rechercheExiste
]);
}
/**
* @Route("/formations/afficher/evaluations/rechercher/initialiser/{idFormation}", name="formations_show_eval_recherches_reset")
*/
public function showFormationEvalRecherchesReset(
$idFormation
): Response
{
$data = [
'evaluationStagiaireNom' => '',
'evaluationSaisies' => '',
'evaluationResultat' => '',
'evaluationSaisies' => '',
'evaluationType' => '',
];
$data = serialize($data);
$expires = time() + 36000;
//LOCAL
$cookie = Cookie::create('EvaluationsRecherches', $data, $expires, '/', '', true, true);
// VPS
// $cookie = Cookie::create('FormationsRecherches', $data, $expires, '/', 'ama64.fr', true, true);
$res = new Response();
$res->headers->setCookie($cookie);
$res->sendHeaders();
return $this->redirectToRoute('formations_show_eval', [
'idFormation' => $idFormation
]);
}
/**
* @Route("/formations/afficher/attestations/{idFormation}", name="formations_show_attestations")
*/
public function showFormationAttestations(
$idFormation,
FormationsRepository $formationsRepository,
FormationsEtatsRepository $formationsEtatsRepository,
InscriptionsFormationsRepository $inscriptionsFormationsRepository,
EvaluationsRepository $evaluationsRepository,
EvaluationsRattrapagesRepository $evaluationsRattrapagesRepository,
plagesFormationsRepository $plagesFormationsRepository,
ConvocationsRepository $convocationsRepository,
Request $request
): Response
{
$formation = $formationsRepository->find($idFormation);
$formationEtat = $formationsEtatsRepository->find($formation->getEtat());
$rechercheExiste = null;
//GESTION DES VALEURS DANS LE FORMULAIRE DE RECHERCHES
$cookie = $request->cookies->get('AttestationsRecherches');
if($cookie) {
$rechercheExiste = 1;
$dataCookie = unserialize($cookie);
$attestationStagiaireNom = $dataCookie['attestationStagiaireNom'];
$attestationResultat = $dataCookie['attestationResultat'];
if($attestationStagiaireNom != '') {
$attestationStagiaireNom = $attestationStagiaireNom;
}
else {
$attestationStagiaireNom = null;
}
if($attestationResultat != '') {
$attestationResultat = $attestationResultat;
}
else {
$attestationResultat = null;
}
}
else {
$attestationStagiaireNom = null;
$attestationResultat = null;
}
$formulaireRecherches = $this->createForm(AttestationsRechercherFormType::class, null, [
'attestationStagiaireNom' => $attestationStagiaireNom,
'attestationResultat' => $attestationResultat,
]);
$formulaireRecherches->handleRequest($request);
if($formulaireRecherches->isSubmitted() && $formulaireRecherches->isValid())
{
$attestationStagiaireNom = $formulaireRecherches->get('stagiaireNom')->getData();
$attestationResultat = $formulaireRecherches->get('resultat')->getData();
//CREATION COOKIE STOCKAGE DES DONNEES DE RECHERCHES
$data = [
'attestationStagiaireNom' => $attestationStagiaireNom,
'attestationResultat' => $attestationResultat,
];
$data = serialize($data);
$expires = time() + 36000;
//LOCAL
$cookie = Cookie::create('AttestationsRecherches', $data, $expires, '/', '', true, true);
// VPS
// $cookie = Cookie::create('FormationsRecherches', $data, $expires, '/', 'ama64.fr',
$res = new Response();
$res->headers->setCookie( $cookie );
$res->sendHeaders();
}
// FIN TRAITEMENT DES RECHERCHES
$inscriptions = $inscriptionsFormationsRepository->findByAttestationsRecherches(
$formation,
$attestationStagiaireNom
);
// dd($inscriptions);
$evaluationsTab = [];
$evaluationTabPSC1 = [];
$evaluationsRattrapagesTab = [];
$evaluationsRattrapagesTabPSC1 = [];
$absences = [];
foreach($inscriptions as $inscription) {
$stagiaire = $inscription->getStagiaires();
$idStagiaire = $stagiaire->getId();
$evaluations = $evaluationsRepository->findBy([
'formation' => $formation,
'stagiaire' => $stagiaire,
'validation' => [1,2]
]);
$evaluationsRattrapages = $evaluationsRattrapagesRepository->findBy([
'formation' => $formation,
'stagiaire' => $stagiaire,
'validation' => [1,2]
]);
$evaluationsTab[$idStagiaire] = count($evaluations);
if($evaluations) {
$evaluationTabPSC1[$idStagiaire] = $evaluations[0]->getPart2PSC1();
}
else {
$evaluationTabPSC1[$idStagiaire] = '';
}
$evaluationsRattrapagesTab[$idStagiaire] = count($evaluationsRattrapages);
if($evaluationsRattrapages) {
$evaluationsRattrapagesTabPSC1[$idStagiaire] = $evaluationsRattrapages[0]->getPart2PSC1();
}
else {
$evaluationsRattrapagesTabPSC1[$idStagiaire] = '';
}
$absencesStagiaires = $plagesFormationsRepository->findByPlagesAbsences($stagiaire, $idFormation);
if(count($absencesStagiaires) > 0) {
$absences[$stagiaire->getId()] = true;
} else {
$absences[$stagiaire->getId()] = false;
}
//TABLEAU DES CONVOCATIONS POUR DEBLOQUER STAGIAIRE AVANT CLOTURE DE FORMATION
$tabConvocation = [];
foreach($inscriptions as $inscription) {
$stagiaire = $inscription->getStagiaires();
$idStagiaire = $stagiaire->getId();
$convocation = $convocationsRepository->findBy(['Stagiaire' => $stagiaire, 'formation' => $formation]);
$idConvocation = $convocation[0]->getId();
$tabConvocation[$idStagiaire] = $idConvocation;
}
// dd($tabConvocation);
}
$jourFr = [
'1' => 'Lundi',
'2' => 'Mardi',
'3' => 'Mercredi',
'4' => 'Jeudi',
'5' => 'Vendredi',
'6' => 'Samedi',
'7' => 'Dimanche',
];
return $this->render('formations/formationsAfficherAttestations.html.twig', [
'formation' => $formation,
'formationEtat' => $formationEtat,
'inscriptions' => $inscriptions,
'evaluationsTab' => $evaluationsTab,
'evaluationsRattrapagesTab' => $evaluationsRattrapagesTab,
'evaluationsTabPSC1' => $evaluationTabPSC1,
'evaluationsRattrapagesTabPSC1' => $evaluationsRattrapagesTabPSC1,
'formulaireRecherches' => $formulaireRecherches->createView(),
'absences' => $absences,
'jourFr' => $jourFr,
'nav' => '8',
'tabConvocation' => $tabConvocation
]);
}
/**
* @Route("/formations/afficher/attestations/rechercher/initialiser/{idFormation}", name="formations_show_attestations_recherches_reset")
*/
public function showFormationAttestationsRecherchesReset(
$idFormation
): Response
{
$data = [
'attestationStagiaireNom' => '',
'attestationResultat' => '',
];
$data = serialize($data);
$expires = time() + 36000;
//LOCAL
$cookie = Cookie::create('AttestationsRecherches', $data, $expires, '/', '', true, true);
// VPS
// $cookie = Cookie::create('FormationsRecherches', $data, $expires, '/', 'ama64.fr', true, true);
$res = new Response();
$res->headers->setCookie($cookie);
$res->sendHeaders();
return $this->redirectToRoute('formations_show_attestations', [
'idFormation' => $idFormation
]);
}
/**
* @Route("/formations/afficher/attestations/finFormation/{idFormation}", name="formations_show_attestations_fin")
*/
public function showFormationAttestationsFin(
$idFormation,
FormationsRepository $formationsRepository,
// PlanningsFormationsRepository $planningsFormationsRepository,
FormationsEtatsRepository $formationsEtatsRepository,
PlagesFormationsRepository $plagesFormationsRepository,
InscriptionsFormationsRepository $inscriptionsFormationsRepository
): Response
{
$formation = $formationsRepository->find($idFormation);
$formationEtat = $formationsEtatsRepository->find($formation->getEtat());
// $plannings = $planningsFormationsRepository->findBy(
// ['formation' => $formation],
// ['dateDebut' => 'ASC']
// );
$inscriptions = $inscriptionsFormationsRepository->findByListeStagiairesInscriptionsPresences(2, $idFormation)->getQuery()->getResult();
// dd($inscriptions);
$tabAttestationsStagiairesPresents = [];
foreach($inscriptions as $inscription) {
$plagesAbsents = $plagesFormationsRepository->createQueryBuilder('p')
->join('p.planning', 'f')
->join('p.stagiaire', 's')
->andWhere('f.formation = '.$idFormation)
->andWhere('s.id = '.$inscription->getStagiaires()->getId())
->andWhere('p.presences = 2')
->andWhere('p.etat = 1')
->getQuery()
->getResult();
if(empty($plagesAbsents)) {
$tabAttestationsStagiairesPresents[] = [
'idStagiaire' => $inscription->getStagiaires()->getId(),
'nomPrenom' => $inscription->getStagiaires()->getNom().' '.$inscription->getStagiaires()->getPrenom()
];
}
}
// dd($tabAttestationsStagiairesPresents);
// $plagesAbsents = '';
// foreach($plagesPresents as $plagePresent) {
// $plagesAbsents = $plagesFormationsRepository->createQueryBuilder('p')
// ->join('p.planning', 'f')
// ->join('p.stagiaire', 's')
// ->andWhere('f.formation = '.$idFormation)
// ->andWhere('p.presences = 2')
// ->andWhere('s.id = '.$plagePresent->getStagiaire()->getId())
// ->orderBy('s.nom', 'ASC')
// ->getQuery()
// ->getResult();
// // dd($plagesAbsents);
// }
// // dd($tabAttestationsStagiairesPresents);
$domainesColors = [
0 => 'bg-secondary',
1 => 'bg-primary',
2 => 'bg-success',
3 => 'bg-warning'
];
$jourFr = [
'1' => 'Lundi',
'2' => 'Mardi',
'3' => 'Mercredi',
'4' => 'Jeudi',
'5' => 'Vendredi',
'6' => 'Samedi',
'7' => 'Dimanche',
];
return $this->render('formations/formationsAfficherAttestationsFinFormation.html.twig', [
'formation' => $formation,
'tabAttestationsStagiairesPresents' => $tabAttestationsStagiairesPresents,
// 'plagesAbsents' => $plagesAbsents,
// 'plannings' => $plannings,
// 'message' => $this->message,
// 'domainesColors' => $domainesColors,
'formationEtat' => $formationEtat,
'jourFr' => $jourFr,
'nav' => '9'
]);
}
/**
* @Route("/formations/afficher/bilan/{idFormation}", name="formations_show_bilan")
*/
public function showFormationBilan(
$idFormation,
FormationsRepository $formationsRepository,
FormationsEtatsRepository $formationsEtatsRepository,
ConvocationsRepository $convocationsRepository,
PlagesFormationsRepository $plagesFormationsRepository,
EvaluationsRepository $evaluationsRepository,
EvaluationsRattrapagesRepository $evaluationsRattrapagesRepository
): Response
{
$formation = $formationsRepository->find($idFormation);
// dd($formation->getFormationInsciptions()[1]->getStagiaires()->getPlagesFormations()[0]);
$formationEtat = $formationsEtatsRepository->find($formation->getEtat());
//CONVOCATIONS : nbre de convoc / nbre de s'engage / nbre de demande de report / nbre contientieux
$convocationsTab = [];
$convocations = $convocationsRepository->findByConvocBilan($idFormation, '');
$convocationsTab['total'] = $convocations;
$convocations = $convocationsRepository->findByConvocBilan($idFormation, [2]);
$convocationsTab['engage'] = $convocations;
$convocations = $convocationsRepository->findByConvocBilan($idFormation, [3,4,5,6,7,8,9]);
$convocationsTab['report'] = $convocations;
$convocations = $convocationsRepository->findByConvocBilan($idFormation, [1,10,11]);
$convocationsTab['contentieux'] = $convocations;
//
$plagesTab = [];
$plages = $plagesFormationsRepository->findByPlagesBilan($idFormation, null);
$plagesTab['total'] = $plages;
$plages = $plagesFormationsRepository->findByPlagesBilan($idFormation, 1);
$plagesTab['presences'] = ($plages*100)/$plagesTab['total'];
$plages = $plagesFormationsRepository->findByPlagesBilan($idFormation, 2);
$plagesTab['absences'] = ($plages*100)/$plagesTab['total'];
//
$evaluationsTab = [];
$evaluationsRattrapagesTab = [];
if($formation->getBloc()->getNumBloc() == 1) {
$evaluations = $evaluationsRepository->findByEvaluationsBilan($idFormation, null);
$evaluationsTab['total'] = $evaluations;
$evaluations = $evaluationsRepository->findByEvaluationsBilan($idFormation, 1);
$evaluationsTab['reussite'] = ($evaluations*100)/$evaluationsTab['total'];
$evaluations = $evaluationsRepository->findByEvaluationsBilan($idFormation, 2);
$evaluationsTab['echec'] = ($evaluations*100)/$evaluationsTab['total'];
$evaluationsRattrapages = $evaluationsRattrapagesRepository->findByEvalutionsRattrapagesBilan($idFormation, null);
$evaluationsRattrapagesTab['total'] = $evaluationsRattrapages;
if($evaluationsRattrapagesTab['total'] != 0) {
$evaluationsRattrapages = $evaluationsRattrapagesRepository->findByEvalutionsRattrapagesBilan($idFormation, 1);
$evaluationsRattrapagesTab['reussite'] = ($evaluationsRattrapages*100)/$evaluationsRattrapagesTab['total'];
$evaluationsRattrapages = $evaluationsRattrapagesRepository->findByEvalutionsRattrapagesBilan($idFormation, 2);
$evaluationsRattrapagesTab['echec'] = ($evaluationsRattrapages*100)/$evaluationsRattrapagesTab['total'];
}
else {
$evaluationsRattrapagesTab['reussite'] = 0;
$evaluationsRattrapagesTab['echec'] = 0;
}
}
// CHEMIN TELECHARGEMENT DES ATTESTATIONS ZIP
$domainesColors = [
0 => 'bg-secondary',
1 => 'bg-primary',
2 => 'bg-success',
3 => 'bg-warning'
];
$jourFr = [
'1' => 'Lundi',
'2' => 'Mardi',
'3' => 'Mercredi',
'4' => 'Jeudi',
'5' => 'Vendredi',
'6' => 'Samedi',
'7' => 'Dimanche',
];
return $this->render('formations/formationsAfficherBilan.html.twig', [
'formation' => $formation,
'formationEtat' => $formationEtat,
'convocationsTab' => $convocationsTab,
'plagesTab' => $plagesTab,
'evaluationsTab' => $evaluationsTab,
'evaluationsRattrapagesTab' => $evaluationsRattrapagesTab,
'jourFr' => $jourFr,
'nav' => '10'
]);
}
/**
* @Route("/formations/bilan/attestations/telecharger/{idFormation}", name="formations_bilan_attestations_zip_download")
*/
public function attestationsZipDownload(
$idFormation,
FormationsRepository $formationsRepository
): Response
{
$formation = $formationsRepository->find($idFormation);
$formationIntitule = $formation->getIntitule();
$formationIntitule = str_replace(' ', '-', $formationIntitule);
return (new BinaryFileResponse(
$this->AttestPdfDirectory.'idFormation-'.$idFormation.'/'.$formationIntitule.'_Bilan.zip'
))->setContentDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT, $formationIntitule.'_Bilan.zip');
}
/**
* @Route("/formations/attestations/PSC1/afficher/{idFormation}", name="formations_show_psc1")
*/
public function showPSC1(
$idFormation,
FormationsRepository $formationsRepository,
FormationsEtatsRepository $formationsEtatsRepository,
PlagesFormationsRepository $plagesFormationsRepository,
PlanningsFormationsRepository $planningsFormationsRepository
): Response
{
$formation = $formationsRepository->find($idFormation);
$formationEtat = $formationsEtatsRepository->find($formation->getEtat());
// $listeStagiaires = $plagesFormationsRepository->findByPlagesPSC1($idFormation);
// $listePlagesPSC1 = $plagesFormationsRepository->findByPlagesPSC1Toutes($idFormation);
$plannings = $planningsFormationsRepository->createQueryBuilder('planning')
->andWhere('planning.formation IN (:val1)')
->andWhere('planning.etat = 1')
->andWhere("planning.psc1Groupe1 = 1 OR planning.psc1Groupe2 = 1")
->setParameter('val1', $formation)
->getQuery()
->getResult();
// dd($plannings);
$planningsDateDebut1 = $plannings[0]->getDateDebut();
$planningsDateDebut2 = $plannings[1]->getDateDebut();
$plagesToutes = $plagesFormationsRepository->createQueryBuilder('plages')
->leftJoin('plages.planning', 'planning')
->leftJoin('plages.stagiaire', 'stagiaire')
->andWhere('plages.planning IN (:val1)')
->andWhere('plages.etat = 1')
->setParameter('val1', $plannings)
->orderBy('planning.psc1Groupe1', 'DESC')
->addOrderBy('stagiaire.id', 'ASC')
->getQuery()
->getResult();
// dump($plagesToutes);
$listeStagiairesTab = [];
$x = 1;
foreach($plagesToutes as $plage) {
if (array_key_exists($plage->getStagiaire()->getId(), $listeStagiairesTab)) {
if($plage->getPlanning()->getPsc1Groupe1() == 1) {
$listeStagiairesTab[$plage->getStagiaire()->getId()][] = ['psc1Groupe1' => [$plage->getId(), $plage->getPSC1Groupe()]];
}
else if($plage->getPlanning()->getPsc1Groupe2() == 1) {
$listeStagiairesTab[$plage->getStagiaire()->getId()][] = ['psc1Groupe2' => [$plage->getId(), $plage->getPSC1Groupe()]];
}
} else {
$listeStagiairesTab[$plage->getStagiaire()->getId()]['stagiaire'] = [
'id' => $plage->getStagiaire()->getId(),
'nom' => $plage->getStagiaire()->getNom(),
'prenom' => $plage->getStagiaire()->getPrenom(),
];
if($plage->getPlanning()->getPsc1Groupe1() == 1) {
$listeStagiairesTab[$plage->getStagiaire()->getId()][] = ['psc1Groupe1' => [$plage->getId(), $plage->getPSC1Groupe()]];
}
else if($plage->getPlanning()->getPsc1Groupe2() == 1) {
$listeStagiairesTab[$plage->getStagiaire()->getId()][] = ['psc1Groupe2' => [$plage->getId(), $plage->getPSC1Groupe()]];
}
}
$x++;
}
// dd($listeStagiairesTab);
$domainesColors = [
0 => 'bg-secondary',
1 => 'bg-primary',
2 => 'bg-success',
3 => 'bg-warning'
];
$jourFr = [
'1' => 'Lundi',
'2' => 'Mardi',
'3' => 'Mercredi',
'4' => 'Jeudi',
'5' => 'Vendredi',
'6' => 'Samedi',
'7' => 'Dimanche',
];
return $this->render('formations/formationsAfficherPSC1.html.twig', [
'formation' => $formation,
'formationEtat' => $formationEtat,
'jourFr' => $jourFr,
'listeStagiairesTab' => $listeStagiairesTab,
'planningsDateDebut1' => $planningsDateDebut1,
'planningsDateDebut2' => $planningsDateDebut2,
'nav' => '5'
]);
}
}