Browse Source

Finalisation tableau de bord + ticket

packProduct
Fab 3 years ago
parent
commit
d1252e37e6
6 changed files with 119 additions and 18 deletions
  1. +18
    -2
      Controller/User/UserAdminController.php
  2. +2
    -2
      Definition/Field/PointSale/PointSaleFieldDefinition.php
  3. +29
    -0
      Definition/Field/Ticket/TicketFieldDefinition.php
  4. +39
    -10
      Repository/Product/ProductRepositoryQuery.php
  5. +30
    -3
      Repository/Product/ProductStore.php
  6. +1
    -1
      Solver/Ticket/TicketSolver.php

+ 18
- 2
Controller/User/UserAdminController.php View File

@@ -3,13 +3,15 @@
namespace Lc\CaracoleBundle\Controller\User;


use EasyCorp\Bundle\EasyAdminBundle\Collection\EntityCollection;
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
use Lc\CaracoleBundle\Controller\ControllerTrait;
use Lc\SovBundle\Container\User\UserContainer;
use Lc\CaracoleBundle\Controller\AbstractAdminController;
use Lc\SovBundle\Controller\User\UserAdminController as SovUserAdminController;
use Lc\SovBundle\Definition\ActionDefinition;
use Lc\SovBundle\Repository\RepositoryQueryInterface;

abstract class UserAdminController extends AbstractAdminController
abstract class UserAdminController extends SovUserAdminController
{
use ControllerTrait;

@@ -23,6 +25,20 @@ abstract class UserAdminController extends AbstractAdminController
return $this->getUserContainer()->getFactory()->create();
}

public function overrideEntitiesActions(?EntityCollection $entities): void
{
foreach ($entities as $entity) {
foreach ($entity->getActions() as $action){
if($action->getName() == ActionDefinition::SWITCH_USER){
$sectionDefault = $this->getSectionContainer()->getStore()->setMerchant($this->getMerchantCurrent())->getOneDefault();
$url = $this->generateUrl($this->getParameter('lc_sov.homepage_route'), array('_switch_user' => $entity->getInstance()->getEmail(), 'section'=> $sectionDefault));
$action->setLinkUrl($url);
}
}

}
}

public function configureFields(string $pageName): iterable
{
$fields = $this->get(UserContainer::class)

+ 2
- 2
Definition/Field/PointSale/PointSaleFieldDefinition.php View File

@@ -3,10 +3,10 @@
namespace Lc\CaracoleBundle\Definition\Field\PointSale;

use EasyCorp\Bundle\EasyAdminBundle\Field\IntegerField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextEditorField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use Lc\CaracoleBundle\Field\Address\AddressField;
use Lc\SovBundle\Definition\Field\AbstractFieldDefinition;
use Lc\SovBundle\Field\CKEditorField;
use Lc\SovBundle\Field\StatusField;

class PointSaleFieldDefinition extends AbstractFieldDefinition
@@ -52,7 +52,7 @@ class PointSaleFieldDefinition extends AbstractFieldDefinition
return [
'id' => IntegerField::new('id')->setSortable(true)->onlyOnIndex(),
'title' => TextField::new('title')->setSortable(true),
'description' => TextEditorField::new('description'),
'description' => CKEditorField::new('description'),
'status' => StatusField::new('status')->setSortable(true),
'address' => AddressField::new('address')
->setRequired(true),

+ 29
- 0
Definition/Field/Ticket/TicketFieldDefinition.php View File

@@ -0,0 +1,29 @@
<?php

namespace Lc\CaracoleBundle\Definition\Field\Ticket;


use EasyCorp\Bundle\EasyAdminBundle\Field\ChoiceField;
use Lc\CaracoleBundle\Solver\Ticket\TicketSolver;
use Lc\SovBundle\Definition\Field\Ticket\TicketFieldDefinition as SovTicketFieldDefinition;

class TicketFieldDefinition extends SovTicketFieldDefinition
{

public function configureFields(): array
{
return array_merge(parent::configureFields(),[
'type' => ChoiceField::new('type')
->autocomplete()
->setChoices(
$this->translatorAdmin->transChoices(
TicketSolver::getTypeChoices(),
'Ticket',
'type'
)
),
]);

}

}

+ 39
- 10
Repository/Product/ProductRepositoryQuery.php View File

@@ -67,20 +67,49 @@ class ProductRepositoryQuery extends AbstractRepositoryQuery
return $this;
}

public function filterBehaviorCountStock() :self

public function filterAvailableQuantityNegative() :self
{

$this->andWhere(
$this->query->expr()->orX(
$this->query->expr()->andX(
$this->query->expr()->orX(
'pf.behaviorCountStock LIKE :behaviorCountStockByProductFamily',
'pf.behaviorCountStock LIKE :behaviorCountStockByMeasure'
),
'pf.availableQuantity < 0 '
),
$this->query->expr()->andX(
'pf.behaviorCountStock LIKE :behaviorCountStockByProduct',
'r.availableQuantity < 0 '
)
)
);
$this->setParameter(
'behaviorCountStockByProductFamily',
ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_PRODUCT_FAMILY
);
$this->setParameter('behaviorCountStockByMeasure', ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_MEASURE);
$this->setParameter('behaviorCountStockByProduct', ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_PRODUCT);
return $this;
}

public function filterAvailableQuantitySupplierNegative() :self
{

$this->andWhere(
$this->expr()->orX(
$this->expr()->andX(
$this->expr()->orX(
'productFamily.behaviorCountStock LIKE :behaviorCountStockByProductFamily',
'productFamily.behaviorCountStock LIKE :behaviorCountStockByMeasure'
$this->query->expr()->orX(
$this->query->expr()->andX(
$this->query->expr()->orX(
'pf.behaviorCountStock LIKE :behaviorCountStockByProductFamily',
'pf.behaviorCountStock LIKE :behaviorCountStockByMeasure'
),
'productFamily.availableQuantity < 0 '
'pf.availableQuantitySupplier < 0 '
),
$this->expr()->andX(
'productFamily.behaviorCountStock LIKE :behaviorCountStockByProduct',
'e.availableQuantity < 0 '
$this->query->expr()->andX(
'pf.behaviorCountStock LIKE :behaviorCountStockByProduct',
'r.availableQuantitySupplier < 0 '
)
)
);

+ 30
- 3
Repository/Product/ProductStore.php View File

@@ -2,6 +2,7 @@

namespace Lc\CaracoleBundle\Repository\Product;

use App\Solver\Product\ProductFamilySectionPropertySolver;
use Lc\CaracoleBundle\Repository\SectionStoreTrait;
use Lc\CaracoleBundle\Repository\AbstractStore;
use Lc\SovBundle\Repository\RepositoryQueryInterface;
@@ -11,10 +12,12 @@ class ProductStore extends AbstractStore
use SectionStoreTrait;

protected ProductRepositoryQuery $query;
protected ProductFamilySectionPropertySolver $productFamilySectionPropertySolver;

public function __construct(ProductRepositoryQuery $query)
public function __construct(ProductRepositoryQuery $query, ProductFamilySectionPropertySolver $productFamilySectionPropertySolver)
{
$this->query = $query;
$this->productFamilySectionPropertySolver = $productFamilySectionPropertySolver;
}

public function orderByDefault(RepositoryQueryInterface $query) :RepositoryQueryInterface
@@ -41,9 +44,33 @@ class ProductStore extends AbstractStore
$query = $this->createQuery($query);
$query->joinProductFamily();
$query->filterIsOnline();
$query->filterBehaviorCountStock();
$query->filterAvailableQuantityNegative();
$query->groupBy('pf.id');
return $query->find();
$productListAvailableQuantityNegative = $query->find();

foreach ($productListAvailableQuantityNegative as $i=>$product) {
if(!$this->productFamilySectionPropertySolver->useBehaviorStockAvailableQuantity($product->getProductfamily())){
unset($productListAvailableQuantityNegative[$i]);
}
}
return $productListAvailableQuantityNegative;
}

public function getByAvailabilitiesSupplierNegative(ProductRepositoryQuery $query = null): array
{
$query = $this->createQuery($query);
$query->joinProductFamily();
$query->filterIsOnline();
$query->filterAvailableQuantitySupplierNegative();
$query->groupBy('pf.id');
$productListAvailableQuantityNegative = $query->find();

foreach ($productListAvailableQuantityNegative as $i=>$product) {
if(!$this->productFamilySectionPropertySolver->useBehaviorStockAvailableQuantitySupplier($product->getProductfamily())){
unset($productListAvailableQuantityNegative[$i]);
}
}
return $productListAvailableQuantityNegative;
}



+ 1
- 1
Solver/Ticket/TicketSolver.php View File

@@ -7,7 +7,7 @@ use Lc\SovBundle\Solver\Ticket\TicketSolver as SovTicketSolver;

class TicketSolver extends SovTicketSolver
{
public function getTypeChoices(): array
public static function getTypeChoices(): array
{
$choices = parent::getTypeChoices();
$choicesProduct = [

Loading…
Cancel
Save