@@ -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) |
@@ -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), |
@@ -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' | |||
) | |||
), | |||
]); | |||
} | |||
} |
@@ -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 ' | |||
) | |||
) | |||
); |
@@ -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; | |||
} | |||
@@ -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 = [ |