<?php

require_once("_frontend.php");

class Billboards extends Frontend {

  function Billboards() {
    parent::Frontend();
    
    $this->load->model("firma");
    $this->load->model("kategoria");

    $this->_prepareLangPanel("billboards");
    
    $this->_assign('page_class', 'billboards');
  }


  function index()
  {
    $stranka = $this->uri->segment(4);
    $stranka = (!empty($stranka) ? $stranka : 0);
    $stranka = ($stranka < 0 ? 0 : $stranka);
    $kategoria = $this->uri->segment(5);
    
    $jazyk = $this->jazyk;
    
    $zacni_na = $this->nastavenie->vyber("firiem_na_stranku") * $stranka;
    
    $this->_assign("firmy", $this->firma->vyber($jazyk, $zacni_na, $this->nastavenie->vyber("firiem_na_stranku"), $kategoria));
    
    $strankovanie = $this->firma->strankujVystup($stranka, $this->nastavenie->vyber("firiem_na_stranku"), $this->nastavenie->vyber("strankovanie_pocet_listov"), $kategoria);
    
    $this->_assign("firmy_str", $strankovanie);
    $this->_assign("datum_novosti", (date("U") - 86400));
    $this->_assign("filter", $this->kategoria->dataFiltru($jazyk));
    $this->_assign("kategoria", $kategoria);
    
    $this->_assign("firms_lang", $this->language->GetLang("firms"));
    $this->_assign("filter_lang", $this->language->GetLang("filter"));
  
    $lang = $this->language->getLang('billboards');
    $this->_assign('main_lang', $lang);
    
    $this->_setHeader($lang['header_billboards']);
    
    $this->_setBody('billboards');
    $this->_display();
  }
  
  function filter()
  {
    $jazyk = $this->jazyk;
    
    if (isset($_POST["filter"]) && $_POST["filter"] > 0)
    {
      redirect("billboards/index/$jazyk/0/".$_POST["filter"]);
    }
    else
    {
      redirect("billboards/index/$jazyk/0");
    }
  }
  
  function detail()
  {
    $jazyk = $this->jazyk;
    
    $firma = $this->firma->vyber($jazyk, 0 , 1, 0, $this->uri->segment(4));
    $firma = $firma[0];
    
    if (count($firma) == 0 || $firma["firma_id"] != $this->uri->segment(4))
    {
      $this->_assign("nezobrazdetail", 1);
    }
    
    $this->_setBody("detail_firmy");
    
    $this->_assign("firma", $firma);
    
    $this->_assign("overall_lang", $this->language->GetLang("overall"));
    
    $this->_display();
  }
}

?>