Browse Source

Merge branch 'develop'

master
Guillaume 3 years ago
parent
commit
c74630249e
17 changed files with 203 additions and 12 deletions
  1. +15
    -0
      Builder/Product/ProductFamilySectionPropertyBuilder.php
  2. +1
    -0
      Definition/Field/Product/ProductCategoryFieldDefinition.php
  3. +2
    -0
      Definition/Field/User/UserFieldDefinition.php
  4. +1
    -1
      Field/Filter/ProductCategoriesFilter.php
  5. +38
    -0
      Field/Filter/User/UserExtraInfoCityFilter.php
  6. +38
    -0
      Field/Filter/User/UserExtraInfoZipFilter.php
  7. +11
    -1
      Repository/Product/ProductFamilyRepositoryQuery.php
  8. +30
    -0
      Repository/User/UserRepositoryQuery.php
  9. +1
    -0
      Resources/translations/admin.fr.yaml
  10. +0
    -7
      Resources/views/admin/product/field/product_family_section_properties.html.twig
  11. +6
    -1
      Resources/views/admin/section/macros.html.twig
  12. +11
    -0
      Resources/views/admin/user/field/extra_infos_city.html.twig
  13. +11
    -0
      Resources/views/admin/user/field/extra_infos_zip.html.twig
  14. +14
    -0
      Solver/Product/ProductCategorySolver.php
  15. +1
    -0
      Solver/Product/ProductFamilySectionPropertySolver.php
  16. +18
    -1
      Solver/Product/ProductFamilySolver.php
  17. +5
    -1
      Twig/StoreTwigExtension.php

+ 15
- 0
Builder/Product/ProductFamilySectionPropertyBuilder.php View File

$this->productFamilySectionPropertySolver = $productFamilySectionPropertySolver; $this->productFamilySectionPropertySolver = $productFamilySectionPropertySolver;
} }



public function enable(ProductFamilyInterface $productFamily, SectionInterface $section, bool $flush = true): void public function enable(ProductFamilyInterface $productFamily, SectionInterface $section, bool $flush = true): void
{ {
$productFamilySectionProperty = $this->productFamilySectionPropertySolver->getProductFamilySectionProperty($productFamily, $section); $productFamilySectionProperty = $this->productFamilySectionPropertySolver->getProductFamilySectionProperty($productFamily, $section);
} }
} }



public function disable(ProductFamilyInterface $productFamily, SectionInterface $section, bool $flush = true): void
{
$productFamilySectionProperty = $this->productFamilySectionPropertySolver->getProductFamilySectionProperty($productFamily, $section);

if ($productFamilySectionProperty) {
$productFamilySectionProperty->setStatus(0);
$this->entityManager->update($productFamilySectionProperty);
}
if($flush) {
$this->entityManager->flush();
}
}

} }

+ 1
- 0
Definition/Field/Product/ProductCategoryFieldDefinition.php View File

'title', 'title',
'description', 'description',
'image', 'image',
'status',
'saleStatus', 'saleStatus',
'isEligibleTicketRestaurant', 'isEligibleTicketRestaurant',
]; ];

+ 2
- 0
Definition/Field/User/UserFieldDefinition.php View File



namespace Lc\CaracoleBundle\Definition\Field\User; namespace Lc\CaracoleBundle\Definition\Field\User;


use App\Entity\User\GroupUser;
use EasyCorp\Bundle\EasyAdminBundle\Field\ChoiceField; use EasyCorp\Bundle\EasyAdminBundle\Field\ChoiceField;
use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField; use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField;
use Lc\CaracoleBundle\Context\MerchantContextTrait; use Lc\CaracoleBundle\Context\MerchantContextTrait;
->setSortable(true), ->setSortable(true),
'groupUsers' => AssociationField::new('groupUsers') 'groupUsers' => AssociationField::new('groupUsers')
->setFormTypeOption('choices', $groupUsers) ->setFormTypeOption('choices', $groupUsers)
->setCustomOption('class', GroupUser::class)
->setTemplatePath('@LcSov/adminlte/crud/field/association_many.html.twig') ->setTemplatePath('@LcSov/adminlte/crud/field/association_many.html.twig')
->setFormTypeOption('choice_label', function ($choice) { ->setFormTypeOption('choice_label', function ($choice) {
return $choice->getTitle() . '[' . $choice->getMerchant() . ']'; return $choice->getTitle() . '[' . $choice->getMerchant() . ']';

+ 1
- 1
Field/Filter/ProductCategoriesFilter.php View File

$isOffline = " [Hors ligne]"; $isOffline = " [Hors ligne]";
} }
$section = ' ['.$category->getSection()->getTitle().']' ;; $section = ' ['.$category->getSection()->getTitle().']' ;;
return $category->getTitle() . $section. $isOffline;
return $category . $section. $isOffline;


} }
) )

+ 38
- 0
Field/Filter/User/UserExtraInfoCityFilter.php View File

<?php

namespace Lc\CaracoleBundle\Field\Filter\User;

use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto;
use Lc\SovBundle\Field\Filter\AssociationFilter;
use Lc\SovBundle\Repository\RepositoryQueryInterface;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;

/**
* @author La clic ! <contact@laclic.fr>
*/
class UserExtraInfoCityFilter extends AssociationFilter
{
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->filterByExtraInfoCity('%' . $filteredValue . '%');
}
}

}

+ 38
- 0
Field/Filter/User/UserExtraInfoZipFilter.php View File

<?php

namespace Lc\CaracoleBundle\Field\Filter\User;

use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto;
use Lc\SovBundle\Field\Filter\AssociationFilter;
use Lc\SovBundle\Repository\RepositoryQueryInterface;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;

/**
* @author La clic ! <contact@laclic.fr>
*/
class UserExtraInfoZipFilter extends AssociationFilter
{
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->filterByExtraInfoZip('%' . $filteredValue . '%');
}
}

}

+ 11
- 1
Repository/Product/ProductFamilyRepositoryQuery.php View File

parent::__construct($repository, 'productFamily', $paginator); parent::__construct($repository, 'productFamily', $paginator);
} }


public function resetRelationsJoin(): void
{
$this->isJoinSections = false;
$this->isJoinProductCategories = false;
$this->isJoinProductFamilySectionProperties = false;
$this->isJoinProducts = false;
$this->isJoinQualityLabels = false;
}

public function joinProductFamilySectionProperties(bool $addSelect = true): self public function joinProductFamilySectionProperties(bool $addSelect = true): self
{ {
if (!$this->isJoinProductFamilySectionProperties) { if (!$this->isJoinProductFamilySectionProperties) {


$this->innerJoin('.products', 'products'); $this->innerJoin('.products', 'products');
if ($addSelect) { if ($addSelect) {
$this->addSelect('products');
// Décommenté sinon doctrine n'hydrate pas correctement les produits liés au ProductFamily (exemple : un seul sur deux)
// $this->addSelect('products');
} }
} }
return $this; return $this;

+ 30
- 0
Repository/User/UserRepositoryQuery.php View File

use MerchantRepositoryQueryTrait; use MerchantRepositoryQueryTrait;


protected $isJoinUserMerchants = false; protected $isJoinUserMerchants = false;
protected $isJoinAddresses = false;




public function joinUserMerchants(): self public function joinUserMerchants(): self
return $this; return $this;
} }


public function joinAddresses(): self
{
if (!$this->isJoinAddresses) {
$this->isJoinAddresses = true;

return $this
->innerJoin('.addresses', 'addresses');
}
return $this;
}

public function filterMerchantIsActive(): self public function filterMerchantIsActive(): self
{ {
$this->joinUserMerchants(); $this->joinUserMerchants();
->andWhere('userMerchants.merchant = :merchant') ->andWhere('userMerchants.merchant = :merchant')
->setParameter('merchant', $merchant); ->setParameter('merchant', $merchant);
} }

public function filterByExtraInfoZip(string $zip)
{
$this->joinAddresses();

return $this
->andWhere('.extraInfoZip LIKE :extraInfoZip OR addresses.zip LIKE :extraInfoZip')
->setParameter('extraInfoZip', $zip);
}

public function filterByExtraInfoCity(string $city)
{
$this->joinAddresses();

return $this
->andWhere('.extraInfoCity LIKE :extraInfoCity OR addresses.city LIKE :extraInfoCity')
->setParameter('extraInfoCity', $city);
}
} }

+ 1
- 0
Resources/translations/admin.fr.yaml View File

history: Historique history: Historique
credit: Voir l'historique de crédit credit: Voir l'historique de crédit
switchUser: Prendre la main switchUser: Prendre la main
exportOrderPurchasesAsArchive: Récapitulatif des commandes


setting_definition: setting_definition:
merchant: merchant:

+ 0
- 7
Resources/views/admin/product/field/product_family_section_properties.html.twig View File

{% import '@LcCaracole/admin/section/macros.html.twig' as macros_section %}
{% set item = entity.instance %}
{% for section_property in item.productFamilySectionProperties %}
{{ macros_section.section_badge(section_property.section) }}
{% else %}
<span class="badge badge-secondary">Aucune</span>
{% endfor %}

+ 6
- 1
Resources/views/admin/section/macros.html.twig View File


{% macro section_badge(section) %} {% macro section_badge(section) %}
<span class="badge badge-secondary {{ section_container.solver.getHtmlClass(section) }}">{{ section.title }}</span> <span class="badge badge-secondary {{ section_container.solver.getHtmlClass(section) }}">{{ section.title }}</span>
{% endmacro %}



{% macro section_badge_light_custom(section,title, status= 1) %}
<span class="badge badge-secondary {{ status !=1 ? 'stripped'}} {{ section_container.solver.getHtmlClass(section) }}-light">{{ title }}</span>
{% endmacro %} {% endmacro %}

+ 11
- 0
Resources/views/admin/user/field/extra_infos_city.html.twig View File

{% set user = entity.instance %}
{% set city = user.extraInfoCity %}
{% if city is not empty %}
<span class="badge badge-secondary">{{ city }}</span>
{% elseif user.addresses is not empty %}
{% for addresse in user.addresses %}
<span class="badge badge-secondary">{{ addresse.city }}</span>
{% endfor %}
{% else %}
<span class="badge badge-secondary">Aucun(e)</span>
{% endif %}

+ 11
- 0
Resources/views/admin/user/field/extra_infos_zip.html.twig View File

{% set user = entity.instance %}
{% set zip = user.extraInfoZip %}
{% if zip is not empty %}
<span class="badge badge-secondary">{{ zip }}</span>
{% elseif user.addresses is not empty %}
{% for addresse in user.addresses %}
<span class="badge badge-secondary">{{ addresse.zip }}</span>
{% endfor %}
{% else %}
<span class="badge badge-secondary">Aucun(e)</span>
{% endif %}

+ 14
- 0
Solver/Product/ProductCategorySolver.php View File



namespace Lc\CaracoleBundle\Solver\Product; namespace Lc\CaracoleBundle\Solver\Product;


use Lc\CaracoleBundle\Model\Product\ProductCategoryInterface;

class ProductCategorySolver class ProductCategorySolver
{ {


public function isOnline(ProductCategoryInterface $productCategory)
{
if ($productCategory->getParent()) {
if ($productCategory->getStatus() && $productCategory->getParent()->getStatus()) {
return true;
}
} elseif ($productCategory->getStatus()) {
return true;
}
return false;
}

} }





+ 1
- 0
Solver/Product/ProductFamilySectionPropertySolver.php View File

} }
return null; return null;
} }

} }





+ 18
- 1
Solver/Product/ProductFamilySolver.php View File

use Lc\CaracoleBundle\Doctrine\Extension\ProductPropertyInterface; use Lc\CaracoleBundle\Doctrine\Extension\ProductPropertyInterface;
use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface; use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface;
use Lc\CaracoleBundle\Model\Product\ProductFamilyModel; use Lc\CaracoleBundle\Model\Product\ProductFamilyModel;
use Lc\CaracoleBundle\Model\Product\ProductFamilySectionPropertyInterface;
use Lc\CaracoleBundle\Model\Product\ProductInterface; use Lc\CaracoleBundle\Model\Product\ProductInterface;
use Lc\CaracoleBundle\Model\Reduction\ReductionCatalogInterface; use Lc\CaracoleBundle\Model\Reduction\ReductionCatalogInterface;
use Lc\CaracoleBundle\Model\Section\SectionInterface; use Lc\CaracoleBundle\Model\Section\SectionInterface;
{ {


protected ProductSolver $productSolver; protected ProductSolver $productSolver;
protected ProductFamilySectionPropertySolver $productFamilySectionPropertySolver;
protected ProductCategorySolver $productCategorySolver;


public function __construct(ProductSolver $productSolver)
public function __construct(ProductSolver $productSolver, ProductFamilySectionPropertySolver $productFamilySectionPropertySolver, ProductCategorySolver $productCategorySolver)
{ {
$this->productSolver = $productSolver; $this->productSolver = $productSolver;
$this->productFamilySectionPropertySolver = $productFamilySectionPropertySolver;
$this->productCategorySolver = $productCategorySolver;
} }






return false; return false;
} }


public function isCategoriesOnlineInSection(ProductFamilyInterface $productFamily, SectionInterface $section):bool
{
$isCategoriesOnlineInSection =false;
foreach ($productFamily->getProductCategories() as $productCatgory){
if($productCatgory->getSection() === $section && $this->productCategorySolver->isOnline($productCatgory)){
$isCategoriesOnlineInSection = true;
}
}
return $isCategoriesOnlineInSection;
}
} }



+ 5
- 1
Twig/StoreTwigExtension.php View File

return $this->sectionResolver->isOutOfSection(); return $this->sectionResolver->isOutOfSection();
} }


private $sections = null;
public function getSections() public function getSections()
{ {
return $this->sectionStore
if(!$this->sections){
$this->sections = $this->sectionStore
->setMerchant($this->merchantResolver->getCurrent()) ->setMerchant($this->merchantResolver->getCurrent())
->getOnline(); ->getOnline();
}
return $this->sections;
} }


public function getMerchants() public function getMerchants()

Loading…
Cancel
Save