{ | { | ||||
protected function createListQueryBuilder($entityClass, $sortDirection, $sortField = null, $dqlFilter = null) | 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']; | $dqlFilter = $dqlFilter['filter']; | ||||
$queryBuilder = parent::createListQueryBuilder($entityClass, $sortDirection, $sortField, $dqlFilter); | $queryBuilder = parent::createListQueryBuilder($entityClass, $sortDirection, $sortField, $dqlFilter); | ||||
$queryBuilder->leftJoin('entity.orderStatus', 'orderStatus'); | $queryBuilder->leftJoin('entity.orderStatus', 'orderStatus'); | ||||
if ($filterOrderStatus) { | |||||
if ($filterIsOrderStatus) { | |||||
$queryBuilder->andWhere('orderStatus.alias IN (:status)'); | $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; | return $queryBuilder; | ||||
$formAddProductToOrder = $this->createForm(AddPoductToOrderType::class); | $formAddProductToOrder = $this->createForm(AddPoductToOrderType::class); | ||||
$formAddProductToOrder->handleRequest($this->request); | $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; | $orderProduct = new $orderProductClass->name; | ||||
if ($this->orderUtils->isProductAvailable($formAddProductToOrder->get('product')->getData(), $formAddProductToOrder->get('quantity')->getData())) { | if ($this->orderUtils->isProductAvailable($formAddProductToOrder->get('product')->getData(), $formAddProductToOrder->get('quantity')->getData())) { | ||||
$this->orderUtils->addOrderProduct($orderShop, $orderProduct); | $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 { | } else { | ||||
$response['status'] = 'error'; | |||||
$response['message'] = 'Le produit n\'est pas disponible dans cette quantité'; | |||||
$this->utils->addFlash('error', 'error.order.productUnavailable'); | |||||
} | } | ||||
} else { | } 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() | public function orderProductsAction() | ||||
} | } | ||||
} else { | } else { | ||||
$error = true; | $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) { | if (!$error) { | ||||
$this->em->flush(); | $this->em->flush(); | ||||
$response['status'] = 'success'; | |||||
$response['message'] = 'La commande a bien été modifié'; | |||||
$this->utils->addFlash('success', 'success.order.editQuantity'); | |||||
} | } | ||||
} else { | } 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); | |||||
} | } | ||||
$this->utils->addFlash('success', 'success.order.changeInvoiceAddress'); | $this->utils->addFlash('success', 'success.order.changeInvoiceAddress'); | ||||
} else { | } else { | ||||
$this->utils->addFlash('success', 'error.form.submitted'); | |||||
$this->utils->addFlash('error', 'error.form.submitted'); | |||||
} | } | ||||
return $this->createOrderAjaxReponse($orderShop); | return $this->createOrderAjaxReponse($orderShop); | ||||
} | } | ||||
$this->utils->addFlash('success', 'success.order.addPayment'); | $this->utils->addFlash('success', 'success.order.addPayment'); | ||||
} else { | } else { | ||||
$this->utils->addFlash('success', 'error.form.submitted'); | |||||
$this->utils->addFlash('error', $formOrderPayment->getErrors()); | |||||
} | } | ||||
return $this->createOrderAjaxReponse($orderShop); | return $this->createOrderAjaxReponse($orderShop); | ||||
} | } |
Vue.component('order-product', { | Vue.component('order-product', { | ||||
mixins: [mixinTemplate], | mixins: [mixinTemplate], | ||||
props: ['template', 'keyItem', 'orderProduct'], | |||||
props: ['template', 'keyItem', 'orderProduct', 'editionMode'], | |||||
computed: {}, | computed: {}, | ||||
/* data:function() { | /* data:function() { | ||||
return{ | return{ | ||||
}, window.orderProducts[this.key])*!/ | }, window.orderProducts[this.key])*!/ | ||||
},*/ | },*/ | ||||
mounted: function () { | mounted: function () { | ||||
log(this.keyItem); | |||||
log(this.editionMode); | |||||
this.setFields() | this.setFields() | ||||
//this.$el.replace(/__name__/g, this.key); | //this.$el.replace(/__name__/g, this.key); | ||||
}, | }, | ||||
}); | }); | ||||
}, | }, | ||||
updateOrderProducts: function () { | updateOrderProducts: function () { | ||||
log(this.editionMode); | |||||
this.$parent.updateOrderProducts(); | this.$parent.updateOrderProducts(); | ||||
}, | }, | ||||
deleteOrderProduct: function () { | deleteOrderProduct: function () { | ||||
deliveryType: null, | deliveryType: null, | ||||
isLoading: true, | isLoading: true, | ||||
addProductId: null, | addProductId: null, | ||||
editionMode: false, | |||||
addProductQuantity: null, | addProductQuantity: null, | ||||
sectionsArray: [ | sectionsArray: [ | ||||
{ | { | ||||
} | } | ||||
}); | }); | ||||
}, | }, | ||||
switchEditionMode: function(){ | |||||
if(this.editionMode) { | |||||
this.editionMode = false; | |||||
}else { | |||||
this.editionMode = true; | |||||
} | |||||
}, | |||||
addProductToOrder: function () { | addProductToOrder: function () { | ||||
this.postForm('#addProductToOrderForm', false); | this.postForm('#addProductToOrderForm', false); | ||||
}, | }, |
changeStatus: Le statut de la commande a été modifié | changeStatus: Le statut de la commande a été modifié | ||||
changeInvoiceAddress: L'adresse de facuration a bien été modifié | changeInvoiceAddress: L'adresse de facuration a bien été modifié | ||||
changeDeliveryAddress: L'adresse de livraison a bien été modifié | changeDeliveryAddress: L'adresse de livraison a bien été modifié | ||||
addProduct: Le produit a bien été ajouté | |||||
error: | error: | ||||
form: | form: | ||||
submitted: Une erreur est survenue à la soumission du formulaire | submitted: Une erreur est survenue à la soumission du formulaire | ||||
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é | ||||
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 |
<span class="badge badge-secondary">{{ value }}</span> | |||||
<div class="row"> | <div class="row"> | ||||
{{ orderMacros.mainInfo() }} | {{ orderMacros.mainInfo() }} | ||||
<template v-if="order.user"> | <template v-if="order.user"> | ||||
{{ orderMacros.addressInfo() }} | {{ orderMacros.addressInfo() }} | ||||
</template> | </template> | ||||
{{ macros.startCard(12, 'OrderShop.resume') }} | |||||
{{ macros.startCard(12, 'OrderShop.resume') }} | |||||
{% include '@LcShop/backend/order/form/card_orderproducts.html.twig' %} | {% 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') }} | {{ macros.cardOverlay('isLoading') }} | ||||
<div class="col-6"> | |||||
{# <div class="col-6"> | |||||
<h6><strong>Historiques des paiments</strong></h6> | <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} | ${order.orderPaid} | ||||
<ul v-for="(orderPayment, i) in order.orderPayments"> | <ul v-for="(orderPayment, i) in order.orderPayments"> | ||||
<li>${orderPayment}</li> | <li>${orderPayment}</li> | ||||
<button type="button" class="btn btn-default" data-toggle="modal" data-target="#modal-order-payment"> | <button type="button" class="btn btn-default" data-toggle="modal" data-target="#modal-order-payment"> | ||||
{{ "action.addOrderPayment"|trans }} | {{ "action.addOrderPayment"|trans }} | ||||
</button> | </button> | ||||
</div> | |||||
</div>#} | |||||
{{ macros.endCard() }} | {{ macros.endCard() }} | ||||
</script> | </script> | ||||
{{ orderMacros.tableHead() }} | {{ orderMacros.tableHead() }} | ||||
{{ orderMacros.products(form_order_products) }} | {{ orderMacros.products(form_order_products) }} | ||||
{{ orderMacros.tableTotal() }} | {{ orderMacros.tableTotal() }} | ||||
{% do form_order_products.orderProducts.setRendered %} | {% do form_order_products.orderProducts.setRendered %} |
{% macro products(form_order_products) %} | {% macro products(form_order_products) %} | ||||
<tbody> | <tbody> | ||||
<template v-for="(orderProduct, key) in orderProducts"> | <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> | :key-item="key"></order-product> | ||||
</template> | </template> | ||||
</tbody> | </tbody> | ||||
<td> | <td> | ||||
{% verbatim %}{{orderProduct.priceWithTax}}{% endverbatim %}€ | {% verbatim %}{{orderProduct.priceWithTax}}{% endverbatim %}€ | ||||
</td> | </td> | ||||
<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> | ||||
<td> | <td> | ||||
{% verbatim %}{{orderProduct.totalWithTaxAndReduction}}{% endverbatim %}€ | {% verbatim %}{{orderProduct.totalWithTaxAndReduction}}{% endverbatim %}€ | ||||
<div class="row"> | <div class="row"> | ||||
<div class="col-7"> | <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 }} | <i class="fa fa-plus"></i> {{ "action.order.addOrderProduct"|trans }} | ||||
</button> | </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 }} | <i class="fa fa-shopping-basket"></i> {{ "action.order.addReductionCart"|trans }} | ||||
</button> | </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 }} | <i class="fa fa-backspace"></i> {{ "action.order.addReductionCredit"|trans }} | ||||
</button> | </button> | ||||
</div> | </div> | ||||
<table class="table"> | <table class="table"> | ||||
<tbody> | <tbody> | ||||
<tr> | <tr> | ||||
<th>Total produits TTC </th> | |||||
<th>Total produits TTC</th> | |||||
<td>${order.totalOrderProductsWithTax}€</td> | <td>${order.totalOrderProductsWithTax}€</td> | ||||
</tr> | </tr> | ||||
<template v-for="(orderReductionCart, key) in order.orderReductionCarts"> | <template v-for="(orderReductionCart, key) in order.orderReductionCarts"> | ||||
<tr> | <tr> | ||||
<th> | <th> | ||||
${orderReductionCart.title} | ${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> | <i class="fa fa-trash"></i> | ||||
</button> | </button> | ||||
</th> | </th> | ||||
<tr> | <tr> | ||||
<th>${orderReductionCredit.title} | <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> | <i class="fa fa-trash"></i> | ||||
</button> | </button> | ||||
</th> | </th> | ||||
</tr> | </tr> | ||||
</template> | </template> | ||||
<tr> | <tr> | ||||
<th>Total produits après réductions TTC </th> | |||||
<th>Total produits après réductions TTC</th> | |||||
<td>${order.totalOrderProductsWithTaxAndReductions}€</td> | <td>${order.totalOrderProductsWithTaxAndReductions}€</td> | ||||
</tr> | </tr> | ||||
<tr> | <tr> | ||||
<th>Frais de livraisons TTC </th> | |||||
<th>Frais de livraisons TTC</th> | |||||
<td>${order.deliveryPriceWithTaxAndReduction}€</td> | <td>${order.deliveryPriceWithTaxAndReduction}€</td> | ||||
</tr> | </tr> | ||||
{# <tr> | |||||
<th>Total Taxes </th> | |||||
<td>${order.totalWithTax}€</td> | |||||
</tr> | |||||
#} | |||||
{# <tr> | |||||
<th>Total Taxes </th> | |||||
<td>${order.totalWithTax}€</td> | |||||
</tr> | |||||
#} | |||||
<tr> | <tr> | ||||
<th>Total TTC </th> | |||||
<th>Total TTC</th> | |||||
<td>${order.totalWithTax}€</td> | <td>${order.totalWithTax}€</td> | ||||
</tr> | </tr> | ||||
</table> | </table> | ||||
</div> | </div> | ||||
</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> | </div> | ||||
{% endmacro %} | {% endmacro %} | ||||
<div class="info-box-content"> | <div class="info-box-content"> | ||||
<span class="info-box-text">{{ "field.OrderShop.total"|trans({}, 'lcshop') }}</span> | <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> | </div> | ||||
</div> | </div> | ||||
<div class="info-box-content"> | <div class="info-box-content"> | ||||
<span class="info-box-text">{{ "field.OrderShop.status"|trans({}, 'lcshop') }}</span> | <span class="info-box-text">{{ "field.OrderShop.status"|trans({}, 'lcshop') }}</span> | ||||
<strong> ${order.orderStatus}</strong> | <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 }} | {{ "action.edit"|trans }} | ||||
</button> | </button> | ||||
</div> | </div> | ||||
<strong>{{ "field.default.invoiceAddress"|trans({}, 'lcshop') }}</strong> | <strong>{{ "field.default.invoiceAddress"|trans({}, 'lcshop') }}</strong> | ||||
<address v-html="order.invoiceAddress"> | <address v-html="order.invoiceAddress"> | ||||
</address> | </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"> | data-target="#modal-order-invoice-address"> | ||||
{{ "action.edit"|trans }} | {{ "action.edit"|trans }} | ||||
</button> | </button> | ||||
<div v-else> | <div v-else> | ||||
Aucun lieu de livraison défini. | Aucun lieu de livraison défini. | ||||
</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-address"> | data-target="#modal-order-delivery-address"> | ||||
{{ "action.edit"|trans }} | {{ "action.edit"|trans }} | ||||
</button> | </button> | ||||
<div v-html="order.deliveryAvailabilityPointSale"> | <div v-html="order.deliveryAvailabilityPointSale"> | ||||
</div> | </div> | ||||
</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"> | data-target="#modal-order-delivery-availability"> | ||||
{{ "action.edit"|trans }} | {{ "action.edit"|trans }} | ||||
</button> | </button> |
if ($this->getTotalOrderPayments($order) >= $this->priceUtils->getTotalWithTax($order)) { | if ($this->getTotalOrderPayments($order) >= $this->priceUtils->getTotalWithTax($order)) { | ||||
return true; | return true; | ||||
} else { | } else { | ||||
$this->utils->addFlash('error', 'error.order.noPayment'); | |||||
return false; | return false; | ||||
} | } | ||||
} | } |