Compare commits

...

19 Commits

Author SHA1 Message Date
d33dcacc46 Use better namespacing for configuring workflow signature documents 2024-07-18 16:09:34 +02:00
8d97df9f96 Remove trailing ParamConverter annotation 2024-07-18 15:17:35 +02:00
2822800c76 Changie added 2024-07-18 15:12:47 +02:00
8973b7c20b Move logic from twig template to controller and refactor workflow controller 2024-07-18 15:11:43 +02:00
7f144da1a7 Remove todo 2024-07-10 16:27:06 +02:00
ab4193938d Adjust the structure of the signature metadata 2024-07-10 15:39:38 +02:00
e2426ba1d8 Rename configuration parameter for document kinds 2024-07-10 15:38:51 +02:00
8209990437 Add todo as reminder to change isSignature logic in controller 2024-07-10 15:05:08 +02:00
b1885de3e2 Merge branch '288-signature-zone-workflow' of https://gitlab.com/Chill-Projet/chill-bundles into 288-signature-zone-workflow 2024-07-10 14:59:50 +02:00
218280304c php cs fixes 2024-07-10 12:49:51 +02:00
8a7b48b201 Implement logic to save metadata to signature 2024-07-10 12:49:05 +02:00
52a9aab73f Create form for adding document info in metadata property of signature 2024-07-10 12:48:48 +02:00
8f358112b1 Add configuration for signature document types 2024-07-10 12:48:03 +02:00
57a07af3db Display names and sign buttons for person or user signatures 2024-07-09 17:39:17 +02:00
fd216ff66e Remove metadata property from workflow entity 2024-07-09 15:47:06 +02:00
689c2c574a Correct translation 2024-07-09 10:05:15 +00:00
a8de18beac Layout template for adding signature zone to workflow 2024-07-04 17:12:32 +02:00
babca5fc0f Add metadata property to workflow to allow adding info about signatures needed 2024-07-04 17:11:57 +02:00
f2c5663b05 Adjust and add necessary twig templates for signature zone 2024-07-04 09:23:58 +02:00
11 changed files with 202 additions and 19 deletions

View File

@@ -0,0 +1,5 @@
kind: Feature
body: Metadata form added for person signatures
time: 2024-07-18T15:12:33.8134266+02:00
custom:
Issue: "288"

View File

@@ -13,9 +13,9 @@ namespace Chill\MainBundle\Controller;
use Chill\MainBundle\Entity\User;
use Chill\MainBundle\Entity\Workflow\EntityWorkflow;
use Chill\MainBundle\Entity\Workflow\EntityWorkflowComment;
use Chill\MainBundle\Entity\Workflow\EntityWorkflowStep;
use Chill\MainBundle\Form\EntityWorkflowCommentType;
use Chill\MainBundle\Entity\Workflow\EntityWorkflowStepSignature;
use Chill\MainBundle\Form\WorkflowSignatureMetadataType;
use Chill\MainBundle\Form\WorkflowStepType;
use Chill\MainBundle\Pagination\PaginatorFactory;
use Chill\MainBundle\Repository\Workflow\EntityWorkflowRepository;
@@ -277,6 +277,7 @@ class WorkflowController extends AbstractController
$handler = $this->entityWorkflowManager->getHandler($entityWorkflow);
$workflow = $this->registry->get($entityWorkflow, $entityWorkflow->getWorkflowName());
$errors = [];
$signatures = $entityWorkflow->getCurrentStep()->getSignatures();
if (\count($workflow->getEnabledTransitions($entityWorkflow)) > 0) {
// possible transition
@@ -322,22 +323,6 @@ class WorkflowController extends AbstractController
}
}
/*
$commentForm = $this->createForm(EntityWorkflowCommentType::class, $newComment = new EntityWorkflowComment());
$commentForm->handleRequest($request);
if ($commentForm->isSubmitted() && $commentForm->isValid()) {
$this->entityManager->persist($newComment);
$this->entityManager->flush();
$this->addFlash('success', $this->translator->trans('workflow.Comment added'));
return $this->redirectToRoute('chill_main_workflow_show', ['id' => $entityWorkflow->getId()]);
} elseif ($commentForm->isSubmitted() && !$commentForm->isValid()) {
$this->addFlash('error', $this->translator->trans('This form contains errors'));
}
*/
return $this->render(
'@ChillMain/Workflow/index.html.twig',
[
@@ -347,7 +332,7 @@ class WorkflowController extends AbstractController
'transition_form' => isset($transitionForm) ? $transitionForm->createView() : null,
'entity_workflow' => $entityWorkflow,
'transition_form_errors' => $errors,
// 'comment_form' => $commentForm->createView(),
'signatures' => $signatures,
]
);
}
@@ -366,4 +351,47 @@ class WorkflowController extends AbstractController
return $lines;
}
#[Route(path: '/{_locale}/main/workflow/signature/{signature_id}/metadata', name: 'chill_main_workflow_signature_metadata')]
public function addSignatureMetadata(int $signature_id, Request $request): Response
{
$signature = $this->entityManager->getRepository(EntityWorkflowStepSignature::class)->find($signature_id);
if ($signature->getSigner() instanceof User) {
return $this->redirectToRoute('signature_route_user');
}
$metadataForm = $this->createForm(WorkflowSignatureMetadataType::class);
$metadataForm->add('submit', SubmitType::class, ['label' => $this->translator->trans('Save')]);
$metadataForm->handleRequest($request);
if ($metadataForm->isSubmitted() && $metadataForm->isValid()) {
$data = $metadataForm->getData();
$signature->setSignatureMetadata(
[
'base_signer' => [
'document_type' => $data['documentType'],
'document_number' => $data['documentNumber'],
'expiration_date' => $data['expirationDate'],
],
]
);
$this->entityManager->persist($signature);
$this->entityManager->flush();
// Todo should redirect to document for actual signing? To be adjusted still
return $this->redirectToRoute('chill_main_workflow_show', ['id' => $signature->getStep()->getEntityWorkflow()->getId()]);
}
return $this->render(
'@ChillMain/Workflow/_signature_metadata.html.twig',
[
'metadata_form' => $metadataForm->createView(),
'person' => $signature->getSigner(),
]
);
}
}

View File

@@ -193,6 +193,11 @@ class ChillMainExtension extends Extension implements
[]
);
$container->setParameter(
'chill_main.workflow_signatures.base_signer.document_kinds',
$config['workflow_signature']['base_signer']['document_kinds']
);
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../config'));
$loader->load('services.yaml');
$loader->load('services/doctrine.yaml');

View File

@@ -277,6 +277,32 @@ class Configuration implements ConfigurationInterface
->end() // end of root
;
$rootNode->children()
->arrayNode('workflow_signature')
->children()
->arrayNode('base_signer')
->children()
->arrayNode('document_kinds')
->arrayPrototype()
->children()
->scalarNode('key')->cannotBeEmpty()->end()
->arrayNode('labels')
->arrayPrototype()
->children()
->scalarNode('lang')->cannotBeEmpty()->end()
->scalarNode('label')->cannotBeEmpty()->end()
->end()
->end()
->end()
->end()
->end()
->end()
->end()
->end()
->end()
->end()
->end();
$rootNode->children()
->arrayNode('add_address')->addDefaultsIfNotSet()->children()
->scalarNode('default_country')->cannotBeEmpty()->defaultValue('BE')->end()

View File

@@ -0,0 +1,62 @@
<?php
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\MainBundle\Form;
use Chill\MainBundle\Form\Type\ChillDateType;
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
class WorkflowSignatureMetadataType extends AbstractType
{
public function __construct(private readonly ParameterBagInterface $parameterBag, private readonly TranslatableStringHelperInterface $translatableStringHelper) {}
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$documentTypeChoices = $this->parameterBag->get('chill_main.id_document_kinds');
$choices = [];
foreach ($documentTypeChoices as $documentType) {
$labels = [];
foreach ($documentType['labels'] as $label) {
$labels[$label['lang']] = $label['label'];
}
$localizedLabel = $this->translatableStringHelper->localize($labels);
if (null !== $localizedLabel) {
$choices[$localizedLabel] = $documentType['key'];
}
}
$builder
->add('documentType', ChoiceType::class, [
'label' => 'workflow.signature_zone.metadata.docType',
'expanded' => false,
'required' => true,
'choices' => $choices,
])
->add('documentNumber', TextType::class, [
'required' => true,
'label' => 'workflow.signature_zone.metadata.docNumber',
])
->add('expirationDate', ChillDateType::class, [
'required' => true,
'input' => 'datetime_immutable',
'label' => 'workflow.signature_zone.metadata.docExpiration',
]);
}
}

View File

@@ -0,0 +1,19 @@
<h2>{{ 'workflow.signature_zone.title'|trans }}</h2>
<div class="flex-table justify-content-center">
<div class="item-bloc">
{% for s in signatures %}
<div class="item-row mb-2">
<div class="col-sm-6"><span>{{ s.signer|chill_entity_render_box }}</span></div>
<div class="col-sm-6">
<a class="btn btn-show" href="{{ chill_path_add_return_path('chill_main_workflow_signature_metadata', { 'signature_id': s.id}) }}">{{ 'workflow.signature_zone.button_sign'|trans }}</a>
{% if s.state is same as('signed') %}
<p class="updatedBy">{{ s.stateDate }}</p>
{% endif %}
</div>
</div>
{% endfor %}
</div>
</div>

View File

@@ -0,0 +1,24 @@
{% extends '@ChillMain/layout.html.twig' %}
{% block title %}
{{ 'Signature'|trans }}
{% endblock %}
{% block content %}
<div class="col-10 workflow">
<h1 class="mb-5">{{ 'workflow.signature_zone.metadata.sign_by'|trans({ '%name%' : person.firstname ~ ' ' ~ person.lastname}) }}</h1>
{% if metadata_form is not null %}
{{ form_start(metadata_form) }}
{{ form_row(metadata_form.documentType) }}
{{ form_row(metadata_form.documentNumber) }}
{{ form_row(metadata_form.expirationDate) }}
<ul class="record_actions">
<li>
{{ form_widget(metadata_form.submit, { 'attr' : { 'class' : 'btn btn-submit' }} ) }}
</li>
</ul>
{{ form_end(metadata_form) }}
{% endif %}
</div>
{% endblock %}

View File

@@ -57,6 +57,9 @@
</section>
<section class="step my-4">{% include '@ChillMain/Workflow/_follow.html.twig' %}</section>
{% if signatures|length > 0 %}
<section class="step my-4">{% include '@ChillMain/Workflow/_signature.html.twig' %}</section>
{% endif %}
<section class="step my-4">{% include '@ChillMain/Workflow/_decision.html.twig' %}</section>{#
<section class="step my-4">{% include '@ChillMain/Workflow/_comment.html.twig' %}</section> #}
<section class="step my-4">{% include '@ChillMain/Workflow/_history.html.twig' %}</section>

View File

@@ -133,6 +133,8 @@ services:
Chill\MainBundle\Form\WorkflowStepType: ~
Chill\MainBundle\Form\WorkflowSignatureMetadataType: ~
Chill\MainBundle\Form\DataMapper\PrivateCommentDataMapper:
autowire: true
autoconfigure: true

View File

@@ -528,6 +528,15 @@ workflow:
This link grant any user to apply a transition: Le lien d'accès suivant permet d'appliquer une transition
The workflow may be accssed through this link: Une transition peut être appliquée sur ce workflow grâce au lien d'accès suivant
signature_zone:
title: Appliquer les signatures électroniques
button_sign: Signer
metadata:
sign_by: 'Signature pour %name%'
docType: Type de document
docNumber: Numéro de document
docExpiration: Date d'expiration
Subscribe final: Recevoir une notification à l'étape finale
Subscribe all steps: Recevoir une notification à chaque étape