-
Notifications
You must be signed in to change notification settings - Fork 0
/
ajax.php
265 lines (247 loc) · 9.13 KB
/
ajax.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
<?php
include_once("./include/common.php");
try {
$_REQUEST['action']($_REQUEST);
}
catch (Exception $e) {
echo 0;
}
function cityList($param) {
$val = clearTextData($param['q']);
//$val = $param['q'];
//$val = iconv('UTF-8', 'windows-1251', $val);
$res = City::getListLink('c.name LIKE "%'.$val.'%"');
//header('Content-type: text/html; charset=windows-1251');
while ($row = $res->fetchRow()) {
echo "{$row['name']} ({$row['region_name']})|{$row['id']}|{$row['lat']}|{$row['lon']}\r\n";
}
}
function streetList($param) {
$val = clearTextData($param['q']);
$city_id = intval($param['city_id']);
$res = Street::getListLink('city_id='.$city_id.' AND status=1 AND name LIKE "%'.$val.'%"');
while ($row = $res->fetchRow()) echo "{$row['name']}|{$row['id']}\r\n";
}
function getTenementInfo($param) {
if (isset($param['tenement_id'])) {
$tenement_id = intval($param['tenement_id']);
$row = Tenement::getFullStatic($tenement_id);
if ($row) {
$vals = Tenement::getPropertiesValStatic($row);
$vals['id'] = $row['id'];
$vals['city_id'] = $row['city_id'];
$vals['street_id'] = $row['street_id'];
$vals['lat'] = $row['lat'];
$vals['lon'] = $row['lon'];
$vals['address'] = $row['street'].', '.$row['number'];
echo json_encode($vals);
}
else echo '';
}
else {
$city_id = intval($param['city_id']);
$number = clearTextData($param['number']);
$street = clearTextData($param['street']);
$sql = "city_id=$city_id AND name='$street'";
$res = Street::getListLink($sql);
$num_rows = $res->numRows();
if ($num_rows<1) {
/*
* Добавлять без проверки на человека не будем чтобы не было дыры
*/
//$street_id = $streetObj->add(array('city_id'=>$city_id, 'name'=>$street));
echo '';
}
else {
$row = $res->fetchRow();
$street_id = $row['id'];
$res = Tenement::getBy("city_id=$city_id AND street_id=$street_id AND number LIKE '$number'");
if ($res) $row = $res->fetchRow();
if ($row) {
$vals = Tenement::getPropertiesValStatic($row);
$vals['id'] = $row['id'];
$vals['city_id'] = $row['city_id'];
$vals['street_id'] = $row['street_id'];
$vals['lat'] = $row['lat'];
$vals['lon'] = $row['lon'];
$vals['address'] = $street.', '.$row['number'];
echo json_encode($vals);
}
else echo '';
}
}
}
function updateSession(){
echo 1;
}
function delPhoto($param){
$name = clearTextData($param['name']);
$num_deleted = Photo::delete($name);
echo $name;
}
function getFlatListByTenement($param){
global $config;
$id=intval($param['id']);
if (isset($_GET['limit']) && intval($_GET['limit'])==3) {
$limit = 3;
}
else {
$limit = 30;
}
$db_res = Flat::getFullListLink("tenement_id=$id AND (f.status=".REALTY_STATUS_SALE." OR f.status=".REALTY_STATUS_RENT." OR f.status=".REALTY_STATUS_SOLD.") GROUP BY f.id ORDER BY f.updated_on DESC LIMIT $limit");
if (isset($_SESSION['user_id'])&& in_array($_SESSION['user_id'],$config['user_workers'])) {
$is_editor = true;
$h = '<th></th>';
}
else {
$is_editor = false;
$h='';
}
$html = '
История продаж в этом доме:<br><br>
<table class="table table-striped table-bordered table-condensed"><thead>
<tr>
<th>Дата</th><th>Комнат</th><th>Цена (руб.)</th><th>Цена за кв.м.(руб.)</th><th>Этаж</th><th>Общ. пл.м<sup>2</sup></th><th>Сделка</th>'.$h.'
</tr></thead>';
while ($row = $db_res->fetchRow()) {
$html .= '<tr>';
$date = explode(' ',$row['updated_on']);
$dates = explode('-',$date[0]);
$date = $dates[2].'.'.$dates[1].'.'.$dates[0];
//$type = ($row['status']==REALTY_STATUS_SALE) ? 'продажа' : 'аренда';
switch ($row['status'])
{
case REALTY_STATUS_SALE:$type='продажа';break;
case REALTY_STATUS_RENT:$type='аренда';break;
case REALTY_STATUS_SOLD:$type='продано';break;
}
$t = ($is_editor) ? '<td><a href="/flat.html?action=updateDate&id='.$row['id'].'" title="Обновить дату"><img src="/images/icon_update.png"></a></td>' : '';
$price = number_format($row['price'],0);
$price_m = number_format($row['price_m'],0);
$html .= "<td><a href='/flat.html?action=view&id={$row['id']}' title='смотреть'>$date</a></td><td>{$row['rooms']}</td><td>{$price}</td><td>{$price_m}</td><td>{$row['storey']}</td><td>{$row['total_area']}</td><td>$type</td>$t";
$html .= '</tr>';
}
$html .= '</table>';
if (isset($date)) echo $html;
else echo '';
}
function getAnyStreet($param) {
$id=intval($param['id']);
$db_res = Street::getListByCityLink("city_id=$id LIMIT 1");
$row = $db_res->fetchRow();
echo $row['id'].'|'.$row['name'];
}
function getCommercialListByCity($param){
global $config;
$id=intval($param['id']);
if (isset($_SESSION['user_id'])&& in_array($_SESSION['user_id'],$config['user_workers'])) {
$is_editor = true;
$h = '<th></th>';
}
else {
$is_editor = false;
$h='';
}
if (!$is_editor) {
$limit = 5;
}
else {
$limit = 30;
}
$html = '
История продаж в этом населенном пункте:<br><br>
<table class="table table-striped table-bordered table-condensed"><thead>
<tr>
<th>Дата</th><th>Цена (руб.)</th><th>Тип</th><th>Общ. пл.м<sup>2</sup></th><th>Описание</th><th>Сделка</th>'.$h.'
</tr></thead>';
$db_res = Commercial::getFullListLink("f.city_id=$id AND (f.status=".REALTY_STATUS_SALE." OR f.status=".REALTY_STATUS_RENT.") GROUP BY f.id ORDER BY updated_on DESC LIMIT $limit");
while ($row = $db_res->fetchRow()) {
$html .= '<tr>';
$date = formatDate($row['updated_on']);
$t = ($is_editor) ? '<td><a href="/commercial.html?action=updateDate&id='.$row['id'].'" title="Обновить дату"><img src="/images/icon_update.png"></a></td>' : '';
$price = number_format($row['price'],0);
$description = textReduce($row['description']);
$type = Commercial::$TYPE[$row['type_id']];
$type_sale = ($row['status']==REALTY_STATUS_SALE) ? 'продажа' : 'аренда';
$html .= "<td><a href='/commercial.html?action=view&id={$row['id']}' title='смотреть'>$date</a></td><td>{$price}</td><td>{$type}</td><td>{$row['total_area']}</td><td>{$description}</td><td>{$type_sale}</td>$t";
$html .= '</tr>';
}
$html .= '</table>';
if (isset($date)) echo $html;
else echo '';
}
function getHouseListByCity($param){
global $config;
$id=intval($param['id']);
if (isset($_SESSION['user_id'])&& in_array($_SESSION['user_id'],$config['user_workers'])) {
$is_editor = true;
$h = '<th></th>';
}
else {
$is_editor = false;
$h='';
}
if (!$is_editor) {
$limit = 3;
}
else {
$limit = 30;
}
$html = '
История продаж в этом населенном пункте:<br><br>
<table class="table table-striped table-bordered table-condensed"><thead>
<tr>
<th>Дата</th><th>Цена (руб.)</th><th>Общ. пл.м<sup>2</sup></th><th>Участок (соток)</th><th>Описание</th>'.$h.'
</tr></thead>';
$db_res = House::getFullListLink("f.city_id=$id AND f.status=".REALTY_STATUS_SALE." GROUP BY f.id ORDER BY updated_on DESC LIMIT $limit");
while ($row = $db_res->fetchRow()) {
$html .= '<tr>';
$date = formatDate($row['updated_on']);
$t = ($is_editor) ? '<td><a href="/house.html?action=updateDate&id='.$row['id'].'" title="Обновить дату"><img src="/images/icon_update.png"></a></td>' : '';
$price = number_format($row['price'],0);
$description = textReduce($row['description']);
$html .= "<td><a href='/house.html?action=view&id={$row['id']}' title='смотреть'>$date</a></td><td>{$price}</td><td>{$row['total_area']}</td><td>{$row['land_area']}</td><td>{$description}</td>$t";
$html .= '</tr>';
}
$html .= '</table>';
if (isset($date)) echo $html;
else echo '';
}
function getLandListByCity($param){
global $config;
$id=intval($param['id']);
if (isset($_SESSION['user_id'])&& in_array($_SESSION['user_id'],$config['user_workers'])) {
$is_editor = true;
$h = '<th></th>';
}
else {
$is_editor = false;
$h='';
}
if (!$is_editor) {
$limit = 3;
}
else {
$limit = 30;
}
$html = '
История продаж в этом населенном пункте:<br><br>
<table class="table table-striped table-bordered table-condensed"><thead>
<tr>
<th>Дата</th><th>Цена (руб.)</th></th><th>Площадь (соток)</th><th>Описание</th>'.$h.'
</tr></thead>';
$db_res = Land::getFullListLink("f.city_id=$id AND f.status=".REALTY_STATUS_SALE." GROUP BY f.id ORDER BY updated_on DESC LIMIT $limit");
while ($row = $db_res->fetchRow()) {
$html .= '<tr>';
$date = formatDate($row['updated_on']);
$t = ($is_editor) ? '<td><a href="/land.html?action=updateDate&id='.$row['id'].'" title="Обновить дату"><img src="/images/icon_update.png"></a></td>' : '';
$price = number_format($row['price'],0);
$description = textReduce($row['description']);
$html .= "<td><a href='/land.html?action=view&id={$row['id']}' title='смотреть'>$date</a></td><td>{$price}</td><td>{$row['area']}</td><td>{$description}</td>$t";
$html .= '</tr>';
}
$html .= '</table>';
if (isset($date)) echo $html;
else echo '';
}
?>