Joywork/ajax/getBaloon.php

367 lines
17 KiB
PHP
Raw Permalink Normal View History

2026-05-22 20:21:54 +02:00
<?php
header('Content-Type: application/json; charset=utf-8');
require_once($_SERVER['DOCUMENT_ROOT']."/config.php");
$get=clearInputData($_GET);
ini_set('display_errors', 0);
error_reporting(E_ALL & ~E_DEPRECATED & ~E_STRICT & ~E_NOTICE);
$sql = "SELECT
objects.*,
rayon.rayon,
ads_objects.ads_agent,
ads_objects.ads_source,
ads_objects.ads_url
FROM objects objects
JOIN object_location on objects.id = object_location.object_id
LEFT JOIN rayon rayon on objects.rayon = rayon.id
LEFT JOIN ads_objects ON ads_objects.obj_id = objects.id
WHERE objects.id = $get[id]";
if ($_GET['dev'] || $_SESSION['id'] == 5238) {
echo $sql;
echo '<br/>';
}
$rez = mysql_query($sql);
$data = array(
"type" => "FeatureCollection"
);
$i = 0;
while ($obj = mysql_fetch_assoc($rez)) {
$sqlPhotoInfo = "SELECT oop.sort_order, p.photo FROM objects_object_photo oop, object_photo p WHERE p.id = oop.object_photo_id AND oop.object_id = $obj[id] ORDER BY oop.sort_order";
$rezPhotoInfo = mysql_query($sqlPhotoInfo);
if (mysql_num_rows($rezPhotoInfo) > 0) {
while ($photoInfo = mysql_fetch_assoc($rezPhotoInfo)) {
$obj['photo' . $photoInfo['sort_order']] = $photoInfo['photo'];
}
}
//Доп обработка
if(!$obj['etazh']) {
$obj['etazh'] = Filter::getFloorFromName($obj['nazv'],true);
} else {
Filter::getFloorFromName($obj['nazv'],true);
}
if(!$obj['etazh_iz']) {
$obj['etazh_iz']=Filter::getMaxFloorFromName($obj['nazv'],true);
} else {
Filter::getMaxFloorFromName($obj['nazv'],true);
}
Filter::getSpaceFromName($obj['nazv'],true);
$obj['nazv']=Filter::name($obj['nazv']);
$obj['sobstv'] = Filter::replaceSobstv($obj['sobstv']);
$obj['opis'] = str_replace("<br>","\n",$obj['opis']);
if ($obj['stoim_prim'] == 0) {
$obj['stoim_prim'] = '';
}
if (isset($_SESSION['notes_bd_usl']))
$notes_bd_usl = $_SESSION['notes_bd_usl'];
if (empty($notes_bd_usl))
$notes_bd_usl = ' true';
$sql_count_notes = "SELECT COUNT(*) FROM object_notes WHERE object_id = $obj[id] AND $notes_bd_usl";
$obj['notes'] = mysql_result(mysql_query($sql_count_notes),0);
$photo = "";
for($num=1;$num<=20;$num++) {
if($obj['photo'.$num]) {
$photo = $obj['photo'.$num];
break;
}
}
$photoI = '';
if(empty($photo)) {
$photoI .= '<div class="">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="Capa_1" x="0px" y="0px" width="130px" height="130px" viewBox="0 0 217.267 217.267" style="enable-background:new 0 0 217.267 217.267;" xml:space="preserve">
<g>
<path d="M163.627,138.057c1.94,0,3.505-1.564,3.505-3.505V83.749c0-1.937-1.564-3.504-3.505-3.504 c-1.937,0-3.504,1.567-3.504,3.504v50.803C160.123,136.493,161.69,138.057,163.627,138.057z" fill="#506979"/>
<path d="M108.633,0C48.73,0,0,48.732,0,108.633c0,29.931,12.167,57.071,31.816,76.738c0.014,0.014,0.017,0.034,0.031,0.048 s0.032,0.018,0.046,0.031c19.666,19.646,46.807,31.815,76.74,31.815c59.901,0,108.634-48.731,108.634-108.633S168.531,0,108.633,0 z M108.633,7.009c26.758,0,51.12,10.416,69.285,27.379l-26.936,26.938H52.564c-9.661,0-17.521,7.861-17.521,17.521v59.573 c0,9.661,7.861,17.521,17.521,17.521h3.805l-21.979,21.978C17.42,159.753,7.009,135.394,7.009,108.633 C7.009,52.599,52.595,7.009,108.633,7.009z M86.196,108.63c0-12.363,10.056-22.42,22.417-22.42c4.921,0,9.466,1.615,13.172,4.313 l-1.875,1.875c-3.207-2.24-7.094-3.564-11.297-3.564c-10.913,0-19.789,8.879-19.789,19.792c0,4.195,1.321,8.09,3.559,11.3 l-1.874,1.868C87.811,118.095,86.196,113.554,86.196,108.63z M131.034,108.63c0,12.364-10.054,22.418-22.418,22.418 c-4.915,0-9.449-1.608-13.145-4.298l1.874-1.876c3.203,2.231,7.082,3.546,11.274,3.546c10.91,0,19.794-8.877,19.794-19.791 c0-4.187-1.321-8.071-3.549-11.272l1.875-1.875C129.433,99.181,131.034,103.717,131.034,108.63z M95.833,108.63 c0-7.051,5.735-12.784,12.78-12.784c2.257,0,4.347,0.639,6.184,1.668l-17.304,17.306C96.469,112.972,95.833,110.885,95.833,108.63 z M121.397,108.63c0,7.049-5.735,12.782-12.781,12.782c-2.244,0-4.322-0.633-6.158-1.652l17.29-17.289 C120.769,104.31,121.397,106.383,121.397,108.63z M90.467,131.753c5.005,3.936,11.298,6.311,18.146,6.311 c16.229,0,29.431-13.206,29.431-29.431c0-6.848-2.375-13.141-6.311-18.149l22.148-22.146h10.814 c5.797,0,10.513,4.717,10.513,10.513v59.573c0,5.797-4.716,10.513-10.513,10.513H73.289L90.467,131.753z M126.784,85.523 c-5.007-3.948-11.311-6.326-18.168-6.326c-16.23,0-29.426,13.204-29.426,29.429c0,6.858,2.375,13.158,6.321,18.172l-22.136,22.135 H52.561c-5.797,0-10.513-4.716-10.513-10.514V78.847c0-5.795,4.716-10.513,10.513-10.513h91.413L126.784,85.523z M108.633,210.257 c-26.759,0-51.12-10.417-69.287-27.377l26.934-26.939h98.422c9.66,0,17.521-7.86,17.521-17.521V78.847 c0-9.661-7.861-17.521-17.521-17.521h-3.806l21.977-21.979c16.968,18.17,27.381,42.529,27.381,69.287 C210.258,164.667,164.667,210.257,108.633,210.257z" fill="#506979"/>
<path d="M53.002,54.317h23.654c1.937,0,3.504-1.567,3.504-3.504s-1.567-3.504-3.504-3.504H53.002 c-1.938,0-3.504,1.567-3.504,3.504S51.064,54.317,53.002,54.317z" fill="#506979"/>
</g>
</svg>
</div>';
} else {
$photoI .= '<div class="fotorama" data-fit="cover" data-nav="false" data-allowfullscreen="true" data-width="310px" data-height="200px">';
for($num=1;$num<=50;$num++)
if($obj['photo'.$num]) {
if(stripos($obj['photo'.$num],"http") === false) {
$obj['photo'.$num] = "/photos/".$obj['photo'.$num];
}
if($obj['photo'.$num]) {
$photoI .= '<img src="'.$obj['photo'.$num].'">';
}
}
$photoI .= '</div>';
if($obj['id_add_user'] || $obj['fbn_id'] || $obj['ads_agent']) {
$photoI .= '<div class="arrow_box">Агент</div>';
} else {
$photoI .= '<div class="arrow_box">Собственник</div>';
}
}
$canEdit = false;
list($dateAdd, $timeAdd) = explode(" ", $obj['date_add']);
list($d, $m, $y) = explode(".", $dateAdd);
$date_add = date('d-m-Y', strtotime($obj['date_add']));
$date = $date_add."&nbsp;&nbsp;".$timeAdd;
/*$dateI = '';
if (!$obj['archive'] || $obj['operation_type'] == 1) {
$dateI .= '<span>'.$date.'</span>';
}*/
if ($obj['operation_type'] == 0) {
$srok = '<span>Сдается '.$SROK_ARENDY["$obj[srok]"].'&nbsp;'.(($obj['prim_srok'])? "($obj[prim_srok]))" : "").'</span>';
} else {
if ($obj['operation_type'] == 1) {
$srok = '<span>Продается</span>';
}
}
$heart = ' <label><input type="checkbox" onclick="to_favor('.$obj['id'].');" id="favorite'.$obj['id'].'" class="favorite-input" ';
if($favor) if(in_array($obj['id'],$favor)) $heart .= 'checked';
$heart .= '><span class="ti-heart" ';
if($favor) if(in_array($obj['id'],$favor)) $heart .= 'active';
$heart .= ' id="favorite-star'.$obj['id'].'"></span></label>';
$copy = '';
if ((($obj['archive'] == 1 && !$obj['id_add_user']) || ($obj['ads_url'] && !$obj['ads_agent'] && !$obj['id_add_user']))) {
$copy = '<div class="action-button actionJW add_from_archive" data-id="'.$obj['id'].'" title="В мои объекты" onclick="event.stopPropagation();event.preventDefault();copyToMyObjects(\''.$obj['id'].'\');">
<i class="ti-plus"></i>
</div>';
}
$contentInfo = '<div class="object_wrap"><div id="objects" class="jw__objects">
<div class="object-images jw__object" id="photos'.$obj['id'].'">'.$photoI .'</div>
</div>'.
'<div class="info" data-id="'.$obj['id'].'">
<div class="price jw__object">
<span onclick="window.open(\'/object.php?id=\' + this.closest(\'.info\').dataset.id, \'_blank\')">
'.number_format($obj['stoim'], 0, ',', ' ').'<span class="rub">p</span>
'.($obj['operation_type'] == 1 ? "<br/>": "").'<span'.($obj['operation_type'] == 0 && $obj['type'] == 7 ? " style='display:none;'": "").
($obj['operation_type'] == 1 ? " style='font-size:24px;'": "").'>'.$obj['stoim_prim'].'</span></span>
<div class="jw__action-button">
<input type="checkbox" class="form-control to_send_input" id="to_send'.$obj['id'].'">
<div class="action-button sendPDF to_send " id="to_send_button'.$obj['id'].'" data-id="'.$obj['id'].'">
<span class="get_pdf" title="К отправке">pdf</span>
</div>
<div class="action-button actionJW addEditNote' . (($obj['notes']) ? ' haveNotes' : '') . '" data-id="'.$obj['id'].'" title="Примечания" onclick="event.stopPropagation();event.preventDefault();openNotesWindow(\''.$obj['id'].'\');">
<i class="ti-pencil-alt"></i>
</div>
<div class="action-button actionJW tasks add-event" title="Задачи" onclick="event.stopPropagation();event.preventDefault();openEventsWindow(\''.$obj['id'].'\');" data-id="'.$obj['id'].'">
<i class="ti-time"></i>
</div>
' . $copy . '
</div>
'. $heart .
'<div class="date srok" onclick="window.open(\'/object.php?id=\' + this.closest(\'.info\').dataset.id, \'_blank\')">' . $srok . '</div>'
.'</div>'.
'<div class="jw__object info-block" onclick="window.open(\'/object.php?id=\' + this.closest(\'.info\').dataset.id, \'_blank\')">
<div class="object-content__info-row">';
$contentInfo .= '<div class="object-content__info-row">';
$contentInfo .= '<div class="nazv">'. str_replace(array('"', '\''), '', $obj['nazv']).'&nbsp;•&nbsp;';
if ($obj['type'] == 7) {
if ($obj['land_area'] * 1 != 0) {
$contentInfo .= '<span>' . $obj['land_area'] * 1 . ' cоток</span>';
}
if ($obj['land_usage_name']) {
$contentInfo .= '<span>' . $obj['land_usage_name'] . '</span>';
}
} else {
if ($obj['ploshad'] * 1 != 0) {
$contentInfo .= '<span>' . $obj['ploshad'] * 1 . ' кв. м</span>';
}
$contentInfo .= '&nbsp;•&nbsp;';
if ($obj['etazh'] * 1 != 0) {
if ($obj['type'] == 3) {
$contentInfo .= '<span>';
if ($obj['etazh_iz'] * 1 != 0) {
$contentInfo .= $obj['etazh_iz'] . "";
}
$contentInfo .= '</span>';
} else {
$etaz = $obj['etazh'] . ' ';
if ((int)$obj['etazh'] == 1 && !empty($obj['etaz_first_type'])) {
$etaz = $etaz_first_types[$obj['etaz_first_type']];
}
$contentInfo .= '' . $etaz;
if ($obj['etazh_iz'] * 1 != 0) {
$contentInfo .= "/" . $obj['etazh_iz'];
}
$contentInfo .= '</span>';
}
}
}
$contentInfo .= '</div>';
if ($obj['dom']) {$contentInfo .= ", " . $obj['dom'];}
if ($obj['korpus']) {$contentInfo .= ", корпус " . $obj['korpus'];} if ($obj['litera']) {$contentInfo .= ", литера " . $obj['litera'];}
$contentInfo .= ' </span></div>
</div>';
$contentInfo .='<div class="place">
<div class="subway">';
$mtr = array();
$sql = "SELECT metro.metro FROM metro, sp_metro WHERE sp_metro.id_metro = metro.id AND sp_metro.id_obj = $obj[id]";
$result = mysql_query($sql);
while($m = mysql_fetch_row($result)) {
$mtr[] = $m[0];
}
if (count($mtr) > 0) {
$contentInfo .= '<div class="subway-station">
<span class="subway-logo"></span>
<span>';
$contentInfo .= $mtr[0];
$contentInfo .= '</span>';
if($obj['peshkom'] || $obj['transport']) {
if($obj['peshkom']) {
$contentInfo .= ' &#128694;<span> ' . $obj['peshkom']." минут" . '</span>';
}
if($obj['transport']) {
$contentInfo .= ' &#128652;<span> ' . $obj['transport']." минут" . '</span>';
}
}
$contentInfo .= ' </div>';
if (count($mtr) > 1) {
$k = 0;
foreach ($mtr as $metro_res) {
if ($k == 0) {
$k++;
} else {
$contentInfo .= '<div class="subway-station">
<span class="subway-logo"></span><span> '.$metro_res.'</span>
</div>';
}
}
}
}else{
if ($obj['rayon']) {
$contentInfo .= '<span>' . str_replace([' район', 'район', ' р-н', 'р-н'], '', $obj['rayon']) . ' район</span>';
}
}
$contentInfo .= '</div>';
$contentInfo .= '<div class="address">';
$contentInfo .= str_replace(array('"', '\''), '', $obj['adres']);
$contentInfo .= '</div>';
$contentInfo .= '<div style="width:100%">';
$contentInfo .= '<div style="width:60%;float:left;">';
$contentInfo .= '<div class="phone">';
// $contentInfo .= str_replace(array('"', '\''), '', $obj['phone']);
$contentInfo .= str_replace(array('"', '\''), '', $obj['phone']);
$contentInfo .= '</div>';
$contentInfo .= '<div class="name">';
//if ($user != null) { $contentInfo .= $user->fio; } else { $contentInfo .= $obj['sobstv']; }
if(!empty($obj['sobstv'])){
$contentInfo .= '<div class=""><a title="'.str_replace(array('"', '\''), '', $obj['sobstv']).'" class="neweditClient" href="javascript:{}">';
if( strlen($obj['sobstv']) > 25 ) {
$contentInfo .= substr(str_replace(array('"', '\''), '', $obj['sobstv']), 0, 25).'...';
}else{
$contentInfo .= str_replace(array('"', '\''), '', $obj['sobstv']);
}
$contentInfo .= '</a></div>';
}
$contentInfo .= '</div>';
$contentInfo .= '<div class="date" style="padding: 10px 0;" >';
$contentInfo .= $date_add;
$contentInfo .= '</div>';
$contentInfo .= '</div>';
if ($obj['ads_url'] && $obj['ads_source'] && !$obj['archive']) {
$contentInfo .= '<div style="width:40%;float:left;text-align:right:">';
$sourceLink = $obj['ads_url'];
$sourceName = "";
if ($obj['ads_source'] == 3){
$sourceName = "Яндекс";
$img = "<img width='20px;' src='/images/logo/yandex.jpg' alt='img'> ";
}
if ($obj['ads_source'] == 1){
$sourceName = "Авито";
$img = "<img width='20px;' src='/images/logo/avito.png' alt='img'> ";
}
if ($obj['ads_source'] == 4){
$sourceName = "Циан";
$img = "<img width='20px;' src='/images/logo/cian.png' alt='img'> ";
}
if ($obj['ads_source'] == 6){
$sourceName = "Юла";
$img = "<img width='20px;' src='/images/logo/jila.png' alt='img'> ";
}
if ($obj['ads_source'] == 5){
$sourceName = "SOB.RU";
$img = "<img width='20px;' src='/images/logo/sob.jpg' alt='img'> ";
}
//if ($obj['ads_source'] == 7){
//$sourceName = "N1.RU";
//$img = "<img width='20px;' src='/images/logo/n1.jpg' alt='img'> ";
//}
if ($obj['ads_source'] == 11){
$sourceName = "Домклик";
$img = "<img width='20px;' src='/images/logo/domcl.jpg' alt='img'> ";
}
if ($sourceLink && $sourceName) {
$contentInfo .= '<div class="title">';
$contentInfo .= $img . '<a href="javascript:{}" onclick="window.open(\'' . $sourceLink . '\', \'_blank\')">' . $sourceName . '</a>';
$contentInfo .= '</div>';
}
$contentInfo .= '</div>';
$contentInfo .= '</div>';
$contentInfo .= '<div class="clear"></div>';
} else {
$contentInfo .= '</div>';
$contentInfo .= '<div class="clear"></div>';
}
$contentInfo .= '</div>';
$contentInfo .= '</div></div></div></div>';
echo mb_convert_encoding($contentInfo, "UTF-8", "auto");
exit;
}