@@ -0,0 +1,8 @@ | |||
<?php | |||
namespace Lc\ShopBundle\Context; | |||
interface OrderReductionCartInterface | |||
{ | |||
} |
@@ -0,0 +1,8 @@ | |||
<?php | |||
namespace Lc\ShopBundle\Context; | |||
interface OrderReductionCreditInterface | |||
{ | |||
} |
@@ -2,7 +2,7 @@ | |||
namespace Lc\ShopBundle\Context; | |||
interface CartInterface | |||
interface OrderStatusInterface | |||
{ | |||
} |
@@ -2,6 +2,10 @@ | |||
namespace Lc\ShopBundle\Context; | |||
use Doctrine\Common\Collections\Collection; | |||
use Lc\ShopBundle\Model\PointSale; | |||
interface ReductionCartInterface | |||
{ | |||
} |
@@ -0,0 +1,7 @@ | |||
<?php | |||
namespace Lc\ShopBundle\Context; | |||
interface ReductionCartPropertyInterface | |||
{ | |||
} |
@@ -2,7 +2,6 @@ | |||
namespace Lc\ShopBundle\Context; | |||
interface CartProductInterface | |||
interface ReductionCreditInterface | |||
{ | |||
} |
@@ -0,0 +1,8 @@ | |||
<?php | |||
namespace Lc\ShopBundle\Context; | |||
interface ReductionPropertyInterface | |||
{ | |||
} |
@@ -22,6 +22,7 @@ use Symfony\Component\Form\Extension\Core\Type\CollectionType; | |||
use Symfony\Component\Form\FormEvent; | |||
use Symfony\Component\Form\FormEvents; | |||
use Symfony\Component\Security\Core\Security; | |||
use Symfony\Contracts\Translation\TranslatorInterface; | |||
class AdminController extends EasyAdminController | |||
{ | |||
@@ -32,9 +33,10 @@ class AdminController extends EasyAdminController | |||
protected $merchantUtils ; | |||
protected $mailjetTransport ; | |||
protected $orderUtils ; | |||
protected $translator; | |||
public function __construct(Security $security, UserManagerInterface $userManager, EntityManagerInterface $em, Utils $utils, | |||
MerchantUtilsInterface $merchantUtils, MailjetTransport $mailjetTransport, OrderUtilsInterface $orderUtils) | |||
MerchantUtilsInterface $merchantUtils, MailjetTransport $mailjetTransport, OrderUtilsInterface $orderUtils, TranslatorInterface $translator) | |||
{ | |||
$this->security = $security; | |||
$this->userManager = $userManager; | |||
@@ -43,6 +45,7 @@ class AdminController extends EasyAdminController | |||
$this->merchantUtils = $merchantUtils ; | |||
$this->mailjetTransport = $mailjetTransport ; | |||
$this->orderUtils = $orderUtils ; | |||
$this->translator = $translator; | |||
} | |||
/** | |||
@@ -317,7 +320,6 @@ class AdminController extends EasyAdminController | |||
if($isFilterMultipleMerchantsInterface) { | |||
$propertyMerchant .= 's' ; | |||
} | |||
$form->add($child->getName(), EntityType::class, array( | |||
'class' => $this->em->getClassMetadata($passedOptions['class'])->getName(), | |||
'label' => $passedOptions['label'], | |||
@@ -352,6 +354,7 @@ class AdminController extends EasyAdminController | |||
}, | |||
'required' => $passedOptions['required'], | |||
'choice_attr' => $passedOptions['choice_attr'], | |||
) | |||
); | |||
} |
@@ -2,17 +2,16 @@ | |||
namespace Lc\ShopBundle\Controller\Backend; | |||
use Doctrine\ORM\EntityRepository; | |||
use EasyCorp\Bundle\EasyAdminBundle\Event\EasyAdminEvents; | |||
use Lc\ShopBundle\Context\AddressInterface; | |||
use Lc\ShopBundle\Context\OrderProductInterface; | |||
use Lc\ShopBundle\Context\UserInterface; | |||
use Lc\ShopBundle\Form\Order\AddPoductToOrderType; | |||
use Lc\ShopBundle\Form\Order\OrderAddressType; | |||
use Lc\ShopBundle\Form\Order\OrderDeliveryAddressType; | |||
use Lc\ShopBundle\Form\Order\OrderInvoiceAddressType; | |||
use Lc\ShopBundle\Form\Order\OrderProductsType; | |||
use Lc\ShopBundle\Form\OrderProductType; | |||
use Lc\ShopBundle\Form\Backend\Order\AddPoductToOrderType; | |||
use Lc\ShopBundle\Form\Backend\Order\OrderDeliveryAddressType; | |||
use Lc\ShopBundle\Form\Backend\Order\OrderInvoiceAddressType; | |||
use Lc\ShopBundle\Form\Backend\Order\OrderProductsType; | |||
use Lc\ShopBundle\Form\Backend\Order\OrderReductionCartType; | |||
use Lc\ShopBundle\Form\Backend\Order\OrderReductionCreditType; | |||
use Lc\ShopBundle\Form\Backend\Order\OrderStatusType; | |||
use Symfony\Bridge\Doctrine\Form\Type\EntityType; | |||
use Symfony\Component\Form\Extension\Core\Type\SubmitType; | |||
use Symfony\Component\HttpFoundation\Response; | |||
@@ -20,13 +19,7 @@ use Symfony\Component\HttpFoundation\Response; | |||
class OrderController extends AdminController | |||
{ | |||
/*protected $orderUtils; | |||
public function __construct(Security $security, UserManagerInterface $userManager, EntityManagerInterface $em, Utils $utils, MerchantUtilsInterface $merchantUtils, MailjetTransport $mailjetTransport, OrderUtilsInterface $orderUtils) | |||
{ | |||
$this->orderUtils = $orderUtils; | |||
parent::__construct($security, $userManager, $em, $utils, $merchantUtils, $mailjetTransport); | |||
}*/ | |||
public function updateEntity($entity) | |||
{ | |||
@@ -162,6 +155,36 @@ class OrderController extends AdminController | |||
return new Response(json_encode($response)); | |||
} | |||
public function orderStatusAction() | |||
{ | |||
$id = $this->request->query->get('id'); | |||
$easyadmin = $this->request->attributes->get('easyadmin'); | |||
$orderShop = $easyadmin['item']; | |||
$formOrderStatus = $this->createForm(OrderStatusType::class, $orderShop); | |||
$formOrderStatus->handleRequest($this->request); | |||
if ($formOrderStatus->isSubmitted() && $formOrderStatus->isValid()) { | |||
if($orderShop = $this->orderUtils->setOrderStatus($formOrderStatus->get('orderStatus')->getData(), $orderShop)){ | |||
$this->persistEntity($orderShop); | |||
$this->em->flush(); | |||
$this->addFlash('success', 'La commande a bien été modifié.'); | |||
} | |||
}else{ | |||
$this->addFlash('error', 'Une erreur s\'est produite'); | |||
} | |||
return $this->redirectToRoute('easyadmin', [ | |||
'action' => 'show', | |||
'entity' => $this->request->query->get('entity'), | |||
'id' => $id | |||
]); | |||
} | |||
public function orderProductsAction() | |||
{ | |||
@@ -199,6 +222,50 @@ class OrderController extends AdminController | |||
} | |||
public function orderReductionCartAction() | |||
{ | |||
$id = $this->request->query->get('id'); | |||
$easyadmin = $this->request->attributes->get('easyadmin'); | |||
$orderShop = $easyadmin['item']; | |||
$formOrderReductionCart = $this->createForm(OrderReductionCartType::class, $orderShop); | |||
$formOrderReductionCart->handleRequest($this->request); | |||
if ($formOrderReductionCart->isSubmitted() && $formOrderReductionCart->isValid()) { | |||
$reductionCart = $formOrderReductionCart->get('reductionCart')->getData(); | |||
$orderShop->reductionError = array(); | |||
if($this->orderUtils->isReductionCartAllowToBeAddToOrder($orderShop, $reductionCart)){ | |||
$orderReductionCart = $this->orderUtils->createOrderReductionCart($orderShop, $reductionCart); | |||
$this->em->persist($orderReductionCart); | |||
$this->em->flush(); | |||
$response['status'] = 'success'; | |||
$response['message'] = 'La réduction a bien été ajouté'; | |||
}else{ | |||
$response['status'] = 'error'; | |||
$response['message'] = 'Cette réduction ne peut pas être appliqué sur cette commande'; | |||
$response['message'] .= '<ul>'; | |||
foreach ($orderShop->reductionError as $error) { | |||
$response['message'] .= '<li> <i>'.$this->translator->trans($error, array(), 'lcshop'). '</i></li>'; | |||
} | |||
$response['message'] .= '</ul>'; | |||
} | |||
} else { | |||
$response['status'] = 'error'; | |||
$response['message'] = 'Une erreur est survenue'; | |||
} | |||
$response['data'] = $this->orderUtils->getOrderAsJsonObject($orderShop);; | |||
return new Response(json_encode($response)); | |||
} | |||
public function renderOrderShopTemplate($actionName, $templatePath, array $parameters = []) | |||
{ | |||
if ($actionName == 'show') { | |||
@@ -225,6 +292,33 @@ class OrderController extends AdminController | |||
'id' => $parameters['entity']->getId() | |||
]) | |||
)); | |||
$formOrderStatus = $this->createForm(OrderStatusType::class, null, array( | |||
'data' => $parameters['entity'], | |||
'action' => $this->generateUrl('easyadmin', [ | |||
'action' => 'orderStatus', | |||
'entity' => $this->entity['name'], | |||
'id' => $parameters['entity']->getId() | |||
]) | |||
)); | |||
$formOrderReductionCart = $this->createForm(OrderReductionCartType::class, null, array( | |||
'data' => $parameters['entity'], | |||
'action' => $this->generateUrl('easyadmin', [ | |||
'action' => 'orderReductionCart', | |||
'entity' => $this->entity['name'], | |||
'id' => $parameters['entity']->getId() | |||
]) | |||
)); | |||
$formOrderReductionCredit = $this->createForm(OrderReductionCreditType::class, null, array( | |||
'data' => $parameters['entity'], | |||
'action' => $this->generateUrl('easyadmin', [ | |||
'action' => 'orderReductionCredit', | |||
'entity' => $this->entity['name'], | |||
'id' => $parameters['entity']->getId() | |||
]) | |||
)); | |||
if(!isset($parameters['form_order_delivery_address'])) { | |||
$formOrderDeliveryAddress = $this->createForm(OrderDeliveryAddressType::class, null, array( | |||
'data' => $parameters['entity'], | |||
@@ -236,9 +330,12 @@ class OrderController extends AdminController | |||
)); | |||
$parameters['form_order_delivery_address'] = $formOrderDeliveryAddress->createView(); | |||
} | |||
$parameters['form_order_reduction_credit'] = $formOrderReductionCredit->createView(); | |||
$parameters['form_order_reduction_cart'] = $formOrderReductionCart->createView(); | |||
$parameters['form_add_product_to_order'] = $formAddProductToOrder->createView(); | |||
$parameters['form_order_products'] = $formOrderProducts->createView(); | |||
$parameters['form_order_invoice_address'] = $formOrderInvoiceAddress->createView(); | |||
$parameters['form_order_status'] = $formOrderStatus->createView(); | |||
} | |||
return parent::renderTemplate($actionName, $templatePath, $parameters); | |||
} |
@@ -3,26 +3,15 @@ | |||
namespace Lc\ShopBundle\Controller\Backend; | |||
use App\Entity\Product; | |||
use App\Entity\ReductionCatalog; | |||
use Doctrine\DBAL\Types\FloatType; | |||
use Doctrine\ORM\EntityRepository; | |||
use EasyCorp\Bundle\EasyAdminBundle\Event\EasyAdminEvents; | |||
use Lc\ShopBundle\Context\ProductCategoryInterface; | |||
use Lc\ShopBundle\Context\ProductFamilyInterface; | |||
use Lc\ShopBundle\Context\ProductInterface; | |||
use Lc\ShopBundle\Context\ReductionCartInterface; | |||
use Lc\ShopBundle\Context\ReductionCatalogInterface; | |||
use Lc\ShopBundle\Context\TaxRateInterface; | |||
use Lc\ShopBundle\Context\UnitInterface; | |||
use Lc\ShopBundle\Form\ProductFamilyCategoriesType; | |||
use Lc\ShopBundle\Form\ProductType; | |||
use Lc\ShopBundle\Form\ReductionCatalogType; | |||
use Symfony\Bridge\Doctrine\Form\Type\EntityType; | |||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType; | |||
use Lc\ShopBundle\Form\Backend\Common\ReductionCatalogType; | |||
use Lc\ShopBundle\Form\Backend\ProductFamily\ProductType; | |||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType; | |||
use Symfony\Component\Form\Extension\Core\Type\CollectionType; | |||
use Symfony\Component\Form\Extension\Core\Type\DateType; | |||
use Symfony\Component\Form\Extension\Core\Type\MoneyType; | |||
use Symfony\Component\Form\Extension\Core\Type\NumberType; | |||
use Symfony\Component\HttpFoundation\Response; | |||
@@ -40,7 +29,7 @@ class ProductFamilyController extends AdminController | |||
$class = $this->em->getClassMetadata(ProductCategoryInterface::class); | |||
$this->taxRateClass = $this->em->getClassMetadata(TaxRateInterface::class); | |||
$formBuilder->add('productCategories', ProductFamilyCategoriesType::class); | |||
//$formBuilder->add('productCategories', ProductFamilyCategoriesType::class); | |||
$reductionCatalogRepo = $this->em->getRepository(ReductionCatalogInterface::class); |
@@ -1,6 +1,6 @@ | |||
<?php | |||
namespace Lc\ShopBundle\Form; | |||
namespace Lc\ShopBundle\Form\Backend\Common; | |||
use Symfony\Component\Form\AbstractType; | |||
use Symfony\Component\Form\Extension\Core\Type\HiddenType; |
@@ -1,6 +1,6 @@ | |||
<?php | |||
namespace Lc\ShopBundle\Form; | |||
namespace Lc\ShopBundle\Form\Backend\Common; | |||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType; | |||
use Symfony\Component\Form\Extension\Core\Type\TextareaType; |
@@ -0,0 +1,59 @@ | |||
<?php | |||
namespace Lc\ShopBundle\Form\Backend\Common; | |||
use Lc\ShopBundle\Context\GroupUserInterface; | |||
use Lc\ShopBundle\Form\Backend\ReductionCommon\BehaviorTaxRateType; | |||
use Lc\ShopBundle\Form\Backend\ReductionCommon\DateEndType; | |||
use Lc\ShopBundle\Form\Backend\ReductionCommon\DateStartType; | |||
use Lc\ShopBundle\Form\Backend\ReductionCommon\GroupUsersFilterType; | |||
use Lc\ShopBundle\Form\Backend\ReductionCommon\PermanentType; | |||
use Lc\ShopBundle\Form\Backend\ReductionCommon\UnitType; | |||
use Lc\ShopBundle\Form\Backend\ReductionCommon\UsersFilterType; | |||
use Lc\ShopBundle\Form\Backend\ReductionCommon\ValueType; | |||
use Symfony\Bridge\Doctrine\Form\Type\EntityType; | |||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType; | |||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType; | |||
use Symfony\Component\Form\Extension\Core\Type\DateTimeType; | |||
use Symfony\Component\Form\Extension\Core\Type\NumberType; | |||
use Symfony\Component\Form\Extension\Core\Type\TextType; | |||
use Doctrine\ORM\EntityManagerInterface; | |||
use Symfony\Component\Form\AbstractType; | |||
use Symfony\Component\Form\FormBuilderInterface; | |||
use Symfony\Component\OptionsResolver\OptionsResolver; | |||
class ReductionCatalogType extends AbstractType | |||
{ | |||
protected $em; | |||
public function __construct(EntityManagerInterface $entityManager) | |||
{ | |||
$this->em = $entityManager; | |||
} | |||
public function buildForm(FormBuilderInterface $builder, array $options) | |||
{ | |||
$builder | |||
->add('title', TextType::class, [ | |||
'label' => 'Titre', | |||
'required' => false, | |||
]) | |||
->add('behaviorTaxRate', BehaviorTaxRateType::class) | |||
->add('unit', UnitType::class) | |||
->add('value', ValueType::class) | |||
->add('permanent', PermanentType::class) | |||
->add('dateStart', DateStartType::class) | |||
->add('dateEnd', DateEndType::class) | |||
->add('users', UsersFilterType::class) | |||
->add('groupUsers', GroupUsersFilterType::class); | |||
} | |||
public function configureOptions(OptionsResolver $resolver) | |||
{ | |||
$resolver->setDefaults([ | |||
'label' => false, | |||
'translation_domain'=> 'lcshop' | |||
]); | |||
} | |||
} |
@@ -1,6 +1,6 @@ | |||
<?php | |||
namespace Lc\ShopBundle\Form; | |||
namespace Lc\ShopBundle\Form\Backend\Merchant; | |||
use CKSource\Bundle\CKFinderBundle\Form\Type\CKFinderFileChooserType; | |||
use Lc\ShopBundle\Context\MerchantConfigInterface; |
@@ -1,6 +1,6 @@ | |||
<?php | |||
namespace Lc\ShopBundle\Form\Order; | |||
namespace Lc\ShopBundle\Form\Backend\Order; | |||
use Doctrine\ORM\EntityManagerInterface; | |||
use Doctrine\ORM\EntityRepository; |
@@ -1,6 +1,6 @@ | |||
<?php | |||
namespace Lc\ShopBundle\Form\Order; | |||
namespace Lc\ShopBundle\Form\Backend\Order; | |||
use Doctrine\ORM\EntityManagerInterface; | |||
use Doctrine\ORM\EntityRepository; |
@@ -1,6 +1,6 @@ | |||
<?php | |||
namespace Lc\ShopBundle\Form\Order; | |||
namespace Lc\ShopBundle\Form\Backend\Order; | |||
use Doctrine\ORM\EntityManagerInterface; | |||
use Doctrine\ORM\EntityRepository; |
@@ -1,6 +1,6 @@ | |||
<?php | |||
namespace Lc\ShopBundle\Form\Order; | |||
namespace Lc\ShopBundle\Form\Backend\Order; | |||
use App\Entity\Product; | |||
use Doctrine\ORM\EntityManagerInterface; |
@@ -1,6 +1,6 @@ | |||
<?php | |||
namespace Lc\ShopBundle\Form\Order; | |||
namespace Lc\ShopBundle\Form\Backend\Order; | |||
use Doctrine\ORM\EntityManagerInterface; | |||
use Lc\ShopBundle\Context\MerchantUtilsInterface; |
@@ -0,0 +1,58 @@ | |||
<?php | |||
namespace Lc\ShopBundle\Form\Backend\Order; | |||
use App\Entity\Product; | |||
use Doctrine\ORM\EntityManagerInterface; | |||
use Lc\ShopBundle\Context\OrderProductInterface; | |||
use Lc\ShopBundle\Context\OrderReductionCartInterface; | |||
use Lc\ShopBundle\Context\OrderShopInterface; | |||
use Lc\ShopBundle\Context\ProductInterface; | |||
use Lc\ShopBundle\Context\ReductionCartInterface; | |||
use Lc\ShopBundle\Form\DataTransformer\ProductToIdTransformer; | |||
use Symfony\Bridge\Doctrine\Form\Type\EntityType; | |||
use Symfony\Component\Form\AbstractType; | |||
use Symfony\Component\Form\Extension\Core\Type\ButtonType; | |||
use Symfony\Component\Form\Extension\Core\Type\HiddenType; | |||
use Symfony\Component\Form\Extension\Core\Type\NumberType; | |||
use Symfony\Component\Form\Extension\Core\Type\SubmitType; | |||
use Symfony\Component\Form\FormBuilderInterface; | |||
use Symfony\Component\OptionsResolver\OptionsResolver; | |||
class OrderReductionCartType extends AbstractType | |||
{ | |||
protected $em; | |||
public function __construct(EntityManagerInterface $em) | |||
{ | |||
$this->em = $em; | |||
} | |||
public function buildForm(FormBuilderInterface $builder, array $options) | |||
{ | |||
$entity = $options['data']; | |||
$reductionCartClass = $this->em->getClassMetadata(ReductionCartInterface::class); | |||
$reductionCartRepo = $this->em->getRepository(ReductionCartInterface::class);; | |||
$builder | |||
->add('reductionCart', EntityType::class, array( | |||
'class' => $reductionCartClass->getName(), | |||
'choices' => $reductionCartRepo->getEligibleReductionCart($entity), | |||
'required' => true, | |||
'mapped'=>false | |||
)); | |||
$builder->add('saveOrderReductionCart', ButtonType::class, array( | |||
'label' => 'field.OrderShop.saveOrderReductionCart' | |||
)); | |||
} | |||
public function configureOptions(OptionsResolver $resolver) | |||
{ | |||
$resolver->setDefaults([ | |||
'data_class' => $this->em->getClassMetadata(OrderShopInterface::class)->getName(), | |||
]); | |||
} | |||
} |
@@ -0,0 +1,64 @@ | |||
<?php | |||
namespace Lc\ShopBundle\Form\Backend\Order; | |||
use App\Entity\Product; | |||
use Doctrine\ORM\EntityManagerInterface; | |||
use Lc\ShopBundle\Context\OrderProductInterface; | |||
use Lc\ShopBundle\Context\OrderReductionCartInterface; | |||
use Lc\ShopBundle\Context\OrderShopInterface; | |||
use Lc\ShopBundle\Context\OrderUtilsInterface; | |||
use Lc\ShopBundle\Context\ProductInterface; | |||
use Lc\ShopBundle\Context\ReductionCartInterface; | |||
use Lc\ShopBundle\Context\ReductionCreditInterface; | |||
use Lc\ShopBundle\Form\DataTransformer\ProductToIdTransformer; | |||
use Symfony\Bridge\Doctrine\Form\Type\EntityType; | |||
use Symfony\Component\Form\AbstractType; | |||
use Symfony\Component\Form\Extension\Core\Type\ButtonType; | |||
use Symfony\Component\Form\Extension\Core\Type\HiddenType; | |||
use Symfony\Component\Form\Extension\Core\Type\NumberType; | |||
use Symfony\Component\Form\Extension\Core\Type\SubmitType; | |||
use Symfony\Component\Form\FormBuilderInterface; | |||
use Symfony\Component\OptionsResolver\OptionsResolver; | |||
class OrderReductionCreditType extends AbstractType | |||
{ | |||
protected $em; | |||
protected $orderUtils; | |||
public function __construct(EntityManagerInterface $em, OrderUtilsInterface $orderUtils) | |||
{ | |||
$this->em = $em; | |||
$this->orderUtils = $orderUtils; | |||
} | |||
public function buildForm(FormBuilderInterface $builder, array $options) | |||
{ | |||
$entity = $options['data']; | |||
$reductionCreditClass = $this->em->getClassMetadata(ReductionCreditInterface::class); | |||
$reductionCreditRepo = $this->em->getRepository(ReductionCreditInterface::class);; | |||
$builder | |||
->add('reductionCredit', EntityType::class, array( | |||
'class' => $reductionCreditClass->getName(), | |||
'choices' => $this->orderUtils->getReductionCreditByUser($entity->getUser()), | |||
//'choices' => $this->orderUtils->getReductionCreditsAvailable($entity), | |||
'required' => true, | |||
'mapped'=>false | |||
)); | |||
$builder->add('saveOrderReductionCredit', ButtonType::class, array( | |||
'label' => 'field.OrderShop.saveOrderReductionCredit' | |||
)); | |||
} | |||
public function configureOptions(OptionsResolver $resolver) | |||
{ | |||
$resolver->setDefaults([ | |||
'data_class' => $this->em->getClassMetadata(OrderShopInterface::class)->getName(), | |||
]); | |||
} | |||
} |
@@ -0,0 +1,56 @@ | |||
<?php | |||
namespace Lc\ShopBundle\Form\Backend\Order; | |||
use Doctrine\ORM\EntityManagerInterface; | |||
use Doctrine\ORM\EntityRepository; | |||
use Lc\ShopBundle\Context\AddressInterface; | |||
use Lc\ShopBundle\Context\MerchantUtilsInterface; | |||
use Lc\ShopBundle\Context\OrderShopInterface; | |||
use Lc\ShopBundle\Context\OrderStatusInterface; | |||
use Lc\ShopBundle\Context\OrderUtilsInterface; | |||
use Lc\ShopBundle\Context\UserInterface; | |||
use Symfony\Bridge\Doctrine\Form\Type\EntityType; | |||
use Symfony\Component\Form\AbstractType; | |||
use Symfony\Component\Form\Extension\Core\Type\ButtonType; | |||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType; | |||
use Symfony\Component\Form\Extension\Core\Type\CollectionType; | |||
use Symfony\Component\Form\Extension\Core\Type\SubmitType; | |||
use Symfony\Component\Form\FormBuilderInterface; | |||
use Symfony\Component\OptionsResolver\OptionsResolver; | |||
class OrderStatusType extends AbstractType | |||
{ | |||
protected $em; | |||
protected $orderUtils; | |||
public function __construct(EntityManagerInterface $em, OrderUtilsInterface $orderUtils) | |||
{ | |||
$this->em = $em; | |||
$this->orderUtils = $orderUtils; | |||
} | |||
public function buildForm(FormBuilderInterface $builder, array $options) | |||
{ | |||
$entity = $options['data']; | |||
$orderStatusClass = $this->em->getClassMetadata(OrderStatusInterface::class); | |||
$builder->add('orderStatus', EntityType::class, array( | |||
'class'=> $orderStatusClass->name, | |||
'choices'=> $entity->getOrderStatus()->getNextStatusAllowed(), | |||
'required' => false, | |||
'mapped'=>false | |||
)) | |||
->add('saveOrderStatus', SubmitType::class, array( | |||
'label' => 'field.OrderShop.saveOrderStatus' | |||
)); | |||
} | |||
public function configureOptions(OptionsResolver $resolver) | |||
{ | |||
$resolver->setDefaults([ | |||
'data_class' => $this->em->getClassMetadata(OrderShopInterface::class)->getName(), | |||
]); | |||
} | |||
} |
@@ -1,6 +1,6 @@ | |||
<?php | |||
namespace Lc\ShopBundle\Form; | |||
namespace Lc\ShopBundle\Form\Backend\ProductFamily; | |||
use Doctrine\ORM\EntityManagerInterface; | |||
use Lc\ShopBundle\Context\ProductCategoryInterface; |
@@ -1,6 +1,6 @@ | |||
<?php | |||
namespace Lc\ShopBundle\Form; | |||
namespace Lc\ShopBundle\Form\Backend\ProductFamily; | |||
use Doctrine\ORM\EntityManagerInterface; | |||
use Lc\ShopBundle\Context\ProductInterface; |
@@ -0,0 +1,58 @@ | |||
<?php | |||
namespace Lc\ShopBundle\Form\Backend\ReductionCart; | |||
use Doctrine\ORM\EntityManagerInterface; | |||
use Lc\ShopBundle\Context\PointSaleInterface; | |||
use Lc\ShopBundle\Context\ReductionCatalogInterface; | |||
use Lc\ShopBundle\Context\UserInterface; | |||
use Lc\ShopBundle\Repository\GroupUserRepository; | |||
use Symfony\Bridge\Doctrine\Form\Type\EntityType; | |||
use Symfony\Component\Form\AbstractType; | |||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType; | |||
use Symfony\Component\Form\FormBuilderInterface; | |||
use Symfony\Component\Form\FormEvent; | |||
use Symfony\Component\Form\FormEvents; | |||
use Symfony\Component\OptionsResolver\OptionsResolver; | |||
class PointSalesFilterType extends AbstractType | |||
{ | |||
protected $em; | |||
public function __construct(EntityManagerInterface $entityManager) | |||
{ | |||
$this->em = $entityManager; | |||
} | |||
public function buildForm(FormBuilderInterface $builder, array $options) | |||
{ | |||
$class = $this->em->getClassMetadata(PointSaleInterface::class); | |||
$builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) use ($class) { | |||
$builder = $event->getForm()->getParent(); | |||
$builder->add('pointSalesActive', CheckboxType::class, array( | |||
'label' => 'field.Reduction.pointSalesActive', | |||
'mapped' => false, | |||
'translation_domain'=>'lcshop', | |||
'required'=>false, | |||
'attr' => ['class' => 'big'] | |||
)); | |||
$builder->add('pointSales', EntityType::class, [ | |||
'class' => $class->name, | |||
'required' => false, | |||
'expanded' => false, | |||
'multiple' => true, | |||
'translation_domain'=>'lcshop' | |||
]); | |||
}); | |||
} | |||
public function configureOptions(OptionsResolver $resolver) | |||
{ | |||
$resolver->setDefaults([ | |||
// 'translation_domain' => 'lcshop', | |||
]); | |||
} | |||
} |
@@ -0,0 +1,57 @@ | |||
<?php | |||
namespace Lc\ShopBundle\Form\Backend\ReductionCart; | |||
use Doctrine\ORM\EntityManagerInterface; | |||
use Lc\ShopBundle\Context\ReductionCartInterface; | |||
use Lc\ShopBundle\Context\ReductionCatalogInterface; | |||
use Lc\ShopBundle\Context\UserInterface; | |||
use Lc\ShopBundle\Repository\GroupUserRepository; | |||
use Symfony\Bridge\Doctrine\Form\Type\EntityType; | |||
use Symfony\Component\Form\AbstractType; | |||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType; | |||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType; | |||
use Symfony\Component\Form\FormBuilderInterface; | |||
use Symfony\Component\Form\FormEvent; | |||
use Symfony\Component\Form\FormEvents; | |||
use Symfony\Component\OptionsResolver\OptionsResolver; | |||
class UncombinableTypesType extends AbstractType | |||
{ | |||
protected $em; | |||
public function __construct(EntityManagerInterface $entityManager) | |||
{ | |||
$this->em = $entityManager; | |||
} | |||
public function buildForm(FormBuilderInterface $builder, array $options) | |||
{ | |||
$reductionCartRepo = $this->em->getRepository(ReductionCartInterface::class); | |||
foreach ($reductionCartRepo->getValuesOfFieldType() as $type){ | |||
$types['field.ReductionCart.typeOptions.'.$type['type']] = $type['type']; | |||
} | |||
$builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) use ($types) { | |||
$builder = $event->getForm()->getParent(); | |||
$builder->add('uncombinableTypes', ChoiceType::class, [ | |||
'choices'=> $types, | |||
'translation_domain'=> 'lcshop', | |||
'required' => false, | |||
'expanded' => false, | |||
'multiple' => true | |||
]); | |||
}); | |||
} | |||
public function configureOptions(OptionsResolver $resolver) | |||
{ | |||
/*$resolver->setDefaults([ | |||
'data_class' => $this->em->getClassMetadata(ReductionCatalogInterface::class)->getName(), | |||
]);*/ | |||
} | |||
} |
@@ -0,0 +1,53 @@ | |||
<?php | |||
namespace Lc\ShopBundle\Form\Backend\ReductionCart; | |||
use Doctrine\ORM\EntityManagerInterface; | |||
use Doctrine\ORM\EntityRepository; | |||
use Lc\ShopBundle\Context\ReductionCartInterface; | |||
use Lc\ShopBundle\Context\ReductionCatalogInterface; | |||
use Lc\ShopBundle\Context\UserInterface; | |||
use Lc\ShopBundle\Repository\GroupUserRepository; | |||
use Symfony\Bridge\Doctrine\Form\Type\EntityType; | |||
use Symfony\Component\Form\AbstractType; | |||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType; | |||
use Symfony\Component\Form\FormBuilderInterface; | |||
use Symfony\Component\Form\FormEvent; | |||
use Symfony\Component\Form\FormEvents; | |||
use Symfony\Component\OptionsResolver\OptionsResolver; | |||
class UncombinablesType extends AbstractType | |||
{ | |||
protected $em; | |||
public function __construct(EntityManagerInterface $entityManager) | |||
{ | |||
$this->em = $entityManager; | |||
} | |||
public function buildForm(FormBuilderInterface $builder, array $options) | |||
{ | |||
$reductionCartClass = $this->em->getClassMetadata(ReductionCartInterface::class); | |||
$builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) use ($reductionCartClass) { | |||
$builder = $event->getForm()->getParent(); | |||
$builder->add('uncombinables', EntityType::class, array( | |||
'class' => $reductionCartClass->name, | |||
'required' => false, | |||
'multiple'=>true, | |||
'choice_attr' => function ($choice, $key, $value) { | |||
return ['data-type' => $choice->getType()]; | |||
} | |||
)); | |||
}); | |||
} | |||
public function configureOptions(OptionsResolver $resolver) | |||
{ | |||
/*$resolver->setDefaults([ | |||
'data_class' => $this->em->getClassMetadata(ReductionCatalogInterface::class)->getName(), | |||
]);*/ | |||
} | |||
} |
@@ -0,0 +1,55 @@ | |||
<?php | |||
namespace Lc\ShopBundle\Form\Backend\ReductionCatalog; | |||
use Doctrine\ORM\EntityManagerInterface; | |||
use Lc\ShopBundle\Context\ProductCategoryInterface; | |||
use Symfony\Bridge\Doctrine\Form\Type\EntityType; | |||
use Symfony\Component\Form\AbstractType; | |||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType; | |||
use Symfony\Component\Form\FormBuilderInterface; | |||
use Symfony\Component\Form\FormEvent; | |||
use Symfony\Component\Form\FormEvents; | |||
use Symfony\Component\OptionsResolver\OptionsResolver; | |||
class ProductCategoriesFilterType extends AbstractType | |||
{ | |||
protected $em; | |||
public function __construct(EntityManagerInterface $entityManager) | |||
{ | |||
$this->em = $entityManager; | |||
} | |||
public function buildForm(FormBuilderInterface $builder, array $options) | |||
{ | |||
$class = $this->em->getClassMetadata(ProductCategoryInterface::class); | |||
$builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) use ($class) { | |||
$builder = $event->getForm()->getParent(); | |||
$builder->add('productCategoriesActive', CheckboxType::class, array( | |||
'label' => 'field.Reduction.productCategoriesActive', | |||
'translation_domain'=>'lcshop', | |||
'mapped' => false, | |||
'required'=>false, | |||
'attr' => ['class' => 'big'] | |||
)); | |||
$builder->add('productCategories', EntityType::class, [ | |||
'class' => $class->name, | |||
'required' => false, | |||
'expanded' => false, | |||
'multiple' => true, | |||
'translation_domain'=>'lcshop', | |||
]); | |||
}); | |||
} | |||
public function configureOptions(OptionsResolver $resolver) | |||
{ | |||
$resolver->setDefaults([ | |||
// 'translation_domain' => 'lcshop', | |||
]); | |||
} | |||
} |
@@ -0,0 +1,46 @@ | |||
<?php | |||
namespace Lc\ShopBundle\Form\Backend\ReductionCommon; | |||
use Doctrine\ORM\EntityManagerInterface; | |||
use Lc\ShopBundle\Context\ReductionCartInterface; | |||
use Lc\ShopBundle\Context\ReductionCatalogInterface; | |||
use Lc\ShopBundle\Context\UserInterface; | |||
use Lc\ShopBundle\Repository\GroupUserRepository; | |||
use Symfony\Bridge\Doctrine\Form\Type\EntityType; | |||
use Symfony\Component\Form\AbstractType; | |||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType; | |||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType; | |||
use Symfony\Component\Form\FormBuilderInterface; | |||
use Symfony\Component\Form\FormEvent; | |||
use Symfony\Component\Form\FormEvents; | |||
use Symfony\Component\OptionsResolver\OptionsResolver; | |||
class BehaviorTaxRateType extends AbstractType | |||
{ | |||
public function buildForm(FormBuilderInterface $builder, array $options) | |||
{ | |||
$builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) { | |||
$builder = $event->getForm()->getParent(); | |||
$builder->add('behaviorTaxRate', ChoiceType::class, [ | |||
'translation_domain' => 'lcshop', | |||
'required' => false, | |||
'empty_data' => 'tax-included', | |||
'choices' => [ | |||
'field.default.taxIncluded' => 'tax-included', | |||
'field.default.taxExcluded' => 'tax-excluded' | |||
] | |||
]); | |||
}); | |||
} | |||
public function configureOptions(OptionsResolver $resolver) | |||
{ | |||
/*$resolver->setDefaults([ | |||
'data_class' => $this->em->getClassMetadata(ReductionCatalogInterface::class)->getName(), | |||
]);*/ | |||
} | |||
} |
@@ -0,0 +1,42 @@ | |||
<?php | |||
namespace Lc\ShopBundle\Form\Backend\ReductionCommon; | |||
use Doctrine\ORM\EntityManagerInterface; | |||
use Lc\ShopBundle\Context\ReductionCartInterface; | |||
use Lc\ShopBundle\Context\ReductionCatalogInterface; | |||
use Lc\ShopBundle\Context\UserInterface; | |||
use Lc\ShopBundle\Repository\GroupUserRepository; | |||
use Symfony\Bridge\Doctrine\Form\Type\EntityType; | |||
use Symfony\Component\Form\AbstractType; | |||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType; | |||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType; | |||
use Symfony\Component\Form\Extension\Core\Type\DateTimeType; | |||
use Symfony\Component\Form\FormBuilderInterface; | |||
use Symfony\Component\Form\FormEvent; | |||
use Symfony\Component\Form\FormEvents; | |||
use Symfony\Component\OptionsResolver\OptionsResolver; | |||
class DateEndType extends AbstractType | |||
{ | |||
public function buildForm(FormBuilderInterface $builder, array $options) | |||
{ | |||
$builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) { | |||
$builder = $event->getForm()->getParent(); | |||
$builder->add('dateEnd', DateTimeType::class, array( | |||
'widget' => 'single_text', | |||
'required' => false, | |||
)); | |||
}); | |||
} | |||
public function configureOptions(OptionsResolver $resolver) | |||
{ | |||
/*$resolver->setDefaults([ | |||
'data_class' => $this->em->getClassMetadata(ReductionCatalogInterface::class)->getName(), | |||
]);*/ | |||
} | |||
} |
@@ -0,0 +1,42 @@ | |||
<?php | |||
namespace Lc\ShopBundle\Form\Backend\ReductionCommon; | |||
use Doctrine\ORM\EntityManagerInterface; | |||
use Lc\ShopBundle\Context\ReductionCartInterface; | |||
use Lc\ShopBundle\Context\ReductionCatalogInterface; | |||
use Lc\ShopBundle\Context\UserInterface; | |||
use Lc\ShopBundle\Repository\GroupUserRepository; | |||
use Symfony\Bridge\Doctrine\Form\Type\EntityType; | |||
use Symfony\Component\Form\AbstractType; | |||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType; | |||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType; | |||
use Symfony\Component\Form\Extension\Core\Type\DateTimeType; | |||
use Symfony\Component\Form\FormBuilderInterface; | |||
use Symfony\Component\Form\FormEvent; | |||
use Symfony\Component\Form\FormEvents; | |||
use Symfony\Component\OptionsResolver\OptionsResolver; | |||
class DateStartType extends AbstractType | |||
{ | |||
public function buildForm(FormBuilderInterface $builder, array $options) | |||
{ | |||
$builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) { | |||
$builder = $event->getForm()->getParent(); | |||
$builder->add('dateStart', DateTimeType::class, array( | |||
'widget' => 'single_text', | |||
'required' => false, | |||
)); | |||
}); | |||
} | |||
public function configureOptions(OptionsResolver $resolver) | |||
{ | |||
/*$resolver->setDefaults([ | |||
'data_class' => $this->em->getClassMetadata(ReductionCatalogInterface::class)->getName(), | |||
]);*/ | |||
} | |||
} |
@@ -0,0 +1,58 @@ | |||
<?php | |||
namespace Lc\ShopBundle\Form\Backend\ReductionCommon; | |||
use Doctrine\ORM\EntityManagerInterface; | |||
use Lc\ShopBundle\Context\GroupUserInterface; | |||
use Lc\ShopBundle\Context\ReductionCatalogInterface; | |||
use Lc\ShopBundle\Context\UserInterface; | |||
use Lc\ShopBundle\Repository\GroupUserRepository; | |||
use Symfony\Bridge\Doctrine\Form\Type\EntityType; | |||
use Symfony\Component\Form\AbstractType; | |||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType; | |||
use Symfony\Component\Form\FormBuilderInterface; | |||
use Symfony\Component\Form\FormEvent; | |||
use Symfony\Component\Form\FormEvents; | |||
use Symfony\Component\OptionsResolver\OptionsResolver; | |||
class GroupUsersFilterType extends AbstractType | |||
{ | |||
protected $em; | |||
public function __construct(EntityManagerInterface $entityManager) | |||
{ | |||
$this->em = $entityManager; | |||
} | |||
public function buildForm(FormBuilderInterface $builder, array $options) | |||
{ | |||
$class = $this->em->getClassMetadata(GroupUserInterface::class); | |||
$builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) use ($class) { | |||
$builder = $event->getForm()->getParent(); | |||
$builder->add('groupUsersActive', CheckboxType::class, array( | |||
'label' => 'field.Reduction.groupUsersActive', | |||
'mapped' => false, | |||
'required'=>false, | |||
'translation_domain'=>'lcshop', | |||
'attr' => ['class' => 'big'] | |||
)); | |||
$builder->add('groupUsers', EntityType::class, [ | |||
'class' => $class->name, | |||
'required' => false, | |||
'expanded' => false, | |||
'multiple' => true, | |||
'translation_domain'=>'lcshop', | |||
]); | |||
}); | |||
} | |||
public function configureOptions(OptionsResolver $resolver) | |||
{ | |||
$resolver->setDefaults([ | |||
// 'translation_domain' => 'lcshop', | |||
]); | |||
} | |||
} |
@@ -0,0 +1,45 @@ | |||
<?php | |||
namespace Lc\ShopBundle\Form\Backend\ReductionCommon; | |||
use Doctrine\ORM\EntityManagerInterface; | |||
use Lc\ShopBundle\Context\ReductionCartInterface; | |||
use Lc\ShopBundle\Context\ReductionCatalogInterface; | |||
use Lc\ShopBundle\Context\UserInterface; | |||
use Lc\ShopBundle\Repository\GroupUserRepository; | |||
use Symfony\Bridge\Doctrine\Form\Type\EntityType; | |||
use Symfony\Component\Form\AbstractType; | |||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType; | |||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType; | |||
use Symfony\Component\Form\FormBuilderInterface; | |||
use Symfony\Component\Form\FormEvent; | |||
use Symfony\Component\Form\FormEvents; | |||
use Symfony\Component\OptionsResolver\OptionsResolver; | |||
class PermanentType extends AbstractType | |||
{ | |||
public function buildForm(FormBuilderInterface $builder, array $options) | |||
{ | |||
$builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) { | |||
$builder = $event->getForm()->getParent(); | |||
$builder->add('permanent', CheckboxType::class, array( | |||
'required' => false, | |||
'translation_domain' => 'lcshop', | |||
'label' => 'field.ReductionCatalog.permanent', | |||
'label_attr' => [ | |||
'class' => 'big' | |||
] | |||
)); | |||
}); | |||
} | |||
public function configureOptions(OptionsResolver $resolver) | |||
{ | |||
/*$resolver->setDefaults([ | |||
'data_class' => $this->em->getClassMetadata(ReductionCatalogInterface::class)->getName(), | |||
]);*/ | |||
} | |||
} |
@@ -0,0 +1,45 @@ | |||
<?php | |||
namespace Lc\ShopBundle\Form\Backend\ReductionCommon; | |||
use Doctrine\ORM\EntityManagerInterface; | |||
use Lc\ShopBundle\Context\ReductionCartInterface; | |||
use Lc\ShopBundle\Context\ReductionCatalogInterface; | |||
use Lc\ShopBundle\Context\UserInterface; | |||
use Lc\ShopBundle\Repository\GroupUserRepository; | |||
use Symfony\Bridge\Doctrine\Form\Type\EntityType; | |||
use Symfony\Component\Form\AbstractType; | |||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType; | |||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType; | |||
use Symfony\Component\Form\FormBuilderInterface; | |||
use Symfony\Component\Form\FormEvent; | |||
use Symfony\Component\Form\FormEvents; | |||
use Symfony\Component\OptionsResolver\OptionsResolver; | |||
class UnitType extends AbstractType | |||
{ | |||
public function buildForm(FormBuilderInterface $builder, array $options) | |||
{ | |||
$builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) { | |||
$builder = $event->getForm()->getParent(); | |||
$builder->add('unit', ChoiceType::class, [ | |||
'required' => true, | |||
'translation_domain'=>'lcshop', | |||
'expanded'=>true, | |||
'choices' => [ | |||
'field.default.percent' => 'percent', | |||
'field.default.amount' => 'amount' | |||
] | |||
]); | |||
}); | |||
} | |||
public function configureOptions(OptionsResolver $resolver) | |||
{ | |||
/*$resolver->setDefaults([ | |||
'data_class' => $this->em->getClassMetadata(ReductionCatalogInterface::class)->getName(), | |||
]);*/ | |||
} | |||
} |
@@ -0,0 +1,65 @@ | |||
<?php | |||
namespace Lc\ShopBundle\Form\Backend\ReductionCommon; | |||
use Doctrine\ORM\EntityManagerInterface; | |||
use Lc\ShopBundle\Context\ReductionCatalogInterface; | |||
use Lc\ShopBundle\Context\UserInterface; | |||
use Lc\ShopBundle\Repository\GroupUserRepository; | |||
use Symfony\Bridge\Doctrine\Form\Type\EntityType; | |||
use Symfony\Component\Form\AbstractType; | |||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType; | |||
use Symfony\Component\Form\FormBuilderInterface; | |||
use Symfony\Component\Form\FormEvent; | |||
use Symfony\Component\Form\FormEvents; | |||
use Symfony\Component\OptionsResolver\OptionsResolver; | |||
class UsersFilterType extends AbstractType | |||
{ | |||
protected $em; | |||
public function __construct(EntityManagerInterface $entityManager) | |||
{ | |||
$this->em = $entityManager; | |||
} | |||
public function buildForm(FormBuilderInterface $builder, array $options) | |||
{ | |||
$userClass = $this->em->getClassMetadata(UserInterface::class); | |||
$builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) use ($userClass) { | |||
$builder = $event->getForm()->getParent(); | |||
$builder->add('usersActive', CheckboxType::class, array( | |||
'label' => 'field.Reduction.usersActive', | |||
'mapped' => false, | |||
'translation_domain'=>'lcshop', | |||
'required'=>false, | |||
'attr' => ['class' => 'big'] | |||
)); | |||
$builder->add('users', EntityType::class, [ | |||
'class' => $userClass->name, | |||
'required' => false, | |||
'expanded' => false, | |||
'multiple' => true, | |||
'translation_domain'=>'lcshop', | |||
'choice_attr' => function ($choice, $key, $value) { | |||
$data = array(); | |||
foreach ($choice->getGroupUsers() as $groupUser) { | |||
$data[] = '_'.$groupUser->getId().'_'; | |||
} | |||
return ['data-group-users' => json_encode($data)]; | |||
} | |||
]); | |||
}); | |||
} | |||
public function configureOptions(OptionsResolver $resolver) | |||
{ | |||
$resolver->setDefaults([ | |||
'translation_domain' => 'lcshop', | |||
]); | |||
} | |||
} |
@@ -0,0 +1,40 @@ | |||
<?php | |||
namespace Lc\ShopBundle\Form\Backend\ReductionCommon; | |||
use Doctrine\ORM\EntityManagerInterface; | |||
use Lc\ShopBundle\Context\ReductionCartInterface; | |||
use Lc\ShopBundle\Context\ReductionCatalogInterface; | |||
use Lc\ShopBundle\Context\UserInterface; | |||
use Lc\ShopBundle\Repository\GroupUserRepository; | |||
use Symfony\Bridge\Doctrine\Form\Type\EntityType; | |||
use Symfony\Component\Form\AbstractType; | |||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType; | |||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType; | |||
use Symfony\Component\Form\Extension\Core\Type\NumberType; | |||
use Symfony\Component\Form\FormBuilderInterface; | |||
use Symfony\Component\Form\FormEvent; | |||
use Symfony\Component\Form\FormEvents; | |||
use Symfony\Component\OptionsResolver\OptionsResolver; | |||
class ValueType extends AbstractType | |||
{ | |||
public function buildForm(FormBuilderInterface $builder, array $options) | |||
{ | |||
$builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) { | |||
$builder = $event->getForm()->getParent(); | |||
$builder->add('value', NumberType::class, [ | |||
'required' => false | |||
]); | |||
}); | |||
} | |||
public function configureOptions(OptionsResolver $resolver) | |||
{ | |||
/*$resolver->setDefaults([ | |||
'data_class' => $this->em->getClassMetadata(ReductionCatalogInterface::class)->getName(), | |||
]);*/ | |||
} | |||
} |
@@ -1,40 +0,0 @@ | |||
<?php | |||
namespace Lc\ShopBundle\Form; | |||
use Doctrine\ORM\EntityManagerInterface; | |||
use Lc\ShopBundle\Context\CreditConfigInterface; | |||
use Symfony\Component\Form\AbstractType; | |||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType; | |||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType; | |||
use Symfony\Component\Form\FormBuilderInterface; | |||
use Symfony\Component\OptionsResolver\OptionsResolver; | |||
class CreditConfigType extends AbstractType | |||
{ | |||
protected $em; | |||
public function __construct(EntityManagerInterface $entityManager) | |||
{ | |||
$this->em = $entityManager; | |||
} | |||
public function buildForm(FormBuilderInterface $builder, array $options) | |||
{ | |||
$builder | |||
->add('active', CheckboxType::class, [ | |||
'label' => 'Activé' | |||
]) | |||
->add('limitAmount') | |||
->add('limitReminder') | |||
->add('behavior') | |||
->add('processOrderCheckedDefault'); | |||
} | |||
public function configureOptions(OptionsResolver $resolver) | |||
{ | |||
$resolver->setDefaults([ | |||
'data_class' => $this->em->getClassMetadata(CreditConfigInterface::class)->getName(), | |||
]); | |||
} | |||
} |
@@ -1,6 +1,6 @@ | |||
<?php | |||
namespace Lc\ShopBundle\Form; | |||
namespace Lc\ShopBundle\Form\Frontend; | |||
use FOS\UserBundle\Form\Type\RegistrationFormType as BaseRegistrationFormType; | |||
use Symfony\Component\Form\AbstractType; |
@@ -1,142 +0,0 @@ | |||
<?php | |||
namespace Lc\ShopBundle\Form; | |||
use App\Entity\Supplier; | |||
use Lc\ShopBundle\Context\GroupUserInterface; | |||
use Lc\ShopBundle\Context\ProductCategoryInterface; | |||
use Lc\ShopBundle\Context\ProductFamilyInterface; | |||
use Lc\ShopBundle\Context\ReductionCatalogInterface; | |||
use Lc\ShopBundle\Context\UserInterface; | |||
use Symfony\Bridge\Doctrine\Form\Type\EntityType; | |||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType; | |||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType; | |||
use Symfony\Component\Form\Extension\Core\Type\DateTimeType; | |||
use Symfony\Component\Form\Extension\Core\Type\NumberType; | |||
use Symfony\Component\Form\Extension\Core\Type\TextType; | |||
use Doctrine\ORM\EntityManagerInterface; | |||
use Symfony\Component\Form\AbstractType; | |||
use Symfony\Component\Form\FormBuilderInterface; | |||
use Symfony\Component\OptionsResolver\OptionsResolver; | |||
class ReductionCatalogType extends AbstractType | |||
{ | |||
protected $em; | |||
public function __construct(EntityManagerInterface $entityManager) | |||
{ | |||
$this->em = $entityManager; | |||
} | |||
public function buildForm(FormBuilderInterface $builder, array $options) | |||
{ | |||
$userClass = $this->em->getClassMetadata(UserInterface::class); | |||
$groupUserClass = $this->em->getClassMetadata(GroupUserInterface::class); | |||
$supplierClass = Supplier::class; | |||
$productFamilyClass = $this->em->getClassMetadata(ProductFamilyInterface::class); | |||
$productCategoryClass = $this->em->getClassMetadata(ProductCategoryInterface::class); | |||
$builder | |||
->add('title', TextType::class, [ | |||
'label' => 'Titre', | |||
'required' => false, | |||
]) | |||
->add('behaviorTaxRate', ChoiceType::class, [ | |||
'required' => false, | |||
'choices' => [ | |||
'field.default.taxIncluded' => 'tax-included', | |||
'field.default.taxExcluded' => 'tax-excluded' | |||
] | |||
]) | |||
->add('unit', ChoiceType::class, [ | |||
'required' => false, | |||
'choices' => [ | |||
'field.default.percent' => 'percent', | |||
'field.default.amount' => 'amount' | |||
] | |||
]) | |||
->add('value', NumberType::class, [ | |||
'required' => false | |||
]) | |||
->add('permanent', CheckboxType::class, array( | |||
'required'=>false | |||
)) | |||
->add('dateStart', DateTimeType::class, | |||
['widget' => 'single_text', | |||
'required'=>false, | |||
]) | |||
->add('dateEnd', DateTimeType::class, [ | |||
'widget' => 'single_text', | |||
'required'=>false, | |||
]) | |||
->add('usersActive', CheckboxType::class, array( | |||
'label' => 'field.ReductionCatalog.usersActive', | |||
'mapped' => false, | |||
'required'=>false, | |||
'attr' => ['class' => 'big'] | |||
)) | |||
->add('users', EntityType::class, array( | |||
'class' => $userClass->name, | |||
'required'=>false, | |||
'multiple'=>true | |||
)) | |||
->add('groupUsersActive', CheckboxType::class, array( | |||
'label' => 'field.ReductionCatalog.groupUsersActive', | |||
'mapped' => false, | |||
'required'=>false, | |||
'attr' => ['class' => 'big'] | |||
)) | |||
->add('groupUsers', EntityType::class, array( | |||
'class' => $groupUserClass->name, | |||
'required'=>false, | |||
'multiple'=>true | |||
)); | |||
/* ->add('productFamiliesActive', CheckboxType::class, array( | |||
'label' => 'field.ReductionCatalog.productFamiliesActive', | |||
'mapped' => false, | |||
'required'=>false, | |||
'attr' => ['class' => 'big'] | |||
)) | |||
->add('productFamilies', EntityType::class, array( | |||
'class' => $productFamilyClass->name, | |||
'required'=>false, | |||
'multiple'=>true | |||
)) | |||
->add('productCategoriesActive', CheckboxType::class, array( | |||
'label' => 'field.ReductionCatalog.productCategoriesActive', | |||
'mapped' => false, | |||
'required'=>false, | |||
'attr' => ['class' => 'big'] | |||
)) | |||
->add('productCategories', EntityType::class, array( | |||
'class' => $productCategoryClass->name, | |||
'required'=>false, | |||
'multiple'=>true | |||
)) | |||
->add('suppliersActive', CheckboxType::class, array( | |||
'label' => 'field.ReductionCatalog.suppliersActive', | |||
'mapped' => false, | |||
'required'=>false, | |||
'attr' => ['class' => 'big'] | |||
)) | |||
->add('suppliers', EntityType::class, array( | |||
'class' => $supplierClass, | |||
'required'=>false, | |||
'multiple'=>true | |||
));*/ | |||
} | |||
public function configureOptions(OptionsResolver $resolver) | |||
{ | |||
$resolver->setDefaults([ | |||
'label' => false, | |||
//'data_class' => $this->em->getClassMetadata(ReductionCatalogInterface::class)->getName(), | |||
'translation_domain'=> 'lcshop' | |||
]); | |||
} | |||
} |
@@ -1,64 +0,0 @@ | |||
<?php | |||
namespace Lc\ShopBundle\Model; | |||
use Doctrine\ORM\Mapping as ORM; | |||
/** | |||
* @ORM\MappedSuperclass() | |||
*/ | |||
abstract class Cart extends AbstractEntity | |||
{ | |||
/** | |||
* @ORM\OneToOne(targetEntity="Lc\ShopBundle\Context\VisitorInterface", inversedBy="cart", cascade={"persist", "remove"}) | |||
* @ORM\JoinColumn(nullable=false) | |||
*/ | |||
protected $visitor; | |||
/** | |||
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\UserInterface", inversedBy="carts") | |||
*/ | |||
protected $user; | |||
/** | |||
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\AddressInterface") | |||
*/ | |||
protected $address; | |||
public function getVisitor(): ?Visitor | |||
{ | |||
return $this->visitor; | |||
} | |||
public function setVisitor(Visitor $visitor): self | |||
{ | |||
$this->visitor = $visitor; | |||
return $this; | |||
} | |||
public function getUser(): ?User | |||
{ | |||
return $this->user; | |||
} | |||
public function setUser(?User $user): self | |||
{ | |||
$this->user = $user; | |||
return $this; | |||
} | |||
public function getAddress(): ?Address | |||
{ | |||
return $this->address; | |||
} | |||
public function setAddress(?Address $address): self | |||
{ | |||
$this->address = $address; | |||
return $this; | |||
} | |||
} |
@@ -1,135 +0,0 @@ | |||
<?php | |||
namespace Lc\ShopBundle\Model; | |||
use Doctrine\ORM\Mapping as ORM; | |||
/** | |||
* @ORM\MappedSuperclass() | |||
*/ | |||
abstract class CartProduct extends AbstractEntity | |||
{ | |||
/** | |||
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\CartInterface", inversedBy="cartProducts") | |||
* @ORM\JoinColumn(nullable=false) | |||
*/ | |||
protected $cart; | |||
/** | |||
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\ProductInterface") | |||
* @ORM\JoinColumn(nullable=false) | |||
*/ | |||
protected $product; | |||
/** | |||
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\TaxRateInterface") | |||
* @ORM\JoinColumn(nullable=false) | |||
*/ | |||
protected $taxRate; | |||
/** | |||
* @ORM\Column(type="float") | |||
*/ | |||
protected $price; | |||
/** | |||
* @ORM\Column(type="string", length=31) | |||
*/ | |||
protected $unit; | |||
/** | |||
* @ORM\Column(type="float") | |||
*/ | |||
protected $quantity; | |||
/** | |||
* @ORM\Column(type="string", length=255) | |||
*/ | |||
protected $title; | |||
public function getCart(): ?Cart | |||
{ | |||
return $this->cart; | |||
} | |||
public function setCart(?Cart $cart): self | |||
{ | |||
$this->cart = $cart; | |||
return $this; | |||
} | |||
public function getProduct(): ?Product | |||
{ | |||
return $this->product; | |||
} | |||
public function setProduct(?Product $product): self | |||
{ | |||
$this->product = $product; | |||
return $this; | |||
} | |||
public function getTaxRate(): ?TaxRate | |||
{ | |||
return $this->taxRate; | |||
} | |||
public function setTaxRate(?TaxRate $taxRate): self | |||
{ | |||
$this->taxRate = $taxRate; | |||
return $this; | |||
} | |||
public function getPrice(): ?float | |||
{ | |||
return $this->price; | |||
} | |||
public function setPrice(float $price): self | |||
{ | |||
$this->price = $price; | |||
return $this; | |||
} | |||
public function getUnit(): ?string | |||
{ | |||
return $this->unit; | |||
} | |||
public function setUnit(string $unit): self | |||
{ | |||
$this->unit = $unit; | |||
return $this; | |||
} | |||
public function getQuantity(): ?float | |||
{ | |||
return $this->quantity; | |||
} | |||
public function setQuantity(float $quantity): self | |||
{ | |||
$this->quantity = $quantity; | |||
return $this; | |||
} | |||
public function getTitle(): ?string | |||
{ | |||
return $this->title; | |||
} | |||
public function setTitle(string $title): self | |||
{ | |||
$this->title = $title; | |||
return $this; | |||
} | |||
} |
@@ -0,0 +1,77 @@ | |||
<?php | |||
namespace Lc\ShopBundle\Model; | |||
use Doctrine\ORM\Mapping as ORM; | |||
use Lc\ShopBundle\Context\ReductionCartPropertyInterface; | |||
use Lc\ShopBundle\Context\ReductionInterface; | |||
/** | |||
* @ORM\MappedSuperclass() | |||
*/ | |||
abstract class OrderReductionCart implements ReductionInterface, ReductionCartPropertyInterface | |||
{ | |||
use ReductionTrait; | |||
use ReductionCartPropertyTrait; | |||
/** | |||
* @ORM\Column(type="string", length=255) | |||
*/ | |||
protected $title; | |||
/** | |||
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\OrderShopInterface", inversedBy="orderReductionCarts") | |||
* @ORM\JoinColumn(nullable=false) | |||
*/ | |||
protected $orderShop; | |||
/** | |||
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\ReductionCartInterface") | |||
* @ORM\JoinColumn(nullable=false) | |||
*/ | |||
protected $reductionCart; | |||
public function __toString() | |||
{ | |||
return $this->title; | |||
} | |||
public function getTitle(): ?string | |||
{ | |||
return $this->title; | |||
} | |||
public function setTitle(string $title): self | |||
{ | |||
$this->title = $title; | |||
return $this; | |||
} | |||
public function getOrderShop(): ?OrderShop | |||
{ | |||
return $this->orderShop; | |||
} | |||
public function setOrderShop(?OrderShop $orderShop): self | |||
{ | |||
$this->orderShop = $orderShop; | |||
return $this; | |||
} | |||
public function getReductionCart(): ?ReductionCart | |||
{ | |||
return $this->reductionCart; | |||
} | |||
public function setReductionCart(?ReductionCart $reductionCart): self | |||
{ | |||
$this->reductionCart = $reductionCart; | |||
return $this; | |||
} | |||
} |
@@ -0,0 +1,31 @@ | |||
<?php | |||
namespace Lc\ShopBundle\Model; | |||
use Doctrine\ORM\Mapping as ORM; | |||
use Lc\ShopBundle\Context\ReductionInterface; | |||
/** | |||
* @ORM\MappedSuperclass() | |||
*/ | |||
abstract class OrderReductionCredit implements ReductionInterface | |||
{ | |||
use ReductionTrait ; | |||
/** | |||
* @ORM\Column(type="string", length=255) | |||
*/ | |||
protected $title; | |||
public function getTitle(): ?string | |||
{ | |||
return $this->title; | |||
} | |||
public function setTitle(string $title): self | |||
{ | |||
$this->title = $title; | |||
return $this; | |||
} | |||
} |
@@ -85,35 +85,53 @@ abstract class OrderShop extends AbstractEntity implements FilterMerchantInterfa | |||
*/ | |||
protected $infosDelivery; | |||
/** | |||
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\OrderStatusInterface") | |||
* @ORM\JoinColumn(nullable=false) | |||
*/ | |||
protected $orderStatus; | |||
/** | |||
* @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\OrderReductionCartInterface", mappedBy="orderShop", orphanRemoval=true) | |||
*/ | |||
protected $orderReductionCarts; | |||
/** | |||
* @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\OrderReductionCreditInterface", mappedBy="orderShop", orphanRemoval=true) | |||
*/ | |||
protected $orderReductionCredits; | |||
public function __construct() | |||
{ | |||
$this->orderStatusHistories = new ArrayCollection(); | |||
$this->orderProducts = new ArrayCollection(); | |||
$this->creditHistories = new ArrayCollection(); | |||
$this->orderReductionCarts = new ArrayCollection(); | |||
$this->orderReductionCredits = new ArrayCollection(); | |||
} | |||
public function getDateCreated() | |||
{ | |||
$orderStatusHistory = $this->getOrderStatusHistory('new') ; | |||
if($orderStatusHistory) { | |||
return $orderStatusHistory->getCreatedAt() ; | |||
$orderStatusHistory = $this->getOrderStatusHistory('new'); | |||
if ($orderStatusHistory) { | |||
return $orderStatusHistory->getCreatedAt(); | |||
} | |||
return null ; | |||
return null; | |||
} | |||
public function getOrderStatusHistory($status) | |||
{ | |||
$orderStatusHistories = $this->getOrderStatusHistories() ; | |||
if(count($orderStatusHistories) > 0) { | |||
foreach($orderStatusHistories as $orderStatusHistory) { | |||
if($orderStatusHistory->getOrderStatus() == $status) { | |||
return $orderStatusHistory ; | |||
$orderStatusHistories = $this->getOrderStatusHistories(); | |||
if (count($orderStatusHistories) > 0) { | |||
foreach ($orderStatusHistories as $orderStatusHistory) { | |||
if ($orderStatusHistory->getOrderStatus() == $status) { | |||
return $orderStatusHistory; | |||
} | |||
} | |||
} | |||
return null ; | |||
return null; | |||
} | |||
public function getMerchant(): ?Merchant | |||
@@ -340,4 +358,81 @@ abstract class OrderShop extends AbstractEntity implements FilterMerchantInterfa | |||
return $this; | |||
} | |||
public function getOrderStatus(): ?OrderStatus | |||
{ | |||
return $this->orderStatus; | |||
} | |||
public function setOrderStatusProtected(?OrderStatus $orderStatus): self | |||
{ | |||
$this->orderStatus = $orderStatus; | |||
return $this; | |||
} | |||
/** | |||
* @return Collection|OrderReductionCart[] | |||
*/ | |||
public function getOrderReductionCarts(): Collection | |||
{ | |||
return $this->orderReductionCarts; | |||
} | |||
public function addOrderReductionCart(OrderReductionCart $orderReductionCart): self | |||
{ | |||
if (!$this->orderReductionCarts->contains($orderReductionCart)) { | |||
$this->orderReductionCarts[] = $orderReductionCart; | |||
$orderReductionCart->setOrderShop($this); | |||
} | |||
return $this; | |||
} | |||
public function removeOrderReductionCart(OrderReductionCart $orderReductionCart): self | |||
{ | |||
if ($this->orderReductionCarts->contains($orderReductionCart)) { | |||
$this->orderReductionCarts->removeElement($orderReductionCart); | |||
// set the owning side to null (unless already changed) | |||
if ($orderReductionCart->getOrderShop() === $this) { | |||
$orderReductionCart->setOrderShop(null); | |||
} | |||
} | |||
return $this; | |||
} | |||
/** | |||
* @return Collection|OrderReductionCart[] | |||
*/ | |||
public function getOrderReductionCredits(): Collection | |||
{ | |||
return $this->orderReductionCredits; | |||
} | |||
public function addOrderReductionCredit(OrderReductionCredit $orderReductionCredit): self | |||
{ | |||
if (!$this->orderReductionCredits->contains($orderReductionCredit)) { | |||
$this->orderReductionCredits[] = $orderReductionCredit; | |||
$orderReductionCredit->setOrderShop($this); | |||
} | |||
return $this; | |||
} | |||
public function removeOrderReductionCredit(OrderReductionCredit $orderReductionCredit): self | |||
{ | |||
if ($this->orderReductionCredits->contains($orderReductionCredit)) { | |||
$this->orderReductionCredits->removeElement($orderReductionCredit); | |||
// set the owning side to null (unless already changed) | |||
if ($orderReductionCredit->getOrderShop() === $this) { | |||
$orderReductionCredit->setOrderShop(null); | |||
} | |||
} | |||
return $this; | |||
} | |||
} |
@@ -0,0 +1,108 @@ | |||
<?php | |||
namespace Lc\ShopBundle\Model; | |||
use Doctrine\ORM\Mapping as ORM; | |||
use Doctrine\Common\Collections\ArrayCollection; | |||
use Doctrine\Common\Collections\Collection; | |||
/** | |||
* @ORM\MappedSuperclass() | |||
*/ | |||
abstract class OrderStatus | |||
{ | |||
/** | |||
* @ORM\Column(type="string", length=255) | |||
*/ | |||
protected $title; | |||
/** | |||
* @ORM\Column(type="text", nullable=true) | |||
*/ | |||
protected $description; | |||
/** | |||
* @ORM\ManyToMany(targetEntity="Lc\ShopBundle\Context\OrderStatusInterface") | |||
*/ | |||
protected $nextStatusAllowed; | |||
/** | |||
* @ORM\Column(type="string", length=255) | |||
*/ | |||
protected $alias; | |||
public function __toString() | |||
{ | |||
return $this->title. ' ['.$this->alias.']'; | |||
} | |||
public function __construct() | |||
{ | |||
$this->nextStatusAllowed = new ArrayCollection(); | |||
} | |||
public function getTitle(): ?string | |||
{ | |||
return $this->title; | |||
} | |||
public function setTitle(string $title): self | |||
{ | |||
$this->title = $title; | |||
return $this; | |||
} | |||
public function getDescription(): ?string | |||
{ | |||
return $this->description; | |||
} | |||
public function setDescription(?string $description): self | |||
{ | |||
$this->description = $description; | |||
return $this; | |||
} | |||
/** | |||
* @return Collection|self[] | |||
*/ | |||
public function getNextStatusAllowed(): Collection | |||
{ | |||
return $this->nextStatusAllowed; | |||
} | |||
public function addNextStatusAllowed(self $nextStatusAllowed): self | |||
{ | |||
if (!$this->nextStatusAllowed->contains($nextStatusAllowed)) { | |||
$this->nextStatusAllowed[] = $nextStatusAllowed; | |||
} | |||
return $this; | |||
} | |||
public function removeNextStatusAllowed(self $nextStatusAllowed): self | |||
{ | |||
if ($this->nextStatusAllowed->contains($nextStatusAllowed)) { | |||
$this->nextStatusAllowed->removeElement($nextStatusAllowed); | |||
} | |||
return $this; | |||
} | |||
public function getAlias(): ?string | |||
{ | |||
return $this->alias; | |||
} | |||
public function setAlias(string $alias): self | |||
{ | |||
$this->alias = $alias; | |||
return $this; | |||
} | |||
} |
@@ -16,7 +16,8 @@ abstract class OrderStatusHistory extends AbstractEntity | |||
protected $orderShop; | |||
/** | |||
* @ORM\Column(type="string", length=31) | |||
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\OrderStatusInterface") | |||
* @ORM\JoinColumn(nullable=false) | |||
*/ | |||
protected $orderStatus; | |||
@@ -37,12 +38,12 @@ abstract class OrderStatusHistory extends AbstractEntity | |||
return $this; | |||
} | |||
public function getOrderStatus(): ?string | |||
public function getOrderStatus(): ?OrderStatus | |||
{ | |||
return $this->orderStatus; | |||
} | |||
public function setOrderStatus(string $orderStatus): self | |||
public function setOrderStatus(?OrderStatus $orderStatus): self | |||
{ | |||
$this->orderStatus = $orderStatus; | |||
@@ -31,10 +31,6 @@ abstract class Product extends AbstractEntity implements SortableInterface, Prod | |||
*/ | |||
protected $title; | |||
/** | |||
* @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\OrderProductInterface", mappedBy="product", orphanRemoval=true, cascade={"remove"}) | |||
*/ | |||
protected $orderProducts ; | |||
public function __construct() | |||
{ | |||
@@ -155,35 +151,4 @@ abstract class Product extends AbstractEntity implements SortableInterface, Prod | |||
return $this; | |||
} | |||
/** | |||
* @return Collection|OrderProductInterface[] | |||
*/ | |||
public function getOrderProducts(): Collection | |||
{ | |||
return $this->orderProducts; | |||
} | |||
public function addOrderProduct(OrderProductInterface $orderProduct): self | |||
{ | |||
if (!$this->orderProducts->contains($orderProduct)) { | |||
$this->orderProducts[] = $orderProduct; | |||
$orderProduct->setProduct($this); | |||
} | |||
return $this; | |||
} | |||
public function removeOrderProduct(OrderProductInterface $orderProduct): self | |||
{ | |||
if ($this->orderProducts->contains($orderProduct)) { | |||
$this->orderProducts->removeElement($orderProduct); | |||
// set the owning side to null (unless already changed) | |||
if ($orderProduct->getProduct() === $this) { | |||
$orderProduct->setProduct(null); | |||
} | |||
} | |||
return $this; | |||
} | |||
} |
@@ -19,6 +19,7 @@ abstract class ProductFamily extends AbstractDocumentEntity implements ProductPr | |||
{ | |||
use ProductPropertyTrait; | |||
//Champ hydraté par ProductFamilyUtils | |||
protected $reductionCatalog; | |||
@@ -1,76 +1,208 @@ | |||
<?php | |||
namespace App\Entity; | |||
namespace Lc\ShopBundle\Model; | |||
use Doctrine\Common\Collections\ArrayCollection; | |||
use Doctrine\Common\Collections\Collection; | |||
use Doctrine\ORM\Mapping as ORM; | |||
use Lc\ShopBundle\Context\FilterMerchantInterface; | |||
use Lc\ShopBundle\Context\OrderAmountMinInterface; | |||
use Lc\ShopBundle\Context\ReductionCartPropertyInterface; | |||
use Lc\ShopBundle\Context\ReductionInterface; | |||
use Lc\ShopBundle\Model\AbstractDocumentEntity; | |||
use Lc\ShopBundle\Model\ReductionPropertyTrait; | |||
use Lc\ShopBundle\Model\ReductionTrait; | |||
use Lc\ShopBundle\Context\ReductionPropertyInterface; | |||
use Lc\ShopBundle\Context\StatusInterface; | |||
/** | |||
* @ORM\MappedSuperclass() | |||
*/ | |||
abstract class ReductionCart extends AbstractDocumentEntity | |||
abstract class ReductionCart extends AbstractEntity implements ReductionPropertyInterface, ReductionInterface, ReductionCartPropertyInterface, FilterMerchantInterface, OrderAmountMinInterface, StatusInterface | |||
{ | |||
use StatusTrait; | |||
use OrderAmountMin; | |||
use ReductionTrait; | |||
use ReductionPropertyTrait ; | |||
use ReductionCartPropertyTrait; | |||
use ReductionPropertyTrait { | |||
ReductionPropertyTrait::__construct as private __reductionPropertyConstruct; | |||
} | |||
/** | |||
* @ORM\Column(type="string", length=255) | |||
*/ | |||
protected $title; | |||
/** | |||
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\MerchantInterface") | |||
* @ORM\JoinColumn(nullable=false) | |||
*/ | |||
protected $merchant; | |||
/** | |||
* @ORM\Column(type="boolean", nullable=true) | |||
* @ORM\Column(type="array", nullable=true) | |||
*/ | |||
protected $freeShipping; | |||
protected $codes = []; | |||
/** | |||
* @ORM\Column(type="string", length=25) | |||
* @ORM\Column(type="integer") | |||
*/ | |||
protected $appliedTo; | |||
protected $availableQuantity; | |||
/** | |||
* @ORM\Column(type="integer") | |||
*/ | |||
protected $priority; | |||
protected $availableQuantityPerUser; | |||
/** | |||
* @ORM\ManyToMany(targetEntity="Lc\ShopBundle\Context\PointSaleInterface") | |||
*/ | |||
protected $pointSales; | |||
/** | |||
* @ORM\ManyToMany(targetEntity="Lc\ShopBundle\Context\ReductionCartInterface") | |||
*/ | |||
protected $uncombinables; | |||
/** | |||
* @ORM\Column(type="array", nullable=true) | |||
*/ | |||
protected $uncombinableTypes = []; | |||
public function __toString() | |||
{ | |||
return $this->title; | |||
} | |||
public function __construct() | |||
{ | |||
$this->__reductionPropertyConstruct(); | |||
$this->pointSales = new ArrayCollection(); | |||
$this->uncombinables = new ArrayCollection(); | |||
} | |||
public function getTitle(): ?string | |||
{ | |||
return $this->title; | |||
} | |||
public function setTitle(string $title): self | |||
{ | |||
$this->title = $title; | |||
return $this; | |||
} | |||
public function getMerchant(): ?Merchant | |||
{ | |||
return $this->merchant; | |||
} | |||
public function setMerchant(?Merchant $merchant): self | |||
{ | |||
$this->merchant = $merchant; | |||
return $this; | |||
} | |||
public function getCodes(): ?array | |||
{ | |||
return $this->codes; | |||
} | |||
public function setCodes(?array $codes): self | |||
{ | |||
$this->codes = $codes; | |||
return $this; | |||
} | |||
/** | |||
* @return Collection|PointSale[] | |||
*/ | |||
public function getPointSales(): Collection | |||
{ | |||
return $this->pointSales; | |||
} | |||
public function addPointSale(PointSale $pointSale): self | |||
{ | |||
if (!$this->pointSales->contains($pointSale)) { | |||
$this->pointSales[] = $pointSale; | |||
} | |||
return $this; | |||
} | |||
public function removePointSale(PointSale $pointSale): self | |||
{ | |||
if ($this->pointSales->contains($pointSale)) { | |||
$this->pointSales->removeElement($pointSale); | |||
} | |||
return $this; | |||
} | |||
public function getFreeShipping(): ?bool | |||
public function getAvailableQuantity(): ?int | |||
{ | |||
return $this->freeShipping; | |||
return $this->availableQuantity; | |||
} | |||
public function setFreeShipping(?bool $freeShipping): self | |||
public function setAvailableQuantity(int $availableQuantity): self | |||
{ | |||
$this->freeShipping = $freeShipping; | |||
$this->availableQuantity = $availableQuantity; | |||
return $this; | |||
} | |||
public function getAppliedTo(): ?string | |||
public function getAvailableQuantityPerUser(): ?int | |||
{ | |||
return $this->appliedTo; | |||
return $this->availableQuantityPerUser; | |||
} | |||
public function setAppliedTo(string $appliedTo): self | |||
public function setAvailableQuantityPerUser(int $availableQuantityPerUser): self | |||
{ | |||
$this->appliedTo = $appliedTo; | |||
$this->availableQuantityPerUser = $availableQuantityPerUser; | |||
return $this; | |||
} | |||
/** | |||
* @return Collection|self[] | |||
*/ | |||
public function getUncombinables(): Collection | |||
{ | |||
return $this->uncombinables; | |||
} | |||
public function getPriority(): ?int | |||
public function addUncombinable(self $uncombinable): self | |||
{ | |||
return $this->priority; | |||
if (!$this->uncombinables->contains($uncombinable)) { | |||
$this->uncombinables[] = $uncombinable; | |||
} | |||
return $this; | |||
} | |||
public function setPriority(int $priority): self | |||
public function removeUncombinables(self $uncombinable): self | |||
{ | |||
$this->priority = $priority; | |||
if ($this->uncombinables->contains($uncombinable)) { | |||
$this->uncombinables->removeElement($uncombinable); | |||
} | |||
return $this; | |||
} | |||
public function getUncombinableTypes(): ?array | |||
{ | |||
return $this->uncombinableTypes; | |||
} | |||
public function setUncombinableTypes(?array $uncombinableTypes): self | |||
{ | |||
$this->uncombinableTypes = $uncombinableTypes; | |||
return $this; | |||
} | |||
} |
@@ -0,0 +1,62 @@ | |||
<?php | |||
namespace Lc\ShopBundle\Model; | |||
use Doctrine\ORM\Mapping as ORM; | |||
trait ReductionCartPropertyTrait | |||
{ | |||
/** | |||
* @ORM\Column(type="boolean", nullable=true) | |||
*/ | |||
protected $freeShipping; | |||
/** | |||
* @ORM\Column(type="string", length=25) | |||
*/ | |||
protected $appliedTo; | |||
/** | |||
* @ORM\Column(type="string", length=25) | |||
*/ | |||
protected $type; | |||
public function getFreeShipping(): ?bool | |||
{ | |||
return $this->freeShipping; | |||
} | |||
public function setFreeShipping(?bool $freeShipping): self | |||
{ | |||
$this->freeShipping = $freeShipping; | |||
return $this; | |||
} | |||
public function getAppliedTo(): ?string | |||
{ | |||
return $this->appliedTo; | |||
} | |||
public function setAppliedTo(string $appliedTo): self | |||
{ | |||
$this->appliedTo = $appliedTo; | |||
return $this; | |||
} | |||
public function getType(): ?string | |||
{ | |||
return $this->type; | |||
} | |||
public function setType(string $type): self | |||
{ | |||
$this->type = $type; | |||
return $this; | |||
} | |||
} |
@@ -8,18 +8,28 @@ use Doctrine\ORM\Mapping as ORM; | |||
use Lc\ShopBundle\Context\FilterMerchantInterface; | |||
use Lc\ShopBundle\Context\ReductionCatalogInterface; | |||
use Lc\ShopBundle\Context\ReductionInterface; | |||
use Lc\ShopBundle\Context\ReductionPropertyInterface; | |||
use Lc\ShopBundle\Context\StatusInterface; | |||
use phpDocumentor\Reflection\Types\Integer; | |||
/** | |||
* @ORM\MappedSuperclass() | |||
*/ | |||
abstract class ReductionCatalog extends AbstractDocumentEntity implements ReductionCatalogInterface, FilterMerchantInterface | |||
abstract class ReductionCatalog extends AbstractEntity implements ReductionCatalogInterface, ReductionPropertyInterface, FilterMerchantInterface, StatusInterface | |||
{ | |||
use StatusTrait; | |||
use ReductionTrait; | |||
use ReductionPropertyTrait ; | |||
use ReductionPropertyTrait{ | |||
ReductionPropertyTrait::__construct as private __reductionPropertyConstruct; | |||
} | |||
/** | |||
* @ORM\Column(type="string", length=255) | |||
*/ | |||
protected $title; | |||
/** | |||
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\MerchantInterface", inversedBy="productFamilies") | |||
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\MerchantInterface") | |||
* @ORM\JoinColumn(nullable=false) | |||
*/ | |||
protected $merchant; | |||
@@ -39,26 +49,27 @@ abstract class ReductionCatalog extends AbstractDocumentEntity implements Reduct | |||
*/ | |||
protected $productCategories; | |||
/** | |||
* @ORM\ManyToMany(targetEntity="Lc\ShopBundle\Context\GroupUserInterface") | |||
*/ | |||
protected $groupUsers; | |||
/** | |||
* @ORM\ManyToMany(targetEntity="Lc\ShopBundle\Context\UserInterface") | |||
*/ | |||
protected $users; | |||
public function __construct() | |||
{ | |||
$this->__reductionPropertyConstruct(); | |||
$this->productFamilies = new ArrayCollection(); | |||
$this->groupUsers = new ArrayCollection(); | |||
$this->productCategories = new ArrayCollection(); | |||
$this->users = new ArrayCollection(); | |||
} | |||
public function getTitle(): ?string | |||
{ | |||
return $this->title; | |||
} | |||
public function setTitle(string $title): self | |||
{ | |||
$this->title = $title; | |||
return $this; | |||
} | |||
public function getMerchant(): ?Merchant | |||
{ | |||
return $this->merchant; | |||
@@ -111,31 +122,6 @@ abstract class ReductionCatalog extends AbstractDocumentEntity implements Reduct | |||
return $this; | |||
} | |||
/** | |||
* @return Collection|GroupUser[] | |||
*/ | |||
public function getGroupUsers(): Collection | |||
{ | |||
return $this->groupUsers; | |||
} | |||
public function addGroupUser(GroupUser $groupUser): self | |||
{ | |||
if (!$this->groupUsers->contains($groupUser)) { | |||
$this->groupUsers[] = $groupUser; | |||
} | |||
return $this; | |||
} | |||
public function removeGroupUser(GroupUser $groupUser): self | |||
{ | |||
if ($this->groupUsers->contains($groupUser)) { | |||
$this->groupUsers->removeElement($groupUser); | |||
} | |||
return $this; | |||
} | |||
/** | |||
* @return Collection|ProductCategory[] | |||
@@ -163,42 +149,4 @@ abstract class ReductionCatalog extends AbstractDocumentEntity implements Reduct | |||
return $this; | |||
} | |||
/** | |||
* @return Collection|User[] | |||
*/ | |||
public function getUsers(): Collection | |||
{ | |||
return $this->users; | |||
} | |||
public function addUser(User $user): self | |||
{ | |||
if (!$this->users->contains($user)) { | |||
$this->users[] = $user; | |||
} | |||
return $this; | |||
} | |||
public function removeUser(User $user): self | |||
{ | |||
if ($this->users->contains($user)) { | |||
$this->users->removeElement($user); | |||
} | |||
return $this; | |||
} | |||
/*public function getFromQuantity(): ?int | |||
{ | |||
return $this->fromQuantity; | |||
} | |||
public function setFromQuantity(int $fromQuantity): self | |||
{ | |||
$this->fromQuantity = $fromQuantity; | |||
return $this; | |||
}*/ | |||
} |
@@ -0,0 +1,99 @@ | |||
<?php | |||
namespace Lc\ShopBundle\Model; | |||
use Doctrine\Common\Collections\ArrayCollection; | |||
use Doctrine\Common\Collections\Collection; | |||
use Doctrine\ORM\Mapping as ORM; | |||
use Lc\ShopBundle\Context\FilterMerchantInterface; | |||
use Lc\ShopBundle\Context\ReductionInterface; | |||
use Lc\ShopBundle\Context\ReductionPropertyInterface; | |||
use Lc\ShopBundle\Context\StatusInterface; | |||
/** | |||
* @ORM\MappedSuperclass() | |||
*/ | |||
abstract class ReductionCredit extends AbstractEntity implements ReductionInterface, FilterMerchantInterface, StatusInterface | |||
{ | |||
use ReductionTrait; | |||
use StatusTrait; | |||
/** | |||
* @ORM\Column(type="string", length=255) | |||
*/ | |||
protected $title; | |||
/** | |||
* @ORM\ManyToMany(targetEntity="Lc\ShopBundle\Context\UserInterface") | |||
*/ | |||
protected $users; | |||
/** | |||
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\MerchantInterface") | |||
* @ORM\JoinColumn(nullable=false) | |||
*/ | |||
protected $merchant; | |||
public function __construct() | |||
{ | |||
$this->users = new ArrayCollection(); | |||
} | |||
public function __toString() | |||
{ | |||
return $this->title; | |||
} | |||
public function getTitle(): ?string | |||
{ | |||
return $this->title; | |||
} | |||
public function setTitle(string $title): self | |||
{ | |||
$this->title = $title; | |||
return $this; | |||
} | |||
public function getMerchant(): ?Merchant | |||
{ | |||
return $this->merchant; | |||
} | |||
public function setMerchant(?Merchant $merchant): self | |||
{ | |||
$this->merchant = $merchant; | |||
return $this; | |||
} | |||
/** | |||
* @return Collection|User[] | |||
*/ | |||
public function getUsers(): Collection | |||
{ | |||
return $this->users; | |||
} | |||
public function addUser(User $user): self | |||
{ | |||
if (!$this->users->contains($user)) { | |||
$this->users[] = $user; | |||
} | |||
return $this; | |||
} | |||
public function removeUser(User $user): self | |||
{ | |||
if ($this->users->contains($user)) { | |||
$this->users->removeElement($user); | |||
} | |||
return $this; | |||
} | |||
} |
@@ -2,10 +2,29 @@ | |||
namespace Lc\ShopBundle\Model; | |||
use Doctrine\Common\Collections\ArrayCollection; | |||
use Doctrine\Common\Collections\Collection; | |||
use Doctrine\ORM\Mapping as ORM; | |||
trait ReductionPropertyTrait | |||
{ | |||
/** | |||
* @ORM\ManyToMany(targetEntity="Lc\ShopBundle\Context\UserInterface") | |||
*/ | |||
protected $users; | |||
/** | |||
* @ORM\ManyToMany(targetEntity="Lc\ShopBundle\Context\GroupUserInterface") | |||
*/ | |||
protected $groupUsers; | |||
/** | |||
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\MerchantInterface", inversedBy="productFamilies") | |||
* @ORM\JoinColumn(nullable=false) | |||
*/ | |||
protected $merchant; | |||
/** | |||
* @ORM\Column(type="datetime", nullable=true) | |||
*/ | |||
@@ -22,6 +41,79 @@ trait ReductionPropertyTrait | |||
protected $permanent; | |||
public function __construct() | |||
{ | |||
$this->users = new ArrayCollection(); | |||
$this->groupUsers = new ArrayCollection(); | |||
} | |||
public function getMerchant(): ?Merchant | |||
{ | |||
return $this->merchant; | |||
} | |||
public function setMerchant(?Merchant $merchant): self | |||
{ | |||
$this->merchant = $merchant; | |||
return $this; | |||
} | |||
/** | |||
* @return Collection|User[] | |||
*/ | |||
public function getUsers(): Collection | |||
{ | |||
return $this->users; | |||
} | |||
public function addUser(User $user): self | |||
{ | |||
if (!$this->users->contains($user)) { | |||
$this->users[] = $user; | |||
} | |||
return $this; | |||
} | |||
public function removeUser(User $user): self | |||
{ | |||
if ($this->users->contains($user)) { | |||
$this->users->removeElement($user); | |||
} | |||
return $this; | |||
} | |||
/** | |||
* @return Collection|GroupUser[] | |||
*/ | |||
public function getGroupUsers(): Collection | |||
{ | |||
return $this->groupUsers; | |||
} | |||
public function addGroupUser(GroupUser $groupUser): self | |||
{ | |||
if (!$this->groupUsers->contains($groupUser)) { | |||
$this->groupUsers[] = $groupUser; | |||
} | |||
return $this; | |||
} | |||
public function removeGroupUser(GroupUser $groupUser): self | |||
{ | |||
if ($this->groupUsers->contains($groupUser)) { | |||
$this->groupUsers->removeElement($groupUser); | |||
} | |||
return $this; | |||
} | |||
public function getDateStart(): ?\DateTimeInterface | |||
{ | |||
return $this->dateStart; |
@@ -46,10 +46,6 @@ abstract class User extends UserModelFOS | |||
*/ | |||
protected $orders; | |||
/** | |||
* @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\CartInterface", mappedBy="user") | |||
*/ | |||
protected $carts; | |||
/** | |||
* @ORM\Column(type="string", length=64, nullable=true) | |||
@@ -93,7 +89,6 @@ abstract class User extends UserModelFOS | |||
$this->creditHistories = new ArrayCollection(); | |||
$this->addresses = new ArrayCollection(); | |||
$this->orders = new ArrayCollection(); | |||
$this->carts = new ArrayCollection(); | |||
$this->groupUsers = new ArrayCollection(); | |||
$this->newsletters = new ArrayCollection(); | |||
$this->favoriteProductFamilies = new ArrayCollection(); | |||
@@ -241,37 +236,6 @@ abstract class User extends UserModelFOS | |||
return $this; | |||
} | |||
/** | |||
* @return Collection|Cart[] | |||
*/ | |||
public function getCarts(): Collection | |||
{ | |||
return $this->carts; | |||
} | |||
public function addCart(Cart $cart): self | |||
{ | |||
if (!$this->carts->contains($cart)) { | |||
$this->carts[] = $cart; | |||
$cart->setUser($this); | |||
} | |||
return $this; | |||
} | |||
public function removeCart(Cart $cart): self | |||
{ | |||
if ($this->carts->contains($cart)) { | |||
$this->carts->removeElement($cart); | |||
// set the owning side to null (unless already changed) | |||
if ($cart->getUser() === $this) { | |||
$cart->setUser(null); | |||
} | |||
} | |||
return $this; | |||
} | |||
public function getFirstname(): ?string | |||
{ | |||
return $this->firstname; |
@@ -0,0 +1,22 @@ | |||
<?php | |||
namespace Lc\ShopBundle\Repository; | |||
use Lc\ShopBundle\Context\DefaultRepositoryInterface; | |||
use Lc\ShopBundle\Context\GroupUserInterface; | |||
use Lc\ShopBundle\Context\UnitInterface; | |||
/** | |||
* @method GroupUserInterface|null find($id, $lockMode = null, $lockVersion = null) | |||
* @method GroupUserInterface|null findOneBy(array $criteria, array $orderBy = null) | |||
* @method GroupUserInterface[] findAll() | |||
* @method GroupUserInterface[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) | |||
*/ | |||
class GroupUserRepository extends BaseRepository implements DefaultRepositoryInterface | |||
{ | |||
public function getInterfaceClass() | |||
{ | |||
return GroupUserInterface::class; | |||
} | |||
} |
@@ -0,0 +1,25 @@ | |||
<?php | |||
namespace Lc\ShopBundle\Repository; | |||
use Lc\ShopBundle\Context\DefaultRepositoryInterface; | |||
use Lc\ShopBundle\Context\OrderReductionCartInterface; | |||
use Lc\ShopBundle\Context\OrderReductionCreditInterface; | |||
use Lc\ShopBundle\Context\OrderStatusInterface; | |||
/** | |||
* @method OrderReductionCartInterface|null find($id, $lockMode = null, $lockVersion = null) | |||
* @method OrderReductionCartInterface|null findOneBy(array $criteria, array $orderBy = null) | |||
* @method OrderReductionCartInterface[] findAll() | |||
* @method OrderReductionCartInterface[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) | |||
*/ | |||
class OrderReductionCartRepository extends BaseRepository implements DefaultRepositoryInterface | |||
{ | |||
public function getInterfaceClass() | |||
{ | |||
return OrderReductionCartInterface::class; | |||
} | |||
} |
@@ -0,0 +1,22 @@ | |||
<?php | |||
namespace Lc\ShopBundle\Repository; | |||
use Lc\ShopBundle\Context\DefaultRepositoryInterface; | |||
use Lc\ShopBundle\Context\OrderReductionCreditInterface; | |||
use Lc\ShopBundle\Context\OrderStatusInterface; | |||
/** | |||
* @method OrderReductionCreditInterface|null find($id, $lockMode = null, $lockVersion = null) | |||
* @method OrderReductionCreditInterface|null findOneBy(array $criteria, array $orderBy = null) | |||
* @method OrderReductionCreditInterface[] findAll() | |||
* @method OrderReductionCreditInterface[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) | |||
*/ | |||
class OrderReductionCreditRepository extends BaseRepository implements DefaultRepositoryInterface | |||
{ | |||
public function getInterfaceClass() | |||
{ | |||
return OrderReductionCreditInterface::class; | |||
} | |||
} |
@@ -81,4 +81,5 @@ class OrderShopRepository extends BaseRepository implements DefaultRepositoryInt | |||
->andWhere('SIZE(e.orderStatusHistories) '.$operator.' 0') ; | |||
} | |||
//getValidOrders() | |||
} |
@@ -0,0 +1,21 @@ | |||
<?php | |||
namespace Lc\ShopBundle\Repository; | |||
use Lc\ShopBundle\Context\DefaultRepositoryInterface; | |||
use Lc\ShopBundle\Context\OrderStatusInterface; | |||
/** | |||
* @method OrderStatusInterface|null find($id, $lockMode = null, $lockVersion = null) | |||
* @method OrderStatusInterface|null findOneBy(array $criteria, array $orderBy = null) | |||
* @method OrderStatusInterface[] findAll() | |||
* @method OrderStatusInterface[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) | |||
*/ | |||
class OrderStatusRepository extends BaseRepository implements DefaultRepositoryInterface | |||
{ | |||
public function getInterfaceClass() | |||
{ | |||
return OrderStatusInterface::class; | |||
} | |||
} |
@@ -0,0 +1,49 @@ | |||
<?php | |||
namespace Lc\ShopBundle\Repository; | |||
use Lc\ShopBundle\Context\DefaultRepositoryInterface; | |||
use Lc\ShopBundle\Context\ReductionCartInterface; | |||
/** | |||
* @method ReductionCartInterface|null find($id, $lockMode = null, $lockVersion = null) | |||
* @method ReductionCartInterface|null findOneBy(array $criteria, array $orderBy = null) | |||
* @method ReductionCartInterface[] findAll() | |||
* @method ReductionCartInterface[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) | |||
*/ | |||
class ReductionCartRepository extends BaseRepository implements DefaultRepositoryInterface | |||
{ | |||
public function getInterfaceClass() | |||
{ | |||
return ReductionCartInterface::class; | |||
} | |||
public function getValuesOfFieldType(){ | |||
$query = $this->findByMerchantQuery() ; | |||
$query->select('DISTINCT e.type'); | |||
$query->andWhere('e.status = 1'); | |||
return $query->getQuery()->getResult() ; | |||
} | |||
public function getValuesOfFieldCode(){ | |||
$query = $this->findByMerchantQuery() ; | |||
$query->select('DISTINCT e.codes'); | |||
$query->andWhere('e.status = 1'); | |||
return $query->getQuery()->getResult() ; | |||
} | |||
public function getEligibleReductionCart($order) | |||
{ | |||
$query = $this->findByMerchantQuery() ; | |||
$query->andWhere('e.status = 1'); | |||
return $query->getQuery()->getResult(); | |||
} | |||
} |
@@ -0,0 +1,31 @@ | |||
<?php | |||
namespace Lc\ShopBundle\Repository; | |||
use Lc\ShopBundle\Context\DefaultRepositoryInterface; | |||
use Lc\ShopBundle\Context\ReductionCreditInterface; | |||
/** | |||
* @method ReductionCreditInterface|null find($id, $lockMode = null, $lockVersion = null) | |||
* @method ReductionCreditInterface|null findOneBy(array $criteria, array $orderBy = null) | |||
* @method ReductionCreditInterface[] findAll() | |||
* @method ReductionCreditInterface[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) | |||
*/ | |||
class ReductionCreditRepository extends BaseRepository implements DefaultRepositoryInterface | |||
{ | |||
public function getInterfaceClass() | |||
{ | |||
return ReductionCreditInterface::class; | |||
} | |||
public function getReductionCreditByUser($user){ | |||
$query = $this->findByMerchantQuery() ; | |||
$query->andWhere('e.status = 1'); | |||
$query->andWhere(':user MEMBER OF e.users'); | |||
$query->setParameter('user', $user); | |||
return $query->getQuery()->getResult() ; | |||
} | |||
} |
@@ -4,6 +4,25 @@ body{font-size: 0.9rem;} | |||
.hidden{display: none;} | |||
.select2-container--default .select2-results__option[aria-disabled=true] { | |||
display: none; | |||
} | |||
.field-collection-item-action { | |||
font-size: 2rem; | |||
font-weight: bold; | |||
margin-left: 4px; | |||
width: 7%; | |||
text-align: center; | |||
display:inline-block; | |||
line-height: 2.2rem; | |||
} | |||
.field-collection-item-row .form-control { | |||
width: 92%; float: left; | |||
} | |||
#lc-flash-messages{display: none;} | |||
.main-sidebar .logo-long{padding: 8px 0; text-align: center;} | |||
.main-sidebar .logo-long img{height: 40px; display: inline-block;} | |||
.sidebar-collapse .main-sidebar .logo-long span{display: none;} |
@@ -1,9 +1,16 @@ | |||
jQuery(document).ready(function () { | |||
custom_switch_merchants(); | |||
initAdminLtePlugin(); | |||
initButtonConfirm() ; | |||
initButtonConfirm() | |||
initNotice(); | |||
}); | |||
function initNotice() { | |||
$('#lc-flash-messages .notice').each(function(i, notice){ | |||
generateNotice($(notice).find('.type').html(), $(notice).find('.message').html()); | |||
}); | |||
} | |||
function initButtonConfirm() { | |||
$('.btn-confirm-js').click(function() { | |||
return confirm('Êtes-vous sûr de vouloir réaliser cette action ?') ; | |||
@@ -54,7 +61,6 @@ function initAdminLtePlugin() { | |||
if ($('.select2, select.form-control').length) { | |||
$('form .form-widget>select.form-control, .select2').each(function (i, elm) { | |||
log($(elm)) | |||
if(!$(this).hasClass('disable-select2')) { | |||
setSelect2($(elm)) ; | |||
} | |||
@@ -136,7 +142,7 @@ function checkForm(){ | |||
} | |||
} | |||
function setSelect2($select) { | |||
function setSelect2($select ) { | |||
if (typeof $select.data('select2-id') === 'undefined') { | |||
$select.data('init', 'set') | |||
@@ -165,6 +171,10 @@ function setSelect2($select) { | |||
var event = new Event('change'); | |||
e.target.dispatchEvent(event); | |||
}); | |||
myselect.on('select2:unselect', function (e) { | |||
var event = new Event('change'); | |||
e.target.dispatchEvent(event); | |||
}); | |||
return myselect; | |||
} |
@@ -129,7 +129,7 @@ let mixinPrice = { | |||
quantityUpdated: function () { | |||
this.quantity = formatNumberWithoutFixed(this.quantity) | |||
if(this.quantity) { | |||
if (this.quantity) { | |||
if (this.behaviorPriceValue == 'by-piece') { | |||
this.setBuyingPriceByRefUnit(); | |||
this.setBuyingPriceByRefUnitWithTax(); | |||
@@ -232,8 +232,8 @@ let mixinPrice = { | |||
setPriceFromPriceWithTax: function () { | |||
this.price = getPrice(this.priceWithTax, this.taxRateValue); | |||
}, | |||
emptyPrice:function () { | |||
this.price=null; | |||
emptyPrice: function () { | |||
this.price = null; | |||
this.priceInherited = true; | |||
} | |||
}, | |||
@@ -330,15 +330,76 @@ let mixinReduction = { | |||
data() { | |||
return Object.assign({ | |||
reductionActive: true, | |||
reductionUnit:null, | |||
reductionBehaviorTaxRate:null, | |||
reductionValue:null, | |||
reductionUnit: null, | |||
reductionBehaviorTaxRate: null, | |||
reductionValue: null, | |||
reductionPermanent: true, | |||
reductionUsersActive: false, | |||
reductionUsers: [], | |||
reductionGroupUsersActive: false, | |||
reductionGroupUsers: [], | |||
reductionSuppliersActive: false, | |||
reductionSuppliers: [], | |||
reductionProductCategoriesActive: false, | |||
reductionProductFamiliesActive:false | |||
reductionProductCategories: [], | |||
reductionProductFamiliesActive: false, | |||
reductionProductFamilies: [] | |||
}, window.mixinReductionValues); | |||
}, | |||
mounted: function () { | |||
}, | |||
methods: { | |||
emptySelect2: function (refField) { | |||
this[refField] = []; | |||
$(this.$refs[refField]).trigger('change'); | |||
}, | |||
filterOn: function (values, refFiltered, dataFilter, filterType, selectedWay = false) { | |||
if (values.length > 0) { | |||
this[refFiltered] = []; | |||
$(this.$refs[refFiltered]).val(false).trigger('change'); | |||
$(this.$refs[refFiltered]).find('option').prop('disabled', !selectedWay); | |||
app = this; | |||
values.forEach(function (val) { | |||
if (filterType == 'array') { | |||
$(app.$refs[refFiltered]).find('option[data-' + dataFilter + '*="_' + val + '_"').prop('disabled', selectedWay); | |||
} else { | |||
$(app.$refs[refFiltered]).find('option[data-' + dataFilter + '="' + val + '"').prop('disabled', selectedWay); | |||
} | |||
}); | |||
} else { | |||
$(this.$refs[refFiltered]).find('option').prop('disabled', false); | |||
} | |||
select = setSelect2($(this.$refs[refFiltered])) | |||
} | |||
}, | |||
watch: { | |||
reductionGroupUsersActive:function(){ | |||
this.emptySelect2('reductionGroupUsers'); | |||
}, | |||
reductionGroupUsers: function () { | |||
this.filterOn(this.reductionGroupUsers, 'reductionUsers', 'group-users', 'array'); | |||
}, | |||
reductionUsersActive:function(){ | |||
this.emptySelect2('reductionUsers'); | |||
}, | |||
reductionSuppliersActive:function(){ | |||
this.emptySelect2('reductionSuppliers'); | |||
}, | |||
reductionSuppliers: function () { | |||
this.filterOn(this.reductionSuppliers, 'reductionProductFamilies', 'supplier', 'string'); | |||
}, | |||
reductionProductCategoriesActive:function(){ | |||
this.emptySelect2('reductionProductCategories'); | |||
}, | |||
reductionProductFamiliesActive:function(){ | |||
this.emptySelect2('reductionProductFamilies'); | |||
}, | |||
} | |||
}; |
@@ -126,6 +126,12 @@ appOrder = new Vue({ | |||
updateOrderDeliveryAvailability:function(){ | |||
this.postForm('#orderDeliveryAvailabilityForm', '#modal-order-delivery-availability'); | |||
}, | |||
addOrderReductionCart:function(){ | |||
this.postForm('#orderReductionCartForm', '#modal-reduction-cart'); | |||
}, | |||
addOrderReductionCredit:function(){ | |||
this.postForm('#orderReductionCreditForm', '#modal-reduction-credit'); | |||
}, | |||
postForm:function(formId, modalId){ | |||
var app = this; | |||
this.isLoading = true; |
@@ -0,0 +1,69 @@ | |||
appReductionCart = new Vue({ | |||
el: '#lc-reduction-cart-edit', | |||
delimiters: ['${', '}'], | |||
mixins: [mixinReduction], | |||
data() { | |||
return Object.assign( | |||
{ | |||
reductionCombinable:true, | |||
reductionUncombinableTypes:[], | |||
reductionUncombinables:[], | |||
reductionPointSalesActive: false, | |||
reductionPointSales: [], | |||
reductionDeliveryZonesActive:false, | |||
reductionDeliveryZones:[], | |||
reductionDeliverySlotsActive:false, | |||
reductionDeliverySlots:[], | |||
reductionAppliedTo: null, | |||
currentSection: 'info', | |||
sectionsArray: [ | |||
{ | |||
name: 'info', | |||
nameDisplay: 'Info' | |||
}, | |||
{ | |||
name: 'conditions', | |||
nameDisplay: 'Conditions ' | |||
}, | |||
{ | |||
name: 'actions', | |||
nameDisplay: 'Actions' | |||
} | |||
] | |||
}, window.reductionCartValues); | |||
}, | |||
mounted: function () { | |||
log(window.reductionCartValues ); | |||
this.isMounted = true; | |||
}, | |||
methods: { | |||
changeSection: function (section) { | |||
this.currentSection = section.name; | |||
}, | |||
updateCodes:function (e) { | |||
if( window.reductionCartCodesUsed.indexOf($(e.target).val().toUpperCase())!=-1){ | |||
e.target.setCustomValidity("Invalid field."); | |||
}else{ | |||
e.target.setCustomValidity(""); | |||
} | |||
} | |||
}, | |||
watch: { | |||
reductionDeliveryZonesActive:function(){ | |||
this.emptySelect2('reductionDeliveryZones'); | |||
}, | |||
reductionDeliveryZones:function(){ | |||
this.filterOn(this.reductionDeliveryZones, 'reductionDeliverySlots', 'delivery-zone', 'array'); | |||
}, | |||
reductionDeliverySlotsActive:function(){ | |||
this.emptySelect2('reductionDeliverySlots'); | |||
}, | |||
reductionPointSalesActive:function(){ | |||
this.emptySelect2('reductionPointSales'); | |||
}, | |||
reductionUncombinableTypes: function () { | |||
this.filterOn(this.reductionUncombinableTypes, 'reductionUncombinables', 'type', 'string', true); | |||
} | |||
} | |||
}); |
@@ -10,10 +10,6 @@ list: | |||
delete: Supprimer | |||
send: Envoyer | |||
product: | |||
title: Titre | |||
titleHelp: Un message d'aide | |||
group: | |||
main: Général | |||
address: Adresse | |||
@@ -39,6 +35,10 @@ group: | |||
ReductionCatalog: | |||
info: Informations principal | |||
conditions: Condictions d'application | |||
ReductionCart: | |||
info: Informations | |||
conditions: Conditions d'applications | |||
actions: Actions | |||
OrderShop: | |||
resume: Résumé de commande | |||
addProduct: Ajout de produit à la commande | |||
@@ -46,6 +46,18 @@ None: Aucune valeur | |||
label.form.empty_value: Choisissez une option | |||
form.label.delete: Supprimer l'image | |||
field: | |||
error: | |||
reductionCart: | |||
date: La réduction n'est plus active | |||
pointSale: L'ambassade ne correspond pas | |||
deliveryZone: La zone de livraison ne correspond pas | |||
deliverySlot: La créneau de livraison ne correspond pas | |||
groupUser: Le(s) groupe(s) utilisateurs ne correspondent pas | |||
user: L'utilisateur ne correspond pas | |||
combinable: La réduction n'est pas cumulable avec celle dejà appliqué | |||
amountMin: Le montant minimum de commandes n'est pas respecté | |||
qauntity: La réduction n'est plus disponible | |||
quantityPerUser: La reduction n'est plus disponible pour cet utilisateur | |||
default: | |||
placeholder: Choisissez une option | |||
deliveryPointSale: Lieu de livraison | |||
@@ -189,6 +201,14 @@ field: | |||
simple: Simple | |||
multiple: Multiple | |||
activeReductionCatalog: Appliquer une réduction sur ce produit | |||
Reduction: | |||
usersActive: Filtrer sur les utilisateurs | |||
groupUsersActive: Filtrer sur les groupes d'utilisateurs | |||
suppliersActive: Filtrer sur les producteurs | |||
productCategoriesActive: Filtrer sur les catégories | |||
productCategories: Appliquer aux catégories | |||
productFamiliesActive: Filtrer sur les produits | |||
pointSalesActive: Filtrer sur les ambassades | |||
ReductionCatalog: | |||
fromQuantity: À partir de la quantité | |||
fromQuantityHelp: Par défaut une réduction est apliqué à partir de 1 | |||
@@ -196,21 +216,27 @@ field: | |||
value: Montant ou valeur | |||
permanent: Réduction permanante | |||
dateRange: Date de but et date de fin | |||
usersActive: Filtrer sur les utilisateurs | |||
users: Appliquer aux utilisateurs | |||
groupUsersActive: Filtrer sur les groupes d'utilisateurs | |||
groupUsers: Appliquer aux groupes d'utilisateurs | |||
suppliersActive: Filtrer sur les producteurs | |||
suppliers: Appliquer aux producteurs | |||
productCategoriesActive: Filtrer sur les catégories | |||
productCategories: Appliquer aux catégories | |||
productFamiliesActive: Filtrer sur les produits | |||
productFamilies: Appliquer aux produits | |||
ReductionCart: | |||
type: Type de réduction | |||
typeOptions: | |||
shipping: Livraisons | |||
sponsorship: Parrainage | |||
employees: Employées | |||
availableQuantity: Quantité disponible | |||
availableQuantityPerUser: Quantité disponible par utilisateur | |||
codes: Codes | |||
orderAmountMinHelp: Montant en TTC | |||
combinable: Cumulables aves toutes les réductions | |||
uncombinableTypes: Cumulables sauf avec les types de réductions | |||
uncombinables: Et sauf avec les réductions | |||
value: Montant ou valeur | |||
appliedTo: Appliquer aux | |||
freeShipping: Frais de livraisons offert | |||
appliedToOptions: | |||
order: Montant de la commandes | |||
shipping: Frais de livraisons | |||
unit: Unité | |||
Address: | |||
city: Commune | |||
OrderShop: |
@@ -0,0 +1,16 @@ | |||
{% if app.session is not null and app.session.started %} | |||
{% set _flash_messages = app.session.flashbag.all %} | |||
{% if _flash_messages|length > 0 %} | |||
<div id="lc-flash-messages"> | |||
{% for label, messages in _flash_messages %} | |||
{% for message in messages %} | |||
<div class="notice"> | |||
<span class="type">{{ label }}</span> | |||
<span class="message"> {{ message|trans|striptags }}</span> | |||
</div> | |||
{% endfor %} | |||
{% endfor %} | |||
</div> | |||
{% endif %} | |||
{% endif %} |
@@ -10,19 +10,20 @@ | |||
</div> | |||
<div class="card-body {{ fullWidth == true ? 'p-0' : 'row' }}"> | |||
{% endmacro %} | |||
{% endmacro startCard %} | |||
{% macro cardOverlay(attr) %} | |||
{% macro cardOverlay(attr) %} | |||
</div> | |||
<div v-if="{{ attr }}==true" class="overlay"> | |||
<i class="fas fa-2x fa-sync-alt"></i> | |||
</div> | |||
{% endmacro %} | |||
{% macro endCard(noCol = false) %} | |||
<div v-if="{{ attr }}==true" class="overlay"> | |||
<i class="fas fa-2x fa-sync-alt"></i> | |||
</div> | |||
{% endmacro cardOverlay %} | |||
{% macro endCard(noCol = false) %} | |||
</div> | |||
</div> | |||
{% if noCol == false %}</div>{% endif %} | |||
{% endmacro %} | |||
{% endmacro endCard %} | |||
{% macro productField(colspan, field, fieldName, fieldDisplay = false, displaySuffix="",attr="") %} | |||
@@ -47,7 +48,6 @@ | |||
{% endmacro %} | |||
{% macro priceField(field, fieldTax, fieldName, behaviorPriceValue) %} | |||
<div class="form-group field-price col-12" v-show="behaviorPrice == '{{ behaviorPriceValue }}'"> | |||
<div class="row"> | |||
<div class="col-12"> | |||
@@ -80,32 +80,24 @@ | |||
{% endmacro %} | |||
{% macro reductionCatalogForm(form) %} | |||
{{ _self.startCard(6, 'ReductionCatalog.info') }} | |||
<div class="col-12"> | |||
{{ form_row(form.title) }} | |||
</div> | |||
{# <div class="col-12"> | |||
{{ form_row(form.fromQuantity) }} | |||
</div> | |||
#} | |||
<div class="col-12"> | |||
{{ form_row(form.behaviorTaxRate, {"attr" : {":required": "reductionActive", 'v-model' : 'reductionBehaviorTaxRate'}}) }} | |||
</div> | |||
<div class="col-12"> | |||
{{ form_row(form.unit, {"attr" : {":required": "reductionActive", 'v-model' : 'reductionUnit'}}) }} | |||
</div> | |||
{% macro fieldReductionList(form, field, filterOn = false, filterType='string') %} | |||
<div class="col-12"> | |||
{{ form_row(form.value, {"attr" : {":required": "reductionActive", 'v-model' : 'reductionValue'}}) }} | |||
<div class="form-group"> | |||
<div class="form-group"> | |||
{{ form_widget(attribute(form, field~'Active'), {"attr" : {'v-model' : 'reduction'~field|uc_first~'Active' } }) }} | |||
</div> | |||
<div class="form-widget" v-show="reduction{{ field|uc_first }}Active == true"> | |||
{% set attr = { | |||
'ref' : 'reduction'~field|uc_first , | |||
'v-model' : 'reduction'~field|uc_first | |||
} %} | |||
{{ form_widget(attribute(form, field), {"attr" : attr }) }} | |||
</div> | |||
</div> | |||
</div> | |||
{% endmacro fieldReductionList %} | |||
{{ _self.endCard() }} | |||
{{ _self.startCard(6, 'ReductionCatalog.conditions','success') }} | |||
{% macro fieldReductionDateRange(form) %} | |||
<div class="col-12"> | |||
<div class="form-group"> | |||
<div class="form-group"> | |||
@@ -124,81 +116,89 @@ | |||
</div> | |||
</div> | |||
<div class="col-12"> | |||
{% endmacro fieldReductionDateRange %} | |||
{% macro fieldReductionValue(form) %} | |||
<div class="col-6"> | |||
<div class="form-group"> | |||
<div class="form-group"> | |||
{{ form_widget(form.usersActive, {"attr" : {'v-model' : 'reductionUsersActive' } }) }} | |||
</div> | |||
<div class="form-widget" v-show="reductionUsersActive == true"> | |||
{{ form_widget(form.users) }} | |||
{{ form_label(form.value) }} | |||
<div class="input-group"> | |||
{{ form_widget(form.value, {"attr" : {":required": "reductionActive", 'v-model' : 'reductionValue'}}) }} | |||
<div class="input-group-append"> | |||
<span class="input-group-text"> | |||
<span v-if="reductionUnit =='amount'">€</span> | |||
<span v-else-if="reductionUnit =='percent'">%</span> | |||
</span> | |||
</div> | |||
</div> | |||
</div> | |||
</div> | |||
{% endmacro fieldReductionValue %} | |||
{% macro fieldReductionBehaviorTaxRate(form) %} | |||
<div class="col-6" :class="reductionUnit == 'amount' ? '' : 'hidden'"> | |||
{{ form_row(form.behaviorTaxRate, {"attr" : {":required": "reductionActive && reductionUnit=='amount'", 'v-model' : 'reductionBehaviorTaxRate'}}) }} | |||
</div> | |||
{% endmacro fieldReductionBehaviorTaxRate %} | |||
{% macro fieldReductionUnit(form) %} | |||
<div class="col-12"> | |||
<div class="form-group"> | |||
<div class="form-group"> | |||
{{ form_widget(form.groupUsersActive, {"attr" : {'v-model' : 'reductionGroupUsersActive' } }) }} | |||
</div> | |||
<div class="form-widget" v-show="reductionGroupUsersActive == true"> | |||
{{ form_widget(form.groupUsers) }} | |||
</div> | |||
{{ form_label(form.unit) }} | |||
{% for field in form.unit %} | |||
{{ form_widget(field, {"attr" : {":required": "reductionActive", "v-model" : 'reductionUnit'}}) }} | |||
{% endfor %} | |||
</div> | |||
</div> | |||
{% endmacro fieldReductionUnit %} | |||
{% macro reductionCatalogForm(form) %} | |||
{{ _self.startCard(6, 'ReductionCatalog.info') }} | |||
<div class="col-12"> | |||
{{ form_row(form.title) }} | |||
</div> | |||
{{ _self.fieldReductionUnit(form) }} | |||
{{ _self.fieldReductionValue(form) }} | |||
{{ _self.fieldReductionBehaviorTaxRate(form) }} | |||
{{ _self.endCard() }} | |||
{{ _self.startCard(6, 'ReductionCatalog.conditions','success') }} | |||
{{ _self.fieldReductionDateRange(form) }} | |||
{{ _self.fieldReductionList(form, 'groupUsers') }} | |||
{{ _self.fieldReductionList(form, 'users') }} | |||
{% if form.suppliers is defined %} | |||
<div class="col-12"> | |||
<div class="form-group"> | |||
<div class="form-group"> | |||
{{ form_widget(form.suppliersActive, {"attr" : {'v-model' : 'reductionSuppliersActive' } }) }} | |||
</div> | |||
<div class="form-widget" v-show="reductionSuppliersActive == true"> | |||
{{ form_widget(form.suppliers) }} | |||
</div> | |||
</div> | |||
</div> | |||
{{ _self.fieldReductionList(form, 'suppliers') }} | |||
{% endif %} | |||
{% if form.productCategories is defined %} | |||
<div class="col-12"> | |||
<div class="form-group"> | |||
<div class="form-group"> | |||
{{ form_widget(form.productCategoriesActive, {"attr" : {'v-model' : 'reductionProductCategoriesActive' } }) }} | |||
</div> | |||
<div class="form-widget" v-show="reductionProductCategoriesActive == true"> | |||
{{ form_widget(form.productCategories) }} | |||
</div> | |||
</div> | |||
</div> | |||
{{ _self.fieldReductionList(form, 'productCategories') }} | |||
{% endif %} | |||
{% if form.productFamilies is defined %} | |||
<div class="col-12"> | |||
<div class="form-group"> | |||
<div class="form-group"> | |||
{{ form_widget(form.productFamiliesActive, {"attr" : {'v-model' : 'reductionProductFamiliesActive' } }) }} | |||
</div> | |||
<div class="form-widget" v-show="reductionProductFamiliesActive == true"> | |||
{{ form_widget(form.productFamilies) }} | |||
</div> | |||
</div> | |||
</div> | |||
{{ _self.fieldReductionList(form, 'productFamilies') }} | |||
{% endif %} | |||
{{ _self.endCard() }} | |||
{% endmacro %} | |||
{% endmacro reductionCatalogForm %} | |||
{% macro reductionCatalogFormValues(formValues, isProductFamilyForm= false) %} | |||
<script> | |||
window.mixinReductionValues = { | |||
{% if formValues.status == false and isProductFamilyForm %}reductionActive: false,{% endif %} | |||
{% if formValues.permanent is not null and formValues.permanent == false %}reductionPermanent: false,{% endif %} | |||
{% if formValues.behaviorTaxRate %}reductionBehaviorTaxRate: '{{ formValues.behaviorTaxRate }}',{% endif %} | |||
{% if formValues.value %}reductionValue: parseFloat({{ formValues.value }}),{% endif %} | |||
{% if formValues.unit %}reductionUnit: "{{ formValues.unit }}",{% endif %} | |||
{% if formValues.users is not empty %}reductionUsersActive: true,{% endif %} | |||
{% if formValues.groupUsers is not empty %}reductionGroupUsersActive: true,{% endif %} | |||
{% if formValues.productFamilies is not empty %}reductionProductFamiliesActive: true,{% endif %} | |||
{% if formValues.productCategories is not empty %}reductionProductCategoriesActive: true,{% endif %} | |||
{% if formValues.suppliers is not empty %}reductionSuppliersActive: true,{% endif %} | |||
} | |||
</script> | |||
{% endmacro %} | |||
<script> | |||
window.mixinReductionValues = { | |||
{% if formValues.status == false and isProductFamilyForm %}reductionActive: false,{% endif %} | |||
{% if formValues.permanent is not null and formValues.permanent == false %}reductionPermanent: false,{% endif %} | |||
{% if formValues.behaviorTaxRate %}reductionBehaviorTaxRate: '{{ formValues.behaviorTaxRate }}',{% endif %} | |||
{% if formValues.value %}reductionValue: parseFloat({{ formValues.value }}),{% endif %} | |||
{% if formValues.unit %}reductionUnit: "{{ formValues.unit }}",{% endif %} | |||
{% if formValues.groupUsers is not empty %}reductionGroupUsersActive: true,{% endif %} | |||
{% if formValues.groupUsers is not empty %}reductionGroupUsers: {{ formValues.groupUsers|json_encode }},{% endif %} | |||
{% if formValues.users is not empty %}reductionUsersActive: true,{% endif %} | |||
{% if formValues.users is not empty %}reductionUsers: {{ formValues.users|json_encode }},{% endif %} | |||
{% if formValues.suppliers is not empty %}reductionSuppliersActive: true,{% endif %} | |||
{% if formValues.suppliers is not empty %}reductionSuppliers: {{ formValues.suppliers|json_encode }},{% endif %} | |||
{% if formValues.productFamilies is not empty %}reductionProductFamiliesActive: true,{% endif %} | |||
{% if formValues.productFamilies is not empty %}reductionProductFamilies: {{ formValues.productFamilies|json_encode }},{% endif %} | |||
{% if formValues.productCategories is not empty %}reductionProductCategoriesActive: true,{% endif %} | |||
{% if formValues.productCategories is not empty %}reductionProductCategories: {{ formValues.productCategories|json_encode }},{% endif %} | |||
} | |||
</script> | |||
{% endmacro reductionCatalogFormValues %} |
@@ -154,7 +154,7 @@ | |||
<div class="content-wrapper"> | |||
{% block flash_messages %} | |||
{{ include(_entity_config is defined ? _entity_config.templates.flash_messages : '@EasyAdmin/default/flash_messages.html.twig') }} | |||
{% include '@LcShop/backend/default/block/flash_messages.html.twig' %} | |||
{% endblock flash_messages %} | |||
{% block content_header_wrapper %} |
@@ -5,6 +5,13 @@ | |||
<div class="col-4"> | |||
<h6><strong>{{ "field.OrderShop.mainInfo"|trans({}, 'lcshop') }} : </strong></h6> | |||
<p> | |||
<strong>{{ "field.OrderShop.status"|trans }} </strong><br /> | |||
<span>${order.orderStatus}</span> | |||
<button type="button" class="btn btn-default" data-toggle="modal" data-target="#modal-order-status"> | |||
{{ "action.edit"|trans }} | |||
</button> | |||
</p> | |||
<p> | |||
<strong>{{ "field.OrderShop.user"|trans }} </strong><br /> | |||
<span>${order.user}</span> | |||
@@ -74,6 +81,17 @@ | |||
<script> | |||
window.orderObject = {{ order|json_encode|raw }}; | |||
</script> | |||
<h6><strong>Réductions</strong></h6> | |||
${order.orderReductionCart} | |||
<button type="button" class="btn btn-default" data-toggle="modal" data-target="#modal-reduction-cart"> | |||
{{ "action.addReductionCart"|trans }} | |||
</button> | |||
<br /> | |||
${order.orderReductionCredit} | |||
<button type="button" class="btn btn-default" data-toggle="modal" data-target="#modal-reduction-credit"> | |||
{{ "action.addReductionCredit"|trans }} | |||
</button> | |||
</div> | |||
@@ -16,7 +16,9 @@ | |||
{% include '@LcShop/backend/order/modal_invoiceaddress.html.twig' %} | |||
{% include '@LcShop/backend/order/modal_deliveryaddress.html.twig' %} | |||
{% include '@LcShop/backend/order/modal_deliveryavailability.html.twig' %} | |||
{% include '@LcShop/backend/order/modal_orderstatus.html.twig' %} | |||
{% include '@LcShop/backend/order/modal_reductioncart.html.twig' %} | |||
{% include '@LcShop/backend/order/modal_reductioncredit.html.twig' %} | |||
{{ macros.endCard }} | |||
</div> | |||
</div> |
@@ -1,3 +1,4 @@ | |||
{% trans_default_domain 'lcshop' %} | |||
<div class="modal fade show" id="modal-order-delivery-address"> | |||
{{ form_start(form_order_delivery_address, {'attr': { 'id' : 'orderDeliveryAddressForm'}}) }}) }} |
@@ -1,3 +1,4 @@ | |||
{% trans_default_domain 'lcshop' %} | |||
<div class="modal fade show" id="modal-order-delivery-availability"> | |||
{{ form_start(form_order_delivery_availability, {'attr': { 'id' : 'orderDeliveryAvailabilityForm'}}) }}) }} |
@@ -0,0 +1,29 @@ | |||
{% trans_default_domain 'lcshop' %} | |||
<div class="modal fade show" id="modal-order-status"> | |||
{{ form_start(form_order_status, {'attr': { 'id' : 'orderStatusForm'}}) }}) }} | |||
{% form_theme form_order_status '@LcShop/backend/form/custom_bootstrap_4.html.twig' %} | |||
<div class="modal-dialog"> | |||
<div class="modal-content"> | |||
<div class="modal-header"> | |||
<h4>{{ "form.group.OrderShop.orderStatus"|trans }}</h4> | |||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"> | |||
<span aria-hidden="true">×</span> | |||
</button> | |||
</div> | |||
<div class="modal-body"> | |||
<div class="col"> | |||
{{ form_row(form_order_status.orderStatus) }} | |||
</div> | |||
</div> | |||
<div class="modal-footer justify-content-between"> | |||
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button> | |||
{{ form_row(form_order_status.saveOrderStatus, {"attr": {'class' : 'btn btn-primary'}}) }} | |||
</div> | |||
</div> | |||
<!-- /.modal-content --> | |||
</div> | |||
{{ form_end(form_order_status) }} | |||
</div> |
@@ -0,0 +1,29 @@ | |||
{% trans_default_domain 'lcshop' %} | |||
<div class="modal fade show" id="modal-reduction-cart"> | |||
{{ form_start(form_order_reduction_cart, {'attr': { 'id' : 'orderReductionCartForm'}}) }}) }} | |||
{% form_theme form_order_reduction_cart '@LcShop/backend/form/custom_bootstrap_4.html.twig' %} | |||
<div class="modal-dialog"> | |||
<div class="modal-content"> | |||
<div class="modal-header"> | |||
<h4>{{ "form.group.OrderShop.orderReductionCart"|trans }}</h4> | |||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"> | |||
<span aria-hidden="true">×</span> | |||
</button> | |||
</div> | |||
<div class="modal-body"> | |||
<div class="col"> | |||
{{ form_row(form_order_reduction_cart.reductionCart) }} | |||
</div> | |||
</div> | |||
<div class="modal-footer justify-content-between"> | |||
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button> | |||
{{ form_row(form_order_reduction_cart.saveOrderReductionCart, {"attr": {'class' : 'btn btn-primary', '@click': 'addOrderReductionCart'}}) }} | |||
</div> | |||
</div> | |||
<!-- /.modal-content --> | |||
</div> | |||
{{ form_end(form_order_reduction_cart) }} | |||
</div> |
@@ -0,0 +1,29 @@ | |||
{% trans_default_domain 'lcshop' %} | |||
<div class="modal fade show" id="modal-reduction-credit"> | |||
{{ form_start(form_order_reduction_credit, {'attr': { 'id' : 'orderReductionCreditForm'}}) }}) }} | |||
{% form_theme form_order_reduction_credit '@LcShop/backend/form/custom_bootstrap_4.html.twig' %} | |||
<div class="modal-dialog"> | |||
<div class="modal-content"> | |||
<div class="modal-header"> | |||
<h4>{{ "form.group.OrderShop.orderReductionCredit"|trans }}</h4> | |||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"> | |||
<span aria-hidden="true">×</span> | |||
</button> | |||
</div> | |||
<div class="modal-body"> | |||
<div class="col"> | |||
{{ form_row(form_order_reduction_credit.reductionCredit) }} | |||
</div> | |||
</div> | |||
<div class="modal-footer justify-content-between"> | |||
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button> | |||
{{ form_row(form_order_reduction_credit.saveOrderReductionCredit, {"attr": {'class' : 'btn btn-primary', '@click': 'addOrderReductionCredit'}}) }} | |||
</div> | |||
</div> | |||
<!-- /.modal-content --> | |||
</div> | |||
{{ form_end(form_order_reduction_credit) }} | |||
</div> |
@@ -24,8 +24,6 @@ | |||
<div class="form "> | |||
<script> | |||
window.mixinUnitValues = { | |||
unitsList: {{ getUnitsList()|json_encode|raw }} | |||
}; |
@@ -0,0 +1,22 @@ | |||
{% extends app.request.query.get('action') == 'edit' ? '@LcShop/backend/default/edit.html.twig' : '@LcShop/backend/default/new.html.twig' %} | |||
{% block entity_form %} | |||
{% include '@LcShop/backend/reductioncart/form.html.twig' %} | |||
{% endblock entity_form %} | |||
{% block head_stylesheets %} | |||
{{ parent() }} | |||
<link rel="stylesheet" href="{{ asset('bundles/lcshop/css/backend/adminlte/plugins/daterange/daterangepicker.css') }}"> | |||
{% endblock %} | |||
{% block plugin_javascript %} | |||
{{ parent() }} | |||
<script src="{{ asset('bundles/lcshop/js/backend/plugin/daterange/moment.min.js')}}"></script> | |||
<script src="{{ asset('bundles/lcshop/js/backend/plugin/daterange/daterangepicker.js')}}"></script> | |||
{% endblock %} | |||
{% block script_javascript %} | |||
{{ parent() }} | |||
{% include '@LcShop/backend/default/block/script-vuejs.html.twig' %} | |||
<script src="{{ asset('bundles/lcshop/js/backend/script/reductioncart/vuejs-reduction-cart.js') }}"></script> | |||
{% endblock %} |
@@ -0,0 +1,61 @@ | |||
{{ form_start(form) }} | |||
{% import '@LcShop/backend/default/block/macros.html.twig' as macros %} | |||
{% set formValues = form.vars.value %} | |||
<div id="lc-reduction-cart-edit"> | |||
<div class="card card-light"> | |||
<div class="lc-vue-js-container card-header p-0 border-bottom-0"> | |||
<ul class="nav nav-tabs" id="nav-params"> | |||
<li class="nav-item" v-for="section in sectionsArray"> | |||
<button type="button" | |||
:class="'btn '+((currentSection == section.name) ? 'btn btn-primary' : 'btn ')" | |||
@click="changeSection(section)"> | |||
${ section.nameDisplay } | |||
<span class="glyphicon glyphicon-triangle-bottom"></span> | |||
<i class="fa fa-exclamation-circle invalid-form"></i> | |||
</button> | |||
</li> | |||
</ul> | |||
</div> | |||
</div> | |||
<div class="form "> | |||
<script> | |||
window.reductionCartCodesUsed = {{ list_reduction_codes()|json_encode|raw }}; | |||
window.reductionCartValues = { | |||
{% if formValues.permanent is not null and formValues.permanent == false %}reductionPermanent: false,{% endif %} | |||
{% if formValues.behaviorTaxRate %}reductionBehaviorTaxRate: '{{ formValues.behaviorTaxRate }}',{% endif %} | |||
{% if formValues.value %}reductionValue: parseFloat({{ formValues.value }}),{% endif %} | |||
{% if formValues.unit %}reductionUnit: "{{ formValues.unit }}",{% endif %} | |||
{% if formValues.appliedTo %}reductionAppliedTo: "{{ formValues.appliedTo }}",{% endif %} | |||
{% if formValues.groupUsers is not empty %}reductionGroupUsersActive: true,{% endif %} | |||
{% if formValues.groupUsers is not empty %}reductionGroupUsers: {{ formValues.groupUsers|json_encode }},{% endif %} | |||
{% if formValues.users is not empty %}reductionUsersActive: true,{% endif %} | |||
{% if formValues.users is not empty %}reductionUsers: {{ formValues.users|json_encode }},{% endif %} | |||
{% if formValues.pointSales is not empty %}reductionPointSalesActive: true,{% endif %} | |||
{% if formValues.pointSales is not empty %}reductionPointSales: {{ formValues.pointSales|json_encode }},{% endif %} | |||
{% if formValues.deliveryZones is not empty %}reductionDeliveryZonesActive: true,{% endif %} | |||
{% if formValues.deliveryZones is not empty %}reductionDeliveryZones: {{ formValues.deliveryZones|json_encode }},{% endif %} | |||
{% if formValues.deliverySlots is not empty %}reductionDeliverySlotsActive: true,{% endif %} | |||
{% if formValues.deliverySlots is not empty %}reductionDeliverySlots: {{ formValues.deliverySlots|json_encode }},{% endif %} | |||
{% if formValues.uncombinables is not empty or formValues.uncombinableTypes %}reductionCombinable: true,{% endif %} | |||
{% if formValues.uncombinables is not empty %}reductionUncombinables: {{ formValues.uncombinables|json_encode }},{% endif %} | |||
{% if formValues.uncombinableTypes is not empty %}reductionUncombinableTypes: {{ formValues.uncombinableTypes|json_encode }},{% endif %} | |||
} | |||
</script> | |||
<div v-show="currentSection == 'info'" class="panel panel-default"> | |||
{% include '@LcShop/backend/reductioncart/panel_info.html.twig' %} | |||
</div> | |||
<div v-show="currentSection == 'conditions'" class="panel panel-default"> | |||
{% include '@LcShop/backend/reductioncart/panel_conditions.html.twig' %} | |||
</div> | |||
<div v-show="currentSection == 'actions'" class="panel panel-default"> | |||
{% include '@LcShop/backend/reductioncart/panel_actions.html.twig' %} | |||
</div> | |||
</div> | |||
</div> | |||
{{ form_end(form) }} |
@@ -0,0 +1,20 @@ | |||
{% trans_default_domain 'lcshop' %} | |||
{% import '@LcShop/backend/default/block/macros.html.twig' as macros %} | |||
<div class="row"> | |||
{{ macros.startCard(8, 'ReductionCart.actions') }} | |||
<div class="col-12"> | |||
{{ form_row(form.appliedTo, {"attr" :{"v-model" : 'reductionAppliedTo'}}) }} | |||
</div> | |||
<div class="col-12" v-show="reductionAppliedTo != 'shipping'"> | |||
{{ form_row(form.freeShipping) }} | |||
</div> | |||
{{ macros.fieldReductionUnit(form) }} | |||
{{ macros.fieldReductionValue(form) }} | |||
{{ macros.fieldReductionBehaviorTaxRate(form) }} | |||
{{ macros.endCard() }} | |||
</div> |
@@ -0,0 +1,38 @@ | |||
{% trans_default_domain 'lcshop' %} | |||
{% import '@LcShop/backend/default/block/macros.html.twig' as macros %} | |||
<div class="row"> | |||
{{ macros.startCard(8, 'ReductionCart.conditions') }} | |||
{{ macros.fieldReductionDateRange(form) }} | |||
{{ macros.fieldReductionList(form, 'deliveryZones') }} | |||
{{ macros.fieldReductionList(form, 'deliverySlots') }} | |||
{{ macros.fieldReductionList(form, 'pointSales') }} | |||
{{ macros.fieldReductionList(form, 'groupUsers') }} | |||
{{ macros.fieldReductionList(form, 'users') }} | |||
<div class="col-12"> | |||
<div class="form-group"> | |||
<div class="form-group"> | |||
{{ form_widget(form.combinable, {"attr" : {'v-model' : 'reductionCombinable' } }) }} | |||
</div> | |||
</div> | |||
</div> | |||
<div class="col-6"> | |||
<div class="form-widget" :class="reductionCombinable == false ? '' : 'hidden'"> | |||
{{ form_row(form.uncombinableTypes, {"attr" : {'ref' : 'reductionUncombinableTypes', 'v-model' : 'reductionUncombinableTypes' } }) }} | |||
</div> | |||
</div> | |||
<div class="col-6"> | |||
<div class="form-widget" :class="reductionCombinable == false ? '' : 'hidden'"> | |||
{{ form_row(form.uncombinables, {"attr" : {'ref' : 'reductionUncombinables', 'v-model' : 'reductionUncombinables' } }) }} | |||
</div> | |||
</div> | |||
<div class="col-12"> | |||
{{ form_row(form.orderAmountMin) }} | |||
</div> | |||
{{ macros.endCard() }} | |||
</div> |
@@ -0,0 +1,25 @@ | |||
{% trans_default_domain 'lcshop' %} | |||
{% import '@LcShop/backend/default/block/macros.html.twig' as macros %} | |||
<div class="row"> | |||
{{ macros.startCard(8, 'ReductionCart.info') }} | |||
<div class="col-12"> | |||
{{ form_row(form.title) }} | |||
</div> | |||
<div class="col-12"> | |||
{{ form_row(form.type) }} | |||
</div> | |||
<div class="col-6"> | |||
{{ form_row(form.availableQuantity) }} | |||
</div> | |||
<div class="col-6"> | |||
{{ form_row(form.availableQuantityPerUser) }} | |||
</div> | |||
<div class="col-12"> | |||
{{ form_row(form.codes, {"attr":{'v-on:keyup' : 'updateCodes'}}) }} | |||
</div> | |||
{{ macros.endCard() }} | |||
</div> |
@@ -19,5 +19,4 @@ | |||
{{ parent() }} | |||
{% include '@LcShop/backend/default/block/script-vuejs.html.twig' %} | |||
<script src="{{ asset('bundles/lcshop/js/backend/script/reductioncatalog/vuejs-reduction-catalog.js') }}"></script> | |||
<script src="{{ asset('bundles/lcshop/js/backend/script/productfamily/init-edit.js') }}"></script>#} | |||
{% endblock %} |
@@ -1,13 +1,18 @@ | |||
<?php | |||
namespace Lc\ShopBundle\Services ; | |||
namespace Lc\ShopBundle\Services; | |||
use App\Entity\OrderProductReductionCatalog; | |||
use App\Entity\OrderShop; | |||
use Doctrine\ORM\EntityManagerInterface; | |||
use Lc\ShopBundle\Context\MerchantUtilsInterface; | |||
use Lc\ShopBundle\Context\OrderReductionCartInterface; | |||
use Lc\ShopBundle\Context\OrderShopInterface; | |||
use Lc\ShopBundle\Context\OrderStatusHistoryInterface; | |||
use Lc\ShopBundle\Context\OrderStatusInterface; | |||
use Lc\ShopBundle\Context\ProductFamilyUtilsInterface; | |||
use Lc\ShopBundle\Context\ReductionCartInterface; | |||
use Lc\ShopBundle\Context\ReductionCreditInterface; | |||
use Lc\ShopBundle\Context\UserInterface; | |||
use Symfony\Component\Security\Core\Security; | |||
@@ -18,8 +23,8 @@ class OrderUtils | |||
protected $userUtils; | |||
protected $merchantUtils; | |||
protected $orderShopRepo; | |||
protected $priceUtils ; | |||
protected $productFamilyUtils ; | |||
protected $priceUtils; | |||
protected $productFamilyUtils; | |||
public function __construct(EntityManagerInterface $em, Security $security, UserUtils $userUtils, | |||
MerchantUtilsInterface $merchantUtils, PriceUtils $priceUtils, ProductFamilyUtilsInterface $productFamilyUtils) | |||
@@ -29,8 +34,8 @@ class OrderUtils | |||
$this->userUtils = $userUtils; | |||
$this->merchantUtils = $merchantUtils; | |||
$this->orderShopRepo = $this->em->getRepository($this->em->getClassMetadata(OrderShopInterface::class)->getName()); | |||
$this->priceUtils = $priceUtils ; | |||
$this->productFamilyUtils = $productFamilyUtils ; | |||
$this->priceUtils = $priceUtils; | |||
$this->productFamilyUtils = $productFamilyUtils; | |||
} | |||
public function getCartCurrent() | |||
@@ -85,16 +90,17 @@ class OrderUtils | |||
throw new \ErrorException('La commande doit être liée à un merchant.'); | |||
} | |||
if($this->security->getUser()) { | |||
$orderShop->setCreatedBy($this->security->getUser()) ; | |||
$orderShop->setUpdatedBy($this->security->getUser()) ; | |||
} | |||
else { | |||
$orderShop = $this->setOrderStatus('cart', $orderShop); | |||
if ($this->security->getUser()) { | |||
$orderShop->setCreatedBy($this->security->getUser()); | |||
$orderShop->setUpdatedBy($this->security->getUser()); | |||
} else { | |||
// createdBy doit pouvoir être NULL pour OrderShop, en attendant qu'on en discute, j'assigne ça au premier de la base | |||
$userRepository = $this->em->getRepository($this->em->getClassMetadata(UserInterface::class)->getName()) ; | |||
$user = $userRepository->find(1) ; | |||
$orderShop->setCreatedBy($user) ; | |||
$orderShop->setUpdatedBy($user) ; | |||
$userRepository = $this->em->getRepository($this->em->getClassMetadata(UserInterface::class)->getName()); | |||
$user = $userRepository->find(1); | |||
$orderShop->setCreatedBy($user); | |||
$orderShop->setUpdatedBy($user); | |||
} | |||
$this->em->persist($orderShop); | |||
@@ -114,19 +120,19 @@ class OrderUtils | |||
$orderProductAdd->setTaxRate($orderProductAdd->getProduct()->getTaxRateInherited()); | |||
$orderProductAdd->setQuantityProduct($orderProductAdd->getProduct()->getQuantityInherited()); | |||
$productFamily = $this->productFamilyUtils->getProductFamilyBySlug($orderProductAdd->getProduct()->getProductFamily()->getSlug()) ; | |||
$reductionCatalog = $productFamily->getReductionCatalog() ; | |||
if($reductionCatalog) { | |||
$orderProductReductionCatalog = new OrderProductReductionCatalog() ; | |||
$orderProductReductionCatalog->setTitle($reductionCatalog->getTitle()) ; | |||
$orderProductReductionCatalog->setValue($reductionCatalog->getValue()) ; | |||
$orderProductReductionCatalog->setUnit($reductionCatalog->getUnit()) ; | |||
$orderProductReductionCatalog->setBehaviorTaxRate($reductionCatalog->getBehaviorTaxRate()) ; | |||
$productFamily = $this->productFamilyUtils->getProductFamilyBySlug($orderProductAdd->getProduct()->getProductFamily()->getSlug()); | |||
$reductionCatalog = $productFamily->getReductionCatalog(); | |||
if ($reductionCatalog) { | |||
$orderProductReductionCatalog = new OrderProductReductionCatalog(); | |||
$orderProductReductionCatalog->setTitle($reductionCatalog->getTitle()); | |||
$orderProductReductionCatalog->setValue($reductionCatalog->getValue()); | |||
$orderProductReductionCatalog->setUnit($reductionCatalog->getUnit()); | |||
$orderProductReductionCatalog->setBehaviorTaxRate($reductionCatalog->getBehaviorTaxRate()); | |||
$orderProductAdd->setOrderProductReductionCatalog($orderProductReductionCatalog); | |||
} | |||
foreach($orderShop->getOrderProducts() as $orderProduct) { | |||
foreach ($orderShop->getOrderProducts() as $orderProduct) { | |||
if ($orderProduct->getProduct()->getId() == $orderProductAdd->getProduct()->getId() | |||
&& $this->priceUtils->getPrice($orderProduct) == $this->priceUtils->getPrice($orderProductAdd) | |||
&& $this->compareOrderProductReductionCatalog($orderProduct->getOrderProductReductionCatalog(), $orderProductAdd->getOrderProductReductionCatalog())) { | |||
@@ -140,7 +146,7 @@ class OrderUtils | |||
if (!$updated) { | |||
$orderShop->addOrderProduct($orderProductAdd); | |||
if(isset($orderProductReductionCatalog)) { | |||
if (isset($orderProductReductionCatalog)) { | |||
$this->em->persist($orderProductReductionCatalog); | |||
} | |||
@@ -155,10 +161,10 @@ class OrderUtils | |||
public function compareOrderProductReductionCatalog($orderProductReductionCatalog1, $orderProductReductionCatalog2) | |||
{ | |||
return $orderProductReductionCatalog1 && $orderProductReductionCatalog2 | |||
return $orderProductReductionCatalog1 && $orderProductReductionCatalog2 | |||
&& $orderProductReductionCatalog1->getUnit() == $orderProductReductionCatalog2->getUnit() | |||
&& $orderProductReductionCatalog1->getValue() == $orderProductReductionCatalog2->getValue() | |||
&& $orderProductReductionCatalog1->getBehaviorTaxRate() == $orderProductReductionCatalog2->getBehaviorTaxRate() ; | |||
&& $orderProductReductionCatalog1->getBehaviorTaxRate() == $orderProductReductionCatalog2->getBehaviorTaxRate(); | |||
} | |||
public function countQuantities($orderShop) | |||
@@ -183,9 +189,9 @@ class OrderUtils | |||
foreach ($orderShop->getOrderProducts() as $orderProduct) { | |||
$productCategories = $orderProduct->getProduct()->getProductFamily()->getProductCategories(); | |||
$category = $productCategories[0]->getParentCategory(); | |||
$labelCategory = $category->getTitle() ; | |||
$labelCategory = $category->getTitle(); | |||
if (!isset($categoriesArray[$labelCategory])) { | |||
$categoriesArray[$labelCategory] = [] ; | |||
$categoriesArray[$labelCategory] = []; | |||
} | |||
$categoriesArray[$labelCategory][] = $orderProduct; | |||
} | |||
@@ -195,17 +201,17 @@ class OrderUtils | |||
public function getOrderDatas($order = null) | |||
{ | |||
if(!$order) { | |||
$order = $this->getCartCurrent() ; | |||
if (!$order) { | |||
$order = $this->getCartCurrent(); | |||
} | |||
$data = [] ; | |||
$data['order'] = $order ; | |||
$data['count'] = $this->countQuantities($order) ; | |||
$data['total_with_tax'] = $this->priceUtils->getTotalWithTaxAndReduction($order) ; | |||
$data['order_products_by_category'] = $this->getOrderProductsByParentCategory($order) ; | |||
$data = []; | |||
$data['order'] = $order; | |||
$data['count'] = $this->countQuantities($order); | |||
$data['total_with_tax'] = $this->priceUtils->getTotalWithTaxAndReduction($order); | |||
$data['order_products_by_category'] = $this->getOrderProductsByParentCategory($order); | |||
return $data ; | |||
return $data; | |||
} | |||
@@ -213,12 +219,13 @@ class OrderUtils | |||
{ | |||
$data['id'] = $order->getId(); | |||
$data['user'] = $order->getUser()->getSummary(); | |||
$data['orderStatus'] = $order->getOrderStatus()->__tosString(); | |||
$data['deliveryAddress'] = $order->getDeliveryAddress()->getSummary(); | |||
$data['invoiceAddress'] = $order->getInvoiceAddress()->getSummary(); | |||
$data['total'] = $this->priceUtils->getTotal($order); | |||
$data['totalWithTax'] = $this->priceUtils->getTotalWithTax($order); | |||
$data['totalWithTaxAndReduction'] = $this->priceUtils->getTotalWithTax($order); | |||
$i=0; | |||
$i = 0; | |||
foreach ($this->getOrderProductsByParentCategory($order) as $labelCategory => $orderProducts) { | |||
foreach ($orderProducts as $orderProduct) { | |||
@@ -241,19 +248,59 @@ class OrderUtils | |||
public function getSummaryOrderProductReductionCatalog($orderProductReductionCatalog) | |||
{ | |||
$text = '' ; | |||
$text = ''; | |||
if($orderProductReductionCatalog) { | |||
if($orderProductReductionCatalog->getUnit() == 'amount') { | |||
$text .= '- '.$orderProductReductionCatalog->getValue().' €' ; | |||
if ($orderProductReductionCatalog) { | |||
if ($orderProductReductionCatalog->getUnit() == 'amount') { | |||
$text .= '- ' . $orderProductReductionCatalog->getValue() . ' €'; | |||
} | |||
if($orderProductReductionCatalog->getUnit() == 'percent') { | |||
$text .= '- '.$orderProductReductionCatalog->getValue().' %' ; | |||
if ($orderProductReductionCatalog->getUnit() == 'percent') { | |||
$text .= '- ' . $orderProductReductionCatalog->getValue() . ' %'; | |||
} | |||
} | |||
return $text ; | |||
return $text; | |||
} | |||
public function newOrderStatusHistory($order, $status, $origin = 'user') | |||
{ | |||
$orderStatusHistoryClass = $this->em->getClassMetadata(OrderStatusHistoryInterface::class); | |||
$orderStatusHistory = new $orderStatusHistoryClass->name; | |||
$orderStatusHistory->setOrderShop($order); | |||
$orderStatusHistory->setOrderStatus($status); | |||
$orderStatusHistory->setOrigin($origin); | |||
$this->em->persist($orderStatusHistory); | |||
} | |||
public function createOrderReductionCart(OrderShopInterface $orderShop, ReductionCartInterface $reductionCart) | |||
{ | |||
$orderReductionCartClass = $this->em->getClassMetadata(OrderReductionCartInterface::class); | |||
$orderReductionCart = new $orderReductionCartClass->name; | |||
$orderReductionCart->setOrderShop($orderShop); | |||
$orderReductionCart->setReductionCart($reductionCart); | |||
$orderReductionCart->setTitle($reductionCart->getTitle()); | |||
$orderReductionCart->setValue($reductionCart->getValue()); | |||
$orderReductionCart->setUnit($reductionCart->getUnit()); | |||
$orderReductionCart->setBehaviorTaxRate($reductionCart->getBehaviorTaxRate()); | |||
$orderReductionCart->setFreeShipping($reductionCart->getFreeShipping()); | |||
$orderReductionCart->setAppliedTo($reductionCart->getAppliedTo()); | |||
$orderReductionCart->setType($reductionCart->getType()); | |||
return $orderReductionCart; | |||
} | |||
/*public function getReductionCreditsAvailable($order) | |||
{ | |||
$reductionCreditRepo = $this->em->getRepository(ReductionCreditInterface::class); | |||
$reductionCredits = $reductionCreditRepo->getReductionCreditByUser($order->getUser()); | |||
foreach ($reductionCredits as $reductionCredit){ | |||
} | |||
}*/ | |||
} |
@@ -115,9 +115,11 @@ class PriceUtils | |||
} | |||
return $total ; | |||
} | |||
if($entity instanceof OrderShopInterface) { | |||
return $this->getTotalOrderProducts($entity->getOrderProducts(), true) ; | |||
} | |||
//C'est bizzare ce truc là | |||
//if($entity instanceof OrderShopInterface) { | |||
// return $this->getTotalOrderProducts($entity->getOrderProducts(), true) ; | |||
//} | |||
return null ; | |||
} | |||
@@ -2,6 +2,8 @@ | |||
namespace Lc\ShopBundle\Twig; | |||
use Doctrine\ORM\EntityManagerInterface; | |||
use Lc\ShopBundle\Context\ReductionCartInterface; | |||
use Symfony\Contracts\Translation\TranslatorInterface; | |||
use Twig\Extension\AbstractExtension; | |||
use Twig\TwigFilter; | |||
@@ -9,10 +11,12 @@ use Twig\TwigFunction; | |||
class BackendTwigExtension extends AbstractExtension | |||
{ | |||
public $em; | |||
public $trans; | |||
public function __construct(TranslatorInterface $translator) | |||
public function __construct(EntityManagerInterface $em, TranslatorInterface $translator) | |||
{ | |||
$this->em = $em; | |||
$this->trans = $translator; | |||
} | |||
@@ -21,27 +25,51 @@ class BackendTwigExtension extends AbstractExtension | |||
public function getFunctions() | |||
{ | |||
return array( | |||
new TwigFunction('list_reduction_codes', [$this, 'getListReductionCodes']), | |||
); | |||
} | |||
public function getFilters() | |||
{ | |||
return [ | |||
new TwigFilter('lc_trad', [$this, 'lcTrad']) | |||
new TwigFilter('lc_trad', [$this, 'lcTrad']), | |||
new TwigFilter('uc_first', [$this, 'ucFirst']) | |||
]; | |||
} | |||
public function lcTrad($field, $entityName, $type="field") | |||
public function ucFirst($string) | |||
{ | |||
return ucfirst($string); | |||
} | |||
public function lcTrad($field, $entityName, $type = "field") | |||
{ | |||
$tradKey = $type.'.'.$entityName.'.'.$field; | |||
$tradDefaultKey = $type.'.default.'.$field; | |||
$tradKey = $type . '.' . $entityName . '.' . $field; | |||
$tradDefaultKey = $type . '.default.' . $field; | |||
$trad = $this->trans->trans($tradKey, array(), 'lcshop'); | |||
if($trad == $tradKey){ | |||
if ($trad == $tradKey) { | |||
$trad = $this->trans->trans($tradDefaultKey, array(), 'lcshop'); | |||
} | |||
return $trad; | |||
} | |||
public function getListReductionCodes() | |||
{ | |||
$reductionCartRepo = $this->em->getRepository(ReductionCartInterface::class); | |||
$codesToReturn = array(); | |||
foreach ($reductionCartRepo->getValuesOfFieldCode() as $codes) { | |||
foreach ($codes['codes'] as $code) { | |||
$codesToReturn[] = $code; | |||
} | |||
} | |||
; | |||
return $codesToReturn; | |||
} | |||
} |