Compare commits

...

11 Commits

35 changed files with 1438 additions and 58 deletions

View File

@ -0,0 +1,10 @@
.notification .badge {
position: absolute;
top: -8px;
right: 5px;
padding: 5px 9px;
border-radius: 50%;
background-color: red;
color: white;
font-size: 6pt;
}

View File

@ -11,4 +11,5 @@ return [
Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true],
Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true],
Symfony\Bundle\MakerBundle\MakerBundle::class => ['dev' => true],
Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle::class => ['dev' => true, 'test' => true],
];

View File

@ -2,8 +2,10 @@
namespace App\Controller;
use App\Entity\Messages;
use App\Entity\Supervision;
use App\Entity\User;
use App\Factory\MessageFactory;
use App\Form\EditUserFormType;
use App\Form\SupervisorFormType;
use App\Form\UserFormType;
@ -22,6 +24,10 @@ use Symfony\Component\Security\Http\Attribute\IsGranted;
#[IsGranted('ROLE_ADMIN')]
class AdminController extends AbstractController
{
private array $msgs;
private int $notificationCount = 0;
public function __construct(
private readonly EntityManagerInterface $entityManager,
private readonly UserPasswordHasherInterface $userPasswordHasher,
@ -35,6 +41,8 @@ class AdminController extends AbstractController
{
$this->denyAccessUnlessGranted('ROLE_ADMIN');
$this->navLinks['admin_dashboard'] = NavList::PRESENT_LINK;
$this->msgs = $this->entityManager->getRepository(Messages::class)->getUnreadMessages($user);
$this->notificationCount = $this->entityManager->getRepository(Messages::class)->getUnreadMessageCount($user);
return $this->render(
'internal/admin/admin-dashboard.html.twig',
@ -44,7 +52,8 @@ class AdminController extends AbstractController
'breadcrumbs' => [
new Breadcrumb($this->generateUrl('app_admin_dashboard'), 'Admin Dashboard')
],
'notifications' => $user->retrieveUnreadNotifications(),
'notifications' => $this->msgs,
'notificationCount' => $this->notificationCount,
]
)
);
@ -54,6 +63,8 @@ class AdminController extends AbstractController
public function listUsers(#[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);
/** @var UserRepository $repo */
$repo = $this->entityManager->getRepository(User::class);
@ -77,7 +88,8 @@ class AdminController extends AbstractController
new Breadcrumb($this->generateUrl('app_list_users'), 'List Users')
],
'users' => $users,
'notifications' => $user->retrieveUnreadNotifications(),
'notifications' => $this->msgs,
'notificationCount' => $this->notificationCount,
]
)
);
@ -87,6 +99,8 @@ class AdminController extends AbstractController
public function addUser(Request $request, #[CurrentUser()] User $admin): Response
{
$this->denyAccessUnlessGranted('ROLE_ADMIN');
$this->msgs = $this->entityManager->getRepository(Messages::class)->getUnreadMessages($admin);
$this->notificationCount = $this->entityManager->getRepository(Messages::class)->getUnreadMessageCount($admin);
$user = new User();
$form = $this->createForm(UserFormType::class, $user);
@ -128,6 +142,10 @@ class AdminController extends AbstractController
->setLevel($form->get('level')->getData())
->setCompany($admin->getCompany());
$msg = MessageFactory::createUser($admin, $user, 'Welcome', "Welcome to CM Tracker");
$this->entityManager->persist($msg);
$this->entityManager->persist($user);
$this->entityManager->flush();
@ -148,7 +166,8 @@ class AdminController extends AbstractController
new Breadcrumb($this->generateUrl('app_add_user'), 'Add User')
],
'form' => $form,
'notifications' => $admin->retrieveUnreadNotifications(),
'notifications' => $this->msgs,
'notificationCount' => $this->notificationCount,
]
)
);
@ -159,6 +178,8 @@ class AdminController extends AbstractController
{
/** @var UserRepository $userRepo */
$userRepo = $this->entityManager->getRepository(User::class);
$this->msgs = $this->entityManager->getRepository(Messages::class)->getUnreadMessages($admin);
$this->notificationCount = $this->entityManager->getRepository(Messages::class)->getUnreadMessageCount($admin);
/** @var User $user */
$user = $userRepo->find($id);
@ -195,7 +216,8 @@ class AdminController extends AbstractController
],
'data' => $user,
'form' => $form,
'notifications' => $admin->retrieveUnreadNotifications(),
'notifications' => $this->msgs,
'notificationCount' => $this->notificationCount,
]
)
);
@ -206,6 +228,8 @@ class AdminController extends AbstractController
{
/** @var UserRepository $userRepo */
$userRepo = $this->entityManager->getRepository(User::class);
$this->msgs = $this->entityManager->getRepository(Messages::class)->getUnreadMessages($admin);
$this->notificationCount = $this->entityManager->getRepository(Messages::class)->getUnreadMessageCount($admin);
/** @var User $user */
$user = $userRepo->find($id);
@ -226,7 +250,12 @@ class AdminController extends AbstractController
$sup->setSupervisor($supervisor);
$sup->setWorker($user);
$supMsg = MessageFactory::createUser($admin, $supervisor, 'New Case Worker', "You've been assigned a new case worker, {$user->getName()}");
$userMsg = MessageFactory::createUser($admin, $user, 'New Staff Supervisor', "You've been assigned a new staff supervisor {$supervisor->getName()}");
$this->entityManager->persist($sup);
$this->entityManager->persist($userMsg);
$this->entityManager->persist($supMsg);
$this->entityManager->flush();
return $this->redirectToRoute('app_list_users');
@ -244,7 +273,8 @@ class AdminController extends AbstractController
'user' => $user,
'form' => $form,
'supervisors' => $userRepo->getCaseManagers($admin->getCompany()),
'notifications' => $admin->retrieveUnreadNotifications(),
'notifications' => $this->msgs,
'notificationCount' => $this->notificationCount,
]
)
);

View File

@ -3,9 +3,11 @@
namespace App\Controller;
use App\Entity\MemberCase;
use App\Entity\Messages;
use App\Entity\ReferralSource;
use App\Entity\User;
use App\Entity\UserCase;
use App\Factory\MessageFactory;
use App\Form\MemberCaseFormType;
use App\Form\UserCaseFormType;
use App\Libs\Breadcrumb;
@ -19,6 +21,15 @@ use Symfony\Component\Security\Http\Attribute\CurrentUser;
class CaseController extends AbstractController
{
/**
* Variable to store unread notification messages
*
* @var array
*/
private array $msgs;
private int $notificationCount;
public function __construct(
private EntityManagerInterface $entityManager,
private array $navLinks = []
@ -27,32 +38,59 @@ class CaseController extends AbstractController
$this->navLinks['case_list'] = NavList::PRESENT_LINK;
}
#[Route('/list-cases', name: 'app_list_cases')]
public function listCases(#[CurrentUser()] User $user): Response
#[Route('/my-cases', name: 'app_my_cases')]
public function myCases(#[CurrentUser()] User $user): Response
{
if($this->isGranted('ROLE_ADMIN')) {
$cases = $this->entityManager->getRepository(MemberCase::class)->findAll();
} else {
$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();
}
}
$workers = $this->entityManager->getRepository(User::class)->getCaseWorkers();
return $this->render(
'internal/cases/list-cases.html.twig',
'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')]
public function listCases(#[CurrentUser()] User $user): Response
{
$this->denyAccessUnlessGranted('ROLE_ADMIN');
$cases = $this->entityManager->getRepository(MemberCase::class)->findAll();
$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(
'internal/admin/cases/list-cases.html.twig',
array_merge(
$this->navLinks,
[
'breadcrumbs' => [
new Breadcrumb($this->generateUrl('app_list_cases'), 'List Cases')
],
'notifications' => $user->retrieveUnreadNotifications(),
'notifications' => $this->msgs,
'cases' => $cases,
'workers' => $workers,
'notificationCount' => $this->notificationCount,
]
)
);
@ -62,6 +100,8 @@ class CaseController extends AbstractController
public function addCase(Request $request, #[CurrentUser()] User $admin): Response
{
$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();
$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_add_case'), 'Add Case')
],
'notifications' => $admin->retrieveUnreadNotifications(),
'notifications' => $this->msgs,
'notificationCount' => $this->notificationCount,
'form' => $form,
'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
{
$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);
$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_edit_case', ['id' => $id]), 'Edit Case')
],
'notifications' => $admin->retrieveUnreadNotifications(),
'notifications' => $this->msgs,
'notificationCount' => $this->notificationCount,
'form' => $form,
'case' => $case,
'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
{
$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();
$case = $this->entityManager->getRepository(MemberCase::class)->find($id);
@ -159,7 +205,10 @@ class CaseController extends AbstractController
$this->entityManager->flush();
}
$msg = MessageFactory::createNewCase($admin, $user);
$this->entityManager->persist($uc);
$this->entityManager->persist($msg);
$this->entityManager->flush();
$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_assign_case', ['id' => $id]), 'Assign User')
],
'notifications' => $admin->retrieveUnreadNotifications(),
'notifications' => $this->msgs,
'notificationCount' => $this->notificationCount,
'case' => $case,
'form' => $form,
'id' => $id,
'caseWorkers' => $caseWorkers,

View File

@ -3,6 +3,7 @@
namespace App\Controller;
use App\Entity\CommunityResource;
use App\Entity\Messages;
use App\Entity\User;
use App\Form\ResourceFormType;
use App\Libs\Breadcrumb;
@ -17,6 +18,15 @@ use Symfony\Component\Validator\Constraints\Regex;
class CommunityResourceController extends AbstractController
{
/**
* Variable to store unread notification messages
*
* @var array
*/
private array $msgs;
private int $notificationCount;
public function __construct(
private readonly EntityManagerInterface $entityManager,
private array $navLinks = []
@ -29,6 +39,8 @@ 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);
return $this->render(
'internal/community_resource/list.html.twig',
@ -39,7 +51,8 @@ class CommunityResourceController extends AbstractController
new Breadcrumb('#', 'Community Resources')
],
'resources' => $rsc,
'notifications' => $user->retrieveUnreadNotifications(),
'notifications' => $this->msgs,
'notificationCount' => $this->notificationCount,
]
)
);
@ -55,6 +68,9 @@ 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);
$form = $this->createForm(ResourceFormType::class);
$form->handleRequest($request);
@ -63,6 +79,8 @@ class CommunityResourceController extends AbstractController
$this->entityManager->persist($rsc);
$this->entityManager->flush();
$this->addFlash('success', 'Resource added successfully');
return $this->redirectToRoute('app_community_resource');
}
@ -76,7 +94,8 @@ class CommunityResourceController extends AbstractController
new Breadcrumb($this->generateUrl('app_community_resource'), 'List Resources'),
new Breadcrumb('#', 'Add Resource')
],
'notifications' => $user->retrieveUnreadNotifications(),
'notifications' => $this->msgs,
'notificationCount' => $this->notificationCount,
]
)
);
@ -86,6 +105,9 @@ 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);
$rsc = $this->entityManager->getRepository(CommunityResource::class)->find($id);
$form = $this->createForm(ResourceFormType::class, $rsc);
@ -94,6 +116,8 @@ class CommunityResourceController extends AbstractController
if ($form->isSubmitted() && $form->isValid()) {
$this->entityManager->flush();
$this->addFlash('success', 'Resource updated successfully');
return $this->redirectToRoute('app_community_resource');
}
@ -107,7 +131,8 @@ class CommunityResourceController extends AbstractController
new Breadcrumb($this->generateUrl('app_community_resource'), 'List Resources'),
new Breadcrumb('#', 'Edit Resource')
],
'notifications' => $user->retrieveUnreadNotifications(),
'notifications' => $this->msgs,
'notificationCount' => $this->notificationCount,
]
)
);

View File

@ -2,7 +2,9 @@
namespace App\Controller;
use App\Entity\Messages;
use App\Entity\User;
use App\Libs\Breadcrumb;
use App\Libs\NavList;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
@ -14,6 +16,14 @@ use Symfony\Component\Security\Http\Attribute\CurrentUser;
class DefaultController extends AbstractController
{
/**
* Variable to store unread notification messages
*
* @var array
*/
private array $msgs;
private int $notificationCount = 0;
public function __construct(
private readonly EntityManagerInterface $entityManager,
@ -27,6 +37,8 @@ class DefaultController extends AbstractController
public function dashboard(Request $request, #[CurrentUser()] ?User $user): Response
{
$this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY');
$this->msgs = $this->entityManager->getRepository(Messages::class)->getUnreadMessages($user);
$this->notificationCount = $this->entityManager->getRepository(Messages::class)->getUnreadMessageCount($user);
if (!$user->getCompany()) {
return $this->redirectToRoute('app_register_step', ['step' => RegistrationController::REGISTER_STEP_TWO]);
@ -40,9 +52,10 @@ class DefaultController extends AbstractController
$this->navLinks,
[
'breadcrumbs' => [
'Dashboard'
new Breadcrumb('', 'Dashboard')
],
'notifications' => $user->retrieveUnreadNotifications(),
'notifications' => $this->msgs,
'notificationCount' => $this->notificationCount,
]
)
);
@ -52,6 +65,8 @@ class DefaultController extends AbstractController
public function profile(#[CurrentUser()] User $user): Response
{
$this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY');
$this->msgs = $this->entityManager->getRepository(Messages::class)->getUnreadMessages($user);
$this->notificationCount = $this->entityManager->getRepository(Messages::class)->getUnreadMessageCount($user);
$this->navLinks['profile'] = NavList::PRESENT_LINK;
@ -61,9 +76,10 @@ class DefaultController extends AbstractController
$this->navLinks,
[
'breadcrumbs' => [
'Profile'
new Breadcrumb('', 'Profile')
],
'notifications' => $user->retrieveUnreadNotifications(),
'notifications' => $this->msgs,
'notificationCount' => $this->notificationCount,
]
)
);

View File

@ -5,6 +5,7 @@ namespace App\Controller;
use App\Entity\Member;
use App\Entity\User;
use App\Entity\MemberCase;
use App\Entity\Messages;
use App\Form\MemberFormType;
use App\Libs\Breadcrumb;
use App\Libs\NavList;
@ -17,6 +18,15 @@ use Symfony\Component\Security\Http\Attribute\CurrentUser;
class MemberController extends AbstractController
{
/**
* Variable to store unread notification messages
*
* @var array
*/
private array $msgs;
private int $notificationCount;
public function __construct(
private EntityManagerInterface $entityManager,
private array $navLinks = [],
@ -28,6 +38,9 @@ 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);
$case = $this->entityManager->getRepository(MemberCase::class)->find($id);
$members = $this->entityManager->getRepository(Member::class)->getCaseMembersByName($case);
@ -40,9 +53,10 @@ class MemberController extends AbstractController
new Breadcrumb($this->generateUrl('app_list_cases'), 'List Cases'),
new Breadcrumb($this->generateUrl('app_case_members', ['id' => $id]), 'List Members'),
],
'notifications' => $user->retrieveUnreadNotifications(),
'notifications' => $this->msgs,
'case' => $case,
'members' => $members,
'notificationCount' => $this->notificationCount,
]
)
);
@ -51,6 +65,9 @@ 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);
/** @var MemberCase $case */
$case = $this->entityManager->getRepository(MemberCase::class)->find($id);
@ -110,9 +127,10 @@ class MemberController extends AbstractController
new Breadcrumb($this->generateUrl('app_case_members', ['id' => $id]), 'List Members'),
new Breadcrumb($this->generateUrl('app_case_add_member', ['id' => $id]), 'Add Member'),
],
'notifications' => $user->retrieveUnreadNotifications(),
'notifications' => $this->msgs,
'case' => $case,
'form' => $form->createView(),
'notificationCount' => $this->notificationCount,
]
)
);
@ -121,6 +139,9 @@ 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);
$member = $this->entityManager->getRepository(Member::class)->find($memberId);
$form = $this->createForm(MemberFormType::class, $member);
@ -175,7 +196,8 @@ class MemberController extends AbstractController
new Breadcrumb($this->generateUrl('app_case_members', ['id' => $caseId]), 'List Members'),
new Breadcrumb($this->generateUrl('app_case_edit_member', ['caseId' => $caseId, 'memberId' => $memberId]), 'Edit Member'),
],
'notifications' => $user->retrieveUnreadNotifications(),
'notifications' => $this->msgs,
'notificationCount' => $this->notificationCount,
'member' => $member,
'form' => $form->createView(),
'caseId' => $caseId,

View File

@ -0,0 +1,30 @@
<?php
namespace App\Controller;
use App\Entity\Messages;
use App\Entity\User;
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;
class MessageController extends AbstractController
{
public function __construct(
private EntityManagerInterface $entityManager
) {
}
#[Route('/api/notifications/{msgId}', name: 'app_read_message')]
public function readMessage(string $msgId): Response
{
$message = $this->entityManager->getRepository(Messages::class)->find($msgId);
$message->setReceived(new \DateTimeImmutable());
$this->entityManager->flush();
return new JsonResponse(true, Response::HTTP_OK);
}
}

View File

@ -3,6 +3,7 @@
namespace App\Controller;
use App\Entity\Member;
use App\Entity\Messages;
use App\Entity\Referral;
use App\Entity\StandardNote;
use App\Entity\User;
@ -24,6 +25,15 @@ use Symfony\Component\Security\Http\Attribute\CurrentUser;
class NoteController extends AbstractController
{
/**
* Variable to store unread notification messages
*
* @var array
*/
private array $msgs;
private int $notificationCount;
public function __construct(
private EntityManagerInterface $entityManager,
private array $navLinks = [],
@ -35,6 +45,9 @@ class NoteController extends AbstractController
#[Route('/list-notes/{id?null}', name: 'app_list_notes')]
public function listNotes(#[CurrentUser()] User $user, ?string $id = null): Response
{
$this->msgs = $this->entityManager->getRepository(Messages::class)->getUnreadMessages($user);
$this->notificationCount = $this->entityManager->getRepository(Messages::class)->getUnreadMessageCount($user);
/** @var UserCase[] $cases */
$cases = $this->entityManager->getRepository(UserCase::class)->findBy(['user' => $user]);
$referrals = [];
@ -71,9 +84,10 @@ class NoteController extends AbstractController
'breadcrumbs' => [
new Breadcrumb($this->generateUrl('app_list_notes'), 'List Notes')
],
'notifications' => $user->retrieveUnreadNotifications(),
'notifications' => $this->msgs,
'cases' => $cases,
'notes' => $notes,
'notificationCount' => $this->notificationCount,
]
)
);
@ -85,8 +99,8 @@ class NoteController extends AbstractController
/** @var Referral $referral */
$referral = $this->entityManager->getRepository(Referral::class)->find($id);
$this->entityManager->getRepository(Referral::class)->populateNotes($referral);
//dd($referral);
$this->msgs = $this->entityManager->getRepository(Messages::class)->getUnreadMessages($user);
$this->notificationCount = $this->entityManager->getRepository(Messages::class)->getUnreadMessageCount($user);
$members = $this->entityManager->getRepository(Member::class)->findBy(['caseId' => $referral->getMemberCase()]);
$defaultMethod = NoteMethod::BILLABLE;
@ -128,23 +142,31 @@ class NoteController extends AbstractController
'breadcrumbs' => [
new Breadcrumb($this->generateUrl('app_list_notes'), 'List Notes')
],
'notifications' => $user->retrieveUnreadNotifications(),
'notifications' => $this->msgs,
'referral' => $referral,
'form' => $form,
'default_method' => $defaultMethod,
'default_location' => $defaultLocation,
'notificationCount' => $this->notificationCount,
]
)
);
}
#[Route('/edit-note', name: 'app_edit_note')]
public function editNote(): Response
#[Route('/edit-note/{noteId}', name: 'app_edit_note')]
public function editNote(string $noteId, #[CurrentUser()] User $user, Request $request): Response
{
$this->msgs = $this->entityManager->getRepository(Messages::class)->getUnreadMessages($user);
$this->notificationCount = $this->entityManager->getRepository(Messages::class)->getUnreadMessageCount($user);
return $this->render(
'internal/cases/notes/edit-note.html.twig',
array_merge(
$this->navLinks,
[
'notifications' => $this->msgs,
'notificationCount' => $this->notificationCount,
]
)
);
}

View File

@ -3,8 +3,11 @@
namespace App\Controller;
use App\Entity\MemberCase;
use App\Entity\Messages;
use App\Entity\Referral;
use App\Entity\User;
use App\Entity\UserCase;
use App\Factory\MessageFactory;
use App\Form\ReferralFormType;
use App\Libs\Breadcrumb;
use App\Libs\NavList;
@ -17,6 +20,15 @@ use Symfony\Component\Security\Http\Attribute\CurrentUser;
class ReferralController extends AbstractController
{
/**
* Variable to store unread notification messages
*
* @var array
*/
private array $msgs;
private int $notificationCount;
public function __construct(
private EntityManagerInterface $entityManager,
private array $navLinks = []
@ -26,8 +38,11 @@ class ReferralController extends AbstractController
}
#[Route('/list-referrals/{id}', name: 'app_list_referrals')]
public function listReferrals(Request $request, #[CurrentUser()] User $user, string $id): Response
public function listReferrals(#[CurrentUser()] User $user, string $id): Response
{
$this->msgs = $this->entityManager->getRepository(Messages::class)->getUnreadMessages($user);
$this->notificationCount = $this->entityManager->getRepository(Messages::class)->getUnreadMessageCount($user);
$case = $this->entityManager->getRepository(MemberCase::class)->find($id);
$openReferrals = $this->entityManager->getRepository(Referral::class)->getActiveReferrals($case);
$closedReferrals = $this->entityManager->getRepository(Referral::class)->getClosedReferrals($case);
@ -41,7 +56,8 @@ class ReferralController extends AbstractController
new Breadcrumb($this->generateUrl('app_list_cases'), 'List Cases'),
new Breadcrumb($this->generateUrl('app_list_referrals', ['id' => $case->getId()]), 'Referrals'),
],
'notifications' => $user->retrieveUnreadNotifications(),
'notifications' => $this->msgs,
'notificationCount' => $this->notificationCount,
'case' => $case,
'openReferrals' => $openReferrals,
'closedReferrals' => $closedReferrals,
@ -53,7 +69,13 @@ class ReferralController extends AbstractController
#[Route('/add-referral/{id}', name: 'app_case_add_referral')]
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);
$case = $this->entityManager->getRepository(MemberCase::class)->find($id);
/** @var UserCase $uc */
$uc = $this->entityManager->getRepository(UserCase::class)->findBy(['memberCase' => $case]);
$referral = new Referral();
$form = $this->createForm(ReferralFormType::class, $referral);
@ -64,6 +86,9 @@ class ReferralController extends AbstractController
$referral = $form->getData();
$referral->setMemberCase($case);
$msg = MessageFactory::createReferral($user, $uc->getUser(), $case);
$this->entityManager->persist($msg);
$this->entityManager->persist($referral);
$this->entityManager->flush();
@ -80,7 +105,8 @@ class ReferralController extends AbstractController
new Breadcrumb($this->generateUrl('app_list_referrals', ['id' => $case->getId()]), 'Referrals'),
new Breadcrumb($this->generateUrl('app_case_add_referral', ['id' => $case->getId()]), 'Add Referral')
],
'notifications' => $user->retrieveUnreadNotifications(),
'notifications' => $this->msgs,
'notificationCount' => $this->notificationCount,
'case' => $case,
'form' => $form,
]
@ -91,8 +117,14 @@ class ReferralController extends AbstractController
#[Route('/case/{caseId}/edit-referral/{referralId}', name: 'app_case_edit_referral')]
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);
$referral = $this->entityManager->getRepository(Referral::class)->find($referralId);
$case = $this->entityManager->getRepository(MemberCase::class)->find($caseId);
/** @var UserCase $uc */
$uc = $this->entityManager->getRepository(UserCase::class)->findBy(['case' => $case]);
$form = $this->createForm(ReferralFormType::class, $referral);
$form->handleRequest($request);
@ -100,6 +132,9 @@ class ReferralController extends AbstractController
if ($form->isSubmitted() && $form->isValid()) {
$referral = $form->getData();
$msg = MessageFactory::createReferral($user, $uc->getUser(), $case);
$this->entityManager->persist($msg);
$this->entityManager->flush();
return $this->redirectToRoute('app_list_referrals', ['id' => $case->getId()]);
@ -115,7 +150,8 @@ class ReferralController extends AbstractController
new Breadcrumb($this->generateUrl('app_list_referrals', ['id' => $case->getId()]), 'Referrals'),
new Breadcrumb($this->generateUrl('app_case_edit_referral', ['caseId' => $case->getId(), 'referralId' => $referral->getId()]), 'Edit Referral'),
],
'notifications' => $user->retrieveUnreadNotifications(),
'notifications' => $this->msgs,
'notificationCount' => $this->notificationCount,
'case' => $case,
'form' => $form,
'referral' => $referral,

View File

@ -2,6 +2,7 @@
namespace App\Controller;
use App\Entity\Messages;
use App\Entity\ReferralSource;
use App\Entity\User;
use App\Form\ReferralSourceFormType;
@ -16,6 +17,15 @@ use Symfony\Component\Security\Http\Attribute\CurrentUser;
class ReferralSourceController extends AbstractController
{
/**
* Variable to store unread notification messages
*
* @var array
*/
private array $msgs;
private int $notificationCount;
public function __construct(
private EntityManagerInterface $entityManager,
private array $navList = []
@ -28,6 +38,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);
$sources = $this->entityManager->getRepository(ReferralSource::class)->retrieveOrderedList();
@ -37,7 +49,8 @@ class ReferralSourceController extends AbstractController
$this->navList,
[
'sources' => $sources,
'notifications' => $user->retrieveUnreadNotifications(),
'notifications' => $this->msgs,
'notificationCount' => $this->notificationCount,
'breadcrumbs' => [
new Breadcrumb($this->generateUrl('app_referral_source'), 'Referral Sources')
]
@ -50,6 +63,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);
$rs = new ReferralSource();
$form = $this->createForm(ReferralSourceFormType::class, $rs);
@ -73,7 +88,8 @@ class ReferralSourceController extends AbstractController
$this->navList,
[
'form' => $form,
'notifications' => $user->retrieveUnreadNotifications(),
'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')
@ -87,6 +103,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);
$rs = $this->entityManager->getRepository(ReferralSource::class)->find($id);
@ -111,7 +129,8 @@ class ReferralSourceController extends AbstractController
[
'form' => $form,
'rs' => $rs,
'notifications' => $user->retrieveUnreadNotifications(),
'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')

View File

@ -2,21 +2,35 @@
namespace App\Controller;
use App\Entity\MemberCase;
use App\Entity\Messages;
use App\Entity\StaffNote;
use App\Entity\Supervision;
use App\Entity\User;
use App\Entity\UserCase;
use App\Form\StaffNoteFormType;
use App\Libs\Breadcrumb;
use App\Libs\NavList;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Http\Attribute\CurrentUser;
class StaffController extends AbstractController
{
/**
* Variable to store unread notification messages
*
* @var array <int, Message>
*/
private array $msgs;
private int $notificationCount;
public function __construct(
private readonly EntityManagerInterface $entityManager,
private readonly UserPasswordHasherInterface $userPasswordHasher,
private array $navLinks = []
) {
$this->navLinks = NavList::LIST;
@ -26,17 +40,203 @@ 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);
$sups = $this->entityManager->getRepository(Supervision::class)->findBy(['supervisor' => $user]);
$staff = [];
foreach ($sups as $sup) {
$staff[] = $sup->getWorker();
}
return $this->render(
'internal/staff/staff-dashboard.html.twig',
array_merge(
$this->navLinks,
[
'staff' => $staff,
'breadcrumbs' => [
new Breadcrumb('', 'Staff Dashboard')
],
'notifications' => $user->retrieveUnreadNotifications(),
'notifications' => $this->msgs,
'notificationCount' => $this->notificationCount,
]
)
);
}
#[Route('/staff/my-cases', name:'app_staff_my_cases')]
public function staffMyCases(#[CurrentUser()] User $user): Response
{
$this->denyAccessUnlessGranted('IS_FULLY_AUTHENTICATED');
$this->msgs = $this->entityManager->getRepository(Messages::class)->getUnreadMessages($user);
$this->notificationCount = $this->entityManager->getRepository(Messages::class)->getUnreadMessageCount($user);
$ucs = $this->entityManager->getRepository(UserCase::class)->findBy(['user' => $user]);
$cases = [];
$this->navLinks['staff_dashboard'] = 'nav-link text-dark';
$this->navLinks['staff_notes'] = NavList::PRESENT_LINK;
foreach ($ucs as $uc) {
$cases[] = $uc->getMemberCase();
}
return $this->render(
'internal/staff/cases/my-cases.html.twig',
array_merge(
$this->navLinks,
[
'cases' => $cases,
'user' => $user,
'breadcrumbs' => [
new Breadcrumb($this->generateUrl('app_staff_dashboard'), 'Staff Dashboard'),
new Breadcrumb('', 'Staff Cases')
],
'notifications' => $this->msgs,
'notificationCount' => $this->notificationCount,
]
)
);
}
#[Route('/staff/{staffId}', name: 'app_staff_cases')]
public function staffCases(string $staffId, #[CurrentUser()] User $user): 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);
$staff = $this->entityManager->getRepository(User::class)->find($staffId);
$ucs = $this->entityManager->getRepository(UserCase::class)->findBy(['user' => $staff]);
$cases = [];
foreach ($ucs as $case) {
/** @var UserCase $case */
$cases[] = $case->getMemberCase();
}
return $this->render(
'internal/staff/cases/staff-cases.html.twig',
array_merge(
$this->navLinks,
[
'staffId' => $staffId,
'cases' => $cases,
'breadcrumbs' => [
new Breadcrumb($this->generateUrl('app_staff_dashboard'), 'Staff Dashboard'),
new Breadcrumb('', 'Staff Cases')
],
'notifications' => $this->msgs,
'notificationCount' => $this->notificationCount,
]
)
);
}
#[Route('/staff/{staffId}/case/{caseId}/list-notes', name: 'app_staff_list_notes')]
public function staffListNotes(string $staffId, string $caseId, #[CurrentUser()] User $user): Response
{
$this->denyAccessUnlessGranted('IS_FULLY_AUTHENTICATED');
$this->msgs = $this->entityManager->getRepository(Messages::class)->getUnreadMessages($user);
$this->notificationCount = $this->entityManager->getRepository(Messages::class)->getUnreadMessageCount($user);
$staff = $this->entityManager->getRepository(User::class)->find($staffId);
$case = $this->entityManager->getRepository(MemberCase::class)->find($caseId);
$staffNotes = $this->entityManager->getRepository(StaffNote::class)->findBy(['memberCase' => $case]);
return $this->render(
'internal/staff/notes/list-notes.html.twig',
array_merge(
$this->navLinks,
[
'staffId' => $staffId,
'staff' => $staff,
'case' => $case,
'staffNotes' => $staffNotes,
'breadcrumbs' => [
new Breadcrumb($this->generateUrl('app_staff_dashboard'), 'Staff Dashboard'),
new Breadcrumb(
$this->generateUrl(
($staffId == $user->getId()->toHex() ? 'app_staff_my_cases' : 'app_staff_cases'),
['staffId' => $staffId]
),
($staffId == $user->getId()->toHex() ? 'My Cases' : 'Staff Cases')
),
new Breadcrumb('', 'List Notes')
],
'notifications' => $this->msgs,
'notificationCount' => $this->notificationCount,
]
)
);
}
#[Route('/staff/add-note/{caseId}', name: 'app_staff_add_note')]
public function addNote(string $caseId, #[CurrentUser()] User $user, Request $request): Response
{
$this->denyAccessUnlessGranted('IS_FULLY_AUTHENTICATED');
$this->msgs = $this->entityManager->getRepository(Messages::class)->getUnreadMessages($user);
$this->notificationCount = $this->entityManager->getRepository(Messages::class)->getUnreadMessageCount($user);
$case = $this->entityManager->getRepository(MemberCase::class)->find($caseId);
$form = $this->createForm(StaffNoteFormType::class);
$this->navLinks['staff_dashboard'] = 'nav-link text-dark';
$this->navLinks['staff_notes'] = NavList::PRESENT_LINK;
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$note = $form->getData();
$note->setMemberCase($case);
$this->entityManager->persist($note);
$this->entityManager->flush();
return $this->redirectToRoute('app_staff_list_notes', ['staffId' => $user->getId()->toHex(), 'caseId' => $caseId]);
}
return $this->render(
'internal/staff/notes/add-note.html.twig',
array_merge(
$this->navLinks,
[
'case' => $case,
'form' => $form,
'breadcrumbs' => [
new Breadcrumb($this->generateUrl('app_staff_dashboard'), 'Staff Dashboard'),
new Breadcrumb($this->generateUrl('app_staff_list_notes', ['staffId' => $user->getId()->toHex(), 'caseId' => $caseId]), 'My Cases'),
new Breadcrumb('', 'Add Note'),
],
'notifications' => $this->msgs,
'notificationCount' => $this->notificationCount,
]
)
);
}
#[Route('/staff/edit-note/{noteId}', name: 'app_staff_edit_note')]
public function editNote(string $noteId, #[CurrentUser()] User $user, Request $request): Response
{
$this->denyAccessUnlessGranted('IS_FULLY_AUTHENTICATED');
$this->msgs = $this->entityManager->getRepository(Messages::class)->getUnreadMessages($user);
$this->notificationCount = $this->entityManager->getRepository(Messages::class)->getUnreadMessageCount($user);
$note = $this->entityManager->getRepository(StaffNote::class)->find($noteId);
$case = $note->getMemberCase();
$form = $this->createForm(StaffNoteFormType::class, $note);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$this->entityManager->flush();
$this->addFlash('info', 'Staff notes updated');
$this->redirectToRoute('app_staff_list_note', ['staffId' => $user->getId()->toHex(), 'caseId' => $case->getId()->toHex()]);
}
return new Response();
}
}

View File

@ -104,9 +104,8 @@ class CommunityResource
private array $type = [];
public function __construct(
private DateTime $today
private DateTime $today = new DateTime('now', new DateTimeZone('America/New_York'))
) {
$this->today = new DateTime('now', new DateTimeZone('America/New_York'));
}
public function getId(): ?Uuid

View File

@ -91,10 +91,31 @@ class MemberCase
#[ORM\OneToMany(targetEntity: Referral::class, mappedBy: 'memberCase', orphanRemoval: true)]
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()
{
$this->userCases = new ArrayCollection();
$this->referrals = new ArrayCollection();
$this->monthlyCaseNotes = new ArrayCollection();
$this->members = new ArrayCollection();
$this->staffNotes = new ArrayCollection();
}
public function getId(): ?Uuid
@ -394,4 +415,94 @@ class MemberCase
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;
}
}

144
src/Entity/Messages.php Normal file
View File

@ -0,0 +1,144 @@
<?php
namespace App\Entity;
use App\Enums\MessageType;
use App\Repository\MessagesRepository;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Types\UuidType;
use Symfony\Component\Uid\Uuid;
#[ORM\Entity(repositoryClass: MessagesRepository::class)]
class Messages
{
#[ORM\Id]
#[ORM\Column(type: UuidType::NAME, unique: true)]
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
#[ORM\CustomIdGenerator(class: 'doctrine.uuid_generator')]
private ?Uuid $id = null;
#[ORM\Column]
private ?\DateTimeImmutable $sent = null;
#[ORM\Column(nullable: true)]
private ?\DateTimeImmutable $received = null;
#[ORM\ManyToOne]
#[ORM\JoinColumn(nullable: false)]
private ?User $recipient = null;
#[ORM\Column(enumType: MessageType::class)]
private ?MessageType $type = null;
#[ORM\Column(type: Types::TEXT)]
private ?string $message = null;
#[ORM\Column(length: 255)]
private ?string $title = null;
#[ORM\ManyToOne]
#[ORM\JoinColumn(nullable: false)]
private ?User $sender = null;
public function getId(): ?Uuid
{
return $this->id;
}
public function getSent(): ?\DateTimeImmutable
{
return $this->sent;
}
public function setSent(\DateTimeImmutable $sent): static
{
$this->sent = $sent;
return $this;
}
public function getReceived(): ?\DateTimeImmutable
{
return $this->received;
}
public function setReceived(?\DateTimeImmutable $received): static
{
$this->received = $received;
return $this;
}
public function getRecipient(): ?User
{
return $this->recipient;
}
public function setRecipient(?User $recipient): static
{
$this->recipient = $recipient;
return $this;
}
public function getType(): ?MessageType
{
return $this->type;
}
public function setType(MessageType $type): static
{
$this->type = $type;
return $this;
}
public function getMessage(): ?string
{
return $this->message;
}
public function setMessage(string $message): static
{
$this->message = $message;
return $this;
}
public function getTitle(): ?string
{
return $this->title;
}
public function setTitle(string $title): static
{
$this->title = $title;
return $this;
}
public function getSender(): ?User
{
return $this->sender;
}
public function setSender(?User $sender): static
{
$this->sender = $sender;
return $this;
}
public function toArray(): array
{
return [
'id' => $this->id->toHex(),
'title' => $this->title,
'sender' => $this->sender->getName(),
'type' => $this->type->name,
'date' => $this->sent,
'message' => $this->message
];
}
}

View File

@ -140,6 +140,13 @@ class Note
return $this;
}
public function setMembers(?array $members): static
{
$this->members = $members;
return $this;
}
public function getLocation(): ?NoteLocation
{
return $this->location;

101
src/Entity/StaffNote.php Normal file
View File

@ -0,0 +1,101 @@
<?php
namespace App\Entity;
use App\Enums\ReferralServiceType;
use App\Repository\StaffNoteRepository;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: StaffNoteRepository::class)]
class StaffNote
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(type: Types::DATE_MUTABLE)]
private ?\DateTimeInterface $date = null;
#[ORM\ManyToOne(inversedBy: 'staffNotes')]
#[ORM\JoinColumn(nullable: false)]
private ?MemberCase $memberCase = null;
#[ORM\Column(type: Types::SIMPLE_ARRAY, enumType: ReferralServiceType::class)]
private array $servicesProvided = [];
#[ORM\Column(type: Types::TEXT)]
private ?string $note = null;
#[ORM\Column(length: 500, nullable: true)]
private ?string $recommendations = null;
public function getId(): ?int
{
return $this->id;
}
public function getDate(): ?\DateTimeInterface
{
return $this->date;
}
public function setDate(\DateTimeInterface $date): static
{
$this->date = $date;
return $this;
}
public function getMemberCase(): ?MemberCase
{
return $this->memberCase;
}
public function setMemberCase(?MemberCase $memberCase): static
{
$this->memberCase = $memberCase;
return $this;
}
/**
* @return ReferralServiceType[]
*/
public function getServicesProvided(): array
{
return $this->servicesProvided;
}
public function setServicesProvided(array $servicesProvided): static
{
$this->servicesProvided = $servicesProvided;
return $this;
}
public function getNote(): ?string
{
return $this->note;
}
public function setNote(string $note): static
{
$this->note = $note;
return $this;
}
public function getRecommendations(): ?string
{
return $this->recommendations;
}
public function setRecommendations(string $recommendations): static
{
$this->recommendations = $recommendations;
return $this;
}
}

17
src/Enums/MessageType.php Normal file
View File

@ -0,0 +1,17 @@
<?php
namespace App\Enums;
enum MessageType: int
{
case GENERAL = 0;
case CASE = 1;
case STAFFING = 2;
case BILLING = 3;
case NEW_CASE = 4;
case USER = 5;
case NEW_REFERRAL = 6;
case CALENDAR = 97;
case REMINDER = 98;
case UNKNOWN = 99;
}

View File

@ -0,0 +1,124 @@
<?php
namespace App\Factory;
use App\Entity\MemberCase;
use App\Entity\Messages;
use App\Entity\User;
use App\Enums\MessageType;
use DateTimeImmutable;
class MessageFactory
{
public static function createGeneral(User $sender, User $recipient, string $title, string $message): Messages
{
$msg = new Messages();
$msg->setSent(new DateTimeImmutable())
->setType(MessageType::GENERAL)
->setSender($sender)
->setRecipient($recipient)
->setMessage($message)
->setTitle($title)
;
return $msg;
}
public static function createCase(User $sender, User $recipient): Messages
{
$msg = new Messages();
$msg->setSent(new DateTimeImmutable())
->setType(MessageType::CASE)
->setSender($sender)
->setRecipient($recipient)
->setTitle('Case')
->setMessage("{$sender->getName()} has updated a case")
;
return $msg;
}
public static function createNewCase(User $sender, User $recipient): Messages
{
$msg = new Messages();
$msg->setSent(new DateTimeImmutable())
->setType(MessageType::NEW_CASE)
->setSender($sender)
->setRecipient($recipient)
->setTitle('New Case')
->setMessage("You've been assigned a new case")
;
return $msg;
}
public static function createStaffing(User $sender, User $recipient): Messages
{
$msg = new Messages();
$msg->setSent(new DateTimeImmutable())
->setType(MessageType::STAFFING)
->setSender($sender)
->setRecipient($recipient)
->setTitle('Staff Notes')
->setMessage("Staff notes from {$sender->getName()} are ready for your review")
;
return $msg;
}
public static function createBilling(User $sender, User $recipient): Messages
{
$msg = new Messages();
$msg->setSent(new DateTimeImmutable())
->setType(MessageType::BILLING)
->setSender($sender)
->setRecipient($recipient)
->setTitle('New Billing')
->setMessage("{$sender->getName()} has published their timesheet")
;
return $msg;
}
public static function createReminder(User $sender, User $recipient, string $title, string $message): Messages
{
$msg = new Messages();
$msg->setSent(new DateTimeImmutable())
->setType(MessageType::REMINDER)
->setSender($sender)
->setRecipient($recipient)
->setTitle($title)
->setMessage($message)
;
return $msg;
}
public static function createUser(User $sender, User $recipient, string $title, string $message): Messages
{
$msg = new Messages();
$msg->setSent(new DateTimeImmutable())
->setType(MessageType::USER)
->setSender($sender)
->setRecipient($recipient)
->setTitle($title)
->setMessage($message)
;
return $msg;
}
public static function createReferral(User $sender, User $recipient, MemberCase $case): Messages
{
$msg = new Messages();
$msg->setSender($sender)
->setRecipient($recipient)
->setSent(new DateTimeImmutable())
->setType(MessageType::NEW_REFERRAL)
->setTitle('New Referral')
->setMessage("A referral has been added/updated to case {$case->getCaseName()}")
;
return $msg;
}
}

View File

@ -4,6 +4,7 @@ namespace App\Form;
use App\Entity\CommunityResource;
use App\Enums\County;
use App\Enums\ResourceType;
use App\Enums\State;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
@ -83,6 +84,12 @@ class ResourceFormType extends AbstractType
'widget' => 'single_text',
])
->add('notes')
->add('type', EnumType::class, [
'class' => ResourceType::class,
'expanded' => true,
'multiple' => true,
])
->add('servicesAvailable')
;
}

View File

@ -0,0 +1,38 @@
<?php
namespace App\Form;
use App\Entity\Member;
use App\Entity\StaffNote;
use App\Enums\ReferralServiceType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\EnumType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class StaffNoteFormType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('date', null, [
'widget' => 'single_text',
])
->add('servicesProvided', EnumType::class, [
'class' => ReferralServiceType::class,
'expanded' => true,
'multiple' => true,
])
->add('note', TextareaType::class)
->add('recommendations')
;
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => StaffNote::class,
]);
}
}

View File

@ -16,6 +16,7 @@ class NavList
'case_notes' => 'nav-link text-dark',
'community_resource' => 'nav-link text-dark',
'my_cases' => 'nav-link text-dark',
'staff_notes' => 'nav-link text-dark',
];
public const PRESENT_LINK = 'nav-link text-white active bg-gradient-dark';

View File

@ -0,0 +1,73 @@
<?php
namespace App\Repository;
use App\Entity\Messages;
use App\Entity\User;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
/**
* @extends ServiceEntityRepository<Messages>
*/
class MessagesRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, Messages::class);
}
public function getUnreadMessages(User $user): array
{
$query = $this->createQueryBuilder('m')
->andWhere('m.recipient = :recipient')
->andWhere('m.received IS NULL')
->setParameter('recipient', $user->getId()->toBinary())
->orderBy('m.sent', 'ASC')
->setMaxResults(5)
->getQuery()
->getResult()
;
return $query;
}
public function getUnreadMessageCount(User $user): int
{
$query = $this->createQueryBuilder('m')
->andWhere('m.recipient = :recipient')
->andWhere('m.received IS NULL')
->setParameter('recipient', $user->getId()->toBinary())
->select('COUNT(m)')
->getQuery()
->getSingleScalarResult()
;
return $query;
}
// /**
// * @return Messages[] Returns an array of Messages objects
// */
// public function findByExampleField($value): array
// {
// return $this->createQueryBuilder('m')
// ->andWhere('m.exampleField = :val')
// ->setParameter('val', $value)
// ->orderBy('m.id', 'ASC')
// ->setMaxResults(10)
// ->getQuery()
// ->getResult()
// ;
// }
// public function findOneBySomeField($value): ?Messages
// {
// return $this->createQueryBuilder('m')
// ->andWhere('m.exampleField = :val')
// ->setParameter('val', $value)
// ->getQuery()
// ->getOneOrNullResult()
// ;
// }
}

View File

@ -0,0 +1,43 @@
<?php
namespace App\Repository;
use App\Entity\StaffNote;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
/**
* @extends ServiceEntityRepository<StaffNote>
*/
class StaffNoteRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, StaffNote::class);
}
// /**
// * @return StaffNote[] Returns an array of StaffNote objects
// */
// public function findByExampleField($value): array
// {
// return $this->createQueryBuilder('s')
// ->andWhere('s.exampleField = :val')
// ->setParameter('val', $value)
// ->orderBy('s.id', 'ASC')
// ->setMaxResults(10)
// ->getQuery()
// ->getResult()
// ;
// }
// public function findOneBySomeField($value): ?StaffNote
// {
// return $this->createQueryBuilder('s')
// ->andWhere('s.exampleField = :val')
// ->setParameter('val', $value)
// ->getQuery()
// ->getOneOrNullResult()
// ;
// }
}

View File

@ -37,7 +37,6 @@
</div>
</div>
</div>
</div>
</div>
</main>

View File

@ -17,6 +17,7 @@
<div class="card card-plain">
<div class="card-header">
<h4 class="font-weight-bolder">Assign Case Worker</h4>
<p>{{ case.level.name|lower|capitalize }}</p>
</div>
<div class="card-body">
{{ form_start(form, {'attr': {'onsubmit': 'return validateAssignForm()'}}) }}
@ -38,7 +39,7 @@
<div class='input-group input-group-outline mb-3'>
<input type='checkbox' name='{{ field_name(form.overrideLevel) }}' id='user_form_levelOverride' value='1'/>&nbsp;&nbsp;
<label for='user_form_levelOverride'>Override Level</label>
<label for='user_form_levelOverride' id='levelOverride-label'>Override Level</label>
</div>
<div class="text-center">

View File

@ -73,7 +73,7 @@
{% endif %}
</td>
<td class='align-middle'>
<a href='{{ path('app_case_edit_member', {caseId: case.id, memberId: member.id}) }}' class='text-secondary font-weight-bold text-xs' data-toggle='tooltip' data-original-title='Edit Source'>
<a href='{{ path('app_case_edit_member', {caseId: case.id, memberId: member.id}) }}' title='Edit Member'>
<i class="material-symbols-rounded opacity-5">edit</i>
</a>
</td>

View File

@ -88,6 +88,10 @@
<label for='rsc_form_services' class='form-label'>Services Available</label>
<input type='text' name='{{ field_name(form.servicesAvailable) }}' id='rsc_form_services' class='form-control'/>
</div>
<div class='input-group input-group-outline mb-3'>
{{ form_row(form.type) }}
</div>
</div>
<div class='col'>
<div class='input-group input-group-outline mb-3'>

View File

@ -47,12 +47,21 @@
{% endif %}
{% if is_granted('ROLE_CASE_MANAGER') or is_granted('ROLE_ADMIN') %}
<li class="nav-item mt-3">
<h6 class="ps-4 ms-2 text-uppercase text-xs text-dark font-weight-bolder opacity-5">Staffing pages</h6>
</li>
<li class='nav-item'>
<a class='{{ staff_dashboard }}' href='{{ path('app_staff_dashboard') }}'>
<i class='material-symbols-rounded opacity-5'>dashboard</i>
<span class='nav-link-text ms-1'>Staff Dashboard</span>
</a>
</li>
<li class='nav-item'>
<a class='{{ staff_notes }}' href='{{ path('app_staff_my_cases') }}'>
<i class='material-symbols-rounded opacity-5'></i>
<span class='nav-link-text ms-1'>Staff My Cases</span>
</a>
</li>
{% endif %}
<li class="nav-item mt-3">
@ -88,7 +97,7 @@
<li class="nav-item">
<a class="{{ profile }}" href="{{ path('app_profile') }}">
<i class="material-symbols-rounded opacity-5">person</i>
<span class="nav-link-text ms-1">Profile</span>
<span class="nav-link-text ms-1">{{ app.user.name }}</span>
</a>
</li>
<li class='nav-item'>

View File

@ -6,7 +6,7 @@
<div class='ms-md-auto pe-md-3 d-flex align-items-left'>
{% for label, messages in app.flashes %}
{% for message in messages %}
<div class="flash-{{ label }}">
<div class="flash-{{ label }} bg-gradient-info text-white">
{{ message }}
</div>
{% endfor %}
@ -37,8 +37,9 @@
</li>
{% endif %}
<li class="nav-item dropdown pe-3 d-flex align-items-center" title="Notifications">
<a href="javascript:;" class="nav-link text-body p-0" id="dropdownMenuButton" data-bs-toggle="dropdown" aria-expanded="false">
<a href="javascript:;" class="nav-link text-body p-0 notification" id="dropdownMenuButton" data-bs-toggle="dropdown" aria-expanded="false">
<i class="material-symbols-rounded">notifications</i>
<span class='badge' {% if notificationCount == 0 %} style='display:none;' {% endif %}>{{ notificationCount }}</span>
</a>
<ul class="dropdown-menu dropdown-menu-end px-2 py-3 me-sm-n4" aria-labelledby="dropdownMenuButton">
{% for note in notifications %}
@ -51,12 +52,12 @@
<div class='d-flex flex-column justify-content-center'>
<h6 class='text-sm font-weight-normal mb-1'>
<span class='font-weight-bold'>{{ note.title }}</span>
{{ note.from }}
{{ note.sender.getName() }}
</h6>
<p>{{ note.message }}</p>
<p class='text-xs text-secondary mb-0'>
<i class='fa fa-clock me-1'></i>
{{ note.timestamp|format_datetime('short', 'short', timezone: 'America/Indiana/Indianapolis') }}
{{ note.sent|format_datetime('short', 'short', timezone: 'America/Indiana/Indianapolis') }}
</p>
</div>
</div>

View File

@ -0,0 +1,44 @@
{% extends 'base.html.twig' %}
{% block body %}
{{ block('nav', 'internal/libs/nav.html.twig') }}
<main class="main-content position-relative max-height-vh-100 h-100 border-radius-lg ">
{{ block('topnav', 'internal/libs/top-nav.html.twig') }}
<div class='container-fluid py-2'>
<div class='row'>
<div class='ms-3'>
<h3 class='mb-0 h4 font-weight-bolder'>My Cases</h3>
<p class='mb-4'></p>
</div>
{% for c in cases %}
<div class='col-xl-3 col-sm-6 mb-xl-0 mb-4'>
<div class='card'>
<div class='card-header p-2 ps-3'>
<div class='d-flex justify-content-between'>
<div>
<h4 class='mb-0'>{{ c.caseName }}</h4>
<p class='text-sm mb-0 text-capitalize'>
<a href='tel:'></a>
</p>
</div>
<div class="icon icon-md icon-shape bg-gradient-dark shadow-dark shadow text-center border-radius-lg">
<i class="material-symbols-rounded opacity-10">weekend</i>
</div>
</div>
</div>
<hr class='dark horizontal my-0'>
<div class='card-footer p-2 ps-3'>
<p class='mb-0 text-sm'>
<span class='text-info font-weight-bolder'>
<a href='{{ path('app_staff_list_notes', {staffId: user.id, caseId: c.id}) }}'>Staff Notes</a>
</span>
</p>
</div>
</div>
</div>
{% endfor %}
</div>
</div>
</main>
{% endblock %}

View File

@ -0,0 +1,44 @@
{% extends 'base.html.twig' %}
{% block body %}
{{ block('nav', 'internal/libs/nav.html.twig') }}
<main class="main-content position-relative max-height-vh-100 h-100 border-radius-lg ">
{{ block('topnav', 'internal/libs/top-nav.html.twig') }}
<div class='container-fluid py-2'>
<div class='row'>
<div class='ms-3'>
<h3 class='mb-0 h4 font-weight-bolder'>Staff Cases</h3>
<p class='mb-4'></p>
</div>
{% for c in cases %}
<div class='col-xl-3 col-sm-6 mb-xl-0 mb-4'>
<div class='card'>
<div class='card-header p-2 ps-3'>
<div class='d-flex justify-content-between'>
<div>
<h4 class='mb-0'>{{ c.caseName }}</h4>
<p class='text-sm mb-0 text-capitalize'>
<a href='tel:'></a>
</p>
</div>
<div class="icon icon-md icon-shape bg-gradient-dark shadow-dark shadow text-center border-radius-lg">
<i class="material-symbols-rounded opacity-10">weekend</i>
</div>
</div>
</div>
<hr class='dark horizontal my-0'>
<div class='card-footer p-2 ps-3'>
<p class='mb-0 text-sm'>
<span class='text-info font-weight-bolder'>
<a href='{{ path('app_staff_list_notes', {staffId: staffId, caseId: c.id}) }}'>Staff Notes</a>
</span>
</p>
</div>
</div>
</div>
{% endfor %}
</div>
</div>
</main>
{% endblock %}

View File

@ -0,0 +1,56 @@
{% extends 'base.html.twig' %}
{% block body %}
{{ block('nav', 'internal/libs/nav.html.twig') }}
<main class="main-content position-relative max-height-vh-100 h-100 border-radius-lg ">
{{ block('topnav', 'internal/libs/top-nav.html.twig') }}
<section>
<div class="card card-plain">
<div class="card-header">
<h4 class="font-weight-bolder">Case Info</h4>
<p class="mb-0"></p>
</div>
<div class="card-body">
<div class="container">
{{ form_errors(form) }}
{{ form_start(form) }}
<div class="row">
<div class='col'>
<div class='input-group input-group-outline mb-3'>
<label for='note_form_date'></label>
<input type='date' name='{{ field_name(form.date) }}' id='note_form_date' class='form-control'/>
</div>
<div class='input-group input-group-outline mb-3'>
{{ form_row(form.servicesProvided) }}
</div>
<div class='input-group input-group-outline mb-3'>
<label for='note_form_recommendation' class='form-label'>Recommendation</label>
<input type='text' name='{{ field_name(form.recommendations) }}' id='note_form_recommendation' class='form-control'/>
</div>
</div>
<div class='col'>
<div class='input-group input-group-outline mb-3'>
<textarea name='{{ field_name(form.note) }}' id='note_form_note' class='form-control' placeholder='Note' style='width:100%;height:200px;'></textarea>
</div>
</div>
</div>
<div class='row'>
<div class="text-center">
<button type="submit" class="btn btn-lg bg-gradient-dark btn-lg w-100 mt-4 mb-0">Save Staff Note</button>
</div>
</div>
{{ form_end(form) }}
</div>
</div>
</div>
</section>
</main>
{% endblock %}

View File

@ -0,0 +1,60 @@
{% extends 'base.html.twig' %}
{% block body %}
{{ block('nav', 'internal/libs/nav.html.twig') }}
<main class="main-content position-relative max-height-vh-100 h-100 border-radius-lg ">
{{ block('topnav', 'internal/libs/top-nav.html.twig') }}
<div class="container-fluid py-2">
<div class="row">
<div class="col-12">
<div class="card my-4">
<div class="card-header p-0 position-relative mt-n4 mx-3 z-index-2">
<div class="d-flex justify-content-between bg-gradient-dark shadow-dark border-radius-lg pt-4 pb-3 ps-3 p-2">
<div>
<h6 class="text-white text-capitalize ps-3">{{ case.caseName }}</h6>
</div>
{% if app.user.id == staffId %}
<div>
<button type="button" class="btn btn-block btn-light mb-3" onclick="window.open('{{ path('app_staff_add_note', {caseId: case.id}) }}', '_self')">Add Staff Note</button>
</div>
{% endif %}
</div>
</div>
<div class="card-body px-0 pb-2">
<div class="table-responsive p-0">
<table class="table align-items-center mb-0">
<thead>
<tr>
<th class="text-uppercase text-secondary text-xxs font-weight-bolder opacity-7">Date</th>
<th class="text-secondary opacity-7"></th>
</tr>
</thead>
<tbody id='case-list'>
{% for n in staffNotes %}
<tr>
<td>
<div class='d-flex px-2 py-1'>
<div class='d-flex flex-column justify-content-center'>
<h6 class='mb-0 text-small'>{{ n.date|date('F j, Y') }}</h6>
</div>
</div>
</td>
<td class='align-right'>
<a href='{{ path('app_staff_edit_note', {noteId: n.id}) }}' title='Edit Note'>
<i class='material-symbols-rounded opacity-5'>edit</i>
</a>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</main>
{% endblock %}

View File

@ -5,5 +5,40 @@
<main class="main-content position-relative max-height-vh-100 h-100 border-radius-lg ">
{{ block('topnav', 'internal/libs/top-nav.html.twig') }}
<div class='container-fluid py-2'>
<div class='row'>
<div class='ms-3'>
<h3 class='mb-0 h4 font-weight-bolder'>Staff Dashboard</h3>
<p class='mb-4'></p>
</div>
{% for s in staff %}
<div class='col-xl-3 col-sm-6 mb-xl-0 mb-4'>
<div class='card'>
<div class='card-header p-2 ps-3'>
<div class='d-flex justify-content-between'>
<div>
<h4 class='mb-0'>{{ s.name }}</h4>
<p class='text-sm mb-0 text-capitalize'>
<a href='tel:'></a>
</p>
</div>
<div class="icon icon-md icon-shape bg-gradient-dark shadow-dark shadow text-center border-radius-lg">
<i class="material-symbols-rounded opacity-10">weekend</i>
</div>
</div>
</div>
<hr class='dark horizontal my-0'>
<div class='card-footer p-2 ps-3'>
<p class='mb-0 text-sm'>
<span class='text-info font-weight-bolder'>
<a href='{{ path('app_staff_cases', {staffId: s.id}) }}'>Staff Cases</a>
</span>
</p>
</div>
</div>
</div>
{% endfor %}
</div>
</div>
</main>
{% endblock %}