Skip to content

Commit

Permalink
Merge pull request #93 from kiloutyg/89-meeting-06242024
Browse files Browse the repository at this point in the history
89 meeting 06242024
  • Loading branch information
kiloutyg authored Jun 25, 2024
2 parents 90f963b + d27d4e6 commit 9b06c96
Show file tree
Hide file tree
Showing 8 changed files with 194 additions and 37 deletions.
6 changes: 3 additions & 3 deletions assets/js/risk-weighting-pri-calculus.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ document.addEventListener('turbo:load', function () {
if (riskPriorityIndex > 300) {
riskPriorityIndexField.style.backgroundColor = '#ffcccb'; // Red-ish
riskPriorityExplanation.classList.add('alert-danger');
riskPriorityExplanation.textContent = 'Réaliser une analyse 8D';
riskPriorityExplanation.textContent = 'Réaliser une analyse 8D ou PSA3';
} else if (riskPriorityIndex > 100) {
riskPriorityIndexField.style.backgroundColor = '#ffeda6'; // Orange-ish
riskPriorityExplanation.classList.add('alert-warning');
riskPriorityExplanation.textContent = 'Réaliser une analyse de causes potentielles';
riskPriorityExplanation.textContent = 'Réaliser une analyse de causes potentielles et les actions de suivis dans le PDCA de l\'UAP concerné';
} else {
riskPriorityIndexField.style.backgroundColor = '#c8f7c5'; // Green-ish
riskPriorityExplanation.classList.add('alert-success');
riskPriorityExplanation.textContent = 'Pas d\'analyse, affichage au poste : Alerte d\'un Problème';
riskPriorityExplanation.innerHTML = 'Faire communication par mail au TOP 5 (informer les manager) + Présentation piéces et affichage au poste : Alerte d\'un Problème.<br><strong>➥ Cloture manuelle aprés un mois si absence de récurrence, si récurrence conserver la nouvelle FNC et cloturer la premiére occurrence.</strong>';
}
}

Expand Down
10 changes: 10 additions & 0 deletions src/Controller/FrontController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ class FrontController extends BaseController
#[Route('/', name: 'base')]
public function base(): Response
{
$this->mailerService->sendReminderEmailToAdmin();

return $this->render('base.html.twig', []);
}

Expand All @@ -30,4 +32,12 @@ public function closedFormList(): Response
{
return $this->render('/services/efnc/display/closed_efnc_list.html.twig', []);
}

// #[Route('/admin/old', name: 'old')]
// public function testForOld(): Response
// {
// $this->mailerService->sendReminderEmailToAdmin();

// return $this->redirectToRoute('app_base');
// }
}
63 changes: 40 additions & 23 deletions src/Repository/EFNCRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,45 @@ public function __construct(ManagerRegistry $registry)
parent::__construct($registry, EFNC::class);
}

// /**
// * @return EFNC[] Returns an array of EFNC objects
// */
// public function findByExampleField($value): array
// {
// return $this->createQueryBuilder('e')
// ->andWhere('e.exampleField = :val')
// ->setParameter('val', $value)
// ->orderBy('e.id', 'ASC')
// ->setMaxResults(10)
// ->getQuery()
// ->getResult()
// ;
// }
public function getMonthOldLowLevelRiskEfnc()
{
$date = new \DateTime();
$date->modify('-1 month');
$date = $date->format('Y-m-d');
return $this->createQueryBuilder('e')
->leftJoin('e.riskWeighting', 'r')
->andWhere('r.RiskPriorityIndex < :val')
->andWhere('e.CreatedAt < :date')
->andWhere('e.Status IS NULL')
->andWhere('e.archived IS NULL')
->setParameter('val', '100')
->setParameter('date', $date)
->getQuery()
->getResult();
}

// /**
// * @return EFNC[] Returns an array of EFNC objects
// */
// public function findByExampleField($value): array
// {
// return $this->createQueryBuilder('e')
// ->andWhere('e.exampleField = :val')
// ->setParameter('val', $value)
// ->orderBy('e.id', 'ASC')
// ->setMaxResults(10)
// ->getQuery()
// ->getResult()
// ;
// }

// public function findOneBySomeField($value): ?EFNC
// {
// return $this->createQueryBuilder('e')
// ->andWhere('e.exampleField = :val')
// ->setParameter('val', $value)
// ->getQuery()
// ->getOneOrNullResult()
// ;
// }
// public function findOneBySomeField($value): ?EFNC
// {
// return $this->createQueryBuilder('e')
// ->andWhere('e.exampleField = :val')
// ->setParameter('val', $value)
// ->getQuery()
// ->getOneOrNullResult()
// ;
// }
}
56 changes: 55 additions & 1 deletion src/Service/MailerService.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,27 @@
namespace App\Service;

use App\Entity\EFNC;
use App\Entity\User;

use App\Repository\UserRepository;
use App\Repository\EFNCRepository;

use Symfony\Component\Mailer\MailerInterface;
use Symfony\Component\Mailer\Exception\TransportExceptionInterface;

use Symfony\Component\Mime\Email;
use Symfony\Component\Mime\Part\DataPart;

use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;

use Symfony\Bridge\Twig\Mime\TemplatedEmail;

use Symfony\Bundle\SecurityBundle\Security;

use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;

use App\Entity\User;

use Psr\Log\LoggerInterface;

class MailerService extends AbstractController
{
Expand All @@ -30,12 +34,20 @@ class MailerService extends AbstractController

private $senderEmail;

private $logger;

protected $projectDir;

public function __construct(
MailerInterface $mailer,

UserRepository $userRepository,
EFNCRepository $EFNCRepository,

LoggerInterface $logger,

ParameterBagInterface $params,

string $senderEmail
) {
$this->mailer = $mailer;
Expand All @@ -44,6 +56,9 @@ public function __construct(
$this->EFNCRepository = $EFNCRepository;

$this->senderEmail = $senderEmail;

$this->logger = $logger;
$this->projectDir = $params->get('kernel.project_dir');
}

public function notificationEmail(EFNC $EFNC)
Expand Down Expand Up @@ -124,4 +139,43 @@ public function sendEmail(User $recipient, string $subject, string $html)
return $e->getMessage();
}
}

public function sendReminderEmailToAdmin()
{
$today = new \DateTime();
$fileName = 'email_sent.txt';
$filePath = $this->projectDir . '/public/doc/' . $fileName;

if ($today->format('d') % 2 == 0 && (!file_exists($filePath) || strpos(file_get_contents($filePath), $today->format('Y-m-d')) === false)) {

$senderEmail = $this->senderEmail;

$recipientsEmail = [];
$users = $this->userRepository->findAll();
foreach ($users as $user) {
if ($user !== $this->getUser() && filter_var($user->getEmailAddress(), FILTER_VALIDATE_EMAIL) && in_array('ROLE_ADMIN', $user->getRoles()) === true) {
$recipientsEmail[] = $user->getEmailAddress();
}
}
$monthOldEfnc = $this->EFNCRepository->getMonthOldLowLevelRiskEfnc();
$this->logger->info('Month old efncs: ' . count($monthOldEfnc));
$this->logger->info('month old efncs: ', [$monthOldEfnc]);

$email = (new TemplatedEmail())
->from($senderEmail)
->to(...$recipientsEmail)
->subject('EFNC - Rappel des fiches à cloturer.')
->htmlTemplate('/services/email_templates/reminderEmailToAdmin.html.twig')
->context([
'oldEfncs' => $monthOldEfnc,
]);

try {
$this->mailer->send($email);
return true;
} catch (TransportExceptionInterface $e) {
return false;
}
}
}
}
4 changes: 2 additions & 2 deletions templates/base.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -191,15 +191,15 @@
{% endfor %}
{% if is_granted('ROLE_USER') and archive > 0 %}
<strong>
FNC ARCHIVÉES
FNC ARCHIVÉES (Ne respecte le standard des FNC)
</strong>
<iframe
class="d-flex mb-3 rounded-3 flex-grow-1"
name="form_list"
src="{{ path('app_archived_form_list')}}" frameborder="0"></iframe>
{# {% if is_granted('ROLE_MASTER_ADMIN') and closed > 0 %} #}
<strong>
FNC CLOSES
FNC CLOSES (Actions cloturées dans PDCA UAP)
</strong>
<iframe
class="d-flex mb-3 rounded-3 flex-grow-1"
Expand Down
8 changes: 5 additions & 3 deletions templates/services/efnc/creation/form_creation.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -142,23 +142,25 @@
<strong>
Risque Élevé:
</strong>
Réaliser une analyse 8D.
Réaliser une analyse 8D ou PSA3.
</div>
<div
id="rpi-medium-risk"
style="color: #ffeda6;">
<strong>
Risque Moyen:
</strong>
Réaliser une analyse de causes potentielles.
Réaliser une analyse de causes potentielles et les actions de suivis dans le PDCA de l'UAP concerné.
</div>
<div
id="rpi-low-risk"
style="color: #c8f7c5;">
<strong>
Risque Faible:
</strong>
Pas d'analyse, affichage au poste : Alerte d'un Problème.
Faire communication par mail au TOP 5 (informer les managers) + Présentation piéces et affichage au poste : Alerte d'un Problème.
<br>
➥ Cloture manuelle aprés un mois si absence de récurrence, si récurrence conserver la nouvelle FNC et cloturer la premiére occurrence.
</div>
{% endif %}
<div
Expand Down
12 changes: 7 additions & 5 deletions templates/services/efnc/modification/form_modification.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -148,23 +148,25 @@
<strong>
Risque Élevé:
</strong>
Réaliser une analyse 8D.
Réaliser une analyse 8D ou PSA3.
</div>
<div
id="rpi-medium-risk"
style="color: #ffeda6;">
<strong>
Risque Moyen:
</strong>
Réaliser une analyse de causes potentielles.
Réaliser une analyse de causes potentielles et les actions de suivis dans le PDCA de l'UAP concerné.
</div>
<div
id="rpi-low-risk"
style="color: #c8f7c5;">
<strong>
Risque Faible:
</strong>
Pas d'analyse, affichage au poste : Alerte d'un Problème.
Faire communication par mail au TOP 5 (informer les managers) + Présentation piéces et affichage au poste : Alerte d'un Problème.
<br>
➥ Cloture manuelle aprés un mois si absence de récurrence, si récurrence conserver la nouvelle FNC et cloturer la premiére occurrence.
</div>
{% endif %}
</div>
Expand Down Expand Up @@ -213,7 +215,7 @@
<label
for="archivingCommentary"
class="form-label text-white">
Commentaire d'archivage obligatoire (Ecrire le commentaire pour faire apparaitre le bouton d'archivage)
Commentaire d'archivage obligatoire, si la fiche ne respecte pas le standard prévu (Ecrire le commentaire pour faire apparaitre le bouton d'archivage)
<div
data-archiving-commentary-target="archivingCommentaryMessage"
class="archivingCommentaryMessage-message d-flex justify-content-evenly"></div>
Expand Down Expand Up @@ -255,7 +257,7 @@
<label
for="closingCommentary"
class="form-label text-white">
Commentaire de cloture obligatoire (Ecrire le commentaire pour faire apparaitre le bouton de cloture)
Commentaire de cloture obligatoire, si les actions sont cloturées dans le PDCA de l'UAP concerné (Ecrire le commentaire pour faire apparaitre le bouton de cloture)
<div
data-closing-commentary-target="closingCommentaryMessage"
class="closingCommentaryMessage-message d-flex justify-content-evenly"></div>
Expand Down
72 changes: 72 additions & 0 deletions templates/services/email_templates/reminderEmailToAdmin.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<p>
Bonjour,
</p>

<p>
Voici la liste des Fiches de Non Conformités de risques faibles en attente de clotures (vous pouvez cliquer sur les liens pour les consulter) :
</p>

<div
name="form_list"
style="margin-bottom: 20px; border-radius: 10px; flex-grow: 1; padding: 0;">
<ul
style="background-color: azure; list-style-type: none; padding: 0; margin: 0;">

{% for efnc in oldEfncs %}
<li
style="margin: 0; padding: 0;">
<a
target="_top"
href="http://slanlp0040/efnc/form{{efnc.id}}_modification_display"
style="display: block; padding: 10px; text-decoration: none; color: inherit; background-color: lightgrey; border: 1px solid #ccc; border-radius: 5px; margin-bottom: 10px;">

<span
style="display: flex; justify-content: space-between; align-items: center;">
<span
style="flex: 1; text-align: center; display: inline-block;">
{{ efnc.Title|upper|split('_')|first }}
{{ efnc.id|upper }}
</span>
<span
style="flex: 0; padding: 0 5px; display: inline-block;">
|
</span>
<span
style="flex: 2; text-align: center; display: inline-block;">
{{ efnc.nonConformityOrigin.name|upper }}
</span>
<span
style="flex: 0; padding: 0 5px; display: inline-block;">
|
</span>
<span
style="flex: 5; text-align: center; display: inline-block;">
{{ efnc.product.category.name|upper }}
-
{{ efnc.product.version.name|upper }}
-
{{ efnc.product.color.name|upper }}
</span>
<span
style="flex: 0; padding: 0 5px; display: inline-block;">
|
</span>
<span
style="flex: 1; text-align: center; display: inline-block;">
{{ efnc.Project.name|upper }}
</span>
<span
style="flex: 0; padding: 0 5px; display: inline-block;">
|
</span>
<span
style="flex: 1; text-align: center; display: inline-block;">
{{ efnc.CreatedAt|date('d/m/Y') }}
</span>
</span>

</a>
</li>
{% endfor %}
</ul>
</div>

0 comments on commit 9b06c96

Please sign in to comment.