@@ -18,6 +18,7 @@ use Lc\ShopBundle\Form\Backend\Filters\ListFilterType; | |||
use Lc\ShopBundle\Services\UtilsManager; | |||
use Mailjet\MailjetSwiftMailer\SwiftMailer\MailjetTransport; | |||
use Symfony\Bridge\Doctrine\Form\Type\EntityType; | |||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; | |||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType; | |||
use Symfony\Component\Form\Extension\Core\Type\CollectionType; | |||
use Symfony\Component\Form\Extension\Core\Type\TextareaType; | |||
@@ -38,11 +39,14 @@ class AdminController extends EasyAdminController | |||
protected $merchantUtils; | |||
protected $mailjetTransport; | |||
protected $orderUtils; | |||
protected $mailUtils ; | |||
protected $translator; | |||
protected $parameterBag ; | |||
protected $filtersForm = null; | |||
public function __construct(Security $security, UserManagerInterface $userManager, EntityManagerInterface $em, | |||
MailjetTransport $mailjetTransport, UtilsManager $utilsManager, TranslatorInterface $translator) | |||
MailjetTransport $mailjetTransport, UtilsManager $utilsManager, TranslatorInterface $translator, | |||
ParameterBagInterface $parameterBag) | |||
{ | |||
$this->security = $security; | |||
$this->userManager = $userManager; | |||
@@ -51,7 +55,9 @@ class AdminController extends EasyAdminController | |||
$this->utils = $utilsManager->getUtils(); | |||
$this->merchantUtils = $utilsManager->getMerchantUtils(); | |||
$this->orderUtils = $utilsManager->getOrderUtils();; | |||
$this->mailUtils = $utilsManager->getMailUtils() ; | |||
$this->translator = $translator; | |||
$this->parameterBag = $parameterBag ; | |||
} | |||
public function createCustomForm($class, $action, $parameters, $data = true) |
@@ -7,61 +7,106 @@ use Doctrine\ORM\EntityManagerInterface; | |||
use FOS\UserBundle\Model\UserManagerInterface; | |||
use Lc\ShopBundle\Context\NewsInterface; | |||
use Lc\ShopBundle\Context\UserInterface; | |||
use Lc\ShopBundle\Services\MailUtils; | |||
use Lc\ShopBundle\Services\UtilsManager; | |||
use Mailjet\MailjetSwiftMailer\SwiftMailer\MailjetTransport; | |||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; | |||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface; | |||
use Symfony\Component\Security\Core\Security; | |||
use Symfony\Contracts\Translation\TranslatorInterface; | |||
class NewsController extends AdminController | |||
{ | |||
public function sendTestAction() | |||
{ | |||
$newsletter = $this->getNewsletter() ; | |||
$news = $this->getNews() ; | |||
$merchantCurrent = $this->merchantUtils->getMerchantCurrent() ; | |||
$merchantConfigEmailContact = $merchantCurrent->getMerchantConfig('email-contact'); | |||
if($merchantConfigEmailContact && strlen($merchantConfigEmailContact)) { | |||
$this->mailUtils->send([ | |||
MailUtils::SUBJECT => $news->getTitle(), | |||
MailUtils::TO_EMAIL => $merchantConfigEmailContact, | |||
MailUtils::TO_NAME => $this->parameterBag->get('app.site_name'), | |||
MailUtils::CONTENT_TEMPLATE => 'mail/news', | |||
MailUtils::CONTENT_DATA => [ | |||
'news' => $news, | |||
'newsletter' => $newsletter, | |||
'user' => $this->security->getUser() | |||
], | |||
]); | |||
$this->addFlash('success', 'Actualité de test envoyée à '.$merchantConfigEmailContact); | |||
} | |||
else { | |||
throw new \ErrorException("L'email de contact n'est pas défini pour ce Merchant.") ; | |||
} | |||
return $this->redirectToRoute('easyadmin', ['entity' => 'News', 'action' => 'list']) ; | |||
} | |||
public function sendAction() | |||
{ | |||
$idNews = $this->request->get('id') ; | |||
$newsletter = $this->getNewsletter() ; | |||
$newsletter = $this->merchantUtils->getMerchantCurrent()->getNewsletter() ; | |||
$news = $this->getNews() ; | |||
$users = $this->em->getRepository($this->em->getClassMetadata(UserInterface::class)->getName())->findAllByNewsletter($newsletter) ; | |||
$countUsers = count($users) ; | |||
$messages = []; | |||
if($newsletter) { | |||
$users = $this->em->getRepository($this->em->getClassMetadata(UserInterface::class)->getName())->findAllByNewsletter($newsletter) ; | |||
$countUsers = count($users) ; | |||
$messages = []; | |||
$news = $this->em->getRepository($this->em->getClassMetadata(NewsInterface::class)->getName())->find($idNews) ; | |||
if($news) { | |||
foreach ($users as $user) { | |||
$message = new \Swift_Message('[Place du Local] '.$news->getTitle()); | |||
$message->addTo($user->getEmail()) | |||
->addFrom($this->getParameter('app.noreply_email'), $this->getParameter('app.site_name')) | |||
->setBody($this->renderView('mail/news.html.twig', [ | |||
'message' => $news->getDescription(), | |||
'image' => $news->getImage(), | |||
'newsletter' => $newsletter, | |||
'user' => $user | |||
]), 'text/html'); | |||
array_push($messages, $message); | |||
} | |||
if($countUsers > 0) { | |||
$result = $this->mailjetTransport->bulkSend($messages); | |||
$this->addFlash('success', 'Actualité envoyée à '.count($users).' utilisateurs.'); | |||
$news->setIsSent(true) ; | |||
$this->em->persist($news); | |||
$this->em->flush() ; | |||
} | |||
else { | |||
$this->addFlash('error', 'Aucun utilisateur inscrit à la newsletter.'); | |||
} | |||
} | |||
else { | |||
throw new NotFoundHttpException('Actualité introuvable') ; | |||
} | |||
foreach ($users as $user) { | |||
$message = new \Swift_Message('[Place du Local] '.$news->getTitle()); | |||
$message->addTo($user->getEmail()) | |||
->addFrom($this->getParameter('app.noreply_email'), $this->getParameter('app.site_name')) | |||
->setBody($this->renderView('mail/news-html.html.twig', [ | |||
'news' => $news, | |||
'newsletter' => $newsletter, | |||
'user' => $user | |||
]), 'text/html'); | |||
array_push($messages, $message); | |||
} | |||
if($countUsers > 0) { | |||
$result = $this->mailjetTransport->bulkSend($messages); | |||
$this->addFlash('success', 'Actualité envoyée à '.count($users).' utilisateurs.'); | |||
$news->setIsSent(true) ; | |||
$this->em->persist($news); | |||
$this->em->flush() ; | |||
} | |||
else { | |||
throw new \ErrorException('Aucune newsletter n\'est lié à ce Merchant.') ; | |||
$this->addFlash('error', 'Aucun utilisateur inscrit à la newsletter.'); | |||
} | |||
return $this->redirectToRoute('easyadmin', ['entity' => 'News', 'action' => 'list']) ; | |||
} | |||
public function getNewsletter() | |||
{ | |||
$newsletter = $this->merchantUtils->getMerchantCurrent()->getNewsletter() ; | |||
if($newsletter) { | |||
return $newsletter ; | |||
} | |||
else { | |||
throw new \ErrorException('Aucune newsletter n\'est liée à ce Merchant.') ; | |||
} | |||
} | |||
public function getNews() | |||
{ | |||
$idNews = $this->request->get('id') ; | |||
$news = $this->em->getRepository($this->em->getClassMetadata(NewsInterface::class)->getName())->find($idNews) ; | |||
if($news) { | |||
return $news ; | |||
} | |||
else { | |||
throw new NotFoundHttpException('Actualité introuvable') ; | |||
} | |||
} | |||
} |
@@ -511,6 +511,7 @@ class OrderController extends AdminController | |||
if (!$user instanceof UserInterface) return $user; | |||
else { | |||
//TODO Utiliser getCartByUserOrCreateIt ds OrderUtils | |||
$orderShopUser = $this->em->getRepository(OrderShopInterface::class)->findCartCurrent(['user' => $user]); | |||
if ($orderShopUser) { | |||
$this->utils->addFlash('info', 'error.order.otherOrderAlreadyExist'); |
@@ -1,58 +0,0 @@ | |||
<?php | |||
namespace Lc\ShopBundle\Form\Backend\Common; | |||
use Doctrine\ORM\EntityManagerInterface; | |||
use Doctrine\ORM\EntityRepository; | |||
use Lc\ShopBundle\Context\MerchantUtilsInterface; | |||
use Lc\ShopBundle\Context\ProductInterface; | |||
use Symfony\Bridge\Doctrine\Form\Type\EntityType; | |||
use Symfony\Component\Form\AbstractType; | |||
use Symfony\Component\Form\FormBuilderInterface; | |||
use Symfony\Component\Form\FormEvent; | |||
use Symfony\Component\Form\FormEvents; | |||
use Symfony\Component\OptionsResolver\OptionsResolver; | |||
class ProductType extends AbstractType | |||
{ | |||
protected $em; | |||
protected $merchantUtils; | |||
public function __construct(EntityManagerInterface $entityManager, MerchantUtilsInterface $merchantUtils) | |||
{ | |||
$this->em = $entityManager; | |||
$this->merchantUtils = $merchantUtils; | |||
} | |||
public function buildForm(FormBuilderInterface $builder, array $options) | |||
{ | |||
$productClass = $this->em->getClassMetadata(ProductInterface::class); | |||
$currentMerchant = $this->merchantUtils->getMerchantUser(); | |||
$builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) use ($productClass, $options, $currentMerchant) { | |||
$builder = $event->getForm()->getParent(); | |||
$builder->add('product', EntityType::class, array_merge($options,[ | |||
'class' => $productClass->name, | |||
'query_builder' => function (EntityRepository $er) use ($currentMerchant) { | |||
return $er->createQueryBuilder('p') | |||
->join('p.productFamily', 'pFamily') | |||
->where('pFamily.merchant = :currentMerchant') | |||
->andWhere('pFamily.status = 1') | |||
->setParameter('currentMerchant', $currentMerchant); | |||
}, | |||
'choice_label' => function ($product) { | |||
return $product->getProductFamily()->getTitle() . ' - ' . $product->getTitle(); | |||
} | |||
])); | |||
}); | |||
} | |||
public function configureOptions(OptionsResolver $resolver) | |||
{ | |||
$resolver->setDefaults([ | |||
'translation_domain' => 'lcshop', | |||
]); | |||
} | |||
} |
@@ -1,52 +0,0 @@ | |||
<?php | |||
namespace Lc\ShopBundle\Form\Backend\Common; | |||
use Doctrine\ORM\EntityManagerInterface; | |||
use Doctrine\ORM\EntityRepository; | |||
use Lc\ShopBundle\Context\ReductionCatalogInterface; | |||
use Lc\ShopBundle\Context\UserInterface; | |||
use Lc\ShopBundle\Repository\GroupUserRepository; | |||
use Symfony\Bridge\Doctrine\Form\Type\EntityType; | |||
use Symfony\Component\Form\AbstractType; | |||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType; | |||
use Symfony\Component\Form\FormBuilderInterface; | |||
use Symfony\Component\Form\FormEvent; | |||
use Symfony\Component\Form\FormEvents; | |||
use Symfony\Component\OptionsResolver\OptionsResolver; | |||
class UserType extends AbstractType | |||
{ | |||
protected $em; | |||
public function __construct(EntityManagerInterface $entityManager) | |||
{ | |||
$this->em = $entityManager; | |||
} | |||
public function buildForm(FormBuilderInterface $builder, array $options) | |||
{ | |||
$userClass = $this->em->getClassMetadata(UserInterface::class); | |||
$builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) use ($userClass, $options) { | |||
$builder = $event->getForm()->getParent(); | |||
$builder->add('user', EntityType::class, array_merge($options,[ | |||
'class' => $userClass->name, | |||
'query_builder'=> function (EntityRepository $er) { | |||
$query = $er->findByMerchantQuery(); | |||
return $query; | |||
}, | |||
'expanded' => false, | |||
'translation_domain'=>'lcshop', | |||
])); | |||
}); | |||
} | |||
public function configureOptions(OptionsResolver $resolver) | |||
{ | |||
$resolver->setDefaults([ | |||
'translation_domain' => 'lcshop', | |||
]); | |||
} | |||
} |
@@ -37,6 +37,11 @@ abstract class OrderStatus | |||
self::ALIAS_DONE | |||
] ; | |||
static $statusAliasWaitingDelivery = [ | |||
self::ALIAS_WAITING_DELIVERY, | |||
self::ALIAS_WAITING_DELIVERY_WITH_PAYMENT, | |||
]; | |||
static $statusAliasAsCart = [ | |||
self::ALIAS_CART, | |||
self::ALIAS_WAITING_PAYMENT_ONLINE, |
@@ -8,6 +8,7 @@ use App\Entity\UserPointSale; | |||
use Doctrine\Common\Collections\ArrayCollection; | |||
use Doctrine\Common\Collections\Collection; | |||
use Doctrine\ORM\Mapping as ORM; | |||
use Gedmo\Mapping\Annotation as Gedmo; | |||
use FOS\UserBundle\Model\User as UserModelFOS; | |||
use Lc\ShopBundle\Context\MerchantInterface; | |||
use Lc\ShopBundle\Context\TicketInterface; | |||
@@ -89,6 +90,18 @@ abstract class User extends UserModelFOS | |||
*/ | |||
protected $tickets; | |||
/** | |||
* @ORM\Column(type="datetime") | |||
* @Gedmo\Timestampable(on="create") | |||
*/ | |||
protected $createdAt; | |||
/** | |||
* @ORM\Column(type="datetime") | |||
* @Gedmo\Timestampable(on="update") | |||
*/ | |||
protected $updatedAt; | |||
public function __construct() | |||
{ | |||
parent::__construct(); | |||
@@ -190,7 +203,7 @@ abstract class User extends UserModelFOS | |||
} | |||
/** | |||
* @return Collection|ShopOrder[] | |||
* @return Collection|OrderShop[] | |||
*/ | |||
public function getOrders(): Collection | |||
{ | |||
@@ -395,6 +408,29 @@ abstract class User extends UserModelFOS | |||
} | |||
} | |||
return $this; | |||
} | |||
public function getCreatedAt(): ?\DateTimeInterface | |||
{ | |||
return $this->createdAt; | |||
} | |||
public function setCreatedAt(\DateTimeInterface $createdAt): self | |||
{ | |||
$this->createdAt = $createdAt; | |||
return $this; | |||
} | |||
public function getUpdatedAt(): ?\DateTimeInterface | |||
{ | |||
return $this->updatedAt; | |||
} | |||
public function setUpdatedAt(\DateTimeInterface $updatedAt): self | |||
{ | |||
$this->updatedAt = $updatedAt; | |||
return $this; | |||
} | |||
} |
@@ -65,20 +65,24 @@ class OrderShopRepository extends BaseRepository implements DefaultRepositoryInt | |||
public function filterOrderValid(?QueryBuilder $query): QueryBuilder | |||
{ | |||
$query->leftJoin('e.orderStatus', 'os'); | |||
$query->andWhere('os.alias IN (:alias)'); | |||
$query->setParameter('alias', OrderStatus::$statusAliasAsValid); | |||
return $this->_filterOrderStatus($query, OrderStatus::$statusAliasAsValid) ; | |||
} | |||
return $query; | |||
public function filterOrderWaitingDelivery($query) | |||
{ | |||
return $this->_filterOrderStatus($query, OrderStatus::$statusAliasWaitingDelivery) ; | |||
} | |||
public function filterOrderCart($query) | |||
{ | |||
return $this->_filterOrderStatus($query, OrderStatus::$statusAliasAsCart) ; | |||
} | |||
private function _filterOrderStatus($query, $statusArray) { | |||
$query->leftJoin('e.orderStatus', 'os'); | |||
$query->andWhere('os.alias IN (:alias)'); | |||
$query->setParameter('alias', OrderStatus::$statusAliasAsCart); | |||
return $query; | |||
$query->setParameter('alias',$statusArray); | |||
return $query ; | |||
} | |||
public function findCartCurrent($params) | |||
@@ -139,6 +143,10 @@ class OrderShopRepository extends BaseRepository implements DefaultRepositoryInt | |||
$query = $this->filterOrderValid($query); | |||
} | |||
if (isset($params['isWaitingDelivery'])) { | |||
$query = $this->filterOrderWaitingDelivery($query); | |||
} | |||
if (isset($params['orderStatus'])) { | |||
$query->leftJoin('e.orderStatus', 'os'); | |||
$query->andWhere('os.alias LIKE :alias'); |
@@ -21,7 +21,7 @@ function initNotice() { | |||
} | |||
function initButtonConfirm() { | |||
$('.btn-confirm-js').click(function () { | |||
$('.btn-confirm-js, .action-confirm').click(function () { | |||
return confirm('Êtes-vous sûr de vouloir réaliser cette action ?'); | |||
}); | |||
} |
@@ -52,6 +52,7 @@ group: | |||
conditions: Conditions d'applications | |||
actions: Actions | |||
OrderShop: | |||
redelivery: Relivraison | |||
resume: Résumé de commande | |||
addProduct: Ajout de produit à la commande | |||
orderPayment: Ajouter un règlement | |||
@@ -375,6 +376,10 @@ field: | |||
typeOptions: | |||
individual: Particulier | |||
legal-person: Professionnel | |||
OrderProductRedelivery: | |||
quantityOrder: Quantité commandé | |||
quantityProduct: Quantité (en rapport à l'unité) | |||
unit: Unité | |||
OrderShop: | |||
save: Sauvegarder | |||
reference: Référence | |||
@@ -390,8 +395,10 @@ field: | |||
quantityOrder: Quantité commandé | |||
quantityProduct: Quantité (en rapport à l'unité) | |||
unit: Unité | |||
redeliverySupplier: Erreur producteur | |||
redeliverySupplierOrder: A recommander au producteur | |||
redeliverySupplierShort: Erreur producteur | |||
redeliverySupplier: Erreur producteur (Aura un prix à 0€ dans le prohain bon de commande producteur - vous devez cocher à recommander) | |||
redeliverySupplierOrderShort: À recommander au producteur | |||
redeliverySupplierOrder: À recommander au producteur (Sera affiché dans le prohain bon de commande producteur) | |||
deliveryType: Type de livraison | |||
deliveryTypeOptions: | |||
point-sale: En ambassade |
@@ -135,7 +135,7 @@ | |||
{% endblock new_action %} | |||
{% endif %} | |||
{% if _entity_config['list']['btn_init_export_purchase_order'] is defined %} | |||
<a class="float-right btn-sm btn-success action-sort" | |||
<a class="float-right btn-sm btn-success action-confirm" | |||
href="{{ path('easyadmin', { entity: 'Supplier', action: 'initExportPurchaseOrder' }) }}"> | |||
<i class="fa fa-undo"></i> Réinitialiser export bons de commande | |||
</a> |
@@ -301,11 +301,11 @@ | |||
{% block label %}{{ "field.default.deliveryAvailabilty"|trans({}, 'lcshop') }}{% endblock %} | |||
{% block value %} | |||
<div v-if="order.deliveryType == 'home'"> | |||
<div v-html="order.deliveryAvailabilityZone"> | |||
<div v-html="order.deliveryAvailabilityZone != null ? order.deliveryAvailabilityZone : order.deliveryDate"> | |||
</div> | |||
</div> | |||
<div v-else-if="order.deliveryType == 'point-sale'"> | |||
<div v-html="order.deliveryAvailabilityPointSale"> | |||
<div v-html="order.deliveryAvailabilityPointSale != null ? order.deliveryAvailabilityPointSale : order.deliveryDate"> | |||
</div> | |||
</div> | |||
<div v-else> |
@@ -1,6 +1,6 @@ | |||
<?php | |||
namespace Lc\ShopBundle\Services ; | |||
namespace Lc\ShopBundle\Services; | |||
use Lc\ShopBundle\Context\MerchantUtilsInterface; | |||
use Lc\ShopBundle\Model\Merchant; | |||
@@ -10,61 +10,69 @@ use Twig\Environment; | |||
class MailUtils | |||
{ | |||
const SUBJECT = 'subject' ; | |||
const SUBJECT_PREFIX = 'subject-prefix' ; | |||
const TO_EMAIL = 'to-email' ; | |||
const TO_NAME = 'to-name' ; | |||
const FROM_EMAIL = 'from-email' ; | |||
const FROM_NAME = 'from-name' ; | |||
const REPLY_TO = 'reply-to' ; | |||
const CONTENT_TEMPLATE = 'content-template' ; | |||
const CONTENT_DATA = 'content-data' ; | |||
const ATTACHMENT_DATA = 'attachment-data' ; | |||
const ATTACHMENT_FILENAME = 'attachment-filename' ; | |||
const ATTACHMENT_CONTENT_TYPE = 'attachment-content-type' ; | |||
protected $transport ; | |||
protected $templating ; | |||
protected $parameterBag ; | |||
protected $merchantUtils ; | |||
public function __construct(MailjetTransport $mailjetTransport, Environment $templating,ParameterBagInterface $parameterBag, MerchantUtilsInterface $merchantUtils) | |||
const SUBJECT = 'subject'; | |||
const SUBJECT_PREFIX = 'subject-prefix'; | |||
const TO_EMAIL = 'to-email'; | |||
const TO_NAME = 'to-name'; | |||
const FROM_EMAIL = 'from-email'; | |||
const FROM_NAME = 'from-name'; | |||
const REPLY_TO = 'reply-to'; | |||
const CONTENT_TEMPLATE = 'content-template'; | |||
const CONTENT_DATA = 'content-data'; | |||
const ATTACHMENT_DATA = 'attachment-data'; | |||
const ATTACHMENT_FILENAME = 'attachment-filename'; | |||
const ATTACHMENT_CONTENT_TYPE = 'attachment-content-type'; | |||
protected $transport; | |||
protected $templating; | |||
protected $parameterBag; | |||
protected $merchantUtils; | |||
public function __construct(MailjetTransport $mailjetTransport, Environment $templating, ParameterBagInterface $parameterBag, MerchantUtilsInterface $merchantUtils) | |||
{ | |||
$this->transport = $mailjetTransport ; | |||
$this->templating = $templating ; | |||
$this->parameterBag = $parameterBag ; | |||
$this->merchantUtils = $merchantUtils ; | |||
$this->transport = $mailjetTransport; | |||
$this->templating = $templating; | |||
$this->parameterBag = $parameterBag; | |||
$this->merchantUtils = $merchantUtils; | |||
} | |||
public function send($params = []) | |||
{ | |||
$merchantCurrent = $this->merchantUtils->getMerchantCurrent() ; | |||
$merchantCurrent = $this->merchantUtils->getMerchantCurrent(); | |||
$merchantConfigEmailFrom = $merchantCurrent->getMerchantConfig('email-from') ; | |||
$emailFrom = isset($params[self::FROM_EMAIL]) ? $params[self::FROM_EMAIL] : $merchantConfigEmailFrom ; | |||
$merchantConfigEmailFrom = $merchantCurrent->getMerchantConfig('email-from'); | |||
$emailFrom = isset($params[self::FROM_EMAIL]) ? $params[self::FROM_EMAIL] : $merchantConfigEmailFrom; | |||
$merchantConfigEmailFromName = $merchantCurrent->getMerchantConfig('email-from-name') ; | |||
$emailFromName = isset($params[self::FROM_NAME]) ? $params[self::FROM_NAME] : $merchantConfigEmailFromName ; | |||
$merchantConfigEmailFromName = $merchantCurrent->getMerchantConfig('email-from-name'); | |||
$emailFromName = isset($params[self::FROM_NAME]) ? $params[self::FROM_NAME] : $merchantConfigEmailFromName; | |||
$merchantConfigEmailSubjectPrefix = $merchantCurrent->getMerchantConfig('email-subject-prefix') ; | |||
$emailSubjectPrefix = isset($params[self::SUBJECT_PREFIX]) ? $params[self::SUBJECT_PREFIX] : $merchantConfigEmailSubjectPrefix ; | |||
if($emailSubjectPrefix && strlen($emailSubjectPrefix)) { | |||
$emailSubjectPrefix .= ' ' ; | |||
$merchantConfigEmailSubjectPrefix = $merchantCurrent->getMerchantConfig('email-subject-prefix'); | |||
$emailSubjectPrefix = isset($params[self::SUBJECT_PREFIX]) ? $params[self::SUBJECT_PREFIX] : $merchantConfigEmailSubjectPrefix; | |||
if ($emailSubjectPrefix && strlen($emailSubjectPrefix)) { | |||
$emailSubjectPrefix .= ' '; | |||
} | |||
$message = new \Swift_Message($emailSubjectPrefix.$params[self::SUBJECT]); | |||
$message->addTo( | |||
$message = new \Swift_Message($emailSubjectPrefix . $params[self::SUBJECT]); | |||
if ($this->parameterBag->get('mailjet.dev.redirect.active')==1) { | |||
$message->addTo($this->parameterBag->get('mailjet.dev.redirect.email'), | |||
isset($params[self::TO_NAME]) ? $params[self::TO_NAME] : null); | |||
} else { | |||
$message->addTo( | |||
$params[self::TO_EMAIL], | |||
isset($params[self::TO_NAME]) ? $params[self::TO_NAME] : null) | |||
->addFrom($emailFrom, $emailFromName) | |||
->setBody($this->templating->render($params[self::CONTENT_TEMPLATE].'-html.html.twig', $params[self::CONTENT_DATA]), 'text/html') | |||
->addPart($this->templating->render($params[self::CONTENT_TEMPLATE].'-text.html.twig', $params[self::CONTENT_DATA])); | |||
isset($params[self::TO_NAME]) ? $params[self::TO_NAME] : null); | |||
} | |||
$message->addFrom($emailFrom, $emailFromName) | |||
->setBody($this->templating->render($params[self::CONTENT_TEMPLATE] . '-html.html.twig', $params[self::CONTENT_DATA]), 'text/html') | |||
->addPart($this->templating->render($params[self::CONTENT_TEMPLATE] . '-text.html.twig', $params[self::CONTENT_DATA])); | |||
if(isset($params[self::REPLY_TO]) && strlen($params[self::REPLY_TO])) { | |||
$message->addReplyTo($params[self::REPLY_TO]) ; | |||
if (isset($params[self::REPLY_TO]) && strlen($params[self::REPLY_TO])) { | |||
$message->addReplyTo($params[self::REPLY_TO]); | |||
} | |||
if(isset($params[self::ATTACHMENT_DATA]) && isset($params[self::ATTACHMENT_FILENAME]) && isset($params[self::ATTACHMENT_CONTENT_TYPE])) { | |||
if (isset($params[self::ATTACHMENT_DATA]) && isset($params[self::ATTACHMENT_FILENAME]) && isset($params[self::ATTACHMENT_CONTENT_TYPE])) { | |||
$message->attach(\Swift_Attachment::newInstance( | |||
$params[self::ATTACHMENT_DATA], | |||
$params[self::ATTACHMENT_FILENAME], | |||
@@ -72,6 +80,6 @@ class MailUtils | |||
)); | |||
} | |||
$this->transport->send($message) ; | |||
$this->transport->send($message); | |||
} | |||
} |
@@ -3,10 +3,24 @@ | |||
namespace Lc\ShopBundle\Services\Order; | |||
use Lc\ShopBundle\Context\OrderShopInterface; | |||
use Lc\ShopBundle\Model\OrderStatus; | |||
trait OrderUtilsCartTrait | |||
{ | |||
public function getCartByUserOrCreateIt($user){ | |||
$newOrderShop= $this->em->getRepository(OrderShopInterface::class)->findCartCurrent(['user' => $user]); | |||
if ($newOrderShop === null) { | |||
$newOrderShop = $this->createOrderShop(array( | |||
'user' => $user, | |||
'merchant' => $this->merchantUtils->getMerchantUser() | |||
)); | |||
} | |||
return $newOrderShop; | |||
} | |||
public function getCartCurrent() | |||
{ | |||
$paramsSearchOrderShop = []; |