src/Controller/StudentController.php line 174

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\Student;
  4. use App\Entity\Subscription;
  5. use App\Form\StudentType;
  6. use App\Repository\StudentRepository;
  7. use App\Repository\EvaluationRepository;
  8. use App\Repository\SequenceRepository;
  9. use App\Repository\MarkRepository;
  10. use Knp\Bundle\SnappyBundle\Snappy\Response\PdfResponse;
  11. use Knp\Snappy\Pdf;
  12. use App\Repository\SchoolYearRepository;
  13. use App\Repository\SubscriptionRepository;
  14. use App\Repository\PaymentRepository;
  15. use App\Repository\QuaterRepository;
  16. use App\Repository\InstallmentRepository;
  17. use App\Repository\PaymentPlanRepository;
  18. use Doctrine\ORM\EntityManagerInterface;
  19. use Symfony\Component\HttpFoundation\Request;
  20. use Symfony\Component\HttpFoundation\Response;
  21. use Symfony\Component\Routing\Annotation\Route;
  22. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
  23. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
  24. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  25. use App\Service\SchoolYearService;
  26. /**
  27.  * Studentme controller.
  28.  *
  29.  * @Route("/admin/students")
  30.  */
  31. class StudentController extends AbstractController
  32. {
  33.     private EntityManagerInterface $em;
  34.     private $repo;
  35.     private $scRepo;
  36.     private $seqRepo;
  37.     private SubscriptionRepository $subRepo;
  38.     private $markRepo;
  39.     private $evalRepo;
  40.     private $qtRepo;
  41.     private  $snappy;
  42.     private SchoolYearService      $schoolYearService;
  43.     private PaymentPlanRepository $ppRepo;
  44.     private InstallmentRepository $instRepo;
  45.     private PaymentRepository $pRepo;
  46.     public function __construct(PaymentRepository $pRepoInstallmentRepository $instRepoPaymentPlanRepository $ppRepo,SchoolYearService $schoolYearService,EntityManagerInterface $emSubscriptionRepository $subRepoMarkRepository $markRepoEvaluationRepository $evalRepoStudentRepository $repoSequenceRepository $seqRepoSchoolYearRepository $scRepoQuaterRepository $qtRepoPdf $snappy)
  47.     {
  48.         $this->em       $em;
  49.         $this->repo     $repo;
  50.         $this->scRepo   $scRepo;
  51.         $this->markRepo $markRepo;
  52.         $this->seqRepo  $seqRepo;
  53.         $this->evalRepo $evalRepo;
  54.         $this->subRepo  $subRepo;
  55.         $this->qtRepo   $qtRepo;
  56.         $this->snappy   $snappy;
  57.         $this->ppRepo   $ppRepo;
  58.         $this->pRepo    $pRepo;
  59.         $this->instRepo $instRepo;
  60.         $this->schoolYearService $schoolYearService;
  61.     }
  62.       /**
  63.      * @Route("/create",name= "admin_students_new", methods={"GET","POST"})
  64.      */
  65.     public function create(Request $request): Response
  66.     {
  67.         if (!$this->getUser()) {
  68.             $this->addFlash('warning''You need login first!');
  69.             return $this->redirectToRoute('app_login');
  70.         }
  71.         if (!$this->getUser()->isVerified()) {
  72.             $this->addFlash('warning''You need to have a verified account!');
  73.             return $this->redirectToRoute('app_login');
  74.         }
  75.         $student = new Student();
  76.         $form $this->createForm(StudentType::class, $student);
  77.         $numero $this->repo->getNumeroDispo();
  78.         $student->setMatricule($numero);
  79.         $form->handleRequest($request);
  80.         if ($form->isSubmitted() && $form->isValid()) {
  81.             if($student->getEntryClass()!=NULL){
  82.                 $sub = new Subscription();
  83.                 $sub->setStudent($student);
  84.                 $sub->setClassRoom($student->getEntryClass());
  85.                 $sub->setSchoolYear($this->schoolYearService->sessionYearById());
  86.                 $this->em->persist($sub);
  87.             }
  88.             $this->em->persist($student);
  89.             $this->em->flush();
  90.             $this->addFlash('success''Student succesfully created');
  91.             return $this->redirectToRoute('admin_students', [
  92.                 'type' =>"new_students_not_yet_registered_checkbox",
  93.             ]);
  94.         }
  95.         return $this->render(
  96.             'student/new.html.twig',
  97.             ['form' => $form->createView()]
  98.         );
  99.     }
  100.     /**
  101.      * Lists all Studentme entities.
  102.      *
  103.      * @Route("/{type}", name="admin_students")
  104.      * @Method("GET")
  105.      * @Template()
  106.      */
  107.     public function indexAction($type)
  108.     {
  109.         if (!$this->getUser()) {
  110.             $this->addFlash('warning''You need login first!');
  111.             return $this->redirectToRoute('app_login');
  112.         }
  113.         if (!$this->getUser()->isVerified()) {
  114.             $this->addFlash('warning''You need to have a verified account!');
  115.             return $this->redirectToRoute('app_login');
  116.         }
  117.         $year $this->schoolYearService->sessionYearById();
  118.        
  119.        
  120.         switch ($type) {
  121.             case "new_students_not_yet_registered_checkbox":
  122.                 $students $this->repo->findNewStudents($year);
  123.                 break;
  124.             case "new_registered_students_checkbox":
  125.                 $students =  $this->repo->findNewRegisteredStudents($year);
  126.                 break;
  127.             case "registered_former_students_checkbox":
  128.                 $students =  $this->repo->findFormerRegisteredStudents($year);
  129.                 break;
  130.             case "complete_registered_students_checkbox":
  131.                     $students =  $this->repo->findEnrolledStudentsThisYear2($year);
  132.                 break;
  133.             default:
  134.                 $students $this->repo->findEnrolledStudentsThisYear2();
  135.                 break;
  136.         }
  137.         
  138.         return $this->render('student/list.html.twig'compact("students"));
  139.     }
  140.     /**
  141.      * Finds and displays a Studentme entity.
  142.      *
  143.      * @Route("/{id}/show", name="admin_students_show", requirements={"id"="\d+"})
  144.      * @Method("GET")
  145.      * @Template()
  146.      */
  147.     public function showAction(Student $student)
  148.     {
  149.         // AnnĂ©e scolaire, seuquence, inscrption de l'eleve pour l'annee en cours
  150.         if (!$this->getUser()) {
  151.             $this->addFlash('warning''You need login first!');
  152.             return $this->redirectToRoute('app_login');
  153.         }
  154.         if (!$this->getUser()->isVerified()) {
  155.             $this->addFlash('warning''You need to have a verified account!');
  156.             return $this->redirectToRoute('app_login');
  157.         }
  158.         $year $this->schoolYearService->sessionYearById();
  159.         $seq $this->seqRepo->findOneBy(array("activated" => true));
  160.         $sub $this->subRepo->findOneBy(array("student" => $student"schoolYear" => $year));
  161.         $results['student'] = $student;
  162.         $results['cours'] = null;
  163.         $results['session1'] = null;
  164.         $results['session2'] = null;
  165.         $results['session3'] = null;
  166.         $results['session4'] = null;
  167.         $results['session5'] = null;
  168.         $results['session6'] = null;
  169.         $evals = [];
  170.         $evalSeqs = [];
  171.         $payments $this->pRepo->findBy(array( "schoolYear"=> $year"student"=> $student), array('updatedAt' => 'ASC'));
  172.         $paymentPlan $this->ppRepo->findOneBy(array( "schoolYear"=> $year));
  173.         if($sub!=null){
  174.             $installments $this->instRepo->findBy(array( "paymentPlan"=> $paymentPlan"classRoom"=> $sub->getClassRoom()));
  175.         } else {
  176.             $installments $this->instRepo->findBy(array( "paymentPlan"=> $paymentPlan));
  177.         }
  178.         $seqs $this->seqRepo->findSequenceThisYear($year);
  179.         if ($sub != null) {
  180.             foreach ($seqs as $seq) {
  181.                 $evalSeqs[$seq->getId()] = $this->evalRepo->findBy(array("classRoom" => $sub->getClassRoom(), "sequence" => $seq));
  182.             }
  183.             $courses = [];
  184.             $averageSeqs = [];
  185.             // Traitements de donnees pour les graphes
  186.             foreach ($evalSeqs[$seq->getId()] as $eval) {
  187.                 $courses[] = $eval->getCourse()->getWording();
  188.             }
  189.             foreach ($seqs as $seq) {
  190.                 $average = [];
  191.                 foreach ($evalSeqs[$seq->getId()]  as $eval) {
  192.                     if ($this->markRepo->findOneBy(array("student" => $student"evaluation" => $eval)))
  193.                         $average[] = $this->markRepo->findOneBy(array("student" => $student"evaluation" => $eval))->getValue();
  194.                 }
  195.                 $averageSeqs[$seq->getId()] = $average;
  196.             }
  197.             $filename "assets/images/student/" $student->getMatricule() . ".jpg";
  198.             $file_exists file_exists($filename);
  199.             $results['payments'] = $payments;
  200.             $results['payment_plan'] = $paymentPlan;
  201.             $results['installments'] = $installments;
  202.             $results['sub'] = $sub;
  203.             $results['file_exists'] = $file_exists;
  204.             $results['cours'] = json_encode($courses);
  205.             
  206.             foreach ($seqs as $seq) {
  207.                 $results[strtolower($seq->getWording())] = json_encode($averageSeqs[$seq->getId()]);
  208.             }
  209.         }
  210.         return $this->render('student/show.html.twig'$results);
  211.     }
  212.   
  213.     /**
  214.      * Displays a form to edit an existing Studentme entity.
  215.      *
  216.      * @Route("/{id}/edit", name="admin_students_edit", requirements={"id"="\d+"}, methods={"GET","PUT"})
  217.      * @Template()
  218.      */
  219.     public function edit(Request $requestStudent $student): Response
  220.     {
  221.         if (!$this->getUser()) {
  222.             $this->addFlash('warning''You need login first!');
  223.             return $this->redirectToRoute('app_login');
  224.         }
  225.         if (!$this->getUser()->isVerified()) {
  226.             $this->addFlash('warning''You need to have a verified account!');
  227.             return $this->redirectToRoute('app_login');
  228.         }
  229.         $form $this->createForm(StudentType::class, $student, [
  230.             'method' => 'PUT'
  231.         ]);
  232.         $form->handleRequest($request);
  233.         if ($form->isSubmitted() && $form->isValid()) {
  234.             $this->em->flush();
  235.             $this->addFlash('success''Student succesfully updated');
  236.             //return $this->redirectToRoute('admin_students_show', ['id' => $student->getId()]);
  237.             return $this->redirectToRoute('admin_students', [
  238.                 'type' =>"new_students_not_yet_registered_checkbox",
  239.             ]);
  240.         }
  241.         return $this->render('student/edit.html.twig', [
  242.             'student' => $student,
  243.             'form' => $form->createView()
  244.         ]);
  245.     }
  246.     /**
  247.      * Deletes a Studentme entity.
  248.      *
  249.      * @Route("/{id}/delete", name="admin_students_delete", requirements={"id"="\d+"}, methods={"DELETE"})
  250.      */
  251.     public function delete(Student $studentRequest $request): Response
  252.     {
  253.         if (!$this->getUser()) {
  254.             $this->addFlash('warning''You need login first!');
  255.             return $this->redirectToRoute('app_login');
  256.         }
  257.         if (!$this->getUser()->isVerified()) {
  258.             $this->addFlash('warning''You need to have a verified account!');
  259.             return $this->redirectToRoute('app_login');
  260.         }
  261.         if ($this->isCsrfTokenValid('students_deletion' $student->getId(), $request->request->get('csrf_token'))) {
  262.             $this->em->remove($student);
  263.             $this->em->flush();
  264.             $this->addFlash('info''Student succesfully deleted');
  265.         }
  266.         return $this->redirectToRoute('admin_students', [
  267.             'type' =>"new_students_not_yet_registered_checkbox",
  268.         ]);
  269.     }
  270.     /**
  271.      * Build student's school certificate
  272.      *
  273.      * @Route("/{id}/certificate", name="admin_student_certificate", requirements={"id"="\d+"})
  274.      */
  275.     public function schoolCertificate(Pdf $pdfStudent $std): Response
  276.     {
  277.         if (!$this->getUser()) {
  278.             $this->addFlash('warning''You need login first!');
  279.             return $this->redirectToRoute('app_login');
  280.         }
  281.         if (!$this->getUser()->isVerified()) {
  282.             $this->addFlash('warning''You need to have a verified account!');
  283.             return $this->redirectToRoute('app_login');
  284.         }
  285.         $year $this->schoolYearService->sessionYearById();
  286.         $sub $this->subRepo->findOneBy(array("student" => $std"schoolYear" => $year));
  287.         $html $this->renderView('student/school_certificate.html.twig', array(
  288.             'year' => $year,
  289.             'std'  => $std,
  290.             'sub' => $sub
  291.         ));
  292.         return new Response(
  293.             $pdf->getOutputFromHtml($html),
  294.             200,
  295.             array(
  296.                 'Content-Type'          => 'application/pdf',
  297.                 'Content-Disposition'   => 'inline; filename="certif_'.$std->getMatricule()  . '.pdf"'
  298.             )
  299.         );
  300.     }
  301.      /**
  302.      * Build student's school certificate
  303.      *
  304.      * @Route("/{id}/receipt", name="admin_student_receipt", requirements={"id"="\d+"})
  305.      */
  306.     public function tuitionReceiptAction(Pdf $pdfStudent $std): Response
  307.     {
  308.         if (!$this->getUser()) {
  309.             $this->addFlash('warning''You need login first!');
  310.             return $this->redirectToRoute('app_login');
  311.         }
  312.         if (!$this->getUser()->isVerified()) {
  313.             $this->addFlash('warning''You need to have a verified account!');
  314.             return $this->redirectToRoute('app_login');
  315.         }
  316.         $year $this->schoolYearService->sessionYearById();
  317.         $sub $this->subRepo->findOneBy(array("student" => $std"schoolYear" => $year));
  318.         $payments $this->pRepo->findBy(array( "schoolYear"=> $year"student"=> $std), array('updatedAt' => 'DESC'));
  319.         $paymentPlan $this->ppRepo->findOneBy(array( "schoolYear"=> $year));
  320.         $installments $this->instRepo->findBy(array( "paymentPlan"=> $paymentPlan"classRoom"=> $sub->getClassRoom()));
  321.         $html $this->renderView('student/tuition_receipt.html.twig', array(
  322.             'year' => $year,
  323.             'std'  => $std,
  324.             'sub' => $sub,
  325.             'payments' => $payments,
  326.             'payment_plan' => $paymentPlan,
  327.             'installments' => $installments
  328.         ));
  329.         return new Response(
  330.             $pdf->getOutputFromHtml($html),
  331.             200,
  332.             array(
  333.                 'Content-Type'          => 'application/pdf',
  334.                 'Content-Disposition'   => 'inline; filename="recu_'.$std->getMatricule()  . '.pdf"'
  335.             )
  336.         );
  337.     }
  338.     /**
  339.      * Build student's school certificate
  340.      *
  341.      * @Route("/{id}/badge", name="admin_student_badge", requirements={"id"="\d+"})
  342.      */
  343.     public function schoolBadge(Pdf $pdfStudent $std): Response
  344.     {
  345.         if (!$this->getUser()) {
  346.             $this->addFlash('warning''You need login first!');
  347.             return $this->redirectToRoute('app_login');
  348.         }
  349.         if (!$this->getUser()->isVerified()) {
  350.             $this->addFlash('warning''You need to have a verified account!');
  351.             return $this->redirectToRoute('app_login');
  352.         }
  353.         $year $this->schoolYearService->sessionYearById();
  354.         $sub $this->subRepo->findOneBy(array("student" => $std"schoolYear" => $year));
  355.         $filename "assets/images/student/" $std->getMatricule() . ".jpg";
  356.         $fileExist file_exists($filename);
  357.         $html $this->renderView('student/badge.html.twig', array(
  358.             'sub' => $sub,
  359.             'fileExist' => $fileExist
  360.         ));
  361.         return new Response(
  362.             $pdf->getOutputFromHtml($html),
  363.             200,
  364.             array(
  365.                 'Content-Type'          => 'application/pdf',
  366.                 'Content-Disposition'   => 'inline; filename="badge_'.$std->getMatricule()  . '.pdf"'
  367.             )
  368.         );
  369.     }
  370.     /**
  371.      * Finds and displays a ClassRoom entity.
  372.      *
  373.      * @Route("/{id}/reportCardTrim", name="admin_students_reportcards_quat", requirements={"id"="\d+"})
  374.      * @Method("GET")
  375.      * @Template()
  376.      */
  377.     public function reporCardTrimAction(Pdf $pdfStudent $std)
  378.     {
  379.         if (!$this->getUser()) {
  380.             $this->addFlash('warning''You need login first!');
  381.             return $this->redirectToRoute('app_login');
  382.         }
  383.         if (!$this->getUser()->isVerified()) {
  384.             $this->addFlash('warning''You need to have a verified account!');
  385.             return $this->redirectToRoute('app_login');
  386.         }
  387.         $connection $this->em->getConnection();
  388.         $year $this->schoolYearService->sessionYearById();
  389.         $sub $this->subRepo->findOneBy(array("student" => $std"schoolYear" => $year));
  390.         $quater $this->qtRepo->findOneBy(array("activated" => true));
  391.         $sequences $this->seqRepo->findBy(array("quater" => $quater));
  392.         $filename "assets/images/student/" $std->getMatricule() . ".jpg";
  393.         $fileExist file_exists($filename);
  394.         
  395.         $i 1;
  396.         foreach ($sequences as $seq) {
  397.             /*******************************************************************************************************************/
  398.             /***************CREATION DE la VIEW DES NOTES  SEQUENTIELLES, TRIMESTRIELLES ET ANNUELLES DE L'ELEVE**************/
  399.             /*******************************************************************************************************************/
  400.             // CAS DES NOTES SEQUENTIELLES
  401.             $statement $connection->prepare(
  402.                 "  CREATE OR REPLACE VIEW V_STUDENT_MARK_SEQ" $i " AS
  403.                     SELECT DISTINCT  eval.id as eval,crs.id as crs, room.id as room,  teach.full_name as teacher    , modu.id as module,m.value as value, m.weight as weight
  404.                     FROM  mark  m   JOIN  student    std     ON  m.student_id        =   std.id
  405.                     JOIN  evaluation eval    ON  m.evaluation_id     =   eval.id
  406.                     JOIN  class_room room    ON   eval.class_room_id     =   room.id
  407.                     JOIN  course     crs     ON  eval.course_id      =   crs.id
  408.                     JOIN  attribution att    ON  att.course_id      =   crs.id
  409.                     JOIN  user  teach ON  att.teacher_id  =   teach.id
  410.                     JOIN  module     modu    ON  modu.id       =   crs.module_id
  411.                     JOIN  sequence   seq     ON  seq.id     =   eval.sequence_id
  412.                     WHERE   std.id = ?  AND eval.sequence_id =?
  413.                     ORDER BY crs.id; "
  414.             );
  415.             $statement->bindValue(1$std->getId());
  416.             $statement->bindValue(2$seq->getId());
  417.             $statement->execute();
  418.             $i++;
  419.         }
  420.         $statement $connection->prepare(
  421.             "  CREATE OR REPLACE VIEW V_STUDENT_MARK_QUATER AS
  422.             SELECT DISTINCT    seq1.crs as crs,  (seq1.value*seq1.weight + seq2.value*seq2.weight)/(seq1.weight+seq2.weight)  as value, greatest(seq1.weight , seq2.weight ) as weight , seq1.weight as weight1,seq2.weight as weight2, seq1.value as value1,seq2.value as value2,   seq1.teacher as teacher, seq1.module as   module, seq1.room as room
  423.             FROM V_STUDENT_MARK_SEQ1 seq1
  424.             JOIN  V_STUDENT_MARK_SEQ2 seq2  
  425.             ON  (seq1.crs = seq2.crs)
  426.             ORDER BY seq1.crs"
  427.         );
  428.         $statement->execute();
  429.         
  430.        
  431.         
  432.         $dataQuater $connection->executeQuery("SELECT *  FROM V_STUDENT_MARK_QUATER ")->fetchAll();
  433.         $html $this->renderView('student/reportcardTrimApc.html.twig', array(
  434.             'year' => $year,
  435.             'quater' => $quater,
  436.             'data' => $dataQuater,
  437.             'sequences' => $sequences,
  438.             'std'  => $std,
  439.             'room' => $sub->getClassRoom(),
  440.             'fileExist' => $fileExist
  441.         ));
  442.         return new Response(
  443.             $pdf->getOutputFromHtml($html),
  444.             200,
  445.             array(
  446.                 'Content-Type'          => 'application/pdf',
  447.                 'Content-Disposition'   => 'inline; filename="bull_' .  $quater->getId().'_'.$std->getMatricule()  . '.pdf"'
  448.             )
  449.         );
  450.     }
  451.     /**
  452.      * Finds and displays a ClassRoom entity.
  453.      *
  454.      * @Route("/{id}/reportCardYear", name="admin_students_reportcards_year", requirements={"id"="\d+"})
  455.      * @Method("GET")
  456.      * @Template()
  457.      */
  458.     public function reporCardYear(Student $std)
  459.     {
  460.         if (!$this->getUser()) {
  461.             $this->addFlash('warning''You need login first!');
  462.             return $this->redirectToRoute('app_login');
  463.         }
  464.         if (!$this->getUser()->isVerified()) {
  465.             $this->addFlash('warning''You need to have a verified account!');
  466.             return $this->redirectToRoute('app_login');
  467.         }
  468.         $connection $this->em->getConnection();
  469.         $year $this->schoolYearService->sessionYearById();
  470.         $sequences $this->seqRepo->findSequenceThisYear($year);
  471.         $sub $this->subRepo->findOneBy(array("student" => $std"schoolYear" => $year));
  472.         $filename "assets/images/student/" $std->getMatricule() . ".jpg";
  473.         $fileExist file_exists($filename);
  474.         $i 1;
  475.         foreach ($sequences as $seq) {
  476.             /*******************************************************************************************************************/
  477.             /***************CREATION DE la VIEW DES NOTES  SEQUENTIELLES, TRIMESTRIELLES ET ANNUELLES DE L'ELEVE**************/
  478.             /*******************************************************************************************************************/
  479.             // CAS DES NOTES SEQUENTIELLES
  480.             $statement $connection->prepare(
  481.                 "  CREATE OR REPLACE VIEW V_STUDENT_MARK_SEQ" $i " AS
  482.                     SELECT DISTINCT  eval.id as eval,crs.id as crs, room.id as room,year.id as year,  teach.id as teacher    , modu.id as module,m.value as value, m.weight as weight
  483.                     FROM  mark  m   JOIN  student    std     ON  m.student_id        =   std.id
  484.                     JOIN  evaluation eval    ON  m.evaluation_id     =   eval.id
  485.                     JOIN  class_room room    ON   eval.class_room_id     =   room.id
  486.                     JOIN  course     crs     ON  eval.course_id      =   crs.id
  487.                     JOIN  attribution att    ON  att.course_id      =   crs.id
  488.                     JOIN  user  teach ON  att.teacher_id  =   teach.id
  489.                     JOIN  module     modu    ON  modu.id       =   crs.module_id
  490.                     JOIN  sequence   seq     ON  seq.id     =   eval.sequence_id
  491.                     JOIN  quater   quat     ON  seq.quater_id     =   quat.id
  492.                     JOIN  school_year   year ON  quat.school_year_id     =   year.id
  493.                     WHERE   std.id = ? AND  room.id = ? AND eval.sequence_id =?
  494.                     ORDER BY crs.id; "
  495.             );
  496.             $statement->bindValue(1$std->getId());
  497.             $statement->bindValue(2$sub->getClassRoom()->getId());
  498.             $statement->bindValue(3$seq->getId());
  499.             $statement->execute();
  500.             $i++;
  501.         }
  502.         // CAS DES NOTES TRIMESTRIELLES
  503.         $statement $connection->prepare(
  504.             "  CREATE OR REPLACE VIEW V_STUDENT_MARK_QUATER1 AS
  505.             SELECT DISTINCT    seq1.crs as crs,  (seq1.value*seq1.weight + seq2.value*seq2.weight)/(seq1.weight+seq2.weight)  as value, greatest(seq1.weight , seq2.weight ) as weight ,  seq1.teacher as teacher, seq1.module as   modu, seq1.room as room
  506.             FROM V_STUDENT_MARK_SEQ1 seq1
  507.             JOIN  V_STUDENT_MARK_SEQ2 seq2  
  508.             ON  (seq1.crs = seq2.crs)
  509.             ORDER BY seq1.crs"
  510.         );
  511.         $statement->execute();
  512.         $statement $connection->prepare(
  513.             "  CREATE OR REPLACE VIEW V_STUDENT_MARK_QUATER2 AS
  514.             SELECT DISTINCT    seq1.crs as crs,  (seq1.value*seq1.weight + seq2.value*seq2.weight)/(seq1.weight+seq2.weight)  as value, greatest(seq1.weight , seq2.weight ) as weight ,  seq1.teacher as teacher, seq1.module as   modu, seq1.room as room
  515.             FROM V_STUDENT_MARK_SEQ3 seq1
  516.             JOIN  V_STUDENT_MARK_SEQ4 seq2  
  517.             ON  (seq1.crs = seq2.crs)
  518.             ORDER BY seq1.crs"
  519.         );
  520.         $statement->execute();
  521.         $statement $connection->prepare(
  522.             "  CREATE OR REPLACE VIEW V_STUDENT_MARK_QUATER3 AS
  523.             SELECT DISTINCT    seq1.crs as crs,  (seq1.value*seq1.weight + seq2.value*seq2.weight)/(seq1.weight+seq2.weight)  as value, greatest(seq1.weight , seq2.weight ) as weight ,  seq1.teacher as teacher, seq1.module as   modu, seq1.room as room
  524.             FROM V_STUDENT_MARK_SEQ5 seq1
  525.             JOIN  V_STUDENT_MARK_SEQ6 seq2  
  526.             ON  (seq1.crs = seq2.crs)
  527.             ORDER BY seq1.crs"
  528.         );
  529.         $statement->execute();
  530.        // dd($dataYear);
  531.         // CAS DES NOTES ANNUELLES
  532.         $statement $connection->prepare(
  533.             "CREATE OR REPLACE VIEW ANNUAL_DATA AS
  534.             SELECT DISTINCT 
  535.             course.wording as course, course.coefficient as coef, 
  536.             module.name as module,
  537.             user.full_name as teacher,
  538.             quat1.value as value1, quat1.weight as weight1,  
  539.             quat2.value as value2,  quat2.weight as weight2,  
  540.             quat3.value as value3,quat3.weight as weight3,
  541.             ( quat1.value*quat1.weight+ quat2.value*quat2.weight + quat3.value*quat3.weight) /(quat1.weight+quat2.weight+quat3.weight) as value
  542.              
  543.             FROM V_STUDENT_MARK_QUATER1  quat1 
  544.             JOIN  class_room ON class_room.id = quat1.room
  545.             JOIN  course    ON course.id = quat1.crs
  546.             JOIN  module    ON course.module_id = quat1.modu
  547.             JOIN user ON user.id = quat1.teacher
  548.             JOIN   V_STUDENT_MARK_QUATER2   quat2  ON   quat1.crs = quat2.crs
  549.             JOIN 
  550.             V_STUDENT_MARK_QUATER3   quat3  ON  quat2.crs = quat3.crs
  551.             ORDER BY  module
  552.             "
  553.         );
  554.         $statement->execute();
  555.         $dataYear $connection->executeQuery("SELECT *  FROM ANNUAL_DATA ")->fetchAll();
  556.         
  557.         $html $this->renderView('student/reportcardYearApc.html.twig', array(
  558.             'year' => $year,
  559.             'data' => $dataYear,
  560.             'std'  => $std,
  561.             'room' => $sub->getClassRoom(),
  562.             'fileExist' => $fileExist
  563.         ));
  564.         return new Response(
  565.             $this->snappy->getOutputFromHtml($html),
  566.             200,
  567.             array(
  568.                 'Content-Type' => 'application/pdf',
  569.                 'Content-Disposition' => 'attachment; filename="BUL_ANN_' $std->getMatricule() . '.pdf"',
  570.             )
  571.         );
  572.     }
  573. }