use Lc\ShopBundle\Context\OrderUtilsInterface; | use Lc\ShopBundle\Context\OrderUtilsInterface; | ||||
use Lc\ShopBundle\Context\UserInterface; | use Lc\ShopBundle\Context\UserInterface; | ||||
use Lc\ShopBundle\Form\Backend\Order\AddPoductToOrderType; | use Lc\ShopBundle\Form\Backend\Order\AddPoductToOrderType; | ||||
use Lc\ShopBundle\Form\Backend\Order\DeleteOrderPaymentType; | |||||
use Lc\ShopBundle\Form\Backend\Order\DeleteOrderReductionCartType; | use Lc\ShopBundle\Form\Backend\Order\DeleteOrderReductionCartType; | ||||
use Lc\ShopBundle\Form\Backend\Order\DeleteOrderReductionCreditType; | use Lc\ShopBundle\Form\Backend\Order\DeleteOrderReductionCreditType; | ||||
use Lc\ShopBundle\Form\Backend\Order\OrderDeliveryAddressType; | use Lc\ShopBundle\Form\Backend\Order\OrderDeliveryAddressType; | ||||
class OrderController extends AdminController | class OrderController extends AdminController | ||||
{ | { | ||||
protected $creditUtils; | protected $creditUtils; | ||||
public function __construct(Security $security, UserManagerInterface $userManager, EntityManagerInterface $em, Utils $utils, MerchantUtilsInterface $merchantUtils, MailjetTransport $mailjetTransport, OrderUtilsInterface $orderUtils, TranslatorInterface $translator, CreditUtils $creditUtils) | public function __construct(Security $security, UserManagerInterface $userManager, EntityManagerInterface $em, Utils $utils, MerchantUtilsInterface $merchantUtils, MailjetTransport $mailjetTransport, OrderUtilsInterface $orderUtils, TranslatorInterface $translator, CreditUtils $creditUtils) | ||||
{ | { | ||||
parent::__construct($security, $userManager, $em, $utils, $merchantUtils, $mailjetTransport, $orderUtils, $translator); | parent::__construct($security, $userManager, $em, $utils, $merchantUtils, $mailjetTransport, $orderUtils, $translator); | ||||
$oldStatus = $orderShop->getOrderStatus(); | $oldStatus = $orderShop->getOrderStatus(); | ||||
$orderShop = $this->orderUtils->changeOrderStatus($formOrderStatus->get('orderStatus')->getData(), $orderShop); | $orderShop = $this->orderUtils->changeOrderStatus($formOrderStatus->get('orderStatus')->getData(), $orderShop); | ||||
if($oldStatus !== $orderShop->getOrderStatus()){ | |||||
if ($oldStatus !== $orderShop->getOrderStatus()) { | |||||
$this->utils->addFlash('success', 'success.order.changeStatus'); | $this->utils->addFlash('success', 'success.order.changeStatus'); | ||||
} | } | ||||
} else { | } else { | ||||
//TODO si édition despayment existant on vérifie qu'il est lié à nla commabde courante | //TODO si édition despayment existant on vérifie qu'il est lié à nla commabde courante | ||||
$orderPaymentPost = $this->request->request->get('order_payment'); | $orderPaymentPost = $this->request->request->get('order_payment'); | ||||
if($orderPaymentPost['id']){ | |||||
if ($orderPaymentPost['id']) { | |||||
$orderPayment = $this->em->getRepository(OrderPaymentInterface::class)->find($orderPaymentPost['id']); | $orderPayment = $this->em->getRepository(OrderPaymentInterface::class)->find($orderPaymentPost['id']); | ||||
}else{ | |||||
} else { | |||||
$orderPaymentClass = $this->em->getClassMetadata(OrderPaymentInterface::class); | $orderPaymentClass = $this->em->getClassMetadata(OrderPaymentInterface::class); | ||||
$orderPayment = new $orderPaymentClass->name; | $orderPayment = new $orderPaymentClass->name; | ||||
} | } | ||||
if ($formOrderPayment->isSubmitted() && $formOrderPayment->isValid()) { | if ($formOrderPayment->isSubmitted() && $formOrderPayment->isValid()) { | ||||
$orderPayment->setOrderShop($orderShop); | $orderPayment->setOrderShop($orderShop); | ||||
if($orderPayment->getMeanPayment() === Utils::MEAN_PAYMENT_CREDIT){ | |||||
if ($orderPayment->getMeanPayment() === Utils::MEAN_PAYMENT_CREDIT) { | |||||
$orderPayment->setEditable(false); | $orderPayment->setEditable(false); | ||||
$params['orderPayment'] = $orderPayment; | $params['orderPayment'] = $orderPayment; | ||||
$creditHistory = $this->creditUtils->initCreditHistory(CreditHistory::TYPE_DEBIT, $orderShop->getUser(), $params); | $creditHistory = $this->creditUtils->initCreditHistory(CreditHistory::TYPE_DEBIT, $orderShop->getUser(), $params); | ||||
if ($this->creditUtils->isCreditSufficientToPay($creditHistory->getUserMerchant(), $creditHistory->getAmountInherited())) { | if ($this->creditUtils->isCreditSufficientToPay($creditHistory->getUserMerchant(), $creditHistory->getAmountInherited())) { | ||||
if($this->creditUtils->saveCreditHistory($creditHistory)) { | |||||
if ($this->creditUtils->saveCreditHistory($creditHistory)) { | |||||
$this->em->persist($orderPayment); | $this->em->persist($orderPayment); | ||||
$this->em->flush(); | $this->em->flush(); | ||||
$this->utils->addFlash('success', 'success.credit.debited'); | $this->utils->addFlash('success', 'success.credit.debited'); | ||||
$this->utils->addFlash('success', 'success.order.addPayment'); | $this->utils->addFlash('success', 'success.order.addPayment'); | ||||
} | } | ||||
}else{ | |||||
} else { | |||||
$this->utils->addFlash('error', 'error.credit.notEnoughCredit'); | $this->utils->addFlash('error', 'error.credit.notEnoughCredit'); | ||||
} | } | ||||
}else{ | |||||
} else { | |||||
$orderPayment->setEditable(true); | $orderPayment->setEditable(true); | ||||
$this->em->persist($orderPayment); | $this->em->persist($orderPayment); | ||||
$this->em->flush(); | $this->em->flush(); | ||||
} | } | ||||
} else { | } else { | ||||
$this->utils->addFlash('error', $formOrderPayment->getErrors()); | $this->utils->addFlash('error', $formOrderPayment->getErrors()); | ||||
} | } | ||||
return $this->createOrderAjaxReponse($orderShop); | return $this->createOrderAjaxReponse($orderShop); | ||||
} | } | ||||
public function deleteOrderPaymentAction() | |||||
{ | |||||
$orderShop = $this->getOrderShopEntity(); | |||||
$formDeleteOrderPayment = $this->createForm(DeleteOrderPaymentType::class); | |||||
$formDeleteOrderPayment->handleRequest($this->request); | |||||
if ($formDeleteOrderPayment->isSubmitted() && $formDeleteOrderPayment->isValid()) { | |||||
$orderPayment = $this->em->getRepository(OrderPaymentInterface::class)->find($formDeleteOrderPayment->get('id')->getData()); | |||||
if ($orderPayment && $orderShop->getOrderPayments()->contains($orderPayment) && $orderPayment->getEditable()) { | |||||
$orderShop->removeOrderPayment($orderPayment); | |||||
$this->em->remove($orderPayment); | |||||
$this->em->flush(); | |||||
$this->utils->addFlash('success', 'success.order.removeOrderPayement'); | |||||
} | |||||
} else { | |||||
$this->utils->addFlash('error', $formDeleteOrderPayment->getErrors()); | |||||
} | |||||
return $this->createOrderAjaxReponse($orderShop); | |||||
} | |||||
public function addOrderReductionCartAction() | public function addOrderReductionCartAction() | ||||
{ | { | ||||
$orderShop = $this->getOrderShopEntity(); | $orderShop = $this->getOrderShopEntity(); | ||||
if ($formDeleteOrderReductionCart->isSubmitted() && $formDeleteOrderReductionCart->isValid()) { | if ($formDeleteOrderReductionCart->isSubmitted() && $formDeleteOrderReductionCart->isValid()) { | ||||
$orderReductionCart = $this->em->getRepository(OrderReductionCartInterface::class)->find($formDeleteOrderReductionCart->get('id')->getData()); | $orderReductionCart = $this->em->getRepository(OrderReductionCartInterface::class)->find($formDeleteOrderReductionCart->get('id')->getData()); | ||||
if($orderReductionCart && $orderShop->getOrderReductionCarts()->contains($orderReductionCart)){ | |||||
if ($orderReductionCart && $orderShop->getOrderReductionCarts()->contains($orderReductionCart)) { | |||||
$orderShop->removeOrderReductionCart($orderReductionCart); | $orderShop->removeOrderReductionCart($orderReductionCart); | ||||
$this->em->remove($orderReductionCart); | $this->em->remove($orderReductionCart); | ||||
$this->em->flush(); | $this->em->flush(); | ||||
if ($formDeleteOrderReductionCredit->isSubmitted() && $formDeleteOrderReductionCredit->isValid()) { | if ($formDeleteOrderReductionCredit->isSubmitted() && $formDeleteOrderReductionCredit->isValid()) { | ||||
$orderReductionCredit = $this->em->getRepository(OrderReductionCreditInterface::class)->find($formDeleteOrderReductionCredit->get('id')->getData()); | $orderReductionCredit = $this->em->getRepository(OrderReductionCreditInterface::class)->find($formDeleteOrderReductionCredit->get('id')->getData()); | ||||
if($formDeleteOrderReductionCredit && $orderShop->getOrderReductionCredits()->contains($orderReductionCredit)){ | |||||
if ($formDeleteOrderReductionCredit && $orderShop->getOrderReductionCredits()->contains($orderReductionCredit)) { | |||||
$orderShop->removeOrderReductionCredit($orderReductionCredit); | $orderShop->removeOrderReductionCredit($orderReductionCredit); | ||||
$this->em->remove($orderReductionCredit); | $this->em->remove($orderReductionCredit); | ||||
$this->em->flush(); | $this->em->flush(); | ||||
} | } | ||||
public function renderOrderShopTemplate($actionName, $templatePath, array $parameters = []) | public function renderOrderShopTemplate($actionName, $templatePath, array $parameters = []) | ||||
{ | { | ||||
$orderShop = $this->getOrderShopEntity(); | $orderShop = $this->getOrderShopEntity(); | ||||
switch ($orderShop->getOrderStatus()->getAlias()){ | |||||
switch ($orderShop->getOrderStatus()->getAlias()) { | |||||
case OrderStatus::ALIAS_CART : | case OrderStatus::ALIAS_CART : | ||||
if (!isset($parameters['form_order_delivery_address'])) { | if (!isset($parameters['form_order_delivery_address'])) { | ||||
$parameters['form_delete_order_reduction_credit'] = $this->createCustomForm(DeleteOrderReductionCreditType::class, 'deleteOrderReductionCredit', $parameters)->createView(); | $parameters['form_delete_order_reduction_credit'] = $this->createCustomForm(DeleteOrderReductionCreditType::class, 'deleteOrderReductionCredit', $parameters)->createView(); | ||||
$parameters['form_add_product_to_order'] = $this->createCustomForm(AddPoductToOrderType::class, 'addProductToOrder', $parameters)->createView(); | $parameters['form_add_product_to_order'] = $this->createCustomForm(AddPoductToOrderType::class, 'addProductToOrder', $parameters)->createView(); | ||||
$parameters['form_order_products'] = $this->createCustomForm(OrderProductsType::class, 'orderProducts', $parameters)->createView(); | $parameters['form_order_products'] = $this->createCustomForm(OrderProductsType::class, 'orderProducts', $parameters)->createView(); | ||||
$parameters['form_order_payment'] = $this->createCustomForm(OrderPaymentType::class, 'orderPayment', $parameters, false)->createView(); | |||||
$parameters['form_order_status'] = $this->createCustomForm(OrderStatusType::class, 'orderStatus', $parameters)->createView(); | $parameters['form_order_status'] = $this->createCustomForm(OrderStatusType::class, 'orderStatus', $parameters)->createView(); | ||||
$parameters['form_order_invoice_address'] = $this->createCustomForm(OrderInvoiceAddressType::class, 'orderInvoiceAddress', $parameters)->createView(); | $parameters['form_order_invoice_address'] = $this->createCustomForm(OrderInvoiceAddressType::class, 'orderInvoiceAddress', $parameters)->createView(); | ||||
break; | break; | ||||
case OrderStatus::ALIAS_WAITING_PAYMENT_CREDIT : | case OrderStatus::ALIAS_WAITING_PAYMENT_CREDIT : | ||||
case OrderStatus::ALIAS_WAITING_PAYMENT_ONLINE : | case OrderStatus::ALIAS_WAITING_PAYMENT_ONLINE : | ||||
$parameters['form_order_payment'] = $this->createCustomForm(OrderPaymentType::class, 'orderPayment', $parameters, false)->createView(); | $parameters['form_order_payment'] = $this->createCustomForm(OrderPaymentType::class, 'orderPayment', $parameters, false)->createView(); | ||||
$parameters['form_delete_order_payment'] = $this->createCustomForm(DeleteOrderPaymentType::class, 'deleteOrderPayment', $parameters)->createView(); | |||||
$parameters['form_order_status'] = $this->createCustomForm(OrderStatusType::class, 'orderStatus', $parameters)->createView(); | $parameters['form_order_status'] = $this->createCustomForm(OrderStatusType::class, 'orderStatus', $parameters)->createView(); | ||||
$parameters['form_order_invoice_address'] = $this->createCustomForm(OrderInvoiceAddressType::class, 'orderInvoiceAddress', $parameters)->createView(); | $parameters['form_order_invoice_address'] = $this->createCustomForm(OrderInvoiceAddressType::class, 'orderInvoiceAddress', $parameters)->createView(); | ||||
break; | break; | ||||
if (!$user instanceof UserInterface) return $user; | if (!$user instanceof UserInterface) return $user; | ||||
else { | 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() | |||||
]); | |||||
$orderShopUser = $this->em->getRepository(OrderShopInterface::class)->findCartCurrent(['user'=>$user]); | |||||
if($orderShopUser){ | |||||
$this->utils->addFlash('info', 'error.order.otherOrderAlreadyExist'); | |||||
return $this->redirectToRoute('easyadmin', [ | |||||
'action' => 'edit', | |||||
'entity' => $this->entity['name'], | |||||
'id' => $orderShopUser->getId() | |||||
]); | |||||
}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() | |||||
]); | |||||
} | |||||
} | } | ||||
} | } | ||||
<?php | |||||
namespace Lc\ShopBundle\Form\Backend\Order; | |||||
use App\Entity\Product; | |||||
use Doctrine\ORM\EntityManagerInterface; | |||||
use Lc\ShopBundle\Context\OrderProductInterface; | |||||
use Lc\ShopBundle\Context\OrderReductionCartInterface; | |||||
use Lc\ShopBundle\Context\OrderShopInterface; | |||||
use Lc\ShopBundle\Context\OrderUtilsInterface; | |||||
use Lc\ShopBundle\Context\ProductInterface; | |||||
use Lc\ShopBundle\Context\ReductionCartInterface; | |||||
use Lc\ShopBundle\Context\ReductionCreditInterface; | |||||
use Lc\ShopBundle\Form\DataTransformer\ProductToIdTransformer; | |||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType; | |||||
use Symfony\Component\Form\AbstractType; | |||||
use Symfony\Component\Form\Extension\Core\Type\ButtonType; | |||||
use Symfony\Component\Form\Extension\Core\Type\HiddenType; | |||||
use Symfony\Component\Form\Extension\Core\Type\NumberType; | |||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType; | |||||
use Symfony\Component\Form\Extension\Core\Type\TextType; | |||||
use Symfony\Component\Form\FormBuilderInterface; | |||||
use Symfony\Component\OptionsResolver\OptionsResolver; | |||||
class AddRedeliveryOrderProductType extends AbstractType | |||||
{ | |||||
protected $em; | |||||
protected $orderUtils; | |||||
public function __construct(EntityManagerInterface $em, OrderUtilsInterface $orderUtils) | |||||
{ | |||||
$this->em = $em; | |||||
$this->orderUtils = $orderUtils; | |||||
} | |||||
public function buildForm(FormBuilderInterface $builder, array $options) | |||||
{ | |||||
// TODO ce form n'a pas été testé !!!!! voir exemple sur PDL | |||||
$builder->add('title', TextType::class); | |||||
$builder->add('unit'); | |||||
$builder->add('quantityProduct', NumberType::class); | |||||
$builder->add('quantityOrder', NumberType::class); | |||||
$builder->add('add', ButtonType::class, array( | |||||
'label' => 'action.add' | |||||
)); | |||||
} | |||||
public function configureOptions(OptionsResolver $resolver) | |||||
{ | |||||
$resolver->setDefaults([ | |||||
'data_class' => $this->em->getClassMetadata(OrderProductInterface::class)->getName(), | |||||
]); | |||||
} | |||||
} |
<?php | |||||
namespace Lc\ShopBundle\Form\Backend\Order; | |||||
use App\Entity\Product; | |||||
use Doctrine\ORM\EntityManagerInterface; | |||||
use Lc\ShopBundle\Context\OrderProductInterface; | |||||
use Lc\ShopBundle\Context\OrderReductionCartInterface; | |||||
use Lc\ShopBundle\Context\OrderShopInterface; | |||||
use Lc\ShopBundle\Context\OrderUtilsInterface; | |||||
use Lc\ShopBundle\Context\ProductInterface; | |||||
use Lc\ShopBundle\Context\ReductionCartInterface; | |||||
use Lc\ShopBundle\Context\ReductionCreditInterface; | |||||
use Lc\ShopBundle\Form\DataTransformer\ProductToIdTransformer; | |||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType; | |||||
use Symfony\Component\Form\AbstractType; | |||||
use Symfony\Component\Form\Extension\Core\Type\ButtonType; | |||||
use Symfony\Component\Form\Extension\Core\Type\HiddenType; | |||||
use Symfony\Component\Form\Extension\Core\Type\NumberType; | |||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType; | |||||
use Symfony\Component\Form\FormBuilderInterface; | |||||
use Symfony\Component\OptionsResolver\OptionsResolver; | |||||
class AddReductionCreditType extends AbstractType | |||||
{ | |||||
protected $em; | |||||
protected $orderUtils; | |||||
public function __construct(EntityManagerInterface $em, OrderUtilsInterface $orderUtils) | |||||
{ | |||||
$this->em = $em; | |||||
$this->orderUtils = $orderUtils; | |||||
} | |||||
public function buildForm(FormBuilderInterface $builder, array $options) | |||||
{ | |||||
$entity = $options['data']; | |||||
$reductionCreditClass = $this->em->getClassMetadata(ReductionCreditInterface::class); | |||||
$reductionCreditRepo = $this->em->getRepository(ReductionCreditInterface::class);; | |||||
$builder->add('add', ButtonType::class, array( | |||||
'label' => 'action.add' | |||||
)); | |||||
} | |||||
public function configureOptions(OptionsResolver $resolver) | |||||
{ | |||||
$resolver->setDefaults([ | |||||
'data_class' => $this->em->getClassMetadata(ReductionCreditInterface::class)->getName(), | |||||
]); | |||||
} | |||||
} |
<?php | |||||
namespace Lc\ShopBundle\Form\Backend\Order; | |||||
use App\Entity\Product; | |||||
use Doctrine\ORM\EntityManagerInterface; | |||||
use Lc\ShopBundle\Context\OrderProductInterface; | |||||
use Lc\ShopBundle\Context\OrderReductionCartInterface; | |||||
use Lc\ShopBundle\Context\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\ButtonType; | |||||
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 DeleteOrderPaymentType extends AbstractType | |||||
{ | |||||
protected $em ; | |||||
public function __construct(EntityManagerInterface $em) | |||||
{ | |||||
$this->em = $em ; | |||||
} | |||||
public function buildForm(FormBuilderInterface $builder, array $options) | |||||
{ | |||||
$builder | |||||
->add('id', HiddenType::class) | |||||
->add('delete', ButtonType::class); | |||||
/* ->add('id', HiddenType::class);*/ | |||||
} | |||||
public function configureOptions(OptionsResolver $resolver) | |||||
{ | |||||
/*$resolver->setDefaults([ | |||||
'data_class' => $this->em->getClassMetadata(OrderReductionCartInterface::class)->getName(), | |||||
]);*/ | |||||
} | |||||
} |
.lc-offline-field label::after{content:' [hors ligne]'} | .lc-offline-field label::after{content:' [hors ligne]'} | ||||
input[type=number]::-webkit-inner-spin-button, | |||||
input[type=number]::-webkit-outer-spin-button { | |||||
-webkit-appearance: none; | |||||
} | |||||
input[type=number] { | |||||
-moz-appearance: textfield; | |||||
} | |||||
/* Général */ | /* Général */ | ||||
.btn.btn-primary.action-save{float: right;} | .btn.btn-primary.action-save{float: right;} | ||||
.button-action .btn{margin-left: 10px;} | .button-action .btn{margin-left: 10px;} |
deleteOrderProduct: function () { | deleteOrderProduct: function () { | ||||
$(this.$refs.fieldQuantity).val(0); | $(this.$refs.fieldQuantity).val(0); | ||||
this.$parent.updateOrderProducts(); | this.$parent.updateOrderProducts(); | ||||
}, | |||||
modalAddRedeliveryOrderProduct:function () { | |||||
log(this.orderProduct.id); | |||||
$(this.$parent.$refs['addRedeliveryOrderProductFormOrderProduct']).val(this.orderProduct.id); | |||||
$('#modal-add-redelivery-order-product').modal('show'); | |||||
} | } | ||||
/*log($('#order-products-list').data('prototype')); | /*log($('#order-products-list').data('prototype')); | ||||
var prototype = $('#order-products-list').data('prototype'); | var prototype = $('#order-products-list').data('prototype'); | ||||
templateTest: window.templateTest, | templateTest: window.templateTest, | ||||
orderProducts: [], | orderProducts: [], | ||||
order: [], | order: [], | ||||
orderPaymentFormMeanPayment: null, | |||||
orderPaymentFormAmount: null, | |||||
orderPaymentFormPaidAt:null, | |||||
orderPaymentFormReference:null, | |||||
orderPaymentFormComment:null, | |||||
orderPaymentFormId: null, | |||||
deliveryType: null, | deliveryType: null, | ||||
isLoading: true, | isLoading: true, | ||||
addProductId: null, | addProductId: null, | ||||
addOrderPayment: function () { | addOrderPayment: function () { | ||||
if($('#order_payment_meanPayment').val() == 'credit'){ | if($('#order_payment_meanPayment').val() == 'credit'){ | ||||
if(window.confirm("Vous allez débitez le compte prépayé, êtes vous sur ?")){ | |||||
if(window.confirm("Vous allez débitez le compte prépayév, êtes vous sur ?")){ | |||||
this.postForm('#orderPaymentForm', '#modal-order-payment'); | this.postForm('#orderPaymentForm', '#modal-order-payment'); | ||||
} | } | ||||
}else{ | }else{ | ||||
}, | }, | ||||
editOrderPayment:function(id){ | editOrderPayment:function(id){ | ||||
var orderPayment = this.order.orderPayments[id]; | |||||
$('#modal-order-payment').find('#order_payment_id').val(id); | |||||
$('#modal-order-payment').find('#order_payment_meanPayment').val(orderPayment['meanPayment']); | |||||
$('#modal-order-payment').find('#order_payment_meanPayment').trigger('change'); | |||||
$('#modal-order-payment').find('#order_payment_amount').val(orderPayment['amount']); | |||||
$('#modal-order-payment').find('#order_payment_paidAt').val(orderPayment['paidAt']); | |||||
$('#modal-order-payment').find('#order_payment_reference').val(orderPayment['reference']); | |||||
$('#modal-order-payment').find('#order_payment_comment').val(orderPayment['comment']); | |||||
this.setOrderPaymentFormValues(this.order.orderPayments[id]) | |||||
$('#modal-order-payment').modal("show") | $('#modal-order-payment').modal("show") | ||||
}, | }, | ||||
setOrderPaymentFormValues(orderPayment = false) { | |||||
if (orderPayment)this.orderPaymentFormId = orderPayment['id']; | |||||
else this.orderPaymentFormId = null; | |||||
if (orderPayment) $(this.$refs["meanPaymentSelect"]).val(orderPayment['meanPayment']).trigger('change'); | |||||
else $(this.$refs["meanPaymentSelect"]).val(false).trigger('change'); | |||||
if (orderPayment) this.orderPaymentFormAmount = orderPayment['amount']; | |||||
else this.orderPaymentFormAmount = null; | |||||
if (orderPayment) this.orderPaymentFormPaidAt = orderPayment['paidAt']; | |||||
else this.orderPaymentFormPaidAt = false; | |||||
if (orderPayment) this.orderPaymentFormReference = orderPayment['reference']; | |||||
else this.orderPaymentFormReference = null; | |||||
if (orderPayment) this.orderPaymentFormComment = orderPayment['comment']; | |||||
this.orderPaymentFormComment = null; | |||||
}, | |||||
modalDeleteOrderPayment:function(id){ | |||||
$(this.$refs['deleteOrderPaymentId']).val(id); | |||||
$('#modal-delete-order-payment').modal("show") | |||||
}, | |||||
deleteOrderPayment: function () { | |||||
this.postForm('#deleteOrderPaymentForm', '#modal-delete-order-payment'); | |||||
}, | |||||
updateOrderProducts: function () { | updateOrderProducts: function () { | ||||
this.postForm('#orderProductsForm', false); | this.postForm('#orderProductsForm', false); | ||||
}, | }, | ||||
addOrderReductionCart: function () { | addOrderReductionCart: function () { | ||||
this.postForm('#addOrderReductionCartForm', '#modal-add-reduction-cart'); | this.postForm('#addOrderReductionCartForm', '#modal-add-reduction-cart'); | ||||
}, | }, | ||||
modalOrderReductionCart: function (id) { | |||||
$('#modal-delete-reduction-cart').find('#delete_order_reduction_cart_id').val(id); | |||||
modalDeleteOrderReductionCart: function (id) { | |||||
log($(this.$refs['deleteOrderReductionCartId'])); | |||||
$(this.$refs['deleteOrderReductionCartId']).val(id); | |||||
$('#modal-delete-reduction-cart').modal("show") | $('#modal-delete-reduction-cart').modal("show") | ||||
}, | }, | ||||
deleteOrderReductionCart: function () { | deleteOrderReductionCart: function () { | ||||
this.postForm('#deleteOrderReductionCartForm', '#modal-delete-reduction-cart'); | this.postForm('#deleteOrderReductionCartForm', '#modal-delete-reduction-cart'); | ||||
}, | }, | ||||
modalOrderReductionCredit: function (id) { | |||||
$('#modal-delete-reduction-credit').find('#delete_order_reduction_credit_id').val(id); | |||||
modalDeleteOrderReductionCredit: function (id) { | |||||
$(this.$refs['deleteOrderReductionCreditId']).val(id); | |||||
$('#modal-delete-reduction-credit').modal("show") | $('#modal-delete-reduction-credit').modal("show") | ||||
}, | }, | ||||
deleteOrderReductionCredit: function () { | deleteOrderReductionCredit: function () { | ||||
addOrderReductionCredit: function () { | addOrderReductionCredit: function () { | ||||
this.postForm('#addOrderReductionCreditForm', '#modal-add-reduction-credit'); | this.postForm('#addOrderReductionCreditForm', '#modal-add-reduction-credit'); | ||||
}, | }, | ||||
addRedeliveryOrderProduct: function () { | |||||
this.postForm('#addRedeliveryOrderProductForm', '#modal-add-redelivery-order-product'); | |||||
}, | |||||
postForm: function (formId, modalId) { | postForm: function (formId, modalId) { | ||||
var app = this; | var app = this; | ||||
if(checkFormValidity(formId)) { | if(checkFormValidity(formId)) { |
resume: Résumé de commande | resume: Résumé de commande | ||||
addProduct: Ajout de produit à la commande | addProduct: Ajout de produit à la commande | ||||
orderPayment: Ajouter un règlement | orderPayment: Ajouter un règlement | ||||
orderStatus: Changer de status | |||||
None: Aucune valeur | None: Aucune valeur | ||||
label.form.empty_value: Choisissez une option | label.form.empty_value: Choisissez une option | ||||
form.label.delete: Supprimer l'image | form.label.delete: Supprimer l'image | ||||
productUnavailable: Certains produits ne sont plus disponibles | productUnavailable: Certains produits ne sont plus disponibles | ||||
nextStatusNotAllow: La commande ne peut passer à ce statut | nextStatusNotAllow: La commande ne peut passer à ce statut | ||||
noPayment: Le montant de la commande n'a pas été règlé dans sa totalité | noPayment: Le montant de la commande n'a pas été règlé dans sa totalité | ||||
otherOrderAlreadyExist: Une autre commande existe déjà pour cet utilisateur, vous avez été redirigé. | |||||
reductionCart: | reductionCart: | ||||
conditionsError: Cette réduction ne peut pas être appliqué sur cette commande | conditionsError: Cette réduction ne peut pas être appliqué sur cette commande | ||||
date: La réduction n'est plus active | date: La réduction n'est plus active |
{% if form_order_payment is defined %} | {% if form_order_payment is defined %} | ||||
{% include '@LcShop/backend/order/form/modal_orderpayment.html.twig' %} | {% include '@LcShop/backend/order/form/modal_orderpayment.html.twig' %} | ||||
{% endif %} | {% endif %} | ||||
{% if form_delete_order_payment is defined %} | |||||
{% include '@LcShop/backend/order/form/modal_deleteorderpayment.html.twig' %} | |||||
{% endif %} | |||||
{% if form_add_redelivery_order_product is defined %} | |||||
{% include '@LcShop/backend/order/form/modal_addredeliveryorderproduct.html.twig' %} | |||||
{% endif %} | |||||
{# {{ macros.startCard(3, 'OrderShop.addProduct', 'success') }} | {# {{ macros.startCard(3, 'OrderShop.addProduct', 'success') }} | ||||
{% include '@LcShop/backend/order/form/addproducttoorder.html.twig' %} | {% include '@LcShop/backend/order/form/addproducttoorder.html.twig' %} |
<div class="modal fade show" id="modal-add-redelivery-order-product"> | |||||
{{ form_start(form_add_redelivery_order_product, {'attr': { 'id' : 'addRedeliveryOrderProductForm'}}) }} | |||||
{% form_theme form_add_redelivery_order_product '@LcShop/backend/form/custom_bootstrap_4.html.twig' %} | |||||
<div class="modal-dialog modal-lg"> | |||||
<div class="modal-content"> | |||||
<div class="modal-header"> | |||||
<h4>{{ "group.OrderShop.addRedeliveryOrderProduct"|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_add_redelivery_order_product.orderProduct, {'attr' :{'ref' : 'addRedeliveryOrderProductFormOrderProduct'}}) }} | |||||
{{ form_row(form_add_redelivery_order_product.title) }} | |||||
{{ form_row(form_add_redelivery_order_product.unit) }} | |||||
{{ form_row(form_add_redelivery_order_product.quantityProduct) }} | |||||
{{ form_row(form_add_redelivery_order_product.quantityOrder) }} | |||||
</div> | |||||
</div> | |||||
<div class="modal-footer justify-content-between"> | |||||
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button> | |||||
{{ form_row(form_add_redelivery_order_product.add, {"attr": {'class' : 'btn btn-primary', '@click' : 'addRedeliveryOrderProduct'}}) }} | |||||
</div> | |||||
</div> | |||||
<!-- /.modal-content --> | |||||
</div> | |||||
{{ form_end(form_order_delivery_address) }} | |||||
</div> |
{% trans_default_domain 'lcshop' %} | |||||
<div class="modal fade show" id="modal-delete-order-payment"> | |||||
{{ form_start(form_delete_order_payment, {'attr': { 'id' : 'deleteOrderPaymentForm'}}) }} | |||||
{% form_theme form_delete_order_payment '@LcShop/backend/form/custom_bootstrap_4.html.twig' %} | |||||
<div class="modal-dialog"> | |||||
<div class="modal-content"> | |||||
<div class="modal-header"> | |||||
<h4>{{ "action.order.deleteOrderPayment"|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"> | |||||
Est-vous sur de vouloir surppimer cette réduction | |||||
{{ form_row(form_delete_order_payment.id, {'attr' : {"ref" : 'deleteOrderPaymentId'}}) }} | |||||
</div> | |||||
</div> | |||||
<div class="modal-footer justify-content-between"> | |||||
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button> | |||||
{{ form_row(form_delete_order_payment.delete, {"attr": {'class' : 'btn btn-primary', '@click': 'deleteOrderPayment'}}) }} | |||||
</div> | |||||
</div> | |||||
<!-- /.modal-content --> | |||||
</div>#} | |||||
{{ form_end(form_delete_order_payment) }} | |||||
</div> |
<div class="modal-body"> | <div class="modal-body"> | ||||
<div class="col"> | <div class="col"> | ||||
Est-vous sur de vouloir surppimer cette réduction | Est-vous sur de vouloir surppimer cette réduction | ||||
{{ form_row(form_delete_order_reduction_cart.id) }} | |||||
{{ form_row(form_delete_order_reduction_cart.id, {'attr' : {"ref" : 'deleteOrderReductionCartId'}}) }} | |||||
</div> | </div> | ||||
</div> | </div> |
<div class="modal-body"> | <div class="modal-body"> | ||||
<div class="col"> | <div class="col"> | ||||
Est-vous sur de vouloir surppimer cette réduction | Est-vous sur de vouloir surppimer cette réduction | ||||
{{ form_row(form_delete_order_reduction_credit.id) }} | |||||
{{ form_row(form_delete_order_reduction_credit.id, {'attr' : {"ref" : 'deleteOrderReductionCreditId'}}) }} | |||||
</div> | </div> | ||||
</div> | </div> |
</button> | </button> | ||||
</div> | </div> | ||||
<div class="modal-body"> | <div class="modal-body"> | ||||
{{ form_row(form_order_payment.meanPayment) }} | |||||
{{ form_row(form_order_payment.amount) }} | |||||
{{ form_row(form_order_payment.paidAt) }} | |||||
{{ form_row(form_order_payment.reference) }} | |||||
{{ form_row(form_order_payment.comment) }} | |||||
{{ form_row(form_order_payment.meanPayment, {'attr' : {'v-model' : 'orderPaymentFormMeanPayment', 'ref' : 'meanPaymentSelect'}}) }} | |||||
{{ form_row(form_order_payment.amount, {'attr' : {'v-model' : 'orderPaymentFormAmount'}}) }} | |||||
{{ form_row(form_order_payment.paidAt, {'attr' : {'v-model' : 'orderPaymentFormPaidAt'}}) }} | |||||
{{ form_row(form_order_payment.reference, {'attr' : {'v-model' : 'orderPaymentFormReference'}}) }} | |||||
{{ form_row(form_order_payment.comment, {'attr' : {'v-model' : 'orderPaymentFormComment'}}) }} | |||||
{{ form_row(form_order_payment.id, {'attr' : {'v-model' : 'orderPaymentFormId'}}) }} | |||||
</div> | </div> | ||||
<div class="modal-footer justify-content-between"> | <div class="modal-footer justify-content-between"> | ||||
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button> | <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> |
<div class="modal-content"> | <div class="modal-content"> | ||||
<div class="modal-header"> | <div class="modal-header"> | ||||
<h4>{{ "form.group.OrderShop.orderStatus"|trans }}</h4> | |||||
<h4>{{ "group.OrderShop.orderStatus"|trans }}</h4> | |||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"> | <button type="button" class="close" data-dismiss="modal" aria-label="Close"> | ||||
<span aria-hidden="true">×</span> | <span aria-hidden="true">×</span> | ||||
</button> | </button> |
{% endif %} | {% endif %} | ||||
</td> | </td> | ||||
<td> | <td> | ||||
<button type="button" class="btn-remove-product btn btn-default" @click="modalAddRedeliveryOrderProduct"> | |||||
NICHE | |||||
</button> | |||||
{% verbatim %}{{orderProduct.totalWithTaxAndReduction}}{% endverbatim %}€ | {% verbatim %}{{orderProduct.totalWithTaxAndReduction}}{% endverbatim %}€ | ||||
</td> | </td> | ||||
</tr> | </tr> | ||||
<td>${orderPayment.paidAtText}</td> | <td>${orderPayment.paidAtText}</td> | ||||
<td>${orderPayment.amount}</td> | <td>${orderPayment.amount}</td> | ||||
<td> | <td> | ||||
<button v-show="orderPayment.editable" class="btn-sm btn-info" type="button" @click="editOrderPayment(orderPayment.id)"> | |||||
<button v-show="orderPayment.editable && editionMode && modalExist('#modal-delete-order-payment')" class="btn-sm btn-info" type="button" @click="editOrderPayment(orderPayment.id)"> | |||||
<i class="fa fa-pen"></i> | <i class="fa fa-pen"></i> | ||||
</button> | </button> | ||||
<button v-show="orderPayment.editable && editionMode && modalExist('#modal-delete-order-payment')" | |||||
type="button" class="btn-sm btn-danger" | |||||
@click="modalDeleteOrderPayment(orderPayment.id)"> | |||||
<i class="fa fa-trash"></i> | |||||
</button> | |||||
</td> | </td> | ||||
</tr> | </tr> | ||||
</template> | </template> | ||||
</tbody> | </tbody> | ||||
</table> | </table> | ||||
{{ _self.order_modal_button('#modal-order-payment', 'btn-info', "action.order.addOrderPayment") }} | {{ _self.order_modal_button('#modal-order-payment', 'btn-info', "action.order.addOrderPayment") }} | ||||
<span class="float-right">Total : ${order.orderPaid}</span> | |||||
</div> | |||||
<div class="col-8"> | |||||
<div v-show="order.isOrderPaid" class="alert alert-success alert-dismissible"> | |||||
<h5><i class="icon fas fa-check"></i> Commande soldé</h5> | |||||
</div> | |||||
<div v-show="order.isOrderPaid==false" class="alert alert-danger alert-dismissible"> | |||||
<h5><i class="icon fas fa-check"></i> Commande non soldé</h5> | |||||
</div> | |||||
</div> | |||||
<div class="col-4"> | |||||
<span class="float-right">Total : ${order.totalOrderPaid}</span> | |||||
</div> | </div> | ||||
</div> | </div> | ||||
</div> | </div> | ||||
${orderReductionCart.title} | ${orderReductionCart.title} | ||||
<button v-show="editionMode && modalExist('#modal-delete-reduction-cart')" type="button" | <button v-show="editionMode && modalExist('#modal-delete-reduction-cart')" type="button" | ||||
class="btn-sm btn-danger" | class="btn-sm btn-danger" | ||||
@click="modalOrderReductionCart(orderReductionCart.id)"> | |||||
@click="modalDeleteOrderReductionCart(orderReductionCart.id)"> | |||||
<i class="fa fa-trash"></i> | <i class="fa fa-trash"></i> | ||||
</button> | </button> | ||||
</th> | </th> | ||||
<button v-show="editionMode && modalExist('#modal-delete-reduction-credit')" | <button v-show="editionMode && modalExist('#modal-delete-reduction-credit')" | ||||
type="button" class="btn-sm btn-danger" | type="button" class="btn-sm btn-danger" | ||||
@click="modalOrderReductionCredit(orderReductionCredit.id)"> | |||||
@click="modalDeleteOrderReductionCredit(orderReductionCredit.id)"> | |||||
<i class="fa fa-trash"></i> | <i class="fa fa-trash"></i> | ||||
</button> | </button> | ||||
</th> | </th> |
public function createOrderShop($params) | public function createOrderShop($params) | ||||
{ | { | ||||
//TODO vérifier que l'utilisateur n'a pas déjà une commande en cours | |||||
$orderShop = new OrderShop(); | $orderShop = new OrderShop(); | ||||
$orderShopBelongTo = false; | $orderShopBelongTo = false; | ||||
public function deductAvailabilityProduct(\Lc\ShopBundle\Model\OrderShop $orderShop) | public function deductAvailabilityProduct(\Lc\ShopBundle\Model\OrderShop $orderShop) | ||||
{ | { | ||||
//TODO ne pas déduire des stocks les orderProduct marqué en relivraison | |||||
foreach ($orderShop->getOrderProducts() as $orderProduct) { | foreach ($orderShop->getOrderProducts() as $orderProduct) { | ||||
switch ($orderProduct->getProduct()->getProductFamily()->getBehaviorCountStock()) { | switch ($orderProduct->getProduct()->getProductFamily()->getBehaviorCountStock()) { | ||||
case ProductFamily::BEHAVIOR_COUNT_STOCK_BY_MEASURE : | case ProductFamily::BEHAVIOR_COUNT_STOCK_BY_MEASURE : |