public function setOnlineIfOnlineProductfamily(ProductCategoryInterface $productCategory) | public function setOnlineIfOnlineProductfamily(ProductCategoryInterface $productCategory) | ||||
{ | { | ||||
if ($this->productCategorySolver->hasOnlineProductFamily($productCategory)) { | if ($this->productCategorySolver->hasOnlineProductFamily($productCategory)) { | ||||
$productCategory->setStatus(1); | |||||
$this->entityManager->update($productCategory); | |||||
if(!$productCategory->getStatus()) { | |||||
$productCategory->setStatus(1); | |||||
$this->entityManager->update($productCategory); | |||||
$this->flashBagTranslator->add('success', 'setOnline','ProductCategory', array('%category%'=> $productCategory, '%section%'=> $productCategory->getSection())); | |||||
$this->flashBagTranslator->add('success', 'setOnline', 'ProductCategory', array('%category%' => $productCategory, '%section%' => $productCategory->getSection())); | |||||
} | |||||
// mise à jour du statut du parent | // mise à jour du statut du parent | ||||
$productCategoryParent = $productCategory->getParent(); | $productCategoryParent = $productCategory->getParent(); | ||||
if ($productCategoryParent) { | if ($productCategoryParent) { | ||||
$productCategoryParent->setStatus(1); | |||||
$this->entityManager->update($productCategoryParent); | |||||
if(!$productCategory->getStatus()) { | |||||
$productCategoryParent->setStatus(1); | |||||
$this->entityManager->update($productCategoryParent); | |||||
} | |||||
} | } | ||||
} | } | ||||
} | } | ||||
public function setOfflineIfOfflineProductfamily(ProductCategoryInterface $productCategory) | public function setOfflineIfOfflineProductfamily(ProductCategoryInterface $productCategory) | ||||
{ | { | ||||
if (!$this->productCategorySolver->hasOnlineProductFamily($productCategory)) { | if (!$this->productCategorySolver->hasOnlineProductFamily($productCategory)) { | ||||
$productCategory->setStatus(0); | |||||
$this->entityManager->update($productCategory); | |||||
$this->flashBagTranslator->add('info', 'setOffline','ProductCategory', array('%category%'=> $productCategory, '%section%'=> $productCategory->getSection())); | |||||
if($productCategory->getStatus()) { | |||||
$productCategory->setStatus(0); | |||||
$this->entityManager->update($productCategory); | |||||
$this->flashBagTranslator->add('info', 'setOffline', 'ProductCategory', array('%category%' => $productCategory, '%section%' => $productCategory->getSection())); | |||||
} | |||||
// mise à jour du statut du parent | // mise à jour du statut du parent | ||||
$productCategoryParent = $productCategory->getParent(); | $productCategoryParent = $productCategory->getParent(); | ||||
if ($productCategoryParent && !$this->productCategorySolver->hasOnlineProductFamily($productCategoryParent)) { | if ($productCategoryParent && !$this->productCategorySolver->hasOnlineProductFamily($productCategoryParent)) { | ||||
$productCategoryParent->setStatus(0); | |||||
$this->entityManager->update($productCategoryParent); | |||||
if($productCategory->getStatus()) { | |||||
$productCategoryParent->setStatus(0); | |||||
$this->entityManager->update($productCategoryParent); | |||||
} | |||||
} | } | ||||
} | } | ||||
} | } |
use Lc\CaracoleBundle\Container\Order\OrderShopContainer; | use Lc\CaracoleBundle\Container\Order\OrderShopContainer; | ||||
use Lc\CaracoleBundle\Container\Product\ProductFamilyContainer; | use Lc\CaracoleBundle\Container\Product\ProductFamilyContainer; | ||||
use Lc\CaracoleBundle\Controller\AbstractAdminController; | use Lc\CaracoleBundle\Controller\AbstractAdminController; | ||||
use Lc\CaracoleBundle\Definition\ActionDefinition; | |||||
use Lc\CaracoleBundle\Resolver\SectionResolver; | use Lc\CaracoleBundle\Resolver\SectionResolver; | ||||
use Lc\SovBundle\Repository\RepositoryQueryInterface; | use Lc\SovBundle\Repository\RepositoryQueryInterface; | ||||
use Symfony\Component\HttpFoundation\Response; | use Symfony\Component\HttpFoundation\Response; | ||||
{ | { | ||||
$crud = parent::configureCrud($crud); | $crud = parent::configureCrud($crud); | ||||
$crud->setDefaultSort(['id' => 'DESC']); | |||||
if($this->getRequestCrudAction() === ActionDefinition::SORT) { | |||||
$crud->setDefaultSort(['position' => 'ASC']); | |||||
}else{ | |||||
$crud->setDefaultSort(['id' => 'DESC']); | |||||
} | |||||
return $crud; | return $crud; | ||||
} | } |
public function setUserRolesFromKernelRequest(RequestEvent $event) | public function setUserRolesFromKernelRequest(RequestEvent $event) | ||||
{ | { | ||||
if (!$event->isMasterRequest()) { | |||||
if (!$event->isMainRequest()) { | |||||
return; | return; | ||||
} | } | ||||
if ($this->setUserRoles($event->getRequest())) { | if ($this->setUserRoles($event->getRequest())) { |
$this->productSolver = $productSolver; | $this->productSolver = $productSolver; | ||||
} | } | ||||
public function getTypeDeliveryChoices() | |||||
public static function getTypeDeliveryChoices() | |||||
{ | { | ||||
return [ | return [ | ||||
OrderShopModel::DELIVERY_TYPE_HOME, | OrderShopModel::DELIVERY_TYPE_HOME, |
} | } | ||||
public function getBehaviorCountStockChoices(): array | |||||
public static function getBehaviorCountStockChoices(): array | |||||
{ | { | ||||
return [ | return [ | ||||
ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_MEASURE, | ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_MEASURE, | ||||
]; | ]; | ||||
} | } | ||||
public function getWaringMessageTypeChoices(): array | |||||
public static function getWaringMessageTypeChoices(): array | |||||
{ | { | ||||
return [ | return [ | ||||
ProductFamilyModel::WARNING_MESSAGE_TYPE_ERROR, | ProductFamilyModel::WARNING_MESSAGE_TYPE_ERROR, | ||||
]; | ]; | ||||
} | } | ||||
public function getBehaviorAddToCartChoices(): array | |||||
public static function getBehaviorAddToCartChoices(): array | |||||
{ | { | ||||
return [ | return [ | ||||
ProductFamilyModel::BEHAVIOR_ADD_TO_CART_MULTIPLE, | ProductFamilyModel::BEHAVIOR_ADD_TO_CART_MULTIPLE, | ||||
]; | ]; | ||||
} | } | ||||
public function getBehaviorPriceChoices(): array | |||||
public static function getBehaviorPriceChoices(): array | |||||
{ | { | ||||
return [ | return [ | ||||
ProductFamilyModel::BEHAVIOR_PRICE_BY_PIECE, | ProductFamilyModel::BEHAVIOR_PRICE_BY_PIECE, | ||||
]; | ]; | ||||
} | } | ||||
public function getTypeExpirationDateChoices(): array | |||||
public static function getTypeExpirationDateChoices(): array | |||||
{ | { | ||||
return [ | return [ | ||||
ProductFamilyModel::TYPE_EXPIRATION_DATE_DLC, | ProductFamilyModel::TYPE_EXPIRATION_DATE_DLC, | ||||
} | } | ||||
public function getBehaviorExpirationDateChoices(): array | |||||
public static function getBehaviorExpirationDateChoices(): array | |||||
{ | { | ||||
return [ | return [ | ||||
ProductFamilyModel::BEHAVIOR_EXPIRATION_DATE_BY_PRODUCT_FAMILY, | ProductFamilyModel::BEHAVIOR_EXPIRATION_DATE_BY_PRODUCT_FAMILY, | ||||
} | } | ||||
public function getBehaviorDisplaySaleChoices(): array | |||||
public static function getBehaviorDisplaySaleChoices(): array | |||||
{ | { | ||||
return [ | return [ | ||||
ProductFamilyModel::BEHAVIOR_DISPLAY_SALE_BY_MEASURE, | ProductFamilyModel::BEHAVIOR_DISPLAY_SALE_BY_MEASURE, |
} | } | ||||
public function getAppliedToChoices() | |||||
public static function getAppliedToChoices() | |||||
{ | { | ||||
return [ | return [ | ||||
// ReductionCartModel::APPLIED_TO_DELIVERY, | // ReductionCartModel::APPLIED_TO_DELIVERY, |
const INTERVAL_WEEK = 'W'; | const INTERVAL_WEEK = 'W'; | ||||
const INTERVAL_MONTH = 'M'; | const INTERVAL_MONTH = 'M'; | ||||
public function getIntervalChoices() | |||||
public static function getIntervalChoices() | |||||
{ | { | ||||
return [ | return [ | ||||
self::INTERVAL_DAY, | self::INTERVAL_DAY, |