Explorar el Código

Merge branch 'develop'

master
Fab hace 4 años
padre
commit
7f6cc666fb
Se han modificado 7 ficheros con 74 adiciones y 7 borrados
  1. +3
    -1
      ShopBundle/Model/Address.php
  2. +14
    -3
      ShopBundle/Model/User.php
  3. +5
    -0
      ShopBundle/Resources/translations/lcshop.fr.yaml
  4. +11
    -0
      ShopBundle/Resources/views/backend/default/block/form_address.html.twig
  5. +1
    -1
      ShopBundle/Resources/views/backend/user/block_useraddress.html.twig
  6. +2
    -0
      ShopBundle/Resources/views/backend/user/edit.html.twig
  7. +38
    -2
      ShopBundle/Services/Utils.php

+ 3
- 1
ShopBundle/Model/Address.php Ver fichero

@@ -3,12 +3,14 @@
namespace Lc\ShopBundle\Model;

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

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

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

+ 14
- 3
ShopBundle/Model/User.php Ver fichero

@@ -181,9 +181,20 @@ abstract class User extends UserModelFOS
/**
* @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

+ 5
- 0
ShopBundle/Resources/translations/lcshop.fr.yaml Ver fichero

@@ -80,6 +80,8 @@ group:
email: Email
delivery: Livraison
maintenance: Maintenance
Address:
listLoopBesancon: Adresses de Besançon à spécifier (lat / long)


None: Aucune valeur
@@ -388,6 +390,9 @@ field:
unit: Unité
Address:
city: Commune
statusOptions:
offline: Désactiver
online: Activer
typeOptions:
individual: Particulier
legal-person: Professionnel

+ 11
- 0
ShopBundle/Resources/views/backend/default/block/form_address.html.twig Ver fichero

@@ -51,6 +51,11 @@
<div class="col-12">
{{ form_row(form.deliveryInfos) }}
</div>

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

<div class="col-6">
{{ form_row(form.latitude) }}
</div>
@@ -63,6 +68,12 @@
<div class="col-6">
{{ form_row(form.longitudeOverride) }}
</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) }}


+ 1
- 1
ShopBundle/Resources/views/backend/user/block_useraddress.html.twig Ver fichero

@@ -2,5 +2,5 @@
{% trans_default_domain 'lcshop' %}
<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>' %}
{{ macros.box_info('bg-info', 'address-card', address.summary, '', button) }}
{{ macros.box_info('bg-info', 'address-card', address.summary(true, true), '', button) }}
</div>

+ 2
- 0
ShopBundle/Resources/views/backend/user/edit.html.twig Ver fichero

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

+ 38
- 2
ShopBundle/Services/Utils.php Ver fichero

@@ -7,6 +7,8 @@ use Doctrine\ORM\EntityManagerInterface;
use EasyCorp\Bundle\EasyAdminBundle\Configuration\ConfigManager;
use Geocoder\Model\Coordinates;
use Geocoder\Provider\Addok\Addok;
use Geocoder\Provider\GoogleMaps\GoogleMaps;
use Geocoder\Provider\Nominatim\Nominatim;
use Geocoder\Query\GeocodeQuery;
use Geocoder\Query\ReverseQuery;
use Lc\ShopBundle\Context\ImageInterface;
@@ -172,6 +174,15 @@ class Utils
return $truncate;
}

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

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

public function isBot()
{
@@ -265,8 +276,27 @@ class Utils

public function getGeocoderProvider()
{
$provider = false ;
$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 ;
}

@@ -275,7 +305,13 @@ class Utils
$provider = $this->getGeocoderProvider() ;;
$query = GeocodeQuery::create($query)->withData('type', 'housenumber');
$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)

Cargando…
Cancelar
Guardar