瀏覽代碼

Merge branch 'develop' of https://gitea.laclic.fr/Laclic/LcShopBundle into develop

feature/export_comptable
Fab 4 年之前
父節點
當前提交
6b6f133f2e
共有 6 個文件被更改,包括 57 次插入42 次删除
  1. +47
    -33
      ShopBundle/Controller/Backend/NewsController.php
  2. +1
    -1
      ShopBundle/Model/MerchantConfig.php
  3. +1
    -1
      ShopBundle/Resources/public/js/backend/script/supplier/vuejs-supplier.js
  4. +1
    -1
      ShopBundle/Resources/views/backend/default/block/form_address.html.twig
  5. +0
    -3
      ShopBundle/Resources/views/backend/supplier/panel_general.html.twig
  6. +7
    -3
      ShopBundle/Services/CsvGenerator.php

+ 47
- 33
ShopBundle/Controller/Backend/NewsController.php 查看文件

@@ -61,52 +61,66 @@ class NewsController extends AdminController

public function sendAction()
{
ini_set('memory_limit', '-1');

$currentMerchant = $this->merchantUtils->getMerchantCurrent() ;
$newsletter = $this->getNewsletter() ;
$news = $this->getNews() ;
$users = $this->em->getRepository($this->em->getClassMetadata(UserInterface::class)->getName())->findAllByNewsletter($newsletter) ;
$countUsers = count($users) ;
$toArray = [];

$packageMessagesArray = [];
$packageMessageLimit = 50 ;

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

$i = 0 ;
foreach ($users as $user) {
$toArray[] = [
'Email' => $user->getEmail(),
'Name' => $user->getFirstname().' '.$user->getLastname(),
] ;
if(!isset($packageMessagesArray[$i])) {
$packageMessagesArray[$i] = [] ;
}

if($user->getEmail() && strlen($user->getEmail())) {
$packageMessagesArray[$i][] = [
'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(count($packageMessagesArray[$i]) >= $packageMessageLimit) {
$i ++ ;
}
}
}

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
]
]
];


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

if($response->success()) {
foreach($packageMessagesArray as $messagesArray) {
$body = [
'Messages' => $messagesArray
];
$response = $mj->post(Resources::$Email, ['body' => $body]);
}

if(isset($response) && $response->success()) {
$this->addFlash('success', 'Actualité envoyée à '.$countUsers.' utilisateurs.');

$news->setIsSent(true) ;

+ 1
- 1
ShopBundle/Model/MerchantConfig.php 查看文件

@@ -65,7 +65,7 @@ abstract class MerchantConfig extends AbstractEntity
return $this->value;
}

public function setValue(string $value): self
public function setValue($value): self
{
$this->value = $value;


+ 1
- 1
ShopBundle/Resources/public/js/backend/script/supplier/vuejs-supplier.js 查看文件

@@ -23,7 +23,7 @@ appOrder = new Vue({
nameDisplay: 'SEO'
}
]
});
}, window.addressValues);
},
mounted: function () {},
methods: {

+ 1
- 1
ShopBundle/Resources/views/backend/default/block/form_address.html.twig 查看文件

@@ -1,7 +1,7 @@
<div id="lc-user-address" class="row">
<script>
window.addressValues = {
{% if form.type.vars.value %}addressType: "{{ form.type.vars.value }}",{% endif %}
{% if form.type.vars.value %}addressType: '{{ form.type.vars.value }}'{% endif %}
};
</script>


+ 0
- 3
ShopBundle/Resources/views/backend/supplier/panel_general.html.twig 查看文件

@@ -18,9 +18,6 @@
<div class="col-12">
{{ form_row(form.description) }}
</div>
<div class="col-12">
{{ form_row(form.user) }}
</div>
{{ macros.card_end() }}
</div>
</div>

+ 7
- 3
ShopBundle/Services/CsvGenerator.php 查看文件

@@ -61,9 +61,13 @@ class CsvGenerator

public function encodeArray($array)
{
return array_map(function($value) {
return $this->encode($value) ;
}, $array) ;
if($array && is_array($array)) {
return array_map(function($value) {
return $this->encode($value) ;
}, $array) ;
}

return $array ;
}

public function setTitle($title, $displayHeader = false){

Loading…
取消
儲存