remove notificationCount, convert to use Libs::getMessages method, change datetime creation to use company timezone

This commit is contained in:
Ryan Prather 2025-01-10 13:33:33 +00:00
parent 2d7b7e6d12
commit 02fcb0cc54
8 changed files with 125 additions and 120 deletions

View File

@ -29,8 +29,6 @@ class CommunityResourceController extends AbstractController
*/ */
private array $msgs; private array $msgs;
private int $notificationCount;
public function __construct( public function __construct(
private readonly EntityManagerInterface $entityManager, private readonly EntityManagerInterface $entityManager,
private array $navLinks = [] private array $navLinks = []
@ -43,8 +41,7 @@ class CommunityResourceController extends AbstractController
public function list(#[CurrentUser()] User $user): Response public function list(#[CurrentUser()] User $user): Response
{ {
$rsc = $this->entityManager->getRepository(CommunityResource::class)->findAll(); $rsc = $this->entityManager->getRepository(CommunityResource::class)->findAll();
$this->msgs = $this->entityManager->getRepository(Messages::class)->getUnreadMessages($user); $this->msgs = Libs::getMessages($user, $this->entityManager);
$this->notificationCount = $this->entityManager->getRepository(Messages::class)->getUnreadMessageCount($user);
return $this->render( return $this->render(
'internal/community_resource/list.html.twig', 'internal/community_resource/list.html.twig',
@ -56,7 +53,6 @@ class CommunityResourceController extends AbstractController
], ],
'resources' => $rsc, 'resources' => $rsc,
'notifications' => $this->msgs, 'notifications' => $this->msgs,
'notificationCount' => $this->notificationCount,
] ]
) )
); );
@ -65,8 +61,7 @@ class CommunityResourceController extends AbstractController
#[Route('/resource/map', name: 'app_community_resource_map')] #[Route('/resource/map', name: 'app_community_resource_map')]
public function map(#[CurrentUser()] User $user): Response public function map(#[CurrentUser()] User $user): Response
{ {
$this->msgs = $this->entityManager->getRepository(Messages::class)->getUnreadMessages($user); $this->msgs = Libs::getMessages($user, $this->entityManager);
$this->notificationCount = $this->entityManager->getRepository(Messages::class)->getUnreadMessageCount($user);
$rcs = $this->entityManager->getRepository(CommunityResource::class)->findAll(); $rcs = $this->entityManager->getRepository(CommunityResource::class)->findAll();
@ -81,7 +76,7 @@ class CommunityResourceController extends AbstractController
position: new Point($rsc->getLat(), $rsc->getLon()), position: new Point($rsc->getLat(), $rsc->getLon()),
title: $rsc->getName(), title: $rsc->getName(),
infoWindow: new InfoWindow( infoWindow: new InfoWindow(
content: "{$rsc->getName()}<br>{$rsc->getAddress()}, {$rsc->getCity()}, {$rsc->getState()->value} {$rsc->getZip()}<br>Services: " . $rsc->getServicesAvailable() content: $rsc->_toInfoWindow()
), ),
extra: [ extra: [
'type' => '' 'type' => ''
@ -100,7 +95,6 @@ class CommunityResourceController extends AbstractController
new Breadcrumb('#', 'Community Resources') new Breadcrumb('#', 'Community Resources')
], ],
'notifications' => $this->msgs, 'notifications' => $this->msgs,
'notificationCount' => $this->notificationCount,
] ]
) )
); );
@ -109,9 +103,8 @@ class CommunityResourceController extends AbstractController
#[Route('/resource/add', name: 'app_community_resource_add')] #[Route('/resource/add', name: 'app_community_resource_add')]
public function add(#[CurrentUser()] User $user, Request $request): Response public function add(#[CurrentUser()] User $user, Request $request): Response
{ {
$this->msgs = $this->entityManager->getRepository(Messages::class)->getUnreadMessages($user); $this->msgs = Libs::getMessages($user, $this->entityManager);
$this->notificationCount = $this->entityManager->getRepository(Messages::class)->getUnreadMessageCount($user);
$form = $this->createForm(ResourceFormType::class); $form = $this->createForm(ResourceFormType::class);
$form->handleRequest($request); $form->handleRequest($request);
@ -150,7 +143,6 @@ class CommunityResourceController extends AbstractController
new Breadcrumb('#', 'Add Resource') new Breadcrumb('#', 'Add Resource')
], ],
'notifications' => $this->msgs, 'notifications' => $this->msgs,
'notificationCount' => $this->notificationCount,
] ]
) )
); );
@ -160,9 +152,8 @@ class CommunityResourceController extends AbstractController
#[Route('/resource/edit/{id}', name: 'app_community_resource_edit')] #[Route('/resource/edit/{id}', name: 'app_community_resource_edit')]
public function edit(string $id, #[CurrentUser()] User $user, Request $request): Response public function edit(string $id, #[CurrentUser()] User $user, Request $request): Response
{ {
$this->msgs = $this->entityManager->getRepository(Messages::class)->getUnreadMessages($user); $this->msgs = Libs::getMessages($user, $this->entityManager);
$this->notificationCount = $this->entityManager->getRepository(Messages::class)->getUnreadMessageCount($user);
$rsc = $this->entityManager->getRepository(CommunityResource::class)->find($id); $rsc = $this->entityManager->getRepository(CommunityResource::class)->find($id);
$form = $this->createForm(ResourceFormType::class, $rsc); $form = $this->createForm(ResourceFormType::class, $rsc);
@ -199,7 +190,6 @@ class CommunityResourceController extends AbstractController
new Breadcrumb('#', 'Edit Resource') new Breadcrumb('#', 'Edit Resource')
], ],
'notifications' => $this->msgs, 'notifications' => $this->msgs,
'notificationCount' => $this->notificationCount,
] ]
) )
); );

View File

@ -13,6 +13,7 @@ use App\Libs\Breadcrumb;
use App\Libs\Libs; use App\Libs\Libs;
use App\Libs\NavList; use App\Libs\NavList;
use DateTime; use DateTime;
use DateTimeZone;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
@ -30,8 +31,6 @@ class ItineraryController extends AbstractController
{ {
private array $msgs = []; private array $msgs = [];
private int $notificationCount = 0;
public function __construct( public function __construct(
private EntityManagerInterface $entityManager, private EntityManagerInterface $entityManager,
private array $navLinks = [] private array $navLinks = []
@ -44,9 +43,8 @@ class ItineraryController extends AbstractController
{ {
$this->navLinks['case_itinerary'] = NavList::PRESENT_LINK; $this->navLinks['case_itinerary'] = NavList::PRESENT_LINK;
$this->msgs = $this->entityManager->getRepository(Messages::class)->getUnreadMessages($user); $this->msgs = Libs::getMessages($user, $this->entityManager);
$this->notificationCount = $this->entityManager->getRepository(Messages::class)->getUnreadMessageCount($user);
$itineraries = $this->entityManager->getRepository(CaseItinerary::class)->getRecentTravel( $itineraries = $this->entityManager->getRepository(CaseItinerary::class)->getRecentTravel(
$user $user
); );
@ -67,7 +65,6 @@ class ItineraryController extends AbstractController
new Breadcrumb($this->generateUrl('app_dashboard'), 'Dashboard'), new Breadcrumb($this->generateUrl('app_dashboard'), 'Dashboard'),
], ],
'notifications' => $this->msgs, 'notifications' => $this->msgs,
'notificationCount' => $this->notificationCount,
'itineraries' => $itineraries, 'itineraries' => $itineraries,
'cases' => $cases 'cases' => $cases
] ]
@ -84,12 +81,21 @@ class ItineraryController extends AbstractController
if ($request->getPayload()->get('caseId')) { if ($request->getPayload()->get('caseId')) {
$case = $this->entityManager->getRepository(MemberCase::class)->find($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); $startDate = (
$endDate = ($request->getPayload()->get('endDate') ? new DateTime($request->getPayload()->get('endDate')) : null); $request->getPayload()->get('startDate')
?
$this->msgs = $this->entityManager->getRepository(Messages::class)->getUnreadMessages($user); new DateTime($request->getPayload()->get('startDate'), new DateTimeZone($_ENV['COMPANY_TIMEZONE']))
$this->notificationCount = $this->entityManager->getRepository(Messages::class)->getUnreadMessageCount($user); :
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, [ $itineraries = $this->entityManager->getRepository(CaseItinerary::class)->getRecentTravel($user, [
'case' => $case, 'case' => $case,
'from' => $startDate, 'from' => $startDate,
@ -113,7 +119,7 @@ class ItineraryController extends AbstractController
), ),
title: $itinerary->getOriginLocation()->getName(), title: $itinerary->getOriginLocation()->getName(),
infoWindow: new InfoWindow( infoWindow: new InfoWindow(
content: $itinerary->getOriginLocation()->getName(), content: $itinerary->originInfoWindow(),
) )
)); ));
@ -124,7 +130,7 @@ class ItineraryController extends AbstractController
), ),
title: $itinerary->getDestLocation()->getName(), title: $itinerary->getDestLocation()->getName(),
infoWindow: new InfoWindow( 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'), new Breadcrumb($this->generateUrl('app_report_itinerary'), 'Itinerary Report'),
], ],
'notifications' => $this->msgs, 'notifications' => $this->msgs,
'notificationCount' => $this->notificationCount,
'map' => $map, 'map' => $map,
'total_distance' => $total_distance, 'total_distance' => $total_distance,
'total_duration' => $di->format("%H:%i'%s''"), 'total_duration' => $di->format("%H:%i'%s''"),
@ -188,7 +193,7 @@ class ItineraryController extends AbstractController
$departure = $request->getPayload()->get('departure'); $departure = $request->getPayload()->get('departure');
$arrival = $request->getPayload()->get('arrival'); $arrival = $request->getPayload()->get('arrival');
$caseMileage = (bool) $request->getPayload()->get('caseMileage'); $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); $route = Libs::getRouteDistance($origin, $destination);
@ -234,11 +239,11 @@ class ItineraryController extends AbstractController
} }
if ($request->getPayload()->get('startDate')) { 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')) { 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, [ $itineraries = $this->entityManager->getRepository(CaseItinerary::class)->getRecentTravel($user, [

View File

@ -8,6 +8,7 @@ use App\Entity\MemberCase;
use App\Entity\Messages; use App\Entity\Messages;
use App\Form\MemberFormType; use App\Form\MemberFormType;
use App\Libs\Breadcrumb; use App\Libs\Breadcrumb;
use App\Libs\Libs;
use App\Libs\NavList; use App\Libs\NavList;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
@ -25,8 +26,6 @@ class MemberController extends AbstractController
*/ */
private array $msgs; private array $msgs;
private int $notificationCount;
public function __construct( public function __construct(
private EntityManagerInterface $entityManager, private EntityManagerInterface $entityManager,
private array $navLinks = [], private array $navLinks = [],
@ -38,8 +37,7 @@ class MemberController extends AbstractController
#[Route('/list-members/{id}', name: 'app_case_members')] #[Route('/list-members/{id}', name: 'app_case_members')]
public function listMembers(Request $request, #[CurrentUser()] User $user, string $id): Response public function listMembers(Request $request, #[CurrentUser()] User $user, string $id): Response
{ {
$this->msgs = $this->entityManager->getRepository(Messages::class)->getUnreadMessages($user); $this->msgs = Libs::getMessages($user, $this->entityManager);
$this->notificationCount = $this->entityManager->getRepository(Messages::class)->getUnreadMessageCount($user);
$case = $this->entityManager->getRepository(MemberCase::class)->find($id); $case = $this->entityManager->getRepository(MemberCase::class)->find($id);
$members = $this->entityManager->getRepository(Member::class)->getCaseMembersByName($case); $members = $this->entityManager->getRepository(Member::class)->getCaseMembersByName($case);
@ -56,7 +54,6 @@ class MemberController extends AbstractController
'notifications' => $this->msgs, 'notifications' => $this->msgs,
'case' => $case, 'case' => $case,
'members' => $members, 'members' => $members,
'notificationCount' => $this->notificationCount,
] ]
) )
); );
@ -65,9 +62,8 @@ class MemberController extends AbstractController
#[Route('/add-member/{id}', name: 'app_case_add_member')] #[Route('/add-member/{id}', name: 'app_case_add_member')]
public function addMember(Request $request, #[CurrentUser()] User $user, string $id): Response public function addMember(Request $request, #[CurrentUser()] User $user, string $id): Response
{ {
$this->msgs = $this->entityManager->getRepository(Messages::class)->getUnreadMessages($user); $this->msgs = Libs::getMessages($user, $this->entityManager);
$this->notificationCount = $this->entityManager->getRepository(Messages::class)->getUnreadMessageCount($user);
/** @var MemberCase $case */ /** @var MemberCase $case */
$case = $this->entityManager->getRepository(MemberCase::class)->find($id); $case = $this->entityManager->getRepository(MemberCase::class)->find($id);
@ -130,7 +126,6 @@ class MemberController extends AbstractController
'notifications' => $this->msgs, 'notifications' => $this->msgs,
'case' => $case, 'case' => $case,
'form' => $form->createView(), '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')] #[Route('/case/{caseId}/edit-member/{memberId}', name: 'app_case_edit_member')]
public function editMember(Request $request, #[CurrentUser()] User $user, string $caseId, string $memberId): Response public function editMember(Request $request, #[CurrentUser()] User $user, string $caseId, string $memberId): Response
{ {
$this->msgs = $this->entityManager->getRepository(Messages::class)->getUnreadMessages($user); $this->msgs = Libs::getMessages($user, $this->entityManager);
$this->notificationCount = $this->entityManager->getRepository(Messages::class)->getUnreadMessageCount($user);
$member = $this->entityManager->getRepository(Member::class)->find($memberId); $member = $this->entityManager->getRepository(Member::class)->find($memberId);
$form = $this->createForm(MemberFormType::class, $member); $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'), new Breadcrumb($this->generateUrl('app_case_edit_member', ['caseId' => $caseId, 'memberId' => $memberId]), 'Edit Member'),
], ],
'notifications' => $this->msgs, 'notifications' => $this->msgs,
'notificationCount' => $this->notificationCount,
'member' => $member, 'member' => $member,
'form' => $form->createView(), 'form' => $form->createView(),
'caseId' => $caseId, 'caseId' => $caseId,

View File

@ -3,13 +3,16 @@
namespace App\Controller; namespace App\Controller;
use App\Entity\Messages; use App\Entity\Messages;
use App\Entity\Supervision;
use App\Entity\User; use App\Entity\User;
use App\Enums\MessageType;
use App\Libs\Libs;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Routing\Annotation\Route;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\Security\Http\Attribute\CurrentUser;
class MessageController extends AbstractController class MessageController extends AbstractController
{ {
@ -32,4 +35,28 @@ class MessageController extends AbstractController
'link' => $message->getLink(), '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',
]);
}
} }

View File

@ -18,6 +18,7 @@ use App\Enums\ReferralServiceType;
use App\Form\StandardNoteFormType; use App\Form\StandardNoteFormType;
use App\Form\VisitNoteFormType; use App\Form\VisitNoteFormType;
use App\Libs\Breadcrumb; use App\Libs\Breadcrumb;
use App\Libs\Libs;
use App\Libs\NavList; use App\Libs\NavList;
use DateTime; use DateTime;
use DateTimeZone; use DateTimeZone;
@ -37,8 +38,6 @@ class NoteController extends AbstractController
*/ */
private array $msgs; private array $msgs;
private int $notificationCount;
public function __construct( public function __construct(
private EntityManagerInterface $entityManager, private EntityManagerInterface $entityManager,
private array $navLinks = [], private array $navLinks = [],
@ -47,14 +46,29 @@ class NoteController extends AbstractController
$this->navLinks['case_notes'] = NavList::PRESENT_LINK; $this->navLinks['case_notes'] = NavList::PRESENT_LINK;
} }
#[Route('/list-notes/', name: 'app_list_notes')] #[Route('/list-notes/{caseId?null}', name: 'app_list_notes')]
public function listNotes(#[CurrentUser()] User $user, Request $request): Response public function listNotes(string $caseId = null, #[CurrentUser()] User $user, Request $request): Response
{ {
$this->msgs = $this->entityManager->getRepository(Messages::class)->getUnreadMessages($user); $this->msgs = Libs::getMessages($user, $this->entityManager);
$this->notificationCount = $this->entityManager->getRepository(Messages::class)->getUnreadMessageCount($user);
/** @var UserCase[] $cases */ /** @var UserCase[] $cases */
$cases = $this->entityManager->getRepository(UserCase::class)->findBy(['user' => $user]); $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( return $this->render(
'internal/cases/notes/list-notes.html.twig', 'internal/cases/notes/list-notes.html.twig',
@ -66,7 +80,8 @@ class NoteController extends AbstractController
], ],
'notifications' => $this->msgs, 'notifications' => $this->msgs,
'cases' => $cases, 'cases' => $cases,
'notificationCount' => $this->notificationCount, 'caseNotes' => $caseNotes,
'case' => $case,
] ]
) )
); );
@ -78,8 +93,7 @@ class NoteController extends AbstractController
/** @var Referral $referral */ /** @var Referral $referral */
$referral = $this->entityManager->getRepository(Referral::class)->find($referralId); $referral = $this->entityManager->getRepository(Referral::class)->find($referralId);
$this->entityManager->getRepository(Referral::class)->populateNotes($referral); $this->entityManager->getRepository(Referral::class)->populateNotes($referral);
$this->msgs = $this->entityManager->getRepository(Messages::class)->getUnreadMessages($user); $this->msgs = Libs::getMessages($user, $this->entityManager);
$this->notificationCount = $this->entityManager->getRepository(Messages::class)->getUnreadMessageCount($user);
$members = $this->entityManager->getRepository(Member::class)->findBy(['caseId' => $referral->getMemberCase()]); $members = $this->entityManager->getRepository(Member::class)->findBy(['caseId' => $referral->getMemberCase()]);
$defaultMethod = NoteMethod::BILLABLE; $defaultMethod = NoteMethod::BILLABLE;
@ -126,7 +140,6 @@ class NoteController extends AbstractController
'form' => $form, 'form' => $form,
'default_method' => $defaultMethod, 'default_method' => $defaultMethod,
'default_location' => $defaultLocation, 'default_location' => $defaultLocation,
'notificationCount' => $this->notificationCount,
] ]
) )
); );
@ -135,8 +148,8 @@ class NoteController extends AbstractController
#[Route('/edit-note/{noteType}/{noteId}', name: 'app_edit_note')] #[Route('/edit-note/{noteType}/{noteId}', name: 'app_edit_note')]
public function editNote(string $noteId, string $noteType, #[CurrentUser()] User $user, Request $request): Response public function editNote(string $noteId, string $noteType, #[CurrentUser()] User $user, Request $request): Response
{ {
$this->msgs = $this->entityManager->getRepository(Messages::class)->getUnreadMessages($user); $this->msgs = Libs::getMessages($user, $this->entityManager);
$this->notificationCount = $this->entityManager->getRepository(Messages::class)->getUnreadMessageCount($user);
$form = null; $form = null;
/** @var VisitNote|StandardNote $note */ /** @var VisitNote|StandardNote $note */
@ -159,7 +172,6 @@ class NoteController extends AbstractController
new Breadcrumb($this->generateUrl('app_list_notes'), 'List Notes') new Breadcrumb($this->generateUrl('app_list_notes'), 'List Notes')
], ],
'notifications' => $this->msgs, 'notifications' => $this->msgs,
'notificationCount' => $this->notificationCount,
'note' => $note, 'note' => $note,
'referral' => $note->getReferral(), 'referral' => $note->getReferral(),
'form' => $form, 'form' => $form,
@ -178,11 +190,11 @@ class NoteController extends AbstractController
$case = null; $case = null;
if ($request->getPayload()->get('startDate')) { 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')) { 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')) { if ($request->getPayload()->get('referral')) {

View File

@ -10,6 +10,7 @@ use App\Entity\UserCase;
use App\Factory\MessageFactory; use App\Factory\MessageFactory;
use App\Form\ReferralFormType; use App\Form\ReferralFormType;
use App\Libs\Breadcrumb; use App\Libs\Breadcrumb;
use App\Libs\Libs;
use App\Libs\NavList; use App\Libs\NavList;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
@ -27,8 +28,6 @@ class ReferralController extends AbstractController
*/ */
private array $msgs; private array $msgs;
private int $notificationCount;
public function __construct( public function __construct(
private EntityManagerInterface $entityManager, private EntityManagerInterface $entityManager,
private array $navLinks = [] private array $navLinks = []
@ -44,8 +43,7 @@ class ReferralController extends AbstractController
#[Route('/list-referrals/{id}', name: 'app_list_referrals')] #[Route('/list-referrals/{id}', name: 'app_list_referrals')]
public function listReferrals(#[CurrentUser()] User $user, string $id, Request $request): Response public function listReferrals(#[CurrentUser()] User $user, string $id, Request $request): Response
{ {
$this->msgs = $this->entityManager->getRepository(Messages::class)->getUnreadMessages($user); $this->msgs = Libs::getMessages($user, $this->entityManager);
$this->notificationCount = $this->entityManager->getRepository(Messages::class)->getUnreadMessageCount($user);
$case = $this->entityManager->getRepository(MemberCase::class)->find($id); $case = $this->entityManager->getRepository(MemberCase::class)->find($id);
$openReferrals = $this->entityManager->getRepository(Referral::class)->getActiveReferrals($case); $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'), new Breadcrumb($this->generateUrl('app_list_referrals', ['id' => $case->getId()]), 'Referrals'),
], ],
'notifications' => $this->msgs, 'notifications' => $this->msgs,
'notificationCount' => $this->notificationCount,
'case' => $case, 'case' => $case,
'openReferrals' => $openReferrals, 'openReferrals' => $openReferrals,
'closedReferrals' => $closedReferrals, 'closedReferrals' => $closedReferrals,
@ -78,9 +75,8 @@ class ReferralController extends AbstractController
public function addReferral(Request $request, #[CurrentUser()] User $user, string $id): Response public function addReferral(Request $request, #[CurrentUser()] User $user, string $id): Response
{ {
$this->denyAccessUnlessGranted(['ROLE_ADMIN', 'ROLE_CASE_MANAGER']); $this->denyAccessUnlessGranted(['ROLE_ADMIN', 'ROLE_CASE_MANAGER']);
$this->msgs = $this->entityManager->getRepository(Messages::class)->getUnreadMessages($user); $this->msgs = Libs::getMessages($user, $this->entityManager);
$this->notificationCount = $this->entityManager->getRepository(Messages::class)->getUnreadMessageCount($user);
$case = $this->entityManager->getRepository(MemberCase::class)->find($id); $case = $this->entityManager->getRepository(MemberCase::class)->find($id);
/** @var UserCase $uc */ /** @var UserCase $uc */
$uc = $this->entityManager->getRepository(UserCase::class)->findBy(['memberCase' => $case]); $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') new Breadcrumb($this->generateUrl('app_case_add_referral', ['id' => $case->getId()]), 'Add Referral')
], ],
'notifications' => $this->msgs, 'notifications' => $this->msgs,
'notificationCount' => $this->notificationCount,
'case' => $case, 'case' => $case,
'form' => $form, 'form' => $form,
] ]
@ -126,9 +121,8 @@ class ReferralController extends AbstractController
public function editReferral(Request $request, #[CurrentUser()] User $user, string $caseId, string $referralId): Response public function editReferral(Request $request, #[CurrentUser()] User $user, string $caseId, string $referralId): Response
{ {
$this->denyAccessUnlessGranted(['ROLE_ADMIN', 'ROLE_CASE_MANAGER']); $this->denyAccessUnlessGranted(['ROLE_ADMIN', 'ROLE_CASE_MANAGER']);
$this->msgs = $this->entityManager->getRepository(Messages::class)->getUnreadMessages($user); $this->msgs = Libs::getMessages($user, $this->entityManager);
$this->notificationCount = $this->entityManager->getRepository(Messages::class)->getUnreadMessageCount($user);
$referral = $this->entityManager->getRepository(Referral::class)->find($referralId); $referral = $this->entityManager->getRepository(Referral::class)->find($referralId);
$case = $this->entityManager->getRepository(MemberCase::class)->find($caseId); $case = $this->entityManager->getRepository(MemberCase::class)->find($caseId);
/** @var UserCase $uc */ /** @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'), new Breadcrumb($this->generateUrl('app_case_edit_referral', ['caseId' => $case->getId(), 'referralId' => $referral->getId()]), 'Edit Referral'),
], ],
'notifications' => $this->msgs, 'notifications' => $this->msgs,
'notificationCount' => $this->notificationCount,
'case' => $case, 'case' => $case,
'form' => $form, 'form' => $form,
'referral' => $referral, 'referral' => $referral,

View File

@ -7,6 +7,7 @@ use App\Entity\ReferralSource;
use App\Entity\User; use App\Entity\User;
use App\Form\ReferralSourceFormType; use App\Form\ReferralSourceFormType;
use App\Libs\Breadcrumb; use App\Libs\Breadcrumb;
use App\Libs\Libs;
use App\Libs\NavList; use App\Libs\NavList;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
@ -24,8 +25,6 @@ class ReferralSourceController extends AbstractController
*/ */
private array $msgs; private array $msgs;
private int $notificationCount;
public function __construct( public function __construct(
private EntityManagerInterface $entityManager, private EntityManagerInterface $entityManager,
private array $navList = [] private array $navList = []
@ -38,9 +37,8 @@ class ReferralSourceController extends AbstractController
public function listReferralSources(#[CurrentUser()] User $user): Response public function listReferralSources(#[CurrentUser()] User $user): Response
{ {
$this->denyAccessUnlessGranted('ROLE_ADMIN'); $this->denyAccessUnlessGranted('ROLE_ADMIN');
$this->msgs = $this->entityManager->getRepository(Messages::class)->getUnreadMessages($user); $this->msgs = Libs::getMessages($user, $this->entityManager);
$this->notificationCount = $this->entityManager->getRepository(Messages::class)->getUnreadMessageCount($user);
$sources = $this->entityManager->getRepository(ReferralSource::class)->retrieveOrderedList(); $sources = $this->entityManager->getRepository(ReferralSource::class)->retrieveOrderedList();
return $this->render( return $this->render(
@ -50,7 +48,6 @@ class ReferralSourceController extends AbstractController
[ [
'sources' => $sources, 'sources' => $sources,
'notifications' => $this->msgs, 'notifications' => $this->msgs,
'notificationCount' => $this->notificationCount,
'breadcrumbs' => [ 'breadcrumbs' => [
new Breadcrumb($this->generateUrl('app_referral_source'), 'Referral Sources') 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 public function addSource(Request $request, #[CurrentUser()] User $user): Response
{ {
$this->denyAccessUnlessGranted('ROLE_ADMIN'); $this->denyAccessUnlessGranted('ROLE_ADMIN');
$this->msgs = $this->entityManager->getRepository(Messages::class)->getUnreadMessages($user); $this->msgs = Libs::getMessages($user, $this->entityManager);
$this->notificationCount = $this->entityManager->getRepository(Messages::class)->getUnreadMessageCount($user);
$rs = new ReferralSource(); $rs = new ReferralSource();
$form = $this->createForm(ReferralSourceFormType::class, $rs); $form = $this->createForm(ReferralSourceFormType::class, $rs);
@ -89,7 +85,6 @@ class ReferralSourceController extends AbstractController
[ [
'form' => $form, 'form' => $form,
'notifications' => $this->msgs, 'notifications' => $this->msgs,
'notificationCount' => $this->notificationCount,
'breadcrumbs' => [ 'breadcrumbs' => [
new Breadcrumb($this->generateUrl('app_referral_source'), 'Referral Sources'), new Breadcrumb($this->generateUrl('app_referral_source'), 'Referral Sources'),
new Breadcrumb($this->generateUrl('app_add_source'), 'Add Source') 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 public function editSource(Request $request, #[CurrentUser()] User $user, string $id): Response
{ {
$this->denyAccessUnlessGranted('ROLE_ADMIN'); $this->denyAccessUnlessGranted('ROLE_ADMIN');
$this->msgs = $this->entityManager->getRepository(Messages::class)->getUnreadMessages($user); $this->msgs = Libs::getMessages($user, $this->entityManager);
$this->notificationCount = $this->entityManager->getRepository(Messages::class)->getUnreadMessageCount($user);
$rs = $this->entityManager->getRepository(ReferralSource::class)->find($id); $rs = $this->entityManager->getRepository(ReferralSource::class)->find($id);
$form = $this->createForm(ReferralSourceFormType::class, $rs); $form = $this->createForm(ReferralSourceFormType::class, $rs);
@ -130,7 +124,6 @@ class ReferralSourceController extends AbstractController
'form' => $form, 'form' => $form,
'rs' => $rs, 'rs' => $rs,
'notifications' => $this->msgs, 'notifications' => $this->msgs,
'notificationCount' => $this->notificationCount,
'breadcrumbs' => [ 'breadcrumbs' => [
new Breadcrumb($this->generateUrl('app_referral_source'), 'Referral Sources'), new Breadcrumb($this->generateUrl('app_referral_source'), 'Referral Sources'),
new Breadcrumb($this->generateUrl('app_edit_source', ['id' => $id]), 'Edit Source') new Breadcrumb($this->generateUrl('app_edit_source', ['id' => $id]), 'Edit Source')

View File

@ -12,6 +12,7 @@ use App\Factory\MessageFactory;
use App\Form\StaffNoteFormType; use App\Form\StaffNoteFormType;
use App\Form\SupervisorStaffNoteFormType; use App\Form\SupervisorStaffNoteFormType;
use App\Libs\Breadcrumb; use App\Libs\Breadcrumb;
use App\Libs\Libs;
use App\Libs\NavList; use App\Libs\NavList;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
@ -29,8 +30,6 @@ class StaffController extends AbstractController
*/ */
private array $msgs; private array $msgs;
private int $notificationCount;
public function __construct( public function __construct(
private readonly EntityManagerInterface $entityManager, private readonly EntityManagerInterface $entityManager,
private array $navLinks = [] private array $navLinks = []
@ -42,8 +41,7 @@ class StaffController extends AbstractController
#[Route('/staff-dashboard', name: 'app_staff_dashboard')] #[Route('/staff-dashboard', name: 'app_staff_dashboard')]
public function staffDashboard(#[CurrentUser()] User $user): Response public function staffDashboard(#[CurrentUser()] User $user): Response
{ {
$this->msgs = $this->entityManager->getRepository(Messages::class)->getUnreadMessages($user); $this->msgs = Libs::getMessages($user, $this->entityManager);
$this->notificationCount = $this->entityManager->getRepository(Messages::class)->getUnreadMessageCount($user);
$sups = $this->entityManager->getRepository(Supervision::class)->findBy(['supervisor' => $user]); $sups = $this->entityManager->getRepository(Supervision::class)->findBy(['supervisor' => $user]);
$staff = []; $staff = [];
@ -62,7 +60,6 @@ class StaffController extends AbstractController
new Breadcrumb('', 'Staff Dashboard') new Breadcrumb('', 'Staff Dashboard')
], ],
'notifications' => $this->msgs, 'notifications' => $this->msgs,
'notificationCount' => $this->notificationCount,
] ]
) )
); );
@ -74,11 +71,11 @@ class StaffController extends AbstractController
if (!$this->isGranted('IS_AUTHENTICATED_FULLY')) { if (!$this->isGranted('IS_AUTHENTICATED_FULLY')) {
return $this->redirectToRoute('app_login'); return $this->redirectToRoute('app_login');
} }
$this->msgs = $this->entityManager->getRepository(Messages::class)->getUnreadMessages($user); $this->navLinks['staff_dashboard'] = NavList::DEFAULT;
$this->notificationCount = $this->entityManager->getRepository(Messages::class)->getUnreadMessageCount($user); $this->navLinks['staff_notes'] = NavList::PRESENT_LINK;
$this->msgs = Libs::getMessages($user, $this->entityManager);
$sup = $this->entityManager->getRepository(Supervision::class)->findOneBy(['worker' => $user]); $sup = $this->entityManager->getRepository(Supervision::class)->findOneBy(['worker' => $user]);
$ucs = $this->entityManager->getRepository(UserCase::class)->findBy(['user' => $user]); $ucs = $this->entityManager->getRepository(UserCase::class)->findBy(['user' => $user]);
$cases = []; $cases = [];
$this->navLinks['staff_dashboard'] = 'nav-link text-dark'; $this->navLinks['staff_dashboard'] = 'nav-link text-dark';
@ -101,7 +98,6 @@ class StaffController extends AbstractController
new Breadcrumb('', 'Staff Cases') new Breadcrumb('', 'Staff Cases')
], ],
'notifications' => $this->msgs, 'notifications' => $this->msgs,
'notificationCount' => $this->notificationCount,
] ]
) )
); );
@ -113,8 +109,7 @@ class StaffController extends AbstractController
if (!$this->isGranted('IS_AUTHENTICATED_FULLY')) { if (!$this->isGranted('IS_AUTHENTICATED_FULLY')) {
return $this->redirectToRoute('app_login'); return $this->redirectToRoute('app_login');
} }
$this->msgs = $this->entityManager->getRepository(Messages::class)->getUnreadMessages($user); $this->msgs = Libs::getMessages($user, $this->entityManager);
$this->notificationCount = $this->entityManager->getRepository(Messages::class)->getUnreadMessageCount($user);
$staff = $this->entityManager->getRepository(User::class)->find($staffId); $staff = $this->entityManager->getRepository(User::class)->find($staffId);
$ucs = $this->entityManager->getRepository(UserCase::class)->findBy(['user' => $staff]); $ucs = $this->entityManager->getRepository(UserCase::class)->findBy(['user' => $staff]);
@ -137,7 +132,6 @@ class StaffController extends AbstractController
new Breadcrumb('', 'Staff Cases') new Breadcrumb('', 'Staff Cases')
], ],
'notifications' => $this->msgs, 'notifications' => $this->msgs,
'notificationCount' => $this->notificationCount,
] ]
) )
); );
@ -149,8 +143,9 @@ class StaffController extends AbstractController
if (!$this->isGranted('IS_AUTHENTICATED_FULLY')) { if (!$this->isGranted('IS_AUTHENTICATED_FULLY')) {
return $this->redirectToRoute('app_login'); return $this->redirectToRoute('app_login');
} }
$this->msgs = $this->entityManager->getRepository(Messages::class)->getUnreadMessages($user); $this->msgs = Libs::getMessages($user, $this->entityManager);
$this->notificationCount = $this->entityManager->getRepository(Messages::class)->getUnreadMessageCount($user); $this->navLinks['staff_dashboard'] = NavList::DEFAULT;
$this->navLinks['staff_notes'] = NavList::PRESENT_LINK;
$isWorker = ($staffId == $user->getId()->toString()); $isWorker = ($staffId == $user->getId()->toString());
$staff = $this->entityManager->getRepository(User::class)->find($staffId); $staff = $this->entityManager->getRepository(User::class)->find($staffId);
@ -179,7 +174,6 @@ class StaffController extends AbstractController
new Breadcrumb('', 'List Notes') new Breadcrumb('', 'List Notes')
], ],
'notifications' => $this->msgs, 'notifications' => $this->msgs,
'notificationCount' => $this->notificationCount,
] ]
) )
); );
@ -191,8 +185,9 @@ class StaffController extends AbstractController
if (!$this->isGranted('IS_AUTHENTICATED_FULLY')) { if (!$this->isGranted('IS_AUTHENTICATED_FULLY')) {
return $this->redirectToRoute('app_login'); return $this->redirectToRoute('app_login');
} }
$this->msgs = $this->entityManager->getRepository(Messages::class)->getUnreadMessages($user); $this->msgs = Libs::getMessages($user, $this->entityManager);
$this->notificationCount = $this->entityManager->getRepository(Messages::class)->getUnreadMessageCount($user); $this->navLinks['staff_dashboard'] = NavList::DEFAULT;
$this->navLinks['staff_notes'] = NavList::PRESENT_LINK;
$case = $this->entityManager->getRepository(MemberCase::class)->find($caseId); $case = $this->entityManager->getRepository(MemberCase::class)->find($caseId);
$form = $this->createForm(StaffNoteFormType::class); $form = $this->createForm(StaffNoteFormType::class);
@ -242,7 +237,6 @@ class StaffController extends AbstractController
new Breadcrumb('', 'Add Note'), new Breadcrumb('', 'Add Note'),
], ],
'notifications' => $this->msgs, 'notifications' => $this->msgs,
'notificationCount' => $this->notificationCount,
] ]
) )
); );
@ -254,8 +248,9 @@ class StaffController extends AbstractController
if (!$this->isGranted('IS_AUTHENTICATED_FULLY')) { if (!$this->isGranted('IS_AUTHENTICATED_FULLY')) {
return $this->redirectToRoute('app_login'); return $this->redirectToRoute('app_login');
} }
$this->msgs = $this->entityManager->getRepository(Messages::class)->getUnreadMessages($user); $this->msgs = Libs::getMessages($user, $this->entityManager);
$this->notificationCount = $this->entityManager->getRepository(Messages::class)->getUnreadMessageCount($user); $this->navLinks['staff_dashboard'] = NavList::DEFAULT;
$this->navLinks['staff_notes'] = NavList::PRESENT_LINK;
$note = $this->entityManager->getRepository(StaffNote::class)->find($noteId); $note = $this->entityManager->getRepository(StaffNote::class)->find($noteId);
$case = $note->getMemberCase(); $case = $note->getMemberCase();
@ -289,7 +284,6 @@ class StaffController extends AbstractController
new Breadcrumb('', 'Edit Note'), new Breadcrumb('', 'Edit Note'),
], ],
'notifications' => $this->msgs, 'notifications' => $this->msgs,
'notificationCount' => $this->notificationCount,
] ]
) )
); );
@ -301,8 +295,9 @@ class StaffController extends AbstractController
if (!$this->isGranted('IS_AUTHENTICATED_FULLY')) { if (!$this->isGranted('IS_AUTHENTICATED_FULLY')) {
return $this->redirectToRoute('app_login'); return $this->redirectToRoute('app_login');
} }
$this->msgs = $this->entityManager->getRepository(Messages::class)->getUnreadMessages($user); $this->msgs = Libs::getMessages($user, $this->entityManager);
$this->notificationCount = $this->entityManager->getRepository(Messages::class)->getUnreadMessageCount($user); $this->navLinks['staff_dashboard'] = NavList::DEFAULT;
$this->navLinks['staff_notes'] = NavList::PRESENT_LINK;
$note = $this->entityManager->getRepository(StaffNote::class)->find($noteId); $note = $this->entityManager->getRepository(StaffNote::class)->find($noteId);
$case = $note->getMemberCase(); $case = $note->getMemberCase();
@ -340,7 +335,6 @@ class StaffController extends AbstractController
new Breadcrumb('', 'Sign Note'), new Breadcrumb('', 'Sign Note'),
], ],
'notifications' => $this->msgs, 'notifications' => $this->msgs,
'notificationCount' => $this->notificationCount,
] ]
) )
); );
@ -352,8 +346,7 @@ class StaffController extends AbstractController
if (!$this->isGranted('IS_AUTHENTICATED_FULLY')) { if (!$this->isGranted('IS_AUTHENTICATED_FULLY')) {
return $this->redirectToRoute('app_login'); return $this->redirectToRoute('app_login');
} }
$this->msgs = $this->entityManager->getRepository(Messages::class)->getUnreadMessages($user); $this->msgs = Libs::getMessages($user, $this->entityManager);
$this->notificationCount = $this->entityManager->getRepository(Messages::class)->getUnreadMessageCount($user);
$note = $this->entityManager->getRepository(StaffNote::class)->find($noteId); $note = $this->entityManager->getRepository(StaffNote::class)->find($noteId);
$case = $note->getMemberCase(); $case = $note->getMemberCase();
@ -392,7 +385,6 @@ class StaffController extends AbstractController
new Breadcrumb('', 'Sign Note'), new Breadcrumb('', 'Sign Note'),
], ],
'notifications' => $this->msgs, 'notifications' => $this->msgs,
'notificationCount' => $this->notificationCount,
] ]
) )
); );
@ -404,8 +396,9 @@ class StaffController extends AbstractController
if (!$this->isGranted('IS_AUTHENTICATED_FULLY')) { if (!$this->isGranted('IS_AUTHENTICATED_FULLY')) {
return $this->redirectToRoute('app_login'); return $this->redirectToRoute('app_login');
} }
$this->msgs = $this->entityManager->getRepository(Messages::class)->getUnreadMessages($user); $this->msgs = Libs::getMessages($user, $this->entityManager);
$this->notificationCount = $this->entityManager->getRepository(Messages::class)->getUnreadMessageCount($user); $this->navLinks['staff_dashboard'] = NavList::DEFAULT;
$this->navLinks['staff_notes'] = NavList::PRESENT_LINK;
$note = $this->entityManager->getRepository(StaffNote::class)->find($noteId); $note = $this->entityManager->getRepository(StaffNote::class)->find($noteId);
@ -421,7 +414,6 @@ class StaffController extends AbstractController
new Breadcrumb('', 'View Note'), new Breadcrumb('', 'View Note'),
], ],
'notifications' => $this->msgs, 'notifications' => $this->msgs,
'notificationCount' => $this->notificationCount,
] ]
) )
); );