@@ -0,0 +1,8 @@ | |||
<?php | |||
namespace Lc\ShopBundle\Context; | |||
interface PointSaleUtilsInterface | |||
{ | |||
} |
@@ -0,0 +1,8 @@ | |||
<?php | |||
namespace Lc\ShopBundle\Context; | |||
interface UserPointSaleInterface | |||
{ | |||
} |
@@ -1,201 +0,0 @@ | |||
<?php | |||
namespace Lc\ShopBundle\Controller\Admin; | |||
use App\Entity\OrderProduct; | |||
use App\Entity\Product; | |||
use Doctrine\DBAL\Types\FloatType; | |||
use Doctrine\ORM\EntityRepository; | |||
use EasyCorp\Bundle\EasyAdminBundle\Event\EasyAdminEvents; | |||
use Lc\ShopBundle\Context\AddressInterface; | |||
use Lc\ShopBundle\Context\PointSaleInterface; | |||
use Lc\ShopBundle\Context\ProductCategoryInterface; | |||
use Lc\ShopBundle\Context\ProductFamilyInterface; | |||
use Lc\ShopBundle\Context\ProductInterface; | |||
use Lc\ShopBundle\Context\TaxRateInterface; | |||
use Lc\ShopBundle\Context\UserInterface; | |||
use Lc\ShopBundle\Form\OrderProductType; | |||
use Lc\ShopBundle\Form\ProductFamilyCategoriesType; | |||
use Lc\ShopBundle\Form\ProductType; | |||
use Lc\ShopBundle\Model\PointSale; | |||
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\CollectionType; | |||
use Symfony\Component\Form\Extension\Core\Type\DateType; | |||
use Symfony\Component\Form\Extension\Core\Type\HiddenType; | |||
use Symfony\Component\Form\Extension\Core\Type\MoneyType; | |||
use Symfony\Component\Form\Extension\Core\Type\NumberType; | |||
use Symfony\Component\Form\Extension\Core\Type\SubmitType; | |||
use Symfony\Component\HttpFoundation\Request; | |||
use Symfony\Component\HttpFoundation\Response; | |||
class OrderController extends AdminController | |||
{ | |||
public function updateEntity($entity) | |||
{ | |||
foreach ($entity->getOrderProducts() as $orderProduct) { | |||
//dump($orderProduct); | |||
$orderProduct->setCreatedBy($this->getUser()); | |||
$orderProduct->setUpdatedBy($this->getUser()); | |||
$orderProduct->setTaxRate($orderProduct->getProduct()->getProductFamily()->getTaxRate()); | |||
$orderProduct->setOrderShop($entity); | |||
$this->em->persist($orderProduct); | |||
$entity->addOrderProduct($orderProduct); | |||
} | |||
$this->setUpdated($entity); | |||
parent::updateEntity($entity); | |||
} | |||
public function persistEntity($entity) | |||
{ | |||
foreach ($entity->getOrderProducts() as $orderProduct) { | |||
$orderProduct->setUnit($orderProduct->getProduct()->getUnitInherited()); | |||
$orderProduct->setTitle($orderProduct->getProduct()->getTitleInherited()); | |||
$orderProduct->setPrice($orderProduct->getProduct()->getPriceInherited()); | |||
if ($orderProduct->getProduct()->getProductFamily()->getTaxRate()) { | |||
$orderProduct->setTaxRate($orderProduct->getProduct()->getProductFamily()->getTaxRate()); | |||
} else { | |||
$orderProduct->setTaxRate($this->security->getUser()->getMerchant()->getTaxRate()); | |||
} | |||
$orderProduct->setOrderShop($entity); | |||
$orderProduct->setCreatedBy($this->getUser()); | |||
$orderProduct->setUpdatedBy($this->getUser()); | |||
$this->em->persist($orderProduct); | |||
$entity->addOrderProduct($orderProduct); | |||
} | |||
parent::persistEntity($entity); | |||
} | |||
public function createEntityFormBuilder($entity, $view, $override=true) | |||
{ | |||
$formBuilder = parent::createEntityFormBuilder($entity, $view); | |||
$formBuilder->add('orderProducts', CollectionType::class, array( | |||
'label' => 'Déclinaisons', | |||
'entry_type' => OrderProductType::class, | |||
'entry_options' => ['label' => false], | |||
'allow_add' => true, | |||
'allow_delete' => true, | |||
'required' => true | |||
) | |||
); | |||
$userClass = $this->em->getClassMetadata(UserInterface::class); | |||
$formBuilder->add('user', EntityType::class, array( | |||
'class' => $userClass->name | |||
)); | |||
$addressClass = $this->em->getClassMetadata(AddressInterface::class); | |||
$formBuilder->add('invoiceAddress', EntityType::class, array( | |||
'class' => $addressClass->name, | |||
'placeholder' => '', | |||
'query_builder' => function (EntityRepository $er) use ($entity) { | |||
return $er->createQueryBuilder('a') | |||
->where('a.user = :user') | |||
->setParameter('user', $entity->getUser()); | |||
}, | |||
)); | |||
return $formBuilder; | |||
} | |||
public function getUserViaFirstStepForm($entity) | |||
{ | |||
$userClass = $this->em->getClassMetadata(UserInterface::class); | |||
$userChoiceForm = $this->createFormBuilder($entity) | |||
->add('user', EntityType::class, array( | |||
'class' => $userClass->name | |||
)) | |||
->add('nextStep', SubmitType::class) | |||
->getForm(); | |||
$userChoiceForm->handleRequest($this->request); | |||
if ($userChoiceForm->isSubmitted() && $userChoiceForm->isValid()) { | |||
return $userChoiceForm->get('user')->getData(); | |||
} | |||
$parameters = [ | |||
'form' => $userChoiceForm->createView(), | |||
'formView' => 'default', | |||
'entity' => $entity, | |||
]; | |||
return $this->executeDynamicMethod('render<EntityName>Template', ['new', $this->entity['templates']['new'], $parameters]); | |||
} | |||
protected function newAction() | |||
{ | |||
$this->dispatch(EasyAdminEvents::PRE_NEW); | |||
$entity = $this->executeDynamicMethod('createNew<EntityName>Entity'); | |||
$easyadmin = $this->request->attributes->get('easyadmin'); | |||
$easyadmin['item'] = $entity; | |||
$this->request->attributes->set('easyadmin', $easyadmin); | |||
$fields = $this->entity['new']['fields']; | |||
$newForm = $this->executeDynamicMethod('create<EntityName>NewForm', [$entity, $fields]); | |||
$newForm->handleRequest($this->request); | |||
//ETAPE 1 Choix de l'utilisateur | |||
$user = $newForm->get('user')->getData(); | |||
if ($user == null) { | |||
$user = $this->getUserViaFirstStepForm($entity); | |||
} | |||
if (!$user instanceof UserInterface) return $user; | |||
else { | |||
$entity->setUser($user); | |||
//réinitialise le formulaire pour charger les adresses en fonction de l'utilisateur sélectionné | |||
$newForm = $this->executeDynamicMethod('create<EntityName>NewForm', [$entity, $fields]); | |||
$newForm->handleRequest($this->request); | |||
//dump( $entity); | |||
//dump( $entity); | |||
if ($newForm->isSubmitted() && $newForm->isValid()) { | |||
/*dump($entity); | |||
die();*/ | |||
//$this->dispatch(EasyAdminEvents::PRE_PERSIST, ['entity' => $entity]); | |||
$this->executeDynamicMethod('persist<EntityName>Entity', [$entity, $newForm]); | |||
$this->dispatch(EasyAdminEvents::POST_PERSIST, ['entity' => $entity]); | |||
return $this->redirectToReferrer(); | |||
} | |||
$this->dispatch(EasyAdminEvents::POST_NEW, [ | |||
'entity_fields' => $fields, | |||
'form' => $newForm, | |||
'entity' => $entity | |||
]); | |||
$parameters = [ | |||
'form' => $newForm->createView(), | |||
'entity_fields' => $fields, | |||
'entity' => $entity | |||
]; | |||
return $this->executeDynamicMethod('render<EntityName>Template', ['new', $this->entity['templates']['new'], $parameters]); | |||
} | |||
} | |||
} |
@@ -6,6 +6,8 @@ use Doctrine\ORM\EntityManager; | |||
use Doctrine\ORM\EntityManagerInterface; | |||
use Lc\ShopBundle\Context\ProductCategoryInterface; | |||
use Lc\ShopBundle\Context\ProductInterface; | |||
use Lc\ShopBundle\Services\PriceUtils; | |||
use Lc\ShopBundle\Services\ProductFamilyUtils; | |||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; | |||
use Symfony\Component\HttpFoundation\JsonResponse; | |||
use Symfony\Component\HttpFoundation\Response; | |||
@@ -17,10 +19,14 @@ class ApiController extends AbstractController | |||
protected $userManager; | |||
protected $em ; | |||
protected $utils ; | |||
protected $priceUtils ; | |||
protected $productFamilyUtils; | |||
public function __construct(EntityManagerInterface $entityManager) | |||
public function __construct(EntityManagerInterface $entityManager, PriceUtils $priceUtils, ProductFamilyUtils $productFamilyUtils) | |||
{ | |||
$this->em = $entityManager; | |||
$this->priceUtils = $priceUtils; | |||
$this->productFamilyUtils = $productFamilyUtils; | |||
} | |||
public function getEntity($entity, $id) | |||
@@ -28,9 +34,6 @@ class ApiController extends AbstractController | |||
$repo = $this->em->getRepository(ProductCategoryInterface::class); | |||
$data = $repo->findBy(array()); | |||
dump($data); | |||
if($entity == 'product'){ | |||
$repo = $this->em->getRepository(ProductInterface::class); | |||
@@ -38,14 +41,16 @@ class ApiController extends AbstractController | |||
$data= array( | |||
'id' => $data->getId(), | |||
'title' => $data->getTitleInherited(), | |||
'price' => $data->getPriceInherited(), | |||
'price' => $this->priceUtils->getPrice($data), | |||
'priceWithTax' => $this->priceUtils->getPriceWithTax($data), | |||
'priceWithTaxAndReduction' => $this->priceUtils->getPriceWithTaxAndReduction($data), | |||
'unit' => $data->getUnitInherited(), | |||
'availableQuantity' => $data->getAvailableQuantityInherited(), | |||
'taxRate' => $data->getTaxRateInherited(), | |||
); | |||
} | |||
return new Response('<html><body>NICHE</body></html>'); | |||
return new Response(json_encode($data)); | |||
} | |||
} |
@@ -1,6 +1,6 @@ | |||
<?php | |||
namespace Lc\ShopBundle\Controller\Admin; | |||
namespace Lc\ShopBundle\Controller\Backend; | |||
use Doctrine\ORM\EntityManagerInterface; | |||
use Doctrine\ORM\EntityRepository; | |||
@@ -10,6 +10,7 @@ use FOS\UserBundle\Model\UserManagerInterface; | |||
use Lc\ShopBundle\Context\FilterMultipleMerchantsInterface; | |||
use Lc\ShopBundle\Context\MerchantInterface; | |||
use Lc\ShopBundle\Context\MerchantUtilsInterface; | |||
use Lc\ShopBundle\Context\OrderUtilsInterface; | |||
use Lc\ShopBundle\Context\StatusInterface; | |||
use Lc\ShopBundle\Context\TreeInterface; | |||
use Lc\ShopBundle\Form\AbstractEditPositionType; | |||
@@ -30,9 +31,10 @@ class AdminController extends EasyAdminController | |||
protected $utils; | |||
protected $merchantUtils ; | |||
protected $mailjetTransport ; | |||
protected $orderUtils ; | |||
public function __construct(Security $security, UserManagerInterface $userManager, EntityManagerInterface $em, Utils $utils, | |||
MerchantUtilsInterface $merchantUtils, MailjetTransport $mailjetTransport) | |||
MerchantUtilsInterface $merchantUtils, MailjetTransport $mailjetTransport, OrderUtilsInterface $orderUtils) | |||
{ | |||
$this->security = $security; | |||
$this->userManager = $userManager; | |||
@@ -40,6 +42,7 @@ class AdminController extends EasyAdminController | |||
$this->utils = $utils; | |||
$this->merchantUtils = $merchantUtils ; | |||
$this->mailjetTransport = $mailjetTransport ; | |||
$this->orderUtils = $orderUtils ; | |||
} | |||
/** |
@@ -1,6 +1,6 @@ | |||
<?php | |||
namespace Lc\ShopBundle\Controller\Admin; | |||
namespace Lc\ShopBundle\Controller\Backend; | |||
use Lc\ShopBundle\Context\MerchantConfigInterface; | |||
use Lc\ShopBundle\Context\MerchantInterface; |
@@ -1,6 +1,6 @@ | |||
<?php | |||
namespace Lc\ShopBundle\Controller\Admin; | |||
namespace Lc\ShopBundle\Controller\Backend; | |||
use App\Repository\UserRepository; | |||
use Lc\ShopBundle\Context\NewsInterface; |
@@ -0,0 +1,332 @@ | |||
<?php | |||
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 Symfony\Bridge\Doctrine\Form\Type\EntityType; | |||
use Symfony\Component\Form\Extension\Core\Type\SubmitType; | |||
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) | |||
{ | |||
foreach ($entity->getOrderProducts() as $orderProduct) { | |||
//dump($orderProduct); | |||
$orderProduct->setCreatedBy($this->getUser()); | |||
$orderProduct->setUpdatedBy($this->getUser()); | |||
$orderProduct->setTaxRate($orderProduct->getProduct()->getProductFamily()->getTaxRate()); | |||
$orderProduct->setOrderShop($entity); | |||
$this->em->persist($orderProduct); | |||
$entity->addOrderProduct($orderProduct); | |||
} | |||
$this->setUpdated($entity); | |||
parent::updateEntity($entity); | |||
} | |||
public function persistEntity($entity) | |||
{ | |||
foreach ($entity->getOrderProducts() as $orderProduct) { | |||
$orderProduct->setUnit($orderProduct->getProduct()->getUnitInherited()); | |||
$orderProduct->setTitle($orderProduct->getProduct()->getTitleInherited()); | |||
$orderProduct->setPrice($orderProduct->getProduct()->getPriceInherited()); | |||
if ($orderProduct->getProduct()->getProductFamily()->getTaxRate()) { | |||
$orderProduct->setTaxRate($orderProduct->getProduct()->getProductFamily()->getTaxRate()); | |||
} else { | |||
$orderProduct->setTaxRate($this->security->getUser()->getMerchant()->getTaxRate()); | |||
} | |||
$orderProduct->setOrderShop($entity); | |||
$orderProduct->setCreatedBy($this->getUser()); | |||
$orderProduct->setUpdatedBy($this->getUser()); | |||
$this->em->persist($orderProduct); | |||
$entity->addOrderProduct($orderProduct); | |||
} | |||
parent::persistEntity($entity); | |||
} | |||
public function getUserViaFirstStepForm($entity) | |||
{ | |||
$userClass = $this->em->getClassMetadata(UserInterface::class); | |||
$userChoiceForm = $this->createFormBuilder($entity) | |||
->add('user', EntityType::class, array( | |||
'class' => $userClass->name | |||
)) | |||
->add('nextStep', SubmitType::class) | |||
->getForm(); | |||
$userChoiceForm->handleRequest($this->request); | |||
if ($userChoiceForm->isSubmitted() && $userChoiceForm->isValid()) { | |||
return $userChoiceForm->get('user')->getData(); | |||
} | |||
$parameters = [ | |||
'form' => $userChoiceForm->createView(), | |||
'formView' => 'default', | |||
'entity' => $entity, | |||
]; | |||
return $this->executeDynamicMethod('render<EntityName>Template', ['new', $this->entity['templates']['new'], $parameters]); | |||
} | |||
public function addProductToOrderAction() | |||
{ | |||
$id = $this->request->query->get('id'); | |||
$easyadmin = $this->request->attributes->get('easyadmin'); | |||
$orderShop = $easyadmin['item']; | |||
$orderProductClass = $this->em->getClassMetadata(OrderProductInterface::class); | |||
$formAddProductToOrder = $this->createForm(AddPoductToOrderType::class); | |||
$formAddProductToOrder->handleRequest($this->request); | |||
if ($formAddProductToOrder->get('product')->getData() == null) { | |||
$response['status'] = 'error'; | |||
$response['message'] = 'Vous devez choisir un produit dans la liste'; | |||
} else if ($formAddProductToOrder->get('quantity')->getData() == null) { | |||
$response['status'] = 'error'; | |||
$response['message'] = 'Vous devez entrer une quantité'; | |||
} else if ($formAddProductToOrder->isSubmitted() && $formAddProductToOrder->isValid()) { | |||
$orderProduct = new $orderProductClass->name; | |||
$orderProduct->setQuantityOrder($formAddProductToOrder->get('quantity')->getData()); | |||
$orderProduct->setProduct($formAddProductToOrder->get('product')->getData()); | |||
$this->orderUtils->addOrderProduct($orderShop, $orderProduct); | |||
$response['status'] = 'success'; | |||
$response['message'] = 'Le produit a bien été ajouté à la commande'; | |||
} else { | |||
$response['status'] = 'error'; | |||
$response['message'] = 'Une erreur est survenue'; | |||
} | |||
$response['data'] = $this->orderUtils->getOrderAsJsonObject($orderShop);; | |||
return new Response(json_encode($response)); | |||
} | |||
public function orderInvoiceAddressAction() | |||
{ | |||
$id = $this->request->query->get('id'); | |||
$easyadmin = $this->request->attributes->get('easyadmin'); | |||
$orderShop = $easyadmin['item']; | |||
$formOrderInvoiceAddress = $this->createForm(OrderInvoiceAddressType::class, $orderShop); | |||
$formOrderInvoiceAddress->handleRequest($this->request); | |||
if ($formOrderInvoiceAddress->isSubmitted() && $formOrderInvoiceAddress->isValid()) { | |||
$this->em->persist($orderShop); | |||
$this->em->flush(); | |||
$response['status'] = 'success'; | |||
$response['message'] = 'La commande a bien été modifié'; | |||
} else { | |||
$response['status'] = 'error'; | |||
$response['message'] = 'Une erreur est survenue'; | |||
} | |||
$response['data'] = $this->orderUtils->getOrderAsJsonObject($orderShop);; | |||
return new Response(json_encode($response)); | |||
} | |||
public function orderProductsAction() | |||
{ | |||
$id = $this->request->query->get('id'); | |||
$easyadmin = $this->request->attributes->get('easyadmin'); | |||
$orderShop = $easyadmin['item']; | |||
$formOrderProducts = $this->createForm(OrderProductsType::class, $orderShop); | |||
$formOrderProducts->handleRequest($this->request); | |||
if ($formOrderProducts->isSubmitted() && $formOrderProducts->isValid()) { | |||
// dump($formOrderProducts->get('orderProducts')->getData()); | |||
foreach ($orderShop->getOrderProducts() as $orderProduct) { | |||
if ($orderProduct->getQuantityOrder() <= 0) { | |||
$response['niche'] = $orderProduct->getQuantityOrder(); | |||
$this->em->remove($orderProduct); | |||
} else { | |||
$this->em->persist($orderProduct); | |||
} | |||
} | |||
$this->em->flush(); | |||
$response['status'] = 'success'; | |||
$response['message'] = 'La commande a bien été modifié'; | |||
} 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') { | |||
$formAddProductToOrder = $this->createForm(AddPoductToOrderType::class, null, array( | |||
'action' => $this->generateUrl('easyadmin', [ | |||
'action' => 'addProductToOrder', | |||
'entity' => $this->entity['name'], | |||
'id' => $parameters['entity']->getId() | |||
]) | |||
)); | |||
$formOrderProducts = $this->createForm(OrderProductsType::class, null, array( | |||
'action' => $this->generateUrl('easyadmin', [ | |||
'action' => 'orderProducts', | |||
'entity' => $this->entity['name'], | |||
'id' => $parameters['entity']->getId() | |||
]) | |||
)); | |||
$formOrderInvoiceAddress = $this->createForm(OrderInvoiceAddressType::class, null, array( | |||
'data' => $parameters['entity'], | |||
'action' => $this->generateUrl('easyadmin', [ | |||
'action' => 'orderInvoiceAddress', | |||
'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'], | |||
'action' => $this->generateUrl('easyadmin', [ | |||
'action' => 'orderDeliveryAddress', | |||
'entity' => $this->entity['name'], | |||
'id' => $parameters['entity']->getId() | |||
]) | |||
)); | |||
$parameters['form_order_delivery_address'] = $formOrderDeliveryAddress->createView(); | |||
} | |||
$parameters['form_add_product_to_order'] = $formAddProductToOrder->createView(); | |||
$parameters['form_order_products'] = $formOrderProducts->createView(); | |||
$parameters['form_order_invoice_address'] = $formOrderInvoiceAddress->createView(); | |||
} | |||
return parent::renderTemplate($actionName, $templatePath, $parameters); | |||
} | |||
protected function newAction() | |||
{ | |||
$this->dispatch(EasyAdminEvents::PRE_NEW); | |||
$entity = $this->executeDynamicMethod('createNew<EntityName>Entity'); | |||
$easyadmin = $this->request->attributes->get('easyadmin'); | |||
$easyadmin['item'] = $entity; | |||
$this->request->attributes->set('easyadmin', $easyadmin); | |||
$fields = $this->entity['new']['fields']; | |||
$newForm = $this->executeDynamicMethod('create<EntityName>NewForm', [$entity, $fields]); | |||
$newForm->handleRequest($this->request); | |||
//ETAPE 1 Choix de l'utilisateur | |||
$user = $newForm->get('user')->getData(); | |||
if ($user == null) { | |||
$user = $this->getUserViaFirstStepForm($entity); | |||
} | |||
if (!$user instanceof UserInterface) return $user; | |||
else { | |||
$orderShop = $this->orderUtils->createOrderShop(array( | |||
'user' => $user, | |||
'merchant' => $this->merchantUtils->getMerchantUser() | |||
)); | |||
return $this->redirectToRoute('easyadmin', [ | |||
'action' => 'edit', | |||
'entity' => $this->entity['name'], | |||
'id' => $orderShop->getId() | |||
]); | |||
} | |||
} | |||
/** | |||
* The method that is executed when the user performs a 'show' action on an entity. | |||
* | |||
* @return Response | |||
*/ | |||
public function showAction() | |||
{ | |||
$this->dispatch(EasyAdminEvents::PRE_SHOW); | |||
$id = $this->request->query->get('id'); | |||
$easyadmin = $this->request->attributes->get('easyadmin'); | |||
$entity = $easyadmin['item']; | |||
$fields = $this->entity['show']['fields']; | |||
$deleteForm = $this->createDeleteForm($this->entity['name'], $id); | |||
$this->dispatch(EasyAdminEvents::POST_SHOW, [ | |||
'deleteForm' => $deleteForm, | |||
'fields' => $fields, | |||
'entity' => $entity, | |||
]); | |||
$parameters = [ | |||
'entity' => $entity, | |||
'fields' => $fields, | |||
'delete_form' => $deleteForm->createView(), | |||
'order' => $this->orderUtils->getOrderAsJsonObject($entity) | |||
]; | |||
return $this->executeDynamicMethod('render<EntityName>Template', ['show', $this->entity['templates']['show'], $parameters]); | |||
} | |||
/** | |||
* Réécriture de edit action pr rediriger vers le show */ | |||
public function editAction() | |||
{ | |||
$id = $this->request->query->get('id'); | |||
$entity = $this->request->query->get('entity'); | |||
return $this->redirectToRoute('easyadmin', [ | |||
'action' => 'show', | |||
'entity' => $entity, | |||
'id' => $id | |||
]); | |||
} | |||
} |
@@ -1,6 +1,6 @@ | |||
<?php | |||
namespace Lc\ShopBundle\Controller\Admin; | |||
namespace Lc\ShopBundle\Controller\Backend; | |||
use App\Entity\Product; | |||
use App\Entity\ReductionCatalog; |
@@ -1,6 +1,6 @@ | |||
<?php | |||
namespace Lc\ShopBundle\Controller\Admin; | |||
namespace Lc\ShopBundle\Controller\Backend; | |||
use FOS\UserBundle\Doctrine\UserManager; | |||
use FOS\UserBundle\Model\UserManagerInterface ; |
@@ -42,7 +42,7 @@ class CartController extends BaseController | |||
$form->handleRequest($request); | |||
if ($form->isSubmitted() && $form->isValid()) { | |||
$orderShop = $this->orderUtils->getOrderShopCurrent() ; | |||
$orderShop = $this->orderUtils->getCartCurrent() ; | |||
$data = $form->getData() ; | |||
foreach($data as $orderProduct) { | |||
if($orderProduct instanceof OrderProductInterface) { |
@@ -0,0 +1,63 @@ | |||
<?php | |||
namespace Lc\ShopBundle\Form\Order; | |||
use Doctrine\ORM\EntityManagerInterface; | |||
use Doctrine\ORM\EntityRepository; | |||
use Lc\ShopBundle\Context\MerchantUtilsInterface; | |||
use Lc\ShopBundle\Context\ProductInterface; | |||
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\IntegerType; | |||
use Symfony\Component\Form\FormBuilderInterface; | |||
use Symfony\Component\OptionsResolver\OptionsResolver; | |||
class AddPoductToOrderType extends AbstractType | |||
{ | |||
protected $em; | |||
protected $merchantUtils; | |||
public function __construct(EntityManagerInterface $em, MerchantUtilsInterface $merchantUtils) | |||
{ | |||
$this->em = $em; | |||
$this->merchantUtils = $merchantUtils; | |||
} | |||
public function buildForm(FormBuilderInterface $builder, array $options) | |||
{ | |||
//$data = $options['data'] ; | |||
$productClass = $this->em->getClassMetadata(ProductInterface::class); | |||
$currentMerchant = $this->merchantUtils->getMerchantUser(); | |||
$builder | |||
->add('product', EntityType::class, array( | |||
'class' => $productClass->name, | |||
'placeholder' => '', | |||
'mapped' => false, | |||
'required' => false, | |||
'query_builder' => function (EntityRepository $er) use ($currentMerchant) { | |||
return $er->createQueryBuilder('p') | |||
->join('p.productFamily', 'pFamily') | |||
->where('pFamily.merchant = :currentMerchant') | |||
->setParameter('currentMerchant', $currentMerchant); | |||
}, | |||
'choice_label' => function ($product) { | |||
return $product->getProductFamily()->getTitle() . ' - ' . $product->getTitle(); | |||
} | |||
)) | |||
->add('quantity', IntegerType::class, array( | |||
'mapped' => false | |||
)) | |||
->add('addProductToOrder', ButtonType::class, array( | |||
'label'=> 'field.OrderShop.addOrderToProduct' | |||
)); | |||
} | |||
public function configureOptions(OptionsResolver $resolver) | |||
{ | |||
$resolver->setDefaults([ | |||
'translation_domain'=>'lcshop' | |||
]); | |||
} | |||
} |
@@ -0,0 +1,53 @@ | |||
<?php | |||
namespace Lc\ShopBundle\Form\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\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\FormBuilderInterface; | |||
use Symfony\Component\OptionsResolver\OptionsResolver; | |||
class OrderDeliveryAddressType extends AbstractType | |||
{ | |||
protected $em; | |||
protected $merchantUtils; | |||
public function __construct(EntityManagerInterface $em, MerchantUtilsInterface $merchantUtils) | |||
{ | |||
$this->em = $em; | |||
$this->merchantUtils = $merchantUtils; | |||
} | |||
public function buildForm(FormBuilderInterface $builder, array $options) | |||
{ | |||
$entity = $options['data']; | |||
$builder->add('deliveryPointSale', ChoiceType::class, array( | |||
'choices' => $this->merchantUtils->getMerchantUser()->getPointSales(), | |||
'choice_label' => 'labelAdminChoice', | |||
'required' => false, | |||
'mapped' => false, | |||
)) | |||
->add('saveDeliveryAddress', ButtonType::class, array( | |||
'label' => 'field.OrderShop.saveInvoiceAddress' | |||
)); | |||
} | |||
public function configureOptions(OptionsResolver $resolver) | |||
{ | |||
$resolver->setDefaults([ | |||
'data_class' => $this->em->getClassMetadata(OrderShopInterface::class)->getName(), | |||
]); | |||
} | |||
} |
@@ -0,0 +1,57 @@ | |||
<?php | |||
namespace Lc\ShopBundle\Form\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\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\CollectionType; | |||
use Symfony\Component\Form\FormBuilderInterface; | |||
use Symfony\Component\OptionsResolver\OptionsResolver; | |||
class OrderInvoiceAddressType extends AbstractType | |||
{ | |||
protected $em; | |||
protected $merchantUtils; | |||
public function __construct(EntityManagerInterface $em, MerchantUtilsInterface $merchantUtils) | |||
{ | |||
$this->em = $em; | |||
$this->merchantUtils = $merchantUtils; | |||
} | |||
public function buildForm(FormBuilderInterface $builder, array $options) | |||
{ | |||
$entity = $options['data']; | |||
$addressClass = $this->em->getClassMetadata(AddressInterface::class); | |||
$builder->add('invoiceAddress', EntityType::class, array( | |||
'class' => $addressClass->name, | |||
'placeholder' => '', | |||
'query_builder' => function (EntityRepository $er) use ($entity) { | |||
return $er->createQueryBuilder('a') | |||
->where('a.user = :user') | |||
->setParameter('user', $entity->getUser()); | |||
}, | |||
)) | |||
->add('saveInvoiceAddress', ButtonType::class, array( | |||
'label' => 'field.OrderShop.saveInvoiceAddress' | |||
)); | |||
} | |||
public | |||
function configureOptions(OptionsResolver $resolver) | |||
{ | |||
$resolver->setDefaults([ | |||
'data_class' => $this->em->getClassMetadata(OrderShopInterface::class)->getName(), | |||
]); | |||
} | |||
} |
@@ -0,0 +1,46 @@ | |||
<?php | |||
namespace Lc\ShopBundle\Form\Order; | |||
use App\Entity\Product; | |||
use Doctrine\ORM\EntityManagerInterface; | |||
use Lc\ShopBundle\Context\OrderProductInterface; | |||
use Lc\ShopBundle\Context\ProductInterface; | |||
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\HiddenType; | |||
use Symfony\Component\Form\Extension\Core\Type\NumberType; | |||
use Symfony\Component\Form\FormBuilderInterface; | |||
use Symfony\Component\OptionsResolver\OptionsResolver; | |||
class OrderProductType extends AbstractType | |||
{ | |||
protected $em ; | |||
protected $productTransformer ; | |||
public function __construct(EntityManagerInterface $em, ProductToIdTransformer $productTransformer) | |||
{ | |||
$this->em = $em ; | |||
$this->productTransformer = $productTransformer ; | |||
} | |||
public function buildForm(FormBuilderInterface $builder, array $options) | |||
{ | |||
$builder | |||
->add('quantityOrder', NumberType::class,array( | |||
'html5'=>true | |||
)) | |||
->add('product', HiddenType::class); | |||
/* ->add('id', HiddenType::class);*/ | |||
$builder->get('product')->addModelTransformer($this->productTransformer); | |||
} | |||
public function configureOptions(OptionsResolver $resolver) | |||
{ | |||
$resolver->setDefaults([ | |||
'data_class' => $this->em->getClassMetadata(OrderProductInterface::class)->getName(), | |||
]); | |||
} | |||
} |
@@ -0,0 +1,43 @@ | |||
<?php | |||
namespace Lc\ShopBundle\Form\Order; | |||
use Doctrine\ORM\EntityManagerInterface; | |||
use Lc\ShopBundle\Context\MerchantUtilsInterface; | |||
use Lc\ShopBundle\Context\OrderShopInterface; | |||
use Symfony\Component\Form\AbstractType; | |||
use Symfony\Component\Form\Extension\Core\Type\CollectionType; | |||
use Symfony\Component\Form\FormBuilderInterface; | |||
use Symfony\Component\OptionsResolver\OptionsResolver; | |||
class OrderProductsType extends AbstractType | |||
{ | |||
protected $em; | |||
protected $merchantUtils; | |||
public function __construct(EntityManagerInterface $em, MerchantUtilsInterface $merchantUtils) | |||
{ | |||
$this->em = $em; | |||
$this->merchantUtils = $merchantUtils; | |||
} | |||
public function buildForm(FormBuilderInterface $builder, array $options) | |||
{ | |||
$builder->add('orderProducts', CollectionType::class, array( | |||
'label' => false, | |||
'entry_type' => OrderProductType::class, | |||
'entry_options' => ['label' => false], | |||
'allow_add' => true, | |||
'allow_delete' => true, | |||
'required' => true | |||
) | |||
); | |||
} | |||
public function configureOptions(OptionsResolver $resolver) | |||
{ | |||
$resolver->setDefaults([ | |||
]); | |||
} | |||
} |
@@ -1,65 +0,0 @@ | |||
<?php | |||
namespace Lc\ShopBundle\Form; | |||
use CKSource\Bundle\CKFinderBundle\Form\Type\CKFinderFileChooserType; | |||
use Doctrine\ORM\EntityManagerInterface; | |||
use FOS\CKEditorBundle\Form\Type\CKEditorType; | |||
use Lc\ShopBundle\Context\OrderProductInterface; | |||
use Lc\ShopBundle\Context\ProductFamilyInterface; | |||
use Lc\ShopBundle\Context\ProductInterface; | |||
use Lc\ShopBundle\Context\TaxRateInterface; | |||
use Lc\ShopBundle\Services\Utils; | |||
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\DateType; | |||
use Symfony\Component\Form\Extension\Core\Type\HiddenType; | |||
use Symfony\Component\Form\Extension\Core\Type\NumberType; | |||
use function PHPSTORM_META\type; | |||
use Symfony\Component\Form\AbstractType; | |||
use Symfony\Component\Form\Extension\Core\Type\TextType; | |||
use Symfony\Component\Form\FormBuilderInterface; | |||
use Symfony\Component\OptionsResolver\OptionsResolver; | |||
class OrderProductType extends AbstractType | |||
{ | |||
protected $em; | |||
protected $utils; | |||
public function __construct(EntityManagerInterface $entityManager, Utils $utils) | |||
{ | |||
$this->em = $entityManager; | |||
$this->utils = $utils; | |||
} | |||
public function buildForm(FormBuilderInterface $builder, array $options) | |||
{ | |||
$productClass = $this->em->getClassMetadata(ProductInterface::class); | |||
$builder->add('product', EntityType::class, array( | |||
'class' => $productClass->name, | |||
'placeholder'=> '', | |||
'choice_label'=> function($product){ | |||
return $product->getProductFamily()->getTitle() . ' - ' . $product->getTitle(); | |||
} | |||
)); | |||
$builder->add('quantity', NumberType::class, array( | |||
'label' => 'Quantité', | |||
'attr' => [ | |||
'append_html' => 'g' | |||
] | |||
)); | |||
} | |||
public function configureOptions(OptionsResolver $resolver) | |||
{ | |||
$resolver->setDefaults([ | |||
'data_class' => $this->em->getClassMetadata(OrderProductInterface::class)->getName(), | |||
]); | |||
} | |||
} |
@@ -98,7 +98,39 @@ abstract class Address extends AbstractEntity | |||
public function __toString() | |||
{ | |||
return $this->getTitle().' - '.$this->getZip().' '.$this->getCity() ; | |||
return $this->getTitle() . ' - ' . $this->getZip() . ' ' . $this->getCity(); | |||
} | |||
public function getSummaryShort() | |||
{ | |||
return $this->getAddress() . ' - ' . $this->getZip() . ' ' . $this->getCity(); | |||
} | |||
public function getSummary() | |||
{ | |||
$html = ''; | |||
if ($this->getTitle()) { | |||
$html .= $this->getTitle() . '<br />'; | |||
} | |||
if ($this->getLastname() || $this->getFirstname()) { | |||
$html .= $this->getLastname() . ' ' . $this->getFirstname() . '<br />'; | |||
} | |||
if ($this->getAddress()) { | |||
$html .= $this->getAddress() . '<br />'; | |||
} | |||
if ($this->getZip() || $this->getCity()) { | |||
$html .= $this->getZip() . ' ' . $this->getCity() . '<br />'; | |||
} | |||
if ($this->getPhone()) { | |||
$html .= 'Tél. ' . $this->getPhone(); | |||
} | |||
return $html; | |||
} | |||
public function getUser(): ?User |
@@ -11,7 +11,7 @@ use Lc\ShopBundle\Context\FilterMerchantInterface; | |||
/** | |||
* @ORM\MappedSuperclass() | |||
*/ | |||
abstract class OrderShop implements FilterMerchantInterface | |||
abstract class OrderShop extends AbstractEntity implements FilterMerchantInterface | |||
{ | |||
/** | |||
@@ -50,18 +50,13 @@ abstract class OrderShop implements FilterMerchantInterface | |||
*/ | |||
protected $meanPayment; | |||
/** | |||
* @ORM\Column(type="boolean", nullable=true) | |||
*/ | |||
protected $tillerSynchronisation; | |||
/** | |||
* @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\OrderStatusHistoryInterface", mappedBy="orderShop", orphanRemoval=true) | |||
*/ | |||
protected $orderStatusHistories; | |||
/** | |||
* @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\OrderProductInterface", mappedBy="orderShop", orphanRemoval=true) | |||
* @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\OrderProductInterface", mappedBy="orderShop", cascade={"persist", "remove"}, orphanRemoval=true) | |||
*/ | |||
protected $orderProducts; | |||
@@ -97,6 +92,30 @@ abstract class OrderShop implements FilterMerchantInterface | |||
$this->creditHistories = new ArrayCollection(); | |||
} | |||
public function getDateCreated() | |||
{ | |||
$orderStatusHistory = $this->getOrderStatusHistory('new') ; | |||
if($orderStatusHistory) { | |||
return $orderStatusHistory->getCreatedAt() ; | |||
} | |||
return null ; | |||
} | |||
public function getOrderStatusHistory($status) | |||
{ | |||
$orderStatusHistories = $this->getOrderStatusHistories() ; | |||
if(count($orderStatusHistories) > 0) { | |||
foreach($orderStatusHistories as $orderStatusHistory) { | |||
if($orderStatusHistory->getOrderStatus() == $status) { | |||
return $orderStatusHistory ; | |||
} | |||
} | |||
} | |||
return null ; | |||
} | |||
public function getMerchant(): ?Merchant | |||
{ | |||
return $this->merchant; |
@@ -2,6 +2,8 @@ | |||
namespace Lc\ShopBundle\Model; | |||
use App\Entity\User; | |||
use App\Entity\UserPointSale; | |||
use Doctrine\Common\Collections\ArrayCollection; | |||
use Doctrine\Common\Collections\Collection; | |||
use Doctrine\ORM\Mapping as ORM; | |||
@@ -36,15 +38,17 @@ abstract class PointSale extends AbstractDocumentEntity implements FilterMultipl | |||
*/ | |||
protected $address; | |||
/** | |||
* @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\UserPointSaleInterface", mappedBy="pointSale", orphanRemoval=true) | |||
*/ | |||
protected $userPointSales; | |||
public function labelAdminChoice(){ | |||
return $this->getTitle(); | |||
} | |||
public function __construct() | |||
{ | |||
$this->merchants = new ArrayCollection(); | |||
$this->pointSaleDayInfos = new ArrayCollection(); | |||
$this->userPointSales = new ArrayCollection(); | |||
} | |||
public function __toString() | |||
@@ -52,6 +56,11 @@ abstract class PointSale extends AbstractDocumentEntity implements FilterMultipl | |||
return $this->getTitle() ; | |||
} | |||
public function labelAdminChoice() | |||
{ | |||
return $this->getTitle(); | |||
} | |||
/** | |||
* @return Collection|Merchant[] | |||
*/ | |||
@@ -132,4 +141,35 @@ abstract class PointSale extends AbstractDocumentEntity implements FilterMultipl | |||
return $this; | |||
} | |||
/** | |||
* @return Collection|UserPointSale[] | |||
*/ | |||
public function getUserPointSales(): Collection | |||
{ | |||
return $this->userPointSales; | |||
} | |||
public function addUserPointSale(UserPointSale $userPointSale): self | |||
{ | |||
if (!$this->userPointSales->contains($userPointSale)) { | |||
$this->userPointSales[] = $userPointSale; | |||
$userPointSale->setPointSale($this); | |||
} | |||
return $this; | |||
} | |||
public function removeUserPointSale(UserPointSale $userPointSale): self | |||
{ | |||
if ($this->userPointSales->contains($userPointSale)) { | |||
$this->userPointSales->removeElement($userPointSale); | |||
// set the owning side to null (unless already changed) | |||
if ($userPointSale->getPointSale() === $this) { | |||
$userPointSale->setPointSale(null); | |||
} | |||
} | |||
return $this; | |||
} | |||
} |
@@ -3,6 +3,7 @@ | |||
namespace Lc\ShopBundle\Model; | |||
use App\Entity\Newsletter; | |||
use App\Entity\UserPointSale; | |||
use Doctrine\Common\Collections\ArrayCollection; | |||
use Doctrine\Common\Collections\Collection; | |||
use Doctrine\ORM\Mapping as ORM; | |||
@@ -80,6 +81,11 @@ abstract class User extends UserModelFOS | |||
*/ | |||
protected $favoriteProductFamilies; | |||
/** | |||
* @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\UserPointSaleInterface", mappedBy="user", orphanRemoval=true) | |||
*/ | |||
protected $userPointSales; | |||
public function __construct() | |||
{ | |||
@@ -91,6 +97,13 @@ abstract class User extends UserModelFOS | |||
$this->groupUsers = new ArrayCollection(); | |||
$this->newsletters = new ArrayCollection(); | |||
$this->favoriteProductFamilies = new ArrayCollection(); | |||
$this->userPointSales = new ArrayCollection(); | |||
} | |||
public function getSummary() | |||
{ | |||
return strtoupper($this->getLastname()).' '.$this->getFirstname(). ' ('.$this->getEmail().')'; | |||
} | |||
public function setEmail($email) | |||
@@ -374,4 +387,35 @@ abstract class User extends UserModelFOS | |||
return $this; | |||
} | |||
/** | |||
* @return Collection|UserPointSale[] | |||
*/ | |||
public function getUserPointSales(): Collection | |||
{ | |||
return $this->userPointSales; | |||
} | |||
public function addUserPointSale(UserPointSale $userPointSale): self | |||
{ | |||
if (!$this->userPointSales->contains($userPointSale)) { | |||
$this->userPointSales[] = $userPointSale; | |||
$userPointSale->setUser($this); | |||
} | |||
return $this; | |||
} | |||
public function removeUserPointSale(UserPointSale $userPointSale): self | |||
{ | |||
if ($this->userPointSales->contains($userPointSale)) { | |||
$this->userPointSales->removeElement($userPointSale); | |||
// set the owning side to null (unless already changed) | |||
if ($userPointSale->getUser() === $this) { | |||
$userPointSale->setUser(null); | |||
} | |||
} | |||
return $this; | |||
} | |||
} |
@@ -0,0 +1,64 @@ | |||
<?php | |||
namespace Lc\ShopBundle\Model; | |||
use Doctrine\ORM\Mapping as ORM; | |||
/** | |||
* @ORM\MappedSuperclass | |||
*/ | |||
abstract class UserPointSale | |||
{ | |||
/** | |||
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\UserInterface", inversedBy="userPointSales") | |||
* @ORM\JoinColumn(nullable=false) | |||
*/ | |||
protected $user; | |||
/** | |||
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\PointSaleInterface", inversedBy="userPointSales") | |||
* @ORM\JoinColumn(nullable=false) | |||
*/ | |||
protected $pointSale; | |||
/** | |||
* @ORM\Column(type="text", nullable=true) | |||
*/ | |||
protected $comment; | |||
public function getUser(): ?User | |||
{ | |||
return $this->user; | |||
} | |||
public function setUser(?User $user): self | |||
{ | |||
$this->user = $user; | |||
return $this; | |||
} | |||
public function getPointSale(): ?PointSale | |||
{ | |||
return $this->pointSale; | |||
} | |||
public function setPointSale(?PointSale $pointSale): self | |||
{ | |||
$this->pointSale = $pointSale; | |||
return $this; | |||
} | |||
public function getComment(): ?string | |||
{ | |||
return $this->comment; | |||
} | |||
public function setComment(?string $comment): self | |||
{ | |||
$this->comment = $comment; | |||
return $this; | |||
} | |||
} |
@@ -18,4 +18,73 @@ class OrderShopRepository extends BaseRepository implements DefaultRepositoryInt | |||
return OrderShopInterface::class; | |||
} | |||
public function findCartCurrent($params) | |||
{ | |||
$query = $this->createQueryBuilder('e') ; | |||
if(isset($params['user'])) { | |||
$query->andWhere('e.user = :user')->setParameter('user', $params['user']) ; | |||
} | |||
if(isset($params['visitor'])) { | |||
$query->andWhere('e.visitor = :visitor')->setParameter('visitor', $params['visitor']) ; | |||
} | |||
$query->leftJoin('e.orderStatusHistories', 'orderStatusHistories') | |||
->andWhere('SIZE(e.orderStatusHistories) = 0') ; | |||
$results = $query->getQuery()->getResult() ; | |||
if($results) { | |||
return $results[0] ; | |||
} | |||
return null ; | |||
} | |||
public function findAllBy($params = []) | |||
{ | |||
$query = $this->findByMerchantQuery() ; | |||
if(isset($params['dateStart'])) { | |||
$query->andWhere('e.createdAt >= :dateStart')->setParameter('dateStart', $params['dateStart']) ; | |||
} | |||
if(isset($params['dateEnd'])) { | |||
$query->andWhere('e.createdAt <= :dateEnd')->setParameter('dateEnd', $params['dateEnd']) ; | |||
} | |||
if(!isset($params['isCart'])) { | |||
$query = $this->filterOrderCart($query) ; | |||
} | |||
if(isset($params['user'])) { | |||
$query->andWhere('e.user = :user')->setParameter('user', $params['user']) ; | |||
} | |||
$query->orderBy('e.createdAt', 'DESC') ; | |||
return $query->getQuery()->getResult() ; | |||
} | |||
public function findAllByDateStartEnd($dateStart, $dateEnd) | |||
{ | |||
$query = $this->findByMerchantQuery() | |||
->andWhere('e.createdAt >= :dateStart') | |||
->setParameter('dateStart', $dateStart) | |||
->andWhere('e.createdAt <= :dateEnd') | |||
->setParameter('dateEnd', $dateEnd); | |||
$this->filterOrderCart($query) ; | |||
return $query->getQuery()->getResult() ; | |||
} | |||
public function filterOrderCart($query, $isCart = false) | |||
{ | |||
$operator = $isCart ? '=' : '>' ; | |||
return $query->leftJoin('e.orderStatusHistories', 'orderStatusHistories') | |||
->andWhere('SIZE(e.orderStatusHistories) '.$operator.' 0') ; | |||
} | |||
} |
@@ -0,0 +1,22 @@ | |||
<?php | |||
namespace Lc\ShopBundle\Repository; | |||
use Lc\ShopBundle\Context\DefaultRepositoryInterface; | |||
use Lc\ShopBundle\Context\PointSaleInterface; | |||
/** | |||
* @method UserPointSaleInterface|null find($id, $lockMode = null, $lockVersion = null) | |||
* @method UserPointSaleInterface|null findOneBy(array $criteria, array $orderBy = null) | |||
* @method UserPointSaleInterface[] findAll() | |||
* @method UserPointSaleInterface[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) | |||
*/ | |||
class UserPointSaleRepository extends BaseRepository implements DefaultRepositoryInterface | |||
{ | |||
public function getInterfaceClass() | |||
{ | |||
return UserPointSaleInterface::class; | |||
} | |||
} |
@@ -3,7 +3,7 @@ easy_admin: | |||
design: | |||
templates: | |||
list: '@LcShop/backend/default/list.html.twig' | |||
layout: '@LcShop/backend/default/layout.html.twig' | |||
layout: '@LcShop/backend/default/layout/layout.html.twig' | |||
menu: '@LcShop/backend/default/menu.html.twig' | |||
edit: '@LcShop/backend/default/edit.html.twig' | |||
new: '@LcShop/backend/default/new.html.twig' |
@@ -1,7 +1,7 @@ | |||
admin_switch_merchant: | |||
path: /admin/switch-merchant | |||
controller: Lc\ShopBundle\Controller\Admin\MerchantController::switchMerchantAction | |||
controller: Lc\ShopBundle\Controller\Backend\MerchantController::switchMerchantAction | |||
lc_api: | |||
path: /api/{entity}/{id} |
@@ -2,6 +2,8 @@ | |||
body{font-size: 0.9rem;} | |||
[class*="sidebar-dark-"] .nav-sidebar > .nav-item.menu-open , [class*="sidebar-dark-"] .nav-sidebar > .nav-item:hover {background:rgba(255,255,255,.1); } | |||
.hidden{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;} |
@@ -54,6 +54,7 @@ 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)) ; | |||
} |
@@ -300,6 +300,7 @@ let mixinTemplate = { | |||
immediate: true, // makes the watcher fire on first render, too. | |||
handler() { | |||
if (this.template) { | |||
var res = Vue.compile(this.template); | |||
this.templateRender = res.render; |
@@ -0,0 +1,231 @@ | |||
// Reference array sent to dynamic staticRenderFns | |||
var staticRenderFns = []; | |||
Vue.component('order-product-form', { | |||
mixins: [mixinTemplate], | |||
props: ['template', 'keyForm'], | |||
computed: {}, | |||
data() { | |||
return Object.assign( | |||
{ | |||
title: null, | |||
price: null, | |||
priceWithTax: null, | |||
priceWithTaxAndReduction: null, | |||
totalWithoutTax: null, | |||
totalWithTax: null, | |||
buyingPrice: null, | |||
quantity: 1, | |||
unit: null, | |||
product: null | |||
}, window.orderProductForm[this.keyForm]) | |||
}, | |||
mounted: function () { | |||
this.setSelect2(); | |||
this.updateQuantity(); | |||
}, | |||
methods: { | |||
updateLine: function (data) { | |||
this.price = data.price; | |||
this.priceWithTax = data.priceWithTax; | |||
this.priceWithTaxAndReduction = data.priceWithTaxAndReduction; | |||
this.priceWithTax = data.priceWithTax; | |||
this.updateQuantity(); | |||
this.$parent.updateTotalPrice(); | |||
}, | |||
updateQuantity: function () { | |||
this.totalWithTax = parseFloat(this.priceWithTaxAndReduction * this.quantity).toFixed(2); | |||
this.totalWithoutTax = parseFloat(this.price * this.quantity).toFixed(2); | |||
this.$parent.updateTotalPrice(); | |||
}, | |||
setSelect2: function () { | |||
var selectProduct = $(this.$el).find('select.form-control'); | |||
var select2Product =setSelect2(selectProduct); | |||
var vue = this; | |||
select2Product.on('select2:select', function (e) { | |||
//dispatch event pour que le select soit "submitable" | |||
var event = new Event('change'); | |||
e.target.dispatchEvent(event); | |||
this.product = select2Product.val(); | |||
$.ajax({ | |||
url: DOMAIN + "/api/product/" + this.product, | |||
method: "GET", | |||
dataType: "json", | |||
success: function (response) { | |||
vue.updateLine(response); | |||
} | |||
}); | |||
}) | |||
}, | |||
deleteProductForm: function () { | |||
if (confirm('Êtes-vous sur de cette action ?')) { | |||
this.$parent.formOrderProductArray.splice(this.keyForm, 1); | |||
} | |||
} | |||
}, | |||
watch: {} | |||
}); | |||
Vue.component('delivery-availability-choice', { | |||
mixins: [mixinTemplate], | |||
props: ['template', 'key', 'name', 'id'], | |||
data() { | |||
return { | |||
id: -1, | |||
deliveryAvailability: null, // Have to assign to this variable** | |||
deliveryAvailabilities: null, // Have to assign to this variable** | |||
selected_category: "", | |||
value: null, | |||
label: null | |||
}; | |||
}, | |||
mounted() { | |||
}, | |||
methods: { | |||
updateDeliveryAvailability() { | |||
log(this.deliveryAvailability); | |||
/*log('bnfbf'); | |||
var self = this; | |||
$.ajax({ | |||
url: DOMAIN+"/admin/delivery-availaibility/14", | |||
method: "POST", | |||
dataType: "", | |||
success: function (response) { | |||
self.categories = response.categories; | |||
} | |||
});*/ | |||
} | |||
} | |||
}); | |||
appOrder = new Vue({ | |||
el: '#lc-order-edit', | |||
delimiters: ['${', '}'], | |||
computed: {}, | |||
data() { | |||
return Object.assign( | |||
{ | |||
currentSection: 'cart', | |||
formOrderProductArray: [], | |||
indexOrderProductForm: 0, | |||
formDeliveryAvailabilityLargeArray: [], | |||
formDeliveryAvailabilityShortArray: [], | |||
indexDeliveryAvailability: null, | |||
invoiceAddress: null, | |||
deliveryAddress: null, | |||
deliveryType: null, | |||
deliveryPointSale: null, | |||
deliveryAvailability: 'niche', | |||
totalWithTax: null, | |||
totalWithoutTax: null, | |||
sectionsArray: [ | |||
{ | |||
name: 'cart', | |||
nameDisplay: 'Panier' | |||
}, | |||
{ | |||
name: 'addresses', | |||
nameDisplay: 'Adresses' | |||
}, | |||
{ | |||
name: 'delivery', | |||
nameDisplay: 'Livraisons' | |||
} | |||
] | |||
})/*, window.appOrderProductFamilyValues)*/; | |||
}, | |||
mounted: function () { | |||
}, | |||
methods: { | |||
addProductToOrder:function(){ | |||
if(this.addProductId && this.addProductQuantity){ | |||
} | |||
}, | |||
updateTotalPrice: function () { | |||
this.totalWithoutTax = 0; | |||
this.totalWithTax = 0; | |||
for (var i = 0; i < this.$refs.orderProductForm.length; i++) { | |||
var line = this.$refs.orderProductForm[i]; | |||
this.totalWithoutTax = parseFloat(parseFloat(this.totalWithoutTax) + parseFloat(line.totalWithoutTax)).toFixed(2); | |||
this.totalWithTax = parseFloat(parseFloat(this.totalWithTax) + parseFloat(line.totalWithTax)).toFixed(2); | |||
} | |||
}, | |||
changeSection: function (section) { | |||
this.updateChild(); | |||
this.currentSection = section.name; | |||
this.addDeliveryAvailabilityChoice(); | |||
}, | |||
addDeliveryAvailabilityChoice: function () { | |||
$.ajax({ | |||
url: DOMAIN + "/admin/delivery-availaibility/" + this.deliveryAddress, | |||
method: "POST", | |||
dataType: "", | |||
success: function (response) { | |||
for (i = 0; i < response.large.length; i++) { | |||
slot = response.large[i]; | |||
var deliveryAvailabilityForm = $('#delivery-availability-short').data('prototype'); | |||
deliveryAvailabilityForm = deliveryAvailabilityForm.replace(/__id__/g, "{{ form.deliveryAvailabilityZone.vars.id }}_"+slot.id ); | |||
deliveryAvailabilityForm = deliveryAvailabilityForm.replace(/__name__/g, "{{ form.deliveryAvailabilityZone.vars.full_name }}" ); | |||
deliveryAvailabilityForm = deliveryAvailabilityForm.replace(/__value__/g, slot.id ); | |||
deliveryAvailabilityForm = deliveryAvailabilityForm.replace(/__label__/g, slot.label ); | |||
appOrder.formDeliveryAvailabilityLargeArray.push(deliveryAvailabilityForm); | |||
appOrder.indexDeliveryAvailability++; | |||
} | |||
for (i = 0; i < response.short.length; i++) { | |||
slot = response.short[i]; | |||
var deliveryAvailabilityForm = $('#delivery-availability-short').data('prototype'); | |||
deliveryAvailabilityForm = deliveryAvailabilityForm.replace(/__id__/g, "{{ form.deliveryAvailabilityZone.vars.id }}_"+slot.id ); | |||
deliveryAvailabilityForm = deliveryAvailabilityForm.replace(/__name__/g, "{{ form.deliveryAvailabilityZone.vars.full_name }}" ); | |||
deliveryAvailabilityForm = deliveryAvailabilityForm.replace(/__value__/g, slot.id ); | |||
deliveryAvailabilityForm = deliveryAvailabilityForm.replace(/__label__/g, slot.label ); | |||
appOrder.formDeliveryAvailabilityShortArray.push(deliveryAvailabilityForm); | |||
appOrder.indexDeliveryAvailability++; | |||
} | |||
} | |||
}); | |||
}, | |||
addOrderProductForm: function () { | |||
var $collectionHolder = $('#order-products-list'); | |||
var prototype = $collectionHolder.data('prototype'); | |||
var newForm = prototype; | |||
newForm = newForm.replace(/__name__/g, this.indexOrderProductForm); | |||
this.formOrderProductArray.push(newForm); | |||
this.indexOrderProductForm++; | |||
//updateSortableProducts(); | |||
}, | |||
updateChild: function () { | |||
if (typeof this.$refs.productForm !== 'undefined') { | |||
for (i = 0; i < this.$refs.productForm.length; i++) { | |||
this.$refs.productForm[i].updateProductForm(); | |||
this.$refs.productForm[i].updateProductView(); | |||
} | |||
} | |||
}, | |||
getUnitReference: function () { | |||
if (typeof this.$refs.productUnitPrice !== 'undefined') { | |||
return this.$refs.productUnitPrice.unitReference; | |||
} | |||
} | |||
}, | |||
watch: { | |||
title: function () { | |||
this.updateChild() | |||
}, | |||
} | |||
}); | |||
@@ -1,131 +1,93 @@ | |||
// Reference array sent to dynamic staticRenderFns | |||
var staticRenderFns = []; | |||
Vue.component('order-product-form', { | |||
Vue.component('order-product', { | |||
mixins: [mixinTemplate], | |||
props: ['template', 'keyForm'], | |||
props: ['template', 'keyItem', 'orderProduct'], | |||
computed: {}, | |||
data() { | |||
return Object.assign( | |||
{ | |||
title: null, | |||
price: null, | |||
priceWithTax: null, | |||
totalWithoutTax: null, | |||
totalWithTax: null, | |||
buyingPrice: null, | |||
quantity: 1, | |||
unit: null, | |||
product: null | |||
}, window.orderProductForm[this.keyForm]) | |||
}, | |||
/* data:function() { | |||
return{ | |||
product:null | |||
}; | |||
/!* return Object.assign( | |||
{ | |||
/!*title: null, | |||
price: null, | |||
priceWithTax: null, | |||
priceWithTaxAndReduction: null, | |||
totalWithoutTax: null, | |||
totalWithTax: null, | |||
buyingPrice: null, | |||
quantity: 1, | |||
unit: null, | |||
product: null*!/ | |||
}, window.orderProducts[this.key])*!/ | |||
},*/ | |||
mounted: function () { | |||
this.setSelect2(); | |||
this.updateQuantity(); | |||
log(this.keyItem); | |||
this.setFields() | |||
//this.$el.replace(/__name__/g, this.key); | |||
}, | |||
methods: { | |||
updateLine: function (data) { | |||
this.price = data.price; | |||
this.priceWithTax = getPriceWithTax(this.price, data.taxRate); | |||
this.updateQuantity(); | |||
this.$parent.updateTotalPrice(); | |||
init: function () { | |||
//log(this.$els); | |||
//log(this.$element); | |||
}, | |||
updateQuantity: function () { | |||
this.totalWithTax = parseFloat(this.priceWithTax * this.quantity).toFixed(3); | |||
this.totalWithoutTax = parseFloat(this.price * this.quantity).toFixed(3); | |||
this.$parent.updateTotalPrice(); | |||
}, | |||
setSelect2: function () { | |||
var select = $(this.$el).find('select.form-control'); | |||
var monSelect = $(this.$el).find('select.form-control').select2({ | |||
//theme: 'bootstrap', | |||
debug: true, | |||
placeholder: "Select an option" | |||
setFields: function () { | |||
var app = this; | |||
fields = ['fieldQuantity', 'fieldProduct']; | |||
fields.forEach(function (field) { | |||
var name = $(app.$refs[field]).prop('name'); | |||
var id = $(app.$refs[field]).prop('id'); | |||
name = name.replace(/__name__/g, app.keyItem); | |||
id = id.replace(/__name__/g, app.keyItem); | |||
$(app.$refs[field]).prop('name', name); | |||
$(app.$refs[field]).prop('id', id); | |||
//log(app.$refs[field]); | |||
}); | |||
var vue = this; | |||
monSelect.on('select2:select', function (e) { | |||
//dispatch event pour que le select soit "submitable" | |||
var event = new Event('change'); | |||
e.target.dispatchEvent(event); | |||
this.product = monSelect.val(); | |||
$.ajax({ | |||
url: DOMAIN + "/api/product/" + this.product, | |||
method: "GET", | |||
dataType: "", | |||
success: function (response) { | |||
vue.updateLine(response); | |||
} | |||
}); | |||
}) | |||
}, | |||
deleteProductForm: function () { | |||
if (confirm('Êtes-vous sur de cette action ?')) { | |||
this.$parent.formOrderProductArray.splice(this.keyForm, 1); | |||
} | |||
updateOrderProducts: function () { | |||
this.$parent.updateOrderProducts(); | |||
}, | |||
deleteOrderProduct: function () { | |||
$(this.$refs.fieldQuantity).val(0); | |||
this.$parent.updateOrderProducts(); | |||
} | |||
}, | |||
watch: {} | |||
}); | |||
/*log($('#order-products-list').data('prototype')); | |||
var prototype = $('#order-products-list').data('prototype'); | |||
var newForm = prototype; | |||
newForm = newForm.replace(/__name__/g, key); | |||
Vue.component('delivery-availability-choice', { | |||
mixins: [mixinTemplate], | |||
props: ['template', 'key', 'name', 'id'], | |||
data() { | |||
return { | |||
id: -1, | |||
deliveryAvailability: null, // Have to assign to this variable** | |||
deliveryAvailabilities: null, // Have to assign to this variable** | |||
selected_category: "", | |||
value: null, | |||
label: null | |||
}; | |||
}, | |||
mounted() { | |||
}, | |||
methods: { | |||
updateDeliveryAvailability() { | |||
log(this.deliveryAvailability); | |||
/*log('bnfbf'); | |||
var self = this; | |||
$.ajax({ | |||
url: DOMAIN+"/admin/delivery-availaibility/14", | |||
method: "POST", | |||
dataType: "", | |||
success: function (response) { | |||
self.categories = response.categories; | |||
} | |||
});*/ | |||
} | |||
*/ | |||
} | |||
}); | |||
appOrder = new Vue({ | |||
el: '#lc-order-edit', | |||
delimiters: ['${', '}'], | |||
computed: {}, | |||
computed: { | |||
deliveryAddressHtml: function () { | |||
log(this.order.deliveryAddress); | |||
return this.order.deliveryAddress; | |||
} | |||
}, | |||
data() { | |||
return Object.assign( | |||
{ | |||
currentSection: 'cart', | |||
formOrderProductArray: [], | |||
indexOrderProductForm: 0, | |||
formDeliveryAvailabilityLargeArray: [], | |||
formDeliveryAvailabilityShortArray: [], | |||
indexDeliveryAvailability: null, | |||
invoiceAddress: null, | |||
deliveryAddress: null, | |||
templateTest: window.templateTest, | |||
orderProducts: [], | |||
order: [], | |||
deliveryType: null, | |||
deliveryPointSale: null, | |||
deliveryAvailability: 'niche', | |||
totalWithTax: null, | |||
totalWithoutTax: null, | |||
isLoading: true, | |||
addProductId: null, | |||
addProductQuantity: null, | |||
sectionsArray: [ | |||
{ | |||
name: 'cart', | |||
@@ -143,85 +105,49 @@ appOrder = new Vue({ | |||
})/*, window.appOrderProductFamilyValues)*/; | |||
}, | |||
mounted: function () { | |||
log('ncnnc'); | |||
log(window.templateTest); | |||
this.updateOrder(window.orderObject); | |||
//log($(this.$el).find('#orderProductsForm').replace(/__name__/g, 0)); | |||
}, | |||
methods: { | |||
updateTotalPrice: function () { | |||
this.totalWithoutTax = 0; | |||
this.totalWithTax = 0; | |||
for (var i = 0; i < this.$refs.orderProductForm.length; i++) { | |||
var line = this.$refs.orderProductForm[i]; | |||
this.totalWithoutTax = parseFloat(parseFloat(this.totalWithoutTax) + parseFloat(line.totalWithoutTax)).toFixed(2); | |||
this.totalWithTax = parseFloat(parseFloat(this.totalWithTax) + parseFloat(line.totalWithTax)).toFixed(2); | |||
} | |||
addProductToOrder: function () { | |||
this.postForm('#addProductToOrderForm', false); | |||
}, | |||
changeSection: function (section) { | |||
this.updateChild(); | |||
this.currentSection = section.name; | |||
this.addDeliveryAvailabilityChoice(); | |||
updateOrderProducts: function () { | |||
this.postForm('#orderProductsForm', false); | |||
}, | |||
updateOrderInvoiceAddress: function () { | |||
this.postForm('#orderInvoiceAddressForm', '#modal-order-invoice-address'); | |||
}, | |||
updateOrderDeliveryAddress: function () { | |||
this.postForm('#orderDeliveryAddressForm', '#modal-order-invoice-address'); | |||
}, | |||
addDeliveryAvailabilityChoice: function () { | |||
updateOrderDeliveryAvailability:function(){ | |||
this.postForm('#orderDeliveryAvailabilityForm', '#modal-order-delivery-availability'); | |||
}, | |||
postForm:function(formId, modalId){ | |||
var app = this; | |||
this.isLoading = true; | |||
if(modalId)$(modalId).modal('hide'); | |||
$.ajax({ | |||
url: DOMAIN + "/admin/delivery-availaibility/" + this.deliveryAddress, | |||
url: $(formId).prop('action'), | |||
method: "POST", | |||
dataType: "", | |||
data: $(formId).serialize(), | |||
dataType: "json", | |||
success: function (response) { | |||
for (i = 0; i < response.large.length; i++) { | |||
slot = response.large[i]; | |||
var deliveryAvailabilityForm = $('#delivery-availability-short').data('prototype'); | |||
deliveryAvailabilityForm = deliveryAvailabilityForm.replace(/__id__/g, "{{ form.deliveryAvailabilityZone.vars.id }}_"+slot.id ); | |||
deliveryAvailabilityForm = deliveryAvailabilityForm.replace(/__name__/g, "{{ form.deliveryAvailabilityZone.vars.full_name }}" ); | |||
deliveryAvailabilityForm = deliveryAvailabilityForm.replace(/__value__/g, slot.id ); | |||
deliveryAvailabilityForm = deliveryAvailabilityForm.replace(/__label__/g, slot.label ); | |||
appOrder.formDeliveryAvailabilityLargeArray.push(deliveryAvailabilityForm); | |||
appOrder.indexDeliveryAvailability++; | |||
} | |||
for (i = 0; i < response.short.length; i++) { | |||
slot = response.short[i]; | |||
var deliveryAvailabilityForm = $('#delivery-availability-short').data('prototype'); | |||
deliveryAvailabilityForm = deliveryAvailabilityForm.replace(/__id__/g, "{{ form.deliveryAvailabilityZone.vars.id }}_"+slot.id ); | |||
deliveryAvailabilityForm = deliveryAvailabilityForm.replace(/__name__/g, "{{ form.deliveryAvailabilityZone.vars.full_name }}" ); | |||
deliveryAvailabilityForm = deliveryAvailabilityForm.replace(/__value__/g, slot.id ); | |||
deliveryAvailabilityForm = deliveryAvailabilityForm.replace(/__label__/g, slot.label ); | |||
appOrder.formDeliveryAvailabilityShortArray.push(deliveryAvailabilityForm); | |||
appOrder.indexDeliveryAvailability++; | |||
} | |||
generateNotice(response.status, response.message); | |||
app.updateOrder(response.data); | |||
} | |||
}); | |||
}, | |||
addOrderProductForm: function () { | |||
var $collectionHolder = $('#order-products-list'); | |||
var prototype = $collectionHolder.data('prototype'); | |||
var newForm = prototype; | |||
newForm = newForm.replace(/__name__/g, this.indexOrderProductForm); | |||
this.formOrderProductArray.push(newForm); | |||
this.indexOrderProductForm++; | |||
//updateSortableProducts(); | |||
}, | |||
updateChild: function () { | |||
if (typeof this.$refs.productForm !== 'undefined') { | |||
for (i = 0; i < this.$refs.productForm.length; i++) { | |||
this.$refs.productForm[i].updateProductForm(); | |||
this.$refs.productForm[i].updateProductView(); | |||
} | |||
} | |||
updateOrder: function (orderObject) { | |||
this.orderProducts = orderObject.orderProducts; | |||
this.order = orderObject; | |||
this.isLoading = false; | |||
}, | |||
getUnitReference: function () { | |||
if (typeof this.$refs.productUnitPrice !== 'undefined') { | |||
return this.$refs.productUnitPrice.unitReference; | |||
} | |||
} | |||
}, | |||
watch: { | |||
title: function () { | |||
this.updateChild() | |||
}, | |||
} | |||
}); | |||
@@ -39,13 +39,17 @@ group: | |||
ReductionCatalog: | |||
info: Informations principal | |||
conditions: Condictions d'application | |||
OrderShop: | |||
resume: Résumé de commande | |||
addProduct: Ajout de produit à la commande | |||
None: Aucune valeur | |||
label.form.empty_value: Choisissez une option | |||
form.label.delete: Supprimer l'image | |||
field: | |||
default: | |||
placeholder: Choisissez une option | |||
deliveryPointSale: Lieu de livraison | |||
deliveryAvailabilty: Créneau de livraison | |||
id: Id | |||
status: En ligne | |||
statusOptions: | |||
@@ -106,7 +110,7 @@ field: | |||
warningMessageType: Type de message d'avertissement | |||
warningMessageTypeOptions: | |||
warning: Attention (jaune) | |||
info: Information (bleu) | |||
info: Information (gris) | |||
error: Erreur (rouge) | |||
success: Succès (vert) | |||
warningMessage: Contenu du message d'avertissement | |||
@@ -133,6 +137,8 @@ field: | |||
isSent: Envoyée | |||
behaviorTaxRate: Avec ou sans TVA | |||
behaviorTaxRateHelp: Appliquer la réduction sur le prix HT ou le prix TTC | |||
deliveryAddress: Addresse de livraison | |||
invoiceAddress: Addresse de facturation | |||
PointSale: | |||
code: Code | |||
codeHelp: Code utilisé pour retrouver l'ambassade dans le tunnel de commande (Non sensible à la casse) | |||
@@ -207,6 +213,13 @@ field: | |||
Address: | |||
city: Commune | |||
OrderShop: | |||
mainInfo: Information principal | |||
product: Produit | |||
user: Client | |||
orderNumber: Numéro de commande | |||
quantity: Quantité | |||
addOrderToProduct: Ajouter le produit | |||
action: | |||
new: Créer %entity_label% |
@@ -12,7 +12,13 @@ | |||
{% endmacro %} | |||
{% macro endCard(noCol = false) %} | |||
{% 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> | |||
</div> | |||
{% if noCol == false %}</div>{% endif %} |
@@ -50,91 +50,4 @@ | |||
{% block script_javascript %} | |||
{{ parent() }} | |||
<script src="{{ asset('bundles/lcshop/js/backend/script/default/init-edit.js') }}"></script> | |||
{#<script type="text/javascript"> | |||
$(function() { | |||
$('.edit-form').areYouSure({ 'message': '{{ 'form.are_you_sure'|trans({}, 'EasyAdminBundle')|e('js') }}' }); | |||
const entityForm = document.querySelector('form.edit-form'); | |||
const formSubmitButton = entityForm.querySelector('button[type="submit"]'); | |||
const inputFieldsSelector = 'input,select,textarea'; | |||
// Adding visual feedback for invalid fields: any ".form-group" with invalid fields | |||
// receives "has-error" class. The class is removed on click on the ".form-group" | |||
// itself to support custom/complex fields. | |||
formSubmitButton.addEventListener('click', function() { | |||
entityForm.querySelectorAll(inputFieldsSelector).forEach(function (input) { | |||
if (!input.validity.valid) { | |||
const formGroup = input.closest('div.form-group'); | |||
formGroup.classList.add('has-error'); | |||
formGroup.addEventListener('click', function onFormGroupClick() { | |||
formGroup.classList.remove('has-error'); | |||
formGroup.removeEventListener('click', onFormGroupClick); | |||
}); | |||
} | |||
}); | |||
}); | |||
// forms with tabs require some special treatment for errors. The problem | |||
// is when the field with errors is included in a tab not currently visible. | |||
// Browser shows this error "An invalid form control with name='...' is not focusable." | |||
// So, the user clicks on Submit button, the form is not submitted and the error | |||
// is not displayed. This JavaScript code ensures that each tab shows a badge with | |||
// the number of errors in it. | |||
formSubmitButton.addEventListener('click', function() { | |||
const formTabPanes = entityForm.querySelectorAll('.tab-pane'); | |||
if (0 === formTabPanes.length) { | |||
return; | |||
} | |||
let firstNavTabItemWithError = null; | |||
formTabPanes.forEach(function (tabPane) { | |||
let tabPaneNumErrors = 0; | |||
tabPane.querySelectorAll(inputFieldsSelector).forEach(function (input) { | |||
if (!input.validity.valid) { | |||
tabPaneNumErrors++; | |||
} | |||
}); | |||
let navTabItem = entityForm.querySelector('.nav-item a[href="#' + tabPane.id + '"]'); | |||
let existingErrorBadge = navTabItem.querySelector('span.badge.badge-danger'); | |||
if (null !== existingErrorBadge) { | |||
navTabItem.removeChild(existingErrorBadge); | |||
} | |||
if (tabPaneNumErrors > 0) { | |||
let newErrorBadge = document.createElement('span'); | |||
newErrorBadge.classList.add('badge', 'badge-danger'); | |||
newErrorBadge.title = 'form.tab.error_badge_title'; | |||
newErrorBadge.textContent = tabPaneNumErrors; | |||
navTabItem.appendChild(newErrorBadge); | |||
if (null === firstNavTabItemWithError) { | |||
firstNavTabItemWithError = navTabItem; | |||
} | |||
} | |||
}); | |||
if (firstNavTabItemWithError) { | |||
firstNavTabItemWithError.click(); | |||
} | |||
}); | |||
$('a.action-delete').on('click', function(e) { | |||
e.preventDefault(); | |||
$('#modal-delete').modal({ backdrop: true, keyboard: true }) | |||
.off('click', '#modal-delete-button') | |||
.on('click', '#modal-delete-button', function () { | |||
$('#delete-form').trigger('submit'); | |||
}); | |||
}); | |||
}); | |||
</script>#} | |||
{% endblock %} |
@@ -0,0 +1,5 @@ | |||
{% trans_default_domain "lcshop" %} | |||
{% block ajax %} | |||
{% endblock %} |
@@ -31,9 +31,10 @@ | |||
{% endblock %} | |||
{% block head_custom_stylesheets %} | |||
<link rel="stylesheet" href="{{ asset('bundles/lcshop/css/backend/custom.css') }}"> | |||
{% for asset_css in easyadmin_config('design.assets.css') %} | |||
<link rel="stylesheet" href="{{ asset(asset_css) }}"> | |||
{% endfor %} | |||
{% endblock head_custom_stylesheets %} | |||
{# | |||
@@ -48,7 +49,6 @@ | |||
{% set favicon = easyadmin_config('design.assets.favicon') %} | |||
<link rel="icon" type="{{ favicon.mime_type }}" href="{{ asset(favicon.path) }}"/> | |||
{% endblock %} | |||
</head> | |||
{% block body %} |
@@ -0,0 +1,76 @@ | |||
{% set _entity_config = easyadmin_entity(app.request.query.get('entity')) %} | |||
{# the empty string concatenation is needed when the primary key is an object (e.g. an Uuid object) #} | |||
{% set _entity_id = '' ~ attribute(entity, _entity_config.primary_key_field_name) %} | |||
{% trans_default_domain _entity_config.translation_domain %} | |||
{% set _trans_parameters = { '%entity_name%': _entity_config.name|trans, '%entity_label%': _entity_config.label|trans, '%entity_id%': _entity_id } %} | |||
{% extends _entity_config.templates.layout %} | |||
{% block body_id 'easyadmin-show-' ~ _entity_config.name ~ '-' ~ _entity_id %} | |||
{% block content_title %} | |||
{% apply spaceless %} | |||
{% set _default_title = 'show.page_title'|trans(_trans_parameters, 'EasyAdminBundle') %} | |||
{{ _entity_config.show.title is defined ? _entity_config.show.title|trans(_trans_parameters) : _default_title }} | |||
{% endapply %} | |||
{% endblock %} | |||
{% block content_footer_wrapper '' %} | |||
{% block main %} | |||
<div class="form-horizontal"> | |||
{% block show_fields %} | |||
{% set _fields_visible_by_user = fields|filter((metadata, field) => easyadmin_is_granted(metadata.permission)) %} | |||
{% for field, metadata in _fields_visible_by_user %} | |||
{% block show_field %} | |||
<div class="form-group field-{{ metadata.type|default('default')|lower }} {{ metadata.css_class|default('') }}"> | |||
<label class="control-label"> | |||
{{ metadata.label|trans(_trans_parameters)|raw }} | |||
</label> | |||
<div class="form-widget"> | |||
<div class="form-control"> | |||
{{ easyadmin_render_field_for_show_view(_entity_config.name, entity, metadata) }} | |||
</div> | |||
{% if metadata.help|default('') != '' %} | |||
<small class="form-help"><i class="fa fa-fw fa-info-circle"></i> {{ metadata.help|trans|raw }}</small> | |||
{% endif %} | |||
</div> | |||
</div> | |||
{% endblock %} | |||
{% endfor %} | |||
{% endblock %} | |||
</div> | |||
<section class="content-footer"> | |||
<div class="form-actions"> | |||
{% block item_actions %} | |||
{% set _show_actions = easyadmin_get_actions_for_show_item(_entity_config.name) %} | |||
{% set _request_parameters = app.request.query.all %} | |||
{{ include('@EasyAdmin/default/includes/_actions.html.twig', { | |||
actions: _show_actions, | |||
entity_config: _entity_config, | |||
request_parameters: _request_parameters, | |||
translation_domain: _entity_config.translation_domain, | |||
trans_parameters: _trans_parameters, | |||
item_id: _entity_id, | |||
item: entity | |||
}, with_context = false) }} | |||
{% endblock item_actions %} | |||
</div> | |||
</section> | |||
{% block delete_form %} | |||
{{ include('@EasyAdmin/default/includes/_delete_form.html.twig', { | |||
view: 'show', | |||
referer: app.request.query.get('referer', ''), | |||
delete_form: delete_form, | |||
_translation_domain: _entity_config.translation_domain, | |||
_trans_parameters: _trans_parameters, | |||
_entity_config: _entity_config, | |||
}, with_context = false) }} | |||
{% endblock delete_form %} | |||
{% endblock %} |
@@ -0,0 +1,14 @@ | |||
{{ form_start(form_add_product_to_order, {'attr': {"class" : 'row', 'id' : 'addProductToOrderForm'}}) }} | |||
{% form_theme form_add_product_to_order '@LcShop/backend/form/custom_bootstrap_4.html.twig' %} | |||
<div class="col-12"> | |||
{{ form_row(form_add_product_to_order.product, {'attr': {"v-model" : 'addProductId'}}) }} | |||
</div> | |||
<div class="col-12"> | |||
{{ form_row(form_add_product_to_order.quantity, {'attr': {"v-model" : 'addProductQuantity'}}) }} | |||
</div> | |||
<div class="col-12"> | |||
{{ form_row(form_add_product_to_order.addProductToOrder, {'attr': {"class": "btn-success float-right", "@click" : 'addProductToOrder'}}) }} | |||
</div> | |||
{{ form_end(form_add_product_to_order) }} | |||
@@ -0,0 +1,81 @@ | |||
{% import '@LcShop/backend/default/block/macros.html.twig' as macros %} | |||
{% import '@LcShop/backend/order/macros.html.twig' as orderMacros %} | |||
{% trans_default_domain 'lcshop' %} | |||
{{ macros.startCard(9, 'OrderShop.resume') }} | |||
<div class="col-4"> | |||
<h6><strong>{{ "field.OrderShop.mainInfo"|trans({}, 'lcshop') }} : </strong></h6> | |||
<p> | |||
<strong>{{ "field.OrderShop.user"|trans }} </strong><br /> | |||
<span>${order.user}</span> | |||
</p> | |||
<p> | |||
<strong>{{ "field.OrderShop.orderNumber"|trans }} </strong><br /> | |||
<span>${order.id}</span> | |||
</p> | |||
</div> | |||
<div class="col-4" > | |||
<div v-if="order.deliveryType == 'at-home'"> | |||
<h6><strong>{{ "field.default.deliveryAddress"|trans({}, 'lcshop') }} : </strong></h6> | |||
<address v-html="order.deliveryAddress"> | |||
</address> | |||
</div> | |||
<div v-else-if="order.deliveryType == 'point-sale'"> | |||
<h6><strong>{{ "field.default.deliveryPointSale"|trans({}, 'lcshop') }} : </strong></h6> | |||
<address v-html="order.deliveryPointSale"> | |||
</address> | |||
</div> | |||
<div v-else> | |||
Aucun lieu de livraison défini. | |||
</div> | |||
<button type="button" class="btn btn-default" data-toggle="modal" data-target="#modal-order-delivery-address"> | |||
{{ "action.edit"|trans }} | |||
</button> | |||
</div> | |||
<div class="col-4"> | |||
<h6><strong>{{ "field.default.invoiceAddress"|trans({}, 'lcshop') }}</strong></h6> | |||
<address v-html="order.invoiceAddress"> | |||
</address> | |||
<button type="button" class="btn btn-default" data-toggle="modal" data-target="#modal-order-invoice-address"> | |||
{{ "action.edit"|trans }} | |||
</button> | |||
</div> | |||
<div class="col-12"> | |||
<h6><strong>{{ "field.default.deliveryAvailabilty"|trans({}, 'lcshop') }} : </strong></h6> | |||
<div v-if="order.deliveryType == 'at-home'"> | |||
<div v-html="order.deliveryAvailabilityZone"> | |||
</div> | |||
</div> | |||
<div v-else-if="order.deliveryType == 'point-sale'"> | |||
<div v-html="order.deliveryAvailabilityPointSale"> | |||
</div> | |||
</div> | |||
<button type="button" class="btn btn-default" data-toggle="modal" data-target="#modal-order-delivery-availability"> | |||
{{ "action.edit"|trans }} | |||
</button> | |||
</div> | |||
<div class="col-12"> | |||
{{ form_start(form_order_products, {'attr': {'id' : 'orderProductsForm'}}) }} | |||
<script> | |||
window.templateTest = '{{ orderMacros.productsTemplate(form_order_products)|replace({"\n":' ', "\r":' ', "'" : "\\'"})|raw }}'; | |||
</script> | |||
{{ orderMacros.tableHead() }} | |||
{{ orderMacros.products(form_order_products) }} | |||
{{ orderMacros.tableTotal() }} | |||
{{ form_end(form_order_products) }} | |||
<div class="clearfix"></div> | |||
<script> | |||
window.orderObject = {{ order|json_encode|raw }}; | |||
</script> | |||
</div> | |||
{{ macros.cardOverlay('isLoading') }} | |||
{{ macros.endCard(9) }} |
@@ -1,23 +1,28 @@ | |||
{% extends app.request.query.get('action') == 'edit' ? '@LcShop/backend/default/edit.html.twig' : '@LcShop/backend/default/new.html.twig' %} | |||
{% extends '@LcShop/backend/default/show.html.twig' %} | |||
{% block entity_form %} | |||
{% import '@LcShop/backend/default/block/macros.html.twig' as macros %} | |||
{% block main %} | |||
{% if formView is defined and formView == 'default'%} | |||
{% import '@LcShop/backend/default/block/macros.html.twig' as macros %} | |||
{{ macros.startCard(8, 'OrderShop.selectUser') }} | |||
<div class="col-12"> | |||
{{ form(form) }} | |||
</div> | |||
{{ macros.endCard() }} | |||
{% else %} | |||
{% include '@LcShop/backend/order/form.html.twig' %} | |||
{% endif %} | |||
<div class="lc-vue-js-container" id="lc-order-edit"> | |||
<div class="row"> | |||
{% include '@LcShop/backend/order/form.html.twig' %} | |||
{% endblock entity_form %} | |||
{{ macros.startCard(3, 'OrderShop.addProduct', 'success') }} | |||
{% include '@LcShop/backend/order/card_addproducttoorder.html.twig' %} | |||
{% include '@LcShop/backend/order/modal_invoiceaddress.html.twig' %} | |||
{% include '@LcShop/backend/order/modal_deliveryaddress.html.twig' %} | |||
{% include '@LcShop/backend/order/modal_deliveryavailability.html.twig' %} | |||
{{ macros.endCard }} | |||
</div> | |||
</div> | |||
{% endblock %} | |||
{% block body_javascript %} | |||
{% block script_javascript %} | |||
{{ parent() }} | |||
{% include '@LcShop/backend/default/block/script-vuejs.html.twig' %} | |||
<script src="{{ asset('bundles/lcshop/js/backend/script/order/vuejs-order.js') }}"></script> |
@@ -1,49 +1,12 @@ | |||
{{ form_start(form, {"attr": {'@change' : 'formUpdated'}}) }} | |||
<div class="lc-vue-js-container" id="lc-order-edit"> | |||
{#{{ form_start(form, {"attr": {'class' : "col-9"}}) }}#} | |||
<div id="lc-product-family-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" | |||
v-if="(section.name == 'delivery' && deliveryType == 'at-home' && deliveryAddress>0) || (section.name != 'delivery')" | |||
:class="'btn '+((currentSection == section.name) ? 'btn btn-primary' : 'btn')" | |||
@click="changeSection(section)"> | |||
${ section.nameDisplay } | |||
<span class="glyphicon glyphicon-triangle-bottom"></span> | |||
</button> | |||
</li> | |||
</ul> | |||
</div> | |||
</div> | |||
</div> | |||
<div class="form"> | |||
<script>// rendered by server | |||
/*window.appProductFamilyValues = { | |||
{#{% if form.vars.value.title %}title: "{{ form.vars.value.title }}",{% endif %}#} | |||
};*/ | |||
</script> | |||
<div v-show="currentSection == 'cart'" class="panel panel-default"> | |||
{% include '@LcShop/backend/order/panel_orderproducts.html.twig' %} | |||
</div> | |||
<div v-show="currentSection == 'addresses'" class="panel panel-default"> | |||
{% include '@LcShop/backend/order/panel_addresses.html.twig' %} | |||
</div> | |||
<div v-show="currentSection == 'delivery'" class="panel panel-default"> | |||
{% include '@LcShop/backend/order/panel_delivery.html.twig' %} | |||
</div> | |||
</div> | |||
</div> | |||
{% include '@LcShop/backend/order/card_orderproducts.html.twig' %} | |||
{#{% include '@LcShop/backend/order/card_adresses.html.twig' %}#} | |||
{# | |||
{{ form_end(form) }} | |||
#} | |||
@@ -0,0 +1,86 @@ | |||
{% macro tableHead() %} | |||
<table id="order-products-list" class="table table-striped"> | |||
<thead> | |||
<tr> | |||
<th colspan="2"> | |||
<span>Produits / Producteurs</span> | |||
</th> | |||
<th> | |||
<span>Prix HT à l'unité</span> | |||
</th> | |||
<th> | |||
<span>Prix TTC à l'unité </span> | |||
</th> | |||
<th> | |||
<span>Disponibilité</span> | |||
</th> | |||
<th> | |||
<span>Quantité</span> | |||
</th> | |||
<th> | |||
<span>Total</span> | |||
</th> | |||
</tr> | |||
</thead> | |||
{% endmacro %} | |||
{% macro products(form_order_products) %} | |||
<tbody> | |||
<template v-for="(orderProduct, key) in orderProducts"> | |||
<order-product ref="orderProductBLOP" :order-product="orderProduct" :template="templateTest" :key-item="key"></order-product> | |||
</template> | |||
</tbody> | |||
{% endmacro %} | |||
{% macro productsTemplate(form_order_products) %} | |||
<tr class="order-product-item"> | |||
<td colspan="2">{% verbatim %}{{orderProduct.title}}{% endverbatim %}</td> | |||
<td> | |||
{% verbatim %}{{orderProduct.price}}{% endverbatim %}€ | |||
</td> | |||
<td> | |||
{% verbatim %}{{orderProduct.priceWithTax}}{% endverbatim %}€ | |||
</td> | |||
<td></td> | |||
<td> | |||
{{ form_widget(form_order_products.orderProducts.vars.prototype.quantityOrder, {'attr' : {'ref': 'fieldQuantity', 'v-model' : 'orderProduct.quantityOrder', '@change' : 'updateOrderProducts'}}) }} | |||
{{ form_widget(form_order_products.orderProducts.vars.prototype.product, {'attr' : {'ref' : 'fieldProduct', 'v-model' : 'orderProduct.product'}}) }} | |||
{#{{ form_widget(form_order_products.orderProducts.vars.prototype.id, {'attr' : {'ref' : 'fieldId', 'v-model' : 'orderProduct.id'}}) }}#} | |||
<button type="button" class="btn-remove-product btn btn-default" @click="deleteOrderProduct()"> | |||
<i class="fa fa-trash"></i> | |||
</button> | |||
</td> | |||
<td> | |||
{% verbatim %}{{orderProduct.totalWithTaxAndReduction}}{% endverbatim %}€ | |||
</td> | |||
</tr> | |||
{% endmacro %} | |||
{% macro tableTotal() %} | |||
</table> | |||
<div class="clearfix"></div> | |||
<div class="row"> | |||
<div class="col-7"></div> | |||
<div class="col-5"> | |||
<div class="table-responsive"> | |||
<table class="table"> | |||
<tbody> | |||
<tr> | |||
<th>Total without Tax</th> | |||
<td>${order.total}€</td> | |||
</tr> | |||
<tr> | |||
<th>Total</th> | |||
<td>${order.totalWithTax}€</td> | |||
</tr> | |||
</tbody> | |||
</table> | |||
</div> | |||
</div> | |||
</div> | |||
{% endmacro %} |
@@ -0,0 +1,28 @@ | |||
<div class="modal fade show" id="modal-order-delivery-address"> | |||
{{ form_start(form_order_delivery_address, {'attr': { 'id' : 'orderDeliveryAddressForm'}}) }}) }} | |||
{% form_theme form_order_delivery_address '@LcShop/backend/form/custom_bootstrap_4.html.twig' %} | |||
<div class="modal-dialog"> | |||
<div class="modal-content"> | |||
<div class="modal-header"> | |||
<h4>{{ "form.group.OrderShop.deliveryAddress"|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_delivery_address.deliveryPointSale) }} | |||
</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_delivery_address.saveDeliveryAddress, {"attr": {'class' : 'btn btn-primary', '@click' : 'updateOrderDeliveryAddress'}}) }} | |||
</div> | |||
</div> | |||
<!-- /.modal-content --> | |||
</div> | |||
{{ form_end(form_order_delivery_address) }} | |||
</div> |
@@ -0,0 +1,33 @@ | |||
<div class="modal fade show" id="modal-order-delivery-availability"> | |||
{{ form_start(form_order_delivery_availability, {'attr': { 'id' : 'orderDeliveryAvailabilityForm'}}) }}) }} | |||
{% form_theme form_order_delivery_availability '@LcShop/backend/form/custom_bootstrap_4.html.twig' %} | |||
<div class="modal-dialog"> | |||
<div class="modal-content"> | |||
<div class="modal-header"> | |||
<h4>{{ "form.group.OrderShop.deliveryAvailabilty"|trans }}</h4> | |||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"> | |||
<span aria-hidden="true">×</span> | |||
</button> | |||
</div> | |||
<div class="modal-body"> | |||
${order.deliveryType} | |||
<div class="col" v-if="order.deliveryType=='point-sale'"> | |||
{{ form_row(form_order_delivery_availability.deliveryAvailabilityPointSale) }} | |||
</div> | |||
<div class="col" v-else-if="order.deliveryType=='at-home'"> | |||
{{ form_row(form_order_delivery_availability.deliveryAvailabilityZone) }} | |||
</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_delivery_availability.saveDeliveryAvailability, {"attr": {'class' : 'btn btn-primary', '@click' : 'updateOrderDeliveryAvailability'}}) }} | |||
</div> | |||
</div> | |||
<!-- /.modal-content --> | |||
</div> | |||
{{ form_end(form_order_delivery_availability) }} | |||
</div> |
@@ -0,0 +1,25 @@ | |||
<div class="modal fade show" id="modal-order-invoice-address"> | |||
{{ form_start(form_order_invoice_address, {'attr': { 'id' : 'orderInvoiceAddressForm'}}) }}) }} | |||
{% form_theme form_order_invoice_address '@LcShop/backend/form/custom_bootstrap_4.html.twig' %} | |||
<div class="modal-dialog"> | |||
<div class="modal-content"> | |||
<div class="modal-header"> | |||
<h4>{{ "form.group.OrderShop.invoiceAddress"|trans }}</h4> | |||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"> | |||
<span aria-hidden="true">×</span> | |||
</button> | |||
</div> | |||
<div class="modal-body"> | |||
{{ form_row(form_order_invoice_address.invoiceAddress) }} | |||
</div> | |||
<div class="modal-footer justify-content-between"> | |||
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button> | |||
{{ form_row(form_order_invoice_address.saveInvoiceAddress, {"attr": {'class' : 'btn btn-primary', '@click' : 'updateOrderInvoiceAddress'}}) }} | |||
</div> | |||
</div> | |||
<!-- /.modal-content --> | |||
</div> | |||
{{ form_end(form_order_invoice_address) }} | |||
</div> |
@@ -0,0 +1,12 @@ | |||
{% extends '@LcShop/backend/default/new.html.twig' %} | |||
{% block entity_form %} | |||
{% import '@LcShop/backend/default/block/macros.html.twig' as macros %} | |||
{{ macros.startCard(8, 'OrderShop.selectUser') }} | |||
<div class="col-12"> | |||
{{ form(form) }} | |||
</div> | |||
{{ macros.endCard() }} | |||
{% endblock entity_form %} | |||
@@ -4,27 +4,13 @@ | |||
<div class="card-header"> | |||
<h3>{{ "form.group.ProductFamily.addresses"|trans }}</h3> | |||
</div> | |||
<div class="row" > | |||
<div class="row"> | |||
<div class="col"> | |||
{{ form_label(form.deliveryType) }} | |||
{% for field in form.deliveryType %} | |||
{{ form_widget(field, {"attr" : {"v-model" : 'deliveryType'}}) }} | |||
{% endfor %} | |||
</div> | |||
<div class="col" v-if="deliveryType == 'at-home'"> | |||
{{ form_row(form.deliveryAddress, {"attr": {'v-model' : 'deliveryAddress'}}) }} | |||
</div> | |||
<div class="col" v-else-if="deliveryType == 'point-sale'"> | |||
{{ form_row(form.deliveryPointSale, {"attr": {'v-model' : 'deliveryPointSale'}}) }} | |||
</div> | |||
<div class="col"> | |||
{{ form_row(form.invoiceAddress, {"attr": {'v-model' : 'invoiceAddress', 'v-selecttwo' : 'invoiceAddress'}}) }} | |||
</div> | |||
</div> | |||
</fieldset> | |||
</div> | |||
</div> | |||
</div> |
@@ -1,135 +0,0 @@ | |||
{% macro printOrderProductRow(orderProduct) %} | |||
<tr class="order-product-item"> | |||
<td colspan="2"> | |||
<div class="form-widget"> | |||
{{ form_widget(orderProduct.product, {'attr' : {'v-model' : 'product'}}) }} | |||
</div> | |||
</td> | |||
<td> | |||
<div class="form-widget"> | |||
{% verbatim %}{{ price }}{% endverbatim %}€ | |||
</div> | |||
</td> | |||
<td> | |||
<div class="form-widget"> | |||
{% verbatim %}{{ priceWithTax }}{% endverbatim %}€ | |||
</div> | |||
</td> | |||
<td> | |||
<div class="form-widget"> | |||
{{ form_widget(orderProduct.quantity, {'attr' : {'v-model' : 'quantity', '@change': 'updateQuantity'}}) }} | |||
</div> | |||
</td> | |||
<td> | |||
{% verbatim %}{{ totalWithTax }}{% endverbatim %}€ | |||
</td> | |||
<td> | |||
<button type="button" class="btn-remove-product btn btn-default" @click="deleteProductForm()"> | |||
<i class="fa fa-trash"></i> | |||
</button> | |||
</td> | |||
</tr> | |||
{% endmacro %} | |||
{% import _self as formMacros %} | |||
{% import '@LcShop/backend/default/block/macros.html.twig' as macros %} | |||
<div class="row"> | |||
{{ macros.startCard(12, 'OrderShop.cart') }} | |||
<div class="col-12"> | |||
<table id="order-products-list" class="table table-striped" | |||
data-prototype="{{ formMacros.printOrderProductRow(form.orderProducts.vars.prototype)|e('html_attr') }}"> | |||
<thead> | |||
<tr> | |||
<th colspan="2"> | |||
<span>Produit</span> | |||
</th> | |||
<th> | |||
<span>Prix HT à l'unité</span> | |||
</th> | |||
<th> | |||
<span>Prix TTC à l'unité</span> | |||
</th> | |||
<th> | |||
<span>Quantité</span> | |||
</th> | |||
<th> | |||
<span>Total</span> | |||
</th> | |||
<th> | |||
<span>Action</span> | |||
</th> | |||
</tr> | |||
</thead> | |||
<tbody> | |||
<template v-for="(formProduct, key) in formOrderProductArray"> | |||
<order-product-form ref="orderProductForm" :template="formProduct" :key-form="key"></order-product-form> | |||
</template> | |||
</tbody> | |||
</table> | |||
<button type="button" class="add_tag_link btn-add-product btn btn-default float-right" @click="addOrderProductForm"> | |||
<span class="fa fa-plus"></span> Ajouter un produit | |||
</button> | |||
<div class="clearfix"></div> | |||
<div class="row"> | |||
<div class="col-6"></div> | |||
<div class="col-6"> | |||
<div class="table-responsive"> | |||
<table class="table"> | |||
<tbody> | |||
<tr> | |||
<td>Total without Tax</td> | |||
<td>${totalWithoutTax}€</td> | |||
</tr> | |||
<tr> | |||
<td>Total Tax</td> | |||
<td>${totalWithTax- totalWithoutTax}€</td> | |||
</tr> | |||
<tr> | |||
<td>Total</td> | |||
<td>${totalWithTax}€</td> | |||
</tr> | |||
</tbody> | |||
</table> | |||
</div> | |||
</div> | |||
</div> | |||
<div class="clearfix"></div> | |||
<script> | |||
window.orderProductForm = new Array(); | |||
</script> | |||
{% for keyForm, orderProduct in form.orderProducts %} | |||
<script> | |||
window.orderProductForm[{{ keyForm }}] = { | |||
{% if orderProduct.vars.value.title %}title: "{{ orderProduct.vars.value.title }}",{% endif %} | |||
{% if orderProduct.vars.value.quantity %}quantity: "{{ orderProduct.vars.value.quantity }}",{% endif %} | |||
{% if orderProduct.vars.value.unit %}unit: "{{ orderProduct.vars.value.unit }}",{% endif %} | |||
{#{% if orderProduct.vars.value.buyingPrice %}buyingPrice: "{{ orderProduct.vars.value.buyingPrice }}",{% endif %}#} | |||
{% if orderProduct.vars.value.price %}price: parseFloat({{ orderProduct.vars.value.price }}).toFixed(3),{% endif %} | |||
{% if orderProduct.vars.value.product %}product: {{ orderProduct.vars.value.product.id }}{% endif %} | |||
}; | |||
jQuery(window).on('load', function () { | |||
var orderProductForm = '{{ formMacros.printOrderProductRow(orderProduct)|replace({"\n":' ', "\r":' ', "'" : "\\'"})|raw }}'; | |||
appOrder.formOrderProductArray.push(orderProductForm); | |||
appOrder.indexOrderProductForm++; | |||
}); | |||
</script> | |||
{% endfor %} | |||
{% do form.orderProducts.setRendered %} | |||
</div> | |||
{{ macros.endCard() }} | |||
</div> |
@@ -4,35 +4,6 @@ | |||
<tr class="lc-draggable"> | |||
<td><i class="fa fa-fw fa-sort"></i></td> | |||
{#<td colspan="2" class="title" v-on:click="titleInherited = true"> | |||
<div v-show="titleInherited == false"> | |||
<div v-if="title" class="blop"> | |||
{% verbatim %}{{ title }}{% endverbatim %} | |||
</div> | |||
<div v-else class="inherited"> | |||
{% verbatim %}{{ productFamily.title }}{% endverbatim %} | |||
</div> | |||
</div> | |||
<div v-show="titleInherited == true"> | |||
{{ form_widget(product.title, {'attr' : {'v-model' : 'title', 'v-on:focusout': 'titleInherited = false'}}) }} | |||
</div> | |||
</td>#} | |||
{# | |||
<td colspan="2" class="unit" v-on:click="unitInherited = true"> | |||
<div v-show="unitInherited == false"> | |||
<div v-if="unit" class="blop"> | |||
{% verbatim %}{{ unitWording }}{% endverbatim %} | |||
</div> | |||
<div v-else class="inherited"> | |||
{% verbatim %}{{ unitWording }}{% endverbatim %} | |||
</div> | |||
</div> | |||
<div v-show="unitInherited == true"> | |||
{{ form_widget(product.unit, {'attr' : {'v-model' : 'unit', 'v-on:focusout': 'unitInherited = false', '@change' : 'updateLine'}}) }} | |||
</div> | |||
</td>#} | |||
{{ macros.productField(2, product.title, 'title') }} | |||
{{ macros.productField(1, product.quantity, 'quantity') }} | |||
{{ macros.productField(2, product.unit, 'unit', 'unitWording') }} |
@@ -1,72 +0,0 @@ | |||
<?php | |||
namespace Lc\ShopBundle\Routing; | |||
use Lc\ShopBundle\Model\Address; | |||
use Symfony\Component\Config\Loader\Loader; | |||
use Symfony\Component\Routing\Route; | |||
use Symfony\Component\Routing\RouteCollection; | |||
class CrudLoader extends Loader | |||
{ | |||
private $isLoaded = false; | |||
public function load($resource, $type = null) | |||
{ | |||
if (true === $this->isLoaded) { | |||
throw new \RuntimeException('Do not add the "extra" loader twice'); | |||
} | |||
$routes = new RouteCollection(); | |||
$lcShopRoutes = array( | |||
'address' => "Address", | |||
"cart" => "Cart", | |||
"credit_config" => "CreditConfig", | |||
"document_nelivery_note" => "DocumentDeliveryNote", | |||
"document_quotation" => "DocumentQuotation", | |||
"document_invoice" => "DocumentInvoice", | |||
"merchant" => "Merchant", | |||
"merchant_config" => "MerchantConfig", | |||
/*"order"=>"Order"*/ | |||
"point_sale" => "PointSale", | |||
"tax_rate" => "TaxRate", | |||
"product" => "Products" | |||
); | |||
$actions = [ | |||
'index' => 'indexAction', | |||
'edit' => 'editAction', | |||
'delete' => 'deleteAction', | |||
'show' => 'showAction' | |||
]; | |||
foreach ($lcShopRoutes as $entity => $controller) { | |||
foreach ($actions as $actionName => $action) { | |||
if ($actionName == 'edit' || $actionName == 'delete' || $actionName == "show") { | |||
$path = '/' . $entity . '/' . $actionName . '/{id}'; | |||
} else { | |||
$path = '/' . $entity . '/' . $actionName; | |||
} | |||
$defaults = [ | |||
'_controller' => 'Lc\ShopBundle\Controller\\' . $controller . 'Controller::' . $action | |||
]; | |||
$requirements = [ | |||
'parameter' => '\d+', | |||
]; | |||
$route = new Route($path, $defaults, $requirements); | |||
$routeName = 'lc_shop_' . $entity . '_' . $actionName; | |||
$routes->add($routeName, $route); | |||
} | |||
} | |||
$this->isLoaded = true; | |||
return $routes; | |||
} | |||
public function supports($resource, $type = null) | |||
{ | |||
return 'crud' === $type; | |||
} | |||
} |
@@ -1,41 +0,0 @@ | |||
<?php | |||
namespace Lc\ShopBundle\Services ; | |||
use Lc\ShopBundle\Context\AddressInterface; | |||
class AddressUtils | |||
{ | |||
public function getSummaryShort(AddressInterface $address) | |||
{ | |||
return $address->getAddress().' - '.$address->getZip().' '.$address->getCity() ; | |||
} | |||
public function getSummary(AddressInterface $address) | |||
{ | |||
$html = '' ; | |||
if($address->getTitle()) { | |||
$html .= $address->getTitle().'<br />' ; | |||
} | |||
if($address->getLastname() || $address->getFirstname()) { | |||
$html .= $address->getLastname().' '.$address->getFirstname().'<br />' ; | |||
} | |||
if($address->getAddress()) { | |||
$html .= $address->getAddress().'<br />' ; | |||
} | |||
if($address->getZip() || $address->getCity()) { | |||
$html .= $address->getZip().' '.$address->getCity().'<br />' ; | |||
} | |||
if($address->getPhone()) { | |||
$html .= 'Tél. '.$address->getPhone() ; | |||
} | |||
return $html ; | |||
} | |||
} |
@@ -6,7 +6,9 @@ use App\Entity\OrderProductReductionCatalog; | |||
use App\Entity\OrderShop; | |||
use Doctrine\ORM\EntityManagerInterface; | |||
use Lc\ShopBundle\Context\MerchantUtilsInterface; | |||
use Lc\ShopBundle\Context\OrderShopInterface; | |||
use Lc\ShopBundle\Context\ProductFamilyUtilsInterface; | |||
use Lc\ShopBundle\Context\UserInterface; | |||
use Symfony\Component\Security\Core\Security; | |||
class OrderUtils | |||
@@ -15,7 +17,7 @@ class OrderUtils | |||
protected $security; | |||
protected $userUtils; | |||
protected $merchantUtils; | |||
private $orderShopRepo; | |||
protected $orderShopRepo; | |||
protected $priceUtils ; | |||
protected $productFamilyUtils ; | |||
@@ -26,12 +28,12 @@ class OrderUtils | |||
$this->security = $security; | |||
$this->userUtils = $userUtils; | |||
$this->merchantUtils = $merchantUtils; | |||
$this->orderShopRepo = $this->em->getRepository(OrderShop::class); | |||
$this->orderShopRepo = $this->em->getRepository($this->em->getClassMetadata(OrderShopInterface::class)->getName()); | |||
$this->priceUtils = $priceUtils ; | |||
$this->productFamilyUtils = $productFamilyUtils ; | |||
} | |||
public function getOrderShopCurrent() | |||
public function getCartCurrent() | |||
{ | |||
$paramsSearchOrderShop = []; | |||
@@ -46,7 +48,7 @@ class OrderUtils | |||
$paramsSearchOrderShop['visitor'] = $visitor; | |||
} | |||
$orderShop = $this->orderShopRepo->findOneBy($paramsSearchOrderShop); | |||
$orderShop = $this->orderShopRepo->findCartCurrent($paramsSearchOrderShop); | |||
if (!$orderShop) { | |||
$orderShop = $this->createOrderShop([ | |||
@@ -83,6 +85,18 @@ 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 { | |||
// 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) ; | |||
} | |||
$this->em->persist($orderShop); | |||
$this->em->flush(); | |||
@@ -136,6 +150,7 @@ class OrderUtils | |||
$this->em->flush(); | |||
} | |||
} | |||
public function compareOrderProductReductionCatalog($orderProductReductionCatalog1, $orderProductReductionCatalog2) | |||
@@ -181,7 +196,7 @@ class OrderUtils | |||
public function getOrderDatas($order = null) | |||
{ | |||
if(!$order) { | |||
$order = $this->getOrderShopCurrent() ; | |||
$order = $this->getCartCurrent() ; | |||
} | |||
$data = [] ; | |||
@@ -193,6 +208,37 @@ class OrderUtils | |||
return $data ; | |||
} | |||
public function getOrderAsJsonObject(OrderShopInterface $order) | |||
{ | |||
$data['id'] = $order->getId(); | |||
$data['user'] = $order->getUser()->getSummary(); | |||
$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; | |||
foreach ($this->getOrderProductsByParentCategory($order) as $labelCategory => $orderProducts) { | |||
foreach ($orderProducts as $orderProduct) { | |||
$data['orderProducts'][$i]['id'] = $orderProduct->getId(); | |||
$data['orderProducts'][$i]['product'] = $orderProduct->getProduct()->getId(); | |||
$data['orderProducts'][$i]['quantityOrder'] = $orderProduct->getQuantityOrder(); | |||
$data['orderProducts'][$i]['labelCategory'] = $labelCategory; | |||
$data['orderProducts'][$i]['title'] = $orderProduct->getTitle(); | |||
$data['orderProducts'][$i]['price'] = $this->priceUtils->getPrice($orderProduct); | |||
$data['orderProducts'][$i]['priceWithTax'] = $this->priceUtils->getPriceWithTax($orderProduct); | |||
$data['orderProducts'][$i]['priceWithTaxAndReduction'] = $this->priceUtils->getPriceWithTaxAndReduction($orderProduct); | |||
$data['orderProducts'][$i]['quantity'] = $orderProduct->getQuantityOrder(); | |||
$data['orderProducts'][$i]['totalWithTaxAndReduction'] = $this->priceUtils->getTotalOrderProductsWithTaxAndReduction(array($orderProduct)); | |||
$i++; | |||
} | |||
} | |||
return $data; | |||
} | |||
public function getSummaryOrderProductReductionCatalog($orderProductReductionCatalog) | |||
{ | |||
$text = '' ; |
@@ -0,0 +1,43 @@ | |||
<?php | |||
namespace Lc\ShopBundle\Services ; | |||
use Doctrine\ORM\EntityManagerInterface; | |||
use Lc\ShopBundle\Context\PointSaleInterface; | |||
use Lc\ShopBundle\Context\UserInterface; | |||
use Lc\ShopBundle\Context\UserPointSaleInterface; | |||
class PointSaleUtils | |||
{ | |||
protected $em ; | |||
public function __construct(EntityManagerInterface $em) | |||
{ | |||
$this->em = $em ; | |||
} | |||
public function isUserLinkedToPointSale(UserInterface $user, PointSaleInterface $pointSale) | |||
{ | |||
foreach($user->getUserPointSales() as $userPointSale) { | |||
if($userPointSale->getPointSale()->getId() == $pointSale->getId()) { | |||
return true ; | |||
} | |||
} | |||
return false ; | |||
} | |||
public function linkUserToPointSale(UserInterface $user, PointSaleInterface $pointSale) | |||
{ | |||
if(!$this->isUserLinkedToPointSale($user, $pointSale)) { | |||
$userPointSaleClass = $this->em->getClassMetadata(UserPointSaleInterface::class)->getName(); | |||
$userPointSale = new $userPointSaleClass ; | |||
$userPointSale->setUser($user) ; | |||
$userPointSale->setPointSale($pointSale) ; | |||
$this->em->persist($userPointSale); | |||
$this->em->flush() ; | |||
} | |||
} | |||
} |
@@ -50,6 +50,15 @@ class PriceUtils | |||
); | |||
} | |||
/*public function getPriceUnitWithTaxAndReduction($entity) | |||
{ | |||
if($entity instanceof ProductInterface) { | |||
return $this->getPriceWithTaxAndReduction($entity) / $entity->getQuantity() ; | |||
} | |||
return null ; | |||
}*/ | |||
public function getPriceByRefUnit($entity) | |||
{ | |||
if($entity instanceof ProductPropertyInterface) { |
@@ -3,6 +3,7 @@ | |||
namespace Lc\ShopBundle\Services ; | |||
use Doctrine\ORM\EntityManagerInterface; | |||
use Lc\ShopBundle\Context\MerchantUtilsInterface; | |||
use Symfony\Component\HttpFoundation\Cookie ; | |||
use Lc\ShopBundle\Context\VisitorInterface; | |||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; | |||
@@ -15,14 +16,17 @@ class UserUtils | |||
protected $utils ; | |||
protected $requestStack ; | |||
protected $visitorRepository ; | |||
protected $merchantUtils ; | |||
public function __construct(ParameterBagInterface $parameterBag, EntityManagerInterface $em, Utils $utils, RequestStack $requestStack) | |||
public function __construct(ParameterBagInterface $parameterBag, EntityManagerInterface $em, Utils $utils, | |||
RequestStack $requestStack, MerchantUtilsInterface $merchantUtils) | |||
{ | |||
$this->em = $em ; | |||
$this->parameterBag = $parameterBag ; | |||
$this->utils = $utils ; | |||
$this->requestStack = $requestStack ; | |||
$this->visitorRepository = $this->em->getRepository($this->em->getClassMetadata(VisitorInterface::class)->getName()) ; | |||
$this->merchantUtils = $merchantUtils ; | |||
} | |||
public function getCookieNameVisitor() | |||
@@ -80,4 +84,22 @@ class UserUtils | |||
$this->em->flush() ; | |||
} | |||
public function setNewsletter($user, $subscribeNewsletter) | |||
{ | |||
$currentMerchant = $this->merchantUtils->getMerchantCurrent() ; | |||
$newsletters = $currentMerchant->getNewsletters() ; | |||
if(isset($newsletters[0]) && $newsletters[0]) { | |||
if($subscribeNewsletter) { | |||
$user->addNewsletter($newsletters[0]) ; | |||
} | |||
else { | |||
$user->removeNewsletter($newsletters[0]) ; | |||
} | |||
} | |||
$this->em->persist($user) ; | |||
$this->em->flush() ; | |||
} | |||
} |