Joywork/ajax/getFindObjects.php

786 lines
26 KiB
PHP
Raw Permalink Normal View History

2026-05-22 20:21:54 +02:00
<?php
$start = microtime(true);
require_once($_SERVER['DOCUMENT_ROOT'] . "/config.php");
if (!$_SESSION['id']) {
die("Доступ запрещён!");
}
$db_sphinx = new MysqlPdo(hstsph2, null, null, null, true, '9306');
$currentUserId = $_SESSION['id'];
$user_view = new User;
$user_view->get($currentUserId);
$get = clearInputData($_GET);
$post = clearInputData($_POST);
$gmtmsk = get_time_zone_user();
$time_zone = '';
if($gmtmsk >= 0){
$time_zone = '+'.$gmtmsk.' hour';
} else {
$time_zone = '-'.$gmtmsk.' hour';
}
if (!isset($user_view->agencyId)) {
$user_view->agencyId = $currentUserId;
$user_view->agencyName = $user_view->agency_name;
}
$user = $user_view;
$usersArr = array();
$s_1 = '';
if ($post['filter_employee']) {
$empWho = array();
$empArr = json_decode(html_entity_decode($post['filter_employee']), ENT_QUOTES);
foreach($empArr as $empId) {
if (strpos($empId, "all_") !== false) {
$agencyId = str_replace('all_', '', $empId);
$sql_u = "SELECT id FROM `users`
WHERE id = $agencyId OR
id_manager = $agencyId OR
id_manager IN (SELECT id FROM users WHERE id_manager = $agencyId)";
$q_u = mysql_query($sql_u);
while($r_u = mysql_fetch_row($q_u)){
$empWho[] = $r_u[0];
}
} else if(strpos($empId, "I_") !== false){
$empWho[] = str_replace('I_', '', $empId);
} else {
$empWho[] = $empId;
}
}
if (!empty($empWho))
$s_1 .= " AND id_add_user IN (" . implode(", ", $empWho) . ")";
}
$s_2 = '';
if (isset($post['filter_type'])) {
$filter_type = json_decode(html_entity_decode($post['filter_type']), ENT_QUOTES);
$ob_types = [];
foreach($filter_type as $type) {
if ($indx = array_search($type, $OBJECT_TYPES)) {
$ob_types[] = $indx;
}
}
if (!empty($ob_types))
$s_2 .= " AND type IN (" . implode(',', $ob_types) . ")";
}
$param5 = (int) $_POST['param5'];
$s_3 = '';
if ($param5 > 0) {
$param5 += pow(2, 10);
if ($param5 & (pow(2, 0))) {
$s_3 .= ' add_to_avito_feed=1 OR ';
}
if ($param5 & (pow(2, 1))) {
$s_3 .= ' add_to_cian_feed=1 OR ';
}
if ($param5 & (pow(2, 2))) {
$s_3 .= ' add_to_domclick_feed=1 OR ';
}
if ($param5 & (pow(2, 3))) {
$s_3 .= ' add_to_emls_feed=1 OR ';
}
if ($param5 & (pow(2, 4))) {
$s_3 .= ' add_to_bn_feed=1 OR ';
}
}
if ($s_3 !== '') {
$s_3 = substr($s_3, 0, strlen($s_3) - 3);
$s_3 = " AND ($s_3) ";
}
$param3 = (int) $_POST['param3'];
$s_4 = '';
if ($param3 > 0) {
$s_4 .= ' AND add_to_zipal=1 ';
}
$param4 = (int) $_POST['param4'];
$s_5 = '';
if ($param4 > 0) {
$s_5 .= ' AND add_to_yandex_feed=1 ';
}
$param7 = (int) $_POST['param7'];
$s_7 = '';
if ($param7 > 0) {
$arr_pac = array();
$sql_pac = "select object_id from advertising_package_object_publish where active = 1";
$q_pac = mysql_query($sql_pac);
while($r_pac = mysql_fetch_row($q_pac)){
$arr_pac[] = $r_pac[0];
}
if(!empty($arr_pac)){
$s_7 .= ' AND id in ('.implode(',',$arr_pac).') ';
} else {
$s_7 .= ' AND id in (0) ';
}
}
if (((int) $_POST['param6']) && $s_3 === '' && $s_4 === '' && $s_5 === '') {
$arr_pac = array();
$sql_pac = "select object_id from advertising_package_object_publish where active = 1";
$q_pac = mysql_query($sql_pac);
while($r_pac = mysql_fetch_row($q_pac)){
$arr_pac[] = $r_pac[0];
}
$s_3 = ' AND add_to_yandex_feed=0 AND add_to_zipal=0 AND add_to_avito_feed=0 AND add_to_cian_feed=0 AND add_to_domclick_feed=0 AND add_to_emls_feed=0 AND add_to_bn_feed=0 AND id not in ('.implode(',', $arr_pac).') ';
}
$param8 = (int) $_POST['param8'];
$s_10 = '';
$param10 = (string)$_POST['param10'];
if ($param10 == 'sale') {
$s_10 .= ' AND operation_type = 1 ';
$_SESSION['sale'] = 1;
$_SESSION['rent'] = 0;
} else if ($param10 == 'rent') {
$s_10 .= ' AND operation_type = 0 ';
$_SESSION['sale'] = 0;
$_SESSION['rent'] = 1;
} else {
unset($_SESSION['sale']);
unset($_SESSION['rent']);
}
$s_9 = '';
$isArchive = false;
$param9 = (int) $_POST['param9'];
if ($param9 == 1) {
$isArchive = true;
$s_9 .= ' archive = 1 AND use_in_advert = 1 ';
} else {
$s_9 .= ' archive = 0 AND use_in_advert = 1 ';
}
$usl = "";
if (trim($_POST['search']) !== '') {
$search = trim($_POST['search']);
if (preg_match('/^\d+$/', $search)) {
$usl .= " AND id = " . $search;
} else {
$adres_mas = explode(" ", $search);
$strSph = '';
for ($a = 0; $a < count($adres_mas); $a++) {
if (strlen($strSph) > 1) {
$strSph = $strSph . ' ';
}
if ($adres_mas[$a]) {
$strSph = $strSph . '@adres ' . trim(str_replace("/","-",$adres_mas[$a]));
}
}
$usl .= " AND MATCH ('$strSph')";
}
}
if ($_POST['filter_activities']) {
$activitiesArr = json_decode(html_entity_decode($_POST['filter_activities']), ENT_QUOTES);
$a_arr = array();
$sql_a = "SELECT object_id FROM objects_activities WHERE activity_id IN (" . implode(", ", $activitiesArr) . ")";
$q_a = mysql_query($sql_a);
while($r_a = mysql_fetch_row($q_a)){
$a_arr[] = $r_a[0];
}
if(!empty($a_arr)){
$usl .= " AND id IN (" . implode(", ", $a_arr) . ")";
} else {
$usl .= " AND id IN (0)";
}
}
if ($_POST['price_from']) {
$usl .= " AND price_for_order >= " . $_POST['price_from'] . " ";
}
if ($_POST['price_to']) {
$usl .= " AND price_for_order <= " . $_POST['price_to'] . " ";
}
if (isset($_POST['komnat_from']) && $_POST['komnat_from']) {
$usl .= " AND komnat >= " . $_POST['komnat_from'];
}
if (isset($_POST['komnat_to']) && $_POST['komnat_to']) {
$usl .= " AND komnat <= " . $_POST['komnat_to'];
}
// Фильтр доп. полей (для модалки Найти объект при создании Спроса).
// SQL-условия уже построены в /ajax/setReqObjectFieldsFilter.php и лежат в сессии.
if (isset($_SESSION['filter_object_fields_req']['sql']) && is_array($_SESSION['filter_object_fields_req']['sql'])) {
$obj_ids = [];
foreach ($_SESSION['filter_object_fields_req']['sql'] as $sql_where) {
$sql_dop = "SELECT `object_id` FROM `object_data` WHERE $sql_where";
$q_dop = mysql_query($sql_dop);
$result_dop = [];
if ($q_dop) {
while ($r_dop = mysql_fetch_row($q_dop)) {
$result_dop[] = $r_dop[0];
}
}
if (!empty($obj_ids)) {
$obj_ids = array_intersect($obj_ids, $result_dop);
} else {
$obj_ids = $result_dop;
}
}
$obj_ids = array_unique($obj_ids);
if (count($obj_ids)) {
$usl .= ' AND id IN (' . implode(',', $obj_ids) . ') ';
} else {
$usl .= ' AND id < 0 '; // нет совпадений с фильтром доп.полей
}
}
$depClass = new Department();
/*$users_sp = [];
$agentsOfAgency = User::getAllAgents($user_view->agencyId);
foreach ($agentsOfAgency as $agent) {
if (!in_array($agent['id'], $agentIds)) {
$users_sp[] = $agent['id'];
}
}
$sqlUsers = "SELECT id, role_id, department_id FROM `users`
WHERE id = $user_view->agencyId OR
id_manager = $user_view->agencyId OR
id_manager IN (
SELECT id FROM users
WHERE id_manager = $user_view->agencyId
)";
$rezUsers = mysql_query($sqlUsers);
$rowsUsers = mysql_num_rows($rezUsers);
if ($rowsUsers > 0){
while($row = mysql_fetch_assoc($rezUsers)) {
if(!in_array($row['id'], $users_sp)){
$users_sp[] = $row['id'];
}
if((int)$row['role_id'] > 0 && (int)$row['department_id'] > 0){
$role_user = $depClass->getRole((int)$row['role_id']);
if($role_user['role'] == 'admin_department'){
$menagerDep = User::getDepManagers($role_user['department_id']);
foreach($menagerDep as $md){
if(!in_array($md['id'], $users_sp)){
$users_sp[] = $md['id'];
}
$thisAgents = User::getAgentsOfAgency($md['id'], true);
foreach($thisAgents as $da){
if (!in_array($da['id'], $users_sp)) {
$users_sp[] = $da['id'];
}
}
}
}
}
}
}
if(empty($users_sp)) {
$users_sp[] = $user_view->agencyId;
}*/
$agency_id = $user_view->agencyId;
$sql_users = "SELECT id FROM users WHERE id in (select id from users where id=$agency_id or id_manager=$agency_id or id_manager in
(select id from users where id_manager=$agency_id or id_manager in
(select id from users where id_manager=$agency_id)))";
$q_users = mysql_query($sql_users);
$rows_user = mysql_num_rows($q_users);
$users_sp = array();
while($r_user = mysql_fetch_assoc($q_users)){
$users_sp[] = (int)$r_user['id'];
}
$kol_on_page = 10;
$sql_count = "SELECT count(*)
FROM objects
WHERE $s_9 $s_10
$s_1 $s_2 $s_3 $s_4 $s_5 $s_7
AND id_add_user in (" .implode(',', $users_sp).") $usl LIMIT 100000 OPTION max_matches=100000";
$rezVsego = $db_sphinx->query($sql_count, true);
$ids = array();
$vsego = $db_sphinx->result($rezVsego,0);
$sql_count_sale = "SELECT count(*)
FROM objects
WHERE $s_9 AND operation_type = 1
$s_1 $s_2 $s_3 $s_4 $s_5 $s_7
AND id_add_user in (" .implode(',', $users_sp).") $usl LIMIT 100000 OPTION max_matches=100000";
$vsego_sale = $db_sphinx->result($db_sphinx->query($sql_count_sale),0);
$sql_count_rent = "SELECT count(*)
FROM objects
WHERE $s_9 AND operation_type = 0
$s_1 $s_2 $s_3 $s_4 $s_5 $s_7
AND id_add_user in (" .implode(',', $users_sp).") $usl LIMIT 100000 OPTION max_matches=100000";
$vsego_rent = $db_sphinx->result($db_sphinx->query($sql_count_rent),0);
$all_pages = ceil($vsego / $kol_on_page);
if (isset($post['page'])) {
$page = $post['page'];
} else {
$page = 1;
}
$ot = ($page - 1) * $kol_on_page;
//var_dump($vsego);
if($vsego > 0) {
$sqlIds = "SELECT id as obj_id, id_add_user
FROM objects
WHERE $s_9 $s_10 AND use_in_advert = 1
$s_1 $s_2 $s_3 $s_4 $s_5 $s_7
and id_add_user in (" .implode(',', $users_sp).") $usl ORDER BY date_add DESC LIMIT $ot, $kol_on_page";
if($_SESSION['id'] == 5238){
echo $sqlIds;
}
$rez = $db_sphinx->query($sqlIds, true);
$ids = array();
$id_users_add = array();
$users_phone2 = array();
while ($obj = $db_sphinx->fetch_assoc($rez)) {
$ids[] = $obj['obj_id'];
$id_users_add[] = $obj['id_add_user'];
}
$sql_user_add = "SELECT id, phone2 FROM users WHERE id in (".implode(',', $id_users_add).")";
$q_user_add = mysql_query($sql_user_add);
while($r_user_add = mysql_fetch_assoc($q_user_add)){
if(!empty($r_user_add['phone2'])){
$users_phone2[$r_user_add['id']] = $r_user_add['phone2'];
}
}
}
function num_of_pages__2($page, $all_pages) {
if ($page == 1) {
echo "<li class=active><p class='find_obj___a1'>1</p></li>";
} else {
$prev = $page - 1;
echo "<li><p class='find_obj___a1'>1</p></li>";
}
if ($all_pages > 8) {
if ($page > 4) {
$ot = $page - 3;
echo "<li><p class='find_obj___a1'>...</p></li>";
} else {
$ot = 2;
}
if ($page < $all_pages - 4) {
$do = $page + 3;
} else {
$do = $all_pages;
}
} else {
$ot = 2;
$do = $all_pages;
}
for ($i = $ot; $i < $do; $i++) {
if ($i == $page) {
$cl = "active";
} else {
$cl = "";
}
echo "<li class='$cl'><p class='find_obj___a1'>$i</p></li>";
}
if ($all_pages > 8 and $page < $all_pages - 4) {
echo "<li><p class='find_obj___a1'>...</p></li>";
}
if ($page == $all_pages) {
echo "<li class=active><p class='find_obj___a1'>$all_pages</p></li>";
} else {
echo "<li><p class='find_obj___a1'>$all_pages</p></li>";
$nxt = $page + 1;
}
}
if(count($ids) > 0) {
$sql = "SELECT objects.*,
rayon.rayon,
DATE_FORMAT(objects.date_add,'%d.%m.%Y %H:%i') as date_add,
DATE_FORMAT(objects.date_really_add,'%d.%m.%Y %H:%i') as date_really_add,
lu.name as land_usage_name
FROM objects objects
LEFT JOIN rayon rayon on objects.rayon = rayon.id
LEFT JOIN land_usage_type lu on objects.land_usage_type_id = lu.id
WHERE objects.id in (" . implode(", ", $ids) .")
order by objects.date_add desc";
$rez = mysql_query($sql, $mdb);
$arrActivities = [];
$sql_adv = "SELECT * FROM `activities` WHERE `user_id` = '".$user->id."' OR `manager_id` = '".$user->id."'";
if ($user->id_manager)
$sql_adv .= " OR `manager_id` = '".$user->id_manager."' OR `user_id` = '".$user->id_manager."'";
if ($user->agencyId)
$sql_adv .= " OR `manager_id` = '".$user->agencyId."' OR `user_id` = '".$user->agencyId."'";
$sql_adv .= ' ORDER BY `name`';
$q_adv = mysql_query($sql_adv);
$rows_adv = mysql_num_rows($q_adv);
if ($rows_adv > 0) {
while ($r_adv = mysql_fetch_assoc($q_adv)) {
$arrActivities[$r_adv['id']] = $r_adv;
}
}
if (mysql_num_rows($rez)) {
echo '<div class="f-system_pagination" style="margin-top: 30px;"><ul class="pagination">';
if ($all_pages > 1) {
num_of_pages__2($page, $all_pages);
}
echo '</ul>';
echo '<div class="clear"></div>';
echo '</div>';
if ($_POST['view'] == 'table') {
$cl = new Clients();
$usersId = $cl->getUsersFilter($usersArr, $_SESSION['id'], 1);
$arrIdWhoWork = $arrIdAddUsers = $usersIdReal = array();
foreach ($usersId as $usrId) {
$arrIdWhoWork[] = "who_work = $usrId";
$arrIdAddUsers[] = "id_add_user = $usrId";
}
include($_SERVER['DOCUMENT_ROOT']."/templates/system__object_table_header.php");
}
if (isset($_SESSION['notes_bd_usl'])) {
$notes_bd_usl = $_SESSION['notes_bd_usl'];
} else {
$agencyId = User::getAgencyIdForUser($_SESSION['id']);
$usersIds = User::getAllAgencyUsers($agencyId);
$usersIds[] = $_SESSION['id'];
$usersIds = array_unique($usersIds);
$notes_bd_usl = "created_by IN (" . implode(",", $usersIds) . ")";
$_SESSION['notes_bd_usl'] = $notes_bd_usl;
}
$time = microtime(true) - $start;
if($_SESSION['id'] == 5238){
echo $time." сек.";
}
$agency_id = $user->agencyId;
//начитываем ошибки размещения объектов в рекламе
/*$objAdsErrors = [];
$sql_ads = "SELECT `object_id`, `service_id`, `errors` FROM `ads_stats` WHERE `agency_id` = '$agency_id' AND `object_id` IN (" . implode(", ", $ids) .") AND `errors` IS NOT NULL";
$rezAdsErrors = mysql_query($sql_ads);
if (mysql_num_rows($rezAdsErrors) > 0) {
while ($objAdsInfo = mysql_fetch_assoc($rezAdsErrors)) {
$object_id = $objAdsInfo['object_id'];
$service_id = $objAdsInfo['service_id'];
$objAdsErrors[$object_id][$service_id] = json_decode($objAdsInfo['errors']);
}
}*/
//начитка тегов списком
$rezActivityArray = [];
$sqlAddInfo = "SELECT object_id, activity_id FROM objects_activities WHERE object_id in (" . implode(", ", $ids) .")";
$rezAddInfo = mysql_query($sqlAddInfo);
if (mysql_num_rows($rezAddInfo) > 0) {
while ($objActivity = mysql_fetch_assoc($rezAddInfo)) {
if (!isset($rezActivityArray[$objActivity["object_id"]])) {
$rezActivityArray[$objActivity["object_id"]] = [];
}
$rezActivityArray[$objActivity["object_id"]][] = $objActivity["activity_id"];
}
}
//начитка фото списком
$rezPhotoArray = [];
$sqlPhotoInfo = "SELECT oop.sort_order, oop.object_id, p.photo
FROM objects_object_photo oop, object_photo p
WHERE p.id = oop.object_photo_id AND oop.object_id in (" . implode(", ", $ids) .")
ORDER BY oop.sort_order";
$rezPhotoInfo = mysql_query($sqlPhotoInfo);
if (mysql_num_rows($rezPhotoInfo) > 0) {
while ($objPhoto = mysql_fetch_assoc($rezPhotoInfo)) {
if (!isset($rezPhotoArray[$objPhoto["object_id"]])) {
$rezPhotoArray[$objPhoto["object_id"]] = [];
}
$rezPhotoArray[$objPhoto["object_id"]]['photo' . $objPhoto['sort_order']] = $objPhoto["photo"];
}
}
//начитываем данные воронки для объектов
$objReqFunnelArray = [];
$sqlReqFunnel = "SELECT id, funnel_id, stage, object_id FROM requisitions WHERE object_id in (" . implode(", ", $ids) .") AND type_id = 2 AND deleted = 0 AND cancel = 0";
$qReqFunnel = mysql_query($sqlReqFunnel);
if(mysql_num_rows($qReqFunnel) > 0){
while ($objReqFunnel = mysql_fetch_assoc($qReqFunnel)) {
$objReqFunnelArray[] = $objReqFunnel;
}
}
//начитываем кол-во заявок для объектов
/* $objRequisitionsArray = [];
$sqlRequisitions = "SELECT count(id) as cnt, object_id FROM requisitions WHERE type_id = 4 AND cancel = 0 AND object_id in (" . implode(", ", $ids) .") GROUP BY object_id";
$qRequisitions = mysql_query($sqlRequisitions);
if(mysql_num_rows($qRequisitions) > 0){
while ($objRequisitions = mysql_fetch_assoc($qRequisitions)) {
$objRequisitionsArray[] = $objRequisitions;
}
}*/
/* $objPriceHistoryArray = [];
$sqlPriceHistory="SELECT date_change_price, price, price_ku FROM objects_price_history WHERE object_id in (" . implode(", ", $ids) .")";
$rezPriceHistory=mysql_query($sqlPriceHistory);
if(mysql_num_rows($rezPriceHistory)>0){
}*/
//начитываем клиентов списком
$objClientsArray = [];
$objClientsLike = [];
$sql_cl_obj = "SELECT client_id FROM client_objects WHERE object_id in (".implode(',', $ids).")";
$q_cl_obj = mysql_query($sql_cl_obj);
while($r_cl_obj = mysql_fetch_assoc($q_cl_obj)){
$objClientsLike[] = $r_cl_obj['client_id'];
}
$sqlClients = "SELECT `id`, `fio`, `email`, `phone`, `objects` FROM `clients` WHERE id in (" . implode(", ", $objClientsLike) . ")";
$qClient = mysql_query($sqlClients);
if (mysql_num_rows($qClient) > 0) {
while ($objCl = mysql_fetch_assoc($qClient)) {
mask_client_contacts_inplace($objCl);
$objClientsArray[] = $objCl;
}
}
//начитываем координаты списком
$objCoordinatesArray = [];
$sqlCoordinates = "SELECT address, object_id, latitude, longitude FROM object_location WHERE object_id in (" . implode(", ", $ids) .")";
$rezCoordinatesAll = mysql_query($sqlCoordinates);
if (mysql_num_rows($rezCoordinatesAll) > 0) {
while ($objCoords = mysql_fetch_assoc($rezCoordinatesAll)) {
$objCoordinatesArray[] = $objCoords;
}
}
//начитываем цены
$objPricesArray = [];
$sqlPrices = "SELECT * FROM `object_prices`
WHERE `object_id` in (" . implode(", ", $ids) .") AND `agency_id`='$agency_id'";
if ($queryPrices = mysql_query($sqlPrices)) {
if (mysql_num_rows($queryPrices) > 0) {
while ($objPrice = mysql_fetch_assoc($queryPrices)) {
$objPricesArray[] = $objPrice;
}
}
}
$objectsFound = [];
while ($obj = mysql_fetch_assoc($rez)) {
if (isset($rezActivityArray[$obj["id"]])) {
$obj['activities'] = $rezActivityArray[$obj["id"]];
} else {
$obj['activities'] = null;
}
if ($objPricesArray) {
foreach ($objPricesArray as $objPrice) {
if ($objPrice["object_id"] == $obj["id"]) {
if (!is_null($objPrice['prep_price'])) {
$obj['prep_price'] = $objPrice['prep_price'];
}
if (!is_null($objPrice['start_price'])) {
$obj['start_price'] = $objPrice['start_price'];
}
if (!is_null($objPrice['fact_price'])) {
$obj['fact_price'] = $objPrice['fact_price'];
}
break;
}
}
}
$sqlAddInfo = "SELECT activity_id FROM objects_activities WHERE object_id=$obj[id]";
$rezAddInfo = mysql_query($sqlAddInfo);
if (mysql_num_rows($rezAddInfo) > 0) {
$obj['activities'] = array();
while($row = mysql_fetch_array($rezAddInfo)) {
$obj['activities'][] = $row['activity_id'];
}
} else {
$obj['activities'] = null;
}
if ($_POST['view'] == 'table') {
if (!isset($clientObjIdsSql)) {
$clientObjIdsSql = [];
}
$sql_cl_obj = "SELECT client_id FROM client_objects WHERE object_id = {$obj['id']}";
$q_cl_obj = mysql_query($sql_cl_obj);
while($r_cl_obj = mysql_fetch_assoc($q_cl_obj)){
$clientObjIdsSql[] = $r_cl_obj['client_id'];
};
$objectsFound[] = $obj;
} else {
if (isset($rezPhotoArray[$obj["id"]])) {
foreach ($rezPhotoArray[$obj["id"]] as $key => $photo) {
$obj[$key] = $photo;
}
}
$use_advert_budget = ($_SESSION['use_advert_budget']);
include($_SERVER['DOCUMENT_ROOT'] . "/templates/system_object_can.php");
}
$time3 = microtime(true) - $start;
if($_SESSION['id'] == 5238){
echo $time3." сек.";
}
}
if (isset($objectsFound) && !empty($objectsFound) && isset($clientObjIdsSql) && !empty($clientObjIdsSql)) {
$clientData = [];
$clientCountData = [];
$sql_clients = "SELECT `id`, `fio`, `email`, `phone`, `objects` FROM `clients` WHERE id in (".implode(',', $clientObjIdsSql).")";
$q_client = mysql_query($sql_clients);
if (mysql_num_rows($q_client) > 0) {
while ($client = mysql_fetch_array($q_client)) {
$objIdsTmp = $client['objects'];
$objIdsTmp = preg_replace("/[^,0-9]/", '', $objIdsTmp);
if (!empty($objIdsTmp)) {
$objIdsTmp = explode(',', $objIdsTmp);
$clientItemBase = array(
'fio' => $client['fio'],
'phone' => $client['phone'],
'id' => $client['id'],
);
mask_client_contacts_inplace($clientItemBase);
foreach ($objIdsTmp as $objIdTmp) {
if (!isset($clientData[$objIdTmp])) {
$clientData[$objIdTmp] = [];
}
$clientData[$objIdTmp][] = $clientItemBase;
}
}
}
}
if ($_COOKIE['debug_spd']) { echo '<script>console.log(`ajax/getObjectsView.php:1398 '.microtime(true).'`)</script>'; }
foreach ($objectsFound as $obj) {
include($_SERVER['DOCUMENT_ROOT'] . "/templates/system__object_table.php");
}
}
$time2 = microtime(true) - $start;
if($_SESSION['id'] == 5238){
echo $time2." сек.";
}
if ($_POST['view'] == 'table') {
include($_SERVER['DOCUMENT_ROOT']."/templates/system__object_table_find_footer.php");
}
echo '<div class="f-system_pagination"><ul class="pagination">';
if ($all_pages > 1) {
num_of_pages__2($page, $all_pages);
}
echo '</ul>';
echo '<div class="clear"></div></div>';
}
} else {
?>
<div class="empty-block">
<h1><i class="ti-na"></i></h1>
<h2>Объектов не найдено</h2>
</div>
<?php } ?>
<div class="clear"></div>
<script>
let sale_count = parseInt('<?= $vsego_sale; ?>');
if (sale_count !== 0 && !isNaN(sale_count)) {
$('.filter-popup-type[data-id="sale"] .filter_counter').text(sale_count);
$('.filter-popup-type[data-id="sale"] .filter_counter').show();
} else {
$('.filter-popup-type[data-id="sale"] .filter_counter').text('0');
$('.filter-popup-type[data-id="sale"] .filter_counter').hide();
}
let rent_count = parseInt('<?= $vsego_rent; ?>');
if (rent_count !== 0 && !isNaN(rent_count)) {
$('.filter-popup-type[data-id="rent"] .filter_counter').text(rent_count);
$('.filter-popup-type[data-id="rent"] .filter_counter').show();
} else {
$('.filter-popup-type[data-id="rent"] .filter_counter').text('0');
$('.filter-popup-type[data-id="rent"] .filter_counter').hide();
}
$('.object-content__preloader').hide();
</script>