fix: CaseController

migrate documents to MemberController
add link to new case message
This commit is contained in:
Ryan Prather 2025-01-21 14:09:21 -05:00
parent c04e255476
commit 2af4b8e04e

View File

@ -101,8 +101,10 @@ class CaseController extends AbstractController
}
$case = $this->entityManager->getRepository(MemberCase::class)->find($caseId);
$caseDocs = $this->entityManager->getRepository(CaseDocument::class)->getDocumentsByCase($case);
$compDocs = $this->entityManager->getRepository(CompanyDocument::class)->findBy(['company' => $user->getCompany()]);
/** @todo validate user has access to case, check for admin, case manager of case worker */
//$uc = $this->entityManager->getRepository(UserCase::class)
$sources = $this->entityManager->getRepository(ReferralSource::class)->findAll();
return $this->render(
@ -111,8 +113,6 @@ class CaseController extends AbstractController
$this->navLinks,
[
'case' => $case,
'caseDocs' => $caseDocs,
'compDocs' => $compDocs,
'sources' => $sources,
'breadcrumbs' => [
new Breadcrumb($this->generateUrl('app_list_cases'), 'List Cases'),
@ -129,9 +129,8 @@ class CaseController extends AbstractController
{
$this->denyAccessUnlessGranted('ROLE_ADMIN');
$companyDocs = $this->entityManager->getRepository(CompanyDocument::class)->findBy(['company' => $admin->getCompany()]);
$case = new MemberCase();
$form = $this->createForm(MemberCaseFormType::class, $case, ['docs' => $companyDocs]);
$form = $this->createForm(MemberCaseFormType::class);
$form->handleRequest($request);
@ -159,7 +158,6 @@ class CaseController extends AbstractController
'notifications' => Libs::getMessages($admin, $this->entityManager),
'form' => $form,
'sources' => $this->entityManager->getRepository(ReferralSource::class)->retrieveOrderedList(),
'docs' => $companyDocs,
]
)
);
@ -227,7 +225,11 @@ class CaseController extends AbstractController
$this->entityManager->flush();
}
$msg = MessageFactory::createNewCase($admin, $user);
$msg = MessageFactory::createNewCase(
$admin,
$user,
$this->generateUrl('app_view_case', ['caseId' => $case->getId()->toString()])
);
$this->entityManager->persist($uc);
$this->entityManager->persist($msg);