@@ -51,13 +51,13 @@ class OrderShopFieldDefinition extends AbstractFieldDefinition | |||
{ | |||
return [ | |||
'id' => IntegerField::new('id', 'ID')->setSortable(true), | |||
'userLastname' => TextareaField::new('user.lastname')->setSortable(true) | |||
'userLastname' => TextareaField::new('user.lastname') | |||
->setCustomOption('filter_fqcn', OrderShopUserLastnameFilter::class), | |||
//->setTemplatePath('@LcShop/backend/default/field/textorempty.html.twig'), | |||
'userFirstname' => TextareaField::new('user.firstname')->setSortable(true) | |||
'userFirstname' => TextareaField::new('user.firstname') | |||
->setCustomOption('filter_fqcn', OrderShopUserFirstnameFilter::class), | |||
//->setTemplatePath('@LcShop/backend/default/field/textorempty.html.twig'), | |||
'userEmail' => TextareaField::new('user.email')->setSortable(true) | |||
'userEmail' => TextareaField::new('user.email') | |||
->setCustomOption('filter_fqcn', OrderShopUserEmailFilter::class), | |||
//->setTemplatePath('@LcShop/backend/default/field/user.html.twig'), | |||
'total' => NumberField::new('total') |
@@ -47,6 +47,7 @@ class UserFieldDefinition extends SovUserFieldDefinition | |||
'birthdate', | |||
'countOrder', | |||
'totalSpent', | |||
'isSaleAlwaysOpen', | |||
]; | |||
} | |||
@@ -85,7 +86,7 @@ class UserFieldDefinition extends SovUserFieldDefinition | |||
->setFormTypeOption('choice_label', function ($choice) { | |||
return $choice->getTitle() . '[' . $choice->getMerchant() . ']'; | |||
}) | |||
->setSortable(true), | |||
->setSortable(false), | |||
'ticketTypesNotification' => ChoiceField::new('ticketTypesNotification') | |||
->setSortable(true) | |||
->setFormTypeOption('expanded', false) |
@@ -13,7 +13,6 @@ use Lc\CaracoleBundle\Field\Filter\User\UserMerchantLastnameFilter; | |||
use Lc\SovBundle\Definition\Field\AbstractFieldDefinition; | |||
class UserMerchantFieldDefinition extends AbstractFieldDefinition | |||
{ | |||
use MerchantContextTrait; | |||
@@ -21,36 +20,35 @@ class UserMerchantFieldDefinition extends AbstractFieldDefinition | |||
public function configureIndex(): array | |||
{ | |||
return [ | |||
'id', | |||
'lastname', | |||
'firstname', | |||
'email', | |||
'credit', | |||
'id', | |||
'lastname', | |||
'firstname', | |||
'email', | |||
'credit', | |||
]; | |||
} | |||
public function configureForm(): array | |||
{ | |||
return [ | |||
'user', | |||
'user', | |||
]; | |||
} | |||
public function configureFields(): array | |||
{ | |||
return [ | |||
'id'=> IntegerField::new('id')->onlyOnIndex()->setSortable(true), | |||
'lastname'=> TextField::new('user.lastname')->setSortable(true) | |||
->setCustomOption('filter_fqcn', UserMerchantLastnameFilter::class), | |||
'firstname'=> TextField::new('user.firstname')->setSortable(true) | |||
->setCustomOption('filter_fqcn', UserMerchantFirstnameFilter::class), | |||
'email'=> TextField::new('user.email')->setSortable(true) | |||
->setCustomOption('filter_fqcn', UserMerchantEmailFilter::class), | |||
'credit'=> NumberField::new('credit')->setSortable(true) | |||
->setTemplatePath('@LcSov/adminlte/crud/field/amount.html.twig') | |||
->setCustomOption('appendHtml', '€'), | |||
'user'=> AssociationField::new('user'), | |||
'id' => IntegerField::new('id')->onlyOnIndex()->setSortable(true), | |||
'lastname' => TextField::new('user.lastname') | |||
->setCustomOption('filter_fqcn', UserMerchantLastnameFilter::class), | |||
'firstname' => TextField::new('user.firstname') | |||
->setCustomOption('filter_fqcn', UserMerchantFirstnameFilter::class), | |||
'email' => TextField::new('user.email') | |||
->setCustomOption('filter_fqcn', UserMerchantEmailFilter::class), | |||
'credit' => NumberField::new('credit')->setSortable(true) | |||
->setTemplatePath('@LcSov/adminlte/crud/field/amount.html.twig') | |||
->setCustomOption('appendHtml', '€'), | |||
'user' => AssociationField::new('user'), | |||
]; | |||
} |
@@ -0,0 +1,45 @@ | |||
<?php | |||
namespace Lc\CaracoleBundle\Field\Filter\Order; | |||
use Doctrine\ORM\EntityRepository; | |||
use Doctrine\ORM\QueryBuilder; | |||
use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto; | |||
use Lc\SovBundle\Field\Filter\AssociationFilter; | |||
use Lc\SovBundle\Field\Filter\FilterTrait; | |||
use Lc\SovBundle\Repository\RepositoryQueryInterface; | |||
use Symfony\Bridge\Doctrine\Form\Type\EntityType; | |||
use Symfony\Component\Form\Extension\Core\Type\TextType; | |||
use Symfony\Component\Form\FormBuilderInterface; | |||
/** | |||
* @author La clic ! <contact@laclic.fr> | |||
*/ | |||
class OrderProductUserEmailFilter | |||
{ | |||
use FilterTrait; | |||
public function buildProperty(FormBuilderInterface $builder, FieldDto $fieldDto, $options = array()) | |||
{ | |||
$builder->add( | |||
$this->getFieldPropertySnake($fieldDto->getProperty()), | |||
TextType::class, | |||
array( | |||
'required' => false, | |||
'attr' => array( | |||
'class' => ' input-sm', | |||
'form' => 'filters-form', | |||
), | |||
) | |||
); | |||
} | |||
public function applyFilter(RepositoryQueryInterface $repositoryQuery, FieldDto $fieldDto, $filteredValue = null) | |||
{ | |||
if ($filteredValue !== null) { | |||
$repositoryQuery->filterByEmailUser('%'.$filteredValue.'%'); | |||
} | |||
} | |||
} |
@@ -0,0 +1,45 @@ | |||
<?php | |||
namespace Lc\CaracoleBundle\Field\Filter\Order; | |||
use Doctrine\ORM\EntityRepository; | |||
use Doctrine\ORM\QueryBuilder; | |||
use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto; | |||
use Lc\SovBundle\Field\Filter\AssociationFilter; | |||
use Lc\SovBundle\Field\Filter\FilterTrait; | |||
use Lc\SovBundle\Repository\RepositoryQueryInterface; | |||
use Symfony\Bridge\Doctrine\Form\Type\EntityType; | |||
use Symfony\Component\Form\Extension\Core\Type\TextType; | |||
use Symfony\Component\Form\FormBuilderInterface; | |||
/** | |||
* @author La clic ! <contact@laclic.fr> | |||
*/ | |||
class OrderProductUserFirstnameFilter | |||
{ | |||
use FilterTrait; | |||
public function buildProperty(FormBuilderInterface $builder, FieldDto $fieldDto, $options = array()) | |||
{ | |||
$builder->add( | |||
$this->getFieldPropertySnake($fieldDto->getProperty()), | |||
TextType::class, | |||
array( | |||
'required' => false, | |||
'attr' => array( | |||
'class' => ' input-sm', | |||
'form' => 'filters-form', | |||
), | |||
) | |||
); | |||
} | |||
public function applyFilter(RepositoryQueryInterface $repositoryQuery, FieldDto $fieldDto, $filteredValue = null) | |||
{ | |||
if ($filteredValue !== null) { | |||
$repositoryQuery->filterByFirstnameUser('%'.$filteredValue.'%'); | |||
} | |||
} | |||
} |
@@ -0,0 +1,45 @@ | |||
<?php | |||
namespace Lc\CaracoleBundle\Field\Filter\Order; | |||
use Doctrine\ORM\EntityRepository; | |||
use Doctrine\ORM\QueryBuilder; | |||
use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto; | |||
use Lc\SovBundle\Field\Filter\AssociationFilter; | |||
use Lc\SovBundle\Field\Filter\FilterTrait; | |||
use Lc\SovBundle\Repository\RepositoryQueryInterface; | |||
use Symfony\Bridge\Doctrine\Form\Type\EntityType; | |||
use Symfony\Component\Form\Extension\Core\Type\TextType; | |||
use Symfony\Component\Form\FormBuilderInterface; | |||
/** | |||
* @author La clic ! <contact@laclic.fr> | |||
*/ | |||
class OrderProductUserLastnameFilter | |||
{ | |||
use FilterTrait; | |||
public function buildProperty(FormBuilderInterface $builder, FieldDto $fieldDto, $options = array()) | |||
{ | |||
$builder->add( | |||
$this->getFieldPropertySnake($fieldDto->getProperty()), | |||
TextType::class, | |||
array( | |||
'required' => false, | |||
'attr' => array( | |||
'class' => ' input-sm', | |||
'form' => 'filters-form', | |||
), | |||
) | |||
); | |||
} | |||
public function applyFilter(RepositoryQueryInterface $repositoryQuery, FieldDto $fieldDto, $filteredValue = null) | |||
{ | |||
if ($filteredValue !== null) { | |||
$repositoryQuery->filterByLastnameUser('%'.$filteredValue.'%'); | |||
} | |||
} | |||
} |
@@ -53,7 +53,11 @@ class OrderShopDistributionFilter | |||
} | |||
// On sépare le cycleNumber et Year | |||
$cycleExplode = explode("a", $filteredValue); | |||
$cycleNumber = $cycleExplode[0]; | |||
if (!empty($cycleExplode[0])) { | |||
$cycleNumber = $cycleExplode[0]; | |||
} else { | |||
$cycleNumber = 0; | |||
} | |||
if (isset($cycleExplode[1])) { | |||
$year = $cycleExplode[1]; | |||
if (strlen($year) == 2) { |
@@ -38,7 +38,7 @@ class OrderShopUserEmailFilter | |||
public function applyFilter(RepositoryQueryInterface $repositoryQuery, FieldDto $fieldDto, $filteredValue = null) | |||
{ | |||
if ($filteredValue !== null) { | |||
$repositoryQuery->filterByDeliveryType('%'.$filteredValue.'%'); | |||
$repositoryQuery->filterByUserEmail('%'.$filteredValue.'%'); | |||
} | |||
} | |||
@@ -11,9 +11,6 @@ use Lc\SovBundle\Doctrine\Extension\DevAliasTrait; | |||
use Lc\SovBundle\Doctrine\Extension\TimestampableTrait; | |||
use Lc\SovBundle\Model\User\UserInterface; | |||
/** | |||
* @ORM\MappedSuperclass | |||
*/ | |||
interface UnitInterface | |||
{ | |||
public function getCreatedBy(): ?UserInterface; |
@@ -19,6 +19,7 @@ class OrderProductRepositoryQuery extends AbstractRepositoryQuery | |||
protected bool $isJoinProductFamily = false; | |||
protected bool $isJoinOrderShop = false; | |||
protected bool $isJoinOrderStatus = false; | |||
protected bool $isJoinUser = false; | |||
public function __construct(OrderProductRepository $repository, PaginatorInterface $paginator) | |||
{ | |||
@@ -28,15 +29,15 @@ class OrderProductRepositoryQuery extends AbstractRepositoryQuery | |||
public function filterByOrderShop(OrderShopInterface $orderShop): self | |||
{ | |||
return $this | |||
->andWhere('.orderShop = :orderShop') | |||
->setParameter('orderShop', $orderShop); | |||
->andWhere('.orderShop = :orderShop') | |||
->setParameter('orderShop', $orderShop); | |||
} | |||
public function filterByProduct(ProductInterface $product): self | |||
{ | |||
return $this | |||
->andWhere('.product = :product') | |||
->setParameter('product', $product); | |||
->andWhere('.product = :product') | |||
->setParameter('product', $product); | |||
} | |||
public function filterByUser(UserInterface $user): self | |||
@@ -44,8 +45,35 @@ class OrderProductRepositoryQuery extends AbstractRepositoryQuery | |||
$this->joinOrderShop(); | |||
return $this | |||
->andWhere('orderShop.user = :user') | |||
->setParameter('user', $user); | |||
->andWhere('orderShop.user = :user') | |||
->setParameter('user', $user); | |||
} | |||
public function filterByEmailUser(string $email): self | |||
{ | |||
$this->joinUser(); | |||
return $this | |||
->andWhere('user.email LIKE :email') | |||
->setParameter('email', $email); | |||
} | |||
public function filterByFirstnameUser(string $firstname): self | |||
{ | |||
$this->joinUser(); | |||
return $this | |||
->andWhere('user.firstname LIKE :firstname') | |||
->setParameter('firstname', $firstname); | |||
} | |||
public function filterByLastnameUser(string $lastname): self | |||
{ | |||
$this->joinUser(); | |||
return $this | |||
->andWhere('user.lastname LIKE :lastname') | |||
->setParameter('lastname', $lastname); | |||
} | |||
public function filterBySection(SectionInterface $section): self | |||
@@ -60,15 +88,15 @@ class OrderProductRepositoryQuery extends AbstractRepositoryQuery | |||
$this->joinOrderStatus(); | |||
return $this | |||
->andWhere('orderStatus.alias IN (:alias)') | |||
->setParameter('alias', $status); | |||
->andWhere('orderStatus.alias IN (:alias)') | |||
->setParameter('alias', $status); | |||
} | |||
public function selectCount(): self | |||
{ | |||
return $this | |||
->select('count(orderProduct.id) as total'); | |||
->select('count(orderProduct.id) as total'); | |||
} | |||
public function joinProduct(): self | |||
@@ -77,7 +105,7 @@ class OrderProductRepositoryQuery extends AbstractRepositoryQuery | |||
$this->isJoinProduct = true; | |||
return $this | |||
->leftJoin('.product', 'product'); | |||
->leftJoin('.product', 'product'); | |||
} | |||
return $this; | |||
} | |||
@@ -89,7 +117,7 @@ class OrderProductRepositoryQuery extends AbstractRepositoryQuery | |||
$this->isJoinProductFamily = true; | |||
return $this | |||
->leftJoin('product.productFamily', 'productFamily'); | |||
->leftJoin('product.productFamily', 'productFamily'); | |||
} | |||
return $this; | |||
} | |||
@@ -100,7 +128,22 @@ class OrderProductRepositoryQuery extends AbstractRepositoryQuery | |||
$this->isJoinOrderShop = true; | |||
return $this | |||
->leftJoin('.orderShop', 'orderShop'); | |||
->leftJoin('.orderShop', 'orderShop'); | |||
} | |||
return $this; | |||
} | |||
public function joinUser(): self | |||
{ | |||
if (!$this->isJoinOrderShop) { | |||
$this->joinOrderShop(); | |||
} | |||
if (!$this->isJoinUser) { | |||
$this->isJoinUser = true; | |||
return $this | |||
->leftJoin('orderShop.user', 'user'); | |||
} | |||
return $this; | |||
} | |||
@@ -123,12 +166,13 @@ class OrderProductRepositoryQuery extends AbstractRepositoryQuery | |||
$this->isJoinOrderStatus = true; | |||
return $this | |||
->leftJoin('orderShop.orderStatus', 'orderStatus'); | |||
->leftJoin('orderShop.orderStatus', 'orderStatus'); | |||
} | |||
return $this; | |||
} | |||
public function filterByMerchant(MerchantInterface $merchant){ | |||
public function filterByMerchant(MerchantInterface $merchant) | |||
{ | |||
$this->joinOrderShop(); | |||
$this->joinSection(); | |||
return $this->andWhere('section.merchant = :merchant') |
@@ -4,7 +4,7 @@ $(document).ready(function() { | |||
}) ; | |||
function initSwitchMerchant() { | |||
let $form = $('form.switch-merchant') ; | |||
let $form = $('.nav-switch-merchant form.switch-merchant') ; | |||
$form.find('select').change(function() { | |||
$form.submit() ; | |||
}) ; |
@@ -18,9 +18,14 @@ | |||
{% set form_switch_merchant = carac_form_switch_merchant('admin', 'carac_merchant_favorite') %} | |||
{% form_theme form_switch_merchant '@LcSov/adminlte/crud/form_theme.html.twig' %} | |||
{{ form_start(form_switch_merchant) }} | |||
{{ form(form_switch_merchant) }} | |||
<div class="hidden"> | |||
{{ form_widget(form_switch_merchant.merchant, {attr:{'class': 'disable-select2'}}) }} | |||
</div> | |||
{{ form_rest(form_switch_merchant) }} | |||
{{ form_end(form_switch_merchant) }} | |||
<button id="carac-button-visit-merchant" type="button" class="btn btn-default" | |||
data-dismiss="modal">Visiter</button> | |||
data-dismiss="modal">Visiter | |||
</button> | |||
{% endblock %} | |||
{% endembed %} |
@@ -1,11 +1,13 @@ | |||
{% set distrubution = field.value %} | |||
{% set cycleType = distrubution.cycleType %} | |||
{% if cycleType == "day" %} | |||
{% set labelCycleType = "J" %} | |||
{% elseif cycleType == "week" %} | |||
{% set labelCycleType = "S" %} | |||
{% elseif cycleType == "month" %} | |||
{% set labelCycleType = "M" %} | |||
{% set distribution = field.value %} | |||
{% if distribution %} | |||
{% set cycleType = distribution.cycleType %} | |||
{% if cycleType == "day" %} | |||
{% set labelCycleType = "J" %} | |||
{% elseif cycleType == "week" %} | |||
{% set labelCycleType = "S" %} | |||
{% elseif cycleType == "month" %} | |||
{% set labelCycleType = "M" %} | |||
{% endif %} | |||
{% endif %} | |||
{{ labelCycleType ~ distrubution.cycleNumber }}A{{ distrubution.year|slice(2,2) }} | |||
{{ labelCycleType ~ distribution.cycleNumber }}A{{ distribution.year|slice(2,2) }} |
@@ -45,6 +45,8 @@ | |||
{% set user = app.user %} | |||
{% set merchant_current = merchant_current() %} | |||
{{ dump( merchant_current)}} | |||
{{ dump( user.favoriteMerchant )}} | |||
{% if(user.favoriteMerchant != merchant_current) %} | |||
{# modal affichée uniquement si la sessionStorage.visit_merchant n'est pas défini (js) #} | |||
{% include '@LcCaracole/admin/merchant/modal/switch_merchant.html.twig' %} |