<?php | <?php | ||||
namespace Lc\ShopBundle\Controller\Admin; | |||||
namespace Lc\ShopBundle\Controller\Backend; | |||||
use Doctrine\ORM\EntityManagerInterface; | use Doctrine\ORM\EntityManagerInterface; | ||||
use Doctrine\ORM\EntityRepository; | use Doctrine\ORM\EntityRepository; |
<?php | <?php | ||||
namespace Lc\ShopBundle\Controller\Admin; | |||||
namespace Lc\ShopBundle\Controller\Backend; | |||||
use Lc\ShopBundle\Context\MerchantConfigInterface; | use Lc\ShopBundle\Context\MerchantConfigInterface; | ||||
use Lc\ShopBundle\Context\MerchantInterface; | use Lc\ShopBundle\Context\MerchantInterface; |
<?php | <?php | ||||
namespace Lc\ShopBundle\Controller\Admin; | |||||
namespace Lc\ShopBundle\Controller\Backend; | |||||
use App\Repository\UserRepository; | use App\Repository\UserRepository; | ||||
use Lc\ShopBundle\Context\NewsInterface; | use Lc\ShopBundle\Context\NewsInterface; |
<?php | <?php | ||||
namespace Lc\ShopBundle\Controller\Admin; | |||||
namespace Lc\ShopBundle\Controller\Backend; | |||||
use Doctrine\ORM\EntityManagerInterface; | |||||
use Doctrine\ORM\EntityRepository; | use Doctrine\ORM\EntityRepository; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Event\EasyAdminEvents; | use EasyCorp\Bundle\EasyAdminBundle\Event\EasyAdminEvents; | ||||
use FOS\UserBundle\Model\UserManagerInterface; | |||||
use Lc\ShopBundle\Context\AddressInterface; | use Lc\ShopBundle\Context\AddressInterface; | ||||
use Lc\ShopBundle\Context\MerchantUtilsInterface; | |||||
use Lc\ShopBundle\Context\OrderProductInterface; | use Lc\ShopBundle\Context\OrderProductInterface; | ||||
use Lc\ShopBundle\Context\OrderUtilsInterface; | |||||
use Lc\ShopBundle\Context\UserInterface; | use Lc\ShopBundle\Context\UserInterface; | ||||
use Lc\ShopBundle\Form\Order\AddPoductToOrderType; | 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\Order\OrderProductsType; | ||||
use Lc\ShopBundle\Form\OrderProductType; | use Lc\ShopBundle\Form\OrderProductType; | ||||
use Lc\ShopBundle\Services\Utils; | |||||
use Mailjet\MailjetSwiftMailer\SwiftMailer\MailjetTransport; | |||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType; | use Symfony\Bridge\Doctrine\Form\Type\EntityType; | ||||
use Symfony\Component\Form\Extension\Core\Type\CollectionType; | |||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType; | use Symfony\Component\Form\Extension\Core\Type\SubmitType; | ||||
use Symfony\Component\HttpFoundation\Response; | use Symfony\Component\HttpFoundation\Response; | ||||
use Symfony\Component\Security\Core\Security; | |||||
class OrderController extends AdminController | class OrderController extends AdminController | ||||
parent::persistEntity($entity); | parent::persistEntity($entity); | ||||
} | } | ||||
public function createEntityFormBuilder($entity, $view, $override = true) | |||||
{ | |||||
$formBuilder = parent::createEntityFormBuilder($entity, $view, false); | |||||
$userClass = $this->em->getClassMetadata(UserInterface::class); | |||||
$addressClass = $this->em->getClassMetadata(AddressInterface::class); | |||||
$formBuilder->add('user', EntityType::class, array( | |||||
'class' => $userClass->name | |||||
)); | |||||
$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()); | |||||
}, | |||||
)); | |||||
$formBuilder = $this->overrideFormBuilder($formBuilder, $entity, $view); | |||||
return $formBuilder; | |||||
} | |||||
public function getUserViaFirstStepForm($entity) | public function getUserViaFirstStepForm($entity) | ||||
} | } | ||||
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() | public function orderProductsAction() | ||||
{ | { | ||||
$response['niche'] = $orderProduct->getQuantityOrder(); | $response['niche'] = $orderProduct->getQuantityOrder(); | ||||
$this->em->remove($orderProduct); | $this->em->remove($orderProduct); | ||||
} else { | } else { | ||||
//dump($orderProduct); | |||||
$this->em->persist($orderProduct); | $this->em->persist($orderProduct); | ||||
} | } | ||||
} | } | ||||
//$this->em->persist($orderShop); | |||||
$this->em->flush(); | $this->em->flush(); | ||||
$response['status'] = 'success'; | $response['status'] = 'success'; | ||||
$response['message'] = 'La commande a bien été modifié'; | $response['message'] = 'La commande a bien été modifié'; | ||||
$response['message'] = 'Une erreur est survenue'; | $response['message'] = 'Une erreur est survenue'; | ||||
} | } | ||||
$response['data'] = $this->orderUtils->getOrderAsJsonObject($orderShop);; | $response['data'] = $this->orderUtils->getOrderAsJsonObject($orderShop);; | ||||
//die('nicicici'); | |||||
return new Response(json_encode($response)); | return new Response(json_encode($response)); | ||||
} | } | ||||
'id' => $parameters['entity']->getId() | '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_add_product_to_order'] = $formAddProductToOrder->createView(); | ||||
$parameters['form_order_products'] = $formOrderProducts->createView(); | $parameters['form_order_products'] = $formOrderProducts->createView(); | ||||
$parameters['form_order_invoice_address'] = $formOrderInvoiceAddress->createView(); | |||||
} | } | ||||
return parent::renderTemplate($actionName, $templatePath, $parameters); | return parent::renderTemplate($actionName, $templatePath, $parameters); | ||||
} | } |
<?php | <?php | ||||
namespace Lc\ShopBundle\Controller\Admin; | |||||
namespace Lc\ShopBundle\Controller\Backend; | |||||
use App\Entity\Product; | use App\Entity\Product; | ||||
use App\Entity\ReductionCatalog; | use App\Entity\ReductionCatalog; |
<?php | <?php | ||||
namespace Lc\ShopBundle\Controller\Admin; | |||||
namespace Lc\ShopBundle\Controller\Backend; | |||||
use FOS\UserBundle\Doctrine\UserManager; | use FOS\UserBundle\Doctrine\UserManager; | ||||
use FOS\UserBundle\Model\UserManagerInterface ; | use FOS\UserBundle\Model\UserManagerInterface ; |
<?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(), | |||||
]); | |||||
} | |||||
} |
<?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(), | |||||
]); | |||||
} | |||||
} |
public function __toString() | 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 | public function getUser(): ?User |
$this->userPointSales = new ArrayCollection(); | $this->userPointSales = new ArrayCollection(); | ||||
} | } | ||||
public function getSummary() | |||||
{ | |||||
return strtoupper($this->getLastname()).' '.$this->getFirstname(). ' ('.$this->getEmail().')'; | |||||
} | |||||
public function setEmail($email) | public function setEmail($email) | ||||
{ | { | ||||
$this->setUsername($email); | $this->setUsername($email); |
admin_switch_merchant: | admin_switch_merchant: | ||||
path: /admin/switch-merchant | path: /admin/switch-merchant | ||||
controller: Lc\ShopBundle\Controller\Admin\MerchantController::switchMerchantAction | |||||
controller: Lc\ShopBundle\Controller\Backend\MerchantController::switchMerchantAction | |||||
lc_api: | lc_api: | ||||
path: /api/{entity}/{id} | path: /api/{entity}/{id} |
body{font-size: 0.9rem;} | 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); } | [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{padding: 8px 0; text-align: center;} | ||||
.main-sidebar .logo-long img{height: 40px; display: inline-block;} | .main-sidebar .logo-long img{height: 40px; display: inline-block;} | ||||
.sidebar-collapse .main-sidebar .logo-long span{display: none;} | .sidebar-collapse .main-sidebar .logo-long span{display: none;} |
if ($('.select2, select.form-control').length) { | if ($('.select2, select.form-control').length) { | ||||
$('form .form-widget>select.form-control, .select2').each(function (i, elm) { | $('form .form-widget>select.form-control, .select2').each(function (i, elm) { | ||||
log($(elm)) | |||||
if(!$(this).hasClass('disable-select2')) { | if(!$(this).hasClass('disable-select2')) { | ||||
setSelect2($(elm)) ; | setSelect2($(elm)) ; | ||||
} | } |
mixins: [mixinTemplate], | mixins: [mixinTemplate], | ||||
props: ['template', 'keyItem', 'orderProduct'], | props: ['template', 'keyItem', 'orderProduct'], | ||||
computed: {}, | computed: {}, | ||||
/* data:function() { | |||||
return{ | |||||
/* 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 () { | |||||
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 () { | |||||
log(this.keyItem); | log(this.keyItem); | ||||
this.setFields() | this.setFields() | ||||
//this.$el.replace(/__name__/g, this.key); | //this.$el.replace(/__name__/g, this.key); | ||||
}, | }, | ||||
methods:{ | |||||
init:function(){ | |||||
methods: { | |||||
init: function () { | |||||
//log(this.$els); | //log(this.$els); | ||||
//log(this.$element); | //log(this.$element); | ||||
}, | }, | ||||
setFields:function(){ | |||||
setFields: function () { | |||||
var app = this; | var app = this; | ||||
fields = ['fieldQuantity', 'fieldProduct']; | fields = ['fieldQuantity', 'fieldProduct']; | ||||
fields.forEach(function (field) { | fields.forEach(function (field) { | ||||
//log(app.$refs[field]); | //log(app.$refs[field]); | ||||
}); | }); | ||||
}, | }, | ||||
updateOrderProducts:function () { | |||||
updateOrderProducts: function () { | |||||
this.$parent.updateOrderProducts(); | this.$parent.updateOrderProducts(); | ||||
}, | }, | ||||
deleteOrderProduct:function(){ | |||||
deleteOrderProduct: function () { | |||||
$(this.$refs.fieldQuantity).val(0); | $(this.$refs.fieldQuantity).val(0); | ||||
this.$parent.updateOrderProducts(); | this.$parent.updateOrderProducts(); | ||||
} | } | ||||
appOrder = new Vue({ | appOrder = new Vue({ | ||||
el: '#lc-order-edit', | el: '#lc-order-edit', | ||||
delimiters: ['${', '}'], | delimiters: ['${', '}'], | ||||
computed: {}, | |||||
computed: { | |||||
deliveryAddressHtml: function () { | |||||
log(this.order.deliveryAddress); | |||||
return this.order.deliveryAddress; | |||||
} | |||||
}, | |||||
data() { | data() { | ||||
return Object.assign( | return Object.assign( | ||||
{ | { | ||||
templateTest: window.templateTest, | templateTest: window.templateTest, | ||||
orderProducts:[], | |||||
order:[], | |||||
isLoading:true, | |||||
addProductId:null, | |||||
addProductQuantity:null, | |||||
orderProducts: [], | |||||
order: [], | |||||
deliveryType: null, | |||||
isLoading: true, | |||||
addProductId: null, | |||||
addProductQuantity: null, | |||||
sectionsArray: [ | sectionsArray: [ | ||||
{ | { | ||||
log(window.templateTest); | log(window.templateTest); | ||||
this.updateOrder(window.orderObject); | this.updateOrder(window.orderObject); | ||||
//log($(this.$el).find('#orderProductsForm').replace(/__name__/g, 0)); | //log($(this.$el).find('#orderProductsForm').replace(/__name__/g, 0)); | ||||
}, | |||||
}, | |||||
methods: { | methods: { | ||||
updateOrderProducts:function(){ | |||||
addProductToOrder: function () { | |||||
this.postForm('#addProductToOrderForm', false); | |||||
}, | |||||
updateOrderProducts: function () { | |||||
this.postForm('#orderProductsForm', false); | |||||
}, | |||||
updateOrderInvoiceAddress: function () { | |||||
this.postForm('#orderInvoiceAddressForm', '#modal-order-invoice-address'); | |||||
}, | |||||
updateOrderDeliveryAddress: function () { | |||||
this.postForm('#orderDeliveryAddressForm', '#modal-order-invoice-address'); | |||||
}, | |||||
updateOrderDeliveryAvailability:function(){ | |||||
this.postForm('#orderDeliveryAvailabilityForm', '#modal-order-delivery-availability'); | |||||
}, | |||||
postForm:function(formId, modalId){ | |||||
var app = this; | var app = this; | ||||
this.isLoading=true; | |||||
//$('#orderProductsForm').submit(); | |||||
this.isLoading = true; | |||||
if(modalId)$(modalId).modal('hide'); | |||||
$.ajax({ | $.ajax({ | ||||
url: $('#orderProductsForm').prop('action'), | |||||
url: $(formId).prop('action'), | |||||
method: "POST", | method: "POST", | ||||
data: $('#orderProductsForm').serialize(), | |||||
dataType:"json", | |||||
data: $(formId).serialize(), | |||||
dataType: "json", | |||||
success: function (response) { | success: function (response) { | ||||
generateNotice(response.status, response.message); | generateNotice(response.status, response.message); | ||||
if (response.status == 'success') { | |||||
app.updateOrder(response.data); | |||||
} | |||||
app.updateOrder(response.data); | |||||
} | } | ||||
}); | }); | ||||
}, | }, | ||||
updateOrder:function (orderObject){ | |||||
updateOrder: function (orderObject) { | |||||
this.orderProducts = orderObject.orderProducts; | this.orderProducts = orderObject.orderProducts; | ||||
this.order = orderObject; | this.order = orderObject; | ||||
this.isLoading=false; | |||||
this.isLoading = false; | |||||
}, | }, | ||||
addProductToOrder:function(){ | |||||
var app = this; | |||||
this.isLoading=true; | |||||
$.ajax({ | |||||
url: $('#addProductToOrderForm').prop('action'), | |||||
method: "POST", | |||||
data: $('#addProductToOrderForm').serialize(), | |||||
dataType:"json", | |||||
success: function (response) { | |||||
generateNotice(response.status, response.message); | |||||
if (response.status == 'success') { | |||||
app.updateOrder(response.data); | |||||
} | |||||
} | |||||
}); | |||||
}, | |||||
}, | }, | ||||
watch: { | watch: { | ||||
} | } |
field: | field: | ||||
default: | default: | ||||
placeholder: Choisissez une option | placeholder: Choisissez une option | ||||
deliveryPointSale: Lieu de livraison | |||||
deliveryAvailabilty: Créneau de livraison | |||||
id: Id | id: Id | ||||
status: En ligne | status: En ligne | ||||
statusOptions: | statusOptions: | ||||
isSent: Envoyée | isSent: Envoyée | ||||
behaviorTaxRate: Avec ou sans TVA | behaviorTaxRate: Avec ou sans TVA | ||||
behaviorTaxRateHelp: Appliquer la réduction sur le prix HT ou le prix TTC | behaviorTaxRateHelp: Appliquer la réduction sur le prix HT ou le prix TTC | ||||
deliveryAddress: Addresse de livraison | |||||
invoiceAddress: Addresse de facturation | |||||
PointSale: | PointSale: | ||||
code: Code | code: Code | ||||
codeHelp: Code utilisé pour retrouver l'ambassade dans le tunnel de commande (Non sensible à la casse) | codeHelp: Code utilisé pour retrouver l'ambassade dans le tunnel de commande (Non sensible à la casse) | ||||
Address: | Address: | ||||
city: Commune | city: Commune | ||||
OrderShop: | OrderShop: | ||||
mainInfo: Information principal | |||||
product: Produit | product: Produit | ||||
user: Client | |||||
orderNumber: Numéro de commande | |||||
quantity: Quantité | quantity: Quantité | ||||
addOrderToProduct: Ajouter le produit | addOrderToProduct: Ajouter le produit | ||||
{% import '@LcShop/backend/default/block/macros.html.twig' as macros %} | {% import '@LcShop/backend/default/block/macros.html.twig' as macros %} | ||||
{% import '@LcShop/backend/order/macros.html.twig' as orderMacros %} | {% import '@LcShop/backend/order/macros.html.twig' as orderMacros %} | ||||
{% trans_default_domain 'lcshop' %} | |||||
{{ macros.startCard(9, 'OrderShop.resume') }} | {{ 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"> | <div class="col-12"> | ||||
{{ form_start(form_order_products, {'attr': {'id' : 'orderProductsForm'}}) }} | {{ form_start(form_order_products, {'attr': {'id' : 'orderProductsForm'}}) }} | ||||
window.orderObject = {{ order|json_encode|raw }}; | window.orderObject = {{ order|json_encode|raw }}; | ||||
</script> | </script> | ||||
</div> | </div> | ||||
{{ macros.cardOverlay('isLoading') }} | {{ macros.cardOverlay('isLoading') }} | ||||
{{ macros.endCard(9) }} | {{ macros.endCard(9) }} |
{{ macros.startCard(3, 'OrderShop.addProduct', 'success') }} | {{ macros.startCard(3, 'OrderShop.addProduct', 'success') }} | ||||
{% include '@LcShop/backend/order/card_addproducttoorder.html.twig' %} | {% 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 }} | {{ macros.endCard }} | ||||
</div> | </div> | ||||
</div> | </div> |
<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> |
<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> |
<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> |
</div> | </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"> | <div class="col"> | ||||
{{ form_row(form.invoiceAddress, {"attr": {'v-model' : 'invoiceAddress', 'v-selecttwo' : 'invoiceAddress'}}) }} | {{ form_row(form.invoiceAddress, {"attr": {'v-model' : 'invoiceAddress', 'v-selecttwo' : 'invoiceAddress'}}) }} |
<?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 ; | |||||
} | |||||
} |
public function getOrderAsJsonObject(OrderShopInterface $order) | public function getOrderAsJsonObject(OrderShopInterface $order) | ||||
{ | { | ||||
$data['id'] = $order->getId(); | $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['total'] = $this->priceUtils->getTotal($order); | ||||
$data['totalWithTax'] = $this->priceUtils->getTotalWithTax($order); | $data['totalWithTax'] = $this->priceUtils->getTotalWithTax($order); | ||||
$data['totalWithTaxAndReduction'] = $this->priceUtils->getTotalWithTax($order); | $data['totalWithTaxAndReduction'] = $this->priceUtils->getTotalWithTax($order); | ||||
$data['deliveryAddress'] = $order->getDeliveryAddress($order); | |||||
$i=0; | $i=0; | ||||
foreach ($this->getOrderProductsByParentCategory($order) as $labelCategory => $orderProducts) { | foreach ($this->getOrderProductsByParentCategory($order) as $labelCategory => $orderProducts) { | ||||