Esempio n. 1
0
 public function terminosAction()
 {
     $view = new ViewModel();
     $comidas = $this->joinAction()->toArray();
     $storage = new \Zend\Authentication\Storage\Session('Auth');
     $session = $storage->read();
     if (!isset($session)) {
         $face = new \Usuario\Controller\ClientesController();
         $facebook = $face->facebook();
         $this->layout()->loginUrl = $facebook['loginUrl'];
         $this->layout()->user = $facebook['user'];
         if ($facebook['id_facebook']) {
             $url = '/terminos';
             $id_face = $this->getClientesTable()->usuarioface($facebook['email']);
             if (count($id_face) > 0) {
                 if ($id_face[0]['id_facebook'] == '') {
                     $this->getClientesTable()->idfacebook($id_face[0]['in_id'], $facebook['id_facebook'], $facebook['logoutUrl']);
                     AuthController::sessionfacebook($facebook['email'], $facebook['id_facebook'], $url);
                 } else {
                     $this->getClientesTable()->idfacebook2($id_face[0]['in_id'], $facebook['logoutUrl']);
                     AuthController::sessionfacebook($facebook['email'], $facebook['id_facebook'], $url);
                 }
             } else {
                 $this->getClientesTable()->insertarusuariofacebbok($facebook['name'], $facebook['email'], $facebook['id_facebook'], $facebook['logoutUrl']);
                 AuthController::sessionfacebook($facebook['email'], $facebook['id_facebook'], $url);
             }
         }
     }
     $this->layout()->comidas = $comidas;
     // $this->layout('layout/layout-portada');
     $this->layout()->clase = 'Terminos';
 }
Esempio n. 2
0
 public function verplatosAction()
 {
     $view = new ViewModel();
     if ($_GET['callback']) {
         header('Content-type: application/x-javascript');
         header("Status: 200");
         $idplato = (int) $this->params()->fromQuery('id');
         $nombre = $this->params()->fromQuery('va_nombre');
         $email = $this->params()->fromQuery('va_email');
         $comentario = $this->params()->fromQuery('tx_descripcion');
         $puntaje = (int) $this->params()->fromQuery('Ta_puntaje_in_id');
         $validar = explode('http://', $comentario);
         if (count($validar) == 2) {
             $result = array('resultado' => false);
             echo "jsonpCallback(" . json_encode($result) . ")";
         } else {
             $comentario = $comentario;
             $envia = array('Ta_plato_in_id' => $idplato, 'va_nombre' => $nombre, 'va_email' => $email, 'tx_descripcion' => $comentario, 'Ta_puntaje_in_id' => $puntaje);
             $cantidad = $this->getClientesTable()->usuario1($email);
             if (count($cantidad) == 0) {
                 $this->getClientesTable()->agregarComentariomovil($envia);
                 ClientesController::correomovill($email, $nombre);
             } else {
                 $this->getClientesTable()->agregarComentariomovil($envia);
             }
             $this->getPlatosTable()->cromSolr($idplato, '');
             $result = array('resultado' => true);
             echo "jsonpCallback(" . json_encode($result) . ")";
         }
         exit;
         $view->setTerminal(true);
         return $view;
     }
     $datos = $this->params()->fromRoute();
     $storage = new \Zend\Authentication\Storage\Session('Auth');
     $session = $storage->read();
     if ($session) {
         $participa = $this->getClientesTable()->compruebarUsuariox($session->in_id);
         $activo = $participa->en_estado;
     }
     if (!isset($session)) {
         $face = new \Usuario\Controller\ClientesController();
         $facebook = $face->facebook();
         $this->layout()->loginUrl = $facebook['loginUrl'];
         $this->layout()->user = $facebook['user'];
         if ($facebook['id_facebook']) {
             $url = $_SERVER['REQUEST_URI'];
             //$url='/plato/'.$datos['nombre'].'/'.$datos['nombre'];
             // $url='/plato/'.$datos['nombre'];
             $id_face = $this->getClientesTable()->usuarioface($facebook['email']);
             if (count($id_face) > 0) {
                 if ($id_face[0]['id_facebook'] == '') {
                     $this->getClientesTable()->idfacebook($id_face[0]['in_id'], $facebook['id_facebook'], $facebook['logoutUrl']);
                     AuthController::sessionfacebook($facebook['email'], $facebook['id_facebook'], $url);
                 } else {
                     $this->getClientesTable()->idfacebook2($id_face[0]['in_id'], $facebook['logoutUrl']);
                     AuthController::sessionfacebook($facebook['email'], $facebook['id_facebook'], $url);
                 }
             } else {
                 $this->getClientesTable()->insertarusuariofacebbok($facebook['name'], $facebook['email'], $facebook['id_facebook'], $facebook['logoutUrl']);
                 AuthController::sessionfacebook($facebook['email'], $facebook['id_facebook'], $url);
             }
         }
     }
     $urlerror = $datos['nombre'];
     $nombre = explode('-', $datos['nombre']);
     $id = array_pop($nombre);
     $listarecomendacion = $this->getPlatosTable()->getPlatoxRestaurant($id)->toArray();
     //          if(count($listarecomendacion)<1)
     //          {$this->redirect()->toUrl('/');}
     $texto = 'restaurante:"' . $listarecomendacion[0]['restaurant_nombre'] . '"';
     $limit = 10;
     $palabraBuscar = isset($texto) ? $texto : false;
     $query = "({$palabraBuscar})";
     $fq = array('fq' => 'en_estado:activo AND restaurant_estado:activo AND -id:' . $listarecomendacion[0]['in_id'], 'wt' => 'json');
     $results = false;
     if ($query) {
         $solr = \Classes\Solr::getInstance()->getSolr();
         if (get_magic_quotes_gpc() == 1) {
             $query = stripslashes($query);
         }
         try {
             $results = $solr->search($query, 0, $limit, $fq);
         } catch (Exception $e) {
             echo "<div>ingrese algun valor</div>";
         }
     }
     if (count($results->response->docs) < 10) {
         if (count($results->response->docs) == 0) {
             $consulta = $this->consultaAction(10, $listarecomendacion[0]['in_id'], $listarecomendacion[0]['tipo_plato_nombre']);
             $resultados = $results->response->docs;
         } elseif (count($results->response->docs) == 1) {
             $consulta = $this->consultaAction(9, $listarecomendacion[0]['in_id'], $listarecomendacion[0]['tipo_plato_nombre']);
             $resultados = $results->response->docs;
         } elseif (count($results->response->docs) == 2) {
             $consulta = $this->consultaAction(8, $listarecomendacion[0]['in_id'], $listarecomendacion[0]['tipo_plato_nombre']);
             $resultados = $results->response->docs;
         } elseif (count($results->response->docs) == 3) {
             $consulta = $this->consultaAction(7, $listarecomendacion[0]['in_id'], $listarecomendacion[0]['tipo_plato_nombre']);
             $resultados = $results->response->docs;
         } elseif (count($results->response->docs) == 4) {
             $consulta = $this->consultaAction(6, $listarecomendacion[0]['in_id'], $listarecomendacion[0]['tipo_plato_nombre']);
             $resultados = $results->response->docs;
         } elseif (count($results->response->docs) == 5) {
             $consulta = $this->consultaAction(5, $listarecomendacion[0]['in_id'], $listarecomendacion[0]['tipo_plato_nombre']);
             $resultados = $results->response->docs;
         } elseif (count($results->response->docs) == 6) {
             $consulta = $this->consultaAction(4, $listarecomendacion[0]['in_id'], $listarecomendacion[0]['tipo_plato_nombre']);
             $resultados = $results->response->docs;
         } elseif (count($results->response->docs) == 7) {
             $consulta = $this->consultaAction(3, $listarecomendacion[0]['in_id'], $listarecomendacion[0]['tipo_plato_nombre']);
             $resultados = $results->response->docs;
         } elseif (count($results->response->docs) == 8) {
             $consulta = $this->consultaAction(2, $listarecomendacion[0]['in_id'], $listarecomendacion[0]['tipo_plato_nombre']);
             $resultados = $results->response->docs;
         } elseif (count($results->response->docs) == 9) {
             $consulta = $this->consultaAction(1, $listarecomendacion[0]['in_id'], $listarecomendacion[0]['tipo_plato_nombre']);
             $resultados = $results->response->docs;
         }
     } else {
         $resultados = $results->response->docs;
     }
     $servicios = $this->getPlatosTable()->getServicioxPlato($id);
     $locales = $this->getPlatosTable()->getLocalesxRestaurante($listarecomendacion[0]['restaurant_id']);
     $pagos = $this->getPlatosTable()->getPagoxPlato($id);
     $form = new \Usuario\Form\ComentariosForm();
     $canonical = new \Application\View\Helper\Canonical();
     $canonicalurl = new \Application\View\Helper\CanonicalUrl();
     $resta = $canonicalurl($canonical($listarecomendacion[0]['restaurant_nombre']));
     $form->get('submit')->setValue('Agregar');
     $request = $this->getRequest();
     if ($request->isPost()) {
         if ($session) {
             $datos = $this->getRequest()->getPost()->toArray();
             $datos['Ta_plato_in_id'] = $id;
             $datos['tx_descripcion'] = htmlspecialchars($datos['tx_descripcion']);
             $validar = explode('http://', $datos['tx_descripcion']);
             // if(count($validar)==2){
             //                return $this->redirect()->toUrl('/plato/'.$urlerror.'?m=1');
             //                }
             // else {
             $form->setData($datos);
             if (!$form->isValid()) {
                 $this->getComentariosTable()->agregarComentario($form->getData(), $participa->in_id);
                 $this->getComentariosTable()->cromSolar($id, '');
                 $datos = $this->params()->fromRoute();
                 if ($datos['tx_descripcion']) {
                     $this->redirect()->toUrl('/plato/' . $resta . '/' . $datos['nombre']);
                 }
             }
             //}
         }
     }
     $this->layout()->clase = 'Detalle';
     $listarcomentarios = $this->getPlatosTable()->getComentariosxPlatos($id);
     $paginator = new \Zend\Paginator\Paginator(new \Zend\Paginator\Adapter\Iterator($listarcomentarios));
     $paginator->setCurrentPageNumber((int) $this->params()->fromQuery('page', 1));
     $paginator->setItemCountPerPage(10);
     $config = $this->getServiceLocator()->get('Config');
     $this->layout()->title = $listarecomendacion[0]['va_nombre'];
     $this->layout()->image = $listarecomendacion[0]['va_imagen'] == 'platos-default.png' ? $config['host']['images'] . '/defecto/' . $listarecomendacion[0]['va_imagen'] : $config['host']['images'] . '/plato/principal/' . $listarecomendacion[0]['va_imagen'];
     $this->layout()->description = trim($listarecomendacion[0]['restaurant_nombre']) . '-' . trim($listarecomendacion[0]['tx_descripcion']) . '-' . trim($listarecomendacion[0]['va_direccion']) . '-' . trim($listarecomendacion[0]['va_direccion_referencia'] . '-(' . trim($listarecomendacion[0]['distrito']) . ')- teléfono:' . trim($listarecomendacion[0]['va_telefono']));
     $this->layout()->url = $config['host']['ruta'] . '/plato/' . $resta . '/' . $datos['nombre'];
     $listatitle = trim($listarecomendacion[0]['va_nombre']) . ':' . trim($listarecomendacion[0]['tx_descripcion']) . ':' . trim($listarecomendacion[0]['tipo_plato_nombre']) . ':' . trim($listarecomendacion[0]['restaurant_nombre']) . ':' . trim($listarecomendacion[0]['distrito']) . ' │ ';
     $menu = $this->menu();
     $view->setVariables(array('lista' => $listarecomendacion, 'comentarios' => $paginator, 'form' => $form, 'servicios' => $servicios, 'urlplato' => $id, 'urlnombre' => $datos['nombre'], 'pagos' => $pagos, 'locales' => $locales, 'cantidad' => $this->getCount($listarcomentarios), 'variable' => $id, 'listatitle' => $listatitle, 'masplatos' => $resultados, 'listades' => $consulta, 'menus' => $menu, 'session' => $session, 'resta' => $resta, 'participa' => $activo));
     return $view;
 }