Commit 86cfc65a by Julien Jorry

BIG UPDATE : update BO + front office

parent 43f8c8d4
body {
background-color: lightgray;
}
}
\ No newline at end of file
......@@ -27,4 +27,7 @@ const mlc = require('../js/mlc.js');
// can be use to sort with drag'n drop in sonata admin
// require('../../public/bundles/pixsortablebehavior/js/init.js');
$('#flash-messages').flashNotification('init');
\ No newline at end of file
$('#flash-messages').flashNotification('init');
$(function () {
$('[data-toggle="tooltip"]').tooltip()
})
\ No newline at end of file
......@@ -25,7 +25,7 @@ bazinga_geocoder:
# httplug_client: '@httplug.client' # When using HTTPlugBundle
region: 'France'
api_key: 'XXXXXXXXX'
locale: fr
locale: fr
# region: ~
# use_ssl: false
# google_maps_business:
......@@ -35,7 +35,7 @@ bazinga_geocoder:
# use_ssl: false
openstreetmap:
factory: Bazinga\GeocoderBundle\ProviderFactory\NominatimFactory
locale: fr
locale: fr
# cache: '@Symfony\Component\Cache\Simple\ApcuCache'
# cache_lifetime: 3600
# cache_precision: ~
......
knp_paginator:
page_range: 5 # number of links showed in the pagination menu (e.g: you have 10 pages, a page_range of 3, on the 5th page you'll see links to page 4, 5, 6)
default_options:
page_name: page # page query parameter name
sort_field_name: sort # sort field query parameter name
sort_direction_name: direction # sort direction query parameter name
distinct: true # ensure distinct results, useful when ORM queries are using GROUP BY statements
filter_field_name: filterField # filter field query parameter name
filter_value_name: filterValue # filter value query parameter name
template:
pagination: '@KnpPaginator/Pagination/twitter_bootstrap_v4_pagination.html.twig' # sliding pagination controls template
sortable: '@KnpPaginator/Pagination/font_awesome_sortable_link.html.twig' # sort link template
filtration: '@KnpPaginator/Pagination/filtration.html.twig' # filters template
\ No newline at end of file
......@@ -4,7 +4,7 @@ sonata_admin:
role_admin: ROLE_ADMIN
role_super_admin: ROLE_SUPER_ADMIN
title: 'MLC Admin'
title_logo: /images/admin/logo.png
title_logo: /images/logo.png
templates:
layout: '@SonataAdmin/standard_layout.html.twig'
#outer_list_rows_mosaic: '@SonataAdmin/list_outer_rows_mosaic.html.twig'
......@@ -224,12 +224,14 @@ sonata_admin:
- admin.traduction.gerer
sonata.admin.group.flux:
keep_open: false
on_top: true
label: "Flux"
label_catalogue: SonataAdminBundle
icon: '<i class="fa fa-euro"></i>'
items:
- admin.flux.gerer
- admin.all.cotisations
- admin.transfert.gerer
- admin.transaction.gerer
sonata.admin.group.menu_builder:
keep_open: false
on_top: true
......
......@@ -58,7 +58,7 @@ services:
app.twig.main.extension:
class: App\Twig\AppExtension
autowire: false
arguments: ["@service_container"]
arguments: ["@service_container", "@knp_paginator"]
app.twig.menu.extension:
class: App\Twig\MenuExtension
......@@ -99,6 +99,19 @@ services:
public: true
calls:
- [ setUserManager, ['@fos_user.user_manager']]
- [ setTokenStorage, ['@security.token_storage']]
admin.all.cotisations:
class: App\Admin\CotisationAdmin
arguments: [~, App\Entity\Cotisation, ~]
tags:
- name: sonata.admin
manager_type: orm
group: "Flux"
label: "Cotisations"
public: true
calls:
- [ setTokenStorage, ['@security.token_storage']]
admin.adherent.cotisations:
class: App\Admin\CotisationAdherentAdmin
......@@ -109,6 +122,8 @@ services:
group: "Adherent"
label: "Cotisation"
public: true
calls:
- [ setTokenStorage, ['@security.token_storage']]
# admin.prestataire.gerer:
# class: App\Admin\PrestataireoldAdmin
......@@ -144,6 +159,8 @@ services:
group: "Prestataire"
label: "Cotisation"
public: true
calls:
- [ setTokenStorage, ['@security.token_storage']]
admin.groupe.gerer:
class: App\Admin\GroupeAdmin
......@@ -236,6 +253,32 @@ services:
calls:
- [ setSubClasses, [{transaction: 'App\Entity\Transaction', transfert: 'App\Entity\Transfert', cotisation: 'App\Entity\Cotisation'}]]
admin.transfert.gerer:
class: App\Admin\TransfertAdmin
arguments: [~, App\Entity\Transfert, ~]
tags:
- name: sonata.admin
manager_type: orm
group: "Flux"
label: "Transfert"
pager_type: "simple"
public: true
# calls:
# - [ setSubClasses, [{transaction: 'App\Entity\Transaction', transfert: 'App\Entity\Transfert', cotisation: 'App\Entity\Cotisation'}]]
admin.transaction.gerer:
class: App\Admin\TransactionAdmin
arguments: [~, App\Entity\Transaction, ~]
tags:
- name: sonata.admin
manager_type: orm
group: "Flux"
label: "Transaction"
pager_type: "simple"
public: true
# calls:
# - [ setSubClasses, [{transaction: 'App\Entity\Transaction', transfert: 'App\Entity\Transfert', cotisation: 'App\Entity\Cotisation'}]]
# admin.flux.gerer:
# class: App\Admin\FluxAdmin
# arguments: [~, App\Entity\Transaction, ~]
......
......@@ -3,6 +3,7 @@ App\Entity\Siege:
siege_1:
name: 'Siege MLC'
content: 'MLC'
compte: '<randomFloat(2, 1000, 2000)>'
App\Entity\TypePrestataire:
typepresta1:
......@@ -45,6 +46,7 @@ App\Entity\Groupe:
groupe{1..10}:
name: '<text(10)>'
content: '<text(200)>'
compte: '<randomFloat(2, 100, 200)>'
siege: '@siege_1'
App\Entity\Geoloc:
......@@ -62,6 +64,7 @@ App\Entity\Comptoir:
enabled: true
tel: '<phoneNumber()>'
email: '<email()>'
compte: '<randomFloat(2, 100, 200)>'
groupe: '@groupe<numberBetween(1,10)>'
geoloc (unique): '@geoloc<numberBetween(1,70)>'
......@@ -85,12 +88,13 @@ App\Entity\Groupeprestataire:
App\Entity\Adherent:
adherent{1..11}:
ecompte: '<randomFloat(2, 0, 50)>'
ecompte: '<randomFloat(2, 100, 200)>'
groupe: '@groupe<numberBetween(1, 10)>'
# user (unique): '@user<numberBetween(1,10)>'
App\Entity\Prestataire:
prestataire{1..21}:
compte: '<randomFloat(2, 100, 200)>'
raison: '<text(10)>'
responsable: '<text(10)>'
metier: '<text(10)>'
......@@ -103,6 +107,7 @@ App\Entity\Prestataire:
groupe: '@groupe<numberBetween(1, 10)>'
horaires: "<dayOfWeek()> de <time('H')>h à <time('H')>h"
prestataire{22..32}:
compte: '<randomFloat(2, 100, 200)>'
raison: <text(10)>
responsable: <text(10)>
metier: <text(10)>
......@@ -197,6 +202,7 @@ App\Entity\User:
enabled: true
groups: ['@usergroup_comptoir']
roles: ['ROLE_COMPTOIR']
gestionnaireComptoir: '@comptoir1'
usergestiongroupe:
username: 'user_gestiongroupe'
email: 'groupe@doume.test'
......@@ -204,6 +210,7 @@ App\Entity\User:
enabled: true
groups: ['@usergroup_gestiongroupe']
roles: ['ROLE_GESTION_GROUPE']
gestionnaireGroupe: '@groupe1'
usertresorier:
username: 'user_tresorier'
email: 'tresorier@doume.test'
......@@ -257,7 +264,7 @@ App\Entity\User:
email: <email()>
plainPassword: 'test'
enabled: true
# groups: ['@usergroup_prestataire']
groups: ['@usergroup_prestataire']
roles: ['ROLE_PRESTATAIRE']
prestataire: '@prestataire<current()>'
......@@ -268,7 +275,7 @@ App\Entity\TransactionAdherentPrestataire:
type: 'adherent_prestataire'
reference: 'test'
moyen: 'cb'
montant: '<numberBetween(1,50)>'
montant: '<randomFloat(2, 0,2)>'
expediteur: '@adherent<current()>'
destinataire: '@prestataire<current()>'
createdAt: '<dateTimeBetween("-200 days", "now")>'
......@@ -279,7 +286,7 @@ App\Entity\TransactionPrestataireAdherent:
type: 'prestataire_adherent'
reference: 'test'
moyen: 'cb'
montant: '<numberBetween(1,50)>'
montant: '<randomFloat(2, 0,2)>'
expediteur: '@prestataire<current()>'
destinataire: '@adherent<current()>'
createdAt: '<dateTimeBetween("-200 days", "now")>'
......@@ -290,8 +297,8 @@ App\Entity\TransactionPrestatairePrestataire:
type: 'prestataire_prestataire'
reference: 'test'
moyen: 'cb'
montant: '<numberBetween(1,50)>'
expediteur: '@prestataire<numberBetween(1, 10)>'
montant: '<randomFloat(2, 0,2)>'
expediteur: '@prestataire<current()>'
destinataire: '@prestataire<numberBetween(11, 21)>'
createdAt: '<dateTimeBetween("-200 days", "now")>'
parenttype: 'transaction'
......@@ -301,7 +308,7 @@ App\Entity\TransfertComptoirAdherent:
type: 'comptoir_adherent'
reference: 'test'
moyen: 'cb'
montant: '<numberBetween(1,50)>'
montant: '<randomFloat(2, 0,2)>'
expediteur: '@comptoir<numberBetween(1,50)>'
destinataire: '@adherent<current()>'
createdAt: '<dateTimeBetween("-200 days", "now")>'
......@@ -312,7 +319,7 @@ App\Entity\TransfertComptoirGroupe:
type: 'comptoir_groupe'
reference: 'test'
moyen: 'cb'
montant: '<numberBetween(1,50)>'
montant: '<randomFloat(2, 0,2)>'
expediteur: '@comptoir<numberBetween(1,50)>'
destinataire: '@groupe<numberBetween(1,10)>'
createdAt: '<dateTimeBetween("-200 days", "now")>'
......@@ -323,7 +330,7 @@ App\Entity\TransfertComptoirPrestataire:
type: 'comptoir_prestataire'
reference: 'test'
moyen: 'cb'
montant: '<numberBetween(1,50)>'
montant: '<randomFloat(2, 0,2)>'
expediteur: '@comptoir<numberBetween(1,50)>'
destinataire: '@prestataire<numberBetween(1,32)>'
createdAt: '<dateTimeBetween("-200 days", "now")>'
......@@ -334,7 +341,7 @@ App\Entity\TransfertGroupeComptoir:
type: 'groupe_comptoir'
reference: 'test'
moyen: 'cb'
montant: '<numberBetween(1,50)>'
montant: '<randomFloat(2, 0,2)>'
expediteur: '@groupe<numberBetween(1,10)>'
destinataire: '@comptoir<numberBetween(1,50)>'
createdAt: '<dateTimeBetween("-200 days", "now")>'
......@@ -345,8 +352,8 @@ App\Entity\TransfertPrestataireComptoir:
type: 'prestataire_comptoir'
reference: 'test'
moyen: 'cb'
montant: '<numberBetween(1,50)>'
expediteur: '@prestataire<numberBetween(1,30)>'
montant: '<randomFloat(2, 0,2)>'
expediteur: '@prestataire<current()>'
destinataire: '@comptoir<numberBetween(1,50)>'
createdAt: '<dateTimeBetween("-200 days", "now")>'
parenttype: 'transfert'
......@@ -356,7 +363,7 @@ App\Entity\TransfertSiegeGroupe:
type: 'siege_groupe'
reference: 'test'
moyen: 'cb'
montant: '<numberBetween(1,50)>'
montant: '<randomFloat(2, 0,2)>'
expediteur: '@siege_1'
destinataire: '@groupe<numberBetween(1,10)>'
createdAt: '<dateTimeBetween("-200 days", "now")>'
......
......@@ -28,11 +28,13 @@ use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
class AdherentAdmin extends AbstractAdmin
{
protected $baseRouteName = 'adherent';
protected $baseRoutePattern = 'adherent';
protected $tokenStorage;
protected $datagridValues = [
// reverse order (default = 'ASC')
......@@ -43,6 +45,11 @@ class AdherentAdmin extends AbstractAdmin
// '_per_page' => 32
];
public function setTokenStorage(TokenStorageInterface $tokenStorage)
{
$this->tokenStorage = $tokenStorage;
}
public function configure()
{
parent::configure();
......@@ -115,7 +122,7 @@ class AdherentAdmin extends AbstractAdmin
$formMapper
->add('user.phone', TextType::class, array(
'label' => 'Téléphone :',
'required' => true
'required' => false
))
->add('user.email', TextType::class, array(
'label' => 'Email :',
......@@ -139,9 +146,12 @@ class AdherentAdmin extends AbstractAdmin
'choice_label' => function ($choice) {
return MoyenEnum::getTypeName($choice);
},
))
->add('user.cotisations.first.cotisationInfos.recu', CheckboxType::class, array('label' => 'Reçu'))
->end();
));
if ($this->tokenStorage->getToken()->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'])
......@@ -276,6 +286,14 @@ class AdherentAdmin extends AbstractAdmin
$collection->remove('delete');
}
public function getBatchActions()
{
$actions = parent::getBatchActions();
unset($actions['delete']);
return $actions;
}
/**
* {@inheritdoc}
*/
......
......@@ -3,6 +3,7 @@
namespace App\Admin;
use App\Entity\Geoloc;
use App\Form\Type\GeolocFormType;
use Sonata\AdminBundle\Admin\AbstractAdmin;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Datagrid\ListMapper;
......@@ -37,18 +38,29 @@ class ComptoirAdmin extends AbstractAdmin
}
$formMapper
->with('Comptoir', ['class' => 'col-md-8'])
->add('groupe', null, array('label' => 'Groupe local'))
->add('name', null, array('label' => 'Nom'))
->add('email', null, array('label' => 'Email'))
->add('tel', null, array('label' => 'Téléphone'))
->add('groupe', null, array(
'label' => 'Groupe local',
'required' => true,
))
->add('name', null, array(
'label' => 'Nom',
'required' => true,
))
->add('email', null, array(
'label' => 'Email',
'required' => true,
))
->add('tel', null, array(
'label' => 'Téléphone',
'required' => true,
))
->add('enabled', null, array('label' => 'Activé ?'))
->end()
->with('Geoloc', ['class' => 'col-md-4'])
->add('geoloc.adresse', null, array('label' => 'Adresse'))
->add('geoloc.cpostal', null, array('label' => 'Code postal'))
->add('geoloc.ville', null, array('label' => 'Ville'))
->add('geoloc.lat', null, array('label' => 'Latitude'))
->add('geoloc.lon', null, array('label' => 'Longitude'))
->add('geoloc', GeolocFormType::class, array(
'label' => false,
'required' => true
))
->end()
;
}
......
......@@ -65,7 +65,6 @@ class CotisationAdherentAdmin extends CotisationAdmin
protected function configureRoutes(RouteCollection $collection)
{
parent::configureRoutes($collection);
// $collection->add('create', );
}
/**
......
......@@ -2,6 +2,7 @@
namespace App\Admin;
use App\Entity\Adherent;
use App\Entity\Prestataire;
use App\Enum\MoyenEnum;
use Sonata\AdminBundle\Admin\AbstractAdmin;
......@@ -13,17 +14,23 @@ use Sonata\AdminBundle\Show\ShowMapper;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\DateType;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
class CotisationAdmin extends AbstractAdmin
{
protected $baseRouteName = 'cotisation';
protected $baseRoutePattern = 'cotisation';
protected $tokenStorage;
/**
* {@inheritdoc}
*/
protected function configureShowFields(ShowMapper $showMapper)
protected $translator;
protected $datagridValues = [
'_sort_order' => 'DESC',
'_sort_by' => 'createdAt',
];
public function setTokenStorage(TokenStorageInterface $tokenStorage)
{
$this->tokenStorage = $tokenStorage;
}
/**
......@@ -57,9 +64,12 @@ class CotisationAdmin extends AbstractAdmin
'choice_label' => function ($choice) {
return MoyenEnum::getTypeName($choice);
},
))
->add('cotisationInfos.recu', CheckboxType::class, array('label' => 'Reçu'))
->end()
));
if ($this->tokenStorage->getToken() != null && $this->tokenStorage->getToken()->getUser()->isGranted('ROLE_TRESORIER') ) {
$formMapper
->add('cotisationInfos.recu', CheckboxType::class, array('label' => 'Reçu'));
}
$formMapper->end()
->with('Date', ['class' => 'col-md-4'])
->add('cotisationInfos.debut', DateType::class, array(
'label' => 'Date de début',
......@@ -81,8 +91,10 @@ class CotisationAdmin extends AbstractAdmin
protected function configureRoutes(RouteCollection $collection)
{
// $collection->remove('edit');
$collection->remove('delete');
if ($this->tokenStorage->getToken() != null && !$this->tokenStorage->getToken()->getUser()->isGranted('ROLE_TRESORIER') ) {
$collection->clearExcept('list');
}
}
/**
......@@ -92,10 +104,11 @@ class CotisationAdmin extends AbstractAdmin
{
unset($this->listModes['mosaic']);
$listMapper
// ->addIdentifier('user')
->addIdentifier('operateur', null, array(
'label' => 'Opérateur',
'disabled' => true
))
->addIdentifier('cotisationInfos.annee')
->addIdentifier('cotisationInfos.debut')
->addIdentifier('cotisationInfos.fin')
->addIdentifier('montant')
->addIdentifier('moyen')
->addIdentifier('createdAt')
......
......@@ -65,7 +65,7 @@ class FaqAdmin extends AbstractAdmin
->addIdentifier('content', 'html', array('label' => 'Text'))
->addIdentifier('fichier', null, array('label' => 'Fichier'))
->addIdentifier('image', null, array('label' => 'Image'))
->addIdentifier('user', null, array('label' => 'Utilisateur'))
->addIdentifier('user', null, array('label' => 'Auteur'))
->addIdentifier('enabled', null, array('label' => 'Activé', 'datatype' => 'App.Document', 'template' => '@SonataAdmin/Boolean/editable_boolean.html.twig'))
;
}
......
......@@ -15,6 +15,12 @@ use Symfony\Component\Form\Extension\Core\Type\TextType;
class NewsAdmin extends AbstractAdmin
{
protected $translator;
protected $datagridValues = [
'_sort_order' => 'DESC',
'_sort_by' => 'createdAt',
];
/**
* {@inheritdoc}
*/
......@@ -66,4 +72,12 @@ class NewsAdmin extends AbstractAdmin
->addIdentifier('enabled', null, array('label' => 'Activé', 'datatype' => 'App.Document', 'template' => '@SonataAdmin/Boolean/editable_boolean.html.twig'))
;
}
public function getBatchActions()
{
$actions = parent::getBatchActions();
unset($actions['delete']);
return $actions;
}
}
......@@ -328,6 +328,14 @@ class PrestataireAdmin extends AbstractAdmin
$collection->remove('delete');
}
public function getBatchActions()
{
$actions = parent::getBatchActions();
unset($actions['delete']);
return $actions;
}
/**
* {@inheritdoc}
*/
......
<?php
namespace App\Admin;
use App\Admin\FluxAdmin;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
class TransactionAdmin extends FluxAdmin
{
protected $translator;
protected $datagridValues = [
'_sort_order' => 'DESC',
'_sort_by' => 'createdAt',
];
/**
* {@inheritdoc}
*/
public function createQuery($context = 'list')
{
$query = parent::createQuery($context);
$query->andWhere($query->getRootAliases()[0].".parenttype = :type")
->setParameter('type', 'transaction');
;
return $query;
}
/**
* {@inheritdoc}
*/
protected function configureDatagridFilters(DatagridMapper $datagridMapper): void
{
$datagridMapper
->add('type', null, array(
'label' => 'Type de transaction',
'advanced_filter' => false,
'show_filter' => true
))
->add('operateur', null, array(
'label' => 'Operateur',
'advanced_filter' => false,
'show_filter' => true
))
;
}
}
<?php
namespace App\Admin;
use App\Admin\FluxAdmin;
use App\Entity\User;
use Sonata\AdminBundle\Admin\AbstractAdmin;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Form\FormMapper;
use Sonata\AdminBundle\Form\Type\Filter\ChoiceType;
use Sonata\AdminBundle\Route\RouteCollection;
use Sonata\AdminBundle\Show\ShowMapper;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType as SChoiceType;
use Symfony\Component\Translation\TranslatorInterface;
class TransfertAdmin extends FluxAdmin
{
protected $translator;
protected $datagridValues = [
'_sort_order' => 'DESC',
'_sort_by' => 'createdAt',
];
/**
* {@inheritdoc}
*/
public function createQuery($context = 'list')
{
$query = parent::createQuery($context);
$query->andWhere($query->getRootAliases()[0].".parenttype = :type")
->setParameter('type', 'transfert');
;
return $query;
}
/**
* {@inheritdoc}
*/
protected function configureDatagridFilters(DatagridMapper $datagridMapper): void
{
$datagridMapper
->add('type', null, array(
'label' => 'Type de transfert',
'advanced_filter' => false,
'show_filter' => true
))
->add('operateur', null, array(
'label' => 'Operateur',
'advanced_filter' => false,
'show_filter' => true
))
;
}
}
......@@ -25,4 +25,12 @@ class GroupAdmin extends BaseGroupAdmin
$collection->clearExcept('list');
}
}
public function getBatchActions()
{
$actions = parent::getBatchActions();
unset($actions['delete']);
return $actions;
}
}
......@@ -32,6 +32,11 @@ use Sonata\UserBundle\Admin\Model\UserAdmin as BaseUserAdmin;
class UserAdmin extends BaseUserAdmin
{
public function configure()
{
parent::configure();
$this->setTemplate('edit', '@SonataAdmin/base_edit.html.twig');
}
/**
* {@inheritdoc}
*/
......@@ -180,12 +185,32 @@ class UserAdmin extends BaseUserAdmin
->add('enabled', null, ['required' => false])
->end();
if (!($subject->isGranted('ROLE_SUPER_ADMIN') || $subject->isGranted('ROLE_ADMIN_SIEGE'))) {
$hideOrShowGroupe = ['class' => 'hide'];
$hideOrShowComptoir = ['class' => 'hide'];
if ($subject->isGranted('ROLE_GESTION_GROUPE') && !empty($subject->getGestionnaireGroupe())) {
$hideOrShowGroupe = [];
}
if ($subject->isGranted('ROLE_COMPTOIR') && !empty($subject->getGestionnaireComptoir())) {
$hideOrShowComptoir = [];
}
$formMapper->with('Groups')
->add('groups', ModelType::class, [
'required' => false,
'expanded' => true,
'multiple' => true,
])
->add('gestionnaireGroupe', null, [
'required' => false,
'label' => 'Groupe local géré (obligatoire)',
'attr' => $hideOrShowGroupe,
'label_attr' => $hideOrShowGroupe,
])
->add('gestionnaireComptoir', null, [
'required' => false,
'label' => 'Comptoir géré (obligatoire)',
'attr' => $hideOrShowComptoir,
'label_attr' => $hideOrShowComptoir,
])
->end();
}
// ->with('Roles')
......@@ -202,4 +227,19 @@ class UserAdmin extends BaseUserAdmin
// ->end()
$formMapper->end();
}
public function getBatchActions()
{
$actions = parent::getBatchActions();
unset($actions['delete']);
return $actions;
}
public function getDashboardActions()
{
$actions = parent::getDashboardActions();
unset($actions['list']);
return $actions;
}
}
......@@ -30,29 +30,29 @@ use Symfony\Component\Routing\Annotation\Route;
*/
class FluxController extends AbstractController
{
/**
* @Route("/flux/transaction/adherent/prestataire", name="transactionAdherentPrestataire")
*/
public function transactionAdherentPrestataireAction(Request $request)
{
$em = $this->getDoctrine()->getManager();
// /**
// * @Route("/flux/transaction/adherent/prestataire", name="transactionAdherentPrestataire")
// */
// public function transactionAdherentPrestataireAction(Request $request)
// {
// $em = $this->getDoctrine()->getManager();
$entity = new TransactionAdherentPrestataire();
$entity->setOperateur($this->getUser());
$form = $this->createForm(TransactionAdherentPrestataireFormType::class, $entity);
$form->handleRequest($request);
// $entity = new TransactionAdherentPrestataire();
// $entity->setOperateur($this->getUser());
// $form = $this->createForm(TransactionAdherentPrestataireFormType::class, $entity);
// $form->handleRequest($request);
$data = $form->getData();
dump($data);
// $data = $form->getData();
// dump($data);
if ($form->isSubmitted() && $form->isValid()) {
//TODO : terminer fonction ;)
$em->persist($data);
$em->flush();
}
// if ($form->isSubmitted() && $form->isValid()) {
// //TODO : terminer fonction ;)
// $em->persist($data);
// $em->flush();
// }
return $this->render('flux/transactionAdherentPrestataire.html.twig', [
'form' => $form->createView(),
]);
}
// return $this->render('flux/transactionAdherentPrestataire.html.twig', [
// 'form' => $form->createView(),
// ]);
// }
}
......@@ -4,6 +4,7 @@ namespace App\Controller;
use App\Entity\Faq;
use App\Entity\User;
use App\Entity\Usergroup;
use App\Form\Type\TransactionAdherentPrestataireFormType;
use Doctrine\ORM\EntityManagerInterface;
use Geocoder\Provider\Nominatim\Nominatim;
......@@ -45,13 +46,67 @@ class IndexController extends AbstractController
}
/**
* @Route("/adherer", name="adherer")
*/
public function adhererAction(Request $request)
{
// @TODO : formulaire d'adhésion sans cotisation ? à valider après ?
// $adherent = new Adherent();
// $user = $this->um->createUser();
// $groupe = $this->em->getRepository(Usergroup::class)->findOneByName('Adherent');
// $user->setEnabled(true);
// $user->addGroup($groupe);
// $user->addRole('ROLE_ADHERENT');
// $adherent->setEcompte('0');
// $user->setAdherent($adherent);
// $adherent->setUser($user);
// if (count($adherent->getUser()->getCotisations()) <= 0) {
// $cotisation = new Cotisation();
// $cotisation->setDebut(new \DateTime());
// $cotisation->setFin(new \DateTime('+ 1 year'));
// $adherent->getUser()->addCotisation($cotisation);
// }
// if ($adherent->getGeoloc() == null) {
// $adherent->setGeoloc(new Geoloc());
// }
$form = $this->createForm(AdhererFormType::class);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
// $this->em->persist($adherent);
// $this->em->flush();
// $this->addFlash(
// 'success',
// 'Adhésion bien pris en compte, vous recevrez un email très bientôt !'
// );
}
return $this->render('adherent/adherer.html.twig', array(
'user' => $this->getUser(),
'form' => $form->createView()
));
}
/**
* @Route("/group/choice/{id}", name="group_choice")
*/
public function groupChoiceAction(Usergroup $group, Request $request)
{
$request->getSession()->remove('_choixGroup');
// On enregistre le rôle choisit en session
$request->getSession()->set('_groupId', $group->getId());
// @TODO : On redirige sur l'index (ou en fonction du rôle?)
return $this->redirectToRoute('index');
}
/**
* @Route("/charte", name="charte")
*/
public function charteAction()
{
return $this->render('charte.html.twig', array(
// 'user' => $this->getUser()
));
return $this->render('charte.html.twig');
}
/**
......@@ -80,8 +135,6 @@ class IndexController extends AbstractController
*/
public function contactAction()
{
return $this->render('contact.html.twig', array(
// 'user' => $this->getUser()
));
return $this->render('contact.html.twig');
}
}
......@@ -4,12 +4,17 @@ namespace App\Controller;
use App\Entity\Prestataire;
use App\Entity\Rubrique;
use App\Entity\TransactionPrestataireAdherent;
use App\Entity\TypePrestataire;
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\Request;
use Symfony\Component\Routing\Annotation\Route;
class PrestaController extends AbstractController
class PrestatairesController extends AbstractController
{
private $em;
......@@ -19,16 +24,6 @@ class PrestaController extends AbstractController
}
/**
* @Route("/prestataire/{slug}", name="show_prestataire")
*/
public function showPrestaAction(Prestataire $prestataire)
{
return $this->render('presta/show.html.twig', array(
'presta' => $prestataire
));
}
/**
* @Route("/prestataires/liste", name="liste_prestataire")
*/
public function listePrestaAction()
......@@ -89,4 +84,14 @@ class PrestaController extends AbstractController
'rubrique' => $rubrique
));
}
/**
* @Route("/prestataire/{slug}", name="show_prestataire")
*/
public function showPrestaAction(Prestataire $prestataire)
{
return $this->render('presta/show.html.twig', array(
'presta' => $prestataire
));
}
}
......@@ -5,15 +5,20 @@ namespace App\Controller;
use App\Entity\Adherent;
use App\Entity\Cotisation;
use App\Entity\Geoloc;
use App\Entity\TransactionAdherentPrestataire;
use App\Entity\Usergroup;
use App\Form\Type\AdherentInfosFormType;
use App\Form\Type\AdhererFormType;
use App\Form\Type\TransactionAdherentPrestataireFormType;
use Doctrine\ORM\EntityManagerInterface;
use FOS\UserBundle\Model\UserManagerInterface;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
class AdherentController extends AbstractController
class UserAdherentController extends AbstractController
{
protected $em;
protected $um;
......@@ -25,38 +30,54 @@ class AdherentController extends AbstractController
}
/**
* @Route("/adherer", name="adherer")
* @Route("/adherent/infos", name="adherent_infos")
* @IsGranted("ROLE_ADHERENT")
*/
public function adhererAction(Request $request)
public function adherentInfosAction(Request $request)
{
$adherent = new Adherent();
$user = $this->um->createUser();
$groupe = $this->em->getRepository(Usergroup::class)->findOneByName('Adherent');
$user->setEnabled(true);
$user->addGroup($groupe);
$user->addRole('ROLE_ADHERENT');
$adherent->setEcompte('0');
$user->setAdherent($adherent);
$adherent->setUser($user);
if (count($adherent->getUser()->getCotisations()) <= 0) {
$cotisation = new Cotisation();
$cotisation->setDebut(new \DateTime());
$cotisation->setFin(new \DateTime('+ 1 year'));
$adherent->getUser()->addCotisation($cotisation);
}
if ($adherent->getGeoloc() == null) {
$adherent->setGeoloc(new Geoloc());
}
$form = $this->createForm(AdhererFormType::class);
$form = $this->createForm(AdherentInfosFormType::class, $this->getUser()->getAdherent());
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
}
return $this->render('adherent/adherer.html.twig', array(
return $this->render('adherent/infos.html.twig', array(
'user' => $this->getUser(),
'form' => $form->createView()
));
}
/**
* @Route("/adherent/transaction/prestataire/", name="transactionAdherentPrestataire")
* @IsGranted("ROLE_ADHERENT")
*/
public function transactionAdherentPrestataireAction(Request $request)
{
$entity = new TransactionAdherentPrestataire();
$entity->setOperateur($this->getUser());
$form = $this->createForm(TransactionAdherentPrestataireFormType::class, $entity);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$data = $form->getData();
$this->em->persist($data);
$this->em->flush();
$this->addFlash(
'success',
'Transaction bien effectuée !'
);
$referer = $request->headers->get('referer');
if ($referer && !$request->isXmlHttpRequest()) {
return $this->redirect($referer);
} elseif (!$request->isXmlHttpRequest()) {
return new Response('', Response::HTTP_BAD_REQUEST);
}
}
return $this->render('flux/transaction.html.twig', [
'form' => $form->createView(),
'compte' => $this->getUser()->getAdherent()->getCompte(),
'title' => 'Transaction à un prestataire'
]);
}
}
<?php
namespace App\Controller;
use App\Entity\Adherent;
use App\Entity\Cotisation;
use App\Entity\Geoloc;
use App\Entity\TransactionAdherentPrestataire;
use App\Entity\Usergroup;
use App\Form\Type\AdherentInfosFormType;
use App\Form\Type\AdhererFormType;
use App\Form\Type\TransactionAdherentPrestataireFormType;
use Doctrine\ORM\EntityManagerInterface;
use FOS\UserBundle\Model\UserManagerInterface;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
class UserGestionnaireGroupeController extends AbstractController
{
protected $em;
protected $um;
public function __construct(EntityManagerInterface $em, UserManagerInterface $um)
{
$this->em = $em;
$this->um = $um;
}
/**
* @Route("/egroupe/infos", name="groupe_infos")
* @IsGranted("ROLE_ADHERENT")
*/
public function adherentInfosAction(Request $request)
{
// $form = $this->createForm(AdherentInfosFormType::class, $this->getUser()->getAdherent());
// $form->handleRequest($request);
// if ($form->isSubmitted() && $form->isValid()) {
// }
// return $this->render('adherent/infos.html.twig', array(
// 'user' => $this->getUser(),
// 'form' => $form->createView()
// ));
}
/**
* @Route("/adherent/transaction/prestataire/", name="transactionAdherentPrestataire")
* @IsGranted("ROLE_ADHERENT")
*/
public function transactionAdherentPrestataireAction(Request $request)
{
$entity = new TransactionAdherentPrestataire();
$entity->setOperateur($this->getUser());
$form = $this->createForm(TransactionAdherentPrestataireFormType::class, $entity);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$data = $form->getData();
$this->em->persist($data);
$this->em->flush();
$this->addFlash(
'success',
'Transaction bien effectuée !'
);
$referer = $request->headers->get('referer');
if ($referer && !$request->isXmlHttpRequest()) {
return $this->redirect($referer);
} elseif (!$request->isXmlHttpRequest()) {
return new Response('', Response::HTTP_BAD_REQUEST);
}
}
return $this->render('flux/transaction.html.twig', [
'form' => $form->createView(),
'compte' => $this->getUser()->getAdherent()->getCompte(),
'title' => 'Transaction à un prestataire'
]);
}
}
<?php
namespace App\Controller;
use App\Entity\Prestataire;
use App\Entity\Rubrique;
use App\Entity\TransactionPrestataireAdherent;
use App\Entity\TypePrestataire;
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\Request;
use Symfony\Component\Routing\Annotation\Route;
class UserPrestataireController extends AbstractController
{
private $em;
public function __construct(EntityManagerInterface $em)
{
$this->em = $em;
}
/**
* @Route("/prestataireinfos", name="prestataire_infos")
* @IsGranted("ROLE_PRESTATAIRE")
*/
public function prestataireInfosAction(Request $request)
{
$form = $this->createForm(PrestataireInfosFormType::class, $this->getUser()->getPrestataire());
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$this->em->persist($form->getData());
$this->em->flush();
}
return $this->render('presta/infos.html.twig', array(
'user' => $this->getUser(),
'form' => $form->createView()
));
}
/**
* @Route("/prestataire/transaction/{type}/", name="transactionPrestataireAdherent", defaults={"type": "adherent"})
* @Route("/prestataire/transaction/{type}/", name="transactionPrestatairePrestataire", defaults={"type": "prestataire"})
* @IsGranted("ROLE_PRESTATAIRE")
*/
public function transactionPrestataireAdherentAction($type, Request $request)
{
$entityName = 'App\Entity\TransactionPrestataire'.ucwords($type);
$entity = new $entityName();
$entity->setOperateur($this->getUser());
$form = $this->createForm('App\Form\Type\TransactionPrestataire'.ucwords($type).'FormType', $entity);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$data = $form->getData();
$this->em->persist($data);
$this->em->flush();
$this->addFlash(
'success',
'Transaction bien effectuée !'
);
$referer = $request->headers->get('referer');
if ($referer && !$request->isXmlHttpRequest()) {
return $this->redirect($referer);
} elseif (!$request->isXmlHttpRequest()) {
return new Response('', Response::HTTP_BAD_REQUEST);
}
}
return $this->render('flux/transaction.html.twig', [
'form' => $form->createView(),
'compte' => $this->getUser()->getPrestataire()->getCompte(),
'title' => 'Transaction à un '.$type
]);
}
}
......@@ -48,12 +48,24 @@ class Adherent
return $this->id;
}
public function getEcompte()
public function getEcompte(): float
{
return $this->ecompte;
}
public function setEcompte($ecompte): self
public function setEcompte(float $ecompte): self
{
$this->ecompte = $ecompte;
return $this;
}
public function getCompte(): float
{
return $this->ecompte;
}
public function setCompte(float $ecompte): self
{
$this->ecompte = $ecompte;
......
......@@ -51,13 +51,11 @@ class Comptoir
*/
private $groupe;
// *
// * @var User
// *
// * @ORM\ManyToOne(targetEntity="User", inversedBy="cotisations")
// * @ORM\JoinColumn(name="user_id", referencedColumnName="id", nullable=false)
// private $user;
/**
* @var ArrayCollection|User[]
* @ORM\OneToMany(targetEntity="User", mappedBy="gestionnaireComptoir", fetch="EXTRA_LAZY")
*/
private $gestionnaires;
/**
* @return int
......@@ -68,24 +66,6 @@ class Comptoir
}
/**
* @return User
*/
public function getUser(): User
{
return $this->user;
}
/**
* @param User $user
* @return Comptoir
*/
public function setUser(User $user)
{
$this->user = $user;
return $this;
}
/**
* Get media
* @return
*/
......@@ -122,6 +102,40 @@ class Comptoir
return $this->groupe;
}
/**
* @return User[]|ArrayCollection
*/
public function getGestionnaires()
{
return $this->gestionnaires;
}
/**
* @param User $gestionnaire
* @return $this
*/
public function addGestionnaire(User $gestionnaire)
{
if (!$this->gestionnaires->contains($gestionnaire)) {
$this->gestionnaires[] = $gestionnaire;
$gestionnaire->setGestionnaireComptoir($this);
}
return $this;
}
/**
* @param User $gestionnaire
* @return $this
*/
public function removeGestionnaire(User $gestionnaire)
{
if ($this->gestionnaires->contains($gestionnaire)) {
$this->gestionnaires->removeElement($gestionnaire);
$gestionnaire->setGestionnaireComptoir(null);
}
return $this;
}
public function __toString(): string
{
return (!empty($this->name)?$this->name:'Comptoir');
......
......@@ -4,13 +4,15 @@ namespace App\Entity;
use App\Entity\EntityTrait\EnablableEntityTrait;
use App\Enum\MoyenEnum;
use Doctrine\ORM\Event\LifecycleEventArgs;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Timestampable\Traits\TimestampableEntity;
use Symfony\Component\Validator\Constraints as Assert;
/**
* FLUX = TRANSFERT ou TRANSACTION
* @ORM\Entity
* @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_pre_adh" = "TransactionPrestataireAdherent", "tro_pre_pre" = "TransactionPrestatairePrestataire", "tre_cpt_adh" = "TransfertComptoirAdherent", "tre_cpt_grp" = "TransfertComptoirGroupe", "tre_cpt_pre" = "TransfertComptoirPrestataire", "tre_grp_cpt" = "TransfertGroupeComptoir", "tre_pre_cpt" = "TransfertPrestataireComptoir", "tre_sie_grp" = "TransfertSiegeGroupe"})
......@@ -31,6 +33,7 @@ abstract class Flux
/**
* @ORM\ManyToOne(targetEntity="User", inversedBy="flux", cascade={"all"})
* @ORM\JoinColumn(name="user_id", referencedColumnName="id", nullable=true)
* @Assert\NotBlank
*/
protected $operateur;
......@@ -39,6 +42,7 @@ abstract class Flux
* @var string
*
* @ORM\Column(name="type", type="string", length=200)
* @Assert\NotBlank
*/
protected $type;
......@@ -47,6 +51,7 @@ abstract class Flux
* @var string
*
* @ORM\Column(name="parenttype", type="string", length=20)
* @Assert\NotBlank
*/
protected $parenttype;
......@@ -54,6 +59,10 @@ abstract class Flux
* @var float
*
* @ORM\Column(name="montant", type="decimal", precision=7, scale=2)
* @Assert\Type("float")
* @Assert\GreaterThan(
* value = 0
* )
*/
protected $montant;
......@@ -61,6 +70,7 @@ abstract class Flux
* @var string
*
* @ORM\Column(name="moyen", type="string", length=100)
* @Assert\NotBlank
*/
private $moyen;
......@@ -68,6 +78,7 @@ abstract class Flux
* @var null|string
*
* @ORM\Column(name="reference", type="string", length=255, nullable=true)
* @Assert\NotBlank
*/
protected $reference;
......@@ -83,7 +94,7 @@ abstract class Flux
$this->type = $this->getType();
}
public function getId(): int
public function getId(): ?int
{
return $this->id;
}
......@@ -223,4 +234,27 @@ abstract class Flux
return $this;
}
/**
* @ORM\PostPersist
* @param LifecycleEventArgs $event
*/
public function postPersist(LifecycleEventArgs $event)
{
$flux = $event->getEntity();
$compteExp = $flux->getExpediteur()->getCompte() - $flux->getMontant();
if ($compteExp < 0) {
throw new \Exception("Transaction adherent => prestataire : Opération impossible !");
} else {
$em = $event->getEntityManager();
$flux->getExpediteur()->setCompte($compteExp);
$compteDest = $flux->getDestinataire()->getCompte() + $flux->getMontant();
$flux->getDestinataire()->setCompte($compteDest);
$em->persist($flux->getExpediteur());
$em->persist($flux->getDestinataire());
$em->flush();
}
}
}
......@@ -19,7 +19,8 @@ class Groupe
{
use NameSlugContentEntityTrait,
TimestampableEntity,
EnablableEntityTrait;
EnablableEntityTrait,
HasCompteEntity;
/**
* @var int
......@@ -59,6 +60,12 @@ class Groupe
*/
private $adherents;
/**
* @var ArrayCollection|User[]
* @ORM\OneToMany(targetEntity="User", mappedBy="gestionnaireGroupe", fetch="EXTRA_LAZY")
*/
private $gestionnaires;
public function __construct()
{
$this->comptoirs = new ArrayCollection();
......@@ -205,6 +212,41 @@ class Groupe
return $this;
}
/**
* @return User[]|ArrayCollection
*/
public function getGestionnaires()
{
return $this->gestionnaires;
}
/**
* @param User $gestionnaire
* @return $this
*/
public function addGestionnaire(User $gestionnaire)
{
if (!$this->gestionnaires->contains($gestionnaire)) {
$this->gestionnaires[] = $gestionnaire;
$gestionnaire->setGestionnaireGroupe($this);
}
return $this;
}
/**
* @param User $gestionnaire
* @return $this
*/
public function removeGestionnaire(User $gestionnaire)
{
if ($this->gestionnaires->contains($gestionnaire)) {
$this->gestionnaires->removeElement($gestionnaire);
$gestionnaire->setGestionnaireGroupe(null);
}
return $this;
}
public function getComptoirsCount()
{
return $this->getComptoirs()->count();
......
......@@ -2,25 +2,30 @@
namespace App\Entity;
use Doctrine\ORM\Event\LifecycleEventArgs;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
/**
* TRANSACTION
* - ADHERENTS => PRESTATAIRES (Paiement numérique)
*
* @ORM\Entity
* @ORM\HasLifecycleCallbacks
*/
class TransactionAdherentPrestataire extends Transaction
{
/**
* @ORM\OneToOne(targetEntity="Adherent")
* @ORM\JoinColumn(name="adherent_id", referencedColumnName="id", nullable=true)
* @Assert\NotBlank
*/
protected $expediteur;
/**
* @ORM\OneToOne(targetEntity="Prestataire")
* @ORM\JoinColumn(name="prestataire_id", referencedColumnName="id", nullable=true)
* @Assert\NotBlank
*/
protected $destinataire;
......
......@@ -3,6 +3,7 @@
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
/**
* TRANSACTION
......@@ -15,12 +16,14 @@ class TransactionPrestataireAdherent extends Transaction
/**
* @ORM\OneToOne(targetEntity="Prestataire")
* @ORM\JoinColumn(name="prestataire_id", referencedColumnName="id", nullable=true)
* @Assert\NotBlank
*/
protected $expediteur;
/**
* @ORM\OneToOne(targetEntity="Adherent")
* @ORM\JoinColumn(name="adherent_id", referencedColumnName="id", nullable=true)
* @Assert\NotBlank
*/
protected $destinataire;
......
......@@ -3,6 +3,7 @@
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
/**
* TRANSACTION
......@@ -15,12 +16,14 @@ class TransactionPrestatairePrestataire extends Transaction
/**
* @ORM\OneToOne(targetEntity="Prestataire")
* @ORM\JoinColumn(name="prestataire_id", referencedColumnName="id", nullable=true)
* @Assert\NotBlank
*/
protected $expediteur;
/**
* @ORM\OneToOne(targetEntity="Prestataire")
* @ORM\JoinColumn(name="prestataire_dest_id", referencedColumnName="id", nullable=true)
* @Assert\NotBlank
*/
protected $destinataire;
......
......@@ -79,6 +79,16 @@ class User extends BaseUser
private $emailTokens;
/**
* @ORM\ManyToOne(targetEntity="Groupe", inversedBy="gestionnaires", cascade={"all"})
*/
private $gestionnaireGroupe;
/**
* @ORM\ManyToOne(targetEntity="Comptoir", inversedBy="gestionnaires", cascade={"all"})
*/
private $gestionnaireComptoir;
/**
* @ORM\Column(name="apiKey", type="string", length=255, nullable=true)
*/
private $apiKey;
......@@ -297,13 +307,49 @@ class User extends BaseUser
*/
public function removeFlux(Flux $flux)
{
throw new \LogicException('User::removeFlux : This code should not be reached!');
throw new \LogicException('User::removeFlux : Ce code ne devrait jamais être atteint !');
// if ($this->flux->contains($flux)) {
// $this->flux->removeElement($flux);
// }
return $this;
}
/**
* @param null|Groupe $gestionnaireGroupe
* @return $this
*/
public function setGestionnaireGroupe(?Groupe $gestionnaireGroupe)
{
$this->gestionnaireGroupe = $gestionnaireGroupe;
return $this;
}
/**
* @return null|Groupe
*/
public function getGestionnaireGroupe(): ?Groupe
{
return $this->gestionnaireGroupe;
}
/**
* @param null|Comptoir $gestionnaireComptoir
* @return $this
*/
public function setGestionnaireComptoir(?Comptoir $gestionnaireComptoir)
{
$this->gestionnaireComptoir = $gestionnaireComptoir;
return $this;
}
/**
* @return null|Comptoir
*/
public function getGestionnaireComptoir(): ?Comptoir
{
return $this->gestionnaireComptoir;
}
public function createEmailToken()
{
$token = new EmailToken();
......@@ -337,4 +383,12 @@ class User extends BaseUser
}
}
}
public function getName()
{
if (empty($this->getFullname())) {
return $this->__toString();
}
return $this->getFullname();
}
}
<?php
namespace App\EventListener;
use App\Entity\Adherent;
use App\Entity\EntityTrait\GeolocEntityTrait;
use App\Entity\Prestataire;
use App\Entity\User;
use Doctrine\ORM\Event\PreUpdateEventArgs;
use Geocoder\Provider\Nominatim\Nominatim;
use Geocoder\Query\GeocodeQuery;
class UserListener
{
public function preUpdate(PreUpdateEventArgs $eventArgs)
{
$entity = $eventArgs->getEntity();
if (!($entity instanceof User) && !empty($user->getUsername())) {
return;
}
// GEOCODING ADDRESS :
$httpClient = new \Http\Adapter\Guzzle6\Client();
$provider = Nominatim::withOpenStreetMapServer($httpClient, 'test');
$geocoder = new \Geocoder\StatefulGeocoder($provider, 'fr');
$fullAddress = $entity->getAdresse().' '.$entity->getCpostal().' '.$entity->getVille();
// Query geocoding from complete addresse
$result = $geocoder->geocodeQuery(GeocodeQuery::create($fullAddress));
if (count($result) > 0) {
$coords = $result->first()->getCoordinates();
$entity->setLat($coords->getLatitude());
$entity->setLon($coords->getLongitude());
}
}
}
<?php
namespace App\Form\Type;
use App\Entity\Adherent;
use App\Entity\Groupe;
use App\Entity\Prestataire;
use App\Entity\User;
use App\Enum\MoyenEnum;
use App\Form\Type\CotisationFormType;
use App\Form\Type\GeolocFormType;
use App\Form\Type\RegistrationFormType;
use Doctrine\DBAL\Types\FloatType;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
use Symfony\Component\DependencyInjection\ContainerInterface;
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\SubmitType;
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\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
class AdherentInfosFormType extends AbstractType
{
protected $container;
protected $em;
protected $tk;
public function __construct(ContainerInterface $container, EntityManagerInterface $em, TokenStorageInterface $tk)
{
$this->container = $container;
$this->em = $em;
$this->tk = $tk;
}
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('user', RegistrationFormType::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',
))
->add('geoloc', GeolocFormType::class, array(
'label' => 'ADRESSE',
'required' => false
))
->add('save', SubmitType::class, ['label' => "Modifier"])
;
}
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'data_class' => Adherent::class,
'cascade_validation' => true
]);
}
public function getBlockPrefix()
{
return 'formAdherentInfos';
}
}
......@@ -2,14 +2,9 @@
namespace App\Form\Type;
use App\Entity\User;
use App\Enum\MoyenEnum;
use Doctrine\DBAL\Types\FloatType;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityRepository;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use App\Entity\Cotisation;
use App\Form\Type\CotisationInfosFormType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
......@@ -23,10 +18,25 @@ class CotisationFormType extends FluxFormType
->add('type', HiddenType::class, array(
'data' => 'cotisation',
'data_class' => null
))
));
// ->add('cotisationInfos', CotisationInfosFormType::class, array(
// 'label' => 'Infos'
// ))
;
}
/**
* {@inheritdoc}
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
'data_class' => Cotisation::class,
'cascade_validation' => true
));
}
public function getParent()
{
return FluxFormType::class;
......
<?php
namespace App\Form\Type;
use App\Entity\CotisationInfos;
use App\Entity\User;
use App\Form\Type\CotisationFormType;
use Doctrine\DBAL\Types\FloatType;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityRepository;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\DateType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
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\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
class CotisationInfosFormType extends FluxFormType
{
protected $tokenStorage;
public function __construct(TokenStorageInterface $tokenStorage)
{
$this->tokenStorage = $tokenStorage;
}
public function buildForm(FormBuilderInterface $builder, array $options)
{
$now = new \DateTime();
$builder
->add('annee', TextType::class, array(
'label' => 'Année',
'data' => $now->format('Y')
))
->add('debut', DateType::class, array(
'label' => 'Date de début',
'data' => new \DateTime(),
'widget' => 'single_text',
'html5' => false,
'attr' => ['class' => 'js-datepicker'],
))
->add('fin', DateType::class, array(
'label' => 'Date de fin',
'data' => new \DateTime('+ 1 year'),
'widget' => 'single_text',
'html5' => false,
'attr' => ['class' => 'js-datepicker'],
));
if ($this->tokenStorage->getToken() != null && $this->tokenStorage->getToken()->getUser()->isGranted('ROLE_TRESORIER') ) {
$builder
->add('recu', CheckboxType::class, array('label' => 'Reçu'));
}
;
}
/**
* {@inheritdoc}
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
'data_class' => CotisationInfos::class,
'cascade_validation' => true
));
}
public function getBlockPrefix()
{
return 'formCotisationInfos';
}
}
......@@ -2,6 +2,7 @@
namespace App\Form\Type;
use App\Entity\Flux;
use App\Entity\User;
use App\Enum\MoyenEnum;
use Doctrine\ORM\EntityManagerInterface;
......@@ -10,8 +11,10 @@ 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\MoneyType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormError;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\OptionsResolver\OptionsResolver;
......@@ -52,9 +55,29 @@ class FluxFormType extends AbstractType
'label' => 'Reference :',
'required' => true
))
->add('save', SubmitType::class, ['label' => "Valider la transaction"])
->addEventListener(FormEvents::POST_SUBMIT, function (FormEvent $event) use ($builder) {
$transaction = $event->getData();
if ($event->getForm()->isValid() && (!$transaction || null === $transaction->getId())) {
if ($transaction->getExpediteur()->getCompte() < $transaction->getMontant()) {
$event->getForm()->get('montant')->addError(new FormError("Montant supérieur à votre solde !"));
}
}
})
;
}
/**
* {@inheritdoc}
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
'data_class' => Flux::class,
'cascade_validation' => true
));
}
public function getBlockPrefix()
{
return 'formFlux';
......
......@@ -14,27 +14,45 @@ class GeolocFormType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$geoloc = null;
if (!empty($options['data'])) {
$geoloc = $options['data'];
}
$builder
->add('adresse', TextType::class, array(
'label' => 'Addresse :',
'required' => false
'required' => $options['required']
))
->add('cpostal', TextType::class, array(
'label' => 'Code postal :',
'required' => false
'required' => $options['required']
))
->add('ville', TextType::class, array(
'label' => 'Ville :',
'required' => false
'required' => $options['required']
))
;
if ($options['with_latlon'] === true || (!empty($geoloc) && (!empty($geoloc->getLat()) || !empty($geoloc->getLon())))) {
$builder
->add('lat', null, array(
'label' => 'Latitude :',
'required' => false
))
->add('lon', null, array(
'label' => 'Longitude :',
'required' => false
))
;
}
}
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'data_class' => Geoloc::class
'data_class' => Geoloc::class,
'with_latlon' => false
]);
$resolver->setRequired(['with_latlon']);
}
public function getBlockPrefix()
......
<?php
namespace App\Form\Type;
use App\Entity\Adherent;
use App\Entity\Groupe;
use App\Entity\Prestataire;
use App\Entity\User;
use App\Enum\MoyenEnum;
use App\Form\Type\CotisationFormType;
use App\Form\Type\GeolocFormType;
use App\Form\Type\RegistrationFormType;
use Doctrine\DBAL\Types\FloatType;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
use Symfony\Component\DependencyInjection\ContainerInterface;
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\SubmitType;
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\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
class PrestataireInfosFormType extends AbstractType
{
protected $container;
protected $em;
protected $tk;
public function __construct(ContainerInterface $container, EntityManagerInterface $em, TokenStorageInterface $tk)
{
$this->container = $container;
$this->em = $em;
$this->tk = $tk;
}
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('raison', TextType::class, array(
'label' => 'Raison :',
'required' => true
))
->add('statut', TextType::class, array(
'label' => 'Statut :',
'required' => false
))
->add('siret', TextType::class, array(
'label' => 'SIRET :',
'required' => true
))
->add('iban', TextType::class, array(
'label' => 'IBAN :',
'required' => true
))
->add('responsable', TextType::class, array(
'label' => 'Responsable :',
'required' => false
))
->add('metier', TextType::class, array(
'label' => 'Métier responsable :',
'required' => true
))
->add('user', RegistrationFormType::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',
))
->add('geoloc', GeolocFormType::class, array(
'label' => 'ADRESSE',
'required' => false
))
->add('save', SubmitType::class, ['label' => "Modifier"])
->add('save2', SubmitType::class, ['label' => "Modifier"])
;
}
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'data_class' => Prestataire::class,
'cascade_validation' => true
]);
}
public function getBlockPrefix()
{
return 'formPrestataireInfos';
}
}
......@@ -4,9 +4,11 @@ namespace App\Form\Type;
use App\Entity\User;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
......@@ -19,12 +21,19 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
class RegistrationFormType extends AbstractType
{
protected $em;
public function __construct(EntityManagerInterface $em)
{
$this->em = $em;
}
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->remove('username')
->add('email', EmailType::class, array(
'label' => 'form.email',
'label' => 'Courriel',
'required' => true,
'translation_domain' => 'FOSUserBundle'
))
......@@ -49,10 +58,13 @@ class RegistrationFormType extends AbstractType
'invalid_message' => 'fos_user.password.mismatch',
))
->addEventListener(FormEvents::POST_SUBMIT, function (FormEvent $event) use ($builder) {
$repo = $this->em->getRepository(User::class);
$emailExist = $repo->findBy(array('email' => $event->getForm()->get('email')->getData()));
if (count($emailExist) > 0) {
$event->getForm()->get('email')->addError(new FormError('form.error.email_used'));
$user = $event->getData();
if (!$user || null === $user->getId()) {
$repo = $this->em->getRepository(User::class);
$emailExist = $repo->findBy(array('email' => $event->getForm()->get('email')->getData()));
if (count($emailExist) > 0) {
$event->getForm()->get('email')->addError(new FormError('Courriel déjà utilisé, veuillez vous connecter ou utiliser un autre courriel!'));
}
}
})
;
......
......@@ -4,18 +4,10 @@ namespace App\Form\Type;
use App\Entity\Adherent;
use App\Entity\Prestataire;
use App\Entity\User;
use App\Enum\MoyenEnum;
use Doctrine\DBAL\Types\FloatType;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityRepository;
use App\Entity\TransactionAdherentPrestataire;
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\FormBuilderInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\OptionsResolver\OptionsResolver;
class TransactionAdherentPrestataireFormType extends TransactionFormType
......@@ -24,7 +16,7 @@ class TransactionAdherentPrestataireFormType extends TransactionFormType
{
$builder
->add('expediteur', HiddenType::class, array(
'data' => 1,//TODO : $this->tk->getToken()->getUser()->getAdherent()->getId(),
'data' => $this->tk->getToken()->getUser()->getAdherent()->getId(),
'data_class' => null,
'entity_class' => Adherent::class,
'em' => $this->em
......@@ -45,7 +37,7 @@ class TransactionAdherentPrestataireFormType extends TransactionFormType
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
'class' => '\App\Entity\TransactionAdherentPrestataire',
'class' => TransactionAdherentPrestataire::class,
));
}
......
......@@ -2,18 +2,9 @@
namespace App\Form\Type;
use App\Entity\User;
use App\Enum\MoyenEnum;
use Doctrine\DBAL\Types\FloatType;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityRepository;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use App\Form\Type\FluxFormType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
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;
class TransactionFormType extends FluxFormType
{
......
<?php
namespace App\Form\Type;
use App\Entity\Adherent;
use App\Entity\Prestataire;
use App\Entity\TransactionPrestataireAdherent;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class TransactionPrestataireAdherentFormType extends TransactionFormType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('expediteur', HiddenType::class, array(
'data' => $this->tk->getToken()->getUser()->getPrestataire()->getId(),
'data_class' => null,
'entity_class' => Prestataire::class,
'em' => $this->em
))
->add('destinataire', EntityType::class, array(
'class' => Adherent::class,
'choices' => $this->em->getRepository(Adherent::class)->findBy(array('enabled' => true)),
'placeholder' => 'Adherent',
'required' => true,
'label' => 'Adherent :',
))
;
}
/**
* {@inheritdoc}
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
'class' => TransactionPrestataireAdherent::class,
));
}
public function getParent()
{
return TransactionFormType::class;
}
public function getBlockPrefix()
{
return 'formTransactionPrestataireAdherent';
}
}
<?php
namespace App\Form\Type;
use App\Entity\Prestataire;
use App\Entity\TransactionPrestatairePrestataire;
use App\Entity\User;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class TransactionPrestatairePrestataireFormType extends TransactionFormType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('expediteur', HiddenType::class, array(
'data' => $this->tk->getToken()->getUser()->getPrestataire()->getId(),
'data_class' => null,
'entity_class' => Prestataire::class,
'em' => $this->em
))
->add('destinataire', EntityType::class, array(
'class' => Prestataire::class,
'choices' => $this->em->getRepository(Prestataire::class)->findBy(array('enabled' => true)),
'placeholder' => 'Prestataire',
'required' => true,
'label' => 'Prestataire :',
))
;
}
/**
* {@inheritdoc}
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
'class' => TransactionPrestatairePrestataire::class,
));
}
public function getParent()
{
return TransactionFormType::class;
}
public function getBlockPrefix()
{
return 'formTransactionPrestatairePrestataire';
}
}
<?php
namespace App\Form\Type;
use App\Entity\Adherent;
use App\Entity\Comptoir;
use App\Entity\TransfertComptoirAdherent;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class TransfertComptoirAdherentFormType extends TransfertFormType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('expediteur', HiddenType::class, array(
'data' => $this->tk->getToken()->getUser()->getGestionnaireComptoir()->getId(),
'data_class' => null,
'entity_class' => Comptoir::class,
'em' => $this->em
))
->add('destinataire', EntityType::class, array(
'class' => Adherent::class,
'choices' => $this->em->getRepository(Adherent::class)->findBy(array('enabled' => true)),
'placeholder' => 'Adherent',
'required' => true,
'label' => 'Adherent :',
))
;
}
/**
* {@inheritdoc}
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
'class' => TransfertComptoirAdherent::class,
));
}
public function getParent()
{
return TransfertFormType::class;
}
public function getBlockPrefix()
{
return 'formTransfertComptoirAdherent';
}
}
<?php
namespace App\Form\Type;
use App\Entity\Comptoir;
use App\Entity\Groupe;
use App\Entity\TransfertComptoirGroupe;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class TransfertComptoirGroupeFormType extends TransfertFormType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('expediteur', HiddenType::class, array(
'data' => $this->tk->getToken()->getUser()->getGestionnaireComptoir()->getId(),
'data_class' => null,
'entity_class' => Comptoir::class,
'em' => $this->em
))
->add('destinataire', EntityType::class, array(
'class' => Groupe::class,
'choices' => $this->em->getRepository(Groupe::class)->findBy(array('enabled' => true)),
'placeholder' => 'Groupe',
'required' => true,
'label' => 'Groupe :',
))
;
}
/**
* {@inheritdoc}
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
'class' => TransfertComptoirGroupe::class,
));
}
public function getParent()
{
return TransfertFormType::class;
}
public function getBlockPrefix()
{
return 'formTransfertComptoirGroupe';
}
}
<?php
namespace App\Form\Type;
use App\Entity\Comptoir;
use App\Entity\Prestataire;
use App\Entity\TransfertComptoirPrestataire;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class TransfertComptoirPrestataireFormType extends TransfertFormType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('expediteur', HiddenType::class, array(
'data' => $this->tk->getToken()->getUser()->getGestionnaireComptoir()->getId(),
'data_class' => null,
'entity_class' => Comptoir::class,
'em' => $this->em
))
->add('destinataire', EntityType::class, array(
'class' => Prestataire::class,
'choices' => $this->em->getRepository(Prestataire::class)->findBy(array('enabled' => true)),
'placeholder' => 'Prestataire',
'required' => true,
'label' => 'Prestataire :',
))
;
}
/**
* {@inheritdoc}
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
'class' => TransfertComptoirPrestataire::class,
));
}
public function getParent()
{
return TransfertFormType::class;
}
public function getBlockPrefix()
{
return 'formTransfertComptoirPrestataire';
}
}
......@@ -2,18 +2,9 @@
namespace App\Form\Type;
use App\Entity\User;
use App\Enum\MoyenEnum;
use Doctrine\DBAL\Types\FloatType;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityRepository;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use App\Form\Type\FluxFormType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
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;
class TransfertFormType extends FluxFormType
{
......
<?php
namespace App\Form\Type;
use App\Entity\Comptoir;
use App\Entity\Groupe;
use App\Entity\TransfertComptoirPrestataire;
use App\Entity\TransfertGroupeComptoir;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class TransfertGroupeComptoirFormType extends TransfertFormType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('expediteur', HiddenType::class, array(
'data' => $this->tk->getToken()->getUser()->getGestionnaireGroupe()->getId(),
'data_class' => null,
'entity_class' => Groupe::class,
'em' => $this->em
))
->add('destinataire', EntityType::class, array(
'class' => Comptoir::class,
'choices' => $this->em->getRepository(Comptoir::class)->findBy(array('enabled' => true)),
'placeholder' => 'Comptoir',
'required' => true,
'label' => 'Comptoir :',
))
;
}
/**
* {@inheritdoc}
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
'class' => TransfertGroupeComptoir::class,
));
}
public function getParent()
{
return TransfertFormType::class;
}
public function getBlockPrefix()
{
return 'formTransfertGroupeComptoir';
}
}
<?php
namespace App\Form\Type;
use App\Entity\Comptoir;
use App\Entity\Groupe;
use App\Entity\TransfertPrestataireComptoir;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class TransfertPrestataireComptoirFormType extends TransfertFormType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('expediteur', HiddenType::class, array(
'data' => $this->tk->getToken()->getUser()->getPrestataire()->getId(),
'data_class' => null,
'entity_class' => Prestataire::class,
'em' => $this->em
))
->add('destinataire', EntityType::class, array(
'class' => Comptoir::class,
'choices' => $this->em->getRepository(Comptoir::class)->findBy(array('enabled' => true)),
'placeholder' => 'Comptoir',
'required' => true,
'label' => 'Comptoir :',
))
;
}
/**
* {@inheritdoc}
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
'class' => TransfertPrestataireComptoir::class,
));
}
public function getParent()
{
return TransfertFormType::class;
}
public function getBlockPrefix()
{
return 'formTransfertPrestataireComptoir';
}
}
<?php
namespace App\Form\Type;
use App\Entity\Comptoir;
use App\Entity\Groupe;
use App\Entity\Siege;
use App\Entity\TransfertSiegeGroupe;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class TransfertSiegeGroupeFormType extends TransfertFormType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('expediteur', HiddenType::class, array(
'data' => 1,
'data_class' => null,
'entity_class' => Siege::class,
'em' => $this->em
))
->add('destinataire', EntityType::class, array(
'class' => Groupe::class,
'choices' => $this->em->getRepository(Groupe::class)->findBy(array('enabled' => true)),
'placeholder' => 'Groupe',
'required' => true,
'label' => 'Groupe :',
))
;
}
/**
* {@inheritdoc}
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
'class' => TransfertSiegeGroupe::class,
));
}
public function getParent()
{
return TransfertFormType::class;
}
public function getBlockPrefix()
{
return 'formTransfertSiegeGroupe';
}
}
......@@ -53,6 +53,9 @@ class AfterLoginRedirection implements AuthenticationSuccessHandlerInterface
$redirection = new RedirectResponse($this->router->generate('sonata_admin_dashboard'));
}
} else {
if (!$request->getSession()->has('_groupId') && count($token->getUser()->getGroups()) > 1) {
$request->getSession()->set('_choixGroup', 'true');
}
$redirection = new RedirectResponse($this->router->generate('index'));
}
......
<?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 Version20190218154011 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 user ADD gestionnaire_groupe_id INT DEFAULT NULL, ADD gestionnaire_comptoir_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE user ADD CONSTRAINT FK_8D93D64929D29E4D FOREIGN KEY (gestionnaire_groupe_id) REFERENCES groupe (id)');
$this->addSql('ALTER TABLE user ADD CONSTRAINT FK_8D93D6493D550E0D FOREIGN KEY (gestionnaire_comptoir_id) REFERENCES comptoir (id)');
$this->addSql('CREATE INDEX IDX_8D93D64929D29E4D ON user (gestionnaire_groupe_id)');
$this->addSql('CREATE INDEX IDX_8D93D6493D550E0D ON user (gestionnaire_comptoir_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 user DROP FOREIGN KEY FK_8D93D64929D29E4D');
$this->addSql('ALTER TABLE user DROP FOREIGN KEY FK_8D93D6493D550E0D');
$this->addSql('DROP INDEX IDX_8D93D64929D29E4D ON user');
$this->addSql('DROP INDEX IDX_8D93D6493D550E0D ON user');
$this->addSql('ALTER TABLE user DROP gestionnaire_groupe_id, DROP gestionnaire_comptoir_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 Version20190219214013 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 groupe ADD compte NUMERIC(7, 2) NOT NULL');
}
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 groupe DROP compte');
}
}
<?php
namespace App\Repository;
use App\Entity\Flux;
use App\Entity\Prestataire;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Symfony\Bridge\Doctrine\RegistryInterface;
/**
* @method Flux|null find($id, $lockMode = null, $lockVersion = null)
* @method Flux|null findOneBy(array $criteria, array $orderBy = null)
* @method Flux[] findAll()
* @method Flux[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class FluxRepository extends ServiceEntityRepository
{
public function __construct(RegistryInterface $registry)
{
parent::__construct($registry, Flux::class);
}
/**
* @param Prestataire $presta [description]
* @return Query Returns a query fo finding an array of Flux
*/
public function getQueryByPrestataire(Prestataire $presta)
{
$em = $this->getEntityManager();
$connection = $em->getConnection();
$statement = $connection->prepare("SELECT f.id FROM flux f WHERE f.prestataire_id = :id OR f.prestataire_dest_id = :id");
$statement->bindValue('id', $presta->getId());
$statement->execute();
$results = $statement->fetchAll();
$qb = $this->createQueryBuilder('f');
return $qb
->where($qb->expr()->in('f.id', ':ids'))
->setParameter('ids', $results)
->getQuery()
;
}
/**
* @param Adherent $adherent [description]
* @return Query Returns a query fo finding an array of Flux
*/
public function getQueryByAdherent(Adherent $adherent)
{
$em = $this->getEntityManager();
$connection = $em->getConnection();
$statement = $connection->prepare("SELECT f.id FROM flux f WHERE f.adherent_id = :id");
$statement->bindValue('id', $adherent->getId());
$statement->execute();
$results = $statement->fetchAll();
$qb = $this->createQueryBuilder('f');
return $qb
->where($qb->expr()->in('f.id', ':ids'))
->setParameter('ids', $results)
->getQuery()
;
}
}
......@@ -2,8 +2,12 @@
namespace App\Twig;
use App\Entity\Flux;
use App\Entity\Groupe;
use App\Entity\Rubrique;
use App\Entity\User;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Security\Core\User\UserInterface;
use Twig\Extension\AbstractExtension;
use Twig\TwigFilter;
use Twig\TwigFunction;
......@@ -12,10 +16,12 @@ use Twig\TwigTest;
class AppExtension extends AbstractExtension
{
public $container;
public $paginator;
public function __construct($container)
public function __construct($container, $paginator)
{
$this->container = $container;
$this->paginator = $paginator;
}
public function getFunctions()
......@@ -23,6 +29,7 @@ class AppExtension extends AbstractExtension
return [
new \Twig_SimpleFunction('getAllRubriques', array($this, 'getAllRubriques')),
new \Twig_SimpleFunction('getAllGroupes', array($this, 'getAllGroupes')),
new \Twig_SimpleFunction('getAllFlux', array($this, 'getAllFlux')),
new \Twig_SimpleFunction('parameter', function($name)
{
return $this->container->getParameter($name);
......@@ -46,6 +53,26 @@ class AppExtension extends AbstractExtension
];
}
public function getAllFlux(User $user, Request $request)
{
$query = null;
if ($user->getPrestataire() != null) {
$query = $this->container->get('doctrine')->getRepository(Flux::class)->getQueryByPrestataire($user->getPrestataire());
} else if ($user->getAdherent() != null) {
$query = $this->container->get('doctrine')->getRepository(Flux::class)->getQueryByAdherent($user->getAdherent());
}
if ($query != null) {
$pagination = $this->paginator->paginate(
$query, /* query NOT result */
$request->query->getInt('page', 1)/*page number*/,
10/*limit per page*/
);
return $pagination;
}
return null;
}
public function getAllGroupes()
{
return $this->container->get('doctrine')->getRepository(Groupe::class)->findBy(array('enabled' => true));
......
{% extends 'common/layout.html.twig' %}
{% block content %}
<div class='container adherent_infos'>
<div class="row">
<div class="col-6">
<div class='infos mt-4'>
<h4>Modifier mes informations :</h4>
<p>
{{form_start(form)}}
{{ form_row(form.user) }}
{{ form_row(form.groupe) }}
{{ form_row(form.geoloc) }}
{{ form_row(form.save) }}
{{form_end(form)}}
</p>
</div>
</div>
<div class="col-6">
{% if app.user.adherent is not null and app.user.adherent.ecompte >= 0 %}
<div class='ecompte mt-4'>
<h4>Mon ecompte :</h4>
<ul class='list-group'>
<li class="list-group-item">{{(app.user.adherent.ecompte)|number_format(2, '.', ',')}}</li>
</ul>
</div>
{% endif %}
{% if app.user.cotisations|length > 0 %}
<div class='cotisations mt-4'>
<h4>Mes cotisations :</h4>
<ul class='list-group'>
{% for cotisation in app.user.cotisations %}
<li class="list-group-item">{{cotisation.annee|upper}} : {{cotisation.montant}}&euro; (payée le {{cotisation.createdAt|date('d-m-Y')}})</li>
{% endfor %}
</ul>
</div>
{% endif %}
{% if app.user.flux|length > 0 %}
<div class='flux mt-4'>
<h4>Mes transactions :</h4>
<ul class='list-group'>
{% for flux in app.user.flux %}
<li class="list-group-item">{{flux.parenttype|capitalize}} à {{flux.destinataire}} {{flux.montant}}&euro; (payée le {{flux.createdAt|date('d-m-Y')}})</li>
{% endfor %}
</ul>
</div>
{% endif %}
</div>
</div>
</div>
{% endblock %}
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% extends sonata_block.templates.block_base %}
{% block block %}
{% for group in groups %}
{% set display = (group.roles is empty or is_granted(sonata_admin.adminPool.getOption('role_super_admin')) ) %}
{% for role in group.roles if not display %}
{% set display = is_granted(role)%}
{% endfor %}
{% if display %}
<div class="box">
<div class="box-header">
<h3 class="box-title">{{ group.label|trans({}, group.label_catalogue) }}</h3>
</div>
<div class="box-body">
<table class="table table-hover">
<tbody>
{% for admin in group.items %}
{% if admin.dashboardActions|length > 0 %}
<tr>
<td class="sonata-ba-list-label" width="40%">
{{ admin.label|trans({}, admin.translationdomain) }}
</td>
<td>
<div class="btn-group">
{% for action in admin.dashboardActions %}
{% include action.template|default('@SonataAdmin/CRUD/dashboard__action.html.twig') with {'action': action} %}
{% endfor %}
</div>
</td>
</tr>
{% endif %}
{% endfor %}
</tbody>
</table>
</div>
</div>
{% endif %}
{% endfor %}
{% endblock %}
{% extends 'SonataAdminBundle:CRUD:base_edit.html.twig' %}
{% block javascripts %}
{{ parent() }}
{% if app.request.get('_route') == 'admin_app_user_edit' %}
<script type="text/javascript">
$(function () {
$("input[name='{{ admin.uniqid }}[groups][]']").each(function () {
$(this).on('ifChecked', function(event){
if ($.trim($(this).closest('label').text()) == 'Gestionnaire de Groupe') {
console.log('Gestionnaire de Groupe');
$('#sonata-ba-field-container-{{ admin.uniqid }}_gestionnaireGroupe label.hide').removeClass('hide');
$('#sonata-ba-field-container-{{ admin.uniqid }}_gestionnaireGroupe div.select2-container').removeClass('hide');
} else if ($.trim($(this).closest('label').text()) == 'Comptoir') {
console.log('Comptoir');
$('#sonata-ba-field-container-{{ admin.uniqid }}_gestionnaireComptoir label.hide').removeClass('hide');
$('#sonata-ba-field-container-{{ admin.uniqid }}_gestionnaireComptoir div.select2-container').removeClass('hide');
}
});
$(this).on('ifUnchecked', function(event){
if ($.trim($(this).closest('label').text()) == 'Gestionnaire de Groupe') {
console.log('Uncheck Gestionnaire de Groupe');
$('#{{ admin.uniqid }}_gestionnaireGroupe').select2('val',[]);
$('#sonata-ba-field-container-{{ admin.uniqid }}_gestionnaireGroupe label.control-label').addClass('hide');
$('#sonata-ba-field-container-{{ admin.uniqid }}_gestionnaireGroupe div.select2-container').addClass('hide');
} else if ($.trim($(this).closest('label').text()) == 'Comptoir') {
console.log('Uncheck Comptoir');
$('#{{ admin.uniqid }}_gestionnaireComptoir').select2('val',[]);
$('#sonata-ba-field-container-{{ admin.uniqid }}_gestionnaireComptoir label.control-label').addClass('hide');
$('#sonata-ba-field-container-{{ admin.uniqid }}_gestionnaireComptoir div.select2-container').addClass('hide');
}
});
});
});
</script>
{% endif %}
{% endblock %}
{% if getAllFlux(app.user, app.request).getTotalItemCount > 0 %}
<div class='flux mt-4'>
<h4>Mes transactions :</h4>
<h5>({{getAllFlux(app.user, app.request).getTotalItemCount}})</h5>
<ul class='list-group'>
{% for flux in getAllFlux(app.user, app.request) %}
<li class="list-group-item">{{flux.parenttype|capitalize}} à {{flux.destinataire}} {{flux.montant}}&euro; (payée le {{flux.createdAt|date('d-m-Y')}})</li>
{% endfor %}
</ul>
</div>
{% endif %}
\ No newline at end of file
{% trans_default_domain 'app' %}
<!DOCTYPE html>
<!--[if IE 8]> <html class="no-js lt-ie9" lang="fr"> <![endif]-->
<!--[if gt IE 8]><!-->
......@@ -12,6 +13,9 @@
<meta name="keywords" content="{{ keywords|default('mlc_keywords'|trans) }}" />
<meta name="author" content="{{ 'mlc_author'|trans }}">
{# UTILISER LES FONT AWESOME POUR L'ICONOGRAPHIE #}
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.2/css/all.css" integrity="sha384-fnmOCqbTlWIlj8LyTjo7mOUStjsKC4pOpQbqyi7RrhN7udi9RwhKkMHpvLbHG9Sr" crossorigin="anonymous">
{# POUR AJOUTER DES META ( like og: ) #}
{% block meta %}
{% endblock meta %}
......@@ -26,6 +30,7 @@
<body>
{% include 'common/flash-messages.html.twig' %}
{% include 'common/modale_choix_groupe.html.twig' %}
<!-- HEADER -->
{% block header %}
......@@ -51,6 +56,20 @@
{# POUR AJOUTER DES JS #}
{% block js %} {% endblock js %}
{# AFFICHAGE DE LA MODALE DE CHOIX DU RÔLE (groupe associé aux rôles) #}
{% if app.request.session.has('_choixGroup') %}
<script type="text/javascript">
$(document).ready(function() {
$('#roleGroupeModal').modal('show');
});
</script>
{% endif %}
<script type="text/javascript">
$('.viewChoiceGroup').on('click', function () {
$('#roleGroupeModal').modal('show');
});
</script>
</body>
</html>
......@@ -2,21 +2,58 @@
{% set menuItems = getMenuItemsFromAlias('main') %}
{% endif %}
{% if menuItems is not null and menuItems|length > 0 %}
<nav class="menu navbar navbar-expand-md navbar-light bg-light">
<a class="navbar-brand" href="{{ url('index') }}">
<img src="/images/logo.png" height="45" class="d-inline-block align-top" alt="{{ parameter('mlc_name') }}">
</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<nav class="menu navbar navbar-expand-md navbar-light bg-light">
<a class="navbar-brand" href="{{ url('index') }}">
<img src="/images/logo.png" height="45" class="d-inline-block align-top" alt="{{ parameter('mlc_name') }}">
</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
{% if menuItems is not null and menuItems|length > 0 %}
{% import 'common/menu_tree_macro.html.twig' as tree %}
{% set currentPath = app.request.requestUri %}
<div class="collapse navbar-collapse" id="navbarSupportedContent">
{{ tree.menu(menuItems, currentPath) }}
<ul class="navbar-nav ml-auto">
{{ tree.menu(menuItems, currentPath) }}
{# MENU UTILISATEUR AYANT ACCES A L'ADMIN CONNECTE #}
{% if app.user and (is_granted('ROLE_ADMIN') or is_granted('ROLE_SUPER_ADMIN')) %}
<li class="nav-item ml-auto" role="menu-item">
<a href="{{ path('sonata_admin_dashboard') }}" class="nav-link" data-toggle="tooltip" data-placement="bottom" title="{{ 'Administration'|trans }}">
{# {{ 'Administration'|trans }} #}
<i class="fas fa-cog"></i>
</a>
</li>
{% endif %}
{# MENU UTILISATEUR CONNECTE #}
{% if app.user %}
<li class="nav-item dropdown" role="menu-item">
<a href="#" id="navbarDropdownUC" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" class="nav-link parent dropdown-toggle" alt='{{ app.user.name }}'>
<span style="{# font-size: 1em; color: grey; #}">
<i class="fas fa-user"></i>
</span>
</a>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdownUC">
{% if is_granted('ROLE_ADHERENT') %}
<a href="{{ path('adherent_infos') }}" class="dropdown-item">{{ 'Mes infos'|trans }}</a>
<a href="{{ path('transactionAdherentPrestataire') }}" class="dropdown-item">{{ 'Transaction vers presta'|trans }}</a>
{% endif %}
{% if is_granted('ROLE_PRESTATAIRE') %}
<a href="{{ path('prestataire_infos') }}" class="dropdown-item">{{ 'Mes infos'|trans }}</a>
<a href="{{ path('transactionPrestataireAdherent') }}" class="dropdown-item">{{ 'Transaction vers adherent'|trans }}</a>
<a href="{{ path('transactionPrestatairePrestataire') }}" class="dropdown-item">{{ 'Transaction vers presta'|trans }}</a>
{% endif %}
{% if app.user.groups|length > 1 %}
<a href="#" class="viewChoiceGroup dropdown-item">{{ 'Choix du rôle'|trans }}</a>
{% endif %}
<a href="{{ path('fos_user_security_logout') }}" class="dropdown-item">{{ 'Déconnexion'|trans }}</a>
</div>
</li>
{% endif %}
</ul>
</div>
</nav>
{% endif %}
{% endif %}
\ No newline at end of file
</nav>
{% macro menu(items, currentPath) %}
{% import _self as self %}
<ul class="navbar-nav mr-auto">
{% for menuItem in items %}
{% set url = menuItem.url %}
{% set attributes = "menu-item" %}
{% if menuItem.classAttribute %}
{% set attributes = attributes ~ ' ' ~ menuItem.classAttribute %}
{% endif %}
{% if menuItem.hasChild() %}
{% set attributes = attributes ~ ' has-child dropdown' %}
{% for childItem in menuItem.children %}
{% set childUrl = childItem.url %}
{% if childUrl == currentPath %}
{% set attributes = attributes ~ ' active current-parent' %}
{% endif %}
{% endfor %}
{% endif %}
<li class="nav-item {% if menuItem.hasChild() %}dropdown{% endif %}{{ attributes }}" role="menu-item">
{% if menuItem.hasChild() %}
<a href="#" id="navbarDropdown{{ menuItem.id }}" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" class="nav-link parent dropdown-toggle {% if currentPath == url %}current{% endif %}" {% if menuItem.target %} target="_blank"{% endif %}>{{ menuItem.name }}</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown{{ menuItem.id }}">
{{ self.menuchild(menuItem.children, currentPath) }}
</div>
{% else %}
<a href="{{ url }}" class="nav-link {% if currentPath == url %}current{% endif %}" {% if menuItem.target %} target="_blank"{% endif %}>{{ menuItem.name }}</a>
{% for menuItem in items %}
{% set url = menuItem.url %}
{% set attributes = "menu-item" %}
{% if menuItem.classAttribute %}
{% set attributes = attributes ~ ' ' ~ menuItem.classAttribute %}
{% endif %}
{% if menuItem.hasChild() %}
{% set attributes = attributes ~ ' has-child dropdown' %}
{% for childItem in menuItem.children %}
{% set childUrl = childItem.url %}
{% if childUrl == currentPath %}
{% set attributes = attributes ~ ' active current-parent' %}
{% endif %}
</li>
{% endfor %}
</ul>
{% endfor %}
{% endif %}
<li class="nav-item {% if menuItem.hasChild() %}dropdown{% endif %}{{ attributes }}" role="menu-item">
{% if menuItem.hasChild() %}
<a href="#" id="navbarDropdown{{ menuItem.id }}" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" class="nav-link parent dropdown-toggle {% if currentPath == url %}current{% endif %}" {% if menuItem.target %} target="_blank"{% endif %}>{{ menuItem.name }}</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown{{ menuItem.id }}">
{{ self.menuchild(menuItem.children, currentPath) }}
</div>
{% else %}
<a href="{{ url }}" class="nav-link {% if currentPath == url %}current{% endif %}" {% if menuItem.target %} target="_blank"{% endif %}>{{ menuItem.name }}</a>
{% endif %}
</li>
{% endfor %}
{% endmacro %}
{% macro menuchild(items, currentPath) %}
{% import _self as self %}
......
<!-- Modal -->
<div class="modal fade" id="roleGroupeModal" tabindex="-1" role="dialog" aria-labelledby="roleGroupeModalTitle" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="roleGroupeModalLongTitle">{{ 'Choix du rôle'|trans }}</h5>
{# <button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button> #}
</div>
<div class="modal-body">
<div class='row'>
{% for group in app.user.groups %}
<div class='col'>
<a role="button" class="btn btn-secondary text-nowrap" href='{{path('group_choice', {'id': group.id})}}'>{{ group.name|trans }}</a>
</div>
{% endfor %}
</div>
</div>
{# <div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">{{ 'Fermer'|trans }}</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div> #}
</div>
</div>
</div>
\ No newline at end of file
{% extends 'common/layout.html.twig' %}
{% block content %}
<div class='container groupeshow mt-5'>
<h4>{{ title }} :</h4>
<h5>Mon compte : {{compte}}</h5>
{{form_start(form)}}
{{ form_row(form.expediteur) }}
{{ form_row(form.destinataire) }}
{{ form_row(form.montant) }}
{{ form_row(form.moyen) }}
{{ form_row(form.reference) }}
{{ form_row(form.save) }}
{{form_end(form)}}
</div>
{% endblock %}
{% extends 'base.html.twig' %}
{% block title %}Test page flux !{% endblock %}
{% block body %}
<style>
.example-wrapper { margin: 1em auto; max-width: 800px; width: 95%; font: 18px/1.5 sans-serif; }
.example-wrapper code { background: #F5F5F5; padding: 2px 6px; }
</style>
<div class="example-wrapper">
{{form_start(form)}}
<button class="btn btn-primary btn-sm btn-block" type="submit" id="_submit" name="_submit" >SUBMIT</button>
{{form_end(form)}}
</div>
{% endblock %}
{% extends 'common/layout.html.twig' %}
{% block content %}
<div class='container prestataire_infos'>
<div class="row">
<div class="col-sm-12 col-md-6">
<div class='infos mt-4'>
{{form_start(form)}}
<h4><a class="btn btn-block btn-secondary" data-toggle="collapse" href="#infospresta" role="button" aria-expanded="false" aria-controls="infospresta"><span class="btn-label"><i class="fas fa-cogs mr-2"></i></span>Modifier les informations du prestataire</a></h4>
<div class="collapse" id="infospresta">
<div class="card card-body">
{{ form_row(form.groupe) }}
{{ form_row(form.raison) }}
{{ form_row(form.statut) }}
{{ form_row(form.siret) }}
{{ form_row(form.iban) }}
{{ form_row(form.responsable) }}
{{ form_row(form.metier) }}
{{ form_row(form.geoloc) }}
{{ form_row(form.save) }}
</div>
</div>
<h4><a class="btn btn-block btn-secondary" data-toggle="collapse" href="#infosuser" role="button" aria-expanded="false" aria-controls="infosuser">Modifier les informations du l'utilisateur</a></h4>
<div class="collapse" id="infosuser">
<div class="card card-body">
{{ form_row(form.user) }}
{{ form_row(form.save2) }}
</div>
</div>
{{form_end(form)}}
</div>
</div>
<div class="col-sm-12 col-md-6">
{% if app.user.prestataire is not null and app.user.prestataire.compte >= 0 %}
<div class='compte mt-4'>
<h4>Mon compte :</h4>
<ul class='list-group'>
<li class="list-group-item">{{(app.user.prestataire.compte)|number_format(2, '.', ',')}}</li>
</ul>
</div>
{% endif %}
{% if app.user.cotisations|length > 0 %}
<div class='cotisations mt-4'>
<h4>Mes cotisations :</h4>
<ul class='list-group'>
{% for cotisation in app.user.cotisations %}
<li class="list-group-item">{{cotisation.annee|upper}} : {{cotisation.montant}}&euro; (payée le {{cotisation.createdAt|date('d-m-Y')}})</li>
{% endfor %}
</ul>
</div>
{% endif %}
{% if getAllFlux(app.user, app.request).getTotalItemCount > 0 %}
<div class='flux mt-4'>
<h4>Mes transactions :</h4>
<h5>({{getAllFlux(app.user, app.request).getTotalItemCount}})</h5>
<ul class='list-group'>
{% for flux in getAllFlux(app.user, app.request) %}
<li class="list-group-item">{{flux.parenttype|capitalize}} à {{flux.destinataire}} {{flux.montant}}&euro; (payée le {{flux.createdAt|date('d-m-Y')}})</li>
{% endfor %}
</ul>
</div>
{% endif %}
{% if app.user.prestataire.rubriques|length > 0 %}
<div class='flux mt-4'>
<h4>Mes rubriques :</h4>
<ul class='list-group'>
{% for rubrique in app.user.prestataire.rubriques %}
{% if rubrique.enabled %}
<li class="list-group-item">{{rubrique.name|capitalize}}</li>
{% endif %}
{% endfor %}
</ul>
</div>
{% endif %}
</div>
</div>
</div>
{% endblock %}
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