Commit 6d88c9e1 by Julien Jorry

- Ajout des ecompte + compte nantie pour le siège

- Correction des flux (retrait, vente, transaction, transfert, cotisation, reconversion) avec fonction operate() et events
- Correction des back office pour le comptoir/groupe et le presta
- Ajout des events sur les flux (> envoi de mail)
- Corrections fixtures
- Correction carte openstreetmap comptoir
- Ajout de la configuration DoxyFile pour la documentation du code via Doxygen
parent 51a05627
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -3,4 +3,18 @@ body {
}
#mapid {
height: 360px;
}
.exportbutton .dropdown-menu>li>a {
color: #777;
display: block;
padding: 3px 20px;
clear: both;
font-weight: 400;
line-height: 1.42857143;
color: #333;
white-space: nowrap;
}
.exportbutton .dropdown-menu>li>a:hover {
background-color: #e1e3e9;
color: #333;
}
\ No newline at end of file
......@@ -104,18 +104,10 @@ api_platform:
# get: ~
# post: ~
# put: ~
# App\Entity\TransfertComptoirAdherent:
# get: ~
# post: ~
# put: ~
# App\Entity\TransfertComptoirGroupe:
# get: ~
# post: ~
# put: ~
# App\Entity\TransfertComptoirPrestataire:
# get: ~
# post: ~
# put: ~
# App\Entity\TransfertGroupeComptoir:
# get: ~
# post: ~
......@@ -124,10 +116,6 @@ api_platform:
# get: ~
# post: ~
# put: ~
# App\Entity\TransfertPrestataireComptoir:
# get: ~
# post: ~
# put: ~
# App\Entity\TransfertSiegeGroupe:
# get: ~
# post: ~
......
# See https://symfony.com/doc/current/email/dev_environment.html
swiftmailer:
# send all emails to a specific address
#delivery_addresses: ['me@example.com']
delivery_addresses: ['me@example.com']
......@@ -14,6 +14,7 @@ parameters:
app.mlc_title: 'Outil de gestion de monnaie locale complémentaire' # Nom complet (< 100 caractères)
app.mlc_name: 'Monnaie locale complémentaire' # Nom complet (< 100 caractères)
app.mlc_name_small: 'MLC' # Nom court (< 25 caractères)
app.mlc_notif_email: 'contact@mlc.com' # Email d'où sont envoyés les notifications
app.cotisation_montant: 10
app.map_center: '[45.7,3.2]'
app.map_zoom: 9
......@@ -117,6 +118,11 @@ services:
App\Controller\RegistrationController:
autowire: false
app.versionable.listener:
class: App\Listener\FluxListener
tags:
- { name: doctrine.event_subscriber, connection: default }
app.hidden_entity_type_extension:
class: App\Form\HiddenEntityExtension
tags:
......
......@@ -73,6 +73,7 @@ App\Entity\Usergroup:
'ROLE_ADMIN_ADHERENT_GERER_LIST',
'ROLE_ADMIN_ADHERENT_GERER_CREATE',
'ROLE_ADMIN_ADHERENT_GERER_VIEW',
'ROLE_ADMIN_ADHERENT_COTISATIONS_ALL',
'ROLE_ADMIN_COMPTOIR_GERER_EDIT',
'ROLE_ADMIN_COMPTOIR_GERER_VIEW',
'ROLE_ADMIN_TRANSFERT_GERER_LIST',
......
......@@ -446,17 +446,6 @@ App\Entity\TransactionPrestatairePrestataire:
destinataire: '@prestataire<numberBetween(11, 21)>'
createdAt: '<dateTimeBetween("-200 days", "now")>'
parenttype: 'transaction'
App\Entity\TransfertComptoirAdherent:
tre_cpt_adh{2..11}:
operateur: '@usercomptoir'
type: 'comptoir_adherent'
reference: 'test'
moyen: 'cb'
montant: '<randomFloat(2,1,2)>'
expediteur: '@comptoir<numberBetween(1,50)>'
destinataire: '@adherent<current()>'
createdAt: '<dateTimeBetween("-200 days", "now")>'
parenttype: 'transfert'
App\Entity\TransfertComptoirGroupe:
tre_cpt_grp{2..11}:
operateur: '@usercomptoir'
......@@ -468,17 +457,6 @@ App\Entity\TransfertComptoirGroupe:
destinataire: '@groupe<numberBetween(1,10)>'
createdAt: '<dateTimeBetween("-200 days", "now")>'
parenttype: 'transfert'
App\Entity\TransfertComptoirPrestataire:
tre_cpt_pre{2..11}:
operateur: '@usercomptoir'
type: 'comptoir_prestataire'
reference: 'test'
moyen: 'cb'
montant: '<randomFloat(2,1,2)>'
expediteur: '@comptoir<numberBetween(1,50)>'
destinataire: '@prestataire<numberBetween(1,32)>'
createdAt: '<dateTimeBetween("-200 days", "now")>'
parenttype: 'transfert'
App\Entity\TransfertGroupeComptoir:
tre_grp_cpt{1..10}:
operateur: '@usergestiongroupe'
......@@ -523,3 +501,47 @@ App\Entity\TransfertSiegeGroupe:
destinataire: '@groupe<numberBetween(1,10)>'
createdAt: '<dateTimeBetween("-200 days", "now")>'
parenttype: 'transfert'
App\Entity\VenteComptoirAdherent:
vte_cpt_adh{2..11}:
operateur: '@usercomptoir'
type: 'comptoir_adherent'
reference: 'vte_cpt_adh<current()>'
moyen: 'vente'
montant: '<randomFloat(2,1,2)>'
expediteur: '@comptoir<numberBetween(1,50)>'
destinataire: '@adherent<current()>'
createdAt: '<dateTimeBetween("-200 days", "now")>'
parenttype: 'vente'
App\Entity\VenteComptoirPrestataire:
vte_cpt_pre{2..11}:
operateur: '@usercomptoir'
type: 'comptoir_prestataire'
reference: 'vte_cpt_pre<current()>'
moyen: 'vente'
montant: '<randomFloat(2,1,2)>'
expediteur: '@comptoir<numberBetween(1,50)>'
destinataire: '@prestataire<current()>'
createdAt: '<dateTimeBetween("-200 days", "now")>'
parenttype: 'vente'
App\Entity\RetraitComptoirAdherent:
ret_cpt_adh{2..11}:
operateur: '@usercomptoir'
type: 'retrait_adherent'
reference: 'vte_cpt_adh<current()>'
moyen: 'retrait'
montant: '<randomFloat(2,1,2)>'
expediteur: '@comptoir<numberBetween(1,50)>'
destinataire: '@adherent<current()>'
createdAt: '<dateTimeBetween("-200 days", "now")>'
parenttype: 'retrait'
App\Entity\RetraitComptoirPrestataire:
ret_cpt_pre{2..11}:
operateur: '@usercomptoir'
type: 'retrait_prestataire'
reference: 'vte_cpt_pre<current()>'
moyen: 'retrait'
montant: '<randomFloat(2,1,2)>'
expediteur: '@comptoir<numberBetween(1,50)>'
destinataire: '@prestataire<current()>'
createdAt: '<dateTimeBetween("-200 days", "now")>'
parenttype: 'retrait'
......@@ -29,6 +29,7 @@ use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Security\Core\Security;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
/**
* Administration des adhérents
......@@ -158,7 +159,7 @@ class AdherentAdmin extends AbstractAdmin
'disabled' => true
));
}
$formMapper
$formMapper
->add('user.phone', TextType::class, array(
'label' => 'Téléphone :',
'required' => false
......@@ -211,7 +212,7 @@ class AdherentAdmin extends AbstractAdmin
// ))
// ->end();
// }
$formMapper
$formMapper
->with('Addresse', ['class' => 'col-md-7'])
->add('geoloc.adresse', TextType::class, array(
'label' => 'Addresse :',
......
......@@ -119,8 +119,8 @@ class CotisationAdmin extends AbstractAdmin
protected function configureRoutes(RouteCollection $collection)
{
$collection->remove('delete');
if ($this->security->getUser() != null && !($this->security->getUser()->isGranted('ROLE_TRESORIER') || $this->security->getUser()->isGranted('ROLE_SUPER_ADMIN'))) {
$collection->clearExcept('list');
if ($this->security->getUser() != null && !($this->security->getUser()->isGranted('ROLE_TRESORIER') || $this->security->getUser()->isGranted('ROLE_SUPER_ADMIN') || $this->security->getUser()->isGranted('ROLE_COMPTOIR'))) {
$collection->clearExcept(array('list', 'export'));
}
}
......
......@@ -44,7 +44,7 @@ class FluxAdmin extends AbstractAdmin
*/
protected function configureRoutes(RouteCollection $collection)
{
$collection->clearExcept('list');
$collection->clearExcept(array('list', 'export'));
}
/**
......
......@@ -4,6 +4,7 @@ namespace App\Admin;
use App\Admin\FluxAdmin;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Route\RouteCollection;
/**
* Administration des transactions
......@@ -72,4 +73,9 @@ class TransactionAdmin extends FluxAdmin
))
;
}
protected function configureRoutes(RouteCollection $collection)
{
$collection->clearExcept(array('list', 'export'));
}
}
......@@ -34,6 +34,11 @@ class TransfertAdmin extends FluxAdmin
$this->security = $security;
}
protected function configureRoutes(RouteCollection $collection)
{
$collection->clearExcept(array('list', 'export'));
}
/**
* {@inheritdoc}
*/
......@@ -59,7 +64,7 @@ class TransfertAdmin extends FluxAdmin
->setParameter('ids', $ids)
;
}
} else if ($user->isGranted('ROLE_COMPTOIR')) {
} elseif ($user->isGranted('ROLE_COMPTOIR')) {
if (empty($user->getComptoirsgere())) {
$query->andWhere('false');
} else {
......
......@@ -207,10 +207,10 @@ class UserAdmin extends BaseUserAdmin
;
$hideOrShowGroupe = ['class' => 'hide'];
$hideOrShowComptoir = ['class' => 'hide'];
if (($subject->isGranted('ROLE_GESTION_GROUPE') || $subject->isGranted('ROLE_CONTACT')) && !empty($subject->getGroupesgere())) {
if (($subject->isGranted('ROLE_GESTION_GROUPE') || $subject->isGranted('ROLE_CONTACT')) && empty($subject->getGroupesgere())) {
$hideOrShowGroupe = [];
}
if ($subject->isGranted('ROLE_COMPTOIR') && !empty($subject->getComptoirsgere())) {
if ($subject->isGranted('ROLE_COMPTOIR') && empty($subject->getComptoirsgere())) {
$hideOrShowComptoir = [];
}
$formMapper
......
......@@ -2,8 +2,11 @@
namespace App\Controller;
use App\Events\MLCEvents;
use App\Events\FluxEvent;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Form;
use Symfony\Component\HttpFoundation\Request;
......@@ -32,12 +35,15 @@ use Symfony\Component\Translation\TranslatorInterface;
*/
class FluxController extends AbstractController
{
protected $em;
protected $translator;
protected $eventDispatcher;
public function __construct(EntityManagerInterface $em, TranslatorInterface $translator)
public function __construct(EntityManagerInterface $em, TranslatorInterface $translator, EventDispatcherInterface $eventDispatcher)
{
$this->em = $em;
$this->translator = $translator;
$this->eventDispatcher = $eventDispatcher;
}
protected function manageFluxForm(Request $request, Form $form, $compte, $success, $title)
......@@ -51,6 +57,10 @@ class FluxController extends AbstractController
'success',
$success
);
$this->eventDispatcher->dispatch(
MLCEvents::FLUX,
new FluxEvent($data)
);
$referer = $request->headers->get('referer');
if ($referer && !$request->isXmlHttpRequest()) {
return $this->redirect($referer);
......@@ -61,7 +71,7 @@ class FluxController extends AbstractController
return $this->render('flux/transaction.html.twig', [
'form' => $form->createView(),
'compte' => $compte,
// 'compte' => $compte,
'title' => $title
]);
}
......
......@@ -77,7 +77,6 @@ class IndexController extends AbstractController
return $this->redirectToRoute('installation');
}
/* Pour la modale de login => SecurityController loginAction */
/** @var $session Session */
$session = $request->getSession();
$lastUsernameKey = Secur::LAST_USERNAME;
// last username entered by the user
......@@ -123,8 +122,8 @@ class IndexController extends AbstractController
'BRAVO ! Vous avez créer le siège et le premier utilisateur'
);
// if (null === $response = $event->getResponse()) {
$url = $this->generateUrl('fos_user_registration_confirmed');
$response = new RedirectResponse($url);
$url = $this->generateUrl('fos_user_registration_confirmed');
$response = new RedirectResponse($url);
// }
$this->eventDispatcher->dispatch(FOSUserEvents::REGISTRATION_COMPLETED, new FilterUserResponseEvent($user, $request, $response));
......
......@@ -7,21 +7,21 @@ use App\Entity\Cotisation;
use App\Entity\Geoloc;
use App\Entity\Groupe;
use App\Entity\TransactionAdherentPrestataire;
use App\Entity\TransfertComptoirAdherent;
use App\Entity\TransfertComptoirPrestataire;
use App\Entity\TransfertPrestataireComptoir;
use App\Entity\Usergroup;
use App\Entity\VenteComptoirAdherent;
use App\Entity\VenteComptoirPrestataire;
use App\Entity\RetraitComptoirAdherent;
use App\Entity\RetraitComptoirPrestataire;
use App\Form\Type\AdherentInfosFormType;
use App\Form\Type\AdhererFormType;
use App\Form\Type\GroupeInfosFormType;
use App\Form\Type\TransactionAdherentPrestataireFormType;
use App\Form\Type\TransfertComptoirAdherentFormType;
use App\Form\Type\TransfertComptoirPrestataireFormType;
use App\Form\Type\TransfertPrestataireComptoirFormType;
use App\Form\Type\VenteComptoirAdherentFormType;
use App\Form\Type\VenteComptoirPrestataireFormType;
use App\Form\Type\RetraitComptoirAdherentFormType;
use App\Form\Type\RetraitComptoirPrestataireFormType;
use Doctrine\ORM\EntityManagerInterface;
use FOS\UserBundle\Model\UserManagerInterface;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
......@@ -60,75 +60,111 @@ class UserComptoirController extends FluxController
return $this->redirectToRoute('index');
}
// /**
// * @Route("/user/comptoir/transfert/adherent/", name="transfertComptoirAdherent")
// * @IsGranted("ROLE_COMPTOIR")
// */
// public function transfertComptoirAdherentAction(Request $request)
// {
// $entity = new TransfertComptoirAdherent();
// $entity->setOperateur($this->getUser());
// $form = $this->createForm(TransfertComptoirAdherentFormType::class, $entity);
// return $this->manageFluxForm(
// $request,
// $form,
// $this->getUser()->getComptoirsgere()->getCompte(),
// $this->translator->trans('Transfert à un adhérent bien effectuée !'),
// $this->translator->trans('Transfert à un adhérent')
// );
// }
// /**
// * @Route("/user/comptoir/transfert/prestataire/", name="transfertComptoirPrestataire")
// * @IsGranted("ROLE_COMPTOIR")
// */
// public function transfertComptoirPrestataireAction(Request $request)
// {
// $entity = new TransfertComptoirPrestataire();
// $entity->setOperateur($this->getUser());
// $form = $this->createForm(TransfertComptoirPrestataireFormType::class, $entity);
// return $this->manageFluxForm(
// $request,
// $form,
// $this->getUser()->getComptoirsgere()->getCompte(),
// $this->translator->trans('Transfert à un prestataire bien effectuée !'),
// $this->translator->trans('Transfert à un prestataire')
// );
// }
/**
* @Route("/user/comptoir/transfert/adherent/", name="transfertComptoirAdherent")
* @Route("/user/comptoir/vente/adherent/", name="venteComptoirAdherent")
* @IsGranted("ROLE_COMPTOIR")
*/
public function transfertComptoirAdherentAction(Request $request)
public function venteComptoirAdherentAction(Request $request)
{
$entity = new TransfertComptoirAdherent();
$entity = new VenteComptoirAdherent();
$entity->setOperateur($this->getUser());
$form = $this->createForm(TransfertComptoirAdherentFormType::class, $entity);
$form = $this->createForm(VenteComptoirAdherentFormType::class, $entity);
return $this->manageFluxForm(
$request,
$form,
$this->getUser()->getComptoirsgere()->getCompte(),
$this->translator->trans('Transfert à un adhérent bien effectuée !'),
$this->translator->trans('Transfert à un adhérent')
$this->translator->trans('Vente à un adhérent bien effectuée !'),
$this->translator->trans('Vente à un adhérent')
);
}
/**
* @Route("/user/comptoir/transfert/prestataire/", name="transfertComptoirPrestataire")
* @Route("/user/comptoir/vente/prestataire/", name="venteComptoirPrestataire")
* @IsGranted("ROLE_COMPTOIR")
*/
public function transfertComptoirPrestataireAction(Request $request)
public function venteComptoirPrestataireAction(Request $request)
{
$entity = new TransfertComptoirPrestataire();
$entity = new VenteComptoirPrestataire();
$entity->setOperateur($this->getUser());
$form = $this->createForm(TransfertComptoirPrestataireFormType::class, $entity);
$form = $this->createForm(VenteComptoirPrestataireFormType::class, $entity);
return $this->manageFluxForm(
$request,
$form,
$this->getUser()->getComptoirsgere()->getCompte(),
$this->translator->trans('Transfert à un prestataire bien effectuée !'),
$this->translator->trans('Transfert à un prestataire')
$this->translator->trans('Vente à un prestataire bien effectuée !'),
$this->translator->trans('Vente à un prestataire')
);
}
/**
* @Route("/user/comptoir/vente/adherent/", name="venteComptoirAdherent")
* @Route("/user/comptoir/retrait/adherent/", name="retraitComptoirAdherent")
* @IsGranted("ROLE_COMPTOIR")
*/
public function venteComptoirAdherentAction(Request $request)
public function retraitComptoirAdherentAction(Request $request)
{
$entity = new VenteComptoirAdherent();
$entity = new RetraitComptoirAdherent();
$entity->setOperateur($this->getUser());
$form = $this->createForm(VenteComptoirAdherentFormType::class, $entity);
$form = $this->createForm(RetraitComptoirAdherentFormType::class, $entity);
return $this->manageFluxForm(
$request,
$form,
$this->getUser()->getComptoirsgere()->getCompte(),
$this->translator->trans('Vente à un adhérent bien effectuée !'),
$this->translator->trans('Vente à un adhérent')
$this->translator->trans("Retrait d'un adhérent bien effectuée !"),
$this->translator->trans("Retrait d'un adhérent")
);
}
/**
* @Route("/user/comptoir/vente/prestataire/", name="venteComptoirPrestataire")
* @Route("/user/comptoir/retrait/prestataire/", name="retraitComptoirPrestataire")
* @IsGranted("ROLE_COMPTOIR")
*/
public function venteComptoirPrestataireAction(Request $request)
public function retraitComptoirPrestataireAction(Request $request)
{
$entity = new VenteComptoirPrestataire();
$entity = new RetraitComptoirPrestataire();
$entity->setOperateur($this->getUser());
$form = $this->createForm(VenteComptoirPrestataireFormType::class, $entity);
$form = $this->createForm(RetraitComptoirPrestataireFormType::class, $entity);
return $this->manageFluxForm(
$request,
$form,
$this->getUser()->getComptoirsgere()->getCompte(),
$this->translator->trans('Vente à un prestataire bien effectuée !'),
$this->translator->trans('Vente à un prestataire')
$this->translator->trans("Retrait d'un prestataire bien effectuée !"),
$this->translator->trans("Retrait d'un prestataire")
);
}
......
......@@ -2,6 +2,7 @@
namespace App\Controller;
use App\Entity\Flux;
use App\Entity\Prestataire;
use App\Entity\Rubrique;
use App\Entity\TransactionPrestataireAdherent;
......@@ -13,6 +14,9 @@ use App\Form\Type\TransactionPrestataireAdherentFormType;
use App\Form\Type\TransfertPrestataireSiegeFormType;
use Doctrine\ORM\EntityManagerInterface;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
use Sonata\Exporter\Handler;
use Sonata\Exporter\Source\DoctrineORMQuerySourceIterator;
use Sonata\Exporter\Writer\CsvWriter;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
......@@ -119,4 +123,70 @@ class UserPrestataireController extends FluxController
$this->translator->trans('Reconversion de monnaie au siège')
);
}
/**
* Export all transferts / transactions for prestataire
*
* @param Request $request Request
* @param String $format Format of export ('json', 'xml', 'csv', 'xls')
* @Route("/prestataire/export/{format}/", name="exportPrestaFlux", defaults={"format": "csv"})
* @IsGranted("ROLE_PRESTATAIRE")
*/
public function exportFluxAction(Request $request, $format = 'csv')
{
// Prepare the data source
$query = $this->em->getRepository(Flux::class)->getQueryByPrestataire($this->getUser()->getPrestataire());
$fields = ['expediteur', 'destinataire', 'type', 'parenttype', 'montant', 'moyen', 'operateur'];
$source = new DoctrineORMQuerySourceIterator($query, $fields);
$filename = sprintf(
'export_flux_%s.%s',
date('Y_m_d_H_i_s', strtotime('now')),
$format
);
return $this->getResponse(
$format,
$filename,
$source
);
}
private function getResponse($format, $filename, SourceIteratorInterface $source)
{
switch ($format) {
case 'xls':
$writer = new XlsWriter('php://output');
$contentType = 'application/vnd.ms-excel';
break;
case 'xml':
$writer = new XmlWriter('php://output');
$contentType = 'text/xml';
break;
case 'json':
$writer = new JsonWriter('php://output');
$contentType = 'application/json';
break;
case 'csv':
$writer = new CsvWriter('php://output', ',', '"', '\\', true, true);
$contentType = 'text/csv';
break;
default:
throw new \RuntimeException('Invalid format');
}
$callback = static function () use ($source, $writer) {
$handler = Handler::create($source, $writer);
$handler->export();
};
return new StreamedResponse($callback, 200, [
'Content-Type' => $contentType,
'Content-Disposition' => sprintf('attachment; filename="%s"', $filename),
]);
}
}
<?php
namespace AppBundle\DataFixtures\ORM;
use Hautelook\AliceBundle\Alice\DataFixtureLoader;
use Nelmio\Alice\Fixtures;
class AppFixtures extends DataFixtureLoader
{
/**
* {@inheritDoc}
*/
protected function getFixtures()
{
return array(
__DIR__ . '/user.yaml',
);
}
}
App\Entity\User:
user{1..30}:
username: <userName()>
email: <email()>
plainPassword: 'test'
enabled: true
App\Entity\Prestataire:
prestataire{1..5}:
raison: <text(10)>
metier: <text(10)>
iban: <randomNumber(20)>
statut: <text(10)>
siret: <randomNumber(10)>
user: '@user<current()>'
typeprestataire: 'prestataire'
App\Entity\Prestataire:
prestataire{1..5}:
raison: <text(10)>
metier: <text(10)>
iban: <randomNumber(20)>
statut: <text(10)>
siret: <randomNumber(10)>
user: '@user<current()>'
typeprestataire: 'partenaire'
App\Entity\Comptoir:
comptoir{1..15}:
name: <text(10)>
user: '@user<current()>'
App\Entity\Groupe:
groupe{1..3}:
__construct: [<text(10)>]
users: '10x @user*'
gestionnaires: '2x @user*'
redacteurs: '2x @user*'
tresoriers: '1x @user*'
contacts: '2x @user*'
prestataires: '5x @prestataire*'
comptoirs: '5x @comptoir*'
\ No newline at end of file
......@@ -4,6 +4,7 @@ namespace App\Entity;
use App\Entity\EntityTrait\EnablableEntityTrait;
use App\Entity\EntityTrait\GeolocEntityTrait;
use App\Entity\EntityTrait\HasEcompteEntity;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Timestampable\Traits\TimestampableEntity;
......@@ -15,7 +16,8 @@ class Adherent
{
use EnablableEntityTrait,
TimestampableEntity,
GeolocEntityTrait;
GeolocEntityTrait,
HasEcompteEntity;
/**
* @ORM\Id()
......@@ -25,11 +27,6 @@ class Adherent
private $id;
/**
* @ORM\Column(type="decimal", precision=7, scale=2)
*/
private $ecompte;
/**
* @var User
*
* @ORM\OneToOne(targetEntity="User", cascade={"all"}, mappedBy="adherent", fetch="LAZY")
......@@ -48,26 +45,14 @@ class Adherent
return $this->id;
}
public function getEcompte(): float
{
return $this->ecompte;
}
public function setEcompte(float $ecompte): self
{
$this->ecompte = $ecompte;
return $this;
}
public function getCompte(): float
{
return $this->ecompte;
return $this->getEcompte();
}
public function setCompte(float $ecompte): self
{
$this->ecompte = $ecompte;
$this->setEcompte($ecompte);
return $this;
}
......
......@@ -34,12 +34,33 @@ class Cotisation extends Flux
$this->cotisationInfos = new CotisationInfos();
}
public function operate()
{
$compteExp = $this->getExpediteur()->getEcompte() - $this->getMontant();
if ($this->getMoyen() == MoyenEnum::MOYEN_MLC) {
if ($compteExp < 0) {
throw new \Exception("[FLUX] Opération impossible ! Montant supérieur au solde de l'expéditeur !");
} else {
$this->getExpediteur()->removeEcompte($this->getMontant());
$this->getDestinataire()->addEcompte($this->getMontant());
return [$this->getExpediteur(), $this->getDestinataire()];
}
}
return [];
}
public function getUsersToNotify()
{
return ['siege'];
}
/**
* @return string
*/
public function getParenttype(): string
{
return 'cotisation';
return self::TYPE_COTISATION;
}
/**
......
......@@ -9,6 +9,7 @@ use Symfony\Component\Validator\Constraints as Assert;
trait HasCompteEntity
{
/**
* Compte de billets
* @var int
*
* @ORM\Column(name="compte", type="decimal", precision=12, scale=2)
......@@ -32,4 +33,26 @@ trait HasCompteEntity
$this->compte = $compte;
return $this;
}
/**
* Incremente le compte
* @param int $compte
* @return $this
*/
public function addCompte(float $compte)
{
$this->compte += $compte;
return $this;
}
/**
* Décremente le compte
* @param int $compte
* @return $this
*/
public function removeCompte(float $compte)
{
$this->compte -= $compte;
return $this;
}
}
<?php
namespace App\Entity\EntityTrait;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Component\Validator\Constraints as Assert;
trait HasEcompteEntity
{
/**
* Compte de MLC numérique
* @var int
*
* @ORM\Column(name="ecompte", type="decimal", precision=12, scale=2)
*/
private $ecompte = 0;
/**
* @return int
*/
public function getEcompte(): float
{
return $this->ecompte;
}
/**
* @param int $ecompte
* @return $this
*/
public function setEcompte(float $ecompte)
{
$this->ecompte = $ecompte;
return $this;
}
/**
* Incremente le ecompte
* @param int $ecompte
* @return $this
*/
public function addEcompte(float $ecompte)
{
$this->ecompte += $ecompte;
return $this;
}
/**
* Décremente le ecompte
* @param int $ecompte
* @return $this
*/
public function removeEcompte(float $ecompte)
{
$this->ecompte -= $ecompte;
return $this;
}
}
......@@ -15,15 +15,17 @@ use Symfony\Component\Validator\Constraints as Assert;
* @ORM\HasLifecycleCallbacks()
* @ORM\InheritanceType("SINGLE_TABLE")
* @ORM\DiscriminatorColumn(name="discr", type="string")
* @ORM\DiscriminatorMap({"cotisation" = "Cotisation", "cotisation_adherent" = "CotisationAdherent", "cotisation_prestataire" = "CotisationPrestataire", "tro_adh_pre" = "TransactionAdherentPrestataire", "tro_adh_adh" = "TransactionAdherentAdherent", "tro_pre_adh" = "TransactionPrestataireAdherent", "tro_pre_pre" = "TransactionPrestatairePrestataire", "tre_cpt_adh" = "TransfertComptoirAdherent", "tre_cpt_grp" = "TransfertComptoirGroupe", "tre_cpt_pre" = "TransfertComptoirPrestataire", "tre_grp_cpt" = "TransfertGroupeComptoir", "tre_pre_cpt" = "TransfertPrestataireComptoir", "tre_pre_sie" = "TransfertPrestataireSiege", "tre_sie_grp" = "TransfertSiegeGroupe", "tre_grp_sie" = "TransfertGroupeSiege", "vte_cpt_pre" = "VenteComptoirPrestataire", "vte_cpt_adh" = "VenteComptoirAdherent"})
* @ORM\DiscriminatorMap({"cotisation" = "Cotisation", "cotisation_adherent" = "CotisationAdherent", "cotisation_prestataire" = "CotisationPrestataire", "tro_adh_pre" = "TransactionAdherentPrestataire", "tro_adh_adh" = "TransactionAdherentAdherent", "tro_pre_adh" = "TransactionPrestataireAdherent", "tro_pre_pre" = "TransactionPrestatairePrestataire", "tre_cpt_grp" = "TransfertComptoirGroupe", "tre_grp_cpt" = "TransfertGroupeComptoir", "tre_pre_cpt" = "TransfertPrestataireComptoir", "tre_pre_sie" = "TransfertPrestataireSiege", "tre_sie_grp" = "TransfertSiegeGroupe", "tre_grp_sie" = "TransfertGroupeSiege", "vte_cpt_pre" = "VenteComptoirPrestataire", "vte_cpt_adh" = "VenteComptoirAdherent", "ret_cpt_pre" = "RetraitComptoirPrestataire", "ret_cpt_adh" = "RetraitComptoirAdherent"})
*/
abstract class Flux
{
use TimestampableEntity;
const TYPE_COTISATION = 'cotisation';
const TYPE_TRANSFERT = 'transfert';
const TYPE_TRANSACTION = 'transaction';
const TYPE_VENTE = 'vente';
const TYPE_RETRAIT = 'retrait';
/**
* @var int
......@@ -91,6 +93,21 @@ abstract class Flux
abstract public function getParenttype();
/**
* Effectuer l'opération (transfert, transaction, vente, retrait...)
* @return array Tableau des entité(s) à persister (siege, comptoir, groupe, presta, adherent...)
*/
abstract public function operate();
/**
* Obtenir la liste des utilisateurs à notifier
* @return array Tableau d'utilisateurs
*/
public function getUsersToNotify()
{
return [];
}
public function __construct()
{
$this->parenttype = $this->getParenttype();
......@@ -257,23 +274,7 @@ abstract class Flux
throw new \Exception("[FLUX] Opération impossible ! Montant inférieur ou égal à zéro !");
}
if ($flux->getExpediteur() == $flux->getDestinataire()) {
throw new \Exception("[FLUX] Opération impossible ! Expediteur et destinataire sont les mêmes !");
}
$compteExp = $flux->getExpediteur()->getCompte() - $flux->getMontant();
if ($flux->getParenttype() != 'cotisation' || ($flux->getParenttype() == 'cotisation' && $flux->getMoyen() == MoyenEnum::MOYEN_MLC)) {
if ($compteExp < 0) {
throw new \Exception("[FLUX] Opération impossible ! Montant supérieur au solde de l'expéditeur !");
} else {
$em = $event->getEntityManager();
$flux->getExpediteur()->setCompte($compteExp);
$em->persist($flux->getExpediteur());
if ($flux->getParenttype() != 'vente') {
$compteDest = $flux->getDestinataire()->getCompte() + $flux->getMontant();
$flux->getDestinataire()->setCompte($compteDest);
$em->persist($flux->getDestinataire());
}
$em->flush();
}
throw new \Exception("[FLUX] Opération impossible ! Expéditeur et Destinataire ne peuvent pas être les mêmes !");
}
}
......
<?php
/**
* AMAP class
*
* @package Default
* @author
**/
namespace App\Entity;
use App\Entity\EntityTrait\ContactEmailTelTrait;
......
......@@ -5,6 +5,7 @@ namespace App\Entity;
use App\Entity\EntityTrait\EnablableEntityTrait;
use App\Entity\EntityTrait\GeolocEntityTrait;
use App\Entity\EntityTrait\HasCompteEntity;
use App\Entity\EntityTrait\HasEcompteEntity;
use App\Entity\Groupeprestataire;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
......@@ -23,7 +24,8 @@ class Prestataire
use EnablableEntityTrait,
TimestampableEntity,
GeolocEntityTrait,
HasCompteEntity;
HasCompteEntity,
HasEcompteEntity;
/**
* @var int
......@@ -133,11 +135,11 @@ class Prestataire
*/
protected $media;
/**
* @var User
*
* @ORM\OneToOne(targetEntity="User", cascade={"all"}, mappedBy="prestataire", fetch="LAZY")
*/
/**
* @var User
*
* @ORM\OneToOne(targetEntity="User", cascade={"all"}, mappedBy="prestataire", fetch="LAZY")
*/
protected $user;
/**
......
<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Retrait => (Retrait de monnaie papier en échange de monnaie numérique)
*
* Types de retraits :
*
* - ADHERENTS => COMPTOIR (Retrait d'un adherent)
* - PRESTATAIRES => COMPTOIR (Retrait d'un prestataire)
*
* @ORM\Entity
*/
abstract class Retrait extends Flux
{
/**
* @ORM\OneToOne(targetEntity="Comptoir")
* @ORM\JoinColumn(name="comptoir_id", referencedColumnName="id")
*/
protected $expediteur;
/**
* @return string
*/
public function getParenttype(): string
{
return self::TYPE_RETRAIT;
}
public function operate()
{
$compteExp = $this->getExpediteur()->getCompte() - $this->getMontant();
if ($compteExp < 0) {
throw new \Exception("[FLUX] Retrait impossible ! Montant supérieur au solde du comptoir !");
} else {
$this->getExpediteur()->removeCompte($this->getMontant());
$this->getExpediteur()->getGroupe()->getSiege()->addCompteNantie($this->getMontant());
$this->getDestinataire()->removeEcompte($this->getMontant());
return [$this->getExpediteur(), $this->getDestinataire(), $this->getExpediteur()->getGroupe()->getSiege()];
}
return [];
}
public function getUsersToNotify()
{
return array_merge($this->getExpediteur()->getGestionnaires()->toArray(), [$this->getDestinataire()->getUser()]);
}
}
......@@ -5,22 +5,16 @@ namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* TRANSFERT
* - COMPTOIRS => ADHERENTS (Diffusion de monnaie papier auprès des adhérents)
* RETRAIT
* - ADHERENTS => COMPTOIR (Retrait d'un adherent)
*
* @ORM\Entity()
*/
class TransfertComptoirAdherent extends Transfert
class RetraitComptoirAdherent extends Retrait
{
/**
* @ORM\OneToOne(targetEntity="Comptoir")
* @ORM\JoinColumn(name="comptoir_id", referencedColumnName="id", nullable=true)
*/
protected $expediteur;
/**
* @ORM\OneToOne(targetEntity="Adherent")
* @ORM\JoinColumn(name="adherent_id", referencedColumnName="id", nullable=true)
* @ORM\JoinColumn(name="adherent_id", referencedColumnName="id")
*/
protected $destinataire;
......@@ -29,11 +23,6 @@ class TransfertComptoirAdherent extends Transfert
*/
public function getType(): string
{
return 'comptoir_adherent';
}
public function isVente()
{
return false;
return 'retrait_adherent';
}
}
......@@ -5,22 +5,16 @@ namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* TRANSFERT
* - COMPTOIRS => PRESTATAIRES (Transfert de monnaie virtuelle auprès des prestataires)
* RETRAIT
* - PRESTATAIRES => COMPTOIR (Retrait d'un prestataire)
*
* @ORM\Entity()
*/
class TransfertComptoirPrestataire extends Transfert
class RetraitComptoirPrestataire extends Retrait
{
/**
* @ORM\OneToOne(targetEntity="Comptoir")
* @ORM\JoinColumn(name="comptoir_id", referencedColumnName="id", nullable=true)
*/
protected $expediteur;
/**
* @ORM\OneToOne(targetEntity="Prestataire")
* @ORM\JoinColumn(name="prestataire_id", referencedColumnName="id", nullable=true)
* @ORM\JoinColumn(name="prestataire_id", referencedColumnName="id")
*/
protected $destinataire;
......@@ -29,6 +23,6 @@ class TransfertComptoirPrestataire extends Transfert
*/
public function getType(): string
{
return 'comptoir_prestataire';
return 'retrait_prestataire';
}
}
......@@ -32,6 +32,13 @@ class Siege
*/
private $groupes;
/**
* @var int
*
* @ORM\Column(name="compte_nantie", type="decimal", precision=12, scale=2)
*/
private $compteNantie = 0;
public function __construct()
{
$this->groupes = new ArrayCollection();
......@@ -46,6 +53,44 @@ class Siege
}
/**
* @return int
*/
public function getCompteNantie(): float
{
return $this->compteNantie;
}
/**
* @param int $compteNantie
* @return $this
*/
public function setCompteNantie(float $compteNantie)
{
$this->compteNantie = $compteNantie;
return $this;
}
/**
* @param int $compteNantie
* @return $this
*/
public function addCompteNantie(float $compteNantie)
{
$this->compteNantie += $compteNantie;
return $this;
}
/**
* @param int $compteNantie
* @return $this
*/
public function removeCompteNantie(float $compteNantie)
{
$this->compteNantie -= $compteNantie;
return $this;
}
/**
* @return Groupe[]|ArrayCollection
*/
public function getGroupes()
......
......@@ -31,4 +31,23 @@ abstract class Transaction extends Flux
{
return self::TYPE_TRANSACTION;
}
public function operate()
{
$compteExp = $this->getExpediteur()->getEcompte() - $this->getMontant();
if ($compteExp < 0) {
throw new \Exception("[FLUX] Transaction impossible ! Montant supérieur au solde de l'expéditeur !");
} else {
$this->getExpediteur()->removeEcompte($this->getMontant());
$this->getDestinataire()->addEcompte($this->getMontant());
return [$this->getExpediteur(), $this->getDestinataire()];
}
return [];
}
public function getUsersToNotify()
{
return [$this->getDestinataire()->getUser(), $this->getExpediteur()->getUser()];
}
}
......@@ -17,14 +17,14 @@ class TransactionAdherentAdherent extends Transaction
{
/**
* @ORM\OneToOne(targetEntity="Adherent")
* @ORM\JoinColumn(name="adherent_id", referencedColumnName="id", nullable=true)
* @ORM\JoinColumn(name="adherent_id", referencedColumnName="id")
* @Assert\NotBlank
*/
protected $expediteur;
/**
* @ORM\OneToOne(targetEntity="Adherent")
* @ORM\JoinColumn(name="adherent_dest_id", referencedColumnName="id", nullable=true)
* @ORM\JoinColumn(name="adherent_dest_id", referencedColumnName="id")
* @Assert\NotBlank
*/
protected $destinataire;
......
......@@ -17,14 +17,14 @@ class TransactionAdherentPrestataire extends Transaction
{
/**
* @ORM\OneToOne(targetEntity="Adherent")
* @ORM\JoinColumn(name="adherent_id", referencedColumnName="id", nullable=true)
* @ORM\JoinColumn(name="adherent_id", referencedColumnName="id")
* @Assert\NotBlank
*/
protected $expediteur;
/**
* @ORM\OneToOne(targetEntity="Prestataire")
* @ORM\JoinColumn(name="prestataire_id", referencedColumnName="id", nullable=true)
* @ORM\JoinColumn(name="prestataire_id", referencedColumnName="id")
* @Assert\NotBlank
*/
protected $destinataire;
......
......@@ -15,14 +15,14 @@ class TransactionPrestataireAdherent extends Transaction
{
/**
* @ORM\OneToOne(targetEntity="Prestataire")
* @ORM\JoinColumn(name="prestataire_id", referencedColumnName="id", nullable=true)
* @ORM\JoinColumn(name="prestataire_id", referencedColumnName="id")
* @Assert\NotBlank
*/
protected $expediteur;
/**
* @ORM\OneToOne(targetEntity="Adherent")
* @ORM\JoinColumn(name="adherent_id", referencedColumnName="id", nullable=true)
* @ORM\JoinColumn(name="adherent_id", referencedColumnName="id")
* @Assert\NotBlank
*/
protected $destinataire;
......
......@@ -15,14 +15,14 @@ class TransactionPrestatairePrestataire extends Transaction
{
/**
* @ORM\OneToOne(targetEntity="Prestataire")
* @ORM\JoinColumn(name="prestataire_id", referencedColumnName="id", nullable=true)
* @ORM\JoinColumn(name="prestataire_id", referencedColumnName="id")
* @Assert\NotBlank
*/
protected $expediteur;
/**
* @ORM\OneToOne(targetEntity="Prestataire")
* @ORM\JoinColumn(name="prestataire_dest_id", referencedColumnName="id", nullable=true)
* @ORM\JoinColumn(name="prestataire_dest_id", referencedColumnName="id")
* @Assert\NotBlank
*/
protected $destinataire;
......
......@@ -34,4 +34,18 @@ abstract class Transfert extends Flux
{
return self::TYPE_TRANSFERT;
}
public function operate()
{
$compteExp = $this->getExpediteur()->getCompte() - $this->getMontant();
if ($compteExp < 0) {
throw new \Exception("[FLUX] Transfert impossible ! Montant supérieur au solde de l'expéditeur !");
} else {
$this->getExpediteur()->removeCompte($this->getMontant());
$this->getDestinataire()->addCompte($this->getMontant());
return [$this->getExpediteur(), $this->getDestinataire()];
}
return [];
}
}
......@@ -14,13 +14,13 @@ class TransfertComptoirGroupe extends Transfert
{
/**
* @ORM\OneToOne(targetEntity="Comptoir")
* @ORM\JoinColumn(name="comptoir_id", referencedColumnName="id", nullable=true)
* @ORM\JoinColumn(name="comptoir_id", referencedColumnName="id")
*/
protected $expediteur;
/**
* @ORM\OneToOne(targetEntity="Groupe")
* @ORM\JoinColumn(name="groupe_id", referencedColumnName="id", nullable=true)
* @ORM\JoinColumn(name="groupe_id", referencedColumnName="id")
*/
protected $destinataire;
......@@ -31,4 +31,9 @@ class TransfertComptoirGroupe extends Transfert
{
return 'comptoir_groupe';
}
public function getUsersToNotify()
{
return array_merge($this->getExpediteur()->getGestionnaires()->toArray(), $this->getDestinataire()->getGestionnaires()->toArray());
}
}
......@@ -14,13 +14,13 @@ class TransfertGroupeComptoir extends Transfert
{
/**
* @ORM\OneToOne(targetEntity="Groupe")
* @ORM\JoinColumn(name="groupe_id", referencedColumnName="id", nullable=true)
* @ORM\JoinColumn(name="groupe_id", referencedColumnName="id")
*/
protected $expediteur;
/**
* @ORM\OneToOne(targetEntity="Comptoir")
* @ORM\JoinColumn(name="comptoir_id", referencedColumnName="id", nullable=true)
* @ORM\JoinColumn(name="comptoir_id", referencedColumnName="id")
*/
protected $destinataire;
......@@ -31,4 +31,9 @@ class TransfertGroupeComptoir extends Transfert
{
return 'groupe_comptoir';
}
public function getUsersToNotify()
{
return array_merge($this->getExpediteur()->getGestionnaires()->toArray(), $this->getDestinataire()->getGestionnaires()->toArray());
}
}
......@@ -14,13 +14,13 @@ class TransfertGroupeSiege extends Transfert
{
/**
* @ORM\OneToOne(targetEntity="Groupe")
* @ORM\JoinColumn(name="groupe_id", referencedColumnName="id", nullable=true)
* @ORM\JoinColumn(name="groupe_id", referencedColumnName="id")
*/
protected $expediteur;
/**
* @ORM\OneToOne(targetEntity="Siege")
* @ORM\JoinColumn(name="siege_id", referencedColumnName="id", nullable=true)
* @ORM\JoinColumn(name="siege_id", referencedColumnName="id")
*/
protected $destinataire;
......@@ -31,4 +31,10 @@ class TransfertGroupeSiege extends Transfert
{
return 'groupe_siege';
}
public function getUsersToNotify()
{
// @TODO : notify siege ?
return $this->getExpediteur()->getGestionnaires()->toArray();
}
}
......@@ -14,13 +14,13 @@ class TransfertPrestataireComptoir extends Transfert
{
/**
* @ORM\OneToOne(targetEntity="Prestataire")
* @ORM\JoinColumn(name="prestataire_id", referencedColumnName="id", nullable=true)
* @ORM\JoinColumn(name="prestataire_id", referencedColumnName="id")
*/
protected $expediteur;
/**
* @ORM\OneToOne(targetEntity="Comptoir")
* @ORM\JoinColumn(name="comptoir_id", referencedColumnName="id", nullable=true)
* @ORM\JoinColumn(name="comptoir_id", referencedColumnName="id")
*/
protected $destinataire;
......@@ -31,4 +31,18 @@ class TransfertPrestataireComptoir extends Transfert
{
return 'prestataire_comptoir';
}
public function operate()
{
$this->getExpediteur()->addEcompte($this->getMontant());
$this->getDestinataire()->addCompte($this->getMontant());
$this->getDestinataire()->getGroupe()->getSiege()->addCompteNantie($this->getMontant());
return [$this->getExpediteur(), $this->getDestinataire()];
}
public function getUsersToNotify()
{
return array_merge($this->getDestinataire()->getGestionnaires()->toArray(), [$this->getExpediteur()->getUser()]);
}
}
......@@ -15,13 +15,13 @@ class TransfertPrestataireSiege extends Transfert
{
/**
* @ORM\OneToOne(targetEntity="Prestataire")
* @ORM\JoinColumn(name="prestataire_id", referencedColumnName="id", nullable=true)
* @ORM\JoinColumn(name="prestataire_id", referencedColumnName="id")
*/
protected $expediteur;
/**
* @ORM\OneToOne(targetEntity="Siege")
* @ORM\JoinColumn(name="siege_id", referencedColumnName="id", nullable=true)
* @ORM\JoinColumn(name="siege_id", referencedColumnName="id")
*/
protected $destinataire;
......@@ -56,4 +56,19 @@ class TransfertPrestataireSiege extends Transfert
{
return 'prestataire_siege'; //reconversion
}
public function operate()
{
$flux->getExpediteur()->removeEcompte($this->getMontant());
$flux->getDestinataire()->addCompte($this->getMontant());
$this->getDestinataire()->removeCompteNantie($this->getMontant());
return [$this->getExpediteur(), $this->getDestinataire()];
}
public function getUsersToNotify()
{
// @TODO : notify siege ?
return [$this->getExpediteur()->getUser()];
}
}
......@@ -14,13 +14,13 @@ class TransfertSiegeGroupe extends Transfert
{
/**
* @ORM\OneToOne(targetEntity="Siege")
* @ORM\JoinColumn(name="siege_id", referencedColumnName="id", nullable=true)
* @ORM\JoinColumn(name="siege_id", referencedColumnName="id")
*/
protected $expediteur;
/**
* @ORM\OneToOne(targetEntity="Groupe")
* @ORM\JoinColumn(name="groupe_id", referencedColumnName="id", nullable=true)
* @ORM\JoinColumn(name="groupe_id", referencedColumnName="id")
*/
protected $destinataire;
......@@ -31,4 +31,10 @@ class TransfertSiegeGroupe extends Transfert
{
return 'siege_groupe';
}
public function getUsersToNotify()
{
// @TODO : notify siege ?
return $this->getDestinataire()->getGestionnaires()->toArray();
}
}
......@@ -124,6 +124,14 @@ class User extends BaseUser
*/
protected $groups;
/**
* Alerte email à chaque transaction concernant l'utilisateur
* @var bool
*
* @ORM\Column(name="alertemailflux", type="boolean", nullable=false)
*/
protected $alertemailflux;
public function __construct()
{
parent::__construct();
......@@ -132,6 +140,7 @@ class User extends BaseUser
$this->emailTokens = new ArrayCollection();
$this->faqs = new ArrayCollection();
$this->news = new ArrayCollection();
$this->alertemailflux = true;
$this->createApiKey();
}
......@@ -486,4 +495,23 @@ class User extends BaseUser
return $this;
}
/**
* Get alertemailflux
* @return
*/
public function getAlertemailflux()
{
return $this->alertemailflux;
}
/**
* Set alertemailflux
* @return $this
*/
public function setAlertemailflux($alertemailflux)
{
$this->alertemailflux = $alertemailflux;
return $this;
}
}
......@@ -17,10 +17,35 @@ use Doctrine\ORM\Mapping as ORM;
abstract class Vente extends Flux
{
/**
* @ORM\OneToOne(targetEntity="Comptoir")
* @ORM\JoinColumn(name="comptoir_id", referencedColumnName="id")
*/
protected $expediteur;
/**
* @return string
*/
public function getParenttype(): string
{
return self::TYPE_VENTE;
}
public function operate()
{
$compteExp = $this->getExpediteur()->getCompte() - $this->getMontant();
if ($compteExp < 0) {
throw new \Exception("[FLUX] Vente impossible ! Montant supérieur au solde du comptoir !");
} else {
$this->getExpediteur()->removeCompte($this->getMontant());
$this->getExpediteur()->getGroupe()->getSiege()->addCompteNantie($this->getMontant());
return [$this->getExpediteur(), $this->getExpediteur()->getGroupe()->getSiege()];
}
return [];
}
public function getUsersToNotify()
{
return array_merge($this->getExpediteur()->getGestionnaires()->toArray(), [$this->getDestinataire()->getUser()]);
}
}
......@@ -13,14 +13,8 @@ use Doctrine\ORM\Mapping as ORM;
class VenteComptoirAdherent extends Vente
{
/**
* @ORM\OneToOne(targetEntity="Comptoir")
* @ORM\JoinColumn(name="comptoir_id", referencedColumnName="id", nullable=true)
*/
protected $expediteur;
/**
* @ORM\OneToOne(targetEntity="Adherent")
* @ORM\JoinColumn(name="adherent_id", referencedColumnName="id", nullable=true)
* @ORM\JoinColumn(name="adherent_id", referencedColumnName="id")
*/
protected $destinataire;
......
......@@ -13,14 +13,8 @@ use Doctrine\ORM\Mapping as ORM;
class VenteComptoirPrestataire extends Vente
{
/**
* @ORM\OneToOne(targetEntity="Comptoir")
* @ORM\JoinColumn(name="comptoir_id", referencedColumnName="id", nullable=true)
*/
protected $expediteur;
/**
* @ORM\OneToOne(targetEntity="Prestataire")
* @ORM\JoinColumn(name="prestataire_id", referencedColumnName="id", nullable=true)
* @ORM\JoinColumn(name="prestataire_id", referencedColumnName="id")
*/
protected $destinataire;
......
......@@ -13,6 +13,7 @@ abstract class MoyenEnum
const MOYEN_MLC = "mlc";
const MOYEN_AUTRE = "autre";
const MOYEN_VENTE = "vente";
const MOYEN_RETRAIT = "retrait";
/** @var array user friendly named type */
......@@ -26,6 +27,7 @@ abstract class MoyenEnum
self::MOYEN_MLC => 'MLC',
self::MOYEN_AUTRE => 'Autre',
self::MOYEN_VENTE => 'Vente',
self::MOYEN_RETRAIT => 'Retrait',
];
/**
......@@ -55,7 +57,8 @@ abstract class MoyenEnum
self::MOYEN_HELLOASSO,
self::MOYEN_MLC,
self::MOYEN_AUTRE,
self::MOYEN_VENTE
self::MOYEN_VENTE,
self::MOYEN_RETRAIT
];
}
}
<?php
namespace App\EventListener;
use App\Events\MLCEvents;
use App\Events\FluxEvent;
use App\Entity\Flux;
use App\Entity\User;
use Doctrine\ORM\EntityManagerInterface;
use FOS\UserBundle\Event\FormEvent;
use FOS\UserBundle\Event\UserEvent;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\Templating\EngineInterface;
/**
* Listener responsable des évènements liés aux flux (transfert, transaction, retrait, vente...)
*/
class MLCEventListener implements EventSubscriberInterface
{
protected $em;
protected $mailer;
protected $params;
protected $templating;
public function __construct(EntityManagerInterface $em, \Swift_Mailer $mailer, ParameterBagInterface $params, EngineInterface $templating)
{
$this->em = $em;
$this->mailer = $mailer;
$this->params = $params;
$this->templating = $templating;
}
public static function getSubscribedEvents()
{
return array(
MLCEvents::FLUX => 'onFlux',
MLCEvents::COTISATION_COTISATION => 'onCotisation',
MLCEvents::COTISATION_COTISATION_ADHERENT => 'onCotisation',
MLCEvents::COTISATION_COTISATION_PRESTATAIRE => 'onCotisation',
MLCEvents::TRANSACTION_ADHERENT_ADHERENT => 'onTransaction',
MLCEvents::TRANSACTION_ADHERENT_PRESTATAIRE => 'onTransaction',
MLCEvents::TRANSACTION_PRESTATAIRE_ADHERENT => 'onTransaction',
MLCEvents::TRANSACTION_PRESTATAIRE_PRESTATAIRE => 'onTransaction',
MLCEvents::TRANSFERT_COMPTOIR_GROUPE => 'onTransfert',
MLCEvents::TRANSFERT_GROUPE_COMPTOIR => 'onTransfert',
MLCEvents::TRANSFERT_GROUPE_SIEGE => 'onTransfert',
MLCEvents::TRANSFERT_SIEGE_GROUPE => 'onTransfert',
MLCEvents::TRANSFERT_PRESTATAIRE_COMPTOIR => 'onDepot',
MLCEvents::TRANSFERT_PRESTATAIRE_SIEGE => 'onReconversion',
MLCEvents::RETRAIT_COMPTOIR_ADHERENT => 'onRetrait',
MLCEvents::RETRAIT_COMPTOIR_PRESTATAIRE => 'onRetrait',
MLCEvents::VENTE_COMPTOIR_ADHERENT => 'onVente',
MLCEvents::VENTE_COMPTOIR_PRESTATAIRE => 'onVente',
);
}
public function onFlux(FluxEvent $event)
{
foreach ($event->getFlux()->getUsersToNotify() as $user) {
if ($user instanceof User && $user->getAlertemailflux()) {
$this->sendMail($user, $event->getFlux());
} elseif ($user == 'siege') {
$users = $this->container->get('doctrine')
->getEntityManager()
->createQuery('SELECT u FROM App:User u WHERE u.roles LIKE :role')
->setParameter('role', '%"ROLE_ADMIN_SIEGE"%')
->getResult();
foreach ($users as $userAdminSiege) {
$this->sendMail($userAdminSiege, $event->getFlux());
}
}
}
}
private function sendMail(User $user, Flux $flux)
{
$subject = $this->params->get('app.mlc_name_small').' : '.ucwords($flux->getParenttype()).' '.ucwords($flux->getType());
$mail = (new \Swift_Message($subject))
->setFrom($this->params->get('app.mlc_notif_email'))
->setTo($user->getEmail())
->setBody(
$this->templating->render(
'email/notification_flux.html.twig',
array(
'subject' => $subject,
'user' => $user,
'flux' => $flux
)
),
'text/html'
);
$this->mailer->send($mail);
}
public function onCotisation(FluxEvent $event)
{
}
public function onTransaction(FluxEvent $event)
{
}
public function onTransfert(FluxEvent $event)
{
if ($event->getUsers()) {
}
}
public function onDepot(FluxEvent $event)
{
}
public function onReconversion(FluxEvent $event)
{
}
public function onRetrait(FluxEvent $event)
{
}
public function onVente(FluxEvent $event)
{
}
}
<?php
namespace App\Events;
use App\Entity\Flux;
use Symfony\Component\EventDispatcher\Event;
class FluxEvent extends Event
{
protected $flux;
/**
* @param FormInterface $form The associated form
* @param mixed $data The data
*/
public function __construct(Flux $flux)
{
$this->flux = $flux;
}
/**
* Get flux
* @return
*/
public function getFlux()
{
return $this->flux;
}
/**
* Set flux
* @return $this
*/
public function setFlux($flux)
{
$this->flux = $flux;
return $this;
}
}
<?php
namespace FOS\UserBundle;
namespace App\Events;
/**
* Tous les évènements
......@@ -7,20 +7,25 @@ namespace FOS\UserBundle;
* LOCO : Outil de gestion de Monnaie Locale Complémentaire
* @author Julien Jorry <julien.jorry@gmail.com>
*/
final class FOSUserEvents
final class MLCEvents
{
/* FLUX */
const FLUX = 'mlc.flux';
const COTISATION_COTISATION = 'mlc.flux.cotisation';
const COTISATION_COTISATION_ADHERENT = 'mlc.flux.cotisation.adherent';
const COTISATION_COTISATION_PRESTATAIRE = 'mlc.flux.cotisation.prestataire';
const TRANSACTION_ADHERENT_ADHERENT = 'mlc.flux.transaction.adherent.adherent';
const TRANSACTION_ADHERENT_PRESTATAIRE = 'mlc.flux.transaction.adherent.prestataire';
const TRANSACTION_PRESTATAIRE_ADHERENT = 'mlc.flux.transaction.prestataire.adherent';
const TRANSACTION_PRESTATAIRE_PRESTATAIRE = 'mlc.flux.transaction.prestataire.prestataire';
const TRANSFERT_COMPTOIR_ADHERENT = 'mlc.flux.transfert.comptoir.adherent';
const TRANSFERT_COMPTOIR_PRESTATAIRE = 'mlc.flux.transfert.comptoir.prestataire';
const TRANSFERT_COMPTOIR_GROUPE = 'mlc.flux.transfert.comptoir.groupe';
const TRANSFERT_GROUPE_COMPTOIR = 'mlc.flux.transfert.groupe.comptoir';
const TRANSFERT_GROUPE_SIEGE = 'mlc.flux.transfert.groupe.siege';
const TRANSFERT_SIEGE_GROUPE = 'mlc.flux.transfert.siege.groupe';
const TRANSFERT_PRESTATAIRE_COMPTOIR = 'mlc.flux.transfert.prestataire.comptoir';
const TRANSFERT_PRESTATAIRE_SIEGE = 'mlc.flux.transfert.prestataire.siege';
const TRANSFERT_SIEGE_GROUPE = 'mlc.flux.transfert.siege.groupe';
const TRANSFERT_SIEGE_GROUPE = 'mlc.flux.transfert.siege.groupe';
}
\ No newline at end of file
const RETRAIT_COMPTOIR_ADHERENT = 'mlc.flux.retrait.comptoir.adherent';
const RETRAIT_COMPTOIR_PRESTATAIRE = 'mlc.flux.retrait.comptoir.prestataire';
const VENTE_COMPTOIR_ADHERENT = 'mlc.flux.vente.comptoir.adherent';
const VENTE_COMPTOIR_PRESTATAIRE = 'mlc.flux.vente.comptoir.prestataire';
}
......@@ -15,6 +15,10 @@ use App\Entity\TransfertGroupeSiege;
use App\Entity\TransfertPrestataireComptoir;
use App\Entity\TransfertPrestataireSiege;
use App\Entity\TransfertSiegeGroupe;
use App\Entity\RetraitComptoirAdherent;
use App\Entity\RetraitComptoirPrestataire;
use App\Entity\VenteComptoirAdherent;
use App\Entity\VenteComptoirPrestataire;
use App\Entity\User;
use App\Enum\MoyenEnum;
use App\Form\Type\AdherentInfosFormType;
......@@ -33,6 +37,10 @@ use App\Form\Type\TransfertGroupeSiegeFormType;
use App\Form\Type\TransfertPrestataireComptoirFormType;
use App\Form\Type\TransfertPrestataireSiegeFormType;
use App\Form\Type\TransfertSiegeGroupeFormType;
use App\Form\Type\RetraitComptoirAdherentFormType;
use App\Form\Type\RetraitComptoirPrestataireFormType;
use App\Form\Type\VenteComptoirAdherentFormType;
use App\Form\Type\VenteComptoirPrestataireFormType;
use App\Form\Type\UserInfosFormType;
use FOS\UserBundle\Form\Type\ChangePasswordFormType;
use Symfony\Component\Form\FormFactoryInterface as FormF;
......@@ -195,17 +203,17 @@ class FormFactory
return $form->createView();
}
public function getTransfertComptoirToXForm(User $user, $type)
public function getRetraitComptoirToXForm(User $user, $type)
{
$type = strtolower($type);
if (empty($user) || empty($user->getComptoirsgere()) || !($type == 'adherent' || $type == 'groupe' || $type == 'prestataire')) {
throw new \Exception("[FORM 12] Opération impossible !");
}
$class = "App\Entity\TransfertComptoir".ucwords($type);
$class = "App\Entity\RetraitComptoir".ucwords($type);
$entity = new $class();
$entity->setOperateur($user);
$entity->setExpediteur($user->getComptoirsgere());
$form = $this->ff->create('App\Form\Type\TransfertComptoir'.ucwords($type).'FormType', $entity, array('action' => $this->router->generate('transfertComptoir'.ucwords($type))));
$form = $this->ff->create('App\Form\Type\RetraitComptoir'.ucwords($type).'FormType', $entity, array('action' => $this->router->generate('retraitComptoir'.ucwords($type))));
return $form->createView();
}
......
......@@ -18,6 +18,7 @@ use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
......
......@@ -62,7 +62,12 @@ class FluxFormType extends AbstractType
))
;
} else {
$maxvalue = $flux->getExpediteur()->getCompte();
// @TODO : finir logique ici : emlc ou billets mlc et check expediteur ou destinataire ?
if ($flux->getParenttype() == Flux::TYPE_TRANSACTION) {
$maxvalue = $flux->getExpediteur()->getEcompte();
} else {
$maxvalue = $flux->getExpediteur()->getCompte();
}
$builder
->add('montant', MoneyType::class, array(
'label' => 'Montant :',
......@@ -83,12 +88,12 @@ class FluxFormType extends AbstractType
))
->add('save', SubmitType::class, ['label' => "Valider"])
->addEventListener(FormEvents::POST_SUBMIT, function (FormEvent $event) use ($builder) {
$flux = $event->getData();
if ($event->getForm()->isValid() && (!$flux || null === $flux->getId())) {
if ($flux->getExpediteur()->getCompte() < $flux->getMontant()) {
$event->getForm()->get('montant')->addError(new FormError("Montant supérieur à votre solde !"));
}
}
// $flux = $event->getData();
// if ($event->getForm()->isValid() && (!$flux || null === $flux->getId())) {
// if ($flux->getExpediteur()->getCompte() < $flux->getMontant()) {
// $event->getForm()->get('montant')->addError(new FormError("Montant supérieur à votre solde !"));
// }
// }
})
;
}
......@@ -99,8 +104,8 @@ class FluxFormType extends AbstractType
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
'data_class' => Flux::class,
'cascade_validation' => true
'data_class' => Flux::class,
'cascade_validation' => true
));
}
......
......@@ -4,13 +4,13 @@ namespace App\Form\Type;
use App\Entity\Adherent;
use App\Entity\Comptoir;
use App\Entity\TransfertComptoirAdherent;
use App\Entity\RetraitComptoirAdherent;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class TransfertComptoirAdherentFormType extends TransfertFormType
class RetraitComptoirAdherentFormType extends RetraitFormType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
......@@ -37,17 +37,17 @@ class TransfertComptoirAdherentFormType extends TransfertFormType
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
'class' => TransfertComptoirAdherent::class,
'class' => RetraitComptoirAdherent::class,
));
}
public function getParent()
{
return TransfertFormType::class;
return RetraitFormType::class;
}
public function getBlockPrefix()
{
return 'formTransfertComptoirAdherent';
return 'formRetraitComptoirAdherent';
}
}
......@@ -4,13 +4,13 @@ namespace App\Form\Type;
use App\Entity\Comptoir;
use App\Entity\Prestataire;
use App\Entity\TransfertComptoirPrestataire;
use App\Entity\RetraitComptoirPrestataire;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class TransfertComptoirPrestataireFormType extends TransfertFormType
class RetraitComptoirPrestataireFormType extends RetraitFormType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
......@@ -37,17 +37,17 @@ class TransfertComptoirPrestataireFormType extends TransfertFormType
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
'class' => TransfertComptoirPrestataire::class,
'class' => RetraitComptoirPrestataire::class,
));
}
public function getParent()
{
return TransfertFormType::class;
return RetraitFormType::class;
}
public function getBlockPrefix()
{
return 'formTransfertComptoirPrestataire';
return 'formRetraitComptoirPrestataire';
}
}
<?php
namespace App\Form\Type;
use App\Enum\MoyenEnum;
use App\Form\Type\FluxFormType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\FormBuilderInterface;
class RetraitFormType extends FluxFormType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('type', HiddenType::class, array(
'data' => 'retrait',
'data_class' => null
))
->add('moyen', HiddenType::class, array(
'data' => MoyenEnum::MOYEN_RETRAIT
))
;
}
public function getParent()
{
return FluxFormType::class;
}
public function getBlockPrefix()
{
return 'formRetrait';
}
}
......@@ -4,7 +4,6 @@ namespace App\Form\Type;
use App\Entity\Comptoir;
use App\Entity\Groupe;
use App\Entity\TransfertComptoirPrestataire;
use App\Entity\TransfertGroupeComptoir;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
......
......@@ -46,6 +46,7 @@ class UserInfosFormType extends AbstractType
'disabled' => true,
'translation_domain' => 'FOSUserBundle'
))
->add('alertemailflux', CheckboxType::class, ['label' => "Alertes email à chaque transaction ?"])
;
}
......
<?php
namespace App\Listener;
use App\Entity\Flux;
use Doctrine\Common\EventSubscriber;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Event\OnFlushEventArgs;
use Doctrine\ORM\Events;
use Symfony\Component\Security\Core\Security;
class FluxListener implements EventSubscriber
{
private $em;
private $security;
public function __construct(EntityManagerInterface $em, Security $security)
{
$this->em = $em;
$this->security = $security;
}
public function getSubscribedEvents()
{
return array(Events::onFlush);
}
public function onFlush(OnFlushEventArgs $args)
{
$em = $args->getEntityManager();
$uow = $em->getUnitOfWork();
$inserted = $uow->getScheduledEntityInsertions();
foreach ($inserted as $entity) {
if ($entity instanceof Flux) {
$topersists = $entity->operate();
foreach ($topersists as $topersist) {
$class = $em->getClassMetadata(get_class($topersist));
$em->persist($topersist);
$em->getUnitOfWork()->computeChangeSet($class, $topersist);
}
// @TODO : do something (log, save, email...) on flux persist
// => tag sur un service ?
}
}
}
}
<?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 Version20200212164434 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 adherent CHANGE ecompte ecompte NUMERIC(12, 2) NOT NULL');
$this->addSql('ALTER TABLE prestataire ADD ecompte NUMERIC(12, 2) NOT NULL');
}
public function down(Schema $schema) : void
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
$this->addSql('ALTER TABLE adherent CHANGE ecompte ecompte NUMERIC(7, 2) NOT NULL');
$this->addSql('ALTER TABLE prestataire DROP ecompte');
}
}
<?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 Version20200212172915 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 siege ADD compte_nantie NUMERIC(12, 2) NOT NULL');
}
public function down(Schema $schema) : void
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
$this->addSql('ALTER TABLE siege DROP compte_nantie');
}
}
<?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 Version20200213232207 extends AbstractMigration
{
public function getDescription() : string
{
return '';
}
public function up(Schema $schema) : void
{
// this up() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
$this->addSql('ALTER TABLE user ADD alertemailflux TINYINT(1) NOT NULL');
$this->addSql('UPDATE user SET alertemailflux = true');
}
public function down(Schema $schema) : void
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
$this->addSql('ALTER TABLE user DROP alertemailflux');
}
}
......@@ -36,7 +36,7 @@ class FormExtension extends AbstractExtension
new \Twig_SimpleFunction('getTransactionPrestatairePrestataireForm', array($this, 'getTransactionPrestatairePrestataireForm')),
new \Twig_SimpleFunction('getTransfertPrestataireSiegeForm', array($this, 'getTransfertPrestataireSiegeForm')),
new \Twig_SimpleFunction('getTransfertPrestataireComptoirForm', array($this, 'getTransfertPrestataireComptoirForm')),
new \Twig_SimpleFunction('getTransfertComptoirToXForm', array($this, 'getTransfertComptoirToXForm')),
new \Twig_SimpleFunction('getRetraitComptoirToXForm', array($this, 'getRetraitComptoirToXForm')),
new \Twig_SimpleFunction('getVenteComptoirToXForm', array($this, 'getVenteComptoirToXForm')),
new \Twig_SimpleFunction('getTransfertComptoirGroupeForm', array($this, 'getTransfertComptoirGroupeForm')),
new \Twig_SimpleFunction('getTransfertGroupeComptoirForm', array($this, 'getTransfertGroupeComptoirForm')),
......@@ -97,9 +97,9 @@ class FormExtension extends AbstractExtension
{
return $this->container->get('app.formfactory')->getTransfertPrestataireComptoirForm($user);
}
public function getTransfertComptoirToXForm(User $user, $destinataire)
public function getRetraitComptoirToXForm(User $user, $destinataire)
{
return $this->container->get('app.formfactory')->getTransfertComptoirToXForm($user, $destinataire);
return $this->container->get('app.formfactory')->getRetraitComptoirToXForm($user, $destinataire);
}
public function getVenteComptoirToXForm(User $user, $destinataire)
{
......
......@@ -25,5 +25,39 @@
{% endfor %}
</tbody>
</table>
<br/>
<div class="btn-group">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
<i class="fa fa-share-square-o" aria-hidden="true"></i>
Export
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li>
<a href="{{ path('exportPrestaFlux', {'format' : 'json'}) }}">
<i class="fa fa-arrow-circle-o-down" aria-hidden="true"></i>
JSON
</a>
</li>
<li>
<a href="{{ path('exportPrestaFlux', {'format' : 'xml'}) }}">
<i class="fa fa-arrow-circle-o-down" aria-hidden="true"></i>
XML
</a>
</li>
<li>
<a href="{{ path('exportPrestaFlux', {'format' : 'csv'}) }}">
<i class="fa fa-arrow-circle-o-down" aria-hidden="true"></i>
CSV
</a>
</li>
<li>
<a href="{{ path('exportPrestaFlux', {'format' : 'xls'}) }}">
<i class="fa fa-arrow-circle-o-down" aria-hidden="true"></i>
XLS
</a>
</li>
</ul>
</div>
{% endblock blockcontent %}
{% endif %}
\ No newline at end of file
......@@ -48,6 +48,7 @@
{% set compte = siege.getCompte() %}
{% set soldelabel = 'Solde du siège'|trans %}
{% include 'block/solde.html.twig' with {'compte': compte, 'soldelabel': soldelabel} %}
{% include 'block/solde.html.twig' with {'compte': siege.getCompteNantie(), 'soldelabel': 'Monnaie nantie'} %}
{% include 'block/userinfos.html.twig' %}
{% include 'block/userpassword.html.twig' %}
{% include 'siege/block/transfert_siegegroupe.html.twig' %}
......@@ -99,7 +100,8 @@
{% include 'block/transactions.html.twig' %}
{% include 'comptoir/block/vente_adherent.html.twig' %}
{% include 'comptoir/block/vente_prestataire.html.twig' %}
{% include 'comptoir/block/transaction_prestataire.html.twig' %}
{% include 'comptoir/block/retrait_prestataire.html.twig' %}
{% include 'comptoir/block/retrait_adherent.html.twig' %}
{% include 'comptoir/block/reconversion.html.twig' %}
{% elseif is_granted('ROLE_CONTACT') %}
......@@ -120,12 +122,15 @@
{% set compte = siege.getCompte() %}
{% set soldelabel = 'Solde du siège'|trans %}
{% include 'block/solde.html.twig' with {'compte': compte, 'soldelabel': soldelabel} %}
{% include 'block/solde.html.twig' with {'compte': siege.getCompteNantie(), 'soldelabel': 'Monnaie nantie'} %}
{% include 'block/userinfos.html.twig' %}
{% include 'block/userpassword.html.twig' %}
{% elseif is_granted('ROLE_PRESTATAIRE') %}
{% elseif is_granted('ROLE_PRESTATAIRE') and app.user and app.user.prestataire %}
{% include 'presta/block/solde.html.twig' %}
{% set esoldelabel = 'Solde e-mlc'|trans %}
{% include 'block/solde.html.twig' with {'compte': app.user.prestataire.ecompte, 'soldelabel': esoldelabel} %}
{% include 'presta/block/infos.html.twig' %}
{% include 'block/userinfos.html.twig' %}
{% include 'block/userpassword.html.twig' %}
......@@ -134,11 +139,15 @@
{% include 'groupepresta/block/inscription.html.twig' %}
{% include 'presta/block/transaction_presta.html.twig' %}
{% include 'presta/block/transaction_adherent.html.twig' %}
{% include 'presta/block/reconversion.html.twig' %}
{% if app.user.prestataire.ecompte > 0 %}
{% include 'presta/block/reconversion.html.twig' %}
{% endif %}
{% elseif is_granted('ROLE_ADHERENT') %}
{% elseif is_granted('ROLE_ADHERENT') and app.user and app.user.adherent %}
{% include 'adherent/block/solde.html.twig' %}
{% set esoldelabel = 'Solde e-mlc'|trans %}
{% include 'block/solde.html.twig' with {'compte': app.user.adherent.ecompte, 'soldelabel': esoldelabel} %}
{% include 'adherent/block/infos.html.twig' %}
{% include 'block/userpassword.html.twig' %}
{% include 'block/cotisations.html.twig' %}
......
......@@ -11,6 +11,7 @@
{{ form_row(form.email) }}
{{ form_row(form.firstname) }}
{{ form_row(form.lastname) }}
{{ form_row(form.alertemailflux) }}
<input type="submit" id="_submituserinfos" name="_submituserinfos" value="{{ 'Valider'|trans }}" />
{{form_end(form)}}
{% endblock blockcontent %}
\ No newline at end of file
......@@ -2,7 +2,7 @@
{% block javascripts %}
{{ parent() }}
{% if app.request.get('_route') == 'admin_app_user_edit' %}
{% if app.request.get('_route') == 'admin_app_user_edit' or app.request.get('_route') == 'admin_app_user_create' %}
<script type="text/javascript">
$(function () {
$("input[name='{{ admin.uniqid }}[groups][]']").each(function () {
......
......@@ -18,7 +18,7 @@
{% for comptoir in comptoirs %}
{% if comptoir.geoloc != null and comptoir.geoloc.lat != null and comptoir.geoloc.lon != null%}
var marker_{{count}} = L.marker([{{comptoir.geoloc.lat}}, {{comptoir.geoloc.lon}}]).addTo(mymap);
marker_{{count}}.bindPopup("{% if comptoir.media != null %}{% thumbnail comptoir.media, 'small' %}<br/><br/>{% endif %}{% spaceless %}
marker_{{count}}.bindPopup("{% spaceless %}{% if comptoir.media != null %}{% thumbnail comptoir.media, 'small' %}<br/><br/>{% endif %}
<a href='{{ path('show_comptoir', {'slug': comptoir.slug}) }}'>
<strong>{{comptoir.__toString()}}</strong>
<br/>{% endspaceless %}");
......
{% extends 'block/onetransaction.html.twig' %}
{% block blocktitle %}
<i class="fa fa-exchange-alt mr-4"></i> {{ 'Transfert à un adhérent'|trans }}
<i class="fa fa-exchange-alt mr-4"></i> {{ "Retrait d'un adhérent"|trans }}
{% endblock blocktitle %}
{% block blockcontent %}
{% set form = getTransfertComptoirToXForm(app.user, 'adherent') %}
{% set form = getRetraitComptoirToXForm(app.user, 'adherent') %}
{{ parent() }}
{% endblock blockcontent %}
\ No newline at end of file
{% extends 'block/onetransaction.html.twig' %}
{% block blocktitle %}
<i class="fa fa-exchange-alt mr-4"></i> {{ 'Transfert à un prestataire'|trans }}
<i class="fa fa-exchange-alt mr-4"></i> {{ "Retrait d'un prestataire"|trans }}
{% endblock blocktitle %}
{% block blockcontent %}
{% set form = getTransfertComptoirToXForm(app.user, 'prestataire') %}
{% set form = getRetraitComptoirToXForm(app.user, 'prestataire') %}
{{ parent() }}
{% endblock blockcontent %}
\ No newline at end of file
<table style="padding: 20px;width: 100%;" bgcolor="#f6f6f6">
<tr>
<td></td>
<td style="border: 1px solid #f0f0f0;clear: both !important;display: block !important;Margin: 0 auto !important;max-width: 600px !important;padding: 20px;" bgcolor="#FFFFFF">
<!-- content -->
<div style="display: block; margin: 0 auto; max-width: 600px;">
<table style="width: 100%;">
<tr>
<td>
{% block main %}
{% block title%}
<h2 style="font-size: 18px; color: #111111; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-weight: bold; line-height: 1.2em; margin: 40px 0 10px;">
{{title}}
</h2>
{% endblock title%}
<br/>
{% block content %}
{% endblock content %}
{% block footer%}
<p>{{ parameter('app.mlc_name') }}</p>
{% endblock footer%}
{% endblock main %}
</td>
</tr>
</table>
</div>
<!-- /content -->
</td>
<td>© Kohinos</td>
</tr>
</table>
\ No newline at end of file
{% extends 'email/email_layout.html.twig' %}
{% set title %}{% spaceless %}
{{ subject }}
{% endspaceless %}
{% endset %}
{% block content %}
<h2 style="font-size: 18px; color: #111111; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-weight: bold; line-height: 1.2em; margin: 40px 0 10px;">{{ user.name|title }},</h2><br/>
{# @TODO #}
<h3>Nouveau flux {{flux.parenttype}} : {{flux.type}} :</h3>
<p>Référence : {{flux.reference}}</p>
<p>Montant de {{flux.montant}} (Moyen : {{flux.moyen}})</p>
<p>Opérateur : {{flux.operateur.name}}</p>
{% endblock %}
\ No newline at end of file
......@@ -3,7 +3,7 @@
{% block content %}
<div class='container groupeshow mt-5'>
<h4>{{ title }} :</h4>
<h5>{{ 'Mon compte'|trans }} : {{compte}}</h5>
{# <h5>{{ 'Mon compte'|trans }} : {{compte}}</h5> #}
{{form_start(form)}}
{{ form_row(form.expediteur) }}
{{ form_row(form.destinataire) }}
......
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