1265 lines
49 KiB
PHP
1265 lines
49 KiB
PHP
|
|
<?php
|
|||
|
|
|
|||
|
|
require_once($_SERVER['DOCUMENT_ROOT']."/ajax/vue_php_function.php");
|
|||
|
|
|
|||
|
|
if (!isset($_SESSION['id'])) exit();
|
|||
|
|
|
|||
|
|
//error_reporting(E_ALL | E_STRICT);
|
|||
|
|
//ini_set('display_errors', 1);
|
|||
|
|
|
|||
|
|
$data = json_decode(file_get_contents("php://input"));
|
|||
|
|
$pdo = new MysqlPdo(hst, ndb, user, pass);
|
|||
|
|
$sql = "SET NAMES 'utf8'";
|
|||
|
|
$pdo->query($sql);
|
|||
|
|
$request = $data->request;
|
|||
|
|
|
|||
|
|
//Типы объектов
|
|||
|
|
if ($request == 'get_object_types') {
|
|||
|
|
$type_id = json_decode($data->object_type_id);
|
|||
|
|
$list = AutoSearch::getCommonFields('object_type', intval($type_id));
|
|||
|
|
echo json_encode($list);
|
|||
|
|
exit();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//Кол-во комнат
|
|||
|
|
if ($request == 'get_rooms_counts') {
|
|||
|
|
$list = AutoSearch::getCommonFields('rooms_counts');
|
|||
|
|
echo json_encode($list);
|
|||
|
|
exit();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//Источники добавления объектов
|
|||
|
|
if ($request == 'get_object_sources') {
|
|||
|
|
$source_id = json_decode($data->object_source_id);
|
|||
|
|
$list = AutoSearch::getCommonFields('object_source', intval($source_id));
|
|||
|
|
echo json_encode($list);
|
|||
|
|
exit();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//Типы категорий помещений
|
|||
|
|
if ($request == 'get_category_types') {
|
|||
|
|
$list = AutoSearch::getCommonFields('category_type', $data->category_type_ids);
|
|||
|
|
echo json_encode($list);
|
|||
|
|
exit();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// Срок аренды объектов
|
|||
|
|
if ($request == 'get_rent_srok') {
|
|||
|
|
$srok_id = json_decode($data->rent_srok_id);
|
|||
|
|
$list = AutoSearch::getCommonFields('rent_srok', intval($srok_id));
|
|||
|
|
echo json_encode($list);
|
|||
|
|
exit();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// Регионы РФ
|
|||
|
|
if ($request == 'get_regions') {
|
|||
|
|
$user_id = json_decode($data->user_id);
|
|||
|
|
$regions = json_decode($data->regions);
|
|||
|
|
$html = '';
|
|||
|
|
$list = AutoSearch::getCommonFields('regions', $regions);
|
|||
|
|
|
|||
|
|
|
|||
|
|
if (empty($regions)) { // Устанавливаем регионы пользователя по-умолчанию
|
|||
|
|
$user = new User;
|
|||
|
|
$user->get($_SESSION['id']);
|
|||
|
|
|
|||
|
|
$regions = [];
|
|||
|
|
if ($user->region_rf_id == 1) {
|
|||
|
|
$regions = [53, 80];
|
|||
|
|
} else if ($user->region_rf_id == 2) {
|
|||
|
|
$regions = [50, 81];
|
|||
|
|
} else if ($user->region_rf_id == 3) {
|
|||
|
|
$regions = [94, 95];
|
|||
|
|
} else {
|
|||
|
|
|
|||
|
|
$sql = "SELECT rf_regions.* FROM rf_regions AS parent
|
|||
|
|
JOIN rf_regions ON rf_regions.parent = parent.id
|
|||
|
|
WHERE parent.id = {$user->region_rf_id} ORDER BY id ASC";
|
|||
|
|
|
|||
|
|
if ($rez = mysql_query($sql)) {
|
|||
|
|
while($row = mysql_fetch_assoc($rez)) {
|
|||
|
|
$regions[] = $row['id'];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
foreach ($list as $key => $region) {
|
|||
|
|
$html .= '<option value="'.$region['value'].'" '. ((in_array($region['value'], $regions)) ? 'selected' : '') .'>'.$region['label'].'</option>';
|
|||
|
|
}
|
|||
|
|
echo json_encode(['list' => $list, 'regions' => $regions, 'html' => ('<select id="asfiltr-object-regions" multiple>' . $html . '</select>')]);
|
|||
|
|
exit();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// Районы субъекта
|
|||
|
|
if ($request == 'get_rayons') {
|
|||
|
|
$user_id = json_decode($data->user_id);
|
|||
|
|
$regions = json_decode($data->regions);
|
|||
|
|
$rayons = json_decode($data->rayons);
|
|||
|
|
|
|||
|
|
if (is_null($regions)) {
|
|||
|
|
echo "[]";
|
|||
|
|
exit();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (in_array(80, $regions)) {
|
|||
|
|
$sql = "SELECT * FROM rf_regions WHERE parent = '80'";
|
|||
|
|
$rez = mysql_query($sql);
|
|||
|
|
while($sub_regions = mysql_fetch_assoc($rez)) {
|
|||
|
|
$regions[] = $sub_regions['id'];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$html = '';
|
|||
|
|
if (is_array($regions))
|
|||
|
|
$cond = "WHERE id IN (SELECT rayon_id FROM rf_region_rayons WHERE rf_region_id IN (".implode(',', $regions)."))";
|
|||
|
|
else
|
|||
|
|
$cond = "WHERE id IN (SELECT rayon_id FROM rf_region_rayons WHERE rf_region_id = $regions)";
|
|||
|
|
|
|||
|
|
$list = AutoSearch::getCommonFields('rayons', $regions, $cond);
|
|||
|
|
foreach ($list as $key => $rayon) {
|
|||
|
|
$html .= '<option value="'.$rayon['value'].'" '. ((in_array($rayon['value'], $rayons)) ? 'selected' : '') .'>'.$rayon['label'].'</option>';
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//ищем отдельные города
|
|||
|
|
if (is_array($regions)) {
|
|||
|
|
$sqlSep = "SELECT * FROM separate_city where region_id IN (".implode(',', $regions).")";
|
|||
|
|
$rezSep = mysql_query($sqlSep);
|
|||
|
|
} else {
|
|||
|
|
$sqlSep = "SELECT * FROM separate_city where region_id = " . $regions;
|
|||
|
|
$rezSep = mysql_query($sqlSep);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
while ($city = mysql_fetch_assoc($rezSep)) {
|
|||
|
|
//$html .= "<optgroup label='" . $city['name'] . "'>";
|
|||
|
|
$sqlCityRayon = "SELECT * FROM separate_city_rayons where sep_city_id = " . $city['id'];
|
|||
|
|
$rezCityRayon = mysql_query($sqlCityRayon);
|
|||
|
|
while ($cityRayon = mysql_fetch_assoc($rezCityRayon)) {
|
|||
|
|
$sqlRayon = "SELECT * FROM rayon where id = " . $cityRayon['rayon_id'];
|
|||
|
|
$rezRayon = mysql_query($sqlRayon);
|
|||
|
|
while ($rayon = mysql_fetch_assoc($rezRayon)) {
|
|||
|
|
if (in_array($rayon['id'], $rayons)) {
|
|||
|
|
$sl = "selected";
|
|||
|
|
} else {
|
|||
|
|
$sl = "";
|
|||
|
|
}
|
|||
|
|
$html .= "<option value='$rayon[id]' $sl>$rayon[rayon]</option>";
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
//$html .= "</optgroup>";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
echo json_encode(['list' => $list, 'html' => ('<select id="asfiltr-object-rayons" multiple>' . $html . '</select>')]);
|
|||
|
|
exit();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// Станции метро
|
|||
|
|
if ($request == 'get_metro') {
|
|||
|
|
$user_id = json_decode($data->user_id);
|
|||
|
|
$regions = json_decode($data->regions);
|
|||
|
|
$metro_stations = json_decode($data->metro_stations);
|
|||
|
|
|
|||
|
|
if (is_null($regions)) {
|
|||
|
|
echo "[]";
|
|||
|
|
exit();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$html = '';
|
|||
|
|
if (is_array($regions)) {
|
|||
|
|
foreach($regions as $key => $region) {
|
|||
|
|
if ($region == 1500) // Нижний Новгород
|
|||
|
|
$regions[$key] = 1148;
|
|||
|
|
else if ($region == 1504) // Новосибирск
|
|||
|
|
$regions[$key] = 1152;
|
|||
|
|
else if ($region == 1520) // Самара
|
|||
|
|
$regions[$key] = 1168;
|
|||
|
|
else if ($region == 1526) // Екатеринбург
|
|||
|
|
$regions[$key] = 1174;
|
|||
|
|
else if ($region == 1432) // Казань
|
|||
|
|
$regions[$key] = 1080;
|
|||
|
|
else if ($region == 53 || $region == 1) // Москва и Московская область
|
|||
|
|
$regions[$key] = 80;
|
|||
|
|
else if ($region == 50 || $region == 2) // Санкт-Петербург и Ленинградская обл
|
|||
|
|
$regions[$key] = 81;
|
|||
|
|
}
|
|||
|
|
$cond = "WHERE region_rf_id IN (" . implode(',', $regions) . ")";
|
|||
|
|
} else {
|
|||
|
|
$cond = "WHERE region_rf_id = " . $regions;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$list = AutoSearch::getCommonFields('metro_stations', $metro_stations, $cond);
|
|||
|
|
foreach ($list as $key => $station) {
|
|||
|
|
$html .= '<option value="'.$station['value'].'" '. ((in_array($station['value'], $metro_stations)) ? 'selected' : '') .'>'.$station['label'].'</option>';
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
echo json_encode(['list' => $list, 'count' => count($list), 'html' => ('<select id="asfiltr-metro-stations" multiple>' . $html . '</select>')]);
|
|||
|
|
exit();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// Типы оформления сделки
|
|||
|
|
/*if ($request == 'get_deal_type') {
|
|||
|
|
$user_id = json_decode($data->user_id);
|
|||
|
|
$order_type = intval(json_decode($data->order_type));
|
|||
|
|
|
|||
|
|
$html = '';
|
|||
|
|
$list = AutoSearch::getCommonFields('order_type', $order_type);
|
|||
|
|
foreach ($list as $key => $deal) {
|
|||
|
|
$html .= '<option value="'.$deal['value'].'" '. ((intval($deal['value']) == $order_type) ? 'selected' : '') .'>'.$deal['label'].'</option>';
|
|||
|
|
}
|
|||
|
|
echo json_encode(['list' => $list, 'html' => ('<select id="asfiltr-order-types">' . $html . '</select>')]);
|
|||
|
|
exit();
|
|||
|
|
}*/
|
|||
|
|
|
|||
|
|
// Типы домов
|
|||
|
|
if ($request == 'get_house_type') {
|
|||
|
|
$user_id = json_decode($data->user_id);
|
|||
|
|
$house_type = intval(json_decode($data->house_type));
|
|||
|
|
|
|||
|
|
$html = '<option value="0" '. (($house_type == 0) ? 'selected' : '') .'>Не выбрано</option>';
|
|||
|
|
$list = AutoSearch::getCommonFields('house_type', $house_type);
|
|||
|
|
foreach ($list as $houseType) {
|
|||
|
|
$html .= '<option value="'. $houseType['value'] .'" ' . (($houseType['value'] == $house_type) ? 'selected' : '') . '>'. $houseType['label'] .'</option>';
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
echo json_encode(['list' => $list, 'html' => ('<select id="asfiltr-house-types">' . $html . '</select>')]);
|
|||
|
|
exit();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// Типы материала стен
|
|||
|
|
if ($request == 'get_house_material') {
|
|||
|
|
$user_id = json_decode($data->user_id);
|
|||
|
|
$house_material = intval(json_decode($data->house_material));
|
|||
|
|
|
|||
|
|
$html = '<option value="0" '. (($house_material == 0) ? 'selected' : '') .'>Не выбрано</option>';
|
|||
|
|
$list = AutoSearch::getCommonFields('house_material', $house_material);
|
|||
|
|
foreach ($list as $houseMaterial) {
|
|||
|
|
$html .= '<option value="'. $houseMaterial['value'] .'" ' . (($houseMaterial['value'] == $house_material) ? 'selected' : '') . '>'. $houseMaterial['label'] .'</option>';
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
echo json_encode(['list' => $list, 'html' => ('<select id="asfiltr-house-materials">' . $html . '</select>')]);
|
|||
|
|
exit();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// Годы постройки
|
|||
|
|
if ($request == 'get_build_year') {
|
|||
|
|
$user_id = json_decode($data->user_id);
|
|||
|
|
$build_year = json_decode($data->build_year);
|
|||
|
|
|
|||
|
|
$html = '<option value="0" '. (($build_year == 0) ? 'selected' : '') .'>Не выбрано</option>';
|
|||
|
|
$list = AutoSearch::getCommonFields('build_year', $build_year);
|
|||
|
|
foreach ($list as $buildYear) {
|
|||
|
|
$html .= '<option value="'. $buildYear['value'] .'" ' . (($buildYear['value'] == $build_year) ? 'selected' : '') . '>'. $buildYear['label'] .'</option>';
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
echo json_encode(['list' => $list, 'html' => ('<select id="asfiltr-build-year">' . $html . '</select>')]);
|
|||
|
|
exit();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//
|
|||
|
|
if ($request == 'get_legal_address') {
|
|||
|
|
$user_id = json_decode($data->user_id);
|
|||
|
|
$legal_address = json_decode($data->legal_address);
|
|||
|
|
|
|||
|
|
$html = '<option value="0" '. (($legal_address == 0) ? 'selected' : '') .'>Не выбрано</option>';
|
|||
|
|
$list = AutoSearch::getCommonFields('legal_address', $legal_address);
|
|||
|
|
foreach ($list as $item) {
|
|||
|
|
$html .= '<option value="'. $item['value'] .'" ' . (($item['value'] == $legal_address) ? 'selected' : '') . '>'. $item['label'] .'</option>';
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
echo json_encode(['list' => $list, 'html' => ('<select id="asfiltr-legal-address">' . $html . '</select>')]);
|
|||
|
|
exit();
|
|||
|
|
}
|
|||
|
|
if ($request == 'get_is_occupied') {
|
|||
|
|
$user_id = json_decode($data->user_id);
|
|||
|
|
$is_occupied= json_decode($data->is_occupied);
|
|||
|
|
|
|||
|
|
$html = '<option value="0" '. (($is_occupied == 0) ? 'selected' : '') .'>Не выбрано</option>';
|
|||
|
|
$list = AutoSearch::getCommonFields('is_occupied', $is_occupied);
|
|||
|
|
foreach ($list as $item) {
|
|||
|
|
$html .= '<option value="'. $item['value'] .'" ' . (($item['value'] == $is_occupied) ? 'selected' : '') . '>'. $item['label'] .'</option>';
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
echo json_encode(['list' => $list, 'html' => ('<select id="asfiltr-is-occupied">' . $html . '</select>')]);
|
|||
|
|
exit();
|
|||
|
|
}
|
|||
|
|
if ($request == 'get_layout_id') {
|
|||
|
|
$user_id = json_decode($data->user_id);
|
|||
|
|
$layout_id = json_decode($data->layout_id);
|
|||
|
|
|
|||
|
|
$html = '<option value="0" '. (($layout_id == 0) ? 'selected' : '') .'>Не выбрано</option>';
|
|||
|
|
$list = AutoSearch::getCommonFields('layout_id', $layout_id);
|
|||
|
|
foreach ($list as $item) {
|
|||
|
|
$html .= '<option value="'. $item['value'] .'" ' . (($item['value'] == $layout_id) ? 'selected' : '') . '>'. $item['label'] .'</option>';
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
echo json_encode(['list' => $list, 'html' => ('<select id="asfiltr-layout-id">' . $html . '</select>')]);
|
|||
|
|
exit();
|
|||
|
|
}
|
|||
|
|
if ($request == 'get_wet_spots') {
|
|||
|
|
$user_id = json_decode($data->user_id);
|
|||
|
|
$wet_spots = json_decode($data->wet_spots);
|
|||
|
|
|
|||
|
|
$html = '<option value="0" '. (($wet_spots == 0) ? 'selected' : '') .'>Не выбрано</option>';
|
|||
|
|
$list = AutoSearch::getCommonFields('wet_spots', $wet_spots);
|
|||
|
|
foreach ($list as $item) {
|
|||
|
|
$html .= '<option value="'. $item['value'] .'" ' . (($item['value'] == $wet_spots) ? 'selected' : '') . '>'. $item['label'] .'</option>';
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
echo json_encode(['list' => $list, 'html' => ('<select id="asfiltr-wet-spots">' . $html . '</select>')]);
|
|||
|
|
exit();
|
|||
|
|
}
|
|||
|
|
if ($request == 'get_commer_condition') {
|
|||
|
|
$user_id = json_decode($data->user_id);
|
|||
|
|
$commer_condition = json_decode($data->commer_condition);
|
|||
|
|
|
|||
|
|
$html = '<option value="0" '. (($commer_condition == 0) ? 'selected' : '') .'>Не выбрано</option>';
|
|||
|
|
$list = AutoSearch::getCommonFields('commer_condition', $commer_condition);
|
|||
|
|
foreach ($list as $item) {
|
|||
|
|
$html .= '<option value="'. $item['value'] .'" ' . (($item['value'] == $commer_condition) ? 'selected' : '') . '>'. $item['label'] .'</option>';
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
echo json_encode(['list' => $list, 'html' => ('<select id="asfiltr-commer-condition">' . $html . '</select>')]);
|
|||
|
|
exit();
|
|||
|
|
}
|
|||
|
|
if ($request == 'get_is_furniture') {
|
|||
|
|
$user_id = json_decode($data->user_id);
|
|||
|
|
$is_furniture = json_decode($data->is_furniture);
|
|||
|
|
|
|||
|
|
$html = '<option value="0" '. (($is_furniture == 0) ? 'selected' : '') .'>Не выбрано</option>';
|
|||
|
|
$list = AutoSearch::getCommonFields('is_furniture', $is_furniture);
|
|||
|
|
foreach ($list as $item) {
|
|||
|
|
$html .= '<option value="'. $item['value'] .'" ' . (($item['value'] == $is_furniture) ? 'selected' : '') . '>'. $item['label'] .'</option>';
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
echo json_encode(['list' => $list, 'html' => ('<select id="asfiltr-is-furniture">' . $html . '</select>')]);
|
|||
|
|
exit();
|
|||
|
|
}
|
|||
|
|
if ($request == 'get_commer_access') {
|
|||
|
|
$user_id = json_decode($data->user_id);
|
|||
|
|
$commer_access = json_decode($data->commer_access);
|
|||
|
|
|
|||
|
|
$html = '<option value="0" '. (($commer_access == 0) ? 'selected' : '') .'>Не выбрано</option>';
|
|||
|
|
$list = AutoSearch::getCommonFields('commer_access', $commer_access);
|
|||
|
|
foreach ($list as $item) {
|
|||
|
|
$html .= '<option value="'. $item['value'] .'" ' . (($item['value'] == $commer_access) ? 'selected' : '') . '>'. $item['label'] .'</option>';
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
echo json_encode(['list' => $list, 'html' => ('<select id="asfiltr-commer-access">' . $html . '</select>')]);
|
|||
|
|
exit();
|
|||
|
|
}
|
|||
|
|
if ($request == 'get_parking_types') {
|
|||
|
|
$user_id = json_decode($data->user_id);
|
|||
|
|
$parking_types = json_decode($data->parking_types);
|
|||
|
|
|
|||
|
|
$html = '<option value="0" '. (($parking_types == 0) ? 'selected' : '') .'>Не выбрано</option>';
|
|||
|
|
$list = AutoSearch::getCommonFields('parking_types', $parking_types, "WHERE vid = 0");
|
|||
|
|
foreach ($list as $item) {
|
|||
|
|
$html .= '<option value="'. $item['value'] .'" ' . (($item['value'] == $parking_types) ? 'selected' : '') . '>'. $item['label'] .'</option>';
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
echo json_encode(['list' => $list, 'html' => ('<select id="asfiltr-parking-types">' . $html . '</select>')]);
|
|||
|
|
exit();
|
|||
|
|
}
|
|||
|
|
if ($request == 'get_parking_id') {
|
|||
|
|
$user_id = json_decode($data->user_id);
|
|||
|
|
$parking_id = json_decode($data->parking_id);
|
|||
|
|
|
|||
|
|
$html = '<option value="0" '. (($parking_id == 0) ? 'selected' : '') .'>Не выбрано</option>';
|
|||
|
|
$list = AutoSearch::getCommonFields('parking_id', $parking_id, "WHERE vid = 1");
|
|||
|
|
foreach ($list as $item) {
|
|||
|
|
$html .= '<option value="'. $item['value'] .'" ' . (($item['value'] == $parking_id) ? 'selected' : '') . '>'. $item['label'] .'</option>';
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
echo json_encode(['list' => $list, 'html' => ('<select id="asfiltr-parking-id">' . $html . '</select>')]);
|
|||
|
|
exit();
|
|||
|
|
}
|
|||
|
|
if ($request == 'get_vat_type_id') {
|
|||
|
|
$user_id = json_decode($data->user_id);
|
|||
|
|
$vat_type_id = json_decode($data->vat_type_id);
|
|||
|
|
|
|||
|
|
$html = '<option value="0" '. (($vat_type_id == 0) ? 'selected' : '') .'>Не выбрано</option>';
|
|||
|
|
$list = AutoSearch::getCommonFields('vat_type_id', $vat_type_id);
|
|||
|
|
foreach ($list as $item) {
|
|||
|
|
$html .= '<option value="'. $item['value'] .'" ' . (($item['value'] == $vat_type_id) ? 'selected' : '') . '>'. $item['label'] .'</option>';
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
echo json_encode(['list' => $list, 'html' => ('<select id="asfiltr-vat-type-id">' . $html . '</select>')]);
|
|||
|
|
exit();
|
|||
|
|
}
|
|||
|
|
if ($request == 'get_floor_material_id') {
|
|||
|
|
$user_id = json_decode($data->user_id);
|
|||
|
|
$floor_material_id = json_decode($data->floor_material_id);
|
|||
|
|
|
|||
|
|
$list = AutoSearch::getCommonFields('floor_material_id', $floor_material_id);
|
|||
|
|
foreach ($list as $item) {
|
|||
|
|
$html .= '<option value="'. $item['value'] .'" ' . (($item['value'] == $floor_material_id) ? 'selected' : '') . '>'. $item['label'] .'</option>';
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
echo json_encode(['list' => $list, 'html' => ('<select id="asfiltr-floor-material" multiple>' . $html . '</select>')]);
|
|||
|
|
exit();
|
|||
|
|
}
|
|||
|
|
if ($request == 'get_commerc_portal_id') {
|
|||
|
|
$user_id = json_decode($data->user_id);
|
|||
|
|
$commerc_portal_id = json_decode($data->commerc_portal_id);
|
|||
|
|
|
|||
|
|
$list = AutoSearch::getCommonFields('commerc_portal_id', $commerc_portal_id);
|
|||
|
|
foreach ($list as $item) {
|
|||
|
|
$html .= '<option value="'. $item['value'] .'" ' . (($item['value'] == $commerc_portal_id) ? 'selected' : '') . '>'. $item['label'] .'</option>';
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
echo json_encode(['list' => $list, 'html' => ('<select id="asfiltr-commerc-portal" multiple>' . $html . '</select>')]);
|
|||
|
|
exit();
|
|||
|
|
}
|
|||
|
|
if ($request == 'get_commerc_purpose') {
|
|||
|
|
$user_id = json_decode($data->user_id);
|
|||
|
|
$commerc_purpose = json_decode($data->commerc_purpose);
|
|||
|
|
|
|||
|
|
$list = AutoSearch::getCommonFields('commerc_purpose', $commerc_purpose);
|
|||
|
|
foreach ($list as $item) {
|
|||
|
|
$html .= '<option value="'. $item['value'] .'" ' . (($item['value'] == $commerc_purpose) ? 'selected' : '') . '>'. $item['label'] .'</option>';
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
echo json_encode(['list' => $list, 'html' => ('<select id="asfiltr-commerc-purpose" multiple>' . $html . '</select>')]);
|
|||
|
|
exit();
|
|||
|
|
}
|
|||
|
|
if ($request == 'get_commerc_land_category_id') {
|
|||
|
|
$user_id = json_decode($data->user_id);
|
|||
|
|
$commerc_land_category_id = json_decode($data->commerc_land_category_id);
|
|||
|
|
|
|||
|
|
$list = AutoSearch::getCommonFields('commerc_land_category_id', $commerc_land_category_id);
|
|||
|
|
foreach ($list as $item) {
|
|||
|
|
$html .= '<option value="'. $item['value'] .'" ' . (($item['value'] == $commerc_land_category_id) ? 'selected' : '') . '>'. $item['label'] .'</option>';
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
echo json_encode(['list' => $list, 'html' => ('<select id="asfiltr-commerc-land-category" multiple>' . $html . '</select>')]);
|
|||
|
|
exit();
|
|||
|
|
}
|
|||
|
|
if ($request == 'get_commerc_permitted_use_id') {
|
|||
|
|
$user_id = json_decode($data->user_id);
|
|||
|
|
$commerc_permitted_use_id = json_decode($data->commerc_permitted_use_id);
|
|||
|
|
|
|||
|
|
$list = AutoSearch::getCommonFields('commerc_permitted_use_id', $commerc_permitted_use_id);
|
|||
|
|
foreach ($list as $item) {
|
|||
|
|
$html .= '<option value="'. $item['value'] .'" ' . (($item['value'] == $commerc_permitted_use_id) ? 'selected' : '') . '>'. $item['label'] .'</option>';
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
echo json_encode(['list' => $list, 'html' => ('<select id="asfiltr-commerc-permitted-use" multiple>' . $html . '</select>')]);
|
|||
|
|
exit();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if ($request == 'get_commerc_electricity_id') {
|
|||
|
|
$user_id = json_decode($data->user_id);
|
|||
|
|
$commerc_electricity_id = json_decode($data->commerc_electricity_id);
|
|||
|
|
|
|||
|
|
$html = '<option value="0" '. (($commerc_electricity_id == 0) ? 'selected' : '') .'>Не выбрано</option>';
|
|||
|
|
$list = AutoSearch::getCommonFields('commerc_electricity_id', $commerc_electricity_id);
|
|||
|
|
foreach ($list as $item) {
|
|||
|
|
$html .= '<option value="'. $item['value'] .'" ' . (($item['value'] == $commerc_electricity_id) ? 'selected' : '') . '>'. $item['label'] .'</option>';
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
echo json_encode(['list' => $list, 'html' => ('<select id="asfiltr-commerc-electricity">' . $html . '</select>')]);
|
|||
|
|
exit();
|
|||
|
|
}
|
|||
|
|
if ($request == 'get_commerc_gas_id') {
|
|||
|
|
$user_id = json_decode($data->user_id);
|
|||
|
|
$commerc_gas_id = json_decode($data->commerc_gas_id);
|
|||
|
|
|
|||
|
|
$html = '<option value="0" '. (($commerc_gas_id == 0) ? 'selected' : '') .'>Не выбрано</option>';
|
|||
|
|
$list = AutoSearch::getCommonFields('commerc_gas_id', $commerc_gas_id);
|
|||
|
|
foreach ($list as $item) {
|
|||
|
|
$html .= '<option value="'. $item['value'] .'" ' . (($item['value'] == $commerc_gas_id) ? 'selected' : '') . '>'. $item['label'] .'</option>';
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
echo json_encode(['list' => $list, 'html' => ('<select id="asfiltr-commerc-gas">' . $html . '</select>')]);
|
|||
|
|
exit();
|
|||
|
|
}
|
|||
|
|
if ($request == 'get_commerc_water_id') {
|
|||
|
|
$user_id = json_decode($data->user_id);
|
|||
|
|
$commerc_water_id = json_decode($data->commerc_water_id);
|
|||
|
|
|
|||
|
|
$html = '<option value="0" '. (($commerc_water_id == 0) ? 'selected' : '') .'>Не выбрано</option>';
|
|||
|
|
$list = AutoSearch::getCommonFields('commerc_water_id', $commerc_water_id);
|
|||
|
|
foreach ($list as $item) {
|
|||
|
|
$html .= '<option value="'. $item['value'] .'" ' . (($item['value'] == $commerc_water_id) ? 'selected' : '') . '>'. $item['label'] .'</option>';
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
echo json_encode(['list' => $list, 'html' => ('<select id="asfiltr-commerc-water">' . $html . '</select>')]);
|
|||
|
|
exit();
|
|||
|
|
}
|
|||
|
|
if ($request == 'get_commerc_sewage_id') {
|
|||
|
|
$user_id = json_decode($data->user_id);
|
|||
|
|
$commerc_sewage_id = json_decode($data->commerc_sewage_id);
|
|||
|
|
|
|||
|
|
$html = '<option value="0" '. (($commerc_sewage_id == 0) ? 'selected' : '') .'>Не выбрано</option>';
|
|||
|
|
$list = AutoSearch::getCommonFields('commerc_sewage_id', $commerc_sewage_id);
|
|||
|
|
foreach ($list as $item) {
|
|||
|
|
$html .= '<option value="'. $item['value'] .'" ' . (($item['value'] == $commerc_sewage_id) ? 'selected' : '') . '>'. $item['label'] .'</option>';
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
echo json_encode(['list' => $list, 'html' => ('<select id="asfiltr-commerc-sewage">' . $html . '</select>')]);
|
|||
|
|
exit();
|
|||
|
|
}
|
|||
|
|
if ($request == 'get_commerc_driveways') {
|
|||
|
|
$user_id = json_decode($data->user_id);
|
|||
|
|
$commerc_driveways = json_decode($data->commerc_driveways);
|
|||
|
|
|
|||
|
|
$html = '<option value="0" '. (($commerc_driveways == 0) ? 'selected' : '') .'>Не выбрано</option>';
|
|||
|
|
$list = AutoSearch::getCommonFields('commerc_driveways', $commerc_driveways);
|
|||
|
|
foreach ($list as $item) {
|
|||
|
|
$html .= '<option value="'. $item['value'] .'" ' . (($item['value'] == $commerc_driveways) ? 'selected' : '') . '>'. $item['label'] .'</option>';
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
echo json_encode(['list' => $list, 'html' => ('<select id="asfiltr-commerc-driveways">' . $html . '</select>')]);
|
|||
|
|
exit();
|
|||
|
|
}
|
|||
|
|
if ($request == 'get_commerc_building_type_id') {
|
|||
|
|
$user_id = json_decode($data->user_id);
|
|||
|
|
$commerc_building_type_id = json_decode($data->commerc_building_type_id);
|
|||
|
|
|
|||
|
|
$list = AutoSearch::getCommonFields('commerc_building_type_id', $commerc_building_type_id);
|
|||
|
|
foreach ($list as $item) {
|
|||
|
|
$html .= '<option value="'. $item['value'] .'" ' . ((in_array($item['value'], $commerc_building_type_id)) ? 'selected' : '') . '>'. $item['label'] .'</option>';
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
echo json_encode(['list' => $list, 'html' => ('<select id="asfiltr-commerc-building-type" multiple>' . $html . '</select>')]);
|
|||
|
|
exit();
|
|||
|
|
}
|
|||
|
|
if ($request == 'get_commerc_building_class_id') {
|
|||
|
|
$user_id = json_decode($data->user_id);
|
|||
|
|
$commerc_building_class_id = json_decode($data->commerc_building_class_id);
|
|||
|
|
|
|||
|
|
$list = AutoSearch::getCommonFields('commerc_building_class_id', $commerc_building_class_id);
|
|||
|
|
foreach ($list as $item) {
|
|||
|
|
$html .= '<option value="'. $item['value'] .'" ' . ((in_array($item['value'], $commerc_building_class_id)) ? 'selected' : '') . '>'. $item['label'] .'</option>';
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
echo json_encode(['list' => $list, 'html' => ('<select id="asfiltr-commerc-building-class" multiple>' . $html . '</select>')]);
|
|||
|
|
exit();
|
|||
|
|
}
|
|||
|
|
if ($request == 'get_commerc_houseline_type_id') {
|
|||
|
|
$user_id = json_decode($data->user_id);
|
|||
|
|
$commerc_houseline_type_id = json_decode($data->commerc_houseline_type_id);
|
|||
|
|
|
|||
|
|
$html = '<option value="0" '. (($commerc_houseline_type_id == 0) ? 'selected' : '') .'>Не выбрано</option>';
|
|||
|
|
$list = AutoSearch::getCommonFields('commerc_houseline_type_id', $commerc_houseline_type_id);
|
|||
|
|
foreach ($list as $item) {
|
|||
|
|
$html .= '<option value="'. $item['value'] .'" ' . (($item['value'] == $commerc_houseline_type_id) ? 'selected' : '') . '>'. $item['label'] .'</option>';
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
echo json_encode(['list' => $list, 'html' => ('<select id="asfiltr-commerc-houseline-type-id">' . $html . '</select>')]);
|
|||
|
|
exit();
|
|||
|
|
}
|
|||
|
|
if ($request == 'get_commerc_building_category_id') {
|
|||
|
|
$user_id = json_decode($data->user_id);
|
|||
|
|
$commerc_building_category_id = json_decode($data->commerc_building_category_id);
|
|||
|
|
|
|||
|
|
$html = '<option value="0" '. (($commerc_building_category_id == 0) ? 'selected' : '') .'>Не выбрано</option>';
|
|||
|
|
$list = AutoSearch::getCommonFields('commerc_building_category_id', $commerc_building_category_id);
|
|||
|
|
foreach ($list as $item) {
|
|||
|
|
$html .= '<option value="'. $item['value'] .'" ' . (($item['value'] == $commerc_building_category_id) ? 'selected' : '') . '>'. $item['label'] .'</option>';
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
echo json_encode(['list' => $list, 'html' => ('<select id="asfiltr-commerc-building-category">' . $html . '</select>')]);
|
|||
|
|
exit();
|
|||
|
|
}
|
|||
|
|
if ($request == 'get_commerc_opened_id') {
|
|||
|
|
$user_id = json_decode($data->user_id);
|
|||
|
|
$commerc_opened_id = json_decode($data->commerc_opened_id);
|
|||
|
|
|
|||
|
|
$list = AutoSearch::getCommonFields('commerc_opened_id', $commerc_opened_id);
|
|||
|
|
foreach ($list as $item) {
|
|||
|
|
$html .= '<option value="'. $item['value'] .'" ' . (($item['value'] == $commerc_opened_id) ? 'selected' : '') . '>'. $item['label'] .'</option>';
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
echo json_encode(['list' => $list, 'html' => ('<select id="asfiltr-commerc-opened" multiple>' . $html . '</select>')]);
|
|||
|
|
exit();
|
|||
|
|
}
|
|||
|
|
if ($request == 'get_commerc_building_ventilation') {
|
|||
|
|
$user_id = json_decode($data->user_id);
|
|||
|
|
$commerc_building_ventilation = json_decode($data->commerc_building_ventilation);
|
|||
|
|
|
|||
|
|
$html = '<option value="0" '. (($commerc_building_ventilation == 0) ? 'selected' : '') .'>Не выбрано</option>';
|
|||
|
|
$list = AutoSearch::getCommonFields('commerc_building_ventilation', $commerc_building_ventilation);
|
|||
|
|
foreach ($list as $item) {
|
|||
|
|
$html .= '<option value="'. $item['value'] .'" ' . (($item['value'] == $commerc_building_ventilation) ? 'selected' : '') . '>'. $item['label'] .'</option>';
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
echo json_encode(['list' => $list, 'html' => ('<select id="asfiltr-commerc-building-ventilation">' . $html . '</select>')]);
|
|||
|
|
exit();
|
|||
|
|
}
|
|||
|
|
if ($request == 'get_commerc_building_conditioning') {
|
|||
|
|
$user_id = json_decode($data->user_id);
|
|||
|
|
$commerc_building_conditioning = json_decode($data->commerc_building_conditioning);
|
|||
|
|
|
|||
|
|
$html = '<option value="0" '. (($commerc_building_conditioning == 0) ? 'selected' : '') .'>Не выбрано</option>';
|
|||
|
|
$list = AutoSearch::getCommonFields('commerc_building_conditioning', $commerc_building_conditioning);
|
|||
|
|
foreach ($list as $item) {
|
|||
|
|
$html .= '<option value="'. $item['value'] .'" ' . (($item['value'] == $commerc_building_conditioning) ? 'selected' : '') . '>'. $item['label'] .'</option>';
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
echo json_encode(['list' => $list, 'html' => ('<select id="asfiltr-commerc-building-conditioning">' . $html . '</select>')]);
|
|||
|
|
exit();
|
|||
|
|
}
|
|||
|
|
if ($request == 'get_commerc_building_heating') {
|
|||
|
|
$user_id = json_decode($data->user_id);
|
|||
|
|
$commerc_building_heating = json_decode($data->commerc_building_heating);
|
|||
|
|
|
|||
|
|
$html = '<option value="0" '. (($commerc_building_heating == 0) ? 'selected' : '') .'>Не выбрано</option>';
|
|||
|
|
$list = AutoSearch::getCommonFields('commerc_building_heating', $commerc_building_heating);
|
|||
|
|
foreach ($list as $item) {
|
|||
|
|
$html .= '<option value="'. $item['value'] .'" ' . (($item['value'] == $commerc_building_heating) ? 'selected' : '') . '>'. $item['label'] .'</option>';
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
echo json_encode(['list' => $list, 'html' => ('<select id="asfiltr-commerc-building-heating">' . $html . '</select>')]);
|
|||
|
|
exit();
|
|||
|
|
}
|
|||
|
|
if ($request == 'get_commerc_building_fire') {
|
|||
|
|
$user_id = json_decode($data->user_id);
|
|||
|
|
$commerc_building_fire = json_decode($data->commerc_building_fire);
|
|||
|
|
|
|||
|
|
$html = '<option value="0" '. (($commerc_building_fire == 0) ? 'selected' : '') .'>Не выбрано</option>';
|
|||
|
|
$list = AutoSearch::getCommonFields('commerc_building_fire', $commerc_building_fire);
|
|||
|
|
foreach ($list as $item) {
|
|||
|
|
$html .= '<option value="'. $item['value'] .'" ' . (($item['value'] == $commerc_building_fire) ? 'selected' : '') . '>'. $item['label'] .'</option>';
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
echo json_encode(['list' => $list, 'html' => ('<select id="asfiltr-commerc-building-fire">' . $html . '</select>')]);
|
|||
|
|
exit();
|
|||
|
|
}
|
|||
|
|
if ($request == 'get_garage_type_id') {
|
|||
|
|
$user_id = json_decode($data->user_id);
|
|||
|
|
$garage_type_id = json_decode($data->garage_type_id);
|
|||
|
|
|
|||
|
|
$html = '<option value="0" '. (($garage_type_id == 0) ? 'selected' : '') .'>Не выбрано</option>';
|
|||
|
|
$list = AutoSearch::getCommonFields('garage_type_id', $garage_type_id);
|
|||
|
|
foreach ($list as $item) {
|
|||
|
|
$html .= '<option value="'. $item['value'] .'" ' . (($item['value'] == $garage_type_id) ? 'selected' : '') . '>'. $item['label'] .'</option>';
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
echo json_encode(['list' => $list, 'html' => ('<select id="asfiltr-garage-type-id">' . $html . '</select>')]);
|
|||
|
|
exit();
|
|||
|
|
}
|
|||
|
|
if ($request == 'get_garage_vid_id') {
|
|||
|
|
$user_id = json_decode($data->user_id);
|
|||
|
|
$garage_vid_id = json_decode($data->garage_vid_id);
|
|||
|
|
|
|||
|
|
$html = '<option value="0" '. (($garage_vid_id == 0) ? 'selected' : '') .'>Не выбрано</option>';
|
|||
|
|
$list = AutoSearch::getCommonFields('garage_vid_id', $garage_vid_id);
|
|||
|
|
foreach ($list as $item) {
|
|||
|
|
$html .= '<option value="'. $item['value'] .'" ' . (($item['value'] == $garage_vid_id) ? 'selected' : '') . '>'. $item['label'] .'</option>';
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
echo json_encode(['list' => $list, 'html' => ('<select id="asfiltr-garage-vid-id">' . $html . '</select>')]);
|
|||
|
|
exit();
|
|||
|
|
}
|
|||
|
|
if ($request == 'get_boks_vid_id') {
|
|||
|
|
$user_id = json_decode($data->user_id);
|
|||
|
|
$boks_vid_id = json_decode($data->boks_vid_id);
|
|||
|
|
|
|||
|
|
$html = '<option value="0" '. (($boks_vid_id == 0) ? 'selected' : '') .'>Не выбрано</option>';
|
|||
|
|
$list = AutoSearch::getCommonFields('boks_vid_id', $boks_vid_id);
|
|||
|
|
foreach ($list as $item) {
|
|||
|
|
$html .= '<option value="'. $item['value'] .'" ' . (($item['value'] == $boks_vid_id) ? 'selected' : '') . '>'. $item['label'] .'</option>';
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
echo json_encode(['list' => $list, 'html' => ('<select id="asfiltr-boks-vid-id">' . $html . '</select>')]);
|
|||
|
|
exit();
|
|||
|
|
}
|
|||
|
|
if ($request == 'get_commerc_status_id') {
|
|||
|
|
$user_id = json_decode($data->user_id);
|
|||
|
|
$commerc_status_id = json_decode($data->commerc_status_id);
|
|||
|
|
|
|||
|
|
$html = '<option value="0" '. (($commerc_status_id == 0) ? 'selected' : '') .'>Не выбрано</option>';
|
|||
|
|
$list = AutoSearch::getCommonFields('commerc_status_id', $commerc_status_id);
|
|||
|
|
foreach ($list as $item) {
|
|||
|
|
$html .= '<option value="'. $item['value'] .'" ' . (($item['value'] == $commerc_status_id) ? 'selected' : '') . '>'. $item['label'] .'</option>';
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
echo json_encode(['list' => $list, 'html' => ('<select id="asfiltr-commerc-status-id">' . $html . '</select>')]);
|
|||
|
|
exit();
|
|||
|
|
}
|
|||
|
|
if ($request == 'get_commerc_specifications') {
|
|||
|
|
$user_id = json_decode($data->user_id);
|
|||
|
|
$commerc_specifications = json_decode($data->commerc_specifications);
|
|||
|
|
|
|||
|
|
$list = AutoSearch::getCommonFields('commerc_specifications', $commerc_specifications);
|
|||
|
|
foreach ($list as $item) {
|
|||
|
|
$html .= '<option value="'. $item['value'] .'" ' . ((in_array($item['value'], $commerc_specifications)) ? 'selected' : '') . '>'. $item['label'] .'</option>';
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
echo json_encode(['list' => $list, 'html' => ('<select id="asfiltr-commerc-specifications" multiple>' . $html . '</select>')]);
|
|||
|
|
exit();
|
|||
|
|
}
|
|||
|
|
if ($request == 'get_commerc_infrastructure') {
|
|||
|
|
$user_id = json_decode($data->user_id);
|
|||
|
|
$commerc_infrastructure = json_decode($data->commerc_infrastructure);
|
|||
|
|
|
|||
|
|
$list = AutoSearch::getCommonFields('commerc_infrastructure', $commerc_infrastructure, "WHERE id < 27");
|
|||
|
|
foreach ($list as $item) {
|
|||
|
|
$html .= '<option value="'. $item['value'] .'" ' . ((in_array($item['value'], $commerc_infrastructure)) ? 'selected' : '') . '>'. $item['label'] .'</option>';
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
echo json_encode(['list' => $list, 'html' => ('<select id="asfiltr-commerc-infrastructure" multiple>' . $html . '</select>')]);
|
|||
|
|
exit();
|
|||
|
|
}
|
|||
|
|
if ($request == 'get_commerc_infrastructure1') {
|
|||
|
|
$user_id = json_decode($data->user_id);
|
|||
|
|
$commerc_infrastructure1 = json_decode($data->commerc_infrastructure1);
|
|||
|
|
|
|||
|
|
$list = AutoSearch::getCommonFields('commerc_infrastructure', $commerc_infrastructure1, "WHERE vid=1");
|
|||
|
|
foreach ($list as $item) {
|
|||
|
|
$html .= '<option value="'. $item['value'] .'" ' . ((in_array($item['value'], $commerc_infrastructure1)) ? 'selected' : '') . '>'. $item['label'] .'</option>';
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
echo json_encode(['list' => $list, 'html' => ('<select id="asfiltr-commerc-infrastructure1" multiple>' . $html . '</select>')]);
|
|||
|
|
exit();
|
|||
|
|
}
|
|||
|
|
if ($request == 'get_commerc_infrastructure2') {
|
|||
|
|
$user_id = json_decode($data->user_id);
|
|||
|
|
$commerc_infrastructure2 = json_decode($data->commerc_infrastructure2);
|
|||
|
|
|
|||
|
|
$list = AutoSearch::getCommonFields('commerc_infrastructure', $commerc_infrastructure2, "WHERE vid1=1");
|
|||
|
|
foreach ($list as $item) {
|
|||
|
|
$html .= '<option value="'. $item['value'] .'" ' . ((in_array($item['value'], $commerc_infrastructure2)) ? 'selected' : '') . '>'. $item['label'] .'</option>';
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
echo json_encode(['list' => $list, 'html' => ('<select id="asfiltr-commerc-infrastructure2" multiple>' . $html . '</select>')]);
|
|||
|
|
exit();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
// Поиск и получение ранее сохраненного фильтра
|
|||
|
|
if ($request == 'get_filter') {
|
|||
|
|
$user_id = json_decode($data->user_id);
|
|||
|
|
$req_id = json_decode($data->req_id);
|
|||
|
|
$filter_id = json_decode($data->filter_id);
|
|||
|
|
|
|||
|
|
$autosearch = new AutoSearch();
|
|||
|
|
if (!is_null($filter_id))
|
|||
|
|
echo json_encode($autosearch->getFilter(intval($filter_id), intval($user_id), false));
|
|||
|
|
else
|
|||
|
|
echo json_encode($autosearch->getFilterByReq(intval($req_id), intval($user_id), false));
|
|||
|
|
|
|||
|
|
exit();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//
|
|||
|
|
if ($request == 'save_field_input') {
|
|||
|
|
|
|||
|
|
/*if($_SESSION['id'] == 5427){
|
|||
|
|
error_reporting(E_ALL | E_STRICT);
|
|||
|
|
ini_set('display_errors', 1);
|
|||
|
|
}*/
|
|||
|
|
|
|||
|
|
$user_id = json_decode($data->user_id);
|
|||
|
|
$id = json_decode($data->filter_id);
|
|||
|
|
$param_id = $data->param_id;
|
|||
|
|
$fields = $data->fields;
|
|||
|
|
|
|||
|
|
$result = null;
|
|||
|
|
$autosearch = new AutoSearch();
|
|||
|
|
if ($result = $autosearch->saveFilterFields(intval($id), intval($user_id), (array)$fields)) {
|
|||
|
|
$filter = $autosearch->getFilter(intval($id), intval($user_id), false);
|
|||
|
|
$_SESSION['asfilter_'.$id] = $filter;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (!is_null($filter)) {
|
|||
|
|
$new_fields = $autosearch->getFilterInfo($filter, true, false);
|
|||
|
|
$new_value = $new_fields[$param_id]['value'];
|
|||
|
|
} else {
|
|||
|
|
$new_value = $filter[$param_id];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
echo json_encode([
|
|||
|
|
'result' => $result,
|
|||
|
|
'filter_id' => $id,
|
|||
|
|
'user_id' => $user_id,
|
|||
|
|
'param_id' => $param_id,
|
|||
|
|
'fields' => $fields,
|
|||
|
|
'value' => $new_value
|
|||
|
|
]);
|
|||
|
|
exit();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//
|
|||
|
|
if ($request == 'get_field_input') {
|
|||
|
|
$user_id = $data->user_id;
|
|||
|
|
$id = $data->filter_id;
|
|||
|
|
$field_id = $data->field_id;
|
|||
|
|
|
|||
|
|
$autosearch = new AutoSearch();
|
|||
|
|
$filter = $autosearch->getFilter(intval($id), intval($user_id));
|
|||
|
|
echo json_encode($autosearch->buildFilterInput($filter, $field_id));
|
|||
|
|
exit();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if ($request == 'get_filter_by_req') {
|
|||
|
|
|
|||
|
|
$user_id = $data->user_id;
|
|||
|
|
$req_ids = $data->req_ids;
|
|||
|
|
|
|||
|
|
if (empty($user_id) || empty($req_ids)) {
|
|||
|
|
echo json_encode([
|
|||
|
|
'success' => false,
|
|||
|
|
'result' => null
|
|||
|
|
]);
|
|||
|
|
exit();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (is_array($req_ids)) {
|
|||
|
|
$req_ids = array_map('intval', $req_ids);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$results = [];
|
|||
|
|
$autosearch = new AutoSearch();
|
|||
|
|
|
|||
|
|
$user = new \User;
|
|||
|
|
$user_company_id = $user->getAgencyIdForUser($user_id);
|
|||
|
|
|
|||
|
|
$sql_users = "SELECT id FROM users WHERE company_id = '$user_company_id'";
|
|||
|
|
$query = mysql_query($sql_users);
|
|||
|
|
$agents_ids = [];
|
|||
|
|
while ($row = mysql_fetch_assoc($query)) {
|
|||
|
|
$agents_ids[] = (int)$row['id'];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$all_filters = $autosearch->getFiltersByReqs($req_ids, $agents_ids, false);
|
|||
|
|
|
|||
|
|
foreach ($req_ids as $req_id) {
|
|||
|
|
$filter = isset($all_filters[$req_id]) ? $all_filters[$req_id] : null;
|
|||
|
|
|
|||
|
|
if ($filter && isset($filter['id'])) {
|
|||
|
|
$filter_id = intval($filter['id']);
|
|||
|
|
$result['autosearch_id'] = $filter_id;
|
|||
|
|
$result['autosearch'] = [
|
|||
|
|
'active' => intval($filter['is_active']),
|
|||
|
|
'count' => $filter['count'],
|
|||
|
|
'is_search' => $filter['is_search'],
|
|||
|
|
'is_reverse' => $filter['is_reverse'],
|
|||
|
|
'total' => $filter['total'],
|
|||
|
|
'error' => $filter['error'],
|
|||
|
|
'_raw' => $filter
|
|||
|
|
];
|
|||
|
|
|
|||
|
|
$info = '';
|
|||
|
|
$comment = '';
|
|||
|
|
$info_ar = $autosearch->getFilterInfo($filter, true, true);
|
|||
|
|
|
|||
|
|
foreach ($info_ar as $key => $field) {
|
|||
|
|
if (isset($field['label']) && isset($field['value'])) {
|
|||
|
|
if ($key === "comment") {
|
|||
|
|
$comment = '<b>' . $field['label'] . ':</b> ' . $field['value'];
|
|||
|
|
} else {
|
|||
|
|
$info .= ' <b>' . $field['label'] . ':</b> ' . $field['value'] . ';';
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$result['autosearch']['filter'][$key] = [
|
|||
|
|
'id' => $field['id'],
|
|||
|
|
'label' => $field['label'],
|
|||
|
|
'value' => $field['value']
|
|||
|
|
];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (!empty($info)) {
|
|||
|
|
$result['autosearch_info'] = rtrim(rtrim($info, ';'), '<br/>');
|
|||
|
|
$result['autosearch_comment'] = trim($comment) . '<b>ID фильтра:</b> ' . $filter_id;
|
|||
|
|
$result['autosearch_comment'] .= ', <b>Автопоиск:</b> ' . ((intval($filter['is_active'])) ? '<span style="color:#43a047">включен</span>' : '<span style="color:#f24646">отключен</span>');
|
|||
|
|
$result['autosearch_comment'] .= ', <b>Уведомления:</b> ' . ((intval($filter['telegram_notify'])) ? '<span style="color:#43a047">включены</span>' : '<span style="color:#f24646">отключены</span>');
|
|||
|
|
}
|
|||
|
|
} else {
|
|||
|
|
$result = null;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (!is_null($result)) {
|
|||
|
|
$results[(string)$req_id] = $result;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
echo json_encode([
|
|||
|
|
'success' => true,
|
|||
|
|
'count' => count($results),
|
|||
|
|
'results' => $results,
|
|||
|
|
'_req_ids' => $req_ids
|
|||
|
|
]);
|
|||
|
|
exit();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//
|
|||
|
|
if ($request == 'delete_field_input') {
|
|||
|
|
$user_id = intval($data->user_id);
|
|||
|
|
$id = intval($data->filter_id);
|
|||
|
|
$field_id = $data->field_id;
|
|||
|
|
|
|||
|
|
$autosearch = new AutoSearch();
|
|||
|
|
echo json_encode([
|
|||
|
|
'field_id' => $field_id,
|
|||
|
|
'result' => $autosearch->unsetFilterField($id, $user_id, $field_id)
|
|||
|
|
]);
|
|||
|
|
exit();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// Сохранение/редактирование параметров автопоиска
|
|||
|
|
if ($request == 'add_edit') {
|
|||
|
|
$user_id = json_decode($data->user_id);
|
|||
|
|
$is_new_req = json_decode($data->is_new_req);
|
|||
|
|
$params = (array)$data->params;
|
|||
|
|
|
|||
|
|
$error = false;
|
|||
|
|
$success = false;
|
|||
|
|
$autosearch = new AutoSearch();
|
|||
|
|
|
|||
|
|
$result = $autosearch->addEditFilter($params['id'], $params, !(isset($params['req_id'])));
|
|||
|
|
|
|||
|
|
if ($result['success']) {
|
|||
|
|
$filter = $autosearch->getFilter(intval($result['id']), $user_id);
|
|||
|
|
$filter_info = $autosearch->getFilterInfo($filter, true);
|
|||
|
|
echo json_encode(['success' => $result['success'], 'id' => $result['id'], 'filter' => $filter_info, 'error' => $result['error'], 'sql' => $result['sql']]);
|
|||
|
|
} else {
|
|||
|
|
echo json_encode(['error' => $result['error'], 'sql' => $result['sql']]);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
exit();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//
|
|||
|
|
if ($request == 'set_req_filter') {
|
|||
|
|
$user_id = intval($data->user_id);
|
|||
|
|
$req_id = intval($data->req_id);
|
|||
|
|
$filter_id = intval($data->filter_id);
|
|||
|
|
|
|||
|
|
$autosearch = new AutoSearch();
|
|||
|
|
if ($result = $autosearch->setReqToFilter($req_id, $filter_id, $user_id)) {
|
|||
|
|
echo json_encode(['success' => true, 'req_id' => $result['req_id'], 'filter_id' => $result['filter_id']]);
|
|||
|
|
} else {
|
|||
|
|
echo json_encode(['error' => $result]);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
exit();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$get = clearInputData($_GET);
|
|||
|
|
if ($get['request'] == 'get_filter_info') {
|
|||
|
|
$user_id = $_SESSION['id'];
|
|||
|
|
$req_id = $get['req_id'];
|
|||
|
|
$filter_id = $get['filter_id'];
|
|||
|
|
|
|||
|
|
$autosearch = new AutoSearch();
|
|||
|
|
if (!is_null($filter_id)) {
|
|||
|
|
$filter = $autosearch->getFilter(intval($filter_id), intval($user_id), false);
|
|||
|
|
} else {
|
|||
|
|
$filter = $autosearch->getFilterByReq(intval($req_id), intval($user_id), false);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
echo json_encode($autosearch->getFilterInfo($filter));
|
|||
|
|
exit();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//
|
|||
|
|
if ($request == 'set_object_viewed') {
|
|||
|
|
$user_id = json_decode($data->user_id);
|
|||
|
|
$filter_id = json_decode($data->filter_id);
|
|||
|
|
$object_id = json_decode($data->object_id);
|
|||
|
|
|
|||
|
|
if (intval($user_id) !== intval($_SESSION['id']))
|
|||
|
|
exit();
|
|||
|
|
|
|||
|
|
if (!is_null($filter_id) && !is_null($object_id)) {
|
|||
|
|
$autosearch = new AutoSearch();
|
|||
|
|
if ($results = $autosearch->addObjectToViewed($filter_id, $object_id)) {
|
|||
|
|
echo json_encode($results);
|
|||
|
|
} else {
|
|||
|
|
echo json_encode([
|
|||
|
|
'error' => $results['error']
|
|||
|
|
]);
|
|||
|
|
}
|
|||
|
|
} else {
|
|||
|
|
echo json_encode([
|
|||
|
|
'error' => "Не указан ИД фильтра или объекта"
|
|||
|
|
]);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
exit();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//
|
|||
|
|
if ($request == 'add_object_to_favour') {
|
|||
|
|
$user_id = json_decode($data->user_id);
|
|||
|
|
$filter_id = json_decode($data->filter_id);
|
|||
|
|
$object_id = json_decode($data->object_id);
|
|||
|
|
|
|||
|
|
if (intval($user_id) !== intval($_SESSION['id']))
|
|||
|
|
exit();
|
|||
|
|
|
|||
|
|
if (!is_null($filter_id) && !is_null($object_id)) {
|
|||
|
|
$autosearch = new AutoSearch();
|
|||
|
|
if ($results = $autosearch->addObjectToFavour($filter_id, $object_id, true, true)) {
|
|||
|
|
echo json_encode($results);
|
|||
|
|
} else {
|
|||
|
|
echo json_encode([
|
|||
|
|
'error' => $results['error']
|
|||
|
|
]);
|
|||
|
|
}
|
|||
|
|
} else {
|
|||
|
|
echo json_encode([
|
|||
|
|
'error' => "Не указан ИД фильтра или объекта"
|
|||
|
|
]);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
exit();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//
|
|||
|
|
if ($request == 'add_object_to_ignored') {
|
|||
|
|
$user_id = json_decode($data->user_id);
|
|||
|
|
$filter_id = json_decode($data->filter_id);
|
|||
|
|
$object_id = json_decode($data->object_id);
|
|||
|
|
|
|||
|
|
if (intval($user_id) !== intval($_SESSION['id']))
|
|||
|
|
exit();
|
|||
|
|
|
|||
|
|
if (!is_null($filter_id) && !is_null($object_id)) {
|
|||
|
|
$autosearch = new AutoSearch();
|
|||
|
|
if ($results = $autosearch->addObjectToIgnored($filter_id, $object_id)) {
|
|||
|
|
echo json_encode($results);
|
|||
|
|
} else {
|
|||
|
|
echo json_encode([
|
|||
|
|
'error' => $results['error']
|
|||
|
|
]);
|
|||
|
|
}
|
|||
|
|
} else {
|
|||
|
|
echo json_encode([
|
|||
|
|
'error' => "Не указан ИД фильтра или объекта"
|
|||
|
|
]);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
exit();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//
|
|||
|
|
if ($request == 'restart_search') {
|
|||
|
|
/*error_reporting(E_ALL | E_STRICT);
|
|||
|
|
ini_set('display_errors', 1);*/
|
|||
|
|
|
|||
|
|
$user_id = json_decode($data->user_id);
|
|||
|
|
$filter_id = json_decode($data->filter_id);
|
|||
|
|
|
|||
|
|
if (intval($user_id) !== intval($_SESSION['id']))
|
|||
|
|
exit();
|
|||
|
|
|
|||
|
|
if (!is_null($filter_id)) {
|
|||
|
|
$autosearch = new AutoSearch();
|
|||
|
|
//$results = $autosearch->clearAllResults($filter_id);
|
|||
|
|
if ($results = $autosearch->search($filter_id, 0, 100)) {
|
|||
|
|
echo json_encode([
|
|||
|
|
'success' => true,
|
|||
|
|
'total' => $results['total'],
|
|||
|
|
'error' => $results['error'],
|
|||
|
|
'time' => $results['time'],
|
|||
|
|
'info' => $results['info']
|
|||
|
|
]);
|
|||
|
|
} else {
|
|||
|
|
echo json_encode([
|
|||
|
|
'error' => $results['error'],
|
|||
|
|
'total' => $results['total'],
|
|||
|
|
'time' => $results['time'],
|
|||
|
|
'info' => $results['info']
|
|||
|
|
]);
|
|||
|
|
}
|
|||
|
|
} else {
|
|||
|
|
echo json_encode([
|
|||
|
|
'error' => "Не указан ИД фильтра"
|
|||
|
|
]);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
exit();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//
|
|||
|
|
if ($request == 'clear_results') {
|
|||
|
|
$user_id = json_decode($data->user_id);
|
|||
|
|
$filter_id = json_decode($data->filter_id);
|
|||
|
|
|
|||
|
|
if (intval($user_id) !== intval($_SESSION['id']))
|
|||
|
|
exit();
|
|||
|
|
|
|||
|
|
if (!is_null($filter_id)) {
|
|||
|
|
$autosearch = new AutoSearch();
|
|||
|
|
if ($results = $autosearch->clearAllResults($filter_id, true)) {
|
|||
|
|
echo json_encode([
|
|||
|
|
'success' => true
|
|||
|
|
]);
|
|||
|
|
} else {
|
|||
|
|
echo json_encode([
|
|||
|
|
'error' => $results['error']
|
|||
|
|
]);
|
|||
|
|
}
|
|||
|
|
} else {
|
|||
|
|
echo json_encode([
|
|||
|
|
'error' => "Не указан ИД фильтра"
|
|||
|
|
]);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
exit();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//
|
|||
|
|
if ($request == 'get_results') {
|
|||
|
|
|
|||
|
|
//error_reporting(E_ALL | E_STRICT);
|
|||
|
|
//ini_set('display_errors', 1);
|
|||
|
|
|
|||
|
|
$user_id = intval($data->user_id);
|
|||
|
|
$filter_id = intval($data->filter_id);
|
|||
|
|
$section = $data->section;
|
|||
|
|
$sort_order = $data->order;
|
|||
|
|
$offset = intval($data->offset);
|
|||
|
|
|
|||
|
|
if ($user_id !== intval($_SESSION['id']))
|
|||
|
|
exit();
|
|||
|
|
|
|||
|
|
$autosearch = new AutoSearch(null);
|
|||
|
|
if ($filter = $autosearch->getFilter($filter_id, $user_id)) {
|
|||
|
|
if ($results = $autosearch->getResults($filter['id'], $section, $offset, (array)$sort_order, 10, true, true)) {
|
|||
|
|
echo json_encode([
|
|||
|
|
'success' => true,
|
|||
|
|
'section' => $section,
|
|||
|
|
'filter_id' => intval($filter['id']),
|
|||
|
|
'req_id' => intval($filter['req_id']),
|
|||
|
|
'objects' => $results['results'],
|
|||
|
|
'count' => intval($results['count']),
|
|||
|
|
'total' => intval($results['total']),
|
|||
|
|
'perpage' => intval($results['perpage']),
|
|||
|
|
'error' => $results['error'],
|
|||
|
|
'sort_order' => $results['sort_order'],
|
|||
|
|
'sql' => $results['sql'],
|
|||
|
|
'viewed_id' => $results['viewed'],
|
|||
|
|
//'ignored_id' => $results['ignored'],
|
|||
|
|
'favoured_id' => $results['favoured'],
|
|||
|
|
'sended_id' => $results['sended'],
|
|||
|
|
'filter' => $filter
|
|||
|
|
]);
|
|||
|
|
} else {
|
|||
|
|
echo json_encode([
|
|||
|
|
'error' => $results['error'],
|
|||
|
|
'section' => $section,
|
|||
|
|
'filter_id' => $filter['id'],
|
|||
|
|
'req_id' => $filter['req_id'],
|
|||
|
|
'sort_order' => $results['sort_order'],
|
|||
|
|
'sql' => $results['sql'],
|
|||
|
|
'filter' => $filter,
|
|||
|
|
]);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
exit();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//
|
|||
|
|
if ($request == 'get_reverse_counter') {
|
|||
|
|
$object_id = json_decode($data->object_id);
|
|||
|
|
$autosearch = new AutoSearch();
|
|||
|
|
$results = $autosearch->reverseSearch($object_id, 0, 100, false, true, true, true);
|
|||
|
|
$output = [
|
|||
|
|
'time' => $results['time'],
|
|||
|
|
'total' => intval($results['total']),
|
|||
|
|
'has_items' => $results['has_items'],
|
|||
|
|
];
|
|||
|
|
|
|||
|
|
if (in_array($_SESSION['id'], [4, 6635, 5427])) {
|
|||
|
|
$output['object'] = $results['object'];
|
|||
|
|
$output['sql'] = preg_replace('/\r|\n|\t/', '', $results['sql']);
|
|||
|
|
$output['sql_count'] = preg_replace('/\r|\n|\t/', '', $results['sql_count']);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
echo json_encode($output);
|
|||
|
|
exit();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//
|
|||
|
|
if ($request == 'get_requisitions') {
|
|||
|
|
//error_reporting(E_ALL | E_STRICT);
|
|||
|
|
//ini_set('display_errors', 1);
|
|||
|
|
$perpage = 10;
|
|||
|
|
$object_id = json_decode($data->object_id);
|
|||
|
|
$offset = json_decode($data->offset);
|
|||
|
|
$autosearch = new AutoSearch();
|
|||
|
|
$results = $autosearch->reverseSearch($object_id, $offset, $perpage, false, false, true, true);
|
|||
|
|
|
|||
|
|
$user = new \User;
|
|||
|
|
$user->get($_SESSION['id']);
|
|||
|
|
$user->checkPermissions($_SESSION['id'], false);
|
|||
|
|
|
|||
|
|
$requisitions = [];
|
|||
|
|
if ($results['total'] > 0) {
|
|||
|
|
$req = new Requisitions($pdo);
|
|||
|
|
$req->set_user($user);
|
|||
|
|
|
|||
|
|
$results['requisitions'] = array_unique($results['requisitions']);
|
|||
|
|
foreach ($results['requisitions'] as $req_id) {
|
|||
|
|
if (!empty($req_id)) {
|
|||
|
|
if ($requisition = $req->get_req_id($req_id)) {
|
|||
|
|
unset($requisition['is_kanban']);
|
|||
|
|
unset($requisition['e']);
|
|||
|
|
$requisitions = array_merge($requisition, $requisitions);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$requisitions = array_reverse($requisitions);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
echo json_encode([
|
|||
|
|
'count' => intval($results['total']),
|
|||
|
|
'offset' => intval($results['offset']),
|
|||
|
|
'perpage' => intval($perpage),
|
|||
|
|
'requisitions' => $requisitions,
|
|||
|
|
'error' => $results['error'],
|
|||
|
|
//'_results' => $results,
|
|||
|
|
]);
|
|||
|
|
exit();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//
|
|||
|
|
if ($request == 'get_filter_info') {
|
|||
|
|
//error_reporting(E_ALL | E_STRICT);
|
|||
|
|
//ini_set('display_errors', 1);
|
|||
|
|
$filter_id = $data->filter_id;
|
|||
|
|
$user_id = $data->user_id;
|
|||
|
|
$autosearch = new AutoSearch();
|
|||
|
|
if ($filter = $autosearch->getFilter(intval($filter_id), intval($user_id), false)) {
|
|||
|
|
|
|||
|
|
$info = '';
|
|||
|
|
$comment = '';
|
|||
|
|
$info_ar = $autosearch->getFilterInfo($filter, true, true);
|
|||
|
|
foreach ($info_ar as $key => $filter) {
|
|||
|
|
if (isset($filter['label']) && isset($filter['value'])) {
|
|||
|
|
if ($key === "comment")
|
|||
|
|
$comment = '<b>' . $filter['label'] . ':</b> ' . $filter['value'];
|
|||
|
|
else
|
|||
|
|
$info .= ' <b>' . $filter['label'] . ':</b> ' . $filter['value'] . ';';
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (!empty($filter['geo'])) {
|
|||
|
|
$geo = (array)json_decode($filter['geo'], true);
|
|||
|
|
$geo = array_filter(array_map(function($item) {
|
|||
|
|
return !empty($item);
|
|||
|
|
}, $geo));
|
|||
|
|
|
|||
|
|
$info .= ' <b>Гео:</b> ' . declOfNum(count($geo), ['%d уточнение', '%d уточнения', '%d уточнений']). ';';
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
echo json_encode([
|
|||
|
|
'html' => rtrim(trim($info), ';') ."<br/>". trim($comment) ."<br/>". '<b>ID фильтра:</b> ' . $filter_id
|
|||
|
|
]);
|
|||
|
|
} else {
|
|||
|
|
echo json_encode([
|
|||
|
|
'html' => ''
|
|||
|
|
]);
|
|||
|
|
}
|
|||
|
|
exit();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
?>
|