Commit 99f8ef01 by Julien Jorry

UPDATE transfert siege <=> groupe + debug + translation + infos adherent ...

parent 3e932b61
......@@ -11,7 +11,6 @@
border-right: 1px solid #eee;
}
.card {
position: relative;
display: -webkit-box;
......
......@@ -19,16 +19,17 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Translation\TranslatorInterface;
class UserAdherentController extends AbstractController
{
protected $em;
protected $um;
protected $translator;
public function __construct(EntityManagerInterface $em, UserManagerInterface $um)
public function __construct(EntityManagerInterface $em, TranslatorInterface $translator)
{
$this->em = $em;
$this->um = $um;
$this->translator = $translator;
}
/**
......@@ -45,7 +46,7 @@ class UserAdherentController extends AbstractController
$this->em->flush();
$this->addFlash(
'success',
'Infos du prestataire modifiée !'
$this->translator->trans('Infos du prestataire modifiée !')
);
$referer = $request->headers->get('referer');
if ($referer && !$request->isXmlHttpRequest()) {
......@@ -76,7 +77,7 @@ class UserAdherentController extends AbstractController
$this->em->flush();
$this->addFlash(
'success',
'Transaction bien effectuée !'
$this->translator->trans('Transaction bien effectuée !')
);
$referer = $request->headers->get('referer');
if ($referer && !$request->isXmlHttpRequest()) {
......@@ -89,7 +90,7 @@ class UserAdherentController extends AbstractController
return $this->render('flux/transaction.html.twig', [
'form' => $form->createView(),
'compte' => $this->getUser()->getAdherent()->getCompte(),
'title' => 'Transaction à un prestataire'
'title' => $this->translator->trans('Transaction à un prestataire')
]);
}
......@@ -114,7 +115,7 @@ class UserAdherentController extends AbstractController
$this->em->flush();
$this->addFlash(
'success',
'Transaction bien effectuée !'
$this->translator->trans('Transaction bien effectuée !')
);
$referer = $request->headers->get('referer');
if ($referer && !$request->isXmlHttpRequest()) {
......@@ -127,7 +128,7 @@ class UserAdherentController extends AbstractController
return $this->render('flux/transaction.html.twig', [
'form' => $form->createView(),
'compte' => $this->getUser()->getAdherent()->getCompte(),
'title' => 'Transaction à un adhérent'
'title' => $this->translator->trans('Transaction à un adhérent')
]);
}
}
......@@ -23,16 +23,16 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Translation\TranslatorInterface;
class UserComptoirController extends AbstractController
{
protected $em;
protected $um;
protected $translator;
public function __construct(EntityManagerInterface $em, UserManagerInterface $um)
public function __construct(EntityManagerInterface $em, TranslatorInterface $translator)
{
$this->em = $em;
$this->um = $um;
$this->translator = $translator;
}
/**
......@@ -50,7 +50,7 @@ class UserComptoirController extends AbstractController
$this->em->flush();
$this->addFlash(
'success',
'Comptoir bien modifié !'
$this->translator->trans('Comptoir bien modifié !')
);
$referer = $request->headers->get('referer');
if ($referer && !$request->isXmlHttpRequest()) {
......@@ -80,7 +80,7 @@ class UserComptoirController extends AbstractController
$this->em->flush();
$this->addFlash(
'success',
'Transfert bien effectuée !'
$this->translator->trans('Transfert bien effectuée !')
);
$referer = $request->headers->get('referer');
if ($referer && !$request->isXmlHttpRequest()) {
......@@ -93,7 +93,7 @@ class UserComptoirController extends AbstractController
return $this->render('flux/transaction.html.twig', [
'form' => $form->createView(),
'compte' => $this->getUser()->getComptoirsgere()->getCompte(),
'title' => 'Transfert à un adhérent'
'title' => $this->translator->trans('Transfert à un adhérent')
]);
}
......@@ -114,7 +114,7 @@ class UserComptoirController extends AbstractController
$this->em->flush();
$this->addFlash(
'success',
'Reconversion bien effectuée !'
$this->translator->trans('Reconversion bien effectuée !')
);
$referer = $request->headers->get('referer');
if ($referer && !$request->isXmlHttpRequest()) {
......@@ -127,7 +127,7 @@ class UserComptoirController extends AbstractController
return $this->render('flux/transaction.html.twig', [
'form' => $form->createView(),
'compte' => $this->getUser()->getComptoirsgere()->getCompte(),
'title' => "Reconversion d'un prestataire"
'title' => $this->translator->trans("Reconversion d'un prestataire")
]);
}
}
......@@ -10,14 +10,17 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Translation\TranslatorInterface;
class UserController extends AbstractController
{
private $em;
private $translator;
public function __construct(EntityManagerInterface $em)
public function __construct(EntityManagerInterface $em, TranslatorInterface $translator)
{
$this->em = $em;
$this->translator = $translator;
}
/**
......@@ -34,7 +37,7 @@ class UserController extends AbstractController
$this->em->flush();
$this->addFlash(
'success',
"Infos de l'utilisateur modifiée !"
$this->translator->trans("Infos de l'utilisateur modifiée !")
);
$referer = $request->headers->get('referer');
if ($referer && !$request->isXmlHttpRequest()) {
......
......@@ -22,16 +22,17 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Translation\TranslatorInterface;
class UserGestionnaireGroupeController extends AbstractController
{
protected $em;
protected $um;
protected $translator;
public function __construct(EntityManagerInterface $em, UserManagerInterface $um)
public function __construct(EntityManagerInterface $em, TranslatorInterface $translator)
{
$this->em = $em;
$this->um = $um;
$this->translator = $translator;
}
/**
......@@ -49,7 +50,7 @@ class UserGestionnaireGroupeController extends AbstractController
$this->em->flush();
$this->addFlash(
'success',
'Groupe local bien modifié !'
$this->translator->trans('Groupe local bien modifié !')
);
$referer = $request->headers->get('referer');
if ($referer && !$request->isXmlHttpRequest()) {
......@@ -79,7 +80,7 @@ class UserGestionnaireGroupeController extends AbstractController
$this->em->flush();
$this->addFlash(
'success',
'Transfert bien effectuée !'
$this->translator->trans('Transfert bien effectuée !')
);
$referer = $request->headers->get('referer');
if ($referer && !$request->isXmlHttpRequest()) {
......@@ -92,7 +93,7 @@ class UserGestionnaireGroupeController extends AbstractController
return $this->render('flux/transaction.html.twig', [
'form' => $form->createView(),
'compte' => $this->getUser()->getGroupesgere()->getCompte(),
'title' => 'Transfert à un comptoir'
'title' => $this->translator->trans('Transfert à un comptoir')
]);
}
}
......@@ -16,14 +16,17 @@ use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Translation\TranslatorInterface;
class UserPrestataireController extends AbstractController
{
private $em;
private $translator;
public function __construct(EntityManagerInterface $em)
public function __construct(EntityManagerInterface $em, TranslatorInterface $translator)
{
$this->em = $em;
$this->translator = $translator;
}
/**
......@@ -40,7 +43,7 @@ class UserPrestataireController extends AbstractController
$this->em->flush();
$this->addFlash(
'success',
'Infos du prestataire modifiée !'
$this->translator->trans('Infos du prestataire modifiée !')
);
$referer = $request->headers->get('referer');
if ($referer && !$request->isXmlHttpRequest()) {
......@@ -64,17 +67,11 @@ class UserPrestataireController extends AbstractController
if ($form->isSubmitted() && $form->isValid()) {
$prestataire = $form->getData();
// $this->getUser()->getPrestataire()->setGroupeprestataires($prestataire->getGroupeprestataires()->getValues());
// dump($prestataire);
// exit();
// dump($this->getUser()->getPrestataire()->getGroupeprestataires());
// exit();
// $this->em->persist($this->getUser()->getPrestataire());
$this->em->persist($prestataire);
$this->em->flush();
$this->addFlash(
'success',
'Information bien prise en compte !'
$this->translator->trans('Information bien prise en compte !')
);
if ($request->isXmlHttpRequest()) {
return new JsonResponse(array('status' => 'success'));
......@@ -111,7 +108,7 @@ class UserPrestataireController extends AbstractController
$this->em->flush();
$this->addFlash(
'success',
'Transaction bien effectuée !'
$this->translator->trans('Transaction bien effectuée !')
);
$referer = $request->headers->get('referer');
if ($referer && !$request->isXmlHttpRequest()) {
......@@ -124,7 +121,7 @@ class UserPrestataireController extends AbstractController
return $this->render('flux/transaction.html.twig', [
'form' => $form->createView(),
'compte' => $this->getUser()->getPrestataire()->getCompte(),
'title' => 'Transaction à un '.$type
'title' => $this->translator->trans('Transaction à un ').$type
]);
}
......@@ -147,7 +144,7 @@ class UserPrestataireController extends AbstractController
$this->em->flush();
$this->addFlash(
'success',
'Reconversion envoyée, elle sera validée lorsque le virement sera effectué !'
$this->translator->trans('Reconversion envoyée, elle sera validée lorsque le virement sera effectué !')
);
$referer = $request->headers->get('referer');
if ($referer && !$request->isXmlHttpRequest()) {
......@@ -160,7 +157,7 @@ class UserPrestataireController extends AbstractController
return $this->render('flux/transaction.html.twig', [
'form' => $form->createView(),
'compte' => $this->getUser()->getPrestataire()->getCompte(),
'title' => 'Reconversion de monnaie au siège'
'title' => $this->translator->trans('Reconversion de monnaie au siège')
]);
}
}
<?php
namespace App\Controller;
use App\Entity\Adherent;
use App\Entity\Cotisation;
use App\Entity\Geoloc;
use App\Entity\Groupe;
use App\Entity\Siege;
use App\Entity\TransactionAdherentPrestataire;
use App\Entity\TransfertGroupeComptoir;
use App\Entity\TransfertGroupeSiege;
use App\Entity\TransfertSiegeGroupe;
use App\Entity\Usergroup;
use App\Form\Type\AdherentInfosFormType;
use App\Form\Type\AdhererFormType;
use App\Form\Type\GroupeInfosFormType;
use App\Form\Type\TransactionAdherentPrestataireFormType;
use App\Form\Type\TransfertGroupeComptoirFormType;
use App\Form\Type\TransfertGroupeSiegeFormType;
use App\Form\Type\TransfertSiegeGroupeFormType;
use Doctrine\ORM\EntityManagerInterface;
use FOS\UserBundle\Model\UserManagerInterface;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Translation\TranslatorInterface;
class UserSiegeController extends AbstractController
{
protected $em;
protected $translator;
public function __construct(EntityManagerInterface $em, TranslatorInterface $translator)
{
$this->em = $em;
$this->translator = $translator;
}
// /**
// * @Route("/user/siege/infos", name="groupe_infos")
// * @Security("is_granted('ROLE_AMIN_SIEGE') or is_granted('ROLE_SUPER_ADMIN')")
// */
// public function siegeInfosAction(Request $request)
// {
// $form = $this->createForm(SiegeInfosFormType::class, $this->getUser()->getGroupesgere());
// $form->handleRequest($request);
// if ($form->isSubmitted() && $form->isValid()) {
// $data = $form->getData();
// $this->em->persist($data);
// $this->em->flush();
// $this->addFlash(
// 'success',
// 'Siege bien modifié !'
// );
// $referer = $request->headers->get('referer');
// if ($referer && !$request->isXmlHttpRequest()) {
// return $this->redirect($referer);
// } elseif (!$request->isXmlHttpRequest()) {
// return new Response('', Response::HTTP_BAD_REQUEST);
// }
// }
// return $this->redirectToRoute('index');
// }
/**
* @Route("/siege/transfert/groupe/", name="transfertSiegeGroupe")
* @Security("is_granted('ROLE_ADMIN_SIEGE') or is_granted('ROLE_SUPER_ADMIN')")
*/
public function transfertSiegeGroupeAction(Request $request)
{
$entity = new TransfertSiegeGroupe();
$entity->setOperateur($this->getUser());
$form = $this->createForm(TransfertSiegeGroupeFormType::class, $entity);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$data = $form->getData();
$this->em->persist($data);
$this->em->flush();
$this->addFlash(
'success',
$this->translator->trans('Transfert bien effectuée !')
);
$referer = $request->headers->get('referer');
if ($referer && !$request->isXmlHttpRequest()) {
return $this->redirect($referer);
} elseif (!$request->isXmlHttpRequest()) {
return new Response('', Response::HTTP_BAD_REQUEST);
}
}
return $this->render('flux/transaction.html.twig', [
'form' => $form->createView(),
'compte' => $this->em->getRepository(Siege::class)->findOneById(1)->getCompte(),
'title' => $this->translator->trans('Transfert à un groupe')
]);
}
/**
* @Route("/groupe/transfert/siege/", name="transfertGroupeSiege")
* @Security("is_granted('ROLE_ADMIN_SIEGE') or is_granted('ROLE_SUPER_ADMIN')")
*/
public function transfertGroupeSiegeAction(Request $request)
{
$entity = new TransfertGroupeSiege();
$entity->setOperateur($this->getUser());
$form = $this->createForm(TransfertGroupeSiegeFormType::class, $entity);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$data = $form->getData();
$this->em->persist($data);
$this->em->flush();
$this->addFlash(
'success',
$this->translator->trans('Transfert bien effectuée !')
);
$referer = $request->headers->get('referer');
if ($referer && !$request->isXmlHttpRequest()) {
return $this->redirect($referer);
} elseif (!$request->isXmlHttpRequest()) {
return new Response('', Response::HTTP_BAD_REQUEST);
}
}
return $this->render('flux/transaction.html.twig', [
'form' => $form->createView(),
'compte' => $this->em->getRepository(Siege::class)->findOneById(1)->getCompte(),
'title' => $this->translator->trans('Transfert du groupe au siège')
]);
}
}
......@@ -15,7 +15,7 @@ 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"})
* @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"})
*/
abstract class Flux
{
......
......@@ -16,6 +16,7 @@ use Doctrine\ORM\Mapping as ORM;
* Types de transfert : (Les transferts dans la structure sont les flux de billets détenus par les opérateurs.)
*
* - SIEGE => GROUPES LOCAUX (Transfert du siège au groupe)
* - GROUPE => SIEGE (Transfert du groupe au siège)
* - GROUPES LOCAUX => COMPTOIRS (Transfert du groupe au comptoir)
* - COMPTOIRS => GROUPES LOCAUX (Transfert du comptoir au groupe)
* - COMPTOIRS => ADHERENTS (Diffusion de monnaie papier auprès des adhérents)
......
<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* TRANSFERT
* - GROUPES LOCAUX => SIEGE (Transfert du groupe au siège)
*
* @ORM\Entity()
*/
class TransfertGroupeSiege extends Transfert
{
/**
* @ORM\OneToOne(targetEntity="Groupe")
* @ORM\JoinColumn(name="groupe_id", referencedColumnName="id", nullable=true)
*/
protected $expediteur;
/**
* @ORM\OneToOne(targetEntity="Siege")
* @ORM\JoinColumn(name="siege_id", referencedColumnName="id", nullable=true)
*/
protected $destinataire;
/**
* @return string
*/
public function getType(): string
{
return 'groupe_siege';
}
}
......@@ -10,6 +10,7 @@ use App\Entity\TransactionComptoirPrestataire;
use App\Entity\TransactionPrestataireAdherent;
use App\Entity\TransactionPrestatairePrestataire;
use App\Entity\TransfertGroupeComptoir;
use App\Entity\TransfertGroupeSiege;
use App\Entity\TransfertPrestataireComptoir;
use App\Entity\TransfertPrestataireSiege;
use App\Entity\TransfertSiegeGroupe;
......@@ -26,6 +27,7 @@ use App\Form\Type\TransactionAdherentPrestataireFormType;
use App\Form\Type\TransactionPrestataireAdherentFormType;
use App\Form\Type\TransactionPrestatairePrestataireFormType;
use App\Form\Type\TransfertGroupeComptoirFormType;
use App\Form\Type\TransfertGroupeSiegeFormType;
use App\Form\Type\TransfertPrestataireComptoirFormType;
use App\Form\Type\TransfertPrestataireSiegeFormType;
use App\Form\Type\TransfertSiegeGroupeFormType;
......@@ -46,7 +48,7 @@ class FormFactory
public function getUserInfosForm(User $user)
{
if (empty($user)) {
return null;
throw new \Exception("[FORM 1] Opération impossible !");
}
$form = $this->ff->create(RegistrationFormType::class, $user, array('action' => $this->router->generate('user_infos')));
......@@ -56,7 +58,7 @@ class FormFactory
public function getGroupeInfosForm(User $user)
{
if (empty($user) || empty($user->getGroupesgere())) {
return null;
throw new \Exception("[FORM 2] Opération impossible !");
}
$form = $this->ff->create(GroupeInfosFormType::class, $user->getGroupesgere(), array('action' => $this->router->generate('groupe_infos')));
......@@ -66,7 +68,7 @@ class FormFactory
public function getComptoirInfosForm(User $user)
{
if (empty($user) || empty($user->getComptoirsgere())) {
return null;
throw new \Exception("[FORM 3] Opération impossible !");
}
$form = $this->ff->create(ComptoirInfosFormType::class, $user->getComptoirsgere(), array('action' => $this->router->generate('comptoir_infos')));
......@@ -76,7 +78,7 @@ class FormFactory
public function getPrestataireInfosForm(User $user)
{
if (empty($user) || empty($user->getPrestataire())) {
return null;
throw new \Exception("[FORM 4] Opération impossible !");
}
$form = $this->ff->create(PrestataireInfosFormType::class, $user->getPrestataire(), array('action' => $this->router->generate('prestataire_infos')));
......@@ -86,7 +88,7 @@ class FormFactory
public function getAdherentInfosForm(User $user)
{
if (empty($user) || empty($user->getAdherent())) {
return null;
throw new \Exception("[FORM 5] Opération impossible !");
}
$form = $this->ff->create(AdherentInfosFormType::class, $user->getAdherent(), array('action' => $this->router->generate('adherent_infos')));
......@@ -96,7 +98,7 @@ class FormFactory
public function getGroupePrestataireInscriptionForm(User $user)
{
if (empty($user) || empty($user->getPrestataire())) {
return null;
throw new \Exception("[FORM 6] Opération impossible !");
}
$form = $this->ff->create(GroupePrestataireInscriptionFormType::class, $user->getPrestataire(), array('action' => $this->router->generate('groupeprestataire_inscription')));
......@@ -106,7 +108,7 @@ class FormFactory
public function getTransactionAdherentAdherentForm(User $user)
{
if (empty($user) || empty($user->getAdherent())) {
return null;
throw new \Exception("[FORM 7] Opération impossible !");
}
$entity = new TransactionAdherentAdherent();
$entity->setOperateur($user);
......@@ -119,7 +121,7 @@ class FormFactory
public function getTransactionAdherentPrestataireForm(User $user)
{
if (empty($user) || empty($user->getAdherent())) {
return null;
throw new \Exception("[FORM 8] Opération impossible !");
}
$entity = new TransactionAdherentPrestataire();
$entity->setOperateur($user);
......@@ -132,7 +134,7 @@ class FormFactory
public function getTransactionPrestataireAdherentForm(User $user)
{
if (empty($user) || empty($user->getPrestataire())) {
return null;
throw new \Exception("[FORM] Opération impossible !");
}
$entity = new TransactionPrestataireAdherent();
$entity->setOperateur($user);
......@@ -145,7 +147,7 @@ class FormFactory
public function getTransactionPrestatairePrestataireForm(User $user)
{
if (empty($user) || empty($user->getPrestataire())) {
return null;
throw new \Exception("[FORM 9] Opération impossible !");
}
$entity = new TransactionPrestatairePrestataire();
$entity->setOperateur($user);
......@@ -158,7 +160,7 @@ class FormFactory
public function getTransfertPrestataireSiegeForm(User $user)
{
if (empty($user) || empty($user->getPrestataire())) {
return null;
throw new \Exception("[FORM 10] Opération impossible !");
}
$entity = new TransfertPrestataireSiege();
// $entity->setReconverti(false);
......@@ -173,7 +175,7 @@ class FormFactory
public function getTransfertPrestataireComptoirForm(User $user)
{
if (empty($user) || empty($user->getComptoirsgere())) {
return null;
throw new \Exception("[FORM 11] Opération impossible !");
}
$entity = new TransfertPrestataireComptoir();
// $entity->setReconverti(false);
......@@ -189,7 +191,7 @@ class FormFactory
{
$type = strtolower($type);
if (empty($user) || empty($user->getComptoirsgere()) || !($type == 'adherent' || $type == 'groupe' || $type == 'prestataire')) {
return null;
throw new \Exception("[FORM 12] Opération impossible !");
}
$class = "App\Entity\TransfertComptoir".ucwords($type);
$entity = new $class();
......@@ -200,30 +202,40 @@ class FormFactory
return $form->createView();
}
// public function getTransfertGroupeComptoirForm(User $user)
// {
// $type = strtolower($type);
// if (empty($user) || empty($user->getGroupesgere())) {
// return null;
// }
// $class = 'Transaction'.ucwords($type).'Comptoir';
// $entity = new TransfertGroupeComptoir();
// $entity->setOperateur($user);
// $entity->setExpediteur($user->getGroupesgere());
// $form = $this->ff->create(TransfertGroupeComptoirFormType::class, $entity, array('action' => $this->router->generate('transfertGroupeComptoir')));
// return $form->createView();
// }
// public function getTransfertSiegeGroupeForm(User $user)
// {
// if (empty($user) || !$user->hasRole('ROLE_ADMIN_SIEGE')) {
// return null;
// }
// $entity = new TransfertSiegeGroupe();
// $entity->setOperateur($user);
// $form = $this->ff->create(TransfertSiegeGroupeFormType::class, $entity, array('action' => $this->router->generate('transfertSiegeGroupe')));
public function getTransfertGroupeComptoirForm(User $user)
{
if (empty($user) || empty($user->getGroupesgere())) {
throw new \Exception("[FORM 13] Opération impossible !");
}
$entity = new TransfertGroupeComptoir();
$entity->setOperateur($user);
$entity->setExpediteur($user->getGroupesgere());
$form = $this->ff->create(TransfertGroupeComptoirFormType::class, $entity, array('action' => $this->router->generate('transfertGroupeComptoir')));
return $form->createView();
}
public function getTransfertSiegeGroupeForm(User $user)
{
if (empty($user) || !$user->hasRole('ROLE_ADMIN_SIEGE')) {
throw new \Exception("[FORM 14] Opération impossible !");
}
$entity = new TransfertSiegeGroupe();
$entity->setOperateur($user);
$form = $this->ff->create(TransfertSiegeGroupeFormType::class, $entity, array('action' => $this->router->generate('transfertSiegeGroupe')));
return $form->createView();
}
// return $form->createView();
// }
public function getTransfertGroupeSiegeForm(User $user)
{
if (empty($user) || !$user->hasRole('ROLE_ADMIN_SIEGE')) {
throw new \Exception("[FORM 15] Opération impossible !");
}
$entity = new TransfertGroupeSiege();
$entity->setOperateur($user);
$form = $this->ff->create(TransfertGroupeSiegeFormType::class, $entity, array('action' => $this->router->generate('transfertGroupeSiege')));
return $form->createView();
}
}
......@@ -47,6 +47,10 @@ class AdherentInfosFormType extends AbstractType
'label' => false,
'required' => false
))
->add('geoloc', GeolocFormType::class, array(
'label' => false,
'required' => false
))
->add('groupe', ChoiceType::class, array(
'required' => true,
'disabled' => true,
......@@ -55,10 +59,6 @@ class AdherentInfosFormType extends AbstractType
'choice_label' => 'name',
'placeholder' => 'Choisir un groupe',
))
->add('geoloc', GeolocFormType::class, array(
'label' => 'ADRESSE',
'required' => false
))
->add('save', SubmitType::class, ['label' => "Modifier"])
;
}
......
......@@ -15,6 +15,9 @@ class TransfertGroupeComptoirFormType extends TransfertFormType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
if (empty($this->security->getUser()) || empty($this->security->getUser()->getGroupesgere())) {
throw new \Exception("[FORM TRANSFERT GROUPE COMPTOIR] Opération impossible !");
}
$builder
->add('expediteur', HiddenType::class, array(
'data' => $this->security->getUser()->getGroupesgere()->getId(),
......@@ -24,7 +27,7 @@ class TransfertGroupeComptoirFormType extends TransfertFormType
))
->add('destinataire', EntityType::class, array(
'class' => Comptoir::class,
'choices' => $this->em->getRepository(Comptoir::class)->findBy(array('enabled' => true)),
'choices' => $this->em->getRepository(Comptoir::class)->findBy(array('groupe' => $this->security->getUser()->getGroupesgere(), 'enabled' => true), array('name' => 'ASC')),
'placeholder' => 'Comptoir',
'required' => true,
'label' => 'Comptoir :',
......
<?php
namespace App\Form\Type;
use App\Entity\Comptoir;
use App\Entity\Groupe;
use App\Entity\Siege;
use App\Entity\TransfertGroupeSiege;
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 TransfertGroupeSiegeFormType extends TransfertFormType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('expediteur', EntityType::class, array(
'class' => Groupe::class,
'choices' => $this->em->getRepository(Groupe::class)->findBy(array('enabled' => true)),
'choice_label' => function ($choice) {
return ((!empty($choice->getName())?$choice->getName():'Groupe').' ('.$choice->getCompte().')');
},
'placeholder' => 'Groupe',
'required' => true,
'label' => 'Groupe :',
))
->add('destinataire', HiddenType::class, array(
'data' => 1,
'data_class' => null,
'entity_class' => Siege::class,
'em' => $this->em
))
;
}
/**
* {@inheritdoc}
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
'class' => TransfertGroupeSiege::class,
));
}
public function getParent()
{
return TransfertFormType::class;
}
public function getBlockPrefix()
{
return 'formTransfertGroupeSiege';
}
}
......@@ -25,6 +25,9 @@ class TransfertSiegeGroupeFormType extends TransfertFormType
->add('destinataire', EntityType::class, array(
'class' => Groupe::class,
'choices' => $this->em->getRepository(Groupe::class)->findBy(array('enabled' => true)),
'choice_label' => function ($choice) {
return ((!empty($choice->getName())?$choice->getName():'Groupe').' ('.$choice->getCompte().')');
},
'placeholder' => 'Groupe',
'required' => true,
'label' => 'Groupe :',
......
......@@ -38,6 +38,7 @@ class FormExtension extends AbstractExtension
new \Twig_SimpleFunction('getTransfertComptoirToXForm', array($this, 'getTransfertComptoirToXForm')),
new \Twig_SimpleFunction('getTransfertGroupeComptoirForm', array($this, 'getTransfertGroupeComptoirForm')),
new \Twig_SimpleFunction('getTransfertSiegeGroupeForm', array($this, 'getTransfertSiegeGroupeForm')),
new \Twig_SimpleFunction('getTransfertGroupeSiegeForm', array($this, 'getTransfertGroupeSiegeForm')),
];
}
......@@ -101,4 +102,8 @@ class FormExtension extends AbstractExtension
{
return $this->container->get('app.formfactory')->getTransfertSiegeGroupeForm($user);
}
public function getTransfertGroupeSiegeForm(User $user)
{
return $this->container->get('app.formfactory')->getTransfertGroupeSiegeForm($user);
}
}
{% extends 'block/block_collapse.html.twig' %}
{% block blocktitle %}
<i class="fa fa-user-tie mr-4"></i> {{'Modifier vos informations'|trans}}
<i class="fa fa-user-tie mr-4"></i> {{ 'Modifier vos informations'|trans }}
{% endblock blocktitle %}
{% block blocksubtitle %}
{% endblock blocksubtitle %}
{% block blockcontent %}
{% set form = getAdherentInfosForm(app.user) %}
{{form_start(form)}}
{{ form_row(form.user)}}
{{ form_row(form.groupe)}}
{{ form_start(form) }}
{{ form_row(form.user) }}
{{ form_row(form.geoloc) }}
{{ form_row(form.groupe) }}
{{ form_row(form.save) }}
{{form_end(form)}}
{{ form_end(form) }}
{% endblock blockcontent %}
\ No newline at end of file
......@@ -5,21 +5,21 @@
<div class="row">
<div class="col-6">
<div class='infos mt-4'>
<h4>{{"Modifier mes informations"|trans}} :</h4>
<h4>{{ "Modifier mes informations"|trans }} :</h4>
<p>
{{form_start(form)}}
{{ form_start(form) }}
{{ form_row(form.user) }}
{{ form_row(form.groupe) }}
{{ form_row(form.geoloc) }}
{{ form_row(form.groupe) }}
{{ form_row(form.save) }}
{{form_end(form)}}
{{ form_end(form) }}
</p>
</div>
</div>
<div class="col-6">
{% if app.user.adherent is not null and app.user.adherent.ecompte >= 0 %}
<div class='ecompte mt-4'>
<h4>Mon ecompte :</h4>
<h4>{{ "Mon ecompte"|trans }} :</h4>
<ul class='list-group'>
<li class="list-group-item">{{(app.user.adherent.ecompte)|number_format(2, '.', ',')}}</li>
</ul>
......@@ -27,7 +27,7 @@
{% endif %}
{% if app.user.cotisations|length > 0 %}
<div class='cotisations mt-4'>
<h4>Mes cotisations :</h4>
<h4>{{ "Mes cotisations"|trans }} :</h4>
<ul class='list-group'>
{% for cotisation in app.user.cotisations %}
<li class="list-group-item">{{cotisation.annee|upper}} : {{cotisation.montant}}&euro; (payée le {{cotisation.createdAt|date('d-m-Y')}})</li>
......@@ -37,7 +37,7 @@
{% endif %}
{% if app.user.flux|length > 0 %}
<div class='flux mt-4'>
<h4>Mes transactions :</h4>
<h4>{{ "Mes transactions"|trans }} :</h4>
<ul class='list-group'>
{% for flux in app.user.flux %}
<li class="list-group-item">{{flux.parenttype|capitalize}} à {{flux.destinataire}} {{flux.montant}}&euro; (payée le {{flux.createdAt|date('d-m-Y')}})</li>
......
{# UNIQUEMENT POUR LES TESTS #}
{% if app.environment == 'dev' %}
{% if app.environment == 'dev' and is_granted('ROLE_USER') %}
{% set routeName = routeName|default('index')%}
{% if is_granted('ROLE_PREVIOUS_ADMIN') %}
<div class='w-100 text-center'>
<div class='w-100 text-center mb-2'>
<a class='btn btn-xs m-1 btn-primary' href='{{path(routeName, [], true)}}?_switch_user=_exit'>
EXIT
RETOUR SUPER ADMIN
</a>
</div>
{% else %}
<div class='mb-2'>
<a class='btn btn-xs m-1 btn-primary' href='{{path(routeName, [], true)}}?_switch_user=user_prestataire'>
<a class='btn btn-xs m-1 btn-primary' href='{{path('index', [], true)}}?_switch_user=user_prestataire'>
PRESTATAIRE
</a>
<a class='btn btn-xs m-1 btn-primary' href='{{path(routeName, [], true)}}?_switch_user=user_adherent'>
<a class='btn btn-xs m-1 btn-primary' href='{{path('index', [], true)}}?_switch_user=user_adherent'>
ADHERENT
</a>
<a class='btn btn-xs m-1 btn-primary' href='{{path(routeName, [], true)}}?_switch_user=user_adminsiege'>
......@@ -48,7 +48,10 @@
{% set soldelabel = 'Solde du siège'|trans %}
{% include 'block/solde.html.twig' with {'compte': compte, 'soldelabel': soldelabel} %}
{% include 'block/userinfos.html.twig' %}
{% include 'siege/block/transfert_siegegroupe.html.twig' %}
{% include 'siege/block/transfert_groupesiege.html.twig' %}
{% elseif is_granted('ROLE_REDACTEUR') %}
{% include 'block/userinfos.html.twig' %}
{% elseif is_granted('ROLE_TRESORIER') %}
{% set siege = getSiege() %}
{% set compte = siege.getCompte() %}
......@@ -66,6 +69,8 @@
{% endif %}
{% include 'groupe/block/infos.html.twig' %}
{% include 'block/userinfos.html.twig' %}
{% include 'block/transactions.html.twig' %}
{% include 'groupe/block/transaction_comptoir.html.twig' %}
{% elseif is_granted('ROLE_COMPTOIR') %}
{% if app.user.comptoirsgere != null %}
{% set compte = app.user.comptoirsgere.compte %}
......
{% extends 'block/onetransaction.html.twig' %}
{% block blocktitle %}
<i class="fa fa-exchange-alt mr-4"></i> Transfert vers un comptoir
{% endblock blocktitle %}
{% block blockcontent %}
{% set form = getTransfertGroupeComptoirForm(app.user) %}
{{ 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 du groupe au siège'|trans }}
{% endblock blocktitle %}
{% block blockcontent %}
{% set form = getTransfertGroupeSiegeForm(app.user) %}
{{ 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 groupe'|trans }}
{% endblock blocktitle %}
{% block blockcontent %}
{% set form = getTransfertSiegeGroupeForm(app.user) %}
{{ parent() }}
{% endblock blockcontent %}
\ No newline at end of file
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