Added messages, notifications, count, and supporting elements
This commit is contained in:
@@ -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,
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
Reference in New Issue
Block a user