Added messages, notifications, count, and supporting elements
This commit is contained in:
parent
2b8682bcbb
commit
6b61d1a182
@ -2,8 +2,10 @@
|
|||||||
|
|
||||||
namespace App\Controller;
|
namespace App\Controller;
|
||||||
|
|
||||||
|
use App\Entity\Messages;
|
||||||
use App\Entity\Supervision;
|
use App\Entity\Supervision;
|
||||||
use App\Entity\User;
|
use App\Entity\User;
|
||||||
|
use App\Factory\MessageFactory;
|
||||||
use App\Form\EditUserFormType;
|
use App\Form\EditUserFormType;
|
||||||
use App\Form\SupervisorFormType;
|
use App\Form\SupervisorFormType;
|
||||||
use App\Form\UserFormType;
|
use App\Form\UserFormType;
|
||||||
@ -22,6 +24,10 @@ use Symfony\Component\Security\Http\Attribute\IsGranted;
|
|||||||
#[IsGranted('ROLE_ADMIN')]
|
#[IsGranted('ROLE_ADMIN')]
|
||||||
class AdminController extends AbstractController
|
class AdminController extends AbstractController
|
||||||
{
|
{
|
||||||
|
private array $msgs;
|
||||||
|
|
||||||
|
private int $notificationCount = 0;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private readonly EntityManagerInterface $entityManager,
|
private readonly EntityManagerInterface $entityManager,
|
||||||
private readonly UserPasswordHasherInterface $userPasswordHasher,
|
private readonly UserPasswordHasherInterface $userPasswordHasher,
|
||||||
@ -35,6 +41,8 @@ class AdminController extends AbstractController
|
|||||||
{
|
{
|
||||||
$this->denyAccessUnlessGranted('ROLE_ADMIN');
|
$this->denyAccessUnlessGranted('ROLE_ADMIN');
|
||||||
$this->navLinks['admin_dashboard'] = NavList::PRESENT_LINK;
|
$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(
|
return $this->render(
|
||||||
'internal/admin/admin-dashboard.html.twig',
|
'internal/admin/admin-dashboard.html.twig',
|
||||||
@ -44,7 +52,8 @@ class AdminController extends AbstractController
|
|||||||
'breadcrumbs' => [
|
'breadcrumbs' => [
|
||||||
new Breadcrumb($this->generateUrl('app_admin_dashboard'), 'Admin Dashboard')
|
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
|
public function listUsers(#[CurrentUser()] User $user): Response
|
||||||
{
|
{
|
||||||
$this->denyAccessUnlessGranted('ROLE_ADMIN');
|
$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 */
|
/** @var UserRepository $repo */
|
||||||
$repo = $this->entityManager->getRepository(User::class);
|
$repo = $this->entityManager->getRepository(User::class);
|
||||||
@ -77,7 +88,8 @@ class AdminController extends AbstractController
|
|||||||
new Breadcrumb($this->generateUrl('app_list_users'), 'List Users')
|
new Breadcrumb($this->generateUrl('app_list_users'), 'List Users')
|
||||||
],
|
],
|
||||||
'users' => $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
|
public function addUser(Request $request, #[CurrentUser()] User $admin): Response
|
||||||
{
|
{
|
||||||
$this->denyAccessUnlessGranted('ROLE_ADMIN');
|
$this->denyAccessUnlessGranted('ROLE_ADMIN');
|
||||||
|
$this->msgs = $this->entityManager->getRepository(Messages::class)->getUnreadMessages($admin);
|
||||||
|
$this->notificationCount = $this->entityManager->getRepository(Messages::class)->getUnreadMessageCount($admin);
|
||||||
|
|
||||||
$user = new User();
|
$user = new User();
|
||||||
$form = $this->createForm(UserFormType::class, $user);
|
$form = $this->createForm(UserFormType::class, $user);
|
||||||
@ -128,6 +142,10 @@ class AdminController extends AbstractController
|
|||||||
->setLevel($form->get('level')->getData())
|
->setLevel($form->get('level')->getData())
|
||||||
->setCompany($admin->getCompany());
|
->setCompany($admin->getCompany());
|
||||||
|
|
||||||
|
|
||||||
|
$msg = MessageFactory::createUser($admin, $user, 'Welcome', "Welcome to CM Tracker");
|
||||||
|
|
||||||
|
$this->entityManager->persist($msg);
|
||||||
$this->entityManager->persist($user);
|
$this->entityManager->persist($user);
|
||||||
$this->entityManager->flush();
|
$this->entityManager->flush();
|
||||||
|
|
||||||
@ -148,7 +166,8 @@ class AdminController extends AbstractController
|
|||||||
new Breadcrumb($this->generateUrl('app_add_user'), 'Add User')
|
new Breadcrumb($this->generateUrl('app_add_user'), 'Add User')
|
||||||
],
|
],
|
||||||
'form' => $form,
|
'form' => $form,
|
||||||
'notifications' => $admin->retrieveUnreadNotifications(),
|
'notifications' => $this->msgs,
|
||||||
|
'notificationCount' => $this->notificationCount,
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@ -159,6 +178,8 @@ class AdminController extends AbstractController
|
|||||||
{
|
{
|
||||||
/** @var UserRepository $userRepo */
|
/** @var UserRepository $userRepo */
|
||||||
$userRepo = $this->entityManager->getRepository(User::class);
|
$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 */
|
/** @var User $user */
|
||||||
$user = $userRepo->find($id);
|
$user = $userRepo->find($id);
|
||||||
@ -195,7 +216,8 @@ class AdminController extends AbstractController
|
|||||||
],
|
],
|
||||||
'data' => $user,
|
'data' => $user,
|
||||||
'form' => $form,
|
'form' => $form,
|
||||||
'notifications' => $admin->retrieveUnreadNotifications(),
|
'notifications' => $this->msgs,
|
||||||
|
'notificationCount' => $this->notificationCount,
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@ -206,6 +228,8 @@ class AdminController extends AbstractController
|
|||||||
{
|
{
|
||||||
/** @var UserRepository $userRepo */
|
/** @var UserRepository $userRepo */
|
||||||
$userRepo = $this->entityManager->getRepository(User::class);
|
$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 */
|
/** @var User $user */
|
||||||
$user = $userRepo->find($id);
|
$user = $userRepo->find($id);
|
||||||
@ -226,7 +250,12 @@ class AdminController extends AbstractController
|
|||||||
$sup->setSupervisor($supervisor);
|
$sup->setSupervisor($supervisor);
|
||||||
$sup->setWorker($user);
|
$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($sup);
|
||||||
|
$this->entityManager->persist($userMsg);
|
||||||
|
$this->entityManager->persist($supMsg);
|
||||||
$this->entityManager->flush();
|
$this->entityManager->flush();
|
||||||
|
|
||||||
return $this->redirectToRoute('app_list_users');
|
return $this->redirectToRoute('app_list_users');
|
||||||
@ -244,7 +273,8 @@ class AdminController extends AbstractController
|
|||||||
'user' => $user,
|
'user' => $user,
|
||||||
'form' => $form,
|
'form' => $form,
|
||||||
'supervisors' => $userRepo->getCaseManagers($admin->getCompany()),
|
'supervisors' => $userRepo->getCaseManagers($admin->getCompany()),
|
||||||
'notifications' => $admin->retrieveUnreadNotifications(),
|
'notifications' => $this->msgs,
|
||||||
|
'notificationCount' => $this->notificationCount,
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
namespace App\Controller;
|
namespace App\Controller;
|
||||||
|
|
||||||
use App\Entity\CommunityResource;
|
use App\Entity\CommunityResource;
|
||||||
|
use App\Entity\Messages;
|
||||||
use App\Entity\User;
|
use App\Entity\User;
|
||||||
use App\Form\ResourceFormType;
|
use App\Form\ResourceFormType;
|
||||||
use App\Libs\Breadcrumb;
|
use App\Libs\Breadcrumb;
|
||||||
@ -17,6 +18,15 @@ use Symfony\Component\Validator\Constraints\Regex;
|
|||||||
|
|
||||||
class CommunityResourceController extends AbstractController
|
class CommunityResourceController extends AbstractController
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Variable to store unread notification messages
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
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 = []
|
||||||
@ -29,6 +39,8 @@ 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->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',
|
||||||
@ -39,7 +51,8 @@ class CommunityResourceController extends AbstractController
|
|||||||
new Breadcrumb('#', 'Community Resources')
|
new Breadcrumb('#', 'Community Resources')
|
||||||
],
|
],
|
||||||
'resources' => $rsc,
|
'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')]
|
#[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->notificationCount = $this->entityManager->getRepository(Messages::class)->getUnreadMessageCount($user);
|
||||||
|
|
||||||
$form = $this->createForm(ResourceFormType::class);
|
$form = $this->createForm(ResourceFormType::class);
|
||||||
$form->handleRequest($request);
|
$form->handleRequest($request);
|
||||||
|
|
||||||
@ -63,6 +79,8 @@ class CommunityResourceController extends AbstractController
|
|||||||
$this->entityManager->persist($rsc);
|
$this->entityManager->persist($rsc);
|
||||||
$this->entityManager->flush();
|
$this->entityManager->flush();
|
||||||
|
|
||||||
|
$this->addFlash('success', 'Resource added successfully');
|
||||||
|
|
||||||
return $this->redirectToRoute('app_community_resource');
|
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($this->generateUrl('app_community_resource'), 'List Resources'),
|
||||||
new Breadcrumb('#', 'Add Resource')
|
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')]
|
#[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->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);
|
||||||
|
|
||||||
@ -94,6 +116,8 @@ class CommunityResourceController extends AbstractController
|
|||||||
if ($form->isSubmitted() && $form->isValid()) {
|
if ($form->isSubmitted() && $form->isValid()) {
|
||||||
$this->entityManager->flush();
|
$this->entityManager->flush();
|
||||||
|
|
||||||
|
$this->addFlash('success', 'Resource updated successfully');
|
||||||
|
|
||||||
return $this->redirectToRoute('app_community_resource');
|
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($this->generateUrl('app_community_resource'), 'List Resources'),
|
||||||
new Breadcrumb('#', 'Edit Resource')
|
new Breadcrumb('#', 'Edit Resource')
|
||||||
],
|
],
|
||||||
'notifications' => $user->retrieveUnreadNotifications(),
|
'notifications' => $this->msgs,
|
||||||
|
'notificationCount' => $this->notificationCount,
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
@ -2,7 +2,9 @@
|
|||||||
|
|
||||||
namespace App\Controller;
|
namespace App\Controller;
|
||||||
|
|
||||||
|
use App\Entity\Messages;
|
||||||
use App\Entity\User;
|
use App\Entity\User;
|
||||||
|
use App\Libs\Breadcrumb;
|
||||||
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;
|
||||||
@ -14,6 +16,14 @@ use Symfony\Component\Security\Http\Attribute\CurrentUser;
|
|||||||
|
|
||||||
class DefaultController extends AbstractController
|
class DefaultController extends AbstractController
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Variable to store unread notification messages
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
private array $msgs;
|
||||||
|
|
||||||
|
private int $notificationCount = 0;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private readonly EntityManagerInterface $entityManager,
|
private readonly EntityManagerInterface $entityManager,
|
||||||
@ -27,6 +37,8 @@ class DefaultController extends AbstractController
|
|||||||
public function dashboard(Request $request, #[CurrentUser()] ?User $user): Response
|
public function dashboard(Request $request, #[CurrentUser()] ?User $user): Response
|
||||||
{
|
{
|
||||||
$this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY');
|
$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()) {
|
if (!$user->getCompany()) {
|
||||||
return $this->redirectToRoute('app_register_step', ['step' => RegistrationController::REGISTER_STEP_TWO]);
|
return $this->redirectToRoute('app_register_step', ['step' => RegistrationController::REGISTER_STEP_TWO]);
|
||||||
@ -40,9 +52,10 @@ class DefaultController extends AbstractController
|
|||||||
$this->navLinks,
|
$this->navLinks,
|
||||||
[
|
[
|
||||||
'breadcrumbs' => [
|
'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
|
public function profile(#[CurrentUser()] User $user): Response
|
||||||
{
|
{
|
||||||
$this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY');
|
$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;
|
$this->navLinks['profile'] = NavList::PRESENT_LINK;
|
||||||
|
|
||||||
@ -61,9 +76,10 @@ class DefaultController extends AbstractController
|
|||||||
$this->navLinks,
|
$this->navLinks,
|
||||||
[
|
[
|
||||||
'breadcrumbs' => [
|
'breadcrumbs' => [
|
||||||
'Profile'
|
new Breadcrumb('', 'Profile')
|
||||||
],
|
],
|
||||||
'notifications' => $user->retrieveUnreadNotifications(),
|
'notifications' => $this->msgs,
|
||||||
|
'notificationCount' => $this->notificationCount,
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
@ -5,6 +5,7 @@ namespace App\Controller;
|
|||||||
use App\Entity\Member;
|
use App\Entity\Member;
|
||||||
use App\Entity\User;
|
use App\Entity\User;
|
||||||
use App\Entity\MemberCase;
|
use App\Entity\MemberCase;
|
||||||
|
use App\Entity\Messages;
|
||||||
use App\Form\MemberFormType;
|
use App\Form\MemberFormType;
|
||||||
use App\Libs\Breadcrumb;
|
use App\Libs\Breadcrumb;
|
||||||
use App\Libs\NavList;
|
use App\Libs\NavList;
|
||||||
@ -17,6 +18,15 @@ use Symfony\Component\Security\Http\Attribute\CurrentUser;
|
|||||||
|
|
||||||
class MemberController extends AbstractController
|
class MemberController extends AbstractController
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Variable to store unread notification messages
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
private array $msgs;
|
||||||
|
|
||||||
|
private int $notificationCount;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private EntityManagerInterface $entityManager,
|
private EntityManagerInterface $entityManager,
|
||||||
private array $navLinks = [],
|
private array $navLinks = [],
|
||||||
@ -28,6 +38,9 @@ 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->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);
|
||||||
|
|
||||||
@ -40,9 +53,10 @@ class MemberController extends AbstractController
|
|||||||
new Breadcrumb($this->generateUrl('app_list_cases'), 'List Cases'),
|
new Breadcrumb($this->generateUrl('app_list_cases'), 'List Cases'),
|
||||||
new Breadcrumb($this->generateUrl('app_case_members', ['id' => $id]), 'List Members'),
|
new Breadcrumb($this->generateUrl('app_case_members', ['id' => $id]), 'List Members'),
|
||||||
],
|
],
|
||||||
'notifications' => $user->retrieveUnreadNotifications(),
|
'notifications' => $this->msgs,
|
||||||
'case' => $case,
|
'case' => $case,
|
||||||
'members' => $members,
|
'members' => $members,
|
||||||
|
'notificationCount' => $this->notificationCount,
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@ -51,6 +65,9 @@ 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->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);
|
||||||
|
|
||||||
@ -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_members', ['id' => $id]), 'List Members'),
|
||||||
new Breadcrumb($this->generateUrl('app_case_add_member', ['id' => $id]), 'Add Member'),
|
new Breadcrumb($this->generateUrl('app_case_add_member', ['id' => $id]), 'Add Member'),
|
||||||
],
|
],
|
||||||
'notifications' => $user->retrieveUnreadNotifications(),
|
'notifications' => $this->msgs,
|
||||||
'case' => $case,
|
'case' => $case,
|
||||||
'form' => $form->createView(),
|
'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')]
|
#[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->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);
|
||||||
@ -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_members', ['id' => $caseId]), 'List Members'),
|
||||||
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' => $user->retrieveUnreadNotifications(),
|
'notifications' => $this->msgs,
|
||||||
|
'notificationCount' => $this->notificationCount,
|
||||||
'member' => $member,
|
'member' => $member,
|
||||||
'form' => $form->createView(),
|
'form' => $form->createView(),
|
||||||
'caseId' => $caseId,
|
'caseId' => $caseId,
|
||||||
|
30
src/Controller/MessageController.php
Normal file
30
src/Controller/MessageController.php
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
@ -3,6 +3,7 @@
|
|||||||
namespace App\Controller;
|
namespace App\Controller;
|
||||||
|
|
||||||
use App\Entity\Member;
|
use App\Entity\Member;
|
||||||
|
use App\Entity\Messages;
|
||||||
use App\Entity\Referral;
|
use App\Entity\Referral;
|
||||||
use App\Entity\StandardNote;
|
use App\Entity\StandardNote;
|
||||||
use App\Entity\User;
|
use App\Entity\User;
|
||||||
@ -24,6 +25,15 @@ use Symfony\Component\Security\Http\Attribute\CurrentUser;
|
|||||||
|
|
||||||
class NoteController extends AbstractController
|
class NoteController extends AbstractController
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Variable to store unread notification messages
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
private array $msgs;
|
||||||
|
|
||||||
|
private int $notificationCount;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private EntityManagerInterface $entityManager,
|
private EntityManagerInterface $entityManager,
|
||||||
private array $navLinks = [],
|
private array $navLinks = [],
|
||||||
@ -35,6 +45,9 @@ class NoteController extends AbstractController
|
|||||||
#[Route('/list-notes/{id?null}', name: 'app_list_notes')]
|
#[Route('/list-notes/{id?null}', name: 'app_list_notes')]
|
||||||
public function listNotes(#[CurrentUser()] User $user, ?string $id = null): Response
|
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 */
|
/** @var UserCase[] $cases */
|
||||||
$cases = $this->entityManager->getRepository(UserCase::class)->findBy(['user' => $user]);
|
$cases = $this->entityManager->getRepository(UserCase::class)->findBy(['user' => $user]);
|
||||||
$referrals = [];
|
$referrals = [];
|
||||||
@ -71,9 +84,10 @@ class NoteController extends AbstractController
|
|||||||
'breadcrumbs' => [
|
'breadcrumbs' => [
|
||||||
new Breadcrumb($this->generateUrl('app_list_notes'), 'List Notes')
|
new Breadcrumb($this->generateUrl('app_list_notes'), 'List Notes')
|
||||||
],
|
],
|
||||||
'notifications' => $user->retrieveUnreadNotifications(),
|
'notifications' => $this->msgs,
|
||||||
'cases' => $cases,
|
'cases' => $cases,
|
||||||
'notes' => $notes,
|
'notes' => $notes,
|
||||||
|
'notificationCount' => $this->notificationCount,
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@ -85,8 +99,8 @@ class NoteController extends AbstractController
|
|||||||
/** @var Referral $referral */
|
/** @var Referral $referral */
|
||||||
$referral = $this->entityManager->getRepository(Referral::class)->find($id);
|
$referral = $this->entityManager->getRepository(Referral::class)->find($id);
|
||||||
$this->entityManager->getRepository(Referral::class)->populateNotes($referral);
|
$this->entityManager->getRepository(Referral::class)->populateNotes($referral);
|
||||||
|
$this->msgs = $this->entityManager->getRepository(Messages::class)->getUnreadMessages($user);
|
||||||
//dd($referral);
|
$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;
|
||||||
@ -128,23 +142,31 @@ class NoteController extends AbstractController
|
|||||||
'breadcrumbs' => [
|
'breadcrumbs' => [
|
||||||
new Breadcrumb($this->generateUrl('app_list_notes'), 'List Notes')
|
new Breadcrumb($this->generateUrl('app_list_notes'), 'List Notes')
|
||||||
],
|
],
|
||||||
'notifications' => $user->retrieveUnreadNotifications(),
|
'notifications' => $this->msgs,
|
||||||
'referral' => $referral,
|
'referral' => $referral,
|
||||||
'form' => $form,
|
'form' => $form,
|
||||||
'default_method' => $defaultMethod,
|
'default_method' => $defaultMethod,
|
||||||
'default_location' => $defaultLocation,
|
'default_location' => $defaultLocation,
|
||||||
|
'notificationCount' => $this->notificationCount,
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Route('/edit-note', name: 'app_edit_note')]
|
#[Route('/edit-note/{noteId}', name: 'app_edit_note')]
|
||||||
public function editNote(): Response
|
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(
|
return $this->render(
|
||||||
'internal/cases/notes/edit-note.html.twig',
|
'internal/cases/notes/edit-note.html.twig',
|
||||||
array_merge(
|
array_merge(
|
||||||
$this->navLinks,
|
$this->navLinks,
|
||||||
|
[
|
||||||
|
'notifications' => $this->msgs,
|
||||||
|
'notificationCount' => $this->notificationCount,
|
||||||
|
]
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -3,8 +3,11 @@
|
|||||||
namespace App\Controller;
|
namespace App\Controller;
|
||||||
|
|
||||||
use App\Entity\MemberCase;
|
use App\Entity\MemberCase;
|
||||||
|
use App\Entity\Messages;
|
||||||
use App\Entity\Referral;
|
use App\Entity\Referral;
|
||||||
use App\Entity\User;
|
use App\Entity\User;
|
||||||
|
use App\Entity\UserCase;
|
||||||
|
use App\Factory\MessageFactory;
|
||||||
use App\Form\ReferralFormType;
|
use App\Form\ReferralFormType;
|
||||||
use App\Libs\Breadcrumb;
|
use App\Libs\Breadcrumb;
|
||||||
use App\Libs\NavList;
|
use App\Libs\NavList;
|
||||||
@ -17,6 +20,15 @@ use Symfony\Component\Security\Http\Attribute\CurrentUser;
|
|||||||
|
|
||||||
class ReferralController extends AbstractController
|
class ReferralController extends AbstractController
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Variable to store unread notification messages
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
private array $msgs;
|
||||||
|
|
||||||
|
private int $notificationCount;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private EntityManagerInterface $entityManager,
|
private EntityManagerInterface $entityManager,
|
||||||
private array $navLinks = []
|
private array $navLinks = []
|
||||||
@ -26,8 +38,11 @@ class ReferralController extends AbstractController
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[Route('/list-referrals/{id}', name: 'app_list_referrals')]
|
#[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);
|
$case = $this->entityManager->getRepository(MemberCase::class)->find($id);
|
||||||
$openReferrals = $this->entityManager->getRepository(Referral::class)->getActiveReferrals($case);
|
$openReferrals = $this->entityManager->getRepository(Referral::class)->getActiveReferrals($case);
|
||||||
$closedReferrals = $this->entityManager->getRepository(Referral::class)->getClosedReferrals($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_cases'), 'List Cases'),
|
||||||
new Breadcrumb($this->generateUrl('app_list_referrals', ['id' => $case->getId()]), 'Referrals'),
|
new Breadcrumb($this->generateUrl('app_list_referrals', ['id' => $case->getId()]), 'Referrals'),
|
||||||
],
|
],
|
||||||
'notifications' => $user->retrieveUnreadNotifications(),
|
'notifications' => $this->msgs,
|
||||||
|
'notificationCount' => $this->notificationCount,
|
||||||
'case' => $case,
|
'case' => $case,
|
||||||
'openReferrals' => $openReferrals,
|
'openReferrals' => $openReferrals,
|
||||||
'closedReferrals' => $closedReferrals,
|
'closedReferrals' => $closedReferrals,
|
||||||
@ -53,7 +69,13 @@ class ReferralController extends AbstractController
|
|||||||
#[Route('/add-referral/{id}', name: 'app_case_add_referral')]
|
#[Route('/add-referral/{id}', name: 'app_case_add_referral')]
|
||||||
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->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);
|
$case = $this->entityManager->getRepository(MemberCase::class)->find($id);
|
||||||
|
/** @var UserCase $uc */
|
||||||
|
$uc = $this->entityManager->getRepository(UserCase::class)->findBy(['memberCase' => $case]);
|
||||||
|
|
||||||
$referral = new Referral();
|
$referral = new Referral();
|
||||||
$form = $this->createForm(ReferralFormType::class, $referral);
|
$form = $this->createForm(ReferralFormType::class, $referral);
|
||||||
@ -64,6 +86,9 @@ class ReferralController extends AbstractController
|
|||||||
$referral = $form->getData();
|
$referral = $form->getData();
|
||||||
$referral->setMemberCase($case);
|
$referral->setMemberCase($case);
|
||||||
|
|
||||||
|
$msg = MessageFactory::createReferral($user, $uc->getUser(), $case);
|
||||||
|
|
||||||
|
$this->entityManager->persist($msg);
|
||||||
$this->entityManager->persist($referral);
|
$this->entityManager->persist($referral);
|
||||||
$this->entityManager->flush();
|
$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_list_referrals', ['id' => $case->getId()]), 'Referrals'),
|
||||||
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' => $user->retrieveUnreadNotifications(),
|
'notifications' => $this->msgs,
|
||||||
|
'notificationCount' => $this->notificationCount,
|
||||||
'case' => $case,
|
'case' => $case,
|
||||||
'form' => $form,
|
'form' => $form,
|
||||||
]
|
]
|
||||||
@ -91,8 +117,14 @@ class ReferralController extends AbstractController
|
|||||||
#[Route('/case/{caseId}/edit-referral/{referralId}', name: 'app_case_edit_referral')]
|
#[Route('/case/{caseId}/edit-referral/{referralId}', name: 'app_case_edit_referral')]
|
||||||
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->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);
|
$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 */
|
||||||
|
$uc = $this->entityManager->getRepository(UserCase::class)->findBy(['case' => $case]);
|
||||||
|
|
||||||
$form = $this->createForm(ReferralFormType::class, $referral);
|
$form = $this->createForm(ReferralFormType::class, $referral);
|
||||||
$form->handleRequest($request);
|
$form->handleRequest($request);
|
||||||
@ -100,6 +132,9 @@ class ReferralController extends AbstractController
|
|||||||
if ($form->isSubmitted() && $form->isValid()) {
|
if ($form->isSubmitted() && $form->isValid()) {
|
||||||
$referral = $form->getData();
|
$referral = $form->getData();
|
||||||
|
|
||||||
|
$msg = MessageFactory::createReferral($user, $uc->getUser(), $case);
|
||||||
|
|
||||||
|
$this->entityManager->persist($msg);
|
||||||
$this->entityManager->flush();
|
$this->entityManager->flush();
|
||||||
|
|
||||||
return $this->redirectToRoute('app_list_referrals', ['id' => $case->getId()]);
|
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_list_referrals', ['id' => $case->getId()]), 'Referrals'),
|
||||||
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' => $user->retrieveUnreadNotifications(),
|
'notifications' => $this->msgs,
|
||||||
|
'notificationCount' => $this->notificationCount,
|
||||||
'case' => $case,
|
'case' => $case,
|
||||||
'form' => $form,
|
'form' => $form,
|
||||||
'referral' => $referral,
|
'referral' => $referral,
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Controller;
|
namespace App\Controller;
|
||||||
|
|
||||||
|
use App\Entity\Messages;
|
||||||
use App\Entity\ReferralSource;
|
use App\Entity\ReferralSource;
|
||||||
use App\Entity\User;
|
use App\Entity\User;
|
||||||
use App\Form\ReferralSourceFormType;
|
use App\Form\ReferralSourceFormType;
|
||||||
@ -16,6 +17,15 @@ use Symfony\Component\Security\Http\Attribute\CurrentUser;
|
|||||||
|
|
||||||
class ReferralSourceController extends AbstractController
|
class ReferralSourceController extends AbstractController
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Variable to store unread notification messages
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
private array $msgs;
|
||||||
|
|
||||||
|
private int $notificationCount;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private EntityManagerInterface $entityManager,
|
private EntityManagerInterface $entityManager,
|
||||||
private array $navList = []
|
private array $navList = []
|
||||||
@ -28,6 +38,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->notificationCount = $this->entityManager->getRepository(Messages::class)->getUnreadMessageCount($user);
|
||||||
|
|
||||||
$sources = $this->entityManager->getRepository(ReferralSource::class)->retrieveOrderedList();
|
$sources = $this->entityManager->getRepository(ReferralSource::class)->retrieveOrderedList();
|
||||||
|
|
||||||
@ -37,7 +49,8 @@ class ReferralSourceController extends AbstractController
|
|||||||
$this->navList,
|
$this->navList,
|
||||||
[
|
[
|
||||||
'sources' => $sources,
|
'sources' => $sources,
|
||||||
'notifications' => $user->retrieveUnreadNotifications(),
|
'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')
|
||||||
]
|
]
|
||||||
@ -50,6 +63,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->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);
|
||||||
@ -73,7 +88,8 @@ class ReferralSourceController extends AbstractController
|
|||||||
$this->navList,
|
$this->navList,
|
||||||
[
|
[
|
||||||
'form' => $form,
|
'form' => $form,
|
||||||
'notifications' => $user->retrieveUnreadNotifications(),
|
'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')
|
||||||
@ -87,6 +103,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->notificationCount = $this->entityManager->getRepository(Messages::class)->getUnreadMessageCount($user);
|
||||||
|
|
||||||
$rs = $this->entityManager->getRepository(ReferralSource::class)->find($id);
|
$rs = $this->entityManager->getRepository(ReferralSource::class)->find($id);
|
||||||
|
|
||||||
@ -111,7 +129,8 @@ class ReferralSourceController extends AbstractController
|
|||||||
[
|
[
|
||||||
'form' => $form,
|
'form' => $form,
|
||||||
'rs' => $rs,
|
'rs' => $rs,
|
||||||
'notifications' => $user->retrieveUnreadNotifications(),
|
'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')
|
||||||
|
144
src/Entity/Messages.php
Normal file
144
src/Entity/Messages.php
Normal 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
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
17
src/Enums/MessageType.php
Normal file
17
src/Enums/MessageType.php
Normal 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;
|
||||||
|
}
|
124
src/Factory/MessageFactory.php
Normal file
124
src/Factory/MessageFactory.php
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
73
src/Repository/MessagesRepository.php
Normal file
73
src/Repository/MessagesRepository.php
Normal 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()
|
||||||
|
// ;
|
||||||
|
// }
|
||||||
|
}
|
@ -17,6 +17,7 @@
|
|||||||
<div class="card card-plain">
|
<div class="card card-plain">
|
||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
<h4 class="font-weight-bolder">Assign Case Worker</h4>
|
<h4 class="font-weight-bolder">Assign Case Worker</h4>
|
||||||
|
<p>{{ case.level.name|lower|capitalize }}</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
{{ form_start(form, {'attr': {'onsubmit': 'return validateAssignForm()'}}) }}
|
{{ form_start(form, {'attr': {'onsubmit': 'return validateAssignForm()'}}) }}
|
||||||
@ -38,7 +39,7 @@
|
|||||||
|
|
||||||
<div class='input-group input-group-outline mb-3'>
|
<div class='input-group input-group-outline mb-3'>
|
||||||
<input type='checkbox' name='{{ field_name(form.overrideLevel) }}' id='user_form_levelOverride' value='1'/>
|
<input type='checkbox' name='{{ field_name(form.overrideLevel) }}' id='user_form_levelOverride' value='1'/>
|
||||||
<label for='user_form_levelOverride'>Override Level</label>
|
<label for='user_form_levelOverride' id='levelOverride-label'>Override Level</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
<div class='ms-md-auto pe-md-3 d-flex align-items-left'>
|
<div class='ms-md-auto pe-md-3 d-flex align-items-left'>
|
||||||
{% for label, messages in app.flashes %}
|
{% for label, messages in app.flashes %}
|
||||||
{% for message in messages %}
|
{% for message in messages %}
|
||||||
<div class="flash-{{ label }}">
|
<div class="flash-{{ label }} bg-gradient-info text-white">
|
||||||
{{ message }}
|
{{ message }}
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
@ -37,8 +37,9 @@
|
|||||||
</li>
|
</li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<li class="nav-item dropdown pe-3 d-flex align-items-center" title="Notifications">
|
<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>
|
<i class="material-symbols-rounded">notifications</i>
|
||||||
|
<span class='badge' {% if notificationCount == 0 %} style='display:none;' {% endif %}>{{ notificationCount }}</span>
|
||||||
</a>
|
</a>
|
||||||
<ul class="dropdown-menu dropdown-menu-end px-2 py-3 me-sm-n4" aria-labelledby="dropdownMenuButton">
|
<ul class="dropdown-menu dropdown-menu-end px-2 py-3 me-sm-n4" aria-labelledby="dropdownMenuButton">
|
||||||
{% for note in notifications %}
|
{% for note in notifications %}
|
||||||
@ -51,12 +52,12 @@
|
|||||||
<div class='d-flex flex-column justify-content-center'>
|
<div class='d-flex flex-column justify-content-center'>
|
||||||
<h6 class='text-sm font-weight-normal mb-1'>
|
<h6 class='text-sm font-weight-normal mb-1'>
|
||||||
<span class='font-weight-bold'>{{ note.title }}</span>
|
<span class='font-weight-bold'>{{ note.title }}</span>
|
||||||
{{ note.from }}
|
{{ note.sender.getName() }}
|
||||||
</h6>
|
</h6>
|
||||||
<p>{{ note.message }}</p>
|
<p>{{ note.message }}</p>
|
||||||
<p class='text-xs text-secondary mb-0'>
|
<p class='text-xs text-secondary mb-0'>
|
||||||
<i class='fa fa-clock me-1'></i>
|
<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>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user