<?php
namespace AppBundle\Controller;
use Pimcore\Controller\FrontendController;
use Pimcore\Model\DataObject\Akcii;
use Pimcore\Model\DataObject\Budni;
use Pimcore\Model\DataObject\Trenery;
use Pimcore\Model\DataObject\Abonement;
use Symfony\Component\HttpFoundation\Request;
use Zend\Paginator\Paginator;
class NewsController extends FrontendController
{
// КОНТРОЛЕР АКЦИЙ
public function akciiAction(Request $request)
{
$actionsList = new Akcii\Listing();
$val = 'cross';
if(strstr($request->getRequestUri(), 'akcii-fitness-energy')) {
$val = 'fitness';
}
$where_str = "branch LIKE '%$val%' or branch LIKE 'all'";
$actionsList->setCondition($where_str);
$actionsList->setOrderKey('dateSort');
$paginator = new Paginator($actionsList);
$paginator->setCurrentPageNumber($request->get('page'));
$paginator->setItemCountPerPage(8);
$this->view->listCount = $actionsList->count();
$this->view->paginator = $paginator;
}
public function showAkciiAction(Request $request)
{
$docPath = $request->getPathInfo();
// "id" is the named parameters in "Static Routes"
$object = Akcii::getByPath($docPath);
if (!$object instanceof Akcii || !$object->isPublished()) {
// this will trigger a 404 error response
throw $this->createNotFoundException('Invalid request');
}
$this->view->Akcii = $object;
}
// КОНТРОЛЕР БУДНЕЙ
public function budniAction(Request $request)
{
// get a list of news objects and order them by date
$budniList = new Budni\Listing();
$val = 'cross';
if(strstr($request->getRequestUri(), 'budni-fitness-energy')) {
$val = 'fitness';
}
$where_str = "branch LIKE '%$val%' or branch LIKE 'all'";
$budniList->setCondition($where_str);
$budniList->setOrderKey('dateSort');
$budniList->setOrder('desc');
$paginator = new Paginator($budniList);
$paginator->setCurrentPageNumber($request->get('page'));
$paginator->setItemCountPerPage(9);
$this->view->listCount = $budniList->count();
$this->view->paginator = $paginator;
}
public function showBudniAction(Request $request)
{
$docPath = $request->getPathInfo();
// "id" is the named parameters in "Static Routes"
$object = Budni::getByPath($docPath);
if (!$object instanceof Budni || !$object->isPublished()) {
// this will trigger a 404 error response
throw $this->createNotFoundException('Invalid request');
}
$this->view->Budni = $object;
}
// КОНТРОЛЕР ТРЕНЕРОВ
public function treneryAction(Request $request)
{
$treneryList = new Trenery\Listing();
$val = 'cross';
if(strstr($request->getRequestUri(), 'komanda-fitness-energy')) {
$val = 'fitness';
}
$where_str = "branch LIKE '%$val%' or branch LIKE 'all'";
$treneryList->setCondition($where_str);
$treneryList->setOrderKey('dateSort');
$paginator = new Paginator($treneryList);
$paginator->setCurrentPageNumber($request->get('page'));
$paginator->setItemCountPerPage(40);
$this->view->listCount = $treneryList->count();
$this->view->paginator = $paginator;
}
public function showTreneryAction(Request $request) {
$docPath = $request->getPathInfo();
// "id" is the named parameters in "Static Routes"
$object = Trenery::getByPath($docPath);
if (!$object instanceof Trenery || !$object->isPublished()) {
throw $this->createNotFoundException('Invalid request');
}
$this->view->Trenery = $object;
}
// КОНТРОЛЕР АБОНЕМЕНТОВ
public function abonementsAction(Request $request)
{
$abonementsList = new Abonement\Listing();
$val = 'cross';
if(strstr($request->getRequestUri(), 'ceny-fitness-energy')) {
$val = 'fitness';
}
$where_str = "branch LIKE '%$val%' or branch LIKE 'all'";
$abonementsList->setCondition($where_str);
$abonementsList->setOrderKey('order');
$abonementsList->setOrder('asc');
$paginator = new Paginator($abonementsList);
$paginator->setItemCountPerPage(50);
$this->view->listCount = $abonementsList->count();
$this->view->paginator = $paginator;
}
public function showAbonementsAction(Request $request)
{
$docPath = $request->getPathInfo();
$object = Abonement::getByPath($docPath);
$shared_secret = '5d131445d03d483aa49356cb45b2e331';
if (!$object instanceof Abonement || !$object->isPublished()) {
// this will trigger a 404 error response
throw $this->createNotFoundException('Invalid request');
}
$service_type = $object->getService();
$name = $object->getProduct();
$club = $object->getClub();
$duration = $object->getDuration();
$price = $object->getPrice();
$data_string = $service_type . $name . $club . $duration . $price;
$signature = hash_hmac('sha256', $data_string, $shared_secret);
$this->view->signature = $signature;
$this->view->Abonement = $object;
}
}