@@ -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()); | |||
@@ -408,7 +410,7 @@ class OrderController extends AdminController | |||
$this->em->persist($orderShop); | |||
$this->em->flush(); | |||
$this->mailUtils->send([ | |||
MailUtils::SUBJECT => 'Régler votre commande', | |||
MailUtils::SUBJECT => 'Réglement de votre commande', | |||
MailUtils::TO_EMAIL => $orderShop->getUser()->getEmail(), | |||
MailUtils::TO_NAME => $orderShop->getUser()->getName(), | |||
MailUtils::CONTENT_TEMPLATE => 'mail/order-payment-link', |
@@ -2,13 +2,14 @@ | |||
namespace Lc\ShopBundle\Model; | |||
use App\Entity\OrderStatus; | |||
use Doctrine\Common\Collections\ArrayCollection; | |||
use Doctrine\Common\Collections\Collection; | |||
use Gedmo\Mapping\Annotation as Gedmo; | |||
use Doctrine\ORM\Mapping as ORM; | |||
use Lc\ShopBundle\Context\DocumentInterface; | |||
use Lc\ShopBundle\Context\FilterMerchantInterface; | |||
use Lc\ShopBundle\Services\Order\OrderUtils; | |||
use Lc\ShopBundle\Model\OrderStatus ; | |||
/** | |||
* @ORM\MappedSuperclass() | |||
@@ -157,7 +158,7 @@ abstract class OrderShop extends AbstractEntity implements FilterMerchantInterfa | |||
public function getDateCreated() | |||
{ | |||
$orderStatusHistory = $this->getOrderStatusHistory('new'); | |||
$orderStatusHistory = $this->getOrderStatusHistory(OrderStatus::ALIAS_WAITING_DELIVERY); | |||
if ($orderStatusHistory) { | |||
return $orderStatusHistory->getCreatedAt(); | |||
} |
@@ -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({ |
@@ -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 |
@@ -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 %} |
@@ -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 %} |
@@ -1,6 +1,6 @@ | |||
{#{{ 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" %} | |||
{% else %} | |||
{% set format = field_options.format %} |
@@ -144,7 +144,29 @@ | |||
{% if _entity_config['list']['btn_download_purchase_order_archive'] is defined %} | |||
<a class="float-right btn-sm btn-success" | |||
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> | |||
{% endif %} | |||
@@ -296,8 +318,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 %} |
@@ -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); |
@@ -58,6 +58,7 @@ class FrontendTwigExtension extends AbstractExtension | |||
new TwigFunction('get_form_newsletter', [$this, 'getFormNewsletter']), | |||
new TwigFunction('get_merchants', [$this, 'getMerchants']), | |||
new TwigFunction('get_file_manager_folder', [$this, 'getFileManagerFolder']), | |||
new TwigFunction('lc_format_price', [$this, 'formatPrice']), | |||
); | |||
} | |||
@@ -91,10 +92,11 @@ class FrontendTwigExtension extends AbstractExtension | |||
return $form->createView(); | |||
} | |||
public function formatPrice($price) | |||
public function formatPrice($price, $unbreakableSpace = true) | |||
{ | |||
$price = number_format($price, 2, ',', ' '); | |||
$price = $price . ' €'; | |||
$price .= $unbreakableSpace ? ' ' : ' ' ; | |||
$price .= '€' ; | |||
return $price; | |||
} | |||