Commit a94aa7ff by Damien Moulard

Merge branch 'dev'

parents 43effb53 26605d3a
......@@ -107,11 +107,21 @@ function showConfirmTransactionModal(div, form, montant, destinataire = null) {
// Bind modal validation button with form submition
$('#confirmTransactionModal #confirmTransactionButton').off()
$('#confirmTransactionModal #confirmTransactionButton').on('click', function(e){
// prevent hiccup
if ($(form).data('submitted') === true) {
e.preventDefault();
} else {
$(form).data('submitted', true);
form.submit()
}
});
$('#confirmTransactionModal #dismissTransactionButton').on('click', function(e){
$(form).data('submitted', false);
});
}
jQuery(document).ready(function() {
$(function() {
// Get the ul that holds the collection of groupes
$collectionHolder = $('.groupeprestas');
......@@ -209,15 +219,12 @@ jQuery(document).ready(function() {
$('form[name^=formVente]')
.add('form[name^=formRetrait]')
.add('form[name=formTransfertPrestataireComptoir]')
.submit(function (e) {
.on('submit', function (e) {
// Stop form submition
e.preventDefault();
var form = this;
// Set form moyen
$('#' + form.name + '_moyen').val('mlc')
if (form.checkValidity()) {
var div = form.name === 'formTransfertPrestataireComptoir' ? '.confirmTransfertPrestataireComptoir' :
form.name.includes('Prestataire') ? '.confirmTransactionPrestataire' :
......@@ -236,5 +243,4 @@ jQuery(document).ready(function() {
form.submit()
}
});
});
......@@ -109,6 +109,8 @@ security:
ROLE_API: ROLE_USER
ROLE_ADHERENT: ROLE_USER
ROLE_PRESTATAIRE: ROLE_USER
ROLE_CAISSIER_PRESTATAIRE: ROLE_USER
ROLE_CAISSIER_COMPTOIR: ROLE_USER
ROLE_ADMIN_SIEGE: [ROLE_USER, ROLE_ADMIN, ROLE_ADMIN_COMPTOIR_READER]
ROLE_REDACTEUR: [ROLE_USER, ROLE_ADMIN]
ROLE_TRESORIER: [ROLE_USER, ROLE_ADMIN, ROLE_ADMIN_COMPTOIR_READER]
......
......@@ -289,6 +289,7 @@ services:
public: true
calls:
- [ setSecurity, ['@security.helper']]
- [ setUserManager, ['@fos_user.user_manager']]
admin.groupepresta.gerer:
class: App\Admin\GroupeprestataireAdmin
......
......@@ -28,6 +28,10 @@ App\Entity\Usergroup:
__construct: ['Adherent', ['ROLE_ADHERENT']]
usergroup_prestataire:
__construct: ['Prestataire', ['ROLE_PRESTATAIRE']]
usergroup_caissier_prestataire:
__construct: ['Caissier de Prestataire', ['ROLE_CAISSIER_PRESTATAIRE']]
usergroup_caissier_comptoir:
__construct: ['Caissier de Comptoir', ['ROLE_CAISSIER_COMPTOIR']]
usergroup_adminsiege:
__construct: ['Administrateur du Siege', [
'ROLE_ADMIN_SIEGE',
......
......@@ -28,6 +28,10 @@ App\Entity\Usergroup:
__construct: ['Adherent', ['ROLE_ADHERENT']]
usergroup_prestataire:
__construct: ['Prestataire', ['ROLE_PRESTATAIRE']]
usergroup_caissier_prestataire:
__construct: ['Caissier de Prestataire', ['ROLE_CAISSIER_PRESTATAIRE']]
usergroup_caissier_comptoir:
__construct: ['Caissier de Comptoir', ['ROLE_CAISSIER_COMPTOIR']]
usergroup_adminsiege:
__construct: ['Administrateur du Siege', [
'ROLE_ADMIN_SIEGE',
......@@ -937,6 +941,24 @@ App\Entity\User:
plainPassword: 'nopassword'
enabled: true
roles: ['ROLE_API']
usercaissierprestataire:
username: 'user_caissier_prestataire'
email: 'caissier_prestataire@kohinos.test'
plainPassword: 'test'
enabled: true
possiblegroups: ['@usergroup_caissier_prestataire']
groups: ['@usergroup_caissier_prestataire']
roles: ['ROLE_CAISSIER_PRESTATAIRE']
caissierprestataires: ['@prestataireuser']
usercaissiercomptoir:
username: 'user_caissier_comptoir'
email: 'caissier_comptoir@kohinos.test'
plainPassword: 'test'
enabled: true
possiblegroups: ['@usergroup_caissier_comptoir']
groups: ['@usergroup_caissier_comptoir']
roles: ['ROLE_CAISSIER_COMPTOIR']
caissiercomptoirs: ['@comptoir1']
# TEST DE TRANSACTIONS / TRANSFERTS !
# App\Entity\TransactionAdherentPrestataire:
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -3,19 +3,19 @@
"app": {
"js": [
"/build/runtime.420770e4.js",
"/build/app.50959599.js"
"/build/app.bf48f0d2.js"
],
"css": [
"/build/app.4ada5381.css"
"/build/app.e9278f1f.css"
]
},
"admin": {
"js": [
"/build/runtime.420770e4.js",
"/build/admin.f9a92453.js"
"/build/admin.21942bf0.js"
],
"css": [
"/build/admin.4d653142.css"
"/build/admin.3589a647.css"
]
}
}
......
{
"build/admin.css": "/build/admin.4d653142.css",
"build/admin.js": "/build/admin.f9a92453.js",
"build/app.css": "/build/app.4ada5381.css",
"build/app.js": "/build/app.50959599.js",
"build/admin.css": "/build/admin.3589a647.css",
"build/admin.js": "/build/admin.21942bf0.js",
"build/app.css": "/build/app.e9278f1f.css",
"build/app.js": "/build/app.bf48f0d2.js",
"build/runtime.js": "/build/runtime.420770e4.js",
"build/ckeditor/adapters/jquery.js": "/build/ckeditor/adapters/jquery.js",
"build/ckeditor/ckeditor.js": "/build/ckeditor/ckeditor.js",
......
......@@ -21,12 +21,17 @@
namespace App\Admin;
use App\Entity\Comptoir;
use App\Entity\ContactComptoir;
use App\Entity\Geoloc;
use App\Entity\GlobalParameter;
use App\Entity\Groupe;
use App\Entity\User;
use App\Entity\Adherent;
use App\Entity\Usergroup;
use App\Form\Type\ContactEntityFormType;
use App\Form\Type\GeolocFormType;
use App\Form\Type\UserWithPswdFormType;
use Doctrine\ORM\EntityRepository;
use FOS\CKEditorBundle\Form\Type\CKEditorType;
use Sonata\AdminBundle\Admin\AbstractAdmin;
......@@ -42,6 +47,12 @@ use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Security\Core\Security;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormError;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\ArrayCollection;
use FOS\UserBundle\Model\UserManagerInterface;
/**
* Administration des comptoirs
......@@ -150,6 +161,30 @@ class ComptoirAdmin extends AbstractAdmin
'label' => false
))
->end()
->with('Caissier(s)', ['class' => 'col-md-6'])
->add('caissiers', EntityType::class, [
// 'mapped' => false,
'class' => User::class,
'multiple' => true,
'required' => false,
'label' => 'Associer à un(des) utilisateur(s) existant :',
'choices' => $this->getConfigurationPool()->getContainer()->get('doctrine')->getRepository(User::class)->findAll(),
'choice_label' => 'username',
'placeholder' => 'Choisir un utilisateur',
])
->add('newcaissiers', CollectionType::class, [
'mapped' => false,
'required' => false,
'label' => 'Nouvel Utilisateur/Adhérent',
'entry_type' => UserWithPswdFormType::class,
'entry_options' => [
'required' => false,
'label' => false, ],
'by_reference' => false,
'allow_add' => true,
'allow_delete' => true,
])
->end()
->with('Image', ['class' => 'col-md-6'])
->add('media', MediaType::class, array(
'provider' => 'sonata.media.provider.image',
......@@ -165,6 +200,56 @@ class ComptoirAdmin extends AbstractAdmin
))
->end()
;
$em = $this->getConfigurationPool()->getContainer()->get('doctrine')->getManager();
$formMapper->getFormBuilder()->addEventListener(FormEvents::POST_SUBMIT, function (FormEvent $event) use ($em) {
$comptoir = $event->getData();
$users = null;
if (null != $event->getForm()->get('caissiers')->getData()) {
$caissiers = $event->getForm()->get('caissiers')->getData();
$this->addCaissers($caissiers, $comptoir);
}
if (null != $event->getForm()->get('newcaissiers')->getData()) {
$newcaissiers = $event->getForm()->get('newcaissiers')->getData();
$collection = new ArrayCollection($newcaissiers);
$return = $this->addCaissers($collection, $comptoir);
if (count($return) > 0) {
$event->getForm()->get('newcaissiers')->addError(new FormError('Caissiers : Courriel(s) déjà utilisé : ' . implode(', ', $return) . '!'));
}
}
});
parent::configureFormFields($formMapper);
}
private function addCaissers(Collection $users, Comptoir $comptoir)
{
$return = [];
$em = $this->getConfigurationPool()->getContainer()->get('doctrine')->getManager();
foreach ($users as $user) {
if (null == $user->getId()) {
$emailExist = $em->getRepository(User::class)->findBy(['email' => $user->getEmail()]);
if (count($emailExist) > 0) {
$return[] = $emailExist;
break;
}
$user->setUsername($user->getEmail());
$adh = new Adherent();
$user->setAdherent($adh);
$groupeAdh = $em->getRepository(Usergroup::class)->findOneByName('Adherent');
$user->addPossiblegroup($groupeAdh);
}
$comptoir->addCaissier($user);
$group = $em->getRepository(Usergroup::class)->findOneByName('Caissier de Comptoir');
$user->addPossiblegroup($group);
$this->userManager->updateUser($user);
$em->persist($user);
$em->persist($comptoir);
}
$em->flush();
return $return;
}
/**
......@@ -206,6 +291,22 @@ class ComptoirAdmin extends AbstractAdmin
return true;
}
/**
* @param UserManagerInterface $userManager
*/
public function setUserManager(UserManagerInterface $userManager): void
{
$this->userManager = $userManager;
}
/**
* @return UserManagerInterface
*/
public function getUserManager()
{
return $this->userManager;
}
protected function configureRoutes(RouteCollection $collection)
{
$collection->add('test');
......
......@@ -34,14 +34,15 @@ use App\Entity\Prestataire;
use App\Entity\Rubrique;
use App\Entity\User;
use App\Entity\Usergroup;
use App\Enum\MoyenEnum;
use App\Form\Type\ContactEntityFormType;
use App\Form\Type\CotisationFormType;
use App\Form\Type\GeolocPrestataireFormType;
use App\Form\Type\UserFormType;
use App\Form\Type\UserWithPswdFormType;
use App\Form\Type\UserInfosFormType;
use App\Util\WordpressUtil;
use Doctrine\ORM\Query;
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\ArrayCollection;
use FOS\CKEditorBundle\Form\Type\CKEditorType;
use FOS\UserBundle\Model\UserManagerInterface;
use Knp\Menu\ItemInterface as MenuItemInterface;
......@@ -311,7 +312,7 @@ class PrestataireAdmin extends AbstractAdmin
'mapped' => false,
'required' => false,
'label' => 'Nouvel Utilisateur/Adhérent',
'entry_type' => UserFormType::class,
'entry_type' => UserWithPswdFormType::class,
'entry_options' => array(
'required' => false,
'label' => false),
......@@ -320,6 +321,30 @@ class PrestataireAdmin extends AbstractAdmin
'allow_delete' => true
))
->end()
->with('Caissier(s)', ['class' => 'col-md-6'])
->add('caissiers', EntityType::class, [
// 'mapped' => false,
'class' => User::class,
'multiple' => true,
'required' => false,
'label' => 'Associer à un(des) utilisateur(s) existant :',
'choices' => $this->getConfigurationPool()->getContainer()->get('doctrine')->getRepository(User::class)->findAll(),
'choice_label' => 'username',
'placeholder' => 'Choisir un utilisateur',
])
->add('newcaissiers', CollectionType::class, [
'mapped' => false,
'required' => false,
'label' => 'Nouvel Utilisateur/Adhérent',
'entry_type' => UserWithPswdFormType::class,
'entry_options' => [
'required' => false,
'label' => false, ],
'by_reference' => false,
'allow_add' => true,
'allow_delete' => true,
])
->end()
->end()
;
// @TODO : add tags model transformer if add new from text
......@@ -339,40 +364,72 @@ class PrestataireAdmin extends AbstractAdmin
$formMapper->getFormBuilder()->addEventListener(FormEvents::POST_SUBMIT, function (FormEvent $event) use ($em) {
$prestataire = $event->getData();
$users = null;
/* Permet d'ajouter le nouvel utilisateur crée (newusers) aux gestionnaires du presta */
if ($event->getForm()->get('users')->getData() != null) {
/*
Permet d'ajouter le nouvel utilisateur créé aux gestionnaires (newusers) et aux caissiers (newcaissiers) du presta
(On crée un compte adhérent en même temps que le prestataire)
*/
if (null != $event->getForm()->get('users')->getData()) {
$users = $event->getForm()->get('users')->getData();
$this->addUsersOrCaissers($users, $prestataire);
}
if (null != $event->getForm()->get('caissiers')->getData()) {
$caissiers = $event->getForm()->get('caissiers')->getData();
$this->addUsersOrCaissers($caissiers, $prestataire, 'ROLE_CAISSIER_PRESTATAIRE');
}
if (null != $event->getForm()->get('newusers')->getData()) {
$newusers = $event->getForm()->get('newusers')->getData();
$collection = new ArrayCollection($newusers);
$return = $this->addUsersOrCaissers($collection, $prestataire);
if (false === $return) {
$event->getForm()->get('newusers')->addError(new FormError('Gestionnaires : Courriel(s) déjà utilisé : ' . implode(', ', $return) . '!'));
}
}
if (null != $event->getForm()->get('newcaissiers')->getData()) {
$newcaissiers = $event->getForm()->get('newcaissiers')->getData();
$collection = new ArrayCollection($newcaissiers);
$return = $this->addUsersOrCaissers($collection, $prestataire, 'ROLE_CAISSIER_PRESTATAIRE');
if (count($return) > 0) {
$event->getForm()->get('newcaissiers')->addError(new FormError('Caissiers : Courriel(s) déjà utilisé : ' . implode(', ', $return) . '!'));
}
if ($event->getForm()->get('newusers')->getData() != null) {
$users = array_merge($users, $event->getForm()->get('newusers')->getData());
}
if ($users != null) {
// On crée un compte adhérent en même temps que le prestataire
});
parent::configureFormFields($formMapper);
}
private function addUsersOrCaissers(Collection $users, Prestataire $prestataire, string $role = 'ROLE_PRESTATAIRE')
{
$return = [];
$em = $this->getConfigurationPool()->getContainer()->get('doctrine')->getManager();
foreach ($users as $user) {
if ($user->getId() == null) {
$emailExist = $em->getRepository(User::class)->findBy(array('email' => $user->getEmail()));
if (null == $user->getId()) {
$emailExist = $em->getRepository(User::class)->findBy(['email' => $user->getEmail()]);
if (count($emailExist) > 0) {
$event->getForm()->get('newusers')->addError(new FormError('Courriel déjà utilisé !'));
$return[] = $emailExist;
break;
}
$user->setUsername($user->getEmail());
$adh = new Adherent();
$user->setAdherent($adh);
$groupeAdh = $this->getConfigurationPool()->getContainer()->get('doctrine')->getRepository(Usergroup::class)->findOneByName('Adherent');
$groupePresta = $this->getConfigurationPool()->getContainer()->get('doctrine')->getRepository(Usergroup::class)->findOneByName('Prestataire');
$groupeAdh = $em->getRepository(Usergroup::class)->findOneByName('Adherent');
$user->addPossiblegroup($groupeAdh);
$user->addPossiblegroup($groupePresta);
$this->userManager->updateUser($user);
// $user->addRole('ROLE_PRESTATAIRE');
// $user->addRole('ROLE_ADHERENT');
}
if ('ROLE_PRESTATAIRE' == $role) {
$prestataire->addUser($user);
$group = $em->getRepository(Usergroup::class)->findOneByName('Prestataire');
} elseif ('ROLE_CAISSIER_PRESTATAIRE' == $role) {
$prestataire->addCaissier($user);
$group = $em->getRepository(Usergroup::class)->findOneByName('Caissier de Prestataire');
}
} else {
$event->getForm()->get('users')->addError(new FormError('Veuillez séléctionner un utilisateur ou en créer un nouveau !'));
$user->addPossiblegroup($group);
$this->userManager->updateUser($user);
$em->persist($user);
$em->persist($prestataire);
}
});
parent::configureFormFields($formMapper);
$em->flush();
// TODO: remove goup (and possible groups?) when user is unselected from caissiers list (get caissiers before update & compare)
return $return;
}
/**
......
......@@ -161,11 +161,15 @@ class FluxController extends AbstractController
//Prepare query depending on user role
$query = null;
$user = $this->security->getUser();
if ($this->session->get('_prestagere') != null && $this->security->getUser()->isGranted('ROLE_PRESTATAIRE')) {
if ($this->session->get('_prestagere') != null) {
if ($this->security->isGranted('ROLE_PRESTATAIRE')) {
$query = $this->em->getRepository(Flux::class)->getQueryByPrestataire($this->session->get('_prestagere'));
} elseif ($this->security->isGranted('ROLE_CAISSIER_PRESTATAIRE')) {
$query = $this->em->getRepository(Flux::class)->getQueryByCaissierprestataire($this->session->get('_prestagere'));
}
} elseif ($user->getAdherent() != null && $this->security->getUser()->isGranted('ROLE_ADHERENT')) {
$query = $this->em->getRepository(Flux::class)->getQueryByAdherent($user->getAdherent());
} elseif ($this->session->get('_comptoirgere') != null && $this->security->getUser()->isGranted('ROLE_COMPTOIR')) {
} elseif ($this->session->get('_comptoirgere') != null && ($this->security->isGranted('ROLE_COMPTOIR') || $this->security->isGranted('ROLE_CAISSIER_COMPTOIR'))) {
$query = $this->em->getRepository(Flux::class)->getQueryByComptoir($this->session->get('_comptoirgere'));
} elseif ($this->session->get('_groupegere') != null && $this->security->getUser()->isGranted('ROLE_GESTION_GROUPE')) {
$query = $this->em->getRepository(Flux::class)->getQueryByGroupe($this->session->get('_groupegere'));
......
......@@ -34,7 +34,6 @@ use App\Entity\Siege;
use App\Entity\User;
use App\Entity\Usergroup;
use App\Entity\Payment;
use App\Enum\MoyenEnum;
use App\Form\Type\AdhererFormType;
use App\Form\Type\ContactFormType;
use App\Form\Type\InstallFormType;
......@@ -350,9 +349,16 @@ class IndexController extends AbstractController
*/
public function comptoirChoiceAction(Usergroup $group, Comptoir $comptoir, Request $request)
{
if (!($this->getUser()->getPossiblegroups()->exists(function ($key, $value) {
$this->em->refresh($this->getUser());
if (
!($this->getUser()->getPossiblegroups()->exists(function ($key, $value) {
return in_array('ROLE_COMPTOIR', $value->getRoles());
}) and $this->getUser()->getComptoirsgeres()->contains($comptoir))) {
}) and $this->getUser()->getComptoirsgeres()->contains($comptoir))
and
(!($this->getUser()->getPossiblegroups()->exists(function ($key, $value) {
return in_array('ROLE_CAISSIER_COMPTOIR', $value->getRoles());
}) and $this->getUser()->getCaissiercomptoirs()->contains($comptoir)))
) {
$this->addFlash(
'error',
"Accès impossible !"
......@@ -372,7 +378,14 @@ class IndexController extends AbstractController
'main'
);
if ($this->getUser()->getPossiblegroups()->exists(function ($key, $value) {
return in_array('ROLE_COMPTOIR', $value->getRoles());
})
) {
return $this->redirectToRoute('sonata_admin_dashboard');
} else {
return $this->redirectToRoute('index');
}
}
/**
......@@ -384,9 +397,16 @@ class IndexController extends AbstractController
*/
public function prestaChoiceAction(Usergroup $group, Prestataire $prestataire, Request $request)
{
if (!($this->getUser()->getPossiblegroups()->exists(function ($key, $value) {
$this->em->refresh($this->getUser());
if (
(!($this->getUser()->getPossiblegroups()->exists(function ($key, $value) {
return in_array('ROLE_PRESTATAIRE', $value->getRoles());
}) and $this->getUser()->getPrestataires()->contains($prestataire))) {
}) and $this->getUser()->getPrestataires()->contains($prestataire)))
and
(!($this->getUser()->getPossiblegroups()->exists(function ($key, $value) {
return in_array('ROLE_CAISSIER_PRESTATAIRE', $value->getRoles());
}) and $this->getUser()->getCaissierprestataires()->contains($prestataire)))
) {
$this->addFlash(
'error',
"Accès impossible !"
......
......@@ -43,6 +43,7 @@ use App\Form\Type\RetraitComptoirAdherentFormType;
use App\Form\Type\RetraitComptoirPrestataireFormType;
use Doctrine\ORM\EntityManagerInterface;
use FOS\UserBundle\Model\UserManagerInterface;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
......@@ -117,7 +118,7 @@ class UserComptoirController extends FluxController
/**
* @Route("/user/comptoir/vente/adherent/", name="venteComptoirAdherent")
* @IsGranted("ROLE_COMPTOIR")
* @Security("has_role('ROLE_COMPTOIR') or has_role('ROLE_CAISSIER_COMPTOIR')")
*/
public function venteComptoirAdherentAction(Request $request)
{
......@@ -135,7 +136,7 @@ class UserComptoirController extends FluxController
/**
* @Route("/user/comptoir/vente/prestataire/", name="venteComptoirPrestataire")
* @IsGranted("ROLE_COMPTOIR")
* @Security("has_role('ROLE_COMPTOIR') or has_role('ROLE_CAISSIER_COMPTOIR')")
*/
public function venteComptoirPrestataireAction(Request $request)
{
......@@ -153,7 +154,7 @@ class UserComptoirController extends FluxController
/**
* @Route("/user/comptoir/retrait/adherent/", name="retraitComptoirAdherent")
* @IsGranted("ROLE_COMPTOIR")
* @Security("has_role('ROLE_COMPTOIR') or has_role('ROLE_CAISSIER_COMPTOIR')")
*/
public function retraitComptoirAdherentAction(Request $request)
{
......@@ -171,7 +172,7 @@ class UserComptoirController extends FluxController
/**
* @Route("/user/comptoir/retrait/prestataire/", name="retraitComptoirPrestataire")
* @IsGranted("ROLE_COMPTOIR")
* @Security("has_role('ROLE_COMPTOIR') or has_role('ROLE_CAISSIER_COMPTOIR')")
*/
public function retraitComptoirPrestataireAction(Request $request)
{
......@@ -189,7 +190,7 @@ class UserComptoirController extends FluxController
/**
* @Route("/user/comptoir/reconversion/", name="transfertPrestataireComptoir")
* @IsGranted("ROLE_COMPTOIR")
* @Security("has_role('ROLE_COMPTOIR') or has_role('ROLE_CAISSIER_COMPTOIR')")
*/
public function transfertPrestataireComptoirAction(Request $request)
{
......
......@@ -31,6 +31,7 @@ class AppFixturesPatches extends Fixture
public function load(ObjectManager $manager)
{
self::updateTresorierRole($manager);
self::addCaissiersRoles($manager);
}
/**
......@@ -57,4 +58,34 @@ class AppFixturesPatches extends Fixture
$manager->flush();
}
}
/**
* Add to Tresorier role the permission to view all flux in admin
*/
public function addCaissiersRoles(ObjectManager $manager)
{
$usergroup = $manager->getRepository(Usergroup::class)->findOneBy([
'name' => 'Caissier de Prestataire',
]);
if (!$usergroup) {
$usergroup = new Usergroup('Caissier de Prestataire');
$usergroup->setRoles(['ROLE_CAISSIER_PRESTATAIRE']);
$manager->persist($usergroup);
}
$usergroup = $manager->getRepository(Usergroup::class)->findOneBy([
'name' => 'Caissier de Comptoir',
]);
if (!$usergroup) {
$usergroup = new Usergroup('Caissier de Comptoir');
$usergroup->setRoles(['ROLE_CAISSIER_COMPTOIR']);
$manager->persist($usergroup);
}
$manager->flush();
}
}
......@@ -27,6 +27,7 @@ use App\Entity\EntityTrait\GeolocEntityTrait;
use App\Entity\EntityTrait\HasCompteEntity;
use App\Entity\EntityTrait\NameSlugContentEntityTrait;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Timestampable\Traits\TimestampableEntity;
use Symfony\Component\Validator\Constraints as Assert;
......@@ -97,10 +98,23 @@ class Comptoir
*/
private $contacts;
/**
* @var ArrayCollection|User[]
*
* @ORM\ManyToMany(targetEntity="User", inversedBy="caissiercomptoirs", cascade={"persist"})
* @ORM\JoinTable(name="user_comptoir_caissier",
* joinColumns={@ORM\JoinColumn(name="comptoir_id", referencedColumnName="id")},
* inverseJoinColumns={@ORM\JoinColumn(name="user_id", referencedColumnName="id")}
* )
* @Groups({"read", "write"})
*/
private $caissiers;
public function __construct()
{
$this->gestionnaires = new ArrayCollection();
$this->contacts = new ArrayCollection();
$this->caissiers = new ArrayCollection();
}
/**
......@@ -243,4 +257,49 @@ class Comptoir
{
return (!empty($this->name)?$this->name:'Comptoir');
}
/**
* @return Collection|User[]
*/
public function getCaissiers(): Collection
{
return $this->caissiers;
}
public function getCaissiersString()
{
return join(' - ', array_map(function ($user) {
return $user->getName() . ':' . $user->getEmail();
}, $this->caissiers->getValues()));
}
public function addCaissier(User $caissier): self
{
if (!$this->caissiers->contains($caissier)) {
$this->caissiers[] = $caissier;
}
return $this;
}
/**
* @param ArrayCollection[]|User $caissiers
*
* @return Comptoir
*/
public function setCaissiers($caissiers): self
{
$this->caissiers = $caissiers;
return $this;
}
public function removeCaissier(User $caissier): self
{
if ($this->caissiers->contains($caissier)) {
$this->caissiers->removeElement($caissier);
}
return $this;
}
}
......@@ -239,6 +239,18 @@ class Prestataire
*/
protected $tauxreconversion;
/**
* @var ArrayCollection|User[]
*
* @ORM\ManyToMany(targetEntity="User", inversedBy="caissierprestataires", cascade={"persist"})
* @ORM\JoinTable(name="user_prestataire_caissier",
* joinColumns={@ORM\JoinColumn(name="prestataire_id", referencedColumnName="id")},
* inverseJoinColumns={@ORM\JoinColumn(name="user_id", referencedColumnName="id")}
* )
* @Groups({"read", "write"})
*/
private $caissiers;
public function __construct()
{
$this->users = new ArrayCollection();
......@@ -246,6 +258,7 @@ class Prestataire
$this->geolocs = new ArrayCollection();
$this->etats = new ArrayCollection();
$this->rubriques = new ArrayCollection();
$this->caissiers = new ArrayCollection();
}
/**
......@@ -805,4 +818,50 @@ class Prestataire
{
return 'mapcontentpresta';
}
/**
* @return Collection|User[]
*/
public function getCaissiers(): Collection
{
return $this->caissiers;
}
public function getCaissiersString()
{
return join(' - ', array_map(function ($user) {
return $user->getName() . ':' . $user->getEmail();
}, $this->caissiers->getValues()));
}
public function addCaissier(User $caissier): self
{
if (!$this->caissiers->contains($caissier)) {
$this->caissiers[] = $caissier;
}
return $this;
}
/**
* @param ArrayCollection[]|User $caissiers
*
* @return Prestataire
*/
public function setCaissiers($caissiers): self
{
$this->caissiers = $caissiers;
return $this;
}
public function removeCaissier(User $caissier): self
{
if ($this->caissiers->contains($caissier)) {
$this->caissiers->removeElement($caissier);
}
return $this;
}
}
......@@ -24,7 +24,7 @@ namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Retrait => (Retrait de monnaie papier en échange de monnaie numérique)
* Retrait => (Retrait de monnaie papier en échange de monnaie numérique).
*
* Types de retraits :
*
......@@ -52,15 +52,20 @@ abstract class Retrait extends Flux
public function operate($em)
{
$compteExp = $this->getExpediteur()->getCompte() - $this->getMontant();
$compteDest = $this->getDestinataire()->getEcompte() - $this->getMontant();
if ($compteExp < 0) {
throw new \Exception("[FLUX] Retrait impossible ! Montant supérieur au solde du comptoir !");
throw new \Exception('[FLUX] Retrait impossible ! Montant supérieur au solde du comptoir !');
} elseif ($compteDest < 0) {
throw new \Exception('[FLUX] Retrait impossible ! Montant supérieur au solde du demandeur !');
} else {
$this->getExpediteur()->removeCompte($this->getMontant());
$this->getExpediteur()->getGroupe()->getSiege()->addCompteNantie($this->getMontant());
$this->getExpediteur()->getGroupe()->getSiege()->removeEcompte($this->getMontant());
$this->getDestinataire()->removeEcompte($this->getMontant());
return [$this->getExpediteur(), $this->getDestinataire(), $this->getExpediteur()->getGroupe()->getSiege()];
}
return [];
}
}
......@@ -208,6 +208,16 @@ class User extends BaseUser
*/
protected $alertemailflux = true;
/**
* @ORM\ManyToMany(targetEntity=Prestataire::class, mappedBy="caissiers")
*/
private $caissierprestataires;
/**
* @ORM\ManyToMany(targetEntity=Comptoir::class, mappedBy="caissiers")
*/
private $caissiercomptoirs;
public function __construct()
{
parent::__construct();
......@@ -226,6 +236,8 @@ class User extends BaseUser
$this->alertemailflux = true;
$this->createApiKey();
$this->createEmailToken();
$this->caissierprestataires = new ArrayCollection();
$this->caissiercomptoirs = new ArrayCollection();
}
/**
......@@ -704,4 +716,60 @@ class User extends BaseUser
return $this;
}
/**
* @return Collection|Prestataire[]
*/
public function getCaissierprestataires(): Collection
{
return $this->caissierprestataires;
}
public function addCaissierprestataire(Prestataire $caissierprestataire): self
{
if (!$this->caissierprestataires->contains($caissierprestataire)) {
$this->caissierprestataires[] = $caissierprestataire;
$caissierprestataire->addCaissier($this);
}
return $this;
}
public function removeCaissierprestataire(Prestataire $caissierprestataire): self
{
if ($this->caissierprestataires->contains($caissierprestataire)) {
$this->caissierprestataires->removeElement($caissierprestataire);
$caissierprestataire->removeCaissier($this);
}
return $this;
}
/**
* @return Collection|Comptoir[]
*/
public function getCaissiercomptoirs(): Collection
{
return $this->caissiercomptoirs;
}
public function addCaissiercomptoir(Comptoir $caissiercomptoir): self
{
if (!$this->caissiercomptoirs->contains($caissiercomptoir)) {
$this->caissiercomptoirs[] = $caissiercomptoir;
$caissiercomptoir->addCaissier($this);
}
return $this;
}
public function removeCaissiercomptoir(Comptoir $caissiercomptoir): self
{
if ($this->caissiercomptoirs->contains($caissiercomptoir)) {
$this->caissiercomptoirs->removeElement($caissiercomptoir);
$caissiercomptoir->removeCaissier($this);
}
return $this;
}
}
......@@ -45,6 +45,9 @@ class SwitchUserSubscriber implements EventSubscriberInterface
$this->em = $em;
}
/**
* Super admin switches user
*/
public function onSwitchUser(SwitchUserEvent $event)
{
$request = $event->getRequest();
......@@ -60,8 +63,12 @@ class SwitchUserSubscriber implements EventSubscriberInterface
$groupe = $user->getPossiblegroups()->first();
if (in_array('ROLE_PRESTATAIRE', $groupe->getRoles()) && count($user->getPrestataires()) >= 1) {
$request->getSession()->set('_prestagere', $user->getPrestataires()[0]);
} elseif (in_array('ROLE_CAISSIER_PRESTATAIRE', $groupe->getRoles()) && count($user->getCaissierprestataires()) >= 1) {
$request->getSession()->set('_prestagere', $user->getCaissierprestataires()[0]);
} elseif (in_array('ROLE_COMPTOIR', $groupe->getRoles()) && count($user->getComptoirsGeres()) >= 1) {
$request->getSession()->set('_comptoirgere', $user->getComptoirsGeres()[0]);
} elseif (in_array('ROLE_CAISSIER_COMPTOIR', $groupe->getRoles()) && count($user->getCaissiercomptoirs()) >= 1) {
$request->getSession()->set('_comptoirgere', $user->getCaissiercomptoirs()[0]);
} elseif ((in_array('ROLE_TRESORIER', $groupe->getRoles()) || in_array('ROLE_CONTACT', $groupe->getRoles()) || in_array('ROLE_GESTION_GROUPE', $groupe->getRoles())) && count($user->getGroupesGeres()) >= 1) {
$request->getSession()->set('_groupegere', $user->getGroupesGeres()[0]);
}
......@@ -73,8 +80,12 @@ class SwitchUserSubscriber implements EventSubscriberInterface
$groupe = $user->getGroups()->first();
if (in_array('ROLE_PRESTATAIRE', $groupe->getRoles()) && count($user->getPrestataires()) >= 1) {
$request->getSession()->set('_prestagere', $user->getPrestataires()[0]);
} elseif (in_array('ROLE_CAISSIER_PRESTATAIRE', $groupe->getRoles()) && count($user->getCaissierprestataires()) >= 1) {
$request->getSession()->set('_prestagere', $user->getCaissierprestataires()[0]);
} elseif (in_array('ROLE_COMPTOIR', $groupe->getRoles()) && count($user->getComptoirsGeres()) >= 1) {
$request->getSession()->set('_comptoirgere', $user->getComptoirsGeres()[0]);
} elseif (in_array('ROLE_CAISSIER_COMPTOIR', $groupe->getRoles()) && count($user->getCaissiercomptoirs()) >= 1) {
$request->getSession()->set('_comptoirgere', $user->getCaissiercomptoirs()[0]);
} elseif ((in_array('ROLE_TRESORIER', $groupe->getRoles()) || in_array('ROLE_CONTACT', $groupe->getRoles()) || in_array('ROLE_GESTION_GROUPE', $groupe->getRoles())) && count($user->getGroupesGeres()) >= 1) {
$request->getSession()->set('_groupegere', $user->getGroupesGeres()[0]);
}
......@@ -105,8 +116,12 @@ class SwitchUserSubscriber implements EventSubscriberInterface
$groupe = $user->getGroups()->first();
if (in_array('ROLE_PRESTATAIRE', $groupe->getRoles()) && count($user->getPrestataires()) >= 1) {
$request->getSession()->set('_prestagere', $user->getPrestataires()[0]);
} elseif (in_array('ROLE_CAISSIER_PRESTATAIRE', $groupe->getRoles()) && count($user->getCaissierprestataires()) >= 1) {
$request->getSession()->set('_prestagere', $user->getCaissierprestataires()[0]);
} elseif (in_array('ROLE_COMPTOIR', $groupe->getRoles()) && count($user->getComptoirsGeres()) >= 1) {
$request->getSession()->set('_comptoirgere', $user->getComptoirsGeres()[0]);
} elseif (in_array('ROLE_CAISSIER_COMPTOIR', $groupe->getRoles()) && count($user->getCaissiercomptoirs()) >= 1) {
$request->getSession()->set('_comptoirgere', $user->getCaissiercomptoirs()[0]);
} elseif ((in_array('ROLE_TRESORIER', $groupe->getRoles()) || in_array('ROLE_CONTACT', $groupe->getRoles()) || in_array('ROLE_GESTION_GROUPE', $groupe->getRoles())) && count($user->getGroupesGeres()) >= 1) {
$request->getSession()->set('_groupegere', $user->getGroupesGeres()[0]);
}
......
......@@ -42,7 +42,6 @@ use App\Entity\Siege;
use App\Entity\AchatMonnaieAdherent;
use App\Entity\AchatMonnaiePrestataire;
use App\Entity\User;
use App\Enum\MoyenEnum;
use App\Form\Type\AdherentInfosFormType;
use App\Form\Type\ComptoirInfosFormType;
use App\Form\Type\GroupeInfosFormType;
......
......@@ -25,7 +25,6 @@ use App\Entity\Adherent;
use App\Entity\Groupe;
use App\Entity\Prestataire;
use App\Entity\User;
use App\Enum\MoyenEnum;
use App\Form\Type\GeolocFormType;
use App\Form\Type\UserInfosFormType;
use Doctrine\DBAL\Types\FloatType;
......
......@@ -23,7 +23,6 @@ namespace App\Form\Type;
use App\Entity\Adherent;
use App\Entity\Groupe;
use App\Enum\MoyenEnum;
use App\Form\Type\GeolocFormType;
use App\Form\Type\RegistrationFormType;
use Doctrine\ORM\EntityManagerInterface;
......
......@@ -26,7 +26,6 @@ use App\Entity\Groupe;
use App\Entity\Prestataire;
use App\Entity\Rubrique;
use App\Entity\User;
use App\Enum\MoyenEnum;
use Doctrine\DBAL\Types\FloatType;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface;
......
......@@ -23,7 +23,6 @@ namespace App\Form\Type;
use App\Entity\Adherent;
use App\Entity\TransactionAdherentAdherent;
use App\Enum\MoyenEnum;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\FormBuilderInterface;
......
......@@ -26,7 +26,6 @@ use App\Entity\Prestataire;
use App\Entity\Siege;
use App\Entity\TransfertPrestataireSiege;
use App\Entity\User;
use App\Enum\MoyenEnum;
use App\Form\Type\TransfertFormType;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
......
<?php
/*
* kohinos_cooperatic
* Copyright (C) 2019-2020 ADML63
* Copyright (C) 2020- Cooperatic
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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;
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;
class UserWithPswdFormType extends AbstractType
{
protected $em;
public function __construct(EntityManagerInterface $em)
{
$this->em = $em;
}
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('email', EmailType::class, array(
'label' => 'Courriel',
'required' => true,
'translation_domain' => 'FOSUserBundle'
))
->add('firstname', TextType::class, array(
'label' => 'Prénom',
'required' => true,
))
->add('lastname', TextType::class, array(
'label' => 'Nom',
'required' => true,
))
->add('plainPassword', PasswordType::class, array(
'label' => 'Mot de passe',
'required' => true,
))
->add('phone', TextType::class, array(
'label' => 'Téléphone fixe :',
'required' => false
))
->add('mobile', TextType::class, array(
'label' => 'Téléphone mobile :',
'required' => false
))
->add('enabled', null, array(
'label' => 'Activé ?'
))
;
}
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
'data_class' => User::class,
'cascade_validation' => true
));
}
public function getBlockPrefix()
{
return 'user_form';
}
}
......@@ -80,8 +80,12 @@ class AfterLoginRedirection implements AuthenticationSuccessHandlerInterface
$groupe = $user->getPossiblegroups()->first();
if (in_array('ROLE_PRESTATAIRE', $groupe->getRoles()) && count($user->getPrestataires()) >= 1) {
$request->getSession()->set('_prestagere', $user->getPrestataires()[0]);
} elseif (in_array('ROLE_CAISSIER_PRESTATAIRE', $groupe->getRoles()) && count($user->getCaissierprestataires()) >= 1) {
$request->getSession()->set('_prestagere', $user->getCaissierprestataires()[0]);
} elseif (in_array('ROLE_COMPTOIR', $groupe->getRoles()) && count($user->getComptoirsGeres()) >= 1) {
$request->getSession()->set('_comptoirgere', $user->getComptoirsGeres()[0]);
} elseif (in_array('ROLE_CAISSIER_COMPTOIR', $groupe->getRoles()) && count($user->getCaissiercomptoirs()) >= 1) {
$request->getSession()->set('_comptoirgere', $user->getCaissiercomptoirs()[0]);
} elseif ((in_array('ROLE_TRESORIER', $groupe->getRoles()) || in_array('ROLE_CONTACT', $groupe->getRoles()) || in_array('ROLE_GESTION_GROUPE', $groupe->getRoles())) && count($user->getGroupesGeres()) >= 1) {
$request->getSession()->set('_groupegere', $user->getGroupesGeres()[0]);
}
......@@ -93,8 +97,12 @@ class AfterLoginRedirection implements AuthenticationSuccessHandlerInterface
$groupe = $user->getGroups()->first();
if (in_array('ROLE_PRESTATAIRE', $groupe->getRoles()) && count($user->getPrestataires()) >= 1) {
$request->getSession()->set('_prestagere', $user->getPrestataires()[0]);
} elseif (in_array('ROLE_CAISSIER_PRESTATAIRE', $groupe->getRoles()) && count($user->getCaissierprestataires()) >= 1) {
$request->getSession()->set('_prestagere', $user->getCaissierprestataires()[0]);
} elseif (in_array('ROLE_COMPTOIR', $groupe->getRoles()) && count($user->getComptoirsGeres()) >= 1) {
$request->getSession()->set('_comptoirgere', $user->getComptoirsGeres()[0]);
} elseif (in_array('ROLE_CAISSIER_COMPTOIR', $groupe->getRoles()) && count($user->getCaissiercomptoirs()) >= 1) {
$request->getSession()->set('_comptoirgere', $user->getCaissiercomptoirs()[0]);
} elseif ((in_array('ROLE_TRESORIER', $groupe->getRoles()) || in_array('ROLE_CONTACT', $groupe->getRoles()) || in_array('ROLE_GESTION_GROUPE', $groupe->getRoles())) && count($user->getGroupesGeres()) >= 1) {
$request->getSession()->set('_groupegere', $user->getGroupesGeres()[0]);
}
......@@ -125,8 +133,12 @@ class AfterLoginRedirection implements AuthenticationSuccessHandlerInterface
$groupe = $user->getGroups()->first();
if (in_array('ROLE_PRESTATAIRE', $groupe->getRoles()) && count($user->getPrestataires()) >= 1) {
$request->getSession()->set('_prestagere', $user->getPrestataires()[0]);
} elseif (in_array('ROLE_CAISSIER_PRESTATAIRE', $groupe->getRoles()) && count($user->getCaissierprestataires()) >= 1) {
$request->getSession()->set('_prestagere', $user->getCaissierprestataires()[0]);
} elseif (in_array('ROLE_COMPTOIR', $groupe->getRoles()) && count($user->getComptoirsGeres()) >= 1) {
$request->getSession()->set('_comptoirgere', $user->getComptoirsGeres()[0]);
} elseif (in_array('ROLE_CAISSIER_COMPTOIR', $groupe->getRoles()) && count($user->getCaissiercomptoirs()) >= 1) {
$request->getSession()->set('_comptoirgere', $user->getCaissiercomptoirs()[0]);
} elseif ((in_array('ROLE_TRESORIER', $groupe->getRoles()) || in_array('ROLE_CONTACT', $groupe->getRoles()) || in_array('ROLE_GESTION_GROUPE', $groupe->getRoles())) && count($user->getGroupesGeres()) >= 1) {
$request->getSession()->set('_groupegere', $user->getGroupesGeres()[0]);
}
......
<?php
/*
* kohinos_cooperatic
* Copyright (C) 2019-2020 ADML63
* Copyright (C) 2020- Cooperatic
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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 Version20210423123528 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->addSql('CREATE TABLE user_comptoir_caissier (comptoir_id INT NOT NULL, user_id INT NOT NULL, INDEX IDX_DC1FEA74AEB0C1F5 (comptoir_id), INDEX IDX_DC1FEA74A76ED395 (user_id), PRIMARY KEY(comptoir_id, user_id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_general_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE user_prestataire_caissier (prestataire_id INT NOT NULL, user_id INT NOT NULL, INDEX IDX_65D67ECEBE3DB2B7 (prestataire_id), INDEX IDX_65D67ECEA76ED395 (user_id), PRIMARY KEY(prestataire_id, user_id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_general_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE user_comptoir_caissier ADD CONSTRAINT FK_DC1FEA74AEB0C1F5 FOREIGN KEY (comptoir_id) REFERENCES comptoir (id)');
$this->addSql('ALTER TABLE user_comptoir_caissier ADD CONSTRAINT FK_DC1FEA74A76ED395 FOREIGN KEY (user_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE user_prestataire_caissier ADD CONSTRAINT FK_65D67ECEBE3DB2B7 FOREIGN KEY (prestataire_id) REFERENCES prestataire (id)');
$this->addSql('ALTER TABLE user_prestataire_caissier ADD CONSTRAINT FK_65D67ECEA76ED395 FOREIGN KEY (user_id) REFERENCES user (id)');
}
public function down(Schema $schema) : void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('DROP TABLE user_comptoir_caissier');
$this->addSql('DROP TABLE user_prestataire_caissier');
}
}
......@@ -73,6 +73,26 @@ class FluxRepository extends ServiceEntityRepository
}
/**
* @param Prestataire $presta [description]
* @return Query Returns a query fo finding an array of Flux
*/
public function getQueryByCaissierprestataire(Prestataire $presta)
{
$sqlQuery = "SELECT f.id FROM {$this->tableName} f WHERE (f.prestataire_id = :id OR f.prestataire_dest_id = :id) AND f.type = 'adherent_prestataire'";
$statement = $this->connection->prepare($sqlQuery);
$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)
->orderBy('f.createdAt', 'DESC')
->getQuery()
;
}
/**
* @param Adherent $adherent [description]
* @param string $parenttype Parent type of flux (cotisation, transfert, transaction, vente...)
* @return Query Returns a query fo finding an array of Flux
......
......@@ -209,10 +209,14 @@ class AppExtension extends AbstractExtension
{
$query = null;
if ($this->session->get('_prestagere') != null) {
if ($this->security->isGranted('ROLE_PRESTATAIRE')) {
$query = $this->em->getRepository(Flux::class)->getQueryByPrestataire($this->session->get('_prestagere'), $parenttype);
} elseif ($this->security->isGranted('ROLE_CAISSIER_PRESTATAIRE')) {
$query = $this->em->getRepository(Flux::class)->getQueryByCaissierprestataire($this->session->get('_prestagere'));
}
} elseif ($user->getAdherent() != null) {
$query = $this->em->getRepository(Flux::class)->getQueryByAdherent($user->getAdherent(), $parenttype);
} elseif ($this->session->get('_comptoirgere') != null) {
} elseif ($this->session->get('_comptoirgere') != null && ($this->security->isGranted('ROLE_COMPTOIR') || $this->security->isGranted('ROLE_CAISSIER_COMPTOIR'))) {
$query = $this->em->getRepository(Flux::class)->getQueryByComptoir($this->session->get('_comptoirgere'));
} elseif ($this->session->get('_groupegere') != null) {
$query = $this->em->getRepository(Flux::class)->getQueryByGroupe($this->session->get('_groupegere'));
......
......@@ -14,6 +14,11 @@
{{ 'PRESTATAIRE'|trans }}
</a>
{% endif %}
{% if isDevFixture('user_caissier_prestataire') %}
<a class='btn btn-xs m-1 btn-primary' href='{{path(routeName, [], true)}}?_switch_user=user_caissier_prestataire'>
{{ 'CAISSIER PRESTATAIRE'|trans }}
</a>
{% endif %}
{% if isDevFixture('user_adherent') %}
<a class='btn btn-xs m-1 btn-primary' href='{{path('index', [], true)}}?_switch_user=user_adherent'>
{{ 'ADHERENT'|trans }}
......@@ -29,6 +34,11 @@
{{ 'COMPTOIR'|trans }}
</a>
{% endif %}
{% if isDevFixture('user_caissier_comptoir') %}
<a class='btn btn-xs m-1 btn-primary' href='{{path(routeName, [], true)}}?_switch_user=user_caissier_comptoir'>
{{ 'CAISSIER COMPTOIR'|trans }}
</a>
{% endif %}
{% if isDevFixture('user_gestiongroupe') %}
<a class='btn btn-xs m-1 btn-primary' href='{{path(routeName, [], true)}}?_switch_user=user_gestiongroupe'>
{{ 'GESTION GROUPE'|trans }}
......@@ -142,6 +152,20 @@
{% include 'comptoir/block/retrait_adherent.html.twig' %}
{% include 'comptoir/block/reconversion.html.twig' %}
{% elseif app.user and is_granted('ROLE_CAISSIER_COMPTOIR') %}
{% if getCurrentComptoir() != null %}
{% set compte = getCurrentComptoir().compte %}
{% set soldelabel = 'Solde du comptoir "'|trans ~ getCurrentComptoir() ~ '"' %}
{% include 'block/solde.html.twig' with {'compte': compte, 'soldelabel': soldelabel} %}
{% endif %}
{% include 'block/transactions.html.twig' %}
{% include 'comptoir/block/vente_adherent.html.twig' %}
{% include 'comptoir/block/vente_prestataire.html.twig' %}
{% include 'comptoir/block/retrait_prestataire.html.twig' %}
{% include 'comptoir/block/retrait_adherent.html.twig' %}
{% include 'comptoir/block/reconversion.html.twig' %}
{% elseif app.user and is_granted('ROLE_CONTACT') %}
{% include 'groupe/block/infos.html.twig' %}
......@@ -185,6 +209,11 @@
{% include 'presta/block/reconversion.html.twig' %}
{% endif %}
{% elseif app.user and is_granted('ROLE_CAISSIER_PRESTATAIRE') %}
<!-- TODO : and if isCaissierOfPrestataire -->
{% include 'block/transactions.html.twig' %}
{% elseif app.user and is_granted('ROLE_ADHERENT') and app.user.adherent %}
{% set esoldelabel = 'Solde e-mlc'|trans %}
......
......@@ -16,12 +16,24 @@
<a role="button" class="btn btn-default btn-secondary" href='{{path('presta_choice', {'prestaid' : presta.id, 'usergrpid': group.id})}}'>{{ group.name|trans }} - {{presta}} </a>
</div>
{% endfor %}
{% elseif role == 'ROLE_CAISSIER_PRESTATAIRE' %}
{% for presta in app.user.caissierprestataires %}
<div class='col-6 text-center p-2'>
<a role="button" class="btn btn-default btn-secondary" href='{{path('presta_choice', {'prestaid' : presta.id, 'usergrpid': group.id})}}'>{{ group.name|trans }} - {{presta}} </a>
</div>
{% endfor %}
{% elseif role == 'ROLE_COMPTOIR' %}
{% for comptoir in app.user.comptoirsgeres %}
<div class='col-6 text-center p-2'>
<a role="button" class="btn btn-default btn-secondary" href='{{path('comptoir_choice', {'cptid' : comptoir.id, 'usergrpid': group.id})}}'>{{ group.name|trans }} - {{comptoir}} </a>
</div>
{% endfor %}
{% elseif role == 'ROLE_CAISSIER_COMPTOIR' %}
{% for comptoir in app.user.caissiercomptoirs %}
<div class='col-6 text-center p-2'>
<a role="button" class="btn btn-default btn-secondary" href='{{path('comptoir_choice', {'cptid' : comptoir.id, 'usergrpid': group.id})}}'>{{ group.name|trans }} - {{comptoir}} </a>
</div>
{% endfor %}
{% elseif role == 'ROLE_TRESORIER' or role == 'ROLE_CONTACT' or role == 'ROLE_GESTION_GROUPE' %}
{% for groupe in app.user.groupesgeres %}
<div class='col-6 text-center p-2'>
......
......@@ -21,7 +21,7 @@
<p>{{ 'Voulez-vous continuer ?'|trans }}</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">{{ 'Annuler'|trans }}</button>
<button type="button" class="btn btn-secondary" id="dismissTransactionButton" data-dismiss="modal">{{ 'Annuler'|trans }}</button>
<button type="button" class="btn btn-primary" id="confirmTransactionButton">{{ 'Confirmer'|trans }}</button>
</div>
</div>
......
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