Obvody/app/Presentation/Mapa/MapaPresenter.php

45 lines
1.3 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Presentation\Mapa;
use App\Model\ZaznamFacade;
use Nette;
use Nette\Utils\Json;
final class MapaPresenter extends Nette\Application\UI\Presenter
{
/** Od tohoto počtu měsíců je obvod ve filtru stáří vykreslený červeně. */
public const STUPNICE_MESICU = 24;
/** Od tohoto počtu měsíců je rozpracovaný obvod vykreslený červeně. */
public const STUPNICE_PRIDELENI = 12;
public function __construct(
private ZaznamFacade $zaznam,
) {
}
public function renderDefault(?int $obvod = null, ?string $filtr = null): void
{
$povolene = ['obvody', 'stari', 'nedokoncene'];
if (!in_array($filtr, $povolene, true)) {
$filtr = 'obvody';
}
$stari = $this->zaznam->getStariObvodu();
foreach ($stari as &$polozka) {
$polozka['url'] = $this->link('Obvod:view', $polozka['id']);
}
unset($polozka);
$this->template->obvod_id = $obvod;
$this->template->filtr = $filtr;
$this->template->maxMesicu = self::STUPNICE_MESICU;
$this->template->maxPrideleni = self::STUPNICE_PRIDELENI;
$this->template->stariJson = Json::encode($stari, htmlSafe: true, forceObjects: true);
}
}