Browse Source

Merge branch 'develop'

master
Guillaume 4 years ago
parent
commit
68b2bed67c
9 changed files with 127 additions and 35 deletions
  1. +7
    -5
      ShopBundle/Controller/Backend/AdminController.php
  2. +29
    -28
      ShopBundle/Controller/Backend/NewsController.php
  3. +3
    -0
      ShopBundle/Repository/ProductFamilyRepository.php
  4. +34
    -0
      ShopBundle/Repository/ProductRepository.php
  5. +1
    -0
      ShopBundle/Resources/translations/lcshop.fr.yaml
  6. +31
    -0
      ShopBundle/Resources/views/backend/default/block/list_products.html.twig
  7. +16
    -1
      ShopBundle/Resources/views/backend/default/block/macros.html.twig
  8. +1
    -1
      ShopBundle/Resources/views/backend/default/menu.html.twig
  9. +5
    -0
      ShopBundle/Twig/BackendTwigExtension.php

+ 7
- 5
ShopBundle/Controller/Backend/AdminController.php View File

@@ -343,6 +343,7 @@ class AdminController extends EasyAdminController
$latsPos = $elm['position'];

}
dump($latsPos);
//die();
//to do récupérer les élements hors ligne et incrémenter position
/*foreach ($repo->findBy(array('status'=> false)) as $offlineEntity) {
@@ -563,7 +564,7 @@ class AdminController extends EasyAdminController
return $this->executeDynamicMethod('render<EntityName>Template', ['edit', $this->entity['templates']['edit'], $parameters]);
}

public function createNewEntity(){
/* public function createNewEntity(){
$idDuplicate = $this->request->query->get('duplicate', null);
if($idDuplicate){
$easyadmin = $this->request->attributes->get('easyadmin');
@@ -578,9 +579,10 @@ class AdminController extends EasyAdminController
return new $entityFullyQualifiedClassName();
}

}
}*/

public function duplicateAction(){
$id = $this->request->query->get('id');
$refererUrl = $this->request->query->get('referer', '');

@@ -588,12 +590,12 @@ class AdminController extends EasyAdminController

$entity= $this->em->getRepository($easyadmin['entity']['class'])->find($id);

$newProductFamily = clone $entity ;
$newEntity = clone $entity ;

$this->em->persist($newProductFamily) ;
$this->em->persist($newEntity) ;
$this->em->flush() ;

return $this->redirectToRoute('easyadmin', ['entity' => $easyadmin['entity']['name'], 'action' => 'edit', 'id' =>$newProductFamily->getId(), 'referer' =>$refererUrl ]) ;
return $this->redirectToRoute('easyadmin', ['entity' => $easyadmin['entity']['name'], 'action' => 'edit', 'id' =>$newEntity->getId(), 'referer' =>$refererUrl ]) ;
}
}


+ 29
- 28
ShopBundle/Controller/Backend/NewsController.php View File

@@ -67,43 +67,42 @@ class NewsController extends AdminController
$users = $this->em->getRepository($this->em->getClassMetadata(UserInterface::class)->getName())->findAllByNewsletter($newsletter) ;
$countUsers = count($users) ;
$toArray = [];
$messagesArray = [];

$paramsTemplate = [
'news' => $news,
'newsletter' => $newsletter,
'user' => $this->security->getUser()
] ;

foreach ($users as $user) {
$toArray[] = [
'Email' => $user->getEmail(),
'Name' => $user->getFirstname().' '.$user->getLastname(),
] ;
if($user->getEmail() && strlen($user->getEmail())) {
$messagesArray[] = [
'To' => [
[
'Email' => $user->getEmail(),
'Name' => $user->getFirstname().' '.$user->getLastname(),
]
],
'From' => [
'Email' => $this->getParameter('app.noreply_email'),
'Name' => $this->getParameter('app.site_name')
],
'Subject' => $currentMerchant->getMerchantConfig('email-subject-prefix').' '.$news->getTitle(),
'TextPart' => $this->renderView('mail/news-text.html.twig', $paramsTemplate),
'HTMLPart' => $this->renderView('mail/news-html.html.twig', $paramsTemplate),
'CustomCampaign' => $news->getTitle(),
'DeduplicateCampaign' => true
] ;
}
}

if($countUsers > 0) {

$mj = new \Mailjet\Client($this->mailjetTransport->getApiKey(), $this->mailjetTransport->getApiSecret(),true,['version' => 'v3.1']);

$paramsTemplate = [
'news' => $news,
'newsletter' => $newsletter,
'user' => $this->security->getUser()
] ;

$body = [
'Messages' => [
[
'From' => [
'Email' => $this->getParameter('app.noreply_email'),
'Name' => $this->getParameter('app.site_name')
],
'To' => $toArray,
'Subject' => $currentMerchant->getMerchantConfig('email-subject-prefix').' '.$news->getTitle(),
'TextPart' => $this->renderView('mail/news-text.html.twig', $paramsTemplate),
'HTMLPart' => $this->renderView('mail/news-html.html.twig', $paramsTemplate),
'CustomCampaign' => $news->getTitle(),
'DeduplicateCampaign' => true
]
]
'Messages' => $messagesArray
];


$response = $mj->post(Resources::$Email, ['body' => $body]);

if($response->success()) {
@@ -114,6 +113,8 @@ class NewsController extends AdminController
$this->em->flush() ;
}
else {
print_r($response->getBody()) ;
die() ;
$this->addFlash('error', "Une erreur est survenue lors de l'envoi de l'actualité.");
}
}

+ 3
- 0
ShopBundle/Repository/ProductFamilyRepository.php View File

@@ -5,6 +5,7 @@ namespace Lc\ShopBundle\Repository;
use Lc\ShopBundle\Context\DefaultRepositoryInterface;
use Lc\ShopBundle\Context\ProductFamilyInterface;
use Lc\ShopBundle\Context\ReductionCatalogInterface;
use Lc\ShopBundle\Model\ProductFamily;

/**
* @method ProductFamilyInterface|null find($id, $lockMode = null, $lockVersion = null)
@@ -104,4 +105,6 @@ class ProductFamilyRepository extends BaseRepository implements DefaultRepositor
}




}

+ 34
- 0
ShopBundle/Repository/ProductRepository.php View File

@@ -4,6 +4,7 @@ namespace Lc\ShopBundle\Repository;

use Lc\ShopBundle\Context\DefaultRepositoryInterface;
use Lc\ShopBundle\Context\ProductInterface;
use Lc\ShopBundle\Model\ProductFamily;

/**
* @method ProductInterface|null find($id, $lockMode = null, $lockVersion = null)
@@ -18,4 +19,37 @@ class ProductRepository extends BaseRepository implements DefaultRepositoryInter
return ProductInterface::class;
}


public function findProductByAvailabilitiesNegative()
{
$qb = $this->createQueryBuilder('e');
$qb->innerJoin('e.productFamily', 'productFamily');
$qb->addSelect('productFamily');
$qb->where('productFamily.merchant = :currentMerchant');
$qb->andWhere('productFamily.status = 1');
$qb->setParameter('currentMerchant', $this->merchantUtils->getMerchantCurrent()->getId());

$qb->andWhere(
$qb->expr()->orX(
$qb->expr()->andX(
$qb->expr()->orX(
'productFamily.behaviorCountStock LIKE :behaviorCountStockByProductFamily',
'productFamily.behaviorCountStock LIKE :behaviorCountStockByMeasure'
),
'productFamily.availableQuantity < 0 '
),
$qb->expr()->andX(
'productFamily.behaviorCountStock LIKE :behaviorCountStockByProduct',
'e.availableQuantity < 0 '
)
)
);
$qb->setParameter('behaviorCountStockByProductFamily', ProductFamily::BEHAVIOR_COUNT_STOCK_BY_PRODUCT_FAMILY);
$qb->setParameter('behaviorCountStockByMeasure', ProductFamily::BEHAVIOR_COUNT_STOCK_BY_MEASURE);
$qb->setParameter('behaviorCountStockByProduct', ProductFamily::BEHAVIOR_COUNT_STOCK_BY_PRODUCT);
$qb->groupBy('productFamily.id');

return $qb->getQuery()->getResult();
}

}

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

@@ -44,6 +44,7 @@ group:
parameters: Paramètres
initReduction: Réduction
export: Note à l'export
stockNegative: Produits stocks négatif
ReductionCatalog:
info: Informations principal
conditions: Conditions d'application

+ 31
- 0
ShopBundle/Resources/views/backend/default/block/list_products.html.twig View File

@@ -0,0 +1,31 @@
{% import '@LcShop/backend/default/block/macros.html.twig' as macros %}
<table class="table table-condensed">
<thead>
<tr>
<th>Produits</th>
<th>Stock</th>
<th></th>
</tr>
</thead>
<tbody>
{% for product in product_availabilities_negative %}
<tr>
<td>
{{ product.productFamily.title }}
{% if product.productFamily.behaviorCountStock == constant("Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_COUNT_STOCK_BY_PRODUCT") %}
- {{ product.title }}
{% endif %}
</td>
<td>
{{ macros.available_quantity_product(product) }}
</td>
<td>
<a class="btn-sm btn-primary" href="{{ path('easyadmin', {'action' : 'edit', 'entity': 'ProductFamily', 'id' : product.productFamily.id }) }}#stock">
<i class="fa fa-pen"></i>
</a>
</td>
</tr>
{% endfor %}
</tbody>
</table>


+ 16
- 1
ShopBundle/Resources/views/backend/default/block/macros.html.twig View File

@@ -261,7 +261,22 @@
</div>
{% endmacro form_widget_append %}

{#{% macro modal(title, form) %}
{% macro available_quantity_product(product) %}

{% if product.productFamily.behaviorCountStock == constant("Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_COUNT_STOCK_BY_PRODUCT_FAMILY") %}
{{ product.productFamily.availableQuantity }}
{% elseif product.productFamily.behaviorCountStock == constant("Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_COUNT_STOCK_BY_MEASURE") %}
{{ product.productFamily.availableQuantity }}
/ {{ product.productFamily.unit.unitReference }}

{% elseif product.productFamily.behaviorCountStock == constant("Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_COUNT_STOCK_BY_PRODUCT") %}
{{ product.availableQuantity }}

{% endif %}

{% endmacro available_quantity_product %}

{# {% macro modal(title, form) %}
{% embed '@LcShop/backend/default/block/embed_modal.twig' %}
{% trans_default_domain 'lcshop' %}
{% block id %}{{ id }}{% endblock %}

+ 1
- 1
ShopBundle/Resources/views/backend/default/menu.html.twig View File

@@ -24,7 +24,7 @@
{% if item.icon is not empty %}<i class="fa fa-fw {{ item.icon }}"></i>{% endif %}
<p>{{ item.label|trans(domain = translation_domain) }}
{% if item.children|default([]) is not empty %}<i class="right fas fa-angle-left"></i>{% endif %}
{% if item.params.count_menu_item is defined %}<span class="badge badge-info right">{{ count_menu_items(item.params.count_menu_item) }}</span>{% endif %}
{% if item.params.count_menu_item is defined and count_menu_items(item.params.count_menu_item) > 0 %}<span class="badge badge-{{ item.params.alert is defined ? 'danger' : 'info' }} right">{{ count_menu_items(item.params.count_menu_item) }}</span>{% endif %}
</p>
</a>
{% endif %}

+ 5
- 0
ShopBundle/Twig/BackendTwigExtension.php View File

@@ -3,8 +3,10 @@
namespace Lc\ShopBundle\Twig;

use Doctrine\ORM\EntityManagerInterface;
use Lc\ShopBundle\Context\ProductInterface;
use Lc\ShopBundle\Context\ReductionCartInterface;
use Lc\ShopBundle\Context\TicketInterface;
use Lc\ShopBundle\Repository\ProductRepository;
use Symfony\Contracts\Translation\TranslatorInterface;
use Twig\Extension\AbstractExtension;
use Twig\TwigFilter;
@@ -83,6 +85,9 @@ class BackendTwigExtension extends AbstractExtension
case 'ticket' :
$ticketRepo = $this->em->getRepository(TicketInterface::class);
return $ticketRepo->countAllOpen();
case 'productAvailabilitiesNegative' :
$productRepo = $this->em->getRepository(ProductInterface::class);
return count($productRepo->findProductByAvailabilitiesNegative());

}
}

Loading…
Cancel
Save