Commit 36fc65fd by Julien Jorry

in dev

parent e6d936db
...@@ -16,7 +16,7 @@ $('#flash-messages').flashNotification('init'); ...@@ -16,7 +16,7 @@ $('#flash-messages').flashNotification('init');
$(document).ready(function() { $(document).ready(function() {
var mapMarkers = []; var mapMarkers = [];
$('.searchLatLon').on('click', function (e) { $(document).on('click', '.searchLatLon', function (e) {
e.preventDefault(); e.preventDefault();
var self = $(this); var self = $(this);
$.ajax({ $.ajax({
...@@ -75,7 +75,7 @@ $(document).ready(function() { ...@@ -75,7 +75,7 @@ $(document).ready(function() {
if (data.newvalue == 'false') { if (data.newvalue == 'false') {
self.text('non'); self.text('non');
self.data('value', 'false'); self.data('value', 'false');
self.addClass(' '); self.addClass('label-danger');
self.removeClass('label-success'); self.removeClass('label-success');
} else { } else {
self.data('value', 'true'); self.data('value', 'true');
......
...@@ -19,6 +19,7 @@ fos_ck_editor: ...@@ -19,6 +19,7 @@ fos_ck_editor:
Blockquote, -, Image, Link, Unlink, Table] Blockquote, -, Image, Link, Unlink, Table]
- [Format, Maximize, Source] - [Format, Maximize, Source]
enterMode: CKEDITOR.ENTER_BR
filebrowserBrowseRoute: admin_sonata_media_media_ckeditor_browser filebrowserBrowseRoute: admin_sonata_media_media_ckeditor_browser
filebrowserImageBrowseRoute: admin_sonata_media_media_ckeditor_browser filebrowserImageBrowseRoute: admin_sonata_media_media_ckeditor_browser
# Display images by default when clicking the image dialog browse button # Display images by default when clicking the image dialog browse button
......
jms_serializer: jms_serializer:
visitors: visitors:
json: # TODO: will crash in prod json_serialization:
options: options:
- JSON_UNESCAPED_SLASHES - JSON_UNESCAPED_SLASHES
- JSON_PRESERVE_ZERO_FRACTION - JSON_PRESERVE_ZERO_FRACTION
...@@ -93,7 +93,8 @@ security: ...@@ -93,7 +93,8 @@ security:
ROLE_GESTION_GROUPE: [ROLE_USER, ROLE_ADMIN] ROLE_GESTION_GROUPE: [ROLE_USER, ROLE_ADMIN]
ROLE_COMPTOIR: [ROLE_USER, ROLE_ADMIN] ROLE_COMPTOIR: [ROLE_USER, ROLE_ADMIN]
ROLE_CONTACT: [ROLE_USER, ROLE_ADMIN] ROLE_CONTACT: [ROLE_USER, ROLE_ADMIN]
ROLE_SUPER_ADMIN: [ROLE_SONATA_ADMIN, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH] ROLE_ADMIN: [ROLE_USER, ROLE_SONATA_ADMIN]
ROLE_SUPER_ADMIN: [ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]
# Easy way to control access for large sections of your site # Easy way to control access for large sections of your site
# Note: Only the *first* access control that matches will be used # Note: Only the *first* access control that matches will be used
...@@ -109,6 +110,7 @@ security: ...@@ -109,6 +110,7 @@ security:
# Secured part of the site # Secured part of the site
# This config requires being logged for the whole site and having the admin role for the admin part. # This config requires being logged for the whole site and having the admin role for the admin part.
# Change these rules to adapt them to your needs # 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_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: ^/.*, role: IS_AUTHENTICATED_ANONYMOUSLY } - { path: ^/.*, role: IS_AUTHENTICATED_ANONYMOUSLY }
...@@ -21,17 +21,18 @@ sonata_user: ...@@ -21,17 +21,18 @@ sonata_user:
sonata_block: sonata_block:
default_contexts: [sonata_page_bundle] default_contexts: [sonata_page_bundle]
blocks: blocks:
sonata.block.service.text: # sonata.block.service.text:
contexts: [admin] # contexts: [admin]
sonata.admin.block.stats: # sonata.admin.block.stats:
contexts: [admin] # contexts: [admin]
sonata.admin.block.admin_list: sonata.admin.block.admin_list:
contexts: [admin] contexts: [admin]
sonata.admin.block.search_result: # sonata.admin.block.search_result:
# contexts: [admin]
# sonata.formatter.block.formatter:
# contexts: [admin]
admin.block.dashboard:
contexts: [admin] contexts: [admin]
sonata.formatter.block.formatter:
contexts: [admin]
sonata_formatter: sonata_formatter:
default_formatter: text default_formatter: text
......
sonata_admin: sonata_admin:
security: security:
handler: sonata.admin.security.handler.role # handler: sonata.admin.security.handler.role
handler: app.security.handler.role
role_admin: ROLE_ADMIN role_admin: ROLE_ADMIN
role_super_admin: ROLE_SUPER_ADMIN role_super_admin: ROLE_SUPER_ADMIN
title: 'MLC Admin' title: 'MLC Admin'
...@@ -88,10 +89,18 @@ sonata_admin: ...@@ -88,10 +89,18 @@ sonata_admin:
# BOTTOM BOTTOM BOTTOM # BOTTOM BOTTOM BOTTOM
blocks: blocks:
- -
class: col-xs-12 col-md-6 class: col-xs-12 col-md-12
position: top
type: admin.block.dashboard
-
class: col-xs-12 col-md-12
position: center position: center
type: sonata.admin.block.admin_list type: sonata.admin.block.admin_list
# - # -
# class: col-xs-12 col-md-6
# position: center
# type: sonata.admin.block.admin_list
# -
# class: col-xs-4 col-md-3 # class: col-xs-4 col-md-3
# position: top # position: top
# type: sonata.admin.block.stats # type: sonata.admin.block.stats
...@@ -196,6 +205,8 @@ sonata_admin: ...@@ -196,6 +205,8 @@ sonata_admin:
- admin.prestataire.gerer - admin.prestataire.gerer
- admin.prestataire.cotisations - admin.prestataire.cotisations
- admin.groupepresta.gerer - admin.groupepresta.gerer
- admin.etatpresta.gerer
- admin.rubrique.gerer
sonata.admin.group.groupe: sonata.admin.group.groupe:
on_top: true on_top: true
label: "Groupes locaux" label: "Groupes locaux"
...@@ -210,6 +221,17 @@ sonata_admin: ...@@ -210,6 +221,17 @@ sonata_admin:
icon: '<i class="fa fa-home"></i>' icon: '<i class="fa fa-home"></i>'
items: items:
- admin.comptoir.gerer - admin.comptoir.gerer
sonata.admin.group.flux:
keep_open: false
label: "Flux"
label_catalogue: SonataAdminBundle
icon: '<i class="fa fa-euro-sign"></i>'
items:
- admin.flux.gerer
- admin.all.cotisations
- admin.transfert.gerer
- admin.transaction.gerer
- admin.reconversion.gerer
# sonata.admin.group.compta: # sonata.admin.group.compta:
# keep_open: false # keep_open: false
# on_top: true # on_top: true
...@@ -242,14 +264,6 @@ sonata_admin: ...@@ -242,14 +264,6 @@ sonata_admin:
icon: '<i class="fa fa-pager"></i>' icon: '<i class="fa fa-pager"></i>'
items: items:
- admin.page.gerer - admin.page.gerer
sonata.admin.group.rubrique:
keep_open: false
on_top: true
label: "Rubriques"
label_catalogue: SonataAdminBundle
icon: '<i class="fa fa-list"></i>'
items:
- admin.rubrique.gerer
sonata.admin.group.faq: sonata.admin.group.faq:
keep_open: false keep_open: false
on_top: true on_top: true
...@@ -266,17 +280,6 @@ sonata_admin: ...@@ -266,17 +280,6 @@ sonata_admin:
icon: '<i class="fa fa-flag"></i>' icon: '<i class="fa fa-flag"></i>'
items: items:
- admin.traduction.gerer - admin.traduction.gerer
sonata.admin.group.flux:
keep_open: false
label: "Flux"
label_catalogue: SonataAdminBundle
icon: '<i class="fa fa-euro-sign"></i>'
items:
- admin.flux.gerer
- admin.all.cotisations
- admin.transfert.gerer
- admin.transaction.gerer
- admin.reconversion.gerer
sonata.admin.group.menu_builder: sonata.admin.group.menu_builder:
keep_open: false keep_open: false
on_top: true on_top: true
...@@ -310,4 +313,3 @@ sonata_admin: ...@@ -310,4 +313,3 @@ sonata_admin:
# items: # items:
# - app.admin.post # - app.admin.post
# roles: [ ROLE_ONE, ROLE_TWO ] # roles: [ ROLE_ONE, ROLE_TWO ]
...@@ -45,6 +45,14 @@ sonata_media: ...@@ -45,6 +45,14 @@ sonata_media:
formats: formats:
small: { width: 100 , quality: 95} small: { width: 100 , quality: 95}
big: { width: 500 , quality: 90} big: { width: 500 , quality: 90}
rubrique:
providers:
- sonata.media.provider.image
formats:
preview: { width: 50, quality: 90}
small: { width: 100 , quality: 90}
big: { width: 400 , quality: 90}
prestataire: prestataire:
providers: providers:
- sonata.media.provider.image - sonata.media.provider.image
......
...@@ -5,3 +5,4 @@ twig: ...@@ -5,3 +5,4 @@ twig:
form_themes: form_themes:
- 'bootstrap_4_layout.html.twig' - 'bootstrap_4_layout.html.twig'
- '@SonataFormatter/Form/formatter.html.twig' - '@SonataFormatter/Form/formatter.html.twig'
- 'rubrique/media_widgets.html.twig'
\ No newline at end of file
...@@ -150,6 +150,19 @@ services: ...@@ -150,6 +150,19 @@ services:
- { name: form.type_extension } - { name: form.type_extension }
# - { name: form.type_extension, extended_type: Sonata\MediaBundle\Form\Type\MediaType } # - { name: form.type_extension, extended_type: Sonata\MediaBundle\Form\Type\MediaType }
app.security.handler.role:
class: App\Security\Handler\VoterSecurityHandler
arguments:
- '@security.authorization_checker'
- [ROLE_SUPER_ADMIN]
admin.block.dashboard:
class: App\Block\DashboardKohinosBlock
arguments:
- '@twig'
tags:
- { name: sonata.block }
###### Configuration de l'admin ###### ###### Configuration de l'admin ######
admin.adherent.gerer: admin.adherent.gerer:
...@@ -252,6 +265,18 @@ services: ...@@ -252,6 +265,18 @@ services:
calls: calls:
- [ setSecurity, ['@security.helper']] - [ setSecurity, ['@security.helper']]
admin.etatpresta.gerer:
class: App\Admin\EtatprestataireAdmin
arguments: [~, App\Entity\EtatPrestataire, ~]
tags:
- name: sonata.admin
manager_type: orm
group: "Prestataire"
label: "Tags"
public: true
calls:
- [ setSecurity, ['@security.helper']]
admin.news.gerer: admin.news.gerer:
class: App\Admin\NewsAdmin class: App\Admin\NewsAdmin
arguments: [~, App\Entity\News, ~] arguments: [~, App\Entity\News, ~]
......
...@@ -2,20 +2,20 @@ ...@@ -2,20 +2,20 @@
"entrypoints": { "entrypoints": {
"app": { "app": {
"js": [ "js": [
"/build/runtime.6cf710cd.js", "/build/runtime.js",
"/build/app.43b7b3f6.js" "/build/app.js"
], ],
"css": [ "css": [
"/build/app.0d65a23b.css" "/build/app.css"
] ]
}, },
"admin": { "admin": {
"js": [ "js": [
"/build/runtime.6cf710cd.js", "/build/runtime.js",
"/build/admin.62757d63.js" "/build/admin.js"
], ],
"css": [ "css": [
"/build/admin.48a381da.css" "/build/admin.css"
] ]
} }
} }
......
{ {
"build/admin.css": "/build/admin.48a381da.css", "build/admin.css": "/build/admin.css",
"build/admin.js": "/build/admin.62757d63.js", "build/admin.js": "/build/admin.js",
"build/app.css": "/build/app.0d65a23b.css", "build/app.css": "/build/app.css",
"build/app.js": "/build/app.43b7b3f6.js", "build/app.js": "/build/app.js",
"build/runtime.js": "/build/runtime.6cf710cd.js", "build/runtime.js": "/build/runtime.js",
"build/ckeditor/adapters/jquery.js": "/build/ckeditor/adapters/jquery.js", "build/ckeditor/adapters/jquery.js": "/build/ckeditor/adapters/jquery.js",
"build/ckeditor/ckeditor.js": "/build/ckeditor/ckeditor.js", "build/ckeditor/ckeditor.js": "/build/ckeditor/ckeditor.js",
"build/ckeditor/config.js": "/build/ckeditor/config.js", "build/ckeditor/config.js": "/build/ckeditor/config.js",
......
{"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
...@@ -76,18 +76,16 @@ class AdherentAdmin extends AbstractAdmin ...@@ -76,18 +76,16 @@ class AdherentAdmin extends AbstractAdmin
->innerJoin($query->getRootAliases()[0] .'.user', 'u') ->innerJoin($query->getRootAliases()[0] .'.user', 'u')
->addSelect('u') ->addSelect('u')
; ;
if (empty($this->getRequest()->getSession()->get('_groupegere'))) {
if ($user->isGranted('ROLE_GESTION_GROUPE') || $user->isGranted('ROLE_CONTACT')) { if ($user->isGranted('ROLE_GESTION_GROUPE') || $user->isGranted('ROLE_CONTACT')) {
if (empty($user->getGroupesgeres())) {
$query->andWhere('false'); $query->andWhere('false');
}
} else { } else {
$groupe = $user->getGroupesgeres();
$query $query
->andWhere($query->expr()->in($query->getRootAliases()[0].'.groupe', ':group')) ->andWhere($query->getRootAliases()[0].'.groupe = :groupe')
// ->andWhere($query->getRootAliases()[0] . '.groupe = :group') ->setParameter('groupe', $this->getRequest()->getSession()->get('_groupegere'))
->setParameter('group', $groupes)
; ;
} }
}
return $query; return $query;
} }
...@@ -151,7 +149,7 @@ class AdherentAdmin extends AbstractAdmin ...@@ -151,7 +149,7 @@ class AdherentAdmin extends AbstractAdmin
'label' => false 'label' => false
)) ))
->end() ->end()
->with('Addresse', ['class' => 'col-md-5']) ->with('Adresse', ['class' => 'col-md-5'])
->add('geoloc', GeolocFormType::class, array( ->add('geoloc', GeolocFormType::class, array(
'label' => false, 'label' => false,
'required' => false 'required' => false
...@@ -295,7 +293,8 @@ class AdherentAdmin extends AbstractAdmin ...@@ -295,7 +293,8 @@ class AdherentAdmin extends AbstractAdmin
'advanced_filter' => false 'advanced_filter' => false
]) ])
->add('user.email', null, [ ->add('user.email', null, [
'label' => "Email" 'label' => "Email",
'advanced_filter' => false
]) ])
; ;
} }
......
...@@ -44,18 +44,16 @@ class ComptoirAdmin extends AbstractAdmin ...@@ -44,18 +44,16 @@ class ComptoirAdmin extends AbstractAdmin
{ {
$query = parent::createQuery($context); $query = parent::createQuery($context);
$user = $this->security->getUser(); $user = $this->security->getUser();
if (empty($this->getRequest()->getSession()->get('_groupegere'))) {
if ($user->isGranted('ROLE_GESTION_GROUPE') || $user->isGranted('ROLE_CONTACT')) { if ($user->isGranted('ROLE_GESTION_GROUPE') || $user->isGranted('ROLE_CONTACT')) {
if (empty($user->getGroupesgeres())) {
$query->andWhere('false'); $query->andWhere('false');
}
} else { } else {
$groupes = $user->getGroupesgeres();
$query $query
->andWhere($query->expr()->in($query->getRootAliases()[0].'.groupe', ':group')) ->andWhere($query->getRootAliases()[0].'.groupe = :groupe')
// ->andWhere($query->getRootAliases()[0] . '.groupe = :group') ->setParameter('groupe', $this->getRequest()->getSession()->get('_groupegere'))
->setParameter('group', $groupes)
; ;
} }
}
return $query; return $query;
} }
...@@ -72,9 +70,7 @@ class ComptoirAdmin extends AbstractAdmin ...@@ -72,9 +70,7 @@ class ComptoirAdmin extends AbstractAdmin
} }
$formMapper $formMapper
->with('Comptoir', ['class' => 'col-md-8']); ->with('Comptoir', ['class' => 'col-md-8']);
if (($user->isGranted('ROLE_GESTION_GROUPE') || $user->isGranted('ROLE_CONTACT')) && !empty($user->getGroupesgeres())) { if (($user->isGranted('ROLE_GESTION_GROUPE') || $user->isGranted('ROLE_CONTACT')) && !empty($this->getRequest()->getSession()->get('_groupegere'))) {
$em = $this->modelManager->getEntityManager(Groupe::class);
$formMapper->add('groupe', null, array( $formMapper->add('groupe', null, array(
'label' => 'Groupe local', 'label' => 'Groupe local',
'required' => true, 'required' => true,
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
namespace App\Admin; namespace App\Admin;
use App\Entity\Adherent; use App\Entity\Adherent;
use App\Entity\GlobalParameter;
use App\Entity\User; use App\Entity\User;
use Sonata\AdminBundle\Datagrid\DatagridMapper; use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Datagrid\ListMapper; use Sonata\AdminBundle\Datagrid\ListMapper;
...@@ -11,6 +12,7 @@ use Sonata\AdminBundle\Route\RouteCollection; ...@@ -11,6 +12,7 @@ use Sonata\AdminBundle\Route\RouteCollection;
use Sonata\AdminBundle\Show\ShowMapper; use Sonata\AdminBundle\Show\ShowMapper;
use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType; use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\MoneyType;
/** /**
* Administration des cotisations des adhérents * Administration des cotisations des adhérents
...@@ -39,11 +41,12 @@ class CotisationAdherentAdmin extends CotisationAdmin ...@@ -39,11 +41,12 @@ class CotisationAdherentAdmin extends CotisationAdmin
->andWhere($query->getRootAliases()[0] .".type='cotisation_adherent'") ->andWhere($query->getRootAliases()[0] .".type='cotisation_adherent'")
// ->andWhere('u.adherent IS NOT NULL') // ->andWhere('u.adherent IS NOT NULL')
; ;
if (empty($this->getRequest()->getSession()->get('_groupegere'))) {
if ($user->isGranted('ROLE_GESTION_GROUPE') || $user->isGranted('ROLE_CONTACT')) { if ($user->isGranted('ROLE_GESTION_GROUPE') || $user->isGranted('ROLE_CONTACT')) {
if (empty($user->getGroupesgeres())) {
$query->andWhere('false'); $query->andWhere('false');
}
} else { } else {
$groupe = $this->session->get('_groupegere'); $groupe = $this->getRequest()->getSession()->get('_groupegere');
$em = $this->getConfigurationPool()->getContainer()->get('doctrine')->getEntityManager(); $em = $this->getConfigurationPool()->getContainer()->get('doctrine')->getEntityManager();
$adhTable = $em->getMetadataFactory()->getMetadataFor(Adherent::class)->getTableName(); $adhTable = $em->getMetadataFactory()->getMetadataFor(Adherent::class)->getTableName();
$connection = $em->getConnection(); $connection = $em->getConnection();
...@@ -55,7 +58,6 @@ class CotisationAdherentAdmin extends CotisationAdmin ...@@ -55,7 +58,6 @@ class CotisationAdherentAdmin extends CotisationAdmin
->setParameter('ids', $ids) ->setParameter('ids', $ids)
; ;
} }
}
return $query; return $query;
} }
...@@ -83,6 +85,7 @@ class CotisationAdherentAdmin extends CotisationAdmin ...@@ -83,6 +85,7 @@ class CotisationAdherentAdmin extends CotisationAdmin
*/ */
protected function configureFormFields(FormMapper $formMapper): void protected function configureFormFields(FormMapper $formMapper): void
{ {
$cotisation = $this->getSubject();
$expediteurInfos = array( $expediteurInfos = array(
'label' => 'Expéditeur', 'label' => 'Expéditeur',
'class' => Adherent::class, 'class' => Adherent::class,
...@@ -96,6 +99,10 @@ class CotisationAdherentAdmin extends CotisationAdmin ...@@ -96,6 +99,10 @@ class CotisationAdherentAdmin extends CotisationAdmin
} }
$formMapper $formMapper
->with('Cotisation', ['class' => 'col-md-8']) ->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))
))
->add('reference', HiddenType::class, array( ->add('reference', HiddenType::class, array(
'data' => 'cotisation_adherent' 'data' => 'cotisation_adherent'
)) ))
...@@ -128,9 +135,6 @@ class CotisationAdherentAdmin extends CotisationAdmin ...@@ -128,9 +135,6 @@ class CotisationAdherentAdmin extends CotisationAdmin
->addIdentifier('expediteur', null, array( ->addIdentifier('expediteur', null, array(
'label' => 'Adherent' 'label' => 'Adherent'
)) ))
->addIdentifier('expediteur.user.email', null, array(
'label' => 'Email'
))
; ;
parent::configureListFields($listMapper); parent::configureListFields($listMapper);
} }
......
...@@ -84,10 +84,6 @@ class CotisationAdmin extends AbstractAdmin ...@@ -84,10 +84,6 @@ class CotisationAdmin extends AbstractAdmin
->add('cotisationInfos.annee', null, array( ->add('cotisationInfos.annee', null, array(
'label' => 'Année', 'label' => 'Année',
)) ))
->add('montant', MoneyType::class, array(
'label' => 'Montant',
'data' => ($cotisation->getMontant() != null)?$cotisation->getMontant():floatval($this->em->getRepository(GlobalParameter::class)->val(GlobalParameter::COTISATION_MONTANT))
))
->add('moyen', ChoiceType::class, array( ->add('moyen', ChoiceType::class, array(
'required' => true, 'required' => true,
'choices' => MoyenEnum::getAvailableTypes(), 'choices' => MoyenEnum::getAvailableTypes(),
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
namespace App\Admin; namespace App\Admin;
use App\Entity\Flux; use App\Entity\Flux;
use App\Entity\GlobalParameter;
use App\Entity\Prestataire; use App\Entity\Prestataire;
use App\Entity\User; use App\Entity\User;
use Sonata\AdminBundle\Datagrid\DatagridMapper; use Sonata\AdminBundle\Datagrid\DatagridMapper;
...@@ -13,6 +14,7 @@ use Sonata\AdminBundle\Show\ShowMapper; ...@@ -13,6 +14,7 @@ use Sonata\AdminBundle\Show\ShowMapper;
use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType; use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\MoneyType;
/** /**
* Administration des cotisations des prestataires * Administration des cotisations des prestataires
...@@ -41,11 +43,12 @@ class CotisationPrestataireAdmin extends CotisationAdmin ...@@ -41,11 +43,12 @@ class CotisationPrestataireAdmin extends CotisationAdmin
->andWhere($query->getRootAliases()[0] .".type='cotisation_prestataire'") ->andWhere($query->getRootAliases()[0] .".type='cotisation_prestataire'")
// ->andWhere('u.prestataire IS NOT NULL') // ->andWhere('u.prestataire IS NOT NULL')
; ;
if (empty($this->getRequest()->getSession()->get('_groupegere'))) {
if ($user->isGranted('ROLE_GESTION_GROUPE') || $user->isGranted('ROLE_CONTACT')) { if ($user->isGranted('ROLE_GESTION_GROUPE') || $user->isGranted('ROLE_CONTACT')) {
if (empty($user->getGroupesgeres())) {
$query->andWhere('false'); $query->andWhere('false');
}
} else { } else {
$groupe = $this->session->get('_groupegere'); $groupe = $this->getRequest()->getSession()->get('_groupegere');
$em = $this->getConfigurationPool()->getContainer()->get('doctrine')->getEntityManager(); $em = $this->getConfigurationPool()->getContainer()->get('doctrine')->getEntityManager();
$fluxTable = $em->getMetadataFactory()->getMetadataFor(Flux::class)->getTableName(); $fluxTable = $em->getMetadataFactory()->getMetadataFor(Flux::class)->getTableName();
$prestaTable = $em->getMetadataFactory()->getMetadataFor(Prestataire::class)->getTableName(); $prestaTable = $em->getMetadataFactory()->getMetadataFor(Prestataire::class)->getTableName();
...@@ -58,7 +61,6 @@ class CotisationPrestataireAdmin extends CotisationAdmin ...@@ -58,7 +61,6 @@ class CotisationPrestataireAdmin extends CotisationAdmin
->setParameter('ids', $ids) ->setParameter('ids', $ids)
; ;
} }
}
return $query; return $query;
} }
...@@ -87,6 +89,7 @@ class CotisationPrestataireAdmin extends CotisationAdmin ...@@ -87,6 +89,7 @@ class CotisationPrestataireAdmin extends CotisationAdmin
*/ */
protected function configureFormFields(FormMapper $formMapper): void protected function configureFormFields(FormMapper $formMapper): void
{ {
$cotisation = $this->getSubject();
$expediteurInfos = array( $expediteurInfos = array(
'label' => 'Expéditeur', 'label' => 'Expéditeur',
'class' => Prestataire::class, 'class' => Prestataire::class,
...@@ -100,6 +103,10 @@ class CotisationPrestataireAdmin extends CotisationAdmin ...@@ -100,6 +103,10 @@ class CotisationPrestataireAdmin extends CotisationAdmin
} }
$formMapper $formMapper
->with('Cotisation', ['class' => 'col-md-8']) ->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))
))
->add('reference', HiddenType::class, array( ->add('reference', HiddenType::class, array(
'data' => 'cotisation_prestataire' 'data' => 'cotisation_prestataire'
)) ))
...@@ -129,8 +136,7 @@ class CotisationPrestataireAdmin extends CotisationAdmin ...@@ -129,8 +136,7 @@ class CotisationPrestataireAdmin extends CotisationAdmin
{ {
unset($this->listModes['mosaic']); unset($this->listModes['mosaic']);
$listMapper $listMapper
->addIdentifier('expediteur', null, array('label' => 'Prestataire')) ->addIdentifier('expediteur', null, array('label' => 'Prestataire'));
->addIdentifier('expediteur.user.email', null, array('label' => 'Email'));
parent::configureListFields($listMapper); parent::configureListFields($listMapper);
} }
} }
<?php
namespace App\Admin;
use App\Entity\Prestataire;
use App\Enum\GroupePrestaEnum;
use FOS\CKEditorBundle\Form\Type\CKEditorType;
use Sonata\AdminBundle\Admin\AbstractAdmin;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Form\FormMapper;
use Sonata\AdminBundle\Route\RouteCollection;
use Sonata\AdminBundle\Show\ShowMapper;
use Sonata\MediaBundle\Form\Type\MediaType;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Security\Core\Security;
/**
* Administration des tags/états des prestataires (rappel, suspendus, ...)
*
* KOHINOS : Outil de gestion de Monnaie Locale Complémentaire
* @author Julien Jorry <julien.jorry@gmail.com>
*/
class EtatprestataireAdmin extends AbstractAdmin
{
protected $security;
protected $datagridValues = [
// reverse order (default = 'ASC')
'_sort_order' => 'DESC',
// name of the ordered field (default = the model's id field, if any)
'_sort_by' => 'name',
];
public function configure()
{
parent::configure();
}
public function setSecurity(Security $security)
{
$this->security = $security;
}
/**
* {@inheritdoc}
*/
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'));
$groupepresta = $this->getSubject();
$formMapper
->with('Informations', ['class' => 'col-md-7'])
->add('name', TextType::class, array(
'label' => 'Nom :',
'required' => true
))
->add('content', CKEditorType::class, array(
'label' => 'Description :',
// 'config' => ['enterMode' => 'CKEDITOR.ENTER_BR'],
'required' => false
))
->add('enabled', CheckboxType::class, array(
'label' => 'Activé ?',
'required' => false,
'label_attr' => array('class' => 'checkbox-inline')
))
->end()
;
}
/**
* {@inheritdoc}
*/
protected function configureListFields(ListMapper $listMapper)
{
unset($this->listModes['mosaic']);
$listMapper
->addIdentifier('name', null, array(
'label' => 'Nom'
))
->addIdentifier('content', null, array(
'label' => 'Description'
))
->addIdentifier('enabled', null, array(
'label' => 'Activé',
'datatype' => 'App.EtatPrestataire',
'template' => '@SonataAdmin/Boolean/editable_boolean.html.twig'
))
;
}
protected function configureRoutes(RouteCollection $collection)
{
parent::configureRoutes($collection);
$collection->remove('delete');
}
public function getBatchActions()
{
$actions = parent::getBatchActions();
unset($actions['delete']);
return $actions;
}
public function getDashboardActions()
{
$actions = parent::getDashboardActions();
// unset($actions['list']);
return $actions;
}
}
...@@ -157,7 +157,7 @@ class GroupeAdmin extends AbstractAdmin ...@@ -157,7 +157,7 @@ class GroupeAdmin extends AbstractAdmin
'getPrestatairesCount', 'getPrestatairesCount',
null, null,
[ [
'label' => 'Nb prestataires', 'label' => 'Nombre de prestas',
'sortable' => true, 'sortable' => true,
'sort_field_mapping' => ['fieldName' => 'id'], 'sort_field_mapping' => ['fieldName' => 'id'],
'sort_parent_association_mappings' => [], 'sort_parent_association_mappings' => [],
......
...@@ -52,17 +52,16 @@ class GroupeprestataireAdmin extends AbstractAdmin ...@@ -52,17 +52,16 @@ class GroupeprestataireAdmin extends AbstractAdmin
{ {
$user = $this->security->getUser(); $user = $this->security->getUser();
$query = parent::createQuery($context); $query = parent::createQuery($context);
if (empty($this->getRequest()->getSession()->get('_groupegere'))) {
if ($user->isGranted('ROLE_GESTION_GROUPE') || $user->isGranted('ROLE_CONTACT')) { if ($user->isGranted('ROLE_GESTION_GROUPE') || $user->isGranted('ROLE_CONTACT')) {
if (empty($user->getGroupesgeres())) {
$query->andWhere('false'); $query->andWhere('false');
}
} else { } else {
$query $query
->andWhere($query->expr()->in($query->getRootAliases()[0].'.groupe', ':groupe')) ->andWhere($query->getRootAliases()[0].'.groupe = :groupe')
// ->andWhere($query->getRootAliases()[0].'.groupe = :groupe') ->setParameter('groupe', $this->getRequest()->getSession()->get('_groupegere'))
->setParameter('groupe', $user->getGroupesgeres())
; ;
} }
}
// @TODO : NE FONCTIONNE PAS : pour pouvoir classer par nombre de prestataires ! // @TODO : NE FONCTIONNE PAS : pour pouvoir classer par nombre de prestataires !
// voir https://github.com/sonata-project/SonataDoctrineORMAdminBundle/issues/297 // voir https://github.com/sonata-project/SonataDoctrineORMAdminBundle/issues/297
if ('list' === $context) { if ('list' === $context) {
...@@ -89,7 +88,6 @@ class GroupeprestataireAdmin extends AbstractAdmin ...@@ -89,7 +88,6 @@ class GroupeprestataireAdmin extends AbstractAdmin
protected function configureFormFields(FormMapper $formMapper) protected function configureFormFields(FormMapper $formMapper)
{ {
$user = $this->security->getUser(); $user = $this->security->getUser();
$prestataires = $this->getConfigurationPool()->getContainer()->get('doctrine')->getRepository(Prestataire::class)->findBy(array('enabled' => true), array('raison'=> 'ASC'));
$groupepresta = $this->getSubject(); $groupepresta = $this->getSubject();
$formMapper $formMapper
...@@ -106,9 +104,10 @@ class GroupeprestataireAdmin extends AbstractAdmin ...@@ -106,9 +104,10 @@ class GroupeprestataireAdmin extends AbstractAdmin
'required' => true 'required' => true
)) ))
; ;
if (($user->isGranted('ROLE_GESTION_GROUPE') || $user->isGranted('ROLE_CONTACT')) && !empty($this->security->getUser()->getGroupesgeres())) { if (($user->isGranted('ROLE_GESTION_GROUPE') || $user->isGranted('ROLE_CONTACT') || $user->isGranted('ROLE_TRESORIER')) && !empty($this->getRequest()->getSession()->get('_groupegere'))) {
//TODO : check request ! $prestataires = $this->getConfigurationPool()->getContainer()->get('doctrine')->getRepository(Prestataire::class)->findByGroupeLocal($this->getRequest()->getSession()->get('_groupegere'));
$prestataires = $this->getConfigurationPool()->getContainer()->get('doctrine')->getRepository(Prestataire::class)->findBy(array('enabled' => true, 'groupe' => $this->security->getUser()->getGroupesgeres()), array('raison'=> 'ASC')); } else {
$prestataires = $this->getConfigurationPool()->getContainer()->get('doctrine')->getRepository(Prestataire::class)->findBy(array('enabled' => true), array('raison'=> 'ASC'));
} }
if ($user->isGranted('ROLE_SUPER_ADMIN') || $user->isGranted('ROLE_ADMIN_SIEGE')) { if ($user->isGranted('ROLE_SUPER_ADMIN') || $user->isGranted('ROLE_ADMIN_SIEGE')) {
$formMapper $formMapper
...@@ -124,7 +123,7 @@ class GroupeprestataireAdmin extends AbstractAdmin ...@@ -124,7 +123,7 @@ class GroupeprestataireAdmin extends AbstractAdmin
'required' => false 'required' => false
)) ))
->add('content', CKEditorType::class, array( ->add('content', CKEditorType::class, array(
'label' => 'Texte', 'label' => 'Description',
'required' => false, 'required' => false,
)) ))
->add('enabled', CheckboxType::class, array( ->add('enabled', CheckboxType::class, array(
...@@ -184,15 +183,10 @@ class GroupeprestataireAdmin extends AbstractAdmin ...@@ -184,15 +183,10 @@ class GroupeprestataireAdmin extends AbstractAdmin
'strip' => true, 'strip' => true,
'truncate' => 50 'truncate' => 50
)) ))
->add( ->add('getPrestatairesCount', null, array(
'getPrestatairesCount', 'label' => 'Nombre de prestas',
null, 'sortable' => false,
[ ))
'sortable' => true,
'sort_field_mapping' => ['fieldName' => 'id'],
'sort_parent_association_mappings' => [],
]
)
->addIdentifier('enabled', null, array( ->addIdentifier('enabled', null, array(
'label' => 'Activé', 'label' => 'Activé',
'datatype' => 'App.Groupeprestataire', 'datatype' => 'App.Groupeprestataire',
......
...@@ -5,12 +5,16 @@ namespace App\Admin; ...@@ -5,12 +5,16 @@ namespace App\Admin;
use App\Entity\Comptoir; use App\Entity\Comptoir;
use App\Entity\Prestataire; use App\Entity\Prestataire;
use App\Entity\Siege; use App\Entity\Siege;
use App\Entity\Rubrique;
use FOS\CKEditorBundle\Form\Type\CKEditorType; use FOS\CKEditorBundle\Form\Type\CKEditorType;
use Sonata\AdminBundle\Admin\AbstractAdmin; use Sonata\AdminBundle\Admin\AbstractAdmin;
use Sonata\AdminBundle\Datagrid\ListMapper; use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Form\FormMapper; use Sonata\AdminBundle\Form\FormMapper;
use Sonata\AdminBundle\Route\RouteCollection; use Sonata\AdminBundle\Route\RouteCollection;
use Sonata\AdminBundle\Show\ShowMapper; use Sonata\AdminBundle\Show\ShowMapper;
use Sonata\MediaBundle\Form\Type\MediaType;
use Sonata\MediaBundle\Provider\Pool;
use Sonata\MediaBundle\Provider\MediaProviderInterface;
use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType; use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType; use Symfony\Component\Form\Extension\Core\Type\CollectionType;
...@@ -29,7 +33,7 @@ class RubriqueAdmin extends AbstractAdmin ...@@ -29,7 +33,7 @@ class RubriqueAdmin extends AbstractAdmin
protected $security; protected $security;
protected $datagridValues = [ protected $datagridValues = [
'_sort_order' => 'ASC', '_sort_order' => 'ASC',
'_sort_by' => 'name', '_sort_by' => 'id',
]; ];
public function configure() public function configure()
...@@ -45,17 +49,41 @@ class RubriqueAdmin extends AbstractAdmin ...@@ -45,17 +49,41 @@ class RubriqueAdmin extends AbstractAdmin
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function createQuery($context = 'list')
{
$query = parent::createQuery($context);
$query
->leftJoin($query->getRootAliases()[0] .'.media', 'm')
->addSelect('m')
;
return $query;
}
/**
* {@inheritdoc}
*/
protected function configureFormFields(FormMapper $formMapper) protected function configureFormFields(FormMapper $formMapper)
{ {
$rubrique = $this->getSubject();
$user = $this->security->getUser(); $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), array('raison'=> 'ASC'));
// TODO : ?
// if (($user->isGranted('ROLE_GESTION_GROUPE') || $user->isGranted('ROLE_CONTACT')) && $this->security->getUser()->getGroupesgere() != null) { // get the current Image instance
// $prestataires = $this->getConfigurationPool()->getContainer()->get('doctrine')->getRepository(Prestataire::class)->findBy(array('enabled' => true, 'groupe' => $this->security->getUser()->getGroupesgere()), array('raison'=> 'ASC')); $imageHelp = null;
// } if (!empty($rubrique) && !empty($rubrique->getMedia())) {
$image = $rubrique->getMedia();
if ($image && ($webPath = $image->getWebPath())) {
// get the container so the full path to the image can be set
$container = $this->getConfigurationPool()->getContainer();
$fullPath = $container->get('request_stack')->getCurrentRequest()->getBasePath().'/'.$webPath;
// add a 'help' option containing the preview's img tag
$imageHelp = '<img src="'.$fullPath.'" class="admin-preview" />';
}
}
$groupe = $this->getSubject(); $groupe = $this->getSubject();
$formMapper $formMapper
->with("Création d'une rubrique") ->with("Contenu", ['class' => 'col-md-6'])
->add('name', TextType::class, array( ->add('name', TextType::class, array(
'label' => 'Nom :', 'label' => 'Nom :',
'required' => true 'required' => true
...@@ -64,8 +92,24 @@ class RubriqueAdmin extends AbstractAdmin ...@@ -64,8 +92,24 @@ class RubriqueAdmin extends AbstractAdmin
'label' => 'Description :', 'label' => 'Description :',
'required' => false, 'required' => false,
)) ))
->add('enabled', CheckboxType::class, array(
'label' => 'Activé ?',
'required' => false,
'label_attr' => array('class' => 'checkbox-inline')
))
->end()
->with('Image', ['class' => 'col-md-6'])
->add('media', MediaType::class, array(
'provider' => 'sonata.media.provider.image',
'context' => 'rubrique',
// 'help' => $imageHelp,
'label' => false,
'required' => false
))
->end()
->with('Prestataires', ['class' => 'col-md-6'])
->add('prestataires', CollectionType::class, array( ->add('prestataires', CollectionType::class, array(
'label' => 'Prestataires', 'label' => false,
'entry_type' => EntityType::class, 'entry_type' => EntityType::class,
'entry_options' => array( 'entry_options' => array(
'class' => Prestataire::class, 'class' => Prestataire::class,
...@@ -78,18 +122,13 @@ class RubriqueAdmin extends AbstractAdmin ...@@ -78,18 +122,13 @@ class RubriqueAdmin extends AbstractAdmin
'allow_add' => true, 'allow_add' => true,
'allow_delete' => true 'allow_delete' => true
)) ))
->add('enabled', CheckboxType::class, array(
'label' => 'Activé ?',
'required' => false,
'label_attr' => array('class' => 'checkbox-inline')
))
->end() ->end()
; ;
} }
protected function configureRoutes(RouteCollection $collection) protected function configureRoutes(RouteCollection $collection)
{ {
$collection->remove('delete'); // $collection->remove('delete');
} }
// public function getBatchActions() // public function getBatchActions()
...@@ -107,19 +146,21 @@ class RubriqueAdmin extends AbstractAdmin ...@@ -107,19 +146,21 @@ class RubriqueAdmin extends AbstractAdmin
{ {
unset($this->listModes['mosaic']); unset($this->listModes['mosaic']);
$listMapper $listMapper
->addIdentifier('name', null, array('label' => 'Nom du groupe')) ->addIdentifier('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')) ->addIdentifier('content', 'html', array('truncate' => array('length' => 80), 'label' => 'Description'))
->add( ->add('getPrestatairesCount', null, array(
'getPrestatairesCount', 'label' => 'Nombre de prestas',
null, 'sortable' => false,
[ ))
'label' => 'Nb prestataires',
'sortable' => true,
'sort_field_mapping' => ['fieldName' => 'id'],
'sort_parent_association_mappings' => [],
]
)
->addIdentifier('enabled', null, array('label' => 'Activé', 'datatype' => 'App.Groupeprestataire', 'template' => '@SonataAdmin/Boolean/editable_boolean.html.twig')) ->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' => [
'edit' => [],
'delete' => [],
]
])
; ;
} }
} }
...@@ -68,10 +68,10 @@ class TransfertAdmin extends FluxAdmin ...@@ -68,10 +68,10 @@ class TransfertAdmin extends FluxAdmin
$em = $this->getConfigurationPool()->getContainer()->get('doctrine')->getEntityManager(); $em = $this->getConfigurationPool()->getContainer()->get('doctrine')->getEntityManager();
$fluxtable = $em->getMetadataFactory()->getMetadataFor(Flux::class)->getTableName(); $fluxtable = $em->getMetadataFactory()->getMetadataFor(Flux::class)->getTableName();
if ($this->rolecheck->isGranted('ROLE_GESTION_GROUPE') || $this->rolecheck->isGranted('ROLE_CONTACT')) { if ($this->rolecheck->isGranted('ROLE_GESTION_GROUPE') || $this->rolecheck->isGranted('ROLE_CONTACT')) {
if (empty($user->getGroupesgeres())) { if (empty($this->getRequest()->getSession()->get('_groupegere'))) {
$query->andWhere('false'); $query->andWhere('false');
} else { } else {
$groupe = $this->session->get('_groupegere'); $groupe = $this->getRequest()->getSession()->get('_groupegere');
$connection = $em->getConnection(); $connection = $em->getConnection();
$prestatable = $em->getMetadataFactory()->getMetadataFor(Prestataire::class)->getTableName(); $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 = \'prestataire_siege\' AND f.prestataire_id IN (SELECT p.id FROM '.$fluxtable.' p WHERE p.groupe_id = '.$groupe->getId().'))');
......
...@@ -85,7 +85,14 @@ class UserAdmin extends SonataUserAdmin ...@@ -85,7 +85,14 @@ class UserAdmin extends SonataUserAdmin
{ {
parent::configureDatagridFilters($datagridMapper); parent::configureDatagridFilters($datagridMapper);
$datagridMapper $datagridMapper
->add('enabled') ->add('email', null, [
'label' => "Email",
'advanced_filter' => false
])
->add('enabled', null, array(
'label' => 'Activé ?',
'advanced_filter' => false
))
; ;
} }
......
...@@ -37,4 +37,16 @@ class Media extends BaseMedia ...@@ -37,4 +37,16 @@ class Media extends BaseMedia
{ {
return $this->id; return $this->id;
} }
protected function getUploadDir()
{
return '/uploads';
}
public function getWebPath()
{
// return null === $this->path
// ? 'null'
// : $this->getUploadDir().'/'.$this->path;
}
} }
<?php
namespace App\Block;
use Sonata\AdminBundle\Form\FormMapper;
use Sonata\BlockBundle\Block\AbstractBlockService;
use Sonata\BlockBundle\Block\BaseBlockService;
use Sonata\BlockBundle\Block\BlockContextInterface;
use Sonata\BlockBundle\Model\BlockInterface;
use Sonata\CoreBundle\Validator\ErrorElement;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\OptionsResolver\OptionsResolver;
class DashboardKohinosBlock extends AbstractBlockService
{
/**
* {@inheritdoc}
*/
public function execute(BlockContextInterface $blockContext, Response $response = null)
{
// $end = new \DateTime();
// $start = new \DateTime('7 days ago');
// $chart = $this->chartBuilder->getRegistrationsChart($start, $end);
return $this->renderResponse($blockContext->getTemplate(), array(
// 'chart' => $chart,
'block' => $blockContext->getBlock(),
'settings' => $blockContext->getSettings(),
), $response);
}
/**
* {@inheritdoc}
*/
public function getName()
{
return 'Dashboard';
}
/**
* {@inheritdoc}
*/
public function configureSettings(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
'title' => 'Dashboard',
'summaries' => false,
'template' => 'block/dashboard_kohinos.html.twig',
));
}
}
...@@ -135,7 +135,7 @@ class AdminController extends Controller ...@@ -135,7 +135,7 @@ class AdminController extends Controller
$httpClient = new \Http\Adapter\Guzzle6\Client(); $httpClient = new \Http\Adapter\Guzzle6\Client();
$provider = Nominatim::withOpenStreetMapServer($httpClient, 'Mozilla/5.0'); $provider = Nominatim::withOpenStreetMapServer($httpClient, 'Mozilla/5.0');
$geocoder = new \Geocoder\StatefulGeocoder($provider, 'fr'); $geocoder = new \Geocoder\StatefulGeocoder($provider, 'fr');
// Query geocoding from complete addresse // Query geocoding from complete address
$result = $geocoder->geocodeQuery(GeocodeQuery::create($request->get('adresse').' '.$request->get('cpostal').' '.$request->get('ville'))); $result = $geocoder->geocodeQuery(GeocodeQuery::create($request->get('adresse').' '.$request->get('cpostal').' '.$request->get('ville')));
if (count($result) > 0) { if (count($result) > 0) {
$coords = $result->first()->getCoordinates(); $coords = $result->first()->getCoordinates();
......
...@@ -139,7 +139,8 @@ class IndexController extends AbstractController ...@@ -139,7 +139,8 @@ class IndexController extends AbstractController
$presta->setEnabled(true); $presta->setEnabled(true);
$presta->setIban(' '); $presta->setIban(' ');
$presta->setSiret(' '); $presta->setSiret(' ');
$user->addRole('ROLE_PRESTATAIRE'); $groupePresta = $repogroup->findOneBy(array('name' => 'Prestataire'));
$user->addGroup($groupePresta);
$presta->addUser($user); $presta->addUser($user);
$presta->setGroupe($groupe); $presta->setGroupe($groupe);
......
<?php
namespace App\Controller;
use App\Entity\Prestataire;
use App\Entity\Rubrique;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Sonata\MediaBundle\Provider\ImageProvider;
class MapController extends AbstractController
{
protected $imageProvider;
private $em;
public function __construct(ImageProvider $imageProvider, EntityManagerInterface $em)
{
$this->imageProvider = $imageProvider;
$this->em = $em;
}
/**
* @Route("/map/json/prestataire", name="map_prestataire_json", defaults={"rubrique": null})
* @Route("/map/json/prestataire/{id}", name="map_prestataire_json_rubrique")
*/
public function getJsonPrestataireMap(Rubrique $rubrique = null)
{
$points = [];
$filtered_cat = null;
if ($rubrique != null) {
$prestataires = $this->em->getRepository(Prestataire::class)->findByRubrique($rubrique);
} else {
$prestataires = $this->em->getRepository(Prestataire::class)->findBy(['enabled' => true]);
}
dump($rubrique);
dump($prestataires);
foreach ($prestataires as $presta) {
dump($presta->getGeolocs()->toArray());
// if ($rubrique === null || $presta->getRubriques()->contains($rubrique)) {
$geolocs = array_map(function ($geoloc) {
if ($geoloc->isEnabled()) {
return $geoloc;
}
}, $presta->getGeolocs()->toArray());
if (count($geolocs) > 0) {
dump('yeah');
$geoloc = $geolocs[0];
// list($lat, $lon) = explode(',', $presta->latlon);
if ($geoloc->getGeoloc()->getLon() != null and $geoloc->getGeoloc()->getLat() != null) {
dump('yeah2');
$p = new \StdClass();
$p->type = "Feature";
$p->geometry = [
'type'=>'Point',
'coordinates' => [$geoloc->getGeoloc()->getLon(),$geoloc->getGeoloc()->getLat()]
];
// $cat = [];
// foreach ($geo_cats as $gc) {
// if ($gc['id'] == $c->cat) {
// $cat = $gc;
// }
// }
$p->cat = array_map(function ($rubrique) {
// $provider = $this->container->get($rubrique->getMedia()->getProviderName());
return [
'name' => $rubrique->getName(),
'icon' => (($rubrique->getMedia() != null)?$this->imageProvider->generatePublicUrl($rubrique->getMedia(), 'preview'):null),
'content' => $rubrique->getContent()
];
}, $presta->getRubriques()->toArray());
$properties = [
'name' => $presta->__toString(),
'popupContent'=>$presta->getMapContent(),
];
// if (isset($cat['id'])) {
// $properties['cat'] = $cat['id'];
// }
$p->properties = $properties;
$points[] = $p;
}
}
// }
}
dump($points);
exit();
return new JsonResponse($points);
}
}
...@@ -79,7 +79,7 @@ class Adherent ...@@ -79,7 +79,7 @@ class Adherent
* @param null|Groupe $groupe * @param null|Groupe $groupe
* @return $this * @return $this
*/ */
public function setGroupe(?Groupe $groupe) public function setGroupe(?Groupe $groupe): self
{ {
$this->groupe = $groupe; $this->groupe = $groupe;
return $this; return $this;
......
...@@ -26,8 +26,6 @@ class Comptoir ...@@ -26,8 +26,6 @@ class Comptoir
ContactEmailTelTrait, ContactEmailTelTrait,
HasCompteEntity; HasCompteEntity;
const UPLOAD_DIR = "comptoir";
/** /**
* @var int * @var int
* *
......
<?php
namespace App\Entity;
use App\Entity\Prestataire;
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;
use Gedmo\Timestampable\Traits\TimestampableEntity;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity
* @ORM\Table(name="contact_prestataire")
*/
class ContactPrestataire
{
use NameSlugContentEntityTrait,
TimestampableEntity,
EnablableEntityTrait;
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @var Prestataire
*
* @ORM\ManyToOne(targetEntity="Prestataire", cascade={"persist"}, inversedBy="contacts")
* @ORM\JoinColumn(name="prestataire_id", referencedColumnName="id", nullable=false)
*/
private $prestataire;
public function getId(): ?int
{
return $this->id;
}
/**
* Get prestataire
* @return
*/
public function getPrestataire(): Prestataire
{
return $this->prestataire;
}
/**
* Set prestataire
* @return $this
*/
public function setPrestataire($prestataire): self
{
$this->prestataire = $prestataire;
return $this;
}
}
...@@ -35,7 +35,7 @@ class Cotisation extends Flux ...@@ -35,7 +35,7 @@ class Cotisation extends Flux
$this->cotisationInfos = new CotisationInfos(); $this->cotisationInfos = new CotisationInfos();
} }
public function operate() public function operate($em)
{ {
$compteExp = $this->getExpediteur()->getEcompte() - $this->getMontant(); $compteExp = $this->getExpediteur()->getEcompte() - $this->getMontant();
if ($this->getMoyen() == MoyenEnum::MOYEN_MLC) { if ($this->getMoyen() == MoyenEnum::MOYEN_MLC) {
......
<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use App\Entity\EntityTrait\EnablableEntityTrait;
use App\Entity\EntityTrait\NameSlugContentEntityTrait;
use Doctrine\Common\Collections\ArrayCollection;
use Gedmo\Timestampable\Traits\TimestampableEntity;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity(repositoryClass="App\Repository\EtatPrestataireRepository")
*/
class EtatPrestataire
{
use NameSlugContentEntityTrait,
TimestampableEntity,
EnablableEntityTrait;
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @var ArrayCollection|EtatPrestataire[]
*
* @ORM\ManyToMany(targetEntity="Prestataire", inversedBy="etats", cascade={"persist"})
* @ORM\JoinTable(name="etats_prestataires")
*/
protected $prestataires;
public function __construct()
{
$this->prestataires = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
/**
* @return Prestataire[]|ArrayCollection
*/
public function getPrestataires()
{
return $this->prestataires;
}
/**
* @param Prestataire $prestataire
* @return $this
*/
public function addPrestataire(Prestataire $prestataire): self
{
if (!$this->prestataires->contains($prestataire)) {
$this->prestataires[] = $prestataire;
}
return $this;
}
/**
* @param Prestataire $prestataire
* @return $this
*/
public function removePrestataire(Prestataire $prestataire): self
{
if ($this->prestataires->contains($prestataire)) {
$this->prestataires->removeElement($prestataire);
}
return $this;
}
}
...@@ -116,7 +116,7 @@ abstract class Flux ...@@ -116,7 +116,7 @@ abstract class Flux
* Effectuer l'opération (transfert, transaction, vente, retrait...) * Effectuer l'opération (transfert, transaction, vente, retrait...)
* @return array Tableau des entité(s) à persister (siege, comptoir, groupe, presta, adherent...) * @return array Tableau des entité(s) à persister (siege, comptoir, groupe, presta, adherent...)
*/ */
abstract public function operate(); abstract public function operate($em);
/** /**
* Obtenir la liste des utilisateurs à notifier * Obtenir la liste des utilisateurs à notifier
...@@ -331,8 +331,7 @@ abstract class Flux ...@@ -331,8 +331,7 @@ abstract class Flux
public function prePersist(LifecycleEventArgs $event) public function prePersist(LifecycleEventArgs $event)
{ {
$flux = $event->getEntity(); $flux = $event->getEntity();
$tmphash = password_hash($flux->getAllInfosUncrypted(), PASSWORD_BCRYPT, ['cost' => 12]); $flux->setHash('tmp');
$flux->setHash($tmphash);
} }
/** /**
......
<?php
namespace App\Entity;
use App\Entity\Prestataire;
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;
use Gedmo\Timestampable\Traits\TimestampableEntity;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity
* @ORM\Table(name="geoloc_prestataire")
*/
class GeolocPrestataire
{
use NameSlugContentEntityTrait,
TimestampableEntity,
EnablableEntityTrait,
GeolocEntityTrait;
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @var Prestataire
*
* @ORM\ManyToOne(targetEntity="Prestataire", cascade={"persist"}, inversedBy="geolocs")
* @ORM\JoinColumn(name="prestataire_id", referencedColumnName="id", nullable=false)
*/
private $prestataire;
public function getId(): ?int
{
return $this->id;
}
/**
* Get prestataire
* @return
*/
public function getPrestataire(): Prestataire
{
return $this->prestataire;
}
/**
* Set prestataire
* @return $this
*/
public function setPrestataire($prestataire): self
{
$this->prestataire = $prestataire;
return $this;
}
}
...@@ -17,10 +17,13 @@ class GlobalParameter ...@@ -17,10 +17,13 @@ class GlobalParameter
const MLC_NAME = 'MLC_NAME'; const MLC_NAME = 'MLC_NAME';
const MLC_NAME_SMALL = 'MLC_NAME_SMALL'; const MLC_NAME_SMALL = 'MLC_NAME_SMALL';
const MLC_NOTIF_EMAIL = 'MLC_NOTIF_EMAIL'; const MLC_NOTIF_EMAIL = 'MLC_NOTIF_EMAIL';
const COTISATION_MONTANT= 'COTISATION_MONTANT'; const COTISATION_ADHERENT = 'COTISATION_ADHERENT';
const MAP_CENTER = 'MAP_CENTER'; const COTISATION_PRESTATAIRE = 'COTISATION_PRESTATAIRE';
const MAP_ZOOM = 'MAP_ZOOM'; const RECONVERSION_ADHERENT = 'RECONVERSION_ADHERENT';
const FAVICON_URL = 'FAVICON_URL'; const RECONVERSION_PRESTATAIRE = 'RECONVERSION_PRESTATAIRE';
// const MAP_CENTER = 'MAP_CENTER';
// const MAP_ZOOM = 'MAP_ZOOM';
// const FAVICON_URL = 'FAVICON_URL';
/** /**
* @ORM\Id() * @ORM\Id()
......
...@@ -20,8 +20,6 @@ class News ...@@ -20,8 +20,6 @@ class News
NameSlugContentEntityTrait, NameSlugContentEntityTrait,
EnablableEntityTrait; EnablableEntityTrait;
const UPLOAD_DIR = "news";
/** /**
* @var int * @var int
* *
......
...@@ -30,7 +30,7 @@ abstract class Retrait extends Flux ...@@ -30,7 +30,7 @@ abstract class Retrait extends Flux
return self::TYPE_RETRAIT; return self::TYPE_RETRAIT;
} }
public function operate() public function operate($em)
{ {
$compteExp = $this->getExpediteur()->getCompte() - $this->getMontant(); $compteExp = $this->getExpediteur()->getCompte() - $this->getMontant();
if ($compteExp < 0) { if ($compteExp < 0) {
......
...@@ -34,6 +34,13 @@ class Rubrique ...@@ -34,6 +34,13 @@ class Rubrique
*/ */
private $prestataires; private $prestataires;
/**
* @var \App\Application\Sonata\MediaBundle\Entity\Media
* @ORM\ManyToOne(targetEntity="App\Application\Sonata\MediaBundle\Entity\Media", cascade={"persist"}, fetch="EAGER")
* @ORM\JoinColumn(name="media_id", referencedColumnName="id", nullable=true)
*/
protected $media;
public function __construct() public function __construct()
{ {
$this->prestataires = new ArrayCollection(); $this->prestataires = new ArrayCollection();
...@@ -48,6 +55,25 @@ class Rubrique ...@@ -48,6 +55,25 @@ class Rubrique
} }
/** /**
* Get media
* @return
*/
public function getMedia()
{
return $this->media;
}
/**
* Set media
* @return $this
*/
public function setMedia($media): self
{
$this->media = $media;
return $this;
}
/**
* @return Prestataire[]|ArrayCollection * @return Prestataire[]|ArrayCollection
*/ */
public function getPrestataires() public function getPrestataires()
......
...@@ -32,7 +32,7 @@ abstract class Transaction extends Flux ...@@ -32,7 +32,7 @@ abstract class Transaction extends Flux
return self::TYPE_TRANSACTION; return self::TYPE_TRANSACTION;
} }
public function operate() public function operate($em)
{ {
$compteExp = $this->getExpediteur()->getEcompte() - $this->getMontant(); $compteExp = $this->getExpediteur()->getEcompte() - $this->getMontant();
if ($compteExp < 0) { if ($compteExp < 0) {
......
...@@ -35,7 +35,7 @@ abstract class Transfert extends Flux ...@@ -35,7 +35,7 @@ abstract class Transfert extends Flux
return self::TYPE_TRANSFERT; return self::TYPE_TRANSFERT;
} }
public function operate() public function operate($em)
{ {
$compteExp = $this->getExpediteur()->getCompte() - $this->getMontant(); $compteExp = $this->getExpediteur()->getCompte() - $this->getMontant();
if ($compteExp < 0) { if ($compteExp < 0) {
......
...@@ -32,7 +32,7 @@ class TransfertPrestataireComptoir extends Transfert ...@@ -32,7 +32,7 @@ class TransfertPrestataireComptoir extends Transfert
return 'prestataire_comptoir'; return 'prestataire_comptoir';
} }
public function operate() public function operate($em)
{ {
$this->getExpediteur()->addEcompte($this->getMontant()); $this->getExpediteur()->addEcompte($this->getMontant());
$this->getDestinataire()->addCompte($this->getMontant()); $this->getDestinataire()->addCompte($this->getMontant());
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
namespace App\Entity; namespace App\Entity;
use App\Entity\GlobalParameter;
use App\Entity\Prestataire;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert; use Symfony\Component\Validator\Constraints as Assert;
...@@ -57,9 +59,13 @@ class TransfertPrestataireSiege extends Transfert ...@@ -57,9 +59,13 @@ class TransfertPrestataireSiege extends Transfert
return 'prestataire_siege'; //reconversion return 'prestataire_siege'; //reconversion
} }
public function operate() public function operate($em)
{ {
$this->getExpediteur()->removeEcompte($this->getMontant()); $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()->addCompte($this->getMontant());
$this->getDestinataire()->removeCompteNantie($this->getMontant()); $this->getDestinataire()->removeCompteNantie($this->getMontant());
......
...@@ -144,6 +144,9 @@ class User extends BaseUser ...@@ -144,6 +144,9 @@ class User extends BaseUser
public function __construct() public function __construct()
{ {
parent::__construct(); parent::__construct();
$this->imports = new ArrayCollection();
$this->faqs = new ArrayCollection();
$this->documents = new ArrayCollection();
$this->cotisations = new ArrayCollection(); $this->cotisations = new ArrayCollection();
$this->flux = new ArrayCollection(); $this->flux = new ArrayCollection();
$this->emailTokens = new ArrayCollection(); $this->emailTokens = new ArrayCollection();
...@@ -152,8 +155,10 @@ class User extends BaseUser ...@@ -152,8 +155,10 @@ class User extends BaseUser
$this->comptoirsgeres = new ArrayCollection(); $this->comptoirsgeres = new ArrayCollection();
$this->faqs = new ArrayCollection(); $this->faqs = new ArrayCollection();
$this->news = new ArrayCollection(); $this->news = new ArrayCollection();
$this->pages = new ArrayCollection();
$this->alertemailflux = true; $this->alertemailflux = true;
$this->createApiKey(); $this->createApiKey();
$this->createEmailToken();
} }
/** /**
......
...@@ -30,7 +30,7 @@ abstract class Vente extends Flux ...@@ -30,7 +30,7 @@ abstract class Vente extends Flux
return self::TYPE_VENTE; return self::TYPE_VENTE;
} }
public function operate() public function operate($em)
{ {
$compteExp = $this->getExpediteur()->getCompte() - $this->getMontant(); $compteExp = $this->getExpediteur()->getCompte() - $this->getMontant();
if ($compteExp < 0) { if ($compteExp < 0) {
......
...@@ -34,7 +34,7 @@ class GeolocListener ...@@ -34,7 +34,7 @@ class GeolocListener
$provider = Nominatim::withOpenStreetMapServer($httpClient, 'Mozilla/5.0'); $provider = Nominatim::withOpenStreetMapServer($httpClient, 'Mozilla/5.0');
$geocoder = new \Geocoder\StatefulGeocoder($provider, 'fr'); $geocoder = new \Geocoder\StatefulGeocoder($provider, 'fr');
$fullAddress = $entity->getAdresse().' '.$entity->getCpostal().' '.$entity->getVille(); $fullAddress = $entity->getAdresse().' '.$entity->getCpostal().' '.$entity->getVille();
// Query geocoding from complete addresse // Query geocoding from complete address
$result = $geocoder->geocodeQuery(GeocodeQuery::create($fullAddress)); $result = $geocoder->geocodeQuery(GeocodeQuery::create($fullAddress));
if (count($result) > 0) { if (count($result) > 0) {
$coords = $result->first()->getCoordinates(); $coords = $result->first()->getCoordinates();
......
...@@ -5,6 +5,7 @@ namespace App\Form\Extension; ...@@ -5,6 +5,7 @@ namespace App\Form\Extension;
use Sonata\MediaBundle\Form\Type\MediaType; use Sonata\MediaBundle\Form\Type\MediaType;
use Symfony\Component\Form\AbstractTypeExtension; use Symfony\Component\Form\AbstractTypeExtension;
use Symfony\Component\Form\Extension\Core\Type\HiddenType; use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolver;
...@@ -16,6 +17,7 @@ class MediaTypeExtension extends AbstractTypeExtension ...@@ -16,6 +17,7 @@ class MediaTypeExtension extends AbstractTypeExtension
public function configureOptions(OptionsResolver $resolver) public function configureOptions(OptionsResolver $resolver)
{ {
$resolver->setDefined(['show_unlink' => true]); $resolver->setDefined(['show_unlink' => true]);
$resolver->setDefaults(['show_unlink' => true]);
} }
/** /**
......
<?php
namespace App\Form\Type;
use App\Entity\ContactPrestataire;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Routing\RouterInterface;
class ContactPrestataireFormType extends AbstractType
{
private $router;
public function __construct(RouterInterface $router)
{
$this->router = $router;
}
public function buildForm(FormBuilderInterface $builder, array $options)
{
$geoloc = null;
if (!empty($options['data'])) {
$geoloc = $options['data'];
}
$builder
->add('name', TextType::class, array(
'label' => "Nom du contact / description :",
'required' => true,
))
->add('content', TextType::class, array(
'label' => "Téléphone :",
'required' => true,
))
->add('enabled', CheckboxType::class, array(
'label' => 'Public ?',
'required' => false,
'label_attr' => array('class' => 'checkbox-inline')
))
;
}
public function configureOptions(OptionsResolver $resolver)
{
// $resolver->setRequired(['with_latlon']);
$resolver->setDefaults([
'data_class' => ContactPrestataire::class
]);
}
public function getBlockPrefix()
{
return 'formContactPrestataire';
}
}
...@@ -26,7 +26,7 @@ class FirstComptoirFormType extends AbstractType ...@@ -26,7 +26,7 @@ class FirstComptoirFormType extends AbstractType
'required' => true 'required' => true
)) ))
->add('compte', NumberType::class, array( ->add('compte', NumberType::class, array(
'label' => 'Solde de monnaie actuellement au comptoir :', 'label' => 'Solde de monnaie papier actuellement au comptoir :',
'required' => true 'required' => true
)) ))
; ;
......
...@@ -21,7 +21,7 @@ class FirstGroupeFormType extends AbstractType ...@@ -21,7 +21,7 @@ class FirstGroupeFormType extends AbstractType
'required' => true 'required' => true
)) ))
->add('compte', NumberType::class, array( ->add('compte', NumberType::class, array(
'label' => 'Solde de monnaie actuellement au groupe :', 'label' => 'Solde de monnaie papier actuellement au groupe :',
'required' => true 'required' => true
)) ))
; ;
......
...@@ -29,7 +29,7 @@ class GeolocFormType extends AbstractType ...@@ -29,7 +29,7 @@ class GeolocFormType extends AbstractType
} }
$builder $builder
->add('adresse', TextType::class, array( ->add('adresse', TextType::class, array(
'label' => 'Addresse :', 'label' => 'Adresse :',
'required' => $options['required'] 'required' => $options['required']
)) ))
->add('cpostal', TextType::class, array( ->add('cpostal', TextType::class, array(
......
<?php
namespace App\Form\Type;
use App\Entity\GeolocPrestataire;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Routing\RouterInterface;
class GeolocPrestataireFormType extends AbstractType
{
private $router;
public function __construct(RouterInterface $router)
{
$this->router = $router;
}
public function buildForm(FormBuilderInterface $builder, array $options)
{
$geoloc = null;
if (!empty($options['data'])) {
$geoloc = $options['data'];
}
$builder
->add('name', TextType::class, array(
'label' => "Nom de l'adresse :",
'required' => true,
))
->add('enabled', CheckboxType::class, array(
'label' => 'Visible sur la carte ?',
'required' => false,
'label_attr' => array('class' => 'checkbox-inline')
))
->add('geoloc', GeolocFormType::class, array(
'label' => false
))
;
}
public function configureOptions(OptionsResolver $resolver)
{
// $resolver->setRequired(['with_latlon']);
$resolver->setDefaults([
'data_class' => GeolocPrestataire::class
]);
}
public function getBlockPrefix()
{
return 'formGeolocPrestataire';
}
}
...@@ -45,9 +45,9 @@ class GlobalConfigurationFormType extends AbstractType ...@@ -45,9 +45,9 @@ class GlobalConfigurationFormType extends AbstractType
new EmailConstraint(['message' => 'Email invalide !']) new EmailConstraint(['message' => 'Email invalide !'])
], ],
)) ))
->add('mlccotisation', GlobalParameterType::class, array( ->add('mlccotisationadh', GlobalParameterType::class, array(
'label' => 'Montant par défaut des cotisations:', 'label' => 'Montant par défaut des cotisations des adhérents :',
'name_param' => GlobalParameter::COTISATION_MONTANT, 'name_param' => GlobalParameter::COTISATION_ADHERENT,
'help' => 'Ne pas utiliser de virgule ",", utiliser le point "."', 'help' => 'Ne pas utiliser de virgule ",", utiliser le point "."',
'required' => true, 'required' => true,
'_placeholder' => '10', '_placeholder' => '10',
...@@ -55,30 +55,60 @@ class GlobalConfigurationFormType extends AbstractType ...@@ -55,30 +55,60 @@ class GlobalConfigurationFormType extends AbstractType
new TypeConstraint(['type' => 'numeric', 'message' => "Le montant n'est pas valide !"]) new TypeConstraint(['type' => 'numeric', 'message' => "Le montant n'est pas valide !"])
], ],
)) ))
->add('mapcenter', GlobalParameterType::class, array( ->add('mlccotisationpresta', GlobalParameterType::class, array(
'label' => 'Coordonnées du centre de la carte (Format [lat,long], exemple : [45.7,3.2]):', 'label' => 'Montant par défaut des cotisations des prestataires :',
'name_param' => GlobalParameter::MAP_CENTER, 'name_param' => GlobalParameter::COTISATION_PRESTATAIRE,
'help' => 'Ne pas utiliser de virgule ",", utiliser le point "."',
'required' => true, 'required' => true,
'_placeholder' => '[45.7,3.2]', '_placeholder' => '10',
'constraints_param' => [ 'constraints_param' => [
new RegexConstraint(['pattern' => '/^\[[0-9]+\.[0-9]+,[0-9]+\.[0-9]+\]/', 'message' => 'Coordonnées invalide, format attendu : [45.7,3.2]']) new TypeConstraint(['type' => 'numeric', 'message' => "Le montant n'est pas valide !"])
], ],
)) ))
->add('mapzoom', GlobalParameterType::class, array( ->add('mlcreconversionadh', GlobalParameterType::class, array(
'label' => 'Zoom de la carte (nombre entre 1 et 15) :', 'label' => 'Taux de reconversion des adhérents :',
'name_param' => GlobalParameter::MAP_ZOOM, 'name_param' => GlobalParameter::RECONVERSION_ADHERENT,
'help' => 'Ne pas utiliser de virgule ",", utiliser le point "."',
'required' => true, 'required' => true,
'_placeholder' => '9', '_placeholder' => '0',
'constraints_param' => [ 'constraints_param' => [
new RegexConstraint(['pattern' => '/^[0-9]{1,2}$/', 'message' => 'Le zoom doit être un nombre entre 0 et 15 !']) new TypeConstraint(['type' => 'numeric', 'message' => "Le montant n'est pas valide !"])
], ],
)) ))
->add('mlcfavicon', GlobalParameterType::class, array( ->add('mlcreconversionpresta', GlobalParameterType::class, array(
'label' => 'Chemin du favicon :', 'label' => 'Taux de reconversion des prestataires :',
'_data' => '/images/favicon.png', 'name_param' => GlobalParameter::RECONVERSION_PRESTATAIRE,
'name_param' => GlobalParameter::FAVICON_URL, 'help' => 'Ne pas utiliser de virgule ",", utiliser le point "."',
'required' => true, 'required' => true,
'_placeholder' => '0',
'constraints_param' => [
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( ->add('mlctitle', GlobalParameterType::class, array(
'label' => '[SEO] Titre par défaut des pages du site web :', 'label' => '[SEO] Titre par défaut des pages du site web :',
'name_param' => GlobalParameter::MLC_TITLE, 'name_param' => GlobalParameter::MLC_TITLE,
...@@ -106,6 +136,6 @@ class GlobalConfigurationFormType extends AbstractType ...@@ -106,6 +136,6 @@ class GlobalConfigurationFormType extends AbstractType
public function getBlockPrefix() public function getBlockPrefix()
{ {
return 'formSiege'; return 'formGlobalConfiguration';
} }
} }
...@@ -34,7 +34,7 @@ class ImportFormType extends AbstractType ...@@ -34,7 +34,7 @@ class ImportFormType extends AbstractType
'provider' => 'sonata.media.provider.file', 'provider' => 'sonata.media.provider.file',
'context' => 'import', 'context' => 'import',
'label' => 'Fichier .csv', 'label' => 'Fichier .csv',
// 'show_unlink' => false 'show_unlink' => false
)) ))
->add('user', HiddenType::class, array( ->add('user', HiddenType::class, array(
......
...@@ -76,9 +76,14 @@ class PrestataireInfosFormType extends AbstractType ...@@ -76,9 +76,14 @@ class PrestataireInfosFormType extends AbstractType
'choice_label' => 'name', 'choice_label' => 'name',
'placeholder' => 'Choisir un groupe', 'placeholder' => 'Choisir un groupe',
)) ))
->add('geoloc', GeolocFormType::class, array( ->add('geolocs', CollectionType::class, array(
'label' => 'ADRESSE', 'entry_type' => GeolocPrestataireFormType::class,
'required' => false 'entry_options' => array('label' => false),
'required' => false,
'allow_add' => true,
'allow_delete' => true,
'by_reference' => false,
'label' => false
)) ))
->add('rubriques', CollectionType::class, array( ->add('rubriques', CollectionType::class, array(
'label' => 'Rubriques', 'label' => 'Rubriques',
......
...@@ -26,12 +26,13 @@ class SiegeFormType extends AbstractType ...@@ -26,12 +26,13 @@ class SiegeFormType extends AbstractType
'required' => true 'required' => true
)) ))
->add('compte', NumberType::class, array( ->add('compte', NumberType::class, array(
'label' => 'Solde de monnaie actuellement au siège :', 'label' => 'Solde de monnaie papier actuellement au siège :',
'required' => true 'required' => true
)) ))
->add('compteNantie', NumberType::class, array( ->add('compteNantie', NumberType::class, array(
'label' => 'Compte de monnaie nantie :', 'label' => 'Compte de monnaie nantie :',
'required' => true 'required' => true,
'help' => '(montant du fond de garantie)'
)) ))
; ;
} }
......
...@@ -52,6 +52,9 @@ class UserFormType extends AbstractType ...@@ -52,6 +52,9 @@ class UserFormType extends AbstractType
'label' => 'Téléphone mobile :', 'label' => 'Téléphone mobile :',
'required' => false 'required' => false
)) ))
->add('enabled', null, array(
'label' => 'Activé ?'
))
; ;
} }
......
...@@ -33,7 +33,7 @@ class FluxListener implements EventSubscriber ...@@ -33,7 +33,7 @@ class FluxListener implements EventSubscriber
foreach ($inserted as $entity) { foreach ($inserted as $entity) {
if ($entity instanceof Flux) { if ($entity instanceof Flux) {
$topersists = $entity->operate(); $topersists = $entity->operate($em);
foreach ($topersists as $topersist) { foreach ($topersists as $topersist) {
$class = $em->getClassMetadata(get_class($topersist)); $class = $em->getClassMetadata(get_class($topersist));
$em->persist($topersist); $em->persist($topersist);
......
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20200403104008 extends AbstractMigration
{
public function getDescription() : string
{
return '';
}
public function up(Schema $schema) : void
{
// this up() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
$this->addSql('CREATE TABLE etat_prestataire (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(150) NOT NULL, slug VARCHAR(150) NOT NULL, content LONGTEXT DEFAULT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, enabled TINYINT(1) NOT NULL, UNIQUE INDEX UNIQ_DD6CC57989D9B62 (slug), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_general_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE etats_prestataires (etat_prestataire_id INT NOT NULL, prestataire_id INT NOT NULL, INDEX IDX_5D68706574D12AB (etat_prestataire_id), INDEX IDX_5D687065BE3DB2B7 (prestataire_id), PRIMARY KEY(etat_prestataire_id, prestataire_id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_general_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE etats_prestataires ADD CONSTRAINT FK_5D68706574D12AB FOREIGN KEY (etat_prestataire_id) REFERENCES etat_prestataire (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE etats_prestataires ADD CONSTRAINT FK_5D687065BE3DB2B7 FOREIGN KEY (prestataire_id) REFERENCES prestataire (id) ON DELETE CASCADE');
}
public function down(Schema $schema) : void
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
$this->addSql('ALTER TABLE etats_prestataires DROP FOREIGN KEY FK_5D68706574D12AB');
$this->addSql('DROP TABLE etat_prestataire');
$this->addSql('DROP TABLE etats_prestataires');
}
}
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20200406151406 extends AbstractMigration
{
public function getDescription() : string
{
return '';
}
public function up(Schema $schema) : void
{
// this up() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
$this->addSql('CREATE TABLE geoloc_prestataire (id INT AUTO_INCREMENT NOT NULL, prestataire_id INT NOT NULL, geoloc_id INT DEFAULT NULL, name VARCHAR(150) NOT NULL, slug VARCHAR(150) NOT NULL, content LONGTEXT DEFAULT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, enabled TINYINT(1) NOT NULL, UNIQUE INDEX UNIQ_7A6F2D1F989D9B62 (slug), INDEX IDX_7A6F2D1FBE3DB2B7 (prestataire_id), UNIQUE INDEX UNIQ_7A6F2D1FEF390162 (geoloc_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_general_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE geoloc_prestataire ADD CONSTRAINT FK_7A6F2D1FBE3DB2B7 FOREIGN KEY (prestataire_id) REFERENCES prestataire (id)');
$this->addSql('ALTER TABLE geoloc_prestataire ADD CONSTRAINT FK_7A6F2D1FEF390162 FOREIGN KEY (geoloc_id) REFERENCES geoloc (id)');
$this->addSql('ALTER TABLE prestataire DROP FOREIGN KEY FK_60A26480EF390162');
$this->addSql('DROP INDEX UNIQ_60A26480EF390162 ON prestataire');
$this->addSql('ALTER TABLE prestataire DROP geoloc_id');
}
public function down(Schema $schema) : void
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
$this->addSql('DROP TABLE geoloc_prestataire');
$this->addSql('ALTER TABLE prestataire ADD geoloc_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE prestataire ADD CONSTRAINT FK_60A26480EF390162 FOREIGN KEY (geoloc_id) REFERENCES geoloc (id)');
$this->addSql('CREATE UNIQUE INDEX UNIQ_60A26480EF390162 ON prestataire (geoloc_id)');
}
}
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20200406170822 extends AbstractMigration
{
public function getDescription() : string
{
return '';
}
public function up(Schema $schema) : void
{
// this up() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
$this->addSql('CREATE TABLE contact_prestataire (id INT AUTO_INCREMENT NOT NULL, prestataire_id INT NOT NULL, name VARCHAR(150) NOT NULL, slug VARCHAR(150) NOT NULL, content LONGTEXT DEFAULT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, enabled TINYINT(1) NOT NULL, UNIQUE INDEX UNIQ_E0EDB3E989D9B62 (slug), INDEX IDX_E0EDB3EBE3DB2B7 (prestataire_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_general_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE contact_prestataire ADD CONSTRAINT FK_E0EDB3EBE3DB2B7 FOREIGN KEY (prestataire_id) REFERENCES prestataire (id)');
}
public function down(Schema $schema) : void
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
$this->addSql('DROP TABLE contact_prestataire');
}
}
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20200408160435 extends AbstractMigration
{
public function getDescription() : string
{
return '';
}
public function up(Schema $schema) : void
{
// this up() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
$this->addSql('ALTER TABLE rubrique ADD media_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE rubrique ADD CONSTRAINT FK_8FA4097CEA9FDD75 FOREIGN KEY (media_id) REFERENCES media__media (id)');
$this->addSql('CREATE INDEX IDX_8FA4097CEA9FDD75 ON rubrique (media_id)');
}
public function down(Schema $schema) : void
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
$this->addSql('ALTER TABLE rubrique DROP FOREIGN KEY FK_8FA4097CEA9FDD75');
$this->addSql('DROP INDEX IDX_8FA4097CEA9FDD75 ON rubrique');
$this->addSql('ALTER TABLE rubrique DROP media_id');
}
}
<?php
namespace App\Repository;
use App\Entity\EtatPrestataire;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Common\Persistence\ManagerRegistry;
/**
* @method EtatPrestataire|null find($id, $lockMode = null, $lockVersion = null)
* @method EtatPrestataire|null findOneBy(array $criteria, array $orderBy = null)
* @method EtatPrestataire[] findAll()
* @method EtatPrestataire[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class EtatPrestataireRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, EtatPrestataire::class);
}
// /**
// * @return EtatPrestataire[] Returns an array of EtatPrestataire objects
// */
/*
public function findByExampleField($value)
{
return $this->createQueryBuilder('e')
->andWhere('e.exampleField = :val')
->setParameter('val', $value)
->orderBy('e.id', 'ASC')
->setMaxResults(10)
->getQuery()
->getResult()
;
}
*/
/*
public function findOneBySomeField($value): ?EtatPrestataire
{
return $this->createQueryBuilder('e')
->andWhere('e.exampleField = :val')
->setParameter('val', $value)
->getQuery()
->getOneOrNullResult()
;
}
*/
}
...@@ -100,6 +100,50 @@ class FluxRepository extends ServiceEntityRepository ...@@ -100,6 +100,50 @@ class FluxRepository extends ServiceEntityRepository
} }
/** /**
* @param Comptoir $comptoir [description]
* @return Query Returns a query fo finding an array of Flux
*/
public function getQueryByComptoirParams(Comptoir $comptoir, $params)
{
$sql = "SELECT f.id FROM {$this->tableName} f WHERE f.comptoir_id = :id";
if (isset($param['parenttype'])) {
$sql.= ' AND f.parenttype = :parenttype';
}
if (isset($param['type'])) {
$sql.= ' AND f.type = :type';
}
if (isset($param['start'])) {
$sql.= ' AND f.created_at > :start';
}
if (isset($param['end'])) {
$sql.= ' AND f.created_at < :end';
}
$statement = $this->connection->prepare($sql);
$statement->bindValue('id', $comptoir->getId());
if (isset($param['parenttype'])) {
$statement->bindValue('parenttype', $param['parenttype']);
}
if (isset($param['type'])) {
$statement->bindValue('type', $param['type']);
}
if (isset($param['start'])) {
$statement->bindValue('start', $param['start']);
}
if (isset($param['end'])) {
$statement->bindValue('end', $param['end']);
}
$statement->execute();
$results = $statement->fetchAll();
$qb = $this->createQueryBuilder('f');
return $qb
->where($qb->expr()->in('f.id', ':ids'))
->setParameter('ids', $results)
->orderBy('f.createdAt', 'DESC')
->getQuery()
;
}
/**
* @param Groupe $groupe [description] * @param Groupe $groupe [description]
* @return Query Returns a query fo finding an array of Flux * @return Query Returns a query fo finding an array of Flux
*/ */
......
...@@ -29,6 +29,7 @@ class GlobalParameterRepository extends ServiceEntityRepository ...@@ -29,6 +29,7 @@ class GlobalParameterRepository extends ServiceEntityRepository
$item = (array) $item; $item = (array) $item;
$key = $item['name']; $key = $item['name'];
$value = $item['value']; $value = $item['value'];
// @TODO : mettre le prefixe 'KOH_' en parametre (conf yaml)
$result['KOH_'.$key] = $value; $result['KOH_'.$key] = $value;
return $result; return $result;
......
...@@ -2,8 +2,10 @@ ...@@ -2,8 +2,10 @@
namespace App\Repository; namespace App\Repository;
use App\Entity\Groupe;
use App\Entity\Groupeprestataire; use App\Entity\Groupeprestataire;
use App\Entity\Prestataire; use App\Entity\Prestataire;
use App\Entity\Rubrique;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Symfony\Bridge\Doctrine\RegistryInterface; use Symfony\Bridge\Doctrine\RegistryInterface;
...@@ -23,6 +25,40 @@ class PrestataireRepository extends ServiceEntityRepository ...@@ -23,6 +25,40 @@ class PrestataireRepository extends ServiceEntityRepository
/** /**
* @return Prestataire[] Returns an array of Prestataire objects * @return Prestataire[] Returns an array of Prestataire objects
*/ */
public function findByRubrique(Rubrique $rubrique)
{
$qb = $this->createQueryBuilder('p');
return $qb
->where($qb->expr()->isMemberOf(':rubrique', 'p.rubriques'))
->andWhere('p.enabled = :enabled')
->setParameter('rubrique', $rubrique)
->setParameter('enabled', true)
->orderBy('p.raison', 'ASC')
->getQuery()
->getResult()
;
}
/**
* @return Prestataire[] Returns an array of Prestataire objects
*/
public function findByGroupeLocal(Groupe $groupe)
{
$qb = $this->createQueryBuilder('p');
return $qb
->where('p.groupe = :groupe')
->andWhere('p.enabled = :enabled')
->setParameter('groupe', $groupe)
->setParameter('enabled', true)
->orderBy('p.raison', 'ASC')
->getQuery()
->getResult()
;
}
/**
* @return Prestataire[] Returns an array of Prestataire objects
*/
public function findByGroupeprestataire(Groupeprestataire $groupe) public function findByGroupeprestataire(Groupeprestataire $groupe)
{ {
$qb = $this->createQueryBuilder('p'); $qb = $this->createQueryBuilder('p');
......
<?php
namespace App\Security\Handler;
use Sonata\AdminBundle\Admin\AdminInterface;
use Sonata\AdminBundle\Security\Handler\RoleSecurityHandler;
use Symfony\Component\Security\Core\Exception\AuthenticationCredentialsNotFoundException;
class VoterSecurityHandler extends RoleSecurityHandler
{
/**
* {@inheritdoc}
*/
public function isGranted(AdminInterface $admin, $attributes, $object = null)
{
// dump($admin);
// dump($attributes);
// dump($object);
if (!\is_array($attributes)) {
$attributes = [$attributes];
}
foreach ($attributes as $pos => $attribute) {
$attributes[$pos] = sprintf($this->getBaseRole($admin), $attribute);
}
$allRole = sprintf($this->getBaseRole($admin), 'ALL');
// dump($attributes);
// exit();
try {
return $this->authorizationChecker->isGranted($this->superAdminRoles)
|| $this->authorizationChecker->isGranted($attributes, $object)
|| $this->authorizationChecker->isGranted([$allRole], $object);
} catch (AuthenticationCredentialsNotFoundException $e) {
return false;
}
}
}
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