src/Controller/StudentController.php line 81

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