Compare commits

...

3 Commits

8 changed files with 51 additions and 30 deletions

View File

@@ -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();
}

View File

@@ -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();

View File

@@ -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;
}

View File

@@ -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']
)
;
}

View File

@@ -54,7 +54,4 @@ class SentenceSettlementType extends AbstractType
{
return ''; // return an empty string here
}
}

View File

@@ -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) {
@@ -33,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;
}

View File

@@ -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

View File

@@ -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'à