Browse Source

Merge branch 'develop' of https://gitea.laclic.fr/Laclic/LcShopBundle into develop

feature/export_comptable
Guillaume 4 years ago
parent
commit
871f764c03
14 changed files with 268 additions and 86 deletions
  1. +68
    -34
      ShopBundle/Controller/Backend/OrderController.php
  2. +7
    -4
      ShopBundle/Form/Backend/Order/OrderPaymentType.php
  3. +6
    -2
      ShopBundle/Form/Backend/UserMerchant/CreditHistoryType.php
  4. +5
    -0
      ShopBundle/Model/OrderPayoffTrait.php
  5. +11
    -9
      ShopBundle/Resources/public/js/backend/script/order/vuejs-order.js
  6. +5
    -0
      ShopBundle/Resources/translations/lcshop.fr.yaml
  7. +38
    -15
      ShopBundle/Resources/views/backend/order/edit-cart.html.twig
  8. +15
    -6
      ShopBundle/Resources/views/backend/order/form/card_orderproducts.html.twig
  9. +1
    -1
      ShopBundle/Resources/views/backend/order/form/modal_orderpayment.html.twig
  10. +6
    -2
      ShopBundle/Resources/views/backend/order/macros.html.twig
  11. +12
    -1
      ShopBundle/Resources/views/backend/usermerchant/modal_addcredithistory.html.twig
  12. +78
    -9
      ShopBundle/Resources/views/backend/usermerchant/show.html.twig
  13. +12
    -2
      ShopBundle/Services/CreditUtils.php
  14. +4
    -1
      ShopBundle/Services/Order/OrderUtils.php

+ 68
- 34
ShopBundle/Controller/Backend/OrderController.php View File

@@ -2,12 +2,16 @@

namespace Lc\ShopBundle\Controller\Backend;

use Doctrine\ORM\EntityManagerInterface;
use EasyCorp\Bundle\EasyAdminBundle\Event\EasyAdminEvents;
use FOS\UserBundle\Model\UserManagerInterface;
use Lc\ShopBundle\Context\MerchantUtilsInterface;
use Lc\ShopBundle\Context\OrderPaymentInterface;
use Lc\ShopBundle\Context\OrderProductInterface;
use Lc\ShopBundle\Context\OrderReductionCartInterface;
use Lc\ShopBundle\Context\OrderReductionCreditInterface;
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\DeleteOrderReductionCartType;
@@ -19,13 +23,27 @@ use Lc\ShopBundle\Form\Backend\Order\OrderProductsType;
use Lc\ShopBundle\Form\Backend\Order\AddOrderReductionCartType;
use Lc\ShopBundle\Form\Backend\Order\AddOrderReductionCreditType;
use Lc\ShopBundle\Form\Backend\Order\OrderStatusType;
use Lc\ShopBundle\Model\CreditHistory;
use Lc\ShopBundle\Model\OrderStatus;
use Lc\ShopBundle\Services\CreditUtils;
use Lc\ShopBundle\Services\Utils;
use Mailjet\MailjetSwiftMailer\SwiftMailer\MailjetTransport;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Security\Core\Security;
use Symfony\Contracts\Translation\TranslatorInterface;


class OrderController extends AdminController
{
protected $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);
$this->creditUtils = $creditUtils;
}

protected function createListQueryBuilder($entityClass, $sortDirection, $sortField = null, $dqlFilter = null)
{
$filterIsOrderStatus = false;
@@ -212,8 +230,10 @@ class OrderController extends AdminController
$formOrderStatus->handleRequest($this->request);

if ($formOrderStatus->isSubmitted() && $formOrderStatus->isValid()) {
$oldStatus = $orderShop->getOrderStatus();

if ($orderShop = $this->orderUtils->changeOrderStatus($formOrderStatus->get('orderStatus')->getData(), $orderShop)) {
$orderShop = $this->orderUtils->changeOrderStatus($formOrderStatus->get('orderStatus')->getData(), $orderShop);
if($oldStatus !== $orderShop->getOrderStatus()){
$this->utils->addFlash('success', 'success.order.changeStatus');
}
} else {
@@ -240,10 +260,30 @@ class OrderController extends AdminController

if ($formOrderPayment->isSubmitted() && $formOrderPayment->isValid()) {
$orderPayment->setOrderShop($orderShop);
$this->em->persist($orderPayment);
$this->em->flush();

$this->utils->addFlash('success', 'success.order.addPayment');
if($orderPayment->getMeanPayment('credit')){
$orderPayment->setEditable(false);
$params['amount'] = $orderPayment->getAmount();
$params['orderPayment'] = $orderPayment->getId();
$creditHistory = $this->creditUtils->initCreditHistory(CreditHistory::TYPE_DEBIT, $orderShop->getUser(), $params);
if($this->creditUtils->saveCreditHistory($creditHistory)) {
$this->em->persist($orderPayment);
$this->em->flush();
$this->utils->addFlash('success', 'success.credit.debited');
$this->utils->addFlash('success', 'success.order.addPayment');
}else{
$this->utils->addFlash('success', 'error.credit.debited');
}

}else{
$orderPayment->setEditable(true);
$this->em->persist($orderPayment);
$this->em->flush();
$this->utils->addFlash('success', 'success.order.addPayment');
}



} else {
$this->utils->addFlash('error', $formOrderPayment->getErrors());
}
@@ -349,43 +389,37 @@ class OrderController extends AdminController
}


public function renderOrderCartTemplate($actionName, $templatePath, array $parameters = [])
{

if ($actionName == 'show') {
if (!isset($parameters['form_order_delivery_address'])) {
$parameters['form_order_delivery_address'] = $this->createCustomForm(OrderDeliveryAddressType::class, 'orderDeliveryAddress', $parameters)->createView();
}
$parameters['form_add_order_reduction_credit'] = $this->createCustomForm(AddOrderReductionCreditType::class, 'addOrderReductionCredit', $parameters)->createView();
$parameters['form_add_order_reduction_cart'] = $this->createCustomForm(AddOrderReductionCartType::class, 'addOrderReductionCart', $parameters)->createView();
$parameters['form_delete_order_reduction_cart'] = $this->createCustomForm(DeleteOrderReductionCartType::class, 'deleteOrderReductionCart', $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_order_products'] = $this->createCustomForm(OrderProductsType::class, 'orderProducts', $parameters)->createView();
$parameters['form_order_invoice_address'] = $this->createCustomForm(OrderInvoiceAddressType::class, 'orderInvoiceAddress', $parameters)->createView();
$parameters['form_order_status'] = $this->createCustomForm(OrderStatusType::class, 'orderStatus', $parameters)->createView();
}
return parent::renderTemplate($actionName, $templatePath, $parameters);
}

public function renderOrderShopTemplate($actionName, $templatePath, array $parameters = [])
{

if ($actionName == 'show') {
if (!isset($parameters['form_order_delivery_address'])) {
$parameters['form_order_delivery_address'] = $this->createCustomForm(OrderDeliveryAddressType::class, 'orderDeliveryAddress', $parameters)->createView();

$orderShop = $this->getOrderShopEntity();

switch ($orderShop->getOrderStatus()->getAlias()){
case OrderStatus::ALIAS_CART :
if (!isset($parameters['form_order_delivery_address'])) {
$parameters['form_order_delivery_address'] = $this->createCustomForm(OrderDeliveryAddressType::class, 'orderDeliveryAddress', $parameters)->createView();
}
$parameters['form_add_order_reduction_credit'] = $this->createCustomForm(AddOrderReductionCreditType::class, 'addOrderReductionCredit', $parameters)->createView();
$parameters['form_add_order_reduction_cart'] = $this->createCustomForm(AddOrderReductionCartType::class, 'addOrderReductionCart', $parameters)->createView();
$parameters['form_delete_order_reduction_cart'] = $this->createCustomForm(DeleteOrderReductionCartType::class, 'deleteOrderReductionCart', $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_order_products'] = $this->createCustomForm(OrderProductsType::class, 'orderProducts', $parameters)->createView();
break;
case OrderStatus::ALIAS_WAITING_PAYMENT_CREDIT :
case OrderStatus::ALIAS_WAITING_PAYMENT_ONLINE :
$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_invoice_address'] = $this->createCustomForm(OrderInvoiceAddressType::class, 'orderInvoiceAddress', $parameters)->createView();
break;
}
$parameters['form_add_order_reduction_credit'] = $this->createCustomForm(AddOrderReductionCreditType::class, 'addOrderReductionCredit', $parameters)->createView();
$parameters['form_add_order_reduction_cart'] = $this->createCustomForm(AddOrderReductionCartType::class, 'addOrderReductionCart', $parameters)->createView();
$parameters['form_delete_order_reduction_cart'] = $this->createCustomForm(DeleteOrderReductionCartType::class, 'deleteOrderReductionCart', $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_order_products'] = $this->createCustomForm(OrderProductsType::class, 'orderProducts', $parameters)->createView();
$parameters['form_order_invoice_address'] = $this->createCustomForm(OrderInvoiceAddressType::class, 'orderInvoiceAddress', $parameters)->createView();
$parameters['form_order_status'] = $this->createCustomForm(OrderStatusType::class, 'orderStatus', $parameters)->createView();
$parameters['form_order_payment'] = $this->createCustomForm(OrderPaymentType::class, 'orderPayment', $parameters, false)->createView();


}
dump($templatePath);
return parent::renderTemplate($actionName, $templatePath, $parameters);
}

@@ -459,7 +493,7 @@ class OrderController extends AdminController

];

return $this->executeDynamicMethod('render<EntityName>Template', ['show', $this->entity['templates']['show'], $parameters]);
return $this->executeDynamicMethod('renderOrderShopTemplate', ['show', $this->entity['templates']['show'], $parameters]);
}

/**

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

@@ -6,6 +6,7 @@ namespace Lc\ShopBundle\Form\Backend\Order;
use Doctrine\ORM\EntityManagerInterface;
use Lc\ShopBundle\Context\OrderPaymentInterface;
use Lc\ShopBundle\Model\OrderPayment;
use Lc\ShopBundle\Services\Utils;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ButtonType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
@@ -28,11 +29,13 @@ class OrderPaymentType extends AbstractType
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('type', ChoiceType::class, array(
->add('meanPayment', ChoiceType::class, array(
'choices' => array(
'field.orderPayment.' . OrderPayment::TYPE_CHEQUE => OrderPayment::TYPE_CHEQUE,
'field.orderPayment.' . OrderPayment::TYPE_CREDIT => OrderPayment::TYPE_CREDIT,
'field.orderPayment.' . OrderPayment::TYPE_CREDIT_CARD => OrderPayment::TYPE_CREDIT_CARD
'field.default.meanPaymentOptions.' . Utils::MEAN_PAYMENT_CHEQUE => Utils::MEAN_PAYMENT_CHEQUE ,
'field.default.meanPaymentOptions.' . Utils::MEAN_PAYMENT_CREDIT_CARD => Utils::MEAN_PAYMENT_CREDIT_CARD,
'field.default.meanPaymentOptions.' . Utils::MEAN_PAYMENT_CREDIT => Utils::MEAN_PAYMENT_CREDIT,
'field.default.meanPaymentOptions.' . Utils::MEAN_PAYMENT_TRANSFER => Utils::MEAN_PAYMENT_TRANSFER,
'field.default.meanPaymentOptions.' . Utils::MEAN_PAYMENT_CASH => Utils::MEAN_PAYMENT_CASH
),
'required' => true
))

+ 6
- 2
ShopBundle/Form/Backend/UserMerchant/CreditHistoryType.php View File

@@ -65,9 +65,13 @@ class CreditHistoryType extends AbstractType
'widget' => 'single_text',
'required' => true
))
->add('reference', TextType::class)
->add('reference', TextType::class, array(
'required'=>false
))

->add('comment', TextareaType::class)
->add('comment', TextareaType::class, array(
'required'=>false
))
->add('add', SubmitType::class, array(
'label' => 'action.add'
));

+ 5
- 0
ShopBundle/Model/OrderPayoffTrait.php View File

@@ -25,6 +25,11 @@ trait OrderPayoffTrait
*/
protected $editable;

public function __toString()
{
return $this->amount. ' le '.$this->getPaidAt()->format('d-m-y').' par '.$this->getMeanPayment();
}

public function getOrderShop(): ?OrderShop
{
return $this->orderShop;

+ 11
- 9
ShopBundle/Resources/public/js/backend/script/order/vuejs-order.js View File

@@ -39,13 +39,14 @@ Vue.component('order-product', {
var app = this;
fields = ['fieldQuantity', 'fieldProduct'];
fields.forEach(function (field) {
var name = $(app.$refs[field]).prop('name');
var id = $(app.$refs[field]).prop('id');
name = name.replace(/__name__/g, app.keyItem);
id = id.replace(/__name__/g, app.keyItem);
$(app.$refs[field]).prop('name', name);
$(app.$refs[field]).prop('id', id);

if($(app.$refs[field]).length) {
var name = $(app.$refs[field]).prop('name');
var id = $(app.$refs[field]).prop('id');
name = name.replace(/__name__/g, app.keyItem);
id = id.replace(/__name__/g, app.keyItem);
$(app.$refs[field]).prop('name', name);
$(app.$refs[field]).prop('id', id);
}
//log(app.$refs[field]);
});
},
@@ -130,6 +131,7 @@ appOrder = new Vue({
this.postForm('#addProductToOrderForm', false);
},
addOrderPayment: function () {

this.postForm('#orderPaymentForm', '#modal-order-payment');
},
updateOrderProducts: function () {
@@ -167,9 +169,9 @@ appOrder = new Vue({

postForm: function (formId, modalId) {
var app = this;
this.isLoading = true;
if (modalId) $(modalId).modal('hide');
if(checkFormValidity(formId)) {
this.isLoading = true;
if (modalId) $(modalId).modal('hide');
$.ajax({
url: $(formId).prop('action'),
method: "POST",

+ 5
- 0
ShopBundle/Resources/translations/lcshop.fr.yaml View File

@@ -53,6 +53,8 @@ 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é
credt:
debited: Le compte prépayé a bien été débité
error:
form:
submitted: Une erreur est survenue à la soumission du formulaire
@@ -79,6 +81,9 @@ error:
reductionCredit:
userNotAllow: Cet avoir n'est pas disponible pour cet utilisateur
alreayUse: Cet avoir a déjà été utilisé
credit:
notActive: Cet utilisateur n'a pas activé son compte prépayé
debited: Une erreur est survenue, le crédit n'a pas été débité
field:
default:
placeholder: Choisissez une option

+ 38
- 15
ShopBundle/Resources/views/backend/order/edit-cart.html.twig View File

@@ -22,29 +22,52 @@
{% include '@LcShop/backend/order/form/card_orderproducts.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>
</ul>
<button type="button" class="btn btn-default" data-toggle="modal" data-target="#modal-order-payment">
{{ "action.addOrderPayment"|trans }}
</button>
</div>#}

</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' %}
{% endif %}
{% if form_order_delivery_address is defined %}
{% include '@LcShop/backend/order/form/modal_deliveryaddress.html.twig' %}
{% endif %}
{% if form_order_delivery_availability is defined %}
{% include '@LcShop/backend/order/form/modal_deliveryavailability.html.twig' %}
{% endif %}
{% if form_order_status is defined %}
{% include '@LcShop/backend/order/form/modal_orderstatus.html.twig' %}
{% endif %}
{% if form_add_order_reduction_credit is defined %}
{% include '@LcShop/backend/order/form/modal_addreductioncredit.html.twig' %}
{% endif %}
{% if form_add_order_reduction_cart is defined %}
{% include '@LcShop/backend/order/form/modal_addreductioncart.html.twig' %}
{% endif %}
{% if form_delete_order_reduction_cart is defined %}
{% include '@LcShop/backend/order/form/modal_deletereductioncart.html.twig' %}
{% endif %}
{% if form_delete_order_reduction_credit is defined %}
{% include '@LcShop/backend/order/form/modal_deletereductioncredit.html.twig' %}
{% endif %}
{% if form_add_product_to_order is defined %}
{% include '@LcShop/backend/order/form/modal_addproducttoorder.html.twig' %}
{% endif %}
{% if form_order_payment is defined %}
{% include '@LcShop/backend/order/form/modal_orderpayment.html.twig' %}
{% endif %}

{% include '@LcShop/backend/order/form/modal_invoiceaddress.html.twig' %}
{% include '@LcShop/backend/order/form/modal_deliveryaddress.html.twig' %}
{% include '@LcShop/backend/order/form/modal_deliveryavailability.html.twig' %}
{% include '@LcShop/backend/order/form/modal_orderstatus.html.twig' %}
{% include '@LcShop/backend/order/form/modal_addreductioncredit.html.twig' %}
{% include '@LcShop/backend/order/form/modal_addreductioncart.html.twig' %}
{% include '@LcShop/backend/order/form/modal_deletereductioncart.html.twig' %}
{% include '@LcShop/backend/order/form/modal_deletereductioncredit.html.twig' %}
{% include '@LcShop/backend/order/form/modal_addproducttoorder.html.twig' %}

{# {{ macros.startCard(3, 'OrderShop.addProduct', 'success') }}
{% include '@LcShop/backend/order/form/addproducttoorder.html.twig' %}

+ 15
- 6
ShopBundle/Resources/views/backend/order/form/card_orderproducts.html.twig View File

@@ -66,19 +66,28 @@
</div>#}
<div class="col-12">

{{ form_start(form_order_products, {'attr': {'id' : 'orderProductsForm'}}) }}
{% 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 }}';
</script>
{% else %}
<script>
window.templateTest = '{{ orderMacros.productsTemplate(null)|replace({"\n":' ', "\r":' ', "'" : "\\'"})|raw }}';
</script>
{% endif %}


<script>
window.templateTest = '{{ orderMacros.productsTemplate(form_order_products)|replace({"\n":' ', "\r":' ', "'" : "\\'"})|raw }}';
</script>
{{ orderMacros.tableHead() }}

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

{{ orderMacros.tableTotal() }}

{% if form_order_products is defined %}
{% do form_order_products.orderProducts.setRendered %}
{{ form_end(form_order_products) }}
{{ form_end(form_order_products) }}
{% endif %}

<div class="clearfix"></div>
<script>

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

@@ -11,7 +11,7 @@
</button>
</div>
<div class="modal-body">
{{ form_row(form_order_payment.type) }}
{{ form_row(form_order_payment.meanPayment) }}
{{ form_row(form_order_payment.paidAt) }}
{{ form_row(form_order_payment.amount) }}
{{ form_row(form_order_payment.reference) }}

+ 6
- 2
ShopBundle/Resources/views/backend/order/macros.html.twig View File

@@ -26,7 +26,7 @@
{% endmacro %}


{% macro products(form_order_products) %}
{% macro products() %}
<tbody>
<template v-for="(orderProduct, key) in orderProducts">
<order-product ref="orderProductBLOP" :order-product="orderProduct" :edition-mode="editionMode"
@@ -37,7 +37,7 @@
{% endmacro %}


{% macro productsTemplate(form_order_products) %}
{% macro productsTemplate(form_order_products=null) %}
<tr class="order-product-item">
<td colspan="2">{% verbatim %}{{orderProduct.title}}{% endverbatim %}</td>
<td>
@@ -50,6 +50,7 @@
{% verbatim %}{{orderProduct.availableQuantity}}{% endverbatim %}
</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'}}) }}
@@ -61,6 +62,9 @@
<div :class="editionMode ? 'hidden' : ''">
{% verbatim %}{{ orderProduct.quantityOrder }}{% endverbatim %}
</div>
{% else %}
{% verbatim %}{{ orderProduct.quantityOrder }}{% endverbatim %}
{% endif %}
</td>
<td>
{% verbatim %}{{orderProduct.totalWithTaxAndReduction}}{% endverbatim %}€

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

@@ -17,8 +17,19 @@
{{ form_row(add_credit_history_form.type) }}
</div>
<div class="col">
{{ form_row(add_credit_history_form.amount) }}

{{ form_label(add_credit_history_form.amount) }}
<div class="form-widget">
<div class="input-group">
{{ form_widget(add_credit_history_form.amount) }}
<div class="input-group-append">
<span class="input-group-text">€ </span>
</div>
</div>

</div>
</div>

<div class="col">
{{ form_row(add_credit_history_form.meanPayment) }}
</div>

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

@@ -1,18 +1,87 @@
{% extends '@LcShop/backend/default/show.html.twig' %}
{% extends '@LcShop/backend/default/show.html.twig' %}

{% block main %}
{% for creditHistory in entity.creditHistories %}
<li>{{ creditHistory.amount }}</li>

{% else %}
<li><i>Aucun mouvement pour ce compte prépayé</i></li>
{% endfor %}
<div class="row">
<div class="col-12">
<div class="card card-outline card-primary">
<div class="card-header">
<h2 class="card-title text-lg ">
{{ entity.user.summary }} : <strong>{{ entity.credit }}€</strong>
</h2>
<button type="button" class="btn btn-primary float-right" data-toggle="modal"
data-target="#modal-add-credit-history">
{{ "action.addCreditHistory"|trans }}
</button>
</div>

<button type="button" class="btn btn-default" data-toggle="modal" data-target="#modal-add-credit-history">
{{ "action.addCreditHistory"|trans }}
</button>
<div class="card-body p-0">

<table class="table datatable-simple table-bordered table-hover table-striped">

<thead>
<tr>
<th data-index="0" class="" data-searchable="text">Id</th>
<th data-index="1" class="" data-searchable="select">Type</th>
<th data-index="2" class="" data-searchable="select">Amount</th>
<th data-index="3" class="" data-searchable="text">MeanPayment</th>
<th data-index="4" class="" data-searchable="tex">PaidAt</th>
<th data-index="5" class="" data-searchable="text">Reference</th>
<th data-index="6" class="" data-searchable="">Comment</th>
</tr>
</thead>
<tbody>
{% for creditHistory in entity.creditHistories %}
<tr draggable="true" rel="{{ creditHistory.id }}" data-id="{{ creditHistory.id }}">

<td class="sorted">{{ creditHistory.id }}</td>
<td class="">{{ creditHistory.type }}</td>
<td class="">{{ creditHistory.amount }} €</td>
<td class="">{{ creditHistory.meanPayment }}</td>
<td class="">{{ creditHistory.paidAt|date('d-m-y') }}</td>
<td class="">{{ creditHistory.reference }}</td>
<td class="">{{ creditHistory.comment }}</td>
</tr>

{% else %}
<tr>
<td class="no-results" colspan="7">
{{ 'search.no_results'|trans(_trans_parameters, 'EasyAdminBundle') }}
</td>
</tr>
{% endfor %}

</tbody>
<tfoot></tfoot>
</table>
</div>
</div>
</div>
</div>
{% include 'LcShopBundle:backend/usermerchant:modal_addcredithistory.html.twig' %}
{% endblock main %}

{% block head_stylesheets %}
{{ parent() }}
<link rel="stylesheet" href="{{ asset('bundles/lcshop/css/backend/adminlte/plugins/datatables/fixedHeader.dataTables.min.css') }}">
<link rel="stylesheet"
href="{{ asset('bundles/lcshop/css/backend/adminlte/plugins/datatables/dataTables.bootstrap4.min.css') }}">
{% endblock %}

{% block plugin_javascript %}
{{ parent() }}

<script src="{{ asset('bundles/lcshop/js/backend/plugin/datatables/jquery.dataTables.min.js') }}"></script>
<script src="{{ asset('bundles/lcshop/js/backend/plugin/datatables/dataTables.bootstrap4.min.js') }}"></script>
<script src="{{ asset('bundles/lcshop/js/backend/plugin/datatables/dataTables.responsive.min.js') }}"></script>
<script src="{{ asset('bundles/lcshop/js/backend/plugin/datatables/jquery.highlight.js') }}"></script>
<script src="{{ asset('bundles/lcshop/js/backend/plugin/datatables/responsive.bootstrap4.min.js') }}"></script>
<script src="{{ asset('bundles/lcshop/js/backend/plugin/datatables/dataTables.fixedHeader.min.js') }}"></script>
{% endblock %}

{% block script_javascript %}
{{ parent() }}
<script src="{{ asset('bundles/lcshop/js/backend/script/default/init-list.js') }}"></script>
{% endblock %}



+ 12
- 2
ShopBundle/Services/CreditUtils.php View File

@@ -87,8 +87,18 @@ class CreditUtils
return $this->updateCreditActive($user, $merchant, false) ;
}

public function checkCreditActive($userMerchant)
{

public function isCreditActive(UserInterface $user, MerchantInterface $merchant = null){
$userMerchant = $this->getUserMerchant($user, $merchant);
if($userMerchant && $userMerchant->isCreditActive()) {
return true;
}else{
return false;
}
}

public function checkCreditActive(UserMerchantInterface $userMerchant){

if(!$userMerchant || ($userMerchant && !$userMerchant->isCreditActive())) {
return false ;
}

+ 4
- 1
ShopBundle/Services/Order/OrderUtils.php View File

@@ -23,6 +23,7 @@ use Lc\ShopBundle\Model\Document;
use Lc\ShopBundle\Form\Backend\Order\OrderReductionCreditType;
use Lc\ShopBundle\Model\Product;
use Lc\ShopBundle\Model\ProductFamily;
use Lc\ShopBundle\Services\CreditUtils;
use Lc\ShopBundle\Services\DocumentUtils;
use Lc\ShopBundle\Services\Price\OrderShopPriceUtils;
use Lc\ShopBundle\Services\UserUtils;
@@ -45,10 +46,11 @@ class OrderUtils
protected $productFamilyUtils;
protected $documentUtils;
protected $utils;
protected $creditUtils;

public function __construct(EntityManagerInterface $em, Security $security, UserUtils $userUtils,
MerchantUtilsInterface $merchantUtils, PriceUtilsInterface $priceUtils, ProductFamilyUtilsInterface $productFamilyUtils,
DocumentUtils $documentUtils, Utils $utils)
DocumentUtils $documentUtils, Utils $utils, CreditUtils $creditUtils)
{
$this->em = $em;
$this->security = $security;
@@ -61,6 +63,7 @@ class OrderUtils
$this->productFamilyUtils = $productFamilyUtils;
$this->documentUtils = $documentUtils;
$this->utils = $utils;
$this->creditUtils = $creditUtils;
}



Loading…
Cancel
Save