diff --git a/src/Controller/CommunityResourceController.php b/src/Controller/CommunityResourceController.php
index 20b0595..a756e04 100644
--- a/src/Controller/CommunityResourceController.php
+++ b/src/Controller/CommunityResourceController.php
@@ -29,8 +29,6 @@ class CommunityResourceController extends AbstractController
*/
private array $msgs;
- private int $notificationCount;
-
public function __construct(
private readonly EntityManagerInterface $entityManager,
private array $navLinks = []
@@ -43,8 +41,7 @@ class CommunityResourceController extends AbstractController
public function list(#[CurrentUser()] User $user): Response
{
$rsc = $this->entityManager->getRepository(CommunityResource::class)->findAll();
- $this->msgs = $this->entityManager->getRepository(Messages::class)->getUnreadMessages($user);
- $this->notificationCount = $this->entityManager->getRepository(Messages::class)->getUnreadMessageCount($user);
+ $this->msgs = Libs::getMessages($user, $this->entityManager);
return $this->render(
'internal/community_resource/list.html.twig',
@@ -56,7 +53,6 @@ class CommunityResourceController extends AbstractController
],
'resources' => $rsc,
'notifications' => $this->msgs,
- 'notificationCount' => $this->notificationCount,
]
)
);
@@ -65,8 +61,7 @@ class CommunityResourceController extends AbstractController
#[Route('/resource/map', name: 'app_community_resource_map')]
public function map(#[CurrentUser()] User $user): Response
{
- $this->msgs = $this->entityManager->getRepository(Messages::class)->getUnreadMessages($user);
- $this->notificationCount = $this->entityManager->getRepository(Messages::class)->getUnreadMessageCount($user);
+ $this->msgs = Libs::getMessages($user, $this->entityManager);
$rcs = $this->entityManager->getRepository(CommunityResource::class)->findAll();
@@ -81,7 +76,7 @@ class CommunityResourceController extends AbstractController
position: new Point($rsc->getLat(), $rsc->getLon()),
title: $rsc->getName(),
infoWindow: new InfoWindow(
- content: "{$rsc->getName()}
{$rsc->getAddress()}, {$rsc->getCity()}, {$rsc->getState()->value} {$rsc->getZip()}
Services: " . $rsc->getServicesAvailable()
+ content: $rsc->_toInfoWindow()
),
extra: [
'type' => ''
@@ -100,7 +95,6 @@ class CommunityResourceController extends AbstractController
new Breadcrumb('#', 'Community Resources')
],
'notifications' => $this->msgs,
- 'notificationCount' => $this->notificationCount,
]
)
);
@@ -109,9 +103,8 @@ class CommunityResourceController extends AbstractController
#[Route('/resource/add', name: 'app_community_resource_add')]
public function add(#[CurrentUser()] User $user, Request $request): Response
{
- $this->msgs = $this->entityManager->getRepository(Messages::class)->getUnreadMessages($user);
- $this->notificationCount = $this->entityManager->getRepository(Messages::class)->getUnreadMessageCount($user);
-
+ $this->msgs = Libs::getMessages($user, $this->entityManager);
+
$form = $this->createForm(ResourceFormType::class);
$form->handleRequest($request);
@@ -150,7 +143,6 @@ class CommunityResourceController extends AbstractController
new Breadcrumb('#', 'Add Resource')
],
'notifications' => $this->msgs,
- 'notificationCount' => $this->notificationCount,
]
)
);
@@ -160,9 +152,8 @@ class CommunityResourceController extends AbstractController
#[Route('/resource/edit/{id}', name: 'app_community_resource_edit')]
public function edit(string $id, #[CurrentUser()] User $user, Request $request): Response
{
- $this->msgs = $this->entityManager->getRepository(Messages::class)->getUnreadMessages($user);
- $this->notificationCount = $this->entityManager->getRepository(Messages::class)->getUnreadMessageCount($user);
-
+ $this->msgs = Libs::getMessages($user, $this->entityManager);
+
$rsc = $this->entityManager->getRepository(CommunityResource::class)->find($id);
$form = $this->createForm(ResourceFormType::class, $rsc);
@@ -199,7 +190,6 @@ class CommunityResourceController extends AbstractController
new Breadcrumb('#', 'Edit Resource')
],
'notifications' => $this->msgs,
- 'notificationCount' => $this->notificationCount,
]
)
);
diff --git a/src/Controller/ItineraryController.php b/src/Controller/ItineraryController.php
index 19996b8..818b8fa 100644
--- a/src/Controller/ItineraryController.php
+++ b/src/Controller/ItineraryController.php
@@ -13,6 +13,7 @@ use App\Libs\Breadcrumb;
use App\Libs\Libs;
use App\Libs\NavList;
use DateTime;
+use DateTimeZone;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
@@ -30,8 +31,6 @@ class ItineraryController extends AbstractController
{
private array $msgs = [];
- private int $notificationCount = 0;
-
public function __construct(
private EntityManagerInterface $entityManager,
private array $navLinks = []
@@ -44,9 +43,8 @@ class ItineraryController extends AbstractController
{
$this->navLinks['case_itinerary'] = NavList::PRESENT_LINK;
- $this->msgs = $this->entityManager->getRepository(Messages::class)->getUnreadMessages($user);
- $this->notificationCount = $this->entityManager->getRepository(Messages::class)->getUnreadMessageCount($user);
-
+ $this->msgs = Libs::getMessages($user, $this->entityManager);
+
$itineraries = $this->entityManager->getRepository(CaseItinerary::class)->getRecentTravel(
$user
);
@@ -67,7 +65,6 @@ class ItineraryController extends AbstractController
new Breadcrumb($this->generateUrl('app_dashboard'), 'Dashboard'),
],
'notifications' => $this->msgs,
- 'notificationCount' => $this->notificationCount,
'itineraries' => $itineraries,
'cases' => $cases
]
@@ -84,12 +81,21 @@ class ItineraryController extends AbstractController
if ($request->getPayload()->get('caseId')) {
$case = $this->entityManager->getRepository(MemberCase::class)->find($request->getPayload()->get('caseId'));
}
- $startDate = ($request->getPayload()->get('startDate') ?new DateTime($request->getPayload()->get('startDate')) : null);
- $endDate = ($request->getPayload()->get('endDate') ? new DateTime($request->getPayload()->get('endDate')) : null);
-
- $this->msgs = $this->entityManager->getRepository(Messages::class)->getUnreadMessages($user);
- $this->notificationCount = $this->entityManager->getRepository(Messages::class)->getUnreadMessageCount($user);
+ $startDate = (
+ $request->getPayload()->get('startDate')
+ ?
+ new DateTime($request->getPayload()->get('startDate'), new DateTimeZone($_ENV['COMPANY_TIMEZONE']))
+ :
+ null);
+ $endDate = (
+ $request->getPayload()->get('endDate')
+ ?
+ new DateTime($request->getPayload()->get('endDate'), new DateTimeZone($_ENV['COMPANY_TIMEZONE']))
+ :
+ null);
+ $this->msgs = Libs::getMessages($user, $this->entityManager);
+
$itineraries = $this->entityManager->getRepository(CaseItinerary::class)->getRecentTravel($user, [
'case' => $case,
'from' => $startDate,
@@ -113,7 +119,7 @@ class ItineraryController extends AbstractController
),
title: $itinerary->getOriginLocation()->getName(),
infoWindow: new InfoWindow(
- content: $itinerary->getOriginLocation()->getName(),
+ content: $itinerary->originInfoWindow(),
)
));
@@ -124,7 +130,7 @@ class ItineraryController extends AbstractController
),
title: $itinerary->getDestLocation()->getName(),
infoWindow: new InfoWindow(
- content: $itinerary->getDestLocation()->getName(),
+ content: $itinerary->destinationInfoWindow(),
)
));
@@ -155,7 +161,6 @@ class ItineraryController extends AbstractController
new Breadcrumb($this->generateUrl('app_report_itinerary'), 'Itinerary Report'),
],
'notifications' => $this->msgs,
- 'notificationCount' => $this->notificationCount,
'map' => $map,
'total_distance' => $total_distance,
'total_duration' => $di->format("%H:%i'%s''"),
@@ -188,7 +193,7 @@ class ItineraryController extends AbstractController
$departure = $request->getPayload()->get('departure');
$arrival = $request->getPayload()->get('arrival');
$caseMileage = (bool) $request->getPayload()->get('caseMileage');
- $date = new DateTime($request->getPayload()->get('date'));
+ $date = new DateTime($request->getPayload()->get('date'), new DateTimeZone($_ENV['COMPANY_TIMEZONE']));
$route = Libs::getRouteDistance($origin, $destination);
@@ -234,11 +239,11 @@ class ItineraryController extends AbstractController
}
if ($request->getPayload()->get('startDate')) {
- $startDate = new DateTime($request->getPayload()->get('startDate'));
+ $startDate = new DateTime($request->getPayload()->get('startDate'), new DateTimeZone($_ENV['COMPANY_TIMEZONE']));
}
if ($request->getPayload()->get('endDate')) {
- $endDate = new DateTime($request->getPayload()->get('endDate'));
+ $endDate = new DateTime($request->getPayload()->get('endDate'), new DateTimeZone($_ENV['COMPANY_TIMEZONE']));
}
$itineraries = $this->entityManager->getRepository(CaseItinerary::class)->getRecentTravel($user, [
diff --git a/src/Controller/MemberController.php b/src/Controller/MemberController.php
index 97f2ad3..1b5d0dd 100644
--- a/src/Controller/MemberController.php
+++ b/src/Controller/MemberController.php
@@ -8,6 +8,7 @@ use App\Entity\MemberCase;
use App\Entity\Messages;
use App\Form\MemberFormType;
use App\Libs\Breadcrumb;
+use App\Libs\Libs;
use App\Libs\NavList;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
@@ -25,8 +26,6 @@ class MemberController extends AbstractController
*/
private array $msgs;
- private int $notificationCount;
-
public function __construct(
private EntityManagerInterface $entityManager,
private array $navLinks = [],
@@ -38,8 +37,7 @@ class MemberController extends AbstractController
#[Route('/list-members/{id}', name: 'app_case_members')]
public function listMembers(Request $request, #[CurrentUser()] User $user, string $id): Response
{
- $this->msgs = $this->entityManager->getRepository(Messages::class)->getUnreadMessages($user);
- $this->notificationCount = $this->entityManager->getRepository(Messages::class)->getUnreadMessageCount($user);
+ $this->msgs = Libs::getMessages($user, $this->entityManager);
$case = $this->entityManager->getRepository(MemberCase::class)->find($id);
$members = $this->entityManager->getRepository(Member::class)->getCaseMembersByName($case);
@@ -56,7 +54,6 @@ class MemberController extends AbstractController
'notifications' => $this->msgs,
'case' => $case,
'members' => $members,
- 'notificationCount' => $this->notificationCount,
]
)
);
@@ -65,9 +62,8 @@ class MemberController extends AbstractController
#[Route('/add-member/{id}', name: 'app_case_add_member')]
public function addMember(Request $request, #[CurrentUser()] User $user, string $id): Response
{
- $this->msgs = $this->entityManager->getRepository(Messages::class)->getUnreadMessages($user);
- $this->notificationCount = $this->entityManager->getRepository(Messages::class)->getUnreadMessageCount($user);
-
+ $this->msgs = Libs::getMessages($user, $this->entityManager);
+
/** @var MemberCase $case */
$case = $this->entityManager->getRepository(MemberCase::class)->find($id);
@@ -130,7 +126,6 @@ class MemberController extends AbstractController
'notifications' => $this->msgs,
'case' => $case,
'form' => $form->createView(),
- 'notificationCount' => $this->notificationCount,
]
)
);
@@ -139,9 +134,8 @@ class MemberController extends AbstractController
#[Route('/case/{caseId}/edit-member/{memberId}', name: 'app_case_edit_member')]
public function editMember(Request $request, #[CurrentUser()] User $user, string $caseId, string $memberId): Response
{
- $this->msgs = $this->entityManager->getRepository(Messages::class)->getUnreadMessages($user);
- $this->notificationCount = $this->entityManager->getRepository(Messages::class)->getUnreadMessageCount($user);
-
+ $this->msgs = Libs::getMessages($user, $this->entityManager);
+
$member = $this->entityManager->getRepository(Member::class)->find($memberId);
$form = $this->createForm(MemberFormType::class, $member);
@@ -197,7 +191,6 @@ class MemberController extends AbstractController
new Breadcrumb($this->generateUrl('app_case_edit_member', ['caseId' => $caseId, 'memberId' => $memberId]), 'Edit Member'),
],
'notifications' => $this->msgs,
- 'notificationCount' => $this->notificationCount,
'member' => $member,
'form' => $form->createView(),
'caseId' => $caseId,
diff --git a/src/Controller/MessageController.php b/src/Controller/MessageController.php
index 0229ef8..dbaade8 100644
--- a/src/Controller/MessageController.php
+++ b/src/Controller/MessageController.php
@@ -3,13 +3,16 @@
namespace App\Controller;
use App\Entity\Messages;
+use App\Entity\Supervision;
use App\Entity\User;
+use App\Enums\MessageType;
+use App\Libs\Libs;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
-use Symfony\Component\HttpFoundation\JsonResponse;
+use Symfony\Component\Security\Http\Attribute\CurrentUser;
class MessageController extends AbstractController
{
@@ -32,4 +35,28 @@ class MessageController extends AbstractController
'link' => $message->getLink(),
]);
}
+
+ #[Route('/api/send-message', name: 'app_send_message')]
+ public function sendMessage(Request $request, #[CurrentUser()] User $user): Response
+ {
+ $sup = $this->entityManager->getRepository(Supervision::class)->getSupervisorByWorker($user);
+ $data = json_decode($request->getContent(), true);
+ $message = new Messages();
+ $message->setSender($user);
+ $message->setSent(new \DateTimeImmutable());
+ $message->setRecipient($sup);
+ $message->setTitle('New Message');
+ $message->setMessage($data['message']);
+ $message->setType(MessageType::GENERAL);
+
+ //dd($message);
+
+ $this->entityManager->persist($message);
+ $this->entityManager->flush();
+
+ return $this->json([
+ 'success' => true,
+ 'message' => 'Message sent',
+ ]);
+ }
}
diff --git a/src/Controller/NoteController.php b/src/Controller/NoteController.php
index 2160f36..4d4811c 100644
--- a/src/Controller/NoteController.php
+++ b/src/Controller/NoteController.php
@@ -18,6 +18,7 @@ use App\Enums\ReferralServiceType;
use App\Form\StandardNoteFormType;
use App\Form\VisitNoteFormType;
use App\Libs\Breadcrumb;
+use App\Libs\Libs;
use App\Libs\NavList;
use DateTime;
use DateTimeZone;
@@ -37,8 +38,6 @@ class NoteController extends AbstractController
*/
private array $msgs;
- private int $notificationCount;
-
public function __construct(
private EntityManagerInterface $entityManager,
private array $navLinks = [],
@@ -47,14 +46,29 @@ class NoteController extends AbstractController
$this->navLinks['case_notes'] = NavList::PRESENT_LINK;
}
- #[Route('/list-notes/', name: 'app_list_notes')]
- public function listNotes(#[CurrentUser()] User $user, Request $request): Response
+ #[Route('/list-notes/{caseId?null}', name: 'app_list_notes')]
+ public function listNotes(string $caseId = null, #[CurrentUser()] User $user, Request $request): Response
{
- $this->msgs = $this->entityManager->getRepository(Messages::class)->getUnreadMessages($user);
- $this->notificationCount = $this->entityManager->getRepository(Messages::class)->getUnreadMessageCount($user);
+ $this->msgs = Libs::getMessages($user, $this->entityManager);
/** @var UserCase[] $cases */
$cases = $this->entityManager->getRepository(UserCase::class)->findBy(['user' => $user]);
+ $caseNotes = null;
+ $case = null;
+
+ if ($caseId != 'null') {
+ $case = $this->entityManager->getRepository(MemberCase::class)->find($caseId);
+ $params = [
+ 'case' => $case,
+ 'referral' => null,
+ 'startDate' => null,
+ 'endDate' => null,
+ ];
+ $caseNotes = array_merge(
+ $this->entityManager->getRepository(VisitNote::class)->filterNotes($user, $params),
+ $this->entityManager->getRepository(StandardNote::class)->filterNotes($user, $params),
+ );
+ }
return $this->render(
'internal/cases/notes/list-notes.html.twig',
@@ -66,7 +80,8 @@ class NoteController extends AbstractController
],
'notifications' => $this->msgs,
'cases' => $cases,
- 'notificationCount' => $this->notificationCount,
+ 'caseNotes' => $caseNotes,
+ 'case' => $case,
]
)
);
@@ -78,8 +93,7 @@ class NoteController extends AbstractController
/** @var Referral $referral */
$referral = $this->entityManager->getRepository(Referral::class)->find($referralId);
$this->entityManager->getRepository(Referral::class)->populateNotes($referral);
- $this->msgs = $this->entityManager->getRepository(Messages::class)->getUnreadMessages($user);
- $this->notificationCount = $this->entityManager->getRepository(Messages::class)->getUnreadMessageCount($user);
+ $this->msgs = Libs::getMessages($user, $this->entityManager);
$members = $this->entityManager->getRepository(Member::class)->findBy(['caseId' => $referral->getMemberCase()]);
$defaultMethod = NoteMethod::BILLABLE;
@@ -126,7 +140,6 @@ class NoteController extends AbstractController
'form' => $form,
'default_method' => $defaultMethod,
'default_location' => $defaultLocation,
- 'notificationCount' => $this->notificationCount,
]
)
);
@@ -135,8 +148,8 @@ class NoteController extends AbstractController
#[Route('/edit-note/{noteType}/{noteId}', name: 'app_edit_note')]
public function editNote(string $noteId, string $noteType, #[CurrentUser()] User $user, Request $request): Response
{
- $this->msgs = $this->entityManager->getRepository(Messages::class)->getUnreadMessages($user);
- $this->notificationCount = $this->entityManager->getRepository(Messages::class)->getUnreadMessageCount($user);
+ $this->msgs = Libs::getMessages($user, $this->entityManager);
+
$form = null;
/** @var VisitNote|StandardNote $note */
@@ -159,7 +172,6 @@ class NoteController extends AbstractController
new Breadcrumb($this->generateUrl('app_list_notes'), 'List Notes')
],
'notifications' => $this->msgs,
- 'notificationCount' => $this->notificationCount,
'note' => $note,
'referral' => $note->getReferral(),
'form' => $form,
@@ -178,11 +190,11 @@ class NoteController extends AbstractController
$case = null;
if ($request->getPayload()->get('startDate')) {
- $startDate = new DateTime($request->getPayload()->get('startDate'), new DateTimeZone('America/Indiana/Indianapolis'));
+ $startDate = new DateTime($request->getPayload()->get('startDate'), new DateTimeZone($_ENV['COMPANY_TIMEZONE']));
}
if ($request->getPayload()->get('endDate')) {
- $endDate = new DateTime($request->getPayload()->get('endDate'), new DateTimeZone('America/Indiana/Indianapolis'));
+ $endDate = new DateTime($request->getPayload()->get('endDate'), new DateTimeZone($_ENV['COMPANY_TIMEZONE']));
}
if ($request->getPayload()->get('referral')) {
diff --git a/src/Controller/ReferralController.php b/src/Controller/ReferralController.php
index ccba588..033676b 100644
--- a/src/Controller/ReferralController.php
+++ b/src/Controller/ReferralController.php
@@ -10,6 +10,7 @@ use App\Entity\UserCase;
use App\Factory\MessageFactory;
use App\Form\ReferralFormType;
use App\Libs\Breadcrumb;
+use App\Libs\Libs;
use App\Libs\NavList;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
@@ -27,8 +28,6 @@ class ReferralController extends AbstractController
*/
private array $msgs;
- private int $notificationCount;
-
public function __construct(
private EntityManagerInterface $entityManager,
private array $navLinks = []
@@ -44,8 +43,7 @@ class ReferralController extends AbstractController
#[Route('/list-referrals/{id}', name: 'app_list_referrals')]
public function listReferrals(#[CurrentUser()] User $user, string $id, Request $request): Response
{
- $this->msgs = $this->entityManager->getRepository(Messages::class)->getUnreadMessages($user);
- $this->notificationCount = $this->entityManager->getRepository(Messages::class)->getUnreadMessageCount($user);
+ $this->msgs = Libs::getMessages($user, $this->entityManager);
$case = $this->entityManager->getRepository(MemberCase::class)->find($id);
$openReferrals = $this->entityManager->getRepository(Referral::class)->getActiveReferrals($case);
@@ -65,7 +63,6 @@ class ReferralController extends AbstractController
new Breadcrumb($this->generateUrl('app_list_referrals', ['id' => $case->getId()]), 'Referrals'),
],
'notifications' => $this->msgs,
- 'notificationCount' => $this->notificationCount,
'case' => $case,
'openReferrals' => $openReferrals,
'closedReferrals' => $closedReferrals,
@@ -78,9 +75,8 @@ class ReferralController extends AbstractController
public function addReferral(Request $request, #[CurrentUser()] User $user, string $id): Response
{
$this->denyAccessUnlessGranted(['ROLE_ADMIN', 'ROLE_CASE_MANAGER']);
- $this->msgs = $this->entityManager->getRepository(Messages::class)->getUnreadMessages($user);
- $this->notificationCount = $this->entityManager->getRepository(Messages::class)->getUnreadMessageCount($user);
-
+ $this->msgs = Libs::getMessages($user, $this->entityManager);
+
$case = $this->entityManager->getRepository(MemberCase::class)->find($id);
/** @var UserCase $uc */
$uc = $this->entityManager->getRepository(UserCase::class)->findBy(['memberCase' => $case]);
@@ -114,7 +110,6 @@ class ReferralController extends AbstractController
new Breadcrumb($this->generateUrl('app_case_add_referral', ['id' => $case->getId()]), 'Add Referral')
],
'notifications' => $this->msgs,
- 'notificationCount' => $this->notificationCount,
'case' => $case,
'form' => $form,
]
@@ -126,9 +121,8 @@ class ReferralController extends AbstractController
public function editReferral(Request $request, #[CurrentUser()] User $user, string $caseId, string $referralId): Response
{
$this->denyAccessUnlessGranted(['ROLE_ADMIN', 'ROLE_CASE_MANAGER']);
- $this->msgs = $this->entityManager->getRepository(Messages::class)->getUnreadMessages($user);
- $this->notificationCount = $this->entityManager->getRepository(Messages::class)->getUnreadMessageCount($user);
-
+ $this->msgs = Libs::getMessages($user, $this->entityManager);
+
$referral = $this->entityManager->getRepository(Referral::class)->find($referralId);
$case = $this->entityManager->getRepository(MemberCase::class)->find($caseId);
/** @var UserCase $uc */
@@ -159,7 +153,6 @@ class ReferralController extends AbstractController
new Breadcrumb($this->generateUrl('app_case_edit_referral', ['caseId' => $case->getId(), 'referralId' => $referral->getId()]), 'Edit Referral'),
],
'notifications' => $this->msgs,
- 'notificationCount' => $this->notificationCount,
'case' => $case,
'form' => $form,
'referral' => $referral,
diff --git a/src/Controller/ReferralSourceController.php b/src/Controller/ReferralSourceController.php
index e659db8..3ee00cd 100644
--- a/src/Controller/ReferralSourceController.php
+++ b/src/Controller/ReferralSourceController.php
@@ -7,6 +7,7 @@ use App\Entity\ReferralSource;
use App\Entity\User;
use App\Form\ReferralSourceFormType;
use App\Libs\Breadcrumb;
+use App\Libs\Libs;
use App\Libs\NavList;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
@@ -24,8 +25,6 @@ class ReferralSourceController extends AbstractController
*/
private array $msgs;
- private int $notificationCount;
-
public function __construct(
private EntityManagerInterface $entityManager,
private array $navList = []
@@ -38,9 +37,8 @@ class ReferralSourceController extends AbstractController
public function listReferralSources(#[CurrentUser()] User $user): Response
{
$this->denyAccessUnlessGranted('ROLE_ADMIN');
- $this->msgs = $this->entityManager->getRepository(Messages::class)->getUnreadMessages($user);
- $this->notificationCount = $this->entityManager->getRepository(Messages::class)->getUnreadMessageCount($user);
-
+ $this->msgs = Libs::getMessages($user, $this->entityManager);
+
$sources = $this->entityManager->getRepository(ReferralSource::class)->retrieveOrderedList();
return $this->render(
@@ -50,7 +48,6 @@ class ReferralSourceController extends AbstractController
[
'sources' => $sources,
'notifications' => $this->msgs,
- 'notificationCount' => $this->notificationCount,
'breadcrumbs' => [
new Breadcrumb($this->generateUrl('app_referral_source'), 'Referral Sources')
]
@@ -63,9 +60,8 @@ class ReferralSourceController extends AbstractController
public function addSource(Request $request, #[CurrentUser()] User $user): Response
{
$this->denyAccessUnlessGranted('ROLE_ADMIN');
- $this->msgs = $this->entityManager->getRepository(Messages::class)->getUnreadMessages($user);
- $this->notificationCount = $this->entityManager->getRepository(Messages::class)->getUnreadMessageCount($user);
-
+ $this->msgs = Libs::getMessages($user, $this->entityManager);
+
$rs = new ReferralSource();
$form = $this->createForm(ReferralSourceFormType::class, $rs);
@@ -89,7 +85,6 @@ class ReferralSourceController extends AbstractController
[
'form' => $form,
'notifications' => $this->msgs,
- 'notificationCount' => $this->notificationCount,
'breadcrumbs' => [
new Breadcrumb($this->generateUrl('app_referral_source'), 'Referral Sources'),
new Breadcrumb($this->generateUrl('app_add_source'), 'Add Source')
@@ -103,9 +98,8 @@ class ReferralSourceController extends AbstractController
public function editSource(Request $request, #[CurrentUser()] User $user, string $id): Response
{
$this->denyAccessUnlessGranted('ROLE_ADMIN');
- $this->msgs = $this->entityManager->getRepository(Messages::class)->getUnreadMessages($user);
- $this->notificationCount = $this->entityManager->getRepository(Messages::class)->getUnreadMessageCount($user);
-
+ $this->msgs = Libs::getMessages($user, $this->entityManager);
+
$rs = $this->entityManager->getRepository(ReferralSource::class)->find($id);
$form = $this->createForm(ReferralSourceFormType::class, $rs);
@@ -130,7 +124,6 @@ class ReferralSourceController extends AbstractController
'form' => $form,
'rs' => $rs,
'notifications' => $this->msgs,
- 'notificationCount' => $this->notificationCount,
'breadcrumbs' => [
new Breadcrumb($this->generateUrl('app_referral_source'), 'Referral Sources'),
new Breadcrumb($this->generateUrl('app_edit_source', ['id' => $id]), 'Edit Source')
diff --git a/src/Controller/StaffController.php b/src/Controller/StaffController.php
index 791b06a..f5318fc 100644
--- a/src/Controller/StaffController.php
+++ b/src/Controller/StaffController.php
@@ -12,6 +12,7 @@ use App\Factory\MessageFactory;
use App\Form\StaffNoteFormType;
use App\Form\SupervisorStaffNoteFormType;
use App\Libs\Breadcrumb;
+use App\Libs\Libs;
use App\Libs\NavList;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
@@ -29,8 +30,6 @@ class StaffController extends AbstractController
*/
private array $msgs;
- private int $notificationCount;
-
public function __construct(
private readonly EntityManagerInterface $entityManager,
private array $navLinks = []
@@ -42,8 +41,7 @@ class StaffController extends AbstractController
#[Route('/staff-dashboard', name: 'app_staff_dashboard')]
public function staffDashboard(#[CurrentUser()] User $user): Response
{
- $this->msgs = $this->entityManager->getRepository(Messages::class)->getUnreadMessages($user);
- $this->notificationCount = $this->entityManager->getRepository(Messages::class)->getUnreadMessageCount($user);
+ $this->msgs = Libs::getMessages($user, $this->entityManager);
$sups = $this->entityManager->getRepository(Supervision::class)->findBy(['supervisor' => $user]);
$staff = [];
@@ -62,7 +60,6 @@ class StaffController extends AbstractController
new Breadcrumb('', 'Staff Dashboard')
],
'notifications' => $this->msgs,
- 'notificationCount' => $this->notificationCount,
]
)
);
@@ -74,11 +71,11 @@ class StaffController extends AbstractController
if (!$this->isGranted('IS_AUTHENTICATED_FULLY')) {
return $this->redirectToRoute('app_login');
}
- $this->msgs = $this->entityManager->getRepository(Messages::class)->getUnreadMessages($user);
- $this->notificationCount = $this->entityManager->getRepository(Messages::class)->getUnreadMessageCount($user);
+ $this->navLinks['staff_dashboard'] = NavList::DEFAULT;
+ $this->navLinks['staff_notes'] = NavList::PRESENT_LINK;
+ $this->msgs = Libs::getMessages($user, $this->entityManager);
$sup = $this->entityManager->getRepository(Supervision::class)->findOneBy(['worker' => $user]);
-
$ucs = $this->entityManager->getRepository(UserCase::class)->findBy(['user' => $user]);
$cases = [];
$this->navLinks['staff_dashboard'] = 'nav-link text-dark';
@@ -101,7 +98,6 @@ class StaffController extends AbstractController
new Breadcrumb('', 'Staff Cases')
],
'notifications' => $this->msgs,
- 'notificationCount' => $this->notificationCount,
]
)
);
@@ -113,8 +109,7 @@ class StaffController extends AbstractController
if (!$this->isGranted('IS_AUTHENTICATED_FULLY')) {
return $this->redirectToRoute('app_login');
}
- $this->msgs = $this->entityManager->getRepository(Messages::class)->getUnreadMessages($user);
- $this->notificationCount = $this->entityManager->getRepository(Messages::class)->getUnreadMessageCount($user);
+ $this->msgs = Libs::getMessages($user, $this->entityManager);
$staff = $this->entityManager->getRepository(User::class)->find($staffId);
$ucs = $this->entityManager->getRepository(UserCase::class)->findBy(['user' => $staff]);
@@ -137,7 +132,6 @@ class StaffController extends AbstractController
new Breadcrumb('', 'Staff Cases')
],
'notifications' => $this->msgs,
- 'notificationCount' => $this->notificationCount,
]
)
);
@@ -149,8 +143,9 @@ class StaffController extends AbstractController
if (!$this->isGranted('IS_AUTHENTICATED_FULLY')) {
return $this->redirectToRoute('app_login');
}
- $this->msgs = $this->entityManager->getRepository(Messages::class)->getUnreadMessages($user);
- $this->notificationCount = $this->entityManager->getRepository(Messages::class)->getUnreadMessageCount($user);
+ $this->msgs = Libs::getMessages($user, $this->entityManager);
+ $this->navLinks['staff_dashboard'] = NavList::DEFAULT;
+ $this->navLinks['staff_notes'] = NavList::PRESENT_LINK;
$isWorker = ($staffId == $user->getId()->toString());
$staff = $this->entityManager->getRepository(User::class)->find($staffId);
@@ -179,7 +174,6 @@ class StaffController extends AbstractController
new Breadcrumb('', 'List Notes')
],
'notifications' => $this->msgs,
- 'notificationCount' => $this->notificationCount,
]
)
);
@@ -191,8 +185,9 @@ class StaffController extends AbstractController
if (!$this->isGranted('IS_AUTHENTICATED_FULLY')) {
return $this->redirectToRoute('app_login');
}
- $this->msgs = $this->entityManager->getRepository(Messages::class)->getUnreadMessages($user);
- $this->notificationCount = $this->entityManager->getRepository(Messages::class)->getUnreadMessageCount($user);
+ $this->msgs = Libs::getMessages($user, $this->entityManager);
+ $this->navLinks['staff_dashboard'] = NavList::DEFAULT;
+ $this->navLinks['staff_notes'] = NavList::PRESENT_LINK;
$case = $this->entityManager->getRepository(MemberCase::class)->find($caseId);
$form = $this->createForm(StaffNoteFormType::class);
@@ -242,7 +237,6 @@ class StaffController extends AbstractController
new Breadcrumb('', 'Add Note'),
],
'notifications' => $this->msgs,
- 'notificationCount' => $this->notificationCount,
]
)
);
@@ -254,8 +248,9 @@ class StaffController extends AbstractController
if (!$this->isGranted('IS_AUTHENTICATED_FULLY')) {
return $this->redirectToRoute('app_login');
}
- $this->msgs = $this->entityManager->getRepository(Messages::class)->getUnreadMessages($user);
- $this->notificationCount = $this->entityManager->getRepository(Messages::class)->getUnreadMessageCount($user);
+ $this->msgs = Libs::getMessages($user, $this->entityManager);
+ $this->navLinks['staff_dashboard'] = NavList::DEFAULT;
+ $this->navLinks['staff_notes'] = NavList::PRESENT_LINK;
$note = $this->entityManager->getRepository(StaffNote::class)->find($noteId);
$case = $note->getMemberCase();
@@ -289,7 +284,6 @@ class StaffController extends AbstractController
new Breadcrumb('', 'Edit Note'),
],
'notifications' => $this->msgs,
- 'notificationCount' => $this->notificationCount,
]
)
);
@@ -301,8 +295,9 @@ class StaffController extends AbstractController
if (!$this->isGranted('IS_AUTHENTICATED_FULLY')) {
return $this->redirectToRoute('app_login');
}
- $this->msgs = $this->entityManager->getRepository(Messages::class)->getUnreadMessages($user);
- $this->notificationCount = $this->entityManager->getRepository(Messages::class)->getUnreadMessageCount($user);
+ $this->msgs = Libs::getMessages($user, $this->entityManager);
+ $this->navLinks['staff_dashboard'] = NavList::DEFAULT;
+ $this->navLinks['staff_notes'] = NavList::PRESENT_LINK;
$note = $this->entityManager->getRepository(StaffNote::class)->find($noteId);
$case = $note->getMemberCase();
@@ -340,7 +335,6 @@ class StaffController extends AbstractController
new Breadcrumb('', 'Sign Note'),
],
'notifications' => $this->msgs,
- 'notificationCount' => $this->notificationCount,
]
)
);
@@ -352,8 +346,7 @@ class StaffController extends AbstractController
if (!$this->isGranted('IS_AUTHENTICATED_FULLY')) {
return $this->redirectToRoute('app_login');
}
- $this->msgs = $this->entityManager->getRepository(Messages::class)->getUnreadMessages($user);
- $this->notificationCount = $this->entityManager->getRepository(Messages::class)->getUnreadMessageCount($user);
+ $this->msgs = Libs::getMessages($user, $this->entityManager);
$note = $this->entityManager->getRepository(StaffNote::class)->find($noteId);
$case = $note->getMemberCase();
@@ -392,7 +385,6 @@ class StaffController extends AbstractController
new Breadcrumb('', 'Sign Note'),
],
'notifications' => $this->msgs,
- 'notificationCount' => $this->notificationCount,
]
)
);
@@ -404,8 +396,9 @@ class StaffController extends AbstractController
if (!$this->isGranted('IS_AUTHENTICATED_FULLY')) {
return $this->redirectToRoute('app_login');
}
- $this->msgs = $this->entityManager->getRepository(Messages::class)->getUnreadMessages($user);
- $this->notificationCount = $this->entityManager->getRepository(Messages::class)->getUnreadMessageCount($user);
+ $this->msgs = Libs::getMessages($user, $this->entityManager);
+ $this->navLinks['staff_dashboard'] = NavList::DEFAULT;
+ $this->navLinks['staff_notes'] = NavList::PRESENT_LINK;
$note = $this->entityManager->getRepository(StaffNote::class)->find($noteId);
@@ -421,7 +414,6 @@ class StaffController extends AbstractController
new Breadcrumb('', 'View Note'),
],
'notifications' => $this->msgs,
- 'notificationCount' => $this->notificationCount,
]
)
);