<?php

$context = array();
$context['theme'] = get_template_directory_uri();
require_once(WP_PLUGIN_DIR."/tospur/Dao/SearchDao.php");

$cityId = 1;
if($_GET['cityId'])
    $cityId = $_GET['cityId'];
$context['cityId'] = $cityId;
$context['cityName'] = SearchDao::getCityNameWithId($cityId);
$context['select']['city'] = SearchDao::searchCity();
$context['select']['district'] = SearchDao::searchCity($cityId);
$plateArray = array();
foreach($context['select']['district'] as $item){
    $plateArray[$item->id] = array();
    foreach(SearchDao::searchCity($cityId,$item->id) as $i){
        $plateArray[$item->id][] = $i;
    }
}
$context['select']['plate'] = json_encode($plateArray);
$context['select']['buildProperty'] = SearchDao::searchBuildProperty();
$context['select']['room'] = json_encode(SearchDao::searchRoom());
$context['select']['unitPriceRange'] = SearchDao::searchUnitPriceRange($cityId);
$context['select']['totalPrice'] = SearchDao::searchTotalPrice($cityId);
$context['select']['area'] = json_encode(SearchDao::searchArea($cityId));

$context['site_url'] = site_url();
Timber::render('index.html', $context);
?>