<?php | <?php | ||||
namespace Lc\CaracoleBundle\Controller\Admin; | |||||
namespace Lc\CaracoleBundle\Controller; | |||||
use Doctrine\ORM\EntityManagerInterface; | use Doctrine\ORM\EntityManagerInterface; | ||||
use Doctrine\ORM\QueryBuilder; | use Doctrine\ORM\QueryBuilder; | ||||
use Lc\CaracoleBundle\Doctrine\Extension\FilterSectionInterface; | use Lc\CaracoleBundle\Doctrine\Extension\FilterSectionInterface; | ||||
use Lc\CaracoleBundle\Resolver\MerchantResolver; | use Lc\CaracoleBundle\Resolver\MerchantResolver; | ||||
use Lc\CaracoleBundle\Resolver\SectionResolver; | use Lc\CaracoleBundle\Resolver\SectionResolver; | ||||
use Lc\SovBundle\Controller\Admin\AbstractCrudController as SovAbstractCrudController; | |||||
use Lc\SovBundle\Controller\AbstractAdminController as SovAbstractAdminController; | |||||
use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto; | use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Dto\SearchDto; | use EasyCorp\Bundle\EasyAdminBundle\Dto\SearchDto; | ||||
use Lc\SovBundle\Doctrine\EntityManager; | use Lc\SovBundle\Doctrine\EntityManager; | ||||
use Symfony\Component\HttpFoundation\RequestStack; | use Symfony\Component\HttpFoundation\RequestStack; | ||||
use Symfony\Component\HttpFoundation\Session\SessionInterface; | use Symfony\Component\HttpFoundation\Session\SessionInterface; | ||||
abstract class AbstractCrudController extends SovAbstractCrudController | |||||
abstract class AbstractAdminController extends SovAbstractAdminController | |||||
{ | { | ||||
protected $session; | protected $session; | ||||
protected $request; | protected $request; |
<?php | <?php | ||||
namespace Lc\CaracoleBundle\Controller\Common; | |||||
namespace Lc\CaracoleBundle\Controller\Config; | |||||
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud; | use EasyCorp\Bundle\EasyAdminBundle\Config\Crud; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Field\IntegerField; | use EasyCorp\Bundle\EasyAdminBundle\Field\IntegerField; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField; | use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; | use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; | ||||
use Lc\CaracoleBundle\Controller\Admin\AbstractCrudController; | |||||
use Lc\CaracoleBundle\Controller\AbstractAdminController; | |||||
abstract class TaxRateCrudController extends AbstractCrudController | |||||
abstract class TaxRateAdminController extends AbstractAdminController | |||||
{ | { | ||||
public function configureCrud(Crud $crud): Crud | public function configureCrud(Crud $crud): Crud |
<?php | <?php | ||||
namespace Lc\CaracoleBundle\Controller\Admin; | |||||
namespace Lc\CaracoleBundle\Controller\Dashboard; | |||||
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud; | use EasyCorp\Bundle\EasyAdminBundle\Config\Crud; | ||||
use Lc\SovBundle\Controller\Admin\DashboardController as SovDashboardController ; | |||||
use Lc\SovBundle\Controller\Dashboard\DashboardController as SovDashboardController ; | |||||
class DashboardController extends SovDashboardController | |||||
class DashboardAdminController extends SovDashboardController | |||||
{ | { | ||||
public function configureCrud(): Crud | public function configureCrud(): Crud | ||||
{ | { |
use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField; | use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextareaField; | use EasyCorp\Bundle\EasyAdminBundle\Field\TextareaField; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; | use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; | ||||
use Lc\CaracoleBundle\Controller\Admin\AbstractCrudController; | |||||
use Lc\CaracoleBundle\Controller\AbstractAdminController; | |||||
abstract class GroupUserCrudController extends AbstractCrudController | |||||
abstract class GroupUserAdminController extends AbstractAdminController | |||||
{ | { | ||||
namespace Lc\CaracoleBundle\Doctrine\Extension; | namespace Lc\CaracoleBundle\Doctrine\Extension; | ||||
use Lc\CaracoleBundle\Model\Common\TaxRateInterface; | |||||
use Lc\CaracoleBundle\Model\Common\UnitInterface; | |||||
use Lc\CaracoleBundle\Model\Config\TaxRateInterface; | |||||
use Lc\CaracoleBundle\Model\Config\UnitInterface; | |||||
trait PriceTrait | trait PriceTrait | ||||
{ | { | ||||
protected $price; | protected $price; | ||||
/** | /** | ||||
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Common\UnitInterface") | |||||
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Config\UnitInterface") | |||||
* @ORM\JoinColumn(nullable=true) | * @ORM\JoinColumn(nullable=true) | ||||
*/ | */ | ||||
protected $unit; | protected $unit; | ||||
/** | /** | ||||
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Common\TaxRateInterface") | |||||
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Config\TaxRateInterface") | |||||
* @ORM\JoinColumn(nullable=true) | * @ORM\JoinColumn(nullable=true) | ||||
*/ | */ | ||||
protected $taxRate; | protected $taxRate; |
<?php | |||||
namespace Lc\CaracoleBundle\Form\Merchant; | |||||
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | |||||
use Lc\SovBundle\DataTransformer\FileManagerTypeToDataTransformer; | |||||
use Lc\SovBundle\Doctrine\EntityManager; | |||||
use Lc\SovBundle\Translation\TranslatorAdmin; | |||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType; | |||||
use Symfony\Component\Form\AbstractType; | |||||
use Symfony\Component\Form\FormBuilderInterface; | |||||
class SwitchMerchantFormType extends AbstractType | |||||
{ | |||||
protected $em; | |||||
protected $translatorAdmin; | |||||
public function __construct(EntityManager $em, TranslatorAdmin $translatorAdmin) | |||||
{ | |||||
$this->em = $em; | |||||
$this->translatorAdmin = $translatorAdmin; | |||||
} | |||||
public function buildForm(FormBuilderInterface $builder, array $options) | |||||
{ | |||||
$entityName = $this->em->getEntityName(MerchantInterface::class); | |||||
$builder->add( | |||||
'merchants', | |||||
EntityType::class, | |||||
[ | |||||
'class' => $entityName, | |||||
'choice_label' => 'title' | |||||
] | |||||
); | |||||
} | |||||
} |
<?php | |||||
namespace Lc\CaracoleBundle\Model\Common; | |||||
interface TaxRateInterface | |||||
{ | |||||
} |
<?php | |||||
namespace Lc\CaracoleBundle\Model\Common ; | |||||
interface UnitInterface | |||||
{ | |||||
} |
<?php | |||||
namespace Lc\CaracoleBundle\Model\Config; | |||||
interface TaxRateInterface | |||||
{ | |||||
} |
<?php | <?php | ||||
namespace Lc\CaracoleBundle\Model\Common; | |||||
namespace Lc\CaracoleBundle\Model\Config; | |||||
use Doctrine\ORM\Mapping as ORM; | use Doctrine\ORM\Mapping as ORM; | ||||
use Lc\SovBundle\Doctrine\Pattern\AbstractLightEntity; | use Lc\SovBundle\Doctrine\Pattern\AbstractLightEntity; |
<?php | |||||
namespace Lc\CaracoleBundle\Model\Config ; | |||||
interface UnitInterface | |||||
{ | |||||
} |
<?php | <?php | ||||
namespace Lc\CaracoleBundle\Model\Common; | |||||
namespace Lc\CaracoleBundle\Model\Config; | |||||
use Doctrine\ORM\Mapping as ORM; | use Doctrine\ORM\Mapping as ORM; | ||||
use Lc\SovBundle\Doctrine\Pattern\AbstractLightEntity; | use Lc\SovBundle\Doctrine\Pattern\AbstractLightEntity; | ||||
protected $coefficient; | protected $coefficient; | ||||
/** | /** | ||||
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Common\UnitInterface") | |||||
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Config\UnitInterface") | |||||
* @ORM\JoinColumn(nullable=true) | * @ORM\JoinColumn(nullable=true) | ||||
*/ | */ | ||||
protected $unitReference; | protected $unitReference; |
use Doctrine\Common\Collections\Collection; | use Doctrine\Common\Collections\Collection; | ||||
use Doctrine\ORM\Mapping as ORM; | use Doctrine\ORM\Mapping as ORM; | ||||
use Lc\CaracoleBundle\Model\Address\AddressInterface; | use Lc\CaracoleBundle\Model\Address\AddressInterface; | ||||
use Lc\CaracoleBundle\Model\Common\TaxRateInterface; | |||||
use Lc\CaracoleBundle\Model\Config\TaxRateInterface; | |||||
use Lc\CaracoleBundle\Model\Credit\CreditConfigInterface; | use Lc\CaracoleBundle\Model\Credit\CreditConfigInterface; | ||||
use Lc\CaracoleBundle\Model\Newsletter\NewsletterInterface; | use Lc\CaracoleBundle\Model\Newsletter\NewsletterInterface; | ||||
use Lc\CaracoleBundle\Model\PointSale\PointSaleInterface; | use Lc\CaracoleBundle\Model\PointSale\PointSaleInterface; | ||||
protected $creditConfig; | protected $creditConfig; | ||||
/** | /** | ||||
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Common\TaxRateInterface") | |||||
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Config\TaxRateInterface") | |||||
* @ORM\JoinColumn(nullable=false) | * @ORM\JoinColumn(nullable=false) | ||||
*/ | */ | ||||
protected $taxRate; | protected $taxRate; |
<?php | <?php | ||||
namespace Lc\CaracoleBundle\Repository\Common; | |||||
namespace Lc\CaracoleBundle\Repository\Config; | |||||
use Lc\CaracoleBundle\Model\Common\TaxRateInterface; | |||||
use Lc\CaracoleBundle\Model\Config\TaxRateInterface; | |||||
use Lc\SovBundle\Repository\AbstractRepository; | use Lc\SovBundle\Repository\AbstractRepository; | ||||
/** | /** |
<?php | <?php | ||||
namespace Lc\CaracoleBundle\Repository\Common; | |||||
namespace Lc\CaracoleBundle\Repository\Config; | |||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; | use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; | ||||
use Doctrine\Persistence\ManagerRegistry; | use Doctrine\Persistence\ManagerRegistry; | ||||
use Lc\CaracoleBundle\Model\Common\UnitInterface; | |||||
use Lc\CaracoleBundle\Model\Config\UnitInterface; | |||||
/** | /** | ||||
* @method UnitInterface|null find($id, $lockMode = null, $lockVersion = null) | * @method UnitInterface|null find($id, $lockMode = null, $lockVersion = null) |
<nav class="navbar navbar-expand navbar-light main-header"> | <nav class="navbar navbar-expand navbar-light main-header"> | ||||
<ul class="navbar-nav"> | <ul class="navbar-nav"> | ||||
<li class="nav-item d-none d-sm-inline-block"> | |||||
<a href="#" class="nav-link">Marché</a> | |||||
</li> | |||||
<li class="nav-item d-none d-sm-inline-block"> | |||||
<a href="#" class="nav-link">Repas du midi</a> | |||||
</li> | |||||
<li class="nav-item d-none d-sm-inline-block"> | |||||
<a href="#" class="nav-link">Retrait journée</a> | |||||
</li> | |||||
{% for section in carac_get_sections() %} | |||||
<li class="nav-item d-none d-sm-inline-block"> | |||||
<a href="#" class="nav-link">{{ section.title }}</a> | |||||
</li> | |||||
{% endfor %} | |||||
</ul> | </ul> | ||||
<ul class="navbar-nav ml-auto"> | <ul class="navbar-nav ml-auto"> | ||||
<li class="nav-item"> | <li class="nav-item"> | ||||
Switch merchant | |||||
{% set form_switch_merchant = carac_get_form_switch_merchhant() %} | |||||
{{ form_start(form_switch_merchant) }} | |||||
{{ form(form_switch_merchant) }} | |||||
{{ form_end(form_switch_merchant) }} | |||||
</li> | </li> | ||||
</ul> | </ul> | ||||
</nav> | </nav> |
<?php | |||||
namespace Lc\CaracoleBundle\Twig; | |||||
use Doctrine\ORM\EntityManagerInterface; | |||||
use Lc\CaracoleBundle\Form\Merchant\SwitchMerchantFormType; | |||||
use Lc\CaracoleBundle\Repository\Merchant\MerchantRepository; | |||||
use Lc\CaracoleBundle\Repository\Section\SectionRepository; | |||||
use Lc\SovBundle\Translation\TranslatorAdmin; | |||||
use Liip\ImagineBundle\Imagine\Cache\CacheManager; | |||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; | |||||
use Symfony\Component\Form\FormFactoryInterface; | |||||
use Symfony\Component\HttpFoundation\RequestStack; | |||||
use Symfony\Component\HttpKernel\KernelInterface; | |||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface; | |||||
use Symfony\Contracts\Translation\TranslatorInterface; | |||||
use Twig\Extension\AbstractExtension; | |||||
use Twig\TwigFunction; | |||||
class TwigExtension extends AbstractExtension | |||||
{ | |||||
protected $em; | |||||
protected $kernel; | |||||
protected $parameterBag; | |||||
protected $cacheManager; | |||||
protected $requestStack; | |||||
protected $router; | |||||
protected $translator; | |||||
protected $translatorAdmin; | |||||
protected $merchantRepository; | |||||
protected $sectionRepository; | |||||
protected $formFactory; | |||||
public function __construct( | |||||
KernelInterface $kernel, | |||||
ParameterBagInterface $parameterBag, | |||||
CacheManager $cacheManager, | |||||
EntityManagerInterface $entityManager, | |||||
RequestStack $requestStack, | |||||
UrlGeneratorInterface $router, | |||||
TranslatorInterface $translator, | |||||
TranslatorAdmin $translatorAdmin, | |||||
MerchantRepository $merchantRepository, | |||||
SectionRepository $sectionRepository, | |||||
FormFactoryInterface $formFactory | |||||
) { | |||||
$this->kernel = $kernel; | |||||
$this->parameterBag = $parameterBag; | |||||
$this->cacheManager = $cacheManager; | |||||
$this->em = $entityManager; | |||||
$this->requestStack = $requestStack; | |||||
$this->router = $router; | |||||
$this->translator = $translator; | |||||
$this->translatorAdmin = $translatorAdmin; | |||||
$this->merchantRepository = $merchantRepository; | |||||
$this->sectionRepository = $sectionRepository; | |||||
$this->formFactory = $formFactory; | |||||
} | |||||
public function getFunctions() | |||||
{ | |||||
return array( | |||||
new TwigFunction('carac_get_sections', [$this, 'getSections']), | |||||
new TwigFunction('carac_get_form_switch_merchhant', [$this, 'getFormSwitchMerchant']), | |||||
); | |||||
} | |||||
public function getSections() | |||||
{ | |||||
return $this->sectionRepository->findAll(); | |||||
} | |||||
public function getMerchants() | |||||
{ | |||||
return $this->merchantRepository->findAll(); | |||||
} | |||||
public function getFormSwitchMerchant() | |||||
{ | |||||
$form = $this->formFactory->create(SwitchMerchantFormType::class, null, ['action' => '#']); | |||||
return $form->createView(); | |||||
} | |||||
} |