Browse Source

Merge branch 'develop'

master
Fab 4 years ago
parent
commit
24e6c7831a
20 changed files with 180 additions and 58 deletions
  1. +8
    -0
      ShopBundle/Context/UserUtilsInterface.php
  2. +3
    -1
      ShopBundle/Model/Address.php
  3. +1
    -1
      ShopBundle/Model/SluggableTrait.php
  4. +14
    -3
      ShopBundle/Model/User.php
  5. +13
    -0
      ShopBundle/Repository/BaseRepository.php
  6. +2
    -2
      ShopBundle/Repository/ReductionCartRepository.php
  7. +6
    -0
      ShopBundle/Resources/translations/lcshop.fr.yaml
  8. +11
    -0
      ShopBundle/Resources/views/backend/default/block/form_address.html.twig
  9. +10
    -0
      ShopBundle/Resources/views/backend/merchant/panel_order.html.twig
  10. +18
    -0
      ShopBundle/Resources/views/backend/order/list-fields/field_hasreach.html.twig
  11. +23
    -0
      ShopBundle/Resources/views/backend/order/macros.html.twig
  12. +3
    -1
      ShopBundle/Resources/views/backend/order/show-cart.html.twig
  13. +1
    -1
      ShopBundle/Resources/views/backend/user/block_useraddress.html.twig
  14. +2
    -0
      ShopBundle/Resources/views/backend/user/edit.html.twig
  15. +11
    -0
      ShopBundle/Services/MailUtils.php
  16. +2
    -1
      ShopBundle/Services/Order/OrderUtils.php
  17. +4
    -1
      ShopBundle/Services/UserUtils.php
  18. +38
    -42
      ShopBundle/Services/Utils.php
  19. +3
    -2
      ShopBundle/Services/UtilsManager.php
  20. +7
    -3
      ShopBundle/Services/UtilsProcess.php

+ 8
- 0
ShopBundle/Context/UserUtilsInterface.php View File

<?php

namespace Lc\ShopBundle\Context;

interface UserUtilsInterface
{

}

+ 3
- 1
ShopBundle/Model/Address.php View File

namespace Lc\ShopBundle\Model; namespace Lc\ShopBundle\Model;


use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Lc\ShopBundle\Context\StatusInterface;


/** /**
* @ORM\MappedSuperclass() * @ORM\MappedSuperclass()
*/ */
abstract class Address extends AbstractEntity
abstract class Address extends AbstractEntity implements StatusInterface
{ {
use StatusTrait;


const TYPE_INDIVIDUAL = 'individual'; const TYPE_INDIVIDUAL = 'individual';
const TYPE_LEGAL_PERSON = 'legal-person'; const TYPE_LEGAL_PERSON = 'legal-person';

+ 1
- 1
ShopBundle/Model/SluggableTrait.php View File

return $this->slug; return $this->slug;
} }


public function setSlug(string $slug): self
public function setSlug(?string $slug): self
{ {
$this->slug = $slug; $this->slug = $slug;



+ 14
- 3
ShopBundle/Model/User.php View File

/** /**
* @return Collection|Address[] * @return Collection|Address[]
*/ */
public function getAddresses(): Collection
{
return $this->addresses;
public function getAddresses($status = null): Collection
{
if($status){
$addressToReturn = new ArrayCollection();
foreach ($this->addresses as $address){
if($address->getStatus() == $status) {
$addressToReturn[] = $address;
}
}
return $addressToReturn;
}else{
return $this->addresses;
}

} }


public function addAddress(Address $address): self public function addAddress(Address $address): self

+ 13
- 0
ShopBundle/Repository/BaseRepository.php View File

return parent::findOneBy($criteria, $orderBy); return parent::findOneBy($criteria, $orderBy);
} }


public function findSimilarSlug($merchant){
$qb = $this->createQueryBuilder('entity')
->select('entity.id, COUNT(entity.slug) as niche')
->andWhere('entity.status>=0')
->andWhere('entity.merchant= :merchant')
->setParameter('merchant', $merchant)

->groupBy('entity.slug')
->having('COUNT(entity.slug) >1');

return $qb->getQuery()->getResult();
}

} }

+ 2
- 2
ShopBundle/Repository/ReductionCartRepository.php View File

return ReductionCartInterface::class; return ReductionCartInterface::class;
} }


public function findOneByCode($code)
public function findByCode($code)
{ {
$query = $this->findByMerchantQuery() ; $query = $this->findByMerchantQuery() ;
$query->andWhere('e.codes LIKE :code')->setParameter('code', '%'.$code.'%') ; $query->andWhere('e.codes LIKE :code')->setParameter('code', '%'.$code.'%') ;
return $query->getQuery()->getOneOrNullResult() ;
return $query->getQuery()->getResult() ;
} }


public function getValuesOfFieldType(){ public function getValuesOfFieldType(){

+ 6
- 0
ShopBundle/Resources/translations/lcshop.fr.yaml View File

email: Email email: Email
delivery: Livraison delivery: Livraison
maintenance: Maintenance maintenance: Maintenance
Address:
listLoopBesancon: Adresses de Besançon à spécifier (lat / long)




None: Aucune valeur None: Aucune valeur
unit: Unité unit: Unité
Address: Address:
city: Commune city: Commune
statusOptions:
offline: Désactiver
online: Activer
typeOptions: typeOptions:
individual: Particulier individual: Particulier
legal-person: Professionnel legal-person: Professionnel
quantityProduct: Quantité (en rapport à l'unité) quantityProduct: Quantité (en rapport à l'unité)
unit: Unité unit: Unité
OrderShop: OrderShop:
hasReach: Étape atteinte
deliveryTrucks: Véhicules de livraison deliveryTrucks: Véhicules de livraison
createdAt: Date de création createdAt: Date de création
updatedAt: Date de modification updatedAt: Date de modification

+ 11
- 0
ShopBundle/Resources/views/backend/default/block/form_address.html.twig View File

<div class="col-12"> <div class="col-12">
{{ form_row(form.deliveryInfos) }} {{ form_row(form.deliveryInfos) }}
</div> </div>

<div class="col-12 {{ merchantUtils.getMerchantCurrent().isHubBesancon() ? '': 'hidden'}}">
{{ form_row(form.inBesanconLoop) }}
</div>

<div class="col-6"> <div class="col-6">
{{ form_row(form.latitude) }} {{ form_row(form.latitude) }}
</div> </div>
<div class="col-6"> <div class="col-6">
{{ form_row(form.longitudeOverride) }} {{ form_row(form.longitudeOverride) }}
</div> </div>
<div class="col-12">
{{ form_row(form.status) }}
<p class="callout callout-info">
Sauf si vous savez ce que ce vous faites ce champ doit toujours être "Activer"
</p>
</div>


{{ form_row(form.country) }} {{ form_row(form.country) }}



+ 10
- 0
ShopBundle/Resources/views/backend/merchant/panel_order.html.twig View File

<div class="col-6"> <div class="col-6">
{{ form_row(form.merchantConfigs['order-open-time']) }} {{ form_row(form.merchantConfigs['order-open-time']) }}
</div> </div>
{% if form.merchantConfigs['order-open-day-vip'] is defined %}
<div class="col-6">
{{ form_row(form.merchantConfigs['order-open-day-vip']) }}
</div>
{% endif %}
{% if form.merchantConfigs['order-open-time-vip'] is defined %}
<div class="col-6">
{{ form_row(form.merchantConfigs['order-open-time-vip']) }}
</div>
{% endif %}
<div class="col-6"> <div class="col-6">
{{ form_row(form.merchantConfigs['order-close-day']) }} {{ form_row(form.merchantConfigs['order-close-day']) }}
</div> </div>

+ 18
- 0
ShopBundle/Resources/views/backend/order/list-fields/field_hasreach.html.twig View File

{% if value == 1 %}
<span class="badge badge-info">
Adresse de livraison
</span>
{% elseif value == 2 %}
<span class="badge badge-warning">
Adresse de facturation
</span>
{% elseif value == 3 %}
<span class="badge badge-danger">
Page de confirmation
</span>
{% else %}
<span class="badge badge-secondary">
Aucune
</span>
{% endif %}


+ 23
- 0
ShopBundle/Resources/views/backend/order/macros.html.twig View File

{% endembed %} {% endembed %}
{% endmacro %} {% endmacro %}


{% macro box_step_reach() %}
{% embed '@LcShop/backend/default/block/embed_box.twig' %}
{% import '@LcShop/backend/order/macros.html.twig' as order_macros %}
{% trans_default_domain 'lcshop' %}
{% block class %}bg-info{% endblock %}
{% block icon %}list-ol{% endblock %}
{% block label %}Étape atteinte{% endblock %}
{% block value %}
<div v-if="order.hasReach == 1">
Adresse de livraison
</div>
<div v-if="order.hasReach == 2">
Adresse de facturation
</div>
<div v-if="order.hasReach == 3">
Page de paiement
</div>
<div v-if="order.hasReach ==null">
Aucune
</div>
{% endblock %}
{% endembed %}
{% endmacro %}




{% macro box_payments() %} {% macro box_payments() %}

+ 3
- 1
ShopBundle/Resources/views/backend/order/show-cart.html.twig View File

{{ order_macros.box_delivery_slot() }} {{ order_macros.box_delivery_slot() }}
</div> </div>
</template> </template>

<div class="col-3">
{{ order_macros.box_step_reach() }}
</div>


<div class="col-12"> <div class="col-12">
{{ macros.card_start('OrderShop.resume') }} {{ macros.card_start('OrderShop.resume') }}

+ 1
- 1
ShopBundle/Resources/views/backend/user/block_useraddress.html.twig View File

{% trans_default_domain 'lcshop' %} {% trans_default_domain 'lcshop' %}
<div class="col-6 user-address-item"> <div class="col-6 user-address-item">
{% set button = '<button type="button" data-url="'~ path('easyadmin', {"action": 'editAddressUser', 'entity': 'User', 'id': entity.id, 'addressId': address.id})~'" class="btn btn-default btn-edit-user-address" >'~ 'action.edit'|trans ~'</button>' %} {% set button = '<button type="button" data-url="'~ path('easyadmin', {"action": 'editAddressUser', 'entity': 'User', 'id': entity.id, 'addressId': address.id})~'" class="btn btn-default btn-edit-user-address" >'~ 'action.edit'|trans ~'</button>' %}
{{ macros.box_info('bg-info', 'address-card', address.summary, '', button) }}
{{ macros.box_info('bg-info', 'address-card', address.summary(true, true), '', button) }}
</div> </div>

+ 2
- 0
ShopBundle/Resources/views/backend/user/edit.html.twig View File

<div class="col-5"> <div class="col-5">
<div class="row" id="user-addresses"> <div class="row" id="user-addresses">
{% for address in entity.addresses %} {% for address in entity.addresses %}
{% if address.status >=0 %}
{% include '@LcShop/backend/user/block_useraddress.html.twig' %} {% include '@LcShop/backend/user/block_useraddress.html.twig' %}
{% endif %}
{% endfor %} {% endfor %}
</div> </div>
<button type="button" data-url="{{ path('easyadmin', {"action": 'editAddressUser', 'entity': 'User', 'id': entity.id, 'addressId': 'new'}) }}" <button type="button" data-url="{{ path('easyadmin', {"action": 'editAddressUser', 'entity': 'User', 'id': entity.id, 'addressId': 'new'}) }}"

+ 11
- 0
ShopBundle/Services/MailUtils.php View File

const SUBJECT = 'subject'; const SUBJECT = 'subject';
const SUBJECT_PREFIX = 'subject-prefix'; const SUBJECT_PREFIX = 'subject-prefix';
const TO_EMAIL = 'to-email'; const TO_EMAIL = 'to-email';
const COPY_TO = 'copy-to';
const COPY_HIDDEN_TO = 'copy-hidden-to';
const TO_NAME = 'to-name'; const TO_NAME = 'to-name';
const FROM_EMAIL = 'from-email'; const FROM_EMAIL = 'from-email';
const FROM_NAME = 'from-name'; const FROM_NAME = 'from-name';
->setBody($this->templating->render($params[self::CONTENT_TEMPLATE] . '-html.html.twig', $contentData), 'text/html') ->setBody($this->templating->render($params[self::CONTENT_TEMPLATE] . '-html.html.twig', $contentData), 'text/html')
->addPart($this->templating->render($params[self::CONTENT_TEMPLATE] . '-text.html.twig', $contentData)); ->addPart($this->templating->render($params[self::CONTENT_TEMPLATE] . '-text.html.twig', $contentData));


if (isset($params[self::COPY_TO]) && strlen($params[self::COPY_TO])) {
$message->addCc($params[self::COPY_TO]);
}

if (isset($params[self::COPY_HIDDEN_TO]) && strlen($params[self::COPY_HIDDEN_TO])) {
$message->addBcc($params[self::COPY_HIDDEN_TO]);
}


if (isset($params[self::REPLY_TO]) && strlen($params[self::REPLY_TO])) { if (isset($params[self::REPLY_TO]) && strlen($params[self::REPLY_TO])) {
$message->addReplyTo($params[self::REPLY_TO]); $message->addReplyTo($params[self::REPLY_TO]);
} }

+ 2
- 1
ShopBundle/Services/Order/OrderUtils.php View File

use Lc\ShopBundle\Context\PriceUtilsInterface; use Lc\ShopBundle\Context\PriceUtilsInterface;
use Lc\ShopBundle\Context\ProductFamilyUtilsInterface; use Lc\ShopBundle\Context\ProductFamilyUtilsInterface;
use Lc\ShopBundle\Context\ReductionCreditInterface; use Lc\ShopBundle\Context\ReductionCreditInterface;
use Lc\ShopBundle\Context\UserUtilsInterface;
use Lc\ShopBundle\Model\ProductFamily; use Lc\ShopBundle\Model\ProductFamily;
use Lc\ShopBundle\Services\CreditUtils; use Lc\ShopBundle\Services\CreditUtils;
use Lc\ShopBundle\Services\DocumentUtils; use Lc\ShopBundle\Services\DocumentUtils;
protected $creditUtils; protected $creditUtils;
protected $router; protected $router;


public function __construct(EntityManagerInterface $em, Security $security, RouterInterface $router, UserUtils $userUtils,
public function __construct(EntityManagerInterface $em, Security $security, RouterInterface $router, UserUtilsInterface $userUtils,
MerchantUtilsInterface $merchantUtils, PriceUtilsInterface $priceUtils, ProductFamilyUtilsInterface $productFamilyUtils, MerchantUtilsInterface $merchantUtils, PriceUtilsInterface $priceUtils, ProductFamilyUtilsInterface $productFamilyUtils,
DocumentUtils $documentUtils, Utils $utils, CreditUtils $creditUtils) DocumentUtils $documentUtils, Utils $utils, CreditUtils $creditUtils)
{ {

+ 4
- 1
ShopBundle/Services/UserUtils.php View File

use Lc\ShopBundle\Context\VisitorInterface; use Lc\ShopBundle\Context\VisitorInterface;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\Security\Core\Security;


class UserUtils class UserUtils
{ {
protected $cookieChecker ; protected $cookieChecker ;


public function __construct(ParameterBagInterface $parameterBag, EntityManagerInterface $em, Utils $utils, public function __construct(ParameterBagInterface $parameterBag, EntityManagerInterface $em, Utils $utils,
RequestStack $requestStack, MerchantUtilsInterface $merchantUtils, CookieChecker $cookieChecker)
RequestStack $requestStack, MerchantUtilsInterface $merchantUtils, CookieChecker $cookieChecker,
Security $security)
{ {
$this->em = $em ; $this->em = $em ;
$this->parameterBag = $parameterBag ; $this->parameterBag = $parameterBag ;
$this->visitorRepository = $this->em->getRepository($this->em->getClassMetadata(VisitorInterface::class)->getName()) ; $this->visitorRepository = $this->em->getRepository($this->em->getClassMetadata(VisitorInterface::class)->getName()) ;
$this->merchantUtils = $merchantUtils ; $this->merchantUtils = $merchantUtils ;
$this->cookieChecker = $cookieChecker ; $this->cookieChecker = $cookieChecker ;
$this->security = $security ;
} }


public function getCookieNameVisitor() public function getCookieNameVisitor()

+ 38
- 42
ShopBundle/Services/Utils.php View File

use EasyCorp\Bundle\EasyAdminBundle\Configuration\ConfigManager; use EasyCorp\Bundle\EasyAdminBundle\Configuration\ConfigManager;
use Geocoder\Model\Coordinates; use Geocoder\Model\Coordinates;
use Geocoder\Provider\Addok\Addok; use Geocoder\Provider\Addok\Addok;
use Geocoder\Provider\GoogleMaps\GoogleMaps;
use Geocoder\Provider\Nominatim\Nominatim;
use Geocoder\Query\GeocodeQuery; use Geocoder\Query\GeocodeQuery;
use Geocoder\Query\ReverseQuery; use Geocoder\Query\ReverseQuery;
use Lc\ShopBundle\Context\ImageInterface; use Lc\ShopBundle\Context\ImageInterface;
return $truncate; return $truncate;
} }


function stripAccents($stripAccents)
{
return strtr($stripAccents,'àáâãäçèéêëìíîïñòóôõöùúûüýÿÀÁÂÃÄÇÈÉÊËÌÍÎÏÑÒÓÔÕÖÙÚÛÜÝ','aaaaaceeeeiiiinooooouuuuyyAAAAACEEEEIIIINOOOOOUUUUY');
}

function cleanStringToCompare($string)
{
return $this->stripAccents(trim(strtolower($string))) ;
}


public function isBot() public function isBot()
{ {


public function getGeocoderProvider() public function getGeocoderProvider()
{ {
$provider = false ;
$symfonyClient = new HttplugClient(); $symfonyClient = new HttplugClient();
$provider = new Addok($symfonyClient, 'https://api-adresse.data.gouv.fr') ;
$configGeocoderProvider = $this->parameterBag->get('geocoder.provider') ;

/* API du gouvernement */
if($configGeocoderProvider == 'addok') {
$provider = new Addok($symfonyClient, 'https://api-adresse.data.gouv.fr') ;
}
/* Google Maps */
elseif($configGeocoderProvider == 'googlemaps') {
$provider = new GoogleMaps($symfonyClient, null, $this->parameterBag->get('geocoder.api_key')) ;
}
/* Nominatim : OpenStreetMap */
elseif($configGeocoderProvider == 'nominatim') {
$provider = Nominatim::withOpenStreetMapServer($symfonyClient, 'Mozilla/5.0 (platform; rv:geckoversion) Gecko/geckotrail Firefox/firefoxversion');
}

if(!$provider) {
throw new \ErrorException('Aucun provider (geocoding) défini') ;
}

return $provider ; return $provider ;
} }


$provider = $this->getGeocoderProvider() ;; $provider = $this->getGeocoderProvider() ;;
$query = GeocodeQuery::create($query)->withData('type', 'housenumber'); $query = GeocodeQuery::create($query)->withData('type', 'housenumber');
$results = $provider->geocodeQuery($query); $results = $provider->geocodeQuery($query);
return $results->all() ;
$resultsToReturn = array();
foreach($results as $result) {
if ($result->getStreetNumber() && strlen($result->getStreetNumber()) > 0) {
$resultsToReturn[] = $result;
}
}
return $resultsToReturn;
} }


public function callReverseAddressApi($latitude, $longitude) public function callReverseAddressApi($latitude, $longitude)
} }




public function duplicateEntity($entity){
$newEntity = clone $entity ;

if($newEntity instanceof ImageInterface){
$this->duplicateImage($entity);
$newEntity->setImage(null);
}

if($newEntity instanceof ProductFamilyInterface){
$this->productFamilyUtils->processBeforePersistProductFamily($newEntity);
}

$this->em->persist($newEntity) ;
$this->em->flush();

return $newEntity;
}

public function duplicateImage($entity, $folder = false){
$basePath = $this->parameterBag->get('kernel.project_dir').'/public/uploads/images/' ;


if($entity->getImage() && file_exists($basePath.$entity->getImage())) {
dump(pathinfo($basePath.$entity->getImage()));
}
die();


$newImage = md5(uniqid()).'.jpg';
if($folder) $newImage = $folder.'/'.$newImage;

if($entity->getImage() && file_exists($basePath.$entity->getImage())) {
copy($basePath.$entity->getImage(), $basePath . $newImage);
$entity->setImage($newImage);
}else{
$entity->setImage(null);
}
return $entity;
}





} }

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

use Lc\ShopBundle\Context\PriceUtilsInterface; use Lc\ShopBundle\Context\PriceUtilsInterface;
use Lc\ShopBundle\Context\ProductFamilyUtilsInterface; use Lc\ShopBundle\Context\ProductFamilyUtilsInterface;
use Lc\ShopBundle\Context\Services\StatisticsUtilsInterface; use Lc\ShopBundle\Context\Services\StatisticsUtilsInterface;
use Lc\ShopBundle\Context\UserUtilsInterface;
use League\Flysystem\Util; use League\Flysystem\Util;


class UtilsManager class UtilsManager


public function __construct( public function __construct(
Utils $utils, Utils $utils,
UserUtils $userUtils,
UserUtilsInterface $userUtils,
MerchantUtilsInterface $merchantUtils, MerchantUtilsInterface $merchantUtils,
ProductFamilyUtilsInterface $productFamilyUtils, ProductFamilyUtilsInterface $productFamilyUtils,
OrderUtilsInterface $orderUtils, OrderUtilsInterface $orderUtils,
return $this->utils ; return $this->utils ;
} }


public function getUserUtils(): UserUtils
public function getUserUtils(): UserUtilsInterface
{ {
return $this->userUtils ; return $this->userUtils ;
} }

+ 7
- 3
ShopBundle/Services/UtilsProcess.php View File

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


$this->em->persist($newEntity);
if($flush){
$this->em->flush();
if($newEntity instanceof SluggableInterface){
$this->em->persist($newEntity);
if($flush)$this->em->flush();
$newEntity->setSlug(null);
} }
$this->em->persist($newEntity);
if($flush)$this->em->flush();




return $newEntity; return $newEntity;

Loading…
Cancel
Save