Przeglądaj źródła

Complément de commandes

feature/export_comptable
Fab 4 lat temu
rodzic
commit
6cb2491656
9 zmienionych plików z 161 dodań i 109 usunięć
  1. +25
    -7
      ShopBundle/Controller/Backend/OrderController.php
  2. +44
    -0
      ShopBundle/Form/Backend/Order/OrderProductsActionType.php
  3. +4
    -0
      ShopBundle/Resources/public/css/backend/custom.css
  4. +20
    -1
      ShopBundle/Resources/public/js/backend/script/order/vuejs-order.js
  5. +9
    -1
      ShopBundle/Resources/translations/lcshop.fr.yaml
  6. +1
    -0
      ShopBundle/Resources/views/backend/form/custom_bootstrap_4.html.twig
  7. +9
    -88
      ShopBundle/Resources/views/backend/order/form/card_orderproducts.html.twig
  8. +4
    -4
      ShopBundle/Resources/views/backend/order/form/modal_addredeliveryorderproduct.html.twig
  9. +45
    -8
      ShopBundle/Resources/views/backend/order/macros.html.twig

+ 25
- 7
ShopBundle/Controller/Backend/OrderController.php Wyświetl plik

@@ -14,12 +14,14 @@ use Lc\ShopBundle\Context\OrderShopInterface;
use Lc\ShopBundle\Context\OrderUtilsInterface;
use Lc\ShopBundle\Context\UserInterface;
use Lc\ShopBundle\Form\Backend\Order\AddPoductToOrderType;
use Lc\ShopBundle\Form\Backend\Order\AddRedeliveryOrderProductType;
use Lc\ShopBundle\Form\Backend\Order\DeleteOrderPaymentType;
use Lc\ShopBundle\Form\Backend\Order\DeleteOrderReductionCartType;
use Lc\ShopBundle\Form\Backend\Order\DeleteOrderReductionCreditType;
use Lc\ShopBundle\Form\Backend\Order\OrderDeliveryAddressType;
use Lc\ShopBundle\Form\Backend\Order\OrderInvoiceAddressType;
use Lc\ShopBundle\Form\Backend\Order\OrderPaymentType;
use Lc\ShopBundle\Form\Backend\Order\OrderProductsActionType;
use Lc\ShopBundle\Form\Backend\Order\OrderProductsType;
use Lc\ShopBundle\Form\Backend\Order\AddOrderReductionCartType;
use Lc\ShopBundle\Form\Backend\Order\AddOrderReductionCreditType;
@@ -29,6 +31,7 @@ use Lc\ShopBundle\Model\OrderStatus;
use Lc\ShopBundle\Services\CreditUtils;
use Lc\ShopBundle\Services\Utils;
use Mailjet\MailjetSwiftMailer\SwiftMailer\MailjetTransport;
use Proxies\__CG__\App\Entity\OrderProduct;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\HttpFoundation\Response;
@@ -184,15 +187,19 @@ class OrderController extends AdminController
$error = false;
// dump($formOrderProducts->get('orderProducts')->getData());
foreach ($orderShop->getOrderProducts() as $orderProduct) {
if ($this->orderUtils->isProductAvailable($orderProduct->getProduct(), $orderProduct->getQuantityOrder())) {
if ($orderProduct->getQuantityOrder() <= 0) {
$this->em->remove($orderProduct);

if($orderProduct->isRedelivery() === false) {

if ($this->orderUtils->isProductAvailable($orderProduct->getProduct(), $orderProduct->getQuantityOrder())) {
if ($orderProduct->getQuantityOrder() <= 0) {
$this->em->remove($orderProduct);
} else {
$this->em->persist($orderProduct);
}
} else {
$this->em->persist($orderProduct);
$error = true;
$this->utils->addFlash('error', 'error.order.productUnavailable');
}
} else {
$error = true;
$this->utils->addFlash('error', 'error.order.productUnavailable');
}
}
if (!$error) {
@@ -372,6 +379,13 @@ class OrderController extends AdminController
}


public function addRedeliveryOrderProductAction()
{
$orderShop = $this->getOrderShopEntity();
$formAddOrderReductionCredit = $this->createForm(AddRedeliveryOrderProductType::class, $orderShop);
//TODO 0 écrire
}

public function deleteOrderReductionCartAction()
{
$orderShop = $this->getOrderShopEntity();
@@ -454,6 +468,10 @@ class OrderController extends AdminController
$parameters['form_order_status'] = $this->createCustomForm(OrderStatusType::class, 'orderStatus', $parameters)->createView();
$parameters['form_order_invoice_address'] = $this->createCustomForm(OrderInvoiceAddressType::class, 'orderInvoiceAddress', $parameters)->createView();
break;
case OrderStatus::ALIAS_PAID_BY_CREDIT :
case OrderStatus::ALIAS_PAID_ONLINE :
$parameters['form_order_status'] = $this->createCustomForm(OrderStatusType::class, 'orderStatus', $parameters)->createView();
break;
}



+ 44
- 0
ShopBundle/Form/Backend/Order/OrderProductsActionType.php Wyświetl plik

@@ -0,0 +1,44 @@
<?php

namespace Lc\ShopBundle\Form\Backend\Order;

use Doctrine\ORM\EntityManagerInterface;
use Lc\ShopBundle\Context\MerchantUtilsInterface;
use Lc\ShopBundle\Context\OrderShopInterface;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

class OrderProductsActionType extends AbstractType
{
protected $em;
protected $merchantUtils;

public function __construct(EntityManagerInterface $em, MerchantUtilsInterface $merchantUtils)
{
$this->em = $em;
$this->merchantUtils = $merchantUtils;
}

public function buildForm(FormBuilderInterface $builder, array $options)
{

$builder->add('orderProducts', CollectionType::class, array(
'label' => false,
'mapped'=>false,
'entry_type' => CheckboxType::class,
'entry_options' => ['label' => false],
'allow_add' => true,
'allow_delete' => true
)
);
}

public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
]);
}
}

+ 4
- 0
ShopBundle/Resources/public/css/backend/custom.css Wyświetl plik

@@ -94,6 +94,8 @@ table th .select2-container--default .select2-selection--single{padding:0.3rem 0
.lc-offline-field label::after{content:' [hors ligne]'}




/* Général */
.btn.btn-primary.action-save{float: right;}
.button-action .btn{margin-left: 10px;}
@@ -196,6 +198,8 @@ table th .select2-container--default .select2-selection--single{padding:0.3rem 0

.table-order-summary{width: 100%;}


.order-product-item.redelivery{background: rgba(18, 104, 253, 0.38) !important;}
/*.select2-container--bootstrap .select2-selection{max-width: none;}*/
/*.order-product-item{margin: 15px 0; padding: 0;}*/


+ 20
- 1
ShopBundle/Resources/public/js/backend/script/order/vuejs-order.js Wyświetl plik

@@ -60,8 +60,12 @@ Vue.component('order-product', {
this.$parent.updateOrderProducts();
},
modalAddRedeliveryOrderProduct:function () {
log(this.orderProduct.id);
log(this.orderProduct.unit);
$(this.$parent.$refs['addRedeliveryOrderProductFormOrderProduct']).val(this.orderProduct.id);
$(this.$parent.$refs['addRedeliveryOrderProductFormTitle']).val(this.orderProduct.title);
$(this.$parent.$refs['addRedeliveryOrderProductFormUnit']).val(this.orderProduct.unit).trigger('change');
$(this.$parent.$refs['addRedeliveryOrderProductFormQuantityProduct']).val(this.orderProduct.quantityProduct);
$(this.$parent.$refs['addRedeliveryOrderProductFormQuantityOrder']).val(this.orderProduct.quantityOrder);
$('#modal-add-redelivery-order-product').modal('show');
}
/*log($('#order-products-list').data('prototype'));
@@ -145,6 +149,20 @@ appOrder = new Vue({
this.editionMode = true;
}
},
/*
//TODO Sélection groupé à utiliser pr les remboursements
modalAddGroupRedeliveryOrderProduct: function (){
log(this.order.orderProducts);
$('#orderProductsAction').find('.order-product-checkbox:checked').each(function (i,checkbox) {
log($(checkbox).val());
});
$(this.$parent.$refs['addRedeliveryOrderProductFormOrderProduct']).val(this.orderProduct.id);
$(this.$parent.$refs['addRedeliveryOrderProductFormTitle']).val(this.orderProduct.title);
$(this.$parent.$refs['addRedeliveryOrderProductFormUnit']).val(this.orderProduct.unit).trigger('change');
$(this.$parent.$refs['addRedeliveryOrderProductFormQuantityProduct']).val(this.orderProduct.quantityProduct);
$(this.$parent.$refs['addRedeliveryOrderProductFormQuantityOrder']).val(this.orderProduct.quantityOrder);
$('#modal-add-redelivery-order-product').modal('show');
},*/
addProductToOrder: function () {
this.postForm('#addProductToOrderForm', false);
},
@@ -166,6 +184,7 @@ appOrder = new Vue({
$('#modal-order-payment').modal("show")

},

setOrderPaymentFormValues(orderPayment = false) {
if (orderPayment)this.orderPaymentFormId = orderPayment['id'];
else this.orderPaymentFormId = null;

+ 9
- 1
ShopBundle/Resources/translations/lcshop.fr.yaml Wyświetl plik

@@ -44,6 +44,7 @@ group:
addProduct: Ajout de produit à la commande
orderPayment: Ajouter un règlement
orderStatus: Changer de status
addRedeliveryOrderProduct: Ajouter une relivraison
None: Aucune valeur
label.form.empty_value: Choisissez une option
form.label.delete: Supprimer l'image
@@ -55,6 +56,7 @@ success:
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é
addRedeliveryOrderProduct: Un produit a été ajouté en relivraison pour la prochaine commande client
credit:
debited: Le compte prépayé a bien été débité
added: Le compte a bien été crédité
@@ -300,6 +302,10 @@ field:
total: Total
status: Statut
orderStatus: Status de commande
quantityOrder: Quantité commandé
quantityProduct: Quantité (en rapport à l'unité)
unit: Unité
redeliverySupplier: Erreur producteur (A rappeler au prochain bon de commande producteur)
UserMerchant:
credit: Solde du compte prépayé
CreditHistory:
@@ -343,4 +349,6 @@ resetting:

<u>Remarque</u> :<br /> Vous ne pouvez demander un nouveau mot de passe que toutes les 2 heures.


message:
OrderShop:
hasRedelivery: Ce produit a fait l'objet d'une relivraison dans la commande n° %id%

+ 1
- 0
ShopBundle/Resources/views/backend/form/custom_bootstrap_4.html.twig Wyświetl plik

@@ -125,6 +125,7 @@
{% else %}
{% set trad = name|lc_trad(easyadmin['entity']['name'], 'field') %}
{% endif %}

{%- endif -%}
<{{ element|default('label') }}{% if label_attr %}{% with { attr: label_attr } %}{{ block('attributes') }}{% endwith %}{% endif %}>{{ trad }}</{{ element|default('label') }}>
{%- endif -%}

+ 9
- 88
ShopBundle/Resources/views/backend/order/form/card_orderproducts.html.twig Wyświetl plik

@@ -3,90 +3,32 @@
{% trans_default_domain 'lcshop' %}


{#<div class="col-4">
<h6><strong>{{ "field.OrderShop.mainInfo"|trans({}, 'lcshop') }} : </strong></h6>
<p>
<strong>{{ "field.OrderShop.status"|trans }} </strong><br />
<span>${order.orderStatus}</span>
<button type="button" class="btn btn-default" data-toggle="modal" data-target="#modal-order-status">
{{ "action.edit"|trans }}
</button>
</p>
<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 == '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 == '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">

{% if form_order_products is defined %}
{{ form_start(form_order_products, {'attr': {'id' : 'orderProductsForm'}}) }}
<script>
window.templateTest = '{{ orderMacros.productsTemplate(form_order_products)|replace({"\n":' ', "\r":' ', "'" : "\\'"})|raw }}';
window.templateTest = '{{ orderMacros.productsTemplate(form_order_products)|replace({"\n":' ', "\r":' ', "'" : "\\'"})|raw }}';
</script>
{% else %}
<script>
window.templateTest = '{{ orderMacros.productsTemplate(null)|replace({"\n":' ', "\r":' ', "'" : "\\'"})|raw }}';
window.templateTest = '{{ orderMacros.productsTemplate(null)|replace({"\n":' ', "\r":' ', "'" : "\\'"})|raw }}';
</script>
<form id="orderProductsAction">
{% endif %}


{{ orderMacros.tableHead() }}
{{ orderMacros.tableHead() }}

{{ orderMacros.products() }}
{{ orderMacros.products() }}

{{ orderMacros.tableTotal() }}
{{ orderMacros.tableTotal() }}

{% if form_order_products is defined %}
{% do form_order_products.orderProducts.setRendered %}
{% do form_order_products.orderProducts.setRendered %}
{{ form_end(form_order_products) }}
{% else %}
</form>
{% endif %}

<div class="clearfix"></div>
@@ -94,26 +36,5 @@
window.orderObject = {{ order|json_encode|raw }};
</script>
</div>
{# <h6><strong>Réductions</strong></h6>
${order.orderReductionCart}
<button type="button" class="btn btn-default" data-toggle="modal" data-target="#modal-reduction-cart">
{{ "action.addReductionCart"|trans }}
</button>
<br />
${order.orderReductionCredit}
<button type="button" class="btn btn-default" data-toggle="modal" data-target="#modal-reduction-credit">
{{ "action.addReductionCredit"|trans }}
</button>

<br />
<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#}{#
${order.orderPaid}
<ul v-for="(orderPayment, i) in order.orderPayments">
<li>${orderPayment}</li>
</ul>
<button type="button" class="btn btn-default" data-toggle="modal" data-target="#modal-order-payment">
{{ "action.addOrderPayment"|trans }}
</button>#}



+ 4
- 4
ShopBundle/Resources/views/backend/order/form/modal_addredeliveryorderproduct.html.twig Wyświetl plik

@@ -15,10 +15,10 @@
<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) }}
{{ form_row(form_add_redelivery_order_product.title, {'attr' :{'ref' : 'addRedeliveryOrderProductFormTitle'}}) }}
{{ form_row(form_add_redelivery_order_product.unit, {'attr' :{'ref' : 'addRedeliveryOrderProductFormUnit'}}) }}
{{ form_row(form_add_redelivery_order_product.quantityProduct, {'attr' :{'ref' : 'addRedeliveryOrderProductFormQuantityProduct'}}) }}
{{ form_row(form_add_redelivery_order_product.quantityOrder, {'attr' :{'ref' : 'addRedeliveryOrderProductFormQuantityOrder'}}) }}
</div>
</div>
<div class="modal-footer justify-content-between">

+ 45
- 8
ShopBundle/Resources/views/backend/order/macros.html.twig Wyświetl plik

@@ -6,6 +6,9 @@
<table id="order-products-list" class="table table-striped">
<thead>
<tr>
<th :class="editionMode ? '' : 'hidden'">

</th>
<th colspan="2">
<span>Produits / Producteurs</span>
</th>
@@ -24,6 +27,9 @@
<th>
<span>Total</span>
</th>
<th :class="editionMode ? '' : 'hidden'">
Actions
</th>
</tr>
</thead>
{% endmacro %}
@@ -41,8 +47,21 @@


{% macro productsTemplate(form_order_products=null) %}
<tr class="order-product-item">
<td colspan="2">{% verbatim %}{{orderProduct.title}}{% endverbatim %}</td>
<tr :class=" orderProduct.isRedelivery ? 'redelivery order-product-item' : 'order-product-item'">
<td :class="editionMode ? '' : 'hidden'">
<input type="checkbox" :value="orderProduct.id" class="order-product-checkbox" />
</td>
<td colspan="2">
{% verbatim %}{{orderProduct.title}}{% endverbatim %}
<span v-show="orderProduct.hasRedelivery">
- <i class="fa fa-undo" data-toggle="tooltip" :title="orderProduct.redeliveryOrderShop" ></i>
</span>

<span v-show="orderProduct.isRedelivery">
- <i class="fa fa-undo" data-toggle="tooltip" title="Ce produit fait l'objet d'une relivraison" ></i>
</span>

</td>
<td>
{% verbatim %}{{orderProduct.price}}{% endverbatim %}€
</td>
@@ -54,7 +73,7 @@
</td>
<td>
{% if form_order_products is not null %}
<div :class="editionMode ? '' : 'hidden'">
<div :class="editionMode && orderProduct.isRedelivery ==false ? '' : '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'}}) }}#}
@@ -62,7 +81,7 @@
<i class="fa fa-trash"></i>
</button>
</div>
<div :class="editionMode ? 'hidden' : ''">
<div :class="editionMode && orderProduct.isRedelivery ==false ? 'hidden' : ''">
{% verbatim %}{{ orderProduct.quantityOrder }}{% endverbatim %}
</div>
{% else %}
@@ -70,11 +89,24 @@
{% endif %}
</td>
<td>
<button type="button" class="btn-remove-product btn btn-default" @click="modalAddRedeliveryOrderProduct">
NICHE
</button>
{% verbatim %}{{orderProduct.totalWithTaxAndReduction}}{% endverbatim %}€
</td>
<td :class="editionMode ? '' : 'hidden'">
<div class="dropdown" :class="editionMode ? '' : 'hidden'">
<button class="btn btn-info dropdown-toggle" type="button" id="dropdownMenu" data-toggle="dropdown" aria-expanded="false">
Actions
</button>
<div class="dropdown-menu" aria-labelledby="dropdownMenu">
<button v-show="orderProduct.hasRedelivery == false"type="button" class="dropdown-item" @click="modalAddRedeliveryOrderProduct">
Relivraison
</button>

<button type="button" class="dropdown-item" >
Avoirs groupé
</button>
</div>
</div>
</td>
</tr>

{% endmacro %}
@@ -82,7 +114,11 @@
{% macro tableTotal() %}

</table>

<div class="col-12">
<button type="button" class="dropdown-item" >
Avoirs groupé
</button>
</div>
<div class="clearfix"></div>

<div class="row">
@@ -129,6 +165,7 @@
</table>
{{ _self.order_modal_button('#modal-order-payment', 'btn-info', "action.order.addOrderPayment") }}
</div>

<div class="col-8">

<div v-show="order.isOrderPaid" class="alert alert-success alert-dismissible">

Ładowanie…
Anuluj
Zapisz