src/Controller/DefaultController.php line 289
- <?php
- namespace App\Controller;
- use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
- use Symfony\Component\HttpFoundation\Request;
- use Symfony\Component\HttpFoundation\Response;
- use Symfony\Component\Routing\Annotation\Route;
- use Symfony\Component\HttpFoundation\JsonResponse;
- use Symfony\Component\HttpFoundation\ResponseHeaderBag;
- use Symfony\Component\HttpFoundation\BinaryFileResponse;
- use Symfony\Contracts\Translation\TranslatorInterface;
- use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
- use Doctrine\ORM\EntityManagerInterface;
- use Knp\Component\Pager\PaginatorInterface;
- use Symfony\Component\HttpFoundation\Cookie;
- use Symfony\Component\HttpFoundation\RequestStack;
- use Doctrine\Persistence\ManagerRegistry as PersistenceManagerRegistry;
- use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
- use Symfony\Component\Security\Core\Security;
- use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
- use Symfony\Component\Cache\Adapter\FilesystemAdapter;
- use Symfony\Contracts\Cache\ItemInterface;
- use App\Entity\Contenido;
- use App\Entity\Reserva;
- use App\Entity\AddresLog;
- use App\Entity\Alerta;
- use App\Services\ConfigurationManager;
- use App\Services\SettingsManager;
- use App\Services\WebServiceOficinas;
- use App\Services\WebServiceReservas;
- use App\Services\WebServiceTarifasTPV;
- use App\Services\WebServiceTPV;
- use App\Services\WebServiceUsuarios;
- use App\Services\WebServiceDivisas;
- use App\Services\WebServiceFunciones;
- use App\Services\Mailer;
- use Symfony\Component\Form\Extension\Core\Type\HiddenType;
- use App\Form\ViajeType;
- use App\Form\ProfileType;
- use App\Form\CardType;
- use App\Form\AlertasType;
- use App\Form\ClientType;
- class DefaultController extends AbstractController
- {
- private $authorizationChecker;
- public function __construct(AuthorizationCheckerInterface $authorizationChecker)
- {
- $this->authorizationChecker = $authorizationChecker;
- }
- /**
- Comprobar parametro de camapanya "fuente" y guardarlo en cookie
- **/
- private function _checkCookie($request, &$response)
- {
- $fuente = $request->query->get('fuente');
- if ($fuente) {
- $response->headers->setCookie(new Cookie('fuente', $fuente, time()+(86400*30)));
- }
- }
- private function _setCache(&$response)
- {
- // cache publicly for 3600 seconds
- $response->setPublic();
- $response->setMaxAge(3600);
- $response->headers->addCacheControlDirective('must-revalidate', true);
- }
- public function menuAction(Request $request,PersistenceManagerRegistry $doctrine,$zona,$uri,$page,$nivel=0,$tema='', $blog=0)
- {
- $menu = false;
- $locale = $request->getLocale();
- $em = $doctrine->getManager();
- // dump($blog); die();
- $menu_seleccionado = $em->getRepository('App\Entity\Menu')->MenuActivoByZonaQuery($zona);
- if ($menu_seleccionado)
- $menu = $em->getRepository('App\Entity\MenuItem')->childrenHierarchy(null,false,array('menu'=>$menu_seleccionado->getId(),"locale" => $locale));
- return $this->render('default/menu.html.twig', array(
- 'locale' => $locale,
- 'uri' => $uri,
- 'page' => $page,
- 'zona' => $zona,
- 'menu' => $menu,
- 'tema' => $tema,
- 'blog' => $blog,
- 'menuSeleccionado' => $menu_seleccionado,
- 'nivel' => $nivel
- ));
- }
- #[Route(path: [
- 'es' => '/',
- 'en' => '/en'
- ], name: 'index')]
- public function index(Request $request,PersistenceManagerRegistry $doctrine, TranslatorInterface $translator, WebServiceUsuarios $wsu): Response
- {
- //obtener noticia
- $locale = $request->getLocale();
- $em = $doctrine->getManager();
- $of = $maxDia = $cotizaciones = null;
- $oficinas = $em->getRepository('App\Entity\Oficina')->findBy(['activo' => true]);
- $servicios = $em->getRepository('App\Entity\ContenidoServicio')->findByEstado(Contenido::ESTADO_PUBLICADO,['position' => 'ASC']);
- $contenido = $em->getRepository('App\Entity\Home')->findOneByEstado(Contenido::ESTADO_PUBLICADO);
- if(isset($_COOKIE['cookieoficina']) && $_COOKIE['cookieoficina'] != 0){
- $ofi = (integer)($_COOKIE['cookieoficina']);
- if($ofi == 1){
- $of = $em->getRepository('App\Entity\Oficina')->findOneById($this->getParameter('oficina_por_defecto'));
- $maxDia = $em->getRepository('App\Entity\Cotizaciones')->getMaxDia($this->getParameter('oficina_por_defecto'));
- $fechaMax = new \DateTime($maxDia);
- $cotizaciones = $em->getRepository('App\Entity\Cotizaciones')->findAllOrdered($fechaMax, $this->getParameter('oficina_por_defecto'));
- }else {
- $of = $em->getRepository('App\Entity\Oficina')->findOneById($_COOKIE['cookieoficina']);
- $maxDia = $em->getRepository('App\Entity\Cotizaciones')->getMaxDia($ofi);
- $fechaMax = new \DateTime($maxDia);
- $cotizaciones = $em->getRepository('App\Entity\Cotizaciones')->findAllOrdered($fechaMax, $ofi);
- }
- } else {
- $ofi = (integer)0;
- $cotizaciones = (integer)0;
- }
- $user = $this->getUser();
- if ($user != null) {
- $userErp = $wsu->findBy('No', $user->getErpId());
- $fechaCad = new \DateTime($userErp['fechaDoc']);
- $hoy = new \DateTime();
- if ($fechaCad < $hoy) {
- $caducado = true;
- } else {
- $caducado = false;
- }
- } else {
- $caducado = null;
- }
- // dump($maxDia); die();
- $response = $this->render('default/index.html.twig', array(
- 'controller_name' => 'DefaultController',
- 'oficinas' => $oficinas,
- 'cotizaciones' => $cotizaciones,
- 'servicios' => $servicios,
- 'of' => $of,
- 'diaMax' => $maxDia,
- 'contenido' => $contenido,
- 'caducado' => $caducado
- ));
- $this->_checkCookie($request, $response);
- $this->_setCache($response);
- return $response;
- }
- public function cambio(Request $request, PersistenceManagerRegistry $doctrine): Response
- {
- $locale = $request->getLocale();
- $em = $doctrine->getManager();
- $maxDia = null;
- $oficinas = $em->getRepository('App\Entity\Oficina')->findBy(['activo' => true]);
- $divisas = $em->getRepository('App\Entity\Divisa')->findAllOrdered($locale);
- $permiteCompra = 1;
- if(isset($_COOKIE['cookieoficina']) && $_COOKIE['cookieoficina'] != 0){
- $ofi = (integer)($_COOKIE['cookieoficina']);
- $rep = $em->getRepository('App\Entity\Oficina')->findOneById($_COOKIE['cookieoficina']);
- if($rep){
- if($rep->permiteCompra() != 1){
- $permiteCompra = 0;
- }
- }
- if($ofi == 1){
- $maxDia = $em->getRepository('App\Entity\Cotizaciones')->getMaxDia($this->getParameter('oficina_por_defecto'));
- $fechaMax = new \DateTime($maxDia);
- $cotizaciones = $em->getRepository('App\Entity\Cotizaciones')->findAllOrdered($fechaMax, $this->getParameter('oficina_por_defecto'));
- }else {
- $maxDia = $em->getRepository('App\Entity\Cotizaciones')->getMaxDia($ofi);
- $fechaMax = new \DateTime($maxDia);
- $cotizaciones = $em->getRepository('App\Entity\Cotizaciones')->findAllOrdered($fechaMax, $ofi);
- }
- } else {
- $ofi = (integer)0;
- $cotizaciones = $em->getRepository('App\Entity\Cotizaciones')->findBy([], [], 20);
- }
- /********************/
- $maxDia2 = $em->getRepository('App\Entity\Cotizaciones')->getMaxDia($this->getParameter('oficina_por_defecto'));
- $fechaMax2 = new \DateTime($maxDia2);
- $cotizacionesNoCompra = $em->getRepository('App\Entity\Cotizaciones')->findAllOrdered($fechaMax2, $this->getParameter('oficina_por_defecto'));
- $cotizacionesNoCompraJson = [];
- foreach($cotizacionesNoCompra as $n)
- $cotizacionesNoCompraJson[$n->getShortName()->getId()] = $n;
- /********************/
- // var_dump($cotizacionesNoCompraJson);
- // $js = json_encode($cotizacionesNoCompraJson);
- // var_dump($js);
- // die();
- $cotizacionesJson = [];
- foreach($cotizaciones as $c)
- $cotizacionesJson[$c->getShortName()->getId()] = $c;
- $divisasJson = [];
- foreach($divisas as $d)
- $divisasJson[$d->getId()] = [
- 'shortName' => $d->getShortName(),
- 'redondeoMinimo' => $d->getRedondeoMinimo(),
- 'compraMinima' => $d->getCompraMinima(),
- ];
- return $this->render('default/cambio.html.twig', array(
- 'oficinas' => $oficinas,
- 'ofi' => $ofi,
- 'cotizaciones' => $cotizaciones,
- 'cotizacionesJson' => json_encode($cotizacionesJson),
- 'cotizacionesNoCompraJson' => json_encode($cotizacionesNoCompraJson),
- 'divisas' => $divisas,
- 'maxDia' => $maxDia,
- 'divisasJson' => json_encode($divisasJson),
- 'permiteCompra' => $permiteCompra,
- ));
- }
- public function showContact(Request $request, PersistenceManagerRegistry $doctrine): Response
- {
- return $this->render('default/contacto_header.html.twig', []);
- /**** Esto era antes de hacer el shorcode de faq ****/
- /*$locale = $request->getLocale();
- $em = $doctrine->getManager();
- $categoriasfaqq = $em->getRepository("App\Entity\FaqCategory")->findBy(array('idioma' => $locale, 'active' => "1"), array('name' => 'asc'));
- $categorias = $em->getRepository("App\Entity\FaqCategory")->findBy(array('idioma' => $locale, 'active' => "1"), array('name' => 'asc'));
- $categoriasfaq = $em->getRepository("App\Entity\FaqCategory")->findBy(array('idioma' => $locale, 'active' => "1"));
- $faqs = $em->getRepository("App\Entity\Faq")->findBy(array('idioma' => $locale));
- $faqspopulares = $em->getRepository("App\Entity\Faq")->findBy(array('idioma' => $locale, 'popular' => "1"));
- return $this->render('default/contacto_header.html.twig', [
- 'categoriasfaq' => $categoriasfaq,
- 'categoriasfaqq' => $categoriasfaqq,
- 'categorias' => $categorias,
- 'faqs' => $faqs,
- 'faqspopulares' => $faqspopulares
- ]);*/
- }
- public function principalesCambios(Request $request, PersistenceManagerRegistry $doctrine): Response
- {
- $locale = $request->getLocale();
- $em = $doctrine->getManager();
- $repository = $em->getRepository('App\Entity\DivisaConversion');
- $query = $repository->createQueryBuilder('e')
- ->orderBy('e.visitas', 'DESC')
- ->setMaxResults(5)
- ->getQuery();
- $conversiones = $query->getResult();
- return $this->render('default/conversiones_visitadas.html.twig', array(
- 'conversiones' => $conversiones
- ));
- }
- public function empresas(Request $request, PersistenceManagerRegistry $doctrine): Response
- {
- $locale = $request->getLocale();
- $em = $doctrine->getManager();
- $formViaje = $this->createForm(ViajeType::class, null, ["idioma" => $locale, "em" => $em]);
- $viajes = $em->getRepository('App\Entity\Viaje')->findAll();
- if(isset($_COOKIE['cookieoficina']) && $_COOKIE['cookieoficina'] != 0){
- $ofi = (integer)($_COOKIE['cookieoficina']);
- $rep = $em->getRepository('App\Entity\Oficina')->findOneById($_COOKIE['cookieoficina']);
- $maxDia = $em->getRepository('App\Entity\Cotizaciones')->getMaxDia($ofi);
- $fechaMax = new \DateTime($maxDia);
- $cotizaciones = json_encode($em->getRepository('App\Entity\Cotizaciones')->getLastChanges($locale));
- } else {
- $ofi = (integer)0;
- // $cotizaciones = $em->getRepository('App\Entity\Cotizaciones')->getLastChanges($local);
- $cotizaciones = json_encode((integer)0);
- }
- $viajesJson = [];
- foreach($viajes as $v)
- $viajesJson[$v->getDestino()] = [
- 'divisa' => $v->getDivisa()->getNombre(),
- 'id' => $v->getDivisa()->getId()
- ];
- return $this->render('default/empresas.html.twig', array(
- 'formViaje' => $formViaje,
- 'cotizacionviaje' => $cotizaciones,
- 'viajesJson' => json_encode($viajesJson),
- ));
- }
- public function oficinaAction(Request $request, PersistenceManagerRegistry $doctrine, $select_id)
- {
- $local=$request->getLocale();
- $em = $doctrine->getManager();
- $oficinas = $em->getRepository("App\Entity\Oficina")->findBy(['activo' => true]);
- // foreach ($oficinas as $key => $oficina) {
- // if ($oficina->getId() == 66) {
- // unset($oficinas[$key]);
- // }
- // }
- $collator = new \Collator('es_ES');
- $provincias1 = $em->getRepository("App\Entity\Provincia")->findAll();
- $provincias2 = array();
- foreach($oficinas as $ofi){
- if(!in_array($ofi->getProvincia(), $provincias2)){
- array_push($provincias2, $ofi->getProvincia());
- }
- }
- usort($provincias2, function($a, $b) use ($collator) {
- return $collator->compare($a->getNombre(), $b->getNombre());
- });
- // dump($provincias2);die();
- // $collator = new Collator('en_US');
- // $collator->sort($array);
- if(isset($_COOKIE['cookieoficina']) && $_COOKIE['cookieoficina'] != 0){
- $ofi = (integer)($_COOKIE['cookieoficina']);
- }else{
- $ofi = (integer)0;
- }
- $respuesta = $this->render('default/selectOficina.html.twig', array(
- 'provincias' => $provincias2,
- 'select_id' => $select_id,
- 'oficina' => $oficinas,
- // 'cotizaciones' => $cotizaciones,
- 'ofi_var' => $ofi,
- // 'ofi_def' => $ofi_def,
- //'arrayHorarios' => $aux_fr
- ));
- return $respuesta;
- }
- public function cookies(PersistenceManagerRegistry $doctrine)
- {
- $em = $doctrine->getManager();
- if( $em->getRepository('App\Entity\Cookies')->findOneBy(array("tipo_cookies"=>"preferencias", "activo"=>true)) == null){
- $have_preferencias = 0;
- }else{
- $have_preferencias = 1;
- }
- if( $em->getRepository('App\Entity\Cookies')->findOneBy(array("tipo_cookies"=>"estadistica", "activo"=>true)) == null){
- $have_estadistica = 0;
- }else{
- $have_estadistica = 1;
- }
- if( $em->getRepository('App\Entity\Cookies')->findOneBy(array("tipo_cookies"=>"marketing", "activo"=>true)) == null){
- $have_marketing = 0;
- }else{
- $have_marketing = 1;
- }
- $respuesta = $this->render('default/cookies.html.twig', array(
- 'have_preferencias' => $have_preferencias,
- 'have_estadistica' => $have_estadistica,
- 'have_marketing' => $have_marketing
- ));
- return $respuesta;
- }
- public function codigosCookies(PersistenceManagerRegistry $doctrine, $ubicacion)
- {
- $em = $doctrine->getManager();
- $respuesta = "";
- if (isset($_COOKIE['avanza_cookies3'])) {
- $datos_cookies = $_COOKIE['avanza_cookies3'];
- list($cookie_original, $cook_necesarias, $cook_preferencias, $cook_estadistica, $cook_marketing) = explode("_/_", $datos_cookies);
- // var_dump($datos_cookies);
- // var_dump($cook_necesarias); die();
- $activas = [];
- if ($cook_necesarias) $activas[] = 'necesarias';
- if ($cook_preferencias) $activas[] = 'preferencias';
- if ($cook_estadistica) $activas[] = 'estadistica';
- if ($cook_marketing) $activas[] = 'marketing';
- $objetos = $em->getRepository('App\Entity\Cookies')->findBy(array("activo"=>true, "posicion" => $ubicacion, "tipo_cookies" => $activas));
- foreach($objetos as $valor){
- $respuesta .= $valor->getCodigo();
- }
- }
- $sol = $this->render('default/cookies_codigos.html.twig', array(
- 'codigo' => $respuesta
- ));
- return $sol;
- }
- /* SITEMAP BASADO EN CONTENIDO */
- #[Route('/sitemap.{_format}', name: 'sitemapIndex', defaults: ['_format'=>"xml"])]
- public function sitemapIndex(PersistenceManagerRegistry $doctrine)
- {
- $em = $doctrine->getManager();
- //$locales = $this->getParameter('bornay.locales');
- $locales = $this->getParameter('avanza.locales');
- foreach($locales as $locale)
- $sitemaps[$locale]= array("url" => $this->generateUrl('sitemap', array('_locale' => $locale, '_format' => "xml"),UrlGeneratorInterface::ABSOLUTE_URL), "lastmod" => date('c', time()) );
- $respuesta = $this->render('default/sitemapIndex.xml.twig', array(
- 'sitemaps' => $sitemaps,
- ));
- // cache 1 semana
- $respuesta->setPublic();
- $respuesta->setSharedMaxAge(7*24*60*60);
- return $respuesta;
- }
- #[Route(path: [
- 'es' => "/sitemap/{_format}",
- 'en' => "/en/sitemap/{_format}"
- ], name: 'sitemap')]
- public function sitemap(PersistenceManagerRegistry $doctrine, Request $request, $_format)
- {
- $em = $doctrine->getManager();
- $locale = $request->getLocale();
- $items = $urls = array();
- if ($locale=="es")
- $path = $this->generateUrl('index', [], UrlGeneratorInterface::ABSOLUTE_URL);
- else
- $path = $this->generateUrl('index',[] ,UrlGeneratorInterface::ABSOLUTE_URL)."/";
- //home
- $urls[urlencode($path)] = array("changefreq" => "weekly", "priority" => "1.0", "loc" => $path);
- // Paginas
- $paginas = $em->getRepository('App\Entity\Contenido')->ContenidosByIdiomaTipoQuery($locale,"Pagina");
- $this->_sitemapLinia($urls,$path,$locale,$paginas,0.7);
- // Servicios
- $servicios = $em->getRepository('App\Entity\Contenido')->ContenidosByIdiomaTipoQuery($locale,"Servicio");
- $this->_sitemapLinia($urls,$path,$locale,$servicios,0.7);
- //Provincias
- $provincias = $em->getRepository('App\Entity\Provincia')->findAll();
- $this->_sitemapLinia($urls,$path,$locale,$provincias,0.8,"yearly","provincia");
- //Localidades
- $localidades = $em->getRepository('App\Entity\Localidad')->findAll();
- $this->_sitemapLinia($urls,$path,$locale,$localidades,0.8,"monthly","localidad");
- //Oficinas
- $oficinas = $em->getRepository('App\Entity\Oficina')->findAll();
- $this->_sitemapLinia($urls,$path,$locale,$oficinas,0.8,"monthly","oficina");
- //Divisas
- $divisas = $em->getRepository('App\Entity\Divisa')->findBy(["visible" => 1]);
- $this->_sitemapLinia($urls,$path,$locale,$divisas,0.8,"hourly","divisa");
- //Conversiones
- $conversiones = $em->getRepository('App\Entity\DivisaConversion')->findAll();
- $this->_sitemapLinia($urls,$path,$locale,$conversiones,0.8,"hourly","conversion");
- $respuesta = $this->render('default/sitemap.xml.twig', array(
- 'urls' => $urls,
- ));
- // cache 1 semana
- $respuesta->setPublic();
- $respuesta->setSharedMaxAge(7*24*60*60);
- return $respuesta;
- }
- private function _sitemapLinia(&$urls, $path, $locale, $contenidos, $prioridad, $frecuencia = "monthly", $tipo = "pagina")
- {
- foreach($contenidos as $contenido)
- {
- $url["changefreq"] = $frecuencia;
- $url["priority"] = $prioridad;
- if ($locale == "es")
- $path = rtrim($path,'/');
- switch($tipo) {
- case "provincia":
- if ($contenido->getTitulo())
- $url["loc"] = $path.$this->generateUrl('listado_provincia', ["slug" => $contenido->getSlug()]);
- break;
- case "localidad":
- $url["loc"] = $path.$this->generateUrl('listado_localidad', ["slugL" => $contenido->getSlug(), "slugP" => $contenido->getProvincia()->getSlug()]);
- break;
- case "oficina":
- $url["loc"] = $path.$this->generateUrl('ficha_oficina', ["slugO" => $contenido->getSlug(), "slugL" => $contenido->getLocalidad()->getSlug(), "slugP" => $contenido->getProvincia()->getSlug()]);
- break;
- case "divisa":
- if ($contenido->getSlug())
- $url["loc"] = $path.$this->generateUrl('divisas', ["nombre" => $contenido->getSlug()]);
- break;
- case "conversion":
- if ($contenido->getSlug())
- $url["loc"] = $path.$this->generateUrl('divisas', ["nombre" => $contenido->getSlug()]);
- break;
- case "pagina":
- default:
- if ($locale != "es")
- $url["loc"] = $path.$contenido->getUrl($locale);
- else
- $url["loc"] = $path."/".$contenido->getUrl($locale);
- $url["lastmod"] = date('c', $contenido->getFechaModificacion()->getTimestamp());
- }
- if (isset($url["loc"]) and !array_key_exists(urlencode($url["loc"]),$urls) ) {
- $url["loc"] = str_replace([$locale."//","//cms"],["","/cms"],$url["loc"]);
- $urls[urlencode($url["loc"])] = $url;
- }
- }
- }
- /**
- * @Route("/prueba", name="prueba")
- */
- public function prueba(PersistenceManagerRegistry $doctrine, Request $request, ConfigurationManager $cm, SettingsManager $sm, WebServiceOficinas $wso, WebServiceReservas $wsr, WebServiceTarifasTPV $wst, WebServiceTPV $wstpv, WebServiceUsuarios $wsu, WebServiceDivisas $wsd)
- {
- //test configuration/settings services
- dump($sm->getValue('cart.step4.reserva.cupon'));
- dump($cm->getValue('email_empresas'));
- //test Webservices
- dump($wso->getOficinas());
- dump($wsr->getReservas());
- // dump($wst->getTarifas());
- dump($wsu->getClientes());
- die();
- }
- /**
- * @Route( "change", name="app_changes")
- * @Method("GET")
- */
- public function changesAction(EntityManagerInterface $em)
- {
- $cotizaciones = $em->getRepository('App\Entity\Cotizaciones')->findChanges('es');
- foreach ($cotizaciones as $key => $cotizacion) {
- $cotizacion['quant_euro'] = 'euro';
- $cotizacion['euro'] = '1.000';
- $cotizaciones[$key] = $cotizacion;
- }
- print_r(json_encode($cotizaciones));
- die;
- }
- /**
- * @Route( "change-office/{oficina}", name="app_changes_office")
- * @Method("GET")
- */
- public function changesOfficeAction(EntityManagerInterface $em, $oficina)
- {
- $oficinas = $em->getRepository('App\Entity\Oficina')->findAll();
- $cotizaciones = array();
- foreach($oficinas as $key1 => $ofi){
- $ofiErpCod = $ofi->getOficinaErp()->getCodigo();
- if (strtolower($ofiErpCod) == strtolower($oficina)) {
- $ofiErpNom = $ofi->getOficinaErp()->getNombre();
- $id_of = $ofi->getId();
- $cotizaciones["codigo"] = $ofiErpCod;
- $cotizaciones["nombre"] = $ofiErpNom;
- $cotizaciones["Id Oficina"] = $id_of;
- $cotizaciones["changes"] = $em->getRepository('App\Entity\Cotizaciones')->findChanges('es',$id_of);
- foreach ($cotizaciones["changes"] as $key => $cotizacion) {
- $cotizacion['quant_euro'] = 'euro';
- $cotizacion['euro'] = '1.000';
- $cotizaciones["changes"][$key] = $cotizacion;
- }
- }
- }
- print_r(json_encode($cotizaciones));
- die;
- }
- /**
- * @Route( "change-office-all-bak", name="app_changes_office_all")
- * @Method("GET")
- */
- public function changesOfficeAllAction(EntityManagerInterface $em)
- {
- $oficina = $em->getRepository('App\Entity\Oficina')->findAll();
- $cotizaciones = array();
- foreach($oficina as $key1 => $ofi){
- $ofiErpCod = $ofi->getOficinaErp()->getCodigo();
- $ofiErpNom = $ofi->getOficinaErp()->getNombre();
- $id_of = $ofi->getId();
- $cotizacionesT[$ofiErpCod]["codigo"] = $ofiErpCod;
- $cotizacionesT[$ofiErpCod]["nombre"] = $ofiErpNom;
- $cotizacionesT[$ofiErpCod]["Id Oficina"] = $id_of;
- $cotizacionesT[$ofiErpCod]["changes"] = $em->getRepository('App\Entity\Cotizaciones')->findChanges('es',$id_of);
- foreach ($cotizacionesT[$ofiErpCod]["changes"] as $key => $cotizacion) {
- $cotizacion['quant_euro'] = 'euro';
- $cotizacion['euro'] = '1.000';
- $cotizacion["codigo"] = $ofiErpCod;
- $cotizacion["nombre"] = $ofiErpNom;
- $cotizacion["Id Oficina"] = $id_of;
- $cotizaciones["changes"][] = $cotizacion;
- }
- }
- print_r(json_encode($cotizaciones));
- die;
- }
- }