Fab 3 роки тому
джерело
коміт
1821098701
10 змінених файлів з 180 додано та 21 видалено
  1. +19
    -5
      Controller/Dashboard/DashboardAdminAdminController.php
  2. +17
    -15
      Controller/User/UserMerchantAdminController.php
  3. +43
    -0
      Factory/FactoryTrait.php
  4. +12
    -0
      Factory/Reminder/ReminderFactory.php
  5. +39
    -0
      Factory/Ticket/TicketFactory.php
  6. +19
    -1
      Model/Reminder/ReminderModel.php
  7. +11
    -0
      Model/Ticket/TicketModel.php
  8. +18
    -0
      Repository/Reminder/ReminderRepository.php
  9. +1
    -0
      Resources/assets/app/adminlte/common/common.scss
  10. +1
    -0
      Resources/views/admin/Ticket/detail.html.twig

+ 19
- 5
Controller/Dashboard/DashboardAdminAdminController.php Переглянути файл

@@ -4,7 +4,10 @@ namespace Lc\CaracoleBundle\Controller\Dashboard;

use EasyCorp\Bundle\EasyAdminBundle\Config\Assets;
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
{
@@ -15,17 +18,28 @@ class DashboardAdminAdminController extends SovDashboardController
$crud
->overrideTemplate('layout', '@LcCaracole/adminlte/layout.html.twig');

return $crud ;
return $crud;
}

public function configureAssets(): Assets
{
$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'),
]
);
}

}

+ 17
- 15
Controller/User/UserMerchantAdminController.php Переглянути файл

@@ -96,11 +96,11 @@ abstract class UserMerchantAdminController extends AbstractAdminController

public function new(AdminContext $context): Response
{
$entityManager = $this->get('em');
$userFactory = $this->get('user_factory');
$userMerchantFactory = $this->get('user_merchant_factory');
$userRepository = $this->em->getRepository(UserInterface::class);
$userRepository = $entityManager->getRepository(UserInterface::class);
$merchantResolver = $this->get('merchant_resolver');

$userMerchant = $userMerchantFactory->create();

$form = $this->createForm(UserMerchantFormType::class, $userMerchant);
@@ -108,6 +108,7 @@ abstract class UserMerchantAdminController extends AbstractAdminController
$form->handleRequest($context->getRequest());

if ($form->isSubmitted() && $form->isValid()) {

$userMerchant = $form->getData();

$existingUser = $userRepository->findOneByEmail($form->get('email')->getData());
@@ -120,11 +121,11 @@ abstract class UserMerchantAdminController extends AbstractAdminController

$user = $userFactory->create($param);

$this->em->create($user);
$entityManager->create($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();

return $this->redirect($url);
@@ -133,15 +134,15 @@ abstract class UserMerchantAdminController extends AbstractAdminController
$existingUserMerchant = $merchantResolver->getUserMerchant($existingUser);
if ($existingUserMerchant == null) {
$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();

return $this->redirect($url);
} 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'));
}
}
}
@@ -157,7 +158,8 @@ abstract class UserMerchantAdminController extends AbstractAdminController

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');

$userMerchant = $context->getEntity()->getInstance();
@@ -173,10 +175,10 @@ abstract class UserMerchantAdminController extends AbstractAdminController
$userMerchant->getUser()->setLastName($form->get('lastname')->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();

return $this->redirect($url);

+ 43
- 0
Factory/FactoryTrait.php Переглянути файл

@@ -0,0 +1,43 @@
<?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);
}

}

+ 12
- 0
Factory/Reminder/ReminderFactory.php Переглянути файл

@@ -0,0 +1,12 @@
<?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;

}

+ 39
- 0
Factory/Ticket/TicketFactory.php Переглянути файл

@@ -0,0 +1,39 @@
<?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);
}
}

+ 19
- 1
Model/Reminder/ReminderModel.php Переглянути файл

@@ -4,13 +4,15 @@ namespace Lc\CaracoleBundle\Model\Reminder;

use Doctrine\ORM\Mapping as ORM;
use Lc\CaracoleBundle\Doctrine\Extension\FilterMerchantInterface;
use Lc\CaracoleBundle\Doctrine\Extension\FilterSectionInterface;
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
use Lc\CaracoleBundle\Model\Section\SectionInterface;
use Lc\SovBundle\Model\Reminder\ReminderModel as SovReminderModel;

/**
* @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")
@@ -18,6 +20,10 @@ abstract class ReminderModel extends SovReminderModel implements FilterMerchantI
*/
protected $merchant;

/**
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Section\SectionInterface")
*/
protected $section;

public function getMerchant(): MerchantInterface
{
@@ -30,4 +36,16 @@ abstract class ReminderModel extends SovReminderModel implements FilterMerchantI

return $this;
}

public function getSection(): ?SectionInterface
{
return $this->section;
}

public function setSection(?SectionInterface $section): self
{
$this->section = $section;

return $this;
}
}

+ 11
- 0
Model/Ticket/TicketModel.php Переглянути файл

@@ -27,6 +27,17 @@ abstract class TicketModel extends SovTicketModel implements FilterMerchantInter
*/
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
{
return $this->merchant;

+ 18
- 0
Repository/Reminder/ReminderRepository.php Переглянути файл

@@ -0,0 +1,18 @@
<?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;
}

+ 1
- 0
Resources/assets/app/adminlte/common/common.scss Переглянути файл

@@ -5,6 +5,7 @@ nav.navbar.carac {
padding-top: 0px;
padding-bottom: 0px;
border-width: 2px;
z-index: 1;

ul.left {
position: relative;

+ 1
- 0
Resources/views/admin/Ticket/detail.html.twig Переглянути файл

@@ -0,0 +1 @@
{% extends '@LcSov/admin/ticket/detail.html.twig' %}

Завантаження…
Відмінити
Зберегти