use EasyCorp\Bundle\EasyAdminBundle\Config\Assets; | use EasyCorp\Bundle\EasyAdminBundle\Config\Assets; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud; | use EasyCorp\Bundle\EasyAdminBundle\Config\Crud; | ||||
use Lc\SovBundle\Controller\Dashboard\DashboardAdminController as SovDashboardController ; | |||||
use EasyCorp\Bundle\EasyAdminBundle\Config\MenuItem; | |||||
use EasyCorp\Bundle\EasyAdminBundle\Config\UserMenu; | |||||
use Lc\SovBundle\Controller\Dashboard\DashboardAdminController as SovDashboardController; | |||||
use Symfony\Component\Security\Core\User\UserInterface; | |||||
class DashboardAdminAdminController extends SovDashboardController | class DashboardAdminAdminController extends SovDashboardController | ||||
{ | { | ||||
$crud | $crud | ||||
->overrideTemplate('layout', '@LcCaracole/adminlte/layout.html.twig'); | ->overrideTemplate('layout', '@LcCaracole/adminlte/layout.html.twig'); | ||||
return $crud ; | |||||
return $crud; | |||||
} | } | ||||
public function configureAssets(): Assets | public function configureAssets(): Assets | ||||
{ | { | ||||
$assets = parent::configureAssets(); // TODO: Change the autogenerated stub | $assets = parent::configureAssets(); // TODO: Change the autogenerated stub | ||||
$assets->addWebpackEncoreEntry('carac-common') ; | |||||
$assets->addWebpackEncoreEntry('carac-switch-merchant') ; | |||||
$assets->addWebpackEncoreEntry('carac-common'); | |||||
$assets->addWebpackEncoreEntry('carac-switch-merchant'); | |||||
return $assets ; | |||||
return $assets; | |||||
} | |||||
public function configureUserMenu(UserInterface $user): UserMenu | |||||
{ | |||||
return parent::configureUserMenu($user) | |||||
->setMenuItems( | |||||
[ | |||||
MenuItem::linkToRoute('Mon profil', 'fa fa-id-card', 'sov_admin_account_profile'), | |||||
MenuItem::linkToLogout('Déconnexion', 'sign-out-alt'), | |||||
] | |||||
); | |||||
} | } | ||||
} | } |
public function new(AdminContext $context): Response | public function new(AdminContext $context): Response | ||||
{ | { | ||||
$entityManager = $this->get('em'); | |||||
$userFactory = $this->get('user_factory'); | $userFactory = $this->get('user_factory'); | ||||
$userMerchantFactory = $this->get('user_merchant_factory'); | $userMerchantFactory = $this->get('user_merchant_factory'); | ||||
$userRepository = $this->em->getRepository(UserInterface::class); | |||||
$userRepository = $entityManager->getRepository(UserInterface::class); | |||||
$merchantResolver = $this->get('merchant_resolver'); | $merchantResolver = $this->get('merchant_resolver'); | ||||
$userMerchant = $userMerchantFactory->create(); | $userMerchant = $userMerchantFactory->create(); | ||||
$form = $this->createForm(UserMerchantFormType::class, $userMerchant); | $form = $this->createForm(UserMerchantFormType::class, $userMerchant); | ||||
$form->handleRequest($context->getRequest()); | $form->handleRequest($context->getRequest()); | ||||
if ($form->isSubmitted() && $form->isValid()) { | if ($form->isSubmitted() && $form->isValid()) { | ||||
$userMerchant = $form->getData(); | $userMerchant = $form->getData(); | ||||
$existingUser = $userRepository->findOneByEmail($form->get('email')->getData()); | $existingUser = $userRepository->findOneByEmail($form->get('email')->getData()); | ||||
$user = $userFactory->create($param); | $user = $userFactory->create($param); | ||||
$this->em->create($user); | |||||
$entityManager->create($user); | |||||
$userMerchant->setUser($user); | $userMerchant->setUser($user); | ||||
$this->em->create($userMerchant); | |||||
$this->em->flush(); | |||||
$this->addFlash('success', $this->translatorAdmin->trans('form.user_merchant.create')); | |||||
$entityManager->create($userMerchant); | |||||
$entityManager->flush(); | |||||
$this->addFlash('success', $this->get('translator_admin')->trans('form.user_merchant.create')); | |||||
$url = $this->get(AdminUrlGenerator::class)->setAction(Action::INDEX)->generateUrl(); | $url = $this->get(AdminUrlGenerator::class)->setAction(Action::INDEX)->generateUrl(); | ||||
return $this->redirect($url); | return $this->redirect($url); | ||||
$existingUserMerchant = $merchantResolver->getUserMerchant($existingUser); | $existingUserMerchant = $merchantResolver->getUserMerchant($existingUser); | ||||
if ($existingUserMerchant == null) { | if ($existingUserMerchant == null) { | ||||
$userMerchant->setUser($existingUser); | $userMerchant->setUser($existingUser); | ||||
$this->em->create($userMerchant); | |||||
$this->em->flush(); | |||||
$entityManager->create($userMerchant); | |||||
$entityManager->flush(); | |||||
$this->addFlash('success', $this->translatorAdmin->trans('form.user_merchant.linked')); | |||||
$this->addFlash('success', $this->get('translator_admin')->trans('form.user_merchant.linked')); | |||||
$url = $this->get(AdminUrlGenerator::class)->setAction(Action::INDEX)->generateUrl(); | $url = $this->get(AdminUrlGenerator::class)->setAction(Action::INDEX)->generateUrl(); | ||||
return $this->redirect($url); | return $this->redirect($url); | ||||
} else { | } else { | ||||
$this->addFlash('error', $this->translatorAdmin->trans('form.user_merchant.already_exist')); | |||||
$this->addFlash('error', $this->get('translator_admin')->trans('form.user_merchant.already_exist')); | |||||
} | } | ||||
} | } | ||||
} | } | ||||
public function edit(AdminContext $context): Response | public function edit(AdminContext $context): Response | ||||
{ | { | ||||
$userRepository = $this->em->getRepository(UserInterface::class); | |||||
$entityManager = $this->get('em'); | |||||
$userRepository = $entityManager->getRepository(UserInterface::class); | |||||
$merchantResolver = $this->get('merchant_resolver'); | $merchantResolver = $this->get('merchant_resolver'); | ||||
$userMerchant = $context->getEntity()->getInstance(); | $userMerchant = $context->getEntity()->getInstance(); | ||||
$userMerchant->getUser()->setLastName($form->get('lastname')->getData()); | $userMerchant->getUser()->setLastName($form->get('lastname')->getData()); | ||||
$userMerchant->getUser()->setFirstname($form->get('firstname')->getData()); | $userMerchant->getUser()->setFirstname($form->get('firstname')->getData()); | ||||
$this->em->update($userMerchant); | |||||
$this->em->update($userMerchant->getUser()); | |||||
$this->em->flush(); | |||||
$this->addFlash('success', $this->translatorAdmin->trans('form.user_merchant.update')); | |||||
$entityManager->update($userMerchant); | |||||
$entityManager->update($userMerchant->getUser()); | |||||
$entityManager->flush(); | |||||
$this->addFlash('success', $this->get('translator_admin')->trans('form.user_merchant.update')); | |||||
$url = $this->get(AdminUrlGenerator::class)->setAction(Action::INDEX)->generateUrl(); | $url = $this->get(AdminUrlGenerator::class)->setAction(Action::INDEX)->generateUrl(); | ||||
return $this->redirect($url); | return $this->redirect($url); |
<?php | |||||
namespace Lc\CaracoleBundle\Factory; | |||||
use Doctrine\ORM\EntityManagerInterface; | |||||
use Lc\CaracoleBundle\Doctrine\Extension\FilterMerchantInterface; | |||||
use Lc\CaracoleBundle\Doctrine\Extension\FilterSectionInterface; | |||||
use Lc\CaracoleBundle\Resolver\MerchantResolver; | |||||
use Lc\CaracoleBundle\Resolver\SectionResolver; | |||||
use Lc\SovBundle\Factory\AbstractFactory as SovAbstractFactory; | |||||
trait FactoryTrait | |||||
{ | |||||
protected $merchantResolver; | |||||
protected $sectionResolver; | |||||
public function __construct( | |||||
EntityManagerInterface $em, | |||||
MerchantResolver $merchantResolver, | |||||
SectionResolver $sectionResolver | |||||
) { | |||||
$this->em = $em; | |||||
$this->merchantResolver = $merchantResolver; | |||||
$this->sectionResolver = $sectionResolver; | |||||
} | |||||
public function create($params = array()) | |||||
{ | |||||
$entityClass = $this->em->getEntityName($this->getEntityClass()); | |||||
$entity = new $entityClass; | |||||
if ($entity instanceof FilterMerchantInterface && !isset($params['merchant'])) { | |||||
$params['merchant'] = $this->merchantResolver->getCurrent(); | |||||
} | |||||
if ($entity instanceof FilterSectionInterface && !isset($params['section'])) { | |||||
$params['section'] = $this->sectionResolver->getCurrent(); | |||||
} | |||||
return parent::create($params); | |||||
} | |||||
} |
<?php | |||||
namespace Lc\CaracoleBundle\Factory\Reminder; | |||||
use Lc\CaracoleBundle\Factory\FactoryTrait; | |||||
use Lc\SovBundle\Factory\Reminder\ReminderFactory as SovReminderFactory; | |||||
class ReminderFactory extends SovReminderFactory | |||||
{ | |||||
use FactoryTrait; | |||||
} |
<?php | |||||
namespace Lc\CaracoleBundle\Factory\Ticket; | |||||
use Doctrine\ORM\EntityManagerInterface; | |||||
use Lc\CaracoleBundle\Factory\FactoryTrait; | |||||
use Lc\CaracoleBundle\Resolver\MerchantResolver; | |||||
use Lc\CaracoleBundle\Resolver\SectionResolver; | |||||
use Lc\SovBundle\Factory\Ticket\TicketFactory as SovTicketFactory; | |||||
use Lc\SovBundle\Factory\Ticket\TicketMessageFactory; | |||||
class TicketFactory extends SovTicketFactory | |||||
{ | |||||
// use FactoryTrait; | |||||
protected $merchantResolver; | |||||
protected $sectionResolver; | |||||
protected $ticketMessageFactory; | |||||
public function __construct( | |||||
EntityManagerInterface $em, | |||||
MerchantResolver $merchantResolver, | |||||
SectionResolver $sectionResolver, | |||||
TicketMessageFactory $ticketMessageFactory | |||||
) { | |||||
parent::__construct($em, $ticketMessageFactory); | |||||
$this->merchantResolver = $merchantResolver; | |||||
$this->sectionResolver = $sectionResolver; | |||||
} | |||||
public function create($params = array()) | |||||
{ | |||||
if (!isset($params['merchant'])) { | |||||
$params['merchant'] = $this->merchantResolver->getCurrent(); | |||||
} | |||||
return parent::create($params); | |||||
} | |||||
} |
use Doctrine\ORM\Mapping as ORM; | use Doctrine\ORM\Mapping as ORM; | ||||
use Lc\CaracoleBundle\Doctrine\Extension\FilterMerchantInterface; | use Lc\CaracoleBundle\Doctrine\Extension\FilterMerchantInterface; | ||||
use Lc\CaracoleBundle\Doctrine\Extension\FilterSectionInterface; | |||||
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | ||||
use Lc\CaracoleBundle\Model\Section\SectionInterface; | |||||
use Lc\SovBundle\Model\Reminder\ReminderModel as SovReminderModel; | use Lc\SovBundle\Model\Reminder\ReminderModel as SovReminderModel; | ||||
/** | /** | ||||
* @ORM\MappedSuperclass() | * @ORM\MappedSuperclass() | ||||
*/ | */ | ||||
abstract class ReminderModel extends SovReminderModel implements FilterMerchantInterface | |||||
abstract class ReminderModel extends SovReminderModel implements FilterMerchantInterface, FilterSectionInterface | |||||
{ | { | ||||
/** | /** | ||||
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Merchant\MerchantInterface") | * @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Merchant\MerchantInterface") | ||||
*/ | */ | ||||
protected $merchant; | protected $merchant; | ||||
/** | |||||
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Section\SectionInterface") | |||||
*/ | |||||
protected $section; | |||||
public function getMerchant(): MerchantInterface | public function getMerchant(): MerchantInterface | ||||
{ | { | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getSection(): ?SectionInterface | |||||
{ | |||||
return $this->section; | |||||
} | |||||
public function setSection(?SectionInterface $section): self | |||||
{ | |||||
$this->section = $section; | |||||
return $this; | |||||
} | |||||
} | } |
*/ | */ | ||||
protected $orderShop; | protected $orderShop; | ||||
public function getChoicesType(): array | |||||
{ | |||||
$choices = parent::getChoicesType(); | |||||
$choicesProduct = [ | |||||
'entity.Ticket.fields.typeOptions.' . TicketModel::TYPE_PRODUCT_UNAVAILABLE => TicketModel::TYPE_PRODUCT_UNAVAILABLE, | |||||
'entity.Ticket.fields.typeOptions.' . TicketModel::TYPE_PRODUCT_ERROR => TicketModel::TYPE_PRODUCT_ERROR | |||||
]; | |||||
return array_merge($choices, $choicesProduct); | |||||
} | |||||
public function getMerchant(): MerchantInterface | public function getMerchant(): MerchantInterface | ||||
{ | { | ||||
return $this->merchant; | return $this->merchant; |
<?php | |||||
namespace Lc\CaracoleBundle\Repository\Reminder; | |||||
use Lc\CaracoleBundle\Repository\RepositoryTrait; | |||||
use Lc\SovBundle\Model\Reminder\ReminderInterface; | |||||
use Lc\SovBundle\Repository\Reminder\ReminderRepository as SovReminderRepository; | |||||
/** | |||||
* @method ReminderInterface|null find($id, $lockMode = null, $lockVersion = null) | |||||
* @method ReminderInterface|null findOneBy(array $criteria, array $orderBy = null) | |||||
* @method ReminderInterface[] findAll() | |||||
* @method ReminderInterface[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) | |||||
*/ | |||||
class ReminderRepository extends SovReminderRepository | |||||
{ | |||||
use RepositoryTrait; | |||||
} |
padding-top: 0px; | padding-top: 0px; | ||||
padding-bottom: 0px; | padding-bottom: 0px; | ||||
border-width: 2px; | border-width: 2px; | ||||
z-index: 1; | |||||
ul.left { | ul.left { | ||||
position: relative; | position: relative; |
{% extends '@LcSov/admin/ticket/detail.html.twig' %} |