namespace Lc\CaracoleBundle\Controller\User; | namespace Lc\CaracoleBundle\Controller\User; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Collection\EntityCollection; | |||||
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud; | use EasyCorp\Bundle\EasyAdminBundle\Config\Crud; | ||||
use Lc\CaracoleBundle\Controller\ControllerTrait; | use Lc\CaracoleBundle\Controller\ControllerTrait; | ||||
use Lc\SovBundle\Container\User\UserContainer; | 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; | use Lc\SovBundle\Repository\RepositoryQueryInterface; | ||||
abstract class UserAdminController extends AbstractAdminController | |||||
abstract class UserAdminController extends SovUserAdminController | |||||
{ | { | ||||
use ControllerTrait; | use ControllerTrait; | ||||
return $this->getUserContainer()->getFactory()->create(); | 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 | public function configureFields(string $pageName): iterable | ||||
{ | { | ||||
$fields = $this->get(UserContainer::class) | $fields = $this->get(UserContainer::class) |
namespace Lc\CaracoleBundle\Definition\Field\PointSale; | namespace Lc\CaracoleBundle\Definition\Field\PointSale; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Field\IntegerField; | use EasyCorp\Bundle\EasyAdminBundle\Field\IntegerField; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextEditorField; | |||||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; | use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; | ||||
use Lc\CaracoleBundle\Field\Address\AddressField; | use Lc\CaracoleBundle\Field\Address\AddressField; | ||||
use Lc\SovBundle\Definition\Field\AbstractFieldDefinition; | use Lc\SovBundle\Definition\Field\AbstractFieldDefinition; | ||||
use Lc\SovBundle\Field\CKEditorField; | |||||
use Lc\SovBundle\Field\StatusField; | use Lc\SovBundle\Field\StatusField; | ||||
class PointSaleFieldDefinition extends AbstractFieldDefinition | class PointSaleFieldDefinition extends AbstractFieldDefinition | ||||
return [ | return [ | ||||
'id' => IntegerField::new('id')->setSortable(true)->onlyOnIndex(), | 'id' => IntegerField::new('id')->setSortable(true)->onlyOnIndex(), | ||||
'title' => TextField::new('title')->setSortable(true), | 'title' => TextField::new('title')->setSortable(true), | ||||
'description' => TextEditorField::new('description'), | |||||
'description' => CKEditorField::new('description'), | |||||
'status' => StatusField::new('status')->setSortable(true), | 'status' => StatusField::new('status')->setSortable(true), | ||||
'address' => AddressField::new('address') | 'address' => AddressField::new('address') | ||||
->setRequired(true), | ->setRequired(true), |
<?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' | |||||
) | |||||
), | |||||
]); | |||||
} | |||||
} |
return $this; | 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->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 ' | |||||
) | ) | ||||
) | ) | ||||
); | ); |
namespace Lc\CaracoleBundle\Repository\Product; | namespace Lc\CaracoleBundle\Repository\Product; | ||||
use App\Solver\Product\ProductFamilySectionPropertySolver; | |||||
use Lc\CaracoleBundle\Repository\SectionStoreTrait; | use Lc\CaracoleBundle\Repository\SectionStoreTrait; | ||||
use Lc\CaracoleBundle\Repository\AbstractStore; | use Lc\CaracoleBundle\Repository\AbstractStore; | ||||
use Lc\SovBundle\Repository\RepositoryQueryInterface; | use Lc\SovBundle\Repository\RepositoryQueryInterface; | ||||
use SectionStoreTrait; | use SectionStoreTrait; | ||||
protected ProductRepositoryQuery $query; | protected ProductRepositoryQuery $query; | ||||
protected ProductFamilySectionPropertySolver $productFamilySectionPropertySolver; | |||||
public function __construct(ProductRepositoryQuery $query) | |||||
public function __construct(ProductRepositoryQuery $query, ProductFamilySectionPropertySolver $productFamilySectionPropertySolver) | |||||
{ | { | ||||
$this->query = $query; | $this->query = $query; | ||||
$this->productFamilySectionPropertySolver = $productFamilySectionPropertySolver; | |||||
} | } | ||||
public function orderByDefault(RepositoryQueryInterface $query) :RepositoryQueryInterface | public function orderByDefault(RepositoryQueryInterface $query) :RepositoryQueryInterface | ||||
$query = $this->createQuery($query); | $query = $this->createQuery($query); | ||||
$query->joinProductFamily(); | $query->joinProductFamily(); | ||||
$query->filterIsOnline(); | $query->filterIsOnline(); | ||||
$query->filterBehaviorCountStock(); | |||||
$query->filterAvailableQuantityNegative(); | |||||
$query->groupBy('pf.id'); | $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; | |||||
} | } | ||||
class TicketSolver extends SovTicketSolver | class TicketSolver extends SovTicketSolver | ||||
{ | { | ||||
public function getTypeChoices(): array | |||||
public static function getTypeChoices(): array | |||||
{ | { | ||||
$choices = parent::getTypeChoices(); | $choices = parent::getTypeChoices(); | ||||
$choicesProduct = [ | $choicesProduct = [ |