Browse Source

Merge branch 'develop'

master
Guillaume 4 years ago
parent
commit
c967c99574
18 changed files with 119 additions and 75 deletions
  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 View File

<?php

namespace Lc\ShopBundle\Context ;

interface DocumentUtilsInterface
{

}

+ 1
- 3
ShopBundle/Controller/Backend/AdminController.php View File

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

+ 5
- 1
ShopBundle/Controller/Backend/DocumentController.php View File

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') ;

+ 1
- 0
ShopBundle/EventSubscriber/EditEventSubscriber.php View File



public function updateCommonProperty(GenericEvent $event) public function updateCommonProperty(GenericEvent $event)
{ {

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

+ 1
- 1
ShopBundle/Form/Backend/Common/AddressType.php View File

]) ])
->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,

+ 2
- 0
ShopBundle/Model/Document.php View File



/** /**
* @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"})
*/ */

+ 1
- 0
ShopBundle/Repository/OrderShopRepository.php View File

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


} }

+ 0
- 1
ShopBundle/Repository/UserRepository.php View File

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())

+ 9
- 1
ShopBundle/Resources/translations/lcshop.fr.yaml View File

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

+ 9
- 3
ShopBundle/Resources/views/backend/default/block/form_address.html.twig View File

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



+ 15
- 12
ShopBundle/Resources/views/backend/merchant/panel_delivery.html.twig View File

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

+ 3
- 0
ShopBundle/Resources/views/backend/merchant/panel_email.html.twig View File

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

+ 11
- 4
ShopBundle/Services/CsvGenerator.php View File

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







+ 5
- 3
ShopBundle/Services/DocumentUtils.php View File

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

+ 1
- 1
ShopBundle/Services/MailUtils.php View File

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

+ 39
- 42
ShopBundle/Services/Price/PriceUtils.php View File

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

+ 3
- 2
ShopBundle/Services/UtilsManager.php View File

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

+ 5
- 1
ShopBundle/Twig/FrontendTwigExtension.php View File

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()

Loading…
Cancel
Save