Browse Source

Merge branch 'develop'

master
Fab 4 years ago
parent
commit
09e695baef
10 changed files with 73 additions and 38 deletions
  1. +3
    -1
      ShopBundle/Controller/Backend/OrderController.php
  2. +3
    -2
      ShopBundle/Model/OrderShop.php
  3. +1
    -0
      ShopBundle/Resources/public/js/backend/script/default/utils.js
  4. +2
    -1
      ShopBundle/Resources/translations/lcshop.fr.yaml
  5. +0
    -1
      ShopBundle/Resources/views/backend/default/block/actions.html.twig
  6. +1
    -0
      ShopBundle/Resources/views/backend/default/block/flash_messages.html.twig
  7. +2
    -2
      ShopBundle/Resources/views/backend/default/list-fields/field_datetime.html.twig
  8. +25
    -2
      ShopBundle/Resources/views/backend/default/list.html.twig
  9. +32
    -27
      ShopBundle/Services/ProductFamilyUtils.php
  10. +4
    -2
      ShopBundle/Twig/FrontendTwigExtension.php

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

public function updateEntity($entity) public function updateEntity($entity)
{ {


//SI PAS DE problème après le 23/05/2021 à supprimer
die('Une erreur est survenue, merci de contacter FAB : Erreur ligne 80 LC =>OrderController ');
foreach ($entity->getOrderProducts() as $orderProduct) { foreach ($entity->getOrderProducts() as $orderProduct) {
//dump($orderProduct); //dump($orderProduct);
$orderProduct->setCreatedBy($this->getUser()); $orderProduct->setCreatedBy($this->getUser());
$this->em->persist($orderShop); $this->em->persist($orderShop);
$this->em->flush(); $this->em->flush();
$this->mailUtils->send([ $this->mailUtils->send([
MailUtils::SUBJECT => 'Régler votre commande',
MailUtils::SUBJECT => 'Réglement de votre commande',
MailUtils::TO_EMAIL => $orderShop->getUser()->getEmail(), MailUtils::TO_EMAIL => $orderShop->getUser()->getEmail(),
MailUtils::TO_NAME => $orderShop->getUser()->getName(), MailUtils::TO_NAME => $orderShop->getUser()->getName(),
MailUtils::CONTENT_TEMPLATE => 'mail/order-payment-link', MailUtils::CONTENT_TEMPLATE => 'mail/order-payment-link',

+ 3
- 2
ShopBundle/Model/OrderShop.php View File



namespace Lc\ShopBundle\Model; namespace Lc\ShopBundle\Model;


use App\Entity\OrderStatus;
use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Collection;
use Gedmo\Mapping\Annotation as Gedmo; use Gedmo\Mapping\Annotation as Gedmo;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Lc\ShopBundle\Context\DocumentInterface; use Lc\ShopBundle\Context\DocumentInterface;
use Lc\ShopBundle\Context\FilterMerchantInterface; use Lc\ShopBundle\Context\FilterMerchantInterface;
use Lc\ShopBundle\Services\Order\OrderUtils;
use Lc\ShopBundle\Model\OrderStatus ;


/** /**
* @ORM\MappedSuperclass() * @ORM\MappedSuperclass()


public function getDateCreated() public function getDateCreated()
{ {
$orderStatusHistory = $this->getOrderStatusHistory('new');
$orderStatusHistory = $this->getOrderStatusHistory(OrderStatus::ALIAS_WAITING_DELIVERY);
if ($orderStatusHistory) { if ($orderStatusHistory) {
return $orderStatusHistory->getCreatedAt(); return $orderStatusHistory->getCreatedAt();
} }

+ 1
- 0
ShopBundle/Resources/public/js/backend/script/default/utils.js View File



function generateNotice(type, text) { function generateNotice(type, text) {
toastr.options.timeOut = 30000; toastr.options.timeOut = 30000;
toastr.options.preventDuplicates = true;
toastr[type](text); toastr[type](text);


/*var n = noty({ /*var n = noty({

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

common: common:
fieldChange: Le champ a bien été modifié fieldChange: Le champ a bien été modifié
productFamily: productFamily:
editStock: Le stock a bien été modifié
editStock: "Stocks renouveler pour : %count% produits"
error: error:
form: form:
submitted: Une erreur est survenue à la soumission du formulaire submitted: Une erreur est survenue à la soumission du formulaire
notAdded: Le crédit n'a pas été ajouté notAdded: Le crédit n'a pas été ajouté
productFamily: productFamily:
editStock: Le stock n'a pas été modifié, une erreur est survenue editStock: Le stock n'a pas été modifié, une erreur est survenue
editStockNoQuantityDefault: "Le stock n'a pas été modifié pour le produit #%id% (Aucune quantité par défaut)"
field: field:
default: default:
placeholder: Choisissez une option placeholder: Choisissez une option

+ 0
- 1
ShopBundle/Resources/views/backend/default/block/actions.html.twig View File

{% set dropdownAction ={} %} {% set dropdownAction ={} %}
{% for action in actions %} {% for action in actions %}



{% if action.group is defined and action.group==true %} {% if action.group is defined and action.group==true %}
{% set dropdownAction = dropdownAction|merge({(loop.index0): action}) %} {% set dropdownAction = dropdownAction|merge({(loop.index0): action}) %}
{% else %} {% else %}

+ 1
- 0
ShopBundle/Resources/views/backend/default/block/flash_messages.html.twig View File

{% endif %} {% endif %}
{% if _flash_messages|length > 0 %} {% if _flash_messages|length > 0 %}
<div id="lc-flash-messages"> <div id="lc-flash-messages">

{% for label, messages in _flash_messages %} {% for label, messages in _flash_messages %}
{% if label != 'alert' %} {% if label != 'alert' %}
{% for message in messages %} {% for message in messages %}

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

{#{{ value|date('U')}}#}
{# {{ value|date('U')}} #}


{% if field_options.format == "d/m/Y h:i A e" %}
{% if field_options.format == "d/m/Y h:i A e" or field_options.format == null %}
{% set format = "d/m/Y H:i" %} {% set format = "d/m/Y H:i" %}
{% else %} {% else %}
{% set format = field_options.format %} {% set format = field_options.format %}

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

{% if _entity_config['list']['btn_download_purchase_order_archive'] is defined %} {% if _entity_config['list']['btn_download_purchase_order_archive'] is defined %}
<a class="float-right btn-sm btn-success" <a class="float-right btn-sm btn-success"
href="{{ path('easyadmin', { entity: 'Supplier', action: 'exportOrderPurchasesAsArchive' }) }}"> href="{{ path('easyadmin', { entity: 'Supplier', action: 'exportOrderPurchasesAsArchive' }) }}">
<i class="fa fa-download"></i> Télécharger tous les bons de commande
<i class="fa fa-download"></i> Récapitulatif des commandes
</a>
{% endif %}


{% if _entity_config['list']['btn_history_purchase_order'] is defined %}
<a class="float-right btn-sm btn-info"
href="{{ path('easyadmin', { entity: 'PurchaseOrder', action: 'list' }) }}">
<i class="fa fa-history"></i> Historiques des bons de commandes
</a>
{% endif %}

{% if _entity_config['list']['btn_week_purchase_order'] is defined %}
<a class="float-right btn-sm btn-info"
href="{{ path('easyadmin', { entity: 'SupplierOrderPurchase', action: 'list' }) }}">
<i class="fa fa-tractor"></i> Bons de commandes de la semaine
</a>
{% endif %}

{% if _entity_config['list']['btn_add_purchase_order'] is defined %}
<a class="float-right btn-sm btn-primary"
href="{{ path('easyadmin', { entity: 'PurchaseOrder', action: 'new' }) }}">
<i class="fa fa-plus"></i> Créer un bon de commande
</a> </a>
{% endif %} {% endif %}




<td class="{{ isSortingField ? 'sorted' }} {{ metadata.dataType|lower }} {{ metadata.css_class }}" {{ easyadmin_config('design.rtl') ? 'dir="rtl"' }}> <td class="{{ isSortingField ? 'sorted' }} {{ metadata.dataType|lower }} {{ metadata.css_class }}" {{ easyadmin_config('design.rtl') ? 'dir="rtl"' }}>
{% if (field == 'title' or field== 'id') and (metadata.dataType=="string" or metadata.dataType=="integer") %} {% if (field == 'title' or field== 'id') and (metadata.dataType=="string" or metadata.dataType=="integer") %}

<a class="link-as-text" <a class="link-as-text"
href="{{ path('easyadmin', {'action':'edit', 'entity':_entity_config.name, 'id': item.id}) }}">
href="{{ path('easyadmin', _request_parameters|merge({ action: 'edit', id: item.id })) }}">
{{ easyadmin_render_field_for_list_view(_entity_config.name, item, metadata) }} {{ easyadmin_render_field_for_list_view(_entity_config.name, item, metadata) }}
</a> </a>
{% else %} {% else %}

+ 32
- 27
ShopBundle/Services/ProductFamilyUtils.php View File

<?php <?php


namespace Lc\ShopBundle\Services ;
namespace Lc\ShopBundle\Services;


use App\Entity\Product; use App\Entity\Product;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;


class ProductFamilyUtils class ProductFamilyUtils
{ {
protected $priceUtils ;
protected $em ;
protected $priceUtils;
protected $em;



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


public function getCheapestProduct($productFamily) public function getCheapestProduct($productFamily)
{ {
$priceUtils = $this->priceUtils ;
$priceUtils = $this->priceUtils;
return $this->getCheapestOrMostExpensiveProduct($productFamily, function ($a, $b) use ($priceUtils) { return $this->getCheapestOrMostExpensiveProduct($productFamily, function ($a, $b) use ($priceUtils) {
return $priceUtils->getPriceWithTaxAndReduction($a) > $priceUtils->getPriceWithTaxAndReduction($b) ;
return $priceUtils->getPriceWithTaxAndReduction($a) > $priceUtils->getPriceWithTaxAndReduction($b);
}, true); }, true);
} }


public function getCheapestProductByRefUnit($productFamily) public function getCheapestProductByRefUnit($productFamily)
{ {
$priceUtils = $this->priceUtils ;
$priceUtils = $this->priceUtils;
return $this->getCheapestOrMostExpensiveProduct($productFamily, function ($a, $b) use ($priceUtils) { return $this->getCheapestOrMostExpensiveProduct($productFamily, function ($a, $b) use ($priceUtils) {
return $priceUtils->getPriceByRefUnitWithTaxAndReduction($a) > $priceUtils->getPriceByRefUnitWithTaxAndReduction($b) ;
return $priceUtils->getPriceByRefUnitWithTaxAndReduction($a) > $priceUtils->getPriceByRefUnitWithTaxAndReduction($b);
}, false); }, false);
} }


public function getMostExpensiveProductByRefUnit($productFamily) public function getMostExpensiveProductByRefUnit($productFamily)
{ {
$priceUtils = $this->priceUtils ;
$priceUtils = $this->priceUtils;
return $this->getCheapestOrMostExpensiveProduct($productFamily, function ($a, $b) use ($priceUtils) { return $this->getCheapestOrMostExpensiveProduct($productFamily, function ($a, $b) use ($priceUtils) {
return $priceUtils->getPriceByRefUnitWithTaxAndReduction($a) < $priceUtils->getPriceByRefUnitWithTaxAndReduction($b) ;
return $priceUtils->getPriceByRefUnitWithTaxAndReduction($a) < $priceUtils->getPriceByRefUnitWithTaxAndReduction($b);
}, false); }, false);
} }


private function getCheapestOrMostExpensiveProduct($productFamily, $comparisonFunction, $returnSelfIfNotActiveProducts) private function getCheapestOrMostExpensiveProduct($productFamily, $comparisonFunction, $returnSelfIfNotActiveProducts)
{ {
if($productFamily->getActiveProducts()) {
if ($productFamily->getActiveProducts()) {
$products = $productFamily->getProductsOnline()->getValues(); $products = $productFamily->getProductsOnline()->getValues();
if (count($products) > 0) { if (count($products) > 0) {
usort($products, $comparisonFunction); usort($products, $comparisonFunction);
return $products[0]; return $products[0];
} }
}else{
} else {
return $productFamily->getOriginProduct(); return $productFamily->getOriginProduct();
} }
if ($returnSelfIfNotActiveProducts) { if ($returnSelfIfNotActiveProducts) {
return $productFamily; return $productFamily;
}
else {
} else {
return false; return false;
} }
} }




public function processBeforePersistProductFamily($productFamily, $editForm=false, $clone =false){
if($editForm){
public function processBeforePersistProductFamily($productFamily, $editForm = false, $clone = false)
{
if ($editForm) {
$this->processReductionCatalog($productFamily, $editForm); $this->processReductionCatalog($productFamily, $editForm);
$this->processCategories($productFamily); $this->processCategories($productFamily);
} }
} }
} }


protected function processCloneProduct($productFamily)
{
foreach ($productFamily->getProducts() as $i => $product) {
$newProduct = clone $product;
$newProduct->setProductFamily($productFamily);
$this->em->persist($newProduct);
$productFamily->addProduct($newProduct);
}
}

protected function processProducts($entity, $clone = false) protected function processProducts($entity, $clone = false)
{ {
if($clone) {
foreach ($entity->getProducts() as $i => $product) {
$newProduct = clone $product;
$newProduct->setProductFamily($entity);
$this->em->persist($newProduct);
$entity->addProduct($newProduct);
}
}else {
if ($clone) {
$this->processCloneProduct($entity);
} else {
//Récupère le product origin //Récupère le product origin
$originProducts = $this->em->getRepository(ProductInterface::class)->findBy(array( $originProducts = $this->em->getRepository(ProductInterface::class)->findBy(array(
'productFamily' => $entity->getId(), 'productFamily' => $entity->getId(),
foreach ($entity->getProducts() as $product) { foreach ($entity->getProducts() as $product) {
$product->setProductFamily($entity); $product->setProductFamily($entity);


if($entity->getProductsQuantityAsTitle() && $product->getStatus()>=1){
$product->setTitle(str_replace('.', ',',$product->getQuantityInherited()).$product->getUnitInherited()->getWording());
if ($entity->getProductsQuantityAsTitle() && $product->getStatus() >= 1) {
$product->setTitle(str_replace('.', ',', $product->getQuantityInherited()) . $product->getUnitInherited()->getWording());
} }


$this->em->persist($product); $this->em->persist($product);

+ 4
- 2
ShopBundle/Twig/FrontendTwigExtension.php View File

new TwigFunction('get_form_newsletter', [$this, 'getFormNewsletter']), new TwigFunction('get_form_newsletter', [$this, 'getFormNewsletter']),
new TwigFunction('get_merchants', [$this, 'getMerchants']), new TwigFunction('get_merchants', [$this, 'getMerchants']),
new TwigFunction('get_file_manager_folder', [$this, 'getFileManagerFolder']), new TwigFunction('get_file_manager_folder', [$this, 'getFileManagerFolder']),
new TwigFunction('lc_format_price', [$this, 'formatPrice']),
); );
} }


return $form->createView(); return $form->createView();
} }


public function formatPrice($price)
public function formatPrice($price, $unbreakableSpace = true)
{ {
$price = number_format($price, 2, ',', ' '); $price = number_format($price, 2, ',', ' ');
$price = $price . '&nbsp;€';
$price .= $unbreakableSpace ? '&nbsp;' : ' ' ;
$price .= '€' ;
return $price; return $price;
} }



Loading…
Cancel
Save