Преглед на файлове

[Backend] Correctifs multiples

feature/module_traiteur_v1
Fab преди 4 години
родител
ревизия
2c20981820
променени са 7 файла, в които са добавени 40 реда и са изтрити 30 реда
  1. +2
    -0
      ShopBundle/Controller/Backend/OrderController.php
  2. +1
    -0
      ShopBundle/Resources/public/js/backend/script/default/utils.js
  3. +2
    -1
      ShopBundle/Resources/translations/lcshop.fr.yaml
  4. +0
    -1
      ShopBundle/Resources/views/backend/default/block/actions.html.twig
  5. +1
    -0
      ShopBundle/Resources/views/backend/default/block/flash_messages.html.twig
  6. +2
    -1
      ShopBundle/Resources/views/backend/default/list.html.twig
  7. +32
    -27
      ShopBundle/Services/ProductFamilyUtils.php

+ 2
- 0
ShopBundle/Controller/Backend/OrderController.php Целия файл

@@ -80,6 +80,8 @@ class OrderController extends AdminController
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) {
//dump($orderProduct);
$orderProduct->setCreatedBy($this->getUser());

+ 1
- 0
ShopBundle/Resources/public/js/backend/script/default/utils.js Целия файл

@@ -158,6 +158,7 @@ function setFlashMessages(flashMessages){

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

/*var n = noty({

+ 2
- 1
ShopBundle/Resources/translations/lcshop.fr.yaml Целия файл

@@ -116,7 +116,7 @@ success:
common:
fieldChange: Le champ a bien été modifié
productFamily:
editStock: Le stock a bien été modifié
editStock: "Stocks renouveler pour : %count% produits"
error:
form:
submitted: Une erreur est survenue à la soumission du formulaire
@@ -155,6 +155,7 @@ error:
notAdded: Le crédit n'a pas été ajouté
productFamily:
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:
default:
placeholder: Choisissez une option

+ 0
- 1
ShopBundle/Resources/views/backend/default/block/actions.html.twig Целия файл

@@ -1,7 +1,6 @@
{% set dropdownAction ={} %}
{% for action in actions %}


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

+ 1
- 0
ShopBundle/Resources/views/backend/default/block/flash_messages.html.twig Целия файл

@@ -22,6 +22,7 @@
{% endif %}
{% if _flash_messages|length > 0 %}
<div id="lc-flash-messages">

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

+ 2
- 1
ShopBundle/Resources/views/backend/default/list.html.twig Целия файл

@@ -296,8 +296,9 @@

<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") %}

<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) }}
</a>
{% else %}

+ 32
- 27
ShopBundle/Services/ProductFamilyUtils.php Целия файл

@@ -1,6 +1,6 @@
<?php

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

use App\Entity\Product;
use Doctrine\ORM\EntityManagerInterface;
@@ -13,62 +13,62 @@ use Lc\ShopBundle\Model\ProductFamily;

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


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

public function getCheapestProduct($productFamily)
{
$priceUtils = $this->priceUtils ;
$priceUtils = $this->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);
}

public function getCheapestProductByRefUnit($productFamily)
{
$priceUtils = $this->priceUtils ;
$priceUtils = $this->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);
}

public function getMostExpensiveProductByRefUnit($productFamily)
{
$priceUtils = $this->priceUtils ;
$priceUtils = $this->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);
}

private function getCheapestOrMostExpensiveProduct($productFamily, $comparisonFunction, $returnSelfIfNotActiveProducts)
{
if($productFamily->getActiveProducts()) {
if ($productFamily->getActiveProducts()) {
$products = $productFamily->getProductsOnline()->getValues();
if (count($products) > 0) {
usort($products, $comparisonFunction);
return $products[0];
}
}else{
} else {
return $productFamily->getOriginProduct();
}
if ($returnSelfIfNotActiveProducts) {
return $productFamily;
}
else {
} else {
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->processCategories($productFamily);
}
@@ -102,16 +102,21 @@ class ProductFamilyUtils
}
}

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)
{
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
$originProducts = $this->em->getRepository(ProductInterface::class)->findBy(array(
'productFamily' => $entity->getId(),
@@ -144,8 +149,8 @@ class ProductFamilyUtils
foreach ($entity->getProducts() as $product) {
$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);

Loading…
Отказ
Запис