<?php
namespace App\Controller;
use App\Entity\Blog;
use App\Entity\Categoria;
use App\Entity\Ciudad;
use App\Entity\Comentario;
use App\Entity\CodigoDescuento;
use App\Entity\ComentarioBlog;
use App\Entity\Compra;
use App\Entity\CompraItem;
use App\Entity\Contacto;
use App\Entity\Direccion;
use App\Entity\Distribuidor;
use App\Entity\EstadoPedido;
use App\Entity\Faq;
use App\Entity\Favorito;
use App\Entity\FavoritoBlog;
use App\Entity\Image;
use App\Entity\Inventario;
use App\Entity\ListaPrecioItem;
use App\Entity\ListaPrecios;
use App\Entity\MetodoPago;
use App\Entity\PoliticaPromocion;
use App\Entity\Producto;
use App\Entity\Seo;
use App\Entity\Tienda;
use App\Entity\TipSalud;
use App\Entity\Usuario;
use App\Form\ComentarioType;
use App\Form\ContactoType;
use App\Form\DireccionType;
use App\Form\PerfilType;
use App\Service\QI;
use App\Service\ClientifyService;
use Doctrine\ORM\Query;
use FOS\UserBundle\Event\GetResponseNullableUserEvent;
use FOS\UserBundle\Event\GetResponseUserEvent;
use FOS\UserBundle\Model\UserInterface;
use FOS\UserBundle\Model\UserManagerInterface;
use FOS\UserBundle\Util\TokenGeneratorInterface;
use Kreait\Firebase;
use Kreait\Firebase\Factory;
use App\Entity\SeguimientoTracking;
use Kreait\Firebase\ServiceAccount;
use MercadoPago\SDK;
use MercadoPago;
use phpDocumentor\Reflection\Types\This;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcherInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Debug\TraceableEventDispatcher;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Security\Core\Authorization\AuthorizationChecker;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
use Symfony\Component\Serializer\Encoder\JsonEncode;
use Symfony\Component\Serializer\Encoder\JsonEncoder;
use Symfony\Component\Serializer\Encoder\XmlEncoder;
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
use Symfony\Component\Serializer\Serializer;
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
use Symfony\Component\Security\Http\Event\InteractiveLoginEvent;
use Algolia\SearchBundle\SearchService;
use Symfony\Component\HttpFoundation\JsonResponse;
use function Doctrine\ORM\QueryBuilder;
class HomeController extends AbstractController
{
private $qi;
private $userManager;
private $retryTtl;
private $tokenGenerator;
private $eventDispatcher;
private $authorization;
protected $searchService;
private $clientify;
public function __construct(ClientifyService $clientify, QI $qi, UserManagerInterface $userManager,TokenGeneratorInterface $tokenGenerator, EventDispatcherInterface $eventDispatcher,AuthorizationCheckerInterface $authorization,SearchService $searchService)
{
$this->clientify = $clientify;
$this->qi = $qi;
$this->userManager = $userManager;
$this->retryTtl = 7200;
$this->tokenGenerator = $tokenGenerator;
$this->eventDispatcher = $eventDispatcher;
$this->authorization = $authorization;
$this->searchService = $searchService;
}
/**
* @Route("/direcciones/romance/direcciones", name="direcciones")
*/
public function direcciones(Request $request)
{
$dirs = $this->getDoctrine()->getRepository('App:Direccion')->findAll();
foreach ($dirs as $dir){
$this->qi->saveFire($dir);
}
$res =$this->qi->sendMail("envio de prueba", 'ferney@iridian.co', "este mensaje es de prueba");
dd($res);
}
/**
* @Route("/test_mail/romance/test_mail", name="test_mail")
*/
public function testMail(Request $request)
{
$res =$this->qi->sendMail("envio de prueba", 'fabian@iridian.co,fwarrior91@gmail.com', "este mensaje es de prueba");
dd($res);
}
//Rutas romance relax
/**
* @Route("/", name="homepage")
*/
public function home(Request $request)
{
$session = $request->getSession();
$mostre_en_home = $session->get('cierre_home','0') == '1';
$session->set('cierre_home','0');
$user = $this->getUser();
if(!$user){
$idTiendaDefault = $this->qi->getSetting('id-tienda-usuario-anonimo');
$tienda = $this->getDoctrine()->getRepository(Tienda::class)->findOneBy(array("id" => $idTiendaDefault));
$this->qi->setTienda($tienda);
}
else{
if(!$this->qi->getDireccion()){
}
else{
$tienda = $this->qi->getTiendaFromCoordinates($this->qi->getDireccion());
$this->qi->setTienda($tienda);
if(!$tienda){
$this->addFlash(
'warning',
'La direccion seleccionada no tiene cobertura en este momento'
);
}
}
}
if ($this->qi->getSetting('registro_obligatorio') != '1'){
$productos = $this->getDoctrine()->getRepository('App:Producto')->findBy(array('visible'=>true,'destacado'=>true,'principal'=>true), array('orden'=>'asc'),4);
$listas=[];
if($user && $user->getConvenio())
$convenio = $user->getConvenio();
else{
$convenio = $this->getDoctrine()->getRepository(ListaPrecios::class)->find(1);
}
foreach($productos as $product ){
$lista = $this->getDoctrine()->getRepository(ListaPrecioItem::class)->findOneBy(array('lista'=>$convenio,'producto'=>$product));
$listas[]= $lista;
}
$blogs = $this->getDoctrine()->getRepository('App:Blog')->findBy(array('visible'=>true,'destacado'=>true), array('created_at'=>'desc'));
$categorias = $this->qi->getCategoriasConProductos();
$cats = [];
$categorias = $this->getDoctrine()->getRepository('App:Categoria')->findBy(array('visible'=>true, 'home'=>true), array('orden'=>'asc'));
foreach ($categorias as $cat){
$cats[$cat->getNombre()] = $this->qi->prodsCategoria($tienda, $cat->getId());
}
$subcategorias = $this->getDoctrine()->getRepository('App:Subcategoria')->findBy(array('home'=>true, 'visible'=>true), array('orden'=>'asc'));
$idprincipal=null;
return $this->render('home/home_new.html.twig', [
'productos' => $productos,
'listas' => $listas,
'idprincipal' => $idprincipal,
'categorias' => $categorias,
'subcategorias' => $subcategorias,
'cats' => $cats,
'mostre_en_home' => $mostre_en_home,
'blogs'=> $blogs
]);
}else{
$direcciones = $this->getDoctrine()->getRepository(Direccion::class)->findBy(array('usuario'=>$user,'visible'=>true));
return $this->render('basic/addDir.html.twig', [
'direcciones' => $direcciones,
]);
}
}
/**
* @Route("/nosotros/romance/nosotros", name="nosotros")
*/
public function nosotros(Request $request)
{
$tiendas = $this->getDoctrine()->getRepository(Tienda::class)->findBy(array("visible"=>true));
return $this->render('basic/nosotros.html.twig', [
"tiendas"=>$tiendas,
'idprincipal' => $idprincipal=null
]);
}
/**
* @Route("/tiendas/romance/tiendas", name="tiendas")
* @Route("/tiendas/{ciudad_id}/{nombre}", name="tiendas_ciudada")
*/
public function tiendas(Request $request, $ciudad_id = null)
{
$search = array('visible'=>true);
if($ciudad_id){
$ciudad = $this->getDoctrine()->getRepository('App:Ciudad')->find($ciudad_id);
if($ciudad)
$search = array_merge($search,array('ciudad'=>$ciudad));
}
$tiendas = $this->getDoctrine()->getRepository('App:TiendaInfo')->findBy($search);
$tiendasall = $this->getDoctrine()->getRepository('App:TiendaInfo')->findBy(array('visible'=>true));
$distribuidores = $this->getDoctrine()->getRepository(Distribuidor::class)->findBy($search,array('orden'=>"asc"));
$ciudades = [];
foreach ($tiendasall as $tienda){
if($tienda->getCiudad())
$ciudades[$tienda->getCiudad()->getId()] = $tienda->getCiudad()->getNombre();
}
foreach ($distribuidores as $d){
if($d->getCiudad())
$ciudades[$d->getCiudad()->getId()] = $d->getCiudad()->getNombre();
}
// dd($distribuidores);
return $this->render('basic/tiendas.html.twig', [
'tiendas' => $tiendas,
'distribuidores' => $distribuidores,
'ciudades' => $ciudades,
'ciudad_id' => $ciudad_id,
'idprincipal' => $idprincipal=null
]);
}
/**
* @Route("/tienda/{id}", name="tienda")
*/
public function tienda(Request $request, $id)
{
// dd($id);
$tienda = $this->getDoctrine()->getRepository('App:TiendaInfo')->find($id);
// $tienda = $this->getDoctrine()->getRepository('App:TiendaInfo')->createQueryBuilder('t')
// ->where('t.id =:tienda_id ')
// ->setParameter('tienda_id', $id)
// ->andWhere('t.visible = 1')
// ->getQuery()
// ->getResult();
$tiendas = $this->getDoctrine()->getRepository('App:TiendaInfo')->createQueryBuilder('t')
->where('t.id !=:tienda_id ')
->setParameter('tienda_id', $id)
->andWhere('t.visible = 1')
->getQuery()
->getResult();
$imgstienda = $this->getDoctrine()->getRepository('App:Image')->findBy(array('tienda'=>$id));
return $this->render('basic/tienda.html.twig', [
'tiendas' => $tiendas,
'tienda' => $tienda,
'imgs_tienda'=>$imgstienda,
'idprincipal' => $idprincipal=null
]);
}
/**
* @Route("/logo/{id}", name="logo")
*/
public function logo(Request $request,$id)
{
$distribuidor = $this->getDoctrine()->getRepository(Distribuidor::class)->find($id);
return $this->render('basic/logo.html.twig', [
'distribuidor' => $distribuidor
]);
}
/**
* @Route("/envio/romance/envio", name="envio")
*/
public function envio(Request $request)
{
return $this->render('basic/envios.html.twig', [
'idprincipal' => $idprincipal=null
]);
}
/**
* @Route("/promociones/romance/promociones", name="promociones")
*/
public function promociones(Request $request)
{
return $this->render('basic/promociones.html.twig', [
'idprincipal' => $idprincipal=null
]);
}
/**
* @Route("/checkout/romance/checkout", name="checkout")
*/
public function checkout(Request $request)
{
$accessToken = $this->qi->getSetting("access_token_mercado_pago");
SDK::setAccessToken($accessToken);
$payment_methods = SDK::get("/v1/payment_methods")["body"];
$pse = null;
$efecty=null;
$baloto=null;
foreach ($payment_methods as $p){
if (! $pse && $p["id"] == "pse"){
$pse = $p;
}
if (! $efecty && $p["id"] == "efecty"){
$efecty = $p;
}
if (! $baloto && $p["id"] == "baloto"){
$baloto = $p;
}
}
/* @var $user Usuario */
$user = $this->getUser();
$departamentos = $this->getDoctrine()->getRepository('App:Departamento')->findBy(array('visible'=>true),array('nombre'=>'asc'));
$ciudades = $this->getDoctrine()->getRepository('App:Ciudad')->findBy(array('visible'=>true),array('nombre'=>'asc'));
$empty_user = array('nombre'=>'', 'apellido'=>'', 'email'=>'', 'celular'=>'','documento'=>'');
$direcciones = $this->getDoctrine()->getRepository('App:Direccion')->findBy(array('usuario'=>$this->getUser()));
if($this->qi->carritoLength() > 0){
return $this->render('basic/checkout.html.twig',
array("user" => $user, "ciudades" => $ciudades, "departamentos" => $departamentos,"pse"=>$pse,'efecty'=>$efecty,'baloto'=>$baloto,'empty_user'=>$empty_user,'direcciones'=>$direcciones,'idprincipal' => $idprincipal = null)
);
}else{
return $this->redirectToRoute('homepage');
}
}
/**
* @Route("/{producto}/romancerelax", name="producto_slug")
* @Route("/{idproducto}/{categoria}/{producto}/romancerelax/ro", name="producto_slug_cat")
* @Route("/{idproducto}/{producto}/romancerelax", name="producto_slug_subcat")
* @Route("/product/{id}/{nombre}", name="product")
* @Route("/product/{id}/{nombre}/{medida}", name="product_medida")
* @Route("/{idproducto}/{subcategoria}/{categoria}/{producto}/romancerelax/ro", name="producto_slug_subcategoria")
*/
public function product(Request $request, $id=null, $medida=null)
{
$routeName = $request->attributes->get('_route');
$routeParameters = $request->attributes->get('_route_params');
// dd($routeName);
$vieneconsubcategoria=null;
if($routeName == 'producto_slug'){
$prod=$this->getDoctrine()->getRepository('App:Producto')->findOneBy(array('slug'=>$routeParameters['producto']));
$id=$prod->getId();
}
if($routeName == 'producto_slug_cat'){
$prod=$this->getDoctrine()->getRepository('App:Producto')->findOneBy(array('plu'=>$routeParameters['idproducto'], 'slug'=>$routeParameters['producto'], 'principal'=>1 ));
if(!$prod){
$prod=$this->getDoctrine()->getRepository('App:Producto')->findOneBy(array('plu'=>$routeParameters['idproducto']));
}
if($prod != null){
$id=$prod->getId();
}
}
if($routeName == 'producto_slug_subcat'){
$prod=$this->getDoctrine()->getRepository('App:Producto')->findOneBy(array('plu'=>$routeParameters['idproducto'],'slug'=>$routeParameters['producto'], 'principal'=>1 ));
if(!$prod){
$prod=$this->getDoctrine()->getRepository('App:Producto')->findOneBy(array('plu'=>$routeParameters['idproducto']));
}
$id=$prod->getId();
}
if($routeName == 'producto_slug_subcategoria'){
$prod=$this->getDoctrine()->getRepository('App:Producto')->findOneBy(array('plu'=>$routeParameters['idproducto'],'slug'=>$routeParameters['producto'], 'principal'=>1 ));
if(!$prod){
$prod=$this->getDoctrine()->getRepository('App:Producto')->findOneBy(array('plu'=>$routeParameters['idproducto']));
}
$id=$prod->getId();
$vieneconsubcategoria=$routeParameters['subcategoria'];
}
$product = $this->getDoctrine()->getRepository('App:Producto')->find($id);
$idsub=$product->getSubcategoria()->getId();
$subcateg = $this->getDoctrine()->getRepository('App:Subcategoria')->findOneBy(array('id'=>$idsub));
$idcateg = $subcateg->getCategoria();
$categoria=$this->getDoctrine()->getRepository('App:Categoria')->findBy(array('id'=>$idcateg));
$subcategorias = $this->qi->getSubCategoriasConProductos($idcateg);
$idmaterialproduct=$product->getMaterial();
if($idmaterialproduct){
$materialproduct=$this->getDoctrine()->getRepository('App:Material')->findOneBy(array('id'=>$idmaterialproduct));
$namemat=$materialproduct->getNombre();
}else{
$namemat=null;
}
$user = $this->getUser();
if($user && $user->getConvenio())
$convenio = $user->getConvenio();
else{
$convenio = $this->getDoctrine()->getRepository(ListaPrecios::class)->find(1);
}
$lista = $this->getDoctrine()->getRepository(ListaPrecioItem::class)->findOneBy(array('lista'=>$convenio,'producto'=>$product));
$padre = $product->getPadre();
if(!$padre)
$padre = $product;
$hermanos = $this->getDoctrine()->getRepository(Producto::class)->createQueryBuilder('p')
->select('p.plu', 'p.nombre', 'p.tamanio', 'p.maestro','p.tipologia', 'p.materiales','medida.nombre as nombremed','material.nombre as nombremat','medida.id as idmed','medida.orden as medidaorden')
->leftJoin('p.medidas', 'medida')
->leftJoin('p.material', 'material')
->Where('p.maestro = :maestro')
->setParameter('maestro',$product->getMaestro())
->orderBy('medidaorden','asc')
->getQuery()
->getResult();
$medidas=[];
foreach($hermanos as $h){
$medidas[$h['nombremed']]=$h;
}
$url_combos = "categoria/2/combo";
$med=null;
if($medida != null){
$med=$medida;
}
$idprincipal=null;
$slugcat=$categoria[0]->getSlug();
$imgsprod = $this->getDoctrine()->getRepository(Image::class)->createQueryBuilder('i')
->select('i')
->leftJoin('i.producto', 'prod')
->where('prod.plu = '.$product->getId())
->andWhere('i.visible = 1')
->orderBy('i.orden','asc')
->getQuery()
->getResult();
$maestros = $this->qi->themaestros($product->getMaestro());
foreach($maestros as $m){
$princ = $m['principal'];
if($princ == 1){
$principal = $m;
}
}
$relacionados = $principal['relacionados'];
if($product->getsubCategoria()->getCategoria()->getId() == 1){
$imgsprod = $this->getDoctrine()->getRepository(Image::class)->createQueryBuilder('i')
->select('i')
->leftJoin('i.producto', 'prod')
->where('prod.plu = '.$principal['plu'])
->andWhere('i.visible = 1')
->orderBy('i.orden','asc')
->getQuery()
->getResult();
}
return $this->render('basic/product.html.twig', array(
'principal_padre'=>$principal,
'medidaroute' => $medida,
'product' => $product,
'materialproduct'=>$namemat,
'hermanos' => $hermanos,
'idprincipal' => $idprincipal,
'lista' => $lista,
'relacionados' => $relacionados,
'medida' => $med,
'subcategorias'=>$subcategorias,
'idcateg'=>$idcateg,
'slugcat'=>$slugcat,
'imgsprod'=>$imgsprod,
'medidas'=>$medidas,
'vieneconsubcategoria'=>$vieneconsubcategoria,
'idsub'=>$idsub,
'idcateg'=>$idcateg
)
);
}
/**
* @Route("/contacto/romance/contacto", name="contacto")
*/
public function contacto(Request $request)
{
$contacto= new Contacto();
$form = $this->createForm(ContactoType::class, $contacto);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$entityManager = $this->getDoctrine()->getManager();
$entityManager->persist($contacto);
$entityManager->flush();
$asunto = $this->qi->getSetting('asunto_mail_contacto');
$html = $this->renderView('mailing/contacto.html.twig', array(
));
$this->qi->sendMail($asunto,$contacto->getEmail(),$html);
$htmlenvio = $this->renderView('mailing/contactoenvio.html.twig', array(
'nombre'=>$contacto->getNombre(),
'email'=>$contacto->getEmail(),
'telefono'=>$contacto->getTelefono(),
'mensaje'=>$contacto->getMensaje(),
));
$to = $this->qi->getSetting('mail_recepcion_contacto');
$this->qi->sendMail($asunto,$to,$htmlenvio);
return $this->render('basic/contacto.html.twig', [
'gracias'=>true,
'idprincipal' => $idprincipal=null
]);
}
return $this->render('basic/contacto.html.twig', [
'gracias'=>false,
'form'=> $form->createView(),
'idprincipal' => $idprincipal=null
]);
}
/**
* @Route("/blog/romance/blog", name="blog")
* @Route("/blog/{id}/{nombre}", name="blog_categoria")
*/
public function blog(Request $request, $id = null)
{
$categorias = $this->getDoctrine()->getRepository('App:CategoriaBlog')->findAll();
if($id){
$categoria = $this->getDoctrine()->getRepository('App:CategoriaBlog')->find($id);
$blogs = $this->getDoctrine()->getManager()->getRepository('App:Blog')->findBy(array('visible'=>true,'categoria'=>$categoria),array('fecha'=>'desc'));
}else
$blogs = $this->getDoctrine()->getManager()->getRepository('App:Blog')->findBy(array('visible'=>true),array('fecha'=>'desc'));
return $this->render('blog/blog.html.twig', [
'blogs' => $blogs,
'categorias' => $categorias,
'idprincipal' => $idprincipal = null
]);
}
/**
* @Route("/blog-interna/{id}/{nombre}", name="blog-interna")
*/
public function blogInterna(Request $request, $id)
{
$blog = $this->getDoctrine()->getRepository('App:Blog')->find($id);
$blog_next = $this->getDoctrine()->getRepository('App:Blog')->createQueryBuilder('b')
->select('b.id','b.titulo','b.created_at')
->where('b.created_at <= :fecha')
->andWhere('b.id != '.$blog->getId())
->orderBy('b.created_at','desc')
->setMaxResults(1)
->setParameter('fecha', $blog->getCreatedAt())
->getQuery()
->getOneOrNullResult();
if(!$blog_next){
$blog_next = $this->getDoctrine()->getRepository('App:Blog')->createQueryBuilder('b')
->select('b.id','b.titulo')
->orderBy('b.created_at','desc')
->andWhere('b.id != '.$blog->getId())
->setMaxResults(1)
->getQuery()
->getOneOrNullResult();
}
$blog_prev = $this->getDoctrine()->getRepository('App:Blog')->createQueryBuilder('b')
->select('b.id','b.titulo')
->where('b.created_at >= :fecha')
->andWhere('b.id != '.$blog->getId())
->orderBy('b.created_at','asc')
->setMaxResults(1)
->setParameter('fecha', $blog->getCreatedAt())
->getQuery()
->getOneOrNullResult();
if(!$blog_prev){
$blog_prev = $this->getDoctrine()->getRepository('App:Blog')->createQueryBuilder('b')
->select('b.id','b.titulo')
->orderBy('b.created_at','asc')
->andWhere('b.id != '.$blog->getId())
->setMaxResults(1)
->getQuery()
->getOneOrNullResult();
}
$likes = $this->getDoctrine()->getRepository('App:Like')->createQueryBuilder('q')
->select('count(q)')
->leftJoin('q.blog','b')
->where('b.id = '.$blog->getId())
->getQuery()
->getSingleResult();
$comentario = new ComentarioBlog();
$comentario->setBlog($blog);
$like_user = false;
$user_id = 0;
if($this->getUser()){
$user_id = $this->getUser()->getId();
$usuario = $this->getDoctrine()->getRepository('App:Usuario')->find($user_id);
$comentario->setUsuario($usuario);
$idblog=$blog->getId();
$like_user = $this->getDoctrine()->getRepository('App:Like')->findBy(array('blog'=>$idblog));
}
$form = $this->createForm(ComentarioType::class, $comentario);
$creado = false;
if($request->isMethod('POST')){
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$entityManager = $this->getDoctrine()->getManager();
$entityManager->persist($comentario);
$entityManager->flush();
$creado = true;
$comentario = new ComentarioBlog();
$comentario->setBlog($blog);
if($this->getUser()){
$usuario = $this->getDoctrine()->getRepository('App:Usuario')->find($this->getUser()->getId());
$comentario->setUsuario($usuario);
}
$form = $this->createForm(ComentarioType::class, $comentario);
}
}
$comentarios = $this->getDoctrine()->getRepository('App:ComentarioBlog')->createQueryBuilder('q')
->select('q.id','q.comentario', 'q.created_at', "concat(u.nombre, ' ', u.apellido) usuario")
->leftJoin('q.blog','b')
->leftJoin('q.usuario','u')
->where('b.id = '.$blog->getId())
->getQuery()
->getResult();
return $this->render('blog/blog-interna.html.twig', [
'blog' => $blog,
'likes' => $likes,
'comentarios' => $comentarios,
'blog_next' => $blog_next,
'blog_prev' => $blog_prev,
'form' => $form->createView(),
'creado' => $creado,
'like_user' => $like_user,
'user_id' => $user_id,
'idprincipal' => $idprincipal = null
]);
}
/**
* @Route("/comentario/romance/comentario", name="comentario")
*/
public function comentario(Request $request)
{
$contacto= new Comentario();
$form = $this->createForm(ContactoType::class, $contacto);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$entityManager = $this->getDoctrine()->getManager();
$entityManager->persist($contacto);
$entityManager->flush();
$asunto = $this->qi->getSetting('asunto_mail_contacto');
$html = $this->renderView('contact/contact_mail.html.twig', array(
'nombre'=>$contacto->getNombre(),
'email'=>$contacto->getEmail(),
'telefono'=>$contacto->getTelefono(),
'mensaje'=>$contacto->getMensaje(),
));
$this->qi->sendMail($asunto,$contacto->getEmail(),$html);
$to = $this->qi->getSetting('mail_recepcion_pedidos');
$this->qi->sendMail($asunto,$to,$html);
return $this->render('basic/contacto.html.twig', [
'gracias'=>true
]);
}
return $this->render('basic/contacto.html.twig', [
'gracias'=>false,
'form'=> $form->createView(),
'idprincipal' => $idprincipal=null
]);
}
/**
* @Route("/buscador_old/romance/buscador_old", name="buscador_old")
*/
public function buscadorOld(Request $request)
{
/* if (!$this->qi->getDireccion()) {
$tienda = null;
} else {
if (!$this->qi->getTienda()) {
$tienda = $this->qi->getTiendaFromCoordinates($this->qi->getDireccion());
if (!$tienda) {
$this->addFlash(
'warning',
'La direccion seleccionada no tiene cobertura en este momento'
);
return $this->redirectToRoute('misdirecciones');
}
} else {
$tienda = $this->qi->getTienda();
}
} */
/* $query = $request->query->get('query', "");
$productos = $this->getDoctrine()->getRepository(Producto::class)->createQueryBuilder('p')
->select('p')
->leftJoin('p.categorias', 'c')
->where('(p.nombre like :query or p.nombreComercial like :query or p.resumen like :query or p.contraindicaciones like :query or p.interacciones like :query or p.posologia like :query) and p.visible = 1')
->andWhere('c.visible = 1')
->setParameter('query', '%' . $query . '%');
if ($tienda) {
$productos->leftJoin('p.inventarios', 'i')
->leftJoin('i.tienda', 't')
->andWhere('i.cantidad >= 0 and t.id = :tienda')
->setParameter('tienda', $tienda->getId());
}
$productos= $productos->groupBy('p.plu')->orderBy('p.orden','asc')
->getQuery()
->getArrayResult();*/
return false;
/*return $this->render('basic/buscador.html.twig', [
]);*/
}
/**
* @Route("/buscadorapi/romance/buscadorapi", name="buscadorapi")
*/
public function buscadorapi(Request $request)
{
$msg = '';
$status = 0;
$resp = [];
if (!$this->qi->getDireccion()) {
$tienda = null;
} else {
if (!$this->qi->getTienda()) {
$tienda = $this->qi->getTiendaFromCoordinates($this->qi->getDireccion());
if (!$tienda) {
$resp = [];
}
} else {
$tienda = $this->qi->getTienda();
}
}
$query = $request->request->get('search', "");
$productos = $this->getDoctrine()->getRepository(Producto::class)->createQueryBuilder('p')
->select('p.plu value', 'p.nombre label')
->leftJoin('p.categorias', 'c')
->where('(p.nombre like :query or p.nombreComercial like :query or p.resumen like :query or p.contraindicaciones like :query or p.interacciones like :query or p.posologia like :query) and p.visible = 1')
->andWhere('c.visible = 1')
->setParameter('query', '%' . $query . '%');
if ($tienda) {
$productos->leftJoin('p.inventarios', 'i')
->leftJoin('i.tienda', 't')
->andWhere('i.cantidad > 0 and t.id = :tienda')
->setParameter('tienda', $tienda->getId());
}
$productos= $productos->groupBy('p.plu')->orderBy('p.orden','asc')
->getQuery()
->getArrayResult();
return new Response(json_encode($productos));
}
/**
* @Route("/misdirecciones/romance/misdirecciones", name="misdirecciones")
*/
public function misdirecciones(Request $request)
{
$user = $this->getUser();
if(!$user){
return $this->redirectToRoute('homepage');
}
$tiendas = $this->getDoctrine()->getRepository(Tienda::class)->findBy(array('visible'=>true),array('orden'=>'asc'));
$direcciones = $this->getDoctrine()->getRepository(Direccion::class)->findBy(array('usuario'=>$user,'visible'=>true));
return $this->render('basic/addDir.html.twig', [
'tiendas' => $tiendas,
'direcciones' => $direcciones,
'idprincipal' => $idprincipal=null
]);
}
/**
* @Route("/perfil/romance/perfil", name="perfil")
*/
public function perfil(Request $request, $id = null)
{
$user = $this->getUser();
$borre_dir = false;
if($id){
$direccion = $this->getDoctrine()->getRepository(Direccion::class)->find($id);
$direccion->setVisible(false);
$entityManager = $this->getDoctrine()->getManager();
$entityManager->persist($direccion);
$entityManager->flush();
$borre_dir = true;
}
$direcciones = $this->getDoctrine()->getRepository(Direccion::class)->createQueryBuilder('d')
->select('d')
->leftJoin('d.usuario','u')
->where('u.id = '.$user->getId())
->andWhere('d.visible is null or d.visible = 1')
->getQuery()
->getResult();
$form = $this->createForm(PerfilType::class, $user);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$entityManager = $this->getDoctrine()->getManager();
$entityManager->persist($user);
$entityManager->flush();
return $this->render('user/perfil.html.twig', [
'gracias'=>true,
'borre_dir'=>$borre_dir,
'direcciones' => $direcciones,
'form'=> $form->createView()
]);
}
return $this->render('user/perfil.html.twig', [
'gracias'=>false,
'borre_dir'=>$borre_dir,
'direcciones' => $direcciones,
'form'=> $form->createView()
]);
}
/**
* @Route("/recomendaciones-para-pacientes/romance/recomendaciones-para-pacientes", name="recomendaciones")
*/
public function recomendaciones(Request $request)
{
return $this->render('recomendaciones/recomendaciones.html.twig', [
'gracias'=>false,
'form'=> null
]);
}
/**
* @Route("/tips/romance/tips", name="tips")
*/
public function tips(Request $request)
{
$tips = $this->getDoctrine()->getRepository(TipSalud::class)->findBy(array("visible" => true), array('orden'=>'asc'));
return $this->render('tips/index.html.twig', [
"tips"=>$tips,
'gracias'=>false,
'form'=> null
]);
}
/**
* @Route("/tip/{id}", name="tip")
*/
public function tip(Request $request, $id)
{
$tip = $this->getDoctrine()->getRepository(TipSalud::class)->find($id);
return $this->render('tips/tip.html.twig', [
"tip"=>$tip,
'gracias'=>false,
'form'=> null
]);
}
/**
* @Route("/covid-19", name="covid")
*/
public function covid(Request $request)
{
$articulos = $this->getDoctrine()->getRepository('App:Covid')->findBy(array('visible'=>true),array('orden'=>'asc'));
return $this->render('recomendaciones/recomendaciones.html.twig', [
'gracias'=>false,
'form'=> null,
'articulos'=>$articulos
]);
}
/**
* @Route("/servicios-de-enfermeria", name="enfermeria")
*/
public function enfermeria(Request $request)
{
$first = 1;
$size = 100;
$productos = $this->getDoctrine()->getRepository('App:Inventario')->createQueryBuilder('i')
->select('i.precio','p.nombre','p.imagen','p.plu')
->addSelect(
'CASE WHEN p.nombreComercial is not null and p.nombreComercial <> \'\' THEN p.nombreComercial ELSE p.nombre END AS nombrePublico')
->leftJoin('i.producto','p')
->leftJoin('p.categorias','c')
->where('i.cantidad > 0')
->andWhere('p.visible = 1')
->andWhere("p.imagen not like '%icon%'")
->setFirstResult($first)
->setMaxResults($size)
->getQuery()
->getArrayResult();
shuffle($productos);
$productos = array_slice($productos,0,4);
return $this->render('enfermeria/enfermeria.html.twig', [
'gracias'=>false,
'form'=> null,
'productos'=>$productos
]);
}
/**
* @Route("/pedir/romance/pedir", name="pedir")
*/
public function pedir(Request $request)
{
try {
$user = $this->getUser();
$direccion = $this->getDoctrine()->getRepository(Direccion::class)->find($this->qi->getDireccion()->getId());
$metodo_sel = $request->request->get('metodo');
$metodo = $this->getDoctrine()->getRepository(MetodoPago::class)->findOneBy(array('id' => $metodo_sel));
$tienda = $this->getDoctrine()->getRepository(Tienda::class)->find($this->qi->getTienda()->getId());
$costo_domicilio = $tienda->getCostoDomicilio();
$comentarios = $request->request->get('comentarios');
$medico = $request->request->get('medico');
$lifemiles = $request->request->get('lifemiles');
$peticion= $this->qi->getCarrito();
$paga_con = 0;
$canal = "web";
$carrito=[];
if($metodo_sel == "2"){
return $this->redirectToRoute('pagos_payu',array(
"comentarios"=>$comentarios,
"medico" => $medico,
"lifemiles" => $lifemiles
));
}
foreach ($this->qi->getCarrito() as $item){
$elem = array("product_id"=>$item["producto"]->getPlu(),"count"=>$item["cantidad"]);
array_push($carrito,$elem);
}
$res = $this->qi->crearPedido($metodo,$canal,$comentarios,$this->getUser());
/* @var $compra Compra */
$compra =$res["compra"];
$resultado = array("ok" => true, 'obj' => array("compra"=>array("id"=>$compra->getId())));
// dd('entra a pedir',$compra);
if($this->qi->getSetting('enviar_correo') == "1"){
$asunto = $this->qi->getTexto('asunto_compra_cliente');
$this->qi->sendMail($asunto, $this->getUser()->getEmail(), $compra->getBody());
$asunto = $this->qi->getTexto('asunto_compra_tienda');
if($compra->getTienda()) {
$this->qi->sendMail($asunto, $compra->getTienda()->getEmail(), $compra->getBody());
}else{
$this->qi->sendMail($asunto, $this->qi->getSetting('mail_recepcion_pedidos'), $compra->getBody());
}
}
}catch (\Exception $e){
$resultado = array("ok" => false, 'obj' => $e->getCode()." - ".$e->getMessage());
}
if($resultado["ok"]) {
return $this->redirectToRoute('confirmacion', $resultado);
}else{
return $this->redirectToRoute('carrito', $resultado);
}
}
/**
* @Route("/set-direccion/{id}", name="set-direccion")
*/
public function setDireccion(Request $request,$id)
{
$user = $this->getUser();
$dir = $this->getDoctrine()->getRepository(Direccion::class)->find($id);
$this->qi->setDireccion($dir);
$tienda = $this->qi->getTiendaFromCoordinates($dir);
if(!$tienda){
$this->addFlash(
'warning',
'La direccion seleccionada no tiene cobertura en este momento'
);
return $this->redirectToRoute('misdirecciones');
}
$this->qi->setTienda($tienda);
if($this->qi->carritoLength() > 0)
return $this->redirectToRoute('carrito');
return $this->redirectToRoute('homepage');
}
/**
* @Route("/add-direccion/romance/add-direccion", name="add-direccion")
*/
public function addDireccion(Request $request)
{
$user = $this->getUser();
// dd($user);
if($user) {
$dir = new Direccion();
$dirarr = $request->request->get('direccion');
$ciudad = $request->request->get('ciudad');
$prede = $request->request->get('predeterminada');
$prede=$prede ?? 0;
$ciudad = $this->getDoctrine()->getRepository(Ciudad::class)->find($ciudad);
$dir->setUsuario($user);
$dir->setDireccion($dirarr);
$dir->setUid($user->getUid() ?? '');
$dir->setCiudad($ciudad);
$dir->setPredeterminada($prede);
$entityManager = $this->getDoctrine()->getManager();
$entityManager->persist($dir);
$entityManager->flush();
$this->qi->setDireccion($dir);
return $this->redirectToRoute('mis-direcciones');
}else{
return $this->redirectToRoute('login');
}
}
function existeCatProds($productos,$c){
$encontrado = false;
for ($i = 0; $i<count($productos);$i++){
for($k = 0; $k < count($productos[$i]["producto"]["categorias"]);$k++){
$encontrado = $c->getId() == $productos[$i]["producto"]["categorias"][$k]['id'];
if($encontrado){
$k=count($productos[$i]["producto"]["categorias"])+1;
$i=count($productos)+1;
break;
}
}
if($encontrado){
break;
}
}
return $encontrado;
}
function arePointsNear($checkPoint, $centerPoint, $km) {
$ky = 40000 / 360;
$kx = cos(pi() * $centerPoint->getLat() / 180.0) * $ky;
$dx = abs($centerPoint->getLng() - $checkPoint->getLng()) * $kx;
$dy = abs($centerPoint->getLat() - $checkPoint->getLat()) * $ky;
return sqrt($dx * $dx + $dy * $dy) <= $km;
}
/**
* @Route("/categoria", name="categoria")
* @Route("/subcategoria/{id_sub}/{nombre}/{referencia}", name="subcategoria_nombre")
* @Route("/{subcategoria}/{categoria_slug}", name="subcategoria_slug")
* @Route("/buscador/romance/buscador", name="buscador")
* @Route("/{categoria}", name="categoria_slug")
* @Route("/{categoria}/{medida}/romance/ro", name="medida")
* @Route("/{categoria}/{material}/romance", name="material")
*/
public function categoria(Request $request, $id_cat = null, $id_sub = null, $referencia=null, $medidaid=null, $materialid=null )
{
$subcategoria= null;
$titulo = "";
$query = $this->getDoctrine()->getRepository('App:Producto')->createQueryBuilder('p')
->select('p.plu')
->where('p.visible=1')
->leftJoin('p.subcategoria','s');
$routeName = $request->attributes->get('_route');
$routeParameters = $request->attributes->get('_route_params');
$parameter_med='';
$medidaparameter=[];
$medidassel=[];
$material=null;
if($routeName == 'categoria_slug'){
$cat=$this->getDoctrine()->getRepository('App:Categoria')->findOneBy(array('slug'=>$routeParameters['categoria']));
if(!$cat){
return $this->redirectToRoute("homepage");
}
$id_cat=$cat->getId();
}
if($routeName == 'subcategoria_slug' ){
$cat=$this->getDoctrine()->getRepository('App:Categoria')->findOneBy(array('slug'=>$routeParameters['categoria_slug']));
if(!$cat){
return $this->redirectToRoute("homepage");
}
$subcat=$this->getDoctrine()->getRepository('App:Subcategoria')->findOneBy(array('slug'=>$routeParameters['subcategoria'],'categoria'=>$cat->getId()));
if(!$subcat){
return $this->redirectToRoute("homepage");
}
$id_sub=$subcat->getId();
}
if($routeName == 'medida' ){
$parameter_med=str_replace ( '-' , ' ' ,$routeParameters['medida'] );
$routeParameters['categoria'];
$cat=$this->getDoctrine()->getRepository('App:Categoria')->findOneBy(array('slug'=>$routeParameters['categoria']));
$id_cat=$cat->getId();
//$medidaparameter=$this->getDoctrine()->getRepository('App:Medidas')->findBy(array('nombre'=>$parameter_med));
$medidaspa=$this->getDoctrine()->getRepository('App:Medidas')->createQueryBuilder('m')
->select('m.id')
->where('m.nombre like :nombremedidas')
->setParameter('nombremedidas','%'.$parameter_med.'%');
if($cat){
$medidaspa=$medidaspa->leftJoin('m.categoria','cat')
->andWhere('cat.id = :catid')
->setParameter('catid',$cat->getId());
}
$medidaspa= $medidaspa->groupBy('m.id')->getQuery()
->getArrayResult();
foreach ($medidaspa as $result) {
array_push($medidaparameter,$result['id']);
}
}
if($routeName == 'material' ){
$cat=$this->getDoctrine()->getRepository('App:Categoria')->findOneBy(array('slug'=>$routeParameters['categoria']));
$id_cat=$cat->getId();
$material=$this->getDoctrine()->getRepository('App:Material')->findOneBy(array('nombre'=>$routeParameters['material']));
}
if($id_cat) {
$categoria = $this->getDoctrine()->getRepository('App:Categoria')->find($id_cat);
$subcategorias = $this->qi->getSubCategoriasConProductos($id_cat);
if($id_cat != 6){
$query = $query->leftJoin('s.categoria','c')
->andWhere('c.id = :cat')
->setParameter('cat',$id_cat);
}
$titulo = $categoria->getNombre();
}else if($id_sub){
$subcategoria = $this->getDoctrine()->getRepository('App:Subcategoria')->find($id_sub);
$categoria = $subcategoria->getCategoria();
$id_cat=$categoria->getId();
$subcategorias = $this->qi->getSubCategoriasConProductos($id_cat);
$query = $query->andWhere('s.id = :sub')
->setParameter('sub',$id_sub);
$titulo = $subcategoria->getNombre();
}else{
$subcategoria = null;
$categoria = null;
$subcategorias = [];
}
$preciomin = $request->query->get('preciomin',"");
$preciomax = $request->query->get('preciomax',"");
$preciomin_mobile = $request->query->get('preciomin_mobile',"");
$preciomax_mobile = $request->query->get('preciomax_mobile',"");
$medida = $request->query->get('medida',"");
$tipologia = $request->query->get('tipologia',"");
if($request->get('search')) {
$search = $request->get('search',"");
$prods_alg = false;
$em = $this->getDoctrine()->getManagerForClass(Producto::class);
$prods_alg = $this->searchService->rawSearch(Producto::class, $search)['hits'];
$query = $query
->andWhere('p.plu in (:idsalg)')
->setParameter('idsalg',array_column($prods_alg,'plu'));
}
$tecnologias = array();
$tipologias = array();
$adaptabilidades = array();
$independencias = array();
$gammas = array();
$medidas = array();
$filtros = array(
"Tipología" => $tipologias,
"Medida" => $medidas
);
$plus = $query->getQuery()->getArrayResult();
$user = $this->getUser();
if($user && $user->getConvenio())
$convenio = $user->getConvenio();
else{
$convenio = $this->getDoctrine()->getRepository(ListaPrecios::class)->find(1);
}
// consulta productos
$productos=[];
$productospadres = $this->getDoctrine()->getRepository('App:Producto')->createQueryBuilder('p')
->select('pa.plu,pa.slug, pa.nombre, pa.resumen , pa.imagen, pa.tamanio, pa.tecnologia, pa.tipologia, pa.adaptabilidad, pa.independencia,pa.gamma,
pa.color_texto,pa.descuento ,pa.alt,pa.tela,pa.maestro,pa.principal,pa.visible,pa.orden,pa.dctoic,pa.incarrito,
me.nombre as medida, mat.nombre as material, l.precio')
->leftJoin('p.padre','pa')
->leftJoin('pa.listas','l')
->leftJoin('l.lista','li')
->leftJoin('pa.medidas','me')
->leftJoin('pa.material','mat')
->Where('p.plu in (:ids)')
->andWhere('pa is not null')
->setParameter('ids',array_column($plus,'plu'))
->andWhere('li.id = :l_id')
->setParameter('l_id',$convenio->getId());
$productosunicos=$this->getDoctrine()->getRepository('App:Producto')->createQueryBuilder('p')
->select('p.plu, p.slug,p.nombre, p.resumen , p.imagen, p.tamanio, p.tecnologia, p.tipologia, p.adaptabilidad, p.independencia,p.gamma,
p.color_texto,p.descuento ,p.alt,p.tela,p.maestro,p.principal,p.visible,p.orden,p.dctoic,p.incarrito,
me.nombre as medida, mat.nombre as material, l.precio,pa.visible padre_visible, pa.plu padre_id')
->leftJoin('p.padre','pa')
->leftJoin('p.listas','l')
->leftJoin('l.lista','li')
->leftJoin('p.medidas','me')
->leftJoin('p.material','mat')
->Where('p.plu in (:ids)')
->andWhere("(p.padre is null and p.visible = 1) or (pa.visible = 1)")
// ->andWhere('p.padre is null')
->setParameter('ids',array_column($plus,'plu'))
->andWhere('li.id = :l_id')
->setParameter('l_id',$convenio->getId());
/*$productos = $this->getDoctrine()->getRepository('App:Producto')->createQueryBuilder('p')
->select(
'DISTINCT (CASE WHEN p.padre is not null THEN pa.plu ELSE p.plu END) AS plu',
'CASE WHEN p.padre is not null THEN pa.slug ELSE p.slug END AS slug',
'CASE WHEN p.padre is not null THEN pa.nombre ELSE p.nombre END AS nombre',
'CASE WHEN p.padre is not null THEN pa.resumen ELSE p.resumen END AS resumen',
'CASE WHEN p.padre is not null THEN pa.imagen ELSE p.imagen END AS imagen',
'CASE WHEN p.padre is not null THEN pa.tamanio ELSE p.tamanio END AS tamanio',
'CASE WHEN p.padre is not null THEN me.nombre ELSE me.nombre END AS medida',
'CASE WHEN p.padre is not null THEN mat.nombre ELSE me.nombre END AS material',
'CASE WHEN p.padre is not null THEN pa.tecnologia ELSE p.tecnologia END AS tecnologia',
'CASE WHEN p.padre is not null THEN pa.tipologia ELSE p.tipologia END AS tipologia',
'CASE WHEN p.padre is not null THEN pa.adaptabilidad ELSE p.adaptabilidad END AS adaptabilidad',
'CASE WHEN p.padre is not null THEN pa.independencia ELSE p.independencia END AS independencia',
'CASE WHEN p.padre is not null THEN pa.gamma ELSE p.gamma END AS gamma',
'CASE WHEN p.padre is not null THEN pa.color_texto ELSE p.color_texto END AS color_texto',
'CASE WHEN p.padre is not null THEN pa.descuento ELSE p.descuento END AS descuento',
'CASE WHEN p.padre is not null THEN pa.alt ELSE p.alt END AS alt',
'CASE WHEN p.padre is not null THEN pa.tela ELSE p.tela END AS tela',
'CASE WHEN p.padre is not null THEN pa.maestro ELSE p.maestro END AS maestro',
'CASE WHEN p.padre is not null THEN pa.principal ELSE p.principal END AS principal',
'CASE WHEN p.padre is not null THEN pa.visible ELSE p.visible END AS visible',
'CASE WHEN p.padre is not null THEN pa.orden ELSE p.orden END AS orden',
'CASE WHEN p.dctoic is not null THEN pa.dctoic ELSE pa.dctoic END AS dctoic',
'CASE WHEN p.incarrito is not null THEN pa.incarrito ELSE pa.dctoic END AS incarrito',
'CASE WHEN p.padre is not null THEN lipadre.id ELSE l.id END AS lista',
'CASE WHEN p.padre is not null THEN lpadre.precio ELSE l.precio END AS precio')
->leftJoin('p.padre','pa')
->leftJoin('p.listas','l')
->leftJoin('l.lista','li')
->leftJoin('pa.listas','lpadre')
->leftJoin('lpadre.lista','lipadre')
->leftJoin('p.medidas','me')
->leftJoin('p.material','mat')
->Where('p.plu in (:ids)')
->setParameter('ids',array_column($plus,'plu'));
//->andWhere('li.id = :l_id or lipadre.id =:l_id')
//->setParameter('l_id',$convenio->getId());*/
if($preciomin){
$productospadres->andWhere('l.precio >='.$preciomin);
$productosunicos->andWhere('l.precio >='.$preciomin);
}
if($preciomin_mobile){
$productospadres->andWhere('l.precio >='.$preciomin_mobile);
$productosunicos->andWhere('l.precio >='.$preciomin_mobile);
}
if($preciomax){
$productospadres->andWhere('l.precio <='.$preciomax);
$productosunicos->andWhere('l.precio <='.$preciomax);
}
if($preciomax_mobile){
$productospadres->andWhere('l.precio <='.$preciomax_mobile);
$productosunicos->andWhere('l.precio <='.$preciomax_mobile);
}
if($id_cat){
if($id_cat==6){
$productosunicos->andwhere('p.padre is null');
}
$productospadres->leftJoin('pa.categorias','c')
->andWhere('c.id = '.$id_cat);
$productosunicos->leftJoin('p.categorias','c')
->andWhere('c.id = '.$id_cat);
}
if ($id_sub){
$productospadres->leftJoin('pa.subcategoria','sub')
->andWhere('sub.id = '.$id_sub);
$productosunicos->leftJoin('p.subcategoria','sub')
->andWhere('sub.id = '.$id_sub);
}
if(count($medidaparameter)>0){
$productospadres=$productospadres->andWhere($productospadres->expr()->in('me.id',$medidaparameter));
$productosunicos=$productosunicos->andWhere($productosunicos->expr()->in('me.id',$medidaparameter));
//$productospadres->andWhere("me.id = '".$medidaparameter->getId()."'");
// $productosunicos->andWhere("me.id = '".$medidaparameter->getId()."'");
}
/*
$productospadres=$productospadres->orderBy('pa.orden', 'asc')
->groupby('pa.maestro')
->getQuery()->getSQL();
$productosunicos=$productosunicos->orderBy('p.orden', 'asc')
->groupby('p.maestro')
->getQuery()
->getSQL();
dd($productospadres,$productosunicos);
*/
if($material){
$productospadres->andWhere("mat.nombre like '".$material->getNombre()."'");
$productosunicos->andWhere("mat.nombre like '".$material->getNombre()."'");
}
if($tipologia){
/*$productos->andWhere('p.tipologia = :tipologia')
->setParameter('tipologia',$tipologia);*/
$tipologiasel=explode(',',$tipologia);
$busquedatipo='';
foreach($tipologiasel as $key=>$tipo){
$busquedatipo.="p.tipologia like '".$tipo."'";
if($key<(count($tipologiasel)-1)){
$busquedatipo.=" OR ";
}
}
$productospadres->andWhere($busquedatipo);
$productosunicos->andWhere($busquedatipo);
}
if($medida){
$medidassele=explode(',',$medida);
$medidascarga=$this->getDoctrine()->getRepository('App:Medidas')->createQueryBuilder('m')
->select('m.id');
$medidascarga->where($medidascarga->expr()->in('m.nombre',$medidassele));
if($cat){
$medidascarga=$medidascarga->leftJoin('m.categoria','cat')
->andWhere('cat.id = :catid')
->setParameter('catid',$cat->getId());
}
$medidascarga= $medidascarga->groupBy('m.id')->getQuery()
->getArrayResult();
foreach ($medidascarga as $result) {
array_push($medidassel,$result['id']);
}
/*$productos->andWhere('p.medida = :medida')
->setParameter('medida',$medida);*/
/*$busquedasel='';
foreach($medidassel as $key=>$me){
$busquedasel.="p.medida like '".$me."'";
if($key<(count($medidassel)-1)){
$busquedasel.=" OR ";
}
}*/
if(count($medidassel)>0) {
$productospadres->andWhere($productospadres->expr()->in('me.id', $medidassel));
$productosunicos->andWhere($productosunicos->expr()->in('me.id', $medidassel));
}
}
$productospadres=$productospadres->orderBy('pa.orden', 'asc')
->groupby('pa.maestro')
->getQuery()
->getArrayResult();
$productosunicos=$productosunicos->orderBy('p.orden', 'asc')
->groupby('p.maestro')
->getQuery()
->getArrayResult();
$productos=[];
foreach ($productospadres as $productopadre){
$productos[$productopadre['plu']]=$productopadre;
}
foreach ($productosunicos as $productosunico){
$productos[$productosunico['plu']]=$productosunico;
}
//$productos=array_merge($productospadres,$productosunicos);
//$productos =array_map("unserialize", array_unique(array_map("serialize", $productos)));
$maxprecio = $this->getDoctrine()->getRepository('App:Producto')->createQueryBuilder('p')
->select('Max(l.precio) as precio')
->leftJoin('p.listas','l')
->leftJoin('l.lista','li')
->leftJoin('p.medidas','me')
->leftJoin('p.material','mat')
->where('p.visible=1')
->andWhere('li.id = :l_id')
->setParameter('l_id',$convenio->getId());
if($id_cat){
$maxprecio->leftJoin('p.categorias','c')
->andWhere('c.id = '.$id_cat);
}
if ($id_sub){
$maxprecio->leftJoin('p.subcategoria','sub')
->andWhere('sub.id = '.$id_sub);
}
if(count($medidaparameter)>0){
$maxprecio=$maxprecio->andWhere($maxprecio->expr()->in('me.id',$medidaparameter));
//$maxprecio->andWhere("me.nombre like '".$medidaparameter->getNombre()."'");
}
if($material){
$maxprecio->andWhere("mat.nombre like '".$material->getNombre()."'");
}
$maxprecio=$maxprecio->setMaxResults(1)
->getQuery()
->getOneOrNullResult();
$minprecio = $this->getDoctrine()->getRepository('App:Producto')->createQueryBuilder('p')
->select('Min(l.precio) as precio')
->leftJoin('p.listas','l')
->leftJoin('l.lista','li')
->leftJoin('p.medidas','me')
->leftJoin('p.material','mat')
->where('p.visible=1')
->andWhere('li.id = :l_id')
->setParameter('l_id',$convenio->getId());
if($id_cat){
$minprecio->leftJoin('p.categorias','c')
->andWhere('c.id = '.$id_cat);
}
if ($id_sub){
$minprecio->leftJoin('p.subcategoria','sub')
->andWhere('sub.id = '.$id_sub);
}
if(count($medidaparameter)>0){
$minprecio=$minprecio->andWhere($minprecio->expr()->in('me.id',$medidaparameter));
//$minprecio->andWhere("me.nombre like '".$medidaparameter->getNombre()."'");
}
if($material){
$minprecio->andWhere("mat.nombre like '".$material->getNombre()."'");
}
$minprecio=$minprecio->setMaxResults(1)
->getQuery()
->getOneOrNullResult();
$precios=[];
foreach ($productos as $producto){
$precios[]=$producto['precio'];
}
if($precios != null ){
if(count($maxprecio)>0){
$preciomax=round($maxprecio['precio']);
}else{
$preciomax=max($precios);
}
if(count($maxprecio)>0){
$preciomin=round($minprecio['precio']);
}else{
$preciomin=min($precios);
}
}
if($precios != null ){
if(count($maxprecio)>0){
$preciomax_mobile=round($maxprecio['precio']);
}else{
$preciomax_mobile=max($precios);
}
if(count($maxprecio)>0){
$preciomin_mobile=round($minprecio['precio']);
}else{
$preciomin_mobile=min($precios);
}
}
$hermanos = [];
$medidas = [];
$tipologias=[];
foreach ($productos as $producto){
$hermanos = $this->getDoctrine()->getRepository(Producto::class)->createQueryBuilder('p')
->select('p.principal','p.plu', 'p.medida', 'p.nombre', 'p.tamanio', 'p.maestro','me.nombre as medida_real','me.id')
->leftJoin('p.medidas','me')
->where('me is not null')
->andWhere('p.maestro = :maestro')
// ->andWhere('p.visible = 1')
->setParameter('maestro',$producto['maestro'])
->orderBy('p.medida','asc')
->getQuery()
->getResult();
foreach ($hermanos as $hermano){
/* @var $producto Producto */
$medidas[$hermano['medida_real']] = array("nombre" => $hermano['medida_real'], "checked"=>$this->isChecked($request,'medida_real',$hermano['medida_real']) );
if(count($medidassel)>0){
if(in_array($hermano['id'],$medidassel)) {
$medidas[$hermano['medida_real']] = array("nombre" => $hermano['medida_real'], "checked"=>true);
}
}
if($parameter_med){
if(count($medidaparameter)>0){
if(in_array($hermano['id'],$medidaparameter)) {
$medidas[$hermano['medida_real']] = array("nombre" => $hermano['medida_real'], "checked"=>true);
}
}
}
}
}
foreach ($productos as $producto){
/* @var $producto Producto */
$tecs = explode('/', $producto['tecnologia']);
foreach ($tecs as $tec){
$tec = trim($tec);
$tecnologias[$tec] = array("nombre"=>$tec, "checked"=>$this->isChecked($request,'tecnologia',$tec));
}
$tipologias[$producto['tipologia']] = array("nombre" => $producto['tipologia'], "checked"=>$this->isChecked($request,'tipologia',$producto['tipologia']));
if(!array_key_exists($producto['medida'],$medidas))
$medidas[$producto['medida']] = array("nombre" => $producto['medida'], "checked"=>$this->isChecked($request,'medida',$producto['medida']));
$adaptabilidades[$producto['adaptabilidad']] = array("nombre" => $producto['adaptabilidad'], "checked"=>$this->isChecked($request,'adaptabilidad',$producto['adaptabilidad']));
$independencias[$producto['independencia']] = array("nombre" => $producto['independencia'], "checked"=>$this->isChecked($request,'independencia',$producto['independencia']));
$gammas[$producto['gamma']] = array("nombre" => $producto['gamma'], "checked"=>$this->isChecked($request,'gamma',$producto['gamma']));
}
$filtros = array(
"Medida" => $medidas,
"Tipología" => $tipologias,
);
$idcategoria=null;
if($categoria){
$idcategoria=$categoria->getid();
}
$em = $this->getDoctrine()->getManager();
// cod dcto solo al agregar al carrito
$cods = $this->getDoctrine()->getRepository(CodigoDescuento::class)->createQueryBuilder('c')
->select('p.nombre','p.plu')
->leftJoin('c.productos','p')
->where('c.incarrito = true')
->andWhere('c.activo = true')
->getQuery()
->getResult();
foreach($productos as $p){
foreach($cods as $pc){
$pp=$p['plu'];
$codss=$pc['plu'];
if($pp == $codss){
$prod = $this->getDoctrine()->getRepository(Producto::class)->find(array('plu'=>$p['plu']));
$prod->setIncarrito(true);
$em->persist($prod);
$em->flush();
}else{
$prod = $this->getDoctrine()->getRepository(Producto::class)->find(array('plu'=>$p['plu']));
$prod->setIncarrito(false);
$em->persist($prod);
$em->flush();
}
}
}
if($categoria && $categoria->getId() == 6){
return $this->render('basic/promocionesIng.html.twig', [
'principal'=> $categoria,
'idprincipal'=> $idcategoria,
'productos' => $productos,
'subcategorias' => $subcategorias,
'titulo' => $titulo,
'plus' => $plus,
'cant' => count($productos),
]);
}
$referencia=null;
if($id_sub != null){
$referencia=$id_sub;
}
$idcategoria=null;
if($categoria){
$idcategoria=$categoria->getid();
}
return $this->render('basic/buscador.html.twig', [
'principal'=> $categoria,
'idprincipal'=> $idcategoria,
'productos' => $productos,
'preciomaximo' => $preciomax ,
'preciominimo' => $preciomin,
'preciomaximo_mobile' => $preciomax_mobile,
'preciominimo_mobile' => $preciomin_mobile,
'subcategorias' => $subcategorias,
'titulo' => $titulo,
'plus' => $plus,
'cant' => count($productos),
'filtros' => $filtros,
'idsubcategoria' => $id_sub,
'referencia'=>$referencia,
'subcategoria'=>$subcategoria
]);
}
private function isChecked(Request $request,$tipo,$valor){
$qi = $this->qi;
$tipo = $qi->slugify($tipo);
$campos = explode(',',$request->get($tipo));
// dd('request in isChecked ',$tipo,$campos,$request,in_array($valor, $campos));
return in_array($valor, $campos);
}
/**
* @param Request $request
* @param $tipos
* @param $columnas
* @param $query
* @return Query
*/
private function getQueryFilter(Request $request,$tipos, $columnas, $query){
$qi = $this->qi;
$keys = [];
$i = 0;
foreach ($tipos as $key=>$val){
$tipo = $qi->slugify($key);
if($request->get($tipo)){
$campos = explode(',',$request->get($tipo));
$cad = [];
if(count($campos) > 0){
foreach ($campos as $j=>$campo){
array_push($cad,'p.'.$columnas[$i].' like :query_'.$columnas[$i].'_'.$j.' ');
$query->setParameter('query_'.$columnas[$i].'_'.$j,'%'.$campo.'%');
}
$query->andWhere(implode($cad,' or '));
}
}
$i++;
}
return $query;
}
/**
* @Route("/producto/{id}/{tiendaId}", name="producto_old")
*/
public function producto_old(Request $request, $id,$tiendaId)
{
$tienda = $this->getDoctrine()->getRepository('App:Tienda')->find($tiendaId);
$productos = $this->getDoctrine()->getManager()->createQueryBuilder()
->from('App:Inventario','i')
->select('i')
->leftJoin('i.producto','p')
->addSelect('p')
->leftJoin('p.categorias','c')
->addSelect('c')
->where('i.tienda = :tienda')
->addSelect(
'CASE WHEN p.nombreComercial is not null and p.nombreComercial <> \'\' THEN p.nombreComercial ELSE p.nombre END AS nombrePublico')
->andWhere('i.cantidad > 0')
->andWhere('p.plu = :id')
->setParameter('tienda',$tienda)
->setParameter('id',$id)
->getQuery()
->getArrayResult();
return $this->render('basic/producto.html.twig', [
'producto' => $productos[0]
]);
}
/**
* @Route("/producto/{id}", name="producto")
*/
public function producto(Request $request, $id)
{
$tienda = $this->qi->getTienda();
if(!$tienda)
return $this->redirectToRoute('misdirecciones');
$producto = $this->getDoctrine()->getRepository('App:Producto')->find($id);
$inv = $this->getDoctrine()->getRepository('App:Inventario')->findOneBy(array('producto'=>$producto,'tienda'=>$tienda));
$cant = 0;
if($inv)
$cant = $inv->getCantidad();
//dd($tienda,$inv);
return $this->render('basic/producto.html.twig', [
'producto' => $producto,
'cantidad' => $cant
]);
}
/**
* @Route("/add-to-carrito/romance/add-to-carrito", name="add-to-carrito")
*/
public function addtocarrito(Request $request)
{
$body = json_decode($request->getContent());
$mensaje=array('ok' => false, 'mensaje' => "Ha ocurrido un error");
// if($body->cantidad > 0){
if($this->qi->addCantToCar($body->producto,$body->cantidad,$body->wish)) {
$mensaje = array('ok' => true, 'mensaje' => "Agregado al carrito ",'carrito'=>count($this->qi->getCarrito()));
if ($body->wish) {
$mensaje = array('ok' => true, 'mensaje' => "Agregado al wish list");
}
}
// }else{
// $this->qi->deleteItemFromCar($body->producto,$body->wish);
// $mensaje = array('ok' => true, 'mensaje' => "Eliminado del carrito");
// }
$response = new Response();
$response->setContent(json_encode($mensaje));
$response->headers->set('Content-Type', 'application/json');
// dd($response);
return $response;
}
/**
* @Route("/eliminar-carro/{id}", name="eliminar-carro")
*/
public function eliminarDeCarro(Request $request,$id)
{
$this->qi->deleteItemFromCar($id,"");
return $this->redirectToRoute('carrito');
}
/**
* @Route("/cambiar-cantidad/{id}/{cantidad}", name="cambiar-cantidad")
*/
public function cambiarCantidad(Request $request,$id,$cantidad)
{
if($cantidad > 0) {
$this->qi->addItemToCar($id, $cantidad, "");
}
else{
$this->qi->deleteItemFromCar($id, "");
}
return $this->redirectToRoute('carrito');
}
// /**
// * @Route("/carrito/romance/carrito", name="carrito")
// */
// public function carrito(Request $request)
// {
// $session = $request->getSession();
// $mostre_en_carrito = $session->get('cierre_carrito','0') == '1';
// $session->set('cierre_carrito','1');
// $ok = true;
// if($request->get('ok') != null ){
// $ok = $request->get('ok');
// }
// if(!$this->qi->getDireccion()){
// $this->addFlash(
// 'warning',
// 'Debes seleccionar una dirección antes de continuar'
// );
// return $this->redirectToRoute('misdirecciones');
// }
// /* @var $user Usuario */
// $user = $this->getUser();
// if(!$user->getNombre() || !$user->getApellido() || !$user->getCelular() || !$user->getDocumento())
// {
// $this->addFlash(
// 'warning',
// 'Debes actualizar tus datos para continuar con la compra.'
// );
// return $this->redirectToRoute('perfil');
// }
// if(!$this->qi->getTienda()){
// $tienda = $this->qi->getTiendaFromCoordinates($this->qi->getDireccion());
// $this->qi->setTienda($tienda);
// if(!$tienda){
// $this->addFlash(
// 'warning',
// 'La dirección seleccionada no tiene cobertura en este momento'
// );
// return $this->redirectToRoute('misdirecciones');
// }
// }
// $noDisp = $this->qi->validarCarrito();
// if(count($noDisp) ){
// $this->addFlash(
// 'warning',
// 'Algunos productos de tu carrito han sido eliminados ya que en la tienda actual no hay disponibilidad'
// );
// }
// $productos = $this->getDoctrine()->getRepository('App:Producto')->
// findBy(array('visible'=>true),array('orden'=>'desc'),7, rand(1,1500));
// return $this->render('basic/carrito.html.twig', [
// 'productos' => $productos,
// 'ok'=>$ok,
// 'mostre_en_carrito' => $mostre_en_carrito
// ]);
// }
/**
* @Route("/resumen_pedido/{id}", name="resumen_pedido")
*/
public function resumenPedido(Request $request,$id)
{
/* @var Compra $compra*/
$compra = $this->getDoctrine()->getRepository(Compra::class)->find($id);
$productos = $compra->getProductosObj();
return $this->render('basic/resumen.html.twig', [
'productos' => $productos,
'compra' => $compra
]);
}
/**
* @Route("/pedido_respuesta/romance/pedido_respuesta", name="pedido_respuesta")
*/
public function pedido_respuesta(Request $request)
{
$ok = true;
if($request->get('ok') != null ){
$ok = $request->get('ok');
}
if(!$this->qi->getDireccion()){
return $this->redirectToRoute('misdirecciones');
}
if(!$this->qi->getTienda()){
return $this->redirectToRoute('tienda');
}
return $this->render('basic/pedido_respuesta.html.twig', [
'ok'=>$ok
]);
}
// /**
// * @Route("/mapa_tiendas/romance/mapa_tiendas", name="mapaTiendas")
// */
// public function mapaTiendas(Request $request)
// {
// $tiendas = $this->getDoctrine()->getRepository(Tienda::class)->findBy(array('visible'=>true));
// return $this->render('basic/mapaTiendas.html.twig', [
// 'tiendas' => $tiendas,
// 'idprincipal' => $idprincipal=null
// ]);
// }
/**
* @Route("/direccion/romance/direccion", name="direccion")
*/
public function direccion(Request $request)
{
$productos = $this->getDoctrine()->getRepository('App:Producto')->
findBy(array('visible'=>true),array('orden'=>'desc'),7, rand(1,1500));
return $this->render('basic/direccion.html.twig', [
'productos' => $productos,
'idprincipal' => $idprincipal=null
]);
}
/**
* @Route("/confirmacion/romance/confirmacion", name="confirmacion")
*/
public function confirmation(Request $request)
{
$respuesta = $request->get('obj');
$compra = $this->getDoctrine()->getRepository(Compra::class)->find($respuesta["compra"]["id"]);
$productos = $this->qi->getCarrito();
$this->qi->clearCar("");
return $this->render('basic/pedido_respuesta.html.twig', [
'productos' => $productos,
'compra' => $compra,
'ok' => $request->get("ok"),
'idprincipal' => $idprincipal=null
]);
}
/**
* @Route("/ingresar/romance/ingresar", name="ingresar")
*/
public function ingresar(Request $request)
{
$errores = [];
$last_username = '';
/*if($request->isMethod('POST')){
$datos = $request->request->all();
$email = strtolower($datos['_username'] );
$last_username = $email;
$pass = strtolower($datos['_password'] );
try {
$serviceAccount = ServiceAccount::fromJsonFile(__DIR__.'/../../miveci-firebase-adminsdk-pteyb-91be53dc7d.json');
$firebase = (new Factory())
->withServiceAccount($serviceAccount)
->create();
$auth = $firebase->getAuth();
$fbuser = $auth->getUserByEmail($email);
$user = $this->userManager->findUserBy(array('email'=>$email));
$token = new UsernamePasswordToken($user, null, 'main', $user->getRoles());
$this->get('security.token_storage')->setToken($token);
$this->get('session')->set('_security_main', serialize($token));
$event = new InteractiveLoginEvent($request, $token);
//$this->get("event_dispatcher")->dispatch("security.interactive_login", $event);
$this->eventDispatcher->dispatch("security.interactive_login", $event);
if ($this->get('security.context')->isGranted('ROLE_POS_ADMIN')) {
return $this->redirectToRoute('easyadmin');
}else{
return $this->redirectToRoute('homepage');
}
} catch (Firebase\Exception\AuthException $e) {
array_push($errores, $e->getMessage());
//echo($e->getMessage());
//echo(dump($e));
//exit();
} catch (Firebase\Exception\FirebaseException $e) {
array_push($errores, $e->getMessage());
}
}
return $this->render('user/login.html.twig', [
'errores' => $errores,
'last_username' => $last_username,
'idprincipal' => $idprincipal=null
]);*/
}
/**
* @Route("/olvide/romance/olvide", name="olvide")
*/
public function olvide(Request $request)
{
return $this->render('user/olvide.html.twig', [
'idprincipal' => $idprincipal=null
]);
}
/**
* @Route("/crear-cuenta/romance/crear-cuenta", name="crear_cuenta")
*/
public function crearCuenta(Request $request)
{
$errores = [];
if($request->isMethod('POST')){
$datos = $request->request->all();
$properties = [
'displayName' => $datos['nombre'] . " " . $datos['apellido'] ,
'email' => strtolower($datos['email'] ),
'emailverified' => true
];
}
return $this->render('user/registro.html.twig', [
'errores' => $errores,
'idprincipal' => $idprincipal=null
]);
}
/**
* @Route("/load/romance/load", name="load")
*/
public function load(Request $request)
{
/*
$prods = $this->getDoctrine()->getRepository(Inventario::class)->findAll();
foreach ($prods as $inv){
$this->qi->saveFire($inv);
}
*/
// dd(12);
//return $this->redirectToRoute('easyadmin');
//$this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY');
}
/**
* @Route("/preguntas_frecuentes/romance/preguntas_frecuentes", name="preguntas_frecuentes")
*/
public function preguntasFrecuentes(Request $request)
{
$preguntas = $this->getDoctrine()->getRepository(Faq::class)->findBy(array("visible"=>true),array("orden"=>"asc"));
return $this->render('basic/preguntas.html.twig', [
"preguntas" => $preguntas,
'idprincipal' => $idprincipal=null
]);
}
/**
* @Route("/privacidad/romance/privacidad", name="privacidad")
*/
public function privacidad(Request $request)
{
return $this->render('basic/politica.html.twig', [
'llave'=>'politica_privacidad',
'titulo'=> 'Políticas de privacidad',
'idprincipal' => $idprincipal=null
]);
}
/**
* @Route("/terminos/romance/terminos", name="terminos")
*/
public function terminos(Request $request)
{
return $this->render('basic/politica.html.twig', [
'llave'=>'terminos',
'titulo'=> 'Términos y condiciones',
'idprincipal' => $idprincipal=null
]);
}
/**
* @Route("/politica/romance/politica", name="politica")
*/
public function politica(Request $request)
{
return $this->render('basic/politica.html.twig', [
'llave'=>'politica_promocion',
'titulo'=> 'Políticas de promoción',
'idprincipal' => $idprincipal=null
]);
}
/**
* @Route("/politica_promocion/romance/politica_promocion", name="politica_promocion")
*/
public function politicaPromocion(Request $request)
{
$politicas = $this->getDoctrine()->getRepository(PoliticaPromocion::class)->findBy(array("visible"=>true),array("orden"=>"asc"));
return $this->render('basic/privacidad.html.twig', [
"politicas" => $politicas,
'llave'=>'politica_promocion',
'titulo'=> 'Políticas de promoción',
'idprincipal' => $idprincipal=null
]);
}
/**
* @Route("/politica_entrega/romance/politica_entrega", name="politica_entrega")
*/
public function politicaEntrega(Request $request)
{
return $this->render('basic/politica.html.twig', [
'llave'=>'politica_entrega',
'titulo'=> 'Política de entrega y devolución',
'idprincipal' => $idprincipal=null
]);
}
/**
* @Route("/ajax-cart/romance/ajax-cart", name="ajax-cart")
*/
public function ajaxCart(Request $request)
{
return $this->render('cart/ajaxcart.html.twig', [
'idprincipal' => $idprincipal=null
]);
}
/**
* @Method({"GET"})
* @Route("/api/clientify/create/{id}", name="crear_usuario_clientify")
*/
public function crearUsuarioClientify(Request $request,$id)
{
$usuario = $this->getDoctrine()->getRepository('App:Usuario')->find($id);
$this->clientify->CrearContacto($usuario);
// dd($usuario);
}
/**
* @Method({"POST"})
* @Route("/api/auth/register", name="crear_actualizar_usuario")
*/
public function crearActualizarUsuario(Request $request)
{
$logged = $this->getUser();
$um = $this->userManager;
$body = json_decode($request->getContent());
// dd($body);
/* @var $user Usuario */
$user = $um->findUserBy(array('uid'=>$body->uid));
if(!$user){
$user = $um->findUserBy(array('email'=>$body->email));
}
if(!$user){
$user = $um->createUser();
$user->setUid($body->uid);
$user->setEmail($body->email);
$user->setUsername($body->email);
$user->setCelular($body->telefono);
$user->setUsernameCanonical($body->email);
$user->setProviderData(json_encode($body->providerData));
$user->setEnabled(true);
$user->setPassword('redes123');
$user->setCreatedAt(new \DateTime());
// enviar correo de bienvenida
// $mensaje = str_replace('%nombre%', '', $this->qi->getTextoBig('mail-bienvenida'));
$mensaje = $this->renderView('mailing/agradecimiento-registro.html.twig', array(
// 'nombre'=>$user->getNombre(),
'email'=>$user->getEmail(),
// 'telefono'=>$user->getTelefono(),
// 'mensaje'=>$user->getMensaje(),
));
$this->qi->sendMail($this->qi->getTexto('asunto_bienvenida'), $body->email,$mensaje);
if(property_exists($body,'nombre')){
$user->setNombre($body->nombre);
}
if(property_exists($body,'apellido')){
$user->setApellido($body->apellido);
}
if(property_exists($body,'telefono')){
$user->setCelular($body->telefono);
}
if(property_exists($body,'convenio')){
$convenio = $this->getDoctrine()->getRepository('App:ListaPrecios')->findOneBy(array('codigo'=>$body->convenio));
if($convenio)
$user->setConvenio($convenio);
}
if(property_exists($body,'uid')){
$user->setUid($body->uid);
}
}
$em = $this->getDoctrine()->getManager();
$em->persist($user);
$em->flush();
$um->updateUser($user);
// dd($user);
// clientify
$this->clientify->CrearContacto($user);
$token = new UsernamePasswordToken($user, null, 'main', $user->getRoles());
$this->get('security.token_storage')->setToken($token);
$this->get('session')->set('_security_main', serialize($token));
$event = new InteractiveLoginEvent($request, $token);
//$this->get("event_dispatcher")->dispatch("security.interactive_login", $event);
$this->eventDispatcher->dispatch("security.interactive_login", $event);
if ($this->authorization->isGranted('ROLE_POS_ADMIN')) {
$resultado= array("ok"=>true,'obj'=>$user,'url'=> $this->generateUrl('homepage'));
}else{
if($this->qi->carritoLength() > 0){
if($this->qi->getDireccion())
$ruta = $this->generateUrl('carrito');
else
$ruta = $this->generateUrl('misdirecciones');
}
else
$ruta = $this->generateUrl('homepage');
$resultado= array("ok"=>true,'obj'=>$user,'url'=> $ruta);
}
$prlog= false;
if($logged){
$prlog = true;
}
return new Response(json_encode(array("preloged"=>$prlog,"id"=>$user->getId())));
}
/**
* @Method({"POST"})
* @Route("/api/direccion", name="crear_direccion")
*/
public function crearDireccion(Request $request)
{
$body = json_decode($request->getContent());
//dd($body);
$qi = $this->qi;
$user = $this->getDoctrine()->getRepository(Usuario::class)->findOneBy(array('uid'=>$body->uid));
$ciudad = $this->getDoctrine()->getRepository(Ciudad::class)->find($body->ciudad->id);
$news = new Direccion();
$news->setUsuario($user);
$news->setNombre($body->nombre);
$news->setCiudad($ciudad);
$news->setDireccion($body->direccion." ".$body->adicional);
$news->setLat($body->lat);
$news->setLng($body->lng);
$news->setUid($body->uid);
$news->setPredeterminada($body->predeterminada);
$em = $this->getDoctrine()->getManager();
$em->persist($news);
$em->flush();
$qi->saveFire($news);
$resultado= array("ok"=>true,'obj'=>$news);
$encoders = array(new XmlEncoder(), new JsonEncoder());
$normalizer = new ObjectNormalizer();
$normalizer->setCircularReferenceLimit(1);
// Add Circular reference handler
$normalizer->setCircularReferenceHandler(function ($object) {
return $object->getId();
});
$normalizers = array($normalizer);
$serializer = new Serializer($normalizers, $encoders);
$json = $serializer->serialize($resultado,'json');
return new Response($json);
}
/**
* @Method({"POST"})
* @Route("/api/historial/{uid}", name="historial")
*/
public function historial(Request $request,$uid)
{
//$body = json_decode($request->getContent());
// dd($uid);
$qi = $this->qi;
$user = $this->getDoctrine()->getRepository(Usuario::class)->findOneBy(array('uid'=>$uid));
$compras = $this->getDoctrine()->getManager()->createQueryBuilder()
->from('App:Compra','c')
->addSelect('c')
->leftJoin('c.tienda','t')
->addSelect('t')
->leftJoin('c.direccion','d')
->addSelect('d')
->where('c.usuario = :usuario')
->setParameter('usuario',$user)
->getQuery()
->getArrayResult();
//dd($compras);
$resultado= array("ok"=>true,'historial'=>$compras);
$encoders = array(new XmlEncoder(), new JsonEncoder());
$normalizer = new ObjectNormalizer();
$normalizer->setCircularReferenceLimit(1);
// Add Circular reference handler
$normalizer->setCircularReferenceHandler(function ($object) {
return $object->getId();
});
$normalizers = array($normalizer);
$serializer = new Serializer($normalizers, $encoders);
$json = $serializer->serialize($resultado,'json');
return new Response($json);
}
function crearPedido($user,$direccion,$metodo,$tienda,$costo_domicilio,$comentarios,$peticion,$paga_con,$carrito,$canal){
$qi = $this->qi;
$em = $this->getDoctrine()->getManager();
$estado = $this->getDoctrine()->getRepository(EstadoPedido::class)->findOneBy(array('ref' => 'creado'));
$subtotal = 0;
$total = 0;
$news = new Compra();
$news->setCreatedAt(new \DateTime());
$news->setDireccion($direccion);
$news->setUsuario($user);
$news->setFechaRealProcesamiento(new \DateTime());
$news->setEstado($estado);
$news->setEstadoProcesamiento("nuevo");
$news->setCostoDomicilio($costo_domicilio);
$news->setComentarios($comentarios);
$news->setBody(json_encode($peticion));
$news->setCanal($canal);
$news->setMetodo($metodo);
$news->setPagaCon($paga_con);
$news->setSubtotal($subtotal);
$news->setTienda($tienda);
$total = $subtotal + $costo_domicilio;
$news->setTotal($total);
$em->persist($news);
$em->flush();
foreach ($carrito as $item) {
if ($canal == 'app') {
$product_id = $item->product_id;
$count = $item->count;
} else {
$product_id = $item["product_id"];
$count = $item["count"];
}
$prod = $this->getDoctrine()->getRepository(Producto::class)->findOneBy(array('plu' => $product_id));
if($this->qi->getSetting('pedido_multitienda') != '1')
$inv = $this->getDoctrine()->getRepository(Inventario::class)->findOneBy(array('producto' => $prod, 'tienda' => $tienda));
else
$inv = $this->getDoctrine()->getRepository(Inventario::class)->findOneBy(array('producto' => $prod));
if ($inv) {
$subtotal = $subtotal + $inv->getPrecio() * $count;
$newci = new CompraItem();
$newci->setProducto($prod);
$newci->setPrecio($inv->getPrecio() * $count);
$newci->setCantidad($count);
$newci->setCompra($news);
$newci->setCosto($inv->getPrecio());
$em->persist($newci);
$em->flush();
$qi->saveFire($newci);
} else {
}
}
$news->setSubtotal($subtotal);
$total = $subtotal + $costo_domicilio;
$news->setTotal($total);
$em->persist($news);
$em->flush();
$qi->saveFire($news);
$obj = array('tienda' => $tienda,
'compra' => array('id' => $news->getId(),
'total' => $news->getTotal(),
'estado' => $news->getEstadoProcesamiento(),
'subtotal' => $news->getSubtotal(),
'costoDomicilio' => $news->getCostoDomicilio(),
)
);
$resultado = array("ok" => true, 'obj' => $obj);
$qi->updateListenerTienda($tienda);
return $resultado;
}
/**
* @Route("/import/romance/import", name="import")
*/
public function import(Request $request)
{
/*$categorias = $this->getDoctrine()->getRepository('App:Producto')->findAll();
foreach ($categorias as $categoria){
$this->qi->saveFire($categoria);
}*/
/*
$em = $this->getDoctrine()->getManager();
$data = json_decode($request->getContent(), true);
foreach ($data as $producto){
$producto_in = new Producto();
$producto_in->setPlu($producto['sku']);
$producto_in->setNombre($producto['nombreEs']);
$producto_in->setImagen($producto['imagen']);
$producto_in->setOrden(1);
$producto_in->setPrecio(0);
$producto_in->setVisible(true);
if(is_numeric($producto['id'])){
$categoria = $this->getDoctrine()->getRepository('App:Categoria')->find($producto['id']);
$producto_in->addCategoria($categoria);
}
$em->persist($producto_in);
}
$em->flush();
die();
foreach ($data as $categoria){
$categoria_in = new Categoria();
$categoria_in->setNombre($categoria['nombre']);
$categoria_in->setImagen($categoria['imagen']);
$categoria_in->setVisible(true);
$categoria_in->setOrden($categoria['orden']);
$em->persist($categoria_in);
}
$em->flush();
die();
return $this->redirectToRoute('easyadmin');
*/
//$this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY');
}
/**
* @Route("/resetting/iridian", name="reset-iridian")
*/
public function sendEmailAction(Request $request)
{
$username = $request->request->get('username');
$user = $this->userManager->findUserByUsernameOrEmail($username);
$event = new GetResponseNullableUserEvent($user, $request);
if (null !== $event->getResponse()) {
return $event->getResponse();
}
if (null !== $user && !$user->isPasswordRequestNonExpired($this->retryTtl)) {
$event = new GetResponseUserEvent($user, $request);
if (null !== $event->getResponse()) {
return $event->getResponse();
}
if (null === $user->getConfirmationToken()) {
$user->setConfirmationToken($this->tokenGenerator->generateToken());
}
$event = new GetResponseUserEvent($user, $request);
if (null !== $event->getResponse()) {
return $event->getResponse();
}
$this->sendResettingEmailMessage($user);
$user->setPasswordRequestedAt(new \DateTime());
$this->userManager->updateUser($user);
$event = new GetResponseUserEvent($user, $request);
if (null !== $event->getResponse()) {
return $event->getResponse();
}
}
return new RedirectResponse($this->generateUrl('fos_user_resetting_check_email', array('username' => $username)));
}
public function sendResettingEmailMessage(UserInterface $user)
{
$url = $this->generateUrl('fos_user_resetting_reset', array('token' => $user->getConfirmationToken()), UrlGeneratorInterface::ABSOLUTE_URL);
$mensaje= str_replace('%link%','<a href="'.$url.'">link</a>',$this->qi->getTextoBig('mail_contrasena'));
//$this->qi->sendMailPHP($this->qi->getTexto('asunto_mail_resetting'),$user->getEmail(),$mensaje) ;
}
/**
* @Route("/fullreload", name="fullreload")
*/
/*
public function fullreload(Request $request)
{
$productos = $this->getDoctrine()->getRepository('App:Producto')
->createQueryBuilder('p')
->select('p','c as cats')
->leftJoin('p.categorias','c')
->where('c.id is not null')
//->setMaxResults(2)
->getQuery()
->getArrayResult();
$prods = array();
foreach ($productos as $producto){
$cat = $producto['categorias'][0]['id'];
$producto['categorias'] = array($cat);
$prods[$producto['plu']] = $producto;
}
$this->qi->saveMultiFire('Producto',$prods);
dd($prods);
return $this->render('basic/template.html.twig', [
]);
}
*/
/**
* @Route("/load", name="load")
*/
/*
public function load(Request $request)
{
$em = $this->getDoctrine()->getManager();
$precios = array(10000, 5000, 7900, 12000, 17000, 20500,9000, 500, 300, 1000, 14500);
$productos = $this->getDoctrine()->getRepository('App:Producto')->findAll();
$tiendas = $this->getDoctrine()->getRepository('App:Tienda')->findAll();
foreach ($tiendas as $tienda){
$cont = 0;
foreach ($productos as $producto){
if($cont >= count($precios))
$cont = 0;
$inventario = new Inventario();
$inventario->setCantidad(1);
$inventario->setProducto($producto);
$inventario->setPrecio($precios[$cont]);
$inventario->setTienda($tienda);
$cont++;
$em->persist($inventario);
$em->flush();
$this->qi->saveFire($inventario);
}
}
return $this->render('basic/template.html.twig', [
]);
}
*/
/**
* @Route("/mispedidos/romance/mispedidos", name="mispedidos")
*/
public function mispedidos(Request $request)
{
$user = $this->getUser();
if(!$user){
return $this->redirectToRoute('homepage');
}
$aprobado = $this->getDoctrine()->getRepository(EstadoPedido::class)->findBy(array('ref'=>'APPROVED'));
$pedidos = $this->getDoctrine()->getRepository(Compra::class)->findBy(array("usuario"=>$user,'estado'=>$aprobado), array("createdAt"=>"desc"));
return $this->render('basic/pedidos.html.twig', [
'pedidos' => $pedidos,
'idprincipal' => $idprincipal=null
]);
}
/**
* @Route("/mailingcompra/romance/mailingcompra", name="mailingcompra")
*/
public function mailingcompra(Request $request)
{
$compra = $this->getDoctrine()->getRepository('App:Compra')->findOneBy(array(), array('id'=>'desc'));
$asunto = $this->qi->getSetting('asunto_compra_cliente');
$mail = $this->renderView('mailing/pedido.html.twig',array('compra'=>$compra));
$this->qi->sendMail($asunto, 'laura@iridian.co', $mail);
return $this->render('mailing/pedido.html.twig', array(
'compra'=>$compra,
'idprincipal' => $idprincipal=null
));
}
/**
* @Route("/mailingcontacto/romance/mailingcontacto", name="mailingcontacto")
*/
public function mailingcontacto(Request $request)
{
//$compra = $this->getDoctrine()->getRepository('App:Contacto')->findOneBy(array(), array('id'=>'desc'));
$asunto = $this->qi->getTexto('asunto_compra_cliente');
//$mail = $this->renderView('mailing/compra.html.twig',array('compra'=>$compra));
//dd($this->qi->sendMail($asunto, 'mauricio@iridian.co', $mail));
return $this->render('contact/contact_mail.html.twig', array(
'nombre'=>'Luisa',
'email'=>'samuel@iridian.co',
'telefono'=>'3002111111',
'mensaje'=>'Hola quiero saber si venden traumel en tabletas',
));
}
/**
* @Route("/load_images/romance/load_images", name="load_images")
*/
public function load_images(Request $request)
{
$em = $this->getDoctrine()->getManager();
$imgs = [[90069577,1,'jpg'], [90069577,2,'jpg'], [90069577,3,'jpg'], [90069788,1,'jpg'], [90069788,2,'jpg'], [90069788,3,'jpg'], [90069789,1,'jpg'], [90069789,2,'jpg'], [90069789,3,'jpg'], [90069790,1,'jpg'], [90069790,2,'jpg'], [90069790,3,'jpg'], [90070677,1,'jpg'], [90070677,2,'jpg'], [90070677,3,'jpg'], [90071645,1,'jpg'], [90071645,2,'jpg'], [90072962,1,'jpg'], [90072962,2,'jpg'], [90072962,3,'jpg'], [90072967,1,'png'], [90072967,2,'jpg'], [90072967,3,'jpg'], [90073014,1,'jpg'], [90073014,2,'jpg'], [90073015,1,'jpg'], [90073015,2,'jpg'], [90073016,1,'jpg'], [90073016,2,'jpg'], [90073220,1,'png'], [90073220,2,'jpg'], [90073220,3,'jpg'], [90073223,1,'png'], [90073223,2,'jpg'], [90073223,3,'jpg'], [90073225,1,'png'], [90073225,2,'jpg'], [90073225,3,'jpg'], [90073228,1,'png'], [90073228,2,'jpg'], [90073228,3,'jpg'], [90073231,1,'png'], [90073231,2,'jpg'], [90073231,3,'jpg'], [90073241,1,'png'], [90073241,2,'jpg'], [90073241,3,'jpg'], [90073244,1,'png'], [90073244,2,'jpg'], [90073244,3,'jpg'], [90073249,1,'jpg'], [90073249,2,'jpg'], [90073249,3,'jpg'], [90073252,1,'jpg'], [90073252,2,'jpg'], [90073252,3,'jpg'], [90073257,1,'jpg'], [90073257,2,'jpg'], [90073257,3,'jpg'], [90073260,1,'jpg'], [90073260,2,'jpg'], [90073260,3,'jpg'], [90074207,1,'jpg'], [90074207,2,'jpg'], [90074207,3,'jpg'], [90074209,1,'jpg'], [90074209,2,'jpg'], [90074209,3,'jpg'], [90074211,1,'jpg'], [90074211,2,'jpg'], [90074211,3,'jpg'], [90075022,1,'jpg'], [90075022,2,'jpg'], [90075294,1,'png'], [90075294,2,'jpg'], [90075294,3,'jpg'], [90075295,1,'png'], [90075295,2,'jpg'], [90075295,3,'jpg'], [90075342,1,'jpg'], [90075342,2,'jpg'], [90075342,3,'jpg'], [90075348,1,'jpg'], [90075348,2,'jpg'], [90075349,1,'jpg'], [90075349,2,'jpg'], [90075467,1,'jpg'], [90075467,2,'jpg'], [90075467,3,'jpg'], [90075467,4,'jpg'], [90075467,5,'png'], [90075468,1,'jpg'], [90075468,2,'jpg'], [90075468,3,'jpg'], [90075468,4,'jpg'], [90075468,5,'png'], [90075469,1,'jpg'], [90075469,2,'jpg'], [90075469,3,'jpg'], [90075469,4,'jpg'], [90075469,5,'png'], [90075512,1,'jpg'], [90075512,2,'jpg'], [90075512,3,'jpg'], [90075512,4,'jpg'], [90075512,5,'png'], [90075513,1,'jpg'], [90075513,2,'jpg'], [90075513,3,'jpg'], [90075513,4,'jpg'], [90075513,5,'png'], [90076166,1,'jpg'], [90076166,2,'jpg'], [90076166,3,'jpg'], [90076166,4,'jpg'], [90076166,5,'png'], [90076166,6,'jpg'], [90076167,1,'jpg'], [90076167,2,'jpg'], [90076167,3,'jpg'], [90076167,4,'jpg'], [90076167,5,'png'], [90076167,6,'jpg'], [90076168,1,'jpg'], [90076168,2,'jpg'], [90076168,3,'jpg'], [90076168,4,'jpg'], [90076168,5,'png'], [90076168,6,'jpg'], [90076168,7,'jpg'], [90076168,8,'jpg'], [90076169,1,'jpg'], [90076169,2,'jpg'], [90076169,3,'jpg'], [90076169,4,'jpg'], [90076169,5,'png'], [90076169,6,'jpg'], [90076169,7,'jpg'], [90076169,8,'jpg'], [90076195,1,'jpg'], [90076195,2,'jpg'], [90076195,3,'jpg'], [90076195,4,'jpg'], [90076195,5,'png'], [90076195,6,'jpg'], [90076195,7,'jpg'], [90076195,8,'jpg'], [90076196,1,'jpg'], [90076196,2,'jpg'], [90076196,3,'jpg'], [90076196,4,'jpg'], [90076196,5,'png'], [90076196,6,'jpg'], [90076196,7,'jpg'], [90076196,8,'jpg'], [90076485,1,'jpg'], [90076485,2,'jpg'], [90076486,1,'jpg'], [90076486,2,'jpg'], [90077226,1,'jpg'], [90077226,2,'jpg'], [90077226,3,'jpg'], [90077588,1,'jpg'], [90077588,2,'jpg'], [90077588,3,'jpg'], [90077589,1,'jpg'], [90077589,2,'jpg'], [90077589,3,'jpg'], [90077590,1,'jpg'], [90077590,2,'jpg'], [90077590,3,'jpg'], [90077591,1,'jpg'], [90077591,2,'jpg'], [90077591,3,'jpg'], [90077592,1,'jpg'], [90077592,2,'jpg'], [90077592,3,'jpg'], [90077616,1,'jpg'], [90077616,2,'jpg'], [90077616,3,'jpg'], [90077616,4,'jpg'], [90077616,5,'jpg'], [90077616,6,'jpg'], [90077616,7,'jpg'], [90077616,8,'jpg'], [90077616,9,'jpg'], [90077876,1,'jpg'], [90077876,2,'jpg'], [90077876,3,'png'], [90077877,1,'jpg'], [90077877,2,'jpg'], [90078113,1,'jpg'], [90078113,2,'jpg'], [90078113,3,'jpg'], [90078113,4,'jpg'], [90078142,1,'jpg'], [90078142,2,'jpg'], [90078142,3,'jpg'], [90078142,4,'jpg'], [90078142,5,'jpg'], [90078143,1,'jpg'], [90078143,2,'jpg'], [90078143,3,'jpg'], [90078143,4,'jpg'], [90078143,5,'png'], [90078144,1,'jpg'], [90078144,2,'jpg'], [90078144,3,'jpg'], [90078144,4,'jpg'], [90078144,5,'jpg'], [90078145,1,'jpg'], [90078145,2,'jpg'], [90078145,3,'jpg'], [90078145,4,'jpg'], [90078145,5,'png'], [90078146,1,'jpg'], [90078146,2,'jpg'], [90078146,3,'jpg'], [90078146,4,'jpg'], [90078146,5,'jpg'], [90078147,1,'jpg'], [90078147,2,'jpg'], [90078147,3,'jpg'], [90078147,4,'jpg'], [90078147,5,'png'], [90078355,1,'jpg'], [90078355,2,'jpg'], [90078355,3,'jpg'], [90078355,4,'jpg'], [90078355,5,'png'], [90078356,1,'jpg'], [90078356,2,'jpg'], [90078356,3,'jpg'], [90078356,4,'jpg'], [90078356,5,'png'], [90078357,1,'jpg'], [90078357,2,'jpg'], [90078357,3,'jpg'], [90078357,4,'jpg'], [90078357,5,'png'], [90078358,1,'jpg'], [90078358,2,'jpg'], [90078358,3,'jpg'], [90078358,4,'jpg'], [90078358,5,'png'], [90078359,1,'jpg'], [90078359,2,'jpg'], [90078359,3,'jpg'], [90078359,4,'jpg'], [90078359,5,'png'], [90078361,1,'jpg'], [90078361,2,'jpg'], [90078361,3,'jpg'], [90078361,4,'jpg'], [90078361,5,'png'], [90078362,1,'jpg'], [90078362,2,'jpg'], [90078362,3,'jpg'], [90078362,4,'jpg'], [90078362,5,'png'], [90078363,1,'jpg'], [90078363,2,'jpg'], [90078363,3,'jpg'], [90078363,4,'jpg'], [90078363,5,'png'], [90078364,1,'jpg'], [90078364,2,'jpg'], [90078364,3,'jpg'], [90078364,4,'jpg'], [90078364,5,'jpg'], [90078365,1,'jpg'], [90078365,2,'jpg'], [90078365,3,'jpg'], [90078365,4,'jpg'], [90078365,5,'jpg'], [90078366,1,'jpg'], [90078366,2,'jpg'], [90078366,3,'jpg'], [90078366,4,'jpg'], [90078366,5,'jpg'], [90078367,1,'jpg'], [90078367,2,'jpg'], [90078367,3,'jpg'], [90078367,4,'jpg'], [90078367,5,'jpg'], [90078373,1,'jpg'], [90078373,2,'jpg'], [90078373,3,'jpg'], [90078373,4,'jpg'], [90078373,5,'png'], [90078374,1,'jpg'], [90078374,2,'jpg'], [90078374,3,'jpg'], [90078374,4,'jpg'], [90078374,5,'png'], [90078375,1,'jpg'], [90078375,2,'jpg'], [90078375,3,'jpg'], [90078375,4,'jpg'], [90078375,5,'png'], [90078376,1,'jpg'], [90078376,2,'jpg'], [90078376,3,'jpg'], [90078376,4,'jpg'], [90078376,5,'png'], [90078377,1,'jpg'], [90078377,2,'jpg'], [90078377,3,'jpg'], [90078377,4,'jpg'], [90078378,1,'jpg'], [90078378,2,'jpg'], [90078378,3,'jpg'], [90078378,4,'jpg'], [90078379,1,'jpg'], [90078379,2,'jpg'], [90078379,3,'jpg'], [90078379,4,'jpg'], [90078380,1,'jpg'], [90078380,2,'jpg'], [90078380,3,'jpg'], [90078380,4,'jpg'], [90078381,1,'jpg'], [90078381,2,'jpg'], [90078381,3,'jpg'], [90078381,4,'jpg'], [90078381,5,'jpg'], [90078383,1,'jpg'], [90078383,2,'jpg'], [90078383,3,'jpg'], [90078383,4,'jpg'], [90078383,5,'jpg'], [90078384,1,'jpg'], [90078384,2,'jpg'], [90078384,3,'jpg'], [90078384,4,'jpg'], [90078384,5,'jpg'], [90078385,1,'jpg'], [90078385,2,'jpg'], [90078385,3,'jpg'], [90078385,4,'jpg'], [90078385,5,'jpg'], [90078386,1,'jpg'], [90078386,2,'jpg'], [90078386,3,'jpg'], [90078386,4,'jpg'], [90078386,5,'jpg'], [90078387,1,'jpg'], [90078387,2,'jpg'], [90078387,3,'jpg'], [90078387,4,'jpg'], [90078387,5,'jpg'], [90078388,1,'jpg'], [90078388,2,'jpg'], [90078388,3,'jpg'], [90078388,4,'jpg'], [90078388,5,'jpg'], [90078389,1,'jpg'], [90078389,2,'jpg'], [90078389,3,'jpg'], [90078389,4,'jpg'], [90078389,5,'jpg'], [90078487,1,'jpg'], [90078487,2,'jpg'], [90078487,3,'jpg'], [90078487,4,'jpg'], [90078487,5,'jpg'], [90078487,6,'jpg'], [90078487,7,'jpg'], [90078488,1,'jpg'], [90078488,2,'jpg'], [90078488,3,'jpg'], [90078488,4,'jpg'], [90078488,5,'jpg'], [90078488,6,'jpg'], [90078488,7,'jpg'], [90078489,1,'jpg'], [90078489,2,'jpg'], [90078489,3,'jpg'], [90078489,4,'jpg'], [90078489,5,'jpg'], [90078489,6,'jpg'], [90078489,7,'jpg'], [90078490,1,'jpg'], [90078490,2,'jpg'], [90078490,3,'jpg'], [90078490,4,'jpg'], [90078490,5,'jpg'], [90078490,6,'jpg'], [90078490,7,'jpg'], [90078491,1,'jpg'], [90078491,2,'jpg'], [90078491,3,'jpg'], [90078491,4,'jpg'], [90078491,5,'jpg'], [90078491,6,'jpg'], [90078491,7,'jpg'], [90078492,1,'jpg'], [90078492,2,'jpg'], [90078492,3,'jpg'], [90078492,4,'jpg'], [90078492,5,'png'], [90078492,6,'jpg'], [90078492,7,'jpg'], [90078493,1,'jpg'], [90078493,2,'jpg'], [90078493,3,'jpg'], [90078493,4,'jpg'], [90078493,5,'png'], [90078493,6,'jpg'], [90078493,7,'jpg'], [90078494,1,'jpg'], [90078494,2,'jpg'], [90078494,3,'jpg'], [90078494,4,'jpg'], [90078494,5,'png'], [90078494,6,'jpg'], [90078494,7,'jpg'], [90078495,1,'jpg'], [90078495,2,'jpg'], [90078495,3,'jpg'], [90078495,4,'jpg'], [90078495,5,'png'], [90078495,6,'jpg'], [90078495,7,'jpg'], [90078496,1,'jpg'], [90078496,2,'jpg'], [90078496,3,'jpg'], [90078496,4,'jpg'], [90078496,5,'png'], [90078496,6,'jpg'], [90078496,7,'jpg'], [90078497,1,'jpg'], [90078497,2,'jpg'], [90078497,3,'jpg'], [90078497,4,'jpg'], [90078497,5,'jpg'], [90078497,6,'jpg'], [90078497,7,'jpg'], [90078498,1,'jpg'], [90078498,2,'jpg'], [90078498,3,'jpg'], [90078498,4,'jpg'], [90078498,5,'jpg'], [90078498,6,'jpg'], [90078498,7,'jpg'], [90078499,1,'jpg'], [90078499,2,'jpg'], [90078499,3,'jpg'], [90078499,4,'jpg'], [90078499,5,'jpg'], [90078499,6,'jpg'], [90078499,7,'jpg'], [90078500,1,'jpg'], [90078500,2,'jpg'], [90078500,3,'jpg'], [90078500,4,'jpg'], [90078500,5,'jpg'], [90078500,6,'jpg'], [90078500,7,'jpg'], [90078501,1,'jpg'], [90078501,2,'jpg'], [90078501,3,'jpg'], [90078501,4,'jpg'], [90078501,5,'jpg'], [90078501,6,'jpg'], [90078501,7,'jpg'], [90078507,1,'jpg'], [90078507,2,'jpg'], [90078507,3,'jpg'], [90078507,4,'jpg'], [90078507,5,'png'], [90078507,6,'jpg'], [90078507,7,'jpg'], [90078507,8,'jpg'], [90078507,9,'jpg'], [90078508,1,'jpg'], [90078508,2,'jpg'], [90078508,3,'jpg'], [90078508,4,'jpg'], [90078508,5,'png'], [90078508,6,'jpg'], [90078508,7,'jpg'], [90078508,8,'jpg'], [90078508,9,'jpg'], [90078509,1,'jpg'], [90078509,2,'jpg'], [90078509,3,'jpg'], [90078509,4,'jpg'], [90078509,5,'png'], [90078509,6,'jpg'], [90078509,7,'jpg'], [90078509,8,'jpg'], [90078509,9,'jpg'], [90078510,1,'jpg'], [90078510,2,'jpg'], [90078510,3,'jpg'], [90078510,4,'jpg'], [90078510,5,'png'], [90078510,6,'jpg'], [90078510,7,'jpg'], [90078510,8,'jpg'], [90078510,9,'jpg'], [90078511,1,'jpg'], [90078511,2,'jpg'], [90078511,3,'jpg'], [90078511,4,'jpg'], [90078511,5,'png'], [90078511,6,'jpg'], [90078511,7,'jpg'], [90078511,8,'jpg'], [90078511,9,'jpg'], [90078512,1,'jpg'], [90078512,2,'jpg'], [90078512,3,'jpg'], [90078512,4,'jpg'], [90078512,5,'png'], [90078512,6,'jpg'], [90078512,7,'jpg'], [90078513,1,'jpg'], [90078513,2,'jpg'], [90078513,3,'jpg'], [90078513,4,'jpg'], [90078513,5,'png'], [90078513,6,'jpg'], [90078513,7,'jpg'], [90078514,1,'jpg'], [90078514,2,'jpg'], [90078514,3,'jpg'], [90078514,4,'jpg'], [90078514,5,'png'], [90078514,6,'jpg'], [90078514,7,'jpg'], [90078515,1,'jpg'], [90078515,2,'jpg'], [90078515,3,'jpg'], [90078515,4,'jpg'], [90078515,5,'png'], [90078515,6,'jpg'], [90078515,7,'jpg'], [90078516,1,'jpg'], [90078516,2,'jpg'], [90078516,3,'jpg'], [90078516,4,'jpg'], [90078516,5,'png'], [90078516,6,'jpg'], [90078516,7,'jpg'], [90078694,1,'jpg'], [90078694,2,'jpg'], [90078694,3,'jpg'], [90078694,4,'jpg'], [90078694,5,'jpg'], [90078694,6,'jpg'], [90078695,1,'jpg'], [90078695,2,'jpg'], [90078695,3,'jpg'], [90078695,4,'jpg'], [90078695,5,'jpg'], [90078695,6,'jpg'], [90078696,1,'jpg'], [90078696,2,'jpg'], [90078696,3,'jpg'], [90078696,4,'jpg'], [90078696,5,'jpg'], [90078696,6,'jpg'], [90078697,1,'jpg'], [90078697,2,'jpg'], [90078697,3,'jpg'], [90078697,4,'jpg'], [90078697,5,'jpg'], [90078697,6,'jpg'], [90078698,1,'jpg'], [90078698,2,'jpg'], [90078698,3,'jpg'], [90078698,4,'jpg'], [90078698,5,'jpg'], [90078698,6,'jpg'], [90078699,1,'jpg'], [90078699,2,'jpg'], [90078699,3,'jpg'], [90078699,4,'jpg'], [90078699,5,'jpg'], [90078699,6,'jpg'], [90078700,1,'jpg'], [90078700,2,'jpg'], [90078700,3,'jpg'], [90078700,4,'jpg'], [90078700,5,'jpg'], [90078700,6,'jpg'], [90078701,1,'jpg'], [90078701,2,'jpg'], [90078701,3,'jpg'], [90078701,4,'jpg'], [90078701,5,'jpg'], [90078701,6,'jpg'], [90078702,1,'jpg'], [90078702,2,'jpg'], [90078702,3,'jpg'], [90078702,4,'jpg'], [90078702,5,'jpg'], [90078702,6,'jpg'], [90078703,1,'jpg'], [90078703,2,'jpg'], [90078703,3,'jpg'], [90078703,4,'jpg'], [90078703,5,'jpg'], [90078703,6,'jpg'], [90078704,1,'jpg'], [90078704,2,'jpg'], [90078704,3,'jpg'], [90078705,1,'jpg'], [90078705,2,'jpg'], [90078705,3,'jpg'], [90078706,1,'jpg'], [90078706,2,'jpg'], [90078706,3,'jpg'], [90078707,1,'jpg'], [90078707,2,'jpg'], [90078707,3,'jpg'], [90078708,1,'jpg'], [90078708,2,'jpg'], [90078708,3,'jpg'], [90078709,1,'jpg'], [90078709,2,'jpg'], [90078709,3,'jpg'], [90078710,1,'jpg'], [90078710,2,'jpg'], [90078710,3,'jpg'], [90078711,1,'jpg'], [90078711,2,'jpg'], [90078711,3,'jpg'], [90078712,1,'jpg'], [90078712,2,'jpg'], [90078712,3,'jpg'], [90078713,1,'jpg'], [90078713,2,'jpg'], [90078713,3,'jpg'], [90079388,1,'png'], [90079388,2,'jpg'], [90079388,3,'jpg'], [90079389,1,'png'], [90079389,2,'jpg'], [90079389,3,'jpg'], [90079390,1,'png'], [90079390,2,'jpg'], [90079390,3,'jpg'], [90079391,1,'png'], [90079391,2,'jpg'], [90079391,3,'jpg'], [90079392,1,'png'], [90079392,2,'jpg'], [90079392,3,'jpg'], [90079393,1,'png'], [90079393,2,'jpg'], [90079393,3,'jpg'], [90079394,1,'png'], [90079394,2,'jpg'], [90079394,3,'jpg'], [90079395,1,'png'], [90079395,2,'jpg'], [90079395,3,'jpg'], [90079396,1,'png'], [90079396,2,'jpg'], [90079396,3,'jpg'], [90079397,1,'png'], [90079397,2,'jpg'], [90079397,3,'jpg'], [90079398,1,'jpg'], [90079398,2,'jpg'], [90079398,3,'jpg'], [90079401,1,'jpg'], [90079401,2,'jpg'], [90079401,3,'jpg'], [90079402,1,'jpg'], [90079402,2,'jpg'], [90079402,3,'jpg'], [90079403,1,'jpg'], [90079403,2,'jpg'], [90079403,3,'jpg'], [90079404,1,'jpg'], [90079404,2,'jpg'], [90079404,3,'jpg'], [90079409,1,'png'], [90079409,2,'jpg'], [90079409,3,'jpg'], [90079410,1,'png'], [90079410,2,'jpg'], [90079410,3,'jpg'], [90079411,1,'png'], [90079411,2,'jpg'], [90079411,3,'jpg'], [90079412,1,'png'], [90079412,2,'jpg'], [90079412,3,'jpg'], [90079413,1,'png'], [90079413,2,'jpg'], [90079413,3,'jpg'], [90079414,1,'png'], [90079414,2,'jpg'], [90079414,3,'jpg'], [90079415,1,'png'], [90079415,2,'jpg'], [90079415,3,'jpg'], [90079416,1,'png'], [90079416,2,'jpg'], [90079416,3,'jpg'], [90079417,1,'png'], [90079417,2,'jpg'], [90079417,3,'jpg'], [90079418,1,'png'], [90079418,2,'jpg'], [90079418,3,'jpg'], [90079420,1,'jpg'], [90079420,2,'jpg'], [90079420,3,'jpg'], [90079421,1,'jpg'], [90079421,2,'jpg'], [90079421,3,'jpg'], [90079422,1,'jpg'], [90079422,2,'jpg'], [90079422,3,'jpg'], [90079423,1,'jpg'], [90079423,2,'jpg'], [90079423,3,'jpg'], [90079424,1,'jpg'], [90079424,2,'jpg'], [90079424,3,'jpg'], [90077616,10,'jpg'], [90077616,11,'jpg']];
$prods = $this->getDoctrine()->getRepository('App:Producto')->findAll();
$prods_array = [];
foreach ($prods as $prod){
$prods_array[$prod->getPlu()] = $prod;
}
$ini = "https://firebasestorage.googleapis.com/v0/b/romancerelax-2021.appspot.com/o/app_images%2F";
$fin = "?alt=media&token=a72666b0-cf6f-4480-a06b-286f3f0911e6";
foreach ($imgs as $data){
$sku = $data[0];
$pos = $data[1];
$ext = $data[2];
$ruta = $ini.$sku.'_'.$pos.'.'.$ext.$fin;
$producto = $prods_array[$sku];
if($pos == 1){
$producto->setImagen($ruta);
$em->persist($producto);
}else{
$new_img = new Image();
$new_img->setProducto($producto);
$new_img->setVisible(true);
$new_img->setOrden(1);
$new_img->setImage($ruta);
$em->persist($new_img);
}
}
$em->flush();
dd(1);
return $this->render('contact/contact_mail.html.twig', array(
'nombre'=>'Luisa',
'email'=>'samuel@iridian.co',
'telefono'=>'3002111111',
'mensaje'=>'Hola quiero saber si venden traumel en tabletas',
));
}
/**
* @Route("/mis-datos/romance/mis-datos", name="mis-datos")
*/
public function misDatos(Request $request)
{
$user = $this->getUser();
if ($user) {
$perfil = new Usuario();
$form = $this->createForm(PerfilType::class, $perfil);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$perfil = $form->getData();
$um = $this->userManager;
$user = $um->findUserBy(array('uid' => $user->getUid() ));
$user->setNombre($perfil->getNombre());
$user->setDocumento($perfil->getDocumento());
$user->setEmail($perfil->getEmail());
$user->setCelular($perfil->getCelular());
$user->setEmail($form->get('email')->getData());
$em = $this->getDoctrine()->getManager();
$em->persist($user);
$em->flush();
$um->updateUser($user);
return $this->render('home/mis-datos.html.twig', [
'user' => $user,
'msg' => 'submitted and validated',
'form' => $form->createView(),
'perfil' => $perfil
]);
}
return $this->render('home/mis-datos.html.twig', [
'user' => $user,
'msg' => 'no submit',
'form' => $form->createView(),
'perfil' => $perfil,
'idprincipal' => $idprincipal = null
]);
} else {
return $this->redirectToRoute('homepage');
}
}
/**
* @Route("/mis-compras/romance/mis-compras", name="mis-compras")
*/
public function misCompras(Request $request)
{
$user = $this->getUser();
if(!$user){
return $this->redirectToRoute('homepage');
}
// $estado = $this->getDoctrine()->getRepository(EstadoPedido::class)->findOneBy(array("ref" => 'APROBADA'));
// $compras=$this->getDoctrine()->getRepository(Compra::class)->findBy(array( 'usuario'=>$user),array('id'=>'desc'));
$aprobado = $this->getDoctrine()->getRepository(EstadoPedido::class)->findOneBy(array('ref'=>'APROBADA'));
$compras=$this->getDoctrine()->getRepository(Compra::class)->findBy(array('usuario'=>$user),array('createdAt'=>'desc'));
// dd($compras);
return $this->render('home/mis-compras.html.twig', [
'compras'=>$compras,
'idprincipal' => $idprincipal = null
]);
}
/**
* @Route("/mis-compras-interna/romance/mis-compras-interna/{id}", name="mis-compras-interna")
*/
public function misComprasInterna(Request $request,$id)
{
$compra=$this->getDoctrine()->getRepository(Compra::class)->find($id);
$usuario=$compra->getUsuario();
// $tracking = $this->fedex->TrackingPedido($compra);
// $estados = array(
// 'PU' => 'RECIBIDA',
// 'AF' => 'ALISTAMIENTO',
// 'IT' => 'EN CAMINO',
// 'DL' => 'ENTREGADA',
// 'CA' => 'NOVEDAD',
// 'DE' => 'NOVEDAD',
// );
// if(isset($tracking['code'])) {
// $seguimiento = $this->getDoctrine()->getRepository('App:Seguimiento')->findOneBy(array('nombre_es'=>$estados[$tracking['code']]));
// }else{
// $seguimiento = $this->getDoctrine()->getRepository('App:Seguimiento')->find(2);
// }
// $track=$this->getDoctrine()->getRepository('App:SeguimientoTracking')->findOneBy(array('compra'=>$compra,'seguimiento'=>$seguimiento));
// if($seguimiento && !$track){
// $compra->setSeguimiento($seguimiento);
// $segtrack = new SeguimientoTracking();
// $segtrack->setCompra($compra);
// $segtrack->setSeguimiento($seguimiento);
// $em = $this->getDoctrine()->getManager();
// $em->persist($compra);
// $em->persist($segtrack);
// $em->flush();
// }
// dd($compra);
return $this->render('home/mis-compras-interna.html.twig', [
'compra'=>$compra,
'usuario'=>$usuario,
'idprincipal' => $idprincipal = null
]);
}
/**
* @Route("/mis-direcciones/romance/mis-direcciones", name="mis-direcciones")
*/
public function misDirecciones2(Request $request)
{
$user = $this->getUser();
if ($user) {
$direcciones = $this->getDoctrine()->getRepository(Direccion::class)->createQueryBuilder('d')
->select('d')
->leftJoin('d.usuario','u')
->where('u.id = '.$user->getId())
->andWhere('d.visible = 1')
->getQuery()
->getResult();
// ->andWhere('d.visible is null or d.visible = 1')
return $this->render('home/mis-direcciones.html.twig', [
'direcciones' => $direcciones,
'idprincipal' => $idprincipal = null
]);
}
}
/**
* @Route("/editar-direccion/romance/{id}", name="editar-direccion")
*/
public function editarDirecciones(Request $request,$id)
{
$user=$this->getUser();
if(!$user){
return $this->redirectToRoute('homepage');
}
$direccion=$this->getDoctrine()->getRepository(Direccion::class)->find($id);
return $this->render('home/editar_mis-direcciones-formulario.html.twig', [
'direccion'=>$direccion,
'idprincipal' => $idprincipal=null
]);
}
/**
* @Route("/enviar-edicion-formulario-direccion/romance/{id}", name="enviar-edicion-formulario-direccion")
*/
public function enviaredicionformulariodireccion(Request $request,$id)
{
$mensaje = array("ok" => false, "mensaje" => "error");
$user=$this->getUser();
if(!$user){
return $this->redirectToRoute('homepage');
}
$direccioneditada=$this->getDoctrine()->getRepository(Direccion::class)->find($id);
// $nombre=$request->get("nombrecompleto");
// $telefono=$request->get("telefono");
$direccion=$request->get("direccion");
// $zip=$request->get("zip");
$ciudad=$request->get("ciudad");
//$departamento=$request->get("departamento");
// $numerodoc=$request->request->get('numerodoc');
// $tipodoc=$this->getDoctrine()->getRepository(Tipodocumento::class)->find($request->request->get('tipodoc'));
$ciudad=$this->getDoctrine()->getRepository(Ciudad::class)->find($request->request->get('ciudad'));
$em = $this->getDoctrine()->getManager();
// $direccioneditada->setPersona($nombre);
// $direccioneditada->setTelefono($telefono);
$direccioneditada->setDireccion($direccion);
// $direccioneditada->setCodigopostal($zip);
// if($zip) {
// $data =$this->fedex->ValidarPostal($zip, $ciudad->getPais()->getCodigo());
// if(isset($data->error)){
// $this->addFlash(
// 'warning',
// 'Error postal'
// );
// return $this->redirectToRoute('editar-direccion',array('id'=>$id));
// }
// }
$direccioneditada->setCiudad($ciudad);
// $direccioneditada->setTipodocumento($tipodoc);
// $direccioneditada->setNumerodocumento($numerodoc);
$direccioneditada->setVisible(1);
//$direccioneditada->setDepartamento($departamento);
$em = $this->getDoctrine()->getManager();
$em->persist($direccioneditada);
$em->flush();
$mensaje["ok"] = true;
$mensaje["mensaje"] = "Direccion Editada";
return new JsonResponse($mensaje);
}
/**
* @Route("/eliminar-direccion/romance/{id}", name="eliminar-direccion")
*/
public function eliminardireccion(Request $request,$id)
{
// $mensaje = array("ok" => false, "mensaje" => "error");
$user=$this->getUser();
if(!$user){
return $this->redirectToRoute('homepage');
}
$direccion=$this->getDoctrine()->getRepository(Direccion::class)->find($id);
// dd($direccion);
$em = $this->getDoctrine()->getManager();
$direccion->setVisible(false);
// $em->persist($direccioneditada);
// $em->flush();
$em->persist($direccion);
$em->flush();
return $this->redirectToRoute('mis-direcciones',[
'idprincipal' => $idprincipal=null
]);
}
/**
* @Route("/mis-direcciones-formulario/romance/mis-direcciones-formulario", name="mis-direcciones-formulario")
*/
public function misDireccionesFormulario(Request $request)
{
return $this->render('home/mis-direcciones-formulario.html.twig', [
'idprincipal' => $idprincipal = null
]);
}
/**
* @Route("/mis-favoritos/romance/mis-favoritos", name="mis-favoritos")
*/
public function misFavoritos(Request $request)
{
$user=$this->getUser();
if(!$user){
return $this->redirectToRoute('homepage');
}
$favoritos_prod= $this->getDoctrine()->getRepository(Producto::class)->createQueryBuilder('p')
->select('p')
->leftJoin('p.favoritos', 'fav')
->leftJoin('fav.usuario', 'u')
->leftJoin('fav.producto', 'pa')
->Where('u.id ='.$user->getId())
->AndWhere('p.padre is null');
$favoritos_prod= $favoritos_prod->groupBy('p.plu')->getQuery()
->getResult();
$favoritos_blog= $this->getDoctrine()->getRepository(FavoritoBlog::class)->createQueryBuilder('p')
->select('p', 'b.id as id','b.titulo as titulo', 'b.created_at as fecha', 'b.imagen_listado as imagen')
// ->leftJoin('p.favorito', 'fav')
->leftJoin('p.usuario', 'u')
->leftJoin('p.blog', 'b')
->Where('u.id ='.$user->getId())
->getQuery()
->getResult();
return $this->render('home/mis-favoritos.html.twig', [
'favoritos_prod'=>$favoritos_prod,
'favoritos_blog'=>$favoritos_blog,
'user'=>$user,
'idprincipal' => $idprincipal = null
]);
}
/**
* @Method({"POST"})
* @Route("/add-favorito-producto/romance/add-favorito-producto/{id}", name="add-favorito-producto")
*/
public function FavoritoProducto(Request $request,$id)
{
$user=$this->getUser();
$mensaje = array('ok' => false, 'msg' => 'Error al agregar');
$producto=$this->getDoctrine()->getRepository(Producto::class)->find($id);
$favorito=$this->getDoctrine()->getRepository(Favorito::class)->findOneBy(array('producto'=>$producto, 'usuario'=>$user));
$em=$this->getDoctrine()->getManager();
if($favorito){
$em->remove($favorito);
$em->flush();
$mensaje = array('ok' => false, 'msg' => 'Eliminado');
}else{
$newfavorito=new Favorito();
$newfavorito->setUsuario($user);
$newfavorito->setProducto($producto);
$em->persist($newfavorito);
$em->flush();
$mensaje = array('ok' => true, 'msg' => 'agregado');
}
$response = new Response();
$response->setContent(json_encode($mensaje));
$response->headers->set('Content-Type', 'application/json');
return $response;
}
/**
* @Method({"POST"})
* @Route("/add-favorito-blog/romance/add-favorito-blog/{id}", name="add-favorito-blog")
*/
public function FavoritoBlog(Request $request,$id)
{
$user=$this->getUser();
$mensaje = array('ok' => false, 'msg' => 'Error al agregar');
$blog=$this->getDoctrine()->getRepository(Blog::class)->find($id);
$favorito=$this->getDoctrine()->getRepository(FavoritoBlog::class)->findOneBy(array('blog'=>$blog, 'usuario'=>$user));
$em=$this->getDoctrine()->getManager();
if($favorito){
$em->remove($favorito);
$em->flush();
$mensaje = array('ok' => false, 'msg' => 'Eliminado');
}else{
$newfavorito=new FavoritoBlog();
$newfavorito->setUsuario($user);
$newfavorito->setBlog($blog);
$em->persist($newfavorito);
$em->flush();
$mensaje = array('ok' => true, 'msg' => 'agregado');
}
$response = new Response();
$response->setContent(json_encode($mensaje));
$response->headers->set('Content-Type', 'application/json');
return $response;
}
/**
* @Method({"POST"})
* @Route("/cargarfotos/romance/romance/ro", name="cargarfotos")
*/
public function cargarfotos(Request $request)
{
$em = $this->getDoctrine()->getManager();
// $photos=["90071645_1.jpg"];
$photos=["90071645_1.jpg","90071645_2.jpg","90076168_1.jpg","90076168_2.jpg","90076168_3.jpg","90076168_4.jpg","90076168_5.jpg","90076168_6.jpg","90076168_7.jpg","90076168_8.jpg","90076168_9.jpg","90076169_1.jpg","90076169_2.jpg","90076169_3.jpg","90076169_4.jpg","90076169_5.jpg","90076169_6.jpg","90076169_7.jpg","90076169_8.jpg","90076169_9.jpg","90076195_1.jpg","90076195_2.jpg","90076195_3.jpg","90076195_4.jpg","90076195_5.jpg","90076195_6.jpg","90076195_7.jpg","90076195_8.jpg","90076195_9.jpg","90076196_1.jpg","90076196_2.jpg","90076196_3.jpg","90076196_4.jpg","90076196_5.jpg","90076196_6.jpg","90076196_7.jpg","90076196_8.jpg","90076196_9.jpg","90077875_1.jpg","90077875_2.jpg","90078512_1.jpg","90078512_2.jpg","90078512_3.jpg","90078512_4.jpg","90078512_5.jpg","90078512_6.jpg","90078512_7.jpg","90078513_1.jpg","90078513_2.jpg","90078513_3.jpg","90078513_4.jpg","90078513_5.jpg","90078513_6.jpg","90078513_7.jpg","90078514_1.jpg","90078514_2.jpg","90078514_3.jpg","90078514_4.jpg","90078514_5.jpg","90078514_6.jpg","90078514_7.jpg","90078515_1.jpg","90078515_2.jpg","90078515_3.jpg","90078515_4.jpg","90078515_5.jpg","90078515_6.jpg","90078515_7.jpg","90078516_1.jpg","90078516_2.jpg","90078516_4.jpg","90078516_5.jpg","90078516_6.jpg","90078516_7.jpg","90078603_1.jpg","90078603_2.jpg","90078694_1.jpg","90078694_2.jpg","90078694_3.jpg","90078694_4.jpg","90078694_5.jpg","90078694_6.jpg","90078694_7.jpg","90078695_1.jpg","90078695_2.jpg","90078695_3.jpg","90078695_4.jpg","90078695_5.jpg","90078695_6.jpg","90078695_7.jpg","90078696_1.jpg","90078696_2.jpg","90078696_3.jpg","90078696_4.jpg","90078696_5.jpg","90078696_6.jpg","90078696_7.jpg","90078697_1.jpg","90078697_2.jpg","90078697_3.jpg","90078697_4.jpg","90078697_5.jpg","90078697_6.jpg","90078697_7.jpg","90078698_1.jpg","90078698_2.jpg","90078698_3.jpg","90078698_4.jpg","90078698_5.jpg","90078698_6.jpg","90078698_7.jpg","90078699_1.jpg","90078699_2.jpg","90078699_3.jpg","90078699_4.jpg","90078699_5.jpg","90078699_6.jpg","90078699_7.jpg","90078700_1.jpg","90078700_2.jpg","90078700_3.jpg","90078700_4.jpg","90078700_5.jpg","90078700_6.jpg","90078700_7.jpg","90078701_1.jpg","90078701_2.jpg","90078701_3.jpg","90078701_4.jpg","90078701_5.jpg","90078701_6.jpg","90078701_7.jpg","90078702_1.jpg","90078702_2.jpg","90078702_3.jpg","90078702_4.jpg","90078702_5.jpg","90078702_6.jpg","90078702_7.jpg","90078703_1.jpg","90078703_2.jpg","90078703_3.jpg","90078703_4.jpg","90078703_5.jpg","90078703_6.jpg","90078703_7.jpg","90080091_1.jpg","90080091_2.jpg","90080091_3.jpg","90080091_4.jpg","90080091_5.jpg","90080091_6.jpg","90080091_7.jpg","90080091_8.jpg","90080091_9.jpg","90080092_1.jpg","90080092_2.jpg","90080092_3.jpg","90080092_4.jpg","90080092_5.jpg","90080092_6.jpg","90080092_7.jpg","90080092_8.jpg","90080092_9.jpg","90080094_1.jpg","90080094_2.jpg","90080094_3.jpg","90080094_4.jpg","90080094_5.jpg","90080094_6.jpg","90080094_7.jpg","90080094_8.jpg","90080094_9.jpg","90080095_1.jpg","90080095_2.jpg","90080095_3.jpg","90080095_4.jpg","90080095_5.jpg","90080095_6.jpg","90080095_7.jpg","90080095_8.jpg","90080095_9.jpg","90080097_1.jpg","90080097_2.jpg","90080097_3.jpg","90080097_4.jpg","90080097_5.jpg","90080097_6.jpg","90080097_7.jpg","90080097_8.jpg","90080097_9.jpg","90080098_1.jpg","90080098_2.jpg","90080098_3.jpg","90080098_4.jpg","90080098_5.jpg","90080098_6.jpg","90080098_7.jpg","90080098_8.jpg","90080098_9.jpg","90080100_1.jpg","90080100_2.jpg","90080100_3.jpg","90080100_4.jpg","90080100_5.jpg","90080100_6.jpg","90080100_7.jpg","90080100_8.jpg","90080100_9.jpg","90080101_1.jpg","90080101_2.jpg","90080101_3.jpg","90080101_4.jpg","90080101_5.jpg","90080101_6.jpg","90080101_7.jpg","90080101_8.jpg","90080101_9.jpg","90080103_1.jpg","90080103_2.jpg","90080103_3.jpg","90080103_4.jpg","90080103_5.jpg","90080103_6.jpg","90080103_7.jpg","90080103_8.jpg","90080103_9.jpg","90080104_1.jpg","90080104_2.jpg","90080104_3.jpg","90080104_4.jpg","90080104_5.jpg","90080104_6.jpg","90080104_7.jpg","90080104_8.jpg","90080104_9.jpg","90080105_1.jpg","90080105_2.jpg","90080106_1.jpg","90080106_2.jpg","90080107_1.jpg","90080107_2.jpg","90080108_1.jpg","90080108_2.jpg","90080109_1.jpg","90080109_2.jpg","90080111_1.jpg","90080111_2.jpg","90080111_3.jpg","90080111_4.jpg","90080111_5.jpg","90080111_6.jpg","90080111_7.jpg","90080111_8.jpg","90080111_9.jpg","90080112_1.jpg","90080112_2.jpg","90080112_3.jpg","90080112_4.jpg","90080112_5.jpg","90080112_6.jpg","90080112_7.jpg","90080112_8.jpg","90080112_9.jpg","90080114_1.jpg","90080114_2.jpg","90080114_3.jpg","90080114_4.jpg","90080114_5.jpg","90080114_6.jpg","90080114_7.jpg","90080114_8.jpg","90080114_9.jpg","90080115_1.jpg","90080115_2.jpg","90080115_3.jpg","90080115_4.jpg","90080115_5.jpg","90080115_6.jpg","90080115_7.jpg","90080115_8.jpg","90080115_9.jpg","90080117_1.jpg","90080117_2.jpg","90080117_3.jpg","90080117_4.jpg","90080117_5.jpg","90080117_6.jpg","90080117_7.jpg","90080117_8.jpg","90080117_9.jpg","90080118_1.jpg","90080118_2.jpg","90080118_3.jpg","90080118_4.jpg","90080118_5.jpg","90080118_6.jpg","90080118_7.jpg","90080118_8.jpg","90080118_9.jpg","90080120_1.jpg","90080120_2.jpg","90080120_3.jpg","90080120_4.jpg","90080120_5.jpg","90080120_6.jpg","90080120_7.jpg","90080120_8.jpg","90080120_9.jpg","90080121_1.jpg","90080121_2.jpg","90080121_3.jpg","90080121_4.jpg","90080121_5.jpg","90080121_6.jpg","90080121_7.jpg","90080121_8.jpg","90080121_9.jpg","90080123_1.jpg","90080123_2.jpg","90080123_3.jpg","90080123_4.jpg","90080123_5.jpg","90080123_6.jpg","90080123_7.jpg","90080123_8.jpg","90080123_9.jpg","90080124_1.jpg","90080124_2.jpg","90080124_3.jpg","90080124_4.jpg","90080124_5.jpg","90080124_6.jpg","90080124_7.jpg","90080124_8.jpg","90080124_9.jpg","90080141_1.jpg","90080141_2.jpg","90080141_3.jpg","90080141_4.jpg","90080141_5.jpg","90080141_6.jpg","90080141_7.jpg","90080141_8.jpg","90080141_9.jpg","90080144_1.jpg","90080144_2.jpg","90080144_3.jpg","90080144_4.jpg","90080144_5.jpg","90080144_6.jpg","90080144_7.jpg","90080144_8.jpg","90080144_9.jpg","90080147_1.jpg","90080147_2.jpg","90080147_3.jpg","90080147_4.jpg","90080147_5.jpg","90080147_6.jpg","90080147_7.jpg","90080147_8.jpg","90080147_9.jpg","90080150_1.jpg","90080150_2.jpg","90080150_3.jpg","90080150_4.jpg","90080150_5.jpg","90080150_6.jpg","90080150_7.jpg","90080150_8.jpg","90080150_9.jpg","90080153_1.jpg","90080153_2.jpg","90080153_3.jpg","90080153_4.jpg","90080153_5.jpg","90080153_6.jpg","90080153_7.jpg","90080153_8.jpg","90080153_9.jpg","90080556_1.jpg","90080556_2.jpg","90080556_3.jpg","90080556_4.jpg","90080556_5.jpg","90080556_6.jpg","90080557_1.jpg","90080557_2.jpg","90080557_3.jpg","90080557_4.jpg","90080557_5.jpg","90080557_6.jpg","90080558_1.jpg","90080558_2.jpg","90080558_3.jpg","90080558_4.jpg","90080558_5.jpg","90080558_6.jpg","90080559_1.jpg","90080559_2.jpg","90080559_3.jpg","90080559_4.jpg","90080559_5.jpg","90080559_6.jpg","90080828_1.jpg","90080828_2.jpg","90080828_3.jpg","90080828_4.jpg","90080828_5.jpg","90080828_6.jpg","90080828_7.jpg","90080830_1.jpg","90080830_2.jpg","90080830_3.jpg","90080830_4.jpg","90080830_5.jpg","90080830_6.jpg","90080830_7.jpg","90080831_1.jpg","90080831_2.jpg","90080831_3.jpg","90080831_4.jpg","90080831_5.jpg","90080831_6.jpg","90080831_7.jpg","90080832_1.jpg","90080832_2.jpg","90080832_3.jpg","90080832_4.jpg","90080832_5.jpg","90080832_6.jpg","90080832_7.jpg","90080833_1.jpg","90080833_2.jpg","90080833_3.jpg","90080833_4.jpg","90080833_5.jpg","90080833_6.jpg","90080833_7.jpg","90080834_1.jpg","90080834_2.jpg","90080834_3.jpg","90080834_4.jpg","90080834_5.jpg","90080834_6.jpg","90080834_7.jpg","90080835_1.jpg","90080835_2.jpg","90080835_3.jpg","90080835_4.jpg","90080835_5.jpg","90080835_6.jpg","90080835_7.jpg","90080836_1.jpg","90080836_2.jpg","90080836_3.jpg","90080836_4.jpg","90080836_5.jpg","90080836_6.jpg","90080836_7.jpg","90080837_1.jpg","90080837_2.jpg","90080837_3.jpg","90080837_4.jpg","90080837_5.jpg","90080837_6.jpg","90080837_7.jpg","90080838_1.jpg","90080838_2.jpg","90080838_3.jpg","90080838_4.jpg","90080838_5.jpg","90080838_6.jpg","90080838_7.jpg","90080839_1.jpg","90080839_2.jpg","90080839_3.jpg","90080839_4.jpg","90080839_5.jpg","90080839_6.jpg","90080839_7.jpg","90080839_8.jpg","90080839_9.jpg","90080840_1.jpg","90080840_2.jpg","90080840_3.jpg","90080840_4.jpg","90080840_5.jpg","90080840_6.jpg","90080840_7.jpg","90080840_8.jpg","90080840_9.jpg","90080841_1.jpg","90080841_2.jpg","90080841_3.jpg","90080841_4.jpg","90080841_5.jpg","90080841_6.jpg","90080841_7.jpg","90080841_8.jpg","90080841_9.jpg","90080842_1.jpg","90080842_2.jpg","90080842_3.jpg","90080842_4.jpg","90080842_5.jpg","90080842_6.jpg","90080842_7.jpg","90080842_8.jpg","90080842_9.jpg","90080843_1.jpg","90080843_2.jpg","90080843_3.jpg","90080843_4.jpg","90080843_5.jpg","90080843_6.jpg","90080843_7.jpg","90080843_8.jpg","90080843_9.jpg","90080844_1.jpg","90080844_2.jpg","90080844_3.jpg","90080844_4.jpg","90080844_5.jpg","90080844_6.jpg","90080844_7.jpg","90080844_8.jpg","90080844_9.jpg","90080845_1.jpg","90080845_2.jpg","90080845_3.jpg","90080845_4.jpg","90080845_5.jpg","90080845_6.jpg","90080845_7.jpg","90080845_8.jpg","90080845_9.jpg","90080846_1.jpg","90080846_2.jpg","90080846_3.jpg","90080846_4.jpg","90080846_5.jpg","90080846_6.jpg","90080846_7.jpg","90080846_8.jpg","90080846_9.jpg","90080847_1.jpg","90080847_2.jpg","90080847_3.jpg","90080847_4.jpg","90080847_5.jpg","90080847_6.jpg","90080847_7.jpg","90080847_8.jpg","90080847_9.jpg","90080848_1.jpg","90080848_2.jpg","90080848_3.jpg","90080848_4.jpg","90080848_5.jpg","90080848_6.jpg","90080848_7.jpg","90080848_8.jpg","90080848_9.jpg","90080849_1.jpg","90080849_2.jpg","90080849_3.jpg","90080849_4.jpg","90080849_5.jpg","90080849_6.jpg","90080849_7.jpg","90080850_1.jpg","90080850_2.jpg","90080850_3.jpg","90080850_4.jpg","90080850_5.jpg","90080850_6.jpg","90080850_7.jpg","90080851_1.jpg","90080851_2.jpg","90080851_3.jpg","90080851_4.jpg","90080851_5.jpg","90080851_6.jpg","90080851_7.jpg","90080852_1.jpg","90080852_2.jpg","90080852_3.jpg","90080852_4.jpg","90080852_5.jpg","90080852_6.jpg","90080852_7.jpg","90080853_1.jpg","90080853_2.jpg","90080853_3.jpg","90080853_4.jpg","90080853_5.jpg","90080853_6.jpg","90080853_7.jpg","90080883_1.jpg","90080883_2.jpg","90080883_3.jpg","90080883_4.jpg","90080883_5.jpg","90080883_6.jpg","90080883_7.jpg","90080883_8.jpg","90080883_9.jpg","90080884_1.jpg","90080884_2.jpg","90080884_3.jpg","90080884_4.jpg","90080884_5.jpg","90080884_6.jpg","90080884_7.jpg","90080884_8.jpg","90080884_9.jpg","90080885_1.jpg","90080885_2.jpg","90080885_3.jpg","90080885_4.jpg","90080885_5.jpg","90080885_6.jpg","90080885_7.jpg","90080885_8.jpg","90080885_9.jpg","90080886_1.jpg","90080886_2.jpg","90080886_3.jpg","90080886_4.jpg","90080886_5.jpg","90080886_6.jpg","90080886_7.jpg","90080886_8.jpg","90080886_9.jpg","90080887_1.jpg","90080887_2.jpg","90080887_3.jpg","90080887_4.jpg","90080887_5.jpg","90080887_6.jpg","90080887_7.jpg","90080887_8.jpg","90080887_9.jpg","90080888_1.jpg","90080888_2.jpg","90080888_3.jpg","90080888_4.jpg","90080888_5.jpg","90080888_6.jpg","90080888_7.jpg","90080888_8.jpg","90080888_9.jpg","90080889_1.jpg","90080889_2.jpg","90080889_3.jpg","90080889_4.jpg","90080889_5.jpg","90080889_6.jpg","90080889_7.jpg","90080889_8.jpg","90080889_9.jpg","90080890_1.jpg","90080890_2.jpg","90080890_3.jpg","90080890_4.jpg","90080890_5.jpg","90080890_6.jpg","90080890_7.jpg","90080890_8.jpg","90080890_9.jpg","90080891_1.jpg","90080891_2.jpg","90080891_3.jpg","90080891_4.jpg","90080891_5.jpg","90080891_6.jpg","90080891_7.jpg","90080891_8.jpg","90080891_9.jpg","90080892_1.jpg","90080892_2.jpg","90080892_3.jpg","90080892_4.jpg","90080892_5.jpg","90080892_6.jpg","90080892_7.jpg","90080892_8.jpg","90080892_9.jpg","90080893_1.jpg","90080893_2.jpg","90080893_3.jpg","90080893_4.jpg","90080893_5.jpg","90080893_6.jpg","90080893_7.jpg","90080893_8.jpg","90080893_9.jpg","90080894_1.jpg","90080894_2.jpg","90080894_3.jpg","90080894_4.jpg","90080894_5.jpg","90080894_6.jpg","90080894_7.jpg","90080894_8.jpg","90080894_9.jpg","90080895_1.jpg","90080895_2.jpg","90080895_3.jpg","90080895_4.jpg","90080895_5.jpg","90080895_6.jpg","90080895_7.jpg","90080895_8.jpg","90080895_9.jpg","90080896_1.jpg","90080896_2.jpg","90080896_3.jpg","90080896_4.jpg","90080896_5.jpg","90080896_6.jpg","90080896_7.jpg","90080896_8.jpg","90080896_9.jpg","90080897_1.jpg","90080897_2.jpg","90080897_3.jpg","90080897_4.jpg","90080897_5.jpg","90080897_6.jpg","90080897_7.jpg","90080897_8.jpg","90080897_9.jpg","90080898_1.jpg","90080898_2.jpg","90080898_3.jpg","90080898_4.jpg","90080898_5.jpg","90080898_6.jpg","90080898_7.jpg","90080898_8.jpg","90080898_9.jpg","90080899_1.jpg","90080899_2.jpg","90080899_3.jpg","90080899_4.jpg","90080899_5.jpg","90080899_6.jpg","90080899_7.jpg","90080899_8.jpg","90080899_9.jpg","90080900_1.jpg","90080900_2.jpg","90080900_3.jpg","90080900_4.jpg","90080900_5.jpg","90080900_6.jpg","90080900_7.jpg","90080900_8.jpg","90080900_9.jpg","90080901_01.jpg","90080901_2.jpg","90080901_3.jpg","90080901_4.jpg","90080901_5.jpg","90080901_6.jpg","90080901_7.jpg","90080901_8.jpg","90080901_9.jpg","90080902_1.jpg","90080902_2.jpg","90080902_3.jpg","90080902_4.jpg","90080902_5.jpg","90080902_6.jpg","90080902_7.jpg","90080902_8.jpg","90080902_9.jpg","90080904_01.jpg","90080904_2.jpg","90080904_3.jpg","90080904_4.jpg","90080904_5.jpg","90080904_6.jpg","90080904_7.jpg","90080904_8.jpg","90080904_9.jpg","90080905_1.jpg","90080905_2.jpg","90080905_3.jpg","90080905_4.jpg","90080905_5.jpg","90080905_6.jpg","90080905_7.jpg","90080905_8.jpg","90080905_9.jpg","90080906_01.jpg","90080906_2.jpg","90080906_3.jpg","90080906_4.jpg","90080906_5.jpg","90080906_6.jpg","90080906_7.jpg","90080906_8.jpg","90080906_9.jpg","90080907_1.jpg","90080907_2.jpg","90080907_3.jpg","90080907_4.jpg","90080907_5.jpg","90080907_6.jpg","90080907_7.jpg","90080907_8.jpg","90080907_9.jpg","90080908_01.jpg","90080908_2.jpg","90080908_3.jpg","90080908_4.jpg","90080908_5.jpg","90080908_6.jpg","90080908_7.jpg","90080908_8.jpg","90080908_9.jpg","90080909_1.jpg","90080909_2.jpg","90080909_3.jpg","90080909_4.jpg","90080909_5.jpg","90080909_6.jpg","90080909_7.jpg","90080909_8.jpg","90080909_9.jpg","90080910_1.jpg","90080910_2.jpg","90080910_3.jpg","90080910_4.jpg","90080910_5.jpg","90080910_6.jpg","90080910_7.jpg","90080910_8.jpg","90080910_9.jpg","90080911_1.jpg","90080911_2.jpg","90080911_3.jpg","90080911_4.jpg","90080911_5.jpg","90080911_6.jpg","90080911_7.jpg","90080911_8.jpg","90080911_9.jpg","90080912_1.jpg","90080912_2.jpg","90080912_3.jpg","90080912_4.jpg","90080912_5.jpg","90080912_6.jpg","90080912_7.jpg","90080912_8.jpg","90080912_9.jpg","90080913_1.jpg","90080913_2.jpg","90080913_3.jpg","90080913_4.jpg","90080913_5.jpg","90080913_6.jpg","90080913_7.jpg","90080913_8.jpg","90080913_9.jpg","90080914_1.jpg","90080914_2.jpg","90080914_3.jpg","90080914_4.jpg","90080914_5.jpg","90080914_6.jpg","90080914_7.jpg","90080914_8.jpg","90080914_9.jpg","90080915_1.jpg","90080915_2.jpg","90080915_3.jpg","90080915_4.jpg","90080915_5.jpg","90080915_6.jpg","90080915_7.jpg","90080915_8.jpg","90080915_9.jpg","90080916_1.jpg","90080916_2.jpg","90080916_3.jpg","90080916_4.jpg","90080916_5.jpg","90080916_6.jpg","90080916_7.jpg","90080916_8.jpg","90080916_9.jpg","90080917_1.jpg","90080917_2.jpg","90080917_3.jpg","90080917_4.jpg","90080917_5.jpg","90080917_6.jpg","90080917_7.jpg","90080917_8.jpg","90080917_9.jpg","90080918_1.jpg","90080918_2.jpg","90080918_3.jpg","90080918_4.jpg","90080918_5.jpg","90080918_6.jpg","90080918_7.jpg","90080918_8.jpg","90080918_9.jpg","90080919_1.jpg","90080919_2.jpg","90080919_3.jpg","90080919_4.jpg","90080919_5.jpg","90080919_6.jpg","90080919_7.jpg","90080919_8.jpg","90080919_9.jpg","90080920_1.jpg","90080920_2.jpg","90080920_3.jpg","90080920_4.jpg","90080920_5.jpg","90080920_6.jpg","90080920_7.jpg","90080920_8.jpg","90080920_9.jpg","90080921_1.jpg","90080921_2.jpg","90080921_3.jpg","90080921_4.jpg","90080921_5.jpg","90080921_6.jpg","90080921_7.jpg","90080921_8.jpg","90080921_9.jpg","90080922_1.jpg","90080922_2.jpg","90080922_3.jpg","90080922_4.jpg","90080922_5.jpg","90080922_6.jpg","90080922_7.jpg","90080922_8.jpg","90080922_9.jpg","90080923_1.jpg","90080923_2.jpg","90080923_3.jpg","90080923_4.jpg","90080923_5.jpg","90080923_6.jpg","90080923_7.jpg","90080923_8.jpg","90080923_9.jpg","90080924_1.jpg","90080924_2.jpg","90080924_3.jpg","90080924_4.jpg","90080924_5.jpg","90080924_6.jpg","90080924_7.jpg","90080924_8.jpg","90080924_9.jpg","90080925_1.jpg","90080925_2.jpg","90080925_3.jpg","90080925_4.jpg","90080925_5.jpg","90080925_6.jpg","90080925_7.jpg","90080925_8.jpg","90080925_9.jpg","90080926_1.jpg","90080926_2.jpg","90080926_3.jpg","90080926_4.jpg","90080926_5.jpg","90080926_6.jpg","90080926_7.jpg","90080926_8.jpg","90080926_9.jpg","90080927_1.jpg","90080927_2.jpg","90080927_3.jpg","90080927_4.jpg","90080927_5.jpg","90080927_6.jpg","90080927_7.jpg","90080927_8.jpg","90080927_9.jpg","90080928_1.jpg","90080928_2.jpg","90080928_3.jpg","90080928_4.jpg","90080928_5.jpg","90080928_6.jpg","90080928_7.jpg","90080928_8.jpg","90080928_9.jpg","90080929_1.jpg","90080929_2.jpg","90080929_3.jpg","90080929_4.jpg","90080929_5.jpg","90080929_6.jpg","90080929_7.jpg","90080929_8.jpg","90080929_9.jpg","90080930_1.jpg","90080930_2.jpg","90080930_3.jpg","90080930_4.jpg","90080930_5.jpg","90080930_6.jpg","90080930_7.jpg","90080930_8.jpg","90080930_9.jpg","90080931_1.jpg","90080931_2.jpg","90080931_3.jpg","90080931_4.jpg","90080931_5.jpg","90080931_6.jpg","90080931_7.jpg","90080931_8.jpg","90080931_9.jpg","90080932_1.jpg","90080932_2.jpg","90080932_3.jpg","90080932_4.jpg","90080932_5.jpg","90080932_6.jpg","90080932_7.jpg","90080932_8.jpg","90080932_9.jpg","90080933_1.jpg","90080933_2.jpg","90080933_3.jpg","90080933_4.jpg","90080933_5.jpg","90080933_6.jpg","90080933_7.jpg","90080933_8.jpg","90080933_9.jpg","90080934_1.jpg","90080934_2.jpg","90080934_3.jpg","90080934_4.jpg","90080934_5.jpg","90080934_6.jpg","90080934_7.jpg","90080934_8.jpg","90080934_9.jpg","90080935_1.jpg","90080935_2.jpg","90080935_3.jpg","90080935_4.jpg","90080935_5.jpg","90080935_6.jpg","90080935_7.jpg","90080935_8.jpg","90080935_9.jpg","90080936_1.jpg","90080936_2.jpg","90080936_3.jpg","90080936_4.jpg","90080936_5.jpg","90080936_6.jpg","90080936_7.jpg","90080936_8.jpg","90080936_9.jpg","90080937_1.jpg","90080937_2.jpg","90080937_3.jpg","90080937_4.jpg","90080937_5.jpg","90080937_6.jpg","90080937_7.jpg","90080937_8.jpg","90080937_9.jpg","90080938_1.jpg","90080938_2.jpg","90080938_3.jpg","90080938_4.jpg","90080938_5.jpg","90080938_6.jpg","90080938_7.jpg","90080938_8.jpg","90080938_9.jpg","90080939_1.jpg","90080939_2.jpg","90080939_3.jpg","90080939_4.jpg","90080939_5.jpg","90080939_6.jpg","90080939_7.jpg","90080939_8.jpg","90080939_9.jpg","90080940_1.jpg","90080940_2.jpg","90080940_3.jpg","90080940_4.jpg","90080940_5.jpg","90080940_6.jpg","90080940_7.jpg","90080940_8.jpg","90080940_9.jpg","90080941_1.jpg","90080941_2.jpg","90080941_3.jpg","90080941_4.jpg","90080941_5.jpg","90080941_6.jpg","90080941_7.jpg","90080941_8.jpg","90080941_9.jpg","90080942_1.jpg","90080942_2.jpg","90080942_3.jpg","90080942_4.jpg","90080942_5.jpg","90080942_6.jpg","90080942_7.jpg","90080942_8.jpg","90080942_9.jpg","90080943_1.jpg","90080943_2.jpg","90080943_3.jpg","90080943_4.jpg","90080943_5.jpg","90080943_6.jpg","90080943_7.jpg","90080943_8.jpg","90080943_9.jpg","90080944_1.jpg","90080944_2.jpg","90080944_3.jpg","90080944_4.jpg","90080944_5.jpg","90080944_6.jpg","90080944_7.jpg","90080944_8.jpg","90080944_9.jpg","90080945_1.jpg","90080945_2.jpg","90080945_3.jpg","90080945_4.jpg","90080945_5.jpg","90080945_6.jpg","90080945_7.jpg","90080945_8.jpg","90080945_9.jpg","90080946_1.jpg","90080946_2.jpg","90080946_3.jpg","90080946_4.jpg","90080946_5.jpg","90080946_6.jpg","90080946_7.jpg","90080946_8.jpg","90080946_9.jpg","90080947_1.jpg","90080947_2.jpg","90080947_3.jpg","90080947_4.jpg","90080947_5.jpg","90080947_6.jpg","90080947_7.jpg","90080947_8.jpg","90080947_9.jpg","90080948_1.jpg","90080948_2.jpg","90080948_3.jpg","90080948_4.jpg","90080948_5.jpg","90080948_6.jpg","90080948_7.jpg","90080948_8.jpg","90080948_9.jpg","90080949_1.jpg","90080949_2.jpg","90080949_3.jpg","90080949_4.jpg","90080949_5.jpg","90080949_6.jpg","90080949_7.jpg","90080949_8.jpg","90080949_9.jpg","90080950_1.jpg","90080950_2.jpg","90080950_3.jpg","90080950_4.jpg","90080950_5.jpg","90080950_6.jpg","90080950_7.jpg","90080950_8.jpg","90080950_9.jpg","90080951_1.jpg","90080951_2.jpg","90080951_3.jpg","90080951_4.jpg","90080951_5.jpg","90080951_6.jpg","90080951_7.jpg","90080951_8.jpg","90080951_9.jpg","90080952_1.jpg","90080952_2.jpg","90080952_3.jpg","90080952_4.jpg","90080952_5.jpg","90080952_6.jpg","90080952_7.jpg","90080952_8.jpg","90080952_9.jpg","90080953_1.jpg","90080953_2.jpg","90080953_3.jpg","90080953_4.jpg","90080953_5.jpg","90080953_6.jpg","90080953_7.jpg","90080953_8.jpg","90080953_9.jpg","90080954_1.jpg","90080954_2.jpg","90080954_3.jpg","90080954_4.jpg","90080954_5.jpg","90080954_6.jpg","90080954_7.jpg","90080954_8.jpg","90080954_9.jpg","90080955_1.jpg","90080955_2.jpg","90080955_3.jpg","90080955_4.jpg","90080955_5.jpg","90080955_6.jpg","90080955_7.jpg","90080955_8.jpg","90080955_9.jpg","90080956_1.jpg","90080956_2.jpg","90080956_3.jpg","90080956_4.jpg","90080956_5.jpg","90080956_6.jpg","90080956_7.jpg","90080956_8.jpg","90080956_9.jpg","90080957_1.jpg","90080957_2.jpg","90080957_3.jpg","90080957_4.jpg","90080957_5.jpg","90080957_6.jpg","90080957_7.jpg","90080957_8.jpg","90080957_9.jpg","90080958_1.jpg","90080958_2.jpg","90080958_3.jpg","90080958_4.jpg","90080958_5.jpg","90080958_6.jpg","90080958_7.jpg","90080958_8.jpg","90080958_9.jpg","90080959_1.jpg","90080959_2.jpg","90080959_3.jpg","90080959_4.jpg","90080959_5.jpg","90080959_6.jpg","90080959_7.jpg","90080959_8.jpg","90080959_9.jpg","90080960_1.jpg","90080960_2.jpg","90080960_3.jpg","90080960_4.jpg","90080960_5.jpg","90080960_6.jpg","90080960_7.jpg","90080960_8.jpg","90080960_9.jpg","90080961_1.jpg","90080961_2.jpg","90080961_3.jpg","90080961_4.jpg","90080961_5.jpg","90080961_6.jpg","90080961_7.jpg","90080961_8.jpg","90080961_9.jpg","90080962_1.jpg","90080962_2.jpg","90080962_3.jpg","90080962_4.jpg","90080962_5.jpg","90080962_6.jpg","90080962_7.jpg","90080962_8.jpg","90080962_9.jpg","90080963_1.jpg","90080963_2.jpg","90080963_3.jpg","90080963_4.jpg","90080963_5.jpg","90080963_6.jpg","90080963_7.jpg","90080963_8.jpg","90080963_9.jpg","90080964_1.jpg","90080964_2.jpg","90080964_3.jpg","90080964_4.jpg","90080964_5.jpg","90080964_6.jpg","90080964_7.jpg","90080964_8.jpg","90080964_9.jpg","90080965_1.jpg","90080965_2.jpg","90080965_3.jpg","90080965_4.jpg","90080965_5.jpg","90080965_6.jpg","90080965_7.jpg","90080965_8.jpg","90080965_9.jpg","90080966_1.jpg","90080966_2.jpg","90080966_3.jpg","90080966_4.jpg","90080966_5.jpg","90080966_6.jpg","90080966_7.jpg","90080966_8.jpg","90080966_9.jpg","90080970_1.jpg","90080970_2.jpg","90080970_3.jpg","90080970_4.jpg","90080970_5.jpg","90080970_6.jpg","90080970_7.jpg","90080970_8.jpg","90080970_9.jpg","90080971_1.jpg","90080971_2.jpg","90080971_3.jpg","90080971_4.jpg","90080971_5.jpg","90080971_6.jpg","90080971_7.jpg","90080971_8.jpg","90080971_9.jpg"];
$productos=$this->getDoctrine()->getRepository(Producto::class)->findall();
$prods=[];
foreach( $productos as $prod){
$prods[$prod->getPlu()]=$prod;
}
foreach($photos as $ph){
$id_index=explode("_",$ph);
// dd('entró a un foreach',$id_index[1]);
$sku=$id_index[0];
/* @var $producto Producto */
$producto=$prods[$sku];
$image_path="https://firebasestorage.googleapis.com/v0/b/romancerelax-2021.appspot.com/o/app_images%2F".$ph."?alt=media";
if($id_index[1]=="1.jpg"){
// dd('entró a este if');
// $imagencargada=$producto->setImagen();
// if(!$imagencargada){
$producto->setImagen($image_path);
$em->persist($producto);
// }
}else{
$image = new Image();
/* @Var $image Image */
$image->setImage($image_path);
$image->setProducto($producto);
$em->persist($image);
}
$em->flush();
}
}
/**
* @Route("/ajaxdesplegable/{categoria}/romance/romancerelax", name="ajaxdesplegable")
*/
public function ajaxdesplegable(Request $request, $categoria)
{
// dd($categoria);
$categoria=$this->getDoctrine()->getRepository(Categoria::class)->find($categoria);
// dd($categoria);
return $this->render('basic/busqueda2.html.twig', [
'cat'=>$categoria
]);
}
/**
* @Route("/api/ciudades/ro/ro")
* @Method({"POST"})
*/
public function getCiudades(Request $request)
{
$content = $request->getContent();
$request_get = json_decode($content, true);
$departamento_id = $request_get["departamento"];
$ciudades = $this->getDoctrine()->getRepository(Ciudad::class)->createQueryBuilder('c')
->select('c.id', 'c.nombre')
->leftJoin('c.departamento', 'd')
->where('d.id = :departamentoid')
->setParameter('departamentoid', $departamento_id)
->orderBy('c.nombre', 'asc')
->getQuery()
->getArrayResult();
return new Response(json_encode($ciudades));
}
/**
* @Route("/validaremailregister/romance/romancevalida")
*/
public function validaremailregister(Request $request)
{
$body = json_decode($request->getContent(), true);
/* @var $user Usuario */
$user = $body['email'];
$usuario=$this->getDoctrine()->getRepository(Usuario::class)->findOneBy(array('email'=>$user));
if($usuario){
$msg = array('ok'=>false,'mensaje'=>"La dirección de correo electrónico ya está en uso por otra cuenta");
}else{
$msg = array('ok'=>true);
}
return new Response(json_encode($msg));
}
/**
* @Route("/enviosuscripcion/ro/rom", name="enviosuscripcion")
*/
public function enviosuscripcion(Request $request)
{
$mensaje = array("ok" => false, "mensaje" => "error");
$email=$request->get("email");
$mensaje["ok"] = true;
$mensaje["mensaje"] = "Suscripcion realizada.";
$asunto = "Suscripcion al Blog - Romance Relax.";
$html = $this->renderView('contact/suscrip_mail.html.twig', array(
'email'=>$email,
));
$this->qi->sendMail($asunto,$email,$html);
$to = $this->qi->getSetting('mail_recepcion_pedidos');
$this->qi->sendMail($asunto,$to,$html);
return new JsonResponse($mensaje);
}
}