<?php

$house_id = $_GET['id'];

$page = $_GET['page'];
if ($page == 'tospur_sale_secondhand') {
    $house_type = 1;
} else if ($page == 'tospur_sale_rent') {
    $house_type = 2;
}
$detail_sql = "SELECT ts.*,dc.cityName,u.display_name FROM tospur_sale ts" .
    " left join (SELECT cityId,cityName FROM dic_city group by cityId) dc on ts.cityId = dc.cityId" .
    " left join wp_users u on u.ID = ts.consultant_id" .
    " where ts.house_type = " . $house_type . " and ts.id = " . $house_id;

$consultant_sql = 'SELECT u.id,u.display_name FROM wp_users u '
    . 'left join wp_usermeta m on u.id=m.user_id where meta_key="wp_user_level" and meta_value=7;';

global $wpdb;

$context['detail_result'] = $wpdb->get_row($detail_sql);
$context['consultant_result'] = $wpdb->get_results($consultant_sql);

$context['url'] = home_url();
$context['id'] = $house_id;
$context['house_type'] = $house_type;

Timber::render('sale_detail.html', $context);

?>