Browse Source

Merge branch 'develop'

master
Guillaume 4 years ago
parent
commit
a9ef7445da
8 changed files with 69 additions and 13 deletions
  1. +3
    -1
      ShopBundle/Model/Address.php
  2. +14
    -3
      ShopBundle/Model/User.php
  3. +2
    -2
      ShopBundle/Repository/ReductionCartRepository.php
  4. +5
    -0
      ShopBundle/Resources/translations/lcshop.fr.yaml
  5. +11
    -0
      ShopBundle/Resources/views/backend/default/block/form_address.html.twig
  6. +1
    -1
      ShopBundle/Resources/views/backend/user/block_useraddress.html.twig
  7. +2
    -0
      ShopBundle/Resources/views/backend/user/edit.html.twig
  8. +31
    -6
      ShopBundle/Services/Utils.php

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

@@ -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 View File

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

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

@@ -29,11 +29,11 @@ class ReductionCartRepository extends BaseRepository implements DefaultRepositor
return ReductionCartInterface::class;
}

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

public function getValuesOfFieldType(){

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

@@ -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 View File

@@ -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 View File

@@ -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 View File

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

+ 31
- 6
ShopBundle/Services/Utils.php View File

@@ -174,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()
{
@@ -267,16 +276,26 @@ class Utils

public function getGeocoderProvider()
{
$provider = false ;
$symfonyClient = new HttplugClient();
$configGeocoderProvider = $this->parameterBag->get('geocoder.provider') ;

/* API du gouvernement */
$provider = new Addok($symfonyClient, 'https://api-adresse.data.gouv.fr') ;

if($configGeocoderProvider == 'addok') {
$provider = new Addok($symfonyClient, 'https://api-adresse.data.gouv.fr') ;
}
/* Google Maps */
//$provider = new GoogleMaps($symfonyClient, null, '') ;

elseif($configGeocoderProvider == 'googlemaps') {
$provider = new GoogleMaps($symfonyClient, null, $this->parameterBag->get('geocoder.api_key')) ;
}
/* Nominatim : OpenStreetMap */
//$provider = Nominatim::withOpenStreetMapServer($symfonyClient, 'Mozilla/5.0 (platform; rv:geckoversion) Gecko/geckotrail Firefox/firefoxversion');
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 ;
}
@@ -286,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)

Loading…
Cancel
Save