src/Controller/ward/AllocationController.php line 234

Open in your IDE?
  1. <?php
  2. namespace App\Controller\ward;
  3. use App\Entity\AllocationRemark;
  4. use App\Entity\Bursary;
  5. use App\Entity\CancelledAllocation;
  6. use App\Entity\FundAccount;
  7. use App\Entity\Student;
  8. use App\Entity\StudentAllocation;
  9. use App\Entity\Take;
  10. use App\Entity\Transaction;
  11. use App\Entity\Ward;
  12. use App\Form\AllocationCancelType;
  13. use App\Form\AllocationRemarkType;
  14. use App\Form\AllocationType;
  15. use Doctrine\ORM\NonUniqueResultException;
  16. use Doctrine\Persistence\ObjectManager;
  17. use JMS\Serializer\SerializationContext;
  18. use JMS\Serializer\SerializerBuilder;
  19. use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
  20. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  21. use Symfony\Component\HttpFoundation\Request;
  22. use Symfony\Component\HttpFoundation\Response;
  23. use Symfony\Component\Routing\Annotation\Route;
  24. class AllocationController extends AbstractController {
  25.     /**
  26.      * @Route("/allocations", name="allocationsRoute")
  27.      * @IsGranted("ROLE_USER")
  28.      * @param Request $request
  29.      * @return Response
  30.      */
  31.     public function home(Request $request): Response {
  32.         $em $this->getDoctrine()->getManager();
  33.         if(!$request->getSession()->has('ward_id') && !$request->getSession()->get('ward_id') ){
  34.             return $this->redirectToRoute('wardSelectRoute');
  35.         }
  36.         return $this->render('ward/allocations.html.twig',[
  37.         ]);
  38.     }
  39.     /**
  40.      * @Route("/allocations/add/{id}", name="allocationsDateRoute")
  41.      * @IsGranted("ROLE_USER")
  42.      * @param Request $request
  43.      * @param Student $student
  44.      * @return Response
  45.      */
  46.     public function allocationDetail(Request $requestStudent $student):Response {
  47.         if(!$this->isGranted("ROLE_WARD_ADMIN")  && !$this->isGranted("ROLE_ADMIN")){
  48.             return $this->render('ward/others/allocation_detail.html.twig',[
  49.                 'isAuthorised' => false
  50.             ]);
  51.         }
  52.         if(!$request->getSession()->has('ward_id') && !$request->getSession()->get('ward_id') ){
  53.             return $this->redirectToRoute('wardSelectRoute');
  54.         }
  55.         $wardId $request->getSession()->get('ward_id');
  56.         $em $this->getDoctrine()->getManager();
  57.         $wardId $request->getSession()->get('ward_id');
  58.         $ward  $em->getRepository('App:Ward')->findOneBy([
  59.             'id' => $wardId
  60.         ]);
  61.         $phase $em->getRepository('App:Take')->findOneBy([
  62.         ],['id'=> 'desc']);
  63.         if(!$phase->getIsActive() && !$this->isGranted('ROLE_ADMIN')){
  64.             $phaseException $em->getRepository('App:TakeException')->findOneBy([
  65.                 'ward' => $ward,
  66.                 'isActive' => 1
  67.             ]);
  68.             if($phaseException && $phaseException->getIsActive()){
  69.                 // continue
  70.             }else{
  71.                 $this->addFlash('warning',  'The Bursary phase is complete! please contact admin');
  72.                 return $this->render('ward/others/allocation_detail.html.twig',[
  73.                     'isAuthorised' => false
  74.                 ]);
  75.             }
  76.         }
  77.         $bursary $em->getRepository('App:Bursary')->findOneBy([
  78.             'county' => $ward->getSubCounty()->getCounty(),
  79.             'isCurrent' => true
  80.         ]);
  81.         $take $em->getRepository('App:Take')->findOneBy([
  82.             'bursary' => $bursary
  83.         ],['id' => 'DESC']);
  84.         $institutionType $student->getInstitution()->getInstitutionType();
  85.         $studentAllocation = new StudentAllocation($em);
  86.         $studentAllocation->setStudent($student);
  87.         $studentAllocation->setWard($ward);
  88.         $studentAllocation->setCreatedAt(new \DateTimeImmutable());
  89.         $studentAllocation->setIsCancelled(false);
  90.         $studentAllocation->setCreatedBy($this->getUser());
  91.         $studentAllocation->setTake($take);
  92. //        dump($studentAllocation);
  93.         $wardFundAccount $em->getRepository("App:WardFundAccount")->findOneBy([
  94.             'ward' => $ward,
  95.             'isDefault' => true
  96.         ],[ 'id' => 'DESC']);
  97.         if(!$wardFundAccount){
  98.             return $this->render('ward/others/allocation_detail.html.twig',[
  99.                 'isAuthorised' => true,
  100.                 'isAllocated' => false
  101.             ]);
  102.         }
  103.         $form $this->createForm(AllocationType::class, $studentAllocation,[
  104.             'validation_groups' => [
  105.                 'Default'
  106.             ]
  107.         ]);
  108.         $form->handleRequest($request);
  109.         if($form->isSubmitted() && $form->isValid()){
  110.             $studentAllocation->setWard($ward);
  111.             $studentAllocation->setIsCancelled(false);
  112.             $studentAllocation->setStudent($student);
  113.             $studentAllocation->setCreatedBy($this->getUser());
  114.             try {
  115.                 $oldAllocation $em->getRepository("App:StudentAllocation")->findVeryRecentAllocationOfStudent($student->getId());
  116.                 if($oldAllocation){
  117.                     return $this->render('ward/others/allocation_detail.html.twig',[
  118.                         "student" => $student,
  119.                         "allocation" => $studentAllocation,
  120.                         'isAuthorised' => true,
  121.                         'institutionType' => $institutionType,
  122.                         'isSuccessful' => true
  123.                     ]);
  124.                 }
  125.             } catch (NonUniqueResultException $e) {
  126.             }
  127.             $conn $em->getConnection();
  128.             $conn->beginTransaction();
  129.             try {
  130.                 $this->makeAllocation($ward,$studentAllocation->getAmount(), $em);
  131.                 $em->persist($studentAllocation);
  132.                 $em->flush();
  133.                 $em->getConnection()->commit();
  134. //                $this->addFlash('success', 'allocation made Successfully');
  135.                 return $this->render('ward/others/allocation_detail.html.twig',[
  136.                     "student" => $student,
  137.                     "allocation" => $studentAllocation,
  138.                     'isAuthorised' => true,
  139.                     'institutionType' => $institutionType,
  140.                     'isSuccessful' => true
  141.                 ]);
  142.             }catch (\PDOException $e){
  143.                 $em->getConnection()->rollBack();
  144.                 return $this->render('ward/others/allocation_detail.html.twig',[
  145.                     "student" => $student,
  146.                     "allocationForm"=> $form->createView(),
  147.                     'isAuthorised' => true,
  148.                     'institutionType' => $institutionType
  149.                 ]);
  150.             }
  151.         }
  152.         return $this->render('ward/others/allocation_detail.html.twig',[
  153.             "student" => $student,
  154.             "allocationForm"=> $form->createView(),
  155.             'isAuthorised' => true,
  156.             'institutionType' => $institutionType
  157.         ]);
  158.     }
  159.     /**
  160.      * @Route("/allocations/reallocate/{id}", name="reallocationRoute")
  161.      * @IsGranted("ROLE_USER")
  162.      * @param Request $request
  163.      * @param Student $student
  164.      * @return Response
  165.      */
  166.     public function reallocationDetail(Request $requestStudentAllocation  $oldStudentAllocation):Response {
  167.         if(!$this->isGranted("ROLE_WARD_ADMIN") && !$this->isGranted("ROLE_ADMIN") ){
  168.             return $this->render('ward/others/reallocation_detail.html.twig',[
  169.                 'isAuthorised' => false
  170.             ]);
  171.         }
  172.         if(!$request->getSession()->has('ward_id') && !$request->getSession()->get('ward_id') ){
  173.             return $this->redirectToRoute('wardSelectRoute');
  174.         }
  175.         $wardId $request->getSession()->get('ward_id');
  176.         $em $this->getDoctrine()->getManager();
  177.         $wardId $request->getSession()->get('ward_id');
  178.         $ward  $em->getRepository('App:Ward')->findOneBy([
  179.             'id' => $wardId
  180.         ]);
  181.         $bursary $em->getRepository('App:Bursary')->findOneBy([
  182.             'county' => $ward->getSubCounty()->getCounty(),
  183.             'isCurrent' => true
  184.         ]);
  185.         $phase $em->getRepository('App:Take')->findOneBy([
  186.             'bursary' => $bursary
  187.         ],['id'=> 'desc']);
  188.         if(!$phase->getIsActive() && !$this->isGranted('ROLE_ADMIN')){
  189.             $phaseException $em->getRepository('App:TakeException')->findOneBy([
  190.                 'ward' => $ward,
  191.                 'isActive' => 1
  192.             ]);
  193.             if($phaseException && $phaseException->getIsActive()){
  194.                 // continue
  195.             }else{
  196.                 $this->addFlash('warning',  'The Bursary phase is complete! please contact admin');
  197.                 return $this->render('ward/others/allocation_detail.html.twig',[
  198.                     'isAuthorised' => false
  199.                 ]);
  200.             }
  201.         }
  202.         if($phase->getId() != $oldStudentAllocation->getTake()->getId()){
  203.                 $this->addFlash('warning',  'This allocation was done in a different phase');
  204.                 return $this->render('ward/others/allocation_detail.html.twig',[
  205.                     'isAuthorised' => false
  206.                 ]);
  207.         }
  208.         $student $oldStudentAllocation->getStudent();
  209.         $institutionType $student->getInstitution()->getInstitutionType();
  210.         $studentAllocation = new StudentAllocation($em);
  211.         $studentAllocation->setStudent($student);
  212.         $studentAllocation->setWard($ward);
  213.         $studentAllocation->setCreatedAt(new \DateTimeImmutable());
  214.         $studentAllocation->setIsCancelled(false);
  215.         $studentAllocation->setCreatedBy($this->getUser());
  216.         $studentAllocation->setTake($phase);
  217.         $wardFundAccount $em->getRepository("App:WardFundAccount")->findOneBy([
  218.             'ward' => $ward,
  219.             'isDefault' => true
  220.         ],[ 'id' => 'DESC']);
  221.         if(!$wardFundAccount){
  222.             return $this->render('ward/others/reallocation_detail.html.twig',[
  223.                 'isAuthorised' => true,
  224.                 'isAllocated' => false
  225.             ]);
  226.         }
  227.         $form $this->createForm(AllocationType::class, $studentAllocation,[
  228.             'validation_groups' => [
  229.                 'Default'
  230.             ]
  231.         ]);
  232.         $form->handleRequest($request);
  233.         if($form->isSubmitted() && $form->isValid()){
  234.             $studentAllocation->setWard($ward);
  235.             $studentAllocation->setIsCancelled(false);
  236.             $studentAllocation->setStudent($student);
  237.             $studentAllocation->setCreatedBy($this->getUser());
  238.             /*try {
  239.                 $oldAllocation = $em->getRepository("App:StudentAllocation")->findVeryRecentAllocationOfStudent($student->getId());
  240.                 if($oldAllocation){
  241.                     return $this->render('ward/others/reallocation_detail.html.twig',[
  242.                         "student" => $student,
  243.                         "allocation" => $studentAllocation,
  244.                         "oldAllocation" => $oldStudentAllocation,
  245.                         'isAuthorised' => true,
  246.                         'institutionType' => $institutionType,
  247.                         'isSuccessful' => true
  248.                     ]);
  249.                 }
  250.             } catch (NonUniqueResultException $e) {
  251.             }*/
  252.             $conn $em->getConnection();
  253.             $conn->beginTransaction();
  254.             try {
  255.                 $cancelledAllocation = new CancelledAllocation();
  256.                 $cancelledAllocation->setCreatedAt(new \DateTime());
  257.                 $cancelledAllocation->setAllocation($oldStudentAllocation);
  258.                 $cancelledAllocation->setCreatedBy($this->getUser());
  259.                 $cancelledAllocation->setReason("This student was reallocated an amount from ".$oldStudentAllocation->getAmount()." to ".$studentAllocation->getAmount());
  260.                 $em->persist($cancelledAllocation);
  261.                 $oldStudentAllocation->setIsCancelled(true);
  262.                 $this->cancelAllocation($ward$oldStudentAllocation->getAmount(), $em );
  263.                 $this->makeAllocation($ward,$studentAllocation->getAmount(), $em);
  264.                 $em->persist($studentAllocation);
  265.                 $em->flush();
  266.                 $em->getConnection()->commit();
  267.                 return $this->render('ward/others/reallocation_detail.html.twig',[
  268.                     "student" => $student,
  269.                     "allocation" => $studentAllocation,
  270.                     "oldAllocation" => $oldStudentAllocation,
  271.                     'isAuthorised' => true,
  272.                     'institutionType' => $institutionType,
  273.                     'isSuccessful' => true
  274.                 ]);
  275.             }catch (\PDOException $e){
  276.                 $em->getConnection()->rollBack();
  277.                 return $this->render('ward/others/reallocation_detail.html.twig',[
  278.                     "student" => $student,
  279.                     "oldAllocation" => $oldStudentAllocation,
  280.                     "allocationForm"=> $form->createView(),
  281.                     'isAuthorised' => true,
  282.                     'institutionType' => $institutionType
  283.                 ]);
  284.             }
  285.         }
  286.         return $this->render('ward/others/reallocation_detail.html.twig',[
  287.             "student" => $student,
  288.             "oldAllocation" => $oldStudentAllocation,
  289.             "allocationForm"=> $form->createView(),
  290.             'isAuthorised' => true,
  291.             'institutionType' => $institutionType
  292.         ]);
  293.     }
  294.     private function makeAllocation(Ward $ward$amountObjectManager $em){
  295.         $currentBursary $em->getRepository('App:Bursary')->findOneBy([
  296.         ],['id' => 'DESC']);
  297.         $wardFundAccount $em->getRepository("App:WardFundAccount")->findOneBy([
  298.             'ward' => $ward,
  299.             'isDefault' => true
  300.         ],[ 'id' => 'DESC']);
  301.         $wardStudentAccount $em->getRepository("App:WardFundAccount")->findOneBy([
  302.             'isStudent' => true,
  303.             'ward' => $ward
  304.         ],[ 'id' => 'DESC']);
  305.         /****************************************************************************************************/
  306.         // Double entry for allocation transaction  1
  307.         /*****************************************************************************************************/
  308.         $transaction = new Transaction();
  309.         $transaction->setAmount($amount);
  310.         $transaction->setCreatedAt(new \DateTimeImmutable());
  311.         $transaction->setCreatedBy($this->getUser());
  312.         $transaction->setNarration("WARD STUDENT ALLOCATION");
  313.         $transaction->setEntryType('DEBIT');
  314.         $transaction->setBursary($currentBursary);
  315.         $transaction->setBalance($wardFundAccount->getFundAccount()->getBalance());
  316.         $transaction->setEndBalance($wardFundAccount->getFundAccount()->getBalance() - $amount);
  317.         $transaction->setTransactionType('WARD STUDENT ALLOCATION');
  318.         $transaction->setFundAccount($wardFundAccount->getFundAccount());
  319.         /****************************************************************************************************/
  320.         // Double entry for allocation transaction  2
  321.         /*****************************************************************************************************/
  322.         $otherTransaction = new Transaction();
  323.         $otherTransaction->setAmount($amount);
  324.         $otherTransaction->setEntryType('CREDIT');
  325.         $otherTransaction->setBalance($wardStudentAccount->getFundAccount()->getBalance());
  326.         $otherTransaction->setFundAccount($wardStudentAccount->getFundAccount());
  327.         $otherTransaction->setEndBalance($wardStudentAccount->getFundAccount()->getBalance() + $amount);
  328.         $otherTransaction->setCreatedAt(new \DateTimeImmutable());
  329.         $otherTransaction->setCreatedBy($this->getUser());
  330.         $otherTransaction->setNarration("WARD STUDENT ALLOCATION");
  331.         $otherTransaction->setBursary($currentBursary);
  332.         $otherTransaction->setAmount($amount);
  333.         $otherTransaction->setTransactionType("WARD STUDENT ALLOCATION ");
  334.         /** SETUP account & transaction references */
  335.         $transaction->setReferenceFundAccount($otherTransaction->getFundAccount());
  336.         $otherTransaction->setReferenceFundAccount($transaction->getFundAccount());
  337.         $transaction->setTransaction($otherTransaction);
  338.         $otherTransaction->setTransaction($transaction);
  339.         /** UPDATE account balances */
  340.         $transaction->getFundAccount()->setBalance($transaction->getEndBalance());
  341.         $otherTransaction->getFundAccount()->setBalance($otherTransaction->getEndBalance());
  342.         $em->persist($transaction);
  343.         $em->persist($otherTransaction);
  344.     }
  345.     private function cancelAllocation(Ward $ward$amountObjectManager $em){
  346.         $currentBursary $em->getRepository('App:Bursary')->findOneBy([
  347.         ],['id' => 'DESC']);
  348.         $wardFundAccount $em->getRepository("App:WardFundAccount")->findOneBy([
  349.             'ward' => $ward,
  350.             'isDefault' => true
  351.         ],[ 'id' => 'DESC']);
  352.         $wardStudentAccount $em->getRepository("App:WardFundAccount")->findOneBy([
  353.             'isStudent' => true,
  354.             'ward' => $ward
  355.         ],[ 'id' => 'DESC']);
  356.         /****************************************************************************************************/
  357.         // Double entry for allocation transaction  1
  358.         /*****************************************************************************************************/
  359.         $transaction = new Transaction();
  360.         $transaction->setAmount($amount);
  361.         $transaction->setCreatedAt(new \DateTimeImmutable());
  362.         $transaction->setCreatedBy($this->getUser());
  363.         $transaction->setNarration("WARD STUDENT ALLOCATION CANCELLATION");
  364.         $transaction->setEntryType('CREDIT');
  365.         $transaction->setBursary($currentBursary);
  366.         $transaction->setBalance($wardFundAccount->getFundAccount()->getBalance());
  367.         $transaction->setEndBalance($wardFundAccount->getFundAccount()->getBalance() + $amount);
  368.         $transaction->setTransactionType('WARD STUDENT ALLOCATION CANCELLATION');
  369.         $transaction->setFundAccount($wardFundAccount->getFundAccount());
  370.         /****************************************************************************************************/
  371.         // Double entry for allocation transaction  2
  372.         /*****************************************************************************************************/
  373.         $otherTransaction = new Transaction();
  374.         $otherTransaction->setAmount($amount);
  375.         $otherTransaction->setEntryType('DEBIT');
  376.         $otherTransaction->setBalance($wardStudentAccount->getFundAccount()->getBalance());
  377.         $otherTransaction->setFundAccount($wardStudentAccount->getFundAccount());
  378.         $otherTransaction->setEndBalance($wardStudentAccount->getFundAccount()->getBalance() - $amount);
  379.         $otherTransaction->setCreatedAt(new \DateTimeImmutable());
  380.         $otherTransaction->setCreatedBy($this->getUser());
  381.         $otherTransaction->setNarration("WARD STUDENT ALLOCATION CANCELLATION");
  382.         $otherTransaction->setBursary($currentBursary);
  383.         $otherTransaction->setAmount($amount);
  384.         $otherTransaction->setTransactionType("WARD STUDENT ALLOCATION CANCELLATION ");
  385.         /** SETUP account & transaction references */
  386.         $transaction->setReferenceFundAccount($otherTransaction->getFundAccount());
  387.         $otherTransaction->setReferenceFundAccount($transaction->getFundAccount());
  388.         $transaction->setTransaction($otherTransaction);
  389.         $otherTransaction->setTransaction($transaction);
  390.         /** UPDATE account balances */
  391.         $transaction->getFundAccount()->setBalance($transaction->getEndBalance());
  392.         $otherTransaction->getFundAccount()->setBalance($otherTransaction->getEndBalance());
  393.         $em->persist($transaction);
  394.         $em->persist($otherTransaction);
  395.     }
  396.     /**
  397.      * @Route("/allocations/cancel/{id}", methods={"POST", "GET"}, name="allocationsCancelRoute")
  398.      * @IsGranted("ROLE_USER")
  399.      * @param Request $request
  400.      * @param StudentAllocation $allocation
  401.      * @return Response
  402.      */
  403.     public function cancelAllocationAction(Request $requestStudentAllocation $allocation) :Response {
  404.         $em $this->getDoctrine()->getManager();
  405.         if(!$this->isGranted("ROLE_WARD_ADMIN")){
  406.             return $this->render('ward/others/allocation_cancel.html.twig',[
  407.                 'isAuthorised' => false
  408.             ]);
  409.         }
  410.         $phase $em->getRepository(Take::class)->findOneBy([
  411.             'isActive' => true
  412.         ],['id' => 'desc']);
  413.         if($phase){
  414.             if($phase->getId() != $allocation->getTake()->getId()){
  415.                 $this->addFlash('warning',  'This allocation was done in a different phase');
  416.                 return $this->render('ward/others/allocation_cancel.html.twig',[
  417.                     'isAuthorised' => false
  418.                 ]);
  419.             }
  420.         }else{
  421.             $this->addFlash('warning',  'This allocation was done in a different phase');
  422.             return $this->render('ward/others/allocation_cancel.html.twig',[
  423.                 'isAuthorised' => false
  424.             ]);
  425.         }
  426.         if(!$request->getSession()->has('ward_id') && !$request->getSession()->get('ward_id') ){
  427.             return $this->redirectToRoute('wardSelectRoute');
  428.         }
  429.         $wardId $request->getSession()->get('ward_id');
  430.         $ward $em->getRepository('App:Ward')->findOneBy([
  431.             'id' => $wardId
  432.         ]);
  433.         $em $this->getDoctrine()->getManager();
  434.         $cancelledAllocation = new CancelledAllocation();
  435.         $cancelledAllocation->setCreatedAt(new \DateTime());
  436.         $cancelledAllocation->setAllocation($allocation);
  437.         $cancelledAllocation->setCreatedBy($this->getUser());
  438.         /** @var Student $student */
  439.         $student $allocation->getStudent();
  440.         $form $this->createForm(AllocationCancelType::class, $cancelledAllocation,[
  441.             'validation_groups' => [
  442.                 'Default'
  443.             ]
  444.         ]);
  445.         $form->handleRequest($request);
  446.         if($form->isSubmitted() && $form->isValid()) {
  447.             $conn $em->getConnection();
  448.             $conn->beginTransaction();
  449.             try {
  450.                 $this->cancelAllocation($ward,$allocation->getAmount(), $em);
  451.                 $allocation->setIsCancelled(true);
  452.                 $em->persist($cancelledAllocation);
  453.                 $em->flush();
  454.                 $em->getConnection()->commit();
  455.                 return $this->render('ward/others/allocation_cancel.html.twig',[
  456.                     'allocation' => $allocation,
  457.                     'student' => $student,
  458.                     'form' => $form->createView(),
  459.                     'isAuthorised' => true,
  460.                     'isSuccessful' => true
  461.                 ]);
  462.             }catch (\PDOException $e){
  463.                 $em->getConnection()->rollBack();
  464.                 return $this->render('ward/others/allocation_cancel.html.twig',[
  465.                     'allocation' => $allocation,
  466.                     'student' => $student,
  467.                     'form' => $form->createView(),
  468.                     'isSuccessful' => false
  469.                 ]);
  470.             }
  471.         }
  472.         return $this->render('ward/others/allocation_cancel.html.twig',[
  473.             'allocation' => $allocation,
  474.             'student' => $student,
  475.             'form' => $form->createView(),
  476.             'isAuthorised' => true
  477.         ]);
  478.     }
  479.     /**
  480.      * @Route("/allocations/json", name="studentsAllocationsJSONRoute")
  481.      * @IsGranted("ROLE_USER")
  482.      * @return Response
  483.      */
  484.     public function studentsAllocationJSON(Request $request){
  485.         if(!$request->getSession()->has('ward_id') && !$request->getSession()->get('ward_id') ){
  486.             return $this->redirectToRoute('wardSelectRoute');
  487.         }
  488.         $wardId $request->getSession()->get('ward_id');
  489.         $context = new SerializationContext();
  490.         $context->setSerializeNull(true);
  491.         $serializer SerializerBuilder::create()->build();
  492.         $em $this->getDoctrine()->getManager();
  493.         $page $request->request->get('page') > $request->request->get('page'): 1;
  494.         $rows $request->request->get('rows') > $request->request->get('rows'): 20;
  495.         $offset = ($page 1)*$rows;
  496.         $filterRules $request->request->get('filterRules');
  497.         $take $em->getRepository(Take::class)->findOneBy([
  498.             'isActive' => true
  499.         ]);
  500.         $students $em->getRepository('App:StudentAllocation')->getAllStudentAllocations$wardId$filterRules$offset,$rows$take->getId());
  501.         $studentsCount $em->getRepository('App:StudentAllocation')->studentsAllocationsCounter$wardId$filterRules,$take->getId());
  502.         $data = [
  503.             'total' => $studentsCount,
  504.             'rows' => $students,
  505.         ];
  506.         $data $serializer->serialize($data'json'$context);
  507.         return new Response($dataResponse::HTTP_OK);
  508.     }
  509. }