Commit ef02565c by Julien Jorry

in dev 3 : lot of stuff...

parent eb2195b9
......@@ -3,7 +3,7 @@
###< MAC ###
###> symfony/framework-bundle ###
# /.env
/.env
/.env.test
/.env.local
/.env.*.local
......@@ -34,3 +34,7 @@ yarn-error.log
/mlc.test-access.log
/mlc.test-error.log
###< symfony/webpack-encore-bundle ###
###> lexik/jwt-authentication-bundle ###
/config/jwt/*.pem
###< lexik/jwt-authentication-bundle ###
......@@ -17,4 +17,7 @@ body {
.exportbutton .dropdown-menu>li>a:hover {
background-color: #e1e3e9;
color: #333;
}
label.required:after {
content: '*';
}
\ No newline at end of file
......@@ -6,7 +6,14 @@
*/
// any CSS you require will output into a single css file (app.css in this case)
// UTILISER LES FONT AWESOME POUR L'ICONOGRAPHIE
require('../../public/fontawesome/css/all.min.css');
// UTILISER LEAFLET POUR LA CARTE
require('../../public/leaflet/leaflet.css');
// CSS DU KOHINOS
require('../css/app.css');
// THEME BOOTSTRAP / BOOTSWATCH + CONFIGURATION GLOBALE (COULEURS, FONTS...)
require('../css/global.scss');
// Need jQuery? Install it with "yarn add jquery", then uncomment to require it.
......
......@@ -6,6 +6,7 @@
"ext-ctype": "*",
"ext-iconv": "*",
"api-platform/api-pack": "^1.2",
"beberlei/doctrineextensions": "^1.2",
"doctrine/annotations": "^1.8",
"friendsofsymfony/user-bundle": "^2.1",
"geocoder-php/cache-provider": "^4.1",
......
......@@ -2,7 +2,6 @@
return [
Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
Doctrine\Bundle\DoctrineCacheBundle\DoctrineCacheBundle::class => ['all' => true],
Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle::class => ['all' => true],
Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true],
Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle::class => ['all' => true],
......
api_platform:
title: 'API Kohinos'
version: '2.3.0'
enable_fos_user: true
# enable_entrypoint: false
mapping:
paths: ['%kernel.project_dir%/src/Entity']
swagger:
api_keys:
apiKey:
name: API-AUTH-TOKEN
type: header
# Exemple :
##############################
### DEFAULT CONFIGURATION ###
##############################
#
# api_platform:
# # The title of the API.
# title: 'API title'
# # The description of the API.
# description: 'API description'
# # The version of the API.
# version: '0.0.0'
# # Set this to false if you want Webby to disappear.
# show_webby: true
# # Specify a name converter to use.
# name_converter: ~
# # Specify a path name generator to use.
# path_segment_name_generator: 'api_platform.path_segment_name_generator.underscore'
# # Allow using plain IDs for JSON format
# allow_plain_identifiers: false
# validator:
# # Enable the serialization of payload fields when a validation error is thrown
# # If you want to serialize only some payload fields, define them like this [ severity, anotherPayloadField ]
# serialize_payload_fields: []
# eager_loading:
# # To enable or disable eager loading.
# enabled: true
# # Fetch only partial data according to serialization groups.
# # If enabled, Doctrine ORM entities will not work as expected if any of the other fields are used.
# fetch_partial: false
# # Max number of joined relations before EagerLoading throws a RuntimeException.
# max_joins: 30
# # Force join on every relation.
# # If disabled, it will only join relations having the EAGER fetch mode.
# force_eager: true
# # Enable the FOSUserBundle integration.
# enable_fos_user: false
# # Enabling the NelmioApiDocBundle integration has been deprecated in 2.2 and will be removed in 3.0.
# # NelmioApiDocBundle 3 has native support for API Platform
# enable_nelmio_api_doc: false
# # Enable the Swagger documentation and export.
# enable_swagger: true
# # Enable Swagger ui.
# enable_swagger_ui: true
# # Enable ReDoc.
# enable_re_doc: true
# # Enable the entrypoint.
# enable_entrypoint: true
# # Enable the docs.
# enable_docs: true
# # Enable the data collector and the WebProfilerBundle integration.
# enable_profiler: true
# collection:
# # The name of the query parameter to filter nullable results (with the ExistsFilter).
# exists_parameter_name: 'exists'
# # The default order of results.
# order: 'ASC'
# # The name of the query parameter to order results (with the OrderFilter).
# order_parameter_name: 'order'
# pagination:
# # To enable or disable pagination for all resource collections by default.
# enabled: true
# # To allow partial pagination for all resource collections.
# # This improves performances by skipping the `COUNT` query.
# partial: false
# # To allow the client to enable or disable the pagination.
# client_enabled: false
# # To allow the client to set the number of items per page.
# client_items_per_page: false
# # To allow the client to enable or disable the partial pagination.
# client_partial: false
# # The default number of items per page.
# items_per_page: 30
# # The maximum number of items per page.
# maximum_items_per_page: ~
# # The default name of the parameter handling the page number.
# page_parameter_name: 'page'
# # The name of the query parameter to enable or disable pagination.
# enabled_parameter_name: 'pagination'
# # The name of the query parameter to set the number of items per page.
# items_per_page_parameter_name: 'itemsPerPage'
# # The name of the query parameter to enable or disable the partial pagination.
# partial_parameter_name: 'partial'
# mapping:
# # The list of paths with files or directories where the bundle will look for additional resource files.
# paths: []
# # The list of your resources class directories. Defaults to the directories of the mapping paths but might differ.
# resource_class_directories:
# - '%kernel.project_dir%/src/Entity'
# doctrine:
# # To enable or disable Doctrine ORM support.
# enabled: true
# doctrine_mongodb_odm:
# # To enable or disable Doctrine MongoDB ODM support.
# enabled: false
# oauth:
# # To enable or disable oauth.
# enabled: false
# # The oauth client id.
# clientId: ''
# # The oauth client secret.
# clientSecret: ''
# # The oauth type.
# type: 'oauth2'
# # The oauth flow grant type.
# flow: 'application'
# # The oauth token url.
# tokenUrl: '/oauth/v2/token'
# # The oauth authentication url.
# authorizationUrl: '/oauth/v2/auth'
# # The oauth scopes.
# scopes: []
# graphql:
# # Enabled by default with installed GraphQL
# enabled: false
# # The default IDE (graphiql or graphql-playground) used when going to the GraphQL endpoint. False to disable.
# default_ide: 'graphiql'
# graphiql:
# # Enabled by default with installed GraphQL and Twig
# enabled: false
# graphql_playground:
# # Enabled by default with installed GraphQL and Twig
# enabled: false
# # The nesting separator used in the filter names.
# nesting_separator: _
# collection:
# pagination:
# enabled: true
# swagger:
# # The active versions of OpenAPI to be exported or used in the swagger_ui. The first value is the default.
# versions: [2, 3]
# # The swagger api keys.
# api_keys: []
# # The name of the header or query parameter containing the api key.
# # name: ''
# # Whether the api key should be a query parameter or a header.
# # type: 'query' or 'header'
# http_cache:
# # Automatically generate etags for API responses.
# etag: true
# # Default value for the response max age.
# max_age: 3600
# # Default value for the response shared (proxy) max age.
# shared_max_age: 3600
# # Default values of the "Vary" HTTP header.
# vary: ['Accept']
# # To make all responses public by default.
# public: ~
# invalidation:
# # To enable the tags-based cache invalidation system.
# enabled: false
# # URLs of the Varnish servers to purge using cache tags when a resource is updated.
# varnish_urls: []
# # To pass options to the client charged with the request.
# request_options: []
# mercure:
# # Enabled by default with installed GraphQL
# enabled: false
# # The URL sent in the Link HTTP header. If not set, will default to the URL for MercureBundle's default hub.
# hub_url: null
# messenger:
# # Enabled by default with installed symfony/messenger and not installed symfony/symfony
# enabled: false
# elasticsearch:
# # To enable or disable Elasticsearch support.
# enabled: false
# # The hosts to the Elasticsearch nodes.
# hosts: []
# # The mapping between resource classes and indexes.
# mapping: []
# # The list of exceptions mapped to their HTTP status code.
# exception_to_status:
# # With a status code.
# Symfony\Component\Serializer\Exception\ExceptionInterface: 400
# # Or with a constant defined in the 'Symfony\Component\HttpFoundation\Response' class.
# ApiPlatform\Core\Exception\InvalidArgumentException: !php/const Symfony\Component\HttpFoundation\Response::HTTP_BAD_REQUEST
# ApiPlatform\Core\Exception\FilterValidationException: 400
# Doctrine\ORM\OptimisticLockException: 409
# # ...
# # The list of enabled formats. The first one will be the default.
# formats:
# jsonld:
# mime_types: ['application/ld+json']
# json:
# mime_types: ['application/json']
# html:
# mime_types: ['text/html']
# # ...
# # The list of enabled patch formats. The first one will be the default.
# patch_formats: []
# # The list of enabled error formats. The first one will be the default.
# error_formats:
# jsonproblem:
# mime_types: ['application/problem+json']
# jsonld:
# mime_types: ['application/ld+json']
# # ...
# Exemples :
# App\Entity\Book:
# itemOperations:
# get:
......
# See https://symfony.com/doc/current/email/dev_environment.html
swiftmailer:
# send all emails to a specific address
delivery_addresses: ['me@example.com']
delivery_addresses: ['julien.jorry@gmail.com']
......@@ -36,6 +36,11 @@ doctrine:
dql:
string_functions:
str_to_date: App\DQL\StrToDate
numeric_functions:
acos: DoctrineExtensions\Query\Mysql\Acos
cos: DoctrineExtensions\Query\Mysql\Cos
radians: DoctrineExtensions\Query\Mysql\Radians
sin: DoctrineExtensions\Query\Mysql\Sin
filters:
softdeleteable:
class: Gedmo\SoftDeleteable\Filter\SoftDeleteableFilter
......
......@@ -3,8 +3,8 @@ fos_user:
firewall_name: main
user_class: App\Entity\User
from_email:
address: noreply@doume.org
sender_name: Doume
address: noreply@kohinos.fr
sender_name: Kohinos
service:
mailer: fos_user.mailer.twig_swift
user_manager: sonata.user.orm.user_manager
......
# Optional!
nelmio_api_doc:
# models: { use_jms: true }
documentation:
info:
title: MLC
description: Application de gesiton de Monnaie Locale Complémentaire
version: 2.3.0
security_definitions:
api_key:
type: apiKey
name: api_key
in: header
security:
api_key: []
areas: # to filter documented areas
path_patterns: # an array of regexps
- ^/api(?!/doc$)
# host_patterns:
# - ^api\.
\ No newline at end of file
# nelmio_api_doc:
# # models: { use_jms: true }
# documentation:
# info:
# title: MLC
# description: Application de gesiton de Monnaie Locale Complémentaire
# version: 2.3.0
# security_definitions:
# api_key:
# type: apiKey
# name: api_key
# in: header
# security:
# api_key: []
# areas: # to filter documented areas
# path_patterns: # an array of regexps
# - ^/api(?!/doc$)
# # host_patterns:
# # - ^api\.
\ No newline at end of file
......@@ -41,7 +41,7 @@ monolog:
handler: swift_critical
swift_critical:
type: swift_mailer
from_email: debug@doume.org
from_email: noreply@kohinos.fr
to_email: [julien.jorry@gmail.com, stephan@gelberger.com]
subject: "MLC : PHP Error !"
level: info
......@@ -33,6 +33,8 @@ security:
entity:
class: App\Entity\User
property: username
api_key_user_provider:
id: App\Security\ApiKeyUserProvider
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
......@@ -56,6 +58,34 @@ security:
# context: mlc_context
# access_denied_handler: App\Security\AccessDeniedHandler
# -> end custom configuration
# login:
# pattern: ^/api/login
# stateless: true
# anonymous: true
# provider: api_key_user_provider
# form_login:
# check_path: /api/login_check
# success_handler: lexik_jwt_authentication.handler.authentication_success
# failure_handler: lexik_jwt_authentication.handler.authentication_failure
# require_previous_session: false
# api:
# pattern: ^/api/
# stateless: true
# anonymous: true
# provider: api_key_user_provider
# guard:
# authenticators:
# - lexik_jwt_authentication.jwt_token_authenticator
api:
pattern: ^/api
stateless: true
# can be set to false to disabled API doc available for anonymous user !
anonymous: true
guard:
authenticators:
- App\Security\ApiKeyAuthenticator
provider: api_key_user_provider
main:
pattern: ^/
form_login:
......@@ -83,19 +113,17 @@ security:
switch_user:
provider: fos_userbundle
# access_denied_handler: App\Security\AccessDeniedHandler
api:
pattern: ^/api
stateless: true
anonymous: false
provider: entity_provider
guard:
authenticators:
- lexik_jwt_authentication.jwt_token_authenticator
encoders:
FOS\UserBundle\Model\UserInterface: bcrypt
# FOS\UserBundle\Model\UserInterface: bcrypt
FOS\UserBundle\Model\UserInterface:
# Use native password encoder
# This value auto-selects the best possible hashing algorithm
# (i.e. Sodium when available).
algorithm: auto
role_hierarchy:
ROLE_API: ROLE_USER
ROLE_ADHERENT: ROLE_USER
ROLE_PRESTATAIRE: ROLE_USER
ROLE_ADMIN_SIEGE: [ROLE_USER, ROLE_ADMIN]
......@@ -106,11 +134,14 @@ security:
ROLE_COMPTOIR: [ROLE_USER, ROLE_ADMIN]
ROLE_CONTACT: [ROLE_USER, ROLE_ADMIN]
ROLE_ADMIN: [ROLE_USER, ROLE_SONATA_ADMIN]
ROLE_SUPER_ADMIN: [ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]
ROLE_SUPER_ADMIN: [ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH, ROLE_API]
# Easy way to control access for large sections of your site
# Note: Only the *first* access control that matches will be used
access_control:
#
# @TODO : better access control !
#
# Admin login page needs to be accessed without credential
# - { path: ^/admin/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
# - { path: ^/admin/logout$, role: IS_AUTHENTICATED_ANONYMOUSLY }
......@@ -124,6 +155,7 @@ security:
# Change these rules to adapt them to your needs
# - { path: ^/admin/, role: [ROLE_SUPER_ADMIN, ROLE_SONATA_ADMIN, ROLE_ADMIN_SIEGE, ROLE_REDACTEUR, ROLE_TRESORIER, ROLE_CONTROLEUR, ROLE_GESTION_GROUPE, ROLE_COMPTOIR, ROLE_CONTACT] }
- { path: ^/admin/, role: [ROLE_ADMIN] }
- { path: ^/api, roles: IS_AUTHENTICATED_FULLY }
# Bottom line can be uncommented to disabled API doc available for anonymous user !
# - { path: '^/api', roles: ROLE_API }
- { path: ^/.*, role: IS_AUTHENTICATED_ANONYMOUSLY }
......@@ -4,7 +4,7 @@ sonata_admin:
handler: app.security.handler.role
role_admin: ROLE_ADMIN
role_super_admin: ROLE_SUPER_ADMIN
title: 'MLC Admin'
title: 'Admin'
title_logo: /images/logo.png
# Pour modifier l'image par défaut sur la vue "Mosaique" de l'administration
# options:
......@@ -51,9 +51,10 @@ sonata_admin:
# The default stylesheet list:
# - build/app.css
- bundles/sonatacore/vendor/bootstrap/dist/css/bootstrap.min.css
- fontawesome/css/fontawesome.min.css
- fontawesome/css/solid.css
- fontawesome/css/brands.css
- bundles/sonatacore/vendor/components-font-awesome/css/font-awesome.min.css
# - fontawesome/css/fontawesome.min.css
# - fontawesome/css/solid.css
# - fontawesome/css/brands.css
# - public/fontawesome/css/v4-shims.css
- bundles/sonatacore/vendor/ionicons/css/ionicons.min.css
- bundles/sonataadmin/vendor/admin-lte/dist/css/AdminLTE.min.css
......@@ -197,7 +198,7 @@ sonata_admin:
keep_open: false
label: "Prestataires"
label_catalogue: SonataAdminBundle
icon: '<i class="fa fa-user-tie"></i>'
icon: '<i class="fa fa-shopping-basket"></i>'
items:
- route: prestataire_create
label: Ajouter
......@@ -211,7 +212,7 @@ sonata_admin:
on_top: true
label: "Groupes locaux"
label_catalogue: SonataAdminBundle
icon: '<i class="fa fa-chess-rook"></i>'
icon: '<i class="fa fa-object-group"></i>'
items:
- admin.groupe.gerer
sonata.admin.group.comptoir:
......@@ -225,7 +226,7 @@ sonata_admin:
keep_open: false
label: "Flux"
label_catalogue: SonataAdminBundle
icon: '<i class="fa fa-euro-sign"></i>'
icon: '<i class="fa fa-euro"></i>'
items:
- admin.flux.gerer
- admin.all.cotisations
......@@ -245,7 +246,7 @@ sonata_admin:
on_top: true
label: "Actualités"
label_catalogue: SonataAdminBundle
icon: '<i class="fa fa-newspaper"></i>'
icon: '<i class="fa fa-newspaper-o"></i>'
items:
- admin.news.gerer
sonata.admin.group.document:
......@@ -261,7 +262,7 @@ sonata_admin:
on_top: true
label: "Pages"
label_catalogue: SonataAdminBundle
icon: '<i class="fa fa-pager"></i>'
icon: '<i class="fa fa-file-image-o"></i>'
items:
- admin.page.gerer
sonata.admin.group.faq:
......
......@@ -22,17 +22,11 @@ lexik_translation_edition:
resource: "@LexikTranslationBundle/Resources/config/routing.yml"
prefix: /admin
authentication_token:
path: /api/authentication_token
methods: ['POST']
app.swagger_ui:
path: /api/doc
methods: GET
defaults: { _controller: nelmio_api_doc.controller.swagger_ui }
# sonata_api_user:
# type: rest
# prefix: /api/user
# resource: "@SonataUserBundle/Resources/config/routing/api.xml"
# sonata_api_media:
# type: rest
# prefix: /api/media
# resource: "@SonataMediaBundle/Resources/config/routing/api.xml"
\ No newline at end of file
......@@ -84,7 +84,7 @@ services:
app.twig.main.extension:
class: App\Twig\AppExtension
autowire: false
arguments: ["@service_container", "@doctrine.orm.entity_manager", "@knp_paginator", "@session", "@app.rolecheck"]
arguments: ["@service_container", "@security.helper", "@doctrine.orm.entity_manager", "@knp_paginator", "@session", "@app.rolecheck"]
app.twig.mlc.globals.extension:
class: App\Twig\MlcGlobalsExtension
......@@ -155,6 +155,9 @@ services:
arguments:
- '@security.authorization_checker'
- [ROLE_SUPER_ADMIN]
calls:
- [setManager, ['@doctrine.orm.entity_manager']]
- [setRolecheck, ['@app.rolecheck']]
admin.block.dashboard:
class: App\Block\DashboardKohinosBlock
......@@ -181,6 +184,7 @@ services:
calls:
- [ setUserManager, ['@fos_user.user_manager']]
- [ setSecurity, ['@security.helper']]
- [ setEventDispatcher, ['@event_dispatcher']]
admin.all.cotisations:
class: App\Admin\CotisationAdmin
......@@ -193,6 +197,7 @@ services:
public: true
calls:
- [ setSecurity, ['@security.helper']]
- [ setRoleCheck, ['@app.rolecheck']]
admin.adherent.cotisations:
class: App\Admin\CotisationAdherentAdmin
......@@ -205,6 +210,7 @@ services:
public: true
calls:
- [ setSecurity, ['@security.helper']]
- [ setRoleCheck, ['@app.rolecheck']]
admin.prestataire.gerer:
class: App\Admin\PrestataireAdmin
......@@ -232,6 +238,7 @@ services:
public: true
calls:
- [ setSecurity, ['@security.helper']]
- [ setRoleCheck, ['@app.rolecheck']]
admin.groupe.gerer:
class: App\Admin\GroupeAdmin
......@@ -446,4 +453,9 @@ services:
class: App\Listener\Flash
arguments: ["@session"]
tags:
- { name: kernel.event_listener, event: kernel.response }
\ No newline at end of file
- { name: kernel.event_listener, event: kernel.response }
App\Swagger\SwaggerDecorator:
decorates: 'api_platform.swagger.normalizer.api_gateway'
arguments: [ '@App\Swagger\SwaggerDecorator.inner' ]
autoconfigure: false
......@@ -246,6 +246,100 @@ Prodigious\Sonata\MenuBundle\Entity\MenuItem:
target: 0
enabled: 1
# App\Application\Sonata\ClassificationBundle\Entity\Context:
# context1:
# id: actualites
# name: Actualites
# enabled: true
# context2:
# id: comptoir
# name: Comptoir
# enabled: true
# context3:
# id: default
# name: Default
# enabled: true
# context4:
# id: document
# name: Document
# enabled: true
# context5:
# id: faq
# name: Faq
# enabled: true
# context6:
# id: groupe
# name: Groupe
# enabled: true
# context7:
# id: import
# name: Import
# enabled: true
# context8:
# id: prestataire
# name: Prestataire
# enabled: true
# context9:
# id: rubrique
# name: Rubrique
# enabled: true
# App\Application\Sonata\ClassificationBundle\Entity\Category:
# mediacat1:
# context: '@context3'
# name: Default
# enabled: true
# slug: default
# description: Default
# mediacat2:
# context: '@context1'
# name: Actualites
# enabled: true
# slug: actualites
# description: Actualites
# mediacat3:
# context: '@context4'
# name: Document
# enabled: true
# slug: document
# description: Document
# mediacat4:
# context: '@context7'
# name: Import
# enabled: true
# slug: import
# description: Import
# mediacat5:
# context: '@context2'
# name: Comptoir
# enabled: true
# slug: comptoir
# description: Comptoir
# mediacat6:
# context: '@context6'
# name: Groupe
# enabled: true
# slug: groupe
# description: Groupe
# mediacat7:
# context: '@context9'
# name: Rubrique
# enabled: true
# slug: rubrique
# description: Rubrique
# mediacat8:
# context: '@context8'
# name: Prestataire
# enabled: true
# slug: prestataire
# description: Prestataire
# mediacat9:
# context: '@context5'
# name: Faq
# enabled: true
# slug: faq
# description: Faq
App\Application\Sonata\MediaBundle\Entity\Media:
media6:
name: 'wosmpl-marker-icon17-produits-de-lagriculture-et-elevage.png'
......@@ -607,7 +701,6 @@ App\Entity\Rubrique:
enabled: true
media: '@media17'
# Rubrique de la doume
# App\Entity\Rubrique:
# rubrique1:
......
......@@ -2,20 +2,20 @@
"entrypoints": {
"app": {
"js": [
"/build/runtime.js",
"/build/app.js"
"/build/runtime.6cf710cd.js",
"/build/app.5ceba3b7.js"
],
"css": [
"/build/app.css"
"/build/app.f6a68444.css"
]
},
"admin": {
"js": [
"/build/runtime.js",
"/build/admin.js"
"/build/runtime.6cf710cd.js",
"/build/admin.065fe9cf.js"
],
"css": [
"/build/admin.css"
"/build/admin.fecc301b.css"
]
}
}
......
{
"build/admin.css": "/build/admin.css",
"build/admin.js": "/build/admin.js",
"build/app.css": "/build/app.css",
"build/app.js": "/build/app.js",
"build/runtime.js": "/build/runtime.js",
"build/admin.css": "/build/admin.fecc301b.css",
"build/admin.js": "/build/admin.065fe9cf.js",
"build/app.css": "/build/app.f6a68444.css",
"build/app.js": "/build/app.5ceba3b7.js",
"build/runtime.js": "/build/runtime.6cf710cd.js",
"build/ckeditor/adapters/jquery.js": "/build/ckeditor/adapters/jquery.js",
"build/ckeditor/ckeditor.js": "/build/ckeditor/ckeditor.js",
"build/ckeditor/config.js": "/build/ckeditor/config.js",
......@@ -2650,5 +2650,23 @@
"build/ckeditor/skins/moono/images/spinner.gif": "/build/ckeditor/skins/moono/images/spinner.gif",
"build/ckeditor/skins/moono/readme.md": "/build/ckeditor/skins/moono/readme.md",
"build/ckeditor/skins/moono/skin.js": "/build/ckeditor/skins/moono/skin.js",
"build/ckeditor/styles.js": "/build/ckeditor/styles.js"
"build/ckeditor/styles.js": "/build/ckeditor/styles.js",
"build/fonts/fa-brands-400.woff2": "/build/fonts/fa-brands-400.4b115e11.woff2",
"build/fonts/fa-brands-400.woff": "/build/fonts/fa-brands-400.b90365bc.woff",
"build/fonts/fa-brands-400.ttf": "/build/fonts/fa-brands-400.c39278f7.ttf",
"build/fonts/fa-brands-400.eot": "/build/fonts/fa-brands-400.d9d17590.eot",
"build/fonts/fa-regular-400.eot": "/build/fonts/fa-regular-400.414ff5da.eot",
"build/fonts/fa-regular-400.woff": "/build/fonts/fa-regular-400.5dd3976c.woff",
"build/fonts/fa-regular-400.woff2": "/build/fonts/fa-regular-400.65779ebc.woff2",
"build/fonts/fa-regular-400.ttf": "/build/fonts/fa-regular-400.f6c6f6c8.ttf",
"build/fonts/fa-solid-900.woff2": "/build/fonts/fa-solid-900.46280631.woff2",
"build/fonts/fa-solid-900.woff": "/build/fonts/fa-solid-900.61969d43.woff",
"build/fonts/fa-solid-900.eot": "/build/fonts/fa-solid-900.b5596f4d.eot",
"build/fonts/fa-solid-900.ttf": "/build/fonts/fa-solid-900.b70cea03.ttf",
"build/images/fa-brands-400.svg": "/build/images/fa-brands-400.80533988.svg",
"build/images/fa-regular-400.svg": "/build/images/fa-regular-400.e7e957c8.svg",
"build/images/fa-solid-900.svg": "/build/images/fa-solid-900.82905d8d.svg",
"build/images/layers-2x.png": "/build/images/layers-2x.4f0283c6.png",
"build/images/layers.png": "/build/images/layers.a6137456.png",
"build/images/marker-icon.png": "/build/images/marker-icon.2273e3d8.png"
}
\ No newline at end of file
{"name":"","short_name":"","icons":[{"src":"/android-chrome-192x192.png","sizes":"192x192","type":"image/png"},{"src":"/android-chrome-512x512.png","sizes":"512x512","type":"image/png"}],"theme_color":"#ffffff","background_color":"#ffffff","display":"standalone"}
\ No newline at end of file
{"name":"Kohinos","short_name":"Kohinos","icons":[{"src":"/android-chrome-192x192.png","sizes":"192x192","type":"image/png"},{"src":"/android-chrome-512x512.png","sizes":"512x512","type":"image/png"}],"theme_color":"#ffffff","background_color":"#ffffff","display":"standalone"}
\ No newline at end of file
......@@ -8,10 +8,11 @@ use App\Entity\Geoloc;
use App\Entity\Groupe;
use App\Entity\User;
use App\Entity\Usergroup;
use App\Events\MLCEvents;
use App\Enum\MoyenEnum;
use App\Form\Type\UserFormType;
use App\Form\Type\GeolocFormType;
use FOS\UserBundle\Event\FilterUserResponseEvent;
use FOS\UserBundle\Event\UserEvent;
use FOS\UserBundle\FOSUserEvents;
use Knp\Menu\ItemInterface as MenuItemInterface;
use Sonata\AdminBundle\Admin\AbstractAdmin;
......@@ -130,18 +131,9 @@ class AdherentAdmin extends AbstractAdmin
$user->setAdherent($adherent);
$adherent->setUser($user);
}
// if (count($adherent->getUser()->getCotisations()) <= 0) {
// $cotisation = new Cotisation();
// $cotisation->setOperateur($adherent->getUser());
// $cotisation->setExpediteur($adherent);
// $cotisation->setDebut($now);
// $cotisation->setFin(new \DateTime('+ 1 year'));
// $adherent->getUser()->addCotisation($cotisation);
// }
if ($adherent->getGeoloc() == null) {
$adherent->setGeoloc(new Geoloc());
}
//nom, prénom, adresse, tel, mail et cotisation en une seule fois et générer un mdp
$formMapper
->tab('General')
->with('Identité', ['class' => 'col-md-7'])
......@@ -157,76 +149,6 @@ class AdherentAdmin extends AbstractAdmin
->end()
->end()
;
// ->with('Identité', ['class' => 'col-md-7'])
// ->add('user.firstname', TextType::class, array(
// 'label' => 'Prénom :',
// 'required' => true
// ))
// ->add('user.lastname', TextType::class, array(
// 'label' => 'Nom :',
// 'required' => true
// ));
// if (!$this->isCurrentRoute('create')) {
// $formMapper
// ->add('user.username', TextType::class, array(
// 'label' => 'Username :',
// 'required' => true,
// 'disabled' => true
// ));
// }
// $formMapper
// ->add('user.phone', TextType::class, array(
// 'label' => 'Téléphone :',
// 'required' => false
// ))
// ->add('user.email', TextType::class, array(
// 'label' => 'Email :',
// 'required' => true
// ))
// ->add('groupe', ChoiceType::class, array(
// 'required' => true,
// 'label' => 'Groupe local :',
// 'choices' => $this->getConfigurationPool()->getContainer()->get('doctrine')->getRepository(Groupe::class)->findAll(),
// 'choice_label' => 'name',
// 'placeholder' => 'Choisir un groupe',
// ))
// ->end();
// ->with('Cotisation', ['class' => 'col-md-5'])
// //@TODO : géré une ou plusieurs cotisations
// ->add('user.cotisations.first.cotisationInfos.annee', TextType::class, array('label' => 'Année', 'data' => $now->format('Y')))
// ->add('user.cotisations.first.montant', TextType::class, array('label' => 'Montant'))
// ->add('user.cotisations.first.moyen', ChoiceType::class, array(
// 'required' => true,
// 'label' => 'Moyen :',
// 'choices' => MoyenEnum::getAvailableTypes(),
// 'choice_label' => function ($choice) {
// return MoyenEnum::getTypeName($choice);
// },
// ));
// if ($this->security->getUser()->isGranted('ROLE_TRESORIER')) {
// $formMapper
// ->add('user.cotisations.first.cotisationInfos.recu', CheckboxType::class, array('label' => 'Reçu'));
// }
// $formMapper->end();
// if (!$this->isCurrentRoute('create')) {
// $formMapper
// ->with('Date', ['class' => 'col-md-5'])
// ->add('user.cotisations.first.cotisationInfos.debut', DateType::class, array(
// 'label' => 'Date de début',
// 'data' => new \DateTime(),
// 'widget' => 'single_text',
// 'html5' => false,
// 'attr' => ['class' => 'js-datepicker'],
// ))
// ->add('user.cotisations.first.cotisationInfos.fin', DateType::class, array(
// 'label' => 'Date de fin',
// 'data' => new \DateTime('+ 1 year'),
// 'widget' => 'single_text',
// 'html5' => false,
// 'attr' => ['class' => 'js-datepicker'],
// ))
// ->end();
// }
$em = $this->getConfigurationPool()->getContainer()->get('doctrine')->getManager();
$formMapper->getFormBuilder()->addEventListener(FormEvents::POST_SUBMIT, function (FormEvent $event) use ($em) {
......@@ -236,7 +158,7 @@ class AdherentAdmin extends AbstractAdmin
$repo = $em->getRepository(User::class);
$emailExist = $repo->findBy(array('email' => $user->getEmail()));
if (count($emailExist) > 0) {
$event->getForm()->get('user__email')->addError(new FormError('Courriel déjà utilisé !'));
$event->getForm()->get('user')->get('email')->addError(new FormError('Courriel déjà utilisé !'));
} else {
$user->setUsername($user->getEmail());
}
......@@ -258,20 +180,19 @@ class AdherentAdmin extends AbstractAdmin
$adherent->getUser()->setUsername($adherent->getUser()->getEmail());
}
if (empty($adherent->getUser()->getPassword())) {
// @TODO : generate password with tokengenerator
// $tokenGenerator = $this->getConfigurationPool()->getContainer()->get('fos_user.util.token_generator');
// $password = substr($tokenGenerator->generateToken(), 0, 12);
$bytes = random_bytes(64);
$password = rtrim(strtr(base64_encode($bytes), '+/', '-_'), '=');
$adherent->getUser()->setPassword($password);
// @TODO : send email to user
}
$this->userManager->updateUser($adherent->getUser());
$adherent->getUser()->createEmailToken();
$em->persist($adherent->getUser());
$em->persist($adherent);
$em->flush();
// @TODO : envoyer un mail au nouvel utilisateur avec l'emailtoken via le dispatch d'un event
// $this->eventDispatcher->dispatch(FOSUserEvents::REGISTRATION_COMPLETED, new FilterUserResponseEvent($adherent->getUser(), $this->getRequest(), $response));
$this->eventDispatcher->dispatch(MLCEvents::REGISTRATION_ADHERENT, new UserEvent($adherent->getUser(), $this->getRequest()));
}
/**
......@@ -360,7 +281,10 @@ class AdherentAdmin extends AbstractAdmin
'sort_field_mapping' => array('fieldName' => 'name'),
'sort_parent_association_mappings' => array(array('fieldName' => 'groupe'))
))
->addIdentifier('user.enabled', null, array('label' => 'Activé', 'datatype' => 'App.User', 'template' => '@SonataAdmin/Boolean/editable_boolean.html.twig'))
->add('user.enabled', null, array(
'label' => 'Activé',
'editable' => true
))
->addIdentifier('user.updatedAt', null, array('label' => 'Mis à jour'))
;
}
......
......@@ -6,6 +6,7 @@ use App\Entity\Geoloc;
use App\Entity\Groupe;
use App\Form\Type\GeolocFormType;
use Doctrine\ORM\EntityRepository;
use FOS\CKEditorBundle\Form\Type\CKEditorType;
use Sonata\AdminBundle\Admin\AbstractAdmin;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Datagrid\ListMapper;
......@@ -27,6 +28,8 @@ use Symfony\Component\Form\Extension\Core\Type\TextType;
class ComptoirAdmin extends AbstractAdmin
{
protected $security;
protected $baseRouteName = 'comptoir';
protected $baseRoutePattern = 'comptoir';
protected $datagridValues = [
'_sort_order' => 'ASC',
'_sort_by' => 'name',
......@@ -95,11 +98,15 @@ class ComptoirAdmin extends AbstractAdmin
))
->add('email', null, array(
'label' => 'Email',
'required' => true,
'required' => false,
))
->add('tel', null, array(
'label' => 'Téléphone',
'required' => true,
'required' => false,
))
->add('content', CKEditorType::class, array(
'label' => 'Description :',
'required' => false
))
->add('enabled', null, array('label' => 'Activé ?'))
->end()
......@@ -153,9 +160,29 @@ class ComptoirAdmin extends AbstractAdmin
protected function configureRoutes(RouteCollection $collection)
{
$collection->add('test');
$collection->remove('delete');
}
public function configureActionButtons($action, $object = null)
{
$list = parent::configureActionButtons($action, $object);
$list['test']['template'] = '@SonataAdmin/show_map_comptoir.html.twig';
return $list;
}
public function getRouteShowOnFront($object)
{
return $this->routeGenerator->generate('show_comptoir', array('slug' => $object->getSlug()));
}
public function getRouteShowMap()
{
return $this->routeGenerator->generate('comptoirs_carte');
}
/**
* {@inheritdoc}
*/
......@@ -164,11 +191,19 @@ class ComptoirAdmin extends AbstractAdmin
unset($this->listModes['mosaic']);
$listMapper
->addIdentifier('name')
->addIdentifier('email')
->addIdentifier('compte', null, array('label' => 'Solde'))
->addIdentifier('geoloc.adresse', null, array('label' => 'Adresse'))
->addIdentifier('tel', null, array('label' => 'Téléphone'))
->addIdentifier('enabled', null, array('label' => 'Activé', 'datatype' => 'App.Comptoir', 'template' => '@SonataAdmin/Boolean/editable_boolean.html.twig'))
->add('compte', null, array('label' => 'Solde'))
->add('geoloc', null, array('label' => 'Adresse'))
->add('tel', null, array('label' => 'Téléphone'))
->add('enabled', null, array(
'label' => 'Activé',
'editable' => true
))
->add('_action', null, [
'actions' => [
'show' => ['template' => '@SonataAdmin/CRUD/list__action_showonfront.html.twig'],
'edit' => []
]
])
;
}
}
......@@ -12,6 +12,7 @@ use Sonata\AdminBundle\Route\RouteCollection;
use Sonata\AdminBundle\Show\ShowMapper;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\MoneyType;
/**
......@@ -47,10 +48,12 @@ class CotisationAdherentAdmin extends CotisationAdmin
}
} else {
$groupe = $this->getRequest()->getSession()->get('_groupegere');
$em = $this->getConfigurationPool()->getContainer()->get('doctrine')->getEntityManager();
$em = $this->getConfigurationPool()->getContainer()->get('doctrine')->getManager();
$adhTable = $em->getMetadataFactory()->getMetadataFor(Adherent::class)->getTableName();
$fluxTable = $em->getMetadataFactory()->getMetadataFor(Flux::class)->getTableName();
$connection = $em->getConnection();
$statement = $connection->prepare('SELECT f.id FROM flux f INNER JOIN '.$adhTable.' a ON (a.id = f.adherent_id OR a.id = f.adherent_dest_id) WHERE a.groupe_id = '.$groupe->getId());
$statement = $connection->prepare("SELECT f.id FROM $fluxTable f INNER JOIN $adhTable a ON (a.id = f.adherent_id OR a.id = f.adherent_dest_id) WHERE a.groupe_id = :groupe_id");
$statement->bindValue(':groupe_id', $groupe->getId());
$statement->execute();
$ids = $statement->fetchAll();
$query
......@@ -85,33 +88,30 @@ class CotisationAdherentAdmin extends CotisationAdmin
*/
protected function configureFormFields(FormMapper $formMapper): void
{
$em = $this->getConfigurationPool()->getContainer()->get('doctrine')->getManager();
$cotisation = $this->getSubject();
$expediteurInfos = array(
'label' => 'Expéditeur',
'class' => Adherent::class,
'choices' => $this->getConfigurationPool()->getContainer()->get('doctrine')->getRepository(Adherent::class)->findOrderByName(),
'choices' => $em->getRepository(Adherent::class)->findOrderByName(),
'placeholder' => 'Choisir un adhérent',
'required' => true,
);
$exp = $this->getRequest()->get('expediteur');
if (!empty($exp)) {
$expediteurInfos['data'] = $this->getConfigurationPool()->getContainer()->get('doctrine')->getRepository(Adherent::class)->findOneById($exp);
$expediteurInfos['data'] = $em->getRepository(Adherent::class)->findOneById($exp);
}
$formMapper
->with('Cotisation', ['class' => 'col-md-8'])
->add('montant', MoneyType::class, array(
'label' => 'Montant',
'data' => ($cotisation->getMontant() != null)?$cotisation->getMontant():floatval($this->em->getRepository(GlobalParameter::class)->val(GlobalParameter::COTISATION_ADHERENT))
'data' => ($cotisation->getMontant() != null)?$cotisation->getMontant():floatval($em->getRepository(GlobalParameter::class)->val(GlobalParameter::COTISATION_ADHERENT)),
'help' => 'Montant par défaut des cotisations adhérent : '.floatval($em->getRepository(GlobalParameter::class)->val(GlobalParameter::COTISATION_ADHERENT))
))
->add('reference', HiddenType::class, array(
'data' => 'cotisation_adherent'
->add('reference', TextType::class, array(
'required' => false
))
->add('expediteur', EntityType::class, $expediteurInfos)
->add('operateur', HiddenType::class, array(
'data' => $this->security->getUser()->getId(),
'entity_class' => User::class,
'em' => $this->getConfigurationPool()->getContainer()->get('doctrine')->getManager()
))
->end()
;
parent::configureFormFields($formMapper);
......
......@@ -6,7 +6,9 @@ use App\Entity\Adherent;
use App\Entity\GlobalParameter;
use App\Entity\Prestataire;
use App\Entity\Siege;
use App\Entity\User;
use App\Enum\MoyenEnum;
use App\Tools\RoleCheck;
use Doctrine\ORM\EntityManagerInterface;
use Sonata\AdminBundle\Admin\AbstractAdmin;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
......@@ -35,6 +37,7 @@ class CotisationAdmin extends AbstractAdmin
protected $baseRouteName = 'cotisation';
protected $baseRoutePattern = 'cotisation';
protected $security;
protected $rolecheck;
protected $translator;
protected $datagridValues = [
......@@ -47,6 +50,11 @@ class CotisationAdmin extends AbstractAdmin
$this->security = $security;
}
public function setRoleCheck(RoleCheck $rolecheck)
{
$this->rolecheck = $rolecheck;
}
/**
* {@inheritdoc}
*/
......@@ -55,7 +63,11 @@ class CotisationAdmin extends AbstractAdmin
$datagridMapper
->add('cotisationInfos.annee', null, array('label' => 'Année'))
->add('montant', null, array('label' => 'Montant'))
->add('cotisationInfos.recu', null, array('label' => 'Recu ?'))
->add('cotisationInfos.recu', null, [
'label' => "Recu ?",
'show_filter' => true,
'advanced_filter' => false
])
;
}
......@@ -72,15 +84,21 @@ class CotisationAdmin extends AbstractAdmin
->add('parenttype', HiddenType::class, array(
'data' => 'cotisation'
))
->add('operateur', HiddenType::class, array(
'data' => $this->security->getUser()->getId(),
'data_class' => null,
'entity_class' => User::class,
'em' => $em
))
->add('role', HiddenType::class, array(
'data' => $this->rolecheck->getCurrentRole()->__toString()
))
->add('destinataire', HiddenType::class, array(
'data' => $em->getRepository(Prestataire::class)->findBy(array('mlc' => true)),
'data' => $em->getRepository(Prestataire::class)->findOneBy(array('mlc' => true))->getId(),
'data_class' => null,
'entity_class' => Prestataire::class,
'em' => $em
))
->add('cotisationInfos.annee', null, array(
'label' => 'Année',
))
->add('moyen', ChoiceType::class, array(
'required' => true,
'choices' => MoyenEnum::getAvailableTypes(),
......@@ -89,25 +107,33 @@ class CotisationAdmin extends AbstractAdmin
},
))
;
if ($this->security->getUser() != null && $this->security->getUser()->isGranted('ROLE_TRESORIER')) {
if ($this->security->getUser() != null && ($this->security->getUser()->isGranted('ROLE_SUPER_ADMIN') || $this->security->getUser()->isGranted('ROLE_TRESORIER'))) {
$formMapper
->add('cotisationInfos.recu', CheckboxType::class, array('label' => 'Reçu'));
->add('cotisationInfos.recu', CheckboxType::class, array(
'label' => 'Reçu',
'required' => false
));
}
$formMapper->end()
->with('Date', ['class' => 'col-md-4'])
->add('cotisationInfos.debut', DateTimeType::class, array(
->add('cotisationInfos.annee', null, array(
'label' => 'Année',
'required' => false
))
->add('cotisationInfos.debut', DateType::class, array(
'label' => 'Date de début',
'widget' => 'single_text',
'required' => true,
// 'html5' => false,
'date_format' => IntlDateFormatter::SHORT,
// 'attr' => ['class' => 'js-datepicker'],
'format' => IntlDateFormatter::SHORT,
'attr' => ['class' => 'js-datepicker'],
))
->add('cotisationInfos.fin', DateTimeType::class, array(
->add('cotisationInfos.fin', DateType::class, array(
'label' => 'Date de fin',
'widget' => 'single_text',
// 'html5' => false,
'date_format' => IntlDateFormatter::SHORT,
// 'attr' => ['class' => 'js-datepicker'],
'format' => IntlDateFormatter::SHORT,
'attr' => ['class' => 'js-datepicker'],
))
->end()
;
......@@ -128,22 +154,32 @@ class CotisationAdmin extends AbstractAdmin
{
unset($this->listModes['mosaic']);
$listMapper
->addIdentifier('cotisationInfos.annee', null, array(
->add('cotisationInfos.annee', null, array(
'label' => 'Année'
))
->addIdentifier('montant', null, array(
->add('montant', null, array(
'label' => 'Montant'
))
->addIdentifier('moyen', null, array(
->add('moyen', null, array(
'label' => 'Moyen'
))
->addIdentifier('createdAt', null, array(
->add('cotisationInfos.debut', null, array(
'label' => 'Crée le'
))
->addIdentifier('operateur', null, array(
'label' => 'Opérateur',
// 'disabled' => true
->add('cotisationInfos.fin', null, array(
'label' => 'Expire le'
))
->add('cotisationInfos.recu', null, array(
'label' => 'Reçu ?'
))
->add('operateurAndRole', null, array(
'label' => 'Opérateur'
))
->add('_action', null, [
'actions' => [
'edit' => [],
]
])
;
}
}
......@@ -14,6 +14,7 @@ use Sonata\AdminBundle\Show\ShowMapper;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\MoneyType;
/**
......@@ -49,11 +50,12 @@ class CotisationPrestataireAdmin extends CotisationAdmin
}
} else {
$groupe = $this->getRequest()->getSession()->get('_groupegere');
$em = $this->getConfigurationPool()->getContainer()->get('doctrine')->getEntityManager();
$em = $this->getConfigurationPool()->getContainer()->get('doctrine')->getManager();
$fluxTable = $em->getMetadataFactory()->getMetadataFor(Flux::class)->getTableName();
$prestaTable = $em->getMetadataFactory()->getMetadataFor(Prestataire::class)->getTableName();
$connection = $em->getConnection();
$statement = $connection->prepare('SELECT f.id FROM '.$fluxTable.' f INNER JOIN '.$prestaTable.' a ON (a.id = f.prestataire_id OR a.id = f.prestataire_dest_id) WHERE a.groupe_id = '.$groupe->getId());
$statement = $connection->prepare("SELECT f.id FROM $fluxTable f INNER JOIN $prestaTable a ON (a.id = f.prestataire_id OR a.id = f.prestataire_dest_id) WHERE a.groupe_id = :groupe_id");
$statement->bindValue(':groupe_id', $groupe->getId());
$statement->execute();
$ids = $statement->fetchAll();
$query
......@@ -89,33 +91,30 @@ class CotisationPrestataireAdmin extends CotisationAdmin
*/
protected function configureFormFields(FormMapper $formMapper): void
{
$em = $this->getConfigurationPool()->getContainer()->get('doctrine')->getManager();
$cotisation = $this->getSubject();
$expediteurInfos = array(
'label' => 'Expéditeur',
'class' => Prestataire::class,
'choices' => $this->getConfigurationPool()->getContainer()->get('doctrine')->getRepository(Prestataire::class)->findBy(array('enabled' => true), array('raison'=> 'ASC')),
'choices' => $em->getRepository(Prestataire::class)->findBy(array('enabled' => true, 'mlc' => false), array('raison'=> 'ASC')),
'placeholder' => 'Choisir un prestataire',
'required' => true,
);
$exp = $this->getRequest()->get('expediteur');
if (!empty($exp)) {
$expediteurInfos['data'] = $this->getConfigurationPool()->getContainer()->get('doctrine')->getRepository(Prestataire::class)->findOneById($exp);
$expediteurInfos['data'] = $em->getRepository(Prestataire::class)->findOneById($exp);
}
$formMapper
->with('Cotisation', ['class' => 'col-md-8'])
->add('montant', MoneyType::class, array(
'label' => 'Montant',
'data' => ($cotisation->getMontant() != null)?$cotisation->getMontant():floatval($this->em->getRepository(GlobalParameter::class)->val(GlobalParameter::COTISATION_PRESTATAIRE))
'data' => ($cotisation->getMontant() != null)?$cotisation->getMontant():floatval($em->getRepository(GlobalParameter::class)->val(GlobalParameter::COTISATION_PRESTATAIRE)),
'help' => 'Montant par défaut des cotisations prestataire : '.floatval($em->getRepository(GlobalParameter::class)->val(GlobalParameter::COTISATION_PRESTATAIRE))
))
->add('reference', HiddenType::class, array(
'data' => 'cotisation_prestataire'
->add('reference', TextType::class, array(
'required' => false
))
->add('expediteur', EntityType::class, $expediteurInfos)
->add('operateur', HiddenType::class, array(
'data' => $this->security->getUser()->getId(),
'entity_class' => User::class,
'em' => $this->getConfigurationPool()->getContainer()->get('doctrine')->getManager()
))
->end()
;
parent::configureFormFields($formMapper);
......
......@@ -21,6 +21,8 @@ use Symfony\Component\Form\Extension\Core\Type\TextType;
*/
class DocumentAdmin extends AbstractAdmin
{
protected $baseRouteName = 'document';
protected $baseRoutePattern = 'document';
/**
* {@inheritdoc}
*/
......@@ -32,7 +34,7 @@ class DocumentAdmin extends AbstractAdmin
'data' => $this->getConfigurationPool()->getContainer()->get('security.token_storage')->getToken()->getUser()->getId(),
'data_class' => null,
'entity_class' => User::class,
'em' => $this->getConfigurationPool()->getContainer()->get('doctrine')->getEntityManager()
'em' => $this->getConfigurationPool()->getContainer()->get('doctrine')->getManager()
))
->add('media', MediaType::class, array(
'provider' => 'sonata.media.provider.file',
......@@ -64,7 +66,10 @@ class DocumentAdmin extends AbstractAdmin
->addIdentifier('name', null, array('label' => 'Titre'))
->addIdentifier('content', 'html', array('truncate' => array('length' => 80), 'label' => 'Description'))
->addIdentifier('media', null, array('label' => 'Fichier'))
->addIdentifier('enabled', null, array('label' => 'Activé', 'datatype' => 'App.Document', 'template' => '@SonataAdmin/Boolean/editable_boolean.html.twig'))
->add('enabled', null, array(
'label' => 'Activé',
'editable' => true
))
;
}
}
......@@ -28,6 +28,8 @@ use Symfony\Component\Security\Core\Security;
class EtatprestataireAdmin extends AbstractAdmin
{
protected $security;
protected $baseRouteName = 'tags';
protected $baseRoutePattern = 'tags';
protected $datagridValues = [
// reverse order (default = 'ASC')
'_sort_order' => 'DESC',
......@@ -51,7 +53,7 @@ class EtatprestataireAdmin extends AbstractAdmin
protected function configureFormFields(FormMapper $formMapper)
{
$user = $this->security->getUser();
$prestataires = $this->getConfigurationPool()->getContainer()->get('doctrine')->getRepository(Prestataire::class)->findBy(array('enabled' => true), array('raison'=> 'ASC'));
$prestataires = $this->getConfigurationPool()->getContainer()->get('doctrine')->getRepository(Prestataire::class)->findBy(array('enabled' => true, 'mlc' => false), array('raison'=> 'ASC'));
$groupepresta = $this->getSubject();
$formMapper
......@@ -84,13 +86,17 @@ class EtatprestataireAdmin extends AbstractAdmin
->addIdentifier('name', null, array(
'label' => 'Nom'
))
->addIdentifier('content', null, array(
'label' => 'Description'
->add('content', null, array(
'label' => 'Description',
'sortable' => false
))
->addIdentifier('enabled', null, array(
->add('getPrestatairesCount', null, array(
'label' => 'Nombre de prestas',
'sortable' => false
))
->add('enabled', null, array(
'label' => 'Activé',
'datatype' => 'App.EtatPrestataire',
'template' => '@SonataAdmin/Boolean/editable_boolean.html.twig'
'editable' => true
))
;
}
......
......@@ -21,7 +21,6 @@ use Symfony\Component\Form\Extension\Core\Type\TextType;
*/
class FaqAdmin extends AbstractAdmin
{
/**
* {@inheritdoc}
*/
......@@ -33,7 +32,7 @@ class FaqAdmin extends AbstractAdmin
'data' => $this->getConfigurationPool()->getContainer()->get('security.token_storage')->getToken()->getUser()->getId(),
'data_class' => null,
'entity_class' => User::class,
'em' => $this->getConfigurationPool()->getContainer()->get('doctrine')->getEntityManager()
'em' => $this->getConfigurationPool()->getContainer()->get('doctrine')->getManager()
))
->add('name', TextType::class, array(
'label' => 'Titre :'
......@@ -68,11 +67,14 @@ class FaqAdmin extends AbstractAdmin
unset($this->listModes['mosaic']);
$listMapper
->addIdentifier('name', null, array('label' => 'Titre'))
->addIdentifier('content', 'html', array('label' => 'Text'))
->addIdentifier('fichier', null, array('label' => 'Fichier'))
->addIdentifier('image', null, array('label' => 'Image'))
->add('content', 'html', array('label' => 'Text', 'sortable' => false))
->add('fichier', null, array('label' => 'Fichier'))
->add('image', null, array('label' => 'Image'))
->addIdentifier('user', null, array('label' => 'Auteur'))
->addIdentifier('enabled', null, array('label' => 'Activé', 'datatype' => 'App.Document', 'template' => '@SonataAdmin/Boolean/editable_boolean.html.twig'))
->add('enabled', null, array(
'label' => 'Activé',
'editable' => true
))
;
}
}
......@@ -137,14 +137,15 @@ class FluxAdmin extends AbstractAdmin
{
unset($this->listModes['mosaic']);
$listMapper
->addIdentifier('createdAt', 'datetime', array('label' => 'Date'))
->addIdentifier('type', null, array('label' => 'Type'))
->addIdentifier('montant', null, array('label' => 'Montant'))
->addIdentifier('expediteur', null, array('label' => 'Expediteur'))
->addIdentifier('destinataire', null, array('label' => 'Destinataire'))
->add('createdAt', 'datetime', array('label' => 'Date'))
->add('type', null, array('label' => 'Type'))
->add('montant', null, array('label' => 'Montant'))
->add('expediteur', null, array('label' => 'Expediteur'))
->add('destinataire', null, array('label' => 'Destinataire'))
->add('operateur', null, array('label' => 'Operateur'))
->addIdentifier('reference', null, array('label' => 'Reference'))
->addIdentifier('verify', null, array('label' => 'Vérifié'))
// @TODO : ajouter le verify uniquement si l'on souhaite (param url)=> sinon c'est beaucoup trop long...
// ->addIdentifier('verify', null, array('label' => 'Vérifié'))
;
}
}
......@@ -142,6 +142,11 @@ class GroupeAdmin extends AbstractAdmin
$collection->remove('delete');
}
public function getRouteShowOnFront($object)
{
return $this->routeGenerator->generate('show_groupe', array('slug' => $object->getSlug()));
}
/**
* {@inheritdoc}
*/
......@@ -150,9 +155,9 @@ class GroupeAdmin extends AbstractAdmin
unset($this->listModes['mosaic']);
$listMapper
->addIdentifier('name', null, array('label' => 'Nom du groupe'))
->addIdentifier('gestionnaires', null, array('label' => 'Gestionnaires'))
->addIdentifier('content', 'html', array('truncate' => array('length' => 80), 'label' => 'Description'))
->addIdentifier('compte', null, array('label' => 'Solde'))
->add('gestionnaires', null, array('label' => 'Gestionnaires'))
->add('content', 'html', array('truncate' => array('length' => 80), 'label' => 'Description'))
->add('compte', null, array('label' => 'Solde'))
->add(
'getPrestatairesCount',
null,
......@@ -182,7 +187,16 @@ class GroupeAdmin extends AbstractAdmin
'sort_parent_association_mappings' => [],
]
)
->addIdentifier('enabled', null, array('label' => 'Activé', 'datatype' => 'App.Groupeprestataire', 'template' => '@SonataAdmin/Boolean/editable_boolean.html.twig'))
->add('enabled', null, array(
'label' => 'Activé',
'editable' => true
))
->add('_action', null, [
'actions' => [
'show' => ['template' => '@SonataAdmin/CRUD/list__action_showonfront.html.twig'],
'edit' => []
]
])
;
}
}
......@@ -4,6 +4,7 @@ namespace App\Admin;
use App\Entity\Prestataire;
use App\Enum\GroupePrestaEnum;
use App\Form\Type\GeolocFormType;
use FOS\CKEditorBundle\Form\Type\CKEditorType;
use Sonata\AdminBundle\Admin\AbstractAdmin;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
......@@ -62,22 +63,6 @@ class GroupeprestataireAdmin extends AbstractAdmin
->setParameter('groupe', $this->getRequest()->getSession()->get('_groupegere'))
;
}
// @TODO : NE FONCTIONNE PAS : pour pouvoir classer par nombre de prestataires !
// voir https://github.com/sonata-project/SonataDoctrineORMAdminBundle/issues/297
if ('list' === $context) {
$rootAlias = $query->getRootAliases()[0];
$parameters = $this->getFilterParameters();
if ('getPrestatairesCount' === $parameters['_sort_by']) {
$query->setDistinct(true);
// $query->select('o', 'DISTINCT o');
// $query
// ->leftJoin($rootAlias.'.prestataires', 'gpr')
// // ->leftJoin('groupes_prestataires.prestataires', 'pr')
// ->groupBy($rootAlias.'.id')
// ->orderBy('COUNT(gpr.id)', $parameters['_sort_order'])
// ;
}
}
return $query;
}
......@@ -107,7 +92,7 @@ class GroupeprestataireAdmin extends AbstractAdmin
if (($user->isGranted('ROLE_GESTION_GROUPE') || $user->isGranted('ROLE_CONTACT') || $user->isGranted('ROLE_TRESORIER')) && !empty($this->getRequest()->getSession()->get('_groupegere'))) {
$prestataires = $this->getConfigurationPool()->getContainer()->get('doctrine')->getRepository(Prestataire::class)->findByGroupeLocal($this->getRequest()->getSession()->get('_groupegere'));
} else {
$prestataires = $this->getConfigurationPool()->getContainer()->get('doctrine')->getRepository(Prestataire::class)->findBy(array('enabled' => true), array('raison'=> 'ASC'));
$prestataires = $this->getConfigurationPool()->getContainer()->get('doctrine')->getRepository(Prestataire::class)->findBy(array('enabled' => true, 'mlc' => false), array('raison'=> 'ASC'));
}
if ($user->isGranted('ROLE_SUPER_ADMIN') || $user->isGranted('ROLE_ADMIN_SIEGE')) {
$formMapper
......@@ -132,6 +117,12 @@ class GroupeprestataireAdmin extends AbstractAdmin
'label_attr' => array('class' => 'checkbox-inline')
))
->end()
->with('Adresse', ['class' => 'col-md-5'])
->add('geoloc', GeolocFormType::class, array(
'label' => false,
'required' => false
))
->end()
->with('Image', ['class' => 'col-md-5'])
->add('image', MediaType::class, array(
'provider' => 'sonata.media.provider.image',
......@@ -178,6 +169,7 @@ class GroupeprestataireAdmin extends AbstractAdmin
->addIdentifier('type', null, array(
'label' => 'Type'
))
->addIdentifier('geoloc', null, array('label' => 'Adresse'))
->addIdentifier('horaires', 'html', array(
'label' => 'Horaires',
'strip' => true,
......@@ -187,10 +179,9 @@ class GroupeprestataireAdmin extends AbstractAdmin
'label' => 'Nombre de prestas',
'sortable' => false,
))
->addIdentifier('enabled', null, array(
->add('enabled', null, array(
'label' => 'Activé',
'datatype' => 'App.Groupeprestataire',
'template' => '@SonataAdmin/Boolean/editable_boolean.html.twig'
'editable' => true
))
;
}
......
......@@ -38,7 +38,7 @@ class NewsAdmin extends AbstractAdmin
'data' => $this->getConfigurationPool()->getContainer()->get('security.token_storage')->getToken()->getUser()->getId(),
'data_class' => null,
'entity_class' => User::class,
'em' => $this->getConfigurationPool()->getContainer()->get('doctrine')->getEntityManager()
'em' => $this->getConfigurationPool()->getContainer()->get('doctrine')->getManager()
))
->add('media', MediaType::class, array(
'provider' => 'sonata.media.provider.file',
......
......@@ -66,7 +66,7 @@ class PageAdmin extends AbstractAdmin
'data' => $this->getConfigurationPool()->getContainer()->get('security.token_storage')->getToken()->getUser()->getId(),
'data_class' => null,
'entity_class' => User::class,
'em' => $this->getConfigurationPool()->getContainer()->get('doctrine')->getEntityManager()
'em' => $this->getConfigurationPool()->getContainer()->get('doctrine')->getManager()
))
->add('name', TextType::class, array(
'label' => 'Titre :',
......@@ -113,7 +113,10 @@ class PageAdmin extends AbstractAdmin
$listMapper
->addIdentifier('user', null, array('label' => 'Auteur'))
->addIdentifier('name', null, array('label' => 'Titre'))
// ->addIdentifier('enabled', null, array('label' => 'Activé', 'datatype' => 'App.Page', 'template' => '@SonataAdmin/Boolean/editable_boolean.html.twig'))
// ->add('enabled', null, array(
// 'label' => 'Activé',
// 'editable' => true
// ))
;
}
......
......@@ -41,8 +41,9 @@ class ReconversionAdmin extends FluxAdmin
{
$user = $this->security->getUser();
$query = parent::createQuery($context);
$query->andWhere($query->getRootAliases()[0].".type = :type")
->setParameter('type', 'prestataire_siege');
$query
->andWhere($query->getRootAliases()[0].".type = :type")
->setParameter('type', 'reconversion');
;
return $query;
}
......@@ -59,9 +60,11 @@ class ReconversionAdmin extends FluxAdmin
->addIdentifier('operateur', User::class, array('label' => 'Operateur'))
->addIdentifier('expediteur', null, array('label' => 'Expediteur'))
->addIdentifier('destinataire', null, array('label' => 'Destinataire'))
->addIdentifier('montant', null, array('label' => 'Montant'))
->addIdentifier('reference', null, array('label' => 'Reference'))
->addIdentifier('reconverti', null, array('label' => 'Reconverti ?', 'datatype' => 'App.Flux', 'template' => 'block/reconverti_field.html.twig'))
->add('montant', null, array('label' => 'Montant initial'))
->add('tauxreconversion', null, array('label' => 'Taux reconversion'))
->add('montantareconvertir', null, array('label' => 'Montant à transférer'))
->add('reference', null, array('label' => 'Reference'))
->add('reconverti', null, array('label' => 'Reconverti ?', 'datatype' => 'App.Flux', 'template' => 'block/reconverti_field.html.twig'))
;
}
......
......@@ -33,7 +33,7 @@ class RubriqueAdmin extends AbstractAdmin
protected $security;
protected $datagridValues = [
'_sort_order' => 'ASC',
'_sort_by' => 'id',
'_sort_by' => 'name',
];
public function configure()
......@@ -66,7 +66,7 @@ class RubriqueAdmin extends AbstractAdmin
{
$rubrique = $this->getSubject();
$user = $this->security->getUser();
$prestataires = $this->getConfigurationPool()->getContainer()->get('doctrine')->getRepository(Prestataire::class)->findBy(array('enabled' => true), array('raison'=> 'ASC'));
$prestataires = $this->getConfigurationPool()->getContainer()->get('doctrine')->getRepository(Prestataire::class)->findBy(array('enabled' => true, 'mlc' => false), array('raison'=> 'ASC'));
// get the current Image instance
$imageHelp = null;
......@@ -126,19 +126,16 @@ class RubriqueAdmin extends AbstractAdmin
;
}
public function getRouteShowOnFront($object)
{
return $this->routeGenerator->generate('show_rubrique', array('slug' => $object->getSlug()));
}
protected function configureRoutes(RouteCollection $collection)
{
// $collection->remove('delete');
}
// public function getBatchActions()
// {
// $actions = parent::getBatchActions();
// unset($actions['delete']);
// return $actions;
// }
/**
* {@inheritdoc}
*/
......@@ -146,17 +143,20 @@ class RubriqueAdmin extends AbstractAdmin
{
unset($this->listModes['mosaic']);
$listMapper
->addIdentifier('file', null, array('label' => 'Icône', 'template' => '@SonataAdmin/Image/preview_image_o.html.twig'))
->add('file', null, array('label' => 'Icône', 'template' => '@SonataAdmin/Image/preview_image_o.html.twig'))
->add('name', null, array('editable' => true, 'truncate' => array('length' => 80), 'label' => 'Nom du groupe'))
->addIdentifier('content', 'html', array('truncate' => array('length' => 80), 'label' => 'Description'))
->add('content', 'html', array('truncate' => array('length' => 80), 'label' => 'Description'))
->add('getPrestatairesCount', null, array(
'label' => 'Nombre de prestas',
'sortable' => false,
'sortable' => false
))
->add('enabled', null, array(
'label' => 'Activé',
'editable' => true
))
->addIdentifier('enabled', null, array('label' => 'Activé', 'datatype' => 'App.Groupeprestataire', 'template' => '@SonataAdmin/Boolean/editable_boolean.html.twig'))
// You may also specify the actions you want to be displayed in the list
->add('_action', null, [
'actions' => [
'show' => ['template' => '@SonataAdmin/CRUD/list__action_showonfront.html.twig'],
'edit' => [],
'delete' => [],
]
......
......@@ -65,7 +65,7 @@ class TransfertAdmin extends FluxAdmin
// $query->andWhere($query->getRootAliases()[0].".parenttype = :type")
// ->setParameter('type', 'transfert');
$em = $this->getConfigurationPool()->getContainer()->get('doctrine')->getEntityManager();
$em = $this->getConfigurationPool()->getContainer()->get('doctrine')->getManager();
$fluxtable = $em->getMetadataFactory()->getMetadataFor(Flux::class)->getTableName();
if ($this->rolecheck->isGranted('ROLE_GESTION_GROUPE') || $this->rolecheck->isGranted('ROLE_CONTACT')) {
if (empty($this->getRequest()->getSession()->get('_groupegere'))) {
......@@ -74,7 +74,7 @@ class TransfertAdmin extends FluxAdmin
$groupe = $this->getRequest()->getSession()->get('_groupegere');
$connection = $em->getConnection();
$prestatable = $em->getMetadataFactory()->getMetadataFor(Prestataire::class)->getTableName();
$statement = $connection->prepare('SELECT f.id FROM '.$fluxtable.' f WHERE f.groupe_id = '.$groupe->getId().' OR (f.type = \'prestataire_siege\' AND f.prestataire_id IN (SELECT p.id FROM '.$fluxtable.' p WHERE p.groupe_id = '.$groupe->getId().'))');
$statement = $connection->prepare('SELECT f.id FROM '.$fluxtable.' f WHERE f.groupe_id = '.$groupe->getId().' OR (f.type = \'reconversion\' AND f.prestataire_id IN (SELECT p.id FROM '.$fluxtable.' p WHERE p.groupe_id = '.$groupe->getId().'))');
$statement->execute();
$ids = $statement->fetchAll();
$query
......@@ -83,11 +83,11 @@ class TransfertAdmin extends FluxAdmin
;
}
} elseif ($this->rolecheck->isGranted('ROLE_COMPTOIR')) {
if (empty($user->getComptoirsgeres())) {
if (empty($this->getRequest()->getSession()->get('_comptoirgere'))) {
$query->andWhere('false');
} else {
$comptoir = $this->session->get('_comptoirgere');
$em = $this->getConfigurationPool()->getContainer()->get('doctrine')->getEntityManager();
$comptoir = $this->getRequest()->getSession()->get('_comptoirgere');
$em = $this->getConfigurationPool()->getContainer()->get('doctrine')->getManager();
$connection = $em->getConnection();
$statement = $connection->prepare('SELECT f.id FROM '.$fluxtable.' f WHERE f.comptoir_id = '.$comptoir->getId().' OR f.user_id = '.$user->getId());
$statement->execute();
......
......@@ -59,7 +59,10 @@ class UserAdmin extends BaseUserAdmin
->addIdentifier('username')
->add('email')
->add('groups')
->addIdentifier('enabled', null, array('label' => 'Activé', 'datatype' => 'App.User', 'template' => '@SonataAdmin/Boolean/editable_boolean.html.twig'))
->add('enabled', null, array(
'label' => 'Activé',
'editable' => true
))
->add('createdAt')
;
......
......@@ -4,10 +4,9 @@ namespace App\Controller;
use App\Entity\Comptoir;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Routing\Annotation\Route;
class ComptoirController extends AbstractController
class ComptoirController extends FrontController
{
private $em;
......@@ -21,6 +20,9 @@ class ComptoirController extends AbstractController
*/
public function listeComptoirAction()
{
if (!$this->isFrontActivated()) {
return $this->redirectToRoute('index');
}
return $this->render('comptoir/liste.html.twig', array(
'comptoirs' => $this->em->getRepository(Comptoir::class)->findBy(array('enabled' => true), array('createdAt' => 'DESC'))
));
......@@ -31,6 +33,9 @@ class ComptoirController extends AbstractController
*/
public function carteComptoirAction()
{
if (!$this->isFrontActivated()) {
return $this->redirectToRoute('index');
}
return $this->render('comptoir/carte.html.twig', array(
'comptoirs' => $this->em->getRepository(Comptoir::class)->findBy(array('enabled' => true), array('createdAt' => 'DESC'))
));
......@@ -41,9 +46,11 @@ class ComptoirController extends AbstractController
*/
public function showGroupeAction(Comptoir $comptoir)
{
if (!$this->isFrontActivated()) {
return $this->redirectToRoute('index');
}
return $this->render('comptoir/show.html.twig', array(
'comptoir' => $comptoir
));
}
}
<?php
namespace App\Controller;
use App\Entity\Faq;
use Doctrine\ORM\EntityManagerInterface;
use Knp\Component\Pager\PaginatorInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
class FaqController extends FrontController
{
protected $em;
private $paginator;
public function __construct(EntityManagerInterface $em, PaginatorInterface $paginator)
{
$this->em = $em;
$this->paginator = $paginator;
}
/**
* @Route("/faq", name="faq")
*/
public function faqAction()
{
if (!$this->isFrontActivated()) {
return $this->redirectToRoute('index');
}
return $this->render('faq/liste.html.twig', array(
'faqs' => $this->em->getRepository(Faq::class)->findBy(array('enabled' => true), array('createdAt' => 'DESC'))
));
}
/**
* @Route("/faq/{slug}", name="show_faq")
*/
public function showFaqAction(Faq $faq)
{
if (!$this->isFrontActivated()) {
return $this->redirectToRoute('index');
}
return $this->render('faq/show.html.twig', array(
'faq' => $faq
));
}
}
......@@ -13,6 +13,7 @@ use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Core\Security;
use Symfony\Component\Translation\TranslatorInterface;
/**
......@@ -41,8 +42,9 @@ class FluxController extends AbstractController
protected $eventDispatcher;
protected $session;
public function __construct(EntityManagerInterface $em, TranslatorInterface $translator, EventDispatcherInterface $eventDispatcher, SessionInterface $session)
public function __construct(Security $security, EntityManagerInterface $em, TranslatorInterface $translator, EventDispatcherInterface $eventDispatcher, SessionInterface $session)
{
$this->security = $security;
$this->em = $em;
$this->translator = $translator;
$this->eventDispatcher = $eventDispatcher;
......@@ -51,6 +53,9 @@ class FluxController extends AbstractController
protected function manageFluxForm(Request $request, Form $form, $compte, $success, $title)
{
if ($this->security->getUser() == null) {
throw new \Exception("[FLUX] Opération impossible ! Utilisateur déconnecté !");
}
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$data = $form->getData();
......@@ -74,7 +79,6 @@ class FluxController extends AbstractController
return $this->render('flux/transaction.html.twig', [
'form' => $form->createView(),
// 'compte' => $compte,
'title' => $title
]);
}
......
<?php
namespace App\Controller;
use App\Entity\GlobalParameter;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Routing\Annotation\Route;
class FrontController extends AbstractController
{
protected function isFrontActivated()
{
return ($this->em->getRepository(GlobalParameter::class)->val(GlobalParameter::USE_WORDPRESS) == 'false');
}
}
......@@ -4,13 +4,12 @@ namespace App\Controller;
use App\Entity\Groupe;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
class GroupeController extends AbstractController
class GroupeController extends FrontController
{
private $em;
protected $em;
public function __construct(EntityManagerInterface $em)
{
......@@ -22,6 +21,9 @@ class GroupeController extends AbstractController
*/
public function listeGroupeAction()
{
if (!$this->isFrontActivated()) {
return $this->redirectToRoute('index');
}
return $this->render('groupe/liste.html.twig', array(
'groupes' => $this->em->getRepository(Groupe::class)->findBy(array('enabled' => true), array('createdAt' => 'DESC'))
));
......@@ -33,9 +35,11 @@ class GroupeController extends AbstractController
*/
public function showGroupeAction(Groupe $groupe)
{
if (!$this->isFrontActivated()) {
return $this->redirectToRoute('index');
}
return $this->render('groupe/show.html.twig', array(
'groupe' => $groupe
));
}
}
......@@ -24,7 +24,7 @@ class GroupePrestaController extends AbstractController
}
/**
* @Route("/prestataires/groupe/{type}/{slug}", name="show_groupeprestataire")
* @Route("/prestataires/groupe/{slug}", name="show_groupeprestataire")
*/
public function showGroupeAction(Groupeprestataire $groupe)
{
......
......@@ -9,9 +9,9 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
class NewsController extends AbstractController
class NewsController extends FrontController
{
private $em;
protected $em;
private $paginator;
public function __construct(EntityManagerInterface $em, PaginatorInterface $paginator)
......@@ -25,6 +25,9 @@ class NewsController extends AbstractController
*/
public function listeNewsAction(Request $request)
{
if (!$this->isFrontActivated()) {
return $this->redirectToRoute('index');
}
$pagination = $this->paginator->paginate(
$this->em->getRepository(News::class)->findLatest(),
$request->query->getInt('page', 1),
......@@ -40,6 +43,9 @@ class NewsController extends AbstractController
*/
public function showNewsAction(News $news)
{
if (!$this->isFrontActivated()) {
return $this->redirectToRoute('index');
}
return $this->render('news/show.html.twig', array(
'news' => $news
));
......
<?php
namespace App\Controller;
use App\Entity\Page;
use Doctrine\ORM\EntityManagerInterface;
use Knp\Component\Pager\PaginatorInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
class PageController extends FrontController
{
protected $em;
private $paginator;
public function __construct(EntityManagerInterface $em, PaginatorInterface $paginator)
{
$this->em = $em;
$this->paginator = $paginator;
}
/**
* @Route("/page/{slug}", name="show_page")
*/
public function pageAction(Page $page)
{
if (!$this->isFrontActivated()) {
return $this->redirectToRoute('index');
}
$template = 'page.html.twig';
if (!empty($page->getTemplate()) && $this->get('templating')->exists($page->getTemplate())) {
$template = $page->getTemplate();
}
return $this->render($template, array(
'page' => $page
));
}
}
......@@ -10,15 +10,14 @@ use App\Form\Type\PrestataireInfosFormType;
use App\Form\Type\TransactionPrestataireAdherentFormType;
use Doctrine\ORM\EntityManagerInterface;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Routing\RouterInterface;
class PrestatairesController extends AbstractController
class PrestatairesController extends FrontController
{
private $em;
protected $em;
private $router;
public function __construct(EntityManagerInterface $em, RouterInterface $router)
......@@ -32,6 +31,9 @@ class PrestatairesController extends AbstractController
*/
public function showPrestaAction(Prestataire $prestataire)
{
if (!$this->isFrontActivated()) {
return $this->redirectToRoute('index');
}
if ($prestataire->isMlc()) {
// Ne pas montrer la page du prestataire recevant les cotisations !
return new RedirectResponse($this->router->generate('index'));
......@@ -46,6 +48,9 @@ class PrestatairesController extends AbstractController
*/
public function listePrestaAction()
{
if (!$this->isFrontActivated()) {
return $this->redirectToRoute('index');
}
$type_presta = $this->em->getRepository(TypePrestataire::class)->findOneBy(array('slug' => 'prestataire'));
$prestas = $this->em->getRepository(Prestataire::class)->findBy(array('enabled' => true, 'typeprestataire' => $type_presta), array('raison' => 'ASC'));
......@@ -60,6 +65,9 @@ class PrestatairesController extends AbstractController
*/
public function listePartnerAction()
{
if (!$this->isFrontActivated()) {
return $this->redirectToRoute('index');
}
$type_partner = $this->em->getRepository(TypePrestataire::class)->findOneBy(array('slug' => 'partenaire'));
$partners = $this->em->getRepository(Prestataire::class)->findBy(array('enabled' => true, 'typeprestataire' => $type_partner), array('raison' => 'ASC'));
......@@ -74,6 +82,9 @@ class PrestatairesController extends AbstractController
*/
public function cartePrestaAction()
{
if (!$this->isFrontActivated()) {
return $this->redirectToRoute('index');
}
$prestas = $this->em->getRepository(Prestataire::class)->findBy(array('enabled' => true), array('raison' => 'ASC'));
return $this->render('presta/carte.html.twig', array(
......@@ -86,6 +97,9 @@ class PrestatairesController extends AbstractController
*/
public function rubriquesAction()
{
if (!$this->isFrontActivated()) {
return $this->redirectToRoute('index');
}
$rubriques = $this->em->getRepository(Rubrique::class)->findBy(array('enabled' => true), array('name' => 'ASC'));
return $this->render('presta/rubriques.html.twig', array(
......@@ -98,6 +112,9 @@ class PrestatairesController extends AbstractController
*/
public function showRubriqueAction(Rubrique $rubrique)
{
if (!$this->isFrontActivated()) {
return $this->redirectToRoute('index');
}
return $this->render('presta/show_rubrique.html.twig', array(
'rubrique' => $rubrique
));
......
......@@ -3,8 +3,12 @@
namespace App\Controller;
use App\Entity\User;
use App\Entity\CotisationAdherent;
use App\Entity\CotisationPrestataire;
use App\Enum\MoyenEnum;
use App\Form\Type\CotiserFormType;
use App\Form\Type\UserInfosFormType;
use App\Tools\RoleCheck;
use Doctrine\ORM\EntityManagerInterface;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
......@@ -17,30 +21,55 @@ class UserController extends AbstractController
{
private $em;
private $translator;
private $rolecheck;
public function __construct(EntityManagerInterface $em, TranslatorInterface $translator)
public function __construct(EntityManagerInterface $em, TranslatorInterface $translator, RoleCheck $rolecheck)
{
$this->em = $em;
$this->translator = $translator;
$this->rolecheck = $rolecheck;
}
/**
* @Route("/cotiser", name="cotiser")
* @IsGranted("ROLE_USER")
*/
public function cotiserAction(Request $request)
{
$form = $this->createForm(CotiserFormType::class, $adherent);
$options = [];
if ($this->rolecheck->isGranted('ROLE_ADHERENT')) {
$options['data_class'] = CotisationAdherent::class;
} elseif ($this->rolecheck->isGranted('ROLE_PRESTATAIRE')) {
$options['data_class'] = CotisationPrestataire::class;
}
$form = $this->createForm(CotiserFormType::class, null, $options);
$form->handleRequest($request);
if ($form->isSubmitted()) {
$cotisation = $form->getData();
if ($form->get('payMLC')->isClicked()) {
$cotisation->setMoyen(MoyenEnum::MOYEN_MLC);
} else {
$cotisation->setMoyen(MoyenEnum::MOYEN_CB);
}
if ($form->isValid()) {
$adherentNew = $form->getData();
if ($form->get('payMLC')->isClicked()) {
$this->em->persist($cotisation);
$this->em->flush();
$this->addFlash(
'success',
// "Cotisation pour l'année {$cotisation->getCotisationInfos()->getAnnee()} bien reçue. Merci !"
$this->translator->trans("Cotisation bien reçue. Merci !")
);
return $this->redirectToRoute('index');
} else {
//@TODO : redirect to payment page
}
} else {
$this->addFlash(
'error',
'Problème avec l\'adhésion !'
$this->translator->trans('Problème avec la cotisation !')
);
}
}
......
......@@ -34,7 +34,7 @@ class UserGestionnaireGroupeController extends FluxController
*/
public function groupeInfosAction(Request $request)
{
// TODO : récupérer groupe gere en session
// @TODO : récupérer groupe gere en session
$form = $this->createForm(GroupeInfosFormType::class, $this->session->get('_groupegere'));
$form->handleRequest($request);
......
......@@ -11,7 +11,16 @@ use ApiPlatform\Core\Annotation\ApiResource;
use Symfony\Component\Serializer\Annotation\Groups;
/**
* @ApiResource(
* ApiResource(
* attributes={"security"="is_granted('ROLE_ADMIN_ADHERENT_GERER_VIEW')"},
* collectionOperations={
* "get"={"security"="is_granted('ROLE_ADMIN_ADHERENT_GERER_LIST')"},
* "post"={"security"="is_granted('ROLE_ADMIN_ADHERENT_GERER_EDIT')"}
* },
* itemOperations={
* "get"={"security"="is_granted('ROLE_ADMIN_ADHERENT_GERER_LIST')"},
* "put"={"security"="is_granted('ROLE_ADMIN_ADHERENT_GERER_EDIT') or object.user == user"},
* },
* normalizationContext={"groups"={"read"}},
* denormalizationContext={"groups"={"write"}}
* )
......
<?php
namespace App\Entity;
use App\Entity\GlobalParameter;
use App\Entity\Prestataire;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
/**
* COMMISSION
* - PRESTATAIRES => PRESTATAIRE MLC (Commission de Reconversion)
*
* @ORM\Entity()
*/
class CommissionPrestataireMLC extends Flux
{
/**
* @ORM\OneToOne(targetEntity="Prestataire")
* @ORM\JoinColumn(name="prestataire_id", referencedColumnName="id")
*/
protected $expediteur;
/**
* @ORM\OneToOne(targetEntity="Prestataire")
* @ORM\JoinColumn(name="prestataire_dest_id", referencedColumnName="id")
*/
protected $destinataire;
/**
* @return string
*/
public function getParenttype(): string
{
return self::TYPE_COMMISSION;
}
/**
* @return string
*/
public function getType(): string
{
return 'reconversion_prestataire';
}
public function operate($em)
{
return [];
}
public function getUsersToNotify()
{
return [];
}
}
......@@ -16,10 +16,19 @@ use Symfony\Component\Serializer\Annotation\Groups;
/**
* @ApiResource(
* attributes={"security"="is_granted('ROLE_ADMIN_COMPTOIR_GERER_VIEW') or is_granted('ROLE_API')"},
* collectionOperations={
* "get"={"security"="is_granted('ROLE_ADMIN_COMPTOIR_GERER_LIST') or is_granted('ROLE_API')"},
* "post"={"security"="is_granted('ROLE_ADMIN_COMPTOIR_GERER_EDIT')"}
* },
* itemOperations={
* "get"={"security"="is_granted('ROLE_ADMIN_COMPTOIR_GERER_VIEW') or is_granted('ROLE_API')"},
* "put"={"security"="is_granted('ROLE_ADMIN_COMPTOIR_GERER_EDIT')"},
* },
* normalizationContext={"groups"={"read"}},
* denormalizationContext={"groups"={"write"}}
* )
* @ORM\Entity
* @ORM\Entity(repositoryClass="App\Repository\ComptoirRepository")
* @ORM\HasLifecycleCallbacks()
* @ORM\Table(name="comptoir")
*/
......
......@@ -3,8 +3,8 @@
namespace App\Entity;
use App\Entity\Prestataire;
use App\Entity\EntityTrait\ContactEmailTelTrait;
use App\Entity\EntityTrait\EnablableEntityTrait;
use App\Entity\EntityTrait\GeolocEntityTrait;
use App\Entity\EntityTrait\NameSlugContentEntityTrait;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
......@@ -14,7 +14,16 @@ use ApiPlatform\Core\Annotation\ApiResource;
use Symfony\Component\Serializer\Annotation\Groups;
/**
* @ApiResource(
* ApiResource(
* attributes={"security"="is_granted('ROLE_ADMIN_PRESTATAIRE_GERER_VIEW')"},
* collectionOperations={
* "get"={"security"="is_granted('ROLE_ADMIN_PRESTATAIRE_GERER_LIST')"},
* "post"={"security"="is_granted('ROLE_ADMIN_PRESTATAIRE_GERER_EDIT')"}
* },
* itemOperations={
* "get"={"security"="is_granted('ROLE_ADMIN_PRESTATAIRE_GERER_VIEW')"},
* "put"={"security"="is_granted('ROLE_ADMIN_PRESTATAIRE_GERER_EDIT')"},
* },
* normalizationContext={"groups"={"read"}},
* denormalizationContext={"groups"={"write"}}
* )
......@@ -25,7 +34,8 @@ class ContactPrestataire
{
use NameSlugContentEntityTrait,
TimestampableEntity,
EnablableEntityTrait;
EnablableEntityTrait,
ContactEmailTelTrait;
/**
* @ORM\Id()
......
......@@ -17,7 +17,7 @@ class Cotisation extends Flux
{
/**
* @ORM\OneToOne(targetEntity="Prestataire")
* @ORM\JoinColumn(name="prestataire_id", referencedColumnName="id", nullable=true)
* @ORM\JoinColumn(name="prestataire_dest_id", referencedColumnName="id", nullable=true)
*/
protected $destinataire;
......
......@@ -8,7 +8,16 @@ use ApiPlatform\Core\Annotation\ApiResource;
use Symfony\Component\Serializer\Annotation\Groups;
/**
* @ApiResource(
* ApiResource(
* attributes={"security"="is_granted('ROLE_ADMIN_ADHERENT_COTISATIONS_GERER_VIEW')"},
* collectionOperations={
* "get"={"security"="is_granted('ROLE_ADMIN_ADHERENT_COTISATIONS_GERER_LIST')"},
* "post"={"security"="is_granted('ROLE_ADMIN_ADHERENT_COTISATIONS_GERER_EDIT')"}
* },
* itemOperations={
* "get"={"security"="is_granted('ROLE_ADMIN_ADHERENT_COTISATIONS_GERER_VIEW')"},
* "put"={"security"="is_granted('ROLE_ADMIN_ADHERENT_COTISATIONS_GERER_EDIT')"},
* },
* normalizationContext={"groups"={"read"}},
* denormalizationContext={"groups"={"write"}}
* )
......
......@@ -8,7 +8,16 @@ use ApiPlatform\Core\Annotation\ApiResource;
use Symfony\Component\Serializer\Annotation\Groups;
/**
* @ApiResource(
* ApiResource(
* attributes={"security"="is_granted('ROLE_ADMIN_ADHERENT_COTISATIONS_GERER_VIEW') or is_granted('ROLE_ADMIN_PRESTATAIRE_COTISATIONS_GERER_VIEW')"},
* collectionOperations={
* "get"={"security"="is_granted('ROLE_ADMIN_ADHERENT_COTISATIONS_GERER_LIST') or is_granted('ROLE_ADMIN_PRESTATAIRE_COTISATIONS_GERER_LIST')"},
* "post"={"security"="is_granted('ROLE_ADMIN_ADHERENT_COTISATIONS_GERER_EDIT') or is_granted('ROLE_ADMIN_PRESTATAIRE_COTISATIONS_GERER_EDIT')"}
* },
* itemOperations={
* "get"={"security"="is_granted('ROLE_ADMIN_ADHERENT_COTISATIONS_GERER_LIST') or is_granted('ROLE_ADMIN_PRESTATAIRE_COTISATIONS_GERER_VIEW')"},
* "put"={"security"="is_granted('ROLE_ADMIN_ADHERENT_COTISATIONS_GERER_EDIT') or is_granted('ROLE_ADMIN_PRESTATAIRE_COTISATIONS_GERER_EDIT')"},
* },
* normalizationContext={"groups"={"read"}},
* denormalizationContext={"groups"={"write"}}
* )
......
......@@ -8,12 +8,22 @@ use ApiPlatform\Core\Annotation\ApiResource;
use Symfony\Component\Serializer\Annotation\Groups;
/**
* @ApiResource(
* ApiResource(
* attributes={"security"="is_granted('ROLE_ADMIN_PRESTATAIRE_COTISATIONS_GERER_VIEW')"},
* collectionOperations={
* "get"={"security"="is_granted('ROLE_ADMIN_PRESTATAIRE_COTISATIONS_GERER_LIST')"},
* "post"={"security"="is_granted('ROLE_ADMIN_PRESTATAIRE_COTISATIONS_GERER_EDIT')"}
* },
* itemOperations={
* "get"={"security"="is_granted('ROLE_ADMIN_PRESTATAIRE_COTISATIONS_GERER_VIEW')"},
* "put"={"security"="is_granted('ROLE_ADMIN_PRESTATAIRE_COTISATIONS_GERER_EDIT')"},
* },
* normalizationContext={"groups"={"read"}},
* denormalizationContext={"groups"={"write"}}
* )
*
* TRANSACTION
* - Cotisation d'un prestataire
* - Cotisation(s) d'un prestataire
*
* @ORM\Entity
*/
......
......@@ -11,7 +11,16 @@ use ApiPlatform\Core\Annotation\ApiResource;
use Symfony\Component\Serializer\Annotation\Groups;
/**
* @ApiResource(
* ApiResource(
* attributes={"security"="is_granted('ROLE_ADMIN_DOCUMENT_GERER_VIEW')"},
* collectionOperations={
* "get"={"security"="is_granted('ROLE_ADMIN_DOCUMENT_GERER_LIST')"},
* "post"={"security"="is_granted('ROLE_ADMIN_DOCUMENT_GERER_EDIT')"}
* },
* itemOperations={
* "get"={"security"="is_granted('ROLE_ADMIN_DOCUMENT_GERER_VIEW')"},
* "put"={"security"="is_granted('ROLE_ADMIN_DOCUMENT_GERER_EDIT')"},
* },
* normalizationContext={"groups"={"read"}},
* denormalizationContext={"groups"={"write"}}
* )
......
......@@ -12,7 +12,16 @@ use ApiPlatform\Core\Annotation\ApiResource;
use Symfony\Component\Serializer\Annotation\Groups;
/**
* @ApiResource(
* ApiResource(
* attributes={"security"="is_granted('ROLE_ADMIN_PRESTATAIRE_GERER_VIEW')"},
* collectionOperations={
* "get"={"security"="is_granted('ROLE_ADMIN_PRESTATAIRE_GERER_LIST')"},
* "post"={"security"="is_granted('ROLE_ADMIN_PRESTATAIRE_GERER_EDIT')"}
* },
* itemOperations={
* "get"={"security"="is_granted('ROLE_ADMIN_PRESTATAIRE_GERER_VIEW')"},
* "put"={"security"="is_granted('ROLE_ADMIN_PRESTATAIRE_GERER_EDIT')"},
* },
* normalizationContext={"groups"={"read"}},
* denormalizationContext={"groups"={"write"}}
* )
......@@ -80,4 +89,14 @@ class EtatPrestataire
}
return $this;
}
public function getPrestatairesCount()
{
return $this->getPrestataires()->count();
}
public function __toString(): string
{
return $this->getName()?$this->getName():'[Tag]';
}
}
......@@ -11,7 +11,16 @@ use ApiPlatform\Core\Annotation\ApiResource;
use Symfony\Component\Serializer\Annotation\Groups;
/**
* @ApiResource(
* ApiResource(
* attributes={"security"="is_granted('ROLE_ADMIN_FAQ_GERER_VIEW')"},
* collectionOperations={
* "get"={"security"="is_granted('ROLE_ADMIN_FAQ_GERER_LIST')"},
* "post"={"security"="is_granted('ROLE_ADMIN_FAQ_GERER_EDIT')"}
* },
* itemOperations={
* "get"={"security"="is_granted('ROLE_ADMIN_FAQ_GERER_VIEW')"},
* "put"={"security"="is_granted('ROLE_ADMIN_FAQ_GERER_EDIT')"},
* },
* normalizationContext={"groups"={"read"}},
* denormalizationContext={"groups"={"write"}}
* )
......
......@@ -13,26 +13,23 @@ use ApiPlatform\Core\Annotation\ApiResource;
use Symfony\Component\Serializer\Annotation\Groups;
/**
* @ApiResource(
* normalizationContext={"groups"={"read"}},
* denormalizationContext={"groups"={"write"}}
* )
* FLUX = TRANSFERT ou TRANSACTION ou COTISATIONS
* @ORM\Entity(repositoryClass="App\Repository\FluxRepository")
* @ORM\HasLifecycleCallbacks()
* @ORM\InheritanceType("SINGLE_TABLE")
* @ORM\DiscriminatorColumn(name="discr", type="string")
* @ORM\DiscriminatorMap({"cotisation" = "Cotisation", "cotisation_adherent" = "CotisationAdherent", "cotisation_prestataire" = "CotisationPrestataire", "tro_adh_pre" = "TransactionAdherentPrestataire", "tro_adh_adh" = "TransactionAdherentAdherent", "tro_pre_adh" = "TransactionPrestataireAdherent", "tro_pre_pre" = "TransactionPrestatairePrestataire", "tre_cpt_grp" = "TransfertComptoirGroupe", "tre_grp_cpt" = "TransfertGroupeComptoir", "tre_pre_cpt" = "TransfertPrestataireComptoir", "tre_pre_sie" = "TransfertPrestataireSiege", "tre_sie_grp" = "TransfertSiegeGroupe", "tre_grp_sie" = "TransfertGroupeSiege", "vte_cpt_pre" = "VenteComptoirPrestataire", "vte_cpt_adh" = "VenteComptoirAdherent", "ret_cpt_pre" = "RetraitComptoirPrestataire", "ret_cpt_adh" = "RetraitComptoirAdherent"})
* @ORM\DiscriminatorMap({"cotisation" = "Cotisation", "cotisation_adherent" = "CotisationAdherent", "cotisation_prestataire" = "CotisationPrestataire", "tro_adh_pre" = "TransactionAdherentPrestataire", "tro_adh_adh" = "TransactionAdherentAdherent", "tro_pre_adh" = "TransactionPrestataireAdherent", "tro_pre_pre" = "TransactionPrestatairePrestataire", "tre_cpt_grp" = "TransfertComptoirGroupe", "tre_grp_cpt" = "TransfertGroupeComptoir", "tre_pre_cpt" = "TransfertPrestataireComptoir", "tre_pre_sie" = "TransfertPrestataireSiege", "tre_sie_grp" = "TransfertSiegeGroupe", "tre_grp_sie" = "TransfertGroupeSiege", "vte_cpt_pre" = "VenteComptoirPrestataire", "vte_cpt_adh" = "VenteComptoirAdherent", "ret_cpt_pre" = "RetraitComptoirPrestataire", "ret_cpt_adh" = "RetraitComptoirAdherent", "com_rec_pre" = "CommissionPrestataireMLC"})
*/
abstract class Flux
{
use TimestampableEntity;
const TYPE_COTISATION = 'cotisation';
const TYPE_TRANSFERT = 'transfert';
const TYPE_TRANSACTION = 'transaction';
const TYPE_VENTE = 'vente';
const TYPE_RETRAIT = 'retrait';
const TYPE_COTISATION = 'cotisation';
const TYPE_TRANSFERT = 'transfert';
const TYPE_TRANSACTION = 'transaction';
const TYPE_VENTE = 'vente';
const TYPE_RETRAIT = 'retrait';
const TYPE_COMMISSION = 'commission';
/**
* @var int
......@@ -45,7 +42,7 @@ abstract class Flux
protected $id;
/**
* @ORM\ManyToOne(targetEntity="User", inversedBy="flux", cascade={"all"})
* @ORM\ManyToOne(targetEntity="User", inversedBy="flux")
* @ORM\JoinColumn(name="user_id", referencedColumnName="id", nullable=true)
* @Groups({"read", "write"})
*/
......@@ -120,6 +117,14 @@ abstract class Flux
*/
protected $hash;
/**
* @var float
*
* @ORM\Column(name="tauxreconversion", type="decimal", precision=7, scale=2, nullable=true)
* @Groups({"read", "write"})
*/
protected $tauxreconversion;
protected $expediteur = null;
protected $destinataire = null;
protected $cotisationInfos = null;
......@@ -136,11 +141,8 @@ abstract class Flux
* Obtenir la liste des utilisateurs à notifier
* @return array Tableau d'utilisateurs
*/
public function getUsersToNotify()
{
return [];
}
abstract public function getUsersToNotify();
public function __construct()
{
$this->parenttype = $this->getParenttype();
......@@ -325,6 +327,30 @@ abstract class Flux
return $this;
}
/**
* Get tauxreconversion
* @return
*/
public function getTauxreconversion(): ?float
{
return $this->tauxreconversion;
}
/**
* Set tauxreconversion
* @return $this
*/
public function setTauxreconversion(?float $tauxreconversion): self
{
$this->tauxreconversion = $tauxreconversion;
return $this;
}
public function getMontantareconvertir()
{
return ($this->getMontant() - ($this->getMontant()*($this->getTauxreconversion()/100)));
}
public function isVente()
{
return false;
......@@ -364,10 +390,11 @@ abstract class Flux
if ($flux->getExpediteur() == $flux->getDestinataire()) {
throw new \Exception("[FLUX] Opération impossible ! Expéditeur et Destinataire ne peuvent pas être les mêmes !");
}
$hash = password_hash($flux->getAllInfosUncrypted(), PASSWORD_BCRYPT, ['cost' => 12]);
$flux->setHash($hash);
$event->getEntityManager()->persist($flux);
$event->getEntityManager()->flush();
// @TODO : generation du hash du flux trop gourmand en ressource !
// $hash = password_hash($flux->getAllInfosUncrypted(), PASSWORD_BCRYPT, ['cost' => 12]);
// $flux->setHash($hash);
// $event->getEntityManager()->persist($flux);
// $event->getEntityManager()->flush();
}
/**
......@@ -377,29 +404,22 @@ abstract class Flux
*/
public function validateConstraint(ExecutionContextInterface $context)
{
if ($this->getMoyen() == MoyenEnum::MOYEN_MLC && $this->getParenttype() == self::TYPE_COTISATION) {
if ($this->getMoyen() == MoyenEnum::MOYEN_MLC
&& $this->getParenttype() == self::TYPE_COTISATION
&& $this->getExpediteur()->getEcompte() < $this->getMontant()
) {
$context->addViolation('Montant supérieur au solde de monnaie éléctronique.');
}
}
public function toHtmlArray(): string
public function getAllInfosUncrypted(): string
{
if (empty($this->getDestinataire()) || empty($this->getExpediteur()) || empty($this->getMontant())) {
return "[FLUX] Visualisation impossible ! Destinataire / Expéditeur et/ou montant manquant(s) !";
}
$return = '<tr>';
$return .= '<td>'.$this->getCreatedAt()->format('d/m/Y H:i').'</td>';
$return .= '<td>'.ucwords($this->getParenttype()).'</td>';
$return .= '<td>'.$this->getExpediteur().'</td>';
$return .= '<td>'.$this->getDestinataire().'</td>';
$return .= '<td>'.$this->getMontant().'&euro;</td>';
$return .= '</tr>';
return $return;
return $_ENV['APP_SECRET'].$this->id.$this->operateur->getId().$this->role.$this->type.$this->montant.$this->moyen.$this->reference.$this->destinataire->getId().$this->expediteur->getId();
}
public function getAllInfosUncrypted(): string
public function getOperateurAndRole(): string
{
return $_ENV['APP_SECRET'].$this->id.$this->operateur->getId().$this->role.$this->type.$this->montant.$this->moyen.$this->reference.$this->destinataire->getId().$this->expediteur->getId();
return $this->operateur->__toString() . ' (' . $this->role . ')';
}
public function __toString(): string
......
......@@ -10,10 +10,6 @@ use ApiPlatform\Core\Annotation\ApiResource;
use Symfony\Component\Serializer\Annotation\Groups;
/**
* @ApiResource(
* normalizationContext={"groups"={"read"}},
* denormalizationContext={"groups"={"write"}}
* )
* @ORM\Entity
* @ORM\Table(name="geoloc")
*/
......
......@@ -15,6 +15,15 @@ use Symfony\Component\Serializer\Annotation\Groups;
/**
* @ApiResource(
* attributes={"security"="is_granted('ROLE_ADMIN_PRESTATAIRE_GERER_VIEW') or is_granted('ROLE_API')"},
* collectionOperations={
* "get"={"security"="is_granted('ROLE_ADMIN_PRESTATAIRE_GERER_LIST') or is_granted('ROLE_API')"},
* "post"={"security"="is_granted('ROLE_ADMIN_PRESTATAIRE_GERER_EDIT')"}
* },
* itemOperations={
* "get"={"security"="is_granted('ROLE_ADMIN_PRESTATAIRE_GERER_VIEW') or is_granted('ROLE_API')"},
* "put"={"security"="is_granted('ROLE_ADMIN_PRESTATAIRE_GERER_EDIT')"},
* },
* normalizationContext={"groups"={"read"}},
* denormalizationContext={"groups"={"write"}}
* )
......
......@@ -4,32 +4,29 @@ namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use ApiPlatform\Core\Annotation\ApiResource;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/**
* @ApiResource(
* normalizationContext={"groups"={"read"}},
* denormalizationContext={"groups"={"write"}}
* )
* @ORM\Entity(repositoryClass="App\Repository\GlobalParameterRepository")
* @UniqueEntity(
* fields={"name"},
* errorPath="name",
* message="Ce nom de paramètre est déjà utilisé !"
* )
*/
class GlobalParameter
{
// Default global parameters for MLC
const MLC_TITLE = 'MLC_TITLE';
const MLC_DESCRIPTION = 'MLC_DESCRIPTION';
const MLC_KEYWORDS = 'MLC_KEYWORDS';
const USE_WORDPRESS = 'USE_WORDPRESS';
const MLC_NAME = 'MLC_NAME';
const MLC_NAME_SMALL = 'MLC_NAME_SMALL';
const MLC_NOTIF_EMAIL = 'MLC_NOTIF_EMAIL';
const MLC_CONTACT_EMAIL = 'MLC_CONTACT_EMAIL';
const COTISATION_ADHERENT = 'COTISATION_ADHERENT';
const COTISATION_PRESTATAIRE = 'COTISATION_PRESTATAIRE';
const RECONVERSION_ADHERENT = 'RECONVERSION_ADHERENT';
const RECONVERSION_PRESTATAIRE = 'RECONVERSION_PRESTATAIRE';
// const MAP_CENTER = 'MAP_CENTER';
// const MAP_ZOOM = 'MAP_ZOOM';
// const FAVICON_URL = 'FAVICON_URL';
const MAP_CENTER = 'MAP_CENTER';
const MAP_ZOOM = 'MAP_ZOOM';
/**
* @ORM\Id()
......
......@@ -10,14 +10,8 @@ use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Gedmo\Timestampable\Traits\TimestampableEntity;
use Symfony\Component\Validator\Constraints as Assert;
use ApiPlatform\Core\Annotation\ApiResource;
use Symfony\Component\Serializer\Annotation\Groups;
/**
* @ApiResource(
* normalizationContext={"groups"={"read"}},
* denormalizationContext={"groups"={"write"}}
* )
* @ORM\Entity
* @ORM\Table(name="groupe")
*/
......@@ -40,7 +34,7 @@ class Groupe
/**
* @var Siege
*
* @ORM\ManyToOne(targetEntity="Siege", inversedBy="groupes", cascade={"persist"})
* @ORM\ManyToOne(targetEntity="Siege", inversedBy="groupes")
* @ORM\JoinColumn(name="siege_id", referencedColumnName="id", nullable=false)
*/
private $siege;
......
......@@ -16,10 +16,19 @@ use Symfony\Component\Serializer\Annotation\Groups;
/**
* @ApiResource(
* attributes={"security"="is_granted('ROLE_ADMIN_PRESTATAIRE_GERER_VIEW') or is_granted('ROLE_API')"},
* collectionOperations={
* "get"={"security"="is_granted('ROLE_ADMIN_PRESTATAIRE_GERER_LIST') or is_granted('ROLE_API')"},
* "post"={"security"="is_granted('ROLE_ADMIN_PRESTATAIRE_GERER_EDIT')"}
* },
* itemOperations={
* "get"={"security"="is_granted('ROLE_ADMIN_PRESTATAIRE_GERER_VIEW') or is_granted('ROLE_API')"},
* "put"={"security"="is_granted('ROLE_ADMIN_PRESTATAIRE_GERER_EDIT')"},
* },
* normalizationContext={"groups"={"read"}},
* denormalizationContext={"groups"={"write"}}
* )
* @ORM\Entity
* @ORM\Entity(repositoryClass="App\Repository\GroupeprestataireRepository")
* @ORM\Table(name="groupeprestaire")
*/
class Groupeprestataire
......
<?php
namespace App\Entity;
use App\Dto\MapInput;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use ApiPlatform\Core\Annotation\ApiResource;
use App\Controller\MapController;
use App\Entity\EntityTrait\GeolocEntityTrait;
use Symfony\Component\Serializer\Annotation\Groups;
/**
* @ApiResource(
* collectionOperations={
* "get",
* "post"
* },
* itemOperations={
* "get",
* "put",
* "delete",
* },
* collectionOperations={
* "get",
* "post",
* "get_all_poi"={
* "controller"=MapController::class,
* "method"="GET",
* "input"=false,
* "output"=Map::class,
* "path"="/public/poi/all",
* "read"=false,
* "swagger_context" = {
* "parameters" = {
* {
* "name" = "geoloc",
* "in" = "query",
* "description" = "[Latitude, Longitude], exemple : [45.123,4.023]",
* "required" = false,
* "type" : "string",
* },
* {
* "name" = "distance",
* "in" = "query",
* "description" = "Distance in kilometers",
* "required" = false,
* "type" : "string"
* }
* }
* },
* "security"="is_granted('ROLE_ADMIN_PRESTATAIRE_GERER_LIST') or is_granted('ROLE_API')"},
* },
* )
*/
class Map
{
/**
* @var string|null
*
* @ORM\Column(length=150)
* @Groups({"read", "write"})
*/
protected $name;
/**
* @var string|null
*
* @ORM\Column(type="text", nullable=true)
* @Groups({"read", "write"})
*/
private $content;
/**
* @var null|string
*
* @ORM\Column(name="web", type="string", length=255, nullable=true)
* @Groups({"read", "write"})
*/
private $web;
/**
* @var null|string
*
* @ORM\Column(name="link", type="string", length=255, nullable=true)
* @Groups({"read", "write"})
*/
private $link;
/**
* @var null|string
*
* @ORM\Column(name="hours", type="string", length=255, nullable=true)
* @Groups({"read", "write"})
*/
private $hours;
/**
* @var null|string
*
* @ORM\Column(name="icon", type="string", length=255, nullable=true)
* @Groups({"read", "write"})
*/
private $icon;
/**
* @var Rubrique[]
* @ORM\OneToMany(targetEntity="Rubrique")
* @Groups({"read", "write"})
*/
private $rubriques;
/**
* @var Geoloc[]
* @ORM\OneToMany(targetEntity="Geoloc")
* @Groups({"read", "write"})
*/
private $geolocs;
/**
* Get name
* @return
*/
public function getName()
{
return $this->name;
}
/**
* Get content
* @return
*/
public function getContent()
{
return $this->content;
}
/**
* Get web
* @return
*/
public function getWeb()
{
return $this->web;
}
/**
* Get link
* @return
*/
public function getLink()
{
return $this->link;
}
/**
* Get hours
* @return
*/
public function getHours()
{
return $this->hours;
}
/**
* Get icon
* @return
*/
public function getIcon()
{
return $this->icon;
}
/**
* Get rubriques
* @return
*/
public function getRubriques(): ?Rubrique
{
return $this->rubriques;
}
/**
* Get geolocs
* @return
*/
public function getGeolocs(): ?Geoloc
{
return $this->geolocs;
}
}
<?php
namespace App\Entity;
use App\Entity\EntityTrait\EnablableEntityTrait;
use App\Entity\EntityTrait\NameSlugContentEntityTrait;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Gedmo\Timestampable\Traits\TimestampableEntity;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity
* @ORM\Table(name="message")
*/
class Message
{
use NameSlugContentEntityTrait,
EnablableEntityTrait,
TimestampableEntity;
/**
* @var int
*
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @var User
*
* @ORM\ManyToOne(targetEntity="User", inversedBy="messagesSend", cascade={"persist"})
*/
private $expediteur;
/**
* @var User
*
* @ORM\ManyToOne(targetEntity="User", inversedBy="messagesReceived", cascade={"persist"})
*/
private $destinataire;
/**
* @return int
*/
public function getId(): int
{
return $this->id;
}
/**
* @param User $destinataire
* @return $this
*/
public function setDestinataire(User $destinataire)
{
$this->destinataire = $destinataire;
return $this;
}
/**
* @return User
*/
public function getDestinataire(): User
{
return $this->destinataire;
}
/**
* @param User $expediteur
* @return $this
*/
public function setExpediteur(User $expediteur)
{
$this->expediteur = $expediteur;
return $this;
}
/**
* @return User
*/
public function getExpediteur(): User
{
return $this->expediteur;
}
}
......@@ -12,7 +12,16 @@ use ApiPlatform\Core\Annotation\ApiResource;
use Symfony\Component\Serializer\Annotation\Groups;
/**
* @ApiResource(
* ApiResource(
* attributes={"security"="is_granted('ROLE_ADMIN_NEWS_GERER_VIEW')"},
* collectionOperations={
* "get"={"security"="is_granted('ROLE_ADMIN_NEWS_GERER_LIST')"},
* "post"={"security"="is_granted('ROLE_ADMIN_NEWS_GERER_EDIT')"}
* },
* itemOperations={
* "get"={"security"="is_granted('ROLE_ADMIN_NEWS_GERER_VIEW')"},
* "put"={"security"="is_granted('ROLE_ADMIN_NEWS_GERER_EDIT')"},
* },
* normalizationContext={"groups"={"read"}},
* denormalizationContext={"groups"={"write"}}
* )
......
......@@ -12,7 +12,16 @@ use ApiPlatform\Core\Annotation\ApiResource;
use Symfony\Component\Serializer\Annotation\Groups;
/**
* @ApiResource(
* ApiResource(
* attributes={"security"="is_granted('ROLE_ADMIN_PAGE_GERER_VIEW')"},
* collectionOperations={
* "get"={"security"="is_granted('ROLE_ADMIN_PAGE_GERER_LIST')"},
* "post"={"security"="is_granted('ROLE_ADMIN_PAGE_GERER_EDIT')"}
* },
* itemOperations={
* "get"={"security"="is_granted('ROLE_ADMIN_PAGE_GERER_VIEW')"},
* "put"={"security"="is_granted('ROLE_ADMIN_PAGE_GERER_EDIT')"},
* },
* normalizationContext={"groups"={"read"}},
* denormalizationContext={"groups"={"write"}}
* )
......
......@@ -18,6 +18,15 @@ use Symfony\Component\Serializer\Annotation\Groups;
/**
* @ApiResource(
* attributes={"security"="is_granted('ROLE_ADMIN_PRESTATAIRE_GERER_VIEW') or is_granted('ROLE_API')"},
* collectionOperations={
* "get"={"security"="is_granted('ROLE_ADMIN_PRESTATAIRE_GERER_LIST') or is_granted('ROLE_API')"},
* "post"={"security"="is_granted('ROLE_ADMIN_PRESTATAIRE_GERER_EDIT')"}
* },
* itemOperations={
* "get"={"security"="is_granted('ROLE_ADMIN_PRESTATAIRE_GERER_VIEW') or is_granted('ROLE_API')"},
* "put"={"security"="is_granted('ROLE_ADMIN_PRESTATAIRE_GERER_EDIT')"},
* },
* normalizationContext={"groups"={"read"}},
* denormalizationContext={"groups"={"write"}}
* )
......@@ -203,6 +212,14 @@ class Prestataire
*/
private $etats;
/**
* Taux de reconversion propre au prestataire
* @var float
* @ORM\Column(name="tauxreconversion", type="decimal", precision=7, scale=2, nullable=true)
* @Groups({"read", "write"})
*/
protected $tauxreconversion;
public function __construct()
{
$this->users = new ArrayCollection();
......@@ -406,10 +423,10 @@ class Prestataire
}
/**
* @param Geoloc $geoloc
* @param GeolocPrestataire $geoloc
* @return $this
*/
public function addGeoloc(Geoloc $geoloc): self
public function addGeoloc(GeolocPrestataire $geoloc): self
{
if (!$this->geolocs->contains($geoloc)) {
$this->geolocs[] = $geoloc;
......@@ -419,10 +436,10 @@ class Prestataire
}
/**
* @param Geoloc $geoloc
* @param GeolocPrestataire $geoloc
* @return $this
*/
public function removeGeoloc(Geoloc $geoloc): self
public function removeGeoloc(GeolocPrestataire $geoloc): self
{
if ($this->geolocs->contains($geoloc)) {
$this->geolocs->removeElement($geoloc);
......@@ -738,6 +755,25 @@ class Prestataire
return $this;
}
/**
* Get tauxreconversion
* @return
*/
public function getTauxreconversion(): ?float
{
return $this->tauxreconversion;
}
/**
* Set tauxreconversion
* @return $this
*/
public function setTauxreconversion(?float $tauxreconversion): self
{
$this->tauxreconversion = $tauxreconversion;
return $this;
}
public function __toString(): string
{
return ($this->raison?$this->raison:'Prestataire '.$this->id);
......
......@@ -13,6 +13,15 @@ use Symfony\Component\Serializer\Annotation\Groups;
/**
* @ApiResource(
* attributes={"security"="is_granted('ROLE_ADMIN_PRESTATAIRE_GERER_VIEW') or is_granted('ROLE_API')"},
* collectionOperations={
* "get"={"security"="is_granted('ROLE_ADMIN_PRESTATAIRE_GERER_LIST') or is_granted('ROLE_API')"},
* "post"={"security"="is_granted('ROLE_ADMIN_PRESTATAIRE_GERER_EDIT')"}
* },
* itemOperations={
* "get"={"security"="is_granted('ROLE_ADMIN_PRESTATAIRE_GERER_VIEW') or is_granted('ROLE_API')"},
* "put"={"security"="is_granted('ROLE_ADMIN_PRESTATAIRE_GERER_EDIT')"},
* },
* normalizationContext={"groups"={"read"}},
* denormalizationContext={"groups"={"write"}}
* )
......
......@@ -45,9 +45,4 @@ abstract class Transaction extends Flux
}
return [];
}
public function getUsersToNotify()
{
return [$this->getDestinataire()->getUser(), $this->getExpediteur()->getUser()];
}
}
......@@ -36,4 +36,9 @@ class TransactionAdherentAdherent extends Transaction
{
return 'adherent_adherent';
}
public function getUsersToNotify()
{
return [$this->getDestinataire()->getUser(), $this->getExpediteur()->getUser()];
}
}
......@@ -16,15 +16,15 @@ use Symfony\Component\Validator\Constraints as Assert;
class TransactionAdherentPrestataire extends Transaction
{
/**
* @ORM\OneToOne(targetEntity="Adherent")
* @ORM\JoinColumn(name="adherent_id", referencedColumnName="id")
* @ORM\ManyToOne(targetEntity="Adherent")
* @ORM\JoinColumn(name="adherent_id", referencedColumnName="id", nullable=false)
* @Assert\NotBlank
*/
protected $expediteur;
/**
* @ORM\OneToOne(targetEntity="Prestataire")
* @ORM\JoinColumn(name="prestataire_id", referencedColumnName="id")
* @ORM\ManyToOne(targetEntity="Prestataire")
* @ORM\JoinColumn(name="prestataire_id", referencedColumnName="id", nullable=false)
* @Assert\NotBlank
*/
protected $destinataire;
......@@ -36,4 +36,9 @@ class TransactionAdherentPrestataire extends Transaction
{
return 'adherent_prestataire';
}
public function getUsersToNotify()
{
return array_merge([$this->getExpediteur()->getUser()], $this->getDestinataire()->getUsers()->toArray());
}
}
......@@ -34,4 +34,9 @@ class TransactionPrestataireAdherent extends Transaction
{
return 'prestataire_adherent';
}
public function getUsersToNotify()
{
return array_merge([$this->getDestinataire()->getUser()], $this->getExpediteur()->getUsers()->toArray());
}
}
......@@ -34,4 +34,9 @@ class TransactionPrestatairePrestataire extends Transaction
{
return 'prestataire_prestataire';
}
public function getUsersToNotify()
{
return array_merge($this->getExpediteur()->getUsers()->toArray(), $this->getDestinataire()->getUsers()->toArray());
}
}
......@@ -34,7 +34,6 @@ class TransfertGroupeSiege extends Transfert
public function getUsersToNotify()
{
// @TODO : notify siege ?
return $this->getExpediteur()->getGestionnaires()->toArray();
return array_merge(['siege'], $this->getExpediteur()->getGestionnaires()->toArray());
}
}
......@@ -36,7 +36,7 @@ class TransfertPrestataireComptoir extends Transfert
{
$this->getExpediteur()->addEcompte($this->getMontant());
$this->getDestinataire()->addCompte($this->getMontant());
$this->getDestinataire()->getGroupe()->getSiege()->addCompteNantie($this->getMontant());
$this->getDestinataire()->getGroupe()->getSiege()->removeCompteNantie($this->getMontant());
return [$this->getExpediteur(), $this->getDestinataire()];
}
......
......@@ -4,8 +4,11 @@ namespace App\Entity;
use App\Entity\GlobalParameter;
use App\Entity\Prestataire;
use App\Enum\MoyenEnum;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use ApiPlatform\Core\Annotation\ApiResource;
use Symfony\Component\Serializer\Annotation\Groups;
/**
* TRANSFERT
......@@ -31,6 +34,7 @@ class TransfertPrestataireSiege extends Transfert
* @var boolean
* @Assert\Type("bool")
* @ORM\Column(type="boolean")
* @Groups({"read", "write"})
*/
protected $reconverti = false;
......@@ -56,25 +60,49 @@ class TransfertPrestataireSiege extends Transfert
*/
public function getType(): string
{
return 'prestataire_siege'; //reconversion
return 'reconversion';
}
public function operate($em)
{
$this->getExpediteur()->removeEcompte($this->getMontant());
// @TODO : gérer le taux de reconversion
// $taux = $em->getRepository(Prestataire::class)->val(GlobalParameter::RECONVERSION_PRESTATAIRE);
// $taux = $em->getRepository(GlobalParameter::class)->val(GlobalParameter::RECONVERSION_PRESTATAIRE);
// $montantAjoute = $this->getMontant() - ($this->getMontant()*($taux/100));
$this->getDestinataire()->addCompte($this->getMontant());
$this->getDestinataire()->removeCompteNantie($this->getMontant());
// On récupère le taux de reconversion (du formulaire s'il est précisé sinon par défaut dans la configuration globale)
$taux = $this->getTauxreconversion();
if (empty($taux)) {
$taux = $em->getRepository(GlobalParameter::class)->val(GlobalParameter::RECONVERSION_PRESTATAIRE);
}
if ($taux > 0) {
// On calcul les montants à virer au prestataire et la commission
$montantAVirer = $this->getMontant() - ($this->getMontant()*($taux/100));
$montantPreleve = $this->getMontant() - $montantAVirer;
$this->setMontant($montantAVirer);
$this->setTauxreconversion($taux);
// On récupère le presta qui reçoit les commissions
$mlcPrestataire = $em->getRepository(Prestataire::class)->findOneBy(array('mlc' => true));
//Création d'un flux supplémentaire pour représenter la commission prise au prestataire et transféré à l'association qui gère la MLC
$fluxCommission = new CommissionPrestataireMLC();
$fluxCommission->setExpediteur($this->getExpediteur());
$fluxCommission->setOperateur($this->getOperateur());
$fluxCommission->setRole($this->getRole());
$fluxCommission->setDestinataire($mlcPrestataire);
$fluxCommission->setMontant($montantPreleve);
$fluxCommission->setReference('Commission de reconversion');
$fluxCommission->setMoyen(MoyenEnum::MOYEN_TRANSFERT);
$fluxCommission->setTauxreconversion($taux);
$mlcPrestataire->addEcompte($montantPreleve);
return [$this->getExpediteur(), $this->getDestinataire(), $fluxCommission, $mlcPrestataire];
}
return [$this->getExpediteur(), $this->getDestinataire()];
}
public function getUsersToNotify()
{
// @TODO : notify siege ?
return $this->getExpediteur()->getUsers()->toArray();
}
}
......@@ -12,6 +12,15 @@ use Symfony\Component\Serializer\Annotation\Groups;
/**
* @ApiResource(
* attributes={"security"="is_granted('ROLE_ADMIN_PRESTATAIRE_GERER_VIEW') or is_granted('ROLE_API')"},
* collectionOperations={
* "get"={"security"="is_granted('ROLE_ADMIN_PRESTATAIRE_GERER_LIST') or is_granted('ROLE_API')"},
* "post"={"security"="is_granted('ROLE_ADMIN_PRESTATAIRE_GERER_EDIT')"}
* },
* itemOperations={
* "get"={"security"="is_granted('ROLE_ADMIN_PRESTATAIRE_GERER_VIEW') or is_granted('ROLE_API')"},
* "put"={"security"="is_granted('ROLE_ADMIN_PRESTATAIRE_GERER_EDIT')"},
* },
* normalizationContext={"groups"={"read"}},
* denormalizationContext={"groups"={"write"}}
* )
......
......@@ -15,16 +15,25 @@ use Symfony\Component\Serializer\Annotation\Groups;
use FOS\UserBundle\Model\UserInterface;
/**
* @ApiResource(
* normalizationContext={"groups"={"user", "user:read"}},
* denormalizationContext={"groups"={"user", "user:write"}}
* ApiResource(
* attributes={"security"="is_granted('ROLE_SONATA_USER_GERER_VIEW')"},
* collectionOperations={
* "get"={"security"="is_granted('ROLE_SONATA_USER_GERER_LIST')"},
* "post"={"security"="is_granted('ROLE_SONATA_USER_GERER_EDIT')"}
* },
* itemOperations={
* "get"={"security"="is_granted('ROLE_SONATA_USER_GERER_VIEW')"},
* "put"={"security"="is_granted('ROLE_SONATA_USER_GERER_EDIT')"},
* },
* normalizationContext={"groups"={"read"}},
* denormalizationContext={"groups"={"write"}}
* )
* @ORM\Entity(repositoryClass="App\Repository\UserRepository")
* @ORM\Table(name="user")
* @UniqueEntity(
* fields={"firstname", "lastname", "email"},
* fields={"email"},
* errorPath="email",
* message="Ce nom avec cet email est déjà utilisé !"
* message="Cet email est déjà utilisé !"
* )
*/
class User extends BaseUser
......@@ -252,7 +261,6 @@ class User extends BaseUser
return $this;
}
public function isGranted($role)
{
return in_array($role, $this->getRoles());
......@@ -334,7 +342,7 @@ class User extends BaseUser
* @param Prestataire $prestataire
* @return $this
*/
public function removePrestataire(Prestataire $prestataires): self
public function removePrestataire(Prestataire $prestataire): self
{
if ($this->prestataires->contains($prestataire)) {
$this->prestataires->removeElement($prestataire);
......@@ -421,7 +429,7 @@ class User extends BaseUser
* @param Groupesgere $groupesgere
* @return $this
*/
public function removeGroupesgere(Groupe $groupesgeres): self
public function removeGroupesgere(Groupe $groupesgere): self
{
if ($this->groupesgeres->contains($groupesgere)) {
$this->groupesgeres->removeElement($groupesgere);
......@@ -466,7 +474,7 @@ class User extends BaseUser
* @param Comptoirsgere $comptoirsgere
* @return $this
*/
public function removeComptoirsgere(Comptoir $comptoirsgeres): self
public function removeComptoirsgere(Comptoir $comptoirsgere): self
{
if ($this->comptoirsgeres->contains($comptoirsgere)) {
$this->comptoirsgeres->removeElement($comptoirsgere);
......@@ -509,6 +517,14 @@ class User extends BaseUser
}
}
public function __toString()
{
if (empty($this->getFullname())) {
return $this->getEmail();
}
return $this->getFullname();
}
public function getName()
{
if (empty($this->getFullname())) {
......
......@@ -37,6 +37,7 @@ abstract class Vente extends Flux
throw new \Exception("[FLUX] Vente impossible ! Montant supérieur au solde du comptoir !");
} else {
$this->getExpediteur()->removeCompte($this->getMontant());
$this->getExpediteur()->setUpdatedAt(new \DateTime());
$this->getExpediteur()->getGroupe()->getSiege()->addCompteNantie($this->getMontant());
return [$this->getExpediteur(), $this->getExpediteur()->getGroupe()->getSiege()];
......
......@@ -29,17 +29,19 @@ class GeolocListener
if (!$entity instanceof Geoloc) {
return;
}
// GEOCODING ADDRESS :
$httpClient = new \Http\Adapter\Guzzle6\Client();
$provider = Nominatim::withOpenStreetMapServer($httpClient, 'Mozilla/5.0');
$geocoder = new \Geocoder\StatefulGeocoder($provider, 'fr');
$fullAddress = $entity->getAdresse().' '.$entity->getCpostal().' '.$entity->getVille();
// Query geocoding from complete address
$result = $geocoder->geocodeQuery(GeocodeQuery::create($fullAddress));
if (count($result) > 0) {
$coords = $result->first()->getCoordinates();
$entity->setLat($coords->getLatitude());
$entity->setLon($coords->getLongitude());
if (empty($entity->getLat()) && empty($entity->getLon())) {
// GEOCODING ADDRESS :
$httpClient = new \Http\Adapter\Guzzle6\Client();
$provider = Nominatim::withOpenStreetMapServer($httpClient, 'Mozilla/5.0');
$geocoder = new \Geocoder\StatefulGeocoder($provider, 'fr');
$fullAddress = $entity->getAdresse().' '.$entity->getCpostal().' '.$entity->getVille();
// Query geocoding from complete address
$result = $geocoder->geocodeQuery(GeocodeQuery::create($fullAddress));
if (count($result) > 0) {
$coords = $result->first()->getCoordinates();
$entity->setLat($coords->getLatitude());
$entity->setLon($coords->getLongitude());
}
}
}
}
......@@ -9,10 +9,16 @@ use App\Entity\User;
use Doctrine\ORM\EntityManagerInterface;
use FOS\UserBundle\Event\FormEvent;
use FOS\UserBundle\Event\UserEvent;
use FOS\UserBundle\Mailer\MailerInterface;
use FOS\UserBundle\Model\UserManagerInterface;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Routing\RouterInterface;
use Symfony\Component\Security\Csrf\TokenGenerator\TokenGeneratorInterface;
use Symfony\Component\Templating\EngineInterface;
use Symfony\Component\Translation\TranslatorInterface;
/**
* Listener responsable des évènements liés aux flux (transfert, transaction, retrait, vente...)
......@@ -23,18 +29,31 @@ class MLCEventListener implements EventSubscriberInterface
protected $mailer;
protected $params;
protected $templating;
protected $translator;
protected $router;
protected $userManager;
protected $tokenGenerator;
public function __construct(EntityManagerInterface $em, \Swift_Mailer $mailer, ParameterBagInterface $params, EngineInterface $templating)
public function __construct(EntityManagerInterface $em, \Swift_Mailer $mailer, RouterInterface $router, ParameterBagInterface $params, EngineInterface $templating, TranslatorInterface $translator, UserManagerInterface $userManager, TokenGeneratorInterface $tokenGenerator)
{
$this->em = $em;
$this->mailer = $mailer;
$this->params = $params;
$this->templating = $templating;
$this->translator = $translator;
$this->router = $router;
$this->userManager = $userManager;
$this->tokenGenerator = $tokenGenerator;
}
// public function setMailer(TwigSwiftMailer $maileri)
// {
// }
public static function getSubscribedEvents()
{
return array(
MLCEvents::REGISTRATION_ADHERENT => 'onRegistrationAdherent',
MLCEvents::FLUX => 'onFlux',
MLCEvents::COTISATION_COTISATION => 'onCotisation',
MLCEvents::COTISATION_COTISATION_ADHERENT => 'onCotisation',
......@@ -56,15 +75,45 @@ class MLCEventListener implements EventSubscriberInterface
);
}
public function onRegistrationAdherent(UserEvent $event)
{
$user = $event->getUser();
//Set confirmation token (alike resetting password)
if (null === $user->getConfirmationToken()) {
$user->setConfirmationToken($this->tokenGenerator->generateToken());
}
// this depends on requirements
$user->setPasswordRequestedAt(new \DateTime());
$this->userManager->updateUser($user);
$subject = $this->em->getRepository(GlobalParameter::class)->val(GlobalParameter::MLC_NAME_SMALL).' : '.$this->translator->trans('Création de votre compte adhérent');
$mail = (new \Swift_Message($subject))
->setFrom($this->em->getRepository(GlobalParameter::class)->val(GlobalParameter::MLC_NOTIF_EMAIL))
->setTo($user->getEmail())
->setBody(
$this->templating->render(
'email/admin_add_adherent.html.twig',
array(
'subject' => $subject,
'user' => $user,
'confirmationUrl' => $this->router->generate('fos_user_resetting_reset', array('token' => $user->getConfirmationToken()), UrlGeneratorInterface::ABSOLUTE_URL),
)
),
'text/html'
);
$this->mailer->send($mail);
}
public function onFlux(FluxEvent $event)
{
foreach ($event->getFlux()->getUsersToNotify() as $user) {
if ($user instanceof User && $user->getAlertemailflux()) {
$this->sendMail($user, $event->getFlux());
} elseif ($user == 'siege') {
$users = $this->container->get('doctrine')
->getEntityManager()
->createQuery('SELECT u FROM App:User u WHERE u.roles LIKE :role')
$userTable = $this->em->getMetadataFactory()->getMetadataFor(User::class)->getTableName();
$users = $this->em
->createQuery("SELECT u FROM $userTable u WHERE u.roles LIKE :role")
->setParameter('role', '%"ROLE_ADMIN_SIEGE"%')
->getResult();
foreach ($users as $userAdminSiege) {
......@@ -76,7 +125,7 @@ class MLCEventListener implements EventSubscriberInterface
private function sendMail(User $user, Flux $flux)
{
$subject = $this->em->getRepository(GlobalParameter::class)->val(GlobalParameter::MLC_NAME_SMALL).' : '.ucwords($flux->getParenttype()).' '.ucwords($flux->getType());
$subject = $this->em->getRepository(GlobalParameter::class)->val(GlobalParameter::MLC_NAME_SMALL).' : ';
$mail = (new \Swift_Message($subject))
->setFrom($this->em->getRepository(GlobalParameter::class)->val(GlobalParameter::MLC_NOTIF_EMAIL))
->setTo($user->getEmail())
......@@ -94,6 +143,7 @@ class MLCEventListener implements EventSubscriberInterface
$this->mailer->send($mail);
}
// @TODO => notifications/emails differents suivant le type d'action
public function onCotisation(FluxEvent $event)
{
}
......
......@@ -9,7 +9,10 @@ namespace App\Events;
*/
final class MLCEvents
{
/* FLUX */
/* GLOBAL EVENTS*/
const REGISTRATION_ADHERENT = 'mlc.registration_adherent';
/* FLUX EVENTS*/
const FLUX = 'mlc.flux';
const COTISATION_COTISATION = 'mlc.flux.cotisation';
const COTISATION_COTISATION_ADHERENT = 'mlc.flux.cotisation.adherent';
......
......@@ -2,14 +2,14 @@
namespace App\Form;
use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\Form\DataTransformerInterface;
use Symfony\Component\Form\Exception\TransformationFailedException;
class EntityToIdTransformer implements DataTransformerInterface
{
/**
* @var ObjectManager
* @var EntityManagerInterface
*/
protected $objectManager;
......@@ -18,7 +18,7 @@ class EntityToIdTransformer implements DataTransformerInterface
*/
protected $class;
public function __construct(ObjectManager $objectManager, $class)
public function __construct(EntityManagerInterface $objectManager, $class)
{
$this->objectManager = $objectManager;
$this->class = $class;
......
......@@ -46,21 +46,22 @@ class AdherentInfosFormType extends AbstractType
{
$builder
->add('user', UserInfosFormType::class, array(
'label' => false,
'required' => false
'label' => false
))
->add('geoloc', GeolocFormType::class, array(
'label' => false,
'required' => false
))
->add('groupe', ChoiceType::class, array(
'required' => true,
'disabled' => true,
'label' => 'GROUPE LOCAL',
'choices' => $this->container->get('doctrine')->getRepository(Groupe::class)->findAll(),
'choice_label' => 'name',
'placeholder' => 'Choisir un groupe',
'required' => false,
'with_geoloc' => false,
'with_latlon' => false
))
// ->add('groupe', ChoiceType::class, array(
// 'required' => true,
// 'disabled' => true,
// 'label' => 'GROUPE LOCAL',
// 'choices' => $this->container->get('doctrine')->getRepository(Groupe::class)->findAll(),
// 'choice_label' => 'name',
// 'placeholder' => 'Choisir un groupe',
// ))
->add('save', SubmitType::class, ['label' => "Modifier"])
;
}
......
......@@ -48,24 +48,27 @@ class AdhererFormType extends AbstractType
'label' => false,
'required' => false
))
->add('groupe', ChoiceType::class, array(
'required' => true,
'label' => 'GROUPE LOCAL',
'choices' => $this->container->get('doctrine')->getRepository(Groupe::class)->findAll(),
'choice_label' => 'name',
'placeholder' => 'Choisir un groupe',
))
// ->add('groupe', ChoiceType::class, array(
// 'required' => true,
// 'label' => 'GROUPE LOCAL',
// 'choices' => $this->container->get('doctrine')->getRepository(Groupe::class)->findAll(),
// 'choice_label' => 'name',
// 'placeholder' => 'Choisir un groupe',
// ))
->add('geoloc', GeolocFormType::class, array(
'label' => 'ADRESSE',
'required' => false
))
->add('cotisation', AddCotisationFormType::class, array(
'label' => false,
'required' => false,
'mapped' => false,
'data' => $adherent->getUser()->getCotisations()->last()
'with_geoloc' => false,
'with_latlon' => false
))
->add('save', SubmitType::class, ['label' => "Valider l'adhésion"])
// ->add('cotisation', AddCotisationFormType::class, array(
// 'label' => false,
// 'required' => false,
// 'mapped' => false,
// 'data' => $adherent->getUser()->getCotisations()->last()
// ))
// ->add('save', SubmitType::class, ['label' => "Valider l'adhésion"])
->add('save', SubmitType::class, ['label' => "Payer en CB"]);
;
}
......
......@@ -6,6 +6,7 @@ use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\FormBuilderInterface;
class ContactFormType extends AbstractType
......@@ -21,7 +22,7 @@ class ContactFormType extends AbstractType
'label' => 'Votre email :',
'required' => true
))
->add('message', TextType::class, array(
->add('message', TextareaType::class, array(
'label' => 'Votre message :',
'required' => true
))
......
......@@ -32,9 +32,13 @@ class ContactPrestataireFormType extends AbstractType
'label' => "Nom du contact / description :",
'required' => true,
))
->add('content', TextType::class, array(
->add('tel', TextType::class, array(
'label' => "Téléphone :",
'required' => true,
'required' => false,
))
->add('email', TextType::class, array(
'label' => "Email :",
'required' => false,
))
->add('enabled', CheckboxType::class, array(
'label' => 'Public ?',
......
......@@ -22,7 +22,7 @@ class CotisationFormType extends FluxFormType
$builder
->add('montant', MoneyType::class, array(
'label' => 'Montant',
'data' => floatval($this->em->getRepository(GlobalParameter::class)->val(GlobalParameter::COTISATION_MONTANT))
'data' => floatval($this->em->getRepository(GlobalParameter::class)->val(GlobalParameter::COTISATION_ADHERENT))
))
->add('moyen', ChoiceType::class, array(
'required' => true,
......
......@@ -3,58 +3,121 @@
namespace App\Form\Type;
use App\Entity\Adherent;
use App\Entity\Cotisation;
use App\Entity\Groupe;
use App\Entity\Prestataire;
use App\Entity\User;
use App\Entity\GlobalParameter;
use App\Enum\MoyenEnum;
use App\Tools\RoleCheck;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Security\Core\Security;
use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\Constraints\GreaterThanOrEqual;
class CotiserFormType extends AbstractType
{
protected $em;
protected $security;
protected $rolecheck;
protected $session;
public function __construct(EntityManagerInterface $em, Security $security)
public function __construct(EntityManagerInterface $em, Security $security, RoleCheck $rolecheck, SessionInterface $session)
{
$this->em = $em;
$this->security = $security;
$this->rolecheck = $rolecheck;
$this->session = $session;
}
public function buildForm(FormBuilderInterface $builder, array $options)
{
$now = new \DateTime();
if (empty($this->security) && !empty($this->security->getUser())) {
throw new \Exception("Opération impossible ! Utilisateur non connecté !");
}
$now = new \DateTime();
$montant = 0;
$canPayWithMlc = false;
if ($this->rolecheck->isGranted('ROLE_ADHERENT')) {
$montant = floatval($this->em->getRepository(GlobalParameter::class)->val(GlobalParameter::COTISATION_ADHERENT));
$canPayWithMlc = ($this->security->getUser()->getAdherent()->getEcompte() >= $montant);
} elseif ($this->rolecheck->isGranted('ROLE_PRESTATAIRE')) {
$montant = floatval($this->em->getRepository(GlobalParameter::class)->val(GlobalParameter::COTISATION_PRESTATAIRE));
$canPayWithMlc = ($this->session->get('_prestagere')->getEcompte() >= $montant);
}
$builder
->add('operateur', HiddenType::class, array(
'entity_class' => User::class,
'em' => $this->em,
'data_class' => null,
'data' => $this->security->getUser()
'data' => $this->security->getUser()->getId()
))
->add('role', HiddenType::class, array(
'data' => $this->rolecheck->getCurrentRole()->__toString()
))
->add('destinataire', HiddenType::class, array(
'data' => $this->em->getRepository(Prestataire::class)->findOneBy(array('mlc' => true))->getId(),
'data_class' => null,
'entity_class' => Prestataire::class,
'em' => $this->em
))
->add('reference', HiddenType::class, array(
'label' => 'Reference :',
'required' => true,
'data' => 'Cotisation '.$now->format('Y')
))
->add('montant', HiddenType::class, array(
'data' => floatval($this->em->getRepository(GlobalParameter::class)->val(GlobalParameter::COTISATION_MONTANT)),
->add('montant', IntegerType::class, array(
'data' => $montant,
'constraints' => [
new NotBlank(),
new GreaterThanOrEqual(['value' => $montant]),
],
))
->add('moyen', HiddenType::class, array(
'data' => MoyenEnum::MOYEN_MLC,
))
;
;
// ->add('moyen', ChoiceType::class, array(
// 'required' => true,
// 'label' => 'Moyen de paiement :',
// 'choices' => $canPayWithMlc ? [MoyenEnum::getTypeName(MoyenEnum::MOYEN_MLC) => MoyenEnum::MOYEN_MLC, MoyenEnum::getTypeName(MoyenEnum::MOYEN_CB) => MoyenEnum::MOYEN_CB] : [MoyenEnum::getTypeName(MoyenEnum::MOYEN_CB) => MoyenEnum::MOYEN_CB]
// ))
if ($canPayWithMlc) {
$builder->add('payMLC', SubmitType::class, ['label' => "Payer en eMLC"]);
}
$builder->add('payCB', SubmitType::class, ['label' => "Payer en CB"]);
if ($this->rolecheck->isGranted('ROLE_ADHERENT')) {
$builder
->add('expediteur', HiddenType::class, array(
'entity_class' => Adherent::class,
'em' => $this->em,
'data_class' => null,
'data' => $this->security->getUser()->getAdherent()->getId()
))
;
} elseif ($this->rolecheck->isGranted('ROLE_PRESTATAIRE')) {
$builder
->add('expediteur', HiddenType::class, array(
'entity_class' => Prestataire::class,
'em' => $this->em,
'data_class' => null,
'data' => $this->session->get('_prestagere')->getId()
))
;
}
}
/**
......@@ -63,7 +126,6 @@ class CotiserFormType extends AbstractType
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
'data_class' => Cotisation::class,
'cascade_validation' => true
));
}
......
......@@ -18,7 +18,8 @@ class FirstComptoirFormType extends AbstractType
->add('enabled', HiddenType::class, array('data' => true))
->add('name', TextType::class, array(
'label' => 'Nom :',
'required' => true
'required' => true,
'help' => "Vous pourrez éditer la description dans l'interface d'administration"
))
->add('geoloc', GeolocFormType::class, array(
'label' => 'Géolocalisation :',
......
......@@ -73,7 +73,7 @@ class FluxFormType extends AbstractType
;
} else {
$constraintsMontant = [];
if ($flux->getParenttype() == Flux::TYPE_TRANSACTION || $flux->getType() == 'prestataire_siege') {
if ($flux->getParenttype() == Flux::TYPE_TRANSACTION || $flux->getType() == 'reconversion') {
$constraintsMontant = [
new LessThanOrEqual([
'message' => 'Montant supérieur à votre solde.',
......
......@@ -40,11 +40,15 @@ class GeolocFormType extends AbstractType
'label' => 'Ville :',
'required' => $options['required']
))
->add('search', ButtonType::class, [
'label' => 'Géolocaliser',
'attr' => ['class' => 'searchLatLon btn btn-primary', 'data-url' => $this->router->generate('geolocAdresse')],
]);
;
if ($options['with_geoloc'] === true) {
$builder
->add('search', ButtonType::class, [
'label' => 'Géolocaliser',
'attr' => ['class' => 'searchLatLon btn btn-primary', 'data-url' => $this->router->generate('geolocAdresse')],
])
;
}
if ($options['with_latlon'] === true || (!empty($geoloc) && (!empty($geoloc->getLat()) || !empty($geoloc->getLon())))) {
$builder
->add('lat', null, array(
......@@ -64,6 +68,7 @@ class GeolocFormType extends AbstractType
// $resolver->setRequired(['with_latlon']);
$resolver->setDefaults([
'data_class' => Geoloc::class,
'with_geoloc' => true,
'with_latlon' => true
]);
}
......
......@@ -40,7 +40,16 @@ class GlobalConfigurationFormType extends AbstractType
'label' => "Email utilisé pour l'envoi des notifications :",
'name_param' => GlobalParameter::MLC_NOTIF_EMAIL,
'required' => true,
'_placeholder' => 'notification@mlc.com',
'_placeholder' => 'notification@votredomaine.fr',
'constraints_param' => [
new EmailConstraint(['message' => 'Email invalide !'])
],
))
->add('mlccontactemail', GlobalParameterType::class, array(
'label' => "Email de reception des demandes de contact :",
'name_param' => GlobalParameter::MLC_CONTACT_EMAIL,
'required' => true,
'_placeholder' => 'contact@votredomaine.fr',
'constraints_param' => [
new EmailConstraint(['message' => 'Email invalide !'])
],
......@@ -65,16 +74,6 @@ class GlobalConfigurationFormType extends AbstractType
new TypeConstraint(['type' => 'numeric', 'message' => "Le montant n'est pas valide !"])
],
))
->add('mlcreconversionadh', GlobalParameterType::class, array(
'label' => 'Taux de reconversion des adhérents :',
'name_param' => GlobalParameter::RECONVERSION_ADHERENT,
'help' => 'Ne pas utiliser de virgule ",", utiliser le point "."',
'required' => true,
'_placeholder' => '0',
'constraints_param' => [
new TypeConstraint(['type' => 'numeric', 'message' => "Le montant n'est pas valide !"])
],
))
->add('mlcreconversionpresta', GlobalParameterType::class, array(
'label' => 'Taux de reconversion des prestataires :',
'name_param' => GlobalParameter::RECONVERSION_PRESTATAIRE,
......@@ -85,44 +84,38 @@ class GlobalConfigurationFormType extends AbstractType
new TypeConstraint(['type' => 'numeric', 'message' => "Le montant n'est pas valide !"])
],
))
// ->add('mapcenter', GlobalParameterType::class, array(
// 'label' => 'Coordonnées du centre de la carte (Format [lat,long], exemple : [45.7,3.2]):',
// 'name_param' => GlobalParameter::MAP_CENTER,
// 'required' => true,
// '_placeholder' => '[45.7,3.2]',
// 'constraints_param' => [
// new RegexConstraint(['pattern' => '/^\[[0-9]+\.[0-9]+,[0-9]+\.[0-9]+\]/', 'message' => 'Coordonnées invalide, format attendu : [45.7,3.2]'])
// ],
// ))
// ->add('mapzoom', GlobalParameterType::class, array(
// 'label' => 'Zoom de la carte (nombre entre 1 et 15) :',
// 'name_param' => GlobalParameter::MAP_ZOOM,
// 'required' => true,
// '_placeholder' => '9',
// 'constraints_param' => [
// new RegexConstraint(['pattern' => '/^[0-9]{1,2}$/', 'message' => 'Le zoom doit être un nombre entre 0 et 15 !'])
// ],
// ))
// ->add('mlcfavicon', GlobalParameterType::class, array(
// 'label' => 'Chemin du favicon :',
// '_data' => '/images/favicon.png',
// 'name_param' => GlobalParameter::FAVICON_URL,
// 'required' => true,
// ))
->add('mlctitle', GlobalParameterType::class, array(
'label' => '[SEO] Titre par défaut des pages du site web :',
'name_param' => GlobalParameter::MLC_TITLE,
->add('mapcenter', GlobalParameterType::class, array(
'label' => 'Coordonnées du centre de la carte (Format [lat,long], exemple : [45.7,3.2]):',
'name_param' => GlobalParameter::MAP_CENTER,
'required' => true,
'_placeholder' => '[45.7,3.2]',
'constraints_param' => [
new RegexConstraint(['pattern' => '/^\[[0-9]+\.[0-9]+,[0-9]+\.[0-9]+\]/', 'message' => 'Coordonnées invalide, format attendu : [45.7,3.2]'])
],
'help_html' => true,
'help' => "Pour déterminer le centre et zoom de la carte <a target='_blank' href='https://www.openstreetmap.org/'>Ouvrir OpenStreetMap</a><br/>
Exemple : <em>https://www.openstreetmap.org/search?query=clermont#map=12/45.7811/3.0927</em><br/>
Zoom de la carte : 12<br/>
Centre de la carte : [45.7811,3.0927]"
))
->add('mlcdescription', GlobalParameterType::class, array(
'label' => '[SEO] Description par défaut des pages du site web :',
'name_param' => GlobalParameter::MLC_DESCRIPTION,
->add('mapzoom', GlobalParameterType::class, array(
'label' => 'Zoom de la carte (nombre entre 1 et 19) :',
'name_param' => GlobalParameter::MAP_ZOOM,
'required' => true,
'_placeholder' => '9',
'constraints_param' => [
new RegexConstraint(['pattern' => '/^[1-9]$|^1[0-9]$/', 'message' => 'Le zoom doit être un nombre entre 1 et 19, généralement entre 9 et 15 pour les MLC !'])
],
))
->add('mlckeywords', GlobalParameterType::class, array(
'label' => '[SEO] Mot clés par défaut des pages du site web :',
'name_param' => GlobalParameter::MLC_KEYWORDS,
->add('usewordpress', GlobalParameterType::class, array(
'label' => "Utiliser Wordpress pour le site web :",
'name_param' => GlobalParameter::USE_WORDPRESS,
'required' => true,
'_placeholder' => 'false',
'constraints_param' => [
new RegexConstraint(['pattern' => '/^true$|^false$/', 'message' => 'La valeur doit être "true" ou "false"'])
],
'help' => ''
))
;
}
......
......@@ -15,7 +15,7 @@ class GlobalParameterType extends AbstractType
{
$builder
->add('name', HiddenType::class, ['data' => $options['name_param']])
->add('mandatory', HiddenType::class, ['data' => true])
->add('mandatory', HiddenType::class, ['data' => $options['_mandatory']])
->add('value', TextType::class, array(
'label' => false,
'constraints' => $options['constraints_param'],
......@@ -32,10 +32,10 @@ class GlobalParameterType extends AbstractType
$resolver->setDefaults([
'data_class' => GlobalParameter::class,
'required' => true,
'name_param' => 'MLC',
'name_param' => '',
'_placeholder' => '',
'_data' => null,
'default_value' => 'MLC',
'_mandatory' => true,
'constraints_param' => [],
'error_bubbling' => false,
// 'cascade_validation' => true
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment