Procházet zdrojové kódy

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

feature/export_comptable
Fab před 4 roky
rodič
revize
a225c20c2d
4 změnil soubory, kde provedl 87 přidání a 1 odebrání
  1. +4
    -0
      ShopBundle/Repository/OrderShopRepository.php
  2. +3
    -0
      ShopBundle/Resources/translations/lcshop.fr.yaml
  3. +72
    -0
      ShopBundle/Services/MailUtils.php
  4. +8
    -1
      ShopBundle/Services/UtilsManager.php

+ 4
- 0
ShopBundle/Repository/OrderShopRepository.php Zobrazit soubor

@@ -142,6 +142,10 @@ class OrderShopRepository extends BaseRepository implements DefaultRepositoryInt
$query->andWhere('e.' . $params['dateField'] . ' <= :dateEnd')->setParameter('dateEnd', $params['dateEnd']);
}

if (isset($params['weekNumber'])) {
$query->andWhere('e.weekNumber = :weekNumber')->setParameter('weekNumber', $params['weekNumber']);
}

if (isset($params['isCart'])) {
$query = $this->filterOrderCart($query);
}

+ 3
- 0
ShopBundle/Resources/translations/lcshop.fr.yaml Zobrazit soubor

@@ -214,6 +214,9 @@ field:
transfer: Virement
credit: Compte prépayé
minimumAmountCb: "Paiement par carte bancaire : montant minimum"
emailFrom: "Email (From) : email"
emailFromName: "Email (From) : nom"
emailSubjectPrefix: "Email : préfixe"
PointSale:
code: Code
codeHelp: Code utilisé pour retrouver l'ambassade dans le tunnel de commande (Non sensible à la casse)

+ 72
- 0
ShopBundle/Services/MailUtils.php Zobrazit soubor

@@ -0,0 +1,72 @@
<?php

namespace Lc\ShopBundle\Services ;

use Lc\ShopBundle\Context\MerchantUtilsInterface;
use Lc\ShopBundle\Model\Merchant;
use Mailjet\MailjetSwiftMailer\SwiftMailer\MailjetTransport;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
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 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 ;
}

public function send($params = [])
{
$merchantCurrent = $this->merchantUtils->getMerchantCurrent() ;

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

$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(
$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]));

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],
$params[self::ATTACHMENT_CONTENT_TYPE]
));
}

$this->transport->send($message) ;
}
}

+ 8
- 1
ShopBundle/Services/UtilsManager.php Zobrazit soubor

@@ -19,6 +19,7 @@ class UtilsManager
protected $deliveryUtils ;
protected $creditUtils ;
protected $documentUtils ;
protected $mailUtils ;

public function __construct(
Utils $utils,
@@ -29,7 +30,8 @@ class UtilsManager
PriceUtilsInterface $priceUtils,
DeliveryUtilsInterface $deliveryUtils,
CreditUtils $creditUtils,
DocumentUtils $documentUtils
DocumentUtils $documentUtils,
MailUtils $mailUtils
)
{
$this->utils = $utils ;
@@ -41,6 +43,7 @@ class UtilsManager
$this->deliveryUtils = $deliveryUtils ;
$this->creditUtils = $creditUtils ;
$this->documentUtils = $documentUtils ;
$this->mailUtils = $mailUtils ;
}

public function getUtils(): Utils
@@ -88,4 +91,8 @@ class UtilsManager
return $this->documentUtils ;
}

public function getMailUtils(): MailUtils
{
return $this->mailUtils ;
}
}

Načítá se…
Zrušit
Uložit