not sure what I did here
This commit is contained in:
parent
ba28fcca08
commit
0c902b93c4
@ -3,9 +3,11 @@
|
|||||||
namespace App\Controller;
|
namespace App\Controller;
|
||||||
|
|
||||||
use App\Entity\MemberCase;
|
use App\Entity\MemberCase;
|
||||||
|
use App\Entity\Messages;
|
||||||
use App\Entity\ReferralSource;
|
use App\Entity\ReferralSource;
|
||||||
use App\Entity\User;
|
use App\Entity\User;
|
||||||
use App\Entity\UserCase;
|
use App\Entity\UserCase;
|
||||||
|
use App\Factory\MessageFactory;
|
||||||
use App\Form\MemberCaseFormType;
|
use App\Form\MemberCaseFormType;
|
||||||
use App\Form\UserCaseFormType;
|
use App\Form\UserCaseFormType;
|
||||||
use App\Libs\Breadcrumb;
|
use App\Libs\Breadcrumb;
|
||||||
@ -19,6 +21,15 @@ use Symfony\Component\Security\Http\Attribute\CurrentUser;
|
|||||||
|
|
||||||
class CaseController extends AbstractController
|
class CaseController extends AbstractController
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Variable to store unread notification messages
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
private array $msgs;
|
||||||
|
|
||||||
|
private int $notificationCount;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private EntityManagerInterface $entityManager,
|
private EntityManagerInterface $entityManager,
|
||||||
private array $navLinks = []
|
private array $navLinks = []
|
||||||
@ -27,32 +38,59 @@ class CaseController extends AbstractController
|
|||||||
$this->navLinks['case_list'] = NavList::PRESENT_LINK;
|
$this->navLinks['case_list'] = NavList::PRESENT_LINK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[Route('/my-cases', name: 'app_my_cases')]
|
||||||
|
public function myCases(#[CurrentUser()] User $user): Response
|
||||||
|
{
|
||||||
|
$this->navLinks['my_cases'] = NavList::PRESENT_LINK;
|
||||||
|
$this->navLinks['case_list'] = 'nav-link text-dark';
|
||||||
|
$ucs = $this->entityManager->getRepository(UserCase::class)->findBy(['user' => $user]);
|
||||||
|
$this->msgs = $this->entityManager->getRepository(Messages::class)->getUnreadMessages($user);
|
||||||
|
$this->notificationCount = $this->entityManager->getRepository(Messages::class)->getUnreadMessageCount($user);
|
||||||
|
|
||||||
|
$cases = [];
|
||||||
|
foreach ($ucs as $uc) {
|
||||||
|
/** @var UserCase $uc */
|
||||||
|
$cases[] = $uc->getMemberCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->render(
|
||||||
|
'internal/cases/my-cases.html.twig',
|
||||||
|
array_merge(
|
||||||
|
$this->navLinks,
|
||||||
|
[
|
||||||
|
'breadcrumbs' => [
|
||||||
|
new Breadcrumb($this->generateUrl('app_my_cases'), 'List Cases')
|
||||||
|
],
|
||||||
|
'notifications' => $this->msgs,
|
||||||
|
'cases' => $cases,
|
||||||
|
'notificationCount' => $this->notificationCount,
|
||||||
|
]
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[Route('/list-cases', name: 'app_list_cases')]
|
#[Route('/list-cases', name: 'app_list_cases')]
|
||||||
public function listCases(#[CurrentUser()] User $user): Response
|
public function listCases(#[CurrentUser()] User $user): Response
|
||||||
{
|
{
|
||||||
if($this->isGranted('ROLE_ADMIN')) {
|
$this->denyAccessUnlessGranted('ROLE_ADMIN');
|
||||||
$cases = $this->entityManager->getRepository(MemberCase::class)->findAll();
|
|
||||||
} else {
|
$cases = $this->entityManager->getRepository(MemberCase::class)->findAll();
|
||||||
$ucs = $this->entityManager->getRepository(UserCase::class)->findBy(['user' => $user]);
|
|
||||||
$cases = [];
|
|
||||||
foreach ($ucs as $uc) {
|
|
||||||
/** @var UserCase $uc */
|
|
||||||
$cases[] = $uc->getMemberCase();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$workers = $this->entityManager->getRepository(User::class)->getCaseWorkers();
|
$workers = $this->entityManager->getRepository(User::class)->getCaseWorkers();
|
||||||
|
$this->msgs = $this->entityManager->getRepository(Messages::class)->getUnreadMessages($user);
|
||||||
|
$this->notificationCount = $this->entityManager->getRepository(Messages::class)->getUnreadMessageCount($user);
|
||||||
|
|
||||||
return $this->render(
|
return $this->render(
|
||||||
'internal/cases/list-cases.html.twig',
|
'internal/admin/cases/list-cases.html.twig',
|
||||||
array_merge(
|
array_merge(
|
||||||
$this->navLinks,
|
$this->navLinks,
|
||||||
[
|
[
|
||||||
'breadcrumbs' => [
|
'breadcrumbs' => [
|
||||||
new Breadcrumb($this->generateUrl('app_list_cases'), 'List Cases')
|
new Breadcrumb($this->generateUrl('app_list_cases'), 'List Cases')
|
||||||
],
|
],
|
||||||
'notifications' => $user->retrieveUnreadNotifications(),
|
'notifications' => $this->msgs,
|
||||||
'cases' => $cases,
|
'cases' => $cases,
|
||||||
'workers' => $workers,
|
'workers' => $workers,
|
||||||
|
'notificationCount' => $this->notificationCount,
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@ -62,6 +100,8 @@ class CaseController extends AbstractController
|
|||||||
public function addCase(Request $request, #[CurrentUser()] User $admin): Response
|
public function addCase(Request $request, #[CurrentUser()] User $admin): Response
|
||||||
{
|
{
|
||||||
$this->denyAccessUnlessGranted('ROLE_ADMIN');
|
$this->denyAccessUnlessGranted('ROLE_ADMIN');
|
||||||
|
$this->msgs = $this->entityManager->getRepository(Messages::class)->getUnreadMessages($admin);
|
||||||
|
$this->notificationCount = $this->entityManager->getRepository(Messages::class)->getUnreadMessageCount($admin);
|
||||||
|
|
||||||
$case = new MemberCase();
|
$case = new MemberCase();
|
||||||
$form = $this->createForm(MemberCaseFormType::class, $case);
|
$form = $this->createForm(MemberCaseFormType::class, $case);
|
||||||
@ -89,7 +129,8 @@ class CaseController extends AbstractController
|
|||||||
new Breadcrumb($this->generateUrl('app_list_cases'), 'List Cases'),
|
new Breadcrumb($this->generateUrl('app_list_cases'), 'List Cases'),
|
||||||
new Breadcrumb($this->generateUrl('app_add_case'), 'Add Case')
|
new Breadcrumb($this->generateUrl('app_add_case'), 'Add Case')
|
||||||
],
|
],
|
||||||
'notifications' => $admin->retrieveUnreadNotifications(),
|
'notifications' => $this->msgs,
|
||||||
|
'notificationCount' => $this->notificationCount,
|
||||||
'form' => $form,
|
'form' => $form,
|
||||||
'sources' => $this->entityManager->getRepository(ReferralSource::class)->retrieveOrderedList(),
|
'sources' => $this->entityManager->getRepository(ReferralSource::class)->retrieveOrderedList(),
|
||||||
]
|
]
|
||||||
@ -101,6 +142,8 @@ class CaseController extends AbstractController
|
|||||||
public function editCase(Request $request, #[CurrentUser()] User $admin, string $id): Response
|
public function editCase(Request $request, #[CurrentUser()] User $admin, string $id): Response
|
||||||
{
|
{
|
||||||
$this->denyAccessUnlessGranted('ROLE_ADMIN');
|
$this->denyAccessUnlessGranted('ROLE_ADMIN');
|
||||||
|
$this->msgs = $this->entityManager->getRepository(Messages::class)->getUnreadMessages($admin);
|
||||||
|
$this->notificationCount = $this->entityManager->getRepository(Messages::class)->getUnreadMessageCount($admin);
|
||||||
|
|
||||||
$case = $this->entityManager->getRepository(MemberCase::class)->find($id);
|
$case = $this->entityManager->getRepository(MemberCase::class)->find($id);
|
||||||
$form = $this->createForm(MemberCaseFormType::class, $case);
|
$form = $this->createForm(MemberCaseFormType::class, $case);
|
||||||
@ -126,7 +169,8 @@ class CaseController extends AbstractController
|
|||||||
new Breadcrumb($this->generateUrl('app_list_cases'), 'List Cases'),
|
new Breadcrumb($this->generateUrl('app_list_cases'), 'List Cases'),
|
||||||
new Breadcrumb($this->generateUrl('app_edit_case', ['id' => $id]), 'Edit Case')
|
new Breadcrumb($this->generateUrl('app_edit_case', ['id' => $id]), 'Edit Case')
|
||||||
],
|
],
|
||||||
'notifications' => $admin->retrieveUnreadNotifications(),
|
'notifications' => $this->msgs,
|
||||||
|
'notificationCount' => $this->notificationCount,
|
||||||
'form' => $form,
|
'form' => $form,
|
||||||
'case' => $case,
|
'case' => $case,
|
||||||
'sources' => $this->entityManager->getRepository(ReferralSource::class)->retrieveOrderedList(),
|
'sources' => $this->entityManager->getRepository(ReferralSource::class)->retrieveOrderedList(),
|
||||||
@ -139,6 +183,8 @@ class CaseController extends AbstractController
|
|||||||
public function assignCase(string $id, Request $request, #[CurrentUser()] User $admin): Response
|
public function assignCase(string $id, Request $request, #[CurrentUser()] User $admin): Response
|
||||||
{
|
{
|
||||||
$this->denyAccessUnlessGranted('ROLE_ADMIN');
|
$this->denyAccessUnlessGranted('ROLE_ADMIN');
|
||||||
|
$this->msgs = $this->entityManager->getRepository(Messages::class)->getUnreadMessages($admin);
|
||||||
|
$this->notificationCount = $this->entityManager->getRepository(Messages::class)->getUnreadMessageCount($admin);
|
||||||
|
|
||||||
$caseWorkers = $this->entityManager->getRepository(User::class)->getCaseWorkers();
|
$caseWorkers = $this->entityManager->getRepository(User::class)->getCaseWorkers();
|
||||||
$case = $this->entityManager->getRepository(MemberCase::class)->find($id);
|
$case = $this->entityManager->getRepository(MemberCase::class)->find($id);
|
||||||
@ -159,7 +205,10 @@ class CaseController extends AbstractController
|
|||||||
$this->entityManager->flush();
|
$this->entityManager->flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$msg = MessageFactory::createNewCase($admin, $user);
|
||||||
|
|
||||||
$this->entityManager->persist($uc);
|
$this->entityManager->persist($uc);
|
||||||
|
$this->entityManager->persist($msg);
|
||||||
$this->entityManager->flush();
|
$this->entityManager->flush();
|
||||||
|
|
||||||
$this->addFlash('success', 'Case assigned successfully');
|
$this->addFlash('success', 'Case assigned successfully');
|
||||||
@ -177,7 +226,9 @@ class CaseController extends AbstractController
|
|||||||
new Breadcrumb($this->generateUrl('app_list_cases'), 'List Cases'),
|
new Breadcrumb($this->generateUrl('app_list_cases'), 'List Cases'),
|
||||||
new Breadcrumb($this->generateUrl('app_assign_case', ['id' => $id]), 'Assign User')
|
new Breadcrumb($this->generateUrl('app_assign_case', ['id' => $id]), 'Assign User')
|
||||||
],
|
],
|
||||||
'notifications' => $admin->retrieveUnreadNotifications(),
|
'notifications' => $this->msgs,
|
||||||
|
'notificationCount' => $this->notificationCount,
|
||||||
|
'case' => $case,
|
||||||
'form' => $form,
|
'form' => $form,
|
||||||
'id' => $id,
|
'id' => $id,
|
||||||
'caseWorkers' => $caseWorkers,
|
'caseWorkers' => $caseWorkers,
|
||||||
|
@ -91,10 +91,31 @@ class MemberCase
|
|||||||
#[ORM\OneToMany(targetEntity: Referral::class, mappedBy: 'memberCase', orphanRemoval: true)]
|
#[ORM\OneToMany(targetEntity: Referral::class, mappedBy: 'memberCase', orphanRemoval: true)]
|
||||||
private Collection $referrals;
|
private Collection $referrals;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Collection<int, MonthlyCaseNote>
|
||||||
|
*/
|
||||||
|
#[ORM\OneToMany(targetEntity: MonthlyCaseNote::class, mappedBy: 'memberCase')]
|
||||||
|
private Collection $monthlyCaseNotes;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Collection<int, Member>
|
||||||
|
*/
|
||||||
|
#[ORM\OneToMany(targetEntity: Member::class, mappedBy: 'memberCase', orphanRemoval: true)]
|
||||||
|
private Collection $members;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Collection<int, StaffNote>
|
||||||
|
*/
|
||||||
|
#[ORM\OneToMany(targetEntity: StaffNote::class, mappedBy: 'memberCase')]
|
||||||
|
private Collection $staffNotes;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->userCases = new ArrayCollection();
|
$this->userCases = new ArrayCollection();
|
||||||
$this->referrals = new ArrayCollection();
|
$this->referrals = new ArrayCollection();
|
||||||
|
$this->monthlyCaseNotes = new ArrayCollection();
|
||||||
|
$this->members = new ArrayCollection();
|
||||||
|
$this->staffNotes = new ArrayCollection();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getId(): ?Uuid
|
public function getId(): ?Uuid
|
||||||
@ -394,4 +415,94 @@ class MemberCase
|
|||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Collection<int, MonthlyCaseNote>
|
||||||
|
*/
|
||||||
|
public function getMonthlyCaseNotes(): Collection
|
||||||
|
{
|
||||||
|
return $this->monthlyCaseNotes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addMonthlyCaseNote(MonthlyCaseNote $monthlyCaseNote): static
|
||||||
|
{
|
||||||
|
if (!$this->monthlyCaseNotes->contains($monthlyCaseNote)) {
|
||||||
|
$this->monthlyCaseNotes->add($monthlyCaseNote);
|
||||||
|
$monthlyCaseNote->setMemberCase($this);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function removeMonthlyCaseNote(MonthlyCaseNote $monthlyCaseNote): static
|
||||||
|
{
|
||||||
|
if ($this->monthlyCaseNotes->removeElement($monthlyCaseNote)) {
|
||||||
|
// set the owning side to null (unless already changed)
|
||||||
|
if ($monthlyCaseNote->getMemberCase() === $this) {
|
||||||
|
$monthlyCaseNote->setMemberCase(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Collection<int, Member>
|
||||||
|
*/
|
||||||
|
public function getMembers(): Collection
|
||||||
|
{
|
||||||
|
return $this->members;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addMember(Member $member): static
|
||||||
|
{
|
||||||
|
if (!$this->members->contains($member)) {
|
||||||
|
$this->members->add($member);
|
||||||
|
$member->setCaseId($this);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function removeMember(Member $member): static
|
||||||
|
{
|
||||||
|
if ($this->members->removeElement($member)) {
|
||||||
|
// set the owning side to null (unless already changed)
|
||||||
|
if ($member->getCaseId() === $this) {
|
||||||
|
$member->setCaseId(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Collection<int, StaffNote>
|
||||||
|
*/
|
||||||
|
public function getStaffNotes(): Collection
|
||||||
|
{
|
||||||
|
return $this->staffNotes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addStaffNote(StaffNote $staffNote): static
|
||||||
|
{
|
||||||
|
if (!$this->staffNotes->contains($staffNote)) {
|
||||||
|
$this->staffNotes->add($staffNote);
|
||||||
|
$staffNote->setMemberCase($this);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function removeStaffNote(StaffNote $staffNote): static
|
||||||
|
{
|
||||||
|
if ($this->staffNotes->removeElement($staffNote)) {
|
||||||
|
// set the owning side to null (unless already changed)
|
||||||
|
if ($staffNote->getMemberCase() === $this) {
|
||||||
|
$staffNote->setMemberCase(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -140,6 +140,13 @@ class Note
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setMembers(?array $members): static
|
||||||
|
{
|
||||||
|
$this->members = $members;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function getLocation(): ?NoteLocation
|
public function getLocation(): ?NoteLocation
|
||||||
{
|
{
|
||||||
return $this->location;
|
return $this->location;
|
||||||
@ -166,10 +173,10 @@ class Note
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Method to calculate the number of minutes used for a visit rounded to the nearest 15 min increment
|
* Method to calculate the number of minutes used for a visit rounded to the nearest 15 min increment
|
||||||
*
|
*
|
||||||
* @param int $precision
|
* @param int $precision
|
||||||
* The number of minutes to round the time to defaulted to 15
|
* The number of minutes to round the time to defaulted to 15
|
||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
* The number of minutes calculated
|
* The number of minutes calculated
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user