764 lines
34 KiB
PHP
764 lines
34 KiB
PHP
<script type="text/javascript" src="/js/ajax-form.js"></script>
|
||
<script type="text/javascript" src="/js/core.js?t=14"></script>
|
||
<script type="text/javascript" src="/js/subway_newbuildings.js?t=8"></script>
|
||
<script type="text/javascript" src="/js/raion_newbuildings.js?t=12"></script>
|
||
<script type="text/javascript" src="/js/popup.js"></script>
|
||
<script type="text/javascript" src="/js/fotorama.js"></script>
|
||
<style>
|
||
.jw__layout-content .main-title {
|
||
padding: 20px 0 22px 35px;
|
||
position: relative;
|
||
z-index: 99;
|
||
border-bottom: 1px solid #dedede;
|
||
background: #fff;
|
||
}
|
||
.search__tabs {
|
||
padding: 0 35px !important;
|
||
position: relative;
|
||
z-index: 99;
|
||
background: #fff;
|
||
}
|
||
.jw__layout .content-top {
|
||
z-index: 100;
|
||
}
|
||
.show_form {
|
||
padding: 12px 35px 15px;
|
||
margin: 0;
|
||
text-align: center;
|
||
font-size: 15px;
|
||
color: #757575;
|
||
cursor: pointer;
|
||
background: -moz-linear-gradient(top, #f8f8f8, #fff);
|
||
background: -webkit-linear-gradient(top, #f8f8f8, #fff);
|
||
background: -o-linear-gradient(top, #f8f8f8, #fff);
|
||
background: -ms-linear-gradient(top, #f8f8f8, #fff);
|
||
background: linear-gradient(top, #f8f8f8, #fff);
|
||
border-top: 0;
|
||
border-bottom: 1px solid #dedede;
|
||
margin-bottom: 25px;
|
||
}
|
||
.show_form i {
|
||
position: relative;
|
||
top: 2px;
|
||
margin-left: 5px;
|
||
font-size: 17px;
|
||
opacity: .7;
|
||
}
|
||
.show_form:hover i {
|
||
opacity: 1;
|
||
}
|
||
|
||
.optgroup .selected-label {
|
||
background-color: #efefef;
|
||
}
|
||
|
||
.optgroup, .optgroup span {
|
||
border: none !important;
|
||
}
|
||
.district .ms-options > ul > li.ms-reflow {
|
||
font-weight: bold;
|
||
}
|
||
.ms-options > ul > li.ms-reflow {
|
||
margin: 5px 5px 5px 7px;
|
||
padding-bottom: 7px;
|
||
font-size: 16px;
|
||
}
|
||
.ms-options>ul > li > span:hover {
|
||
background-color: #efefef;
|
||
}
|
||
.ms-options > ul {
|
||
column-gap: 2px !important;
|
||
}
|
||
</style>
|
||
|
||
<?php
|
||
$get=clearInputData($_GET);
|
||
|
||
if ($_SESSION['temp_region_newbuilding']) {
|
||
$temp_region= $_SESSION['temp_region_newbuilding'];
|
||
} else {
|
||
$user = new User;
|
||
$user->get($_SESSION['id']);
|
||
$temp_region = $user->region_rf_id;
|
||
}
|
||
|
||
$metro = array();
|
||
if(isset($_GET['metro']))
|
||
{
|
||
foreach($_GET['metro'] as $v) $metro[$v] = 1;
|
||
}
|
||
include_once($_SERVER['DOCUMENT_ROOT']."/ajax/metromap_newbuidings.php");
|
||
|
||
$raion = array();
|
||
if(isset($_GET['raion']))
|
||
{
|
||
foreach($_GET['raion'] as $v) $raion[$v] = 1;
|
||
}
|
||
include_once($_SERVER['DOCUMENT_ROOT']."/ajax/raion_newbuildings.php");
|
||
|
||
$metros = Subway::getElementsList($temp_region);
|
||
function buildTree(array $elements, $parentId = 0) {
|
||
$branch = array();
|
||
foreach ($elements as $element) {
|
||
|
||
if ($element->parent_id == $parentId) {
|
||
$children = buildTree($elements, $element->id);
|
||
if ($children) {
|
||
$element->children = $children;
|
||
}
|
||
$branch[] = $element;
|
||
}
|
||
}
|
||
|
||
return $branch;
|
||
}
|
||
|
||
$regions = Region::getElementsList($temp_region);
|
||
|
||
$treeRegions = buildTree($regions);
|
||
|
||
$districtListHtml = '';
|
||
foreach ($treeRegions as $item) {
|
||
if (!$item->children) {
|
||
$className = 'item';
|
||
$selectedStr = (isset($get['district']) && $get['district'] && in_array($item->id, $get['district'])) ? "selected" : '';
|
||
$districtListHtml .= "<option class='$className' value='$item->id' $selectedStr>$item->name</option>";
|
||
} else {
|
||
$districtListHtml .= "<optgroup label='$item->name'>";
|
||
foreach ($item->children as $subItem) {
|
||
$className = !$subItem->parent_id ? 'parent' : 'item';
|
||
$selectedStr = (isset($get['district']) && $get['district'] && in_array($subItem->id, $get['district'])) ? "selected" : '';
|
||
$districtListHtml .= "<option class='$className' value='$subItem->id' $selectedStr>$subItem->name</option>";
|
||
}
|
||
}
|
||
|
||
$districtListHtml .= "</optgroup>";
|
||
}
|
||
?>
|
||
<div class="show_form" id="show_form" <?php if($_GET['hide_form']) echo 'style="display: block"'; else echo 'style="display: none"'; ?>>Развернуть форму<i class="ti-angle-double-down"></i></div>
|
||
<div class="main-form" <?php if($_GET['hide_form']) echo 'style="display: none"'; ?>>
|
||
<form id="f-system-search-form" action="/newbuildings.php">
|
||
<div class="control-cols">
|
||
<div class="control-col left">
|
||
<div class="control-group">
|
||
<div class="control subway">
|
||
<div class="form-search__main-label small-label">
|
||
<span>Регион:</span>
|
||
</div>
|
||
<div class="jw-search__multiple-select">
|
||
|
||
<select class="text" id="region_newbuilding_select_search" name="region" required>
|
||
<?php
|
||
$region_rf = mysql_query("select * from rf_regions where parent = 0");
|
||
while($dealType = mysql_fetch_assoc($region_rf)) {
|
||
?>
|
||
<option value="<?=$dealType['id']?>" <?php if($dealType['id'] == $temp_region) echo "selected";?>>
|
||
<?=$dealType['name']?>
|
||
</option>
|
||
<?php } ?>
|
||
</select>
|
||
</div>
|
||
</div>
|
||
<div class="clear"></div>
|
||
</div>
|
||
<div id="subway-select-list" class="control-group" style="display: <?= (count($metros) > 0 ? "" : "none") ?>">
|
||
<div class="control subway">
|
||
<div class="form-search__main-label small-label">
|
||
<span>Метро:</span>
|
||
</div>
|
||
<div class="jw-search__multiple-select">
|
||
<select id="select-subway" name="subway[]" multiple="multiple" class="3col ms-subway">
|
||
<optgroup label=''>
|
||
<?php foreach ($metros as $item) {?>
|
||
<option value="<?php echo $item->id;?>" <?php if (isset($get['subway']) && $get['subway'] && in_array($item->id, $get['subway'])) { echo "selected"; } ?>><?php echo $item->name;?></option>
|
||
<?php } ?>
|
||
</optgroup>
|
||
</select>
|
||
<!-- <button id="subway-map-select" class="simple-button" type="button"><i class="ti-map"></i></button> -->
|
||
<button id="subway-map-clear" class="simple-button ms-clear" title="Очистить" type="button" style="font-size: 18px; top: 9px"><i class="ti-close"></i></button>
|
||
</div>
|
||
</div>
|
||
<div class="clear"></div>
|
||
</div>
|
||
<div class="control-group">
|
||
<div class="control district">
|
||
<div class="form-search__main-label small-label">
|
||
<span>Район:</span>
|
||
</div>
|
||
<div class="jw-search__multiple-select">
|
||
<select id="select-district" name="district[]" multiple="multiple" class="ms-district">
|
||
<?= $districtListHtml; ?>
|
||
</select>
|
||
<!-- <select name="district[]" multiple="multiple" class="ms-district">
|
||
<?php // foreach (Region::getElementsList() as $item) {?>
|
||
<option class="<?php // echo !$item->parent_id ? 'parent' : 'item'; ?>" value="<?php // echo $item->id;?>" <?php // if (isset($get['district']) && $get['district'] && in_array($item->id, $get['district'])) { echo "selected"; } ?>><?php // echo $item->name;?></option>
|
||
<?php // } ?>
|
||
</select> -->
|
||
<!-- <button id="district-map-select" class="simple-button" title="Карта" type="button"><i class="ti-map"></i></button> -->
|
||
<button id="district-map-clear" class="simple-button ms-clear" title="Очистить" type="button" style="font-size: 18px; top: 9px"><i class="ti-close"></i></button>
|
||
</div>
|
||
</div>
|
||
<div class="clear"></div>
|
||
</div>
|
||
|
||
<div class="control-group">
|
||
<div class="control address">
|
||
<div class="form-search__main-label small-label">
|
||
<span>Адрес:</span>
|
||
</div>
|
||
<div class="">
|
||
<input style="width: 380px;"
|
||
<?php if ($hasRestrictedAccess) {
|
||
echo 'disabled="disabled"';
|
||
} ?> type="text" name="adres" class="text big-input no-mrg-left <?php if ($hasRestrictedAccess) {
|
||
echo "tooltip-item";
|
||
} ?>" placeholder="Улица, проспект, шоссе, переулок" value="<?php if ($hasRestrictedAccess) {
|
||
echo "";
|
||
} else {
|
||
echo $get['adres'];
|
||
} ?>"
|
||
>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="control-group">
|
||
<div class="control period">
|
||
<div class="form-search__main-label small-label">
|
||
<span>Период по:</span>
|
||
</div>
|
||
<div class="">
|
||
<select name="period" class="ms-period" style="margin-left: 0;">
|
||
<option value="-1" <?php if (isset($get['period']) && $get['period'] && $get['period'] == -1) { echo "selected"; } ?>></option>
|
||
<?php foreach (Building::getUniquePeriods() as $k => $item) { ?>
|
||
<option value="<?php echo $k;?>" <?php if (isset($get['period']) && $get['period'] && $k == $get['period']) { echo "selected"; } ?>><?php echo $item;?></option>
|
||
<?php } ?>
|
||
</select>
|
||
</div>
|
||
</div>
|
||
<div class="clear"></div>
|
||
</div>
|
||
<div class="control-group">
|
||
<div class="control residential">
|
||
<div class="form-search__main-label small-label">
|
||
<span>Комплекс:</span>
|
||
</div>
|
||
<div class="jw-search__multiple-select">
|
||
<select name="block[]" multiple="multiple" class="ms-residential">
|
||
<?php foreach (Block::getElementsList($temp_region) as $item) {?>
|
||
<option value="<?php echo $item->id;?>" <?php if (isset($get['block']) && $get['block'] && in_array($item->id, $get['block'])) { echo "selected"; } ?>><?php echo $item->name;?></option>
|
||
<?php } ?>
|
||
</select>
|
||
<button id="residential-clear" class="simple-button ms-clear" title="Очистить" type="button"><i class="ti-close"></i></button>
|
||
</div>
|
||
</div>
|
||
<div class="clear"></div>
|
||
</div>
|
||
<div class="control-group">
|
||
<div class="control decoration">
|
||
<div class="form-search__main-label small-label">
|
||
<span>Отделка:</span>
|
||
</div>
|
||
<div class="jw-search__multiple-select">
|
||
<select name="decoration[]" multiple="multiple" class="ms-decoration">
|
||
<?php foreach (DecorationType::getElementsList() as $item) {?>
|
||
<option value="<?php echo $item->id;?>" <?php if (isset($get['decoration']) && $get['decoration'] && in_array($item->id, $get['decoration'])) { echo "selected"; } ?>><?php echo $item->name;?></option>
|
||
<?php } ?>
|
||
</select>
|
||
<button id="decoration-clear" class="simple-button ms-clear" title="Очистить" type="button"><i class="ti-close"></i></button>
|
||
</div>
|
||
</div>
|
||
<div class="clear"></div>
|
||
</div>
|
||
</div>
|
||
<div class="control-col right">
|
||
<div class="control-group">
|
||
<div class="control developer">
|
||
<div class="form-search__main-label small-label">
|
||
<span>Застройщик:</span>
|
||
</div>
|
||
<div class="jw-search__multiple-select">
|
||
<select id="select-builder" name="builder[]" multiple="multiple" class="ms-developer">
|
||
<?php foreach (Builder::getElementsList($temp_region) as $item) {?>
|
||
<option value="<?php echo $item->id;?>" <?php if (isset($get['builder']) && $get['builder'] && in_array($item->id, $get['builder'])) { echo "selected"; } ?>><?php echo $item->name;?></option>
|
||
<?php } ?>
|
||
</select>
|
||
<button id="builder-clear" class="simple-button ms-clear" title="Очистить" type="button"><i class="ti-close"></i></button>
|
||
</div>
|
||
</div>
|
||
<div class="clear"></div>
|
||
</div>
|
||
<div class="control-group">
|
||
<div class="control n-type">
|
||
<div class="form-search__main-label small-label">
|
||
<span>Тип:</span>
|
||
</div>
|
||
<div class="jw-search__multiple-select">
|
||
<select name="type[]" multiple="multiple" class="ms-type">
|
||
<?php foreach (RoomType::getElementsList() as $item) {?>
|
||
<option value="<?php echo $item->id;?>" <?php if (isset($get['type']) && $get['type'] && in_array($item->id, $get['type'])) { echo "selected"; } ?>><?php echo $item->name;?></option>
|
||
<?php } ?>
|
||
</select>
|
||
<button id="type-clear" class="simple-button ms-clear" title="Очистить" type="button"><i class="ti-close"></i></button>
|
||
</div>
|
||
</div>
|
||
<div class="clear"></div>
|
||
</div>
|
||
<div class="control-group">
|
||
<div class="control variant">
|
||
<div class="form-search__main-label small-label">
|
||
<span>Вариант:</span>
|
||
</div>
|
||
<div class="jw-search__multiple-select">
|
||
<select name="variant[]" multiple="multiple" class="ms-variant">
|
||
<?php foreach (FlatType::getElementsList() as $item) {?>
|
||
<option value="<?php echo $item->id;?>" <?php if (isset($get['variant']) && $get['variant'] && in_array($item->id, $get['variant'])) { echo "selected"; } ?>><?php echo $item->name;?></option>
|
||
<?php } ?>
|
||
</select>
|
||
<button id="variant-clear" class="simple-button ms-clear" title="Очистить" type="button"><i class="ti-close"></i></button>
|
||
</div>
|
||
</div>
|
||
<div class="clear"></div>
|
||
</div>
|
||
<!-- <div class="control-group">
|
||
<div class="control bank">
|
||
<div class="form-search__main-label small-label">
|
||
<span>Банк:</span>
|
||
</div>
|
||
<div class="jw-search__multiple-select">
|
||
<select name="bank[]" multiple="multiple" class="ms-bank">
|
||
<?php
|
||
// foreach (Bank::getElementsList() as $item) {
|
||
?>
|
||
<option value="<?php // echo $item->id;?>" <?php // if (isset($get['bank']) && $get['bank'] && in_array($item->id, $get['bank'])) { echo "selected"; } ?>><?php // echo $item->name;?></option>
|
||
<?php // } ?>
|
||
</select>
|
||
<button id="bank-clear" class="simple-button ms-clear" title="Очистить" type="button"><i class="ti-close"></i></button>
|
||
</div>
|
||
</div>
|
||
<div class="clear"></div>
|
||
</div> -->
|
||
<!-- <div class="control-group">
|
||
<div class="control payment">
|
||
<div class="form-search__main-label small-label">
|
||
<span>Оплата:</span>
|
||
</div>
|
||
<div class="jw-search__multiple-select">
|
||
<select name="payment[]" multiple="multiple" class="ms-payment">
|
||
<?php // foreach (Apartment::getPaymentList() as $k => $item) { ?>
|
||
<option value="<?php // echo $k;?>" <?php // if (isset($get['payment']) && $get['payment'] && in_array($k, $get['payment'])) { echo "selected"; } ?>><?php // echo $item;?></option>
|
||
<?php // } ?>
|
||
</select>
|
||
<button id="payment-clear" class="simple-button ms-clear" title="Очистить" type="button"><i class="ti-close"></i></button>
|
||
</div>
|
||
</div>
|
||
<div class="clear"></div>
|
||
</div> -->
|
||
</div>
|
||
<div class="clear"></div>
|
||
</div>
|
||
<div class="control-groupline">
|
||
<div class="control-group">
|
||
<div class="control">
|
||
<div class="form-search__main-label small-label"><span>Площадь:</span></div>
|
||
<div class="control-inputs">
|
||
<div class="inputs-group">
|
||
<input type="number" class="text small-input no-mrg-left" min="0" max="1000" name="sq_all_ot" placeholder="от" value="<?php if (isset($get['sq_all_ot']) && $get['sq_all_ot']) { echo $get['sq_all_ot']; } ?>">
|
||
<input type="number" class="text small-input" min="0" max="1000" name="sq_all_do" placeholder="до" value="<?php if (isset($get['sq_all_do']) && $get['sq_all_do']) { echo $get['sq_all_do']; } ?>">
|
||
<span class="form-label with-pad"> м<sup>2</sup></span>
|
||
</div>
|
||
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="control-group">
|
||
<div class="control">
|
||
<div class="form-search__main-label small-label"><span>Этаж:</span></div>
|
||
<div class="control-inputs">
|
||
<div class="inputs-group">
|
||
<input type="number" class="text small-input no-mrg-left" min="0" max="100" name="flat_floor_ot" placeholder="от" value="<?php if (isset($get['flat_floor_ot']) && $get['flat_floor_ot']) { echo $get['flat_floor_ot']; } ?>">
|
||
<input type="number" class="text small-input" min="0" max="100" name="flat_floor_do" placeholder="до" value="<?php if (isset($get['flat_floor_do']) && $get['flat_floor_do']) { echo $get['flat_floor_do']; } ?>">
|
||
</div>
|
||
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="control-group newb-search">
|
||
<div class="control">
|
||
<div class="form-search__main-label small-label">
|
||
<span>Цена:</span>
|
||
</div>
|
||
<div class="control-inputs">
|
||
<div class="inputs-group">
|
||
<div class="fr-input fr-price">
|
||
<input type="text" id="stoim_ot" class="text price medium-input no-mrg-left money-format money" name="stoim_ot" placeholder="от" value="<?php if (isset($get['stoim_ot'])) { echo $get['stoim_ot']; } ?>">
|
||
<div class="fr-ui-slider slider_newbuiding1" id="e-form-slider"></div>
|
||
</div>
|
||
<div class="fr-input fr-price second">
|
||
<input type="text" id="stoim_do" class="text price medium-input money-format money" name="stoim_do" placeholder="до" value="<?php if (isset($get['stoim_do'])) { echo $get['stoim_do']; } ?>">
|
||
<div class="fr-ui-slider slider_newbuiding2" id="e-form-slider"></div>
|
||
</div>
|
||
<span class="form-label with-pad"> <span class="rub">p</span></span>
|
||
<button id="clearAllFilter" style="margin-left: 9%;" class="fr-btn steel small" type="button">Очистить форму</button>
|
||
<div class="clear"></div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="control-group last-level" style="margin-top: 0;">
|
||
<input type="hidden" name="hide_form" value="1">
|
||
<input type="hidden" name="do_search" value="1">
|
||
<?php if($_SESSION['id'] == 93 || $_SESSION['id'] == 1048) echo '<input type=checkbox name=dev value=1> debug'; ?>
|
||
<?php
|
||
if(isset($hasRestrictedAccess) && $hasRestrictedAccess){
|
||
?>
|
||
<button id="search" class="button-fl-left big-button" type="button" onclick="trialperiod.open()">Найти</button>
|
||
<?php
|
||
} else {
|
||
?>
|
||
<button id="search" class="button-fl-left big-button" type="submit">Найти</button>
|
||
<div class="load-bar hidden" style="top: auto !important;">
|
||
<div class="bar"></div>
|
||
<div class="bar"></div>
|
||
<div class="bar"></div>
|
||
<div class="load-bar__center">
|
||
<span class="load-bar__loading">Поиск...</span>
|
||
</div>
|
||
</div>
|
||
<?php } ?>
|
||
|
||
<div class="clear"></div>
|
||
</div>
|
||
<div class="clear"></div>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
<div class="jw-new-residence">
|
||
|
||
<?php
|
||
|
||
$_SESSION['lastNewbuildingsSearchUrl'] = "";
|
||
|
||
if(isset($_GET['do_search'])) {
|
||
|
||
list($mas_usl_bd, $mas_url_add, $order) = search_newbuildings($get);
|
||
|
||
$mas_url_add[] = "hide_form=1";
|
||
$mas_url_add[] = "do_search=1";
|
||
|
||
if (isset($get['payment']) && $get['payment']) {
|
||
|
||
foreach($get['payment'] as $payment) {
|
||
if ($payment == Apartment::PAYMENT_MORTGAGE) {
|
||
$mas_usl_bd[] = "a.building_id in (select bd.id from buildings bd where bd.mortgage = 1)";
|
||
}
|
||
if ($payment == Apartment::PAYMENT_MILITARY) {
|
||
$mas_usl_bd[] = "a.building_id in (select bd.id from buildings bd where bd.military_mortgage = 1)";
|
||
}
|
||
if ($payment == Apartment::PAYMENT_SUBSIDY) {
|
||
$mas_usl_bd[] = "a.subsidy = 1";
|
||
}
|
||
$mas_url_add[] = "payment[]=" . $payment;
|
||
}
|
||
}
|
||
|
||
if($mas_usl_bd) {
|
||
$str_usl_bd = implode(" AND ",$mas_usl_bd);
|
||
}
|
||
|
||
$kol_on_page = 20;
|
||
|
||
|
||
if (empty($temp_region)) {
|
||
$sql_count = "SELECT COUNT(b.id)
|
||
FROM blocks b
|
||
INNER JOIN regions r ON b.region_id = r.id
|
||
LEFT JOIN regions parent_region ON parent_region.id = r.parent_id
|
||
INNER JOIN rf_regions rr ON r.rf_region_id = rr.id
|
||
INNER JOIN builders bld ON b.builder_id = bld.id
|
||
INNER JOIN apartments a ON a.block_id = b.id
|
||
WHERE b.id = a.block_id AND rr.id = $user->region_rf_id AND
|
||
$str_usl_bd
|
||
GROUP BY b.id";
|
||
} else {
|
||
$sql_count = "SELECT COUNT(b.id)
|
||
FROM blocks b
|
||
INNER JOIN regions r ON b.region_id = r.id
|
||
LEFT JOIN regions parent_region ON parent_region.id = r.parent_id
|
||
INNER JOIN rf_regions rr ON r.rf_region_id = rr.id
|
||
INNER JOIN builders bld ON b.builder_id = bld.id
|
||
INNER JOIN apartments a ON a.block_id = b.id
|
||
WHERE b.id = a.block_id AND rr.id = $temp_region AND
|
||
$str_usl_bd
|
||
GROUP BY b.id";
|
||
}
|
||
// INNER JOIN apartments a ON b.id = a.block_id
|
||
$vsego = mysql_num_rows(mysql_query($sql_count));
|
||
|
||
$all_pages = ceil($vsego/$kol_on_page);
|
||
|
||
if(isset($_GET['page'])) {
|
||
$page = $_GET['page'];
|
||
} else {
|
||
$page = 1;
|
||
}
|
||
|
||
$ot = ($page-1)*$kol_on_page;
|
||
|
||
$additionalForCount = " 1 ";
|
||
|
||
if (isset($get['type']) && $get['type']) {
|
||
$additionalForCount .= " AND ap.room_type_id in (" . implode(",",$get['type']) . ") ";
|
||
}
|
||
if (isset($get['period']) && $get['period'] && $get['period'] > 0) {
|
||
$additionalForCount .= " AND ap.building_id in (select bds.id from buildings bds where UNIX_TIMESTAMP(bds.deadline) <=" . $get['period'] . ") ";
|
||
}
|
||
if (isset($get['decoration']) && $get['decoration']) {
|
||
$additionalForCount .= " AND ap.decoration_id in (" . implode(",",$get['decoration']) . ") ";
|
||
}
|
||
|
||
if (isset($get['stoim_ot']) && $get['stoim_ot']) {
|
||
$stoim_ot = intval(str_replace(' ', '', $get['stoim_ot']));
|
||
$additionalForCount .= " AND ap.price >= " . $stoim_ot . " ";
|
||
}
|
||
|
||
if (isset($get['stoim_do']) && $get['stoim_do']) {
|
||
$stoim_do = intval(str_replace(' ', '', $get['stoim_do']));
|
||
$additionalForCount .= " AND ap.price <= " . $stoim_do . " ";
|
||
}
|
||
|
||
if (isset($get['sq_all_ot']) && $get['sq_all_ot']) {
|
||
$additionalForCount .= " AND ap.space_total >= " . $get['sq_all_ot'] . " ";
|
||
}
|
||
|
||
if (isset($get['sq_all_do']) && $get['sq_all_do']) {
|
||
$additionalForCount .= " AND ap.space_total <= " . $get['sq_all_do'] . " ";
|
||
}
|
||
|
||
if (isset($get['flat_floor_ot']) && $get['flat_floor_ot']) {
|
||
$additionalForCount .= " AND ap.flat_floor >= " . $get['flat_floor_ot'] . " ";
|
||
}
|
||
|
||
if (isset($get['flat_floor_do']) && $get['flat_floor_do']) {
|
||
$additionalForCount .= " AND ap.flat_floor <= " . $get['flat_floor_do'] . " ";
|
||
}
|
||
|
||
if (empty($temp_region)) {
|
||
$sql = "SELECT
|
||
b.*,
|
||
bld.name as builder_name,
|
||
bld.logo as builder_logo,
|
||
r.name as region_name,
|
||
parent_region.name as parent_region_name,
|
||
(select count(ap.id) from apartments ap where ap.block_id = b.id AND $additionalForCount) as apartments_count
|
||
FROM blocks b
|
||
INNER JOIN regions r ON b.region_id = r.id
|
||
LEFT JOIN regions parent_region ON parent_region.id = r.parent_id
|
||
INNER JOIN rf_regions rr ON r.rf_region_id = rr.id
|
||
INNER JOIN builders bld ON b.builder_id = bld.id
|
||
INNER JOIN apartments a ON a.block_id = b.id
|
||
WHERE b.id = a.block_id AND
|
||
rr.id = $user->region_rf_id
|
||
AND
|
||
$str_usl_bd
|
||
GROUP BY
|
||
b.id
|
||
$order
|
||
LIMIT $ot, $kol_on_page";
|
||
}
|
||
else {
|
||
$sql = "SELECT
|
||
b.*,
|
||
bld.name as builder_name,
|
||
bld.logo as builder_logo,
|
||
r.name as region_name,
|
||
parent_region.name as parent_region_name,
|
||
(select count(ap.id) from apartments ap where ap.block_id = b.id AND $additionalForCount) as apartments_count
|
||
FROM blocks b
|
||
INNER JOIN regions r ON b.region_id = r.id
|
||
LEFT JOIN regions parent_region ON parent_region.id = r.parent_id
|
||
INNER JOIN rf_regions rr ON r.rf_region_id = rr.id
|
||
INNER JOIN builders bld ON b.builder_id = bld.id
|
||
INNER JOIN apartments a ON a.block_id = b.id
|
||
WHERE b.id = a.block_id AND
|
||
rr.id = $temp_region
|
||
AND
|
||
$str_usl_bd
|
||
GROUP BY
|
||
b.id
|
||
$order
|
||
LIMIT $ot, $kol_on_page";
|
||
}
|
||
// $sql="SELECT
|
||
// b.*,
|
||
// bld.name as builder_name,
|
||
// bld.logo as builder_logo,
|
||
// r.name as region_name,
|
||
// (select count(ap.id) from apartments ap where ap.block_id = b.id AND $additionalForCount) as apartments_count
|
||
// FROM blocks b
|
||
// INNER JOIN regions r ON b.region_id = r.id
|
||
// INNER JOIN rf_regions rr ON r.rf_region_id = rr.id
|
||
// INNER JOIN builders bld ON b.builder_id = bld.id
|
||
// INNER JOIN apartments a ON a.block_id = b.id
|
||
// WHERE
|
||
// b.id = a.block_id
|
||
// AND rr.id = $user->region_rf_id
|
||
// AND
|
||
// $str_usl_bd
|
||
// GROUP BY
|
||
// b.id
|
||
// $order
|
||
// LIMIT $ot, $kol_on_page";
|
||
|
||
// INNER JOIN apartments a ON b.id = a.block_id
|
||
if(isset($_GET['dev'])) {
|
||
echo $sql;
|
||
}
|
||
|
||
$rez=mysql_query($sql,$mdb);
|
||
|
||
if(mysql_num_rows($rez)) {
|
||
echo '<div class="f-system_pagination" style="padding-top: 20px;"><ul class="pagination">';
|
||
|
||
$str_url_add = "";
|
||
|
||
if ($mas_url_add) {
|
||
$str_url_add = implode("&", $mas_url_add);
|
||
}
|
||
|
||
$_SESSION['lastNewbuildingsSearchUrl'] = $str_url_add;
|
||
|
||
if ($all_pages > 1) {
|
||
num_of_pages($page, $all_pages, $str_url_add);
|
||
}
|
||
|
||
echo '</ul><div class="clear"></div></div>';
|
||
|
||
while($obj=mysql_fetch_assoc($rez)) {
|
||
include($_SERVER['DOCUMENT_ROOT']."/templates/newbuildings_object.php");
|
||
}
|
||
|
||
|
||
echo '<div class="f-system_pagination"><ul class="pagination">';
|
||
|
||
if($all_pages > 1) {
|
||
num_of_pages($page, $all_pages, $str_url_add);
|
||
}
|
||
|
||
echo '</ul><div class="clear"></div></div>';
|
||
|
||
// echo "<p style=\"font-size: 9px;float: right;padding-right: 10px;\">На портале используется дополненная и переработанная информация из системы ABC недвижимость</p>";
|
||
|
||
} else {
|
||
?>
|
||
<div class="empty-block">
|
||
|
||
<h1><i class="ti-na"></i></h1>
|
||
|
||
<h2>К сожалению, ничего не найдено</h2>
|
||
|
||
</div>
|
||
<?php
|
||
}
|
||
} else {
|
||
require($_SERVER['DOCUMENT_ROOT']."/templates/footer_banner.php");
|
||
}
|
||
?>
|
||
|
||
</div>
|
||
|
||
<script type="text/javascript">
|
||
$('.datepicker-here2').datepicker({
|
||
autoClose: 'true'
|
||
});
|
||
|
||
|
||
</script>
|
||
|
||
<script>
|
||
$(document).ready(function() {
|
||
$('#region_newbuilding_select_search').change(function() {
|
||
var selectedValue = $(this).val();
|
||
|
||
$.ajax({
|
||
url: '/ajax/change_temp_region.php',
|
||
method: 'POST',
|
||
data: { temp_region: selectedValue, new_building: true },
|
||
success: function(response) {
|
||
if (response !== 'Error updating session') {
|
||
getNewBuildingsDistrictByRegion(response);
|
||
getMetroByRegion(response);
|
||
getBuilderByRegion(response);
|
||
}
|
||
},
|
||
error: function(xhr, status, error) {
|
||
console.log('AJAX Error:', error);
|
||
console.log('Status:', status);
|
||
console.log('Response:', xhr.responseText);
|
||
}
|
||
});
|
||
});
|
||
});
|
||
|
||
function getNewBuildingsDistrictByRegion(temp_region) {
|
||
//console.log('Подгрузка данных района...');
|
||
$.ajax({
|
||
url: '/ajax/getNewBuildingsDistrictByRegion.php',
|
||
method: 'POST',
|
||
data: { temp_region: temp_region },
|
||
success: function(response) {
|
||
$("#select-district").html(response);
|
||
$("#select-district").val([]);
|
||
$("#select-district").multiselect("reload");
|
||
},
|
||
error: function(xhr, status, error) {
|
||
console.log('AJAX Error:', error);
|
||
console.log('Status:', status);
|
||
console.log('Response:', xhr.responseText);
|
||
}
|
||
});
|
||
}
|
||
|
||
function getMetroByRegion(temp_region) {
|
||
$.ajax({
|
||
url: '/ajax/getMetroByRegion.php',
|
||
method: 'POST',
|
||
data: { temp_region: temp_region },
|
||
success: function(response) {
|
||
if (response == '') {
|
||
$("#subway-select-list").hide();
|
||
} else {
|
||
$("#subway-select-list").show();
|
||
}
|
||
$("#select-subway").html(response);
|
||
$("#select-subway").val([]);
|
||
$("#select-subway").multiselect("reload");
|
||
},
|
||
error: function(xhr, status, error) {
|
||
console.log('AJAX Error:', error);
|
||
console.log('Status:', status);
|
||
console.log('Response:', xhr.responseText);
|
||
}
|
||
});
|
||
}
|
||
|
||
function getBuilderByRegion(temp_region) {
|
||
//console.log('Подгрузка данных застройщика...');
|
||
$.ajax({
|
||
url: '/ajax/getBuilderByRegion.php',
|
||
method: 'POST',
|
||
data: { temp_region: temp_region },
|
||
success: function(response) {
|
||
//console.log(response);
|
||
//console.log('Список застройщиков: ' + response);
|
||
$("#select-builder").html(response);
|
||
$("#select-builder").val([]);
|
||
$("#select-builder").multiselect("reload");
|
||
},
|
||
error: function(xhr, status, error) {
|
||
console.log('AJAX Error:', error);
|
||
console.log('Status:', status);
|
||
console.log('Response:', xhr.responseText);
|
||
}
|
||
});
|
||
}
|
||
</script>
|