Commit 36fc65fd by Julien Jorry

in dev

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