Explorar el Código

Recherche communes : intégration code commune

feature/export_comptable
Guillaume hace 4 años
padre
commit
e6f2a93b1e
Se han modificado 2 ficheros con 16 adiciones y 3 borrados
  1. +4
    -1
      ShopBundle/Controller/CitiesController.php
  2. +12
    -2
      ShopBundle/Services/Utils.php

+ 4
- 1
ShopBundle/Controller/CitiesController.php Ver fichero

@@ -39,8 +39,11 @@ class CitiesController extends AbstractController

$return = [] ;
foreach($result as $city) {

$codesPostaux = $city->codesPostaux ;

$return[] = [
'label' => $city->nom,
'label' => '<span class="city">'.$city->nom.'</span> <span class="zip">'.$codesPostaux[0].'</span>',
'value' => $city->code
] ;
}

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

@@ -252,10 +252,20 @@ class Utils
return $result;
}

public function getZipByCity($city)
public function getZipByCity($city, $code = null)
{
$zip = null ;
$returnCitiesSearchZip = json_decode($this->callCitiesApi('get', 'communes', ['nom' => $city, 'fields' => 'nom,codesPostaux'])) ;

$paramsSearch = [
'nom' => $city,
'fields' => 'nom,codesPostaux'
] ;

if($code != null && $code != 0) {
$paramsSearch['code'] = $code ;
}

$returnCitiesSearchZip = json_decode($this->callCitiesApi('get', 'communes', $paramsSearch)) ;

if($returnCitiesSearchZip) {
foreach($returnCitiesSearchZip as $citySearchZip) {

Cargando…
Cancelar
Guardar