Browse Source

Add Assert in Entity & update form template

pull/1/head
Franck J 2 years ago
parent
commit
8360d5d74a
  1. 27
      assets/css/app.css
  2. BIN
      assets/images/favicon.ico
  3. 1
      config/packages/twig.yaml
  4. 28
      public/build/app.css
  5. BIN
      public/build/images/favicon.ico
  6. 1
      public/build/manifest.json
  7. 2
      public/build/vendors~app.js
  8. 6
      src/Entity/Facture.php
  9. 11
      src/Form/FactureType.php
  10. 43
      templates/base.html.twig
  11. 28
      templates/facture/_form.html.twig
  12. 12
      templates/facture/create.html.twig
  13. 2
      templates/include/header.html.twig

27
assets/css/app.css

@ -1,24 +1,17 @@
body {
background-color: floralwhite !important;
color: #312f31 !important;
/*-- pour demarrer sous la navbar fixe --*/
padding-top: 7em;
}
#page-container {
position: relative;
min-height: 100vh;
background-color: floralwhite !important;
color: #312f31 !important;
/*-- pour demarrer sous la navbar fixe --*/
padding-top: 7em;
}
#content-wrap {
/* Footer height */
padding-bottom: 2.5rem;
min-height: 700px;
}
#footer {
position: absolute;
bottom: 0;
width: 100%;
/* Footer height */
height: 2.5rem;
}
right: 0;
bottom: 0;
left: 0;
background-color: #efefef;
}

BIN
assets/images/favicon.ico

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

1
config/packages/twig.yaml

@ -1,2 +1,3 @@
twig:
default_path: '%kernel.project_dir%/templates'
form_themes: ['bootstrap_4_layout.html.twig']

28
public/build/app.css

File diff suppressed because one or more lines are too long

BIN
public/build/images/favicon.ico

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

1
public/build/manifest.json

@ -5,5 +5,6 @@
"build/pdf.js": "/build/pdf.js",
"build/runtime.js": "/build/runtime.js",
"build/vendors~app.js": "/build/vendors~app.js",
"build/images/favicon.ico": "/build/images/favicon.ico",
"build/images/logo.png": "/build/images/logo.png"
}

2
public/build/vendors~app.js

File diff suppressed because one or more lines are too long

6
src/Entity/Facture.php

@ -3,6 +3,7 @@
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity(repositoryClass="App\Repository\FactureRepository")
@ -18,11 +19,14 @@ class Facture
/**
* @ORM\Column(type="integer")
* @Assert\GreaterThan(0, message = "Un identifiant supérieur à {{ value }}.")
* @Assert\Regex(pattern="/^[0-9]{1,4}$/", message="Entre 1 et 4 chiffres.")
*/
private $client_id;
/**
* @ORM\Column(type="string", length=255)
* @Assert\Ip(message = "Ce n'est pas une adresse IP valide.")
*/
private $client_adresse_ip;
@ -38,6 +42,8 @@ class Facture
/**
* @ORM\Column(type="date")
* @Assert\GreaterThanOrEqual("01/01/2020", message = "La date ne peut pas être inférieure à {{ compared_value }}!")
* @Assert\LessThanOrEqual("today", message = "La date ne peut pas être supérieure à aujourd'hui!")
*/
private $facture_createAt;

11
src/Form/FactureType.php

@ -17,14 +17,19 @@ class FactureType extends AbstractType
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('client_id', IntegerType::class)
->add('client_adresse_ip', TextType::class)
->add('client_id', IntegerType::class, [
'help' => 'Un nombre entier de 4 chiffres',
])
->add('client_adresse_ip', TextType::class, [
'help' => 'Une adresse IP normalisée ex: 192.168.0.xxx'
])
->add('montant_ht', MoneyType::class, [
'currency' => false
])
->add('montant_tva', PercentType::class, [
'scale' => 2,
'symbol' => false
'symbol' => false,
'help' => 'Séparateur décimal à utiliser "."',
])
->add('facture_createAt', DateType::class, [
'widget' => 'single_text',

43
templates/base.html.twig

@ -4,40 +4,37 @@
<head>
<meta charset="UTF-8">
<title>{% block title %}Welcome!{% endblock %}</title>
<link rel="shortcut icon" href="{{ asset('build/images/favicon.ico') }}">
{% block stylesheets %}
{# 'app' must match the first argument to addEntry() in webpack.config.js #}
{{ encore_entry_link_tags('app') }}
<!-- Renders a link tag (if your module requires any CSS)
<link rel="stylesheet" href="/build/app.css"> -->
{% endblock %}
</head>
<body>
<!-- conteneur fixe-->
<div id="page-container">
<!-- header area -->
{% block header %}
<header>
<!-- navbar area -->
{% include('include/header.html.twig') %}
<!-- /navbar area -->
</header>
{% endblock %}
<!-- /header area -->
<!-- header area -->
{% block header %}
<header>
<!-- navbar area -->
{% include('include/header.html.twig') %}
<!-- /navbar area -->
</header>
{% endblock %}
<!-- /header area -->
<!-- body area -->
{% block body %}
{% endblock %}
<!-- body area -->
<!-- body area -->
{% block body %}
{% endblock %}
<!-- body area -->
<!-- footer area -->
{% block footer %}
{% include('include/footer.html.twig') %}
{% endblock %}
<!-- ./footer area -->
</div>
<!-- conteneur fixe-->
<!-- footer area -->
{% block footer %}
{% include('include/footer.html.twig') %}
{% endblock %}
<!-- ./footer area -->
{% block javascripts %}
{{ encore_entry_script_tags('app') }}

28
templates/facture/_form.html.twig

@ -2,12 +2,15 @@
{{ form_start(form) }}
<!-- debut des champs pour la saisie -->
<div class="col-md-12 px-0">
<div class="col-sm-8 mx-auto">
<!-- numero identifiant du client -->
<div class="mb-4">
{{ form_label(form.client_id, 'N° identifiant du client') }}
{{ form_widget(form.client_id, {'attr': {'class': 'form-control'}}) }}
{{ form_help(form.client_id, {
'help_attr': {'class': 'small text-muted font-italic'}
}) }}
</div>
<!-- /numero identifiant du client -->
@ -15,6 +18,9 @@
<div class="mb-4">
{{ form_label(form.client_adresse_ip, 'Adresse IP du paiement') }}
{{ form_widget(form.client_adresse_ip, {'attr': {'class': 'form-control'}}) }}
{{ form_help(form.client_adresse_ip, {
'help_attr': {'class': 'small text-muted font-italic'}
}) }}
</div>
<!-- /adresse IP du client -->
@ -29,6 +35,9 @@
<div class="mb-4">
{{ form_label(form.montant_tva, 'Montant de la TVA') }}
{{ form_widget(form.montant_tva, {'attr': {'class': 'form-control'}}) }}
{{ form_help(form.montant_tva, {
'help_attr': {'class': 'small text-muted font-italic'}
}) }}
</div>
<!-- /montant de la TVA -->
@ -39,20 +48,11 @@
</div>
<!-- /date de la facture -->
<!-- bouton de validation du formulaire-->
<button class="btn btn-primary btn-block mb-5">{{ save_button | default('Save') }}</button>
<!-- /bouton de validation du formulaire-->
</div>
<!-- /debut des champs pour la saisie -->
<!-- bouton de validation du formulaire-->
<button class="btn btn-primary">{{ save_button | default('Save') }}</button>
<!-- /bouton de validation du formulaire-->
{{ form_end(form) }}
<!-- /elements du formulaire -->
<div class="d-flex">
<!-- bouton pour revenir a la page precedente -->
<div class="ml-auto">
<button class="btn btn-info" onclick="history.back(-1)">&laquo; {{ back_button | default('Back') }}</button>
</div>
<!-- /bouton pour revenir a la page precedente -->
</div>
<!-- /elements du formulaire -->

12
templates/facture/create.html.twig

@ -6,15 +6,23 @@
{% block body %}
<!-- conteneur de la page du formulaire de creation d une facture -->
<div class="container mt-4" id="content-wrap">
<div class="container mt-4">
<!-- titre de la page de l affichage des factures -->
<div class="py-5 text-center">
<h1 class="display-4 font-weight-bold text-uppercase">{{ title }}</h1>
</div>
<!-- /titre de la page de l affichage des factures -->
<!-- bouton pour revenir a la page precedente -->
<div class="">
<a class="btn btn-info btn-sm" href="/">&laquo;
{{ back_button | default('Retour') }}</a>
</div>
<!-- /bouton pour revenir a la page precedente -->
<br>
<!-- include du template de formulaire -->
{{ include('facture/_form.html.twig', { form: form, save_button: 'Create', back_button: 'Return'}) }}
{{ include('facture/_form.html.twig', { form: form, save_button: 'Valider', back_button: 'Return'}) }}
<!-- include du template de formulaire -->
</div>
<!-- /conteneur de la page du formulaire de creation d une facture -->

2
templates/include/header.html.twig

@ -2,7 +2,7 @@
<nav class="navbar navbar-expand-lg bg-white shadow fixed-top py-0 mb-4">
<div class="container justify-content-center">
<!-- navbar brand & logo -->
<a class="navbar-brand" href="{{ path('app_facture') }}">
<a class="navbar-brand" href="/">
<img class="d-inline-block align-center" src="{{ asset('build/images/logo.png') }}" height="100"
alt="Aucune Commission Logo">
</a>

Loading…
Cancel
Save