Browse Source

Pages commandes

feature/export_comptable
Fab 4 years ago
parent
commit
6306133459
12 changed files with 193 additions and 68 deletions
  1. +14
    -3
      ShopBundle/Controller/Backend/OrderController.php
  2. +4
    -0
      ShopBundle/Form/Backend/Order/OrderPaymentType.php
  3. +4
    -3
      ShopBundle/Form/Backend/Order/OrderStatusType.php
  4. +56
    -2
      ShopBundle/Resources/public/js/backend/script/default/init-list.js
  5. +21
    -0
      ShopBundle/Resources/public/js/backend/script/order/vuejs-order.js
  6. +6
    -1
      ShopBundle/Resources/translations/lcshop.fr.yaml
  7. +2
    -0
      ShopBundle/Resources/views/backend/default/list-fields/field_date.html.twig
  8. +3
    -3
      ShopBundle/Resources/views/backend/default/list.html.twig
  9. +3
    -12
      ShopBundle/Resources/views/backend/order/edit-cart.html.twig
  10. +1
    -1
      ShopBundle/Resources/views/backend/order/form/modal_orderstatus.html.twig
  11. +78
    -42
      ShopBundle/Resources/views/backend/order/macros.html.twig
  12. +1
    -1
      ShopBundle/Resources/views/backend/usermerchant/show.html.twig

+ 14
- 3
ShopBundle/Controller/Backend/OrderController.php View File

@@ -252,15 +252,26 @@ class OrderController extends AdminController
public function orderPaymentAction()
{
$orderShop = $this->getOrderShopEntity();
$orderPaymentClass = $this->em->getClassMetadata(OrderPaymentInterface::class);
$orderPayment = new $orderPaymentClass->name;


//TODO si édition despayment existant on vérifie qu'il est lié à nla commabde courante
$orderPaymentPost = $this->request->request->get('order_payment');
if($orderPaymentPost['id']){
$orderPayment = $this->em->getRepository(OrderPaymentInterface::class)->find($orderPaymentPost['id']);
}else{
$orderPaymentClass = $this->em->getClassMetadata(OrderPaymentInterface::class);
$orderPayment = new $orderPaymentClass->name;
}


$formOrderPayment = $this->createForm(OrderPaymentType::class, $orderPayment);

$formOrderPayment->handleRequest($this->request);


if ($formOrderPayment->isSubmitted() && $formOrderPayment->isValid()) {
$orderPayment->setOrderShop($orderShop);

$orderPayment->setOrderShop($orderShop);
if($orderPayment->getMeanPayment() === Utils::MEAN_PAYMENT_CREDIT){
$orderPayment->setEditable(false);
$params['orderPayment'] = $orderPayment;

+ 4
- 0
ShopBundle/Form/Backend/Order/OrderPaymentType.php View File

@@ -11,6 +11,7 @@ use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ButtonType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\DateType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\MoneyType;
use Symfony\Component\Form\Extension\Core\Type\NumberType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
@@ -30,6 +31,9 @@ class OrderPaymentType extends AbstractType
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('id', HiddenType::class, array(
'mapped'=>false,
))
->add('meanPayment', ChoiceType::class, array(
'choices' => array(
'field.default.meanPaymentOptions.' . Utils::MEAN_PAYMENT_CHEQUE => Utils::MEAN_PAYMENT_CHEQUE,

+ 4
- 3
ShopBundle/Form/Backend/Order/OrderStatusType.php View File

@@ -41,8 +41,8 @@ class OrderStatusType extends AbstractType
'mapped'=>false
))

->add('saveOrderStatus', SubmitType::class, array(
'label' => 'field.OrderShop.saveOrderStatus'
->add('change', SubmitType::class, array(
'label' => 'action.change'
));

}
@@ -51,6 +51,7 @@ class OrderStatusType extends AbstractType
{
$resolver->setDefaults([
'data_class' => $this->em->getClassMetadata(OrderShopInterface::class)->getName(),
'translation_domain'=> 'lcshop'
]);
}
}
}

+ 56
- 2
ShopBundle/Resources/public/js/backend/script/default/init-list.js View File

@@ -50,12 +50,67 @@ function initDataTable() {
.search(this.value)
.draw();
var searchVal = this.value;
var body = $( table.table().body() );
var body = $(table.table().body());

body.unhighlight();
body.highlight(searchVal);
}
});
}else if ($(this).data('searchable') == "date") {
/* var title = $(this).text();

$(this).html('<input type="date" class="datatable-field-date date-start" /> <input type="date" class="datatable-field-date date-end" /> ');

$dateStart = $(this).find('.date-start');
$dateEnd = $(this).find('.date-end');
$('input', this).on('keyup change', function () {
table.draw();
});

$.fn.dataTable.ext.search.push(
function( settings, data, dataIndex ) {
if($dateStart.val()!=="" || $dateEnd.val()!=="" ) {


var dateStart = parseInt(Date.parse($dateStart.val()));
var dateEnd = parseInt(Date.parse($dateEnd.val()));

currentDate = parseInt($('td.date').eq(dataIndex).find('time').data('timestamp'));
log(dateStart);
log(currentDate);
log($('td.date').eq(dataIndex));

return true;
if (((dateStart !== null && currentDate >= dateStart) || dateStart == null) && ((dateEnd !== null && dateEnd >= currentDate) || dateEnd == null)) {
return true;
} else {
return false;
}
}else{
return true;
}
}
);*/


/*$('input', this).on('keyup change', function () {
if (this.value === "") {
$('.table.datatable-simple thead tr:eq(0) th:eq(' + i + ')').removeClass('filtered')
} else {
$('.table.datatable-simple thead tr:eq(0) th:eq(' + i + ')').addClass('filtered')
}
if (table.column(i).search() !== this.value) {
table
.column(i)
.search(this.value)
.draw();
var searchVal = this.value;
var body = $( table.table().body() );

body.unhighlight();
body.highlight(searchVal);
}
});*/
} else if ($(this).data('searchable') == 'select' ){
$(this).html('<select data-allow-clear="false" class="list"><option value="all">Tout afficher</option></select>'); //LC_TRAD
} else if ($(this).data('searchable') == 'select-text') {
@@ -104,7 +159,6 @@ function initDataTable() {
$('.table.datatable-simple thead tr:eq(0) th:eq('+i+')').removeClass('filtered')
column.search('').draw();
}else {
log($(this).val());
$('.table.datatable-simple thead tr:eq(0) th:eq('+i+')').addClass('filtered')
column.search(val, false).draw();
}

+ 21
- 0
ShopBundle/Resources/public/js/backend/script/order/vuejs-order.js View File

@@ -113,6 +113,13 @@ appOrder = new Vue({
//log($(this.$el).find('#orderProductsForm').replace(/__name__/g, 0));
},
methods: {
modalExist:function(modalId){
if($(modalId).length>0){
return true;
}else{
return false;
}
},
preventFormSubmit: function (){
$(document).keypress(function(e) {
if (e.which == 13) {
@@ -139,6 +146,20 @@ appOrder = new Vue({
}else{
this.postForm('#orderPaymentForm', '#modal-order-payment');
}
$('#modal-order-payment').find('#order_payment_id').val('');

},
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']);
$('#modal-order-payment').modal("show")

},
updateOrderProducts: function () {
this.postForm('#orderProductsForm', false);

+ 6
- 1
ShopBundle/Resources/translations/lcshop.fr.yaml View File

@@ -297,6 +297,7 @@ field:
addOrderToProduct: Ajouter le produit
total: Total
status: Statut
orderStatus: Status de commande
UserMerchant:
credit: Solde du compte prépayé
CreditHistory:
@@ -313,6 +314,7 @@ action:
edit: Éditer
search: Rechercher
delete: Supprimer
change: Modifier
save: Sauvegarder les modifications
cancel: Annuler
continue: Continuer
@@ -327,9 +329,12 @@ action:
addOrderProduct: Ajouter un produit
addReductionCart: Ajouter une réduction
addReductionCredit: Ajouter un avoir
editionMode: Activer mode édition
viewMode: Désactiver mode édition
addOrderPayment: Ajouter une transaction

credit:
add: Ajouter du crédit

resetting:
check_email: |
Un e-mail vous a été envoyé. Il contient un lien sur lequel il vous faudra cliquer pour réinitialiser votre mot de passe. Si vous ne recevez pas d'email, vérifiez votre dossier spam ou essayez à nouveau.

+ 2
- 0
ShopBundle/Resources/views/backend/default/list-fields/field_date.html.twig View File

@@ -0,0 +1,2 @@
{#{{ value|date('U')}}#}
<time data-timestamp="{{ value|date('U') }}" title="{{ value|date('r') }}">{{ value|date(field_options.format) }}</time>

+ 3
- 3
ShopBundle/Resources/views/backend/default/list.html.twig View File

@@ -79,7 +79,7 @@
<div class="card card-outline card-primary">
<div class="card-header">
<h2 class="card-title text-lg ">
{{ "list.title"|trans({'%label%' : _entity_config['label']|lower }) }}
{#{{ "list.title"|trans({'%label%' : _entity_config['label']|lower }) }}#}
<span data-toggle="tooltip" title="{{ "list.nbResults"|trans }}" class="badge badge-primary">{{ paginator.nbResults }} <i class="fa fa-bars"></i> </span>
{% if paginator.nbResultsOnline is defined %}<span data-toggle="tooltip" title="{{ "list.nbResultsOnline"|trans }}" class="badge badge-success">{{ paginator.nbResultsOnline }} <i class="fa fa-check"></i> </span>{% endif %}
{% if paginator.nbResultsOffline is defined %}<span data-toggle="tooltip" title="{{ "list.nbResultsOffline"|trans }}" class="badge badge-warning">{{ paginator.nbResultsOffline }} <i class="fa fa-pen"></i></span>{% endif %}
@@ -132,8 +132,8 @@
{% set searchable = 'input'%}
{% elseif metadata.type == 'association' %}
{% set searchable= "select" %}
{#{% elseif metadata.type == 'text' %}
{% set searchable= "select-text" %}#}
{% elseif metadata.type == 'date' %}
{% set searchable= "date" %}#}
{% elseif metadata.type=="toggle" %}
{% set searchable= "select" %}
{% endif %}

+ 3
- 12
ShopBundle/Resources/views/backend/order/edit-cart.html.twig View File

@@ -1,5 +1,5 @@
{% extends '@LcShop/backend/default/show.html.twig' %}
{% trans_default_domain 'lcshop' %}
{% import '@LcShop/backend/default/block/macros.html.twig' as macros %}
{% import '@LcShop/backend/order/macros.html.twig' as orderMacros %}

@@ -22,19 +22,10 @@
{% include '@LcShop/backend/order/form/card_orderproducts.html.twig' %}

{{ macros.cardOverlay('isLoading') }}
<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#}
${order.orderPaid}
<ul v-for="(orderPayment, i) in order.orderPayments">
<li>${orderPayment}</li>
</ul>

</div>
{{ macros.endCard() }}
<button type="button" class="btn btn-default" data-toggle="modal" data-target="#modal-order-payment">
{{ "action.addOrderPayment"|trans }}
</button>



{% if form_order_invoice_address is defined %}
{% include '@LcShop/backend/order/form/modal_invoiceaddress.html.twig' %}

+ 1
- 1
ShopBundle/Resources/views/backend/order/form/modal_orderstatus.html.twig View File

@@ -20,7 +20,7 @@
</div>
<div class="modal-footer justify-content-between">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
{{ form_row(form_order_status.saveOrderStatus, {"attr": {'class' : 'btn btn-primary'}}) }}
{{ form_row(form_order_status.change, {"attr": {'class' : 'btn btn-primary'}}) }}
</div>
</div>
<!-- /.modal-content -->

+ 78
- 42
ShopBundle/Resources/views/backend/order/macros.html.twig View File

@@ -1,4 +1,7 @@
{% trans_default_domain 'lcshop' %}



{% macro tableHead() %}
<table id="order-products-list" class="table table-striped">
<thead>
@@ -51,17 +54,17 @@
</td>
<td>
{% if form_order_products is not null %}
<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>
<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>
{% else %}
{% verbatim %}{{ orderProduct.quantityOrder }}{% endverbatim %}
{% endif %}
@@ -80,20 +83,48 @@
<div class="clearfix"></div>

<div class="row">
<div class="col-7">
<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 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 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 class="col-6">
<div class="row">
<div class="col-12">
{{ _self.order_modal_button('#modal-add-product-to-order', 'btn-success', "action.order.addOrderProduct", 'plus') }}
{{ _self.order_modal_button('#modal-add-reduction-cart', 'btn-warning', "action.order.addReductionCart", 'shopping-basket') }}
{{ _self.order_modal_button('#modal-add-reduction-credit', 'btn-warning', "action.order.addReductionCredit", 'backspace') }}

</div>
<div class="col-12" style="margin-top: 25px;">
<h6><strong>Historiques des transactions</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#}
<table class="table table-striped">
<tbody>
<thead>
<tr>
<th>Mode de règlement</th>
<th>Date</th>
<th>Montant</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<template v-for="(orderPayment, i) in order.orderPayments">
<tr>
<td>${orderPayment.meanPaymentText}</td>
<td>${orderPayment.paidAtText}</td>
<td>${orderPayment.amount}</td>
<td>
<button v-show="orderPayment.editable" class="btn-sm btn-info" type="button" @click="editOrderPayment(orderPayment.id)">
<i class="fa fa-pen"></i>
</button>
</td>
</tr>
</template>
</tbody>
</table>
{{ _self.order_modal_button('#modal-order-payment', 'btn-info', "action.order.addOrderPayment") }}
<span class="float-right">Total : ${order.orderPaid}</span>
</div>
</div>
</div>
<div class="col"></div>
<div class="col-5">
<div class="table-responsive">
<table class="table">
@@ -106,7 +137,8 @@
<tr>
<th>
${orderReductionCart.title}
<button v-show="editionMode" type="button" class="btn-sm btn-danger"
<button v-show="editionMode && modalExist('#modal-delete-reduction-cart')" type="button"
class="btn-sm btn-danger"
@click="modalOrderReductionCart(orderReductionCart.id)">
<i class="fa fa-trash"></i>
</button>
@@ -118,7 +150,8 @@
<tr>
<th>${orderReductionCredit.title}

<button v-show="editionMode" type="button" class="btn-sm btn-danger"
<button v-show="editionMode && modalExist('#modal-delete-reduction-credit')"
type="button" class="btn-sm btn-danger"
@click="modalOrderReductionCredit(orderReductionCredit.id)">
<i class="fa fa-trash"></i>
</button>
@@ -210,10 +243,7 @@
<div class="info-box-content">
<span class="info-box-text">{{ "field.OrderShop.status"|trans({}, 'lcshop') }}</span>
<strong> ${order.orderStatus}</strong>
<button v-show="editionMode" type="button" class="btn btn-default" data-toggle="modal"
data-target="#modal-order-status">
{{ "action.edit"|trans }}
</button>
{{ _self.order_modal_button('#modal-order-status') }}
</div>
</div>
</div>
@@ -239,10 +269,7 @@
<strong>{{ "field.default.invoiceAddress"|trans({}, 'lcshop') }}</strong>
<address v-html="order.invoiceAddress">
</address>
<button v-show="editionMode" type="button" class="btn btn-default" data-toggle="modal"
data-target="#modal-order-invoice-address">
{{ "action.edit"|trans }}
</button>
{{ _self.order_modal_button('#modal-order-invoice-address') }}
</div>
</div>
</div>
@@ -267,10 +294,7 @@
<div v-else>
Aucun lieu de livraison défini.
</div>
<button v-show="editionMode" type="button" class="btn btn-default" data-toggle="modal"
data-target="#modal-order-delivery-address">
{{ "action.edit"|trans }}
</button>
{{ _self.order_modal_button('#modal-order-delivery-address') }}
</div>
</div>
</div>
@@ -291,11 +315,23 @@
<div v-html="order.deliveryAvailabilityPointSale">
</div>
</div>
<button v-show="editionMode" type="button" class="btn btn-default" data-toggle="modal"
data-target="#modal-order-delivery-availability">
{{ "action.edit"|trans }}
</button>
{{ _self.order_modal_button('#modal-order-delivery-availability') }}
</div>
</div>
</div>
{% endmacro addressInfo %}



{% macro order_modal_button(modalId, class="btn-default", trad="action.edit", icon=false) %}

<button v-show="editionMode && modalExist('{{ modalId }}')" type="button" class="btn {{ class }}"
data-toggle="modal"
data-target="{{ modalId }}">
{% if icon %}
<i class="fa fa-{{ icon }}"></i>
{% endif %}
{{ trad|trans }}
</button>

{% endmacro order_modal_button %}

+ 1
- 1
ShopBundle/Resources/views/backend/usermerchant/show.html.twig View File

@@ -28,7 +28,7 @@
<th data-index="3" class="" data-searchable="input">MeanPayment</th>
<th data-index="4" class="" data-searchable="date">PaidAt</th>
<th data-index="5" class="" data-searchable="input">Reference</th>
<th data-index="6" class="" data-searchable="">Comment</th>
<th data-index="6" class="" data-searchable="text">Comment</th>
</tr>
</thead>
<tbody>

Loading…
Cancel
Save