Bläddra i källkod

Merge branch 'develop'

master
Guillaume 4 år sedan
förälder
incheckning
c967c99574
18 ändrade filer med 119 tillägg och 75 borttagningar
  1. +8
    -0
      ShopBundle/Context/DocumentUtilsInterface.php
  2. +1
    -3
      ShopBundle/Controller/Backend/AdminController.php
  3. +5
    -1
      ShopBundle/Controller/Backend/DocumentController.php
  4. +1
    -0
      ShopBundle/EventSubscriber/EditEventSubscriber.php
  5. +1
    -1
      ShopBundle/Form/Backend/Common/AddressType.php
  6. +2
    -0
      ShopBundle/Model/Document.php
  7. +1
    -0
      ShopBundle/Repository/OrderShopRepository.php
  8. +0
    -1
      ShopBundle/Repository/UserRepository.php
  9. +9
    -1
      ShopBundle/Resources/translations/lcshop.fr.yaml
  10. +9
    -3
      ShopBundle/Resources/views/backend/default/block/form_address.html.twig
  11. +15
    -12
      ShopBundle/Resources/views/backend/merchant/panel_delivery.html.twig
  12. +3
    -0
      ShopBundle/Resources/views/backend/merchant/panel_email.html.twig
  13. +11
    -4
      ShopBundle/Services/CsvGenerator.php
  14. +5
    -3
      ShopBundle/Services/DocumentUtils.php
  15. +1
    -1
      ShopBundle/Services/MailUtils.php
  16. +39
    -42
      ShopBundle/Services/Price/PriceUtils.php
  17. +3
    -2
      ShopBundle/Services/UtilsManager.php
  18. +5
    -1
      ShopBundle/Twig/FrontendTwigExtension.php

+ 8
- 0
ShopBundle/Context/DocumentUtilsInterface.php Visa fil

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

namespace Lc\ShopBundle\Context ;

interface DocumentUtilsInterface
{

}

+ 1
- 3
ShopBundle/Controller/Backend/AdminController.php Visa fil

@@ -61,10 +61,8 @@ class AdminController extends EasyAdminController
$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'];
$options['action'] = $this->generateUrl('easyadmin', array(
'action' => $action,

+ 5
- 1
ShopBundle/Controller/Backend/DocumentController.php Visa fil

@@ -10,6 +10,8 @@ use Lc\ShopBundle\Context\OrderUtilsInterface;
use Lc\ShopBundle\Services\Utils;
use Lc\ShopBundle\Services\UtilsManager;
use Mailjet\MailjetSwiftMailer\SwiftMailer\MailjetTransport;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
use Symfony\Component\HttpFoundation\StreamedResponse;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\Security\Core\Security;
use Symfony\Contracts\Translation\TranslatorInterface;
@@ -36,7 +38,9 @@ class DocumentController extends AdminController
}

if($document && $orderShop) {
$this->orderUtils->generateDocumentInvoiceOrderShop($orderShop, 'download') ;
return new StreamedResponse(function () use ($orderShop) {
$this->orderUtils->generateDocumentInvoiceOrderShop($orderShop, 'download') ;
});
}
else {
throw new NotFoundHttpException('Document introuvable') ;

+ 1
- 0
ShopBundle/EventSubscriber/EditEventSubscriber.php Visa fil

@@ -57,6 +57,7 @@ class EditEventSubscriber implements EventSubscriberInterface

public function updateCommonProperty(GenericEvent $event)
{

/* $this->setUpdated($entity);
$this->setAddressCreatedBy($entity) ;*/
}

+ 1
- 1
ShopBundle/Form/Backend/Common/AddressType.php Visa fil

@@ -48,9 +48,9 @@ class AddressType extends AbstractType
])
->add('lastname', TextType::class, ['required' => false])
->add('firstname', TextType::class, ['required' => false])
->add('address', TextareaType::class)
->add('zip', TextType::class)
->add('city', TextType::class)
->add('address', TextType::class)
->add('phone', CollectionType::class, [
'allow_add'=>true,
'allow_delete'=>true,

+ 2
- 0
ShopBundle/Model/Document.php Visa fil

@@ -73,9 +73,11 @@ abstract class Document extends AbstractDocumentEntity implements FilterMerchant

/**
* @ORM\ManyToMany(targetEntity="Lc\ShopBundle\Context\OrderShopInterface", mappedBy="documents")
* @ORM\JoinColumn(nullable=true)
*/
protected $orderShops;


/**
* @ORM\OneToOne(targetEntity="Lc\ShopBundle\Context\OrderRefundInterface", mappedBy="document", cascade={"persist", "remove"})
*/

+ 1
- 0
ShopBundle/Repository/OrderShopRepository.php Visa fil

@@ -300,6 +300,7 @@ class OrderShopRepository extends BaseRepository implements DefaultRepositoryInt
$query->select('SUM(orderProduct.quantityOrder) as quantity');

$result = $query->getQuery()->getOneOrNullResult();

return $result['quantity'];

}

+ 0
- 1
ShopBundle/Repository/UserRepository.php Visa fil

@@ -32,7 +32,6 @@ class UserRepository extends BaseRepository implements DefaultRepositoryInterfac
return $this->createQueryBuilder('e')
->where(':newsletter MEMBER OF e.newsletters')
->setParameter('newsletter', $newsletter->getId())
->andWhere('e.enabled = 1')
->innerJoin('e.userMerchants', 'um')
->andWhere('um.merchant = :merchant AND um.active = 1')
->setParameter('merchant', $newsletter->getMerchant())

+ 9
- 1
ShopBundle/Resources/translations/lcshop.fr.yaml Visa fil

@@ -21,6 +21,8 @@ group:
default: Édition
Général: Général
Adresse: Adresse
Supplier:
contact: Personne de contact
Reminder:
title: Pense bête
list: Pense bêtes
@@ -265,6 +267,7 @@ field:
emailFromName: "Email (From) : nom"
emailSubjectPrefix: "Email : préfixe"
emailContact: Email (contact)
emailFromPurchaseOrder: "Email (From) : bons de commande"
order: Commande
subject: Sujet
metaTitle: Meta title
@@ -278,6 +281,11 @@ field:
codeHelp: Code utilisé pour retrouver l'ambassade dans le tunnel de commande (Non sensible à la casse)
Supplier:
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:
taxRateInherited: Utiliser la TVA par défaut
activeProducts: Activer les déclinaisons
@@ -406,7 +414,7 @@ field:
quantityProduct: Quantité (en rapport à l'unité)
unit: Unité
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
redeliverySupplierOrder: À recommander au producteur (Sera affiché dans le prohain bon de commande producteur)
deliveryType: Type de livraison

+ 9
- 3
ShopBundle/Resources/views/backend/default/block/form_address.html.twig Visa fil

@@ -21,15 +21,15 @@
<div class="col-6">
{{ form_row(form.firstname) }}
</div>
<div class="col-12">
{{ form_row(form.address) }}
</div>
<div class="col-6">
{{ form_row(form.zip) }}
</div>
<div class="col-6">
{{ form_row(form.city) }}
</div>
<div class="col-12">
{{ form_row(form.address) }}
</div>
<div class="col-12">
{{ form_row(form.phone) }}
</div>
@@ -57,6 +57,12 @@
<div class="col-6">
{{ form_row(form.longitude) }}
</div>
<div class="col-6">
{{ form_row(form.latitudeOverride) }}
</div>
<div class="col-6">
{{ form_row(form.longitudeOverride) }}
</div>

{{ form_row(form.country) }}


+ 15
- 12
ShopBundle/Resources/views/backend/merchant/panel_delivery.html.twig Visa fil

@@ -5,21 +5,24 @@
<div class="row">
<div class="col-8">
{{ 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">
{{ form_row(form.deliveryTaxRate) }}
</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() }}
</div>
</div>

+ 3
- 0
ShopBundle/Resources/views/backend/merchant/panel_email.html.twig Visa fil

@@ -18,6 +18,9 @@
<div class="col-12">
{{ form_row(form.merchantConfigs['email-contact']) }}
</div>
<div class="col-12">
{{ form_row(form.merchantConfigs['email-from-purchase-order']) }}
</div>
{{ macros.card_end() }}
</div>
</div>

+ 11
- 4
ShopBundle/Services/CsvGenerator.php Visa fil

@@ -29,7 +29,7 @@ class CsvGenerator
protected $convertEncoding ;
protected $fromEncoding ;
protected $toEncoding ;
protected $delimiter ;

public function __construct()
{
@@ -38,6 +38,7 @@ class CsvGenerator
$this->convertEncoding = false ;
$this->fromEncoding = 'UTF-8' ;
$this->toEncoding = 'ISO-8859-1' ;
$this->delimiter = ';' ;
}

public function enableConvertEncoding($toEncoding, $fromEncoding = null)
@@ -53,7 +54,10 @@ class CsvGenerator
public function encode($value)
{
if($this->convertEncoding) {
return mb_convert_encoding($value, $this->toEncoding, $this->fromEncoding) ;
return mb_convert_encoding(
$value,
$this->toEncoding,
$this->fromEncoding) ;
}

return $value ;
@@ -119,7 +123,7 @@ class CsvGenerator
$handle = fopen($path, 'w+');

foreach ($this->arrayToExport as $line) {
fputcsv($handle, $line, ';', ' ');
fputcsv($handle, $line, $this->getDelimiter(), "\"");
}
fclose($handle);
}
@@ -143,7 +147,10 @@ class CsvGenerator
}



public function getDelimiter()
{
return $this->delimiter ;
}




+ 5
- 3
ShopBundle/Services/DocumentUtils.php Visa fil

@@ -67,12 +67,14 @@ class DocumentUtils
if(isset($params['merchant'])) {
$document->setMerchant($params['merchant']) ;
}
else {
elseif(isset($params['order_shops'])) {
$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']) ;

+ 1
- 1
ShopBundle/Services/MailUtils.php Visa fil

@@ -41,7 +41,7 @@ class MailUtils
$merchantCurrent = $this->merchantUtils->getMerchantCurrent();

$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');
$emailFromName = isset($params[self::FROM_NAME]) ? $params[self::FROM_NAME] : $merchantConfigEmailFromName;

+ 39
- 42
ShopBundle/Services/Price/PriceUtils.php Visa fil

@@ -1,6 +1,6 @@
<?php

namespace Lc\ShopBundle\Services\Price ;
namespace Lc\ShopBundle\Services\Price;

use Lc\ShopBundle\Context\OrderProductInterface;
use Lc\ShopBundle\Context\OrderShopInterface;
@@ -10,59 +10,56 @@ use Lc\ShopBundle\Context\ProductPropertyInterface;

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)
{
$this->productPriceUtils = $productPriceUtils ;
$this->orderProductPriceUtils = $orderProductPriceUtils ;
$this->orderShopPriceUtils = $orderShopPriceUtils ;
$this->productPriceUtils = $productPriceUtils;
$this->orderProductPriceUtils = $orderProductPriceUtils;
$this->orderShopPriceUtils = $orderShopPriceUtils;
}

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

+ 3
- 2
ShopBundle/Services/UtilsManager.php Visa fil

@@ -3,6 +3,7 @@
namespace Lc\ShopBundle\Services ;

use Lc\ShopBundle\Context\DeliveryUtilsInterface;
use Lc\ShopBundle\Context\DocumentUtilsInterface;
use Lc\ShopBundle\Context\MerchantUtilsInterface;
use Lc\ShopBundle\Context\OrderUtilsInterface;
use Lc\ShopBundle\Context\PriceUtilsInterface;
@@ -35,7 +36,7 @@ class UtilsManager
PriceUtilsInterface $priceUtils,
DeliveryUtilsInterface $deliveryUtils,
CreditUtils $creditUtils,
DocumentUtils $documentUtils,
DocumentUtilsInterface $documentUtils,
MailUtils $mailUtils,
TicketUtils $ticketUtils,
PointLocationUtils $pointLocationUtils,
@@ -97,7 +98,7 @@ class UtilsManager
return $this->creditUtils ;
}

public function getDocumentUtils(): DocumentUtils
public function getDocumentUtils(): DocumentUtilsInterface
{
return $this->documentUtils ;
}

+ 5
- 1
ShopBundle/Twig/FrontendTwigExtension.php Visa fil

@@ -13,6 +13,7 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpKernel\KernelInterface;
use Symfony\Component\Routing\RouterInterface;
use Symfony\Component\Security\Core\Security;
use Twig\Extension\AbstractExtension;
use Twig\TwigFilter;
@@ -31,9 +32,11 @@ class FrontendTwigExtension extends AbstractExtension
protected $liipCacheHelper;
protected $parameterBag;
protected $kernel;
protected $router ;

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->security = $security;
@@ -45,6 +48,7 @@ class FrontendTwigExtension extends AbstractExtension
$this->productFamilyRepository = $this->em->getRepository($this->em->getClassMetadata(ProductFamilyInterface::class)->getName());
$this->parameterBag = $parameterBag;
$this->kernel = $kernel;
$this->router = $router ;
}

public function getFunctions()

Laddar…
Avbryt
Spara