add document controller for document actions
This commit is contained in:
parent
75cffad2ea
commit
dce5dcab2f
44
src/Controller/DocumentController.php
Normal file
44
src/Controller/DocumentController.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use App\Libs\NavList;
|
||||
use App\Libs\Libs;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
use Symfony\Component\Security\Http\Attribute\CurrentUser;
|
||||
|
||||
class DocumentController extends AbstractController
|
||||
{
|
||||
public function __construct(
|
||||
private EntityManagerInterface $entityManager,
|
||||
private array $navLinks = []
|
||||
) {
|
||||
$this->navLinks = NavList::LIST;
|
||||
}
|
||||
|
||||
#[Route('/case/{caseId}/doc/{docId}', name: 'app_display_case_doc')]
|
||||
public function displayCaseDocument(string $caseId, string $docId, #[CurrentUser()] User $user): Response
|
||||
{
|
||||
$msgs = Libs::getMessages($user, $this->entityManager);
|
||||
|
||||
$case = $this->entityManager->getRepository(MemberCase::class)->find($caseId);
|
||||
$doc = $this->entityManager->getRepository(CompanyDocument::class)->find($docId);
|
||||
$caseDoc = $this->entityManager->getRepository(CaseDocument::class)->getCaseDocument($case, $doc);
|
||||
|
||||
return $this->render(
|
||||
'internal/cases/documents/display-case-doc.html.twig',
|
||||
array_merge(
|
||||
$this->navLinks,
|
||||
[
|
||||
'msgs' => $msgs,
|
||||
'notificationCount' => count($msgs),
|
||||
'breadcrumbs' => []
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
38
src/Form/CaseDocumentFormType.php
Normal file
38
src/Form/CaseDocumentFormType.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Form;
|
||||
|
||||
use App\Entity\CaseDocument;
|
||||
use App\Entity\CompanyDocument;
|
||||
use App\Entity\Member;
|
||||
use App\Entity\User;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\EnumType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class CaseDocumentFormType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
{
|
||||
$docs = $options['docs'];
|
||||
$builder
|
||||
->add('document', EntityType::class, [
|
||||
'class' => CompanyDocument::class,
|
||||
'choices' => $docs,
|
||||
'multiple' => true,
|
||||
'expanded' => true,
|
||||
'choice_label' => 'title',
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => CaseDocument::class,
|
||||
'docs' => [],
|
||||
]);
|
||||
}
|
||||
}
|
36
src/Form/CompanyDocumentFormType.php
Normal file
36
src/Form/CompanyDocumentFormType.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Form;
|
||||
|
||||
use App\Enums\DocumentExtras;
|
||||
use App\Entity\Company;
|
||||
use App\Entity\CompanyDocument;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\EnumType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class CompanyDocumentFormType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
{
|
||||
$builder
|
||||
->add('title')
|
||||
->add('text', TextareaType::class)
|
||||
->add('extras', EnumType::class, [
|
||||
'class' => DocumentExtras::class,
|
||||
'multiple' => true,
|
||||
'expanded' => true,
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => CompanyDocument::class,
|
||||
]);
|
||||
}
|
||||
}
|
@ -2,12 +2,14 @@
|
||||
|
||||
namespace App\Form;
|
||||
|
||||
use App\Entity\CompanyDocument;
|
||||
use App\Entity\MemberCase;
|
||||
use App\Entity\ReferralSource;
|
||||
use App\Enums\CaseLevel;
|
||||
use App\Enums\County;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\EnumType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
@ -60,6 +62,11 @@ class MemberCaseFormType extends AbstractType
|
||||
->add('county', EnumType::class, [
|
||||
'class' => County::class,
|
||||
])
|
||||
->add('docs', ChoiceType::class, [
|
||||
'data_class' => CompanyDocument::class,
|
||||
'multiple' => true,
|
||||
'expanded' => true,
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
@ -67,6 +74,7 @@ class MemberCaseFormType extends AbstractType
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => MemberCase::class,
|
||||
'docs' => [],
|
||||
'csrf_protection' => true,
|
||||
'csrf_field_name' => '_token',
|
||||
'csrf_token_id' => 'member_case',
|
||||
|
Loading…
Reference in New Issue
Block a user