$latsPos = $elm['position']; | $latsPos = $elm['position']; | ||||
} | } | ||||
dump($latsPos); | |||||
//die(); | //die(); | ||||
//to do récupérer les élements hors ligne et incrémenter position | //to do récupérer les élements hors ligne et incrémenter position | ||||
/*foreach ($repo->findBy(array('status'=> false)) as $offlineEntity) { | /*foreach ($repo->findBy(array('status'=> false)) as $offlineEntity) { | ||||
return $this->executeDynamicMethod('render<EntityName>Template', ['edit', $this->entity['templates']['edit'], $parameters]); | 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); | $idDuplicate = $this->request->query->get('duplicate', null); | ||||
if($idDuplicate){ | if($idDuplicate){ | ||||
$easyadmin = $this->request->attributes->get('easyadmin'); | $easyadmin = $this->request->attributes->get('easyadmin'); | ||||
return new $entityFullyQualifiedClassName(); | return new $entityFullyQualifiedClassName(); | ||||
} | } | ||||
} | |||||
}*/ | |||||
public function duplicateAction(){ | public function duplicateAction(){ | ||||
$id = $this->request->query->get('id'); | $id = $this->request->query->get('id'); | ||||
$refererUrl = $this->request->query->get('referer', ''); | $refererUrl = $this->request->query->get('referer', ''); | ||||
$entity= $this->em->getRepository($easyadmin['entity']['class'])->find($id); | $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() ; | $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 ]) ; | |||||
} | } | ||||
} | } | ||||
$users = $this->em->getRepository($this->em->getClassMetadata(UserInterface::class)->getName())->findAllByNewsletter($newsletter) ; | $users = $this->em->getRepository($this->em->getClassMetadata(UserInterface::class)->getName())->findAllByNewsletter($newsletter) ; | ||||
$countUsers = count($users) ; | $countUsers = count($users) ; | ||||
$toArray = []; | |||||
$messagesArray = []; | |||||
$paramsTemplate = [ | |||||
'news' => $news, | |||||
'newsletter' => $newsletter, | |||||
'user' => $this->security->getUser() | |||||
] ; | |||||
foreach ($users as $user) { | 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) { | if($countUsers > 0) { | ||||
$mj = new \Mailjet\Client($this->mailjetTransport->getApiKey(), $this->mailjetTransport->getApiSecret(),true,['version' => 'v3.1']); | $mj = new \Mailjet\Client($this->mailjetTransport->getApiKey(), $this->mailjetTransport->getApiSecret(),true,['version' => 'v3.1']); | ||||
$paramsTemplate = [ | |||||
'news' => $news, | |||||
'newsletter' => $newsletter, | |||||
'user' => $this->security->getUser() | |||||
] ; | |||||
$body = [ | $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]); | $response = $mj->post(Resources::$Email, ['body' => $body]); | ||||
if($response->success()) { | if($response->success()) { | ||||
$this->em->flush() ; | $this->em->flush() ; | ||||
} | } | ||||
else { | else { | ||||
print_r($response->getBody()) ; | |||||
die() ; | |||||
$this->addFlash('error', "Une erreur est survenue lors de l'envoi de l'actualité."); | $this->addFlash('error', "Une erreur est survenue lors de l'envoi de l'actualité."); | ||||
} | } | ||||
} | } |
use Lc\ShopBundle\Context\DefaultRepositoryInterface; | use Lc\ShopBundle\Context\DefaultRepositoryInterface; | ||||
use Lc\ShopBundle\Context\ProductFamilyInterface; | use Lc\ShopBundle\Context\ProductFamilyInterface; | ||||
use Lc\ShopBundle\Context\ReductionCatalogInterface; | use Lc\ShopBundle\Context\ReductionCatalogInterface; | ||||
use Lc\ShopBundle\Model\ProductFamily; | |||||
/** | /** | ||||
* @method ProductFamilyInterface|null find($id, $lockMode = null, $lockVersion = null) | * @method ProductFamilyInterface|null find($id, $lockMode = null, $lockVersion = null) | ||||
} | } | ||||
} | } |
use Lc\ShopBundle\Context\DefaultRepositoryInterface; | use Lc\ShopBundle\Context\DefaultRepositoryInterface; | ||||
use Lc\ShopBundle\Context\ProductInterface; | use Lc\ShopBundle\Context\ProductInterface; | ||||
use Lc\ShopBundle\Model\ProductFamily; | |||||
/** | /** | ||||
* @method ProductInterface|null find($id, $lockMode = null, $lockVersion = null) | * @method ProductInterface|null find($id, $lockMode = null, $lockVersion = null) | ||||
return ProductInterface::class; | 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(); | |||||
} | |||||
} | } |
parameters: Paramètres | parameters: Paramètres | ||||
initReduction: Réduction | initReduction: Réduction | ||||
export: Note à l'export | export: Note à l'export | ||||
stockNegative: Produits stocks négatif | |||||
ReductionCatalog: | ReductionCatalog: | ||||
info: Informations principal | info: Informations principal | ||||
conditions: Conditions d'application | conditions: Conditions d'application |
{% 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> | |||||
</div> | </div> | ||||
{% endmacro form_widget_append %} | {% 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' %} | {% embed '@LcShop/backend/default/block/embed_modal.twig' %} | ||||
{% trans_default_domain 'lcshop' %} | {% trans_default_domain 'lcshop' %} | ||||
{% block id %}{{ id }}{% endblock %} | {% block id %}{{ id }}{% endblock %} |
{% if item.icon is not empty %}<i class="fa fa-fw {{ item.icon }}"></i>{% endif %} | {% if item.icon is not empty %}<i class="fa fa-fw {{ item.icon }}"></i>{% endif %} | ||||
<p>{{ item.label|trans(domain = translation_domain) }} | <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.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> | </p> | ||||
</a> | </a> | ||||
{% endif %} | {% endif %} |
namespace Lc\ShopBundle\Twig; | namespace Lc\ShopBundle\Twig; | ||||
use Doctrine\ORM\EntityManagerInterface; | use Doctrine\ORM\EntityManagerInterface; | ||||
use Lc\ShopBundle\Context\ProductInterface; | |||||
use Lc\ShopBundle\Context\ReductionCartInterface; | use Lc\ShopBundle\Context\ReductionCartInterface; | ||||
use Lc\ShopBundle\Context\TicketInterface; | use Lc\ShopBundle\Context\TicketInterface; | ||||
use Lc\ShopBundle\Repository\ProductRepository; | |||||
use Symfony\Contracts\Translation\TranslatorInterface; | use Symfony\Contracts\Translation\TranslatorInterface; | ||||
use Twig\Extension\AbstractExtension; | use Twig\Extension\AbstractExtension; | ||||
use Twig\TwigFilter; | use Twig\TwigFilter; | ||||
case 'ticket' : | case 'ticket' : | ||||
$ticketRepo = $this->em->getRepository(TicketInterface::class); | $ticketRepo = $this->em->getRepository(TicketInterface::class); | ||||
return $ticketRepo->countAllOpen(); | return $ticketRepo->countAllOpen(); | ||||
case 'productAvailabilitiesNegative' : | |||||
$productRepo = $this->em->getRepository(ProductInterface::class); | |||||
return count($productRepo->findProductByAvailabilitiesNegative()); | |||||
} | } | ||||
} | } |