src/Controller/DefaultController.php line 391

  1. <?php
  2. namespace App\Controller;
  3. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  4. use Symfony\Component\HttpFoundation\Request;
  5. use Symfony\Component\HttpFoundation\Response;
  6. use Symfony\Component\Routing\Annotation\Route;
  7. use Symfony\Component\HttpFoundation\JsonResponse;
  8. use Symfony\Component\HttpFoundation\ResponseHeaderBag;
  9. use Symfony\Component\HttpFoundation\BinaryFileResponse;
  10. use Symfony\Contracts\Translation\TranslatorInterface;
  11. use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
  12. use Doctrine\ORM\EntityManagerInterface;
  13. use Knp\Component\Pager\PaginatorInterface;
  14. use Symfony\Component\HttpFoundation\Cookie;
  15. use Symfony\Component\HttpFoundation\RequestStack;
  16. use Doctrine\Persistence\ManagerRegistry as PersistenceManagerRegistry;
  17. use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
  18. use Symfony\Component\Security\Core\Security;
  19. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
  20. use Symfony\Component\Cache\Adapter\FilesystemAdapter;
  21. use Symfony\Contracts\Cache\ItemInterface;
  22. use App\Entity\Contenido;
  23. use App\Entity\Reserva;
  24. use App\Entity\AddresLog;
  25. use App\Entity\Alerta;
  26. use App\Services\ConfigurationManager;
  27. use App\Services\SettingsManager;
  28. use App\Services\WebServiceOficinas;
  29. use App\Services\WebServiceReservas;
  30. use App\Services\WebServiceTarifasTPV;
  31. use App\Services\WebServiceTPV;
  32. use App\Services\WebServiceUsuarios;
  33. use App\Services\WebServiceDivisas;
  34. use App\Services\WebServiceFunciones;
  35. use App\Services\Mailer;
  36. use Symfony\Component\Form\Extension\Core\Type\HiddenType;
  37. use App\Form\ViajeType;
  38. use App\Form\ProfileType;
  39. use App\Form\CardType;
  40. use App\Form\AlertasType;
  41. use App\Form\ClientType;
  42. class DefaultController extends AbstractController
  43. {
  44.     
  45.     private $authorizationChecker;
  46.     
  47.     public function __construct(AuthorizationCheckerInterface $authorizationChecker)
  48.         {
  49.             $this->authorizationChecker $authorizationChecker;
  50.         }
  51.     
  52.     
  53.     /**
  54.         Comprobar parametro de camapanya "fuente" y guardarlo en cookie
  55.     **/
  56.     private function _checkCookie($request, &$response)
  57.     {
  58.         $fuente $request->query->get('fuente');
  59.         
  60.         if ($fuente) {
  61.             $response->headers->setCookie(new Cookie('fuente'$fuentetime()+(86400*30)));
  62.         }
  63.         
  64.     }
  65.     
  66.     
  67.     private function _setCache(&$response)
  68.     {
  69.         // cache publicly for 3600 seconds
  70.         $response->setPublic();
  71.         $response->setMaxAge(3600);
  72.         $response->headers->addCacheControlDirective('must-revalidate'true);
  73.     }
  74.     
  75.     public function menuAction(Request $request,PersistenceManagerRegistry $doctrine,$zona,$uri,$page,$nivel=0,$tema=''$blog=0)
  76.     {
  77.         $menu false;
  78.         $locale $request->getLocale();
  79.         $em $doctrine->getManager();
  80.         
  81. //         dump($blog); die();
  82.         
  83.         $menu_seleccionado $em->getRepository('App\Entity\Menu')->MenuActivoByZonaQuery($zona);
  84.         
  85.         if ($menu_seleccionado)
  86.             $menu $em->getRepository('App\Entity\MenuItem')->childrenHierarchy(null,false,array('menu'=>$menu_seleccionado->getId(),"locale" => $locale));
  87.         return $this->render('default/menu.html.twig', array(
  88.             'locale' => $locale,
  89.             'uri' => $uri,
  90.             'page' => $page,
  91.             'zona' => $zona,
  92.             'menu' => $menu,
  93.             'tema' => $tema,
  94.             'blog' => $blog,
  95.             'menuSeleccionado' => $menu_seleccionado,
  96.             'nivel' => $nivel
  97.             
  98.         ));
  99.     }   
  100.     #[Route(path: [
  101.         'es' => '/',
  102.         'en' => '/en'
  103.     ], name'index')]
  104.     public function index(Request $request,PersistenceManagerRegistry $doctrineTranslatorInterface $translatorWebServiceUsuarios $wsu): Response
  105.     {
  106.         //obtener noticia
  107.         $locale $request->getLocale();
  108.         $em $doctrine->getManager();
  109.         $of $maxDia $cotizaciones null;
  110.         
  111.         $oficinas $em->getRepository('App\Entity\Oficina')->findBy(['activo' => true]);
  112.         $servicios $em->getRepository('App\Entity\ContenidoServicio')->findByEstado(Contenido::ESTADO_PUBLICADO,['position' => 'ASC']);
  113.         
  114.         $contenido $em->getRepository('App\Entity\Home')->findOneByEstado(Contenido::ESTADO_PUBLICADO);
  115.         
  116.         if(isset($_COOKIE['cookieoficina']) && $_COOKIE['cookieoficina'] != 0){
  117.             $ofi = (integer)($_COOKIE['cookieoficina']);
  118.             
  119.             if($ofi == 1){
  120.                 $of $em->getRepository('App\Entity\Oficina')->findOneById($this->getParameter('oficina_por_defecto'));
  121.                 $maxDia $em->getRepository('App\Entity\Cotizaciones')->getMaxDia($this->getParameter('oficina_por_defecto'));
  122.                 $fechaMax = new \DateTime($maxDia);
  123.                 $cotizaciones $em->getRepository('App\Entity\Cotizaciones')->findAllOrdered($fechaMax$this->getParameter('oficina_por_defecto'));
  124.             }else {
  125.                 $of $em->getRepository('App\Entity\Oficina')->findOneById($_COOKIE['cookieoficina']);
  126.                 $maxDia $em->getRepository('App\Entity\Cotizaciones')->getMaxDia($ofi);
  127.                 $fechaMax = new \DateTime($maxDia);
  128.                 $cotizaciones $em->getRepository('App\Entity\Cotizaciones')->findAllOrdered($fechaMax$ofi);
  129.             }
  130.         } else {
  131.             $ofi = (integer)0;
  132.             $cotizaciones = (integer)0;
  133.         }
  134.         $user $this->getUser();
  135.         if ($user != null) {
  136.             $userErp $wsu->findBy('No'$user->getErpId());
  137.             $fechaCad = new \DateTime($userErp['fechaDoc']);
  138.             $hoy = new \DateTime();
  139.             if ($fechaCad $hoy) {
  140.                 $caducado true;
  141.             } else {
  142.                 $caducado false;
  143.             }
  144.         } else {
  145.             $caducado null;
  146.         }
  147.         
  148. //         dump($maxDia); die();
  149.         $response $this->render('default/index.html.twig', array(
  150.             'controller_name' => 'DefaultController',
  151.             'oficinas' => $oficinas,
  152.             'cotizaciones' => $cotizaciones,
  153.             'servicios' => $servicios,
  154.             'of' => $of,
  155.             'diaMax' => $maxDia,
  156.             'contenido' => $contenido,
  157.             'caducado' => $caducado
  158.         ));
  159.         
  160.         $this->_checkCookie($request$response);
  161.         $this->_setCache($response);
  162.         
  163.         
  164.         return $response;
  165.     }
  166.     
  167.     
  168.     public function cambio(Request $requestPersistenceManagerRegistry $doctrine): Response
  169.     {
  170.         $locale $request->getLocale();
  171.         $em $doctrine->getManager();
  172.         $maxDia null;
  173.         
  174.         $oficinas $em->getRepository('App\Entity\Oficina')->findBy(['activo' => true]);
  175.         $divisas $em->getRepository('App\Entity\Divisa')->findAllOrdered($locale);
  176.         $permiteCompra 1;
  177.         
  178.         if(isset($_COOKIE['cookieoficina']) && $_COOKIE['cookieoficina'] != 0){
  179.             $ofi = (integer)($_COOKIE['cookieoficina']);
  180.             $rep $em->getRepository('App\Entity\Oficina')->findOneById($_COOKIE['cookieoficina']);
  181.             if($rep){
  182.                 if($rep->permiteCompra() != 1){
  183.                     $permiteCompra 0;
  184.                 }
  185.             }
  186.             if($ofi == 1){
  187.                 $maxDia $em->getRepository('App\Entity\Cotizaciones')->getMaxDia($this->getParameter('oficina_por_defecto'));
  188.                 $fechaMax = new \DateTime($maxDia);
  189.                 $cotizaciones $em->getRepository('App\Entity\Cotizaciones')->findAllOrdered($fechaMax$this->getParameter('oficina_por_defecto'));
  190.             }else {
  191.                 $maxDia $em->getRepository('App\Entity\Cotizaciones')->getMaxDia($ofi);
  192.                 $fechaMax = new \DateTime($maxDia);
  193.                 $cotizaciones $em->getRepository('App\Entity\Cotizaciones')->findAllOrdered($fechaMax$ofi);
  194.             }
  195.         } else {
  196.             $ofi = (integer)0;
  197.             $cotizaciones $em->getRepository('App\Entity\Cotizaciones')->findBy([], [], 20);
  198.         }
  199.         
  200.         
  201.         /********************/
  202.         $maxDia2 $em->getRepository('App\Entity\Cotizaciones')->getMaxDia($this->getParameter('oficina_por_defecto'));
  203.         $fechaMax2 = new \DateTime($maxDia2);
  204.         $cotizacionesNoCompra $em->getRepository('App\Entity\Cotizaciones')->findAllOrdered($fechaMax2$this->getParameter('oficina_por_defecto'));
  205.         
  206.         $cotizacionesNoCompraJson = [];
  207.         foreach($cotizacionesNoCompra as $n)
  208.             $cotizacionesNoCompraJson[$n->getShortName()->getId()] = $n;
  209.         /********************/
  210.         
  211.         // var_dump($cotizacionesNoCompraJson);
  212.         // $js = json_encode($cotizacionesNoCompraJson);
  213.         // var_dump($js);
  214.          // die();
  215.         $cotizacionesJson = [];
  216.         foreach($cotizaciones as $c)
  217.             $cotizacionesJson[$c->getShortName()->getId()] = $c;
  218.             
  219.         $divisasJson = [];
  220.         foreach($divisas as $d)
  221.             $divisasJson[$d->getId()] = [
  222.                 'shortName' => $d->getShortName(),
  223.                 'redondeoMinimo' => $d->getRedondeoMinimo(),
  224.                 'compraMinima' => $d->getCompraMinima(),
  225.             ];
  226.         
  227.         return $this->render('default/cambio.html.twig', array(
  228.             'oficinas' => $oficinas,
  229.             'ofi' => $ofi,
  230.             'cotizaciones' => $cotizaciones,
  231.             'cotizacionesJson' => json_encode($cotizacionesJson),
  232.             'cotizacionesNoCompraJson' => json_encode($cotizacionesNoCompraJson),
  233.             'divisas' => $divisas,
  234.             'maxDia' => $maxDia,
  235.             'divisasJson' => json_encode($divisasJson),
  236.             'permiteCompra' => $permiteCompra,
  237.         ));
  238.     }
  239.     
  240.     public function showContact(Request $requestPersistenceManagerRegistry $doctrine): Response
  241.     {
  242.         return $this->render('default/contacto_header.html.twig', []);
  243.         /**** Esto era antes de hacer el shorcode de faq ****/
  244.         /*$locale = $request->getLocale();
  245.         $em = $doctrine->getManager();
  246.         $categoriasfaqq = $em->getRepository("App\Entity\FaqCategory")->findBy(array('idioma' => $locale, 'active' => "1"), array('name' => 'asc'));
  247.         $categorias = $em->getRepository("App\Entity\FaqCategory")->findBy(array('idioma' => $locale, 'active' => "1"), array('name' => 'asc'));
  248.         $categoriasfaq = $em->getRepository("App\Entity\FaqCategory")->findBy(array('idioma' => $locale, 'active' => "1"));
  249.         $faqs = $em->getRepository("App\Entity\Faq")->findBy(array('idioma' => $locale));
  250.         $faqspopulares = $em->getRepository("App\Entity\Faq")->findBy(array('idioma' => $locale, 'popular' => "1"));
  251.         return $this->render('default/contacto_header.html.twig', [
  252.             'categoriasfaq' => $categoriasfaq,
  253.             'categoriasfaqq' => $categoriasfaqq,
  254.             'categorias' => $categorias,
  255.             'faqs' => $faqs,
  256.             'faqspopulares' => $faqspopulares
  257.         ]);*/
  258.     }
  259.     
  260.     
  261.     public function principalesCambios(Request $requestPersistenceManagerRegistry $doctrine): Response
  262.     {
  263.         $locale $request->getLocale();
  264.         $em $doctrine->getManager();
  265.         
  266.         $repository $em->getRepository('App\Entity\DivisaConversion');
  267.         $query $repository->createQueryBuilder('e')
  268.             ->orderBy('e.visitas''DESC')
  269.             ->setMaxResults(5)
  270.             ->getQuery();
  271.         $conversiones $query->getResult();
  272.         
  273.         return $this->render('default/conversiones_visitadas.html.twig', array(
  274.             'conversiones' => $conversiones
  275.         ));
  276.     }
  277.     
  278.     public function empresas(Request $requestPersistenceManagerRegistry $doctrine): Response
  279.     {
  280.         $locale $request->getLocale();
  281.         $em $doctrine->getManager();
  282.         
  283.         $formViaje $this->createForm(ViajeType::class, null, ["idioma" => $locale"em" => $em]);
  284.         $viajes $em->getRepository('App\Entity\Viaje')->findAll();
  285.         
  286.         if(isset($_COOKIE['cookieoficina']) && $_COOKIE['cookieoficina'] != 0){
  287.             $ofi = (integer)($_COOKIE['cookieoficina']);
  288.             $rep $em->getRepository('App\Entity\Oficina')->findOneById($_COOKIE['cookieoficina']);
  289.             $maxDia $em->getRepository('App\Entity\Cotizaciones')->getMaxDia($ofi);
  290.             $fechaMax = new \DateTime($maxDia);
  291.             $cotizaciones json_encode($em->getRepository('App\Entity\Cotizaciones')->getLastChanges($locale));
  292.         } else {
  293.             $ofi = (integer)0;
  294. //             $cotizaciones        = $em->getRepository('App\Entity\Cotizaciones')->getLastChanges($local);
  295.             $cotizaciones json_encode((integer)0);
  296.         }
  297.         
  298.         $viajesJson = [];
  299.         foreach($viajes as $v)
  300.             $viajesJson[$v->getDestino()] = [
  301.                 'divisa' => $v->getDivisa()->getNombre(),
  302.                 'id' => $v->getDivisa()->getId()
  303.             ];
  304.         
  305.         return $this->render('default/empresas.html.twig', array(
  306.             'formViaje' => $formViaje,
  307.             'cotizacionviaje' => $cotizaciones,
  308.             'viajesJson' => json_encode($viajesJson),
  309.         ));
  310.     }
  311.     
  312.     public function oficinaAction(Request $requestPersistenceManagerRegistry $doctrine$select_id)
  313.     {
  314.         
  315.         $local=$request->getLocale();
  316.         $em $doctrine->getManager();
  317.         
  318.         $oficinas $em->getRepository("App\Entity\Oficina")->findBy(['activo' => true]);
  319. //         foreach ($oficinas as $key => $oficina) {
  320. //             if ($oficina->getId() == 66) {
  321. //                 unset($oficinas[$key]);
  322. //             }
  323. //         }
  324.         $collator = new \Collator('es_ES');
  325.         $provincias1 $em->getRepository("App\Entity\Provincia")->findAll();
  326.         $provincias2 = array();
  327.         foreach($oficinas as $ofi){
  328.           if(!in_array($ofi->getProvincia(), $provincias2)){
  329.               array_push($provincias2$ofi->getProvincia());
  330.           }
  331.         }
  332.         usort($provincias2, function($a$b) use ($collator) {
  333.             return $collator->compare($a->getNombre(), $b->getNombre());
  334.         });
  335.         // dump($provincias2);die();
  336.         // $collator = new Collator('en_US');
  337.         // $collator->sort($array);
  338.         if(isset($_COOKIE['cookieoficina']) && $_COOKIE['cookieoficina'] != 0){
  339.             $ofi = (integer)($_COOKIE['cookieoficina']);
  340.         }else{
  341.             $ofi = (integer)0;
  342.             
  343.         }
  344.         $respuesta $this->render('default/selectOficina.html.twig', array(
  345.             'provincias' => $provincias2,
  346.             'select_id' => $select_id,
  347.             'oficina' => $oficinas,
  348. //             'cotizaciones' => $cotizaciones,
  349.             'ofi_var' => $ofi,
  350. //             'ofi_def' => $ofi_def,
  351.             //'arrayHorarios' => $aux_fr
  352.         ));
  353.         
  354.         return $respuesta;
  355.     }
  356.     
  357.    
  358.     public function cookies(PersistenceManagerRegistry $doctrine)
  359.     {
  360.         $em $doctrine->getManager();
  361.         if( $em->getRepository('App\Entity\Cookies')->findOneBy(array("tipo_cookies"=>"preferencias""activo"=>true)) == null){
  362.             $have_preferencias 0;
  363.         }else{
  364.             $have_preferencias 1;
  365.         }
  366.         if( $em->getRepository('App\Entity\Cookies')->findOneBy(array("tipo_cookies"=>"estadistica""activo"=>true)) == null){
  367.             $have_estadistica 0;
  368.         }else{
  369.             $have_estadistica 1;
  370.         }
  371.         if( $em->getRepository('App\Entity\Cookies')->findOneBy(array("tipo_cookies"=>"marketing""activo"=>true)) == null){
  372.             $have_marketing 0;
  373.         }else{
  374.             $have_marketing 1;
  375.         }
  376.         
  377.         $respuesta $this->render('default/cookies.html.twig', array(
  378.             'have_preferencias' => $have_preferencias,
  379.             'have_estadistica' => $have_estadistica,
  380.             'have_marketing' => $have_marketing
  381.         ));
  382.         return $respuesta
  383.     }    
  384.     
  385.     
  386.     public function codigosCookies(PersistenceManagerRegistry $doctrine$ubicacion)
  387.     {
  388.         $em $doctrine->getManager();
  389.         $respuesta "";
  390.         
  391.         if (isset($_COOKIE['avanza_cookies3'])) {
  392.             $datos_cookies $_COOKIE['avanza_cookies3'];
  393.             list($cookie_original$cook_necesarias$cook_preferencias$cook_estadistica$cook_marketing) = explode("_/_"$datos_cookies);
  394.     //         var_dump($datos_cookies);
  395.     //         var_dump($cook_necesarias); die();
  396.             $activas = [];
  397.             if ($cook_necesarias$activas[] = 'necesarias';
  398.             if ($cook_preferencias$activas[] = 'preferencias';
  399.             if ($cook_estadistica$activas[] = 'estadistica';
  400.             if ($cook_marketing$activas[] = 'marketing';
  401.             
  402.             $objetos $em->getRepository('App\Entity\Cookies')->findBy(array("activo"=>true"posicion" => $ubicacion"tipo_cookies" => $activas));
  403.             foreach($objetos as $valor){
  404.                 $respuesta .= $valor->getCodigo();
  405.             }
  406.              
  407.         }
  408.         
  409.         $sol $this->render('default/cookies_codigos.html.twig', array(
  410.                 'codigo' => $respuesta
  411.             ));
  412.         return $sol;
  413.     } 
  414.     
  415.     
  416.     /* SITEMAP BASADO EN CONTENIDO */
  417.     #[Route('/sitemap.{_format}'name'sitemapIndex'defaults: ['_format'=>"xml"])]
  418.     public function sitemapIndex(PersistenceManagerRegistry $doctrine)
  419.     {
  420.         $em $doctrine->getManager();
  421.         
  422.         //$locales = $this->getParameter('bornay.locales');
  423.         $locales $this->getParameter('avanza.locales');
  424.         foreach($locales as $locale)
  425.             $sitemaps[$locale]= array("url" => $this->generateUrl('sitemap', array('_locale' => $locale'_format' => "xml"),UrlGeneratorInterface::ABSOLUTE_URL), "lastmod" => date('c'time()) );
  426.         
  427.         
  428.         $respuesta $this->render('default/sitemapIndex.xml.twig', array(
  429.             'sitemaps' => $sitemaps,
  430.         ));
  431.         
  432.         // cache 1 semana
  433.         $respuesta->setPublic();
  434.         $respuesta->setSharedMaxAge(7*24*60*60);
  435.         
  436.         return $respuesta;
  437.     }  
  438.     
  439.     
  440.     
  441.      #[Route(path: [
  442.         'es' => "/sitemap/{_format}",
  443.         'en' => "/en/sitemap/{_format}"
  444.     ], name'sitemap')]
  445.     public function sitemap(PersistenceManagerRegistry $doctrineRequest $request$_format)
  446.     {
  447.         $em $doctrine->getManager();
  448.         $locale $request->getLocale();
  449.         $items $urls = array();
  450.         
  451.         if ($locale=="es")
  452.             $path $this->generateUrl('index', [], UrlGeneratorInterface::ABSOLUTE_URL);
  453.         else
  454.             $path =  $this->generateUrl('index',[] ,UrlGeneratorInterface::ABSOLUTE_URL)."/";
  455.         
  456.         //home
  457.         $urls[urlencode($path)] = array("changefreq" => "weekly""priority" => "1.0""loc" => $path);
  458.         
  459.         // Paginas
  460.         $paginas $em->getRepository('App\Entity\Contenido')->ContenidosByIdiomaTipoQuery($locale,"Pagina");
  461.         $this->_sitemapLinia($urls,$path,$locale,$paginas,0.7);
  462.         
  463.         
  464.         // Servicios
  465.         $servicios $em->getRepository('App\Entity\Contenido')->ContenidosByIdiomaTipoQuery($locale,"Servicio");
  466.         $this->_sitemapLinia($urls,$path,$locale,$servicios,0.7);
  467.         
  468.         //Provincias
  469.         $provincias $em->getRepository('App\Entity\Provincia')->findAll();
  470.         $this->_sitemapLinia($urls,$path,$locale,$provincias,0.8,"yearly","provincia");
  471.         
  472.         //Localidades
  473.         $localidades $em->getRepository('App\Entity\Localidad')->findAll();
  474.         $this->_sitemapLinia($urls,$path,$locale,$localidades,0.8,"monthly","localidad");
  475.         
  476.         //Oficinas
  477.         $oficinas $em->getRepository('App\Entity\Oficina')->findAll();
  478.         $this->_sitemapLinia($urls,$path,$locale,$oficinas,0.8,"monthly","oficina");
  479.         
  480.         //Divisas
  481.         $divisas $em->getRepository('App\Entity\Divisa')->findBy(["visible" => 1]);
  482.         $this->_sitemapLinia($urls,$path,$locale,$divisas,0.8,"hourly","divisa");
  483.         
  484.         //Conversiones
  485.         $conversiones $em->getRepository('App\Entity\DivisaConversion')->findAll();
  486.         $this->_sitemapLinia($urls,$path,$locale,$conversiones,0.8,"hourly","conversion");
  487.         
  488.         $respuesta $this->render('default/sitemap.xml.twig', array(
  489.             'urls' => $urls,
  490.         ));
  491.         
  492.         // cache 1 semana
  493.         $respuesta->setPublic();
  494.         $respuesta->setSharedMaxAge(7*24*60*60);
  495.         
  496.         return $respuesta;        
  497.         
  498.     }
  499.     
  500.     
  501.     private function _sitemapLinia(&$urls$path$locale$contenidos$prioridad$frecuencia "monthly"$tipo "pagina")
  502.     {
  503.         foreach($contenidos as $contenido)
  504.         {
  505.             $url["changefreq"] = $frecuencia;
  506.             $url["priority"] = $prioridad;
  507.             
  508.             if ($locale == "es")
  509.                 $path rtrim($path,'/');
  510.             
  511.             switch($tipo) {
  512.             
  513.                 case "provincia":
  514.                     if ($contenido->getTitulo())
  515.                         $url["loc"] = $path.$this->generateUrl('listado_provincia', ["slug" => $contenido->getSlug()]);
  516.                 
  517.                 break;
  518.                 
  519.                 case "localidad":
  520.                     $url["loc"] = $path.$this->generateUrl('listado_localidad', ["slugL" => $contenido->getSlug(), "slugP" => $contenido->getProvincia()->getSlug()]);
  521.                 
  522.                 break;
  523.         
  524.                 case "oficina":
  525.                     $url["loc"] = $path.$this->generateUrl('ficha_oficina', ["slugO" => $contenido->getSlug(), "slugL" => $contenido->getLocalidad()->getSlug(), "slugP" =>                                 $contenido->getProvincia()->getSlug()]);
  526.                     
  527.                 break;
  528.                         
  529.                 case "divisa":
  530.                     if ($contenido->getSlug())
  531.                         $url["loc"] = $path.$this->generateUrl('divisas', ["nombre" => $contenido->getSlug()]);
  532.                 
  533.                 break;
  534.                 
  535.                 case "conversion":
  536.                     if ($contenido->getSlug())
  537.                         $url["loc"] = $path.$this->generateUrl('divisas', ["nombre" => $contenido->getSlug()]);
  538.                 
  539.                 break;
  540.        
  541.                 case "pagina":
  542.                 default:
  543.                     if ($locale != "es")
  544.                         $url["loc"] = $path.$contenido->getUrl($locale);
  545.                     else
  546.                         $url["loc"] = $path."/".$contenido->getUrl($locale);
  547.                     $url["lastmod"] = date('c'$contenido->getFechaModificacion()->getTimestamp());
  548.                     
  549.             }
  550.             
  551.             if (isset($url["loc"]) and !array_key_exists(urlencode($url["loc"]),$urls) ) {
  552.                 $url["loc"] = str_replace([$locale."//","//cms"],["","/cms"],$url["loc"]);
  553.                 $urls[urlencode($url["loc"])] = $url;
  554.             }
  555.             
  556.             
  557.         }
  558.     }    
  559.     
  560.     
  561.     
  562.     /**
  563.      * @Route("/prueba", name="prueba")
  564.      */
  565.     public function prueba(PersistenceManagerRegistry $doctrineRequest $requestConfigurationManager $cmSettingsManager $smWebServiceOficinas $wsoWebServiceReservas $wsrWebServiceTarifasTPV $wstWebServiceTPV $wstpvWebServiceUsuarios $wsuWebServiceDivisas $wsd)
  566.     {
  567.         //test configuration/settings services
  568.         dump($sm->getValue('cart.step4.reserva.cupon'));
  569.         dump($cm->getValue('email_empresas'));
  570.         
  571.         //test Webservices
  572.         dump($wso->getOficinas());
  573.         
  574.         dump($wsr->getReservas());
  575.         
  576. //         dump($wst->getTarifas());
  577.         
  578.         dump($wsu->getClientes());
  579.         
  580.         
  581.         
  582.         die();
  583.     }
  584.     
  585.     
  586.     
  587.     /**
  588.      * @Route( "change",  name="app_changes")
  589.      * @Method("GET")
  590.      */
  591.     public function changesAction(EntityManagerInterface $em)
  592.     {
  593.         $cotizaciones $em->getRepository('App\Entity\Cotizaciones')->findChanges('es');
  594.         foreach ($cotizaciones as $key => $cotizacion) {
  595.             $cotizacion['quant_euro'] = 'euro';
  596.             $cotizacion['euro'] = '1.000';
  597.             $cotizaciones[$key] = $cotizacion;
  598.         }
  599.         print_r(json_encode($cotizaciones));
  600.         die;
  601.     }
  602.     
  603.     
  604.     /**
  605.      * @Route( "change-office/{oficina}",  name="app_changes_office")
  606.      * @Method("GET")
  607.      */
  608.     public function changesOfficeAction(EntityManagerInterface $em$oficina)
  609.     {
  610.         $oficinas $em->getRepository('App\Entity\Oficina')->findAll();
  611.         $cotizaciones = array();
  612.         foreach($oficinas as $key1 => $ofi){
  613.           $ofiErpCod $ofi->getOficinaErp()->getCodigo();
  614.           
  615.           if (strtolower($ofiErpCod) == strtolower($oficina)) {
  616.             $ofiErpNom $ofi->getOficinaErp()->getNombre();
  617.             $id_of $ofi->getId();
  618.             $cotizaciones["codigo"] = $ofiErpCod;
  619.             $cotizaciones["nombre"] = $ofiErpNom;
  620.             $cotizaciones["Id Oficina"] = $id_of;
  621.             $cotizaciones["changes"] = $em->getRepository('App\Entity\Cotizaciones')->findChanges('es',$id_of);
  622.             foreach ($cotizaciones["changes"] as $key => $cotizacion) {
  623.                 $cotizacion['quant_euro'] = 'euro';
  624.                 $cotizacion['euro'] = '1.000';
  625.                 $cotizaciones["changes"][$key] = $cotizacion;
  626.             }
  627.           }
  628.         }
  629.         print_r(json_encode($cotizaciones));
  630.         die;
  631.     }
  632.     
  633.     
  634.     /**
  635.      * @Route( "change-office-all-bak",  name="app_changes_office_all")
  636.      * @Method("GET")
  637.      */
  638.     public function changesOfficeAllAction(EntityManagerInterface $em)
  639.     {
  640.         $oficina $em->getRepository('App\Entity\Oficina')->findAll();
  641.         $cotizaciones = array();
  642.         foreach($oficina as $key1 => $ofi){
  643.           $ofiErpCod $ofi->getOficinaErp()->getCodigo();
  644.           $ofiErpNom $ofi->getOficinaErp()->getNombre();
  645.           $id_of $ofi->getId();
  646.           $cotizacionesT[$ofiErpCod]["codigo"] = $ofiErpCod;
  647.           $cotizacionesT[$ofiErpCod]["nombre"] = $ofiErpNom;
  648.           $cotizacionesT[$ofiErpCod]["Id Oficina"] = $id_of;
  649.           $cotizacionesT[$ofiErpCod]["changes"] = $em->getRepository('App\Entity\Cotizaciones')->findChanges('es',$id_of);
  650.           foreach ($cotizacionesT[$ofiErpCod]["changes"] as $key => $cotizacion) {
  651.               $cotizacion['quant_euro'] = 'euro';
  652.               $cotizacion['euro'] = '1.000';
  653.               $cotizacion["codigo"] = $ofiErpCod;
  654.               $cotizacion["nombre"] = $ofiErpNom;
  655.               $cotizacion["Id Oficina"] = $id_of;
  656.               
  657.               $cotizaciones["changes"][] = $cotizacion;
  658.               
  659.           }
  660.         }
  661.         print_r(json_encode($cotizaciones));
  662.         die;
  663.     }    
  664. }