<?php
namespace Troika\RealEstateBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
class LotController extends \Symfony\Bundle\FrameworkBundle\Controller\AbstractController
{
private function _model($name)
{
return $this
->container
->get($name . '.model');
}
public function cityAction($id)
{
$lot = $this
->_model('lot')
->getByBid($id);
if ($lot) {
switch ($lot->getTypeLot()->getId()) {
case 1:
$url = "/elit_kvartiry/";
break;
case 2:
$url = "/zagorodnaya_nedvizhimost/";
break;
case 3:
$url = "/commercial_nedvigimost/";
break;
case 4:
$url = "/zarubezhnaya_nedvizhimost/";
break;
}
//if ($url) {
// $url .= $lot->getId();
// return $this->redirect($url, 301);
//}
}
$lot = $this
->_model('lot')
->getForTypeById($id, 1);
if (empty($lot)) {
throw new NotFoundHttpException();
}
$similar = $this
->_model('lot')
->getSimilar($lot);
$ogImg = '#';
$photos = $lot->getPhotos();
if (!empty($photos)) {
foreach ($photos as $photo) {
if ($ogImg === '#') {
$ogImg = $photo->getWebPathImage();
if ($photo->getIsMain()) {
break;
}
} elseif ($photo->getIsMain()) {
$ogImg = $photo->getWebPathImage();
break;
}
}
}
$page = $this->getDoctrine()->getRepository('TroikaMainBundle:MainPage')->find(2);
return $this->render(
'TroikaRealEstateBundle:EstateLot:city.html.twig',
[
'ogImg' => $ogImg,
'lot' => $lot,
'similar' => $similar,
'page'=>$page,
'islot' => true
]
);
}
public function cityPdfAction($id)
{
$lot = $this
->_model('lot')
->getForTypeById($id, 1);
if (!$lot) {
throw new NotFoundHttpException();
}
return $this->render('TroikaRealEstateBundle:EstateLot:city.pdf.twig', ['lot' => $lot]);
}
public function cityPdf_Action($id)
{
$lot = $this
->_model('lot')
->getForTypeById($id, 1);
if (!$lot) {
throw new NotFoundHttpException();
}
return $this->render('TroikaRealEstateBundle:EstateLot:city_new.pdf.twig', ['lot' => $lot]);
}
public function commercialAction($id)
{
$lot = $this
->_model('lot')
->getByBid($id);
if ($lot) {
switch ($lot->getTypeLot()->getId()) {
case 1:
$url = "/elit_kvartiry/";
break;
case 2:
$url = "/zagorodnaya_nedvizhimost/";
break;
case 3:
$url = "/commercial_nedvigimost/";
break;
case 4:
$url = "/zarubezhnaya_nedvizhimost/";
break;
}
//if ($url) {
// $url .= $lot->getId();
// return $this->redirect($url, 301);
//}
}
$lot = $this
->_model('lot')
->getForTypeById($id, 3);
if (!$lot) {
throw new NotFoundHttpException();
}
$similar = $this
->_model('lot')
->getSimilarCom($lot);
$ogImg = '';
foreach ($lot->getPhotos() as $photo) {
if ($photo->getIsMain()) {
$ogImg = $photo->getWebPathImage();
}
}
// var_dump($similar->lenght);
$page = $this->getDoctrine()->getRepository('TroikaMainBundle:MainPage')->find(2);
return $this->render(
'TroikaRealEstateBundle:EstateLot:commercial.html.twig',
['ogImg' => $ogImg, 'lot' => $lot, 'similar' => $similar,'page'=>$page,'islot' => true]
);
}
public function commercialPdfAction($id)
{
$lot = $this
->_model('lot')
->getForTypeById($id, 3);
if (!$lot) {
throw new NotFoundHttpException();
}
return $this->render('TroikaRealEstateBundle:EstateLot:commercial.pdf.twig', ['lot' => $lot]);
}
public function commercialPdf_Action($id)
{
$lot = $this
->_model('lot')
->getForTypeById($id, 3);
if (!$lot) {
throw new NotFoundHttpException();
}
return $this->render('TroikaRealEstateBundle:EstateLot:commercial_new.pdf.twig', ['lot' => $lot]);
}
public function favePdfAction(Request $request)
{
$lots = $request->get('lots');
$lots = $this->container->get('lot.model')->getFave($lots);
return $this->render('TroikaRealEstateBundle:EstateList:fave.pdf.twig', ['lots' => $lots]);
}
public function foreignAction($id)
{
$lot = $this
->_model('lot')
->getByBid($id);
if ($lot) {
switch ($lot->getTypeLot()->getId()) {
case 1:
$url = "/elit_kvartiry/";
break;
case 2:
$url = "/zagorodnaya_nedvizhimost/";
break;
case 3:
$url = "/commercial_nedvigimost/";
break;
case 4:
$url = "/zarubezhnaya_nedvizhimost/";
break;
}
//if ($url) {
// $url .= $lot->getId();
// return $this->redirect($url, 301);
//}
}
$lot = $this
->_model('lot')
->getForTypeById($id, 4);
if (!$lot) {
throw new NotFoundHttpException();
}
$similar = $this
->_model('lot')
->getSimilar($lot);
$ogImg = '';
foreach ($lot->getPhotos() as $photo) {
if ($photo->getIsMain()) {
$ogImg = $photo->getWebPathImage();
}
}
$page = $this->getDoctrine()->getRepository('TroikaMainBundle:MainPage')->find(2);
return $this->render('TroikaRealEstateBundle:EstateLot:foreign.html.twig', ['ogImg' => $ogImg, 'lot' => $lot, 'similar' => $similar,'page'=>$page,'islot' => true]
);
}
public function foreignPdfAction($id)
{
$lot = $this
->_model('lot')
->getForTypeById($id, 4);
if (!$lot) {
throw new NotFoundHttpException();
}
return $this->render('TroikaRealEstateBundle:EstateLot:foreign.pdf.twig', ['lot' => $lot]);
}
public function foreignPdf_Action($id)
{
$lot = $this
->_model('lot')
->getForTypeById($id, 4);
if (!$lot) {
throw new NotFoundHttpException();
}
return $this->render('TroikaRealEstateBundle:EstateLot:foreign_new.pdf.twig', ['lot' => $lot]);
}
public function suburbanAction($id)
{
$lot = $this
->_model('lot')
->getByBid($id);
if ($lot) {
switch ($lot->getTypeLot()->getId()) {
case 1:
$url = "/elit_kvartiry/";
break;
case 2:
$url = "/zagorodnaya_nedvizhimost/";
break;
case 3:
$url = "/commercial_nedvigimost/";
break;
case 4:
$url = "/zarubezhnaya_nedvizhimost/";
break;
}
//if ($url) {
// $url .= $lot->getId();
// return $this->redirect($url, 301);
//}
}
if ($id == 851) {
return $this->redirect("/zagorodnaya_nedvizhimost/1019/", 301);
}
$lot = $this
->_model('lot')
->getForTypeById($id, 2);
if (!$lot) {
throw new NotFoundHttpException();
}
$similar = $this
->_model('lot')
->getSimilar($lot);
$ogImg = '';
foreach ($lot->getPhotos() as $photo) {
if ($photo->getIsMain()) {
$ogImg = $photo->getWebPathImage();
}
}
$page = $this->getDoctrine()->getRepository('TroikaMainBundle:MainPage')->find(2);
return $this->render(
'TroikaRealEstateBundle:EstateLot:suburban.html.twig',
['ogImg' => $ogImg, 'lot' => $lot, 'similar' => $similar,'page'=>$page,'islot' => true]
);
}
public function suburbanPdfAction($id)
{
$lot = $this
->_model('lot')
->getForTypeById($id, 2);
if (!$lot) {
throw new NotFoundHttpException();
}
return $this->render('TroikaRealEstateBundle:EstateLot:suburban.pdf.twig', ['lot' => $lot]);
}
public function suburbanPdf_Action($id)
{
$lot = $this
->_model('lot')
->getForTypeById($id, 2);
if (!$lot) {
throw new NotFoundHttpException();
}
return $this->render('TroikaRealEstateBundle:EstateLot:suburban_new.pdf.twig', ['lot' => $lot]);
}
}