src/Controller/MainController.php line 27

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\Church;
  4. use App\Form\ChurchType;
  5. use App\Repository\ChurchRepository;
  6. use App\Repository\LocationRepository;
  7. use App\Repository\MemberRepository;
  8. use App\Repository\PresbyteryRepository;
  9. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  10. use Symfony\Component\HttpFoundation\Request;
  11. use Symfony\Component\HttpFoundation\Response;
  12. use Symfony\Component\Routing\Annotation\Route;
  13. class MainController extends AbstractController
  14. {
  15.     #[Route('/'name'app_home')]
  16.     public function index(): Response
  17.     {
  18.         return $this->render('index.html.twig', [
  19.             'controller_name' => 'MainController',
  20.         ]);
  21.     }
  22.     #[Route('/about-us'name'about_us')]
  23.     public function aboutUs(): Response
  24.     {
  25.         return $this->render('main/about-us.html.twig', [
  26.             'controller_name' => 'MainController',
  27.         ]);
  28.     }
  29.     #[Route('/photo-gallery'name'photo_gallery')]
  30.     public function gallery(): Response
  31.     {
  32.         return $this->render('main/gallery.html.twig', [
  33.             'controller_name' => 'MainController',
  34.         ]);
  35.     }
  36.     #[Route('/admin/dashboard'name'admin_dashboard')]
  37.     public function dashboard(MemberRepository $memberRepositoryChurchRepository  $churchRepositoryPresbyteryRepository $presbyteryRepository): Response
  38.     {
  39.         $presbyteryName '';
  40.         if($this->isGranted('ROLE_SUPER_ADMIN')){
  41.             $members $memberRepository->findAll();
  42.             $church $churchRepository->findAll();
  43.             $presbytery $presbyteryRepository->findAll();
  44.         }else{
  45.             $user $this->getUser();
  46.             $id $user->getPresbytery()->getId();
  47.             $church $churchRepository->findBy(['presbytery' => $id]);
  48.             $members $memberRepository->findBy(['presbytery' => $id]);
  49.             $presbytery $presbyteryRepository->findBy(['id' => $id]);
  50.             $presbyteryName $presbytery[0]->getName();
  51.         }
  52.         return $this->render('main/dashboard.html.twig', [
  53.             'totalMember' => count($members),
  54.             'totalChurch' => count($church),
  55.             'totalPresbytery' => count($presbytery),
  56.             'presbyteryName' => $presbyteryName
  57.         ]);
  58.     }
  59.     #[Route('dashboard/chart'name'dashboard_chart')]
  60.     public function getReports(MemberRepository $memberRepository){
  61.         $user $this->getUser();
  62.         $report $memberRepository->reporting($user);
  63.         $gender = [];
  64.         $ageGroup = [];
  65.         foreach ($report['gender'] as $k => $v)
  66.         {
  67.             array_push($gender$v);
  68.         }
  69.         foreach ($report['age'] as $value)
  70.         {
  71.             foreach ($value as $k => $v)
  72.             {
  73.                 $ageGroup[$k] = $v;
  74.             }
  75.         }
  76.         $data = [
  77.             'gender' =>  $gender,
  78.             'age' =>  $ageGroup,
  79.             'presbytery' =>  $report['presbytery'],
  80.             'maritalStatus' =>  $report['maritalStatus']
  81.         ];
  82.         return $this->json($data,200);
  83.     }
  84.     #[Route('/executives/list'name'executives_list')]
  85.     public function executives(): Response
  86.     {
  87.         $executive['central-committee'] = [
  88.             ['name' => 'Mr. Phur Tshering Lepcha''image' => '8759063249.jpg','designation' => 'President','phone' => '8759063249','address' =>'EPC Anden, West Sikkim'],
  89.             ['name'=> 'Mr. Yon Tshering Lepcha','image' => '9832632727.jpg','designation' => 'Vice- President','phone' => '9832632727','address' =>'EPC Rehnock, East Sikkim'],
  90.             ['name'=> 'Mr. Nikanor Rai','image' => '7908440974.jpg','designation' => 'Secretary ','phone' => '7908440974','address' =>'EPC Penlong, East Sikkim'],
  91.             ['name'=> 'Ms. Leegain Lepcha','image' => '9647853240.jpg','designation' => 'Joint-Secretary','phone' => '9647853240','address' =>'EPC Rumbuk, West Sikkim'],
  92.             ['name'=> 'Ms. Samina Lakhey','image' => '701714172.jpg','designation' => 'Treasurer','phone' => '701714172','address' =>'EPC Tadong, East Sikkim'],
  93.             ['name'=> 'Mr. Andrew Lepcha','image' => '8370936842.jpg','designation' => 'Joint-Treasurer','phone' => '8370936842','address' =>'EPC Pabong, South Sikkim'],
  94.         ];
  95.         $executive['advisors'] = [
  96.             ['name' => 'Rev. Pem Kitter Sherpa''image' => '8016628266.jpg','designation' => '','phone' => '8016628266','address' =>'EPC Mangalbaria, West Sikkim'],
  97.             ['name'=> 'Rev. Thinlay Dorjee Lepcha','image' => '9593763235.jpg','designation' => '','phone' => '9593763235','address' =>'EPC Sagyong, North Sikkim'],
  98.             ['name'=> 'Shri Lawrence Lepcha','image' => '9933092074.jpg','designation' => ' ','phone' => '9933092074','address' =>'EPC Gangtok, East Sikkim'],
  99.             ['name'=> 'Shri Pema Sukmimoo','image' => '9434109962.jpg','designation' => '','phone' => '9434109962','address' =>'EPC Gangtok, East Sikkim'],
  100.             ['name'=> 'Elder Bimal Sherpa','image' => '9647879249.jpg','designation' => '','phone' => '9647879249','address' =>'EPC Gangtok, East Sikkim']
  101.         ];
  102.         $executive['sub-committee'] = [
  103.             ['name' => 'Mr. Jeewan Kharel''image' => '9434382273.jpg','designation' => 'Construction In-Charge','phone' => '9434382273','address' =>'EPC Namthang, South Sikkim'],
  104.             ['name'=> 'Ms. Jessica M. Tamang','image' => '7076174397.jpg','designation' => 'Property In-Charge','phone' => '7076174397 ','address' =>'EPC Bardang, East Sikkim'],
  105.             ['name'=> 'Mr. Samuel Tasho','image' => '9474059363.jpg','designation' => 'Property In-Charge','phone' => '9474059363 ','address' =>'EPC Fambong, West Sikkim'],
  106.         ];
  107.         $executive['executive-committee'] = [
  108.             ['name' => 'Mr. Pravin Chettri ''image' => '7047908765.jpg','designation' => 'Sports In-Charge','phone' => '7047908765','address' =>'EPC Namchi, South Sikkim'],
  109.             ['name'=> 'Elder Moses Tamu','image' => '9593269521.jpg','designation' => 'Publicity Secretary','phone' => '9593269521 ','address' =>'EPC Ravangla, South Sikkim'],
  110.             ['name'=> 'Mr. Simeyon Sukita Rai','image' => '8392086260.jpg','designation' => 'Literature In-Charge','phone' => '8392086260 ','address' =>'EPC Ranguthang, South Sikkim'],
  111.             ['name'=> 'Dr. Romona Lepcha','image' => '8906347419.jpg','designation' => 'Literature In-Charge','phone' => '8906347419 ','address' =>'EPC Rehnock, East Sikkim'],
  112.             ['name'=> 'Mrs. Srijana Subba','image' => 'sdfs','designation' => 'Literature In-Charge','phone' => ' ','address' =>'EPC Soreng, West Sikkim'],
  113.             ['name'=> 'Elder. Jagat Jhon Rai','image' => '9434486793.jpg','designation' => 'Social Wing In-Charge (North)','phone' => '9434486793','address' =>'EPC Gangtok, East Sikkim'],
  114.             ['name'=> 'Mr. Milan Rai ','image' => '9733110850.jpg','designation' => 'Social Wing In-Charge (East)','phone' => '9733110850','address' =>'EPC Gangtok, East Sikkim'],
  115.             ['name'=> 'Mr. Mohan Bista','image' => '7797300940.jpg','designation' => 'Social Wing In-Charge (South)','phone' => '7797300940','address' =>'EPC Ravangla, South Sikkim'],
  116.             ['name'=> 'Mr. Joel Lepcha','image' => '1111111111.jpg','designation' => 'Social Wing In-Charge (West)','phone' => '','address' =>'EPC Fambong, West Sikkim'],
  117.             ['name'=> 'Mr. Emanuel Rai','image' => '9434382209.jpg','designation' => 'Culture In-Charge','phone' => '9434382209','address' =>'EPC Ranka, East Sikkim'],
  118.             ['name'=> 'Mr. Mahindra Bardewa','image' => 'sdfs','designation' => 'Culture In-Charge','phone' => '','address' =>'EPC _________, East Sikkim'],
  119.             ['name'=> 'Mr. Biren Subba','image' => 'sdfs','designation' => 'Culture In-Charge','phone' => '','address' =>'EPC Pabong, South Sikkim'],
  120.             ['name'=> 'Mr. Allen Lepcha','image' => '9434410319.jpg','designation' => 'President, North Presbytery Youth Fellowship','phone' => '9434410319','address' =>'EPC Penlong, North Sikkim'],
  121.             ['name'=> 'Mr. Dhan Bahadur Biswakarma','image' => '2222222222.jpg','designation' => 'Vice-President, North Presbytery Youth Fellowship','phone' => '','address' =>'EPC Mangshila, North Sikkim'],
  122.             ['name'=> 'Mr. Dan Tshering Lepcha','image' => '9641214429.jpg','designation' => 'Secretary, North Presbytery Youth Fellowship','phone' => '9641214429','address' =>'EPC Zim-Gor, North Sikkim'],
  123.             ['name'=> 'Ms. Sara Rai','image' => '7908199163.jpg','designation' => 'Joint Secretary, North Presbytery Youth Fellowship','phone' => '7908199163','address' =>'EPC Penlong, North Sikkim'],
  124.             ['name'=> 'Mr. Tempa Tshering Sherpa','image' => '3333333333.jpg','designation' => 'Treasurer, North Presbytery Youth Fellowship','phone' => '9434410319','address' =>'EPC Kabi, East Sikkim'],
  125.             ['name'=> 'Mr. Purna Limboo','image' => '8158977999.jpg','designation' => 'Co-Ordianator, North Presbytery Youth Fellowship','phone' => '8158977999','address' =>'EPC Mangshila, East Sikkim'],
  126.             ['name'=> 'Mr. Pravesh Chettri','image' => '7407126839.jpg','designation' => 'President, South Presbytery Youth Fellowship, Namchi','phone' => '7407126839','address' =>'EPC Namchi, South Sikkim'],
  127.             ['name'=> 'Ms. Shinemit Lepcha','image' => '9593987841.jpg','designation' => 'Secretary, South Presbytery Youth Fellowship, Namchi','phone' => '9593987841','address' =>'EPC Lungchok, South Sikkim'],
  128.             ['name'=> 'Ms. Dawa Ongmu Sherpa','image' => '8348521349.jpg','designation' => 'Treasurer, South Presbytery Youth Fellowship, Namchi','phone' => '8348521349','address' =>'EPC Damthang, South Sikkim'],
  129.             ['name'=> 'Mr. Shawal Lepcha','image' => '7384224816.jpg','designation' => 'Co-Ordianator, South Presbytery Youth Fellowship, Namchi','phone' => '7384224816','address' =>'EPC Wok, South Sikkim'],
  130.             ['name'=> 'Mr. Palden Sukmimoo','image' => '9474357415.jpg','designation' => 'President, East Presbytery Youth Fellowship','phone' => '9474357415','address' =>'EPC Tshalamthang, East Sikkim'],
  131.             ['name'=> 'Mr. Solomon Sharma','image' => '7076219337.jpg','designation' => 'Vice-President, East Presbytery Youth Fellowship','phone' => '7076219337','address' =>'EPC Tadong, East Sikkim'],
  132.             ['name'=> 'Mr. Robin Gurung','image' => '7602997746.jpg','designation' => 'Secretary, East Presbytery Youth Fellowship','phone' => '7602997746','address' =>'EPC Gangtok, East Sikkim'],
  133.             ['name'=> 'Ms. Mayel Lepcha','image' => '7679685490.jpg','designation' => 'Joint-Secretary, East Presbytery Youth Fellowship','phone' => '7679685490','address' =>'EPC Nandok, East Sikkim'],
  134.             ['name'=> 'Ms. Uma Thapa','image' => '859791806.jpg','designation' => 'Treasurer, East Presbytery Youth Fellowship','phone' => '859791806','address' =>'EPC Pakyong, East Sikkim'],
  135.             ['name'=> 'Mr. Daniel Sukmimoo','image' => '8370978364.jpg','designation' => 'Joint-Treasurer, East Presbytery Youth Fellowship','phone' => '8370978364','address' =>'EPC Pakyong, East Sikkim'],
  136.             ['name'=> ' ','image' => 'sdfs','designation' => 'Co-Ordinator, East Presbytery Youth Fellowship','phone' => '','address' =>'EPC , East Sikkim'],
  137.             ['name'=> 'Elder Moses Tamu','image' => '9593269521.jpg','designation' => 'President, Ravangla Presbytery Youth Fellowship','phone' => '9593269521','address' =>'EPC Ravangla, South Sikkim'],
  138.             ['name'=> 'Mr. James Rai','image' => '9733146024.jpg','designation' => 'Vice-President, Ravangla Presbytery Youth Fellowship','phone' => '9733146024','address' =>'EPC Phamtam, South Sikkim'],
  139.             ['name'=> 'Mr. Lall Singh Limboo','image' => '9593387373.jpg','designation' => 'Secretary, Ravangla Presbytery Youth Fellowship','phone' => '9593387373','address' =>'EPC Pawdara, South Sikkim'],
  140.             ['name'=> 'Ms. Anjali Biswa','image' => '7872657418.jpg','designation' => 'Joint-Secretary, Ravangla Presbytery Youth Fellowship','phone' => '7872657418','address' =>'EPC Ravangla, South Sikkim'],
  141.             ['name'=> 'Mr. Mohan Bista (Chettri)','image' => '7797300940.jpg','designation' => 'Treasurer, Ravangla Presbytery Youth Fellowship','phone' => '7797300940.jpg','address' =>'EPC Ravangla, South Sikkim'],
  142.             ['name'=> 'Mr. Aliya Rai','image' => '9732956909.jpg','designation' => 'Co-Ordinator, Ravangla Presbytery Youth Fellowship','phone' => '9732956909','address' =>'EPC Ravangla, South Sikkim'],
  143.             ['name'=> 'Mr. Moses Pradhan','image' => '8372044509.jpg','designation' => 'President, West Presbytery Youth Fellowship','phone' => '8372044509','address' =>'EPC Soreng, West Sikkim'],
  144.             ['name'=> 'Ms. Galen Lepcha','image' => '9734330031.jpg','designation' => 'Secretary, West Presbytery Youth Fellowship','phone' => '9734330031','address' =>'EPC Rumbuk, West Sikkim'],
  145.             ['name'=> 'Mr. Ashit Subba','image' => '8509823278.jpg','designation' => 'Treasurer, West Presbytery Youth Fellowship','phone' => '8509823278','address' =>'EPC Soreng, West Sikkim'],
  146.             ['name'=> '','image' => '','designation' => 'Co-Ordinator, West Presbytery Youth Fellowship','phone' => '','address' =>'EPC , West Sikkim'],
  147.         ];
  148.         return $this->render('main/executives.html.twig', [
  149.             'executive' => $executive,
  150.         ]);
  151.     }
  152.     #[Route('/member/list'name'member_list')]
  153.     public function memberList(MemberRepository $memberRepositoryPresbyteryRepository $presbyteryRepository): Response
  154.     {
  155.         if($this->isGranted('ROLE_SUPER_ADMIN')){
  156.             $members $memberRepository->findBy([],['id' => 'DESC']);
  157.             $presbyteryList $presbyteryRepository->findBy([],['name' => 'ASC']);
  158.         }else{
  159.             $user $this->getUser();
  160.             $id $user->getPresbytery()->getId();
  161.             $members $memberRepository->findBy(['presbytery' => $id],['id' => 'DESC']);
  162.             $presbyteryList $presbyteryRepository->findBy(['id' => $id],['name' => 'ASC']);
  163.         }
  164.         return $this->render('main/member-list.html.twig', [
  165.             'members' => $members,
  166.             'count' => count($members),
  167.             'presbytery' => $presbyteryList
  168.         ]);
  169.     }
  170.     #[Route('/presbytery/list'name'presbytery_list')]
  171.     public function presbyteryList(PresbyteryRepository $presbyteryRepository): Response
  172.     {
  173.         $presbytery $presbyteryRepository->findAll();
  174.         $dataArray = [];
  175.         foreach ($presbytery as $data){
  176.             $dataArray[] = [
  177.                 'presbytery' => $data->getName(),
  178.                 'church' => $data->getChurch()->getValues()
  179.             ];
  180.         }
  181.         return $this->render('main/presbytery_list.html.twig', [
  182.             'data' => $dataArray,
  183.         ]);
  184.     }
  185.     #[Route('/location/list'name'location_list')]
  186.     public function locationList(LocationRepository $locationRepository): Response
  187.     {
  188.         $data $locationRepository->findAll();
  189.         return $this->render('main/location_list.html.twig', [
  190.             'data' => $data,
  191.         ]);
  192.     }
  193.     #[Route('/church/list'name'church_list')]
  194.     public function churchList(ChurchRepository $churchRepository): Response
  195.     {
  196.         if($this->isGranted('ROLE_SUPER_ADMIN')){
  197.             $churches $churchRepository->findAll();
  198.         }else{
  199.             $user $this->getUser();
  200.             $id $user->getPresbytery()->getId();
  201.             $churches $churchRepository->findBy(['presbytery' => $id],['id' => 'DESC']);
  202.         }
  203.         return $this->render('church/index.html.twig', [
  204.             'churches' => $churches,
  205.         ]);
  206.     }
  207.     #[Route('/church/add'name'add_church')]
  208.     public function addChurch(Request $requestChurchRepository $churchRepository): Response
  209.     {
  210.         $church = new Church();
  211.         $user $this->getUser();
  212.         $form $this->createForm(ChurchType::class, $church,['presbyteryId' => $user->getPresbytery() ? $user->getPresbytery()->getId() : null]);
  213.         $form->handleRequest($request);
  214.         if ($form->isSubmitted() && $form->isValid()) {
  215.             $churchRepository->add($form->getData(), true);
  216.             return $this->redirectToRoute('church_list', [], Response::HTTP_SEE_OTHER);
  217.         }
  218.         return $this->render('church/new.html.twig', [
  219.             'form' => $form->createView(),
  220.         ]);
  221.     }
  222.     #[Route('/church/edit/{id}'name'edit_church')]
  223.     public function editChurch(Request $requestChurchRepository $churchRepository$id): Response
  224.     {
  225.         $church $churchRepository->find($id);
  226.         $user $this->getUser();
  227.         $form $this->createForm(ChurchType::class, $church,['presbyteryId' => $user->getPresbytery() ? $user->getPresbytery()->getId() : null]);
  228.         $form->handleRequest($request);
  229.         if ($form->isSubmitted() && $form->isValid()) {
  230.             $churchRepository->add($form->getData(), true);
  231.             return $this->redirectToRoute('church_list', [], Response::HTTP_SEE_OTHER);
  232.         }
  233.         return $this->render('church/edit.html.twig', [
  234.             'form' => $form->createView(),
  235.         ]);
  236.     }
  237.     #[Route('/filter-location'name'filter_location')]
  238.     public function filterLocation(Request $requestLocationRepository $locationRepository)
  239.     {
  240.         $id $request->query->get('id');
  241.         $filterdLocation $locationRepository->filterLocation($id);
  242.         return $this->json($filterdLocation,Response::HTTP_OK,[],['groups' => ['presbytery']]);
  243.     }
  244.     #[Route('/filter-church'name'filter_church')]
  245.     public function filterChurch(Request $requestChurchRepository $churchRepository,MemberRepository $memberRepository)
  246.     {
  247.         $type intval($request->get('church'));
  248.         $id $request->query->get('id');
  249.         $filteredChurch $churchRepository->filterChurch($id);
  250.         $memberCount $memberRepository->totalMembersCount($id,$type);
  251.         return $this->json([$filteredChurch,'count' => $memberCount],Response::HTTP_OK,[],['groups' => ['presbytery']]);
  252.     }
  253. }