<?php | |||||
namespace Lc\ShopBundle\Context ; | |||||
interface DocumentUtilsInterface | |||||
{ | |||||
} |
$this->translator = $translator; | $this->translator = $translator; | ||||
} | } | ||||
public function createCustomForm($class, $action, $parameters, $data = true) | |||||
public function createCustomForm($class, $action, $parameters, $data = true, $options = array()) | |||||
{ | { | ||||
$options = array(); | |||||
if ($data) $options['data'] = $parameters['entity']; | if ($data) $options['data'] = $parameters['entity']; | ||||
$options['action'] = $this->generateUrl('easyadmin', array( | $options['action'] = $this->generateUrl('easyadmin', array( | ||||
'action' => $action, | 'action' => $action, |
use Lc\ShopBundle\Services\Utils; | use Lc\ShopBundle\Services\Utils; | ||||
use Lc\ShopBundle\Services\UtilsManager; | use Lc\ShopBundle\Services\UtilsManager; | ||||
use Mailjet\MailjetSwiftMailer\SwiftMailer\MailjetTransport; | use Mailjet\MailjetSwiftMailer\SwiftMailer\MailjetTransport; | ||||
use Symfony\Component\HttpFoundation\BinaryFileResponse; | |||||
use Symfony\Component\HttpFoundation\StreamedResponse; | |||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; | use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; | ||||
use Symfony\Component\Security\Core\Security; | use Symfony\Component\Security\Core\Security; | ||||
use Symfony\Contracts\Translation\TranslatorInterface; | use Symfony\Contracts\Translation\TranslatorInterface; | ||||
} | } | ||||
if($document && $orderShop) { | if($document && $orderShop) { | ||||
$this->orderUtils->generateDocumentInvoiceOrderShop($orderShop, 'download') ; | |||||
return new StreamedResponse(function () use ($orderShop) { | |||||
$this->orderUtils->generateDocumentInvoiceOrderShop($orderShop, 'download') ; | |||||
}); | |||||
} | } | ||||
else { | else { | ||||
throw new NotFoundHttpException('Document introuvable') ; | throw new NotFoundHttpException('Document introuvable') ; |
public function updateCommonProperty(GenericEvent $event) | public function updateCommonProperty(GenericEvent $event) | ||||
{ | { | ||||
/* $this->setUpdated($entity); | /* $this->setUpdated($entity); | ||||
$this->setAddressCreatedBy($entity) ;*/ | $this->setAddressCreatedBy($entity) ;*/ | ||||
} | } |
]) | ]) | ||||
->add('lastname', TextType::class, ['required' => false]) | ->add('lastname', TextType::class, ['required' => false]) | ||||
->add('firstname', TextType::class, ['required' => false]) | ->add('firstname', TextType::class, ['required' => false]) | ||||
->add('address', TextareaType::class) | |||||
->add('zip', TextType::class) | ->add('zip', TextType::class) | ||||
->add('city', TextType::class) | ->add('city', TextType::class) | ||||
->add('address', TextType::class) | |||||
->add('phone', CollectionType::class, [ | ->add('phone', CollectionType::class, [ | ||||
'allow_add'=>true, | 'allow_add'=>true, | ||||
'allow_delete'=>true, | 'allow_delete'=>true, |
<?php | |||||
namespace Lc\ShopBundle\Form\Backend\User; | |||||
use App\Entity\Supplier; | |||||
use Doctrine\ORM\EntityManagerInterface; | |||||
use Doctrine\ORM\EntityRepository; | |||||
use Lc\ShopBundle\Model\Ticket; | |||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType; | |||||
use Symfony\Component\Form\AbstractType; | |||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType; | |||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType; | |||||
use Symfony\Component\Form\FormBuilderInterface; | |||||
use Symfony\Component\Form\FormEvent; | |||||
use Symfony\Component\Form\FormEvents; | |||||
use Symfony\Component\OptionsResolver\OptionsResolver; | |||||
class TicketTypesNotificationType extends AbstractType | |||||
{ | |||||
protected $em; | |||||
public function __construct(EntityManagerInterface $entityManager) | |||||
{ | |||||
$this->em = $entityManager; | |||||
} | |||||
public function buildForm(FormBuilderInterface $builder, array $options) | |||||
{ | |||||
$builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) { | |||||
$builder = $event->getForm()->getParent(); | |||||
$builder->add('ticketTypesNotification', ChoiceType::class, [ | |||||
'choices'=> array( | |||||
'field.Ticket.typeOptions.'.Ticket::TYPE_GENERAL_QUESTION => Ticket::TYPE_GENERAL_QUESTION, | |||||
'field.Ticket.typeOptions.'.Ticket::TYPE_PRODUCT_ERROR=> Ticket::TYPE_PRODUCT_ERROR , | |||||
'field.Ticket.typeOptions.'.Ticket::TYPE_PRODUCT_UNAVAILABLE => Ticket::TYPE_PRODUCT_UNAVAILABLE, | |||||
'field.Ticket.typeOptions.'.Ticket::TYPE_TECHNICAL_PROBLEM => Ticket::TYPE_TECHNICAL_PROBLEM | |||||
), | |||||
'required' => false, | |||||
'expanded' => false, | |||||
'multiple' => true, | |||||
'translation_domain'=>'lcshop', | |||||
]); | |||||
}); | |||||
} | |||||
public function configureOptions(OptionsResolver $resolver) | |||||
{ | |||||
$resolver->setDefaults([ | |||||
// 'translation_domain' => 'lcshop', | |||||
]); | |||||
} | |||||
} |
/** | /** | ||||
* @ORM\ManyToMany(targetEntity="Lc\ShopBundle\Context\OrderShopInterface", mappedBy="documents") | * @ORM\ManyToMany(targetEntity="Lc\ShopBundle\Context\OrderShopInterface", mappedBy="documents") | ||||
* @ORM\JoinColumn(nullable=true) | |||||
*/ | */ | ||||
protected $orderShops; | protected $orderShops; | ||||
/** | /** | ||||
* @ORM\OneToOne(targetEntity="Lc\ShopBundle\Context\OrderRefundInterface", mappedBy="document", cascade={"persist", "remove"}) | * @ORM\OneToOne(targetEntity="Lc\ShopBundle\Context\OrderRefundInterface", mappedBy="document", cascade={"persist", "remove"}) | ||||
*/ | */ |
return $this->slug; | return $this->slug; | ||||
} | } | ||||
public function setSlug(string $slug): self | |||||
public function setSlug(?string $slug): self | |||||
{ | { | ||||
$this->slug = $slug; | $this->slug = $slug; | ||||
*/ | */ | ||||
protected $updatedAt; | protected $updatedAt; | ||||
/** | |||||
* @ORM\Column(type="array", nullable=true) | |||||
*/ | |||||
protected $ticketTypesNotification = []; | |||||
public function __construct() | public function __construct() | ||||
{ | { | ||||
parent::__construct(); | parent::__construct(); | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getTicketTypesNotification(): ?array | |||||
{ | |||||
return $this->ticketTypesNotification; | |||||
} | |||||
public function setTicketTypesNotification(?array $ticketTypesNotification): self | |||||
{ | |||||
$this->ticketTypesNotification = $ticketTypesNotification; | |||||
return $this; | |||||
} | |||||
} | } |
$query->select('SUM(orderProduct.quantityOrder) as quantity'); | $query->select('SUM(orderProduct.quantityOrder) as quantity'); | ||||
$result = $query->getQuery()->getOneOrNullResult(); | $result = $query->getQuery()->getOneOrNullResult(); | ||||
return $result['quantity']; | return $result['quantity']; | ||||
} | } |
return $this->createQueryBuilder('e') | return $this->createQueryBuilder('e') | ||||
->where(':newsletter MEMBER OF e.newsletters') | ->where(':newsletter MEMBER OF e.newsletters') | ||||
->setParameter('newsletter', $newsletter->getId()) | ->setParameter('newsletter', $newsletter->getId()) | ||||
->andWhere('e.enabled = 1') | |||||
->innerJoin('e.userMerchants', 'um') | ->innerJoin('e.userMerchants', 'um') | ||||
->andWhere('um.merchant = :merchant AND um.active = 1') | ->andWhere('um.merchant = :merchant AND um.active = 1') | ||||
->setParameter('merchant', $newsletter->getMerchant()) | ->setParameter('merchant', $newsletter->getMerchant()) | ||||
return $qb->getQuery()->getResult(); | return $qb->getQuery()->getResult(); | ||||
} | } | ||||
public function findByTicketTypesNotification($ticketType){ | |||||
$qb = $this->createQueryBuilder('u') | |||||
->where('u.ticketTypesNotification LIKE :ticketType') | |||||
->setParameter('ticketType', '%"' . $ticketType . '"%'); | |||||
return $qb->getQuery()->getResult(); | |||||
} | |||||
} | } |
default: Édition | default: Édition | ||||
Général: Général | Général: Général | ||||
Adresse: Adresse | Adresse: Adresse | ||||
Supplier: | |||||
contact: Personne de contact | |||||
Reminder: | Reminder: | ||||
title: Pense bête | title: Pense bête | ||||
list: Pense bêtes | list: Pense bêtes | ||||
emailFromName: "Email (From) : nom" | emailFromName: "Email (From) : nom" | ||||
emailSubjectPrefix: "Email : préfixe" | emailSubjectPrefix: "Email : préfixe" | ||||
emailContact: Email (contact) | emailContact: Email (contact) | ||||
emailFromPurchaseOrder: "Email (From) : bons de commande" | |||||
order: Commande | order: Commande | ||||
subject: Sujet | subject: Sujet | ||||
metaTitle: Meta title | metaTitle: Meta title | ||||
codeHelp: Code utilisé pour retrouver l'ambassade dans le tunnel de commande (Non sensible à la casse) | codeHelp: Code utilisé pour retrouver l'ambassade dans le tunnel de commande (Non sensible à la casse) | ||||
Supplier: | Supplier: | ||||
user: Utilisateur lié | user: Utilisateur lié | ||||
contactName: Personne de contact (Nom et prénom) | |||||
contactPhone: Téléphone | |||||
contactEmail: Email de la personne de contact | |||||
displayTotalWeightInPurchaseOrder: Afficher le poids total dans les bons de commande | |||||
ProductFamily: | ProductFamily: | ||||
taxRateInherited: Utiliser la TVA par défaut | taxRateInherited: Utiliser la TVA par défaut | ||||
activeProducts: Activer les déclinaisons | activeProducts: Activer les déclinaisons | ||||
quantityProduct: Quantité (en rapport à l'unité) | quantityProduct: Quantité (en rapport à l'unité) | ||||
unit: Unité | unit: Unité | ||||
redeliverySupplierShort: Erreur producteur | redeliverySupplierShort: Erreur producteur | ||||
redeliverySupplier: Erreur producteur (Aura un prix à 0€ dans le prohain bon de commande producteur - vous devez cocher à recommander) | |||||
redeliverySupplierMistake: Erreur producteur (Aura un prix à 0€ dans le prohain bon de commande producteur - vous devez cocher à recommander) | |||||
redeliverySupplierOrderShort: À recommander au producteur | redeliverySupplierOrderShort: À recommander au producteur | ||||
redeliverySupplierOrder: À recommander au producteur (Sera affiché dans le prohain bon de commande producteur) | redeliverySupplierOrder: À recommander au producteur (Sera affiché dans le prohain bon de commande producteur) | ||||
deliveryType: Type de livraison | deliveryType: Type de livraison |
<div class="col-6"> | <div class="col-6"> | ||||
{{ form_row(form.firstname) }} | {{ form_row(form.firstname) }} | ||||
</div> | </div> | ||||
<div class="col-12"> | |||||
{{ form_row(form.address) }} | |||||
</div> | |||||
<div class="col-6"> | <div class="col-6"> | ||||
{{ form_row(form.zip) }} | {{ form_row(form.zip) }} | ||||
</div> | </div> | ||||
<div class="col-6"> | <div class="col-6"> | ||||
{{ form_row(form.city) }} | {{ form_row(form.city) }} | ||||
</div> | </div> | ||||
<div class="col-12"> | |||||
{{ form_row(form.address) }} | |||||
</div> | |||||
<div class="col-12"> | <div class="col-12"> | ||||
{{ form_row(form.phone) }} | {{ form_row(form.phone) }} | ||||
</div> | </div> | ||||
<div class="col-6"> | <div class="col-6"> | ||||
{{ form_row(form.longitude) }} | {{ form_row(form.longitude) }} | ||||
</div> | </div> | ||||
<div class="col-6"> | |||||
{{ form_row(form.latitudeOverride) }} | |||||
</div> | |||||
<div class="col-6"> | |||||
{{ form_row(form.longitudeOverride) }} | |||||
</div> | |||||
{{ form_row(form.country) }} | {{ form_row(form.country) }} | ||||
<div class="row"> | <div class="row"> | ||||
<div class="col-8"> | <div class="col-8"> | ||||
{{ macros.card_start('Merchant.delivery','light') }} | {{ macros.card_start('Merchant.delivery','light') }} | ||||
<div class="col-12"> | |||||
{{ form_row(form.merchantConfigs['image-zones']) }} | |||||
</div> | |||||
<div class="col-12"> | |||||
{{ form_row(form.merchantConfigs['downtime-per-customer']) }} | |||||
</div> | |||||
{% if form.merchantConfigs['image-zones'] is defined %} | |||||
<div class="col-12"> | |||||
{{ form_row(form.merchantConfigs['image-zones']) }} | |||||
</div> | |||||
{% endif %} | |||||
{% if form.merchantConfigs['downtime-per-customer'] is defined %} | |||||
<div class="col-12"> | |||||
{{ form_row(form.merchantConfigs['downtime-per-customer']) }} | |||||
</div> | |||||
{% endif %} | |||||
<div class="col-12"> | <div class="col-12"> | ||||
{{ form_row(form.deliveryTaxRate) }} | {{ form_row(form.deliveryTaxRate) }} | ||||
</div> | </div> | ||||
<div class="col-12"> | |||||
{{ form_row(form.merchantConfigs['bike-delivery']) }} | |||||
</div> | |||||
<div class="col-12"> | |||||
{{ form_row(form.merchantConfigs['bike-delivery-url-map']) }} | |||||
</div> | |||||
{% if form.merchantConfigs['bike-delivery-url-map'] is defined %} | |||||
<div class="col-12"> | |||||
{{ form_row(form.merchantConfigs['bike-delivery-url-map']) }} | |||||
</div> | |||||
{% endif %} | |||||
{{ macros.card_end() }} | {{ macros.card_end() }} | ||||
</div> | </div> | ||||
</div> | </div> |
<div class="col-12"> | <div class="col-12"> | ||||
{{ form_row(form.merchantConfigs['email-contact']) }} | {{ form_row(form.merchantConfigs['email-contact']) }} | ||||
</div> | </div> | ||||
<div class="col-12"> | |||||
{{ form_row(form.merchantConfigs['email-from-purchase-order']) }} | |||||
</div> | |||||
{{ macros.card_end() }} | {{ macros.card_end() }} | ||||
</div> | </div> | ||||
</div> | </div> |
protected $convertEncoding ; | protected $convertEncoding ; | ||||
protected $fromEncoding ; | protected $fromEncoding ; | ||||
protected $toEncoding ; | protected $toEncoding ; | ||||
protected $delimiter ; | |||||
public function __construct() | public function __construct() | ||||
{ | { | ||||
$this->convertEncoding = false ; | $this->convertEncoding = false ; | ||||
$this->fromEncoding = 'UTF-8' ; | $this->fromEncoding = 'UTF-8' ; | ||||
$this->toEncoding = 'ISO-8859-1' ; | $this->toEncoding = 'ISO-8859-1' ; | ||||
$this->delimiter = ';' ; | |||||
} | } | ||||
public function enableConvertEncoding($toEncoding, $fromEncoding = null) | public function enableConvertEncoding($toEncoding, $fromEncoding = null) | ||||
public function encode($value) | public function encode($value) | ||||
{ | { | ||||
if($this->convertEncoding) { | if($this->convertEncoding) { | ||||
return mb_convert_encoding($value, $this->toEncoding, $this->fromEncoding) ; | |||||
return mb_convert_encoding( | |||||
$value, | |||||
$this->toEncoding, | |||||
$this->fromEncoding) ; | |||||
} | } | ||||
return $value ; | return $value ; | ||||
$handle = fopen($path, 'w+'); | $handle = fopen($path, 'w+'); | ||||
foreach ($this->arrayToExport as $line) { | foreach ($this->arrayToExport as $line) { | ||||
fputcsv($handle, $line, ';', ' '); | |||||
fputcsv($handle, $line, $this->getDelimiter(), "\""); | |||||
} | } | ||||
fclose($handle); | fclose($handle); | ||||
} | } | ||||
} | } | ||||
public function getDelimiter() | |||||
{ | |||||
return $this->delimiter ; | |||||
} | |||||
if(isset($params['merchant'])) { | if(isset($params['merchant'])) { | ||||
$document->setMerchant($params['merchant']) ; | $document->setMerchant($params['merchant']) ; | ||||
} | } | ||||
else { | |||||
elseif(isset($params['order_shops'])) { | |||||
$document->setMerchant($params['order_shops'][0]->getMerchant()) ; | $document->setMerchant($params['order_shops'][0]->getMerchant()) ; | ||||
} | } | ||||
foreach($params['order_shops'] as $orderShop) { | |||||
$document->addOrderShop($orderShop) ; | |||||
if(isset($params['order_shops'])) { | |||||
foreach ($params['order_shops'] as $orderShop) { | |||||
$document->addOrderShop($orderShop); | |||||
} | |||||
} | } | ||||
$document->setType($params['type']) ; | $document->setType($params['type']) ; |
$merchantCurrent = $this->merchantUtils->getMerchantCurrent(); | $merchantCurrent = $this->merchantUtils->getMerchantCurrent(); | ||||
$merchantConfigEmailFrom = $merchantCurrent->getMerchantConfig('email-from'); | $merchantConfigEmailFrom = $merchantCurrent->getMerchantConfig('email-from'); | ||||
$emailFrom = isset($params[self::FROM_EMAIL]) ? $params[self::FROM_EMAIL] : $merchantConfigEmailFrom; | |||||
$emailFrom = (isset($params[self::FROM_EMAIL]) && $params[self::FROM_EMAIL] && strlen($params[self::FROM_EMAIL])) ? $params[self::FROM_EMAIL] : $merchantConfigEmailFrom; | |||||
$merchantConfigEmailFromName = $merchantCurrent->getMerchantConfig('email-from-name'); | $merchantConfigEmailFromName = $merchantCurrent->getMerchantConfig('email-from-name'); | ||||
$emailFromName = isset($params[self::FROM_NAME]) ? $params[self::FROM_NAME] : $merchantConfigEmailFromName; | $emailFromName = isset($params[self::FROM_NAME]) ? $params[self::FROM_NAME] : $merchantConfigEmailFromName; |
<?php | <?php | ||||
namespace Lc\ShopBundle\Services\Price ; | |||||
namespace Lc\ShopBundle\Services\Price; | |||||
use Lc\ShopBundle\Context\OrderProductInterface; | use Lc\ShopBundle\Context\OrderProductInterface; | ||||
use Lc\ShopBundle\Context\OrderShopInterface; | use Lc\ShopBundle\Context\OrderShopInterface; | ||||
class PriceUtils implements PriceUtilsInterface | class PriceUtils implements PriceUtilsInterface | ||||
{ | { | ||||
protected $productPriceUtils ; | |||||
protected $orderProductPriceUtils ; | |||||
protected $orderShopPriceUtils ; | |||||
protected $productPriceUtils; | |||||
protected $orderProductPriceUtils; | |||||
protected $orderShopPriceUtils; | |||||
public function __construct(ProductPriceUtils $productPriceUtils, OrderProductPriceUtils $orderProductPriceUtils, OrderShopPriceUtilsInterface $orderShopPriceUtils) | public function __construct(ProductPriceUtils $productPriceUtils, OrderProductPriceUtils $orderProductPriceUtils, OrderShopPriceUtilsInterface $orderShopPriceUtils) | ||||
{ | { | ||||
$this->productPriceUtils = $productPriceUtils ; | |||||
$this->orderProductPriceUtils = $orderProductPriceUtils ; | |||||
$this->orderShopPriceUtils = $orderShopPriceUtils ; | |||||
$this->productPriceUtils = $productPriceUtils; | |||||
$this->orderProductPriceUtils = $orderProductPriceUtils; | |||||
$this->orderShopPriceUtils = $orderShopPriceUtils; | |||||
} | } | ||||
public function __call($name, $arguments) | public function __call($name, $arguments) | ||||
{ | { | ||||
$entity = $arguments[0] ; | |||||
$service = '' ; | |||||
if (strpos($name, 'apply') === false) { | |||||
$entity = $arguments[0]; | |||||
$service = ''; | |||||
if($entity instanceof ProductPropertyInterface) { | |||||
$service = 'productPriceUtils' ; | |||||
} | |||||
if($entity instanceof OrderProductInterface) { | |||||
$service = 'orderProductPriceUtils' ; | |||||
} | |||||
if($entity instanceof OrderShopInterface || is_array($entity)) { | |||||
$service = 'orderShopPriceUtils' ; | |||||
} | |||||
if(strlen($service) && $entity && method_exists($this->$service, $name)) { | |||||
if(isset($arguments[1]) && isset($arguments[2]) && isset($arguments[3])) { | |||||
return $this->$service->$name($entity, $arguments[1], $arguments[2], $arguments[3]) ; | |||||
} | |||||
elseif(isset($arguments[1]) && isset($arguments[2])) { | |||||
return $this->$service->$name($entity, $arguments[1], $arguments[2]) ; | |||||
} | |||||
elseif(isset($arguments[1])) { | |||||
return $this->$service->$name($entity, $arguments[1]) ; | |||||
if ($entity instanceof ProductPropertyInterface) { | |||||
$service = 'productPriceUtils'; | |||||
} | } | ||||
else { | |||||
return $this->$service->$name($entity) ; | |||||
if ($entity instanceof OrderProductInterface) { | |||||
$service = 'orderProductPriceUtils'; | |||||
} | } | ||||
} | |||||
else { | |||||
if(!strlen($service)) { | |||||
throw new \ErrorException("PriceUtils : le type d'entité n'est pas géré.") ; | |||||
if ($entity instanceof OrderShopInterface || is_array($entity)) { | |||||
$service = 'orderShopPriceUtils'; | |||||
} | } | ||||
else { | |||||
if(!method_exists($this->$service, $name)) { | |||||
throw new \ErrorException("PriceUtils : la méthode ".$name." du service ".$service." n'existe pas.") ; | |||||
if (strlen($service) && $entity && method_exists($this->$service, $name)) { | |||||
if (isset($arguments[1]) && isset($arguments[2]) && isset($arguments[3])) { | |||||
return $this->$service->$name($entity, $arguments[1], $arguments[2], $arguments[3]); | |||||
} elseif (isset($arguments[1]) && isset($arguments[2])) { | |||||
return $this->$service->$name($entity, $arguments[1], $arguments[2]); | |||||
} elseif (isset($arguments[1])) { | |||||
return $this->$service->$name($entity, $arguments[1]); | |||||
} else { | |||||
return $this->$service->$name($entity); | |||||
} | |||||
} else { | |||||
if (!strlen($service)) { | |||||
throw new \ErrorException("PriceUtils : le type d'entité n'est pas géré."); | |||||
} else { | |||||
if (!method_exists($this->$service, $name)) { | |||||
throw new \ErrorException("PriceUtils : la méthode " . $name . " du service " . $service . " n'existe pas."); | |||||
} | |||||
} | } | ||||
} | } | ||||
} | |||||
return false ; | |||||
return false; | |||||
} | |||||
} | } | ||||
} | |||||
} |
use Lc\ShopBundle\Context\OrderShopInterface; | use Lc\ShopBundle\Context\OrderShopInterface; | ||||
use Lc\ShopBundle\Context\TicketInterface; | use Lc\ShopBundle\Context\TicketInterface; | ||||
use Lc\ShopBundle\Context\TicketMessageInterface; | use Lc\ShopBundle\Context\TicketMessageInterface; | ||||
use Lc\ShopBundle\Context\UserInterface; | |||||
use Lc\ShopBundle\Model\Ticket; | use Lc\ShopBundle\Model\Ticket; | ||||
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface; | |||||
class TicketUtils | class TicketUtils | ||||
{ | { | ||||
protected $em ; | protected $em ; | ||||
protected $merchantUtils ; | protected $merchantUtils ; | ||||
protected $mailUtils ; | protected $mailUtils ; | ||||
protected $authorizationChecker ; | |||||
public function __construct(EntityManagerInterface $em, MerchantUtilsInterface $merchantUtils, MailUtils $mailUtils) | |||||
public function __construct(EntityManagerInterface $em, MerchantUtilsInterface $merchantUtils, MailUtils $mailUtils, AuthorizationCheckerInterface $authorizationChecker) | |||||
{ | { | ||||
$this->em = $em ; | $this->em = $em ; | ||||
$this->merchantUtils = $merchantUtils ; | $this->merchantUtils = $merchantUtils ; | ||||
$this->mailUtils = $mailUtils ; | $this->mailUtils = $mailUtils ; | ||||
$this->authorizationChecker = $authorizationChecker ; | |||||
} | } | ||||
public function createTicket($params): TicketInterface | public function createTicket($params): TicketInterface | ||||
], | ], | ||||
]) ; | ]) ; | ||||
$this->notifyAdmin($ticket, $ticketMessage); | |||||
return $ticket ; | return $ticket ; | ||||
} | } | ||||
return $ticketMessage ; | return $ticketMessage ; | ||||
} | } | ||||
public function notifyAdmin($ticket, $ticketMessage){ | |||||
$userRepo = $this->em->getRepository(UserInterface::class); | |||||
$usersToNotify = $userRepo->findByTicketTypesNotification($ticket->getType()); | |||||
foreach ($usersToNotify as $userToNotify){ | |||||
if($this->authorizationChecker->isGranted('ROLE_ADMIN', $userToNotify)){ | |||||
// envoi email au client | |||||
$this->mailUtils->send([ | |||||
MailUtils::SUBJECT => 'Nouveau ticket sur placedulocal', | |||||
MailUtils::TO_EMAIL => $userToNotify->getEmail(), | |||||
MailUtils::CONTENT_TEMPLATE => 'mail/ticket-notification', | |||||
MailUtils::CONTENT_DATA => [ | |||||
'firstname' => $userToNotify->getFirstname(), | |||||
'ticket' => $ticket, | |||||
'ticketMessage' => $ticketMessage | |||||
], | |||||
]) ; | |||||
} | |||||
} | |||||
} | |||||
} | } | ||||
namespace Lc\ShopBundle\Services ; | namespace Lc\ShopBundle\Services ; | ||||
use Lc\ShopBundle\Context\DeliveryUtilsInterface; | use Lc\ShopBundle\Context\DeliveryUtilsInterface; | ||||
use Lc\ShopBundle\Context\DocumentUtilsInterface; | |||||
use Lc\ShopBundle\Context\MerchantUtilsInterface; | use Lc\ShopBundle\Context\MerchantUtilsInterface; | ||||
use Lc\ShopBundle\Context\OrderUtilsInterface; | use Lc\ShopBundle\Context\OrderUtilsInterface; | ||||
use Lc\ShopBundle\Context\PriceUtilsInterface; | use Lc\ShopBundle\Context\PriceUtilsInterface; | ||||
PriceUtilsInterface $priceUtils, | PriceUtilsInterface $priceUtils, | ||||
DeliveryUtilsInterface $deliveryUtils, | DeliveryUtilsInterface $deliveryUtils, | ||||
CreditUtils $creditUtils, | CreditUtils $creditUtils, | ||||
DocumentUtils $documentUtils, | |||||
DocumentUtilsInterface $documentUtils, | |||||
MailUtils $mailUtils, | MailUtils $mailUtils, | ||||
TicketUtils $ticketUtils, | TicketUtils $ticketUtils, | ||||
PointLocationUtils $pointLocationUtils, | PointLocationUtils $pointLocationUtils, | ||||
return $this->creditUtils ; | return $this->creditUtils ; | ||||
} | } | ||||
public function getDocumentUtils(): DocumentUtils | |||||
public function getDocumentUtils(): DocumentUtilsInterface | |||||
{ | { | ||||
return $this->documentUtils ; | return $this->documentUtils ; | ||||
} | } |
use Lc\ShopBundle\Context\ProductFamilyInterface; | use Lc\ShopBundle\Context\ProductFamilyInterface; | ||||
use Lc\ShopBundle\Context\ProductFamilyUtilsInterface; | use Lc\ShopBundle\Context\ProductFamilyUtilsInterface; | ||||
use Lc\ShopBundle\Context\ReminderInterface; | use Lc\ShopBundle\Context\ReminderInterface; | ||||
use Lc\ShopBundle\Context\SluggableInterface; | |||||
use Lc\ShopBundle\Context\TaxRateInterface; | use Lc\ShopBundle\Context\TaxRateInterface; | ||||
use Lc\ShopBundle\Context\UnitInterface; | use Lc\ShopBundle\Context\UnitInterface; | ||||
use Lc\ShopBundle\Context\UserInterface; | use Lc\ShopBundle\Context\UserInterface; | ||||
$this->em->persist($newAddress); | $this->em->persist($newAddress); | ||||
} | } | ||||
if($newEntity instanceof SluggableInterface){ | |||||
$newEntity->setTitle($newEntity->getTitle().' '); | |||||
} | |||||
$this->em->persist($newEntity); | $this->em->persist($newEntity); | ||||
if($flush){ | if($flush){ | ||||
$this->em->flush(); | $this->em->flush(); |
use Symfony\Component\Form\FormFactoryInterface; | use Symfony\Component\Form\FormFactoryInterface; | ||||
use Symfony\Component\HttpFoundation\RequestStack; | use Symfony\Component\HttpFoundation\RequestStack; | ||||
use Symfony\Component\HttpKernel\KernelInterface; | use Symfony\Component\HttpKernel\KernelInterface; | ||||
use Symfony\Component\Routing\RouterInterface; | |||||
use Symfony\Component\Security\Core\Security; | use Symfony\Component\Security\Core\Security; | ||||
use Twig\Extension\AbstractExtension; | use Twig\Extension\AbstractExtension; | ||||
use Twig\TwigFilter; | use Twig\TwigFilter; | ||||
protected $liipCacheHelper; | protected $liipCacheHelper; | ||||
protected $parameterBag; | protected $parameterBag; | ||||
protected $kernel; | protected $kernel; | ||||
protected $router ; | |||||
public function __construct(EntityManagerInterface $em, Security $security, MerchantUtilsInterface $merchantUtils, | public function __construct(EntityManagerInterface $em, Security $security, MerchantUtilsInterface $merchantUtils, | ||||
FormFactoryInterface $formFactory, RequestStack $requestStack, ParameterBagInterface $parameterBag, KernelInterface $kernel) | |||||
FormFactoryInterface $formFactory, RequestStack $requestStack, ParameterBagInterface $parameterBag, | |||||
KernelInterface $kernel, RouterInterface $router) | |||||
{ | { | ||||
$this->em = $em; | $this->em = $em; | ||||
$this->security = $security; | $this->security = $security; | ||||
$this->productFamilyRepository = $this->em->getRepository($this->em->getClassMetadata(ProductFamilyInterface::class)->getName()); | $this->productFamilyRepository = $this->em->getRepository($this->em->getClassMetadata(ProductFamilyInterface::class)->getName()); | ||||
$this->parameterBag = $parameterBag; | $this->parameterBag = $parameterBag; | ||||
$this->kernel = $kernel; | $this->kernel = $kernel; | ||||
$this->router = $router ; | |||||
} | } | ||||
public function getFunctions() | public function getFunctions() |