@@ -28,19 +28,25 @@ class OrderController extends AdminController | |||
{ | |||
protected function createListQueryBuilder($entityClass, $sortDirection, $sortField = null, $dqlFilter = null) | |||
{ | |||
$filterOrderStatus = false; | |||
$filterIsOrderStatus = false; | |||
$filterNotOrderStatus = false; | |||
if ($dqlFilter['orderStatus']) $filterOrderStatus = $dqlFilter['orderStatus']; | |||
if (isset($dqlFilter['isOrderStatus'])) $filterIsOrderStatus = $dqlFilter['isOrderStatus']; | |||
if (isset($dqlFilter['notOrderStatus'])) $filterNotOrderStatus = $dqlFilter['notOrderStatus']; | |||
$dqlFilter = $dqlFilter['filter']; | |||
$queryBuilder = parent::createListQueryBuilder($entityClass, $sortDirection, $sortField, $dqlFilter); | |||
$queryBuilder->leftJoin('entity.orderStatus', 'orderStatus'); | |||
if ($filterOrderStatus) { | |||
if ($filterIsOrderStatus) { | |||
$queryBuilder->andWhere('orderStatus.alias IN (:status)'); | |||
$queryBuilder->setParameter('status', $filterOrderStatus); | |||
$queryBuilder->setParameter('status', $filterIsOrderStatus); | |||
} | |||
if ($filterNotOrderStatus) { | |||
$queryBuilder->andWhere('orderStatus.alias NOT IN (:status)'); | |||
$queryBuilder->setParameter('status', $filterNotOrderStatus); | |||
} | |||
return $queryBuilder; | |||
@@ -125,14 +131,8 @@ class OrderController extends AdminController | |||
$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()) { | |||
if ($formAddProductToOrder->isSubmitted() && $formAddProductToOrder->isValid()) { | |||
$orderProduct = new $orderProductClass->name; | |||
if ($this->orderUtils->isProductAvailable($formAddProductToOrder->get('product')->getData(), $formAddProductToOrder->get('quantity')->getData())) { | |||
@@ -141,19 +141,15 @@ class OrderController extends AdminController | |||
$this->orderUtils->addOrderProduct($orderShop, $orderProduct); | |||
$response['status'] = 'success'; | |||
$response['message'] = 'Le produit a bien été ajouté à la commande'; | |||
$this->utils->addFlash('success', 'success.order.addProduct'); | |||
} else { | |||
$response['status'] = 'error'; | |||
$response['message'] = 'Le produit n\'est pas disponible dans cette quantité'; | |||
$this->utils->addFlash('error', 'error.order.productUnavailable'); | |||
} | |||
} else { | |||
$response['status'] = 'error'; | |||
$response['message'] = 'Une erreur est survenue'; | |||
$this->utils->addFlash('error', 'error.form.submitted'); | |||
} | |||
$response['data'] = $this->orderUtils->getOrderAsJsonObject($orderShop);; | |||
return new Response(json_encode($response)); | |||
return $this->createOrderAjaxReponse($orderShop); | |||
} | |||
public function orderProductsAction() | |||
@@ -176,21 +172,17 @@ class OrderController extends AdminController | |||
} | |||
} else { | |||
$error = true; | |||
$response['status'] = 'error'; | |||
$response['message'] = 'Le prduit n\'est pas disponible dans cette quantité'; | |||
$this->utils->addFlash('error', 'error.order.productUnavailable'); | |||
} | |||
} | |||
if (!$error) { | |||
$this->em->flush(); | |||
$response['status'] = 'success'; | |||
$response['message'] = 'La commande a bien été modifié'; | |||
$this->utils->addFlash('success', 'success.order.editQuantity'); | |||
} | |||
} else { | |||
$response['status'] = 'error'; | |||
$response['message'] = 'Une erreur est survenue'; | |||
$this->utils->addFlash('error', 'error.form.submitted'); | |||
} | |||
$response['data'] = $this->orderUtils->getOrderAsJsonObject($orderShop);; | |||
return new Response(json_encode($response)); | |||
return $this->createOrderAjaxReponse($orderShop); | |||
} | |||
@@ -208,7 +200,7 @@ class OrderController extends AdminController | |||
$this->utils->addFlash('success', 'success.order.changeInvoiceAddress'); | |||
} else { | |||
$this->utils->addFlash('success', 'error.form.submitted'); | |||
$this->utils->addFlash('error', 'error.form.submitted'); | |||
} | |||
return $this->createOrderAjaxReponse($orderShop); | |||
} | |||
@@ -253,7 +245,7 @@ class OrderController extends AdminController | |||
$this->utils->addFlash('success', 'success.order.addPayment'); | |||
} else { | |||
$this->utils->addFlash('success', 'error.form.submitted'); | |||
$this->utils->addFlash('error', $formOrderPayment->getErrors()); | |||
} | |||
return $this->createOrderAjaxReponse($orderShop); | |||
} |
@@ -4,7 +4,7 @@ var staticRenderFns = []; | |||
Vue.component('order-product', { | |||
mixins: [mixinTemplate], | |||
props: ['template', 'keyItem', 'orderProduct'], | |||
props: ['template', 'keyItem', 'orderProduct', 'editionMode'], | |||
computed: {}, | |||
/* data:function() { | |||
return{ | |||
@@ -26,7 +26,7 @@ Vue.component('order-product', { | |||
}, window.orderProducts[this.key])*!/ | |||
},*/ | |||
mounted: function () { | |||
log(this.keyItem); | |||
log(this.editionMode); | |||
this.setFields() | |||
//this.$el.replace(/__name__/g, this.key); | |||
}, | |||
@@ -50,6 +50,8 @@ Vue.component('order-product', { | |||
}); | |||
}, | |||
updateOrderProducts: function () { | |||
log(this.editionMode); | |||
this.$parent.updateOrderProducts(); | |||
}, | |||
deleteOrderProduct: function () { | |||
@@ -86,6 +88,7 @@ appOrder = new Vue({ | |||
deliveryType: null, | |||
isLoading: true, | |||
addProductId: null, | |||
editionMode: false, | |||
addProductQuantity: null, | |||
sectionsArray: [ | |||
{ | |||
@@ -116,6 +119,13 @@ appOrder = new Vue({ | |||
} | |||
}); | |||
}, | |||
switchEditionMode: function(){ | |||
if(this.editionMode) { | |||
this.editionMode = false; | |||
}else { | |||
this.editionMode = true; | |||
} | |||
}, | |||
addProductToOrder: function () { | |||
this.postForm('#addProductToOrderForm', false); | |||
}, |
@@ -52,6 +52,7 @@ success: | |||
changeStatus: Le statut de la commande a été modifié | |||
changeInvoiceAddress: L'adresse de facuration a bien été modifié | |||
changeDeliveryAddress: L'adresse de livraison a bien été modifié | |||
addProduct: Le produit a bien été ajouté | |||
error: | |||
form: | |||
submitted: Une erreur est survenue à la soumission du formulaire | |||
@@ -63,7 +64,6 @@ error: | |||
productUnavailable: Certains produits ne sont plus disponibles | |||
nextStatusNotAllow: La commande ne peut passer à ce statut | |||
noPayment: Le montant de la commande n'a pas été règlé dans sa totalité | |||
reductionCart: | |||
conditionsError: Cette réduction ne peut pas être appliqué sur cette commande | |||
date: La réduction n'est plus active |
@@ -0,0 +1,2 @@ | |||
<span class="badge badge-secondary">{{ value }}</span> | |||
@@ -11,32 +11,20 @@ | |||
<div class="row"> | |||
{{ orderMacros.mainInfo() }} | |||
<template v-if="order.user"> | |||
{{ orderMacros.addressInfo() }} | |||
</template> | |||
{{ macros.startCard(12, 'OrderShop.resume') }} | |||
{{ macros.startCard(12, 'OrderShop.resume') }} | |||
{% include '@LcShop/backend/order/form/card_orderproducts.html.twig' %} | |||
{# | |||
{{ macros.startCard(0, 'OrderShop.orderReductionCredit', 'success') }} | |||
{{ form_start(form_order_reduction_credit, {'attr': { 'id' : 'orderReductionCredit'}}) }} | |||
{{ form_end(form_order_reduction_credit) }} | |||
{{ macros.endCard }}#} | |||
{# {% include '@LcShop/backend/order/form/modal_reductioncart.html.twig' %}#} | |||
{{ macros.cardOverlay('isLoading') }} | |||
<div class="col-6"> | |||
{# <div class="col-6"> | |||
<h6><strong>Historiques des paiments</strong></h6> | |||
{#TODO: afficher si la commande est règlé et afficher une alerte si le montant des paiments est supérieur au montant total de la commande#}{##}{##} | |||
#}{#TODO: afficher si la commande est règlé et afficher une alerte si le montant des paiments est supérieur au montant total de la commande#}{##}{##}{##}{##}{# | |||
${order.orderPaid} | |||
<ul v-for="(orderPayment, i) in order.orderPayments"> | |||
<li>${orderPayment}</li> | |||
@@ -44,7 +32,7 @@ | |||
<button type="button" class="btn btn-default" data-toggle="modal" data-target="#modal-order-payment"> | |||
{{ "action.addOrderPayment"|trans }} | |||
</button> | |||
</div> | |||
</div>#} | |||
{{ macros.endCard() }} | |||
@@ -73,11 +73,8 @@ | |||
</script> | |||
{{ orderMacros.tableHead() }} | |||
{{ orderMacros.products(form_order_products) }} | |||
{{ orderMacros.tableTotal() }} | |||
{% do form_order_products.orderProducts.setRendered %} |
@@ -29,7 +29,8 @@ | |||
{% macro products(form_order_products) %} | |||
<tbody> | |||
<template v-for="(orderProduct, key) in orderProducts"> | |||
<order-product ref="orderProductBLOP" :order-product="orderProduct" :template="templateTest" | |||
<order-product ref="orderProductBLOP" :order-product="orderProduct" :edition-mode="editionMode" | |||
:template="templateTest" | |||
:key-item="key"></order-product> | |||
</template> | |||
</tbody> | |||
@@ -45,14 +46,21 @@ | |||
<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> | |||
{% verbatim %}{{orderProduct.availableQuantity}}{% endverbatim %} | |||
</td> | |||
<td> | |||
<div :class="editionMode ? '' : 'hidden'"> | |||
{{ 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> | |||
</div> | |||
<div :class="editionMode ? 'hidden' : ''"> | |||
{% verbatim %}{{ orderProduct.quantityOrder }}{% endverbatim %} | |||
</div> | |||
</td> | |||
<td> | |||
{% verbatim %}{{orderProduct.totalWithTaxAndReduction}}{% endverbatim %}€ | |||
@@ -69,13 +77,16 @@ | |||
<div class="row"> | |||
<div class="col-7"> | |||
<button type="button" class="btn btn-success" data-toggle="modal" data-target="#modal-add-product-to-order"> | |||
<button v-show="editionMode" type="button" class="btn btn-success" data-toggle="modal" | |||
data-target="#modal-add-product-to-order"> | |||
<i class="fa fa-plus"></i> {{ "action.order.addOrderProduct"|trans }} | |||
</button> | |||
<button type="button" class="btn btn-warning" data-toggle="modal" data-target="#modal-add-reduction-cart"> | |||
<button v-show="editionMode" type="button" class="btn btn-warning" data-toggle="modal" | |||
data-target="#modal-add-reduction-cart"> | |||
<i class="fa fa-shopping-basket"></i> {{ "action.order.addReductionCart"|trans }} | |||
</button> | |||
<button type="button" class="btn btn-warning" data-toggle="modal" data-target="#modal-add-reduction-credit"> | |||
<button v-show="editionMode" type="button" class="btn btn-warning" data-toggle="modal" | |||
data-target="#modal-add-reduction-credit"> | |||
<i class="fa fa-backspace"></i> {{ "action.order.addReductionCredit"|trans }} | |||
</button> | |||
</div> | |||
@@ -84,14 +95,15 @@ | |||
<table class="table"> | |||
<tbody> | |||
<tr> | |||
<th>Total produits TTC </th> | |||
<th>Total produits TTC</th> | |||
<td>${order.totalOrderProductsWithTax}€</td> | |||
</tr> | |||
<template v-for="(orderReductionCart, key) in order.orderReductionCarts"> | |||
<tr> | |||
<th> | |||
${orderReductionCart.title} | |||
<button type="button" class="btn-sm btn-danger" @click="modalOrderReductionCart(orderReductionCart.id)"> | |||
<button v-show="editionMode" type="button" class="btn-sm btn-danger" | |||
@click="modalOrderReductionCart(orderReductionCart.id)"> | |||
<i class="fa fa-trash"></i> | |||
</button> | |||
</th> | |||
@@ -102,7 +114,8 @@ | |||
<tr> | |||
<th>${orderReductionCredit.title} | |||
<button type="button" class="btn-sm btn-danger" @click="modalOrderReductionCredit(orderReductionCredit.id)"> | |||
<button v-show="editionMode" type="button" class="btn-sm btn-danger" | |||
@click="modalOrderReductionCredit(orderReductionCredit.id)"> | |||
<i class="fa fa-trash"></i> | |||
</button> | |||
</th> | |||
@@ -110,22 +123,22 @@ | |||
</tr> | |||
</template> | |||
<tr> | |||
<th>Total produits après réductions TTC </th> | |||
<th>Total produits après réductions TTC</th> | |||
<td>${order.totalOrderProductsWithTaxAndReductions}€</td> | |||
</tr> | |||
<tr> | |||
<th>Frais de livraisons TTC </th> | |||
<th>Frais de livraisons TTC</th> | |||
<td>${order.deliveryPriceWithTaxAndReduction}€</td> | |||
</tr> | |||
{# <tr> | |||
<th>Total Taxes </th> | |||
<td>${order.totalWithTax}€</td> | |||
</tr> | |||
#} | |||
{# <tr> | |||
<th>Total Taxes </th> | |||
<td>${order.totalWithTax}€</td> | |||
</tr> | |||
#} | |||
<tr> | |||
<th>Total TTC </th> | |||
<th>Total TTC</th> | |||
<td>${order.totalWithTax}€</td> | |||
</tr> | |||
@@ -133,6 +146,19 @@ | |||
</table> | |||
</div> | |||
</div> | |||
<div class="col-12"> | |||
<button v-show="order.user" type="button" class="btn btn-danger" @click="switchEditionMode"> | |||
<template v-if="editionMode"> | |||
<i class="fa fa-eye"></i> {{ "action.order.viewMode"|trans }} | |||
</template> | |||
<template v-else> | |||
<i class="fa fa-pen"></i> {{ "action.order.editionMode"|trans }} | |||
</template> | |||
</button> | |||
<button v-show="editionMode" type="button" class="btn btn-info float-right"> | |||
<i class="fa fa-credit-card"></i> Envoyer le lien de paiement | |||
</button> | |||
</div> | |||
</div> | |||
{% endmacro %} | |||
@@ -169,8 +195,7 @@ | |||
<div class="info-box-content"> | |||
<span class="info-box-text">{{ "field.OrderShop.total"|trans({}, 'lcshop') }}</span> | |||
<strong> ${order.totalWithTaxAndReduction} €</strong> | |||
<strong> ${order.countProducts}</strong> | |||
<strong> ${order.totalWithTax} €</strong> | |||
</div> | |||
</div> | |||
</div> | |||
@@ -181,7 +206,8 @@ | |||
<div class="info-box-content"> | |||
<span class="info-box-text">{{ "field.OrderShop.status"|trans({}, 'lcshop') }}</span> | |||
<strong> ${order.orderStatus}</strong> | |||
<button type="button" class="btn btn-default" data-toggle="modal" data-target="#modal-order-status"> | |||
<button v-show="editionMode" type="button" class="btn btn-default" data-toggle="modal" | |||
data-target="#modal-order-status"> | |||
{{ "action.edit"|trans }} | |||
</button> | |||
</div> | |||
@@ -209,7 +235,7 @@ | |||
<strong>{{ "field.default.invoiceAddress"|trans({}, 'lcshop') }}</strong> | |||
<address v-html="order.invoiceAddress"> | |||
</address> | |||
<button type="button" class="btn btn-default" data-toggle="modal" | |||
<button v-show="editionMode" type="button" class="btn btn-default" data-toggle="modal" | |||
data-target="#modal-order-invoice-address"> | |||
{{ "action.edit"|trans }} | |||
</button> | |||
@@ -237,7 +263,7 @@ | |||
<div v-else> | |||
Aucun lieu de livraison défini. | |||
</div> | |||
<button type="button" class="btn btn-default" data-toggle="modal" | |||
<button v-show="editionMode" type="button" class="btn btn-default" data-toggle="modal" | |||
data-target="#modal-order-delivery-address"> | |||
{{ "action.edit"|trans }} | |||
</button> | |||
@@ -261,7 +287,7 @@ | |||
<div v-html="order.deliveryAvailabilityPointSale"> | |||
</div> | |||
</div> | |||
<button type="button" class="btn btn-default" data-toggle="modal" | |||
<button v-show="editionMode" type="button" class="btn btn-default" data-toggle="modal" | |||
data-target="#modal-order-delivery-availability"> | |||
{{ "action.edit"|trans }} | |||
</button> |
@@ -406,7 +406,6 @@ class OrderUtils | |||
if ($this->getTotalOrderPayments($order) >= $this->priceUtils->getTotalWithTax($order)) { | |||
return true; | |||
} else { | |||
$this->utils->addFlash('error', 'error.order.noPayment'); | |||
return false; | |||
} | |||
} |