Skip to content

Commit

Permalink
Merge pull request #74 from kiloutyg/63-make-the-commentary-mandatory…
Browse files Browse the repository at this point in the history
…-to-allow-archiving

 blocked in the front and back end
  • Loading branch information
kiloutyg authored Mar 19, 2024
2 parents 90c240e + f7b19fe commit 530f912
Show file tree
Hide file tree
Showing 4 changed files with 210 additions and 109 deletions.
35 changes: 22 additions & 13 deletions src/Controller/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -349,23 +349,32 @@ public function productVersionCreation(Request $request): Response
#[Route('admin/archive/{entityType}/{id}', name: 'archive_entity')]
public function archiveEntity(Request $request, string $entityType, int $id): Response
{
$originUrl = $request->headers->get('referer');
$user = $this->getUser()->getUsername();
$commentary = $request->request->get('archivingCommentary');
if ($this->getUser() !== null && $this->authChecker->isGranted('ROLE_ADMIN') == false) {
$this->addFlash('danger', 'Vous n\'avez pas les droits pour effectuer cette action');
return $this->redirectToRoute('app_base');
} else {

$this->logger->info($user . ' archived entity: ' . $entityType . ' ' . $id . ' ' . 'commentaire: ' . $commentary . ' full request: ' . json_encode($request->getContent()));
$originUrl = $request->headers->get('referer');
$user = $this->getUser()->getUsername();
$commentary = $request->request->get('archivingCommentary');

$result = $this->entityDeletionService->archivedEntity($entityType, $id, $commentary, $user);
if ($entityType == "efnc" && $commentary == null) {
$this->addFlash('danger', 'Un commentaire est requis pour archiver une EFNC');
return $this->redirect($originUrl);
}

if ($result == false) {
$this->addFlash('danger', 'L\'élément n\'a pas pu être archivé');
return $this->redirect($originUrl);
} else {
$this->addFlash('success', 'L\'élément a bien été archivé');
if ($entityType == "efnc") {
return $this->redirectToRoute('app_base', []);
} else {
$result = $this->entityDeletionService->archivedEntity($entityType, $id, $commentary, $user);

if ($result == false) {
$this->addFlash('danger', 'L\'élément n\'a pas pu être archivé');
return $this->redirect($originUrl);
} else {
$this->addFlash('success', 'L\'élément a bien été archivé');
if ($entityType == "efnc") {
return $this->redirectToRoute('app_base', []);
} else {
return $this->redirect($originUrl);
}
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/Controller/EFNCController.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ public function formCreation(Request $request): Response
{
$efnc = new EFNC();
$imcome = new ImmediateConservatoryMeasures();
$riskWeighting = new RiskWeighting();
$product = new Product();
$riskWeighting = new RiskWeighting();

$efnc->getImmediateConservatoryMeasures()->add($imcome);
$efnc->getProduct($product);
$efnc->getRiskWeighting($riskWeighting);
Expand Down
162 changes: 125 additions & 37 deletions templates/services/efnc/creation/form_creation.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,30 @@

{% block body %}

<h3 class="text-white mb-5">
<strong>Création de la Fiche de Non-Conformité :</strong>
<h3
class="text-white mb-5">
<strong>
Création de la Fiche de Non-Conformité :
</strong>
</h3>
<div class="col-lg-8 mx-auto">
<div class="card border-0 shadow rounded-3 my-5 bg-secondary">
<div class="card-body">
<div
class="col-lg-8 mx-auto">
<div
class="card border-0 shadow rounded-3 my-5 bg-secondary">
<div
class="card-body">

{{ form_start(form1, {
attr: {
id: 'formCreationForm',
method: 'POST',
enctype: 'multipart/form-data' }, action: path('app_form_creation') }) }}
<div class="row g-3">
<div
class="row g-3">
<h3>
<strong>Enregistrement de la Non-Conformité:</strong>
<strong>
Enregistrement de la Non-Conformité:
</strong>
</h3>
{% set fields = [
'Creator', 'DetectionDate', 'DetectionTime', 'Team','UAP',
Expand All @@ -30,55 +39,134 @@
{{ form_row(form1[field]) }}
{% endfor %}
<h3>
<strong>Description du Probléme :</strong>
<strong>
Description du Probléme :
</strong>
</h3>
{% set problemDetails = ['AnomalyType', 'Quantity', 'QuantityToBlock', 'DetailedDescription'] %}
{% for detail in problemDetails %}
{{ form_row(form1[detail]) }}
{% endfor %}
<div id="TraceabilityPictureSizeWarning" style="color: red; display: none;">La taille du fichier doit être inferieur à 4Mo.</div>
<div class="mb-3" id="traceability-picture-container">
<label class="form-label" style="font-weight: bold; color: #ffffff;" for="picture_TraceabilityPicture">Photo de Traçabilité Obligatoire :</label>
<input required type="file" accept="image/*" size="4194304" id="picture_TraceabilityPicture" name="picture[TraceabilityPicture][]" multiple="multiple" class="form-control mx-auto" placeholder="Photo de Traçabilité Obligatoire">
<div id="TraceabilityPicturePreview"></div>
<div
id="TraceabilityPictureSizeWarning"
style="color: red; display: none;">
La taille du fichier doit être inferieur à 4Mo.
</div>
<div id="NCpictureSizeWarning" style="color: red; display: none;">La taille du fichier doit être inferieur à 4Mo.</div>
<div class="mb-3" id="nc-picture-container">
<label class="form-label" style="font-weight: bold; color: #ffffff;" for="picture_NCpicture">Photo de non-conformité :</label>
<input required type="file" accept="image/*" size="4194304" id="picture_NCpicture" name="picture[NCpicture][]" multiple="multiple" class="form-control mx-auto" placeholder="Photo de non-conformité">
<div id="NCpicturePreview"></div>
<div
class="mb-3"
id="traceability-picture-container">
<label
class="form-label"
style="font-weight: bold; color: #ffffff;"
for="picture_TraceabilityPicture">
Photo de Traçabilité Obligatoire :
</label>
<input
required
type="file"
accept="image/*"
size="4194304"
id="picture_TraceabilityPicture"
name="picture[TraceabilityPicture][]"
multiple="multiple"
class="form-control mx-auto"
placeholder="Photo de Traçabilité Obligatoire">
<div
id="TraceabilityPicturePreview"></div>
</div>
<div
id="NCpictureSizeWarning"
style="color: red; display: none;">
La taille du fichier doit être inferieur à 4Mo.
</div>
<div
class="mb-3"
id="nc-picture-container">
<label
class="form-label"
style="font-weight: bold; color: #ffffff;"
for="picture_NCpicture">
Photo de non-conformité :
</label>
<input
required
type="file"
accept="image/*"
size="4194304"
id="picture_NCpicture"
name="picture[NCpicture][]"
multiple="multiple"
class="form-control mx-auto"
placeholder="Photo de non-conformité">
<div
id="NCpicturePreview"></div>
</div>
<h3>
<strong>Mesures Conservatoire Immediates:</strong>
<strong>
Mesures Conservatoire Immediates:
</strong>
</h3>
<div id="imcome-container" data-prototype="{{ form_widget(form1.immediateConservatoryMeasures.vars.prototype)|e('html_attr') }}">
<div
id="imcome-container"
data-prototype="{{ form_widget(form1.immediateConservatoryMeasures.vars.prototype)|e('html_attr') }}">
{% for imcomeFormEntry in form1.immediateConservatoryMeasures %}
<div class="imcome-entry">
{{ form_widget(imcomeFormEntry, {'attr': {'class': 'row'}}) }}
<div
class="imcome-entry">
{{ form_widget(imcomeFormEntry, {'attr': {'class': 'row'}}
) }}
</div>
{% endfor %}
</div>
<button type="button" id="add-another-imcome" class="btn btn-info">Ajouter une autre Mesure</button>
<div class="d-grid gap-2 d-md-flex justify-content-md-center mt-5">
<button type="submit" class="btn btn-primary mb-3 submit-EFNCform-creation">Créer</button>
<button
type="button"
id="add-another-imcome"
class="btn btn-info">
Ajouter une autre Mesure
</button>
<div
class="d-grid gap-2 d-md-flex justify-content-md-center mt-5">
<button
type="submit"
class="btn btn-primary mb-3 submit-EFNCform-creation">
Créer
</button>
</div>
<div hidden>
<div
hidden>
<h3>
<strong>Priorisation de la non-conformité :</strong>
<strong>
Priorisation de la non-conformité :
</strong>
</h3>
{% for riskWeightingFormEntry in form1.riskWeighting %}
{{ form_row(riskWeightingFormEntry) }}
{% endfor %}
<div class="risk-priority-explanation"></div>
<div id="rpi-high-risk" style="color: #ffcccb;">
<strong>Risque Élevé:</strong>
Réaliser une analyse 8D.</div>
<div id="rpi-medium-risk" style="color: #ffeda6;">
<strong>Risque Moyen:</strong>
Réaliser une analyse de causes potentielles.</div>
<div id="rpi-low-risk" style="color: #c8f7c5;">
<strong>Risque Faible:</strong>
Pas d'analyse, affichage au poste : Alerte d'un Problème.</div>
<div
class="risk-priority-explanation"></div>
<div
id="rpi-high-risk"
style="color: #ffcccb;">
<strong>
Risque Élevé:
</strong>
Réaliser une analyse 8D.
</div>
<div
id="rpi-medium-risk"
style="color: #ffeda6;">
<strong>
Risque Moyen:
</strong>
Réaliser une analyse de causes potentielles.
</div>
<div
id="rpi-low-risk"
style="color: #c8f7c5;">
<strong>
Risque Faible:
</strong>
Pas d'analyse, affichage au poste : Alerte d'un Problème.
</div>
</div>
</div>

Expand Down
119 changes: 61 additions & 58 deletions templates/services/efnc/modification/form_modification.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -190,74 +190,77 @@
{% endif %}
</div>
{{ form_end(form1) }}
{% if EFNC.archived is null and EFNC.status is null %}
{% if is_granted('ROLE_ADMIN') %}

<form
method="post"
action="{{ path('app_archive_entity', {entityType: 'efnc', id: EFNC.id}) }}">
{% if EFNC.archived is null and EFNC.status is null %}

<form
method="post"
action="{{ path('app_archive_entity', {entityType: 'efnc', id: EFNC.id}) }}">

<div
class="container mt-2 mb-2"
data-controller="archiving-commentary">
<div
class="row justify-content-md-center">
class="container mt-2 mb-2"
data-controller="archiving-commentary">
<div
class="col-md-12">
<label
for="archivingCommentary"
class="form-label text-white">
Commentaire d'archivage obligatoire
<div
data-archiving-commentary-target="archivingCommentaryMessage"
class="archivingCommentaryMessage-message d-flex justify-content-evenly"></div>
</label>
<textarea
class="form-control"
id="archivingCommentary"
name="archivingCommentary"
data-archiving-commentary-target="archivingCommentary"
data-action="keyup->archiving-commentary#archivingCommentary"></textarea>
class="row justify-content-md-center">
<div
class="col-md-12">
<label
for="archivingCommentary"
class="form-label text-white">
Commentaire d'archivage obligatoire
<div
data-archiving-commentary-target="archivingCommentaryMessage"
class="archivingCommentaryMessage-message d-flex justify-content-evenly"></div>
</label>
<textarea
class="form-control"
id="archivingCommentary"
name="archivingCommentary"
data-archiving-commentary-target="archivingCommentary"
data-action="keyup->archiving-commentary#archivingCommentary"></textarea>
</div>
</div>
</div>
<div
class="d-grid gap-2 d-md-flex justify-content-md-center mt-2">
<button
type="submit"
class="btn btn-danger archive-EFNC"
data-archiving-commentary-target="archivingButton"
hidden
disabled>
Archiver
</button>
{% if is_granted('ROLE_MASTER_ADMIN') %}
<a
<div
class="d-grid gap-2 d-md-flex justify-content-md-center mt-2">
<button
type="submit"
class="btn btn-danger archive-EFNC"
href="{{path('app_close_entity', {entityType: 'efnc', id: EFNC.id})}}">
Cloturer
</a>
{% endif %}
data-archiving-commentary-target="archivingButton"
hidden
disabled>
Archiver
</button>
{% if is_granted('ROLE_MASTER_ADMIN') %}
<a
class="btn btn-danger archive-EFNC"
href="{{path('app_close_entity', {entityType: 'efnc', id: EFNC.id})}}">
Cloturer
</a>
{% endif %}
</div>
</div>
</div>
</form>
{% elseif EFNC.archived is same as(true) and EFNC.status is null %}
<div
class="d-grid gap-2 d-md-flex justify-content-md-center mt-2 mb-2 text-white">
Archivage effectué par
</form>
{% elseif EFNC.archived is same as(true) and EFNC.status is null %}
<div
class="d-grid gap-2 d-md-flex justify-content-md-center mt-2 mb-2 text-white">
Archivage effectué par

{{ EFNC.Archiver|capitalize|split('.')|first }}
{{ EFNC.Archiver|upper|split('.')|last }}
{{ EFNC.Archiver|capitalize|split('.')|first }}
{{ EFNC.Archiver|upper|split('.')|last }}

avec le commentaire suivant :
{{ EFNC.archivingCommentary }}
</div>
{% elseif EFNC.archived is same as(true) and EFNC.status is not null %}
<div
class="d-grid gap-2 d-md-flex justify-content-md-center mt-2 mb-2 text-white">
Cloture effectué par
avec le commentaire suivant :
{{ EFNC.archivingCommentary }}
</div>
{% elseif EFNC.archived is same as(true) and EFNC.status is not null %}
<div
class="d-grid gap-2 d-md-flex justify-content-md-center mt-2 mb-2 text-white">
Cloture effectué par

{{ EFNC.Closer|capitalize|split('.')|first }}
{{ EFNC.Closer|upper|split('.')|last }}
</div>
{{ EFNC.Closer|capitalize|split('.')|first }}
{{ EFNC.Closer|upper|split('.')|last }}
</div>
{% endif %}
{% endif %}

</div>
Expand Down

0 comments on commit 530f912

Please sign in to comment.