<?php
namespace App\Controller;
use Hardy\Finder\BedCapacity;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\{ Request, Response };
use Symfony\Component\Routing\Annotation\Route;
#[Route(path: '/facililties')]
class FacilityDashboardController extends AbstractController
{
#[Route(path: '/bed-capacity', name: 'facilities_index')]
public function index(Request $request) : Response
{
$bedCapacity = new BedCapacity();
$type = $request->get('type');
$level = $request->get('level');
$departmentId = $request->get('department_id');
return $this->render('facility_dashboard/index.html.twig', [
'beds' => $bedCapacity->getAllSummary($type, $level, $departmentId),
'ward_types' => $bedCapacity->getWardTypes(),
'url' => $this->generateUrl('facilities_index')
]);
}
#[Route(path: '/bed-capacity-by-district/{id}', name: 'facilities_district')]
public function district(Request $request, int $id) : Response
{
$bedCapacity = new BedCapacity();
$type = $request->get('type');
$level = $request->get('level');
$department = $request->get('department');
$beds = $bedCapacity->getDetailsByDistrictId($id, $type, $level, $department);
if (!$beds) {
return $this->redirectToRoute('homepage');
}
return $this->render('facility_dashboard/district.html.twig', [
'beds' => $beds,
'ward_types' => $bedCapacity->getWardTypes(),
'url' => $this->generateUrl('facilities_district', ['id' => $id])
]);
}
#[Route(path: '/bed-capacity-in-hospital/{id}', name: 'facilities_hospital')]
public function hospital(Request $request, int $id) : Response
{
$bedCapacity = new BedCapacity();
$type = $request->get('type');
$level = $request->get('level');
$department = $request->get('department');
$beds = $bedCapacity->getDetailsByHospitalId($id, $type, $level, $department);
if (!$beds) {
return $this->redirectToRoute('homepage');
}
return $this->render('facility_dashboard/hospital.html.twig', [
'beds' => $beds,
'ward_types' => $bedCapacity->getWardTypes(),
'url' => $this->generateUrl('facilities_hospital', ['id' => $id])
]);
}
#[Route(path: '/bed-types-in-department/{id}', name: 'facilities_department')]
public function department(int $id) : Response
{
$bedCapacity = new BedCapacity();
$beds = $bedCapacity->getDetailsByDepartmentId($id);
if (!$beds) {
return $this->redirectToRoute('homepage');
}
return $this->render('facility_dashboard/department.html.twig', [
'beds' => $beds
]);
}
}