From 30995316ae4b5fc7a8c0186168aad5c5c0828ba8 Mon Sep 17 00:00:00 2001 From: ewandor Date: Wed, 5 Jul 2023 16:18:57 +0200 Subject: [PATCH 1/6] Adding a column for community work penalties on Criminal Documents --- migrations/Version20230705133033.php | 29 +++++++++++++++++++++ src/Entity/Criminal.php | 18 +++++++++++++ src/Form/CriminalType.php | 1 + templates/_cells/documentTable.html.twig | 4 +++ templates/document/types/Criminal.html.twig | 1 + translations/messages+intl-icu.en.yaml | 3 +++ translations/messages+intl-icu.fr.yaml | 3 +++ 7 files changed, 59 insertions(+) create mode 100644 migrations/Version20230705133033.php diff --git a/migrations/Version20230705133033.php b/migrations/Version20230705133033.php new file mode 100644 index 0000000..2c8381f --- /dev/null +++ b/migrations/Version20230705133033.php @@ -0,0 +1,29 @@ +addSql('ALTER TABLE criminal ADD amount_community_work INT AFTER amount_time'); + } + + public function down(Schema $schema): void + { + $this->addSql('ALTER TABLE criminal DROP amount_community_work'); + } +} diff --git a/src/Entity/Criminal.php b/src/Entity/Criminal.php index 5478f62..a6ac31e 100644 --- a/src/Entity/Criminal.php +++ b/src/Entity/Criminal.php @@ -31,6 +31,12 @@ class Criminal extends Document */ private $amountTime; + /** + * @ORM\Column(type="integer", nullable=true) + * @Gedmo\Versioned + */ + private $amountCommunityWork; + /** * @ORM\Column(type="text", length=4294967295, nullable=true) * @Gedmo\Versioned @@ -83,6 +89,18 @@ class Criminal extends Document return $this; } + public function getAmountCommunityWork(): ?int + { + return $this->amountCommunityWork; + } + + public function setAmountCommunityWork(?int $amountCommunityWork): self + { + $this->amountCommunityWork = $amountCommunityWork; + + return $this; + } + public function getContent(): ?string { return $this->content; diff --git a/src/Form/CriminalType.php b/src/Form/CriminalType.php index e187441..f1f78a4 100644 --- a/src/Form/CriminalType.php +++ b/src/Form/CriminalType.php @@ -20,6 +20,7 @@ class CriminalType extends DocumentType ->add('content', ContentType::class, ['label' => 'form_label_informations' ]) ->add('amountMoney', null, ['label' => 'form_label_amount', 'help' => 'form_help_amount']) ->add('amountTime', null, ['label' => 'form_label_time', 'help' => 'form_help_time']) + ->add('amountCommunityWork', null, ['label' => 'form_label_community_work', 'help' => 'form_help_community_work']) ; } diff --git a/templates/_cells/documentTable.html.twig b/templates/_cells/documentTable.html.twig index 22f6ee1..7f75a08 100644 --- a/templates/_cells/documentTable.html.twig +++ b/templates/_cells/documentTable.html.twig @@ -84,6 +84,10 @@
{% trans %}title_hours{% endtrans %}: {{ i.amountTime ? i.amountTime ~ ' h' :'value_no_value'|trans}} {% endif %} + {% if i.amountCommunityWork is defined %} +
{% trans %}title_community_work{% endtrans %}: + {{ i.amountCommunityWork ? i.amountCommunityWork ~ ' h' :'value_no_value'|trans}} + {% endif %} {% if i.accessorySentence is defined and i.accessorySentence is not null %}
{% trans %}title_accessorySentence{% endtrans %} : {{ 'value_yes'|trans}} {% endif %} diff --git a/templates/document/types/Criminal.html.twig b/templates/document/types/Criminal.html.twig index 2126759..cc053fd 100644 --- a/templates/document/types/Criminal.html.twig +++ b/templates/document/types/Criminal.html.twig @@ -7,4 +7,5 @@ \ No newline at end of file diff --git a/translations/messages+intl-icu.en.yaml b/translations/messages+intl-icu.en.yaml index 76680f1..adb5f87 100644 --- a/translations/messages+intl-icu.en.yaml +++ b/translations/messages+intl-icu.en.yaml @@ -257,6 +257,7 @@ form_help_cant_edit_lastname: You cannot edit your first last name form_help_checkbox_adminmode: Check the box to switch the user to admin mode form_help_checkbox_isdesactivated: Check the box to prevent the user from using their account, without deleting it form_help_checkbox_isverified: This box is automatically checked when the user validates his email address. +form_help_community_work: Indicate the duration of community work retained on the criminal record form_help_firstname: First name form_help_gang: Select an associated group form_help_gender: Indicate the person's gender @@ -297,6 +298,7 @@ form_label_checkbox_adminmode: Admin Mode form_label_checkbox_isdesactivated: account Disabled form_label_checkbox_isverified: Email verified form_label_color: Color +form_label_community_work: Total Community Work Duration form_label_complaint_status: Complaint status form_label_content: Content form_label_dead: Deceased @@ -651,6 +653,7 @@ title_comment_add: Add a comment title_comment_belong_document: This belong to title_comment_edition: Edit a comment title_comments: Comments +title_community_work: Hours of Community Work title_complaint: Complaint title_complaints: Complaints title_count: total number diff --git a/translations/messages+intl-icu.fr.yaml b/translations/messages+intl-icu.fr.yaml index d063134..2b89cef 100644 --- a/translations/messages+intl-icu.fr.yaml +++ b/translations/messages+intl-icu.fr.yaml @@ -257,6 +257,7 @@ form_help_cant_edit_lastname: Vous ne pouvez pas éditer votre nom form_help_checkbox_adminmode: Cochez la case pour passer l'utilisateur en mode admin form_help_checkbox_isdesactivated: Cochez la case pour empêcher l'utilisateur d'utiliser son compte, sans l'effacer form_help_checkbox_isverified: Cette case est cochée automatiquement lorsque l'utilisateur valide son adresse email +form_help_community_work: Indiquez le durée des travaux d'intérêt général retenus sur le casier form_help_firstname: Prénom form_help_gang: Séléctionnez un groupe associé a cette personne form_help_gender: Indiquez le genre de la personne @@ -297,6 +298,7 @@ form_label_checkbox_adminmode: Mode Admin form_label_checkbox_isdesactivated: Compte désactivé form_label_checkbox_isverified: Email vérifié form_label_color: Couleur +form_label_community_work: Durée totale TIG form_label_complaint_status: Etat de la plainte form_label_content: Contenu form_label_dead: Individu décédé @@ -650,6 +652,7 @@ title_comment_add: Ajouter un commentaire title_comment_belong_document: Ce document appartient title_comment_edition: Éditer un commentaire title_comments: Commentaires +title_community_work: Heures de TIG title_complaint: Plainte title_complaints: Plaintes title_count: Nombre total From 545f7facaf23fc2d763225787f2f5d6380072879 Mon Sep 17 00:00:00 2001 From: ewandor Date: Sat, 8 Jul 2023 02:45:16 +0200 Subject: [PATCH 2/6] Adding columns on Criminal to track sentences progression --- migrations/Version20230705133715.php | 30 ++++++++ src/Entity/Criminal.php | 83 +++++++++++++++++++++ src/Form/CriminalType.php | 3 + templates/_cells/documentTable.html.twig | 12 ++- templates/document/types/Criminal.html.twig | 30 +++++++- 5 files changed, 152 insertions(+), 6 deletions(-) create mode 100644 migrations/Version20230705133715.php diff --git a/migrations/Version20230705133715.php b/migrations/Version20230705133715.php new file mode 100644 index 0000000..9319fa6 --- /dev/null +++ b/migrations/Version20230705133715.php @@ -0,0 +1,30 @@ +addSql('ALTER TABLE criminal ADD amount_money_settled DOUBLE PRECISION DEFAULT NULL, ADD amount_time_settled INT DEFAULT NULL, ADD amount_community_work_settled INT DEFAULT NULL'); + $this->addSql('UPDATE criminal SET amount_money_settled = amount_money, amount_time_settled = amount_time, amount_community_work_settled = amount_community_work'); + } + + public function down(Schema $schema): void + { + $this->addSql('ALTER TABLE criminal DROP amount_money_settled, DROP amount_time_settled, DROP amount_community_work_settled'); + } +} diff --git a/src/Entity/Criminal.php b/src/Entity/Criminal.php index a6ac31e..dfbfe0a 100644 --- a/src/Entity/Criminal.php +++ b/src/Entity/Criminal.php @@ -2,6 +2,7 @@ namespace App\Entity; +use \OutOfRangeException; use App\Entity\Document; use Doctrine\ORM\Mapping as ORM; use App\Repository\CriminalRepository; @@ -13,6 +14,10 @@ use Symfony\Component\Validator\Constraints as Assert; */ class Criminal extends Document { + const TYPE_JAIL = 'jail'; + const TYPE_FINE = 'fine'; + const TYPE_COMMUNITY_WORK = 'community_work'; + /** * @ORM\ManyToOne(targetEntity=Directory::class, inversedBy="criminals") * @ORM\JoinColumn(nullable=false) @@ -47,6 +52,24 @@ class Criminal extends Document */ private $content; + /** + * @ORM\Column(type="float", nullable=true) + * @Gedmo\Versioned + */ + private $amountMoneySettled; + + /** + * @ORM\Column(type="integer", nullable=true) + * @Gedmo\Versioned + */ + private $amountTimeSettled; + + /** + * @ORM\Column(type="integer", nullable=true) + * @Gedmo\Versioned + */ + private $amountCommunityWorkSettled; + public function __construct(User $user) { parent::__construct($user); @@ -112,4 +135,64 @@ class Criminal extends Document return $this; } + + public function getAmountMoneySettled(): ?float + { + return $this->amountMoneySettled; + } + + public function setAmountMoneySettled(?float $amountMoneySettled): self + { + $this->amountMoneySettled = $amountMoneySettled; + + return $this; + } + + public function getAmountTimeSettled(): ?int + { + return $this->amountTimeSettled; + } + + public function setAmountTimeSettled(?int $amountTimeSettled): self + { + $this->amountTimeSettled = $amountTimeSettled; + + return $this; + } + + public function getAmountCommunityWorkSettled(): ?int + { + return $this->amountCommunityWorkSettled; + } + + public function setAmountCommunityWorkSettled(?int $amountCommunityWorkSettled): self + { + $this->amountCommunityWorkSettled = $amountCommunityWorkSettled; + + return $this; + } + + public function addSettlement($type, $amount) { + if ($type == Criminal::TYPE_FINE) { + if ($this->getAmountMoney() - $this->getAmountMoneySettled() < $amount) { + throw new OutOfRangeException(); + } + $this->setAmountMoneySettled($this->getAmountMoneySettled() + $amount); + } elseif ($type == Criminal::TYPE_JAIL) { + if ($this->getAmountTime() - $this->getAmountTimeSettled() < $amount) { + throw new OutOfRangeException(); + } + $this->setAmountTimeSettled($this->getAmountTimeSettled() + $amount); + + } elseif ($type == Criminal::TYPE_COMMUNITY_WORK) { + if ($this->getAmountCommunityWork() - $this->getAmountCommunityWorkSettled() < $amount) { + throw new OutOfRangeException(); + } + $this->setAmountCommunityWorkSettled($this->getAmountCommunityWorkSettled() + $amount); + } else { + throw new OutOfRangeException(); + } + + return $this; + } } diff --git a/src/Form/CriminalType.php b/src/Form/CriminalType.php index f1f78a4..900323a 100644 --- a/src/Form/CriminalType.php +++ b/src/Form/CriminalType.php @@ -21,6 +21,9 @@ class CriminalType extends DocumentType ->add('amountMoney', null, ['label' => 'form_label_amount', 'help' => 'form_help_amount']) ->add('amountTime', null, ['label' => 'form_label_time', 'help' => 'form_help_time']) ->add('amountCommunityWork', null, ['label' => 'form_label_community_work', 'help' => 'form_help_community_work']) + ->add('amountMoneySettled', null, ['label' => 'form_label_amount_settled', 'help' => 'form_help_amount_settled']) + ->add('amountTimeSettled', null, ['label' => 'form_label_time_settled', 'help' => 'form_help_time_settled']) + ->add('amountCommunityWorkSettled', null, ['label' => 'form_label_community_work_settled', 'help' => 'form_help_community_work_settled']) ; } diff --git a/templates/_cells/documentTable.html.twig b/templates/_cells/documentTable.html.twig index 7f75a08..119ce09 100644 --- a/templates/_cells/documentTable.html.twig +++ b/templates/_cells/documentTable.html.twig @@ -78,15 +78,21 @@ {% endif %} {% if i.amountMoney is defined %}
{% trans %}title_amount{% endtrans %}: - {{ i.amountMoney ? i.amountMoney ~ ' ' ~'currency_symbol'|trans :'value_no_value'|trans }} + {{ i.amountMoney ? i.amountMoney ~ ' ' ~'currency_symbol'|trans : 'value_no_value'|trans }} + {{ i.amountMoney == i.amountMoneySettled ? '✅' : '❌'}} + {% endif %} {% if i.amountTime is defined %}
{% trans %}title_hours{% endtrans %}: - {{ i.amountTime ? i.amountTime ~ ' h' :'value_no_value'|trans}} + {{ i.amountTime ? i.amountTime ~ 'h' : 'value_no_value'|trans}} + {{ i.amountTime == i.amountTimeSettled ? '✅' : '❌'}} + {% endif %} {% if i.amountCommunityWork is defined %}
{% trans %}title_community_work{% endtrans %}: - {{ i.amountCommunityWork ? i.amountCommunityWork ~ ' h' :'value_no_value'|trans}} + {{ i.amountCommunityWork ? i.amountCommunityWork ~ 'h' : 'value_no_value'|trans}} + {{ i.amountCommunityWork == i.amountCommunityWorkSettled ? '✅' : '❌'}} + {% endif %} {% if i.accessorySentence is defined and i.accessorySentence is not null %}
{% trans %}title_accessorySentence{% endtrans %} : {{ 'value_yes'|trans}} diff --git a/templates/document/types/Criminal.html.twig b/templates/document/types/Criminal.html.twig index cc053fd..8f72770 100644 --- a/templates/document/types/Criminal.html.twig +++ b/templates/document/types/Criminal.html.twig @@ -5,7 +5,31 @@
\ No newline at end of file From 2e6c6a8f97c889f64f29a17c05926d0c1c965640 Mon Sep 17 00:00:00 2001 From: ewandor Date: Sat, 8 Jul 2023 02:47:23 +0200 Subject: [PATCH 3/6] Adding a page to list all non executed sentences --- .../UnsettledSentenceController.php | 112 ++++++++++++++++++ src/Entity/SentenceSettlement.php | 79 ++++++++++++ src/Form/SentenceSettlementType.php | 60 ++++++++++ src/Repository/CriminalRepository.php | 18 +++ .../Tools/DocumentRepositoriesExtension.php | 2 +- templates/base.html.twig | 5 +- templates/sentence/line.html.twig | 31 +++++ templates/sentence/list.html.twig | 63 ++++++++++ translations/messages+intl-icu.en.yaml | 8 +- translations/messages+intl-icu.fr.yaml | 6 + 10 files changed, 381 insertions(+), 3 deletions(-) create mode 100644 src/Controller/UnsettledSentenceController.php create mode 100644 src/Entity/SentenceSettlement.php create mode 100644 src/Form/SentenceSettlementType.php create mode 100644 templates/sentence/line.html.twig create mode 100644 templates/sentence/list.html.twig diff --git a/src/Controller/UnsettledSentenceController.php b/src/Controller/UnsettledSentenceController.php new file mode 100644 index 0000000..f7deaa3 --- /dev/null +++ b/src/Controller/UnsettledSentenceController.php @@ -0,0 +1,112 @@ +createForm(SearchBarType::class); + $searchForm->handleRequest($request); + + $pagination = $paginator->paginate( + $CriminalRepository->listForUser($this->getUser()) + ->search(( + $searchForm->isSubmitted() + && $searchForm->isValid() + && $searchForm->getData()['subject'] !== null + ) ? $searchForm->getData()['subject'] : null) + ->limitUnsettled($type) + ->order(['createdAt' => 'DESC']) + ->getResult(), + $request->query->getInt('page', 1) + ); + + foreach ($pagination as $i => $criminal) { + $sentence = new SentenceSettlement($criminal, $type); + $form = $this->createForm( + SentenceSettlementType::class, + $sentence, + [ + 'action'=> $this->generateUrl('unsettled_sentence_settle'), + ]); + $pagination[$i]->form = $form->createView(); + } + + return $this->render('sentence/list.html.twig', [ + 'controller_name' => 'AdminController', + 'type' => $type, + 'pagination' => $pagination, + 'count' => $pagination->getTotalItemCount(), + 'searchForm' => $searchForm->createView(), + ]); + } + + #[Route('/settle', name: 'settle')] + public function settle( + Request $request, + CriminalRepository $CriminalRepository + ) { + $type = null; + $sentenceForm = $this->createForm(SentenceSettlementType::class); + $sentenceForm->handleRequest($request); + + if ($sentenceForm->isSubmitted() && $sentenceForm->isValid()) { + $formData = $sentenceForm->getData(); + $type = $formData['type']; + $criminal = $CriminalRepository->find($formData['criminal_id']); + if (!$criminal) { + $sentenceForm->addError(new FormError('error_document_not_found')); + } else { + try { + $criminal->addSettlement($type, $formData['amount']); + } catch (\OutOfRangeException $e) { + $sentenceForm->addError(new FormError('error_value_out_of_bound')); + } + } + if ($sentenceForm->isValid()) { + $entityManager = $this->getDoctrine()->getManager(); + $entityManager->persist($criminal); + try { + $entityManager->flush(); + } catch (\Throwable $th) { + if ($_ENV['APP_ENV'] === 'dev') { + throw $th; //DEBUG + } else { + $this->logger->error($th); + } + + $this->addFlash('danger', 'alert_error_editing_document'); + return $this->redirectToRoute($request->getRequestUri()); + } + } else { + $this->addFlash('warning', 'alert_error_form_post'); + } + } + + return $this->redirectToRoute('unsettled_sentence_list', ['type' => $type]); + } +} diff --git a/src/Entity/SentenceSettlement.php b/src/Entity/SentenceSettlement.php new file mode 100644 index 0000000..d3c207c --- /dev/null +++ b/src/Entity/SentenceSettlement.php @@ -0,0 +1,79 @@ +criminal = $criminal; + $this->type = $type; + } + + /** + * @return Criminal + */ + public function getCriminal(): Criminal + { + return $this->criminal; + } + + /** + * @param Criminal $criminal + */ + public function setCriminal(Criminal $criminal): void + { + $this->criminal = $criminal; + } + + /** + * @return Criminal + */ + public function getCriminalId(): int + { + return $this->criminal->getId(); + } + + /** + * @return string + */ + public function getType(): string + { + return $this->type; + } + + /** + * @param string $type + */ + public function setType(string $type): void + { + $this->type = $type; + } + + /** + * @return null + */ + public function getAmount() + { + return $this->amount; + } + + /** + * @param null $amount + */ + public function setAmount($amount): void + { + $this->amount = $amount; + } +} \ No newline at end of file diff --git a/src/Form/SentenceSettlementType.php b/src/Form/SentenceSettlementType.php new file mode 100644 index 0000000..d686ff3 --- /dev/null +++ b/src/Form/SentenceSettlementType.php @@ -0,0 +1,60 @@ +TokenStorage = $TokenStorage; + } + + public function buildForm(FormBuilderInterface $builder, array $options) + { + $sentence = $builder->getData(); + + if ($sentence) { + if ($sentence->getType() == "fine") { + $amountType = NumberType::class; + $amountLabel = 'form_label_paid'; + } else { + $amountType = IntegerType::class; + $amountLabel = 'form_label_executed'; + } + } else { + $amountType = null; + $amountLabel = null; + } + + $builder->add('criminal_id', HiddenType::class) + ->add('type', HiddenType::class) + ->add('amount', $amountType, ['label' => $amountLabel]) + ->add('submit', SubmitType::class, [ + 'label' => 'form_button_submit', + 'priority' => -900, + ]) + ; + } + + public function getBlockPrefix() + { + return ''; // return an empty string here + } + + + +} diff --git a/src/Repository/CriminalRepository.php b/src/Repository/CriminalRepository.php index 4872ffd..37c06e7 100644 --- a/src/Repository/CriminalRepository.php +++ b/src/Repository/CriminalRepository.php @@ -19,4 +19,22 @@ class CriminalRepository extends DocumentRepositoriesExtension parent::__construct($registry, Criminal::class); $this->fields = ['amountMoney', 'amountTime', 'content']; //with title, list fields we can search in } + + public function limitUnsettled(string $type) { + if ($type == Criminal::TYPE_FINE) { + $column = 'd.amountMoney'; + } elseif ($type == Criminal::TYPE_JAIL) { + $column = 'd.amountTime'; + } elseif ($type == Criminal::TYPE_COMMUNITY_WORK) { + $column = 'd.amountCommunityWork'; + } else { + throw new \OutOfRangeException($type); + } + + $settledColumn = $column . 'Settled'; + + $this->qb->where("$column <> $settledColumn OR ($column IS NOT NULL AND $settledColumn IS NULL)"); + + return $this; + } } diff --git a/src/Repository/Tools/DocumentRepositoriesExtension.php b/src/Repository/Tools/DocumentRepositoriesExtension.php index 0721497..1a13a81 100644 --- a/src/Repository/Tools/DocumentRepositoriesExtension.php +++ b/src/Repository/Tools/DocumentRepositoriesExtension.php @@ -12,7 +12,7 @@ use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; class DocumentRepositoriesExtension extends ServiceEntityRepository { public array $fields = []; - private QueryBuilder $qb; + protected QueryBuilder $qb; private ?QueryBuilder $qbsearch = null; private ?Group $group = null; private ?User $user = null; diff --git a/templates/base.html.twig b/templates/base.html.twig index f706353..7556998 100644 --- a/templates/base.html.twig +++ b/templates/base.html.twig @@ -152,7 +152,10 @@
  • vaccines{% trans %}title_medicals{% endtrans %}
  • - +
  • + sports{% trans %}title_unsettled_sentence_list{% endtrans %} +
  • + {% if app.user.hasPermission('group_administrate') %}
  • diff --git a/templates/sentence/line.html.twig b/templates/sentence/line.html.twig new file mode 100644 index 0000000..2497cba --- /dev/null +++ b/templates/sentence/line.html.twig @@ -0,0 +1,31 @@ + + + {{ i.directory.firstname }} {{ i.directory.lastname }} {% if i.directory.dead %}, {% trans %}title_dead{% endtrans %}{% endif %} + + + {% trans %}title_missing{% endtrans %}: + {% if type == 'fine' %} + {{ i.amountMoney - i.amountMoneySettled }} {{'currency_symbol'|trans}} + {% elseif type == 'jail' %} + {{ i.amountTime - i.amountTimeSettled }} {{'title_hours'|trans}} + {% elseif type == 'community_work' %} + {{ i.amountCommunityWork - i.amountCommunityWorkSettled }} {{'title_hours'|trans}} + {% endif %} +
    + {{ form_start(i.form) }} + +
    + {{ form_label(i.form.amount) }} +
    + {{ form_widget(i.form.amount) }} + {{ form_widget(i.form.submit, { 'label': 'button_ok' }) }} +
    + {{ form_end(i.form) }} + + + {{i.createdAt |date('_datetime.format'|trans)}} + + + {% include '_cells/documentActions.html.twig' with {'document': i, 'noedit': true, 'nodelete': true, 'noarchive': true} %} + + \ No newline at end of file diff --git a/templates/sentence/list.html.twig b/templates/sentence/list.html.twig new file mode 100644 index 0000000..b81af89 --- /dev/null +++ b/templates/sentence/list.html.twig @@ -0,0 +1,63 @@ +{% extends 'base.html.twig' %} + +{% block title %}{{ "title_unsettled_sentence_list"|trans }}{% endblock %} + +{% block body %} +
    +
    {{form(searchForm)}}
    +
    + +
    +

    {{ 'title_count'|trans }}: {{ count }}

    + {% if pagination[0].directory is not defined %}{% set nodirectorylink = true %}{% endif %} + {% set slicelimit = (limit is defined)? limit : null %} + {% set counter = 0 %} + + {% if pagination|length > 0 %} +
    + + + + + + + {% if noaction is not defined %} + + {% endif %} + + + + {% for i in pagination |slice(0, slicelimit) %} + {% set counter = counter + 1 %} + {% include 'sentence/line.html.twig' with {'sentence': i, 'type': type } %} + {% endfor %} + +
    {% trans %}title_name{% endtrans %}{% trans %}title_missing{% endtrans %}{% trans %}title_date{% endtrans %}{% trans %}tooltip_view{% endtrans %}
    +
    + + {% if slicelimit is not null and pagination|length > slicelimit %} +
    +
    + {% if nodirectorylink is not defined %} + {% trans %}button_view_more{% endtrans %} + {% else %} + {% trans %}button_view_more{% endtrans %} + {% endif %} +
    +
    + {% endif %} + + {% else %} +

    {% trans %}no_data{% endtrans %}

    + {% endif %} +
    + +
    +
    + {{ knp_pagination_render(pagination) }} +
    +{% endblock %} diff --git a/translations/messages+intl-icu.en.yaml b/translations/messages+intl-icu.en.yaml index adb5f87..3f69dac 100644 --- a/translations/messages+intl-icu.en.yaml +++ b/translations/messages+intl-icu.en.yaml @@ -304,6 +304,7 @@ form_label_content: Content form_label_dead: Deceased form_label_download_image: Download picture form_label_email: Email Adress +form_label_executed: Executed form_label_firstname: Firstname form_label_folder_name: Folder name form_label_gang_info: Informations about Group member @@ -335,6 +336,7 @@ form_label_model: Template form_label_motd: M.O.T.D. form_label_name: Name form_label_numberplate: Numberplate +form_label_paid: Paid form_label_password: Password form_label_permissions: Permissions form_label_power: Power @@ -704,6 +706,7 @@ title_errorpage_error: Error title_faceImage: Face photo title_field: Fields title_filter: Filters +title_fines: Fines title_folder_add_directories: List of Directories for adding to a folder title_folder_add_directory: Adding a directory to the folder title_folder_add_documents: Adding a document to the folder @@ -736,6 +739,7 @@ title_group_view_documents: Group's documents title_group_view: View group title_group: group title_groups: groups +title_jail_time: Jail title_hasnopapers: without papers title_height: Height title_history: History @@ -775,6 +779,7 @@ title_medical_trusted: Trusted people title_medicals: Medical visits title_members: Members title_merge_directory: Merges directories +title_missing: Missing title_model: Template title_motd: M.O.T.D title_name: Name @@ -819,7 +824,8 @@ title_users_book: Book title_users_documents: User's documents title_users_list: List of users title_users_sanctions: User's sanctions -title_users: Users +title_users: Users +title_unsettled_sentence_list: Unsettled sentences title_value: Value title_verified: Verified title_versus: Versus diff --git a/translations/messages+intl-icu.fr.yaml b/translations/messages+intl-icu.fr.yaml index 2b89cef..74bf724 100644 --- a/translations/messages+intl-icu.fr.yaml +++ b/translations/messages+intl-icu.fr.yaml @@ -304,6 +304,7 @@ form_label_content: Contenu form_label_dead: Individu décédé form_label_download_image: Télécharger l'image form_label_email: Adresse Email +form_label_executed: Effectuées form_label_firstname: Prénom form_label_folder_name: Nom du dossier form_label_gang_info: Informations du membre dans le Groupe associé @@ -335,6 +336,7 @@ form_label_model: Modèle form_label_motd: M.O.T.D. form_label_name: Nom form_label_numberplate: Plaque d'immatriculation +form_label_paid: Payée form_label_password: Mot de passe form_label_permissions: Permissions form_label_power: Power @@ -703,6 +705,7 @@ title_errorpage_error: Ouups ! title_faceImage: Photo de Face title_field: Champs title_filter: Filtre +title_fines: Amendes title_folder_add_directories: Liste des fiches pour ajout au dossier title_folder_add_directory: Ajouter une fiche au dossier title_folder_add_documents: Ajouter un document au dossier @@ -735,6 +738,7 @@ title_group_view_documents: Voir les documents du groupe title_group_view: Voir un groupe title_group: Groupe title_groups: Groupes +title_jail_time: Prison title_hasnopapers: Sans papier title_height: Taille title_history: Historique @@ -776,6 +780,7 @@ title_members: Membres title_merge_directory: Fusionner les fiches title_model: Modèle title_motd: M.O.T.D +title_missing: Manquant title_name: Nom title_navigation: Menu title_noauthor: Pas d'utilisateur @@ -819,6 +824,7 @@ title_users_documents: Documents de l'utilisateur title_users_list: Liste des Utilisateurs title_users_sanctions: Sanctions de l'utilisateur title_users: Utilisateurs +title_unsettled_sentence_list: Sentences en cours title_value: Valeur title_verified: Vérifié title_versus: Contre From c4e2ae721e87d2451700282535283edfcf6dc81c Mon Sep 17 00:00:00 2001 From: ewandor Date: Sat, 8 Jul 2023 12:49:47 +0200 Subject: [PATCH 4/6] Correcting PHPCS and PHPStan comments --- .../UnsettledSentenceController.php | 18 +++++++------- src/Entity/Criminal.php | 12 +++++----- src/Entity/SentenceSettlement.php | 9 ++----- src/Form/CriminalType.php | 24 +++++++++++++++---- src/Form/SentenceSettlementType.php | 3 --- src/Repository/CriminalRepository.php | 3 ++- 6 files changed, 40 insertions(+), 29 deletions(-) diff --git a/src/Controller/UnsettledSentenceController.php b/src/Controller/UnsettledSentenceController.php index f7deaa3..5517742 100644 --- a/src/Controller/UnsettledSentenceController.php +++ b/src/Controller/UnsettledSentenceController.php @@ -2,16 +2,12 @@ namespace App\Controller; -use App\Entity\Criminal; -use App\Entity\Directory; use App\Entity\SentenceSettlement; -use App\Entity\User; use App\Form\SearchBarType; use App\Form\SentenceSettlementType; use App\Repository\CriminalRepository; -use App\Repository\DirectoryRepository; -use Doctrine\ORM\EntityManagerInterface; use Knp\Component\Pager\PaginatorInterface; +use Psr\Log\LoggerInterface; use Symfony\Component\Form\FormError; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; @@ -21,6 +17,13 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; #[Route('/unsettled_sentence', name: 'unsettled_sentence_')] class UnsettledSentenceController extends AbstractController { + private LoggerInterface $logger; + + public function __construct(LoggerInterface $logger) + { + $this->logger = $logger; + } + #[Route('/list/{type?*}', name: 'list')] public function list( PaginatorInterface $paginator, @@ -50,9 +53,8 @@ class UnsettledSentenceController extends AbstractController $form = $this->createForm( SentenceSettlementType::class, $sentence, - [ - 'action'=> $this->generateUrl('unsettled_sentence_settle'), - ]); + ['action' => $this->generateUrl('unsettled_sentence_settle'),] + ); $pagination[$i]->form = $form->createView(); } diff --git a/src/Entity/Criminal.php b/src/Entity/Criminal.php index dfbfe0a..025ee24 100644 --- a/src/Entity/Criminal.php +++ b/src/Entity/Criminal.php @@ -2,7 +2,7 @@ namespace App\Entity; -use \OutOfRangeException; +use OutOfRangeException; use App\Entity\Document; use Doctrine\ORM\Mapping as ORM; use App\Repository\CriminalRepository; @@ -14,9 +14,9 @@ use Symfony\Component\Validator\Constraints as Assert; */ class Criminal extends Document { - const TYPE_JAIL = 'jail'; - const TYPE_FINE = 'fine'; - const TYPE_COMMUNITY_WORK = 'community_work'; + public const TYPE_JAIL = 'jail'; + public const TYPE_FINE = 'fine'; + public const TYPE_COMMUNITY_WORK = 'community_work'; /** * @ORM\ManyToOne(targetEntity=Directory::class, inversedBy="criminals") @@ -172,7 +172,8 @@ class Criminal extends Document return $this; } - public function addSettlement($type, $amount) { + public function addSettlement($type, $amount) + { if ($type == Criminal::TYPE_FINE) { if ($this->getAmountMoney() - $this->getAmountMoneySettled() < $amount) { throw new OutOfRangeException(); @@ -183,7 +184,6 @@ class Criminal extends Document throw new OutOfRangeException(); } $this->setAmountTimeSettled($this->getAmountTimeSettled() + $amount); - } elseif ($type == Criminal::TYPE_COMMUNITY_WORK) { if ($this->getAmountCommunityWork() - $this->getAmountCommunityWorkSettled() < $amount) { throw new OutOfRangeException(); diff --git a/src/Entity/SentenceSettlement.php b/src/Entity/SentenceSettlement.php index d3c207c..5f8742a 100644 --- a/src/Entity/SentenceSettlement.php +++ b/src/Entity/SentenceSettlement.php @@ -4,10 +4,6 @@ namespace App\Entity; class SentenceSettlement { - const TYPE_JAIL = 'jail'; - const TYPE_FINE = 'fine'; - const TYPE_COMMUNITY_WORK = 'community_work'; - private Criminal $criminal; private string $type; private $amount = null; @@ -15,8 +11,7 @@ class SentenceSettlement public function __construct( Criminal $criminal, string $type - ) - { + ) { $this->criminal = $criminal; $this->type = $type; } @@ -76,4 +71,4 @@ class SentenceSettlement { $this->amount = $amount; } -} \ No newline at end of file +} diff --git a/src/Form/CriminalType.php b/src/Form/CriminalType.php index 900323a..0dccf5e 100644 --- a/src/Form/CriminalType.php +++ b/src/Form/CriminalType.php @@ -20,10 +20,26 @@ class CriminalType extends DocumentType ->add('content', ContentType::class, ['label' => 'form_label_informations' ]) ->add('amountMoney', null, ['label' => 'form_label_amount', 'help' => 'form_help_amount']) ->add('amountTime', null, ['label' => 'form_label_time', 'help' => 'form_help_time']) - ->add('amountCommunityWork', null, ['label' => 'form_label_community_work', 'help' => 'form_help_community_work']) - ->add('amountMoneySettled', null, ['label' => 'form_label_amount_settled', 'help' => 'form_help_amount_settled']) - ->add('amountTimeSettled', null, ['label' => 'form_label_time_settled', 'help' => 'form_help_time_settled']) - ->add('amountCommunityWorkSettled', null, ['label' => 'form_label_community_work_settled', 'help' => 'form_help_community_work_settled']) + ->add( + 'amountCommunityWork', + null, + ['label' => 'form_label_community_work', 'help' => 'form_help_community_work'] + ) + ->add( + 'amountMoneySettled', + null, + ['label' => 'form_label_amount_settled', 'help' => 'form_help_amount_settled'] + ) + ->add( + 'amountTimeSettled', + null, + ['label' => 'form_label_time_settled', 'help' => 'form_help_time_settled'] + ) + ->add( + 'amountCommunityWorkSettled', + null, + ['label' => 'form_label_community_work_settled', 'help' => 'form_help_community_work_settled'] + ) ; } diff --git a/src/Form/SentenceSettlementType.php b/src/Form/SentenceSettlementType.php index d686ff3..71a6cda 100644 --- a/src/Form/SentenceSettlementType.php +++ b/src/Form/SentenceSettlementType.php @@ -54,7 +54,4 @@ class SentenceSettlementType extends AbstractType { return ''; // return an empty string here } - - - } diff --git a/src/Repository/CriminalRepository.php b/src/Repository/CriminalRepository.php index 37c06e7..bbe80a1 100644 --- a/src/Repository/CriminalRepository.php +++ b/src/Repository/CriminalRepository.php @@ -20,7 +20,8 @@ class CriminalRepository extends DocumentRepositoriesExtension $this->fields = ['amountMoney', 'amountTime', 'content']; //with title, list fields we can search in } - public function limitUnsettled(string $type) { + public function limitUnsettled(string $type) + { if ($type == Criminal::TYPE_FINE) { $column = 'd.amountMoney'; } elseif ($type == Criminal::TYPE_JAIL) { From 2c83b7080c7b6844ace99f482817fbfabda7d476 Mon Sep 17 00:00:00 2001 From: ewandor Date: Tue, 25 Jul 2023 23:06:21 +0200 Subject: [PATCH 5/6] Adding missing translations --- translations/messages+intl-icu.en.yaml | 5 +++++ translations/messages+intl-icu.fr.yaml | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/translations/messages+intl-icu.en.yaml b/translations/messages+intl-icu.en.yaml index 3f69dac..5c247cd 100644 --- a/translations/messages+intl-icu.en.yaml +++ b/translations/messages+intl-icu.en.yaml @@ -251,6 +251,7 @@ form_help_accessorySentence: Indicate here the information if addition of access form_help_allowedgroups: Check the groups allowed to access this form_help_allowedsubgroups: This document will be only available for those subgroups form_help_amount: Enter a monetary value +form_help_amount_settled: Entrez une valeur monétaire form_help_arrested_at: Enter the date of arrest form_help_cant_edit_firstname: You cannot edit your first name form_help_cant_edit_lastname: You cannot edit your first last name @@ -278,6 +279,7 @@ form_help_phone: Enter the phone number form_help_power: The power determines the level for the permissions (the higher the power, the more important it is) form_help_search: Indicate the subject of your research. For a date, use the format DD / MM / YYYY form_help_time: Indicate the duration retained on the locker +form_help_time_settled: Indicate the duration executed by the convict form_help_until: Indicate the date on which the permit can be surrendered form_help_versus: Indicate against whom the complaint is made (X if unknown) form_help_wanted: Declare the deceased individual, remember to make a death certificate @@ -289,6 +291,7 @@ form_label_allowedgroups: Authorized groups form_label_allowedsubgroups: Allowed subgroups form_label_allowShare: Check this box to allow public sharing form_label_amount: Total Amount +form_label_amount_settled: Total Amount acquitted form_label_archive: Archives form_label_arrested_at: Arrest form_label_asked_for_lawyer: Request for a lawyer @@ -299,6 +302,7 @@ form_label_checkbox_isdesactivated: account Disabled form_label_checkbox_isverified: Email verified form_label_color: Color form_label_community_work: Total Community Work Duration +form_label_community_work_settled: Total executed Community Work form_label_complaint_status: Complaint status form_label_content: Content form_label_dead: Deceased @@ -351,6 +355,7 @@ form_label_shortName: Short Name form_label_status: Status form_label_subgroups: Speciality form_label_time: Total Duration +form_label_time_settled: Total Duration Executed form_label_title: Title form_label_type: Type form_label_until: until diff --git a/translations/messages+intl-icu.fr.yaml b/translations/messages+intl-icu.fr.yaml index 74bf724..1ee0aa6 100644 --- a/translations/messages+intl-icu.fr.yaml +++ b/translations/messages+intl-icu.fr.yaml @@ -251,6 +251,7 @@ form_help_accessorySentence: Indiquer ici les informations si ajout de peine(s) form_help_allowedgroups: Cochez les groupes autorisés à accéder à ceci form_help_allowedsubgroups: Ce document sera uniquement accessible aux specialitées cochées form_help_amount: Entrez une valeur monétaire +form_help_amount_settled: Entrez une valeur monétaire form_help_arrested_at: Entrez la date d'arrestation form_help_cant_edit_firstname: Vous ne pouvez pas éditer votre prénom form_help_cant_edit_lastname: Vous ne pouvez pas éditer votre nom @@ -278,6 +279,7 @@ form_help_phone: Indiquez le numéro de téléphone form_help_power: Le power détermine le niveau pour les permissions (plus le power est haut, plus il est important) form_help_search: Indiquez le sujet de votre recherche. Pour une date, utilisez le format JJ/MM/AAAA form_help_time: Indiquez la durée retenue sur le casier +form_help_time_settled: Indiquez la durée effectuée par le prévenu form_help_until: Indiquez la date à laquelle le permis peut être redonné form_help_versus: Indiquez contre qui la plainte est déposée (X si inconnu) form_help_wanted: Déclarer l'individu décédé, pensez à faire un Acte de décès @@ -289,6 +291,7 @@ form_label_allowedgroups: Groupes autorisés form_label_allowedsubgroups: Specialitées autorisées en acces form_label_allowShare: Cochez cette case pour autoriser le partage public form_label_amount: Montant total +form_label_amount_settled: Montant total acquitté form_label_archive: Archives form_label_arrested_at: Arrestation form_label_asked_for_lawyer: Demande d'un avocat @@ -299,6 +302,7 @@ form_label_checkbox_isdesactivated: Compte désactivé form_label_checkbox_isverified: Email vérifié form_label_color: Couleur form_label_community_work: Durée totale TIG +form_label_community_work_settled: Durée totale TIG effectués form_label_complaint_status: Etat de la plainte form_label_content: Contenu form_label_dead: Individu décédé @@ -351,6 +355,7 @@ form_label_shortName: Nom court form_label_status: Statut form_label_subgroups: Spécialités form_label_time: Durée totale +form_label_time_settled: Durée totale effectuée form_label_title: Titre form_label_type: Type form_label_until: Jusqu'à From f4972765759593107d2ebdbef62e8c54e358188e Mon Sep 17 00:00:00 2001 From: ewandor Date: Tue, 25 Jul 2023 23:08:15 +0200 Subject: [PATCH 6/6] Correcting error made un CriminalRepository query generator causing an error outside of admin mod --- src/Repository/CriminalRepository.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Repository/CriminalRepository.php b/src/Repository/CriminalRepository.php index bbe80a1..726d178 100644 --- a/src/Repository/CriminalRepository.php +++ b/src/Repository/CriminalRepository.php @@ -34,7 +34,7 @@ class CriminalRepository extends DocumentRepositoriesExtension $settledColumn = $column . 'Settled'; - $this->qb->where("$column <> $settledColumn OR ($column IS NOT NULL AND $settledColumn IS NULL)"); + $this->qb->andWhere("$column <> $settledColumn OR ($column IS NOT NULL AND $settledColumn IS NULL)"); return $this; }